summaryrefslogtreecommitdiff
path: root/kernel/vesa.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-08-27 23:10:04 +0200
committerMichal Idziorek <m.i@gmx.at>2014-08-27 23:10:04 +0200
commit7aea8d20ec8816759c8439fc39d90579fc37e18b (patch)
treef59d354ea1ad128929e0e810da0fa78bab00537b /kernel/vesa.c
parentd680d4c641c085e7a31d19fe2d01f528e96d2ced (diff)
cleanup and switched logging to vesa mode console!
Diffstat (limited to 'kernel/vesa.c')
-rw-r--r--kernel/vesa.c109
1 files changed, 71 insertions, 38 deletions
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 <stdarg.h>
#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;posx<x+sizex;posx++)
+ {
+
for(posy=y;posy<y+sizey;posy++)
{
if(deffont[fnt].line[posy-y]&1<<(7-(posx-x)))
@@ -133,12 +129,17 @@ void PutFont(char c, int x,int y, int color)
}
}
+ }
}
-void PutString(char *str, int x,int y, int color)
+void PutString(char *str, int x,int y, int color, va_list va)
{
+ char buff[256];
+ tfp_sprintf(buff,str,va);
+ str=buff;
+
int i=x;
while((*str)!=0)
{
@@ -148,3 +149,35 @@ void PutString(char *str, int x,int y, int color)
}
}
+
+void PutConsole(char *str, int color, va_list va)
+{
+
+ char buff[256];
+ tfp_vsprintf(buff,str,va);
+ str=buff;
+
+ while((*str)!=0)
+ {
+ PutFont(*str, console_x*10,console_y*12, color);
+ str++;
+ console_x++;
+ if(console_x>console_cols)PutConsoleNL();
+ }
+
+}
+void PutConsoleNL()
+{
+ console_x=0;
+ console_y++;
+ if(console_y>console_lines)console_y=1;
+ for(int i=0;i<console_cols;i++)
+ {
+ PutFont(' ',i*10,(console_y+1)*12,0);
+ }
+
+}
+
+
+
+