summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/console.c23
-rw-r--r--kernel/console.h4
-rw-r--r--kernel/interrupts.c7
-rw-r--r--kernel/kernel.c67
-rw-r--r--kernel/keyboard.c7
5 files changed, 95 insertions, 13 deletions
diff --git a/kernel/console.c b/kernel/console.c
index 4c52e81..70076d5 100644
--- a/kernel/console.c
+++ b/kernel/console.c
@@ -7,7 +7,7 @@ static int posy=0;
void print_char_col(int x, int y, char c, char col)
{
- char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_WIDTH)*2;
+ char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH)*2;
video_mem[0]=c;
video_mem[1]=col;
}
@@ -22,6 +22,7 @@ void print_single_hex(int i)
if(i<10)print_char_col(posx,posy,'0'+i,SCR_GREEN);
else if(i<16)print_char_col(posx,posy,'A'+i-10,SCR_GREEN);
posx++;
+ if(posx>=SCR_WIDTH)scr_nextline();
}
@@ -50,7 +51,7 @@ void scr_clear()
for(x=0;x<SCR_WIDTH;x++)
for(y=0;y<SCR_HEIGHT;y++)
{
- print_char_col(x,y,' ',SCR_BLACK);
+ print_char_col(x,y,'@',SCR_BLUE);
}
@@ -78,8 +79,8 @@ void scr_nextline()
for(x=1;x<SCR_WIDTH;x++)
{
- char* video_mem=(char *)SCR_VIDEOMEM+((x)+(i-1)*SCR_WIDTH)*2;
- char* video_mem2=(char *)SCR_VIDEOMEM+((x)+i*SCR_WIDTH)*2;
+ char* video_mem=(char *)SCR_VIDEOMEM+((x)+(i-1)*SCR_REAL_WIDTH)*2;
+ char* video_mem2=(char *)SCR_VIDEOMEM+((x)+i*SCR_REAL_WIDTH)*2;
*video_mem=*video_mem2;
*(video_mem+1)=*(video_mem2+1);
}
@@ -89,15 +90,19 @@ void scr_nextline()
}
}
+void scr_put_char(char ch,char col)
+{
+ print_char_col(posx,posy,ch,SCR_WHITE);
+ posx++;
+ if(posx>=SCR_WIDTH)scr_nextline();
+}
+
void scr_put_hex(uint16_t val)
{
int i;
- print_char_col(posx,posy,'0',SCR_WHITE);
- posx++;
- print_char_col(posx,posy,'x',SCR_WHITE);
- posx++;
+ scr_put_string("0x");
for(i=0;i<4;i++)
{
@@ -113,7 +118,7 @@ void scr_put_string(char *str)
{
while(*str!=0)
{
- print_char(posx++,posy,*(str++));
+ scr_put_char(*(str++),SCR_WHITE);
}
}
diff --git a/kernel/console.h b/kernel/console.h
index 44fdca9..c1920b8 100644
--- a/kernel/console.h
+++ b/kernel/console.h
@@ -5,7 +5,9 @@
#define SCR_VIDEOMEM 0xb8000
-#define SCR_WIDTH 80
+#define SCR_REAL_WIDTH 80
+
+#define SCR_WIDTH 70
#define SCR_HEIGHT 23
#define SCR_CTRL 0x3D4
diff --git a/kernel/interrupts.c b/kernel/interrupts.c
index 0676732..ce49201 100644
--- a/kernel/interrupts.c
+++ b/kernel/interrupts.c
@@ -33,7 +33,12 @@ void int_enable()
}
-// default handler
+void int_generate88()
+{
+
+ __asm__("int $88");
+
+}
void int_def_handler()
{
__asm__("pusha");
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 989eab6..7d845c5 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -4,6 +4,44 @@
// TODO: cleanup . how can i compile it without the includes!??
+/// PIT /// Timer stuff
+
+/*
+ http://www.brokenthorn.com/Resources/OSDevPit.html
+
+ vcc/gnd - voltage/ground
+
+ D0-D7 - data lines (data bus)
+ wr/rd - writing / reading (system control bus)
+ cs - ignore wr/rd or not (address bus)
+ a0-a1 (address bus)
+
+ // the three 16bit down counters/timers/channels
+ clk 0-2 (in)
+ gate 0-2 (in)
+ out 0-2 (out)
+
+
+
+
+ //typical
+ out1 -> pic interrupt on every tick (system timer)
+ out2 - was used for genearting dram memory refresh (Do not use)
+ out3 -> pc speaker
+
+ gate pins : depend on mode of operation
+ we do have modes 0-5.
+
+
+ */
+
+
+
+
+
+
+
+///////
void int_kb_handler();
////////// KERNEL MAIN///// /////
@@ -23,6 +61,27 @@ void int_test_handler()
}
+// clock handler
+void int_clock_handler()
+{
+ __asm__("pusha");
+
+ scr_put_string_nl(".");
+
+
+ // todo also the other pic!// TODO
+ __asm__("mov $0x20, %al");
+ __asm__("out %al, $0x20");
+ //
+
+ __asm__("popa");
+ __asm__("leave");
+ __asm__("iret");
+ __asm__("popa");
+ __asm__("leave");
+ __asm__("iret");
+
+}
void kernel_main()
{
@@ -37,6 +96,14 @@ void kernel_main()
int_init(0x08);
int_install();
+ // remember that we shifted all interrupts with the pic by 32
+ // so clock = 32 (irq 0)
+ // keyboard = 22 (irq 1)
+ // etc..
+
+ // install pit handler (programmable timer interrupt channel0)
+ int_install_ir(32, 0b10001110, 0x08,&int_clock_handler);
+
// install keyboard handler
int_install_ir(33, 0b10001110, 0x08,&int_kb_handler);
diff --git a/kernel/keyboard.c b/kernel/keyboard.c
index 5d5e71f..f7887f2 100644
--- a/kernel/keyboard.c
+++ b/kernel/keyboard.c
@@ -11,8 +11,11 @@ static char last_code=0;
void int0(uint8_t in)
{
- if(in==0x1e)__asm__("int $88"); // test interrupt 88
- // whenver A is pressed
+ // test interrupt 88 // whenver A is pressed
+ if(in==0x1e)
+ {
+ int_generate88();
+ }
int i=0;
//