start_gcc.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * File : start_gcc.S
  3. * Change Logs:
  4. * Date Author Notes
  5. * 2010-05-17 swkyer first version
  6. * 2010-09-04 bernard porting to Jz47xx
  7. */
  8. #include "../common/mips.inc"
  9. #include "../common/stackframe.h"
  10. #include "soc3210.h"
  11. .section ".start", "ax"
  12. .set noreorder
  13. /* the program entry */
  14. .globl _start
  15. _start:
  16. .set noreorder
  17. la ra, _start
  18. /* disable interrupt */
  19. mfc0 t0, CP0_STATUS
  20. and t0, 0xfffffffe # By default it will be disabled.
  21. mtc0 t0, CP0_STATUS # Set CPU to disable interrupt.
  22. nop
  23. /* disable cache */
  24. mfc0 t0, CP0_CONFIG
  25. and t0, 0xfffffff8
  26. or t0, 0x2 # disable,!default value is not it!
  27. mtc0 t0, CP0_CONFIG # Set CPU to disable cache.
  28. nop
  29. /* setup stack pointer */
  30. li sp, SYSTEM_STACK
  31. la gp, _gp
  32. /* copy IRAM section */
  33. la t0, _iramcopy
  34. la t1, _iramstart
  35. la t2, _iramend
  36. _iram_loop:
  37. lw t3, 0(t0)
  38. sw t3, 0(t1)
  39. addiu t1, 4
  40. bne t1, t2, _iram_loop
  41. addiu t0, 4
  42. /* clear bss */
  43. la t0, __bss_start
  44. la t1, __bss_end
  45. _clr_bss_loop:
  46. sw zero, 0(t0)
  47. bne t0, t1, _clr_bss_loop
  48. addiu t0, t0, 4
  49. /* jump to RT-Thread RTOS */
  50. jal rtthread_startup
  51. nop
  52. /* restart, never die */
  53. j _start
  54. nop
  55. .set reorder
  56. .globl cp0_get_cause
  57. cp0_get_cause:
  58. mfc0 v0, CP0_CAUSE
  59. jr ra
  60. nop
  61. .globl cp0_get_status
  62. cp0_get_status:
  63. mfc0 v0, CP0_STATUS
  64. jr ra
  65. nop
  66. .globl cp0_get_hi
  67. cp0_get_hi:
  68. mfhi v0
  69. jr ra
  70. nop
  71. .globl cp0_get_lo
  72. cp0_get_lo:
  73. mflo v0
  74. jr ra
  75. nop
  76. .extern tlb_refill_handler
  77. .extern cache_error_handler
  78. /* Exception Handler */
  79. /* 0x0 - TLB refill handler */
  80. .section .vectors.1, "ax", %progbits
  81. j tlb_refill_handler
  82. nop
  83. /* 0x100 - Cache error handler */
  84. .section .vectors.2, "ax", %progbits
  85. j cache_error_handler
  86. nop
  87. /* 0x180 - Exception/Interrupt handler */
  88. .section .vectors.3, "ax", %progbits
  89. j _general_exception_handler
  90. nop
  91. /* 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) */
  92. .section .vectors.4, "ax", %progbits
  93. j _irq_handler
  94. nop
  95. .section .vectors, "ax", %progbits
  96. .extern mips_irq_handle
  97. /* general exception handler */
  98. _general_exception_handler:
  99. .set noreorder
  100. la k0, mips_irq_handle
  101. jr k0
  102. nop
  103. .set reorder
  104. /* interrupt handler */
  105. _irq_handler:
  106. .set noreorder
  107. la k0, mips_irq_handle
  108. jr k0
  109. nop
  110. .set reorder