start_gcc.S 2.5 KB

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