diff options
author | dzwdz | 2022-04-10 16:17:57 +0200 |
---|---|---|
committer | dzwdz | 2022-04-10 16:17:57 +0200 |
commit | ec7c6eff3c10565a57ba2b2c14b3f224d9216b76 (patch) | |
tree | 2c61068f72f40403b16863776eb0bd9eacaf1198 /src/kernel/vfs/root.c | |
parent | 1677ac032bb89f87456ac5668118f0091ae5ed9f (diff) |
kernel/i386: rewrite the serial driver to wait for IRQ
proper multiprocess support!
Diffstat (limited to 'src/kernel/vfs/root.c')
-rw-r--r-- | src/kernel/vfs/root.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/kernel/vfs/root.c b/src/kernel/vfs/root.c index 89c2b3e..b5f7a8a 100644 --- a/src/kernel/vfs/root.c +++ b/src/kernel/vfs/root.c @@ -97,12 +97,19 @@ static int handle(struct vfs_request *req, bool *ready) { return req->output.len; } case HANDLE_COM1: { - 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; + // yet another bit of code shared between serial and ps2. + // i really should think how i could unite both of those + if (!serial_ready()) { + *ready = false; + req->caller->state = PS_WAITS4IRQ; + req->caller->waits4irq.req = *req; + req->caller->waits4irq.ready = serial_ready; + return -1; + } + uint8_t buf[16]; + size_t len = serial_read(buf, sizeof buf); + virt_cpy_to(req->caller->pages, req->output.buf, buf, len); + return len; } case HANDLE_PS2: { if (!ps2_ready()) { |