view 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
line wrap: on
line source

#include "kernel.h"

void panic(char *msg) 
{
   printf("Kernel panic: ");
   printf(msg);
   magicBochsBreak();
   halt();
}

// IO port helpers:
void outb(uint16_t port, uint8_t value)
{
   asm volatile ("outb %1, %0" : : "dN" (port), "a" (value));
}

uint8_t inb(uint16_t port)
{
   uint8_t ret;
   asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port));
   return ret;
}

uint16_t inw(uint16_t port)
{
   uint16_t ret;
   asm volatile ("inw %1, %0" : "=a" (ret) : "dN" (port));
   return ret;
}

// string functions:
int strncmp(const char* s1, const char* s2, int size) 
{
  int i;
  for (i=0; i<size; i++) 
  {
    if (s1[i] != s2[i]) return 0;
  }
  return 1;
}