summaryrefslogtreecommitdiff
path: root/kernel/hal/interrupts.h
blob: 673b13bc31d10e907db5a943441b41a9086e12b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//+----------------------------------------------------------------------------
//
// File:     interrupts.h
//
// Module:   
//
// Synopsis: 
//
// Created:  sgasch  6 Jul 2003
//
//+----------------------------------------------------------------------------

#ifndef _INTERRUPTS_H_
#define _INTERRUPTS_H_

#define NUM_IDT_ENTRIES          (256)

// Exceptions range from 0x00..0x11
#define FIRST_EXCEPTION 0x00
#define LAST_EXCEPTION  0x11
#define NUM_EXCEPTIONS  18

// External IRQs range from 0x30..0x3F
#define FIRST_EXTERNAL_INT 0x30
#define LAST_EXTERNAL_INT  0x3F
#define IRQ0               0x30
#define IRQ1               0x31
#define IRQ2               0x39
#define IRQ3               0x33
#define IRQ4               0x34
#define IRQ5               0x35
#define IRQ6               0x36
#define IRQ7               0x37
#define IRQ8               0x38
#define IRQ9               0x39
#define IRQ10              0x3A
#define IRQ11              0x3B
#define IRQ12              0x3C
#define IRQ13              0x3D
#define IRQ14              0x3E
#define IRQ15              0x3F
#define NUM_EXTERNAL_INTS  16

typedef struct _INTERRUPT_GATE
{
    USHORT offsetLow;
    USHORT segmentSelector;
    USHORT reserved  : 5;
    USHORT signature : 8;
    USHORT dpl       : 2;
    USHORT present   : 1;
    USHORT offsetHigh;
} 
INTERRUPT_GATE;

typedef union _IDT_ENTRY
{
    INTERRUPT_GATE i;
    // In theory we could have members for trap gates
    // and task gates if we wanted.
}
IDT_ENTRY;

//
// Defined in intsupport.asm
//
extern void HalInterruptInitializePICs(void);
extern void HalInterruptLoadIDTR(void *uLimitAndBase);
extern void HalIoDelay(void);
extern BYTE HalInterruptHandlerPreamble;
extern BYTE HalInterruptHandlerPreambleBefore;
extern BYTE HalInterruptHandlerPreambleAfter;

//
// Defined in interrupts.c
//
extern void HalDisableInterrupts(void);
extern void HalEnableInterrupts(void);


//
// Defined in keyboard.c
//
extern void HalKeyboardInt(INTERRUPT_STATE *is);

//
// Defined in timer.c
//
extern void HalTimerInt(INTERRUPT_STATE *is);

#endif