From 971f64b95811f90e87af77ed36fb2ee0e5e7d1c4 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 1 Nov 2022 19:58:35 +0200 Subject: [PATCH] Driver directory can be modified by config --- Core/Driver.cpp | 2 +- KConfig.cpp | 29 ++++++++++++++++++++++++----- include/kconfig.hpp | 1 + 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Core/Driver.cpp b/Core/Driver.cpp index 7f0a42f..1a7ed1b 100644 --- a/Core/Driver.cpp +++ b/Core/Driver.cpp @@ -282,7 +282,7 @@ namespace Driver Driver::Driver() { - FileSystem::FILE *DriverDirectory = vfs->Open("/system/drivers"); + FileSystem::FILE *DriverDirectory = vfs->Open(Config.DriverDirectory); if (DriverDirectory->Status == FileSystem::FileStatus::OK) foreach (auto driver in DriverDirectory->Node->Children) if (driver->Flags == FileSystem::NodeFlags::FS_FILE) diff --git a/KConfig.cpp b/KConfig.cpp index 0d99b76..7c58606 100644 --- a/KConfig.cpp +++ b/KConfig.cpp @@ -37,6 +37,12 @@ static struct cag_option ConfigOptions[] = { .value_name = "MODE", .description = "Tasking mode (multi, single)"}, + {.identifier = 'd', + .access_letters = "dD", + .access_name = "drvdir", + .value_name = "VALUE", + .description = "Directory to load drivers from"}, + {.identifier = 'h', .access_letters = "h", .access_name = "help", @@ -48,7 +54,10 @@ KernelConfig ParseConfig(char *Config) int argc = 0; char **argv = nullptr; - struct KernelConfig config = {Memory::MemoryAllocatorType::Pages, 0, 0}; + struct KernelConfig config = {Memory::MemoryAllocatorType::Pages, + 0, + {'/', 's', 'y', 's', 't', 'e', 'm', '/', 'd', 'r', 'i', 'v', 'e', 'r', 's', '\0'}, + 0}; if (Config == NULL) { @@ -56,7 +65,10 @@ KernelConfig ParseConfig(char *Config) return config; } else + { + KPrint("Kernel parameters: %s", Config); goto Parse; + } Parse: { @@ -119,7 +131,7 @@ Parse: { case '\0': { - KPrint("\eFF2200Unterminated string constant in kernel parameters."); + KPrint("\eFF2200Unterminated string constant in kernel parameters. (0)"); CPU::Stop(); break; } @@ -132,7 +144,7 @@ Parse: { case '\0': { - KPrint("\eFF2200Unterminated string constant in kernel parameters."); + KPrint("\eFF2200Unterminated string constant in kernel parameters. (1)"); CPU::Stop(); break; } @@ -162,7 +174,7 @@ Parse: { case '\0': { - KPrint("\eFF2200Unterminated string constant in kernel parameters."); + KPrint("\eFF2200Unterminated string constant in kernel parameters. (2)"); CPU::Stop(); break; } @@ -197,7 +209,7 @@ Parse: break; case '\0': { - KPrint("\eFF2200Unterminated string constant in kernel parameters."); + KPrint("\eFF2200Unterminated string constant in kernel parameters. (3)"); CPU::Stop(); } } @@ -302,6 +314,13 @@ ParseSuccess: } break; } + case 'd': + { + value = cag_option_get_value(&context); + strcpy(config.DriverDirectory, value); + KPrint("\eAAFFAAUsing %s as driver directory", value); + break; + } case 'h': { KPrint("\n---------------------------------------------------------------------------\nUsage: kernel.fsys [OPTION]...\nKernel configuration."); diff --git a/include/kconfig.hpp b/include/kconfig.hpp index cbb2322..80115f4 100644 --- a/include/kconfig.hpp +++ b/include/kconfig.hpp @@ -8,6 +8,7 @@ struct KernelConfig { Memory::MemoryAllocatorType AllocatorType; bool SchedulerType; + char DriverDirectory[256]; int Cores; };