From 116f4a50f729b974e9d4e6e3d26b635dc60b30eb Mon Sep 17 00:00:00 2001 From: "Enrico Fraccaroli (Galfurian)" Date: Wed, 31 May 2023 08:56:52 -0400 Subject: [PATCH] Reorganize includes --- mentos/src/drivers/ata.c | 9 ++++---- mentos/src/kernel.c | 39 ++++++++++++++-------------------- mentos/src/process/scheduler.c | 21 ++++++------------ mentos/src/system/printk.c | 2 +- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/mentos/src/drivers/ata.c b/mentos/src/drivers/ata.c index c771ce7..855823b 100644 --- a/mentos/src/drivers/ata.c +++ b/mentos/src/drivers/ata.c @@ -437,13 +437,14 @@ static inline uint8_t ata_status_wait(ata_device_t *dev, int timeout) uint8_t status; if (timeout > 0) { while (timeout--) { - if (!bit_check((status = inportb(dev->io_reg.status)), ata_status_bsy)) + status = inportb(dev->io_reg.status); + if (!bit_check(status, ata_status_bsy)) break; } } else { - while (bit_check((status = inportb(dev->io_reg.status)), ata_status_bsy)) { - cpu_relax(); - } + do { + status = inportb(dev->io_reg.status); + } while (bit_check(status, ata_status_bsy)); } return status; } diff --git a/mentos/src/kernel.c b/mentos/src/kernel.c index 6bc2acb..927b39b 100644 --- a/mentos/src/kernel.c +++ b/mentos/src/kernel.c @@ -9,39 +9,32 @@ #define __DEBUG_LEVEL__ LOGLEVEL_NOTICE ///< Set log level. #include "io/debug.h" // Include debugging functions. -#include "io/proc_modules.h" -#include "mem/vmem_map.h" -#include "fs/procfs.h" -#include "devices/pci.h" -#include "drivers/ata.h" -#include "descriptor_tables/idt.h" #include "kernel.h" -#include "mem/zone_allocator.h" + #include "descriptor_tables/gdt.h" -#include "system/syscall.h" -#include "version.h" -#include "io/video.h" -#include "hardware/pic8259.h" -#include "drivers/fdc.h" -#include "fs/ext2.h" -#include "klib/irqflags.h" +#include "descriptor_tables/idt.h" #include "drivers/keyboard/keyboard.h" #include "drivers/keyboard/keymap.h" +#include "drivers/ata.h" +#include "drivers/rtc.h" #include "drivers/ps2.h" -#include "process/scheduler.h" #include "process/scheduler_feedback.h" +#include "process/scheduler.h" +#include "mem/zone_allocator.h" +#include "mem/vmem_map.h" +#include "hardware/pic8259.h" #include "hardware/timer.h" -#include "fs/vfs.h" -#include "devices/fpu.h" -#include "system/printk.h" +#include "system/syscall.h" #include "sys/module.h" #include "sys/sem.h" -#include "drivers/rtc.h" -#include "stdio.h" -#include "assert.h" +#include "io/proc_modules.h" #include "io/vga/vga.h" -#include "string.h" -#include "fcntl.h" +#include "io/video.h" +#include "fs/vfs.h" +#include "fs/procfs.h" +#include "fs/ext2.h" +#include "version.h" +#include "stdio.h" /// Describe start address of grub multiboot modules. char *module_start[MAX_MODULES]; diff --git a/mentos/src/process/scheduler.c b/mentos/src/process/scheduler.c index 7a647f8..0dae4ad 100644 --- a/mentos/src/process/scheduler.c +++ b/mentos/src/process/scheduler.c @@ -9,24 +9,17 @@ #define __DEBUG_LEVEL__ LOGLEVEL_NOTICE ///< Set log level. #include "io/debug.h" // Include debugging functions. -#include "assert.h" -#include "strerror.h" -#include "fs/vfs.h" -#include "descriptor_tables/tss.h" -#include "devices/fpu.h" #include "process/scheduler_feedback.h" #include "process/scheduler.h" #include "process/prio.h" #include "process/wait.h" -#include "mem/kheap.h" -#include "system/panic.h" -#include "time.h" -#include "sys/errno.h" -#include "klib/list_head.h" -#include "mem/paging.h" +#include "descriptor_tables/tss.h" #include "hardware/timer.h" -#include "math.h" -#include "stdio.h" +#include "system/panic.h" +#include "sys/errno.h" +#include "strerror.h" +#include "assert.h" +#include "fs/vfs.h" /// @brief Assembly function setting the kernel stack to jump into /// location in Ring 3 mode (USER mode). @@ -523,7 +516,7 @@ void sys_exit(int exit_code) if (runqueue.curr->parent) { int ret = sys_kill(runqueue.curr->parent->pid, SIGCHLD); if (ret == -1) { - printf("[%d] %5d failed sending signal %d : %s\n", ret, runqueue.curr->parent->pid, + pr_err("[%d] %5d failed sending signal %d : %s\n", ret, runqueue.curr->parent->pid, SIGCHLD, strerror(errno)); } } diff --git a/mentos/src/system/printk.c b/mentos/src/system/printk.c index 19713ff..065bd1b 100644 --- a/mentos/src/system/printk.c +++ b/mentos/src/system/printk.c @@ -5,8 +5,8 @@ #include "system/printk.h" #include "stdarg.h" -#include "stdio.h" #include "io/video.h" +#include "stdio.h" int sys_syslog(const char *format, ...) {