diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-08 13:54:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-08 17:19:46 +0200 |
commit | a7bbfda034562b4da80c2561c5dbd4b8c591c838 (patch) | |
tree | 6750df43672ee21bdc818ae56a63185a24bc5d61 | |
parent | dc7340332d94a9e0716ebe7e7d3fcfd6fe4fca13 (diff) | |
download | serenity-a7bbfda034562b4da80c2561c5dbd4b8c591c838.zip |
Kernel: Rename KParams => Kernel::CommandLine
Let's make this read more like English.
-rw-r--r-- | Kernel/CommandLine.cpp (renamed from Kernel/KParams.cpp) | 26 | ||||
-rw-r--r-- | Kernel/CommandLine.h (renamed from Kernel/KParams.h) | 22 | ||||
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 5 | ||||
-rw-r--r-- | Kernel/Makefile | 2 | ||||
-rw-r--r-- | Kernel/PCI/Initializer.cpp | 4 | ||||
-rw-r--r-- | Kernel/Time/TimeManagement.cpp | 8 | ||||
-rw-r--r-- | Kernel/init.cpp | 34 |
7 files changed, 59 insertions, 42 deletions
diff --git a/Kernel/KParams.cpp b/Kernel/CommandLine.cpp index 9a6410a089..d08e1c68e0 100644 --- a/Kernel/KParams.cpp +++ b/Kernel/CommandLine.cpp @@ -24,21 +24,29 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <Kernel/KParams.h> +#include <Kernel/CommandLine.h> -static KParams* s_the; +namespace Kernel { -KParams& KParams::the() +static CommandLine* s_the; + +const CommandLine& kernel_command_line() { + ASSERT(s_the); return *s_the; } -KParams::KParams(const String& cmdline) - : m_cmdline(cmdline) +void CommandLine::initialize(const String& string) +{ + s_the = new CommandLine(string); +} + +CommandLine::CommandLine(const String& string) + : m_string(string) { s_the = this; - for (auto str : m_cmdline.split(' ')) { + for (auto str : m_string.split(' ')) { if (str == "") { continue; } @@ -53,12 +61,14 @@ KParams::KParams(const String& cmdline) } } -String KParams::get(const String& key) const +String CommandLine::get(const String& key) const { return m_params.get(key).value_or({}); } -bool KParams::has(const String& key) const +bool CommandLine::contains(const String& key) const { return m_params.contains(key); } + +} diff --git a/Kernel/KParams.h b/Kernel/CommandLine.h index fff1e59e3e..db312a59ed 100644 --- a/Kernel/KParams.h +++ b/Kernel/CommandLine.h @@ -29,18 +29,24 @@ #include <AK/HashMap.h> #include <AK/String.h> -class KParams { - AK_MAKE_ETERNAL -public: - static KParams& the(); +namespace Kernel { - KParams(const String& cmdline); +class CommandLine { + AK_MAKE_ETERNAL; +public: + static void initialize(const String&); - const String& cmdline() const { return m_cmdline; } + const String& string() const { return m_string; } String get(const String& key) const; - bool has(const String& key) const; + bool contains(const String& key) const; private: - String m_cmdline; + CommandLine(const String&); + + String m_string; HashMap<String, String> m_params; }; + +const CommandLine& kernel_command_line(); + +} diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 2247b3d9e2..2df01329b0 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -33,6 +33,7 @@ #include <AK/JsonObjectSerializer.h> #include <AK/JsonValue.h> #include <Kernel/Arch/i386/CPU.h> +#include <Kernel/CommandLine.h> #include <Kernel/Devices/BlockDevice.h> #include <Kernel/FileSystem/Custody.h> #include <Kernel/FileSystem/FileBackedFileSystem.h> @@ -42,7 +43,6 @@ #include <Kernel/Interrupts/GenericInterruptHandler.h> #include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/KBufferBuilder.h> -#include <Kernel/KParams.h> #include <Kernel/Module.h> #include <Kernel/Net/LocalSocket.h> #include <Kernel/Net/NetworkAdapter.h> @@ -404,7 +404,8 @@ Optional<KBuffer> procfs$uptime(InodeIdentifier) Optional<KBuffer> procfs$cmdline(InodeIdentifier) { KBufferBuilder builder; - builder.appendf("%s\n", KParams::the().cmdline().characters()); + builder.append(kernel_command_line().string()); + builder.append('\n'); return builder.build(); } diff --git a/Kernel/Makefile b/Kernel/Makefile index 992e93bd56..fc5cc89b1b 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -15,6 +15,7 @@ OBJS = \ ../Libraries/LibBareMetal/Output/kprintf.o \ ../Libraries/LibBareMetal/StdLib.o \ Arch/i386/CPU.o \ + CommandLine.o \ Interrupts/InterruptManagement.o \ Interrupts/APIC.o \ Interrupts/IOAPIC.o \ @@ -71,7 +72,6 @@ OBJS = \ Heap/SlabAllocator.o \ Heap/kmalloc.o \ KBufferBuilder.o \ - KParams.o \ KSyms.o \ Lock.o \ Net/E1000NetworkAdapter.o \ diff --git a/Kernel/PCI/Initializer.cpp b/Kernel/PCI/Initializer.cpp index 2d7feb5732..73e601b814 100644 --- a/Kernel/PCI/Initializer.cpp +++ b/Kernel/PCI/Initializer.cpp @@ -25,7 +25,7 @@ */ #include <Kernel/ACPI/ACPIParser.h> -#include <Kernel/KParams.h> +#include <Kernel/CommandLine.h> #include <Kernel/Net/E1000NetworkAdapter.h> #include <Kernel/Net/RTL8139NetworkAdapter.h> #include <Kernel/PCI/IOAccess.h> @@ -100,7 +100,7 @@ PCI::Initializer::Initializer() } bool PCI::Initializer::test_acpi() { - if ((KParams::the().has("noacpi")) || !ACPI::Parser::the().is_operable()) + if ((kernel_command_line().contains("noacpi")) || !ACPI::Parser::the().is_operable()) return false; else return true; diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp index 389707653c..1a85078216 100644 --- a/Kernel/Time/TimeManagement.cpp +++ b/Kernel/Time/TimeManagement.cpp @@ -25,7 +25,7 @@ */ #include <Kernel/ACPI/ACPIParser.h> -#include <Kernel/KParams.h> +#include <Kernel/CommandLine.h> #include <Kernel/Scheduler.h> #include <Kernel/Time/HPET.h> #include <Kernel/Time/HPETComparator.h> @@ -148,10 +148,10 @@ Vector<size_t> TimeManagement::scan_for_non_periodic_timers() bool TimeManagement::is_hpet_periodic_mode_allowed() { - if (!KParams::the().has("hpet")) { + if (!kernel_command_line().contains("hpet")) return true; - } - auto hpet_mode = KParams::the().get("hpet"); + + auto hpet_mode = kernel_command_line().get("hpet"); if (hpet_mode == "periodic") return true; if (hpet_mode == "nonperiodic") diff --git a/Kernel/init.cpp b/Kernel/init.cpp index f6f6c7353d..ab28f7512b 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -36,6 +36,7 @@ #include <Kernel/ACPI/MultiProcessorParser.h> #include <Kernel/Arch/i386/CPU.h> #include <Kernel/CMOS.h> +#include <Kernel/CommandLine.h> #include <Kernel/Devices/BXVGADevice.h> #include <Kernel/Devices/DebugLogDevice.h> #include <Kernel/Devices/DiskPartition.h> @@ -60,7 +61,6 @@ #include <Kernel/Interrupts/APIC.h> #include <Kernel/Interrupts/InterruptManagement.h> #include <Kernel/Interrupts/PIC.h> -#include <Kernel/KParams.h> #include <Kernel/Multiboot.h> #include <Kernel/Net/LoopbackAdapter.h> #include <Kernel/Net/NetworkTask.h> @@ -101,11 +101,11 @@ extern "C" [[noreturn]] void init() kmalloc_init(); slab_alloc_init(); - new KParams(String(reinterpret_cast<const char*>(low_physical_to_virtual(multiboot_info_ptr->cmdline)))); + CommandLine::initialize(reinterpret_cast<const char*>(low_physical_to_virtual(multiboot_info_ptr->cmdline))); MemoryManager::initialize(); - bool text_debug = KParams::the().has("text_debug"); + bool text_debug = kernel_command_line().contains("text_debug"); gdt_init(); idt_init(); @@ -210,17 +210,17 @@ void init_stage2() new RandomDevice; new PTYMultiplexer; - bool dmi_unreliable = KParams::the().has("dmi_unreliable"); + bool dmi_unreliable = kernel_command_line().contains("dmi_unreliable"); if (dmi_unreliable) { DMIDecoder::initialize_untrusted(); } else { DMIDecoder::initialize(); } - bool text_debug = KParams::the().has("text_debug"); - bool force_pio = KParams::the().has("force_pio"); + bool text_debug = kernel_command_line().contains("text_debug"); + bool force_pio = kernel_command_line().contains("force_pio"); - auto root = KParams::the().get("root"); + auto root = kernel_command_line().get("root"); if (root.is_empty()) { root = "/dev/hda"; } @@ -379,12 +379,12 @@ extern "C" int __cxa_atexit(void (*)(void*), void*, void*) void setup_acpi() { - if (!KParams::the().has("acpi")) { + if (!kernel_command_line().contains("acpi")) { ACPI::DynamicParser::initialize_without_rsdp(); return; } - auto acpi = KParams::the().get("acpi"); + auto acpi = kernel_command_line().get("acpi"); if (acpi == "off") { ACPI::Parser::initialize_limited(); return; @@ -404,11 +404,11 @@ void setup_acpi() void setup_vmmouse() { VMWareBackdoor::initialize(); - if (!KParams::the().has("vmmouse")) { + if (!kernel_command_line().contains("vmmouse")) { VMWareBackdoor::the().enable_absolute_vmmouse(); return; } - auto vmmouse = KParams::the().get("vmmouse"); + auto vmmouse = kernel_command_line().get("vmmouse"); if (vmmouse == "off") return; if (vmmouse == "on") { @@ -421,12 +421,12 @@ void setup_vmmouse() void setup_pci() { - if (!KParams::the().has("pci_mmio")) { + if (!kernel_command_line().contains("pci_mmio")) { PCI::Initializer::the().test_and_initialize(false); PCI::Initializer::the().dismiss(); return; } - auto pci_mmio = KParams::the().get("pci_mmio"); + auto pci_mmio = kernel_command_line().get("pci_mmio"); if (pci_mmio == "on") { PCI::Initializer::the().test_and_initialize(false); } else if (pci_mmio == "off") { @@ -442,11 +442,11 @@ void setup_interrupts() { InterruptManagement::initialize(); - if (!KParams::the().has("smp")) { + if (!kernel_command_line().contains("smp")) { InterruptManagement::the().switch_to_pic_mode(); return; } - auto smp = KParams::the().get("smp"); + auto smp = kernel_command_line().get("smp"); if (smp == "off") { InterruptManagement::the().switch_to_pic_mode(); return; @@ -462,11 +462,11 @@ void setup_interrupts() void setup_time_management() { - if (!KParams::the().has("time")) { + if (!kernel_command_line().contains("time")) { TimeManagement::initialize(true); return; } - auto time = KParams::the().get("time"); + auto time = kernel_command_line().get("time"); if (time == "legacy") { TimeManagement::initialize(false); return; |