From 264e6ebaa0816d0d2070090ebd7a75d7767929cb Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Tue, 8 Jul 2014 11:34:16 +0200 Subject: Merge in parts of the experimental branch --- kernel/kernel.c | 151 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 90 insertions(+), 61 deletions(-) (limited to 'kernel/kernel.c') diff --git a/kernel/kernel.c b/kernel/kernel.c index 05d04cc..c8b21cf 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,95 +1,125 @@ -#define SCR_WIDTH 80 -#define SCR_HEIGHT 23 +#include -#define SCR_CTRL 0x3D4 -#define SCR_DATA 0x3D5 +#include "console.h" // this will allow us to write to screen -#define SCR_BLACK 0x0 -#define SCR_BLUE 0x1 -#define SCR_GREEN 0x2 -#define SCR_CYAN 0x3 -#define SCR_RED 0x4 -// todo... -# define SCR_WHITE 0xf +//// interrupt stuff ///// +// +#define INT_MAX 255 +// interrupt descriptor table +static struct int_desc +{ + uint16_t addrLo; + uint16_t sel; + uint8_t zeros; + uint8_t flags; + uint16_t addrHi; + +} idt[INT_MAX]; -void print_char(int x, int y, char c, char col) +// interrupt descriptor table descriptor +static struct idt_desc { - char* video_mem=(char *)0xb8000+(x+y*SCR_WIDTH)*2; - video_mem[0]=c; - video_mem[1]=col; + uint16_t size; + uint32_t base; + +} idtd; + +volatile char col=100; +char col2=0; + +int cursor=0; +char last_code=0; + + +volatile void int_def_handler() +{ + __asm__("pusha"); + + col++; + print_str(5,5,"Interrupted"); + + __asm__("popa"); + __asm__("iret"); + } -float func(float x,float y) +void int_init(uint16_t sel) { - return x*x*y; + int i; + + idtd.size=sizeof(struct int_desc)*INT_MAX-1; // why the -1 ?? + idtd.base=(uint32_t)&idt[0]; + + for(i=0; i> 16) & 0xffff; + idt[irq].zeros=0; + idt[irq].flags=flags; + idt[irq].sel=sel; + } -void sleep(int i) + +void int_install() { - int x; + __asm__("lidt %0"::"m" (idtd)); - for(x=0;x300)time=0; - - } + print_str_col(0,0,str,col); + print_str_col(0,2,str,col2++); -} + int0(); + } -int cursor=0; -char last_code=0; + +} void int0() { int i=0; + char* int_count=(char *)0x7c00+3; char make_codes[]={ 0x1e, // A @@ -149,15 +179,14 @@ void int0() 0xac, // Z }; - char* int_count=(char *)0x7c00+3; - + print_str(6,6,*int_count); if(last_code==*int_count)return; for(i=0;i<26;i++) { if(make_codes[i]==*int_count) { - print_char(cursor,10,'A'+i,0xf); + print_char_col(cursor,10,'A'+i,0xf); } } @@ -165,7 +194,7 @@ void int0() { if(break_codes[i]==*int_count) { - print_char(cursor++,10,'a'+i,0xf); + print_char_col(cursor++,10,'a'+i,SCR_RED); } } -- cgit v1.2.3