diff options
author | Marvin Borner | 2021-06-18 22:30:25 +0200 |
---|---|---|
committer | Marvin Borner | 2021-06-18 22:30:25 +0200 |
commit | 02a0c882275959c0fbd58754418ecc1218821e76 (patch) | |
tree | 7174e4c11a030b6bd7081a71ffa3bd6eee194c4e /kernel | |
parent | b3d8e50aab8f3587f510db13ac8dcbb82e287998 (diff) |
Renamed device prefix from 'io_' to 'dev_'
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/Makefile | 2 | ||||
-rw-r--r-- | kernel/drivers/bga.c | 8 | ||||
-rw-r--r-- | kernel/drivers/ps2/keyboard.c | 8 | ||||
-rw-r--r-- | kernel/drivers/ps2/mouse.c | 8 | ||||
-rw-r--r-- | kernel/drivers/timer.c | 6 | ||||
-rw-r--r-- | kernel/drivers/vbe.c | 8 | ||||
-rw-r--r-- | kernel/drivers/vmware.c | 8 | ||||
-rw-r--r-- | kernel/features/bus.c | 29 | ||||
-rw-r--r-- | kernel/features/dev.c (renamed from kernel/features/io.c) | 112 | ||||
-rw-r--r-- | kernel/features/logger.c | 6 | ||||
-rw-r--r-- | kernel/features/syscall.c | 26 | ||||
-rw-r--r-- | kernel/inc/dev.h | 32 | ||||
-rw-r--r-- | kernel/inc/fs.h | 4 | ||||
-rw-r--r-- | kernel/inc/io.h | 32 | ||||
-rw-r--r-- | kernel/main.c | 4 |
15 files changed, 146 insertions, 147 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index 7107e14..9fed3f1 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -22,7 +22,7 @@ COBJS = entry_asm.o \ drivers/ps2/keyboard.o \ features/mm.o \ features/fs.o \ - features/io.o \ + features/dev.o \ features/bus.o \ features/fb.o \ features/logger.o \ diff --git a/kernel/drivers/bga.c b/kernel/drivers/bga.c index 2f3b1fa..cc93b75 100644 --- a/kernel/drivers/bga.c +++ b/kernel/drivers/bga.c @@ -2,11 +2,11 @@ #include <assert.h> #include <def.h> +#include <dev.h> #include <drivers/bga.h> #include <drivers/cpu.h> #include <drivers/pci.h> #include <fb.h> -#include <io.h> #include <mem.h> #include <mm.h> @@ -75,7 +75,7 @@ static res bga_control(u32 request, void *arg1, void *arg2, void *arg3) UNUSED(arg3); switch (request) { - case IOCTL_FB_GET: { + case DEVCTL_FB_GET: { if (!generic.fb) return -ENOENT; @@ -121,7 +121,7 @@ CLEAR void bga_install(void) { bga_enable(1920, 1200, 32); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->control = bga_control; - io_add(IO_FRAMEBUFFER, dev); + dev_add(DEV_FRAMEBUFFER, dev); } diff --git a/kernel/drivers/ps2/keyboard.c b/kernel/drivers/ps2/keyboard.c index 3516a7e..b16f4b2 100644 --- a/kernel/drivers/ps2/keyboard.c +++ b/kernel/drivers/ps2/keyboard.c @@ -1,11 +1,11 @@ // MIT License, Copyright (c) 2020 Marvin Borner #include <def.h> +#include <dev.h> #include <drivers/cpu.h> #include <drivers/int.h> #include <drivers/ps2.h> #include <errno.h> -#include <io.h> #include <mem.h> #include <print.h> #include <proc.h> @@ -43,7 +43,7 @@ static void keyboard_handler(void) state = 0; merged = 0; - io_unblock(IO_KEYBOARD); + dev_unblock(DEV_KEYBOARD); } static res keyboard_read(void *buf, u32 offset, u32 count) @@ -75,8 +75,8 @@ CLEAR void ps2_keyboard_install(u8 device) int_event_handler_add(1, keyboard_handler); queue = stack_new(); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->read = keyboard_read; dev->ready = keyboard_ready; - io_add(IO_KEYBOARD, dev); + dev_add(DEV_KEYBOARD, dev); } diff --git a/kernel/drivers/ps2/mouse.c b/kernel/drivers/ps2/mouse.c index ab20c90..086f522 100644 --- a/kernel/drivers/ps2/mouse.c +++ b/kernel/drivers/ps2/mouse.c @@ -1,11 +1,11 @@ // MIT License, Copyright (c) 2020 Marvin Borner #include <assert.h> +#include <dev.h> #include <drivers/cpu.h> #include <drivers/int.h> #include <drivers/ps2.h> #include <errno.h> -#include <io.h> #include <mem.h> #include <print.h> #include <proc.h> @@ -33,7 +33,7 @@ static void mouse_finish(void) event->but.middle = (mouse_byte[0] >> 2) & 1; stack_push_bot(queue, event); mouse_cycle = 0; - io_unblock(IO_MOUSE); + dev_unblock(DEV_MOUSE); } static void mouse_handler(void) @@ -141,8 +141,8 @@ CLEAR void ps2_mouse_install(u8 device) int_event_handler_add(12, mouse_handler); queue = stack_new(); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->read = mouse_read; dev->ready = mouse_ready; - io_add(IO_MOUSE, dev); + dev_add(DEV_MOUSE, dev); } diff --git a/kernel/drivers/timer.c b/kernel/drivers/timer.c index 44d66f3..977647c 100644 --- a/kernel/drivers/timer.c +++ b/kernel/drivers/timer.c @@ -1,11 +1,11 @@ // MIT License, Copyright (c) 2020 Marvin Borner #include <def.h> +#include <dev.h> #include <drivers/cpu.h> #include <drivers/int.h> #include <drivers/rtc.h> #include <drivers/timer.h> -#include <io.h> #include <mem.h> #include <proc.h> @@ -70,7 +70,7 @@ CLEAR void timer_install(void) timer_phase(1000); int_event_handler_add(0, timer_handler); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->read = timer_read; - io_add(IO_TIMER, dev); + dev_add(DEV_TIMER, dev); } diff --git a/kernel/drivers/vbe.c b/kernel/drivers/vbe.c index fd91062..2ba9fb1 100644 --- a/kernel/drivers/vbe.c +++ b/kernel/drivers/vbe.c @@ -2,11 +2,11 @@ #include <assert.h> #include <def.h> +#include <dev.h> #include <drivers/cpu.h> #include <drivers/vbe.h> #include <errno.h> #include <fb.h> -#include <io.h> #include <mem.h> #include <mm.h> #include <multiboot.h> @@ -31,7 +31,7 @@ static res vbe_control(u32 request, void *arg1, void *arg2, void *arg3) UNUSED(arg3); switch (request) { - case IOCTL_FB_GET: { + case DEVCTL_FB_GET: { if (!generic.fb) return -ENOENT; @@ -67,7 +67,7 @@ CLEAR void vbe_install(u32 data) generic.fb = vbe->fb; fb_protect(&generic); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->control = vbe_control; - io_add(IO_FRAMEBUFFER, dev); + dev_add(DEV_FRAMEBUFFER, dev); } diff --git a/kernel/drivers/vmware.c b/kernel/drivers/vmware.c index 24f56a0..b2069b6 100644 --- a/kernel/drivers/vmware.c +++ b/kernel/drivers/vmware.c @@ -2,10 +2,10 @@ // VMWare extensions/backdoors for better VM integration #include <def.h> +#include <dev.h> #include <drivers/int.h> #include <drivers/ps2.h> #include <drivers/vmware.h> -#include <io.h> #include <mem.h> #include <print.h> #include <stack.h> @@ -125,7 +125,7 @@ static void vmware_mouse_handler(void) event->but.right = (buttons & VMMOUSE_RIGHT_CLICK) != 0; event->but.middle = (buttons & VMMOUSE_MIDDLE_CLICK) != 0; stack_push_bot(queue, event); - io_unblock(IO_MOUSE); + dev_unblock(DEV_MOUSE); } static res vmware_mouse_ready(void) @@ -152,8 +152,8 @@ CLEAR void vmware_mouse_install(u8 device) int_event_handler_add(12, vmware_mouse_handler); queue = stack_new(); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->read = vmware_mouse_read; dev->ready = vmware_mouse_ready; - io_add(IO_MOUSE, dev); + dev_add(DEV_MOUSE, dev); } diff --git a/kernel/features/bus.c b/kernel/features/bus.c index 3757a3a..ad7352f 100644 --- a/kernel/features/bus.c +++ b/kernel/features/bus.c @@ -4,9 +4,9 @@ #include <bus.h> #include <crypto.h> #include <def.h> +#include <dev.h> #include <drivers/cpu.h> #include <errno.h> -#include <io.h> #include <list.h> #include <mem.h> #include <mm.h> @@ -36,8 +36,8 @@ struct bus { u32 hash; }; -PROTECTED struct list *bus_list = NULL; -PROTECTED struct list *bus_conns = NULL; +PROTECTED static struct list *bus_list = NULL; +PROTECTED static struct list *bus_conns = NULL; static u32 conn_cnt = 1; // 0 is reserved static struct bus *bus_find_bus(u32 hash) @@ -104,7 +104,10 @@ static res bus_register(const char *name) u32 hash = crc32_user(0, name, len); if (bus_find_bus(hash)) - return -EBUSY; + return -EINVAL; + + if (bus_find_owner(proc_current()->pid)) + return -EEXIST; struct bus *bus = zalloc(sizeof(*bus)); strlcpy_user(bus->name, name, sizeof(bus->name)); @@ -182,10 +185,10 @@ static res bus_send(u32 conn, const void *buf, u32 count) if (bus->pid == proc_current()->pid) { stack_push_bot(bus_conn->out, msg); - io_unblock_pid(bus_conn->pid); + dev_unblock_pid(bus_conn->pid); } else { stack_push_bot(bus_conn->in, msg); - io_unblock_pid(bus->pid); + dev_unblock_pid(bus->pid); } return count; @@ -229,8 +232,6 @@ static res bus_receive(void *buf, u32 offset, u32 count) if (!bus_owner && !bus_conn) return -ENOENT; - // TODO: Better round-robin - if (bus_owner) { struct node *iterator = bus_conns->head; while (iterator) { @@ -257,13 +258,13 @@ static res bus_control(u32 request, void *arg1, void *arg2, void *arg3) UNUSED(arg3); switch (request) { - case IOCTL_BUS_CONNECT_BUS: { + case DEVCTL_BUS_CONNECT_BUS: { return bus_connect_bus(arg1, arg2); } - case IOCTL_BUS_CONNECT_CONN: { + case DEVCTL_BUS_CONNECT_CONN: { return bus_connect_conn((u32)arg1); } - case IOCTL_BUS_REGISTER: { + case DEVCTL_BUS_REGISTER: { return bus_register(arg1); } default: { @@ -307,8 +308,6 @@ static res bus_ready(void) if (!bus_owner && !bus_conn) return -ENOENT; - // TODO: Better round-robin - if (bus_owner) { struct node *iterator = bus_conns->head; while (iterator) { @@ -331,10 +330,10 @@ CLEAR void bus_install(void) bus_list = list_new(); bus_conns = list_new(); - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->control = bus_control; dev->read = bus_read; dev->ready = bus_ready; dev->write = bus_write; - io_add(IO_BUS, dev); + dev_add(DEV_BUS, dev); } diff --git a/kernel/features/io.c b/kernel/features/dev.c index 8126ccf..ecc3f0c 100644 --- a/kernel/features/io.c +++ b/kernel/features/dev.c @@ -3,6 +3,7 @@ #include <assert.h> #include <bus.h> #include <def.h> +#include <dev.h> #include <drivers/bga.h> #include <drivers/cpu.h> #include <drivers/int.h> @@ -11,7 +12,6 @@ #include <drivers/vbe.h> #include <drivers/vmware.h> #include <fb.h> -#include <io.h> #include <list.h> #include <logger.h> #include <mem.h> @@ -22,39 +22,39 @@ #include <str.h> #include <syscall.h> -struct io_listener { +struct dev_listener { u32 group; struct proc *proc; }; -PROTECTED static struct io_dev *io_mappings[IO_MAX] = { 0 }; -PROTECTED static struct list *io_listeners[IO_MAX] = { 0 }; +PROTECTED static struct dev_dev *dev_mappings[DEV_MAX] = { 0 }; +PROTECTED static struct list *dev_listeners[DEV_MAX] = { 0 }; static u32 group_id = 0; -static u8 io_type_valid(enum io_type io) +static u8 dev_type_valid(enum dev_type type) { - return io > IO_MIN && io < IO_MAX; + return type > DEV_MIN && type < DEV_MAX; } -static struct io_dev *io_get(enum io_type io) +static struct dev_dev *dev_get(enum dev_type type) { - if (!io_type_valid(io)) + if (!dev_type_valid(type)) return NULL; - return io_mappings[io]; + return dev_mappings[type]; } // TODO: Efficiency -static void io_remove_group(u32 group) +static void dev_remove_group(u32 group) { - for (u32 io = IO_MIN; io < IO_MAX; io++) { - struct node *iterator = io_listeners[io]->head; + for (u32 dev = DEV_MIN; dev < DEV_MAX; dev++) { + struct node *iterator = dev_listeners[dev]->head; while (iterator) { - struct io_listener *listener = iterator->data; + struct dev_listener *listener = iterator->data; struct node *next = iterator->next; if (listener->group == group) - list_remove(io_listeners[io], iterator); + list_remove(dev_listeners[dev], iterator); iterator = next; } } @@ -63,13 +63,13 @@ static void io_remove_group(u32 group) group_id--; } -CLEAR void io_add(enum io_type io, struct io_dev *dev) +CLEAR void dev_add(enum dev_type type, struct dev_dev *dev) { - assert(io_type_valid(io) && !io_mappings[io]); - io_mappings[io] = dev; + assert(dev_type_valid(type) && !dev_mappings[type]); + dev_mappings[type] = dev; } -res io_poll(u32 *devs) +res dev_poll(u32 *devs) { if (!memory_readable(devs)) return -EFAULT; @@ -78,67 +78,67 @@ res io_poll(u32 *devs) for (u32 *p = devs; p && memory_readable(p); p++) { stac(); - enum io_type io = *p; + enum dev_type type = *p; clac(); - if (!io) + if (!type) break; - struct io_dev *dev = io_get(io); + struct dev_dev *dev = dev_get(type); if (!dev || !dev->read) { - io_remove_group(group); + dev_remove_group(group); return -ENOENT; } if (dev->ready) { res ready = dev->ready(); if (ready == EOK) { - io_remove_group(group); - return io; + dev_remove_group(group); + return type; } else if (ready != -EAGAIN) { return ready; } } - struct io_listener *listener = zalloc(sizeof(*listener)); + struct dev_listener *listener = zalloc(sizeof(*listener)); listener->group = group; listener->proc = proc_current(); - list_add(io_listeners[io], listener); + list_add(dev_listeners[type], listener); } proc_state(proc_current(), PROC_BLOCKED); proc_yield(); - return io_poll(devs); + return dev_poll(devs); } -res io_control(enum io_type io, u32 request, void *arg1, void *arg2, void *arg3) +res dev_control(enum dev_type type, u32 request, void *arg1, void *arg2, void *arg3) { - struct io_dev *dev; - if (!(dev = io_get(io)) || !dev->control) + struct dev_dev *dev; + if (!(dev = dev_get(type)) || !dev->control) return -ENOENT; return dev->control(request, arg1, arg2, arg3); } -res io_write(enum io_type io, const void *buf, u32 offset, u32 count) +res dev_write(enum dev_type type, const void *buf, u32 offset, u32 count) { if (!memory_readable_range(memory_range(buf, count))) return -EFAULT; - struct io_dev *dev; - if (!(dev = io_get(io)) || !dev->write) + struct dev_dev *dev; + if (!(dev = dev_get(type)) || !dev->write) return -ENOENT; return dev->write(buf, offset, count); } -res io_read(enum io_type io, void *buf, u32 offset, u32 count) +res dev_read(enum dev_type type, void *buf, u32 offset, u32 count) { if (!memory_writable_range(memory_range(buf, count))) return -EFAULT; - struct io_dev *dev; - if (!(dev = io_get(io)) || !dev->read) + struct dev_dev *dev; + if (!(dev = dev_get(type)) || !dev->read) return -ENOENT; if (dev->ready && dev->ready() != EOK) @@ -147,10 +147,10 @@ res io_read(enum io_type io, void *buf, u32 offset, u32 count) return dev->read(buf, offset, count); } -res io_ready(enum io_type io) +res dev_ready(enum dev_type type) { - struct io_dev *dev; - if (!(dev = io_get(io))) + struct dev_dev *dev; + if (!(dev = dev_get(type))) return -ENOENT; if (dev->ready && dev->ready() != EOK) @@ -159,27 +159,27 @@ res io_ready(enum io_type io) return EOK; } -void io_block(enum io_type io, struct proc *proc) +void dev_block(enum dev_type type, struct proc *proc) { - assert(io_type_valid(io)); - struct io_listener *listener = zalloc(sizeof(*listener)); + assert(dev_type_valid(type)); + struct dev_listener *listener = zalloc(sizeof(*listener)); listener->group = group_id++; listener->proc = proc; - list_add(io_listeners[io], listener); + list_add(dev_listeners[type], listener); proc_state(proc_current(), PROC_BLOCKED); proc_yield(); } -void io_unblock(enum io_type io) +void dev_unblock(enum dev_type type) { - assert(io_type_valid(io)); - struct node *iterator = io_listeners[io]->head; + assert(dev_type_valid(type)); + struct node *iterator = dev_listeners[type]->head; while (iterator) { - struct io_listener *listener = iterator->data; + struct dev_listener *listener = iterator->data; struct proc *proc = listener->proc; proc_state(proc, PROC_RUNNING); struct node *next = iterator->next; - io_remove_group(listener->group); + dev_remove_group(listener->group); free(listener); iterator = next; } @@ -188,17 +188,17 @@ void io_unblock(enum io_type io) proc_yield(); } -void io_unblock_pid(u32 pid) +void dev_unblock_pid(u32 pid) { - for (u32 io = IO_MIN; io < IO_MAX; io++) { - struct node *iterator = io_listeners[io]->head; + for (u32 type = DEV_MIN; type < DEV_MAX; type++) { + struct node *iterator = dev_listeners[type]->head; while (iterator) { - struct io_listener *listener = iterator->data; + struct dev_listener *listener = iterator->data; struct proc *proc = listener->proc; proc_state(proc, PROC_RUNNING); struct node *next = iterator->next; if (proc->pid == pid) { - list_remove(io_listeners[io], iterator); + list_remove(dev_listeners[type], iterator); free(listener); } iterator = next; @@ -209,10 +209,10 @@ void io_unblock_pid(u32 pid) proc_yield(); } -CLEAR void io_install(void) +CLEAR void dev_install(void) { - for (u32 i = 0; i < IO_MAX; i++) - io_listeners[i] = list_new(); + for (u32 i = 0; i < DEV_MAX; i++) + dev_listeners[i] = list_new(); /** * Keyboard & mouse detection diff --git a/kernel/features/logger.c b/kernel/features/logger.c index fd5d730..4385408 100644 --- a/kernel/features/logger.c +++ b/kernel/features/logger.c @@ -1,10 +1,10 @@ // MIT License, Copyright (c) 2021 Marvin Borner #include <def.h> +#include <dev.h> #include <drivers/cpu.h> #include <drivers/serial.h> #include <errno.h> -#include <io.h> #include <logger.h> #include <mem.h> #include <print.h> @@ -36,7 +36,7 @@ static res logger_write(const void *buf, u32 offset, u32 count) void logger_install(void) { - struct io_dev *dev = zalloc(sizeof(*dev)); + struct dev_dev *dev = zalloc(sizeof(*dev)); dev->write = logger_write; - io_add(IO_LOGGER, dev); + dev_add(DEV_LOGGER, dev); } diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c index 6e43caa..997fa96 100644 --- a/kernel/features/syscall.c +++ b/kernel/features/syscall.c @@ -1,11 +1,11 @@ // MIT License, Copyright (c) 2020 Marvin Borner +#include <dev.h> #include <drivers/cpu.h> #include <drivers/int.h> #include <drivers/timer.h> #include <errno.h> #include <fs.h> -#include <io.h> #include <load.h> #include <mem.h> #include <mm.h> @@ -57,29 +57,29 @@ static u32 syscall_handler(u32 esp) break; } - // I/O operations - case SYS_IOPOLL: { - frame->eax = io_poll((void *)frame->ebx); + // Device operations + case SYS_DEV_POLL: { + frame->eax = dev_poll((void *)frame->ebx); break; } - case SYS_IOREAD: { - res ready = io_ready(frame->ebx); + case SYS_DEV_READ: { + res ready = dev_ready(frame->ebx); if (ready == -EAGAIN) { - io_block(frame->ebx, proc_current()); + dev_block(frame->ebx, proc_current()); } else if (ready != EOK) { frame->eax = ready; break; } - frame->eax = io_read(frame->ebx, (void *)frame->ecx, frame->edx, frame->esi); + frame->eax = dev_read(frame->ebx, (void *)frame->ecx, frame->edx, frame->esi); break; } - case SYS_IOWRITE: { - frame->eax = io_write(frame->ebx, (void *)frame->ecx, frame->edx, frame->esi); + case SYS_DEV_WRITE: { + frame->eax = dev_write(frame->ebx, (void *)frame->ecx, frame->edx, frame->esi); break; } - case SYS_IOCONTROL: { - frame->eax = io_control(frame->ebx, frame->ecx, (void *)frame->edx, - (void *)frame->esi, (void *)frame->edi); + case SYS_DEV_CONTROL: { + frame->eax = dev_control(frame->ebx, frame->ecx, (void *)frame->edx, + (void *)frame->esi, (void *)frame->edi); break; } diff --git a/kernel/inc/dev.h b/kernel/inc/dev.h new file mode 100644 index 0000000..fc5e424 --- /dev/null +++ b/kernel/inc/dev.h @@ -0,0 +1,32 @@ +// MIT License, Copyright (c) 2021 Marvin Borner + +#ifndef dev_H +#define dev_H + +#include <def.h> +#include <drivers/int.h> +#include <proc.h> +#include <sys.h> + +struct dev_dev { + res (*read)(void *buf, u32 offset, u32 count) NONNULL; + res (*write)(const void *buf, u32 offset, u32 count) NONNULL; + res (*control)(u32 request, void *arg1, void *arg2, void *arg3); + res (*ready)(void); +}; + +void dev_install(void); +void dev_add(enum dev_type type, struct dev_dev *dev) NONNULL; + +// No NONNULL on syscalls +res dev_control(enum dev_type type, u32 request, void *arg1, void *arg2, void *arg3); +res dev_write(enum dev_type type, const void *buf, u32 offset, u32 count); +res dev_read(enum dev_type type, void *buf, u32 offset, u32 count); +res dev_poll(u32 *devs); +res dev_ready(enum dev_type type); + +void dev_block(enum dev_type type, struct proc *proc) NONNULL; +void dev_unblock(enum dev_type type); +void dev_unblock_pid(u32 pid); + +#endif diff --git a/kernel/inc/fs.h b/kernel/inc/fs.h index 1ea4b21..42cf21a 100644 --- a/kernel/inc/fs.h +++ b/kernel/inc/fs.h @@ -11,12 +11,12 @@ * Device */ -enum dev_type { DEV_BLOCK, DEV_CHAR }; +enum vfs_dev_type { DEV_BLOCK, DEV_CHAR }; struct vfs_dev { u32 id; char name[8]; - enum dev_type type; + enum vfs_dev_type type; struct vfs *vfs; void *data; res (*read)(void *buf, u32 offset, u32 count, struct vfs_dev *dev) NONNULL; diff --git a/kernel/inc/io.h b/kernel/inc/io.h deleted file mode 100644 index c20a6f7..0000000 --- a/kernel/inc/io.h +++ /dev/null @@ -1,32 +0,0 @@ -// MIT License, Copyright (c) 2021 Marvin Borner - -#ifndef IO_H -#define IO_H - -#include <def.h> -#include <drivers/int.h> -#include <proc.h> -#include <sys.h> - -struct io_dev { - res (*read)(void *buf, u32 offset, u32 count) NONNULL; - res (*write)(const void *buf, u32 offset, u32 count) NONNULL; - res (*control)(u32 request, void *arg1, void *arg2, void *arg3); - res (*ready)(void); -}; - -void io_install(void); -void io_add(enum io_type io, struct io_dev *dev) NONNULL; - -// No NONNULL on syscalls -res io_control(enum io_type io, u32 request, void *arg1, void *arg2, void *arg3); -res io_write(enum io_type io, const void *buf, u32 offset, u32 count); -res io_read(enum io_type io, void *buf, u32 offset, u32 count); -res io_poll(u32 *devs); -res io_ready(enum io_type io); - -void io_block(enum io_type io, struct proc *proc) NONNULL; -void io_unblock(enum io_type io); -void io_unblock_pid(u32 pid); - -#endif diff --git a/kernel/main.c b/kernel/main.c index d6e7727..e7daf16 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -1,5 +1,6 @@ // MIT License, Copyright (c) 2020 Marvin Borner +#include <dev.h> #include <drivers/cpu.h> #include <drivers/gdt.h> #include <drivers/ide.h> @@ -9,7 +10,6 @@ #include <drivers/rtc.h> #include <drivers/serial.h> #include <fs.h> -#include <io.h> #include <load.h> #include <mem.h> #include <mm.h> @@ -42,7 +42,7 @@ int kernel_main(u32 magic, u32 addr, u32 esp) pci_install(); pic_install(); idt_install(); - io_install(); + dev_install(); syscall_init(); proc_init(); |