mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +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
c6ebca5b45
commit
a348ab55b0
Notes:
sideshowbarker
2024-07-18 22:59:02 +09:00
Author: https://github.com/asynts Commit: https://github.com/SerenityOS/serenity/commit/a348ab55b03 Pull-request: https://github.com/SerenityOS/serenity/pull/5012 Reviewed-by: https://github.com/alimpfard
12
AK/Debug.h
12
AK/Debug.h
|
@ -201,3 +201,15 @@ constexpr bool debug_pci = true;
|
|||
#else
|
||||
constexpr bool debug_pci = false;
|
||||
#endif
|
||||
|
||||
#ifdef PATA_DEBUG
|
||||
constexpr bool debug_pata = true;
|
||||
#else
|
||||
constexpr bool debug_pata = false;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_IO
|
||||
constexpr bool debug_io = true;
|
||||
#else
|
||||
constexpr bool debug_io = false;
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/PCI/MMIOAccess.h>
|
||||
|
@ -110,9 +111,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();
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Checking MCFG @ V " << &mcfg << ", P 0x" << String::format("%x", p_mcfg.get());
|
||||
#endif
|
||||
dbgln<debug_pci>("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;
|
||||
|
@ -130,36 +129,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) });
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Mapping device @ pci (" << address << ")"
|
||||
<< " " << m_mapped_device_regions.last().vaddr() << " " << m_mapped_device_regions.last().paddr();
|
||||
#endif
|
||||
dbgln<debug_pci>("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)
|
||||
{
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Getting device configuration space for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: Getting device configuration space for {}", address);
|
||||
for (auto& mapping : m_mapped_device_regions) {
|
||||
auto checked_address = mapping.address();
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI Device Configuration Space Mapping: Check if " << checked_address << " was requested";
|
||||
#endif
|
||||
dbgln<debug_pci>("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()) {
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI Device Configuration Space Mapping: Found " << checked_address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI Device Configuration Space Mapping: Found {}", checked_address);
|
||||
return mapping.vaddr();
|
||||
}
|
||||
}
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: No device configuration space found for " << address;
|
||||
#endif
|
||||
|
||||
dbgln<debug_pci>("PCI: No device configuration space found for {}", address);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -167,9 +156,7 @@ u8 MMIOAccess::read8_field(Address address, u32 field)
|
|||
{
|
||||
InterruptDisabler disabler;
|
||||
ASSERT(field <= 0xfff);
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: MMIO Reading 8-bit field 0x" << String::formatted("{:08x}", field) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: MMIO Reading 8-bit field {:#08x} for {}", field, address);
|
||||
return *((u8*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
|
||||
}
|
||||
|
||||
|
@ -177,9 +164,7 @@ u16 MMIOAccess::read16_field(Address address, u32 field)
|
|||
{
|
||||
InterruptDisabler disabler;
|
||||
ASSERT(field < 0xfff);
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: MMIO Reading 16-bit field 0x" << String::formatted("{:08x}", field) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: MMIO Reading 16-bit field {:#08x} for {}", field, address);
|
||||
return *((u16*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
|
||||
}
|
||||
|
||||
|
@ -187,9 +172,7 @@ u32 MMIOAccess::read32_field(Address address, u32 field)
|
|||
{
|
||||
InterruptDisabler disabler;
|
||||
ASSERT(field <= 0xffc);
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: MMIO Reading 32-bit field 0x" << String::formatted("{:08x}", field) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("PCI: MMIO Reading 32-bit field {:#08x} for {}", field, address);
|
||||
return *((u32*)(get_device_configuration_space(address).value().get() + (field & 0xfff)));
|
||||
}
|
||||
|
||||
|
@ -197,36 +180,28 @@ void MMIOAccess::write8_field(Address address, u32 field, u8 value)
|
|||
{
|
||||
InterruptDisabler disabler;
|
||||
ASSERT(field <= 0xfff);
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: MMIO Writing to 8-bit field 0x" << String::formatted("{:08x}", field) << ", value=0x" << String::formatted("{:02x}", value) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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);
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: MMIO Writing to 16-bit field 0x" << String::formatted("{:08x}", field) << ", value=0x" << String::formatted("{:04x}", value) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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);
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: MMIO Writing to 32-bit field 0x" << String::formatted("{:08x}", field) << ", value=0x" << String::formatted("{:08x}", value) << " for " << address;
|
||||
#endif
|
||||
dbgln<debug_pci>("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++) {
|
||||
#ifdef PCI_DEBUG
|
||||
dbg() << "PCI: Enumerating Memory mapped IO segment " << seg;
|
||||
#endif
|
||||
dbgln<debug_pci>("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);
|
||||
|
|
|
@ -178,9 +178,7 @@ void IDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult resu
|
|||
// which could cause page faults. Note that this may be called immediately
|
||||
// before Processor::deferred_call_queue returns!
|
||||
Processor::deferred_call_queue([this, result]() {
|
||||
#ifdef PATA_DEBUG
|
||||
dbg() << "IDEChannel::complete_current_request result: " << result;
|
||||
#endif
|
||||
dbgln<debug_pata>("IDEChannel::complete_current_request result: {}", (int)result);
|
||||
ASSERT(m_current_request);
|
||||
auto& request = *m_current_request;
|
||||
m_current_request = nullptr;
|
||||
|
@ -368,9 +366,7 @@ void IDEChannel::ata_read_sectors_with_dma(bool slave_request)
|
|||
{
|
||||
auto& request = *m_current_request;
|
||||
u32 lba = request.block_index();
|
||||
#ifdef PATA_DEBUG
|
||||
dbg() << "IDEChannel::ata_read_sectors_with_dma (" << lba << " x" << request.block_count() << ")";
|
||||
#endif
|
||||
dbgln<debug_pata>("IDEChannel::ata_read_sectors_with_dma ({} x {})", lba, request.block_count());
|
||||
|
||||
prdt().offset = m_dma_buffer_page->paddr();
|
||||
prdt().size = 512 * request.block_count();
|
||||
|
@ -489,9 +485,7 @@ void IDEChannel::ata_write_sectors_with_dma(bool slave_request)
|
|||
{
|
||||
auto& request = *m_current_request;
|
||||
u32 lba = request.block_index();
|
||||
#ifdef PATA_DEBUG
|
||||
dbg() << "IDEChannel::ata_write_sectors_with_dma (" << lba << " x" << request.block_count() << ")";
|
||||
#endif
|
||||
dbgln<debug_pata>("IDEChannel::ata_write_sectors_with_dma ({} x {})", lba, request.block_count());
|
||||
|
||||
prdt().offset = m_dma_buffer_page->paddr();
|
||||
prdt().size = 512 * request.block_count();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <Kernel/FileSystem/FileDescription.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
||||
|
@ -32,9 +33,7 @@ namespace Kernel {
|
|||
int Process::sys$fcntl(int fd, int cmd, u32 arg)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
#ifdef DEBUG_IO
|
||||
dbg() << "sys$fcntl: fd=" << fd << ", cmd=" << cmd << ", arg=" << arg;
|
||||
#endif
|
||||
dbgln<debug_io>("sys$fcntl: fd={}, cmd={}, arg={}", fd, cmd, arg);
|
||||
auto description = file_description(fd);
|
||||
if (!description)
|
||||
return -EBADF;
|
||||
|
@ -68,4 +67,5 @@ int Process::sys$fcntl(int fd, int cmd, u32 arg)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue