1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 09:45:06 +00:00
serenity/Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/BusDirectory.cpp
Liav A 70afa0b171 Kernel/SysFS: Mark SysFSDirectory traverse and lookup methods as final
This enforces us to remove duplicated code across the SysFS code. This
results in great simplification of how the SysFS works now, because we
enforce one way to treat SysFSDirectory objects.
2022-07-15 12:29:23 +02:00

35 lines
1.1 KiB
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Bus/PCI/API.h>
#include <Kernel/Bus/PCI/Access.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/SysFS/Registry.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/BusDirectory.h>
#include <Kernel/FileSystem/SysFS/Subsystems/Bus/PCI/DeviceDirectory.h>
#include <Kernel/Sections.h>
namespace Kernel {
UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
{
auto pci_directory = adopt_ref(*new (nothrow) PCIBusSysFSDirectory());
SysFSComponentRegistry::the().register_new_bus_directory(pci_directory);
}
UNMAP_AFTER_INIT PCIBusSysFSDirectory::PCIBusSysFSDirectory()
: SysFSDirectory(SysFSComponentRegistry::the().buses_directory())
{
MUST(m_child_components.with([&](auto& list) -> ErrorOr<void> {
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
auto pci_device = PCIDeviceSysFSDirectory::create(*this, device_identifier.address());
list.append(pci_device);
}));
return {};
}));
}
}