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
|
|
11 // IO port helpers:
|
|
12 void outb(uint16_t port, uint8_t value)
|
|
13 {
|
|
14 asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
|
|
15 }
|
|
16
|
|
17 uint8_t inb(uint16_t port)
|
|
18 {
|
|
19 uint8_t ret;
|
|
20 asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port));
|
|
21 return ret;
|
|
22 }
|
|
23
|
|
24 uint16_t inw(uint16_t port)
|
|
25 {
|
|
26 uint16_t ret;
|
|
27 asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port));
|
|
28 return ret;
|
|
29 }
|
|
30
|
|
31 // string functions:
|
|
32 int strncmp(const char* s1, const char* s2, int size)
|
|
33 {
|
|
34 int i;
|
|
35 for (i=0; i<size; i++)
|
|
36 {
|
|
37 if (s1[i] != s2[i]) return 0;
|
|
38 }
|
|
39 return 1;
|
|
40 }
|
|
41
|