mips_cache_gcc.S 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2006-2019, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2016-09-19 Urey first version
  9. */
  10. #ifndef __ASSEMBLY__
  11. #define __ASSEMBLY__
  12. #endif
  13. #include "../common/mips.h"
  14. .text
  15. .set noreorder
  16. .globl cache_init
  17. .ent cache_init
  18. cache_init:
  19. .set noreorder
  20. mtc0 zero, CP0_TAGLO
  21. move t0, a0 // cache total size
  22. move t1, a1 // cache line size
  23. li t2, 0x80000000
  24. addu t3, t0, t2
  25. _cache_init_loop:
  26. cache 8, 0(t2) // icache_index_store_tag
  27. cache 9, 0(t2) // dcache_index_store_tag
  28. addu t2, t1
  29. bne t2, t3, _cache_init_loop
  30. nop
  31. mfc0 t0, CP0_CONFIG
  32. li t1, 0x7
  33. not t1
  34. and t0, t0, t1
  35. or t0, 0x3 // cacheable, noncoherent, write-back, write allocate
  36. mtc0 t0, CP0_CONFIG
  37. jr ra
  38. nop
  39. .set reorder
  40. .end cache_init