diff options
author | dzwdz | 2022-04-07 21:25:54 +0200 |
---|---|---|
committer | dzwdz | 2022-04-07 21:25:54 +0200 |
commit | 86623b76dce72bc611f470e0e9ecad963fd558b2 (patch) | |
tree | e9f1204a3761e4389e4b51276c7d359957f4fb86 | |
parent | da2bbef4e4f586ecf13cd5ffe9a62df3114a3483 (diff) |
kernel: remove the `/tty` device
-rw-r--r-- | src/init/main.c | 4 | ||||
-rw-r--r-- | src/kernel/arch/i386/driver/serial.c | 5 | ||||
-rw-r--r-- | src/kernel/arch/i386/tty/tty.c | 4 | ||||
-rw-r--r-- | src/kernel/arch/io.h | 1 | ||||
-rw-r--r-- | src/kernel/vfs/root.c | 30 |
5 files changed, 10 insertions, 34 deletions
diff --git a/src/init/main.c b/src/init/main.c index fae6606..a46cb18 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -23,9 +23,9 @@ int main(void) { // allocate bss _syscall_memflag(&_bss_start, &_bss_end - &_bss_start, MEMFLAG_PRESENT); - if (!fork2_n_mount("/tty")) ansiterm_drv(); + // TODO if (!fork2_n_mount("/tty")) ansiterm_drv(); - __tty_fd = _syscall_open("/tty", sizeof("/tty") - 1); + __tty_fd = _syscall_open(argify("/com1")); if (__tty_fd < 0) _syscall_exit(1); diff --git a/src/kernel/arch/i386/driver/serial.c b/src/kernel/arch/i386/driver/serial.c index d2c34e7..14bb8fd 100644 --- a/src/kernel/arch/i386/driver/serial.c +++ b/src/kernel/arch/i386/driver/serial.c @@ -44,12 +44,11 @@ bool serial_poll_read(char *c) { size_t serial_read(char *buf, size_t len) { irq_interrupt_flag(true); for (size_t i = 0; i < len; i++) { - for (;;) { - if (serial_poll_read(&buf[i])) break; + while (!serial_poll_read(&buf[i])) asm("hlt" ::: "memory"); - } } irq_interrupt_flag(false); + // TODO root driver assumes no partial reads return len; } diff --git a/src/kernel/arch/i386/tty/tty.c b/src/kernel/arch/i386/tty/tty.c index ab15aba..fa3ce72 100644 --- a/src/kernel/arch/i386/tty/tty.c +++ b/src/kernel/arch/i386/tty/tty.c @@ -11,10 +11,6 @@ void tty_init(void) { serial_write("<3 ", 3); } -void tty_read(char *buf, size_t len) { - serial_read(buf, len); -} - void tty_write(const char *buf, size_t len) { vga_write(buf, len); serial_write(buf, len); diff --git a/src/kernel/arch/io.h b/src/kernel/arch/io.h index acba67a..ef8cb17 100644 --- a/src/kernel/arch/io.h +++ b/src/kernel/arch/io.h @@ -2,7 +2,6 @@ #include <stddef.h> void tty_init(void); -void tty_read(char *buf, size_t len); void tty_write(const char *buf, size_t len); static inline void _tty_hex(const char *buf, size_t len) { diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c index b8b41fc..f61096c 100644 --- a/src/kernel/vfs/root.c +++ b/src/kernel/vfs/root.c @@ -12,7 +12,6 @@ enum { HANDLE_ROOT, - HANDLE_TTY, HANDLE_VGA, HANDLE_COM1, HANDLE_PS2, @@ -60,9 +59,7 @@ int vfs_root_handler(struct vfs_request *req) { switch (req->type) { case VFSOP_OPEN: if (exacteq(req, "/")) return HANDLE_ROOT; - if (exacteq(req, "/tty")) return HANDLE_TTY; if (exacteq(req, "/vga")) return HANDLE_VGA; - if (exacteq(req, "/com1")) return HANDLE_COM1; if (exacteq(req, "/ps2")) return HANDLE_PS2; @@ -83,7 +80,6 @@ int vfs_root_handler(struct vfs_request *req) { case HANDLE_ROOT: { // TODO document directory read format const char src[] = - "tty\0" "vga\0" "com1\0" "ps2\0" @@ -93,14 +89,6 @@ int vfs_root_handler(struct vfs_request *req) { virt_cpy_to(req->caller->pages, req->output.buf, src, len); return len; } - case HANDLE_TTY: { - struct virt_iter iter; - virt_iter_new(&iter, req->output.buf, req->output.len, - req->caller->pages, true, false); - while (virt_iter_next(&iter)) - tty_read(iter.frag, iter.frag_len); - return iter.prior; - } case HANDLE_VGA: { char *vga = (void*)0xB8000; req_preprocess(req, 80*25*2); @@ -109,10 +97,12 @@ int vfs_root_handler(struct vfs_request *req) { return req->output.len; } case HANDLE_COM1: { - char buf[16]; - size_t len = serial_read(buf, sizeof buf); - virt_cpy_to(req->caller->pages, req->output.buf, buf, len); - return len; + struct virt_iter iter; + virt_iter_new(&iter, req->output.buf, req->output.len, + req->caller->pages, true, false); + while (virt_iter_next(&iter)) + serial_read(iter.frag, iter.frag_len); + return iter.prior; } case HANDLE_PS2: { uint8_t buf[16]; @@ -150,14 +140,6 @@ int vfs_root_handler(struct vfs_request *req) { case VFSOP_WRITE: switch (req->id) { case HANDLE_ROOT: return -1; - case HANDLE_TTY: { - struct virt_iter iter; - virt_iter_new(&iter, req->input.buf, req->input.len, - req->caller->pages, true, false); - while (virt_iter_next(&iter)) - tty_write(iter.frag, iter.frag_len); - return iter.prior; - } case HANDLE_VGA: { void *vga = (void*)0xB8000; req_preprocess(req, 80*25*2); |