Skip to content

Commit

Permalink
Kernel: Mark PCI Access enumeration functions as UNMAP_AFTER_INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
bgianfo authored and awesomekling committed Jun 9, 2021
1 parent 9e6f0fd commit 40ea464
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Kernel/PCI/Access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,34 @@ PhysicalID Access::get_physical_id(Address address) const
VERIFY_NOT_REACHED();
}

u8 Access::early_read8_field(Address address, u32 field)
UNMAP_AFTER_INIT u8 Access::early_read8_field(Address address, u32 field)
{
dbgln_if(PCI_DEBUG, "PCI: Early reading 8-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in8(PCI_VALUE_PORT + (field & 3));
}

u16 Access::early_read16_field(Address address, u32 field)
UNMAP_AFTER_INIT u16 Access::early_read16_field(Address address, u32 field)
{
dbgln_if(PCI_DEBUG, "PCI: Early reading 16-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in16(PCI_VALUE_PORT + (field & 2));
}

u32 Access::early_read32_field(Address address, u32 field)
UNMAP_AFTER_INIT u32 Access::early_read32_field(Address address, u32 field)
{
dbgln_if(PCI_DEBUG, "PCI: Early reading 32-bit field {:#08x} for {}", field, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
return IO::in32(PCI_VALUE_PORT);
}

u16 Access::early_read_type(Address address)
UNMAP_AFTER_INIT u16 Access::early_read_type(Address address)
{
dbgln_if(PCI_DEBUG, "PCI: Early reading type for {}", address);
return (early_read8_field(address, PCI_CLASS) << 8u) | early_read8_field(address, PCI_SUBCLASS);
}

void Access::enumerate_functions(int type, u8 bus, u8 device, u8 function, Function<void(Address, ID)>& callback, bool recursive)
UNMAP_AFTER_INIT void Access::enumerate_functions(int type, u8 bus, u8 device, u8 function, Function<void(Address, ID)>& callback, bool recursive)
{
dbgln_if(PCI_DEBUG, "PCI: Enumerating function type={}, bus={}, device={}, function={}", type, bus, device, function);
Address address(0, bus, device, function);
Expand All @@ -95,7 +95,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 device, u8 function, Funct
}
}

void Access::enumerate_device(int type, u8 bus, u8 device, Function<void(Address, ID)>& callback, bool recursive)
UNMAP_AFTER_INIT void Access::enumerate_device(int type, u8 bus, u8 device, Function<void(Address, ID)>& callback, bool recursive)
{
dbgln_if(PCI_DEBUG, "PCI: Enumerating device type={}, bus={}, device={}", type, bus, device);
Address address(0, bus, device, 0);
Expand All @@ -111,26 +111,26 @@ void Access::enumerate_device(int type, u8 bus, u8 device, Function<void(Address
}
}

void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback, bool recursive)
UNMAP_AFTER_INIT void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback, bool recursive)
{
dbgln_if(PCI_DEBUG, "PCI: Enumerating bus type={}, bus={}", type, bus);
for (u8 device = 0; device < 32; ++device)
enumerate_device(type, bus, device, callback, recursive);
}

void Access::enumerate(Function<void(Address, ID)>& callback) const
UNMAP_AFTER_INIT void Access::enumerate(Function<void(Address, ID)>& callback) const
{
for (auto& physical_id : m_physical_ids) {
callback(physical_id.address(), physical_id.id());
}
}

void enumerate(Function<void(Address, ID)> callback)
UNMAP_AFTER_INIT void enumerate(Function<void(Address, ID)> callback)
{
Access::the().enumerate(callback);
}

Optional<u8> get_capabilities_pointer(Address address)
UNMAP_AFTER_INIT Optional<u8> get_capabilities_pointer(Address address)
{
dbgln_if(PCI_DEBUG, "PCI: Getting capabilities pointer for {}", address);
if (PCI::read16(address, PCI_STATUS) & (1 << 4)) {
Expand All @@ -146,7 +146,7 @@ PhysicalID get_physical_id(Address address)
return Access::the().get_physical_id(address);
}

Vector<Capability> get_capabilities(Address address)
UNMAP_AFTER_INIT Vector<Capability> get_capabilities(Address address)
{
dbgln_if(PCI_DEBUG, "PCI: Getting capabilities for {}", address);
auto capabilities_pointer = PCI::get_capabilities_pointer(address);
Expand Down

0 comments on commit 40ea464

Please sign in to comment.