diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-08-27 16:32:34 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-08-27 16:32:34 +0200 |
| commit | d680d4c641c085e7a31d19fe2d01f528e96d2ced (patch) | |
| tree | fb1f35486c584feaeb087c740c42508f7abe32fc | |
| parent | d85b6209f37b4d886f9e85fd9592c9d7cf25deb9 (diff) | |
put vesa init to top and integrated binary font.
binary fool-font is now part of the kernel image and
is loaded by the bootloader on startup into ram
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | boot/mbr.asm | 41 | ||||
| -rw-r--r-- | kernel/kernel.c | 31 | ||||
| -rw-r--r-- | kernel/vesa.c | 65 |
5 files changed, 69 insertions, 75 deletions
@@ -9,6 +9,10 @@ #lets use the size of a 1.44 floppy for a start for our boot img IMAGE_SIZE=1474560 + +#font data starts at 0x8000 +FONT_DATA_START=25600 + #data starts at 0x8000 DATA_START=32768 @@ -20,7 +24,7 @@ FoolOS.img: Fool.img FoolData.img fill.bin cat $^ | head -c $(IMAGE_SIZE) > $@ Fool.img: mbr.bin kernel.bin fill.bin - cat $^ | head -c $(DATA_START) > $@ + cat $^ | head -c $(FONT_DATA_START) > $@ FoolData.img: binfont.bin cat $^ > $@ @@ -29,6 +29,7 @@ Features All features are only very rudiemntary and buggy. +* Runs in bochs (with cirrus) and virtual box. * PIT support / Timing * PIC support & Interrupt handling framework * PCI bus scanning diff --git a/boot/mbr.asm b/boot/mbr.asm index 83edefc..bb1fc2b 100644 --- a/boot/mbr.asm +++ b/boot/mbr.asm @@ -1,39 +1,34 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; -; FoolOS Boot Loader +; THE FOOL-BOOT-LOADER ; -; Copyright 2014 M.Idziorek <m.i@gmx.at> -; -; we have just been loaded by the BIOS and are in 16-bits real mode! -; -; THIS IS THE CENTRAL FILE OF THE BOOTLOADER, -; -; after we are through, -; the following work has been accomplished (chronologically): +; So we have just been loaded by the BIOS and are in 16-bits real mode! +; Now the following work will bee accomplished (chronologically): ; -; * BOOT_DRIVE is set +; * BOOT_DRIVE set ; -; * 50 sectors of our kernel are loaded at KERNEL_OFFSET from floppy +; * 50 sectors of our kernel loaded at KERNEL_OFFSET from floppy ; -; * memoru map is available at MEMMAP_OFFSET -; (look at MEMMEP_SIZE_OFFSET for number of entries) +; * memory map made available at MEMMAP_OFFSET +; (check at MEMMEP_SIZE_OFFSET for number of entries) ; -; * the vesa mode specified by VESA_MODE_SELECT is set up -; (at VESA_MODES, and VESA_MODE_INFO additional info structs are available) +; * the VESA mode specified by VESA_MODE_SELECT will be set up +; (check at VESA_MODES, and VESA_MODE_INFO +; for additional information) ; ; * interrupts disabled ; -; * 32-bit protected mode was set up. +; * 32-bit protected mode set up. ; ; * esp set to 0x90000 (Todo: take care of it!?) ; -; * A20 gate is open +; * A20 gate opened (Todo: really necessary?) ; -; * PICs are configured +; * PICs configured ; -; * we are inside the C kernel! +; * and finally we will jump into the C world to kernel_main() ! ; -;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;we want 16-bit instructions, before we switch to 32-bit protected mode. [bits 16] @@ -104,9 +99,9 @@ boot_16: ;remember BOOT_DRIVE (as was set by BIOS) mov [BOOT_DRIVE],dl - ;Load the KERNEL (50 sectors starting at sector 2) + ;Load the KERNEL (52 sectors starting at sector 2) mov bx,KERNEL_OFFSET - mov dh, 50 ;50 sectors! + mov dh, 52 mov dl, [BOOT_DRIVE] call disk_load diff --git a/kernel/kernel.c b/kernel/kernel.c index efa703b..c260e80 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -29,10 +29,29 @@ void int_test_handler() } -// heart of our operating system +// heart of our operating system. void kernel_main() { + // + // We want to get output to the screen as fast as possible! + // + // Our Fool-Boot-Loader did set up VESA already for us. + // The desired VESA mode is hardcoded in [boot/mbr.asm]. + // + // The [vesa_init(...)] function requires: + // + // * the addresses of the vbeinfo struct + // * the address of the vbemodeinfo struct (for selected mode). + // * the address of our Fool-Font binary data. + // + // The first two paramters are hardcoded in [boot/mbr.asm], + // while the last one is set in the Makefile. The font binary + // is integrated in the kernel image. + // + vesa_init(0x8300,0x8400,0x7200); + while(1); // never ending loop + // clear console //! scr_clear(); @@ -47,7 +66,7 @@ void kernel_main() //! mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600))); mem_init(0x9000); - // we know that here the bootloader placed the mamory map! + // paging (Todo) vmem_init(); // init and interrupt decriptor table @@ -84,9 +103,6 @@ void kernel_main() // floppy floppy_init(); - // vesa init - vesa_init(0x8300,0x8400); - //! scr_put_string_nl(""); @@ -101,12 +117,7 @@ void kernel_main() // put some text on monitor! - uint8_t *rawfont=0xb000; // here the floppy_init puts first sector - // after 0x8000 (font data :)) - PutString(rawfont,"Welcome to Fool OS 001",10,10,0xff00); - PutString(rawfont,"Welcome to Fool OS 001",20,20,0xf00); - PutString(rawfont,"Welcome to Fool OS 001",30,30,0xfff00); while(1); // never ending loop diff --git a/kernel/vesa.c b/kernel/vesa.c index b1a298f..43e0dfb 100644 --- a/kernel/vesa.c +++ b/kernel/vesa.c @@ -36,9 +36,6 @@ typedef struct ModeInfoBlock { uint16_t reserved2; }vbemodeinfo; -static vbemodeinfo *VbeModeInfoBlock; - - typedef struct foolfont_struct { uint8_t line[10]; //every single fool font consists of 10 lines a 8 bit @@ -46,23 +43,27 @@ typedef struct foolfont_struct }foolfont; -void vesa_init(vbeinfo *info,vbemodeinfo *mode) +static foolfont *deffont; +static vbemodeinfo *VbeModeInfoBlock; + +void vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) { - int i=0; + //the only functionallu important 2 init lines! (rest is log) + VbeModeInfoBlock=mode; + deffont=rawfont; + // + + PutString("Welcome to Fool OS 001",30,30,0xfff00); -// while(info[i].VbeSignature[0]=='V') - // { - scr_put_string("vesa: init vbe version: "); - scr_put_hex(info[i].VbeVersion); - scr_put_string(" / videomode ptr: "); - scr_put_hex(info[i].VideoModePtr[0]); - scr_put_hex(info[i].VideoModePtr[1]); - scr_put_string_nl(""); + int i=0; + scr_put_string("vesa: init vbe version: "); + scr_put_hex(info[i].VbeVersion); + scr_put_string(" / videomode ptr: "); + scr_put_hex(info[i].VideoModePtr[0]); + scr_put_hex(info[i].VideoModePtr[1]); + scr_put_string_nl(""); -// i++; - // } - // - int *modeptr=info[i].VideoModePtr[0]; // 0x8322; // do not hardcode !!! take from vbeinfo! + int *modeptr=info[i].VideoModePtr[0]; // todo: take segment from vbeinfo! while(*modeptr!=0xffff&&*modeptr!=0) { @@ -70,7 +71,6 @@ void vesa_init(vbeinfo *info,vbemodeinfo *mode) scr_put_string("vesa: mode supported: "); scr_put_hex(*modeptr); scr_put_string_nl(""); - modeptr++; } @@ -91,15 +91,7 @@ void vesa_init(vbeinfo *info,vbemodeinfo *mode) scr_put_string("vesa: bpp: "); scr_put_hex(mode->bpp); scr_put_string_nl(""); -/* -uint8_t *videomem=mode->physbase; -for(i=0;i<0xffffff;i++) -{ - videomem[i]=i; -} -*/ - - VbeModeInfoBlock=mode; + } @@ -108,7 +100,6 @@ void PutPixel(int x,int y, int color){ //do not write memory outside the screen buffer, check parameters against the VBE mode info if (x<0 || x>VbeModeInfoBlock->Xres|| y<0 || y>VbeModeInfoBlock->Yres) return; -// if (x) x = (x*(VbeModeInfoBlock->bpp>>3)); // get bytes (divide by 8) if (y) y = (y*VbeModeInfoBlock->pitch); uint8_t *cTemp=VbeModeInfoBlock->physbase; @@ -117,23 +108,22 @@ void PutPixel(int x,int y, int color){ cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff); } -void PutFont(foolfont *font , char c, int x,int y, int color) +void PutFont(char c, int x,int y, int color) { - int fnt=0; + int fnt=0; if(c>='A'&&c<='Z')fnt=c-'A'+1; else if(c>='a'&&c<='z')fnt=c-'a'+1; else if(c>='0'&&c<='9')fnt=c-'0'+28; else if(c=' ')fnt=27; - int posx, posy, sizex=8, sizey=10; for(posx=x;posx<x+sizex;posx++) for(posy=y;posy<y+sizey;posy++) { - if(font[fnt].line[posy-y]&1<<(7-(posx-x))) + if(deffont[fnt].line[posy-y]&1<<(7-(posx-x))) { PutPixel(posx,posy,color); } @@ -143,25 +133,18 @@ void PutFont(foolfont *font , char c, int x,int y, int color) } } - - } -void PutString(foolfont *font , char *str, int x,int y, int color) +void PutString(char *str, int x,int y, int color) { int i=x; while((*str)!=0) { - PutFont(font ,*str, i,y, color); + PutFont(*str, i,y, color); i+=9; // spacing str++; } - - - - - } |
