forked from luke8086/boot2c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbios.h
102 lines (76 loc) · 2.1 KB
/
bios.h
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
/*
* bios.h - BIOS services
*
* author: luke8086
* license: GPL-2
*/
#ifndef _BIOS_H_
#define _BIOS_H_
#include <stdint.h>
/*
* Note: this library only covers a tiny subset of available functionality
* of BIOS. To learn more, see http://stanislavs.org/helppc/idx_interrupt.html
* and http://www.ctyme.com/rbrown.htm
*/
/*
* Video services
*/
/* Text attributes */
enum {
CL_BLACK, CL_BLUE, CL_GREEN, CL_CYAN,
CL_RED, CL_MAGENTA, CL_BROWN, CL_LIGHT_GRAY,
/* Bright colors require additional setup to be used for bg */
CL_DARK_GRAY, CL_LIGHT_BLUE, CL_LIGHT_GREEN, CL_LIGHT_CYAN,
CL_LIGHT_RED, CL_LIGHT_MAGENTA, CL_YELLOW, CL_WHITE
};
/* Toggle visibility of the cursor */
void toggle_cursor(int visible);
/* Move text cursor to the given location */
void move_cursor(int x, int y);
/* Write a single character at the cursor position */
void put_char(char);
/*
* Direct access to the text-mode video memory.
* Requires calling set_fs(TEXT_MEM_SEG);
*/
/* Default text-mode dimensions */
#define TEXT_WIDTH 80
#define TEXT_HEIGHT 25
/* Attributed character, a single item of the text-mode memory */
struct attr_char {
uint8_t ascii;
uint8_t attr;
};
/* Text-mode memory */
#define TEXT_MEM_SEG 0xb800
#define TEXT_MEM ((struct attr_char FS_RELATIVE volatile *) 0x00)
/* Access a single character, assuming default screen dimensions */
#define CHAR_AT(x, y) (TEXT_MEM[(y) * TEXT_WIDTH + (x)])
/*
* Keyboard services
*/
/* Single keystroke in the keyboard buffer */
struct keystroke {
char scancode;
char ascii;
};
/* Keyboard scan codes */
enum {
SC_ESC = 0x01,
SC_UP = 0x48,
SC_DOWN = 0x50,
SC_LEFT = 0x4b,
SC_RIGHT = 0x4d,
SC_PGUP = 0x49,
SC_PGDN = 0x51,
};
/* Check if a keystroke is ready in the keyboard buffer */
int check_keystroke(void);
/* Wait for, and return the next keystroke from the keyboard buffer */
struct keystroke get_keystroke(void);
/*
* Clock services
*/
/* Get system time in 18.2Hz ticks since midnight */
uint32_t get_time(void);
#endif /* _BIOS_H_ */