24
|
1 #include "kernel.h"
|
|
2
|
|
3 void panic(char *msg)
|
|
4 {
|
|
5 printf("Kernel panic: ");
|
|
6 printf(msg);
|
|
7 magicBochsBreak();
|
|
8 halt();
|
|
9 }
|
|
10
|
26
|
11 void reboot()
|
|
12 {
|
|
13 while ( (inb(0x64) & 0x02) == 0x02)
|
|
14 {
|
|
15 ;
|
|
16 }
|
|
17 outb(0x64, 0xFE);
|
|
18 }
|
|
19
|
24
|
20 // IO port helpers:
|
|
21 void outb(uint16_t port, uint8_t value)
|
|
22 {
|
|
23 asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
|
|
24 }
|
|
25
|
|
26 uint8_t inb(uint16_t port)
|
|
27 {
|
|
28 uint8_t ret;
|
|
29 asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port));
|
|
30 return ret;
|
|
31 }
|
|
32
|
|
33 uint16_t inw(uint16_t port)
|
|
34 {
|
|
35 uint16_t ret;
|
|
36 asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port));
|
|
37 return ret;
|
|
38 }
|
|
39
|
|
40 // string functions:
|
|
41 int strncmp(const char* s1, const char* s2, int size)
|
|
42 {
|
|
43 int i;
|
|
44 for (i=0; i<size; i++)
|
|
45 {
|
|
46 if (s1[i] != s2[i]) return 0;
|
|
47 }
|
|
48 return 1;
|
|
49 }
|
|
50
|