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
Notes: sideshowbarker 2024-07-17 18:02:32 +09:00
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.
* **`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.

View file

@ -36,6 +36,7 @@ UNMAP_AFTER_INIT static PCIAccessLevel detect_optimal_access_type()
UNMAP_AFTER_INIT void initialize()
{
VERIFY(kernel_command_line().pci_access_level() != PCIAccessLevel::None);
switch (detect_optimal_access_type()) {
case PCIAccessLevel::MemoryAddressing: {
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
{
auto value = lookup("pci_ecam"sv).value_or("on"sv);
if (value == "on"sv)
auto value = lookup("pci"sv).value_or("ecam"sv);
if (value == "ecam"sv)
return PCIAccessLevel::MemoryAddressing;
if (value == "off"sv)
if (value == "io"sv)
return PCIAccessLevel::IOAddressing;
if (value == "none"sv)
return PCIAccessLevel::None;
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
{
return lookup("time"sv).value_or("modern"sv) == "legacy"sv;

View file

@ -31,6 +31,7 @@ enum class AcpiFeatureLevel {
};
enum class PCIAccessLevel {
None,
IOAddressing,
MemoryAddressing,
};
@ -70,6 +71,7 @@ public:
[[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]] 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
PCI::initialize();
PCISerialDevice::detect();
if (!kernel_command_line().is_pci_disabled()) {
PCI::initialize();
PCISerialDevice::detect();
}
VirtualFileSystem::initialize();
@ -321,10 +323,14 @@ void init_stage2(void*)
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();
VirtIO::detect();
if (!kernel_command_line().is_pci_disabled()) {
VirtIO::detect();
}
NetworkingManagement::the().initialize();
Syscall::initialize();