1 ;******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
\r
2 ;* File Name : 91x_vect.s
\r
3 ;* Author : MCD Application Team
\r
4 ;* Date First Issued : 05/18/2006 : Version 1.0
\r
5 ;* Description : This File used to initialize the exception and IRQ
\r
6 ;* vectors, and to enter/return to/from exceptions
\r
8 ;*******************************************************************************
\r
10 * 05/22/2007 : Version 1.2
\r
11 * 05/24/2006 : Version 1.1
\r
12 * 05/18/2006 : Version 1.0
\r
13 ;*******************************************************************************
\r
14 ; THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
\r
15 ; CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS
\r
16 ; A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
\r
17 ; OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
\r
18 ; OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
\r
19 ; CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
20 ;******************************************************************************/
\r
22 #include "FreeRTOSConfig.h"
\r
23 #include "ISR_Support.h"
\r
25 SECTION .intvec:CODE:ROOT(2)
\r
29 VectorAddress EQU 0xFFFFF030 ; VIC Vector address register address.
\r
30 VectorAddressDaisy EQU 0xFC000030 ; Daisy VIC Vector address register
\r
31 I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
\r
32 F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
\r
37 ;*******************************************************************************
\r
38 ; Import the __iar_program_start address from 91x_init.s
\r
39 ;*******************************************************************************
\r
41 IMPORT __iar_program_start
\r
43 ;*******************************************************************************
\r
44 ; Import exception handlers
\r
45 ;*******************************************************************************
\r
47 IMPORT Undefined_Handler
\r
48 IMPORT vPortYieldProcessor ; FreeRTOS SWI handler
\r
49 IMPORT Prefetch_Handler
\r
50 IMPORT Abort_Handler
\r
54 ;*******************************************************************************
\r
55 ; Export Peripherals IRQ handlers table address
\r
56 ;*******************************************************************************
\r
58 ;*******************************************************************************
\r
60 ;*******************************************************************************
\r
63 LDR PC, Undefined_Addr
\r
65 LDR PC, Prefetch_Addr
\r
67 NOP ; Reserved vector
\r
70 ;*******************************************************************************
\r
71 ;* Function Name : FIQHandler
\r
72 ;* Description : This function is called when FIQ exception is entered.
\r
75 ;*******************************************************************************
\r
77 SUB lr,lr,#4 ; Update the link register.
\r
78 STMFD sp!,{r0-r7,lr} ; Save The workspace plus the current return
\r
79 ; address lr_fiq into the FIQ stack.
\r
81 ldr lr,=FIQ_Handler_end
\r
82 bx r0 ;Branch to FIQ_Handler.
\r
85 LDMFD sp!,{r0-r7,pc}^; Return to the instruction following...
\r
86 ; ...the exception interrupt.
\r
89 ;*******************************************************************************
\r
90 ; Exception handlers address table
\r
91 ;*******************************************************************************
\r
93 Reset_Addr DCD __iar_program_start
\r
94 Undefined_Addr DCD UndefinedHandler
\r
95 SWI_Addr DCD vPortYieldProcessor
\r
96 Prefetch_Addr DCD PrefetchAbortHandler
\r
97 Abort_Addr DCD DataAbortHandler
\r
98 DCD 0 ; Reserved vector
\r
99 IRQ_Addr DCD IRQHandler
\r
102 ;*******************************************************************************
\r
104 ;*******************************************************************************
\r
105 ;*******************************************************************************
\r
106 ;* Macro Name : SaveContext
\r
107 ;* Description : This macro is used to save the context before entering
\r
108 ; an exception handler.
\r
109 ;* Input : The range of registers to store.
\r
111 ;*******************************************************************************
\r
113 SaveContext MACRO reg1,reg2
\r
114 STMFD sp!,{reg1-reg2,lr} ; Save The workspace plus the current return
\r
115 ; address lr_ mode into the stack.
\r
116 MRS r1,spsr ; Save the spsr_mode into r1.
\r
117 STMFD sp!,{r1} ; Save spsr.
\r
120 ;*******************************************************************************
\r
121 ;* Macro Name : RestoreContext
\r
122 ;* Description : This macro is used to restore the context to return from
\r
123 ; an exception handler and continue the program execution.
\r
124 ;* Input : The range of registers to restore.
\r
126 ;*******************************************************************************
\r
128 RestoreContext MACRO reg1,reg2
\r
129 LDMFD sp!,{r1} ; Restore the saved spsr_mode into r1.
\r
130 MSR spsr_cxsf,r1 ; Restore spsr_mode.
\r
131 LDMFD sp!,{reg1-reg2,pc}^; Return to the instruction following...
\r
132 ; ...the exception interrupt.
\r
136 ;*******************************************************************************
\r
137 ; Exception Handlers
\r
138 ;*******************************************************************************
\r
141 ;*******************************************************************************
\r
142 ;* Function Name : UndefinedHandler
\r
143 ;* Description : This function is called when undefined instruction
\r
144 ; exception is entered.
\r
147 ;*******************************************************************************
\r
150 SaveContext r0,r12 ; Save the workspace plus the current
\r
151 ; return address lr_ und and spsr_und.
\r
153 ldr r0,=Undefined_Handler
\r
154 ldr lr,=Undefined_Handler_end
\r
155 bx r0 ; Branch to Undefined_Handler.
\r
157 Undefined_Handler_end:
\r
158 RestoreContext r0,r12 ; Return to the instruction following...
\r
159 ; ...the undefined instruction.
\r
161 ;*******************************************************************************
\r
162 ;* Function Name : PrefetchAbortHandler
\r
163 ;* Description : This function is called when Prefetch Abort
\r
164 ; exception is entered.
\r
167 ;*******************************************************************************
\r
169 PrefetchAbortHandler
\r
170 SUB lr,lr,#4 ; Update the link register.
\r
171 SaveContext r0,r12 ; Save the workspace plus the current
\r
172 ; return address lr_abt and spsr_abt.
\r
174 ldr r0,=Prefetch_Handler
\r
175 ldr lr,=Prefetch_Handler_end
\r
176 bx r0 ; Branch to Prefetch_Handler.
\r
178 Prefetch_Handler_end:
\r
179 RestoreContext r0,r12 ; Return to the instruction following that...
\r
180 ; ...has generated the prefetch abort exception.
\r
182 ;*******************************************************************************
\r
183 ;* Function Name : DataAbortHandler
\r
184 ;* Description : This function is called when Data Abort
\r
185 ; exception is entered.
\r
188 ;*******************************************************************************
\r
191 SUB lr,lr,#8 ; Update the link register.
\r
192 SaveContext r0,r12 ; Save the workspace plus the current
\r
193 ; return address lr_ abt and spsr_abt.
\r
194 ldr r0,=Abort_Handler
\r
195 ldr lr,=Abort_Handler_end
\r
196 bx r0 ; Branch to Abort_Handler.
\r
200 RestoreContext r0,r12 ; Return to the instruction following that...
\r
201 ; ...has generated the data abort exception.
\r
202 ;*******************************************************************************
\r
203 ;* Function Name : IRQHandler
\r
204 ;* Description : This function is called when IRQ exception is entered.
\r
207 ;*******************************************************************************
\r
210 portSAVE_CONTEXT ; Save the context of the current task.
\r
212 LDR r0, = VectorAddress
\r
213 LDR r0, [r0] ; Read the routine address
\r
214 LDR r1, = VectorAddressDaisy
\r
218 LDR r0, = VectorAddress ; Write to the VectorAddress to clear the
\r
219 STR r0, [r0] ; respective interrupt in the internal interrupt
\r
220 LDR r1, = VectorAddressDaisy ; Write to the VectorAddressDaisy to clear the
\r
221 STR r1,[r1] ; respective interrupt in the internal interrupt
\r
223 portRESTORE_CONTEXT ; Restore the context of the selected task.
\r
228 ;******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****
\r