Initial checkin of toy OS project.
[os.git] / kernel / inc / hal.h
1 //+----------------------------------------------------------------------------
2 //
3 // File:     hal.h
4 //
5 // Module:   
6 //
7 // Synopsis: 
8 //
9 // Created:  sgasch  5 Jul 2003
10 //
11 //+----------------------------------------------------------------------------
12 #ifndef HAL_H
13 #define HAL_H
14
15 //
16 // Video/CRT driver
17 //
18 #define BLACK         (0)
19 #define BLUE          (1)
20 #define GREEN         (2)
21 #define CYAN          (3)
22 #define RED           (4)
23 #define MAGENTA       (5)
24 #define YELLOW        (6)
25 #define GRAY          (7)
26 #define HIGH          (8)
27 #define WHITE         (HIGH | GRAY)
28
29 void
30 HalVideoSetCurrentColorAttribute(BYTE bFg, BYTE bBg);
31
32 void
33 HalVideoClearScreen(void);
34
35 void
36 HalVideoGetCursorPosition(BYTE *pbLine, BYTE *pbCol);
37
38 void
39 HalVideoSetCursorPosition(BYTE bLine, BYTE bCol);
40
41 void
42 HalVideoPutNullTerminatedString(BYTE *s);
43
44 void
45 HalVideoInitialize(BIOS_HARDWARE_BLOCK *phw);
46
47 void 
48 HalVideoPrint(CHAR *szFormat, ...);
49
50 //
51 // Keyboard driver
52 //
53 #define KB_IRQ          (1)
54 typedef WORD KEYCODE;
55
56 typedef struct _INTERRUPT_STATE
57 {
58     // The register contents at the time of the exception.
59     // We save these explicitly.
60     ULONG gs;
61     ULONG fs;
62     ULONG es;
63     ULONG ds;
64     ULONG ebp;
65     ULONG edi; 
66     ULONG esi;
67     ULONG edx;
68     ULONG ecx; 
69     ULONG ebx;
70     ULONG eax;
71
72     // We explicitly push the interrupt number.
73     // This makes it easy for the handler function to determine
74     // which interrupt occurred.
75     ULONG uIntNum;
76
77     // This may be pushed by the processor; if not, we push
78     // a dummy error code, so the stack layout is the same
79     // for every type of interrupt.
80     ULONG uErrorCode;
81
82     // These are always pushed on the stack by the processor.
83     ULONG eip;
84     ULONG cs;
85     ULONG eflags;
86 }
87 INTERRUPT_STATE;
88
89 typedef void (*INTERRUPT_HANDLER)(INTERRUPT_STATE *pState);
90
91 void HalInitializeInterrupts(void);
92 void HalInterruptInstallHandler(ULONG uIntNum, INTERRUPT_HANDLER p);
93 void HalInterruptDisable();
94 void HalInterruptEnable();
95
96 void HalIoDelay();
97
98 void HalTimerInt(INTERRUPT_STATE *p);
99 void HalKeyboardInt(INTERRUPT_STATE *p);
100
101 extern UINT64 g_ullTimeStampCounter;
102 ULONG HalReadTimestampCounter(void);
103
104 #endif // HAL_H