mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
Kernel: Add a method to retrieve the Physical ID for a PCI address
This commit is contained in:
parent
85b4256d10
commit
97b36febd5
2 changed files with 20 additions and 0 deletions
|
@ -58,6 +58,19 @@ Access::Access()
|
||||||
s_access = this;
|
s_access = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhysicalID Access::get_physical_id(Address address) const
|
||||||
|
{
|
||||||
|
for (auto physical_id : m_physical_ids) {
|
||||||
|
if (physical_id.address().seg() == address.seg()
|
||||||
|
&& physical_id.address().bus() == address.bus()
|
||||||
|
&& physical_id.address().slot() == address.slot()
|
||||||
|
&& physical_id.address().function() == address.function()) {
|
||||||
|
return physical_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
u8 Access::early_read8_field(Address address, u32 field)
|
u8 Access::early_read8_field(Address address, u32 field)
|
||||||
{
|
{
|
||||||
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
|
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
|
||||||
|
@ -137,6 +150,11 @@ Optional<u8> get_capabilities_pointer(Address address)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhysicalID get_physical_id(Address address)
|
||||||
|
{
|
||||||
|
return Access::the().get_physical_id(address);
|
||||||
|
}
|
||||||
|
|
||||||
Vector<Capability> get_capabilities(Address address)
|
Vector<Capability> get_capabilities(Address address)
|
||||||
{
|
{
|
||||||
auto capabilities_pointer = PCI::get_capabilities_pointer(address);
|
auto capabilities_pointer = PCI::get_capabilities_pointer(address);
|
||||||
|
|
|
@ -60,6 +60,8 @@ public:
|
||||||
virtual u16 read16_field(Address address, u32 field) = 0;
|
virtual u16 read16_field(Address address, u32 field) = 0;
|
||||||
virtual u32 read32_field(Address address, u32 field) = 0;
|
virtual u32 read32_field(Address address, u32 field) = 0;
|
||||||
|
|
||||||
|
PhysicalID get_physical_id(Address address) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void enumerate_hardware(Function<void(Address, ID)>) = 0;
|
virtual void enumerate_hardware(Function<void(Address, ID)>) = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue