start_gcc.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * File : start_gcc.S
  3. * Change Logs:
  4. * Date Author Notes
  5. * 2010-05-17 swkyer first version
  6. */
  7. #include "../common/mips.inc"
  8. #include "../common/stackframe.h"
  9. #include "jz47xx.h"
  10. .section ".start", "ax"
  11. .set noreorder
  12. .extern sys_exception_handlers
  13. .extern tlbmiss_handle
  14. .globl _entry
  15. /* exception entry */
  16. _entry:
  17. .org 0x0
  18. .set noreorder
  19. mfc0 t0, $14
  20. jal tlbmiss_handle
  21. move a0, t0
  22. j _sys_dead /* TLB Miss, should never happen */
  23. nop
  24. .set reorder
  25. /*
  26. * void config_tick_timer(uint32_t perio)
  27. */
  28. .globl config_tick_timer
  29. config_tick_timer:
  30. mfc0 t0, $9 /* count */
  31. nop
  32. addu t1, t0, a0
  33. mtc0 t1, $11 /* compare */
  34. jr ra
  35. nop
  36. .globl cp0_get_cause
  37. cp0_get_cause:
  38. mfc0 v0, CP0_CAUSE
  39. jr ra
  40. nop
  41. .globl cp0_get_status
  42. cp0_get_status:
  43. mfc0 v0, CP0_STATUS
  44. jr ra
  45. nop
  46. .globl cp0_get_hi
  47. cp0_get_hi:
  48. mfhi v0
  49. jr ra
  50. nop
  51. .globl cp0_get_lo
  52. cp0_get_lo:
  53. mflo v0
  54. jr ra
  55. nop
  56. .org 0x100
  57. .set noreorder
  58. j _sys_dead /* cache error exception handle */
  59. nop
  60. .set reorder
  61. .globl disable_cp0_counter
  62. disable_cp0_counter:
  63. .set noreorder
  64. mfc0 t0, CP0_CAUSE
  65. lui t1, 0x0800
  66. or t0, t1
  67. mtc0 t0, CP0_CAUSE
  68. jr ra
  69. nop
  70. .set reorder
  71. .globl enable_cp0_counter
  72. enable_cp0_counter:
  73. .set noreorder
  74. mfc0 t0, CP0_CAUSE
  75. lui t1, 0x0800
  76. not t2, t1
  77. and t0, t0, t2
  78. mtc0 t0, CP0_CAUSE
  79. jr ra
  80. nop
  81. .set reorder
  82. // general exception handle
  83. .org 0x180
  84. _gen_exp_handle:
  85. .set noreorder
  86. mfc0 k1, CP0_CAUSE
  87. andi k1, k1, 0x7c
  88. srl k1, k1, 2
  89. lw k0, sys_exception_handlers(k1)
  90. jr k0
  91. nop
  92. .set reorder
  93. /* error happens */
  94. _sys_dead:
  95. .set noreorder
  96. jal rt_hw_cpu_reset
  97. nop
  98. /* should never return here */
  99. j _sys_dead
  100. nop
  101. .set reorder
  102. .globl mips_irq_handle
  103. /* interrupt handle */
  104. .org 0x200
  105. _irq_handle:
  106. .set noreorder
  107. la k0, mips_irq_handle
  108. jr k0
  109. nop
  110. .set reorder
  111. /* the REAL program entry */
  112. .extern mips32_cfg_init
  113. .extern r4k_cache_init
  114. .extern install_default_execpt_handle
  115. .globl _start
  116. .org 0x400
  117. _start:
  118. .set noreorder
  119. la ra, _start
  120. /* init cp0 registers. */
  121. li t0, 0x0040FC00
  122. mtc0 t0, CP0_STATUS
  123. li t1, 0x00800000
  124. mtc0 t1, CP0_CAUSE
  125. /* setup stack pointer */
  126. li sp, SYSTEM_STACK
  127. la gp, _gp
  128. /* clear bss */
  129. la t0, __bss_start
  130. la t1, __bss_end
  131. _clr_bss_loop:
  132. sw zero, 0(t0)
  133. bne t0, t1, _clr_bss_loop
  134. addiu t0, t0, 4
  135. /* read core config */
  136. jal mips32_cfg_init
  137. nop
  138. /* initialize cache */
  139. jal r4k_cache_init
  140. nop
  141. /* setup default exception handle */
  142. jal install_default_execpt_handle
  143. nop
  144. /* jump to RT-Thread RTOS */
  145. jal rtthread_startup
  146. nop
  147. /* restart, never die */
  148. j _start
  149. nop
  150. .set reorder