mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
This commit is contained in:
parent
dd727d1fec
commit
c6ebca5b45
8 changed files with 68 additions and 106 deletions
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/PCI/Access.h>
|
||||
#include <Kernel/PCI/IOAccess.h>
|
||||
|
@ -75,44 +76,34 @@ PhysicalID Access::get_physical_id(Address address) const
|
|||
|
||||
u8 Access::early_read8_field(Address address, u32 field)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Early reading 8-bit field 0x" << String::formatted("{:08x}", field) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Early reading 16-bit field 0x" << String::formatted("{:08x}", field) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Early reading 32-bit field 0x" << String::formatted("{:08x}", field) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Early reading type for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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 slot, u8 function, Function<void(Address, ID)>& callback)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Enumerating function type=" << type << ", bus=" << bus << ", slot=" << slot << ", function=" << function;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function);
|
||||
Address address(0, bus, slot, function);
|
||||
if (type == -1 || type == early_read_type(address))
|
||||
callback(address, { early_read16_field(address, PCI_VENDOR_ID), early_read16_field(address, PCI_DEVICE_ID) });
|
||||
|
@ -128,9 +119,7 @@ void Access::enumerate_functions(int type, u8 bus, u8 slot, u8 function, Functio
|
|||
|
||||
void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID)>& callback)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Enumerating slot type=" << type << ", bus=" << bus << ", slot=" << slot;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot);
|
||||
Address address(0, bus, slot, 0);
|
||||
if (early_read16_field(address, PCI_VENDOR_ID) == PCI_NONE)
|
||||
return;
|
||||
|
@ -146,9 +135,7 @@ void Access::enumerate_slot(int type, u8 bus, u8 slot, Function<void(Address, ID
|
|||
|
||||
void Access::enumerate_bus(int type, u8 bus, Function<void(Address, ID)>& callback)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Enumerating bus type=" << type << ", bus=" << bus;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Enumerating bus type={}, bus={}", type, bus);
|
||||
for (u8 slot = 0; slot < 32; ++slot)
|
||||
enumerate_slot(type, bus, slot, callback);
|
||||
}
|
||||
|
@ -167,18 +154,12 @@ void enumerate(Function<void(Address, ID)> callback)
|
|||
|
||||
Optional<u8> get_capabilities_pointer(Address address)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Getting capabilities pointer for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Getting capabilities pointer for {}", address);
|
||||
if (PCI::read16(address, PCI_STATUS) & (1 << 4)) {
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Found capabilities pointer for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Found capabilities pointer for {}", address);
|
||||
return PCI::read8(address, PCI_CAPABILITIES_POINTER);
|
||||
}
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: No capabilities pointer for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: No capabilities pointer for {}", address);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -189,22 +170,16 @@ PhysicalID get_physical_id(Address address)
|
|||
|
||||
Vector<Capability> get_capabilities(Address address)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Getting capabilities for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Getting capabilities for {}", address);
|
||||
auto capabilities_pointer = PCI::get_capabilities_pointer(address);
|
||||
if (!capabilities_pointer.has_value()) {
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: No capabilities for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: No capabilities for {}", address);
|
||||
return {};
|
||||
}
|
||||
Vector<Capability> capabilities;
|
||||
auto capability_pointer = capabilities_pointer.value();
|
||||
while (capability_pointer != 0) {
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Reading in capability at 0x" << String::formatted("{:02x}", capability_pointer) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address);
|
||||
u16 capability_header = PCI::read16(address, capability_pointer);
|
||||
u8 capability_id = capability_header & 0xff;
|
||||
capability_pointer = capability_header >> 8;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue