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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [Atmel/] [at91lib/] [boards/] [at91sam9xe-ek/] [board_cstartup_iar.s] - Blame information for rev 608

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/* ----------------------------------------------------------------------------
2
 *         ATMEL Microcontroller Software Support
3
 * ----------------------------------------------------------------------------
4
 * Copyright (c) 2008, Atmel Corporation
5
 *
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions are met:
10
 *
11
 * - Redistributions of source code must retain the above copyright notice,
12
 * this list of conditions and the disclaimer below.
13
 *
14
 * Atmel's name may not be used to endorse or promote products derived from
15
 * this software without specific prior written permission.
16
 *
17
 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20
 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 * ----------------------------------------------------------------------------
28
 */
29
 
30
#include "ISR_Support.h"
31
 
32
/*
33
     IAR startup file for AT91SAM9XE microcontrollers.
34
 */
35
 
36
        MODULE  ?cstartup
37
 
38
        ;; Forward declaration of sections.
39
        SECTION IRQ_STACK:DATA:NOROOT(2)
40
        SECTION CSTACK:DATA:NOROOT(3)
41
 
42
//------------------------------------------------------------------------------
43
//         Headers
44
//------------------------------------------------------------------------------
45
 
46
#define __ASSEMBLY__
47
#include "board.h"
48
 
49
//------------------------------------------------------------------------------
50
//         Definitions
51
//------------------------------------------------------------------------------
52
 
53
#define ARM_MODE_ABT     0x17
54
#define ARM_MODE_FIQ     0x11
55
#define ARM_MODE_IRQ     0x12
56
#define ARM_MODE_SVC     0x13
57
#define ARM_MODE_SYS     0x1F
58
 
59
#define I_BIT            0x80
60
#define F_BIT            0x40
61
 
62
//------------------------------------------------------------------------------
63
//         Startup routine
64
//------------------------------------------------------------------------------
65
 
66
/*
67
   Exception vectors
68
 */
69
        SECTION .vectors:CODE:NOROOT(2)
70
 
71
        PUBLIC  resetVector
72
        PUBLIC  irqHandler
73
 
74
        EXTERN  Undefined_Handler
75
        EXTERN  vPortYieldProcessor
76
        EXTERN  Prefetch_Handler
77
        EXTERN  Abort_Handler
78
        EXTERN  FIQ_Handler
79
 
80
        ARM
81
 
82
__iar_init$$done:               ; The interrupt vector is not needed
83
                                ; until after copy initialization is done
84
 
85
resetVector:
86
        ; All default exception handlers (except reset) are
87
        ; defined as weak symbol definitions.
88
        ; If a handler is defined by the application it will take precedence.
89
        LDR     pc, =resetHandler        ; Reset
90
        LDR     pc, Undefined_Addr       ; Undefined instructions
91
        LDR     pc, SWI_Addr             ; Software interrupt (SWI/SVC)
92
        LDR     pc, Prefetch_Addr        ; Prefetch abort
93
        LDR     pc, Abort_Addr           ; Data abort
94
        B       .                        ; RESERVED
95
        LDR     pc, =irqHandler          ; IRQ
96
        LDR     pc, FIQ_Addr             ; FIQ
97
 
98
Undefined_Addr: DCD   Undefined_Handler
99
SWI_Addr:       DCD   vPortYieldProcessor
100
Prefetch_Addr:  DCD   Prefetch_Handler
101
Abort_Addr:     DCD   Abort_Handler
102
FIQ_Addr:       DCD   FIQ_Handler
103
 
104
/*
105
   Handles incoming interrupt requests by branching to the corresponding
106
   handler, as defined in the AIC. Supports interrupt nesting.
107
 */
108
irqHandler:
109
                portSAVE_CONTEXT
110
 
111
        /* Write in the IVR to support Protect Mode */
112
        LDR     lr, =AT91C_BASE_AIC
113
        LDR     r0, [r14, #AIC_IVR]
114
        STR     lr, [r14, #AIC_IVR]
115
 
116
        /* Branch to C portion of the interrupt handler */
117
        MOV     lr, pc
118
        BX      r0
119
 
120
        /* Acknowledge interrupt */
121
        LDR     lr, =AT91C_BASE_AIC
122
        STR     lr, [r14, #AIC_EOICR]
123
 
124
                portRESTORE_CONTEXT
125
 
126
/*
127
   After a reset, execution starts here, the mode is ARM, supervisor
128
   with interrupts disabled.
129
   Initializes the chip and branches to the main() function.
130
 */
131
        SECTION .cstartup:CODE:NOROOT(2)
132
 
133
        PUBLIC  resetHandler
134
        EXTERN  LowLevelInit
135
        EXTERN  ?main
136
        REQUIRE resetVector
137
        ARM
138
 
139
resetHandler:
140
 
141
        /* Set pc to actual code location (i.e. not in remap zone) */
142
            LDR     pc, =label
143
 
144
        /* Perform low-level initialization of the chip using LowLevelInit() */
145
label:
146
            LDR     r0, =LowLevelInit
147
        LDR     r4, =SFE(CSTACK)
148
        MOV     sp, r4
149
        MOV     lr, pc
150
        BX      r0
151
 
152
        /* Set up the interrupt stack pointer. */
153
        MSR     cpsr_c, #ARM_MODE_IRQ | I_BIT | F_BIT      ; Change the mode
154
        LDR     sp, =SFE(IRQ_STACK)
155
 
156
        /* Set up the SVC stack pointer. */
157
        MSR     cpsr_c, #ARM_MODE_SVC | F_BIT              ; Change the mode
158
        LDR     sp, =SFE(CSTACK)
159
 
160
        /* Branch to main() */
161
        LDR     r0, =?main
162
        MOV     lr, pc
163
        BX      r0
164
 
165
        /* Loop indefinitely when program is finished */
166
loop4:
167
        B       loop4
168
 
169
        END

powered by: WebSVN 2.1.0

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