exception.S 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*!
  2. * Copyright (C) 2001-2010 by egnite Software GmbH
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * Portions Copyright Atmel Corporation, see the following note.
  35. */
  36. /* This file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */
  37. /*This file is prepared for Doxygen automatic documentation generation.*/
  38. /*! \file *********************************************************************
  39. *
  40. * \brief Exception and interrupt vectors.
  41. *
  42. * This file maps all events supported by an AVR32.
  43. *
  44. * - Compiler: GNU GCC for AVR32
  45. * - Supported devices: All AVR32 devices with an INTC module can be used.
  46. * - AppNote:
  47. *
  48. * \author Atmel Corporation: http://www.atmel.com \n
  49. * Support and FAQ: http://support.atmel.no/
  50. *
  51. ******************************************************************************/
  52. /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
  53. *
  54. * Redistribution and use in source and binary forms, with or without
  55. * modification, are permitted provided that the following conditions are met:
  56. *
  57. * 1. Redistributions of source code must retain the above copyright notice, this
  58. * list of conditions and the following disclaimer.
  59. *
  60. * 2. Redistributions in binary form must reproduce the above copyright notice,
  61. * this list of conditions and the following disclaimer in the documentation
  62. * and/or other materials provided with the distribution.
  63. *
  64. * 3. The name of Atmel may not be used to endorse or promote products derived
  65. * from this software without specific prior written permission.
  66. *
  67. * 4. This software may only be redistributed and used in connection with an Atmel
  68. * AVR product.
  69. *
  70. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  71. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  72. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  73. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  74. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  75. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  76. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  77. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  78. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  79. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  80. *
  81. */
  82. #if !__AVR32_UC__ && !__AVR32_AP__
  83. #error Implementation for the AVR32 architecture only.
  84. #endif
  85. #include <avr32/io.h>
  86. #include <cfg/arch/avr32pio.h>
  87. //! @{
  88. //! \verbatim
  89. .section .exception, "ax", @progbits
  90. // Start of Exception Vector Table.
  91. /*
  92. * EVBA must be aligned with a power of two strictly greater than the
  93. * EVBA-relative offset of the last vector.
  94. */
  95. .balign 0x200
  96. // Export symbol.
  97. .global _evba
  98. .type _evba, @function
  99. _evba:
  100. .org 0x000
  101. // Unrecoverable Exception.
  102. _handle_Unrecoverable_Exception:
  103. rjmp $
  104. .org 0x004
  105. // TLB Multiple Hit.
  106. _handle_TLB_Multiple_Hit:
  107. rjmp $
  108. .org 0x008
  109. // Bus Error Data Fetch.
  110. _handle_Bus_Error_Data_Fetch:
  111. rjmp $
  112. .org 0x00C
  113. // Bus Error Instruction Fetch.
  114. _handle_Bus_Error_Instruction_Fetch:
  115. rjmp $
  116. .org 0x010
  117. // NMI.
  118. _handle_NMI:
  119. #ifdef INTERRUPT_NMI_ENABLE
  120. lda.w pc, InterruptNMIEntry
  121. #endif
  122. rete
  123. .org 0x014
  124. // Instruction Address.
  125. _handle_Instruction_Address:
  126. rjmp $
  127. .org 0x018
  128. // ITLB Protection.
  129. _handle_ITLB_Protection:
  130. rjmp $
  131. .org 0x01C
  132. // Breakpoint.
  133. _handle_Breakpoint:
  134. rjmp $
  135. .org 0x020
  136. // Illegal Opcode.
  137. _handle_Illegal_Opcode:
  138. rjmp $
  139. .org 0x024
  140. // Unimplemented Instruction.
  141. _handle_Unimplemented_Instruction:
  142. rjmp $
  143. .org 0x028
  144. // Privilege Violation.
  145. _handle_Privilege_Violation:
  146. rjmp $
  147. .org 0x02C
  148. // Floating-Point: UNUSED IN AVR32UC and AVR32AP.
  149. _handle_Floating_Point:
  150. rjmp $
  151. .org 0x030
  152. // Coprocessor Absent: UNUSED IN AVR32UC.
  153. _handle_Coprocessor_Absent:
  154. rjmp $
  155. .org 0x034
  156. // Data Address (Read).
  157. _handle_Data_Address_Read:
  158. rjmp $
  159. .org 0x038
  160. // Data Address (Write).
  161. _handle_Data_Address_Write:
  162. rjmp $
  163. .org 0x03C
  164. // DTLB Protection (Read).
  165. _handle_DTLB_Protection_Read:
  166. rjmp $
  167. .org 0x040
  168. // DTLB Protection (Write).
  169. _handle_DTLB_Protection_Write:
  170. rjmp $
  171. .org 0x044
  172. // DTLB Modified: UNUSED IN AVR32UC.
  173. _handle_DTLB_Modified:
  174. rjmp $
  175. .org 0x050
  176. // ITLB Miss.
  177. _handle_ITLB_Miss:
  178. rjmp $
  179. .org 0x060
  180. // DTLB Miss (Read).
  181. _handle_DTLB_Miss_Read:
  182. rjmp $
  183. .org 0x070
  184. // DTLB Miss (Write).
  185. _handle_DTLB_Miss_Write:
  186. rjmp $
  187. .org 0x100
  188. // Supervisor Call.
  189. _handle_Supervisor_Call:
  190. rjmp $
  191. /*
  192. * Interrupt support.
  193. * The interrupt controller must provide the offset address relative to EVBA.
  194. * Important note:
  195. * All interrupts call a C function named _get_interrupt_handler.
  196. * This function will read group and interrupt line number to then return in
  197. *R12 a pointer to a user-provided interrupt handler.
  198. */
  199. .balign 4
  200. .irp priority, 0, 1, 2, 3
  201. .global _int\priority
  202. .type _int\priority, @function
  203. _int\priority:
  204. #if __AVR32_UC__
  205. /*
  206. * R8-R12, LR, PC and SR are automatically pushed onto the system stack
  207. * by the CPU upon interrupt entry. No other register is saved by
  208. * hardware.
  209. */
  210. #elif __AVR32_AP__
  211. /*
  212. * PC and SR are automatically saved in respectively RAR_INTx and
  213. * RSR_INTx by the CPU upon interrupt entry. No other register is saved
  214. * by hardware.
  215. */
  216. pushm r8-r12, lr
  217. #endif
  218. // Pass the int_level parameter to the _get_interrupt_handler function.
  219. mov r12, \priority
  220. call _get_interrupt_handler
  221. // Get the pointer to the interrupt handler returned by the function.
  222. cp.w r12, 0
  223. #if __AVR32_UC__
  224. /*
  225. * If this was not a spurious interrupt (R12 != NULL), jump to the
  226. * handler.
  227. */
  228. movne pc, r12
  229. #elif __AVR32_AP__
  230. // If this was a spurious interrupt (R12 == NULL), branch.
  231. breq spint\priority
  232. /*
  233. * Push the pointer to the interrupt handler onto the system stack since
  234. * no register may be altered.
  235. */
  236. st.w --sp, r12
  237. popm r8-r12, lr, pc // Restore registers and jump to the handler.
  238. spint\priority:
  239. popm r8-r12, lr
  240. #endif
  241. /*
  242. * If this was a spurious interrupt (R12 == NULL), return from event
  243. * handler.
  244. */
  245. rete
  246. .endr
  247. //! \endverbatim
  248. //! @}