From 7aea8d20ec8816759c8439fc39d90579fc37e18b Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 27 Aug 2014 23:10:04 +0200 Subject: cleanup and switched logging to vesa mode console! --- kernel/vesa.c | 109 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 38 deletions(-) (limited to 'kernel/vesa.c') diff --git a/kernel/vesa.c b/kernel/vesa.c index 43e0dfb..8bac363 100644 --- a/kernel/vesa.c +++ b/kernel/vesa.c @@ -1,6 +1,10 @@ //http://wiki.osdev.org/GUI +#include #include "kernel.h" +#include "../lib/logger/log.h" // logger facilities +#define FOOLOS_MODULE_NAME "vesa" + typedef struct vbeinfo_struct{ char VbeSignature[4]; // == "VESA" uint16_t VbeVersion; // == 0x0300 for VBE 3.0 @@ -42,57 +46,47 @@ typedef struct foolfont_struct }foolfont; - static foolfont *deffont; static vbemodeinfo *VbeModeInfoBlock; +static console_x; +static console_y; + +static console_lines; +static console_cols; + void vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) { - //the only functionallu important 2 init lines! (rest is log) + //the only functionallu important init lines! (rest is log) VbeModeInfoBlock=mode; deffont=rawfont; - // + console_x=0; + console_y=0; + + int line_height=12; + int col_width=10; + console_lines=mode->Yres/line_height; + console_cols=mode->Xres/col_width; - PutString("Welcome to Fool OS 001",30,30,0xfff00); + // vesa info + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setup complete. vbe version: 0x%x / video mode ptr: 0x%x 0x%x", + info->VbeVersion, info->VideoModePtr[1], info->VideoModePtr[0]); - 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(""); + // vesa info on selected mode: + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"res: %d * %d / banks: %d / attr: 0x%x / bpp: %d / physbase: 0x%x", + mode->Xres, mode->Yres, mode->banks, mode->attributes, mode->bpp,mode->physbase); - int *modeptr=info[i].VideoModePtr[0]; // todo: take segment from vbeinfo! + // vesa modes + // todo: take segment from vbeinfo! +#ifdef FOOLSOS_SHOW_VESAMODES + uint16_t *modeptr=info->VideoModePtr[0]; while(*modeptr!=0xffff&&*modeptr!=0) { - - scr_put_string("vesa: mode supported: "); - scr_put_hex(*modeptr); - scr_put_string_nl(""); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mode supported : 0x%x", (*modeptr)); modeptr++; } - - scr_put_string("vesa: selected mode res: "); - scr_put_hex(mode->Xres); - scr_put_string(" x "); - scr_put_hex(mode->Yres); - scr_put_string_nl(""); - scr_put_string("vesa: selected mode banks: "); - scr_put_hex(mode->banks); - scr_put_string_nl(""); - scr_put_string("vesa: attribs: "); - scr_put_hex(mode->attributes); - scr_put_string_nl(""); - scr_put_string("vesa: physbase: "); - scr_put_hex32(mode->physbase); - scr_put_string_nl(""); - scr_put_string("vesa: bpp: "); - scr_put_hex(mode->bpp); - scr_put_string_nl(""); - - +#endif } @@ -116,11 +110,13 @@ void PutFont(char c, int x,int y, int color) 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; + else if(c==' ')fnt=27; int posx, posy, sizex=8, sizey=10; for(posx=x;posxconsole_cols)PutConsoleNL(); + } + +} +void PutConsoleNL() +{ + console_x=0; + console_y++; + if(console_y>console_lines)console_y=1; + for(int i=0;i