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 /kernel | |
| 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
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/kernel.c | 31 | ||||
| -rw-r--r-- | kernel/vesa.c | 65 |
2 files changed, 45 insertions, 51 deletions
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++; } - - - - - } |
