|
0
|
1 #ifndef CYGONCE_HAL_HAL_INTR_H |
|
|
2 #define CYGONCE_HAL_HAL_INTR_H |
|
|
3 |
|
|
4 //============================================================================= |
|
|
5 // |
|
|
6 // hal_intr.h |
|
|
7 // |
|
|
8 // HAL Interrupt and clock support |
|
|
9 // |
|
|
10 //============================================================================= |
|
|
11 //####COPYRIGHTBEGIN#### |
|
|
12 // |
|
|
13 // ------------------------------------------- |
|
|
14 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
15 // Version 1.0 (the "License"); you may not use this file except in |
|
|
16 // compliance with the License. You may obtain a copy of the License at |
|
|
17 // http://sourceware.cygnus.com/ecos |
|
|
18 // |
|
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
21 // License for the specific language governing rights and limitations under |
|
|
22 // the License. |
|
|
23 // |
|
|
24 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
25 // September 30, 1998. |
|
|
26 // |
|
|
27 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
28 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
29 // ------------------------------------------- |
|
|
30 // |
|
|
31 //####COPYRIGHTEND#### |
|
|
32 //============================================================================= |
|
|
33 //#####DESCRIPTIONBEGIN#### |
|
|
34 // |
|
|
35 // Author(s): nickg |
|
|
36 // Contributors: nickg |
|
|
37 // Date: 1998-02-17 |
|
|
38 // Purpose: Define Interrupt support |
|
|
39 // Description: The macros defined here provide the HAL APIs for handling |
|
|
40 // interrupts and the clock. |
|
|
41 // |
|
|
42 // Usage: |
|
|
43 // #include <cyg/hal/hal_intr.h> |
|
|
44 // ... |
|
|
45 // |
|
|
46 // |
|
|
47 //####DESCRIPTIONEND#### |
|
|
48 // |
|
|
49 //============================================================================= |
|
|
50 |
|
|
51 #include <cyg/infra/cyg_type.h> |
|
|
52 |
|
|
53 #include <pkgconf/hal.h> |
|
|
54 |
|
|
55 //----------------------------------------------------------------------------- |
|
|
56 |
|
|
57 // The MN10300 has a somewhat complex interrupt structure. Besides the |
|
|
58 // reset and NMI vectors there are seven maskable interrupt vectors |
|
|
59 // which must point to code in the 64k starting at 0x40000000. There |
|
|
60 // are also 25 Interrupt control groups, each of which can have 4 |
|
|
61 // interrupt lines attached, for a theoretical total of 100 interrupts |
|
|
62 // (!). Some of these are dedicated to specific devices, other to |
|
|
63 // external pins, and others are not connected to anything, resulting |
|
|
64 // in only 45 that can actually be delivered. Each control group may |
|
|
65 // be assigned one of seven interrupt levels, and is delivered to the |
|
|
66 // corresponding vector. Software can then use a register to determine |
|
|
67 // the delivering group and detect from there which interrupt has been |
|
|
68 // delivered. |
|
|
69 // |
|
|
70 // The approach we will adopt at present is for the code attached to |
|
|
71 // each vector to save state and jump via a table to a VSR. The |
|
|
72 // default VSR will fully decode the delivered interrupt into a table |
|
|
73 // of isr/data/object entries. VSR replacement will operate on the |
|
|
74 // first level indirection table rather than the hardware |
|
|
75 // vectors. This is the fastest mechanism, however it needs 100*3*4 + |
|
|
76 // 7*4 = 1228 bytes for the tables. |
|
|
77 // |
|
|
78 |
|
|
79 //----------------------------------------------------------------------------- |
|
|
80 // Interrupt vectors. |
|
|
81 |
|
|
82 // The level-specific hardware vectors |
|
|
83 #define CYG_VECTOR_0 0 |
|
|
84 #define CYG_VECTOR_1 1 |
|
|
85 #define CYG_VECTOR_2 2 |
|
|
86 #define CYG_VECTOR_3 3 |
|
|
87 #define CYG_VECTOR_4 4 |
|
|
88 #define CYG_VECTOR_5 5 |
|
|
89 #define CYG_VECTOR_6 6 |
|
|
90 #define CYG_VECTOR_NMI 7 |
|
|
91 #define CYG_VECTOR_TRAP 8 |
|
|
92 |
|
|
93 #define CYG_VSR_MIN 0 |
|
|
94 #define CYG_VSR_MAX 8 |
|
|
95 #define CYG_VSR_COUNT 9 |
|
|
96 |
|
|
97 #define CYG_EXCEPTION_MIN 0 |
|
|
98 #define CYG_EXCEPTION_MAX 3 |
|
|
99 #define CYG_EXCEPTION_COUNT 4 |
|
|
100 |
|
|
101 |
|
|
102 #if defined(CYG_HAL_MN10300_MN103000) |
|
|
103 |
|
|
104 // The decoded interrupts |
|
|
105 |
|
|
106 #define CYG_VECTOR_NMIRQ 0 |
|
|
107 #define CYG_VECTOR_WATCHDOG 1 |
|
|
108 #define CYG_VECTOR_SYSTEM_ERROR 2 |
|
|
109 #define CYG_VECTOR_RESERVED_3 3 |
|
|
110 |
|
|
111 #define CYG_VECTOR_RESERVED_4 4 |
|
|
112 #define CYG_VECTOR_RESERVED_5 5 |
|
|
113 #define CYG_VECTOR_RESERVED_6 6 |
|
|
114 #define CYG_VECTOR_RESERVED_7 7 |
|
|
115 |
|
|
116 #define CYG_VECTOR_TIMER_0 8 |
|
|
117 #define CYG_VECTOR_TIMER_1 9 |
|
|
118 #define CYG_VECTOR_TIMER_2 10 |
|
|
119 #define CYG_VECTOR_TIMER_3 11 |
|
|
120 |
|
|
121 #define CYG_VECTOR_TIMER_4 12 |
|
|
122 #define CYG_VECTOR_TIMER_5 13 |
|
|
123 #define CYG_VECTOR_TIMER_6 14 |
|
|
124 #define CYG_VECTOR_TIMER_7 15 |
|
|
125 |
|
|
126 #define CYG_VECTOR_TIMER_8 16 |
|
|
127 #define CYG_VECTOR_TIMER_8_COMPARE_A 17 |
|
|
128 #define CYG_VECTOR_TIMER_8_COMPARE_B 18 |
|
|
129 #define CYG_VECTOR_RESERVED_19 19 |
|
|
130 |
|
|
131 #define CYG_VECTOR_TIMER_9 20 |
|
|
132 #define CYG_VECTOR_TIMER_9_COMPARE_A 21 |
|
|
133 #define CYG_VECTOR_TIMER_9_COMPARE_B 22 |
|
|
134 #define CYG_VECTOR_RESERVED_23 23 |
|
|
135 |
|
|
136 #define CYG_VECTOR_TIMER_10 24 |
|
|
137 #define CYG_VECTOR_TIMER_10_COMPARE_A 25 |
|
|
138 #define CYG_VECTOR_TIMER_10_COMPARE_B 26 |
|
|
139 #define CYG_VECTOR_TIMER_10_COMPARE_C 27 |
|
|
140 |
|
|
141 #define CYG_VECTOR_TIMER_11 28 |
|
|
142 #define CYG_VECTOR_TIMER_11_COMPARE_A 29 |
|
|
143 #define CYG_VECTOR_TIMER_11_COMPARE_B 30 |
|
|
144 #define CYG_VECTOR_TIMER_11_COMPARE_C 31 |
|
|
145 |
|
|
146 #define CYG_VECTOR_TIMER_12 32 |
|
|
147 #define CYG_VECTOR_TIMER_12_COMPARE_A 33 |
|
|
148 #define CYG_VECTOR_TIMER_12_COMPARE_B 34 |
|
|
149 #define CYG_VECTOR_TIMER_12_COMPARE_C 35 |
|
|
150 |
|
|
151 #define CYG_VECTOR_TIMER_11_COMPARE_D 36 |
|
|
152 #define CYG_VECTOR_TIMER_12_COMPARE_D 37 |
|
|
153 #define CYG_VECTOR_RESERVED_38 38 |
|
|
154 #define CYG_VECTOR_RESERVED_39 39 |
|
|
155 |
|
|
156 #define CYG_VECTOR_DMA0 40 |
|
|
157 #define CYG_VECTOR_RESERVED_41 41 |
|
|
158 #define CYG_VECTOR_RESERVED_42 42 |
|
|
159 #define CYG_VECTOR_RESERVED_43 43 |
|
|
160 |
|
|
161 #define CYG_VECTOR_DMA1 44 |
|
|
162 #define CYG_VECTOR_RESERVED_45 45 |
|
|
163 #define CYG_VECTOR_RESERVED_46 46 |
|
|
164 #define CYG_VECTOR_RESERVED_47 47 |
|
|
165 |
|
|
166 #define CYG_VECTOR_DMA2 48 |
|
|
167 #define CYG_VECTOR_RESERVED_49 49 |
|
|
168 #define CYG_VECTOR_RESERVED_50 50 |
|
|
169 #define CYG_VECTOR_RESERVED_51 51 |
|
|
170 |
|
|
171 #define CYG_VECTOR_DMA3 52 |
|
|
172 #define CYG_VECTOR_RESERVED_53 53 |
|
|
173 #define CYG_VECTOR_RESERVED_54 54 |
|
|
174 #define CYG_VECTOR_RESERVED_55 55 |
|
|
175 |
|
|
176 #define CYG_VECTOR_SERIAL_0_RX 56 |
|
|
177 #define CYG_VECTOR_SERIAL_0_TX 57 |
|
|
178 #define CYG_VECTOR_RESERVED_58 58 |
|
|
179 #define CYG_VECTOR_RESERVED_59 59 |
|
|
180 |
|
|
181 #define CYG_VECTOR_SERIAL_1_RX 60 |
|
|
182 #define CYG_VECTOR_SERIAL_1_TX 61 |
|
|
183 #define CYG_VECTOR_RESERVED_62 62 |
|
|
184 #define CYG_VECTOR_RESERVED_63 63 |
|
|
185 |
|
|
186 #define CYG_VECTOR_EXTERNAL_0 64 |
|
|
187 #define CYG_VECTOR_RESERVED_65 65 |
|
|
188 #define CYG_VECTOR_RESERVED_66 66 |
|
|
189 #define CYG_VECTOR_RESERVED_67 67 |
|
|
190 |
|
|
191 #define CYG_VECTOR_EXTERNAL_1 68 |
|
|
192 #define CYG_VECTOR_RESERVED_69 69 |
|
|
193 #define CYG_VECTOR_RESERVED_70 70 |
|
|
194 #define CYG_VECTOR_RESERVED_71 71 |
|
|
195 |
|
|
196 #define CYG_VECTOR_EXTERNAL_2 72 |
|
|
197 #define CYG_VECTOR_RESERVED_73 73 |
|
|
198 #define CYG_VECTOR_RESERVED_74 74 |
|
|
199 #define CYG_VECTOR_RESERVED_75 75 |
|
|
200 |
|
|
201 #define CYG_VECTOR_EXTERNAL_3 76 |
|
|
202 #define CYG_VECTOR_RESERVED_77 77 |
|
|
203 #define CYG_VECTOR_RESERVED_78 78 |
|
|
204 #define CYG_VECTOR_RESERVED_79 79 |
|
|
205 |
|
|
206 #define CYG_VECTOR_EXTERNAL_4 80 |
|
|
207 #define CYG_VECTOR_RESERVED_81 81 |
|
|
208 #define CYG_VECTOR_RESERVED_82 82 |
|
|
209 #define CYG_VECTOR_RESERVED_83 83 |
|
|
210 |
|
|
211 #define CYG_VECTOR_EXTERNAL_5 84 |
|
|
212 #define CYG_VECTOR_RESERVED_85 85 |
|
|
213 #define CYG_VECTOR_RESERVED_86 86 |
|
|
214 #define CYG_VECTOR_RESERVED_87 87 |
|
|
215 |
|
|
216 #define CYG_VECTOR_EXTERNAL_6 88 |
|
|
217 #define CYG_VECTOR_RESERVED_89 89 |
|
|
218 #define CYG_VECTOR_RESERVED_90 90 |
|
|
219 #define CYG_VECTOR_RESERVED_91 91 |
|
|
220 |
|
|
221 #define CYG_VECTOR_EXTERNAL_7 92 |
|
|
222 #define CYG_VECTOR_RESERVED_93 93 |
|
|
223 #define CYG_VECTOR_RESERVED_94 94 |
|
|
224 #define CYG_VECTOR_RESERVED_95 95 |
|
|
225 |
|
|
226 #define CYG_VECTOR_AD_CONVERSION 96 |
|
|
227 #define CYG_VECTOR_RESERVED_97 97 |
|
|
228 #define CYG_VECTOR_RESERVED_98 98 |
|
|
229 #define CYG_VECTOR_RESERVED_99 99 |
|
|
230 |
|
|
231 #define CYG_ISR_MIN 0 |
|
|
232 #define CYG_ISR_MAX 99 |
|
|
233 |
|
|
234 #define CYG_ISR_COUNT 100 |
|
|
235 |
|
|
236 #elif defined(CYG_HAL_MN10300_MN103002) |
|
|
237 |
|
|
238 // The decoded interrupts |
|
|
239 |
|
|
240 #define CYG_VECTOR_NMIRQ 0 |
|
|
241 #define CYG_VECTOR_WATCHDOG 1 |
|
|
242 #define CYG_VECTOR_SYSTEM_ERROR 2 |
|
|
243 #define CYG_VECTOR_RESERVED_3 3 |
|
|
244 |
|
|
245 #define CYG_VECTOR_RESERVED_4 4 |
|
|
246 #define CYG_VECTOR_RESERVED_5 5 |
|
|
247 #define CYG_VECTOR_RESERVED_6 6 |
|
|
248 #define CYG_VECTOR_RESERVED_7 7 |
|
|
249 |
|
|
250 #define CYG_VECTOR_TIMER_0 8 |
|
|
251 #define CYG_VECTOR_RESERVED_9 9 |
|
|
252 #define CYG_VECTOR_RESERVED_10 10 |
|
|
253 #define CYG_VECTOR_RESERVED_11 11 |
|
|
254 |
|
|
255 #define CYG_VECTOR_TIMER_1 12 |
|
|
256 #define CYG_VECTOR_RESERVED_13 13 |
|
|
257 #define CYG_VECTOR_RESERVED_14 14 |
|
|
258 #define CYG_VECTOR_RESERVED_15 15 |
|
|
259 |
|
|
260 #define CYG_VECTOR_TIMER_2 16 |
|
|
261 #define CYG_VECTOR_RESERVED_17 17 |
|
|
262 #define CYG_VECTOR_RESERVED_18 18 |
|
|
263 #define CYG_VECTOR_RESERVED_19 19 |
|
|
264 |
|
|
265 #define CYG_VECTOR_TIMER_3 20 |
|
|
266 #define CYG_VECTOR_RESERVED_21 21 |
|
|
267 #define CYG_VECTOR_RESERVED_22 22 |
|
|
268 #define CYG_VECTOR_RESERVED_23 23 |
|
|
269 |
|
|
270 #define CYG_VECTOR_TIMER_4 24 |
|
|
271 #define CYG_VECTOR_RESERVED_25 25 |
|
|
272 #define CYG_VECTOR_RESERVED_26 26 |
|
|
273 #define CYG_VECTOR_RESERVED_27 27 |
|
|
274 |
|
|
275 #define CYG_VECTOR_TIMER_5 28 |
|
|
276 #define CYG_VECTOR_RESERVED_29 29 |
|
|
277 #define CYG_VECTOR_RESERVED_30 30 |
|
|
278 #define CYG_VECTOR_RESERVED_31 31 |
|
|
279 |
|
|
280 #define CYG_VECTOR_TIMER_6 32 |
|
|
281 #define CYG_VECTOR_RESERVED_33 33 |
|
|
282 #define CYG_VECTOR_RESERVED_34 34 |
|
|
283 #define CYG_VECTOR_RESERVED_35 35 |
|
|
284 |
|
|
285 #define CYG_VECTOR_TIMER_6_COMPARE_A 36 |
|
|
286 #define CYG_VECTOR_RESERVED_37 37 |
|
|
287 #define CYG_VECTOR_RESERVED_38 38 |
|
|
288 #define CYG_VECTOR_RESERVED_39 39 |
|
|
289 |
|
|
290 #define CYG_VECTOR_TIMER_6_COMPARE_B 40 |
|
|
291 #define CYG_VECTOR_RESERVED_41 41 |
|
|
292 #define CYG_VECTOR_RESERVED_42 42 |
|
|
293 #define CYG_VECTOR_RESERVED_43 43 |
|
|
294 |
|
|
295 #define CYG_VECTOR_RESERVED_44 44 |
|
|
296 #define CYG_VECTOR_RESERVED_45 45 |
|
|
297 #define CYG_VECTOR_RESERVED_46 46 |
|
|
298 #define CYG_VECTOR_RESERVED_47 47 |
|
|
299 |
|
|
300 #define CYG_VECTOR_DMA0 48 |
|
|
301 #define CYG_VECTOR_RESERVED_49 49 |
|
|
302 #define CYG_VECTOR_RESERVED_50 50 |
|
|
303 #define CYG_VECTOR_RESERVED_51 51 |
|
|
304 |
|
|
305 #define CYG_VECTOR_DMA1 52 |
|
|
306 #define CYG_VECTOR_RESERVED_53 53 |
|
|
307 #define CYG_VECTOR_RESERVED_54 54 |
|
|
308 #define CYG_VECTOR_RESERVED_55 55 |
|
|
309 |
|
|
310 #define CYG_VECTOR_DMA2 56 |
|
|
311 #define CYG_VECTOR_RESERVED_57 57 |
|
|
312 #define CYG_VECTOR_RESERVED_58 58 |
|
|
313 #define CYG_VECTOR_RESERVED_59 59 |
|
|
314 |
|
|
315 #define CYG_VECTOR_DMA3 60 |
|
|
316 #define CYG_VECTOR_RESERVED_61 61 |
|
|
317 #define CYG_VECTOR_RESERVED_62 62 |
|
|
318 #define CYG_VECTOR_RESERVED_63 63 |
|
|
319 |
|
|
320 #define CYG_VECTOR_SERIAL_0_RX 64 |
|
|
321 #define CYG_VECTOR_RESERVED_65 65 |
|
|
322 #define CYG_VECTOR_RESERVED_66 66 |
|
|
323 #define CYG_VECTOR_RESERVED_67 67 |
|
|
324 |
|
|
325 #define CYG_VECTOR_SERIAL_0_TX 68 |
|
|
326 #define CYG_VECTOR_RESERVED_69 69 |
|
|
327 #define CYG_VECTOR_RESERVED_70 70 |
|
|
328 #define CYG_VECTOR_RESERVED_71 71 |
|
|
329 |
|
|
330 #define CYG_VECTOR_SERIAL_1_RX 72 |
|
|
331 #define CYG_VECTOR_RESERVED_73 73 |
|
|
332 #define CYG_VECTOR_RESERVED_74 74 |
|
|
333 #define CYG_VECTOR_RESERVED_75 75 |
|
|
334 |
|
|
335 #define CYG_VECTOR_SERIAL_1_TX 76 |
|
|
336 #define CYG_VECTOR_RESERVED_77 77 |
|
|
337 #define CYG_VECTOR_RESERVED_78 78 |
|
|
338 #define CYG_VECTOR_RESERVED_79 79 |
|
|
339 |
|
|
340 #define CYG_VECTOR_SERIAL_2_RX 80 |
|
|
341 #define CYG_VECTOR_RESERVED_81 81 |
|
|
342 #define CYG_VECTOR_RESERVED_82 82 |
|
|
343 #define CYG_VECTOR_RESERVED_83 83 |
|
|
344 |
|
|
345 #define CYG_VECTOR_SERIAL_2_TX 84 |
|
|
346 #define CYG_VECTOR_RESERVED_85 85 |
|
|
347 #define CYG_VECTOR_RESERVED_86 86 |
|
|
348 #define CYG_VECTOR_RESERVED_87 87 |
|
|
349 |
|
|
350 #define CYG_VECTOR_RESERVED_88 88 |
|
|
351 #define CYG_VECTOR_RESERVED_89 89 |
|
|
352 #define CYG_VECTOR_RESERVED_90 90 |
|
|
353 #define CYG_VECTOR_RESERVED_91 91 |
|
|
354 |
|
|
355 #define CYG_VECTOR_EXTERNAL_0 92 |
|
|
356 #define CYG_VECTOR_RESERVED_93 93 |
|
|
357 #define CYG_VECTOR_RESERVED_94 94 |
|
|
358 #define CYG_VECTOR_RESERVED_95 95 |
|
|
359 |
|
|
360 #define CYG_VECTOR_EXTERNAL_1 96 |
|
|
361 #define CYG_VECTOR_RESERVED_97 97 |
|
|
362 #define CYG_VECTOR_RESERVED_98 98 |
|
|
363 #define CYG_VECTOR_RESERVED_99 99 |
|
|
364 |
|
|
365 #define CYG_VECTOR_EXTERNAL_2 100 |
|
|
366 #define CYG_VECTOR_RESERVED_101 101 |
|
|
367 #define CYG_VECTOR_RESERVED_102 102 |
|
|
368 #define CYG_VECTOR_RESERVED_103 103 |
|
|
369 |
|
|
370 #define CYG_VECTOR_EXTERNAL_3 104 |
|
|
371 #define CYG_VECTOR_RESERVED_105 105 |
|
|
372 #define CYG_VECTOR_RESERVED_106 106 |
|
|
373 #define CYG_VECTOR_RESERVED_107 107 |
|
|
374 |
|
|
375 #define CYG_VECTOR_EXTERNAL_4 108 |
|
|
376 #define CYG_VECTOR_RESERVED_109 109 |
|
|
377 #define CYG_VECTOR_RESERVED_110 110 |
|
|
378 #define CYG_VECTOR_RESERVED_111 111 |
|
|
379 |
|
|
380 #define CYG_VECTOR_EXTERNAL_5 112 |
|
|
381 #define CYG_VECTOR_RESERVED_113 113 |
|
|
382 #define CYG_VECTOR_RESERVED_114 114 |
|
|
383 #define CYG_VECTOR_RESERVED_115 115 |
|
|
384 |
|
|
385 #define CYG_VECTOR_EXTERNAL_6 116 |
|
|
386 #define CYG_VECTOR_RESERVED_117 117 |
|
|
387 #define CYG_VECTOR_RESERVED_118 118 |
|
|
388 #define CYG_VECTOR_RESERVED_119 119 |
|
|
389 |
|
|
390 #define CYG_VECTOR_EXTERNAL_7 120 |
|
|
391 #define CYG_VECTOR_RESERVED_121 121 |
|
|
392 #define CYG_VECTOR_RESERVED_122 122 |
|
|
393 #define CYG_VECTOR_RESERVED_123 123 |
|
|
394 |
|
|
395 #define CYG_ISR_MIN 0 |
|
|
396 #define CYG_ISR_MAX 123 |
|
|
397 |
|
|
398 #define CYG_ISR_COUNT (3+((CYG_ISR_MAX+1)/4)) |
|
|
399 |
|
|
400 #endif |
|
|
401 |
|
|
402 // The vector used by the Real time clock |
|
|
403 |
|
|
404 #ifdef CYG_HAL_MN10300_SIM |
|
|
405 # define CYG_VECTOR_RTC CYG_VECTOR_TIMER_5 |
|
|
406 //# define CYG_VECTOR_RTC CYG_VECTOR_EXTERNAL_1 |
|
|
407 #else |
|
|
408 # ifdef CYG_HAL_MN10300_MN103000 |
|
|
409 # define CYG_VECTOR_RTC CYG_VECTOR_TIMER_8 |
|
|
410 # endif |
|
|
411 # ifdef CYG_HAL_MN10300_MN103002 |
|
|
412 # define CYG_VECTOR_RTC CYG_VECTOR_TIMER_5 |
|
|
413 # endif |
|
|
414 #endif |
|
|
415 |
|
|
416 //----------------------------------------------------------------------------- |
|
|
417 // Timer control registers. |
|
|
418 |
|
|
419 // On simulator we use simulated external interrupt |
|
|
420 |
|
|
421 #if defined(CYG_HAL_MN10300_MN103002) |
|
|
422 |
|
|
423 // On the mn103002 we use timers 4 and 5 |
|
|
424 |
|
|
425 #define TIMER4_CR 0x340010a0 |
|
|
426 #define TIMER4_BR 0x34001090 |
|
|
427 #define TIMER4_MD 0x34001080 |
|
|
428 |
|
|
429 #define TIMER5_CR 0x340010a2 |
|
|
430 #define TIMER5_BR 0x34001092 |
|
|
431 #define TIMER5_MD 0x34001082 |
|
|
432 |
|
|
433 #define TIMER_CR TIMER5_CR |
|
|
434 #define TIMER_BR TIMER5_BR |
|
|
435 #define TIMER_MD TIMER5_MD |
|
|
436 |
|
|
437 #define TIMER0_MD 0x34001000 |
|
|
438 #define TIMER0_BR 0x34001010 |
|
|
439 #define TIMER0_CR 0x34001020 |
|
|
440 |
|
|
441 #elif defined(CYG_HAL_MN10300_MN103000) |
|
|
442 |
|
|
443 // on the mn103000 we use timers 4 and 5 |
|
|
444 #define TIMER4_CR 0x340010a0 |
|
|
445 #define TIMER4_BR 0x34001090 |
|
|
446 #define TIMER4_MD 0x34001080 |
|
|
447 |
|
|
448 #define TIMER5_CR 0x340010a2 |
|
|
449 #define TIMER5_BR 0x34001092 |
|
|
450 #define TIMER5_MD 0x34001082 |
|
|
451 |
|
|
452 #define TIMER_CR TIMER5_CR |
|
|
453 #define TIMER_BR TIMER5_BR |
|
|
454 #define TIMER_MD TIMER5_MD |
|
|
455 |
|
|
456 #define TIMER0_MD 0x34001000 |
|
|
457 #define TIMER0_BR 0x34001010 |
|
|
458 #define TIMER0_CR 0x34001020 |
|
|
459 |
|
|
460 #endif |
|
|
461 |
|
|
462 //----------------------------------------------------------------------------- |
|
|
463 // Static data used by HAL |
|
|
464 |
|
|
465 // ISR tables |
|
|
466 externC volatile CYG_ADDRESS hal_interrupt_handlers[CYG_ISR_COUNT]; |
|
|
467 externC volatile CYG_ADDRWORD hal_interrupt_data[CYG_ISR_COUNT]; |
|
|
468 externC volatile CYG_ADDRESS hal_interrupt_objects[CYG_ISR_COUNT]; |
|
|
469 |
|
|
470 // VSR table |
|
|
471 externC volatile CYG_ADDRESS hal_vsr_table[CYG_VSR_COUNT]; |
|
|
472 |
|
|
473 // MN10300 interrupt control registers, mapped by linker script. |
|
|
474 externC volatile cyg_uint16 mn10300_interrupt_control[0x300/2]; |
|
|
475 |
|
|
476 //----------------------------------------------------------------------------- |
|
|
477 // Interrupt state storage |
|
|
478 |
|
|
479 typedef cyg_uint32 CYG_INTERRUPT_STATE; |
|
|
480 |
|
|
481 //----------------------------------------------------------------------------- |
|
|
482 // Interrupt control macros |
|
|
483 |
|
|
484 #define HAL_DISABLE_INTERRUPTS(_old_) \ |
|
|
485 asm volatile ( \ |
|
|
486 "mov psw,%0;" \ |
|
|
487 "mov 0xF7FF,d0;" \ |
|
|
488 "and %0,d0;" \ |
|
|
489 "mov d0,psw;" \ |
|
|
490 "and 0x0800,%0;" \ |
|
|
491 : "=d"(_old_) \ |
|
|
492 : \ |
|
|
493 : "d0" \ |
|
|
494 ); |
|
|
495 |
|
|
496 #define HAL_ENABLE_INTERRUPTS() \ |
|
|
497 asm volatile ( \ |
|
|
498 "mov psw,d0;" \ |
|
|
499 "or 0x0800,d0;" \ |
|
|
500 "mov d0,psw;" \ |
|
|
501 : \ |
|
|
502 : \ |
|
|
503 : "d0" \ |
|
|
504 ); |
|
|
505 |
|
|
506 #define HAL_RESTORE_INTERRUPTS(_old_) \ |
|
|
507 asm volatile ( \ |
|
|
508 "mov psw,d1;" \ |
|
|
509 "or %0,d1;" \ |
|
|
510 "mov d1,psw;" \ |
|
|
511 : \ |
|
|
512 : "d"(_old_) \ |
|
|
513 : "d1" \ |
|
|
514 ); |
|
|
515 |
|
|
516 #define HAL_QUERY_INTERRUPTS(_old_) \ |
|
|
517 asm volatile ( \ |
|
|
518 "mov psw,%0;" \ |
|
|
519 "and 0x0800,%0;" \ |
|
|
520 : "=d"(_old_) \ |
|
|
521 ); |
|
|
522 |
|
|
523 //----------------------------------------------------------------------------- |
|
|
524 // Translate a vector number into an ISR table index. |
|
|
525 // If we have chained interrupts we have just a single ISR per priority |
|
|
526 // level. On the MN103000 there are several interrupts per controller, |
|
|
527 // so we have to decode to one of 100 vectors. On the MN103002 there is |
|
|
528 // only one interrupt per controller, so we can have just one ISR per |
|
|
529 // controller, except for the NMI vectors which occupy the first 3 slots. |
|
|
530 |
|
|
531 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN |
|
|
532 |
|
|
533 #define HAL_TRANSLATE_VECTOR(_vector_,_index_) \ |
|
|
534 { \ |
|
|
535 /* ICRs are 16 bit regs at 32 bit spacing */ \ |
|
|
536 cyg_ucount16 _ix_ = ((_vector_)>>2)<<1; \ |
|
|
537 \ |
|
|
538 /* read the appropriate interrupt control register */ \ |
|
|
539 cyg_uint16 _icr_ = mn10300_interrupt_control[_ix_]; \ |
|
|
540 \ |
|
|
541 /* extract interrupt priority level */ \ |
|
|
542 _index_ = (_icr_ >> 12) & 0x7; \ |
|
|
543 } |
|
|
544 |
|
|
545 #else |
|
|
546 |
|
|
547 #if defined(CYG_HAL_MN10300_MN103000) |
|
|
548 |
|
|
549 #define HAL_TRANSLATE_VECTOR(_vector_,_index_) _index_ = (_vector_) |
|
|
550 |
|
|
551 #elif defined(CYG_HAL_MN10300_MN103002) |
|
|
552 |
|
|
553 //#define HAL_TRANSLATE_VECTOR(_vector_,_index_) _index_ = ((_vector_)>>2) |
|
|
554 |
|
|
555 #define HAL_TRANSLATE_VECTOR(_vector_,_index_) \ |
|
|
556 _index_ = (((_vector_)<=CYG_VECTOR_SYSTEM_ERROR) ? \ |
|
|
557 (_vector_) : \ |
|
|
558 (((_vector_)>>2)+CYG_VECTOR_RESERVED_3)) |
|
|
559 |
|
|
560 #endif |
|
|
561 |
|
|
562 #endif |
|
|
563 |
|
|
564 |
|
|
565 //----------------------------------------------------------------------------- |
|
|
566 // Interrupt and VSR attachment macros |
|
|
567 |
|
|
568 #define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_, _object_ ) \ |
|
|
569 { \ |
|
|
570 cyg_uint32 _index_; \ |
|
|
571 HAL_TRANSLATE_VECTOR(_vector_,_index_); \ |
|
|
572 \ |
|
|
573 if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)NULL ) \ |
|
|
574 { \ |
|
|
575 hal_interrupt_handlers[_index_] = (CYG_ADDRESS)_isr_; \ |
|
|
576 hal_interrupt_data[_index_] = (CYG_ADDRWORD)_data_; \ |
|
|
577 hal_interrupt_objects[_index_] = (CYG_ADDRESS)_object_; \ |
|
|
578 } \ |
|
|
579 } |
|
|
580 |
|
|
581 #define HAL_INTERRUPT_DETACH( _vector_, _isr_ ) \ |
|
|
582 { \ |
|
|
583 cyg_uint32 _index_; \ |
|
|
584 HAL_TRANSLATE_VECTOR(_vector_,_index_); \ |
|
|
585 \ |
|
|
586 if( hal_interrupt_handlers[_index_] == (CYG_ADDRESS)_isr_ ) \ |
|
|
587 { \ |
|
|
588 hal_interrupt_handlers[_index_] = (CYG_ADDRESS)NULL; \ |
|
|
589 hal_interrupt_data[_index_] = 0; \ |
|
|
590 hal_interrupt_objects[_index_] = 0; \ |
|
|
591 } \ |
|
|
592 } |
|
|
593 |
|
|
594 #define HAL_VSR_GET( _vector_, _pvsr_ ) \ |
|
|
595 *((CYG_ADDRESS *)_pvsr_) = hal_vsr_table[_vector_]; |
|
|
596 |
|
|
597 |
|
|
598 #define HAL_VSR_SET( _vector_, _vsr_, _poldvsr_ ) \ |
|
|
599 if( _poldvsr_ != NULL ) \ |
|
|
600 *(CYG_ADDRESS *)_poldvsr_ = hal_vsr_table[_vector_]; \ |
|
|
601 hal_vsr_table[_vector_] = (CYG_ADDRESS)_vsr_; |
|
|
602 |
|
|
603 |
|
|
604 //----------------------------------------------------------------------------- |
|
|
605 // Interrupt controller access |
|
|
606 // Read interrupt control registers back after writing to them. This |
|
|
607 // ensures that the written value is not sitting in the store buffers |
|
|
608 // when interrupts are re-enabled. |
|
|
609 #define HAL_INTERRUPT_MASK( _vector_ ) \ |
|
|
610 { \ |
|
|
611 /* ICRs are 16 bit regs at 32 bit spacing */ \ |
|
|
612 cyg_ucount16 _index_ = ((_vector_)>>2)<<1; \ |
|
|
613 \ |
|
|
614 /* read the appropriate interrupt control register */ \ |
|
|
615 cyg_uint16 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
616 \ |
|
|
617 /* clear interrupt enable bit for this vector */ \ |
|
|
618 _icr_ &= ~(0x0100<<((_vector_)&3)); \ |
|
|
619 \ |
|
|
620 /* restore the interrupt control register */ \ |
|
|
621 mn10300_interrupt_control[_index_] = _icr_; \ |
|
|
622 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
623 } |
|
|
624 |
|
|
625 #define HAL_INTERRUPT_UNMASK( _vector_ ) \ |
|
|
626 { \ |
|
|
627 /* ICRs are 16 bit regs at 32 bit spacing */ \ |
|
|
628 cyg_ucount16 _index_ = (_vector_>>2)<<1; \ |
|
|
629 \ |
|
|
630 /* read the appropriate interrupt control register */ \ |
|
|
631 cyg_uint16 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
632 \ |
|
|
633 /* set interrupt enable bit for this vector */ \ |
|
|
634 _icr_ |= (0x0100<<(_vector_&3)); \ |
|
|
635 \ |
|
|
636 /* restore the interrupt control register */ \ |
|
|
637 mn10300_interrupt_control[_index_] = _icr_; \ |
|
|
638 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
639 } |
|
|
640 |
|
|
641 #define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ ) \ |
|
|
642 { \ |
|
|
643 /* ICRs are 16 bit regs at 32 bit spacing */ \ |
|
|
644 cyg_ucount16 _index_ = ((_vector_)>>2)<<1; \ |
|
|
645 \ |
|
|
646 /* read the appropriate interrupt control register */ \ |
|
|
647 cyg_uint16 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
648 \ |
|
|
649 /* clear interrupt request bit for this vector */ \ |
|
|
650 _icr_ &= ~(0x0010<<((_vector_)&3)); \ |
|
|
651 \ |
|
|
652 /* set interrupt detect bit for this vector */ \ |
|
|
653 _icr_ |= (0x0001<<((_vector_)&3)); \ |
|
|
654 \ |
|
|
655 /* restore the interrupt control register */ \ |
|
|
656 mn10300_interrupt_control[_index_] = _icr_; \ |
|
|
657 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
658 } |
|
|
659 |
|
|
660 #define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ ) \ |
|
|
661 { \ |
|
|
662 cyg_vector _v_ = _vector_; \ |
|
|
663 /* adjust vector to bit offset in EXTMD */ \ |
|
|
664 _v_ -= CYG_VECTOR_EXTERNAL_0; \ |
|
|
665 _v_ >>= 1; \ |
|
|
666 \ |
|
|
667 cyg_uint16 _val_ = 0; \ |
|
|
668 \ |
|
|
669 /* set bits according to requirements */ \ |
|
|
670 if( _up_ ) _val_ |= 1; \ |
|
|
671 if( !(_level_) ) _val_ |= 2; \ |
|
|
672 \ |
|
|
673 /* get EXTMD */ \ |
|
|
674 cyg_uint16 _reg_ = mn10300_interrupt_control[0x180>>1]; \ |
|
|
675 \ |
|
|
676 /* clear old value and set new */ \ |
|
|
677 _reg_ &= ~(3<<_v_); \ |
|
|
678 _reg_ |= _val_<<_v_; \ |
|
|
679 \ |
|
|
680 /* restore EXTMD */ \ |
|
|
681 mn10300_interrupt_control[0x180>>1] = _reg_; \ |
|
|
682 } |
|
|
683 |
|
|
684 #define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ ) \ |
|
|
685 { \ |
|
|
686 /* ICRs are 16 bit regs at 32 bit spacing */ \ |
|
|
687 cyg_ucount16 _index_ = (_vector_>>2)<<1; \ |
|
|
688 \ |
|
|
689 /* read the appropriate interrupt control register */ \ |
|
|
690 cyg_uint16 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
691 \ |
|
|
692 /* set interrupt level for this group of vectors */ \ |
|
|
693 _icr_ &= 0x0FFF; \ |
|
|
694 _icr_ |= (_level_)<<12; \ |
|
|
695 \ |
|
|
696 /* restore the interrupt control register */ \ |
|
|
697 mn10300_interrupt_control[_index_] = _icr_; \ |
|
|
698 _icr_ = mn10300_interrupt_control[_index_]; \ |
|
|
699 } |
|
|
700 |
|
|
701 //----------------------------------------------------------------------------- |
|
|
702 // Clock control |
|
|
703 |
|
|
704 |
|
|
705 #if 0 // defined(CYG_HAL_MN10300_SIM) |
|
|
706 |
|
|
707 #define OEA_DEV 0x31000000 |
|
|
708 |
|
|
709 #define HAL_SWAP(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)| \ |
|
|
710 (((x)&0xff0000)>>8)|(((x)&0xff000000)>>24)) |
|
|
711 |
|
|
712 #define PAL_COUNTDOWN_TIMER 0x20 // one shot on IR0 |
|
|
713 #define PAL_COUNTDOWN_VALUE 0x24 |
|
|
714 #define PAL_PERIODIC_TIMER 0x28 // repeating on IR1 |
|
|
715 #define PAL_PERIODIC_VALUE 0x2c |
|
|
716 |
|
|
717 |
|
|
718 // IRQ1 set to receive clock intrs |
|
|
719 #define HAL_CLOCK_INITIALIZE( _period_ ) \ |
|
|
720 { \ |
|
|
721 volatile cyg_uint32 *timer = (cyg_uint32 *) \ |
|
|
722 (OEA_DEV + PAL_PERIODIC_TIMER); \ |
|
|
723 cyg_uint32 p = _period_; \ |
|
|
724 \ |
|
|
725 *timer = HAL_SWAP(p); \ |
|
|
726 } |
|
|
727 |
|
|
728 #elif defined(CYG_HAL_MN10300_MN103000) |
|
|
729 |
|
|
730 #define HAL_CLOCK_INITIALIZE( _period_ ) \ |
|
|
731 { \ |
|
|
732 volatile cyg_uint16 *timer_ctr = (cyg_uint16 *)TIMER_BR; \ |
|
|
733 volatile cyg_uint16 *timer_mode = (cyg_uint16 *)TIMER_MD; \ |
|
|
734 volatile cyg_uint8 *timer_a_mode = (cyg_uint8 *)0x34001084; \ |
|
|
735 \ |
|
|
736 *timer_a_mode = 0x04; \ |
|
|
737 \ |
|
|
738 *timer_ctr = 0xf000; \ |
|
|
739 \ |
|
|
740 *timer_mode = 0x0013; \ |
|
|
741 *timer_mode = 0x4013; \ |
|
|
742 *timer_mode = 0x0013; \ |
|
|
743 *timer_mode = 0x8013; \ |
|
|
744 } |
|
|
745 |
|
|
746 #elif defined(CYG_HAL_MN10300_MN103002) |
|
|
747 |
|
|
748 #define HAL_CLOCK_INITIALIZE( _period_ ) \ |
|
|
749 { \ |
|
|
750 volatile cyg_uint16 *timer4_br = (cyg_uint16 *)TIMER4_BR; \ |
|
|
751 volatile cyg_uint8 *timer4_md = (cyg_uint8 *)TIMER4_MD; \ |
|
|
752 volatile cyg_uint16 *timer5_br = (cyg_uint16 *)TIMER5_BR; \ |
|
|
753 volatile cyg_uint8 *timer5_md = (cyg_uint8 *)TIMER5_MD; \ |
|
|
754 \ |
|
|
755 /* Set timers 4 and 5 into cascade mode */ \ |
|
|
756 \ |
|
|
757 *timer5_br = (_period_)>>16; \ |
|
|
758 \ |
|
|
759 *timer5_md = 0x40; \ |
|
|
760 *timer5_md = 0x83; \ |
|
|
761 \ |
|
|
762 *timer4_br = (_period_)&0x0000FFFF; \ |
|
|
763 \ |
|
|
764 *timer4_md = 0x40; \ |
|
|
765 *timer4_md = 0x80; \ |
|
|
766 } |
|
|
767 |
|
|
768 #else |
|
|
769 |
|
|
770 #error Undefined MN10300 model |
|
|
771 |
|
|
772 #endif |
|
|
773 |
|
|
774 #define HAL_CLOCK_RESET( _vector_, _period_ ) |
|
|
775 |
|
|
776 #if 0 //def CYG_HAL_MN10300_SIM |
|
|
777 |
|
|
778 // This timer counts down, so subtract from set value. |
|
|
779 #define HAL_CLOCK_READ( _pvalue_ ) \ |
|
|
780 { \ |
|
|
781 volatile cyg_uint32 *timer = (cyg_uint32 *) \ |
|
|
782 (OEA_DEV + PAL_PERIODIC_TIMER); \ |
|
|
783 volatile cyg_uint32 *value = (cyg_uint32 *) \ |
|
|
784 (OEA_DEV + PAL_PERIODIC_VALUE); \ |
|
|
785 cyg_uint32 t,v; \ |
|
|
786 t = *timer; \ |
|
|
787 v = *value; \ |
|
|
788 *(_pvalue_) = HAL_SWAP(t) - HAL_SWAP(v); \ |
|
|
789 } |
|
|
790 |
|
|
791 #else // CYG_HAL_MN10300_SIM not |
|
|
792 #define HAL_CLOCK_READ( _pvalue_ ) \ |
|
|
793 { \ |
|
|
794 volatile cyg_uint16 *timer4_cr = (cyg_uint16 *)TIMER4_CR; \ |
|
|
795 volatile cyg_uint16 *timer5_cr = (cyg_uint16 *)TIMER5_CR; \ |
|
|
796 \ |
|
|
797 cyg_uint16 t5; \ |
|
|
798 cyg_uint16 t4; \ |
|
|
799 \ |
|
|
800 /* Loop reading the two timers until we can read t5 twice */ \ |
|
|
801 /* with the same value. This avoids getting silly times if */ \ |
|
|
802 /* the timers carry between reading the two regs. */ \ |
|
|
803 do { \ |
|
|
804 t5 = *timer5_cr; \ |
|
|
805 t4 = *timer4_cr; \ |
|
|
806 } while( t5 != *timer5_cr ); \ |
|
|
807 \ |
|
|
808 *(_pvalue_) = CYGNUM_KERNEL_COUNTERS_RTC_PERIOD - ((t5<<16) + t4); \ |
|
|
809 } |
|
|
810 #endif // CYG_HAL_MN10300_SIM |
|
|
811 //----------------------------------------------------------------------------- |
|
|
812 #endif // ifndef CYGONCE_HAL_HAL_INTR_H |
|
|
813 // End of hal_intr.h |