-
Notifications
You must be signed in to change notification settings - Fork 1
/
kern.c
65 lines (56 loc) · 1.08 KB
/
kern.c
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
#include <u.h>
#include "mem.h"
enum {
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA_COLOR_MAGENTA = 5,
VGA_COLOR_BROWN = 6,
VGA_COLOR_LIGHT_GREY = 7,
VGA_COLOR_DARK_GREY = 8,
VGA_COLOR_LIGHT_BLUE = 9,
VGA_COLOR_LIGHT_GREEN = 10,
VGA_COLOR_LIGHT_CYAN = 11,
VGA_COLOR_LIGHT_RED = 12,
VGA_COLOR_LIGHT_MAGENTA = 13,
VGA_COLOR_LIGHT_BROWN = 14,
VGA_COLOR_WHITE = 15,
};
u32int MemMin;
u16int *terminal;
u8int
mkcolor(int fg, int bg)
{
return fg | bg << 4;
}
u16int
mkchar(uchar c, u8int color)
{
return (u16int) c | (u16int) color << 8;
}
void
writestr(char *s, int len, u8int color)
{
int i;
for(i=0;i<len;i++,s++)
*(terminal+i) = mkchar(*s, color);
}
void
main(void)
{
u8int color;
int i;
char msg[] = "Barebones kernel from Plan9 space!";
terminal = (u16int*) 0xB8000;
color = mkcolor(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
/* Clear the screen */
for(i=0;i<25*80;i++)
*(terminal+i) = mkchar(' ', color);
/* Print to the screen */
writestr(msg, sizeof msg-1, color);
/* Throw her in park */
for(;;)
;
}