From e5086811a048120d51add9bff9ba7a669fb582f5 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 7 Feb 2021 00:54:21 +0100 Subject: Fixed some memory leaks (broke some stuff too) --- kernel/drivers/ide.c | 3 ++- kernel/drivers/keyboard.c | 6 +++--- kernel/drivers/mouse.c | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'kernel/drivers') diff --git a/kernel/drivers/ide.c b/kernel/drivers/ide.c index 5a51cb8..7dd2416 100644 --- a/kernel/drivers/ide.c +++ b/kernel/drivers/ide.c @@ -106,7 +106,7 @@ u8 ata_read_one(u8 *buf, u32 lba, struct device *dev) return 1; } -u32 ata_read(void *buf, u32 lba, u32 sector_count, struct device *dev) +s32 ata_read(void *buf, u32 lba, u32 sector_count, struct device *dev) { u8 *b = buf; // I love bytes, yk for (u32 i = 0; i < sector_count; i++) { @@ -150,6 +150,7 @@ void ata_probe(void) vfs->ready = ext2_ready; vfs->stat = ext2_stat; dev->vfs = vfs; + dev->data = data; vfs_mount(dev, "/"); } } diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c index 054849c..0dd7219 100644 --- a/kernel/drivers/keyboard.c +++ b/kernel/drivers/keyboard.c @@ -60,18 +60,18 @@ void keyboard_rate(void) outb(0x60, 0x0); // Rate{00000} Delay{00} 0 } -u32 keyboard_read(void *buf, u32 offset, u32 count, struct device *dev) +s32 keyboard_read(void *buf, u32 offset, u32 count, struct device *dev) { (void)dev; if (stack_empty(queue)) - return 0; + return -1; struct event *e = stack_pop(queue); memcpy(buf, (u8 *)e + offset, count); return count; } -u32 keyboard_ready(void) +u8 keyboard_ready(void) { return !stack_empty(queue); } diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c index 99fb80b..2e9ceae 100644 --- a/kernel/drivers/mouse.c +++ b/kernel/drivers/mouse.c @@ -82,16 +82,16 @@ u8 mouse_serial_read(void) return inb(0x60); } -u32 mouse_ready(void) +u8 mouse_ready(void) { return !stack_empty(queue); } -u32 mouse_read(void *buf, u32 offset, u32 count, struct device *dev) +s32 mouse_read(void *buf, u32 offset, u32 count, struct device *dev) { (void)dev; if (stack_empty(queue)) - return 0; + return -1; struct event *e = stack_pop(queue); memcpy(buf, (u8 *)e + offset, count); -- cgit v1.2.3