]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/ARM9_STR91X_IAR/91x_vect.s
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / ARM9_STR91X_IAR / 91x_vect.s
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
7 ;*                      handlers.\r
8 ;*******************************************************************************\r
9 * History:\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
21 \r
22 #include "FreeRTOSConfig.h"\r
23 #include "ISR_Support.h"\r
24 \r
25     SECTION .intvec:CODE:ROOT(2)                \r
26     CODE32\r
27 \r
28 \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
33 \r
34 \r
35 \r
36 \r
37 ;*******************************************************************************\r
38 ;              Import  the __iar_program_start address from 91x_init.s\r
39 ;*******************************************************************************\r
40 \r
41        IMPORT  __iar_program_start\r
42 \r
43 ;*******************************************************************************\r
44 ;                      Import exception handlers\r
45 ;*******************************************************************************\r
46 \r
47         IMPORT  Undefined_Handler\r
48         IMPORT  vPortYieldProcessor             ; FreeRTOS SWI handler\r
49         IMPORT  Prefetch_Handler\r
50         IMPORT  Abort_Handler\r
51         IMPORT  FIQ_Handler\r
52 \r
53 \r
54 ;*******************************************************************************\r
55 ;            Export Peripherals IRQ handlers table address\r
56 ;*******************************************************************************\r
57 \r
58 ;*******************************************************************************\r
59 ;                        Exception vectors\r
60 ;*******************************************************************************\r
61 \r
62         LDR     PC, Reset_Addr\r
63         LDR     PC, Undefined_Addr\r
64         LDR     PC, SWI_Addr\r
65         LDR     PC, Prefetch_Addr\r
66         LDR     PC, Abort_Addr\r
67         NOP                             ; Reserved vector\r
68         LDR     PC, IRQ_Addr\r
69 \r
70 ;*******************************************************************************\r
71 ;* Function Name  : FIQHandler\r
72 ;* Description    : This function is called when FIQ exception is entered.\r
73 ;* Input          : none\r
74 ;* Output         : none\r
75 ;*******************************************************************************\r
76 FIQHandler\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
80        ldr r0,=FIQ_Handler\r
81        ldr lr,=FIQ_Handler_end\r
82        bx r0                 ;Branch to FIQ_Handler.\r
83 FIQ_Handler_end:\r
84 \r
85       LDMFD   sp!,{r0-r7,pc}^; Return to the instruction following...\r
86                               ; ...the exception interrupt.\r
87 \r
88 \r
89 ;*******************************************************************************\r
90 ;               Exception handlers address table\r
91 ;*******************************************************************************\r
92 \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
100 \r
101 \r
102 ;*******************************************************************************\r
103 ;                                  MACRO\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
110 ;* Output         : none\r
111 ;*******************************************************************************\r
112 \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
118         ENDM\r
119 \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
125 ;* Output         : none\r
126 ;*******************************************************************************\r
127 \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
133         ENDM\r
134 \r
135 \r
136 ;*******************************************************************************\r
137 ;                         Exception Handlers\r
138 ;*******************************************************************************\r
139 \r
140 \r
141 ;*******************************************************************************\r
142 ;* Function Name  : UndefinedHandler\r
143 ;* Description    : This function is called when undefined instruction\r
144 ;                   exception is entered.\r
145 ;* Input          : none\r
146 ;* Output         : none\r
147 ;*******************************************************************************\r
148 \r
149 UndefinedHandler\r
150         SaveContext r0,r12    ; Save the workspace plus the current\r
151                               ; return address lr_ und and spsr_und.\r
152 \r
153        ldr r0,=Undefined_Handler\r
154        ldr lr,=Undefined_Handler_end\r
155        bx r0                 ; Branch to Undefined_Handler.\r
156 \r
157 Undefined_Handler_end:\r
158         RestoreContext r0,r12 ; Return to the instruction following...\r
159                               ; ...the undefined instruction.\r
160 \r
161 ;*******************************************************************************\r
162 ;* Function Name  : PrefetchAbortHandler\r
163 ;* Description    : This function is called when Prefetch Abort\r
164 ;                   exception is entered.\r
165 ;* Input          : none\r
166 ;* Output         : none\r
167 ;*******************************************************************************\r
168 \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
173 \r
174        ldr r0,=Prefetch_Handler\r
175        ldr lr,=Prefetch_Handler_end\r
176        bx r0                 ; Branch to Prefetch_Handler.\r
177 \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
181 \r
182 ;*******************************************************************************\r
183 ;* Function Name  : DataAbortHandler\r
184 ;* Description    : This function is called when Data Abort\r
185 ;                   exception is entered.\r
186 ;* Input          : none\r
187 ;* Output         : none\r
188 ;*******************************************************************************\r
189 \r
190 DataAbortHandler\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
197 \r
198 Abort_Handler_end:\r
199 \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
205 ;* Input          : none\r
206 ;* Output         : none\r
207 ;*******************************************************************************\r
208 \r
209 IRQHandler\r
210         portSAVE_CONTEXT                                        ; Save the context of the current task.\r
211 \r
212         LDR    r0, = VectorAddress\r
213         LDR    r0, [r0]                                         ; Read the routine address\r
214         LDR    r1, = VectorAddressDaisy\r
215         LDR    r1, [r1]\r
216         MOV        lr, pc\r
217         bx         r0\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
222         \r
223         portRESTORE_CONTEXT                                     ; Restore the context of the selected task.\r
224 \r
225        LTORG\r
226 \r
227        END\r
228 ;******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****\r