annotate cos/kernel/klib.c @ 24:d8627924d40d

Split up in more files and reboot command
author windel
date Fri, 02 Dec 2011 14:00:02 +0100
parents
children dcce92b1efbc
rev   line source
24
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
1 #include "kernel.h"
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
2
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
3 void panic(char *msg)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
4 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
5 printf("Kernel panic: ");
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
6 printf(msg);
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
7 magicBochsBreak();
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
8 halt();
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
9 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
10
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
11 // IO port helpers:
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
12 void outb(uint16_t port, uint8_t value)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
13 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
14 asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
15 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
16
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
17 uint8_t inb(uint16_t port)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
18 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
19 uint8_t ret;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
20 asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port));
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
21 return ret;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
22 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
23
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
24 uint16_t inw(uint16_t port)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
25 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
26 uint16_t ret;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
27 asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port));
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
28 return ret;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
29 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
30
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
31 // string functions:
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
32 int strncmp(const char* s1, const char* s2, int size)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
33 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
34 int i;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
35 for (i=0; i<size; i++)
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
36 {
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
37 if (s1[i] != s2[i]) return 0;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
38 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
39 return 1;
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
40 }
d8627924d40d Split up in more files and reboot command
windel
parents:
diff changeset
41