summaryrefslogtreecommitdiff
path: root/kernel/inc/hal.h
blob: 9a52a4e67b996cec435acc6c0677c332aa9f74c5 (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
93
94
95
96
97
98
99
100
101
102
103
104
//+----------------------------------------------------------------------------
//
// File:     hal.h
//
// Module:   
//
// Synopsis: 
//
// Created:  sgasch  5 Jul 2003
//
//+----------------------------------------------------------------------------
#ifndef HAL_H
#define HAL_H

//
// Video/CRT driver
//
#define BLACK         (0)
#define BLUE          (1)
#define GREEN         (2)
#define CYAN          (3)
#define RED           (4)
#define MAGENTA       (5)
#define YELLOW        (6)
#define GRAY          (7)
#define HIGH          (8)
#define WHITE         (HIGH | GRAY)

void
HalVideoSetCurrentColorAttribute(BYTE bFg, BYTE bBg);

void
HalVideoClearScreen(void);

void
HalVideoGetCursorPosition(BYTE *pbLine, BYTE *pbCol);

void
HalVideoSetCursorPosition(BYTE bLine, BYTE bCol);

void
HalVideoPutNullTerminatedString(BYTE *s);

void
HalVideoInitialize(BIOS_HARDWARE_BLOCK *phw);

void 
HalVideoPrint(CHAR *szFormat, ...);

//
// Keyboard driver
//
#define KB_IRQ          (1)
typedef WORD KEYCODE;

typedef struct _INTERRUPT_STATE
{
    // The register contents at the time of the exception.
    // We save these explicitly.
    ULONG gs;
    ULONG fs;
    ULONG es;
    ULONG ds;
    ULONG ebp;
    ULONG edi; 
    ULONG esi;
    ULONG edx;
    ULONG ecx; 
    ULONG ebx;
    ULONG eax;

    // We explicitly push the interrupt number.
    // This makes it easy for the handler function to determine
    // which interrupt occurred.
    ULONG uIntNum;

    // This may be pushed by the processor; if not, we push
    // a dummy error code, so the stack layout is the same
    // for every type of interrupt.
    ULONG uErrorCode;

    // These are always pushed on the stack by the processor.
    ULONG eip;
    ULONG cs;
    ULONG eflags;
}
INTERRUPT_STATE;

typedef void (*INTERRUPT_HANDLER)(INTERRUPT_STATE *pState);

void HalInitializeInterrupts(void);
void HalInterruptInstallHandler(ULONG uIntNum, INTERRUPT_HANDLER p);
void HalInterruptDisable();
void HalInterruptEnable();

void HalIoDelay();

void HalTimerInt(INTERRUPT_STATE *p);
void HalKeyboardInt(INTERRUPT_STATE *p);

extern UINT64 g_ullTimeStampCounter;
ULONG HalReadTimestampCounter(void);

#endif // HAL_H