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>
|
2021-09-09 12:36:40 +03:00
|
|
|
#include <AK/NonnullOwnPtrVector.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>
|
2021-09-09 12:36:40 +03:00
|
|
|
#include <Kernel/KString.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-10-23 18:31:00 +03:00
|
|
|
enum class PanicMode {
|
|
|
|
Halt,
|
|
|
|
Shutdown,
|
|
|
|
};
|
|
|
|
|
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,
|
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 12:08:38 +03:00
|
|
|
MemoryAddressing,
|
2021-04-03 16:46:04 +03:00
|
|
|
};
|
|
|
|
|
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 {
|
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,
|
|
|
|
};
|
|
|
|
|
2022-01-06 00:45:29 +03:00
|
|
|
enum class FrameBufferDevices {
|
|
|
|
Enabled,
|
|
|
|
ConsoleOnly,
|
|
|
|
BootloaderOnly
|
|
|
|
};
|
|
|
|
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] const String& string() const { return m_string; }
|
2021-11-11 02:55:02 +03:00
|
|
|
Optional<StringView> lookup(StringView key) const;
|
|
|
|
[[nodiscard]] bool contains(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;
|
2021-11-28 18:38:10 +03:00
|
|
|
[[nodiscard]] bool is_ioapic_enabled() const;
|
2021-12-19 22:30:36 +03:00
|
|
|
[[nodiscard]] bool is_smp_enabled_without_ioapic_enabled() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[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;
|
2022-01-06 00:45:29 +03:00
|
|
|
[[nodiscard]] FrameBufferDevices are_framebuffer_devices_enabled() const;
|
2021-03-03 11:51:55 +03:00
|
|
|
[[nodiscard]] bool is_force_pio() const;
|
|
|
|
[[nodiscard]] AcpiFeatureLevel acpi_feature_level() const;
|
2021-10-23 19:26:50 +03:00
|
|
|
[[nodiscard]] StringView system_mode() const;
|
2021-10-23 18:31:00 +03:00
|
|
|
[[nodiscard]] PanicMode panic_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-09-09 12:36:40 +03:00
|
|
|
[[nodiscard]] NonnullOwnPtrVector<KString> 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();
|
|
|
|
|
|
|
|
}
|