From 3e7d1acffd81175246fab1ed8be30569c9cd3289 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 10 Apr 2022 15:13:49 +0200 Subject: kernel: idle process --- src/kernel/vfs/request.c | 5 +---- src/kernel/vfs/root.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/kernel/vfs') diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 5b65e52..e8bf147 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -7,7 +7,6 @@ int vfs_request_create(struct vfs_request req_) { struct vfs_request *req; - int ret; process_current->state = PS_WAITS4FS; process_current->waits4fs.queue_next = NULL; @@ -20,9 +19,7 @@ int vfs_request_create(struct vfs_request req_) { switch (req->backend->type) { case VFS_BACK_ROOT: - ret = vfs_root_handler(req); - ret = vfs_request_finish(req, ret); - return ret; + return vfs_root_handler(req); case VFS_BACK_USER: if (req->backend->handler && req->backend->handler->state == PS_WAITS4REQUEST) diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c index f61096c..89c2b3e 100644 --- a/src/kernel/vfs/root.c +++ b/src/kernel/vfs/root.c @@ -55,7 +55,7 @@ static void req_preprocess(struct vfs_request *req, int max_len) { assert(req->input.len + req->offset <= max_len); } -int vfs_root_handler(struct vfs_request *req) { +static int handle(struct vfs_request *req, bool *ready) { switch (req->type) { case VFSOP_OPEN: if (exacteq(req, "/")) return HANDLE_ROOT; @@ -105,6 +105,16 @@ int vfs_root_handler(struct vfs_request *req) { return iter.prior; } case HANDLE_PS2: { + if (!ps2_ready()) { + *ready = false; + req->caller->state = PS_WAITS4IRQ; + /* not copying any memory, both sides point to the same + * struct. this line's only there so i don't depend on + * struct alignment always staying the same */ + req->caller->waits4irq.req = *req; + req->caller->waits4irq.ready = ps2_ready; + return -1; + } uint8_t buf[16]; size_t len = ps2_read(buf, sizeof buf); virt_cpy_to(req->caller->pages, req->output.buf, buf, len); @@ -163,3 +173,12 @@ int vfs_root_handler(struct vfs_request *req) { default: panic_invalid_state(); } } + +int vfs_root_handler(struct vfs_request *req) { + bool ready = true; + int ret = handle(req, &ready); + if (ready) + return vfs_request_finish(req, ret); + else + return -1; +} -- cgit v1.2.3