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
|
#include "tty.h"
#include "stdlib.h"
#include "io_ports.h"
/* this only work for the 32-bit ix86 targets. */
#if !defined(__i386__)
#error "This tutorial needs to be compiled with a ix86-elf compiler"
#endif
#if defined(__cplusplus)
extern "C" /* Use C linkage for kernel_main. */
#endif
static void test(int ok)
{
tty_puts(ok ? " ok\n" : " ko\n");
}
void kernel_main()
{
char ch0[16];
tty_init();
tty_puts("\nHello, kernel World!\n");
memset(ch0, 'x', 4);
memcpy(ch0+4, ch0, 4);
ch0[0] = ' ';
ch0[7] = '\n';
ch0[8] = '\0';
tty_puts(ch0);
test(strncmp("abc", "abd", 8) < 0);
test(strncmp("abd", "abc", 8) > 0);
test(strncmp("abc", "abc", 8) == 0);
test(strncmp("abca", "abcb", 3) == 0);
tty_puts("inw : ");
while(true) {
int ret = inw(0x03F8);
if (ret == 97) {
tty_puts(" ok\n");
break;
}
}
tty_puts("outw :\n");
outw(0x03F8, 'h');
outw(0x03F8, 'e');
outw(0x03F8, 'l');
outw(0x03F8, 'l');
outw(0x03F8, 'o');
outw(0x03F8, '\0');
tty_puts("done.\n");
}
|