diff options
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | fs/file.c | 2 | ||||
| -rw-r--r-- | fs/file.h | 14 | ||||
| -rw-r--r-- | kernel/config.h | 2 | ||||
| -rw-r--r-- | kernel/interrupts.c | 1 | ||||
| -rw-r--r-- | kernel/kernel.c | 23 | ||||
| -rw-r--r-- | kernel/keyboard.c | 1 | ||||
| -rw-r--r-- | kernel/syscalls.c | 5 | ||||
| -rw-r--r-- | kernel/task.c | 1 | ||||
| -rw-r--r-- | lib/logger/log.c | 3 | ||||
| -rw-r--r-- | terminal/vt52.c | 120 | ||||
| -rw-r--r-- | terminal/vt52.h | 12 | ||||
| -rw-r--r-- | userspace/Makefile | 2 | ||||
| -rw-r--r-- | userspace/foolshell.c | 8 | ||||
| -rw-r--r-- | video/console.c | 41 | ||||
| -rw-r--r-- | video/console.h | 13 | ||||
| -rw-r--r-- | xxx/bochs/bochsdebug (renamed from bochs/bochsdebug) | 0 | ||||
| -rw-r--r-- | xxx/bochs/bochsrc (renamed from bochs/bochsrc) | 0 | ||||
| -rw-r--r-- | xxx/font/Makefile (renamed from font/Makefile) | 0 | ||||
| -rw-r--r-- | xxx/font/binarize.py (renamed from font/binarize.py) | 0 | ||||
| -rw-r--r-- | xxx/font/binfont.src (renamed from font/binfont.src) | 0 | ||||
| -rw-r--r-- | xxx/inactive/console.c (renamed from kernel/console.c) | 5 | ||||
| -rw-r--r-- | xxx/inactive/console.h (renamed from kernel/console.h) | 3 |
23 files changed, 197 insertions, 69 deletions
@@ -1,7 +1,4 @@ - - - ##################### # # # FoolOS Build Sys. # @@ -19,7 +16,7 @@ FOOLOS=FoolOS.img FOOLOS_VDI=FoolOS.vdi #submodules -SUBDIRS=font userspace +SUBDIRS=userspace #take care to set this properly! USB_STICK=/dev/sdf @@ -31,11 +28,11 @@ AS=i686-foolos-as ############ compiler flags ############ CFLAGS= ## CFLAGS+=-fstack-protector-all -## CFLAGS+=-Werror-implicit-function-declaration +CFLAGS+=-Wno-implicit-function-declaration ## CFLAGS+=-w CFLAGS+=-ffreestanding #CFLATS+=-Wall -CFLAGS+=-Wextra +#CFLAGS+=-Wextra #CFLAGS+=-O3 #CFLAGS+=-O0 #CFLAGS+=-nostdlib @@ -48,6 +45,7 @@ CFLAGS+=-gstabs #CFLAGS+= -O4 #CFLAGS+=-fdata-sections -ffunction-sections #CFLAGS+= -Werror +CFLAGS+= -w LDFLAGS= LDFLAGS+=-nostdlib diff --git a/fs/file.c b/fs/file.c new file mode 100644 index 0000000..609da63 --- /dev/null +++ b/fs/file.c @@ -0,0 +1,2 @@ +#include "file.h" + diff --git a/fs/file.h b/fs/file.h new file mode 100644 index 0000000..481a173 --- /dev/null +++ b/fs/file.h @@ -0,0 +1,14 @@ +#ifndef FILE_H +#define FILE_H + +#include <stdint.h> + +typedef struct file_struct +{ + + uint32_t file_id; + + +}file; + +#endif diff --git a/kernel/config.h b/kernel/config.h index 74304d8..0a6fd3c 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -8,7 +8,7 @@ #define FOOLOS_CONFIG_H #define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line -#define FOOLOS_LOG_OFF // do not log anything +#define FOOLOS_LOG_OFF // do not log anything #define FOOLOS_CONSOLE // otherwise VESA will be used! #define FOOLSOS_SHOW_VESAMODES #define MEM_PRINT_MEMORYMAP diff --git a/kernel/interrupts.c b/kernel/interrupts.c index d75ec4d..a7eae81 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -4,7 +4,6 @@ #include "asm/asm.h" #include "interrupts.h" -#include "console.h" #include "x86.h" void errlog(uint32_t error_code) diff --git a/kernel/kernel.c b/kernel/kernel.c index 0a4b863..de435c5 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -18,19 +18,17 @@ #include "interrupts.h" #include "multiboot.h" -#include "console.h" #include <stddef.h> // for built-in shell #include "lib/buffer/ringbuffer.h" #include "task.h" -#include "video/vesa.h" +#include "video/console.h" #include "multiboot.h" #include "terminal/vt52.h" - // // The Foolish structure of Fool OS! // @@ -45,15 +43,26 @@ fool_os *get_fool() void kernel_main(uint32_t eax,uint32_t ebx) { - // - // Setup main tty + // Setup terminal output // - scr_clear(); - term_screen screen; + term_out screen; screen.put_char=console_put_char; + screen.update_cursor=update_cursor; + vt52_tty tty=vt52_init(&screen); + get_fool()->tty1=&tty; + + // + // Setup terminal input + // + /* + term_in keyboard; + kb.get_char=console_put_char; + screen.update_cursor=update_cursor; vt52_tty tty=vt52_init(&screen); get_fool()->tty1=&tty; + */ + // diff --git a/kernel/keyboard.c b/kernel/keyboard.c index 0274748..b586d0f 100644 --- a/kernel/keyboard.c +++ b/kernel/keyboard.c @@ -1,7 +1,6 @@ #define FOOLOS_MODULE_NAME "keyboard" #include "x86.h" -#include "console.h" #include "lib/buffer/ringbuffer.h" #include "lib/logger/log.h" // logger facilities diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 6bd51d1..1d63ba4 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -4,7 +4,6 @@ #include "lib/logger/log.h" #include "fs/fs.h" #include "fs/ext2.h" -#include "kernel/console.h" #include "kernel/kernel.h" #include "kernel/config.h" #include "terminal/vt52.h" @@ -84,7 +83,7 @@ int syscall_read(int file, char *buf, int len) { if(l>0) { - console_del_char(); + //console_del_char(); buf--; l--; } @@ -94,7 +93,7 @@ int syscall_read(int file, char *buf, int len) *buf=c; buf++; l++; - if(c!=0x04)console_put_char_white(c); + //if(c!=0x04)console_put_char_white(c); if(c=='\n')return l; if(c==0x04) { diff --git a/kernel/task.c b/kernel/task.c index 495817c..36ccafe 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -6,7 +6,6 @@ #include "lib/buffer/ringbuffer.h" #include "mem.h" #include "timer.h" -#include "console.h" #include "x86.h" #include "vmem.h" diff --git a/lib/logger/log.c b/lib/logger/log.c index 7d58458..430f982 100644 --- a/lib/logger/log.c +++ b/lib/logger/log.c @@ -5,7 +5,6 @@ #include "log.h" #include "kernel/config.h" -#include "kernel/console.h" #include "terminal/vt52.h" #include "lib/printf/printf.h" #include "kernel/timer.h" @@ -63,7 +62,7 @@ void panic(char *module_name, char *message) { char buf_log[256]; tfp_sprintf(buf_log,"KERNEL PANIC !! %s: %s\n",module_name,message); - console_put_str_red(buf_log); + //console_put_str_red(buf_log); while(1) { diff --git a/terminal/vt52.c b/terminal/vt52.c index 4a9cb0a..9ff1150 100644 --- a/terminal/vt52.c +++ b/terminal/vt52.c @@ -1,16 +1,43 @@ // // http://en.wikipedia.org/wiki/VT52 +// http://vt100.net/docs/vt520-rm/ // - #include "vt52.h" #include "kernel/kmalloc.h" - -//TODO: check? #define VT52_WIDTH 80 #define VT52_HEIGHT 25 -#define VT52_ESC 0x33 + + +#define VT52_ESC_1 0x1b //ESC +#define VT52_ESC_2 0x5b //[ + +#define VT52_UP 'A' +#define VT52_DOWN 'B' +#define VT52_RIGHT 'C' +#define VT52_LEFT 'D' +#define VT52_GRAPH_ON 'F' +#define VT52_GRAPH_OFF 'G' +#define VT52_HOME 'H' +#define VT52_REV_FEED 'I' +#define VT52_ERASE_SCR 'J' +#define VT52_ERASE_LINE 'K' +#define VT52_KEYPAD_ON '=' +#define VT52_KEYPAD_OFF '>' + +#define VT52_EXIT '<' + +#define VT52_ENTER_AUTOPRINT '^' +#define VT52_EXIT_AUTOPRINT '_' + +#define VT52_PRINT_LINE 'W' +#define VT52_ENTER_PRINT 'W' +#define VT52_EXIT_PRINT 'X' +#define VT52_PRINT ']' +#define VT52_JUMP 'Y' // followed by LINE COL (subtr -32 from val) +#define VT52_IDENTIFY 'Z' +#define VT52_IDENTIFY_TO_HOST "/Z" static uint32_t index(vt52_tty *tty, uint32_t x, uint32_t y) { @@ -22,14 +49,13 @@ static void clear(vt52_tty *tty) for(int x=0;x<tty->width;x++) for(int y=0;y<tty->height;y++) { - tty->data[index(tty,x,y)]='.'; - tty->screen->put_char('.',0xf,x,y); + tty->data[index(tty,x,y)]=' '; + tty->screen->put_char(' ',0xf,x,y); } } -vt52_tty vt52_init(term_screen *screen) +vt52_tty vt52_init(term_out *screen) { - vt52_tty tty; tty.data=kballoc(1); @@ -52,9 +78,79 @@ static void set_char(vt52_tty *tty, uint32_t x, uint32_t y, uint32_t c) tty->data[index(tty,x,y)]=c; } +static uint8_t escaping=0; + // send one ASCII character to the terminal void vt52_put(vt52_tty *tty, uint8_t c) { + if(c==VT52_ESC_1){escaping=1;return;} + if(c==VT52_ESC_2){if(escaping==1)escaping=2;return;} + + if(escaping==3){tty->x=c-32; escaping++;return;} //TODO: check for overflow? + if(escaping==4){tty->y=c-32; escaping=0;return;} + + if(escaping==2) // two last characters are escape seq: ^[ + { + if(c==VT52_JUMP)escaping++; + + else + { + switch('c') + { + case VT52_UP: + if(tty->y>0)tty->y--; + break; + + case VT52_DOWN: + if(tty->y+1<tty->height)tty->y++; + break; + + case VT52_LEFT: + if(tty->x+1<tty->width)tty->x++; + break; + + case VT52_RIGHT: + if(tty->x>0)tty->x--; + break; + + case VT52_HOME: + tty->x=tty->y=0; + break; + + case VT52_REV_FEED: + + break; + + case VT52_ERASE_SCR: + for(uint32_t y=tty->y+1;y<tty->height;y++) + { + for(uint32_t x=0;x<tty->width-1;x++) + { + uint32_t c=tty->data[index(tty,x,y+1)]; + tty->data[index(tty,x,y)] = c; + tty->screen->put_char(c,0xf,x,y); + } + } + case VT52_ERASE_LINE: + + for(uint32_t x=tty->x;x<tty->width-1;x++) + { + uint32_t c=tty->data[index(tty,x,tty->y)]; + tty->data[index(tty,x,tty->y)] = c; + tty->screen->put_char(c,0xf,x,tty->y); + } + + break; + + } + + escaping=0; + } + + return; + + } + if(c!='\n') { tty->data[index(tty,tty->x,tty->y)]=c; @@ -87,10 +183,8 @@ void vt52_put(vt52_tty *tty, uint8_t c) tty->screen->put_char(c,0xf,x,y); } } - for(uint32_t x=0;x<tty->width;x++) - { - } - - } + + tty->screen->update_cursor(tty->x,tty->y); } + diff --git a/terminal/vt52.h b/terminal/vt52.h index 557c247..cdc62bd 100644 --- a/terminal/vt52.h +++ b/terminal/vt52.h @@ -7,13 +7,13 @@ // REQUIREMENTS // * kballoc // block wise in-kernel allocation - -typedef struct term_screen_struct +typedef struct term_out_struct { - + void (*put_char)(uint8_t c,uint8_t color, uint32_t x, uint32_t y); + void (*update_cursor)(uint32_t col,uint32_t row); -}term_screen; +}term_out; typedef struct vt52_tty_struct { @@ -23,11 +23,11 @@ typedef struct vt52_tty_struct uint32_t x; uint32_t y; uint32_t *data; // screen data - term_screen *screen; + term_out *screen; }vt52_tty; -vt52_tty vt52_init(term_screen *screen); +vt52_tty vt52_init(term_out *screen); void vt52_put(vt52_tty *tty, uint8_t c); #endif diff --git a/userspace/Makefile b/userspace/Makefile index b591280..48d9b1f 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -30,7 +30,7 @@ ext2.img: $(PROGS) ../mp/mp.bin cp $^ mnt/bin echo "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." > mnt/home/miguel/hello.brain # cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt/bin - cp ../font/binfont.bin mnt/ +# cp ../font/binfont.bin mnt/ cp ~/temp/fool-os-stuff/ncurses-5.9/progs/tput mnt/bin cp ../mp/mp.bin mnt/boot/ mkdir -p mnt/etc diff --git a/userspace/foolshell.c b/userspace/foolshell.c index da05e96..84d24b0 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -46,6 +46,14 @@ int main(int argc, char **argv) char *buf=malloc(256); // printf("malloc returned: 0x%08X\n",buf); + // + while(1) + { + fgets(buf,2,stdin); + buf[1]=0; + puts(buf); + } + while(1) { diff --git a/video/console.c b/video/console.c index c1b9c5c..b6958c5 100644 --- a/video/console.c +++ b/video/console.c @@ -6,16 +6,23 @@ static int posx=0; static int posy=0; +static void scr_nextline(); -// glue func for vt52 terminal -void console_put_char(uint8_t c,uint8_t color, uint32_t x, uint32_t y) +void update_cursor(uint32_t col,uint32_t row) { + unsigned short position=(row*80) + col; + + // cursor LOW port to vga INDEX register + x86_outb(0x3D4, 0x0F); + x86_outb(0x3D5, (unsigned char)(position&0xFF)); + // cursor HIGH port to vga INDEX register + x86_outb(0x3D4, 0x0E); + x86_outb(0x3D5, (unsigned char )((position>>8)&0xFF)); + } - print_char_col(x,y,c, color); -} // helper_funcs -void print_char_col(int x, int y, char c, char col) +static void print_char_col(int x, int y, char c, char col) { #ifdef FOOLOS_CONSOLE @@ -26,12 +33,20 @@ void print_char_col(int x, int y, char c, char col) } -void print_char(int x, int y, char c) +// glue func for vt52 terminal +void console_put_char(uint8_t c,uint8_t color, uint32_t x, uint32_t y) +{ + + print_char_col(x,y,c, color); +} +// +// +static void print_char(int x, int y, char c) { print_char_col(x,y,c,SCR_WHITE); } -void print_single_num(int i) +static void print_single_num(int i) { if(i<10)print_char_col(posx,posy,'0'+i,SCR_GREEN); else if(i<16)print_char_col(posx,posy,'A'+i-10,SCR_GREEN); @@ -40,7 +55,7 @@ void print_single_num(int i) } -void print_str_col(int x,int y,char *str, char col) +static void print_str_col(int x,int y,char *str, char col) { while(*str!=0) @@ -50,7 +65,7 @@ void print_str_col(int x,int y,char *str, char col) } -void print_str(int x,int y,char *str) +static void print_str(int x,int y,char *str) { print_str_col(x,y,str,SCR_WHITE); } @@ -82,7 +97,7 @@ void scr_put_string_nl(char *str) } */ -void scr_nextline() +static void scr_nextline() { #ifdef FOOLOS_CONSOLE int i,x; @@ -117,7 +132,7 @@ void scr_nextline() #endif } -void scr_put_char(char ch,char col) +static void scr_put_char(char ch,char col) { if(ch=='\n')scr_nextline(); @@ -163,7 +178,7 @@ void scr_put_hex32(uint32_t val) } */ -void scr_put_string(char *str, char col) +static void scr_put_string(char *str, char col) { while(*str!=0) { @@ -171,7 +186,7 @@ void scr_put_string(char *str, char col) } } -void scr_backspace() +static void scr_backspace() { if(posx==0)return; print_char_col(posx-1,posy,' ',SCR_LGREEN); diff --git a/video/console.h b/video/console.h index a89e0f5..819bd8d 100644 --- a/video/console.h +++ b/video/console.h @@ -1,8 +1,7 @@ #ifndef CONSOLEINT_H #define CONSOLEINT_H -// 80 x 24 -// TODO: implement VT100 +// 80 x 24 ? #include <stdint.h> @@ -35,13 +34,7 @@ #define SCR_WHITE 0xf //autoscroll -void scr_clear(); - - -void scr_nextline(); -void scr_backspace(); -void scr_put_char(char ch,char col); -void scr_put_string(char *str, char col); - +void update_cursor(uint32_t col,uint32_t row); +void console_put_char(uint8_t c,uint8_t color, uint32_t x, uint32_t y); #endif diff --git a/bochs/bochsdebug b/xxx/bochs/bochsdebug index fabafe9..fabafe9 100644 --- a/bochs/bochsdebug +++ b/xxx/bochs/bochsdebug diff --git a/bochs/bochsrc b/xxx/bochs/bochsrc index 47a7d3f..47a7d3f 100644 --- a/bochs/bochsrc +++ b/xxx/bochs/bochsrc diff --git a/font/Makefile b/xxx/font/Makefile index 2eeaf37..2eeaf37 100644 --- a/font/Makefile +++ b/xxx/font/Makefile diff --git a/font/binarize.py b/xxx/font/binarize.py index 1abb9d6..1abb9d6 100644 --- a/font/binarize.py +++ b/xxx/font/binarize.py diff --git a/font/binfont.src b/xxx/font/binfont.src index c1d9ccc..c1d9ccc 100644 --- a/font/binfont.src +++ b/xxx/font/binfont.src diff --git a/kernel/console.c b/xxx/inactive/console.c index 593801a..dc9b90e 100644 --- a/kernel/console.c +++ b/xxx/inactive/console.c @@ -1,3 +1,4 @@ +/* // http://invisible-island.net/xterm/ctlseqs/ctlseqs.html // http://invisible-island.net/vttest/ // http://www.xfree86.org/4.7.0/ctlseqs.html @@ -29,7 +30,6 @@ void console_put_str_gray(char *s){scr_put_string(s,SCR_GRAY2);} void console_put_str_white(char *s){scr_put_string(s,SCR_WHITE);} void console_put_str_green(char *s){scr_put_string(s,SCR_GREEN);} void console_put_str_red(char *s){scr_put_string(s,SCR_RED);} - #else #include "video/vesa.h" @@ -56,5 +56,4 @@ void console_put_str_green(char *s){PutConsole(s,0xffffff);} void console_put_str_red(char *s){PutConsole(s,0xffffff);} #endif - - +*/ diff --git a/kernel/console.h b/xxx/inactive/console.h index 4c56a5a..a153968 100644 --- a/kernel/console.h +++ b/xxx/inactive/console.h @@ -1,3 +1,4 @@ +/* #ifndef CONSOLE_H #define CONSOLE_H @@ -15,5 +16,5 @@ void console_put_str_green(char *); void console_put_str_gray(char *); void console_del_char(); - #endif +*/ |
