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