diff options
author | dzwdz | 2022-05-05 22:12:55 +0200 |
---|---|---|
committer | dzwdz | 2022-05-05 22:12:55 +0200 |
commit | 9900cc737988f25db30b5876f066a78e73389205 (patch) | |
tree | 1bba6cfbe118855ba3d338aa3d881da3aa15ca9e /src/kernel/arch | |
parent | 740cacba5befeba212935b00f8ae95008f564293 (diff) |
kernel: syscalls now have to explicitly save the return value
thus they can opt out of doing that
so the calls which might return immediately but can return later don't
have to both regs_savereturn and return to the caller.
and because of that, the return values of a lot of VFS things have just
got way saner
Diffstat (limited to 'src/kernel/arch')
-rw-r--r-- | src/kernel/arch/i386/driver/ps2.c | 12 | ||||
-rw-r--r-- | src/kernel/arch/i386/driver/ps2.h | 2 | ||||
-rw-r--r-- | src/kernel/arch/i386/driver/serial.c | 15 | ||||
-rw-r--r-- | src/kernel/arch/i386/driver/serial.h | 2 | ||||
-rw-r--r-- | src/kernel/arch/i386/registers.h | 3 | ||||
-rw-r--r-- | src/kernel/arch/i386/sysenter.c | 1 |
6 files changed, 20 insertions, 15 deletions
diff --git a/src/kernel/arch/i386/driver/ps2.c b/src/kernel/arch/i386/driver/ps2.c index 666fa76..8955100 100644 --- a/src/kernel/arch/i386/driver/ps2.c +++ b/src/kernel/arch/i386/driver/ps2.c @@ -28,14 +28,15 @@ size_t ps2_read(uint8_t *buf, size_t len) { return ring_get((void*)&backlog, buf, len); } -int vfs_ps2_accept(struct vfs_request *req) { +void vfs_ps2_accept(struct vfs_request *req) { // when you fix something here go also fix it in the COM1 driver static uint8_t buf[32]; // pretty damn stupid int ret; switch (req->type) { case VFSOP_OPEN: // allows opening /ps2/anything, TODO don't - return vfsreq_finish(req, 0); // fake file handle, whatever + vfsreq_finish(req, 0); // fake file handle, whatever + break; case VFSOP_READ: if (ps2_ready()) { // TODO FUKKEN MESS @@ -48,13 +49,14 @@ int vfs_ps2_accept(struct vfs_request *req) { ret = ps2_read(buf, ret); virt_cpy_to(req->caller->pages, req->output.buf, buf, ret); } else ret = -1; - return vfsreq_finish(req, ret); + vfsreq_finish(req, ret); } else { blocked_on = req; - return -1; } + break; default: - return vfsreq_finish(req, -1); + vfsreq_finish(req, -1); + break; } } diff --git a/src/kernel/arch/i386/driver/ps2.h b/src/kernel/arch/i386/driver/ps2.h index 1bbc2f1..c5d0ce1 100644 --- a/src/kernel/arch/i386/driver/ps2.h +++ b/src/kernel/arch/i386/driver/ps2.h @@ -8,5 +8,5 @@ bool ps2_ready(void); void ps2_recv(uint8_t scancode); size_t ps2_read(uint8_t *buf, size_t max_len); -int vfs_ps2_accept(struct vfs_request *); +void vfs_ps2_accept(struct vfs_request *); bool vfs_ps2_ready(struct vfs_backend *); diff --git a/src/kernel/arch/i386/driver/serial.c b/src/kernel/arch/i386/driver/serial.c index 4e274d8..170cc4d 100644 --- a/src/kernel/arch/i386/driver/serial.c +++ b/src/kernel/arch/i386/driver/serial.c @@ -69,12 +69,13 @@ void serial_write(const char *buf, size_t len) { } -int vfs_com1_accept(struct vfs_request *req) { +void vfs_com1_accept(struct vfs_request *req) { static uint8_t buf[32]; int ret; switch (req->type) { case VFSOP_OPEN: - return vfsreq_finish(req, 0); + vfsreq_finish(req, 0); + break; case VFSOP_READ: if (serial_ready()) { if (req->caller) { @@ -86,11 +87,11 @@ int vfs_com1_accept(struct vfs_request *req) { ret = serial_read(buf, ret); virt_cpy_to(req->caller->pages, req->output.buf, buf, ret); } else ret = -1; - return vfsreq_finish(req, ret); + vfsreq_finish(req, ret); } else { blocked_on = req; - return -1; } + break; case VFSOP_WRITE: if (req->caller) { struct virt_iter iter; @@ -100,9 +101,11 @@ int vfs_com1_accept(struct vfs_request *req) { serial_write(iter.frag, iter.frag_len); ret = iter.prior; } else ret = -1; - return vfsreq_finish(req, ret); + vfsreq_finish(req, ret); + break; default: - return vfsreq_finish(req, -1); + vfsreq_finish(req, -1); + break; } } diff --git a/src/kernel/arch/i386/driver/serial.h b/src/kernel/arch/i386/driver/serial.h index e7f9b7c..6aff142 100644 --- a/src/kernel/arch/i386/driver/serial.h +++ b/src/kernel/arch/i386/driver/serial.h @@ -11,5 +11,5 @@ size_t serial_read(char *buf, size_t len); void serial_write(const char *buf, size_t len); -int vfs_com1_accept(struct vfs_request *); +void vfs_com1_accept(struct vfs_request *); bool vfs_com1_ready(struct vfs_backend *); diff --git a/src/kernel/arch/i386/registers.h b/src/kernel/arch/i386/registers.h index 8bd090d..9f481d3 100644 --- a/src/kernel/arch/i386/registers.h +++ b/src/kernel/arch/i386/registers.h @@ -14,7 +14,8 @@ struct registers { } __attribute__((__packed__)); // saves a return value according to the SysV ABI -static inline void regs_savereturn(struct registers *regs, uint64_t value) { +static inline uint64_t regs_savereturn(struct registers *regs, uint64_t value) { regs->eax = value; regs->edx = value >> 32; + return value; } diff --git a/src/kernel/arch/i386/sysenter.c b/src/kernel/arch/i386/sysenter.c index 1d2a333..71dfbe9 100644 --- a/src/kernel/arch/i386/sysenter.c +++ b/src/kernel/arch/i386/sysenter.c @@ -23,6 +23,5 @@ _Noreturn void sysenter_stage2(void) { val = _syscall(regs->eax, regs->ebx, regs->esi, regs->edi, (uintptr_t)regs->ebp); - regs_savereturn(&process_current->regs, val); process_switch_any(); } |