From 96a1be7e79704d3d60324547b689f8dcdc357524 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 28 Aug 2022 14:53:48 +0200 Subject: kernel/driver: add postqueue_join / postqueue_pop --- src/kernel/arch/amd64/driver/serial.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/kernel/arch/amd64/driver/serial.c') diff --git a/src/kernel/arch/amd64/driver/serial.c b/src/kernel/arch/amd64/driver/serial.c index 9ddb355..2b0812b 100644 --- a/src/kernel/arch/amd64/driver/serial.c +++ b/src/kernel/arch/amd64/driver/serial.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -43,10 +44,7 @@ void serial_preinit(void) { void serial_irq(void) { ring_put1b((void*)&backlog, port_in8(COM1)); - if (blocked_on) { - accept(blocked_on); - blocked_on = blocked_on->postqueue_next; - } + postqueue_pop(&blocked_on, accept); } @@ -71,11 +69,7 @@ static void accept(struct vfs_request *req) { break; case VFSOP_READ: if (ring_used((void*)&backlog) == 0) { - /* nothing to read, join queue */ - assert(!req->postqueue_next); - struct vfs_request **slot = &blocked_on; - while (*slot) slot = &(*slot)->postqueue_next; - *slot = req; + postqueue_join(&blocked_on, req); } else if (req->caller) { ret = ring_to_virt((void*)&backlog, req->caller->pages, req->output.buf, req->output.len); // TODO output.len can overflow here -- cgit v1.2.3