mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:57:35 +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:
parent
2272d93215
commit
b849e4f907
3 changed files with 15 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <Kernel/Memory/MemoryManager.h>
|
#include <Kernel/Memory/MemoryManager.h>
|
||||||
#include <Kernel/Memory/Region.h>
|
#include <Kernel/Memory/Region.h>
|
||||||
#include <Kernel/Memory/TypedMapping.h>
|
#include <Kernel/Memory/TypedMapping.h>
|
||||||
|
#include <Kernel/ProcessExposed.h>
|
||||||
#include <Kernel/Sections.h>
|
#include <Kernel/Sections.h>
|
||||||
|
|
||||||
namespace Kernel::PCI {
|
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)
|
UNMAP_AFTER_INIT bool Access::initialize_for_multiple_pci_domains(PhysicalAddress mcfg_table)
|
||||||
{
|
{
|
||||||
VERIFY(!Access::is_initialized());
|
VERIFY(!Access::is_initialized());
|
||||||
|
ProcFSComponentRegistry::the().root_directory().add_pci_node({});
|
||||||
auto* access = new Access();
|
auto* access = new Access();
|
||||||
if (!access->find_and_register_pci_host_bridges_from_acpi_mcfg_table(mcfg_table))
|
if (!access->find_and_register_pci_host_bridges_from_acpi_mcfg_table(mcfg_table))
|
||||||
return false;
|
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()
|
UNMAP_AFTER_INIT bool Access::initialize_for_one_pci_domain()
|
||||||
{
|
{
|
||||||
VERIFY(!Access::is_initialized());
|
VERIFY(!Access::is_initialized());
|
||||||
|
ProcFSComponentRegistry::the().root_directory().add_pci_node({});
|
||||||
auto* access = new Access();
|
auto* access = new Access();
|
||||||
auto host_bridge = HostBridge::must_create_with_io_access();
|
auto host_bridge = HostBridge::must_create_with_io_access();
|
||||||
access->add_host_controller(move(host_bridge));
|
access->add_host_controller(move(host_bridge));
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
||||||
#include <Kernel/Arch/x86/ProcessorInfo.h>
|
#include <Kernel/Arch/x86/ProcessorInfo.h>
|
||||||
#include <Kernel/Bus/PCI/API.h>
|
#include <Kernel/Bus/PCI/API.h>
|
||||||
|
#include <Kernel/Bus/PCI/Access.h>
|
||||||
#include <Kernel/CommandLine.h>
|
#include <Kernel/CommandLine.h>
|
||||||
#include <Kernel/Devices/DeviceManagement.h>
|
#include <Kernel/Devices/DeviceManagement.h>
|
||||||
#include <Kernel/Devices/HID/HIDManagement.h>
|
#include <Kernel/Devices/HID/HIDManagement.h>
|
||||||
|
@ -949,6 +950,11 @@ UNMAP_AFTER_INIT ProcFSSystemDirectory::ProcFSSystemDirectory(const ProcFSRootDi
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNMAP_AFTER_INIT void ProcFSRootDirectory::add_pci_node(Badge<PCI::Access>)
|
||||||
|
{
|
||||||
|
m_components.append(ProcFSPCI::must_create());
|
||||||
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSRootDirectory> ProcFSRootDirectory::must_create()
|
UNMAP_AFTER_INIT NonnullRefPtr<ProcFSRootDirectory> ProcFSRootDirectory::must_create()
|
||||||
{
|
{
|
||||||
auto directory = adopt_ref(*new (nothrow) ProcFSRootDirectory);
|
auto directory = adopt_ref(*new (nothrow) ProcFSRootDirectory);
|
||||||
|
@ -961,7 +967,6 @@ UNMAP_AFTER_INIT NonnullRefPtr<ProcFSRootDirectory> ProcFSRootDirectory::must_cr
|
||||||
directory->m_components.append(ProcFSDmesg::must_create());
|
directory->m_components.append(ProcFSDmesg::must_create());
|
||||||
directory->m_components.append(ProcFSInterrupts::must_create());
|
directory->m_components.append(ProcFSInterrupts::must_create());
|
||||||
directory->m_components.append(ProcFSKeymap::must_create());
|
directory->m_components.append(ProcFSKeymap::must_create());
|
||||||
directory->m_components.append(ProcFSPCI::must_create());
|
|
||||||
directory->m_components.append(ProcFSDevices::must_create());
|
directory->m_components.append(ProcFSDevices::must_create());
|
||||||
directory->m_components.append(ProcFSUptime::must_create());
|
directory->m_components.append(ProcFSUptime::must_create());
|
||||||
directory->m_components.append(ProcFSCommandLine::must_create());
|
directory->m_components.append(ProcFSCommandLine::must_create());
|
||||||
|
|
|
@ -138,12 +138,18 @@ protected:
|
||||||
mutable Mutex m_lock { "ProcFSLink" };
|
mutable Mutex m_lock { "ProcFSLink" };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace PCI {
|
||||||
|
class Access;
|
||||||
|
}
|
||||||
|
|
||||||
class ProcFSRootDirectory final : public ProcFSExposedDirectory {
|
class ProcFSRootDirectory final : public ProcFSExposedDirectory {
|
||||||
friend class ProcFSComponentRegistry;
|
friend class ProcFSComponentRegistry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> lookup(StringView name) override;
|
virtual ErrorOr<NonnullRefPtr<ProcFSExposedComponent>> lookup(StringView name) override;
|
||||||
static NonnullRefPtr<ProcFSRootDirectory> must_create();
|
static NonnullRefPtr<ProcFSRootDirectory> must_create();
|
||||||
|
|
||||||
|
void add_pci_node(Badge<PCI::Access>);
|
||||||
virtual ~ProcFSRootDirectory();
|
virtual ~ProcFSRootDirectory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue