From aeefdb37d1fc1c0eb7953b9c196cab09460bc167 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 20 Sep 2018 20:51:57 +0200 Subject: we are now prepared for piping with _pipe and _dup2 --- fs/stdstreams.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 fs/stdstreams.c (limited to 'fs/stdstreams.c') diff --git a/fs/stdstreams.c b/fs/stdstreams.c new file mode 100644 index 0000000..1cb9402 --- /dev/null +++ b/fs/stdstreams.c @@ -0,0 +1,56 @@ +#include + +#include "fd.h" +#include "terminal.h" +#include "screen.h" +#include "vesa.h" + +#include "kmalloc.h" + +fd fd_from_term() +{ + uint8_t *mem=kballoc(1); + term_out *screen=mem; + terminal_tty *tty1=mem+sizeof(term_out); + fifo *fif=tty1+sizeof(terminal_tty); + + screen->put_char=console_put_char; + screen->update_cursor=update_cursor; + + *tty1=terminal_init(screen,NULL); + + fif->data=tty1; + fif->put=terminal_put; + + return fd_from_fifo(fif); +} + +fd fd_from_fb_term() +{ + uint8_t *mem=kballoc(1); + term_out *screen=mem; + terminal_tty *tty1=mem+sizeof(term_out); + fifo *fif=tty1+sizeof(terminal_tty); + + screen->put_char=vesa_console_put_char; + screen->update_cursor=vesa_update_cursor; + + *tty1=terminal_init(screen,NULL); + + fif->data=tty1; + fif->put=terminal_put; + + return fd_from_fifo(fif); +} + +fd fd_from_ringbuffer() +{ + fifo *f=kballoc(1); + ringbuffer *r=kballoc(1); + *r=ringbuffer_init(1); + f->data=r; + f->put=ringbuffer_put; + f->get=ringbuffer_get; + f->has=ringbuffer_has; + return fd_from_fifo(f); +} -- cgit v1.2.3