1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

Kernel: Change PCI access commandline option to also represent no access

This change allow the user to request the kernel to not use any PCI
resources/devices at all.

Also, don't try to initialize devices that rely on PCI if disabled.
This commit is contained in:
Liav A 2022-01-21 16:09:05 +02:00 committed by Andreas Kling
parent 6bf59cbb1b
commit f6e635938f
5 changed files with 25 additions and 8 deletions

View file

@ -56,7 +56,8 @@ List of options:
* **`panic`** - This parameter expects **`halt`** or **`shutdown`**. This is particularly useful in CI contexts. * **`panic`** - This parameter expects **`halt`** or **`shutdown`**. This is particularly useful in CI contexts.
* **`pci_ecam`** - This parameter expects **`on`** or **`off`**. * **`pci`** - This parameter expects **`ecam`**, **`io`** or **`none`**. When selecting **`none`**
the kernel will not use PCI resources/devices.
* **`root`** - This parameter configures the device to use as the root file system. It defaults to **`/dev/hda`** if unspecified. * **`root`** - This parameter configures the device to use as the root file system. It defaults to **`/dev/hda`** if unspecified.

View file

@ -36,6 +36,7 @@ UNMAP_AFTER_INIT static PCIAccessLevel detect_optimal_access_type()
UNMAP_AFTER_INIT void initialize() UNMAP_AFTER_INIT void initialize()
{ {
VERIFY(kernel_command_line().pci_access_level() != PCIAccessLevel::None);
switch (detect_optimal_access_type()) { switch (detect_optimal_access_type()) {
case PCIAccessLevel::MemoryAddressing: { case PCIAccessLevel::MemoryAddressing: {
auto mcfg = ACPI::Parser::the()->find_table("MCFG"); auto mcfg = ACPI::Parser::the()->find_table("MCFG");

View file

@ -142,14 +142,21 @@ UNMAP_AFTER_INIT bool CommandLine::is_vmmouse_enabled() const
UNMAP_AFTER_INIT PCIAccessLevel CommandLine::pci_access_level() const UNMAP_AFTER_INIT PCIAccessLevel CommandLine::pci_access_level() const
{ {
auto value = lookup("pci_ecam"sv).value_or("on"sv); auto value = lookup("pci"sv).value_or("ecam"sv);
if (value == "on"sv) if (value == "ecam"sv)
return PCIAccessLevel::MemoryAddressing; return PCIAccessLevel::MemoryAddressing;
if (value == "off"sv) if (value == "io"sv)
return PCIAccessLevel::IOAddressing; return PCIAccessLevel::IOAddressing;
if (value == "none"sv)
return PCIAccessLevel::None;
PANIC("Unknown PCI ECAM setting: {}", value); PANIC("Unknown PCI ECAM setting: {}", value);
} }
UNMAP_AFTER_INIT bool CommandLine::is_pci_disabled() const
{
return lookup("pci"sv).value_or("ecam"sv) == "none"sv;
}
UNMAP_AFTER_INIT bool CommandLine::is_legacy_time_enabled() const UNMAP_AFTER_INIT bool CommandLine::is_legacy_time_enabled() const
{ {
return lookup("time"sv).value_or("modern"sv) == "legacy"sv; return lookup("time"sv).value_or("modern"sv) == "legacy"sv;

View file

@ -31,6 +31,7 @@ enum class AcpiFeatureLevel {
}; };
enum class PCIAccessLevel { enum class PCIAccessLevel {
None,
IOAddressing, IOAddressing,
MemoryAddressing, MemoryAddressing,
}; };
@ -70,6 +71,7 @@ public:
[[nodiscard]] bool is_physical_networking_disabled() const; [[nodiscard]] bool is_physical_networking_disabled() const;
[[nodiscard]] bool is_vmmouse_enabled() const; [[nodiscard]] bool is_vmmouse_enabled() const;
[[nodiscard]] PCIAccessLevel pci_access_level() const; [[nodiscard]] PCIAccessLevel pci_access_level() const;
[[nodiscard]] bool is_pci_disabled() const;
[[nodiscard]] bool is_legacy_time_enabled() const; [[nodiscard]] bool is_legacy_time_enabled() const;
[[nodiscard]] bool is_pc_speaker_enabled() const; [[nodiscard]] bool is_pc_speaker_enabled() const;
[[nodiscard]] FrameBufferDevices are_framebuffer_devices_enabled() const; [[nodiscard]] FrameBufferDevices are_framebuffer_devices_enabled() const;

View file

@ -299,8 +299,10 @@ void init_stage2(void*)
} }
// Initialize the PCI Bus as early as possible, for early boot (PCI based) serial logging // Initialize the PCI Bus as early as possible, for early boot (PCI based) serial logging
PCI::initialize(); if (!kernel_command_line().is_pci_disabled()) {
PCISerialDevice::detect(); PCI::initialize();
PCISerialDevice::detect();
}
VirtualFileSystem::initialize(); VirtualFileSystem::initialize();
@ -321,10 +323,14 @@ void init_stage2(void*)
auto boot_profiling = kernel_command_line().is_boot_profiling_enabled(); auto boot_profiling = kernel_command_line().is_boot_profiling_enabled();
USB::USBManagement::initialize(); if (!kernel_command_line().is_pci_disabled()) {
USB::USBManagement::initialize();
}
FirmwareSysFSDirectory::initialize(); FirmwareSysFSDirectory::initialize();
VirtIO::detect(); if (!kernel_command_line().is_pci_disabled()) {
VirtIO::detect();
}
NetworkingManagement::the().initialize(); NetworkingManagement::the().initialize();
Syscall::initialize(); Syscall::initialize();