2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-06-04 13:54:27 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/HashMap.h>
|
2020-04-08 17:35:00 +03:00
|
|
|
#include <AK/Optional.h>
|
2020-03-22 03:12:45 +03:00
|
|
|
#include <AK/String.h>
|
2021-03-03 11:51:55 +03:00
|
|
|
#include <AK/Vector.h>
|
2019-06-04 13:54:27 +03:00
|
|
|
|
2020-04-08 14:54:44 +03:00
|
|
|
namespace Kernel {
|
2019-06-04 13:54:27 +03:00
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
enum class BootMode {
|
2021-04-16 22:58:51 +03:00
|
|
|
NoFramebufferDevices,
|
2021-03-03 11:51:55 +03:00
|
|
|
SelfTest,
|
2021-08-08 22:40:45 +03:00
|
|
|
Graphical,
|
|
|
|
Unknown,
|
2021-03-03 11:51:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class HPETMode {
|
|
|
|
Periodic,
|
|
|
|
NonPeriodic
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class AcpiFeatureLevel {
|
|
|
|
Enabled,
|
|
|
|
Limited,
|
|
|
|
Disabled,
|
|
|
|
};
|
|
|
|
|
2021-04-03 16:46:04 +03:00
|
|
|
enum class PCIAccessLevel {
|
|
|
|
IOAddressing,
|
|
|
|
MappingPerBus,
|
|
|
|
MappingPerDevice,
|
|
|
|
};
|
|
|
|
|
2021-03-12 19:35:16 +03:00
|
|
|
enum class AHCIResetMode {
|
|
|
|
ControllerOnly,
|
2021-05-29 01:18:45 +03:00
|
|
|
Aggressive,
|
2021-03-12 19:35:16 +03:00
|
|
|
};
|
|
|
|
|
2020-04-08 14:54:44 +03:00
|
|
|
class CommandLine {
|
|
|
|
AK_MAKE_ETERNAL;
|
2020-04-08 17:35:00 +03:00
|
|
|
|
2020-04-08 14:54:44 +03:00
|
|
|
public:
|
2020-08-25 04:35:27 +03:00
|
|
|
static void early_initialize(const char* cmd_line);
|
|
|
|
static void initialize();
|
2019-06-04 13:54:27 +03:00
|
|
|
|
2021-08-08 22:40:45 +03:00
|
|
|
enum class Validate {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] const String& string() const { return m_string; }
|
2021-08-15 09:49:17 +03:00
|
|
|
Optional<StringView> lookup(const StringView& key) const;
|
2021-05-31 11:59:02 +03:00
|
|
|
[[nodiscard]] bool contains(const StringView& key) const;
|
2021-03-03 11:51:55 +03:00
|
|
|
|
2021-03-03 12:00:41 +03:00
|
|
|
[[nodiscard]] bool is_boot_profiling_enabled() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] bool is_ide_enabled() const;
|
|
|
|
[[nodiscard]] bool is_smp_enabled() const;
|
2021-06-04 08:02:14 +03:00
|
|
|
[[nodiscard]] bool is_physical_networking_disabled() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] bool is_vmmouse_enabled() const;
|
2021-04-03 16:46:04 +03:00
|
|
|
[[nodiscard]] PCIAccessLevel pci_access_level() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] bool is_legacy_time_enabled() const;
|
2021-04-16 22:58:51 +03:00
|
|
|
[[nodiscard]] bool is_no_framebuffer_devices_mode() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] bool is_force_pio() const;
|
|
|
|
[[nodiscard]] AcpiFeatureLevel acpi_feature_level() const;
|
2021-08-08 22:40:45 +03:00
|
|
|
[[nodiscard]] BootMode boot_mode(Validate should_validate = Validate::No) const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] HPETMode hpet_mode() const;
|
2021-04-08 21:18:48 +03:00
|
|
|
[[nodiscard]] bool disable_physical_storage() const;
|
|
|
|
[[nodiscard]] bool disable_ps2_controller() const;
|
2021-04-17 22:36:53 +03:00
|
|
|
[[nodiscard]] bool disable_uhci_controller() const;
|
2021-08-08 21:50:20 +03:00
|
|
|
[[nodiscard]] bool disable_usb() const;
|
2021-04-18 16:06:35 +03:00
|
|
|
[[nodiscard]] bool disable_virtio() const;
|
2021-03-12 19:35:16 +03:00
|
|
|
[[nodiscard]] AHCIResetMode ahci_reset_mode() const;
|
2021-08-15 09:49:17 +03:00
|
|
|
[[nodiscard]] StringView userspace_init() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] Vector<String> userspace_init_args() const;
|
2021-08-15 09:49:17 +03:00
|
|
|
[[nodiscard]] StringView root_device() const;
|
2021-05-14 00:22:02 +03:00
|
|
|
[[nodiscard]] size_t switch_to_tty() const;
|
2019-06-07 12:43:58 +03:00
|
|
|
|
2019-06-04 13:54:27 +03:00
|
|
|
private:
|
2020-04-08 14:54:44 +03:00
|
|
|
CommandLine(const String&);
|
|
|
|
|
2021-05-31 11:59:02 +03:00
|
|
|
void add_arguments(const Vector<StringView>& args);
|
2021-05-21 20:42:33 +03:00
|
|
|
void build_commandline(const String& cmdline_from_bootloader);
|
|
|
|
|
2020-04-08 14:54:44 +03:00
|
|
|
String m_string;
|
2021-05-31 11:59:02 +03:00
|
|
|
HashMap<StringView, StringView> m_params;
|
2019-06-04 13:54:27 +03:00
|
|
|
};
|
2020-04-08 14:54:44 +03:00
|
|
|
|
|
|
|
const CommandLine& kernel_command_line();
|
|
|
|
|
|
|
|
}
|