mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
Kernel: Rename two PCI components
Rename ID => HardwareID, and PhysicalID => DeviceIdentifier. This change merely does that to clarify what these objects really are.
This commit is contained in:
parent
82bb08a15c
commit
da327746a2
26 changed files with 97 additions and 97 deletions
|
@ -17,17 +17,17 @@ u8 read8(Address address, u32 field) { return Access::the().read8_field(address,
|
|||
u16 read16(Address address, u32 field) { return Access::the().read16_field(address, field); }
|
||||
u32 read32(Address address, u32 field) { return Access::the().read32_field(address, field); }
|
||||
|
||||
void enumerate(Function<void(Address, PhysicalID const&)> callback)
|
||||
void enumerate(Function<void(Address, DeviceIdentifier const&)> callback)
|
||||
{
|
||||
Access::the().fast_enumerate(callback);
|
||||
}
|
||||
|
||||
PhysicalID get_physical_id(Address address)
|
||||
DeviceIdentifier get_device_identifier(Address address)
|
||||
{
|
||||
return Access::the().get_physical_id(address);
|
||||
return Access::the().get_device_identifier(address);
|
||||
}
|
||||
|
||||
ID get_id(Address address)
|
||||
HardwareID get_hardware_id(Address address)
|
||||
{
|
||||
return { read16(address, PCI_VENDOR_ID), read16(address, PCI_DEVICE_ID) };
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ u8 read8(Address address, u32 field);
|
|||
u16 read16(Address address, u32 field);
|
||||
u32 read32(Address address, u32 field);
|
||||
|
||||
ID get_id(PCI::Address);
|
||||
HardwareID get_hardware_id(PCI::Address);
|
||||
bool is_io_space_enabled(Address);
|
||||
void enumerate(Function<void(Address, PhysicalID const&)> callback);
|
||||
void enumerate(Function<void(Address, DeviceIdentifier const&)> callback);
|
||||
void enable_interrupt_line(Address);
|
||||
void disable_interrupt_line(Address);
|
||||
u8 get_interrupt_line(Address);
|
||||
|
@ -44,6 +44,6 @@ void enable_io_space(Address);
|
|||
void disable_io_space(Address);
|
||||
void enable_memory_space(Address);
|
||||
void disable_memory_space(Address);
|
||||
PhysicalID get_physical_id(Address address);
|
||||
DeviceIdentifier get_device_identifier(Address address);
|
||||
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ u32 Access::read32_field(Address address, u32 field)
|
|||
UNMAP_AFTER_INIT void Access::rescan_hardware()
|
||||
{
|
||||
MutexLocker locker(m_scan_lock);
|
||||
VERIFY(m_physical_ids.is_empty());
|
||||
VERIFY(m_device_identifiers.is_empty());
|
||||
if (m_access_type == AccessType::IO) {
|
||||
dbgln_if(PCI_DEBUG, "PCI: IO enumerating hardware");
|
||||
|
||||
|
@ -381,14 +381,14 @@ UNMAP_AFTER_INIT void Access::enumerate_functions(int type, u8 bus, u8 device, u
|
|||
Address address(0, bus, device, function);
|
||||
auto read_type = (read8_field(address, PCI_CLASS) << 8u) | read8_field(address, PCI_SUBCLASS);
|
||||
if (type == -1 || type == read_type) {
|
||||
PCI::ID id = { read16_field(address, PCI_VENDOR_ID), read16_field(address, PCI_DEVICE_ID) };
|
||||
HardwareID id = { read16_field(address, PCI_VENDOR_ID), read16_field(address, PCI_DEVICE_ID) };
|
||||
ClassCode class_code = read8_field(address, PCI_CLASS);
|
||||
SubclassCode subclass_code = read8_field(address, PCI_SUBCLASS);
|
||||
ProgrammingInterface prog_if = read8_field(address, PCI_PROG_IF);
|
||||
RevisionID revision_id = read8_field(address, PCI_REVISION_ID);
|
||||
SubsystemID subsystem_id = read16_field(address, PCI_SUBSYSTEM_ID);
|
||||
SubsystemVendorID subsystem_vendor_id = read16_field(address, PCI_SUBSYSTEM_VENDOR_ID);
|
||||
m_physical_ids.append(PhysicalID { address, id, revision_id, class_code, subclass_code, prog_if, subsystem_id, subsystem_vendor_id, get_capabilities(address) });
|
||||
m_device_identifiers.append(DeviceIdentifier { address, id, revision_id, class_code, subclass_code, prog_if, subsystem_id, subsystem_vendor_id, get_capabilities(address) });
|
||||
}
|
||||
|
||||
if (read_type == PCI_TYPE_BRIDGE && recursive && (!m_enumerated_buses.get(read8_field(address, PCI_SECONDARY_BUS)))) {
|
||||
|
@ -423,23 +423,23 @@ UNMAP_AFTER_INIT void Access::enumerate_bus(int type, u8 bus, bool recursive)
|
|||
enumerate_device(type, bus, device, recursive);
|
||||
}
|
||||
|
||||
void Access::fast_enumerate(Function<void(Address, PhysicalID const&)>& callback) const
|
||||
void Access::fast_enumerate(Function<void(Address, DeviceIdentifier const&)>& callback) const
|
||||
{
|
||||
MutexLocker locker(m_scan_lock);
|
||||
VERIFY(!m_physical_ids.is_empty());
|
||||
for (auto& physical_id : m_physical_ids) {
|
||||
callback(physical_id.address(), physical_id);
|
||||
VERIFY(!m_device_identifiers.is_empty());
|
||||
for (auto& device_identifier : m_device_identifiers) {
|
||||
callback(device_identifier.address(), device_identifier);
|
||||
}
|
||||
}
|
||||
|
||||
PhysicalID Access::get_physical_id(Address address) const
|
||||
DeviceIdentifier Access::get_device_identifier(Address address) const
|
||||
{
|
||||
for (auto physical_id : m_physical_ids) {
|
||||
if (physical_id.address().domain() == address.domain()
|
||||
&& physical_id.address().bus() == address.bus()
|
||||
&& physical_id.address().device() == address.device()
|
||||
&& physical_id.address().function() == address.function()) {
|
||||
return physical_id;
|
||||
for (auto device_identifier : m_device_identifiers) {
|
||||
if (device_identifier.address().domain() == address.domain()
|
||||
&& device_identifier.address().bus() == address.bus()
|
||||
&& device_identifier.address().device() == address.device()
|
||||
&& device_identifier.address().function() == address.function()) {
|
||||
return device_identifier;
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
static bool initialize_for_memory_access(PhysicalAddress mcfg_table);
|
||||
static bool initialize_for_io_access();
|
||||
|
||||
void fast_enumerate(Function<void(Address, PhysicalID const&)>&) const;
|
||||
void fast_enumerate(Function<void(Address, DeviceIdentifier const&)>&) const;
|
||||
void rescan_hardware();
|
||||
|
||||
static Access& the();
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
u8 read8_field(Address address, u32 field);
|
||||
u16 read16_field(Address address, u32 field);
|
||||
u32 read32_field(Address address, u32 field);
|
||||
PhysicalID get_physical_id(Address address) const;
|
||||
DeviceIdentifier get_device_identifier(Address address) const;
|
||||
|
||||
private:
|
||||
void enumerate_bus(int type, u8 bus, bool recursive);
|
||||
|
@ -80,6 +80,6 @@ private:
|
|||
mutable Mutex m_scan_lock;
|
||||
Bitmap m_enumerated_buses;
|
||||
AccessType m_access_type;
|
||||
Vector<PhysicalID> m_physical_ids;
|
||||
Vector<DeviceIdentifier> m_device_identifiers;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -59,17 +59,17 @@ namespace Kernel {
|
|||
#define PCI_AHCI_IF_PROGIF 0x1
|
||||
|
||||
namespace PCI {
|
||||
struct ID {
|
||||
struct HardwareID {
|
||||
u16 vendor_id { 0 };
|
||||
u16 device_id { 0 };
|
||||
|
||||
bool is_null() const { return !vendor_id && !device_id; }
|
||||
|
||||
bool operator==(const ID& other) const
|
||||
bool operator==(const HardwareID& other) const
|
||||
{
|
||||
return vendor_id == other.vendor_id && device_id == other.device_id;
|
||||
}
|
||||
bool operator!=(const ID& other) const
|
||||
bool operator!=(const HardwareID& other) const
|
||||
{
|
||||
return vendor_id != other.vendor_id || device_id != other.device_id;
|
||||
}
|
||||
|
@ -189,11 +189,11 @@ TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID);
|
|||
TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemVendorID);
|
||||
|
||||
class Access;
|
||||
class PhysicalID {
|
||||
class DeviceIdentifier {
|
||||
public:
|
||||
PhysicalID(Address address, ID id, RevisionID revision_id, ClassCode class_code, SubclassCode subclass_code, ProgrammingInterface prog_if, SubsystemID subsystem_id, SubsystemVendorID subsystem_vendor_id, Vector<Capability> capabilities)
|
||||
DeviceIdentifier(Address address, HardwareID hardware_id, RevisionID revision_id, ClassCode class_code, SubclassCode subclass_code, ProgrammingInterface prog_if, SubsystemID subsystem_id, SubsystemVendorID subsystem_vendor_id, Vector<Capability> capabilities)
|
||||
: m_address(address)
|
||||
, m_id(id)
|
||||
, m_hardware_id(hardware_id)
|
||||
, m_revision_id(revision_id)
|
||||
, m_class_code(class_code)
|
||||
, m_subclass_code(subclass_code)
|
||||
|
@ -209,7 +209,7 @@ public:
|
|||
}
|
||||
|
||||
Vector<Capability> capabilities() const { return m_capabilities; }
|
||||
const ID& id() const { return m_id; }
|
||||
const HardwareID& hardware_id() const { return m_hardware_id; }
|
||||
const Address& address() const { return m_address; }
|
||||
|
||||
RevisionID revision_id() const { return m_revision_id; }
|
||||
|
@ -230,7 +230,7 @@ public:
|
|||
|
||||
private:
|
||||
Address m_address;
|
||||
ID m_id;
|
||||
HardwareID m_hardware_id;
|
||||
|
||||
RevisionID m_revision_id;
|
||||
ClassCode m_class_code;
|
||||
|
@ -259,11 +259,11 @@ struct AK::Formatter<Kernel::PCI::Address> : Formatter<FormatString> {
|
|||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Kernel::PCI::ID> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, Kernel::PCI::ID value)
|
||||
struct AK::Formatter<Kernel::PCI::HardwareID> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, Kernel::PCI::HardwareID value)
|
||||
{
|
||||
return Formatter<FormatString>::format(
|
||||
builder,
|
||||
"PCI::ID [{:04x}:{:04x}]", value.vendor_id, value.device_id);
|
||||
"PCI::HardwareID [{:04x}:{:04x}]", value.vendor_id, value.device_id);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ Device::Device(Address address)
|
|||
|
||||
bool Device::is_msi_capable() const
|
||||
{
|
||||
for (const auto& capability : PCI::get_physical_id(pci_address()).capabilities()) {
|
||||
for (const auto& capability : PCI::get_device_identifier(pci_address()).capabilities()) {
|
||||
if (capability.id() == PCI_CAPABILITY_MSI)
|
||||
return true;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ bool Device::is_msi_capable() const
|
|||
}
|
||||
bool Device::is_msix_capable() const
|
||||
{
|
||||
for (const auto& capability : PCI::get_physical_id(pci_address()).capabilities()) {
|
||||
for (const auto& capability : PCI::get_device_identifier(pci_address()).capabilities()) {
|
||||
if (capability.id() == PCI_CAPABILITY_MSIX)
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ UNMAP_AFTER_INIT void initialize()
|
|||
|
||||
PCI::PCIBusSysFSDirectory::initialize();
|
||||
|
||||
PCI::enumerate([&](const Address& address, PhysicalID const& physical_id) {
|
||||
dmesgln("{} {}", address, physical_id.id());
|
||||
PCI::enumerate([&](const Address& address, DeviceIdentifier const& device_identifier) {
|
||||
dmesgln("{} {}", address, device_identifier.hardware_id());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
|
|||
UNMAP_AFTER_INIT PCIBusSysFSDirectory::PCIBusSysFSDirectory()
|
||||
: SysFSDirectory("pci", SysFSComponentRegistry::the().buses_directory())
|
||||
{
|
||||
PCI::enumerate([&](const Address& address, PhysicalID const&) {
|
||||
PCI::enumerate([&](const Address& address, DeviceIdentifier const&) {
|
||||
auto pci_device = PCI::PCIDeviceSysFSDirectory::create(*this, address);
|
||||
m_components.append(pci_device);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue