summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-20 03:18:04 +0200
committerMiguel <m.i@gmx.at>2018-08-20 03:18:04 +0200
commite4febc5aac3006c3ef025b5f708ec51fdac63b94 (patch)
treee00149a611589520bd6c99e1fe043385df583f5c
parent39100c30b7a16103e75187c9840a79c7df54f3da (diff)
vesa works beuatifullyy
-rw-r--r--driver/mouse.c6
-rw-r--r--driver/vesa.c96
-rw-r--r--driver/vesa.h3
-rw-r--r--kernel/kernel.c22
-rw-r--r--kernel/syscalls.c7
-rw-r--r--terminal/terminal.c2
-rw-r--r--userspace/foolshell.c12
-rw-r--r--userspace/snake.c1
8 files changed, 114 insertions, 35 deletions
diff --git a/driver/mouse.c b/driver/mouse.c
index 23619a4..f585b99 100644
--- a/driver/mouse.c
+++ b/driver/mouse.c
@@ -128,10 +128,10 @@ void mouse_log()
if(mouse_x>800)mouse_x=800;
if(mouse_y>600)mouse_y=600;
- log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]);
+ //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]);
if (mouse_byte[0] & 1)vesa_put_rect(mouse_x,600-mouse_y,10,10,0x00ffff);
- else vesa_put_rect(mouse_x,600-mouse_y,10,10,0x0000ff);
- //PutFont('X', mouse_x,600-mouse_y, 0xffffff);
+ //else vesa_put_rect(mouse_x,600-mouse_y,10,10,0x0000ff);
+ PutFont('X', mouse_x,600-mouse_y, 0xff0000);
}
diff --git a/driver/vesa.c b/driver/vesa.c
index 9b0dd55..b8c03ec 100644
--- a/driver/vesa.c
+++ b/driver/vesa.c
@@ -25,6 +25,60 @@ static uint8_t* physbase;
void PutConsoleNL();
void PutPixel(int x,int y, int color);
+//static char buf[80][24];
+
+void vesa_update_cursor(uint32_t col,uint32_t row)
+{
+ console_x=col;
+ console_y=row;
+}
+
+// helper_funcs
+static void vesa_print_char_col(int x, int y, char c, char col_fg, char col_bg)
+{
+ // uint16_t attrib = (col_bg << 4) | (col_fg & 0x0F);
+ // uint16_t* video_mem=(uint16_t *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH);
+ // *video_mem=c | (attrib << 8) ;
+}
+
+// same colors as in screen.h
+static uint32_t cols[] = {
+ 0x0, // black
+ 0x0066cc, //blue
+ 0x009900, //green
+ 0x33ffff, //cyan
+ 0xff3333, //red
+ 0xcc00cc, //magenta
+ 0x994c00, //brown
+ 0xa0a0a0, //light gray
+ 0x404040, //dark gray
+ 0x3399ff, //light blue
+ 0x99ff33, //light green
+ 0x99ffff, //cyan light
+ 0xff9999, //red light
+ 0xff99ff, //magenta light
+ 0xffff00, //yellow
+ 0xffffff, //white
+};
+
+// glue func for terminal
+void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_t x, uint32_t y)
+{
+// print_char_col(x,y,c, color_bg, color_fg);
+ //PutFont(c, console_x*10,console_y*12, cols[color_fg],cols[color_bg]);
+
+ //PutFont(c, x*10,y*12, cols[color_bg],cols[color_fg]);
+ PutFont(c, x*9,y*11, cols[color_bg],cols[color_fg]);
+
+// buf[console_x][console_y]=c;
+
+// console_x++;
+
+// #ifdef FOOLOS_CONSOLE_AUTOBREAK
+// if(console_x>=console_cols)PutConsoleNL();
+// #endif
+}
+
void vesa_switch_buffers()
{
for(int i=0;i<800*600*2;i++)physbase[i]=buffer[i];
@@ -79,6 +133,10 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont)
int col_width=10;
console_lines=mode->Yres/line_height;
console_cols=mode->Xres/col_width;
+
+ //TODO dynamic (but need to sync with terminal!)
+ console_cols=80;
+ console_lines=24;
// vesa info
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"vbe version: 0x%x / video mode ptr: 0x%x 0x%x",
@@ -127,7 +185,7 @@ void PutPixel(int x,int y, int color)
}
-void PutFont(char c, int x,int y, int color)
+void PutFont(char c, int x,int y, int color_fg,int color_bg)
{
int fnt=0x126-0x20;
@@ -138,16 +196,25 @@ void PutFont(char c, int x,int y, int color)
for(posx=x;posx<x+sizex;posx++)
{
+ PutPixel(posx,y-1,color_bg);
+ }
+ for(posy=y;posy<y+sizey;posy++)
+ {
+ PutPixel(x-1,posy,color_bg);
+ }
+
+ for(posx=x;posx<x+sizex;posx++)
+ {
for(posy=y;posy<y+sizey;posy++)
{
if(deffont[fnt].line[posy-y]&1<<(7-(posx-x)))
{
- PutPixel(posx,posy,color);
+ PutPixel(posx,posy,color_fg);
}
else
{
- PutPixel(posx,posy,0);
+ PutPixel(posx,posy,color_bg);
}
}
@@ -165,7 +232,7 @@ void PutString(char *str, int x,int y, int color, va_list va)
int i=x;
while((*str)!=0)
{
- PutFont(*str, i,y, color);
+ //PutFont(*str, i,y, color);
i+=9; // spacing
str++;
}
@@ -179,7 +246,7 @@ void PutConsoleChar(char c, int color)
PutConsoleNL();
return;
}
- PutFont(c, console_x*10,console_y*12, color);
+ //PutFont(c, console_x*10,console_y*12, color);
console_x++;
@@ -200,14 +267,27 @@ void PutConsole(char *str, int color)
}
void PutConsoleNL()
{
- console_x=0;
console_y++;
- if(console_y>=console_lines-5)console_y=0;
+ if(console_y<console_lines)return;
+
+ for(int line=0;line<24;line++)
+ {
+ for(int j=0;j<console_cols;j++)
+ {
+// buf[j][line]=buf[j][line+1];
+// PutFont(buf[j][line],j*10,line*12,0x33ff66,0);
+// PutFont(buf[j][line+1],j*10,line*12,0x33ff66,0);
+ }
+ }
for(int i=0;i<console_cols;i++)
{
- PutFont(' ',i*10,(console_y)*12,0);
+ PutFont(' ',i*10,23*12,0x33ff66,0);
+ //buf[i][23]=' ';
}
+
+ console_x=0;
+ console_y--;
}
static int boxx;
diff --git a/driver/vesa.h b/driver/vesa.h
index f6e3eaf..ec98e84 100644
--- a/driver/vesa.h
+++ b/driver/vesa.h
@@ -1,5 +1,8 @@
#include <stdint.h>
+void vesa_update_cursor(uint32_t col,uint32_t row);
+void vesa_console_put_char(uint8_t c,uint8_t color_bg, uint8_t color_fg, uint32_t x, uint32_t y);
+
typedef struct foolfont_struct
{
uint8_t line[10]; //every single fool font consists of 10 lines a 8 bit
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 62556cb..ea14869 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -33,13 +33,8 @@ void kernel_main(uint32_t eax,uint32_t ebx)
uint64_t epoch_time=timer_init();
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"PIT - initialized. %u seconds passed since 1970.",epoch_time);
- // STREAMS
- uint32_t sstdin = syscall_open("stdin",0,0); // stdin 0
- uint32_t sstdout = syscall_open("term",0,0); // stdout 1
- uint32_t sstderr = syscall_open("stderr",0,0); // stderr 2
-
// KEYBOARD DRIVER
- keyboard_init(sstdin);
+ keyboard_init(0); //sstdin
// MOUSE DRIVER
mouse_init();
@@ -47,9 +42,6 @@ void kernel_main(uint32_t eax,uint32_t ebx)
// GDT
gdt_setup();
- // INTERRUPTS (code segment: 0x08)
- int_init(0x08);
-
// MULTIBOOT HEADER
multiboot_information *info=get_multiboot(eax, ebx);
@@ -82,11 +74,19 @@ void kernel_main(uint32_t eax,uint32_t ebx)
uint32_t addr=kballoc(1);
fs_content("/binfont.bin",addr,0x100); // copy 0x100 bytes to 0x7000
vesa_init(info->vbe_control_info,info->vbe_mode_info,addr);
- PutString("WELCOME TO THE Fool Operating System",100,100,0xffff00);
- // INIT MULTITASKING (and switch to usermode)
+ // STREAMS
+ uint32_t sstdin = syscall_open("stdin",0,0); // stdin 0
+ uint32_t sstdout = syscall_open("term",0,0); // stdout 1
+ uint32_t sstderr = syscall_open("stderr",0,0); // stderr 2
+
+ // START INTERRUPTS (code segment: 0x08)
+ int_init(0x08);
+
+ // INIT MULTITASKING (and switch to our pseudo-usermode)
task_init(dir);
// we should never reach this
panic(FOOLOS_MODULE_NAME,"reached end of kernel.c !!");
+
}
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index 0c334bc..db23a17 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -5,6 +5,7 @@
#include "fs/fs.h"
#include "fs/ext2.h"
#include "kernel.h"
+#include "driver/vesa.h"
#include "fifo.h"
#include "fd.h"
#include "terminal/terminal.h"
@@ -259,8 +260,14 @@ int syscall_open(char *name, int flags, int mode)
}
else
{
+ // FIRST TIME WE SEE THE GENIUS OF OUR ABSTRACTIONS (I HOPE...)
screen.put_char=console_put_char;
screen.update_cursor=update_cursor;
+
+ // FIRST TIME WE SEE THE GENIUS OF OUR ABSTRACTIONS (I HOPE...)
+ screen.put_char=vesa_console_put_char;
+ screen.update_cursor=vesa_update_cursor;
+
tty1=terminal_init(&screen,NULL);
fifos[next_fifo].data=&tty1;
diff --git a/terminal/terminal.c b/terminal/terminal.c
index 2f10ab8..268310e 100644
--- a/terminal/terminal.c
+++ b/terminal/terminal.c
@@ -230,7 +230,7 @@ terminal_tty terminal_init(term_out *screen,term_in *input)
tty.set_echo=true;
-// tty.set_echo=false;
+ tty.set_echo=false;
tty.command=kballoc(1);
tty.command_l=0;
diff --git a/userspace/foolshell.c b/userspace/foolshell.c
index 47d1e92..c5c3b42 100644
--- a/userspace/foolshell.c
+++ b/userspace/foolshell.c
@@ -71,13 +71,6 @@ int main(int argc, char **argv)
printf("setvbuf returned %i\n",setvbuf(stdin,NULL,_IONBF,0));
- // TODO: remove test (Tryint to write directyly to frameubuff)
- uint32_t *vmem=0xfd000000;
- for(int i=0;i<2000;i++)
- {
- *vmem=0xff0000;
- vmem++;
- }
while(1)
{
prompt();
@@ -93,11 +86,6 @@ int main(int argc, char **argv)
buf[bl]=c;
buf[bl+1]='\0';
bl++;
- for(int i=0;i<20000;i++)
- {
- *vmem=0xff0000;
- vmem++;
- }
}
//fgets(buf,255,stdin);
diff --git a/userspace/snake.c b/userspace/snake.c
index 9bf9fe2..d825987 100644
--- a/userspace/snake.c
+++ b/userspace/snake.c
@@ -18,6 +18,7 @@ int main()
puts("+++");
printf("setvbuf returned %i\n",setvbuf(stdin,NULL,_IONBF,0));
+ printf("setvbuf returned %i\n",setvbuf(stdout,NULL,_IONBF,0));
//fool_tune(1,0,0); // activate gaming mode