Initial checkin of toy OS project.
[os.git] / kernel / hal / interrupts.h
1 //+----------------------------------------------------------------------------
2 //
3 // File:     interrupts.h
4 //
5 // Module:   
6 //
7 // Synopsis: 
8 //
9 // Created:  sgasch  6 Jul 2003
10 //
11 //+----------------------------------------------------------------------------
12
13 #ifndef _INTERRUPTS_H_
14 #define _INTERRUPTS_H_
15
16 #define NUM_IDT_ENTRIES          (256)
17
18 // Exceptions range from 0x00..0x11
19 #define FIRST_EXCEPTION 0x00
20 #define LAST_EXCEPTION  0x11
21 #define NUM_EXCEPTIONS  18
22
23 // External IRQs range from 0x30..0x3F
24 #define FIRST_EXTERNAL_INT 0x30
25 #define LAST_EXTERNAL_INT  0x3F
26 #define IRQ0               0x30
27 #define IRQ1               0x31
28 #define IRQ2               0x39
29 #define IRQ3               0x33
30 #define IRQ4               0x34
31 #define IRQ5               0x35
32 #define IRQ6               0x36
33 #define IRQ7               0x37
34 #define IRQ8               0x38
35 #define IRQ9               0x39
36 #define IRQ10              0x3A
37 #define IRQ11              0x3B
38 #define IRQ12              0x3C
39 #define IRQ13              0x3D
40 #define IRQ14              0x3E
41 #define IRQ15              0x3F
42 #define NUM_EXTERNAL_INTS  16
43
44 typedef struct _INTERRUPT_GATE
45 {
46     USHORT offsetLow;
47     USHORT segmentSelector;
48     USHORT reserved  : 5;
49     USHORT signature : 8;
50     USHORT dpl       : 2;
51     USHORT present   : 1;
52     USHORT offsetHigh;
53
54 INTERRUPT_GATE;
55
56 typedef union _IDT_ENTRY
57 {
58     INTERRUPT_GATE i;
59     // In theory we could have members for trap gates
60     // and task gates if we wanted.
61 }
62 IDT_ENTRY;
63
64 //
65 // Defined in intsupport.asm
66 //
67 extern void HalInterruptInitializePICs(void);
68 extern void HalInterruptLoadIDTR(void *uLimitAndBase);
69 extern void HalIoDelay(void);
70 extern BYTE HalInterruptHandlerPreamble;
71 extern BYTE HalInterruptHandlerPreambleBefore;
72 extern BYTE HalInterruptHandlerPreambleAfter;
73
74 //
75 // Defined in interrupts.c
76 //
77 extern void HalDisableInterrupts(void);
78 extern void HalEnableInterrupts(void);
79
80
81 //
82 // Defined in keyboard.c
83 //
84 extern void HalKeyboardInt(INTERRUPT_STATE *is);
85
86 //
87 // Defined in timer.c
88 //
89 extern void HalTimerInt(INTERRUPT_STATE *is);
90
91 #endif
92