2020-01-18 08:38:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 08:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-04 10:54:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/HashMap.h>
|
2021-09-09 09:36:40 +00:00
|
|
|
#include <AK/NonnullOwnPtrVector.h>
|
2020-04-08 14:35:00 +00:00
|
|
|
#include <AK/Optional.h>
|
2021-03-03 08:51:55 +00:00
|
|
|
#include <AK/Vector.h>
|
2021-09-09 09:36:40 +00:00
|
|
|
#include <Kernel/KString.h>
|
2019-06-04 10:54:27 +00:00
|
|
|
|
2020-04-08 11:54:44 +00:00
|
|
|
namespace Kernel {
|
2019-06-04 10:54:27 +00:00
|
|
|
|
2021-10-23 15:31:00 +00:00
|
|
|
enum class PanicMode {
|
|
|
|
Halt,
|
|
|
|
Shutdown,
|
|
|
|
};
|
|
|
|
|
2021-03-03 08:51:55 +00:00
|
|
|
enum class HPETMode {
|
|
|
|
Periodic,
|
|
|
|
NonPeriodic
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class AcpiFeatureLevel {
|
|
|
|
Enabled,
|
|
|
|
Limited,
|
|
|
|
Disabled,
|
|
|
|
};
|
|
|
|
|
2021-04-03 13:46:04 +00:00
|
|
|
enum class PCIAccessLevel {
|
2022-01-21 14:09:05 +00:00
|
|
|
None,
|
2021-04-03 13:46:04 +00:00
|
|
|
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 09:08:38 +00:00
|
|
|
MemoryAddressing,
|
2021-04-03 13:46:04 +00:00
|
|
|
};
|
|
|
|
|
2021-03-12 16:35:16 +00:00
|
|
|
enum class AHCIResetMode {
|
|
|
|
ControllerOnly,
|
2021-05-28 22:18:45 +00:00
|
|
|
Aggressive,
|
2021-03-12 16:35:16 +00:00
|
|
|
};
|
|
|
|
|
2020-04-08 11:54:44 +00:00
|
|
|
class CommandLine {
|
2020-04-08 14:35:00 +00:00
|
|
|
|
2020-04-08 11:54:44 +00:00
|
|
|
public:
|
2022-04-01 17:58:27 +00:00
|
|
|
static void early_initialize(char const* cmd_line);
|
2020-08-25 01:35:27 +00:00
|
|
|
static void initialize();
|
2022-01-21 09:36:32 +00:00
|
|
|
static bool was_initialized();
|
2019-06-04 10:54:27 +00:00
|
|
|
|
2021-08-08 19:40:45 +00:00
|
|
|
enum class Validate {
|
|
|
|
Yes,
|
|
|
|
No,
|
|
|
|
};
|
|
|
|
|
2022-04-30 12:53:02 +00:00
|
|
|
enum class GraphicsSubsystemMode {
|
2022-01-05 21:45:29 +00:00
|
|
|
Enabled,
|
2022-04-30 12:53:02 +00:00
|
|
|
Limited,
|
|
|
|
Disabled
|
2022-01-05 21:45:29 +00:00
|
|
|
};
|
|
|
|
|
2022-01-11 19:12:12 +00:00
|
|
|
[[nodiscard]] StringView string() const { return m_string->view(); }
|
2021-11-10 23:55:02 +00:00
|
|
|
Optional<StringView> lookup(StringView key) const;
|
|
|
|
[[nodiscard]] bool contains(StringView key) const;
|
2021-03-03 08:51:55 +00:00
|
|
|
|
2021-03-03 09:00:41 +00:00
|
|
|
[[nodiscard]] bool is_boot_profiling_enabled() const;
|
2021-03-03 08:51:55 +00:00
|
|
|
[[nodiscard]] bool is_ide_enabled() const;
|
2021-11-28 15:38:10 +00:00
|
|
|
[[nodiscard]] bool is_ioapic_enabled() const;
|
2021-12-19 19:30:36 +00:00
|
|
|
[[nodiscard]] bool is_smp_enabled_without_ioapic_enabled() const;
|
2021-03-03 08:51:55 +00:00
|
|
|
[[nodiscard]] bool is_smp_enabled() const;
|
2021-06-04 05:02:14 +00:00
|
|
|
[[nodiscard]] bool is_physical_networking_disabled() const;
|
2021-03-03 08:51:55 +00:00
|
|
|
[[nodiscard]] bool is_vmmouse_enabled() const;
|
2021-04-03 13:46:04 +00:00
|
|
|
[[nodiscard]] PCIAccessLevel pci_access_level() const;
|
2022-01-21 14:09:05 +00:00
|
|
|
[[nodiscard]] bool is_pci_disabled() const;
|
2021-03-03 08:51:55 +00:00
|
|
|
[[nodiscard]] bool is_legacy_time_enabled() const;
|
2022-01-22 10:29:55 +00:00
|
|
|
[[nodiscard]] bool is_pc_speaker_enabled() const;
|
2022-04-30 12:53:02 +00:00
|
|
|
[[nodiscard]] GraphicsSubsystemMode graphics_subsystem_mode() const;
|
2021-03-03 08:51:55 +00:00
|
|
|
[[nodiscard]] bool is_force_pio() const;
|
|
|
|
[[nodiscard]] AcpiFeatureLevel acpi_feature_level() const;
|
2021-10-23 16:26:50 +00:00
|
|
|
[[nodiscard]] StringView system_mode() const;
|
2021-10-23 15:31:00 +00:00
|
|
|
[[nodiscard]] PanicMode panic_mode(Validate should_validate = Validate::No) const;
|
2021-03-03 08:51:55 +00:00
|
|
|
[[nodiscard]] HPETMode hpet_mode() const;
|
2021-04-08 18:18:48 +00:00
|
|
|
[[nodiscard]] bool disable_physical_storage() const;
|
|
|
|
[[nodiscard]] bool disable_ps2_controller() const;
|
2021-04-17 19:36:53 +00:00
|
|
|
[[nodiscard]] bool disable_uhci_controller() const;
|
2021-08-08 18:50:20 +00:00
|
|
|
[[nodiscard]] bool disable_usb() const;
|
2021-04-18 13:06:35 +00:00
|
|
|
[[nodiscard]] bool disable_virtio() const;
|
2022-03-15 20:04:12 +00:00
|
|
|
[[nodiscard]] bool is_early_boot_console_disabled() const;
|
2021-03-12 16:35:16 +00:00
|
|
|
[[nodiscard]] AHCIResetMode ahci_reset_mode() const;
|
2021-08-15 06:49:17 +00:00
|
|
|
[[nodiscard]] StringView userspace_init() const;
|
2021-09-09 09:36:40 +00:00
|
|
|
[[nodiscard]] NonnullOwnPtrVector<KString> userspace_init_args() const;
|
2021-08-15 06:49:17 +00:00
|
|
|
[[nodiscard]] StringView root_device() const;
|
2022-01-27 10:55:39 +00:00
|
|
|
[[nodiscard]] bool is_nvme_polling_enabled() const;
|
2021-05-13 21:22:02 +00:00
|
|
|
[[nodiscard]] size_t switch_to_tty() const;
|
2019-06-07 09:43:58 +00:00
|
|
|
|
2019-06-04 10:54:27 +00:00
|
|
|
private:
|
2022-01-11 19:12:12 +00:00
|
|
|
CommandLine(StringView);
|
2020-04-08 11:54:44 +00:00
|
|
|
|
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);
|
2021-05-21 17:42:33 +00:00
|
|
|
|
2022-01-11 19:12:12 +00:00
|
|
|
NonnullOwnPtr<KString> m_string;
|
2021-05-31 08:59:02 +00:00
|
|
|
HashMap<StringView, StringView> m_params;
|
2019-06-04 10:54:27 +00:00
|
|
|
};
|
2020-04-08 11:54:44 +00:00
|
|
|
|
2022-04-01 17:58:27 +00:00
|
|
|
CommandLine const& kernel_command_line();
|
2020-04-08 11:54:44 +00:00
|
|
|
|
|
|
|
}
|