start_gcc.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. #if 0
  33. /* copy IRAM section */
  34. la t0, _iramcopy
  35. la t1, _iramstart
  36. la t2, _iramend
  37. _iram_loop:
  38. lw t3, 0(t0)
  39. sw t3, 0(t1)
  40. addiu t1, 4
  41. bne t1, t2, _iram_loop
  42. addiu t0, 4
  43. #endif
  44. /* clear bss */
  45. la t0, __bss_start
  46. la t1, __bss_end
  47. _clr_bss_loop:
  48. sw zero, 0(t0)
  49. bne t0, t1, _clr_bss_loop
  50. addiu t0, t0, 4
  51. /* jump to RT-Thread RTOS */
  52. jal rtthread_startup
  53. nop
  54. /* restart, never die */
  55. j _start
  56. nop
  57. .set reorder
  58. .globl cp0_get_cause
  59. cp0_get_cause:
  60. mfc0 v0, CP0_CAUSE
  61. jr ra
  62. nop
  63. .globl cp0_get_status
  64. cp0_get_status:
  65. mfc0 v0, CP0_STATUS
  66. jr ra
  67. nop
  68. .globl cp0_get_hi
  69. cp0_get_hi:
  70. mfhi v0
  71. jr ra
  72. nop
  73. .globl cp0_get_lo
  74. cp0_get_lo:
  75. mflo v0
  76. jr ra
  77. nop
  78. .extern tlb_refill_handler
  79. .extern cache_error_handler
  80. /* Exception Handler */
  81. /* 0x0 - TLB refill handler */
  82. .section .vectors.1, "ax", %progbits
  83. .global tlb_refill_exception
  84. .type tlb_refill_exception,@function
  85. tlb_refill_exception:
  86. j tlb_refill_handler
  87. nop
  88. /* 0x100 - Cache error handler */
  89. .section .vectors.2, "ax", %progbits
  90. j cache_error_handler
  91. nop
  92. /* 0x180 - Exception/Interrupt handler */
  93. .section .vectors.3, "ax", %progbits
  94. .global general_exception
  95. .type general_exception,@function
  96. general_exception:
  97. j _general_exception_handler
  98. nop
  99. /* 0x200 - Special Exception Interrupt handler (when IV is set in CP0_CAUSE) */
  100. .section .vectors.4, "ax", %progbits
  101. .global irq_exception
  102. .type irq_exception,@function
  103. irq_exception:
  104. j _irq_handler
  105. nop
  106. .section .vectors, "ax", %progbits
  107. .extern mips_irq_handle
  108. /* general exception handler */
  109. _general_exception_handler:
  110. .set noreorder
  111. la k0, mips_irq_handle
  112. jr k0
  113. nop
  114. .set reorder
  115. /* interrupt handler */
  116. _irq_handler:
  117. .set noreorder
  118. la k0, mips_irq_handle
  119. jr k0
  120. nop
  121. .set reorder