From dc42353f53df0b5425377330f16e668829d8fd9a Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 5 May 2022 21:01:25 +0200 Subject: kernel: ps2 driver is now a separate backend --- src/kernel/vfs/mount.c | 22 +++++++++++++++++++++- src/kernel/vfs/request.h | 1 + src/kernel/vfs/root.c | 9 --------- 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'src/kernel/vfs') diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c index a6c5970..232e702 100644 --- a/src/kernel/vfs/mount.c +++ b/src/kernel/vfs/mount.c @@ -4,6 +4,8 @@ #include #include +#include + struct vfs_mount *vfs_mount_seed(void) { struct vfs_mount *mount = kmalloc(sizeof *mount); struct vfs_backend *backend = kmalloc(sizeof *backend); @@ -19,7 +21,25 @@ struct vfs_mount *vfs_mount_seed(void) { .backend = backend, .refs = 1, // never to be freed }; - return mount; + + // what a mess. + // TODO register funcs + struct vfs_mount *ps2 = kmalloc(sizeof *ps2); + backend = kmalloc(sizeof *backend); + backend->is_user = false; + backend->potential_handlers = 1; + backend->refcount = 1; + backend->kern.ready = vfs_ps2_ready; + backend->kern.accept = vfs_ps2_accept; + *ps2 = (struct vfs_mount){ + .prev = mount, + .prefix = "/ps2", + .prefix_len = 4, + .backend = backend, + .refs = 1, + }; + + return ps2; } struct vfs_mount *vfs_mount_resolve( diff --git a/src/kernel/vfs/request.h b/src/kernel/vfs/request.h index e62f28f..b4624fa 100644 --- a/src/kernel/vfs/request.h +++ b/src/kernel/vfs/request.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include #include diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c index 701d4e6..0c58d86 100644 --- a/src/kernel/vfs/root.c +++ b/src/kernel/vfs/root.c @@ -15,7 +15,6 @@ enum { HANDLE_ROOT, HANDLE_VGA, HANDLE_COM1, - HANDLE_PS2, HANDLE_ATA_ROOT, HANDLE_ATA, _SKIP = HANDLE_ATA + 4, @@ -72,7 +71,6 @@ static int handle(struct vfs_request *req, bool *ready) { if (exacteq(req, "/")) return HANDLE_ROOT; if (exacteq(req, "/vga")) return HANDLE_VGA; if (exacteq(req, "/com1")) return HANDLE_COM1; - if (exacteq(req, "/ps2")) return HANDLE_PS2; if (exacteq(req, "/ata/")) return HANDLE_ATA_ROOT; if (exacteq(req, "/ata/0")) @@ -113,13 +111,6 @@ static int handle(struct vfs_request *req, bool *ready) { virt_cpy_to(req->caller->pages, req->output.buf, buf, len); return len; } - case HANDLE_PS2: { - if (wait_setup(req, ready, ps2_ready)) return -1; - uint8_t buf[16]; - size_t len = ps2_read(buf, min(req->output.len, sizeof buf)); - virt_cpy_to(req->caller->pages, req->output.buf, buf, len); - return len; - } case HANDLE_ATA_ROOT: { // TODO offset char list[8] = {}; -- cgit v1.2.3