hos/kernel.c

67 lines
1.2 KiB
C

//kernel.c
//08/13/03 Josh Holtrop
//Holtrop's Operating System
#include "k_defines.h"
#include "lib/string.h"
#include "lib/io.h"
#include "functions.h"
#include "video.h"
#include "mm.h"
void isr(dword num);
void k_init();
#include "mm.c"
#include "functions.c"
#include "video.c"
dword timer = 0;
dword pagesa = 0;
void k_init()
{
remap_pics(0x20, 0x28);
//set timer : 2e9c = 100hz
outportb(0x43, 0x34);
outportb(0x40, 0x9c); //lsb
outportb(0x40, 0x2e); //msb
enable_ints();
video_init((ModeInfoBlock *) 0x90306);
mm_init();
console_cls();
printf("Memory available to OS: %d MB", mm_totalmem/0x100000);
/* 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 isr(dword num)
{
if (num == 0x20)
{
timer++;
(*(byte *)0xb8000)++;
if ((timer%50)==0)
{
printf("\nReq: 0x%x\t Addr: 0x%x\tEntries: 0x%x\tMem: 0x%x", pagesa, (dword)mm_palloc(1024), mm_freeentries(), mm_freemem());
pagesa++;
}
eoi();
}
//if (num == 0x21)
// restart();
}