1 #include <AT91RM9200_inc.h>
\r
3 /*---------------------------
\r
4 ARM Core Mode and Status Bits
\r
5 ---------------------------*/
\r
9 #define ARM_MODE_USER 0x10
\r
10 #define ARM_MODE_FIQ 0x11
\r
11 #define ARM_MODE_IRQ 0x12
\r
12 #define ARM_MODE_SVC 0x13
\r
13 #define ARM_MODE_ABORT 0x17
\r
14 #define ARM_MODE_UNDEF 0x1B
\r
15 #define ARM_MODE_SYS 0x1F
\r
21 /*----------------------------------------------------------------------------
\r
24 Must be defined as function to put first in the code as it must be mapped
\r
25 at offset 0 of the flash EBI_CSR0, ie. at address 0 before remap.
\r
26 _---------------------------------------------------------------------------*/
\r
32 /*----------------------------------------------------------------------------
\r
33 Exception vectors ( before Remap )
\r
34 ------------------------------------
\r
35 These vectors are read at address 0.
\r
36 They absolutely requires to be in relative addresssing mode in order to
\r
37 guarantee a valid jump. For the moment, all are just looping (what may be
\r
38 dangerous in a final system). If an exception occurs before remap, this
\r
39 would result in an infinite loop.
\r
40 ----------------------------------------------------------------------------*/
\r
42 b undefvec /* Undefined Instruction */
\r
43 b swivec /* Software Interrupt */
\r
44 b pabtvec /* Prefetch Abort */
\r
45 b dabtvec /* Data Abort */
\r
46 b rsvdvec /* reserved */
\r
47 b aicvec /* IRQ : read the AIC */
\r
61 #define MEMEND 0x00004000
\r
63 /* ----------------------------
\r
64 Setup the stack for each mode
\r
65 ---------------------------- */
\r
67 #define IRQ_STACK_SIZE 0x10
\r
68 #define FIQ_STACK_SIZE 0x04
\r
69 #define ABT_STACK_SIZE 0x04
\r
70 #define UND_STACK_SIZE 0x04
\r
71 #define SVC_STACK_SIZE 0x10
\r
72 #define USER_STACK_SIZE 0x400
\r
76 /*- Set up Supervisor Mode and set Supervisor Mode Stack*/
\r
77 msr CPSR_c, #ARM_MODE_SVC | I_BIT | F_BIT
\r
78 mov r13, r0 /* Init stack Undef*/
\r
79 sub r0, r0, #SVC_STACK_SIZE
\r
81 /*- Set up Interrupt Mode and set IRQ Mode Stack*/
\r
82 msr CPSR_c, #ARM_MODE_IRQ | I_BIT | F_BIT
\r
83 mov r13, r0 /* Init stack IRQ*/
\r
84 sub r0, r0, #IRQ_STACK_SIZE
\r
86 /*- Set up Fast Interrupt Mode and set FIQ Mode Stack*/
\r
87 msr CPSR_c, #ARM_MODE_FIQ | I_BIT | F_BIT
\r
88 mov r13, r0 /* Init stack FIQ*/
\r
89 sub r0, r0, #FIQ_STACK_SIZE
\r
91 /*- Set up Abort Mode and set Abort Mode Stack*/
\r
92 msr CPSR_c, #ARM_MODE_ABORT | I_BIT | F_BIT
\r
93 mov r13, r0 /* Init stack Abort*/
\r
94 sub r0, r0, #ABT_STACK_SIZE
\r
96 /*- Set up Undefined Instruction Mode and set Undef Mode Stack*/
\r
97 msr CPSR_c, #ARM_MODE_UNDEF | I_BIT | F_BIT
\r
98 mov r13, r0 /* Init stack Undef*/
\r
99 sub r0, r0, #UND_STACK_SIZE
\r
101 /*- Set up user Mode and set System Mode Stack*/
\r
102 msr CPSR_c, #ARM_MODE_SYS | I_BIT | F_BIT
\r
103 bic r0, r0, #3 /* Insure word alignement */
\r
104 mov sp, r0 /* Init stack System */
\r
107 ldr r0, = AT91F_LowLevelInit
\r
111 /*----------------------------------------
\r
112 Read/modify/write CP15 control register
\r
113 ----------------------------------------*/
\r
114 mrc p15, 0, r0, c1, c0,0 /* read cp15 control registre (cp15 r1) in r0 */
\r
115 ldr r3,= 0xC0000080 /* Reset bit :Little Endian end fast bus mode */
\r
116 ldr r4,= 0xC0001000 /* Set bit :Asynchronous clock mode, Not Fast Bus, I-Cache enable */
\r
119 mcr p15, 0, r0, c1, c0,0 /* write r0 in cp15 control registre (cp15 r1) */
\r
121 /* Enable interrupts */
\r
122 msr CPSR_c, #ARM_MODE_SYS | F_BIT
\r
124 /*------------------------------------------------------------------------------
\r
125 - Branch on C code Main function (with interworking)
\r
126 ----------------------------------------------------
\r
127 - Branch must be performed by an interworking call as either an ARM or Thumb
\r
128 - _start function must be supported. This makes the code not position-
\r
129 - independent. A Branch with link would generate errors
\r
130 ----------------------------------------------------------------------------*/
\r
132 /*- Branch to _start by interworking*/
\r
137 /*-----------------------------------------------------------------------------
\r
140 - End of application. Normally, never occur.
\r
141 - Could jump on Software Reset ( B 0x0 ).
\r
142 ------------------------------------------------------------------------------*/
\r