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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM7_LPC2129_IAR/] [SrcIAR/] [lpc2xxx_cstartup.s] - Blame information for rev 867

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

Line No. Rev Author Line
1 577 jeremybenn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;
3
;; Part one of the system initialization code,
4
;; contains low-level
5
;; initialization.
6
;;
7
;; Copyright 2006 IAR Systems. All rights reserved.
8
;;
9
;; $Revision: 2 $
10
;;
11
 
12
        MODULE  ?cstartup
13
 
14
        ;; Forward declaration of sections.
15
        SECTION IRQ_STACK:DATA:NOROOT(3)
16
        SECTION ABT_STACK:DATA:NOROOT(3)
17
        SECTION SVC_STACK:DATA:NOROOT(3)
18
        SECTION UND_STACK:DATA:NOROOT(3)
19
        SECTION FIQ_STACK:DATA:NOROOT(3)
20
        SECTION CSTACK:DATA:NOROOT(3)
21
 
22
;
23
; The module in this file are included in the libraries, and may be
24
; replaced by any user-defined modules that define the PUBLIC symbol
25
; __iar_program_start or a user defined start symbol.
26
;
27
; To override the cstartup defined in the library, simply add your
28
; modified version to the workbench project.
29
 
30
        SECTION .intvec:CODE:NOROOT(2)
31
 
32
        PUBLIC  __vector
33
        PUBLIC  __vector_0x14
34
        PUBLIC  __iar_program_start
35
                EXTERN  vPortYieldProcessor
36
 
37
        ARM
38
__vector:
39
        ;;
