start_gcc.S 2.8 KB

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