diff --git a/AK/Debug.h b/AK/Debug.h index c49b3c69a8..06deb53dd9 100644 --- a/AK/Debug.h +++ b/AK/Debug.h @@ -111,3 +111,21 @@ constexpr bool debug_smp = true; #else constexpr bool debug_smp = false; #endif + +#ifdef BXVGA_DEBUG +constexpr bool debug_bxvga = true; +#else +constexpr bool debug_bxvga = false; +#endif + +#ifdef PS2MOUSE_DEBUG +constexpr bool debug_ps2mouse = true; +#else +constexpr bool debug_ps2mouse = false; +#endif + +#ifdef VMWAREBACKDOOR_DEBUG +constexpr bool debug_vmware_backdoor = true; +#else +constexpr bool debug_vmware_backdoor = false; +#endif diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp index 034922f373..3c5d71a9f3 100644 --- a/Kernel/Devices/BXVGADevice.cpp +++ b/Kernel/Devices/BXVGADevice.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include @@ -105,9 +106,7 @@ void BXVGADevice::revert_resolution() void BXVGADevice::set_resolution_registers(size_t width, size_t height) { -#ifdef BXVGA_DEBUG - dbg() << "BXVGADevice resolution registers set to - " << width << "x" << height; -#endif + dbgln("BXVGADevice resolution registers set to - {}x{}", width, height); set_register(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED); set_register(VBE_DISPI_INDEX_XRES, (u16)width); set_register(VBE_DISPI_INDEX_YRES, (u16)height); @@ -120,9 +119,7 @@ void BXVGADevice::set_resolution_registers(size_t width, size_t height) bool BXVGADevice::test_resolution(size_t width, size_t height) { -#ifdef BXVGA_DEBUG - dbg() << "BXVGADevice resolution test - " << width << "x" << height; -#endif + dbgln("BXVGADevice resolution test - {}x{}", width, height); set_resolution_registers(width, height); bool resolution_changed = validate_setup_resolution(width, height); revert_resolution(); @@ -237,9 +234,7 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg) if (resolution.width > MAX_RESOLUTION_WIDTH || resolution.height > MAX_RESOLUTION_HEIGHT) return -EINVAL; if (!set_resolution(resolution.width, resolution.height)) { -#ifdef BXVGA_DEBUG - dbg() << "Reverting Resolution: [" << m_framebuffer_width << "x" << m_framebuffer_height << "]"; -#endif + dbgln("Reverting resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height); resolution.pitch = m_framebuffer_pitch; resolution.width = m_framebuffer_width; resolution.height = m_framebuffer_height; @@ -247,9 +242,7 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, FlatPtr arg) return -EFAULT; return -EINVAL; } -#ifdef BXVGA_DEBUG - dbg() << "New resolution: [" << m_framebuffer_width << "x" << m_framebuffer_height << "]"; -#endif + dbgln("New resolution: [{}x{}]", m_framebuffer_width, m_framebuffer_height); resolution.pitch = m_framebuffer_pitch; resolution.width = m_framebuffer_width; resolution.height = m_framebuffer_height; diff --git a/Kernel/Devices/PS2MouseDevice.cpp b/Kernel/Devices/PS2MouseDevice.cpp index 89d42c39b4..e55a765940 100644 --- a/Kernel/Devices/PS2MouseDevice.cpp +++ b/Kernel/Devices/PS2MouseDevice.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -100,9 +101,12 @@ void PS2MouseDevice::irq_handle_byte_read(u8 byte) auto commit_packet = [&] { m_data_state = 0; -#ifdef PS2MOUSE_DEBUG - dbg() << "PS2Mouse: " << m_data.bytes[1] << ", " << m_data.bytes[2] << " " << ((m_data.bytes[0] & 1) ? "Left" : "") << " " << ((m_data.bytes[0] & 2) ? "Right" : ""); -#endif + dbgln("PS2Mouse: {}, {} {} {}", + m_data.bytes[1], + m_data.bytes[2], + (m_data.bytes[0] & 1) ? "Left" : "", + (m_data.bytes[0] & 2) ? "Right" : ""); + m_entropy_source.add_random_event(m_data.dword); { @@ -281,11 +285,12 @@ KResultOr PS2MouseDevice::read(FileDescription&, size_t, UserOrKernelBuf auto packet = m_queue.dequeue(); lock.unlock(); -#ifdef PS2MOUSE_DEBUG - dbgln("PS2 Mouse Read: Buttons {:x}", packet.buttons); - dbgln("PS2 Mouse: X {}, Y {}, Z {}, Relative {}", packet.x, packet.y, packet.z, packet.buttons); - dbgln("PS2 Mouse Read: Filter packets"); -#endif + if constexpr (debug_ps2mouse) { + dbgln("PS2 Mouse Read: Buttons {:x}", packet.buttons); + dbgln("PS2 Mouse: X {}, Y {}, Z {}, Relative {}", packet.x, packet.y, packet.z, packet.buttons); + dbgln("PS2 Mouse Read: Filter packets"); + } + size_t bytes_read_from_packet = min(remaining_space_in_buffer, sizeof(MousePacket)); if (!buffer.write(&packet, nread, bytes_read_from_packet)) return EFAULT; diff --git a/Kernel/Devices/VMWareBackdoor.cpp b/Kernel/Devices/VMWareBackdoor.cpp index 45d7f6dd88..a8c698b26e 100644 --- a/Kernel/Devices/VMWareBackdoor.cpp +++ b/Kernel/Devices/VMWareBackdoor.cpp @@ -25,6 +25,7 @@ */ #include +#include #include #include #include @@ -177,25 +178,34 @@ void VMWareBackdoor::disable_absolute_vmmouse() void VMWareBackdoor::send_high_bandwidth(VMWareCommand& command) { vmware_high_bandwidth_send(command); -#ifdef VMWAREBACKDOOR_DEBUG - dbg() << "VMWareBackdoor Command High bandwidth Send Results: EAX " << String::format("%x", command.ax) << " EBX " << String::format("%x", command.bx) << " ECX " << String::format("%x", command.cx) << " EDX " << String::format("%x", command.dx); -#endif + + dbgln("VMWareBackdoor Command High bandwidth Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}", + command.ax, + command.bx, + command.cx, + command.dx); } void VMWareBackdoor::get_high_bandwidth(VMWareCommand& command) { vmware_high_bandwidth_get(command); -#ifdef VMWAREBACKDOOR_DEBUG - dbg() << "VMWareBackdoor Command High bandwidth Get Results: EAX " << String::format("%x", command.ax) << " EBX " << String::format("%x", command.bx) << " ECX " << String::format("%x", command.cx) << " EDX " << String::format("%x", command.dx); -#endif + + dbgln("VMWareBackdoor Command High bandwidth Get Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}", + command.ax, + command.bx, + command.cx, + command.dx); } void VMWareBackdoor::send(VMWareCommand& command) { vmware_out(command); -#ifdef VMWAREBACKDOOR_DEBUG - dbg() << "VMWareBackdoor Command Send Results: EAX " << String::format("%x", command.ax) << " EBX " << String::format("%x", command.bx) << " ECX " << String::format("%x", command.cx) << " EDX " << String::format("%x", command.dx); -#endif + + dbgln("VMWareBackdoor Command Send Results: EAX {:#x} EBX {:#x} ECX {:#x} EDX {:#x}", + command.ax, + command.bx, + command.cx, + command.dx); } Optional VMWareBackdoor::receive_mouse_packet() @@ -225,10 +235,11 @@ Optional VMWareBackdoor::receive_mouse_packet() int y = (command.cx); int z = (command.dx); -#ifdef PS2MOUSE_DEBUG - dbg() << "Absolute Mouse: Buttons " << String::format("%x", buttons); - dbg() << "Mouse: X " << x << ", Y " << y << ", Z " << z; -#endif + if constexpr (debug_ps2mouse) { + dbgln("Absolute Mouse: Buttons {:x}", buttons); + dbgln("Mouse: x={}, y={}, z={}", x, y, z); + } + MousePacket packet; packet.x = x; packet.y = y;