OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM9_STR91X_IAR/] [91x_vect.s] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.