comparison 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
comparison
equal deleted inserted replaced
23:5dd47d6eebac 24:d8627924d40d
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