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

Kernel/PCI: Don't create /proc/pci if PCI is disabled

Reading from /proc/pci assumes we have PCI enabled and also enumerated.
However, if PCI is disabled for some reason, we can't allow the user to
read from it as there's no valuable data we can supply.
This commit is contained in:
Liav A 2022-01-21 18:09:21 +02:00 committed by Andreas Kling
parent 2272d93215
commit b849e4f907
3 changed files with 15 additions and 1 deletions

View file

@ -17,6 +17,7 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/Region.h>
#include <Kernel/Memory/TypedMapping.h>
#include <Kernel/ProcessExposed.h>
#include <Kernel/Sections.h>
namespace Kernel::PCI {
@ -95,6 +96,7 @@ UNMAP_AFTER_INIT bool Access::find_and_register_pci_host_bridges_from_acpi_mcfg_
UNMAP_AFTER_INIT bool Access::initialize_for_multiple_pci_domains(PhysicalAddress mcfg_table)
{
VERIFY(!Access::is_initialized());
ProcFSComponentRegistry::the().root_directory().add_pci_node({});
auto* access = new Access();
if (!access->find_and_register_pci_host_bridges_from_acpi_mcfg_table(mcfg_table))
return false;
@ -106,6 +108,7 @@ UNMAP_AFTER_INIT bool Access::initialize_for_multiple_pci_domains(PhysicalAddres
UNMAP_AFTER_INIT bool Access::initialize_for_one_pci_domain()
{
VERIFY(!Access::is_initialized());
ProcFSComponentRegistry::the().root_directory().add_pci_node({});
auto* access = new Access();
auto host_bridge = HostBridge::must_create_with_io_access();
access->add_host_controller(move(host_bridge));