summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/fd.c2
-rw-r--r--fs/fifo.c16
-rw-r--r--fs/fifo.h23
-rw-r--r--fs/stdstreams.c56
-rw-r--r--fs/stdstreams.h5
5 files changed, 101 insertions, 1 deletions
diff --git a/fs/fd.c b/fs/fd.c
index 1936f37..f8981a5 100644
--- a/fs/fd.c
+++ b/fs/fd.c
@@ -178,7 +178,7 @@ int fds_from_pipe(fd pipefds[2])
wrt.type=FD_TYPE_PIPE;
read.data=kballoc(1);
- wrt.data=read.type;
+ wrt.data=read.data;
ringbuffer r=ringbuffer_init(1);
diff --git a/fs/fifo.c b/fs/fifo.c
new file mode 100644
index 0000000..abd6c46
--- /dev/null
+++ b/fs/fifo.c
@@ -0,0 +1,16 @@
+#include "fifo.h"
+
+bool fifo_put(fifo* f,uint8_t c)
+{
+ return f->put(f->data,c);
+}
+
+uint8_t fifo_get(fifo* f)
+{
+ return f->get(f->data);
+}
+
+bool fifo_has(fifo* f)
+{
+ return f->has(f->data);
+}
diff --git a/fs/fifo.h b/fs/fifo.h
new file mode 100644
index 0000000..92f3b75
--- /dev/null
+++ b/fs/fifo.h
@@ -0,0 +1,23 @@
+// SIMPLE FIFO DRIVER //
+
+#ifndef FIFO_H
+#define FIFO_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef struct fifo_struct
+{
+ bool (*put)(struct fifo_struct*,uint8_t);
+ uint8_t (*get)(struct fifo_struct*);
+ bool (*has)(struct fifo_struct*);
+ void *data; // opaque data
+
+}fifo;
+
+bool fifo_put(fifo*,uint8_t);
+uint8_t fifo_get(fifo*);
+bool fifo_has(fifo*);
+
+fifo fifo_create_buffered(uint8_t size);
+#endif
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 <stddef.h>
+
+#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);
+}
diff --git a/fs/stdstreams.h b/fs/stdstreams.h
new file mode 100644
index 0000000..06262c9
--- /dev/null
+++ b/fs/stdstreams.h
@@ -0,0 +1,5 @@
+#include "fd.h"
+
+fd fd_from_term();
+fd fd_from_fb_term();
+fd fd_from_ringbuffer();