//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" void isr(dword num); void k_init(); #include "mm.c" #include "functions.c" #include "video.c" dword timer = 0; word index = 0; dword ptrs[512]; dword goon = 1; dword req = 0; 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(); int a; for (a=0; a<512; a++) ptrs[a] = 0; enable_ints(); 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) { if (goon) { if(ptrs[index] = (dword)mm_palloc(1024)) printf("\nReq:%d\tAddr: %x\tEntries: %x\tMem: %x\tIndex: %x", req++, ptrs[index++], mm_freeentries(), mm_freemem(), index); else { goon = 0; index = 0; } } else { dword reslt = mm_pfree((void *)ptrs[index]); //zero returned means chunk freed successfully printf("\nReq:%d\tFree(): %x\tEntries: %x\tMem: %x\tIndex: %x", req++, reslt, mm_freeentries(), mm_freemem(), index++); if (reslt) { for (index=0; index<512; index++) ptrs[index] = 0; index = 0; goon = 1; } } } 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(); } //if (num == 0x21) // restart(); }