40
        ldr   pc,[pc,#+24]              ;; Reset
41
        ldr   pc,[pc,#+24]              ;; Undefined instructions
42
;;        ldr   pc,[pc,#+24]              ;; Software interrupt (SWI/SVC)
43
                b vPortYieldProcessor
44
        ldr   pc,[pc,#+24]              ;; Prefetch abort
45
        ldr   pc,[pc,#+24]              ;; Data abort
46
__vector_0x14
47
        DC32  0                         ;; RESERVED
48
        ldr   pc, [PC, #-0xFF0]         ;; IRQ
49
        ldr   pc,[pc,#+24]              ;; FIQ
50
 
51
        DC32  __iar_program_start       ;; Reset
52
        DC32  undef_handler             ;; Undefined instructions
53
        DC32  0       ;; Software interrupt (SWI/SVC)
54
        DC32  prefetch_handler          ;; Prefetch abort
55
        DC32  data_handler              ;; Data abort
56
        DC32  0                         ;; RESERVED
57
        DC32  0                                  ;; IRQ
58
        DC32  fiq_handler               ;; FIQ
59
 
60
undef_handler
61
    b         undef_handler
62
 
63
prefetch_handler
64
    b         prefetch_handler
65
 
66
data_handler
67
    b         data_handler
68
 
69
fiq_handler
70
    b         fiq_handler
71
; --------------------------------------------------
72
; ?cstartup -- low-level system initialization code.
73
;
74
; After a reser execution starts here, the mode is ARM, supervisor
75
; with interrupts disabled.
76
;
77
 
78
 
79
 
80
        SECTION .text:CODE:NOROOT(2)
81
 
82
;        PUBLIC  ?cstartup
83
        EXTERN  ?main
84
        REQUIRE __vector
85
 
86
        ARM
87
 
88
__iar_program_start:
89
?cstartup:
90
 
91
;
92
; Add initialization needed before setup of stackpointers here.
93
;
94
 
95
; Errata  MAM.1Incorrect read of data from SRAM after Reset and MAM
96
; is not enabled or partially enabled.
97
; Work-around: User code should enable the MAM after Reset and before
98
; any RAM accesses
99
MAMCR    DEFINE  0xE01FC000     ; MAM Control Register
100
MAMTIM   DEFINE  0xE01FC004     ; MAM Timing register
101
 
102
        ldr     r0,=MAMCR
103
        ldr     r1,=MAMTIM
104
        ldr     r2,=0
105
        str     r2,[r0]
106
        ldr     r2,=3     ; 1 < 20 MHz; 20 MHz < 2 < 40 MHz; 40MHz > 3
107
        str     r2,[r1]
108
        ldr     r2,=2
109
        str     r2,[r0]
110
 
111
; Initialize the stack pointers.
112
; The pattern below can be used for any of the exception stacks:
113
; FIQ, IRQ, SVC, ABT, UND, SYS.
114
; The USR mode uses the same stack as SYS.
115
; The stack segments must be defined in the linker command file,
116
; and be declared above.
117
;
118
; --------------------
119
; Mode, correspords to bits 0-5 in CPSR
120
MODE_BITS DEFINE  0x1F    ; Bit mask for mode bits in CPSR
121
USR_MODE  DEFINE  0x10    ; User mode
122
FIQ_MODE  DEFINE  0x11    ; Fast Interrupt Request mode
123
IRQ_MODE  DEFINE  0x12    ; Interrupt Request mode
124
SVC_MODE  DEFINE  0x13    ; Supervisor mode
125
ABT_MODE  DEFINE  0x17    ; Abort mode
126
UND_MODE  DEFINE  0x1B    ; Undefined Instruction mode
127
SYS_MODE  DEFINE  0x1F    ; System mode
128
 
129
        MRS     r0, cpsr                ; Original PSR value
130
 
131
        BIC     r0, r0, #MODE_BITS      ; Clear the mode bits
132
        ORR     r0, r0, #ABT_MODE       ; Set ABT mode bits
133
        MSR     cpsr_c, r0              ; Change the mode
134
        LDR     sp, =SFE(ABT_STACK)     ; End of ABT_STACK
135
 
136
        BIC     r0, r0, #MODE_BITS      ; Clear the mode bits
137
        ORR     r0, r0, #SVC_MODE       ; Set SVC mode bits
138
        MSR     cpsr_c, r0              ; Change the mode
139
        LDR     sp, =SFE(SVC_STACK)     ; End of SVC_STACK
140
 
141
        BIC     r0, r0, #MODE_BITS      ; Clear the mode bits
142
        ORR     r0, r0, #UND_MODE       ; Set UND mode bits
143
        MSR     cpsr_c, r0              ; Change the mode
144
        LDR     sp, =SFE(UND_STACK)     ; End of UND_STACK
145
 
146
        BIC     r0, r0, #MODE_BITS      ; Clear the mode bits
147
        ORR     r0, r0, #FIQ_MODE       ; Set FIQ mode bits
148
        MSR     cpsr_c, r0              ; Change the mode
149
        LDR     sp, =SFE(FIQ_STACK)     ; End of FIQ_STACK
150
 
151
        BIC     r0, r0, #MODE_BITS      ; Clear the mode bits
152
        ORR     r0, r0, #IRQ_MODE       ; Set IRQ mode bits
153
        MSR     cpsr_c, r0              ; Change the mode
154
        LDR     sp, =SFE(IRQ_STACK)     ; End of IRQ_STACK
155
 
156
        BIC     r0 ,r0, #MODE_BITS      ; Clear the mode bits
157
        ORR     r0 ,r0, #SYS_MODE       ; Set System mode bits
158
        MSR     cpsr_c, r0              ; Change the mode
159
        LDR     sp, =SFE(CSTACK)        ; End of CSTACK
160
 
161
#ifdef __ARMVFP__
162
        ;; Enable the VFP coprocessor.
163
 
164
        MOV     r0, #0x40000000         ; Set EN bit in VFP
165
        FMXR    fpexc, r0               ; FPEXC, clear others.
166
 
167
;
168
; Disable underflow exceptions by setting flush to zero mode.
169
; For full IEEE 754 underflow compliance this code should be removed
170
; and the appropriate exception handler installed.
171
;
172
 
173
        MOV     r0, #0x01000000         ; Set FZ bit in VFP
174
        FMXR    fpscr, r0               ; FPSCR, clear others.
175
#endif
176
 
177
;
178
; Add more initialization here
179
;
180
        BIC     r0, r0, #MODE_BITS      ; Clear the mode bits
181
        ORR     r0, r0, #SVC_MODE       ; Set SVC mode bits
182
        MSR     cpsr_c, r0              ; Change the mode
183
 
184
; Continue to ?main for C-level initialization.
185
 
186
        LDR     r0, =?main
187
        BX      r0
188
 
189
        END

powered by: WebSVN 2.1.0

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