aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/stdio.c
diff options
context:
space:
mode:
authortcsullivan <tullivan99@gmail.com>2018-11-17 13:02:57 -0500
committertcsullivan <tullivan99@gmail.com>2018-11-17 13:02:57 -0500
commitc6ef89664b8c0d7aa85bddd5c7014aa6df82cbe7 (patch)
treed1f9d09412a46bdf4344fe30392455070a72993d /src/fs/stdio.c
parentdb38c4b9dac461de0ed75bf6d079dacba1b31bc9 (diff)
added pdclib, removed sash
Diffstat (limited to 'src/fs/stdio.c')
-rw-r--r--src/fs/stdio.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/fs/stdio.c b/src/fs/stdio.c
new file mode 100644
index 0000000..6cea2a3
--- /dev/null
+++ b/src/fs/stdio.c
@@ -0,0 +1,55 @@
+#include "stdio.h"
+
+#include <kernel/heap.h>
+#include <kernel/serial.h>
+
+void *stdio_open(const char *path);
+int stdio_close(void *info);
+uint32_t stdio_read(void *info, uint32_t count, uint8_t *buffer);
+uint32_t stdio_write(void *info, uint32_t count, const uint8_t *buffer);
+
+const vfs_volume_funcs stdio_funcs = {
+ stdio_open,
+ stdio_close,
+ stdio_read,
+ stdio_write,
+ 0, // readdir
+};
+
+void *stdio_open(const char *path)
+{
+ int *id = malloc(sizeof(uint32_t));
+
+ if (path[0] == 'o' && path[1] == 'u' && path[2] == 't')
+ *id = 1;
+ else if (path[0] == 'i' && path[1] == 'n')
+ *id = 0;
+ if (path[0] == 'e' && path[1] == 'r' && path[2] == 'r')
+ *id = 2;
+
+ return id;
+}
+
+int stdio_close(void *info)
+{
+ // Nothing to do
+ free(info);
+ return 0;
+}
+
+uint32_t stdio_read(void *info, uint32_t count, uint8_t *buffer)
+{
+ (void)info;
+ (void)count;
+ (void)buffer;
+ return 0;
+}
+
+uint32_t stdio_write(void *info, uint32_t count, const uint8_t *buffer)
+{
+ (void)info;
+ for (uint32_t i = 0; i < count; i++)
+ serial_put(buffer[count]);
+ return count;
+}
+