cache_gcc.S 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. * 2010-05-17 swkyer first version
  9. * 2019-07-19 Zhou Yanjie clean up code
  10. */
  11. #ifndef __ASSEMBLY__
  12. #define __ASSEMBLY__
  13. #endif
  14. #include "../common/mips_def.h"
  15. #include "../common/mipsregs.h"
  16. #include "../common/stackframe.h"
  17. .text
  18. .set noreorder
  19. .globl cache_init
  20. .ent cache_init
  21. cache_init:
  22. .set noreorder
  23. mtc0 zero, CP0_TAGLO
  24. move t0, a0 // cache total size
  25. move t1, a1 // cache line size
  26. li t2, 0x80000000
  27. addu t3, t0, t2
  28. _cache_init_loop:
  29. cache 8, 0(t2) // icache_index_store_tag
  30. cache 9, 0(t2) // dcache_index_store_tag
  31. addu t2, t1
  32. bne t2, t3, _cache_init_loop
  33. nop
  34. mfc0 t0, CP0_CONFIG
  35. li t1, 0x7
  36. not t1
  37. and t0, t0, t1
  38. or t0, 0x3 // cacheable, noncoherent, write-back, write allocate
  39. mtc0 t0, CP0_CONFIG
  40. jr ra
  41. nop
  42. .set reorder
  43. .end cache_init