diff options
| author | Miguel <m.i@gmx.at> | 2018-10-09 16:21:32 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-10-09 16:21:32 +0200 |
| commit | 63e5017d9863d4ed215782e469e8ee2c6ff8473d (patch) | |
| tree | f12d149ffa34e6a39f4bce4fe9a001e4ca8c6027 | |
| parent | a6a11437a390fb7e95fe995214d82bf5dbfe1eaf (diff) | |
fix pipers
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | fs/fd.c | 10 | ||||
| -rw-r--r-- | fs/fd.h | 2 | ||||
| -rw-r--r-- | kernel/interrupts.c | 2 | ||||
| -rw-r--r-- | kernel/ringbuffer.c | 7 | ||||
| -rw-r--r-- | kernel/scheduler.c | 2 | ||||
| -rw-r--r-- | kernel/syscalls.c | 5 | ||||
| -rw-r--r-- | userspace/bigmem.c | 14 | ||||
| -rw-r--r-- | userspace/files/file.txt | 40 | ||||
| -rw-r--r-- | userspace/fsh.c | 1 | ||||
| -rw-r--r-- | userspace/init.c | 9 | ||||
| -rw-r--r-- | userspace/xterm/xterm.c | 25 | ||||
| -rw-r--r-- | video/compositor.c | 11 | ||||
| -rw-r--r-- | video/compositor.h | 1 |
14 files changed, 105 insertions, 26 deletions
@@ -196,6 +196,8 @@ qemu-run: all -net nic,model=e1000 \ -net tap,ifname=tap0,script=no,downscript=no \ -vga virtio \ + -nographic \ + -vnc :0 \ -m 1024 #-net dump,file=./netfool @@ -25,6 +25,11 @@ bool fd_has(fd* f) if(!f->has)kpanic("no has func") return f->has(f->data); } +bool fd_can_write(fd* f) +{ + if(!f->can_write)kpanic("no has func") + return f->can_write(f->data); +} bool fd_eof(fd* f) { @@ -203,6 +208,10 @@ bool pipe_has(uint32_t *data) { return ringbuffer_has(data); } +bool pipe_can_write(uint32_t *data) +{ + return !ringbuffer_full(data); +} bool pipe_eof(uint8_t *data) { @@ -248,6 +257,7 @@ int fds_from_pipe(fd pipefds[2]) read.eof=pipe_eof; wrt.eof=0; + wrt.can_write=pipe_can_write; read.close=pipe_r_close; wrt.close=pipe_w_close; @@ -22,6 +22,7 @@ typedef struct fd_struct bool (*write)(struct fd_struct*,uint8_t); uint8_t (*read)(struct fd_struct*); bool (*has)(struct fd_struct*); + bool (*can_write)(struct fd_struct*); bool (*eof)(struct fd_struct*); bool (*close)(struct fd_struct*); struct fd_struct (*dupl)(struct fd_struct *); @@ -34,6 +35,7 @@ uint8_t fd_read(fd*); bool fd_has(fd*); bool fd_eof(fd*); bool fd_write(fd*,uint8_t); +bool fd_can_write(fd*); bool fd_close(fd*); fd fd_dupl(fd*); diff --git a/kernel/interrupts.c b/kernel/interrupts.c index aed1a50..2ab1490 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -80,7 +80,7 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq) { if(cpu==0) { - compositor_wake(); + compositor_wake2(); scheduler_wake_worker(esp); } } diff --git a/kernel/ringbuffer.c b/kernel/ringbuffer.c index 3886340..3526f4d 100644 --- a/kernel/ringbuffer.c +++ b/kernel/ringbuffer.c @@ -1,5 +1,6 @@ #include "ringbuffer.h" #include "kmalloc.h" +#include "log.h" ringbuffer ringbuffer_init(uint32_t size) { @@ -37,7 +38,11 @@ bool ringbuffer_has(ringbuffer* f) bool ringbuffer_put(ringbuffer* f,uint8_t c) { - if(ringbuffer_full(f))return false; + if(ringbuffer_full(f)) + { + klog("ringbuffer is full!"); + return false; + } f->data[f->back]=c; f->back--; diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 12c4ffd..bddd705 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -346,7 +346,7 @@ void task_syscall_worker() wake_mouse|=mouse_worker(); //x86_sti(); - //if(wake_mouse) + if(wake_mouse)compositor_wake(); compositor_swap_buffers(); if(wake)scheduler_wake_all(); diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 8ff6241..d579dc3 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -198,6 +198,7 @@ int syscall_write(int file, char *buf, int len,uint32_t pid) if(!open_fd[pid][file])kpanic("writing to closed file descriptor"); for(int i=0;i<len;i++) { + if(!fd_can_write(&fds[pid][file]))return i; fd_write(&fds[pid][file],buf[i]); } return len; @@ -432,7 +433,7 @@ uint32_t syscall_dup2(uint32_t oldfd,int newfd, int none2, uint32_t pid) } uint32_t syscall_gui_rect(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid) { - compositor_swap_buffers(); + compositor_wake(); return 1; } uint32_t syscall_gui_win(uint32_t p1, uint32_t p2, uint32_t p3, uint32_t pid) @@ -449,6 +450,8 @@ uint32_t syscall_generic_test(uint32_t nr,uint32_t p1, uint32_t p2, uint32_t p3, return !task_runs(p1); case SYSCALL_READ : return fd_has(&fds[pid][p1])||fd_eof(&fds[pid][p1]); + case SYSCALL_WRITE : + return fd_can_write(&fds[pid][p1]); } return 1;//other syscalls never block for now. diff --git a/userspace/bigmem.c b/userspace/bigmem.c new file mode 100644 index 0000000..5d474aa --- /dev/null +++ b/userspace/bigmem.c @@ -0,0 +1,14 @@ +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + for(int i=1;i<100;i++) + { + printf("allocating memory: %d byte\n",i*1024*1024); + char *mem=calloc(i*1024*1024,1); + printf("OK (addr=0x%08X)",mem); + } + + return EXIT_SUCCESS; +} diff --git a/userspace/files/file.txt b/userspace/files/file.txt index 7a8a521..f42c4c8 100644 --- a/userspace/files/file.txt +++ b/userspace/files/file.txt @@ -80,7 +80,47 @@ both eyes so that they made a half-garland on the projecting steel. There was no part of the hook that a great fish could feel which was not sweet smelling and good tasting. + +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. +smelling and good tasting. smelling and good tasting. smelling and good tasting. smelling and good tasting. +Before it was really light he had his baits out +and was drifting with the current. One bait was +down forty fathoms. The second was at seventy-five +and the third and fourth were down in the blue +water at one hundred and one hundred and +twenty-five fathoms. Each bait hung head down with +the shank of the hook inside the bait fish, tied +and sewed solid and all the projecting part of the +hook, the curve and the point, was covered with +fresh sardines. Each sardine was hooked through +both eyes so that they made a half-garland on the +projecting steel. There was no part of the hook +that a great fish could feel which was not sweet +smelling and good tasting. diff --git a/userspace/fsh.c b/userspace/fsh.c index 76c0954..0b3acfd 100644 --- a/userspace/fsh.c +++ b/userspace/fsh.c @@ -59,7 +59,6 @@ void prompt() int main(int argc, char **argv) { - while(1); for(int i=0;i<argc;i++) { diff --git a/userspace/init.c b/userspace/init.c index a2b2425..1592d39 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -6,7 +6,10 @@ int main(int argc, char **argv) { - _execve("/bin/xterm",NULL,NULL); + char *argv1[]={"xterm","/bin/fsh",0}; + char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; + + _execve("/bin/xterm",argv1,env1); int pid=_fork(); @@ -45,8 +48,8 @@ int main(int argc, char **argv) return 0; // - char *argv1[]={"/bin/fsh",0}; - char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; +// char *argv1[]={"/bin/fsh",0}; + // char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; // loop forever and spawn shells if the top-shell exits diff --git a/userspace/xterm/xterm.c b/userspace/xterm/xterm.c index 31feea7..4680ab8 100644 --- a/userspace/xterm/xterm.c +++ b/userspace/xterm/xterm.c @@ -1,6 +1,6 @@ -#include <stdio.h> +extern char**environ; -int main() +int main(int argc, char **argv) { _gui_win(); @@ -10,13 +10,11 @@ int main() _pipe(xterm_in); _pipe(xterm_out); - vesa_init(); void *tty=terminal_init_vesa(); int pid=_fork(); - if(!pid) { _close(xterm_in[1]); @@ -26,30 +24,25 @@ int main() _dup2(xterm_out[1],1);// stdout _dup2(xterm_out[1],2);// stderr - while(1); - - char *argv1[]={"/bin/fsh",0}; - char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; + _close(xterm_in[0]); + _close(xterm_out[1]); - while(1); - - _execve("/bin/fsh",argv1,env1); // replace process with our foolshell :) + _execve(argv[1],argv,environ); // replace process with our foolshell or whatever } _close(xterm_in[0]); _close(xterm_out[1]); - _dup2(xterm_in[1],1); // compositor writes here. - - while(1); + _dup2(xterm_in[1],0); // compositor writes here. + _close(xterm_in[1]); 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 + _gui_rect(); } } diff --git a/video/compositor.c b/video/compositor.c index 5dca7bd..192feea 100644 --- a/video/compositor.c +++ b/video/compositor.c @@ -45,6 +45,7 @@ static uint16_t mouse_y=100; static uint16_t mouse_k; static bool skip_render; +static bool skip_render2; static void put_pixel(int x,int y, uint32_t color) { @@ -205,6 +206,7 @@ void compositor_add_window(uint32_t addr,uint32_t pid) windows[0].pid=pid; next_window++; + compositor_mouse_handle(200,200,0); } void compositor_init(uint16_t width, uint16_t height, uint16_t pitch) @@ -218,11 +220,16 @@ void compositor_wake() { skip_render=false; } +void compositor_wake2() +{ + skip_render2=false; +} void compositor_swap_buffers() { - if(skip_render)return; + if(skip_render||skip_render2)return; skip_render=true; + skip_render2=true; static bool first=true; // if(!first)return; @@ -247,7 +254,7 @@ void compositor_kb_handle(char c) if(w->active) { // klog("writing [%c] to window with pid [%d]",c,w->pid); - fd_write(get_fd(w->pid,1),c); + fd_write(get_fd(w->pid,0),c); } } } diff --git a/video/compositor.h b/video/compositor.h index f109018..446cf19 100644 --- a/video/compositor.h +++ b/video/compositor.h @@ -1,6 +1,7 @@ #include <stdint.h> void compositor_wake(); +void compositor_wake2(); void compositor_init(uint16_t width, uint16_t height, uint16_t pitch); void compositor_set_background(char *ppm_raw_filename); void compositor_swap_buffers(); |
