startup_ARMCA7.s 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************************************************************************
  2. * @file startup_ARMCA7.s
  3. * @brief CMSIS Device System Source File for ARM Cortex-A9 Device Series
  4. * @version V1.00
  5. * @date 01 Nov 2017
  6. *
  7. * @note
  8. *
  9. ******************************************************************************/
  10. /*
  11. * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
  12. *
  13. * SPDX-License-Identifier: Apache-2.0
  14. *
  15. * Licensed under the Apache License, Version 2.0 (the License); you may
  16. * not use this file except in compliance with the License.
  17. * You may obtain a copy of the License at
  18. *
  19. * www.apache.org/licenses/LICENSE-2.0
  20. *
  21. * Unless required by applicable law or agreed to in writing, software
  22. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  23. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  24. * See the License for the specific language governing permissions and
  25. * limitations under the License.
  26. */
  27. MODULE ?startup_ARMCA7
  28. /*----------------------------------------------------------------------------
  29. Exception / Interrupt Handler
  30. *----------------------------------------------------------------------------*/
  31. PUBLIC Reset_Handler
  32. PUBWEAK Undef_Handler
  33. PUBWEAK SVC_Handler
  34. PUBWEAK PAbt_Handler
  35. PUBWEAK DAbt_Handler
  36. PUBWEAK IRQ_Handler
  37. PUBWEAK FIQ_Handler
  38. SECTION SVC_STACK:DATA:NOROOT(3)
  39. SECTION IRQ_STACK:DATA:NOROOT(3)
  40. SECTION FIQ_STACK:DATA:NOROOT(3)
  41. SECTION ABT_STACK:DATA:NOROOT(3)
  42. SECTION UND_STACK:DATA:NOROOT(3)
  43. SECTION USR_STACK:DATA:NOROOT(3)
  44. /*----------------------------------------------------------------------------
  45. Exception / Interrupt Vector Table
  46. *----------------------------------------------------------------------------*/
  47. section RESET:CODE:NOROOT(2)
  48. PUBLIC Vectors
  49. Vectors:
  50. LDR PC, =Reset_Handler
  51. LDR PC, =Undef_Handler
  52. LDR PC, =SVC_Handler
  53. LDR PC, =PAbt_Handler
  54. LDR PC, =DAbt_Handler
  55. NOP
  56. LDR PC, =IRQ_Handler
  57. LDR PC, =FIQ_Handler
  58. section .text:CODE:NOROOT(4)
  59. /*----------------------------------------------------------------------------
  60. Reset Handler called on controller reset
  61. *----------------------------------------------------------------------------*/
  62. EXTERN SystemInit
  63. EXTERN __iar_program_start
  64. Reset_Handler:
  65. // Mask interrupts
  66. CPSID if
  67. // Put any cores other than 0 to sleep
  68. MRC p15, 0, R0, c0, c0, 5
  69. ANDS R0, R0, #3
  70. goToSleep:
  71. WFINE
  72. BNE goToSleep
  73. // Reset SCTLR Settings
  74. MRC p15, 0, R0, c1, c0, 0 // Read CP15 System Control register
  75. BIC R0, R0, #(0x1 << 12) // Clear I bit 12 to disable I Cache
  76. BIC R0, R0, #(0x1 << 2) // Clear C bit 2 to disable D Cache
  77. BIC R0, R0, #0x1 // Clear M bit 0 to disable MMU
  78. BIC R0, R0, #(0x1 << 11) // Clear Z bit 11 to disable branch prediction
  79. BIC R0, R0, #(0x1 << 13) // Clear V bit 13 to disable hivecs
  80. MCR p15, 0, R0, c1, c0, 0 // Write value back to CP15 System Control register
  81. ISB
  82. // Configure ACTLR
  83. MRC p15, 0, r0, c1, c0, 1 // Read CP15 Auxiliary Control Register
  84. ORR r0, r0, #(1 << 1) // Enable L2 prefetch hint (UNK/WI since r4p1)
  85. MCR p15, 0, r0, c1, c0, 1 // Write CP15 Auxiliary Control Register
  86. // Set Vector Base Address Register (VBAR) to point to this application's vector table
  87. LDR R0, =Vectors
  88. MCR p15, 0, R0, c12, c0, 0
  89. // Setup Stack for each exception mode
  90. CPS #0x11
  91. LDR SP, =SFE(FIQ_STACK)
  92. CPS #0x12
  93. LDR SP, =SFE(IRQ_STACK)
  94. CPS #0x13
  95. LDR SP, =SFE(SVC_STACK)
  96. CPS #0x17
  97. LDR SP, =SFE(ABT_STACK)
  98. CPS #0x1B
  99. LDR SP, =SFE(UND_STACK)
  100. CPS #0x1F
  101. LDR SP, =SFE(USR_STACK)
  102. // Call SystemInit
  103. BL SystemInit
  104. // Unmask interrupts
  105. CPSIE if
  106. // Call __iar_program_start
  107. BL __iar_program_start
  108. /*----------------------------------------------------------------------------
  109. Default Handler for Exceptions / Interrupts
  110. *----------------------------------------------------------------------------*/
  111. Undef_Handler:
  112. SVC_Handler:
  113. PAbt_Handler:
  114. DAbt_Handler:
  115. IRQ_Handler:
  116. FIQ_Handler:
  117. Default_Handler:
  118. B .
  119. END