crtat91_ram.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Copyright (C) 2005 by egnite Software GmbH. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. *
  32. */
  33. /*
  34. * $Log$
  35. * Revision 1.3 2009/01/16 19:45:42 haraldkipp
  36. * All ARM code is now running in system mode.
  37. *
  38. * Revision 1.2 2006/10/05 17:12:35 haraldkipp
  39. * Bug #1497065 fixed. Stack sizes increased.
  40. *
  41. * Revision 1.1 2005/10/24 11:30:48 haraldkipp
  42. * Initial check in.
  43. *
  44. */
  45. #include <arch/arm.h>
  46. IRQ_STACK_SIZE = (128*4)
  47. FIQ_STACK_SIZE = (64*4)
  48. ABT_STACK_SIZE = (16*4)
  49. UND_STACK_SIZE = (16*4)
  50. SVC_STACK_SIZE = (256*4)
  51. /*
  52. * Section 0: Vector table and reset entry.
  53. */
  54. .section .init0,"ax",%progbits
  55. .global __vectors
  56. __vectors:
  57. ldr pc, [pc, #24] /* Reset */
  58. ldr pc, [pc, #24] /* Undefined instruction */
  59. ldr pc, [pc, #24] /* Software interrupt */
  60. ldr pc, [pc, #24] /* Prefetch abort */
  61. ldr pc, [pc, #24] /* Data abort */
  62. ldr pc, [pc, #24] /* Reserved */
  63. /*
  64. * On IRQ the PC will be loaded from AIC_IVR, which
  65. * provides the address previously set in AIC_SVR.
  66. * The interrupt routine will be called in ARM_MODE_IRQ
  67. * with IRQ disabled and FIQ unchanged.
  68. */
  69. ldr pc, [pc, #-0xF20] /* Interrupt request, auto vectoring. */
  70. ldr pc, [pc, #-0xF20] /* Fast interrupt request, auto vectoring. */
  71. .word _start
  72. .word __undef
  73. .word __swi
  74. .word __prefetch_abort
  75. .word __data_abort
  76. .weak __undef
  77. .set __undef, __xcpt_dummy
  78. .weak __swi
  79. .set __swi, __xcpt_dummy
  80. .weak __prefetch_abort
  81. .set __prefetch_abort, __xcpt_dummy
  82. .weak __data_abort
  83. .set __data_abort, __xcpt_dummy
  84. .global __xcpt_dummy
  85. __xcpt_dummy:
  86. b __xcpt_dummy
  87. .ltorg
  88. .globl _start
  89. _start:
  90. /*
  91. * Section 1: Hardware initialization.
  92. */
  93. .section .init1,"ax",%progbits
  94. /*
  95. * Enable all clocks.
  96. */
  97. mvn r0, #0
  98. ldr r1, =PS_BASE
  99. str r0, [r1, #0x04]
  100. b __set_stacks
  101. .ltorg
  102. .global __set_stacks
  103. __set_stacks:
  104. /*
  105. * Section 2: Set stack pointers.
  106. */
  107. .section .init2,"ax",%progbits
  108. /*
  109. * Set exception stack pointers and enable interrupts.
  110. */
  111. ldr r0, =__xcp_stack
  112. msr CPSR_c, #ARM_MODE_FIQ | ARM_CPSR_I_BIT | ARM_CPSR_F_BIT
  113. mov r13, r0
  114. sub r0, r0, #FIQ_STACK_SIZE
  115. msr CPSR_c, #ARM_MODE_IRQ | ARM_CPSR_I_BIT | ARM_CPSR_F_BIT
  116. mov r13, r0
  117. sub r0, r0, #IRQ_STACK_SIZE
  118. msr CPSR_c, #ARM_MODE_ABORT | ARM_CPSR_I_BIT | ARM_CPSR_F_BIT
  119. mov r13, r0
  120. sub r0, r0, #ABT_STACK_SIZE
  121. msr CPSR_c, #ARM_MODE_UNDEF | ARM_CPSR_I_BIT | ARM_CPSR_F_BIT
  122. mov r13, r0
  123. sub r0, r0, #UND_STACK_SIZE
  124. msr CPSR_c, #ARM_MODE_SVC | ARM_CPSR_I_BIT | ARM_CPSR_F_BIT
  125. mov r13, r0
  126. b __enter_mode
  127. .rept 256
  128. .long 0
  129. .endr
  130. .global __xcp_stack
  131. __xcp_stack:
  132. .ltorg
  133. .global __enter_mode
  134. .align
  135. __enter_mode:
  136. /*
  137. * Section 3: Enter system mode.
  138. */
  139. .section .init3,"ax",%progbits
  140. msr CPSR_c, #ARM_MODE_SYS | ARM_CPSR_I_BIT | ARM_CPSR_F_BIT
  141. b __clear_bss
  142. .ltorg
  143. .global __clear_bss
  144. __clear_bss:
  145. /*
  146. * Section 4: Clear bss.
  147. */
  148. .section .init4,"ax",%progbits
  149. ldr r1, =__bss_start
  150. ldr r2, =__bss_end
  151. ldr r3, =0
  152. _40:
  153. cmp r1, r2
  154. strne r3, [r1], #+4
  155. bne _40
  156. /*
  157. * Initialize user stack pointer.
  158. */
  159. ldr r13, =__stack
  160. b __call_rtos
  161. .ltorg
  162. .global __call_rtos
  163. __call_rtos:
  164. /*
  165. * Section 5: Call RTOS
  166. */
  167. .section .init5,"ax",%progbits
  168. /*
  169. * Jump to Nut/OS initialization.
  170. */
  171. ldr r0, =NutInit
  172. bx r0
  173. End:
  174. b End
  175. .ltorg