mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 17:55:07 +00:00
Kernel: Rename SysFS related classes in PCI code
Give them names that sound related to SysFS.
This commit is contained in:
parent
c74b3a310f
commit
5ec3f5433e
3 changed files with 32 additions and 32 deletions
|
@ -368,45 +368,45 @@ void Capability::write32(u32 field, u32 value)
|
||||||
PCI::write32(m_address, m_ptr + field, value);
|
PCI::write32(m_address, m_ptr + field, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT NonnullRefPtr<ExposedDeviceFolder> ExposedDeviceFolder::create(const SysFSDirectory& parent_folder, Address address)
|
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(const SysFSDirectory& parent_folder, Address address)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) ExposedDeviceFolder(parent_folder, address));
|
return adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(parent_folder, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT ExposedDeviceFolder::ExposedDeviceFolder(const SysFSDirectory& parent_folder, Address address)
|
UNMAP_AFTER_INIT PCIDeviceSysFSDirectory::PCIDeviceSysFSDirectory(const SysFSDirectory& parent_folder, Address address)
|
||||||
: SysFSDirectory(String::formatted("{:04x}:{:04x}:{:02x}.{}", address.seg(), address.bus(), address.device(), address.function()), parent_folder)
|
: SysFSDirectory(String::formatted("{:04x}:{:04x}:{:02x}.{}", address.seg(), address.bus(), address.device(), address.function()), parent_folder)
|
||||||
{
|
{
|
||||||
m_components.append(ExposedAttribute::create("vendor", *this, PCI_VENDOR_ID, 2));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("vendor", *this, PCI_VENDOR_ID, 2));
|
||||||
m_components.append(ExposedAttribute::create("device_id", *this, PCI_DEVICE_ID, 2));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("device_id", *this, PCI_DEVICE_ID, 2));
|
||||||
m_components.append(ExposedAttribute::create("class", *this, PCI_CLASS, 1));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("class", *this, PCI_CLASS, 1));
|
||||||
m_components.append(ExposedAttribute::create("subclass", *this, PCI_SUBCLASS, 1));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("subclass", *this, PCI_SUBCLASS, 1));
|
||||||
m_components.append(ExposedAttribute::create("revision", *this, PCI_REVISION_ID, 1));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("revision", *this, PCI_REVISION_ID, 1));
|
||||||
m_components.append(ExposedAttribute::create("progif", *this, PCI_PROG_IF, 1));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("progif", *this, PCI_PROG_IF, 1));
|
||||||
m_components.append(ExposedAttribute::create("subsystem_vendor", *this, PCI_SUBSYSTEM_VENDOR_ID, 2));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("subsystem_vendor", *this, PCI_SUBSYSTEM_VENDOR_ID, 2));
|
||||||
m_components.append(ExposedAttribute::create("subsystem_id", *this, PCI_SUBSYSTEM_ID, 2));
|
m_components.append(PCIDeviceAttributeSysFSComponent::create("subsystem_id", *this, PCI_SUBSYSTEM_ID, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT void BusExposedFolder::initialize()
|
UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
|
||||||
{
|
{
|
||||||
auto pci_folder = adopt_ref(*new (nothrow) BusExposedFolder());
|
auto pci_folder = adopt_ref(*new (nothrow) PCIBusSysFSDirectory());
|
||||||
SysFSComponentRegistry::the().register_new_component(pci_folder);
|
SysFSComponentRegistry::the().register_new_component(pci_folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
UNMAP_AFTER_INIT BusExposedFolder::BusExposedFolder()
|
UNMAP_AFTER_INIT PCIBusSysFSDirectory::PCIBusSysFSDirectory()
|
||||||
: SysFSDirectory("pci", SysFSComponentRegistry::the().root_folder())
|
: SysFSDirectory("pci", SysFSComponentRegistry::the().root_folder())
|
||||||
{
|
{
|
||||||
PCI::enumerate([&](const Address& address, ID) {
|
PCI::enumerate([&](const Address& address, ID) {
|
||||||
auto pci_device = PCI::ExposedDeviceFolder::create(*this, address);
|
auto pci_device = PCI::PCIDeviceSysFSDirectory::create(*this, address);
|
||||||
m_components.append(pci_device);
|
m_components.append(pci_device);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<ExposedAttribute> ExposedAttribute::create(String name, const ExposedDeviceFolder& device, size_t offset, size_t field_bytes_width)
|
NonnullRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(String name, const PCIDeviceSysFSDirectory& device, size_t offset, size_t field_bytes_width)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new (nothrow) ExposedAttribute(name, device, offset, field_bytes_width));
|
return adopt_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(name, device, offset, field_bytes_width));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExposedAttribute::ExposedAttribute(String name, const ExposedDeviceFolder& device, size_t offset, size_t field_bytes_width)
|
PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(String name, const PCIDeviceSysFSDirectory& device, size_t offset, size_t field_bytes_width)
|
||||||
: SysFSComponent(name)
|
: SysFSComponent(name)
|
||||||
, m_device(device)
|
, m_device(device)
|
||||||
, m_offset(offset)
|
, m_offset(offset)
|
||||||
|
@ -414,7 +414,7 @@ ExposedAttribute::ExposedAttribute(String name, const ExposedDeviceFolder& devic
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<size_t> ExposedAttribute::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, FileDescription*) const
|
KResultOr<size_t> PCIDeviceAttributeSysFSComponent::read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, FileDescription*) const
|
||||||
{
|
{
|
||||||
auto blob = try_to_generate_buffer();
|
auto blob = try_to_generate_buffer();
|
||||||
if (!blob)
|
if (!blob)
|
||||||
|
@ -429,7 +429,7 @@ KResultOr<size_t> ExposedAttribute::read_bytes(off_t offset, size_t count, UserO
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ExposedAttribute::size() const
|
size_t PCIDeviceAttributeSysFSComponent::size() const
|
||||||
{
|
{
|
||||||
auto buffer = try_to_generate_buffer();
|
auto buffer = try_to_generate_buffer();
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
|
@ -437,7 +437,7 @@ size_t ExposedAttribute::size() const
|
||||||
return buffer->size();
|
return buffer->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
OwnPtr<KBuffer> ExposedAttribute::try_to_generate_buffer() const
|
OwnPtr<KBuffer> PCIDeviceAttributeSysFSComponent::try_to_generate_buffer() const
|
||||||
{
|
{
|
||||||
String value;
|
String value;
|
||||||
switch (m_field_bytes_width) {
|
switch (m_field_bytes_width) {
|
||||||
|
|
|
@ -14,37 +14,37 @@
|
||||||
|
|
||||||
namespace Kernel::PCI {
|
namespace Kernel::PCI {
|
||||||
|
|
||||||
class BusExposedFolder final : public SysFSDirectory {
|
class PCIBusSysFSDirectory final : public SysFSDirectory {
|
||||||
public:
|
public:
|
||||||
static void initialize();
|
static void initialize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BusExposedFolder();
|
PCIBusSysFSDirectory();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExposedDeviceFolder final : public SysFSDirectory {
|
class PCIDeviceSysFSDirectory final : public SysFSDirectory {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<ExposedDeviceFolder> create(const SysFSDirectory&, Address);
|
static NonnullRefPtr<PCIDeviceSysFSDirectory> create(const SysFSDirectory&, Address);
|
||||||
const Address& address() const { return m_address; }
|
const Address& address() const { return m_address; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExposedDeviceFolder(const SysFSDirectory&, Address);
|
PCIDeviceSysFSDirectory(const SysFSDirectory&, Address);
|
||||||
|
|
||||||
Address m_address;
|
Address m_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExposedAttribute : public SysFSComponent {
|
class PCIDeviceAttributeSysFSComponent : public SysFSComponent {
|
||||||
public:
|
public:
|
||||||
static NonnullRefPtr<ExposedAttribute> create(String name, const ExposedDeviceFolder& device, size_t offset, size_t field_bytes_width);
|
static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(String name, const PCIDeviceSysFSDirectory& device, size_t offset, size_t field_bytes_width);
|
||||||
|
|
||||||
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const override;
|
virtual KResultOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, FileDescription*) const override;
|
||||||
virtual ~ExposedAttribute() {};
|
virtual ~PCIDeviceAttributeSysFSComponent() {};
|
||||||
virtual size_t size() const override;
|
virtual size_t size() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual OwnPtr<KBuffer> try_to_generate_buffer() const;
|
virtual OwnPtr<KBuffer> try_to_generate_buffer() const;
|
||||||
ExposedAttribute(String name, const ExposedDeviceFolder& device, size_t offset, size_t field_bytes_width);
|
PCIDeviceAttributeSysFSComponent(String name, const PCIDeviceSysFSDirectory& device, size_t offset, size_t field_bytes_width);
|
||||||
NonnullRefPtr<ExposedDeviceFolder> m_device;
|
NonnullRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||||
size_t m_offset;
|
size_t m_offset;
|
||||||
size_t m_field_bytes_width;
|
size_t m_field_bytes_width;
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,7 +51,7 @@ UNMAP_AFTER_INIT void initialize()
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
PCI::BusExposedFolder::initialize();
|
PCI::PCIBusSysFSDirectory::initialize();
|
||||||
|
|
||||||
PCI::enumerate([&](const Address& address, ID id) {
|
PCI::enumerate([&](const Address& address, ID id) {
|
||||||
dmesgln("{} {}", address, id);
|
dmesgln("{} {}", address, id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue