From 13d52897b8a1738a3583cfe6846c977a04c45ccf Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Thu, 27 Mar 2025 14:31:22 +0000 Subject: [PATCH] feat(kernel): update configuration Signed-off-by: EnderIce2 --- Kernel/core/syscalls.cpp | 2 +- Kernel/include/kconfig.hpp | 2 +- Kernel/kernel.cpp | 2 +- Kernel/kernel_config.cpp | 28 +++++++++------------------- Kernel/kernel_thread.cpp | 2 +- Kernel/kshell/shell.cpp | 2 +- 6 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Kernel/core/syscalls.cpp b/Kernel/core/syscalls.cpp index 6faeab69..28496fe9 100644 --- a/Kernel/core/syscalls.cpp +++ b/Kernel/core/syscalls.cpp @@ -64,7 +64,7 @@ extern "C" uintptr_t SystemCallsHandler(SyscallsFrame *Frame) Tasking::TaskInfo *Ttinfo = &thisThread->Info; uintptr_t ret; - if (Config.UseLinuxSyscalls) + if (Config.LinuxSubsystem) { ret = HandleLinuxSyscalls(Frame); goto Ret; diff --git a/Kernel/include/kconfig.hpp b/Kernel/include/kconfig.hpp index 237a6993..06c608a4 100644 --- a/Kernel/include/kconfig.hpp +++ b/Kernel/include/kconfig.hpp @@ -33,7 +33,7 @@ struct KernelConfig bool SchedulerType; char DriverDirectory[256]; char InitPath[256]; - bool UseLinuxSyscalls; + bool LinuxSubsystem; bool InterruptsOnCrash; int Cores; int IOAPICInterruptCore; diff --git a/Kernel/kernel.cpp b/Kernel/kernel.cpp index 286aef66..07dbe9bd 100644 --- a/Kernel/kernel.cpp +++ b/Kernel/kernel.cpp @@ -43,7 +43,7 @@ struct KernelConfig Config = { .SchedulerType = Multi, .DriverDirectory = {'/', 's', 'y', 's', '/', 'd', 'r', 'v', '\0'}, .InitPath = {'/', 's', 'y', 's', '/', 'b', 'i', 'n', '/', 'i', 'n', 'i', 't', '\0'}, - .UseLinuxSyscalls = false, + .LinuxSubsystem = false, .InterruptsOnCrash = true, .Cores = 0, .IOAPICInterruptCore = 0, diff --git a/Kernel/kernel_config.cpp b/Kernel/kernel_config.cpp index 3522455c..71b75377 100644 --- a/Kernel/kernel_config.cpp +++ b/Kernel/kernel_config.cpp @@ -65,7 +65,7 @@ static struct cag_option ConfigOptions[] = { .access_letters = "yY", .access_name = "linux", .value_name = "BOOL", - .description = "Use Linux syscalls by default"}, + .description = "Use Linux Subsystem"}, {.identifier = 'l', .access_letters = NULL, @@ -99,21 +99,11 @@ static struct cag_option ConfigOptions[] = { void ParseConfig(char *ConfigString, KernelConfig *ModConfig) { - if (ConfigString == NULL || - strlen(ConfigString) == 0) - { - KPrint("Empty kernel parameters!"); + assert(ConfigString != NULL && ModConfig != NULL); + if (strlen(ConfigString) == 0) return; - } - - if (ModConfig == NULL) - { - KPrint("ModConfig is NULL!"); - return; - } KPrint("Kernel parameters: %s", ConfigString); - debug("Kernel parameters: %s", ConfigString); char *argv[32]; int argc = 0; @@ -214,9 +204,9 @@ void ParseConfig(char *ConfigString, KernelConfig *ModConfig) { value = cag_option_get_value(&context); strcmp(value, "true") == 0 - ? ModConfig->UseLinuxSyscalls = true - : ModConfig->UseLinuxSyscalls = false; - KPrint("Use Linux syscalls by default: %s", value); + ? ModConfig->LinuxSubsystem = true + : ModConfig->LinuxSubsystem = false; + KPrint("Use Linux Subsystem by default: %s", value); break; } case 'o': @@ -255,9 +245,9 @@ void ParseConfig(char *ConfigString, KernelConfig *ModConfig) } case 'h': { - KPrint("\n---------------------------------------------------------------------------\nUsage: fennix.elf [OPTION]...\nKernel configuration."); - cag_option_print(ConfigOptions, CAG_ARRAY_SIZE(ConfigOptions), - nullptr); + KPrint("Usage: fennix.elf [OPTION]..."); + KPrint("Fennix Kernel v%s", KERNEL_VERSION); + cag_option_print(ConfigOptions, CAG_ARRAY_SIZE(ConfigOptions), nullptr); KPrint("\x1b[1;31;41mSystem Halted."); CPU::Stop(); } diff --git a/Kernel/kernel_thread.cpp b/Kernel/kernel_thread.cpp index fe54d582..ca8f2857 100644 --- a/Kernel/kernel_thread.cpp +++ b/Kernel/kernel_thread.cpp @@ -48,7 +48,7 @@ cold int SpawnInit() nullptr}; Tasking::TaskCompatibility compat = Tasking::Native; - if (Config.UseLinuxSyscalls) + if (Config.LinuxSubsystem) compat = Tasking::Linux; return Execute::Spawn(Config.InitPath, argv, envp, diff --git a/Kernel/kshell/shell.cpp b/Kernel/kshell/shell.cpp index 9391cd5d..b05af5d7 100644 --- a/Kernel/kshell/shell.cpp +++ b/Kernel/kshell/shell.cpp @@ -600,7 +600,7 @@ void KShellThread() } Tasking::TaskCompatibility compat = Tasking::Native; - if (Config.UseLinuxSyscalls) + if (Config.LinuxSubsystem) compat = Tasking::Linux; int ret = Execute::Spawn((char *)path.c_str(), argv, envp,