From 8c273f4dc75b484a802f68f4086e0bb792970a1d Mon Sep 17 00:00:00 2001 From: antifallobst Date: Tue, 6 Jun 2023 22:05:14 +0200 Subject: [PATCH] refactor (kernel): removed unused and unfinished modules system. The new drivers system performs the same task --- inc/modules/loader.h | 32 -------------------------- inc/modules/module.h | 16 ------------- src/boot/kmain.c | 3 --- src/modules/loader.c | 53 -------------------------------------------- src/modules/module.c | 3 --- 5 files changed, 107 deletions(-) delete mode 100644 inc/modules/loader.h delete mode 100644 inc/modules/module.h delete mode 100644 src/modules/loader.c delete mode 100644 src/modules/module.c diff --git a/inc/modules/loader.h b/inc/modules/loader.h deleted file mode 100644 index dcccc42..0000000 --- a/inc/modules/loader.h +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of noxos and licensed under the MIT open source license - -#ifndef NOXOS_MODULES_LOADER_H -#define NOXOS_MODULES_LOADER_H - -#include -#include - -#define MODULE_MANAGER_CHUNK_SIZE 16 - -typedef struct module_manager_chunk_T module_manager_chunk_T; -struct module_manager_chunk_T { - module_T* modules [MODULE_MANAGER_CHUNK_SIZE]; - bitmap_T modules_bitmap; - uint32_t num_modules; - - module_manager_chunk_T* prev; - module_manager_chunk_T* next; -}; - -typedef struct { - module_manager_chunk_T* chunks; -} module_manager_T; - - -void module_manager_init (); -module_manager_chunk_T* module_manager_chunk_alloc (module_manager_chunk_T* prev); - -module_T* module_load (string_t name, string_t path); -void module_unload (module_T* module); - -#endif //NOXOS_MODULES_LOADER_H diff --git a/inc/modules/module.h b/inc/modules/module.h deleted file mode 100644 index e85a706..0000000 --- a/inc/modules/module.h +++ /dev/null @@ -1,16 +0,0 @@ -// This file is part of noxos and licensed under the MIT open source license - -#ifndef NOXOS_MODULE_H -#define NOXOS_MODULE_H - -#include -#include -#include - -typedef struct { - string_t name; - string_t path; - elf_executable_T* executable; -} module_T; - -#endif //NOXOS_MODULE_H diff --git a/src/boot/kmain.c b/src/boot/kmain.c index e9eda30..4d98fa0 100644 --- a/src/boot/kmain.c +++ b/src/boot/kmain.c @@ -21,7 +21,6 @@ #include "drivers/builtin/tty.h" #include "drivers/driver.h" #include "proc/scheduler.h" -#include "modules/loader.h" void limine_terminal_print(boot_info_T* boot_info, string_t string) { boot_info->terminal->write(boot_info->terminal->terminals[0], string, string_length(string)); @@ -55,8 +54,6 @@ void kernel_init(boot_info_T* boot_info) { acpi_init(boot_info); - module_manager_init(); - drive_manager_init(); pci_init(); diff --git a/src/modules/loader.c b/src/modules/loader.c deleted file mode 100644 index ba80c9d..0000000 --- a/src/modules/loader.c +++ /dev/null @@ -1,53 +0,0 @@ -// This file is part of noxos and licensed under the MIT open source license - -#include -#include -#include -#include - -module_manager_T g_module_manager; - -void module_manager_init() { - g_module_manager.chunks = module_manager_chunk_alloc(NULL); -} - -module_manager_chunk_T* module_manager_chunk_alloc(module_manager_chunk_T* prev) { - module_manager_chunk_T* chunk = memory_allocate(sizeof(module_manager_chunk_T)); - - chunk->modules_bitmap = bitmap_init(MODULE_MANAGER_CHUNK_SIZE); - chunk->num_modules = 0; - chunk->next = NULL; - chunk->prev = prev; - if (prev != NULL) { - prev->next = chunk; - } - - return chunk; -} - -module_T* module_load(string_t name, string_t path) { - module_T* module = memory_allocate(sizeof(module_T)); - - module->name = name; - module->path = path; - - vfs_node_T* node = vfs_resolve_path(&g_root_fs, path); - if (node == NULL || node->type != VFS_NODE_FILE) { - memory_free(module); - log(LOG_ERROR, "failed to load module '%s' from '%s' (file not found)", name, path); - return NULL; - } - - void* buffer = memory_allocate(node->size); - vfs_file_read(node, 0, node->size, buffer); - - module->executable = elf_executable_create(buffer); - - log(LOG_INFO, "loaded module '%s' from '%s'", name, path); - - return module; -} - -void module_unload(module_T* module) { - -} \ No newline at end of file diff --git a/src/modules/module.c b/src/modules/module.c deleted file mode 100644 index 23f138f..0000000 --- a/src/modules/module.c +++ /dev/null @@ -1,3 +0,0 @@ -// This file is part of noxos and licensed under the MIT open source license - -#include