diff cos/kernel/kernel.c @ 17:f3e3e0e9c4bc

First attempt IDT loader 64 bits. INT13 occurs
author windel
date Sat, 19 Nov 2011 20:01:28 +0100
parents a58904747019
children 6129643f5c34
line wrap: on
line diff
--- a/cos/kernel/kernel.c	Fri Nov 18 14:41:53 2011 +0100
+++ b/cos/kernel/kernel.c	Sat Nov 19 20:01:28 2011 +0100
@@ -1,7 +1,7 @@
 #include "kernel.h"
 
 static int shiftstate = 0;
-static volatile unsigned char charAvail = 0;
+static volatile uint8_t charAvail = 0;
 static volatile char kbdchar = ' ';
 
 static char keymap[128] = {
@@ -28,6 +28,27 @@
   '?','?','?','?', '?', '?', '?','?', '?', '?','?', '?', '?','?', '?', '?'
 };
 
+// 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;
+}
+
+
 static uint64_t ticks = 0;
 void timerDriverUpdate()
 {
@@ -114,7 +135,7 @@
 /* Allocates 'size' bytes and returns the pointer if succesfull.
    Kernelpanic in case of failure..
 */
-void* malloc(size_t size) {
+void* malloc(uint64_t size) {
   printf("Malloc %d bytes\n", size);
   return kernel_heap;
 }
@@ -127,10 +148,9 @@
 {
   init_screen();
   clear_screen();
-  printf("Welcome!\n");
-  printf("sizeof(uint32_t)=%u, sizeof(uint64_t)=%u\n", sizeof(uint32_t), sizeof(uint64_t));
+  printf("Welcome! .. ");
 
-  printf("Enabling interrupts\n");
+  printf("Enabling interrupts .. ");
   setupIDT();
   printf("Entering mainloop!\n");