GadgetSeed  0.9.6
interrupt.c
[詳解]
1 /** @file
2  @brief STM32 仮想割り込みハンドラ
3 
4  @date 2013.03.10
5  @author Takashi SHUDO
6 */
7 
8 #include "interrupt.h"
9 #include "sysconfig.h"
10 #include "tkprintf.h"
11 #include "task/calltrace.h"
12 #include "task/task.h"
13 
14 //#define DEBUGKBITS 0x03
15 #include "dkprintf.h"
16 
17 
18 unsigned int last_int;
19 void *last_sp;
20 
21 typedef void (*inthdr)(void);
22 typedef void (*gs_inthdr)(unsigned int intnum, void *sp);
23 
24 int is_in_interrupt(void)
25 {
26  int regIPSR;
27 
28  asm("mrs %[result], ipsr" : [result] "=r" (regIPSR) : : );
29 
30  return regIPSR;
31 }
32 
33 static void unreg_inthdr(unsigned int intnum, void *sp)
34 {
35  SYSERR_PRINT("Unknown interrupt(%u).\n", intnum);
36 
37  disp_regs((union st_regs *)sp);
38 
39  while(1)
40  ;
41 }
42 
43 #define CFSR (*(volatile unsigned int *)0xE000ED28)
44 #define MMSR (*(volatile unsigned char *)0xE000ED28)
45 #define BFSR (*(volatile unsigned char *)0xE000ED29)
46 #define UFSR (*(volatile unsigned short *)0xE000ED2A)
47 #define HFSR (*(volatile unsigned int *)0xE000ED2C)
48 #define DFSR (*(volatile unsigned int *)0xE000ED30)
49 #define AFSR (*(volatile unsigned int *)0xE000ED3C)
50 
51 #define DHCSR (*(volatile unsigned int *)0xE000EDF0)
52 #define DCRSR (*(volatile unsigned int *)0xE000EDF4)
53 #define DCRDR (*(volatile unsigned int *)0xE000EDF8)
54 #define DEMCR (*(volatile unsigned int *)0xE000EDFC)
55 
56 void disp_debug_info(void)
57 {
58  tkprintf("CFSR = %08X\n", CFSR);
59  tkprintf(" MMSR = %02X\n", MMSR);
60  tkprintf(" BFSR = %02X\n", BFSR);
61  tkprintf(" UFSR = %04X\n", UFSR);
62  tkprintf("HFSR = %08X\n", HFSR);
63  tkprintf("DFSR = %08X\n", DFSR);
64  tkprintf("AFSR = %08X\n", AFSR);
65 
66  tkprintf("DHCSR = %08X\n", DHCSR);
67  tkprintf("DCRSR = %08X\n", DCRSR);
68  tkprintf("DCRDR = %08X\n", DCRDR);
69  tkprintf("DEMCR = %08X\n", DEMCR);
70 
71  tkprintf("Last Int = %02X(%d)\n", (int)last_int, (int)last_int);
72  tkprintf("Last SP = %08X\n", (int)last_sp);
73 }
74 
75 
76 void fault_inthdr(unsigned int intnum, void *sp)
77 {
78  switch(intnum) {
79  case 3:
80  SYSERR_PRINT("Hard Fault Interrupt(%d).\n", intnum);
81  break;
82 
83  case 4:
84  SYSERR_PRINT("Mem Manage Interrupt(%d).\n", intnum);
85  break;
86 
87  case 5:
88  SYSERR_PRINT("Buf Fault Interrupt(%d).\n", intnum);
89  break;
90 
91  case 6:
92  SYSERR_PRINT("Usage Fault Interrupt(%d).\n", intnum);
93  break;
94 
95  default:
96  SYSERR_PRINT("??? Interrupt(%d).\n", intnum);
97  break;
98  }
99 
100  disp_task_info();
101 
102  disp_regs((union st_regs *)sp);
103 
104  disp_debug_info();
105 
106  print_task();
107 
108  print_stack();
109 
110  print_queues();
111 
112  print_calltrace();
113 
114  while(1)
115  ;
116 }
117 
118 void ur_inthdr_000(unsigned int intnum, void *sp){unreg_inthdr(0,sp);}
119 void ur_inthdr_001(unsigned int intnum, void *sp){unreg_inthdr(1,sp);}
120 void ur_inthdr_002(unsigned int intnum, void *sp){unreg_inthdr(2,sp);}
121 void ur_inthdr_003(unsigned int intnum, void *sp){unreg_inthdr(3,sp);}
122 void ur_inthdr_004(unsigned int intnum, void *sp){unreg_inthdr(4,sp);}
123 void ur_inthdr_005(unsigned int intnum, void *sp){unreg_inthdr(5,sp);}
124 void ur_inthdr_006(unsigned int intnum, void *sp){unreg_inthdr(6,sp);}
125 void ur_inthdr_007(unsigned int intnum, void *sp){unreg_inthdr(7,sp);}
126 void ur_inthdr_008(unsigned int intnum, void *sp){unreg_inthdr(8,sp);}
127 void ur_inthdr_009(unsigned int intnum, void *sp){unreg_inthdr(9,sp);}
128 void ur_inthdr_010(unsigned int intnum, void *sp){unreg_inthdr(10,sp);}
129 void ur_inthdr_011(unsigned int intnum, void *sp){unreg_inthdr(11,sp);}
130 void ur_inthdr_012(unsigned int intnum, void *sp){unreg_inthdr(12,sp);}
131 void ur_inthdr_013(unsigned int intnum, void *sp){unreg_inthdr(13,sp);}
132 void ur_inthdr_014(unsigned int intnum, void *sp){unreg_inthdr(14,sp);}
133 void ur_inthdr_015(unsigned int intnum, void *sp){unreg_inthdr(15,sp);}
134 void ur_inthdr_016(unsigned int intnum, void *sp){unreg_inthdr(16,sp);}
135 void ur_inthdr_017(unsigned int intnum, void *sp){unreg_inthdr(17,sp);}
136 void ur_inthdr_018(unsigned int intnum, void *sp){unreg_inthdr(18,sp);}
137 void ur_inthdr_019(unsigned int intnum, void *sp){unreg_inthdr(19,sp);}
138 void ur_inthdr_020(unsigned int intnum, void *sp){unreg_inthdr(20,sp);}
139 void ur_inthdr_021(unsigned int intnum, void *sp){unreg_inthdr(21,sp);}
140 void ur_inthdr_022(unsigned int intnum, void *sp){unreg_inthdr(22,sp);}
141 void ur_inthdr_023(unsigned int intnum, void *sp){unreg_inthdr(23,sp);}
142 void ur_inthdr_024(unsigned int intnum, void *sp){unreg_inthdr(24,sp);}
143 void ur_inthdr_025(unsigned int intnum, void *sp){unreg_inthdr(25,sp);}
144 void ur_inthdr_026(unsigned int intnum, void *sp){unreg_inthdr(26,sp);}
145 void ur_inthdr_027(unsigned int intnum, void *sp){unreg_inthdr(27,sp);}
146 void ur_inthdr_028(unsigned int intnum, void *sp){unreg_inthdr(28,sp);}
147 void ur_inthdr_029(unsigned int intnum, void *sp){unreg_inthdr(29,sp);}
148 void ur_inthdr_030(unsigned int intnum, void *sp){unreg_inthdr(30,sp);}
149 void ur_inthdr_031(unsigned int intnum, void *sp){unreg_inthdr(31,sp);}
150 void ur_inthdr_032(unsigned int intnum, void *sp){unreg_inthdr(32,sp);}
151 void ur_inthdr_033(unsigned int intnum, void *sp){unreg_inthdr(33,sp);}
152 void ur_inthdr_034(unsigned int intnum, void *sp){unreg_inthdr(34,sp);}
153 void ur_inthdr_035(unsigned int intnum, void *sp){unreg_inthdr(35,sp);}
154 void ur_inthdr_036(unsigned int intnum, void *sp){unreg_inthdr(36,sp);}
155 void ur_inthdr_037(unsigned int intnum, void *sp){unreg_inthdr(37,sp);}
156 void ur_inthdr_038(unsigned int intnum, void *sp){unreg_inthdr(38,sp);}
157 void ur_inthdr_039(unsigned int intnum, void *sp){unreg_inthdr(39,sp);}
158 void ur_inthdr_040(unsigned int intnum, void *sp){unreg_inthdr(40,sp);}
159 void ur_inthdr_041(unsigned int intnum, void *sp){unreg_inthdr(41,sp);}
160 void ur_inthdr_042(unsigned int intnum, void *sp){unreg_inthdr(42,sp);}
161 void ur_inthdr_043(unsigned int intnum, void *sp){unreg_inthdr(43,sp);}
162 void ur_inthdr_044(unsigned int intnum, void *sp){unreg_inthdr(44,sp);}
163 void ur_inthdr_045(unsigned int intnum, void *sp){unreg_inthdr(45,sp);}
164 void ur_inthdr_046(unsigned int intnum, void *sp){unreg_inthdr(46,sp);}
165 void ur_inthdr_047(unsigned int intnum, void *sp){unreg_inthdr(47,sp);}
166 void ur_inthdr_048(unsigned int intnum, void *sp){unreg_inthdr(48,sp);}
167 void ur_inthdr_049(unsigned int intnum, void *sp){unreg_inthdr(49,sp);}
168 void ur_inthdr_050(unsigned int intnum, void *sp){unreg_inthdr(50,sp);}
169 void ur_inthdr_051(unsigned int intnum, void *sp){unreg_inthdr(51,sp);}
170 void ur_inthdr_052(unsigned int intnum, void *sp){unreg_inthdr(52,sp);}
171 void ur_inthdr_053(unsigned int intnum, void *sp){unreg_inthdr(53,sp);}
172 void ur_inthdr_054(unsigned int intnum, void *sp){unreg_inthdr(54,sp);}
173 void ur_inthdr_055(unsigned int intnum, void *sp){unreg_inthdr(55,sp);}
174 void ur_inthdr_056(unsigned int intnum, void *sp){unreg_inthdr(56,sp);}
175 void ur_inthdr_057(unsigned int intnum, void *sp){unreg_inthdr(57,sp);}
176 void ur_inthdr_058(unsigned int intnum, void *sp){unreg_inthdr(58,sp);}
177 void ur_inthdr_059(unsigned int intnum, void *sp){unreg_inthdr(59,sp);}
178 void ur_inthdr_060(unsigned int intnum, void *sp){unreg_inthdr(60,sp);}
179 void ur_inthdr_061(unsigned int intnum, void *sp){unreg_inthdr(61,sp);}
180 void ur_inthdr_062(unsigned int intnum, void *sp){unreg_inthdr(62,sp);}
181 void ur_inthdr_063(unsigned int intnum, void *sp){unreg_inthdr(63,sp);}
182 void ur_inthdr_064(unsigned int intnum, void *sp){unreg_inthdr(64,sp);}
183 void ur_inthdr_065(unsigned int intnum, void *sp){unreg_inthdr(65,sp);}
184 void ur_inthdr_066(unsigned int intnum, void *sp){unreg_inthdr(66,sp);}
185 void ur_inthdr_067(unsigned int intnum, void *sp){unreg_inthdr(67,sp);}
186 void ur_inthdr_068(unsigned int intnum, void *sp){unreg_inthdr(68,sp);}
187 void ur_inthdr_069(unsigned int intnum, void *sp){unreg_inthdr(69,sp);}
188 void ur_inthdr_070(unsigned int intnum, void *sp){unreg_inthdr(70,sp);}
189 void ur_inthdr_071(unsigned int intnum, void *sp){unreg_inthdr(71,sp);}
190 void ur_inthdr_072(unsigned int intnum, void *sp){unreg_inthdr(72,sp);}
191 void ur_inthdr_073(unsigned int intnum, void *sp){unreg_inthdr(73,sp);}
192 void ur_inthdr_074(unsigned int intnum, void *sp){unreg_inthdr(74,sp);}
193 void ur_inthdr_075(unsigned int intnum, void *sp){unreg_inthdr(75,sp);}
194 void ur_inthdr_076(unsigned int intnum, void *sp){unreg_inthdr(76,sp);}
195 void ur_inthdr_077(unsigned int intnum, void *sp){unreg_inthdr(77,sp);}
196 void ur_inthdr_078(unsigned int intnum, void *sp){unreg_inthdr(78,sp);}
197 void ur_inthdr_079(unsigned int intnum, void *sp){unreg_inthdr(79,sp);}
198 void ur_inthdr_080(unsigned int intnum, void *sp){unreg_inthdr(80,sp);}
199 void ur_inthdr_081(unsigned int intnum, void *sp){unreg_inthdr(81,sp);}
200 void ur_inthdr_082(unsigned int intnum, void *sp){unreg_inthdr(82,sp);}
201 void ur_inthdr_083(unsigned int intnum, void *sp){unreg_inthdr(83,sp);}
202 void ur_inthdr_084(unsigned int intnum, void *sp){unreg_inthdr(84,sp);}
203 void ur_inthdr_085(unsigned int intnum, void *sp){unreg_inthdr(85,sp);}
204 void ur_inthdr_086(unsigned int intnum, void *sp){unreg_inthdr(86,sp);}
205 void ur_inthdr_087(unsigned int intnum, void *sp){unreg_inthdr(87,sp);}
206 void ur_inthdr_088(unsigned int intnum, void *sp){unreg_inthdr(88,sp);}
207 void ur_inthdr_089(unsigned int intnum, void *sp){unreg_inthdr(89,sp);}
208 void ur_inthdr_090(unsigned int intnum, void *sp){unreg_inthdr(90,sp);}
209 void ur_inthdr_091(unsigned int intnum, void *sp){unreg_inthdr(91,sp);}
210 void ur_inthdr_092(unsigned int intnum, void *sp){unreg_inthdr(92,sp);}
211 void ur_inthdr_093(unsigned int intnum, void *sp){unreg_inthdr(93,sp);}
212 void ur_inthdr_094(unsigned int intnum, void *sp){unreg_inthdr(94,sp);}
213 void ur_inthdr_095(unsigned int intnum, void *sp){unreg_inthdr(95,sp);}
214 void ur_inthdr_096(unsigned int intnum, void *sp){unreg_inthdr(96,sp);}
215 void ur_inthdr_097(unsigned int intnum, void *sp){unreg_inthdr(97,sp);}
216 void ur_inthdr_098(unsigned int intnum, void *sp){unreg_inthdr(98,sp);}
217 void ur_inthdr_099(unsigned int intnum, void *sp){unreg_inthdr(99,sp);}
218 void ur_inthdr_100(unsigned int intnum, void *sp){unreg_inthdr(100,sp);}
219 void ur_inthdr_101(unsigned int intnum, void *sp){unreg_inthdr(101,sp);}
220 void ur_inthdr_102(unsigned int intnum, void *sp){unreg_inthdr(102,sp);}
221 void ur_inthdr_103(unsigned int intnum, void *sp){unreg_inthdr(103,sp);}
222 void ur_inthdr_104(unsigned int intnum, void *sp){unreg_inthdr(104,sp);}
223 void ur_inthdr_105(unsigned int intnum, void *sp){unreg_inthdr(105,sp);}
224 void ur_inthdr_106(unsigned int intnum, void *sp){unreg_inthdr(106,sp);}
225 void ur_inthdr_107(unsigned int intnum, void *sp){unreg_inthdr(107,sp);}
226 void ur_inthdr_108(unsigned int intnum, void *sp){unreg_inthdr(108,sp);}
227 void ur_inthdr_109(unsigned int intnum, void *sp){unreg_inthdr(109,sp);}
228 void ur_inthdr_110(unsigned int intnum, void *sp){unreg_inthdr(110,sp);}
229 void ur_inthdr_111(unsigned int intnum, void *sp){unreg_inthdr(111,sp);}
230 void ur_inthdr_112(unsigned int intnum, void *sp){unreg_inthdr(112,sp);}
231 void ur_inthdr_113(unsigned int intnum, void *sp){unreg_inthdr(113,sp);}
232 void ur_inthdr_114(unsigned int intnum, void *sp){unreg_inthdr(114,sp);}
233 void ur_inthdr_115(unsigned int intnum, void *sp){unreg_inthdr(115,sp);}
234 void ur_inthdr_116(unsigned int intnum, void *sp){unreg_inthdr(116,sp);}
235 void ur_inthdr_117(unsigned int intnum, void *sp){unreg_inthdr(117,sp);}
236 void ur_inthdr_118(unsigned int intnum, void *sp){unreg_inthdr(118,sp);}
237 void ur_inthdr_119(unsigned int intnum, void *sp){unreg_inthdr(119,sp);}
238 void ur_inthdr_120(unsigned int intnum, void *sp){unreg_inthdr(120,sp);}
239 void ur_inthdr_121(unsigned int intnum, void *sp){unreg_inthdr(121,sp);}
240 void ur_inthdr_122(unsigned int intnum, void *sp){unreg_inthdr(122,sp);}
241 void ur_inthdr_123(unsigned int intnum, void *sp){unreg_inthdr(123,sp);}
242 void ur_inthdr_124(unsigned int intnum, void *sp){unreg_inthdr(124,sp);}
243 void ur_inthdr_125(unsigned int intnum, void *sp){unreg_inthdr(125,sp);}
244 
245 extern void _endof_stack();
246 extern void start(void);
247 
248 static const gs_inthdr init_gs_inthdr_table[MAXVECT] = {
249  ur_inthdr_000,
250  ur_inthdr_001,
251  ur_inthdr_002,
252  ur_inthdr_003,
253  ur_inthdr_004,
254  ur_inthdr_005,
255  ur_inthdr_006,
256  ur_inthdr_007,
257  ur_inthdr_008,
258  ur_inthdr_009,
259  ur_inthdr_010,
260  ur_inthdr_011,
261  ur_inthdr_012,
262  ur_inthdr_013,
263  ur_inthdr_014,
264  ur_inthdr_015,
265  ur_inthdr_016,
266  ur_inthdr_017,
267  ur_inthdr_018,
268  ur_inthdr_019,
269  ur_inthdr_020,
270  ur_inthdr_021,
271  ur_inthdr_022,
272  ur_inthdr_023,
273  ur_inthdr_024,
274  ur_inthdr_025,
275  ur_inthdr_026,
276  ur_inthdr_027,
277  ur_inthdr_028,
278  ur_inthdr_029,
279  ur_inthdr_030,
280  ur_inthdr_031,
281  ur_inthdr_032,
282  ur_inthdr_033,
283  ur_inthdr_034,
284  ur_inthdr_035,
285  ur_inthdr_036,
286  ur_inthdr_037,
287  ur_inthdr_038,
288  ur_inthdr_039,
289  ur_inthdr_040,
290  ur_inthdr_041,
291  ur_inthdr_042,
292  ur_inthdr_043,
293  ur_inthdr_044,
294  ur_inthdr_045,
295  ur_inthdr_046,
296  ur_inthdr_047,
297  ur_inthdr_048,
298  ur_inthdr_049,
299  ur_inthdr_050,
300  ur_inthdr_051,
301  ur_inthdr_052,
302  ur_inthdr_053,
303  ur_inthdr_054,
304  ur_inthdr_055,
305  ur_inthdr_056,
306  ur_inthdr_057,
307  ur_inthdr_058,
308  ur_inthdr_059,
309  ur_inthdr_060,
310  ur_inthdr_061,
311  ur_inthdr_062,
312  ur_inthdr_063,
313  ur_inthdr_064,
314  ur_inthdr_065,
315  ur_inthdr_066,
316  ur_inthdr_067,
317  ur_inthdr_068,
318  ur_inthdr_069,
319  ur_inthdr_070,
320  ur_inthdr_071,
321  ur_inthdr_072,
322  ur_inthdr_073,
323  ur_inthdr_074,
324  ur_inthdr_075,
325  ur_inthdr_076,
326  ur_inthdr_077,
327  ur_inthdr_078,
328  ur_inthdr_079,
329  ur_inthdr_080,
330  ur_inthdr_081,
331  ur_inthdr_082,
332  ur_inthdr_083,
333  ur_inthdr_084,
334  ur_inthdr_085,
335  ur_inthdr_086,
336  ur_inthdr_087,
337  ur_inthdr_088,
338  ur_inthdr_089,
339  ur_inthdr_090,
340  ur_inthdr_091,
341  ur_inthdr_092,
342  ur_inthdr_093,
343  ur_inthdr_094,
344  ur_inthdr_095,
345  ur_inthdr_096,
346  ur_inthdr_097,
347  ur_inthdr_098,
348  ur_inthdr_099,
349  ur_inthdr_100,
350  ur_inthdr_101,
351  ur_inthdr_102,
352  ur_inthdr_103,
353  ur_inthdr_104,
354  ur_inthdr_105,
355  ur_inthdr_106,
356  ur_inthdr_107,
357  ur_inthdr_108,
358  ur_inthdr_109,
359  ur_inthdr_110,
360  ur_inthdr_111,
361  ur_inthdr_112,
362  ur_inthdr_113,
363  ur_inthdr_114,
364  ur_inthdr_115,
365  ur_inthdr_116,
366  ur_inthdr_117,
367  ur_inthdr_118,
368  ur_inthdr_119,
369  ur_inthdr_120,
370  ur_inthdr_121,
371  ur_inthdr_122,
372  ur_inthdr_123,
373  ur_inthdr_124,
374  ur_inthdr_125,
375 };
376 
377 extern void int000(void);
378 extern void int001(void);
379 extern void int002(void);
380 extern void int003(void);
381 extern void int004(void);
382 extern void int005(void);
383 extern void int006(void);
384 extern void int007(void);
385 extern void int008(void);
386 extern void int009(void);
387 extern void int010(void);
388 extern void int011(void);
389 extern void int012(void);
390 extern void int013(void);
391 extern void int014(void);
392 extern void int015(void);
393 extern void int016(void);
394 extern void int017(void);
395 extern void int018(void);
396 extern void int019(void);
397 extern void int020(void);
398 extern void int021(void);
399 extern void int022(void);
400 extern void int023(void);
401 extern void int024(void);
402 extern void int025(void);
403 extern void int026(void);
404 extern void int027(void);
405 extern void int028(void);
406 extern void int029(void);
407 extern void int030(void);
408 extern void int031(void);
409 extern void int032(void);
410 extern void int033(void);
411 extern void int034(void);
412 extern void int035(void);
413 extern void int036(void);
414 extern void int037(void);
415 extern void int038(void);
416 extern void int039(void);
417 extern void int040(void);
418 extern void int041(void);
419 extern void int042(void);
420 extern void int043(void);
421 extern void int044(void);
422 extern void int045(void);
423 extern void int046(void);
424 extern void int047(void);
425 extern void int048(void);
426 extern void int049(void);
427 extern void int050(void);
428 extern void int051(void);
429 extern void int052(void);
430 extern void int053(void);
431 extern void int054(void);
432 extern void int055(void);
433 extern void int056(void);
434 extern void int057(void);
435 extern void int058(void);
436 extern void int059(void);
437 extern void int060(void);
438 extern void int061(void);
439 extern void int062(void);
440 extern void int063(void);
441 extern void int064(void);
442 extern void int065(void);
443 extern void int066(void);
444 extern void int067(void);
445 extern void int068(void);
446 extern void int069(void);
447 extern void int070(void);
448 extern void int071(void);
449 extern void int072(void);
450 extern void int073(void);
451 extern void int074(void);
452 extern void int075(void);
453 extern void int076(void);
454 extern void int077(void);
455 extern void int078(void);
456 extern void int079(void);
457 extern void int080(void);
458 extern void int081(void);
459 extern void int082(void);
460 extern void int083(void);
461 extern void int084(void);
462 extern void int085(void);
463 extern void int086(void);
464 extern void int087(void);
465 extern void int088(void);
466 extern void int089(void);
467 extern void int090(void);
468 extern void int091(void);
469 extern void int092(void);
470 extern void int093(void);
471 extern void int094(void);
472 extern void int095(void);
473 extern void int096(void);
474 extern void int097(void);
475 extern void int098(void);
476 extern void int099(void);
477 extern void int100(void);
478 extern void int101(void);
479 extern void int102(void);
480 extern void int103(void);
481 extern void int104(void);
482 extern void int105(void);
483 extern void int106(void);
484 extern void int107(void);
485 extern void int108(void);
486 extern void int109(void);
487 extern void int110(void);
488 extern void int111(void);
489 extern void int112(void);
490 extern void int113(void);
491 extern void int114(void);
492 extern void int115(void);
493 extern void int116(void);
494 extern void int117(void);
495 extern void int118(void);
496 extern void int119(void);
497 extern void int120(void);
498 extern void int121(void);
499 extern void int122(void);
500 extern void int123(void);
501 extern void int124(void);
502 extern void int125(void);
503 
504 const inthdr init_inthdr_table[MAXVECT] __attribute__ ((section("vect"))) = {
505  _endof_stack,
506  start,
507  int002, // 0x00000008 2 NMI
508  int003, // 0x0000000c 3 HardFault
509  int004, // 0x00000010 4 MemManage
510  int005, // 0x00000014 5 BusFault
511  int006, // 0x00000018 6 UsageFault
512  int007, // 0x0000001c 7 Reserved
513  int008, // 0x00000020 8 Reserved
514  int009, // 0x00000024 9 Reserved
515  int010, // 0x00000028 10 Reserved
516  int011, // 0x0000002c 11 SVCall
517  int012, // 0x00000030 12 Debug Monitor
518  int013, // 0x00000034 13 Reserved
519  int014, // 0x00000038 14 PendSV
520  int015, // 0x0000003c 15 SysTick
521  int016, // 0x00000040 16 WWDG
522  int017, // 0x00000044 17 PVD
523  int018, // 0x00000048 18 TAMP_STAMP
524  int019, // 0x0000004c 19 RTC_WKUP
525  int020, // 0x00000050 20 FLASH
526  int021, // 0x00000054 21 RCC
527  int022, // 0x00000058 22 EXTI0
528  int023, // 0x0000005c 23 EXTI1
529  int024, // 0x00000060 24 EXTI2
530  int025, // 0x00000064 25 EXTI3
531  int026, // 0x00000068 26 EXTI4
532  int027, // 0x0000006c 27 DMA1_Stream0
533  int028, // 0x00000070 24 DMA1_Stream1
534  int029, // 0x00000074 29 DMA1_Stream2
535  int030, // 0x00000078 30 DMA1_Stream3
536  int031, // 0x0000007c 31 DMA1_Stream4
537  int032, // 0x00000080 32 DMA1_Stream5
538  int033, // 0x00000084 33 DMA1_Stream6
539  int034, // 0x00000088 34 ADC
540  int035, // 0x0000008c 35 CAN1_TX
541  int036, // 0x00000090 36 CAN1_RX0
542  int037, // 0x00000094 37 CAN1_RX1
543  int038, // 0x00000098 38 CAN1_SCE
544  int039, // 0x0000009c 39 EXTI9_5
545  int040, // 0x000000a0 40 TIM1_BRK_TIM9 (0xa0)
546  int041, // 0x000000a4 41 TIM1_UP_TIM10
547  int042, // 0x000000a8 42 TIM1_TRG_COM_TIM11
548  int043, // 0x000000ac 43 TIM1_CC
549  int044, // 0x000000b0 44 TIM2
550  int045, // 0x000000b4 45 TIM3
551  int046, // 0x000000b8 46 TIM4
552  int047, // 0x000000cc 47 I2C1_EV
553  int048, // 0x000000c0 48 I2C1_ER
554  int049, // 0x000000c4 49 I2C2_EV
555  int050, // 0x000000c8 50 I2C2_ER
556  int051, // 0x000000cc 51 SPI1
557  int052, // 0x000000d0 52 SPI2
558  int053, // 0x000000d4 53 USART1
559  int054, // 0x000000d8 54 USART2
560  int055, // 0x000000dc 55 USART3
561  int056, // 0x000000e0 56 EXTI15_10
562  int057, // 0x000000e4 57 RTC_Alarm
563  int058, // 0x000000e8 58 OTG_FS_WKUP
564  int059, // 0x000000ec 59 TIM8_BRK_TIM12
565  int060, // 0x000000f0 60 TIM8_UP_TIM13
566  int061, // 0x000000f4 61 TIM8_TRG_COM_TIM14
567  int062, // 0x000000f8 62 TIM8_CC
568  int063, // 0x000000fc 63 DMA1_Stream7
569  int064, // 0x00000100 64 FSMC
570  int065, // 0x00000104 65 SDIO
571  int066, // 0x00000108 66 TIM5
572  int067, // 0x0000010c 67 SPI3
573  int068, // 0x00000110 68 USART4
574  int069, // 0x00000114 69 USART5
575  int070, // 0x00000118 70 TIM6_DAC
576  int071, // 0x0000011c 71 TIM7
577  int072, // 0x00000120 72 DMA2_Stream0
578  int073, // 0x00000124 73 DMA2_Stream1
579  int074, // 0x00000128 74 DMA2_Stream2
580  int075, // 0x0000012c 75 DMA2_Stream3
581  int076, // 0x00000130 76 DMA2_Stream4
582  int077, // 0x00000134 77 ETH
583  int078, // 0x00000138 78 ETH_WKUP
584  int079, // 0x0000013c 79 CAN2_TX
585  int080, // 0x00000140 80 CAN2_RX0
586  int081, // 0x00000144 81 CAN2_RX1
587  int082, // 0x00000148 82 CAN2_SCE
588  int083, // 0x0000014c 83 OTG_FS
589  int084, // 0x00000150 84 DMA2_Stream5
590  int085, // 0x00000154 85 DMA2_Stream6
591  int086, // 0x00000158 86 DMA2_Stream7
592  int087, // 0x0000015c 87 USART6
593  int088, // 0x00000160 88 I2C3_EV
594  int089, // 0x00000164 89 I2C3_ER
595  int090, // 0x00000168 90 OTG_HS_EP1_OUT
596  int091, // 0x0000016c 91 OTG_HS_EP1_IN
597  int092, // 0x00000170 92 OTG_HS_WKUP
598  int093, // 0x00000174 93 OTG_HS
599  int094, // 0x00000178 94 DCMI
600  int095, // 0x0000017c 95 CRYP
601  int096, // 0x00000180 96 HASH_RNG
602  int097, // 0x00000184 97 FPU
603  int098,
604  int099,
605  int100,
606  int101,
607  int102,
608  int103,
609  int104,
610  int105,
611  int106,
612  int107,
613  int108,
614  int109,
615  int110,
616  int111,
617  int112,
618  int113,
619  int114,
620  int115,
621  int116,
622  int117,
623  int118,
624  int119,
625  int120,
626  int121,
627  int122,
628  int123,
629  int124,
630  int125,
631 };
632 
633 gs_inthdr inthdr_table[MAXVECT];
634 
635 void init_interrupt_vector(void)
636 {
637  int i;
638 
639  for(i=0; i<MAXVECT; i++) {
640  inthdr_table[i] = init_gs_inthdr_table[i];
641  }
642 
643 // inthdr_table[3] = fault_inthdr;
644 }
645 
646 int register_interrupt(unsigned short vectnum,
647  void (* func)(unsigned int intnum, void *sp))
648 {
649  if(inthdr_table[vectnum] == init_gs_inthdr_table[vectnum]) {
650  inthdr_table[vectnum] = func;
651  } else {
652  SYSERR_PRINT("Interrupt Vector %d allready registered.\n",
653  vectnum);
654  return -1;
655  }
656 
657  return 0;
658 }
659 
660 int unregister_interrupt(unsigned short vectnum)
661 {
662  inthdr_table[vectnum] = init_gs_inthdr_table[vectnum];
663 
664  return 0;
665 }
666 
667 #ifdef GSC_KERNEL_ENABLE_INTERRUPT_COUNT // $gsc カーネル割込カウンタを有効にする
668 static unsigned int interrupt_count[MAXVECT];
669 
670 int get_interrupt_count(int intnum)
671 {
672  if(inthdr_table[intnum] == init_gs_inthdr_table[intnum]) {
673  return -1;
674  } else {
675  return (int)interrupt_count[intnum];
676  }
677 }
678 #endif
679 
680 void interrupt_func(unsigned int intnum, void *sp)
681 {
682  void (* func)(unsigned int in, void *s);
683 
684  DKPRINTF(0x04, "int = %u\n", intnum);
685 
686 #ifdef GSC_KERNEL_ENABLE_INTERRUPT_COUNT
687  interrupt_count[intnum] ++;
688 #endif
689 
690  last_int = intnum;
691  last_sp = sp;
692 
693  func = inthdr_table[intnum];
694 
695  (* func)(intnum, sp);
696 }
Cortex-M3 MCU レジスタ定義
Definition: asm-Cortex-M3.h:22
int tkprintf(const char *fmt,...)
非タスクコンテキスト実行用メッセージ出力
Definition: tkprintf.c:100
カーネル用機能限定printf
割り込みハンドラ
デバッグ用システムコールトレース
タスク制御
カーネル、ドライバ(非タスク)デバッグ用マクロ