MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_hw_idt_init

Function rt_hw_idt_init

libcpu/ia32/trap.c:39–70  ·  view source on GitHub ↗

* this function initializes the interrupt descript table * */

Source from the content-addressed store, hash-verified

37 *
38 */
39void rt_hw_idt_init(void)
40{
41 extern void Xdefault(void);
42 int i, j, func;
43
44 // install a default handler
45 for (i = 0; i < sizeof(idt)/sizeof(idt[0]); i++)
46 SETGATE(idt[i], 0, GD_KT, &Xdefault, 0);
47
48 /*install trap handler*/
49 for(i = 0; i < 16; i++)
50 {
51 func = (int)trap_func[i];
52 SETGATE(idt[i], 0, GD_KT, func, 0);
53 }
54
55 func = (int)trap_func[3];
56 SETGATE(idt[3], 0, GD_KT, func, 3);
57
58 i = 0;
59
60 /*install exteral interrupt handler*/
61 for(j = IRQ_OFFSET; j < IRQ_OFFSET + MAX_HANDLERS; j++)
62 {
63 func = (int)hdinterrupt_func[i];
64 SETGATE(idt[j], 0, GD_KT, func, 0);
65 i++;
66 }
67
68 // Load the IDT
69 asm volatile("lidt idt_pd + 2");
70}
71
72/**
73 * this function will deal with all kinds of kernel trap

Callers 1

rt_hw_interrupt_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected