diff options
author | Marvin Borner | 2021-04-14 13:39:42 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-14 13:39:42 +0200 |
commit | 212582f69dea4c99c292081b15ea526014b9ad44 (patch) | |
tree | c4fc1643c5acb8821fc0cfbd1b9c0983a50afe97 /kernel/features | |
parent | 9ded3a2bde80eede5fd887812d70c2f834b53c84 (diff) |
Even more I/O - started new PS/2 driver
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/io.c | 41 | ||||
-rw-r--r-- | kernel/features/syscall.c | 11 |
2 files changed, 37 insertions, 15 deletions
diff --git a/kernel/features/io.c b/kernel/features/io.c index 2bd925b..5d69b8e 100644 --- a/kernel/features/io.c +++ b/kernel/features/io.c @@ -5,6 +5,7 @@ #include <io.h> #include <list.h> #include <mm.h> +#include <ps2.h> #include <rand.h> #include <str.h> @@ -29,12 +30,13 @@ CLEAR void io_add(enum io_type io, struct io_dev *dev) io_mappings[io] = dev; } -res io_control(enum io_type io) +res io_control(enum io_type io, u32 request, void *arg1, void *arg2, void *arg3) { - if (!io_get(io)) + struct io_dev *dev; + if (!(dev = io_get(io)) || !dev->control) return -ENOENT; - return -ENOENT; + return dev->control(request, arg1, arg2, arg3); } res io_write(enum io_type io, void *buf, u32 offset, u32 count) @@ -42,8 +44,11 @@ res io_write(enum io_type io, void *buf, u32 offset, u32 count) if (!memory_readable(buf)) return -EFAULT; - if (!io_get(io)) + struct io_dev *dev; + if (!(dev = io_get(io)) || !dev->write) return -ENOENT; + + return dev->write(buf, offset, count); } res io_read(enum io_type io, void *buf, u32 offset, u32 count) @@ -51,17 +56,35 @@ res io_read(enum io_type io, void *buf, u32 offset, u32 count) if (!memory_readable(buf)) return -EFAULT; - if (!io_get(io)) + struct io_dev *dev; + if (!(dev = io_get(io)) || !dev->read) return -ENOENT; + + return dev->read(buf, offset, count); } -res io_poll(enum io_type io) +res io_poll(u32 *devs) { - if (!io_get(io)) - return -ENOENT; + if (!memory_readable(devs)) + return -EFAULT; + + for (u32 *p = devs; p && memory_readable(p) && *p; p++) { + if (!io_get(*p)) + return -ENOENT; + } + + return -EFAULT; } CLEAR void io_install(void) { - // TODO: Install I/O devices by selecting best working driver + ps2_detect(); + + if (ps2_keyboard_support()) { + print("KBD!\n"); + } + + if (ps2_mouse_support()) { + print("MOUSE!\n"); + } } diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 1e21edd..abd7130 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -53,15 +53,10 @@ static void syscall_handler(struct regs *r) r->eax = vfs_write((char *)r->ebx, (void *)r->ecx, r->edx, r->esi); break; } - case SYS_IOCTL: { - r->eax = vfs_ioctl((char *)r->ebx, r->ecx, (void *)r->edx, (void *)r->esi, - (void *)r->edi); - break; - } // I/O operations case SYS_IOPOLL: { - r->eax = io_poll((void *)r->ebx); + r->eax = io_poll((u32 *)r->ebx); break; } case SYS_IOREAD: { @@ -72,6 +67,10 @@ static void syscall_handler(struct regs *r) r->eax = io_write(r->ebx, (void *)r->ecx, r->edx, r->esi); break; } + case SYS_IOCONTROL: { + r->eax = io_control(r->ebx, r->ecx, (void *)r->edx, (void *)r->esi, (void *)r->edi); + break; + } // Process operations case SYS_EXEC: { |