serenity/Kernel/CommandLine.h

111 lines
3 KiB
C
Raw Normal View History

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/Optional.h>
#include <AK/Vector.h>
#include <Kernel/KString.h>
namespace Kernel {
enum class PanicMode {
Halt,
Shutdown,
};
enum class HPETMode {
Periodic,
NonPeriodic
};
enum class AcpiFeatureLevel {
Enabled,
Limited,
Disabled,
};
enum class PCIAccessLevel {
None,
#if ARCH(I386) || ARCH(X86_64)
IOAddressing,
#endif
Kernel/PCI: Simplify the entire subsystem A couple of things were changed: 1. Semantic changes - PCI segments are now called PCI domains, to better match what they are really. It's also the name that Linux gave, and it seems that Wikipedia also uses this name. We also remove PCI::ChangeableAddress, because it was used in the past but now it's no longer being used. 2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as they made a bunch of unnecessary complexity. Instead, Windowed access is removed entirely (this was tested, but never was benchmarked), so we are left with IO access and memory access options. The memory access option is essentially mapping the PCI bus (from the chosen PCI domain), to virtual memory as-is. This means that unless needed, at any time, there is only one PCI bus being mapped, and this is changed if access to another PCI bus in the same PCI domain is needed. For now, we don't support mapping of different PCI buses from different PCI domains at the same time, because basically it's still a non-issue for most machines out there. 2. OOM-safety is increased, especially when constructing the Access object. It means that we pre-allocating any needed resources, and we try to find PCI domains (if requested to initialize memory access) after we attempt to construct the Access object, so it's possible to fail at this point "gracefully". 3. All PCI API functions are now separated into a different header file, which means only "clients" of the PCI subsystem API will need to include that header file. 4. Functional changes - we only allow now to enumerate the bus after a hardware scan. This means that the old method "enumerate_hardware" is removed, so, when initializing an Access object, the initializing function must call rescan on it to force it to find devices. This makes it possible to fail rescan, and also to defer it after construction from both OOM-safety terms and hotplug capabilities.
2021-09-07 09:08:38 +00:00
MemoryAddressing,
};
enum class AHCIResetMode {
ControllerOnly,
Aggressive,
};
class CommandLine {
public:
2022-04-01 17:58:27 +00:00
static void early_initialize(char const* cmd_line);
static void initialize();
static bool was_initialized();
enum class Validate {
Yes,
No,
};
enum class GraphicsSubsystemMode {
Enabled,
Limited,
Disabled
};
2022-01-11 19:12:12 +00:00
[[nodiscard]] StringView string() const { return m_string->view(); }
Optional<StringView> lookup(StringView key) const;
[[nodiscard]] bool contains(StringView key) const;
[[nodiscard]] bool is_boot_profiling_enabled() const;
[[nodiscard]] bool is_ide_enabled() const;
[[nodiscard]] bool is_ioapic_enabled() const;
[[nodiscard]] bool is_smp_enabled_without_ioapic_enabled() const;
[[nodiscard]] bool is_smp_enabled() const;
[[nodiscard]] bool is_physical_networking_disabled() const;
[[nodiscard]] bool is_vmmouse_enabled() const;
[[nodiscard]] PCIAccessLevel pci_access_level() const;
[[nodiscard]] bool is_pci_disabled() const;
[[nodiscard]] bool is_legacy_time_enabled() const;
[[nodiscard]] bool is_pc_speaker_enabled() const;
[[nodiscard]] GraphicsSubsystemMode graphics_subsystem_mode() const;
[[nodiscard]] bool is_force_pio() const;
[[nodiscard]] AcpiFeatureLevel acpi_feature_level() const;
[[nodiscard]] StringView system_mode() const;
[[nodiscard]] PanicMode panic_mode(Validate should_validate = Validate::No) const;
[[nodiscard]] HPETMode hpet_mode() const;
[[nodiscard]] bool disable_physical_storage() const;
[[nodiscard]] bool disable_ps2_controller() const;
[[nodiscard]] bool disable_uhci_controller() const;
[[nodiscard]] bool disable_usb() const;
[[nodiscard]] bool disable_virtio() const;
[[nodiscard]] bool is_early_boot_console_disabled() const;
[[nodiscard]] AHCIResetMode ahci_reset_mode() const;
[[nodiscard]] StringView userspace_init() const;
[[nodiscard]] NonnullOwnPtrVector<KString> userspace_init_args() const;
[[nodiscard]] StringView root_device() const;
[[nodiscard]] bool is_nvme_polling_enabled() const;
[[nodiscard]] size_t switch_to_tty() const;
private:
2022-01-11 19:12:12 +00:00
CommandLine(StringView);
2022-04-01 17:58:27 +00:00
void add_arguments(Vector<StringView> const& args);
2022-01-11 19:12:12 +00:00
static NonnullOwnPtr<KString> build_commandline(StringView cmdline_from_bootloader);
2022-01-11 19:12:12 +00:00
NonnullOwnPtr<KString> m_string;
HashMap<StringView, StringView> m_params;
};
2022-04-01 17:58:27 +00:00
CommandLine const& kernel_command_line();
}