108 lines
2.0 KiB
C
108 lines
2.0 KiB
C
//kernel.c
|
|
//08/13/03 Josh Holtrop
|
|
//Holtrop's Operating System
|
|
|
|
#define VXR video_mode.XResolution
|
|
#define VYR video_mode.YResolution
|
|
|
|
#include "k_defines.h"
|
|
|
|
#include "lib/string.h"
|
|
#include "lib/io.h"
|
|
|
|
#include "functions.h"
|
|
#include "video.h"
|
|
#include "mm.h"
|
|
#include "keyboard.h"
|
|
|
|
void isr(dword num);
|
|
void k_init();
|
|
|
|
#include "keyboard.c"
|
|
#include "mm.c"
|
|
#include "functions.c"
|
|
#include "video.c"
|
|
|
|
dword timer = 0;
|
|
|
|
void type();
|
|
|
|
void k_init()
|
|
{
|
|
remap_pics(0x20, 0x28);
|
|
//set timer : 2e9c = 100hz
|
|
outportb(0x43, 0x34);
|
|
outportb(0x40, 0x9c); //lsb
|
|
outportb(0x40, 0x2e); //msb
|
|
video_init((ModeInfoBlock *) 0x90306);
|
|
mm_init();
|
|
enable_ints();
|
|
console_cls();
|
|
printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem);
|
|
type();
|
|
/* pageblock *pb = first_pageblock;
|
|
for (;;)
|
|
{
|
|
if (pb->flags == MM_PB_NP)
|
|
break;
|
|
printf("\nBase: 0x%x; Limit: 0x%x; Flags: 0x%x, Link: 0x%x", pb->base, pb->length, pb->flags, pb->link);
|
|
pb = (pageblock *) pb->link;
|
|
} */
|
|
}
|
|
|
|
void type()
|
|
{
|
|
dword key = 0;
|
|
for (;;)
|
|
{
|
|
key = kbdWaitKey();
|
|
// printf("Key %c ", key);
|
|
putc('!');
|
|
}
|
|
}
|
|
|
|
void isr(dword num)
|
|
{
|
|
switch(num)
|
|
{
|
|
case 0x20:
|
|
timer++;
|
|
(*(byte *)0xb8000)++;
|
|
switch(timer)
|
|
{
|
|
case 150:
|
|
video_rectf(VXR*3/11, 0, VXR*4/11, VYR-1, 0x00000088);
|
|
break;
|
|
case 200:
|
|
video_rectf(VXR*7/11, 0, VXR*8/11, VYR-1, 0x00000088);
|
|
break;
|
|
case 250:
|
|
video_rectf(VXR/11, 0, VXR*2/11, VYR*2/5, 0x00000088);
|
|
break;
|
|
case 300:
|
|
video_rectf(VXR/11, VYR*3/5, VXR*2/11, VYR-1, 0x00000088);
|
|
break;
|
|
case 350:
|
|
video_rectf(VXR*5/11, VYR/5, VXR*6/11, VYR*4/5, 0x00000088);
|
|
break;
|
|
case 400:
|
|
video_rectf(VXR*9/11, VYR/5, VXR-1, VYR*2/5, 0x00000088);
|
|
break;
|
|
case 450:
|
|
video_rectf(VXR*8/11, VYR*3/5, VXR*10/11, VYR*4/5, 0x00000088);
|
|
break;
|
|
}
|
|
eoi();
|
|
break;
|
|
case 0x21:
|
|
printf("------------------KEYBOARD ISR--------------------------\n");
|
|
isr_keyboard();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|