1 | /* |
---|
2 | * AVR CPU Dependent Source |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-2008. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <rtems/system.h> |
---|
16 | #include <rtems/score/isr.h> |
---|
17 | #include <rtems/score/wkspace.h> |
---|
18 | |
---|
19 | #include <rtems/bspIo.h> /* XXX remove me later */ |
---|
20 | |
---|
21 | /* _CPU_Initialize |
---|
22 | * |
---|
23 | * This routine performs processor dependent initialization. |
---|
24 | * |
---|
25 | * INPUT PARAMETERS: NONE |
---|
26 | * |
---|
27 | * NO_CPU Specific Information: |
---|
28 | * |
---|
29 | * XXX document implementation including references if appropriate |
---|
30 | */ |
---|
31 | void _CPU_Initialize(void) |
---|
32 | { |
---|
33 | printk( "AVR CPU Initialize\n" ); |
---|
34 | |
---|
35 | /* |
---|
36 | * If there is not an easy way to initialize the FP context |
---|
37 | * during Context_Initialize, then it is usually easier to |
---|
38 | * save an "uninitialized" FP context here and copy it to |
---|
39 | * the task's during Context_Initialize. |
---|
40 | */ |
---|
41 | |
---|
42 | /* FP context initialization support goes here */ |
---|
43 | } |
---|
44 | |
---|
45 | /*PAGE |
---|
46 | * |
---|
47 | * _CPU_Context_Initialize |
---|
48 | * |
---|
49 | * This kernel routine initializes the basic non-FP context area associated |
---|
50 | * with each thread. |
---|
51 | * |
---|
52 | * Input parameters: |
---|
53 | * the_context - pointer to the context area |
---|
54 | * stack_base - address of memory for the SPARC |
---|
55 | * size - size in bytes of the stack area |
---|
56 | * new_level - interrupt level for this context area |
---|
57 | * entry_point - the starting execution point for this this context |
---|
58 | * is_fp - TRUE if this context is associated with an FP thread |
---|
59 | * |
---|
60 | * Output parameters: NONE |
---|
61 | */ |
---|
62 | |
---|
63 | void _CPU_Context_Initialize( |
---|
64 | Context_Control *the_context, |
---|
65 | uint32_t *stack_base, |
---|
66 | uint32_t size, |
---|
67 | uint32_t new_level, |
---|
68 | void *entry_point, |
---|
69 | bool is_fp |
---|
70 | ) |
---|
71 | { |
---|
72 | uint16_t stack; |
---|
73 | uint16_t start; |
---|
74 | uint16_t *tmpsp; |
---|
75 | |
---|
76 | /* calc stack high end */ |
---|
77 | stack = (uint16_t) (stack_base) + (uint16_t) (size); |
---|
78 | |
---|
79 | /* calc stack pointer initial value */ |
---|
80 | stack -= 2; |
---|
81 | |
---|
82 | the_context->stack_pointer = stack; |
---|
83 | tmpsp = (uint16_t *) stack; |
---|
84 | start = (uint16_t) entry_point; |
---|
85 | *tmpsp = start; |
---|
86 | #if 0 |
---|
87 | tmpsp[0] = start & 0xff; |
---|
88 | tmpsp[1] = (start >> 8) & 0xff; |
---|
89 | #endif |
---|
90 | |
---|
91 | /* FIXME on level */ |
---|
92 | if (new_level) the_context->status = 0; |
---|
93 | else the_context->status = 0; |
---|
94 | |
---|
95 | #if 1 |
---|
96 | printk(""); |
---|
97 | printk("the_context = 0x%x\n", the_context); |
---|
98 | printk("entry = 0x%x\n", entry_point); |
---|
99 | printk("sp = 0x%x\n\n",stack); |
---|
100 | #endif |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | /*PAGE |
---|
105 | * |
---|
106 | * _CPU_ISR_Get_level |
---|
107 | * |
---|
108 | * NO_CPU Specific Information: |
---|
109 | * |
---|
110 | * XXX document implementation including references if appropriate |
---|
111 | */ |
---|
112 | |
---|
113 | uint32_t _CPU_ISR_Get_level( void ) |
---|
114 | { |
---|
115 | /* |
---|
116 | * This routine returns the current interrupt level. |
---|
117 | */ |
---|
118 | |
---|
119 | return 0; |
---|
120 | } |
---|
121 | |
---|
122 | /*PAGE |
---|
123 | * |
---|
124 | * _CPU_ISR_install_raw_handler |
---|
125 | * |
---|
126 | * NO_CPU Specific Information: |
---|
127 | * |
---|
128 | * XXX document implementation including references if appropriate |
---|
129 | */ |
---|
130 | |
---|
131 | void _CPU_ISR_install_raw_handler( |
---|
132 | uint32_t vector, |
---|
133 | proc_ptr new_handler, |
---|
134 | proc_ptr *old_handler |
---|
135 | ) |
---|
136 | { |
---|
137 | /* |
---|
138 | * This is where we install the interrupt handler into the "raw" interrupt |
---|
139 | * table used by the CPU to dispatch interrupt handlers. |
---|
140 | */ |
---|
141 | } |
---|
142 | |
---|
143 | /*PAGE |
---|
144 | * |
---|
145 | * _CPU_ISR_install_vector |
---|
146 | * |
---|
147 | * This kernel routine installs the RTEMS handler for the |
---|
148 | * specified vector. |
---|
149 | * |
---|
150 | * Input parameters: |
---|
151 | * vector - interrupt vector number |
---|
152 | * old_handler - former ISR for this vector number |
---|
153 | * new_handler - replacement ISR for this vector number |
---|
154 | * |
---|
155 | * Output parameters: NONE |
---|
156 | * |
---|
157 | * |
---|
158 | * NO_CPU Specific Information: |
---|
159 | * |
---|
160 | * XXX document implementation including references if appropriate |
---|
161 | */ |
---|
162 | |
---|
163 | void _CPU_ISR_install_vector( |
---|
164 | uint32_t vector, |
---|
165 | proc_ptr new_handler, |
---|
166 | proc_ptr *old_handler |
---|
167 | ) |
---|
168 | { |
---|
169 | *old_handler = _ISR_Vector_table[ vector ]; |
---|
170 | |
---|
171 | /* |
---|
172 | * If the interrupt vector table is a table of pointer to isr entry |
---|
173 | * points, then we need to install the appropriate RTEMS interrupt |
---|
174 | * handler for this vector number. |
---|
175 | */ |
---|
176 | |
---|
177 | _CPU_ISR_install_raw_handler( vector, new_handler, old_handler ); |
---|
178 | |
---|
179 | /* |
---|
180 | * We put the actual user ISR address in '_ISR_vector_table'. This will |
---|
181 | * be used by the _ISR_Handler so the user gets control. |
---|
182 | */ |
---|
183 | |
---|
184 | _ISR_Vector_table[ vector ] = new_handler; |
---|
185 | } |
---|
186 | |
---|
187 | /*PAGE |
---|
188 | * |
---|
189 | * _CPU_Install_interrupt_stack |
---|
190 | * |
---|
191 | * NO_CPU Specific Information: |
---|
192 | * |
---|
193 | * XXX document implementation including references if appropriate |
---|
194 | */ |
---|
195 | |
---|
196 | void _CPU_Install_interrupt_stack( void ) |
---|
197 | { |
---|
198 | } |
---|
199 | |
---|
200 | /*PAGE |
---|
201 | * |
---|
202 | * _CPU_Thread_Idle_body |
---|
203 | * |
---|
204 | * NOTES: |
---|
205 | * |
---|
206 | * 1. This is the same as the regular CPU independent algorithm. |
---|
207 | * |
---|
208 | * 2. If you implement this using a "halt", "idle", or "shutdown" |
---|
209 | * instruction, then don't forget to put it in an infinite loop. |
---|
210 | * |
---|
211 | * 3. Be warned. Some processors with onboard DMA have been known |
---|
212 | * to stop the DMA if the CPU were put in IDLE mode. This might |
---|
213 | * also be a problem with other on-chip peripherals. So use this |
---|
214 | * hook with caution. |
---|
215 | * |
---|
216 | * NO_CPU Specific Information: |
---|
217 | * |
---|
218 | * XXX document implementation including references if appropriate |
---|
219 | */ |
---|
220 | |
---|
221 | void *_CPU_Thread_Idle_body( uintptr_t ignored ) |
---|
222 | { |
---|
223 | |
---|
224 | for( ; ; ) asm volatile ("sleep"::); |
---|
225 | /* insert your "halt" instruction here */ ; |
---|
226 | return (void *) 0; |
---|
227 | } |
---|