Преглед на файлове

Kernel: Rename KParams => Kernel::CommandLine

Let's make this read more like English.
Andreas Kling преди 5 години
родител
ревизия
a7bbfda034
променени са 7 файла, в които са добавени 59 реда и са изтрити 42 реда
  1. 18 8
      Kernel/CommandLine.cpp
  2. 14 8
      Kernel/CommandLine.h
  3. 3 2
      Kernel/FileSystem/ProcFS.cpp
  4. 1 1
      Kernel/Makefile
  5. 2 2
      Kernel/PCI/Initializer.cpp
  6. 4 4
      Kernel/Time/TimeManagement.cpp
  7. 17 17
      Kernel/init.cpp

+ 18 - 8
Kernel/KParams.cpp → 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);
 }
+
+}

+ 14 - 8
Kernel/KParams.h → 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();
+
+}

+ 3 - 2
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();
 }
 

+ 1 - 1
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 \

+ 2 - 2
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;

+ 4 - 4
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")

+ 17 - 17
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;