diff options
| author | Miguel <m.i@gmx.at> | 2018-10-05 23:41:51 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-10-05 23:41:51 +0200 |
| commit | fe8180d88540bfa96595dcc58290de5425e534e3 (patch) | |
| tree | a7a681cdcf013119d121fb17ce3b731763a4a644 /userspace | |
| parent | 4dbe6a264d7a3bd38ca1ac0921248654a50f1b5e (diff) | |
drunken proggin
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/init.c | 18 | ||||
| -rw-r--r-- | userspace/xterm/terminal.c | 16 | ||||
| -rw-r--r-- | userspace/xterm/vesa.c | 21 | ||||
| -rw-r--r-- | userspace/xterm/vesa.h | 2 | ||||
| -rw-r--r-- | userspace/xterm/xterm.c | 46 |
5 files changed, 81 insertions, 22 deletions
diff --git a/userspace/init.c b/userspace/init.c index d07942b..645acd9 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -1,31 +1,38 @@ #include <stdio.h> #include <time.h> #include "put_pixel.h" +#include "newcalls.h" + int main(int argc, char **argv) { // loop forever and spawn shells if the top-shell exits - _execve("/bin/xterm",NULL,NULL); + int fds[2]; + _pipe(fds); - _execve("/bin/vesa",NULL,NULL); int pid=_fork(); if(pid==0) { + _execve("/bin/xterm",NULL,NULL); int pid=_fork(); + if(pid==0) { - _execve("/bin/pain1",NULL,NULL); + _execve("/bin/xterm",NULL,NULL); } else { - _execve("/bin/vesa",NULL,NULL); + _execve("/bin/xterm",NULL,NULL); } } else { + _execve("/bin/xterm",NULL,NULL); + while(1); // block + int pid=_fork(); if(pid==0) { @@ -33,7 +40,8 @@ int main(int argc, char **argv) } else { - _execve("/bin/pain3",NULL,NULL); + _execve("/bin/pain1",NULL,NULL); + //_execve("/bin/pain3",NULL,NULL); } } diff --git a/userspace/xterm/terminal.c b/userspace/xterm/terminal.c index 4f321dd..ba7986e 100644 --- a/userspace/xterm/terminal.c +++ b/userspace/xterm/terminal.c @@ -6,6 +6,8 @@ #include <stdbool.h> #include <stddef.h> +#include "vesa.h" + #define NPAR_START 1000 #define TERM_WIDTH 80 #define TERM_HEIGHT 24 @@ -290,6 +292,7 @@ static void reset(terminal_tty *tty) tty->command_l=0; } + terminal_tty terminal_init(term_out *screen,term_in *input) { terminal_tty tty; @@ -326,6 +329,19 @@ terminal_tty terminal_init(term_out *screen,term_in *input) return tty; } +term_out tout; +terminal_tty tty; +terminal_tty* terminal_init_vesa() +{ + + tout.put_char=vesa_console_put_char; + tout.update_cursor=vesa_update_cursor; + + tty=(terminal_init(&tout,NULL)); + return &tty; + + +} // send one ASCII character to the terminal void terminal_put(terminal_tty *tty, uint8_t c) diff --git a/userspace/xterm/vesa.c b/userspace/xterm/vesa.c index d38f3f2..e795cc8 100644 --- a/userspace/xterm/vesa.c +++ b/userspace/xterm/vesa.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <stdio.h> #include "../newcalls.h" +#include "vesa.h" #define VMEM_USER_FRAMEBUFFER 0xfa000000 @@ -134,6 +135,9 @@ void vesa_set_physbase(uint32_t addr) uint32_t vesa_init() { + + FILE *f=fopen("/doc/fonts/binfont.bin","r"); + fread(deffont,10,95,f); //inf->framebuffer_type /* @@ -351,20 +355,3 @@ void vesa_init_doublebuff() VbeModeInfoBlock->physbase=buffer; } */ - -int main() -{ - FILE *f=fopen("/doc/fonts/binfont.bin","r"); - fread(deffont,10,95,f); - - vesa_init(); - - _gui_win(); - - while(1) - { - vesa_console_put_char('X' ,15, 0, 5, 5); - _gui_rect(); - } - -} diff --git a/userspace/xterm/vesa.h b/userspace/xterm/vesa.h new file mode 100644 index 0000000..16a52f1 --- /dev/null +++ b/userspace/xterm/vesa.h @@ -0,0 +1,2 @@ +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); diff --git a/userspace/xterm/xterm.c b/userspace/xterm/xterm.c index 10b222c..96389a9 100644 --- a/userspace/xterm/xterm.c +++ b/userspace/xterm/xterm.c @@ -1,2 +1,48 @@ #include <stdio.h> +int main() +{ + _gui_win(); + + int xterm_in[2]; + int xterm_out[2]; + + _pipe(xterm_in); + _pipe(xterm_out); + + + vesa_init(); + void *tty=terminal_init_vesa(); + + int pid=_fork(); + + if(!pid) + { + _close(xterm_in[1]); + _close(xterm_out[0]); + + _dup2(xterm_in[0],0);// stdin + _dup2(xterm_out[1],1);// stdout + _dup2(xterm_out[1],2);// stderr + + char *argv1[]={"/bin/fsh",0}; + char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; + + _execve("/bin/fsh",argv1,env1); // replace process with our foolshell :) + } + + _close(xterm_in[0]); + _close(xterm_out[1]); + + _dup2(xterm_in[1],1); // compositor writes here. + + while(1) + { + char buf[1]; + _read(xterm_out[0],buf,1); // show what foolshell writes to its stdout/stderr + + _gui_rect(); //lock + terminal_put(tty,buf[0]); + _gui_rect(); //unlock + } +} |
