mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Convert dbgprintf()/klog() => dbgln()/dmesgln() in UHCI code
This commit is contained in:
parent
e4d84b5e79
commit
40e5210036
Notes:
sideshowbarker
2024-07-18 22:11:22 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/40e5210036a
3 changed files with 27 additions and 21 deletions
|
@ -106,9 +106,9 @@ UHCIController::UHCIController(PCI::Address address, PCI::ID id)
|
|||
: PCI::Device(address)
|
||||
, m_io_base(PCI::get_BAR4(pci_address()) & ~1)
|
||||
{
|
||||
klog() << "UHCI: Controller found " << id << " @ " << address;
|
||||
klog() << "UHCI: I/O base " << m_io_base;
|
||||
klog() << "UHCI: Interrupt line: " << PCI::get_interrupt_line(pci_address());
|
||||
dmesgln("UHCI: Controller found {} @ {}", id, address);
|
||||
dmesgln("UHCI: I/O base {}", m_io_base);
|
||||
dmesgln("UHCI: Interrupt line: {}", PCI::get_interrupt_line(pci_address()));
|
||||
|
||||
reset();
|
||||
start();
|
||||
|
@ -200,8 +200,6 @@ void UHCIController::create_structures()
|
|||
#endif
|
||||
}
|
||||
|
||||
kprintf("Done!\n");
|
||||
|
||||
m_free_td_pool.resize(MAXIMUM_NUMBER_OF_TDS);
|
||||
for (size_t i = 0; i < m_free_td_pool.size(); i++) {
|
||||
auto placement_addr = reinterpret_cast<void*>(m_td_pool->vaddr().offset(PAGE_SIZE).get() + (i * sizeof(Kernel::USB::TransferDescriptor)));
|
||||
|
@ -364,7 +362,7 @@ void UHCIController::do_debug_transfer()
|
|||
auto data_td = allocate_transfer_descriptor();
|
||||
auto response_td = allocate_transfer_descriptor();
|
||||
|
||||
kprintf("BUFFER PHYSICAL ADDRESS = 0x%08x\n", m_td_buffer_region->physical_page(0)->paddr().get());
|
||||
dbgln("BUFFER PHYSICAL ADDRESS = {}", m_td_buffer_region->physical_page(0)->paddr());
|
||||
|
||||
setup_packet* packet = reinterpret_cast<setup_packet*>(m_td_buffer_region->vaddr().as_ptr());
|
||||
packet->bmRequestType = 0x81;
|
||||
|
@ -400,7 +398,7 @@ void UHCIController::do_debug_transfer()
|
|||
void UHCIController::spawn_port_proc()
|
||||
{
|
||||
RefPtr<Thread> usb_hotplug_thread;
|
||||
timespec sleep_time;
|
||||
timespec sleep_time {};
|
||||
|
||||
sleep_time.tv_sec = 1;
|
||||
Process::create_kernel_process(usb_hotplug_thread, "UHCIHotplug", [&, sleep_time] {
|
||||
|
@ -414,7 +412,7 @@ void UHCIController::spawn_port_proc()
|
|||
port_data = read_portsc1();
|
||||
if (port_data & UHCI_PORTSC_CONNECT_STATUS_CHANGED) {
|
||||
if (port_data & UHCI_PORTSC_CURRRENT_CONNECT_STATUS) {
|
||||
klog() << "UHCI: Device attach detected on Root Port 1!";
|
||||
dmesgln("UHCI: Device attach detected on Root Port 1!");
|
||||
|
||||
// Reset the port
|
||||
port_data = read_portsc1();
|
||||
|
@ -428,21 +426,21 @@ void UHCIController::spawn_port_proc()
|
|||
|
||||
write_portsc1(port_data & (~UHCI_PORTSC_PORT_ENABLE_CHANGED | ~UHCI_PORTSC_CONNECT_STATUS_CHANGED));
|
||||
} else {
|
||||
klog() << "UHCI: Device detach detected on Root Port 1!";
|
||||
dmesgln("UHCI: Device detach detected on Root Port 1!");
|
||||
}
|
||||
|
||||
port_data = read_portsc1();
|
||||
write_portsc1(port_data | UHCI_PORTSC_PORT_ENABLED);
|
||||
kprintf("port should be enabled now: 0x%x\n", read_portsc1());
|
||||
dbgln("port should be enabled now: {:#04x}\n", read_portsc1());
|
||||
do_debug_transfer();
|
||||
}
|
||||
} else {
|
||||
port_data = UHCIController::the().read_portsc2();
|
||||
if (port_data & UHCI_PORTSC_CONNECT_STATUS_CHANGED) {
|
||||
if (port_data & UHCI_PORTSC_CURRRENT_CONNECT_STATUS) {
|
||||
klog() << "UHCI: Device attach detected on Root Port 2!";
|
||||
dmesgln("UHCI: Device attach detected on Root Port 2!");
|
||||
} else {
|
||||
klog() << "UHCI: Device detach detected on Root Port 2!";
|
||||
dmesgln("UHCI: Device detach detected on Root Port 2!");
|
||||
}
|
||||
|
||||
UHCIController::the().write_portsc2(
|
||||
|
@ -461,10 +459,10 @@ void UHCIController::handle_irq(const RegisterState&)
|
|||
if (!read_usbsts())
|
||||
return;
|
||||
|
||||
#if UHCI_DEBUG
|
||||
klog() << "UHCI: Interrupt happened!";
|
||||
klog() << "Value of USBSTS: " << read_usbsts();
|
||||
#endif
|
||||
if constexpr (UHCI_DEBUG) {
|
||||
dbgln("UHCI: Interrupt happened!");
|
||||
dbgln("Value of USBSTS: {:#04x}", read_usbsts());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,12 +124,10 @@ struct alignas(16) TransferDescriptor final {
|
|||
|
||||
void print()
|
||||
{
|
||||
// FIXME: Use dbgln() or klog() when we have something working.
|
||||
// We're using kprintf() for now because the output stands out from the rest of the text in the log
|
||||
kprintf("UHCI: TD(%p) @ 0x%08x: link_ptr=0x%08x, status=0x%08x, token=0x%08x, buffer_ptr=0x%08x\n", this, m_paddr, m_link_ptr, m_control_status, m_token, m_buffer_ptr);
|
||||
dbgln("UHCI: TD({}) @ {}: link_ptr={}, status={}, token={}, buffer_ptr={}", this, m_paddr, m_link_ptr, (u32)m_control_status, m_token, m_buffer_ptr);
|
||||
|
||||
// Now let's print the flags!
|
||||
kprintf("UHCI: TD(%p) @ 0x%08x: link_ptr=%s%s%s, status=%s%s%s%s%s%s%s\n",
|
||||
dbgln("UHCI: TD({}) @ {}: link_ptr={}{}{}, status={}{}{}{}{}{}{}",
|
||||
this,
|
||||
m_paddr,
|
||||
(last_in_chain()) ? "T " : "",
|
||||
|
@ -266,7 +264,7 @@ struct alignas(16) QueueHead {
|
|||
|
||||
void print()
|
||||
{
|
||||
kprintf("UHCI: QH(%p) @ 0x%08x: link_ptr=0x%08x, element_link_ptr=0x%08x\n", this, m_paddr, m_link_ptr, m_element_link_ptr);
|
||||
dbgln("UHCI: QH({}) @ {}: link_ptr={}, element_link_ptr={}", this, m_paddr, m_link_ptr, (FlatPtr)m_element_link_ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -255,3 +255,13 @@ struct AK::Formatter<Kernel::PCI::Address> : Formatter<FormatString> {
|
|||
"PCI [{:04x}:{:02x}:{:02x}:{:02x}]", value.seg(), value.bus(), value.device(), value.function());
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Kernel::PCI::ID> : Formatter<FormatString> {
|
||||
void format(FormatBuilder& builder, Kernel::PCI::ID value)
|
||||
{
|
||||
return Formatter<FormatString>::format(
|
||||
builder,
|
||||
"PCI::ID [{:04x}:{:04x}]", value.vendor_id, value.device_id);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue