1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:17:36 +00:00

Everywhere: Debug macros instead of constexpr.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
This commit is contained in:
asynts 2021-01-23 23:59:27 +01:00 committed by Andreas Kling
parent bb483f7ef4
commit 8465683dcf
98 changed files with 414 additions and 972 deletions

View file

@ -74,34 +74,34 @@ PhysicalID Access::get_physical_id(Address address) const
u8 Access::early_read8_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: Early reading 8-bit field {:#08x} for {}", field, address);
dbgln<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)
{
dbgln<debug_pci>("PCI: Early reading 16-bit field {:#08x} for {}", field, address);
dbgln<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)
{
dbgln<debug_pci>("PCI: Early reading 32-bit field {:#08x} for {}", field, address);
dbgln<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)
{
dbgln<debug_pci>("PCI: Early reading type for {}", address);
dbgln<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 slot, u8 function, Function<void(Address, ID)>& callback)
{
dbgln<debug_pci>("PCI: Enumerating function type={}, bus={}, slot={}, function={}", type, bus, slot, function);
dbgln<PCI_DEBUG>("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) });
@ -117,7 +117,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)
{
dbgln<debug_pci>("PCI: Enumerating slot type={}, bus={}, slot={}", type, bus, slot);
dbgln<PCI_DEBUG>("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;
@ -133,7 +133,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)
{
dbgln<debug_pci>("PCI: Enumerating bus type={}, bus={}", type, bus);
dbgln<PCI_DEBUG>("PCI: Enumerating bus type={}, bus={}", type, bus);
for (u8 slot = 0; slot < 32; ++slot)
enumerate_slot(type, bus, slot, callback);
}
@ -152,12 +152,12 @@ void enumerate(Function<void(Address, ID)> callback)
Optional<u8> get_capabilities_pointer(Address address)
{
dbgln<debug_pci>("PCI: Getting capabilities pointer for {}", address);
dbgln<PCI_DEBUG>("PCI: Getting capabilities pointer for {}", address);
if (PCI::read16(address, PCI_STATUS) & (1 << 4)) {
dbgln<debug_pci>("PCI: Found capabilities pointer for {}", address);
dbgln<PCI_DEBUG>("PCI: Found capabilities pointer for {}", address);
return PCI::read8(address, PCI_CAPABILITIES_POINTER);
}
dbgln<debug_pci>("PCI: No capabilities pointer for {}", address);
dbgln<PCI_DEBUG>("PCI: No capabilities pointer for {}", address);
return {};
}
@ -168,16 +168,16 @@ PhysicalID get_physical_id(Address address)
Vector<Capability> get_capabilities(Address address)
{
dbgln<debug_pci>("PCI: Getting capabilities for {}", address);
dbgln<PCI_DEBUG>("PCI: Getting capabilities for {}", address);
auto capabilities_pointer = PCI::get_capabilities_pointer(address);
if (!capabilities_pointer.has_value()) {
dbgln<debug_pci>("PCI: No capabilities for {}", address);
dbgln<PCI_DEBUG>("PCI: No capabilities for {}", address);
return {};
}
Vector<Capability> capabilities;
auto capability_pointer = capabilities_pointer.value();
while (capability_pointer != 0) {
dbgln<debug_pci>("PCI: Reading in capability at {:#02x} for {}", capability_pointer, address);
dbgln<PCI_DEBUG>("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;

View file

@ -194,7 +194,7 @@ public:
, m_id(id)
, m_capabilities(capabilities)
{
if constexpr (debug_pci) {
if constexpr (PCI_DEBUG) {
for (auto capability : capabilities)
dbgln("{} has capability {}", address, capability.m_id);
}

View file

@ -35,7 +35,7 @@ void IOAccess::initialize()
{
if (!Access::is_initialized()) {
new IOAccess();
dbgln<debug_pci>("PCI: IO access initialised.");
dbgln<PCI_DEBUG>("PCI: IO access initialised.");
}
}
@ -49,37 +49,37 @@ IOAccess::IOAccess()
u8 IOAccess::read8_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: IO Reading 8-bit field {:#08x} for {}", field, address);
return Access::early_read8_field(address, field);
}
u16 IOAccess::read16_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: IO Reading 16-bit field {:#08x} for {}", field, address);
return Access::early_read16_field(address, field);
}
u32 IOAccess::read32_field(Address address, u32 field)
{
dbgln<debug_pci>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: IO Reading 32-bit field {:#08x} for {}", field, address);
return Access::early_read32_field(address, field);
}
void IOAccess::write8_field(Address address, u32 field, u8 value)
{
dbgln<debug_pci>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: IO Writing to 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out8(PCI_VALUE_PORT + (field & 3), value);
}
void IOAccess::write16_field(Address address, u32 field, u16 value)
{
dbgln<debug_pci>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: IO Writing to 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out16(PCI_VALUE_PORT + (field & 2), value);
}
void IOAccess::write32_field(Address address, u32 field, u32 value)
{
dbgln<debug_pci>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: IO Writing to 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
IO::out32(PCI_ADDRESS_PORT, address.io_address_for_field(field));
IO::out32(PCI_VALUE_PORT, value);
}

View file

@ -109,7 +109,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write);
auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr();
dbgln<debug_pci>("PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get()));
dbgln<PCI_DEBUG>("PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get()));
for (u32 index = 0; index < ((mcfg.header.length - sizeof(ACPI::Structures::MCFG)) / sizeof(ACPI::Structures::PCI_MMIO_Descriptor)); index++) {
u8 start_bus = mcfg.descriptors[index].start_pci_bus;
@ -127,26 +127,26 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg)
enumerate_hardware([&](const Address& address, ID id) {
m_mapped_device_regions.append(make<DeviceConfigurationSpaceMapping>(address, m_segments.get(address.seg()).value()));
m_physical_ids.append({ address, id, get_capabilities(address) });
dbgln<debug_pci>("PCI: Mapping device @ pci ({}) {} {}", address, m_mapped_device_regions.last().vaddr(), m_mapped_device_regions.last().paddr());
dbgln<PCI_DEBUG>("PCI: Mapping device @ pci ({}) {} {}", address, m_mapped_device_regions.last().vaddr(), m_mapped_device_regions.last().paddr());
});
}
Optional<VirtualAddress> MMIOAccess::get_device_configuration_space(Address address)
{
dbgln<debug_pci>("PCI: Getting device configuration space for {}", address);
dbgln<PCI_DEBUG>("PCI: Getting device configuration space for {}", address);
for (auto& mapping : m_mapped_device_regions) {
auto checked_address = mapping.address();
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Check if {} was requested", checked_address);
dbgln<PCI_DEBUG>("PCI Device Configuration Space Mapping: Check if {} was requested", checked_address);
if (address.seg() == checked_address.seg()
&& address.bus() == checked_address.bus()
&& address.slot() == checked_address.slot()
&& address.function() == checked_address.function()) {
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Found {}", checked_address);
dbgln<PCI_DEBUG>("PCI Device Configuration Space Mapping: Found {}", checked_address);
return mapping.vaddr();
}
}
dbgln<debug_pci>("PCI: No device configuration space found for {}", address);
dbgln<PCI_DEBUG>("PCI: No device configuration space found for {}", address);
return {};
}
@ -154,7 +154,7 @@ u8 MMIOAccess::read8_field(Address address, u32 field)
{
InterruptDisabler disabler;
ASSERT(field <= 0xfff);
dbgln<debug_pci>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
return *((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
}
@ -162,7 +162,7 @@ u16 MMIOAccess::read16_field(Address address, u32 field)
{
InterruptDisabler disabler;
ASSERT(field < 0xfff);
dbgln<debug_pci>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
return *((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
}
@ -170,7 +170,7 @@ u32 MMIOAccess::read32_field(Address address, u32 field)
{
InterruptDisabler disabler;
ASSERT(field <= 0xffc);
dbgln<debug_pci>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
dbgln<PCI_DEBUG>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
return *((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
}
@ -178,28 +178,28 @@ void MMIOAccess::write8_field(Address address, u32 field, u8 value)
{
InterruptDisabler disabler;
ASSERT(field <= 0xfff);
dbgln<debug_pci>("PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: MMIO Writing 8-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
}
void MMIOAccess::write16_field(Address address, u32 field, u16 value)
{
InterruptDisabler disabler;
ASSERT(field < 0xfff);
dbgln<debug_pci>("PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: MMIO Writing 16-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
}
void MMIOAccess::write32_field(Address address, u32 field, u32 value)
{
InterruptDisabler disabler;
ASSERT(field <= 0xffc);
dbgln<debug_pci>("PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
dbgln<PCI_DEBUG>("PCI: MMIO Writing 32-bit field {:#08x}, value={:#02x} for {}", field, value, address);
*((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff))) = value;
}
void MMIOAccess::enumerate_hardware(Function<void(Address, ID)> callback)
{
for (u16 seg = 0; seg < m_segments.size(); seg++) {
dbgln<debug_pci>("PCI: Enumerating Memory mapped IO segment {}", seg);
dbgln<PCI_DEBUG>("PCI: Enumerating Memory mapped IO segment {}", seg);
// Single PCI host controller.
if ((early_read8_field(Address(seg), PCI_HEADER_TYPE) & 0x80) == 0) {
enumerate_bus(-1, 0, callback);