summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorEvan Smal <evan.smal@hotmail.com>2022-12-28 17:55:04 -0500
committerJelle Raaijmakers <jelle@gmta.nl>2023-01-05 01:44:19 +0100
commit288a73ea0e21ab1f98dba68e6b71d37da87b5591 (patch)
tree5d0d6e511155b5e23face6f3440a1a8aaec75f19 /Kernel
parent6a5be5f1c555fa880822d988e52058b50a3eea84 (diff)
downloadserenity-288a73ea0e21ab1f98dba68e6b71d37da87b5591.zip
Kernel: Add dmesgln_pci logging for Kernel::PCI
A virtual method named device_name() was added to Kernel::PCI to support logging the PCI::Device name and address using dmesgln_pci. Previously, PCI::Device did not store the device name. All devices inheriting from PCI::Device now use dmesgln_pci where they previously used dmesgln.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Arch/x86_64/PCI/IDELegacyModeController.h2
-rw-r--r--Kernel/Bus/PCI/Device.h17
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.cpp6
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.h1
-rw-r--r--Kernel/Bus/VirtIO/Console.h1
-rw-r--r--Kernel/Bus/VirtIO/RNG.h1
-rw-r--r--Kernel/Devices/Audio/AC97.h1
-rw-r--r--Kernel/Graphics/Bochs/GraphicsAdapter.h1
-rw-r--r--Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp4
-rw-r--r--Kernel/Graphics/Intel/NativeGraphicsAdapter.h2
-rw-r--r--Kernel/Graphics/VMWare/GraphicsAdapter.h2
-rw-r--r--Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h2
-rw-r--r--Kernel/Net/Intel/E1000NetworkAdapter.cpp11
-rw-r--r--Kernel/Net/Intel/E1000NetworkAdapter.h1
-rw-r--r--Kernel/Net/NE2000/NetworkAdapter.cpp24
-rw-r--r--Kernel/Net/NE2000/NetworkAdapter.h1
-rw-r--r--Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp28
-rw-r--r--Kernel/Net/Realtek/RTL8139NetworkAdapter.h1
-rw-r--r--Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp22
-rw-r--r--Kernel/Net/Realtek/RTL8168NetworkAdapter.h1
-rw-r--r--Kernel/Storage/ATA/AHCI/Controller.cpp2
-rw-r--r--Kernel/Storage/ATA/AHCI/Controller.h2
-rw-r--r--Kernel/Storage/NVMe/NVMeController.cpp8
-rw-r--r--Kernel/Storage/NVMe/NVMeController.h1
24 files changed, 90 insertions, 52 deletions
diff --git a/Kernel/Arch/x86_64/PCI/IDELegacyModeController.h b/Kernel/Arch/x86_64/PCI/IDELegacyModeController.h
index 11aff3d33b..218a9c4e79 100644
--- a/Kernel/Arch/x86_64/PCI/IDELegacyModeController.h
+++ b/Kernel/Arch/x86_64/PCI/IDELegacyModeController.h
@@ -21,6 +21,8 @@ class PCIIDELegacyModeController final : public IDEController
public:
static ErrorOr<NonnullLockRefPtr<PCIIDELegacyModeController>> initialize(PCI::DeviceIdentifier const&, bool force_pio);
+ virtual StringView device_name() const override { return "PCIIDELegacyModeController"sv; }
+
bool is_bus_master_capable() const;
bool is_pci_native_mode_enabled() const;
diff --git a/Kernel/Bus/PCI/Device.h b/Kernel/Bus/PCI/Device.h
index f167e192e1..9c1d1fa92e 100644
--- a/Kernel/Bus/PCI/Device.h
+++ b/Kernel/Bus/PCI/Device.h
@@ -6,6 +6,8 @@
#pragma once
+#include <AK/Format.h>
+#include <AK/StringBuilder.h>
#include <AK/Types.h>
#include <Kernel/Bus/PCI/Definitions.h>
@@ -16,6 +18,9 @@ public:
Address pci_address() const { return m_pci_address; };
virtual ~Device() = default;
+
+ virtual StringView device_name() const = 0;
+
void enable_pin_based_interrupts() const;
void disable_pin_based_interrupts() const;
@@ -35,4 +40,16 @@ private:
Address m_pci_address;
};
+template<typename... Parameters>
+void dmesgln_pci(Device const& device, AK::CheckedFormatString<Parameters...>&& fmt, Parameters const&... parameters)
+{
+ AK::StringBuilder builder;
+ if (builder.try_append("{}: {}: "sv).is_error())
+ return;
+ if (builder.try_append(fmt.view()).is_error())
+ return;
+ AK::VariadicFormatParams variadic_format_params { device.device_name(), device.pci_address(), parameters... };
+ vdmesgln(builder.string_view(), variadic_format_params);
+}
+
}
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp
index d9867968de..78e62ca29d 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.cpp
+++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp
@@ -75,9 +75,9 @@ ErrorOr<NonnullLockRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI
ErrorOr<void> UHCIController::initialize()
{
- dmesgln("UHCI: Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
- dmesgln("UHCI: I/O base {}", m_registers_io_window);
- dmesgln("UHCI: Interrupt line: {}", interrupt_number());
+ dmesgln_pci(*this, "Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
+ dmesgln_pci(*this, "I/O base {}", m_registers_io_window);
+ dmesgln_pci(*this, "Interrupt line: {}", interrupt_number());
TRY(spawn_async_poll_process());
TRY(spawn_port_process());
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.h b/Kernel/Bus/USB/UHCI/UHCIController.h
index 1b45461cd5..4041da4be4 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.h
+++ b/Kernel/Bus/USB/UHCI/UHCIController.h
@@ -38,6 +38,7 @@ public:
virtual ~UHCIController() override;
virtual StringView purpose() const override { return "UHCI"sv; }
+ virtual StringView device_name() const override { return purpose(); }
virtual ErrorOr<void> initialize() override;
virtual ErrorOr<void> reset() override;
diff --git a/Kernel/Bus/VirtIO/Console.h b/Kernel/Bus/VirtIO/Console.h
index 9694fa0a3c..3b8e58d302 100644
--- a/Kernel/Bus/VirtIO/Console.h
+++ b/Kernel/Bus/VirtIO/Console.h
@@ -22,6 +22,7 @@ public:
virtual ~Console() override = default;
virtual StringView purpose() const override { return class_name(); }
+ virtual StringView device_name() const override { return class_name(); }
unsigned device_id() const
{
diff --git a/Kernel/Bus/VirtIO/RNG.h b/Kernel/Bus/VirtIO/RNG.h
index f7ddef9b83..5f7f8a1ee8 100644
--- a/Kernel/Bus/VirtIO/RNG.h
+++ b/Kernel/Bus/VirtIO/RNG.h
@@ -21,6 +21,7 @@ class RNG final
public:
static NonnullLockRefPtr<RNG> must_create(PCI::DeviceIdentifier const&);
virtual StringView purpose() const override { return class_name(); }
+ virtual StringView device_name() const override { return class_name(); }
virtual ~RNG() override = default;
virtual void initialize() override;
diff --git a/Kernel/Devices/Audio/AC97.h b/Kernel/Devices/Audio/AC97.h
index 092b9115ba..c120ef1b0f 100644
--- a/Kernel/Devices/Audio/AC97.h
+++ b/Kernel/Devices/Audio/AC97.h
@@ -32,6 +32,7 @@ public:
// ^IRQHandler
virtual StringView purpose() const override { return "AC97"sv; }
+ virtual StringView device_name() const override { return purpose(); }
private:
enum NativeAudioMixerRegister : u8 {
diff --git a/Kernel/Graphics/Bochs/GraphicsAdapter.h b/Kernel/Graphics/Bochs/GraphicsAdapter.h
index bb298a3a5f..5fca7601a1 100644
--- a/Kernel/Graphics/Bochs/GraphicsAdapter.h
+++ b/Kernel/Graphics/Bochs/GraphicsAdapter.h
@@ -26,6 +26,7 @@ class BochsGraphicsAdapter final : public GenericGraphicsAdapter
public:
static NonnullLockRefPtr<BochsGraphicsAdapter> initialize(PCI::DeviceIdentifier const&);
virtual ~BochsGraphicsAdapter() = default;
+ virtual StringView device_name() const override { return "BochsGraphicsAdapter"sv; }
private:
ErrorOr<void> initialize_adapter(PCI::DeviceIdentifier const&);
diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
index 3029e1c814..f410fceb75 100644
--- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
+++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.cpp
@@ -43,8 +43,8 @@ ErrorOr<void> IntelNativeGraphicsAdapter::initialize_adapter()
auto bar0_space_size = PCI::get_BAR_space_size(address, PCI::HeaderType0BaseRegister::BAR0);
VERIFY(bar0_space_size == 0x80000);
auto bar2_space_size = PCI::get_BAR_space_size(address, PCI::HeaderType0BaseRegister::BAR2);
- dmesgln("Intel Native Graphics Adapter @ {}, MMIO @ {}, space size is {:x} bytes", address, PhysicalAddress(PCI::get_BAR0(address)), bar0_space_size);
- dmesgln("Intel Native Graphics Adapter @ {}, framebuffer @ {}", address, PhysicalAddress(PCI::get_BAR2(address)));
+ dmesgln_pci(*this, "MMIO @ {}, space size is {:x} bytes", PhysicalAddress(PCI::get_BAR0(address)), bar0_space_size);
+ dmesgln_pci(*this, "framebuffer @ {}", PhysicalAddress(PCI::get_BAR2(address)));
PCI::enable_bus_mastering(address);
m_display_connector = IntelNativeDisplayConnector::must_create(PhysicalAddress(PCI::get_BAR2(address) & 0xfffffff0), bar2_space_size, PhysicalAddress(PCI::get_BAR0(address) & 0xfffffff0), bar0_space_size);
diff --git a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
index dc8a72c5e8..b7c58dea8a 100644
--- a/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
+++ b/Kernel/Graphics/Intel/NativeGraphicsAdapter.h
@@ -24,6 +24,8 @@ public:
virtual ~IntelNativeGraphicsAdapter() = default;
+ virtual StringView device_name() const override { return "IntelNativeGraphicsAdapter"sv; }
+
private:
ErrorOr<void> initialize_adapter();
diff --git a/Kernel/Graphics/VMWare/GraphicsAdapter.h b/Kernel/Graphics/VMWare/GraphicsAdapter.h
index 705b60865e..fd159fb9fa 100644
--- a/Kernel/Graphics/VMWare/GraphicsAdapter.h
+++ b/Kernel/Graphics/VMWare/GraphicsAdapter.h
@@ -29,6 +29,8 @@ public:
static LockRefPtr<VMWareGraphicsAdapter> try_initialize(PCI::DeviceIdentifier const&);
virtual ~VMWareGraphicsAdapter() = default;
+ virtual StringView device_name() const override { return "VMWareGraphicsAdapter"sv; }
+
ErrorOr<void> modeset_primary_screen_resolution(Badge<VMWareDisplayConnector>, size_t width, size_t height);
size_t primary_screen_width(Badge<VMWareDisplayConnector>) const;
size_t primary_screen_height(Badge<VMWareDisplayConnector>) const;
diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h
index 5b93a51820..bc6bf22b5e 100644
--- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h
+++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.h
@@ -41,6 +41,8 @@ public:
virtual void initialize() override;
+ virtual StringView device_name() const override { return "VirtIOGraphicsAdapter"sv; }
+
ErrorOr<void> mode_set_resolution(Badge<VirtIODisplayConnector>, VirtIODisplayConnector&, size_t width, size_t height);
void set_dirty_displayed_rect(Badge<VirtIODisplayConnector>, VirtIODisplayConnector&, Graphics::VirtIOGPU::Protocol::Rect const& dirty_rect, bool main_buffer);
ErrorOr<void> flush_displayed_image(Badge<VirtIODisplayConnector>, VirtIODisplayConnector&, Graphics::VirtIOGPU::Protocol::Rect const& dirty_rect, bool main_buffer);
diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.cpp b/Kernel/Net/Intel/E1000NetworkAdapter.cpp
index baaf77ffbc..7b5f4a11da 100644
--- a/Kernel/Net/Intel/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/Intel/E1000NetworkAdapter.cpp
@@ -192,16 +192,17 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::setup_interrupts()
UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize()
{
- dmesgln("E1000: Found @ {}", pci_address());
+ dmesgln_pci(*this, "Found @ {}", pci_address());
+
enable_bus_mastering(pci_address());
- dmesgln("E1000: IO base: {}", m_registers_io_window);
- dmesgln("E1000: Interrupt line: {}", interrupt_number());
+ dmesgln_pci(*this, "IO base: {}", m_registers_io_window);
+ dmesgln_pci(*this, "Interrupt line: {}", interrupt_number());
detect_eeprom();
- dmesgln("E1000: Has EEPROM? {}", m_has_eeprom);
+ dmesgln_pci(*this, "Has EEPROM? {}", m_has_eeprom);
read_mac_address();
auto const& mac = mac_address();
- dmesgln("E1000: MAC address: {}", mac.to_string());
+ dmesgln_pci(*this, "MAC address: {}", mac.to_string());
initialize_rx_descriptors();
initialize_tx_descriptors();
diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.h b/Kernel/Net/Intel/E1000NetworkAdapter.h
index d14920dda5..4869c40c84 100644
--- a/Kernel/Net/Intel/E1000NetworkAdapter.h
+++ b/Kernel/Net/Intel/E1000NetworkAdapter.h
@@ -32,6 +32,7 @@ public:
virtual bool link_full_duplex() override;
virtual StringView purpose() const override { return class_name(); }
+ virtual StringView device_name() const override { return "E1000"sv; }
protected:
void setup_interrupts();
diff --git a/Kernel/Net/NE2000/NetworkAdapter.cpp b/Kernel/Net/NE2000/NetworkAdapter.cpp
index 65fba19d1f..3df63f0be9 100644
--- a/Kernel/Net/NE2000/NetworkAdapter.cpp
+++ b/Kernel/Net/NE2000/NetworkAdapter.cpp
@@ -169,17 +169,17 @@ UNMAP_AFTER_INIT NE2000NetworkAdapter::NE2000NetworkAdapter(PCI::Address address
, IRQHandler(irq)
, m_registers_io_window(move(registers_io_window))
{
- dmesgln("NE2000: Found @ {}", pci_address());
+ dmesgln_pci(*this, "Found @ {}", pci_address());
- dmesgln("NE2000: Port base: {}", m_registers_io_window);
- dmesgln("NE2000: Interrupt line: {}", interrupt_number());
+ dmesgln_pci(*this, "Port base: {}", m_registers_io_window);
+ dmesgln_pci(*this, "Interrupt line: {}", interrupt_number());
int ram_errors = ram_test();
- dmesgln("NE2000: RAM test {}, got {} byte errors", (ram_errors == 0 ? "OK" : "KO"), ram_errors);
+ dmesgln_pci(*this, "RAM test {}, got {} byte errors", (ram_errors == 0 ? "OK" : "KO"), ram_errors);
reset();
set_mac_address(m_mac_address);
- dmesgln("NE2000: MAC address: {}", m_mac_address.to_string());
+ dmesgln_pci(*this, "MAC address: {}", m_mac_address.to_string());
enable_irq();
}
@@ -206,22 +206,22 @@ bool NE2000NetworkAdapter::handle_irq(RegisterState const&)
u8 fae = in8(REG_RD_FAE_TALLY);
u8 crc = in8(REG_RD_CRC_TALLY);
u8 miss = in8(REG_RD_MISS_PKT_TALLY);
- dmesgln("NE2000NetworkAdapter: Packet reception error framing={} crc={} missed={}", fae, crc, miss);
+ dmesgln_pci(*this, "Packet reception error framing={} crc={} missed={}", fae, crc, miss);
// TODO: handle counters
}
if (status & BIT_INTERRUPTMASK_TXE) {
- dmesgln("NE2000NetworkAdapter: Packet transmission error");
+ dmesgln_pci(*this, "Packet transmission error");
}
if (status & BIT_INTERRUPTMASK_OVW) {
- dmesgln("NE2000NetworkAdapter: Ring buffer reception overflow error");
+ dmesgln_pci(*this, "Ring buffer reception overflow error");
// TODO: handle counters
}
if (status & BIT_INTERRUPTMASK_CNT) {
- dmesgln("NE2000NetworkAdapter: Counter overflow error");
+ dmesgln_pci(*this, "Counter overflow error");
// TODO: handle counters
}
if (status & BIT_INTERRUPTMASK_RST) {
- dmesgln("NE2000NetworkAdapter: NIC requires reset due to packet reception overflow");
+ dmesgln_pci(*this, "NIC requires reset due to packet reception overflow");
// TODO: proper reset procedure
reset();
}
@@ -371,12 +371,12 @@ void NE2000NetworkAdapter::send_raw(ReadonlyBytes payload)
dbgln_if(NE2000_DEBUG, "NE2000NetworkAdapter: Sending packet length={}", payload.size());
if (payload.size() > NE2K_RAM_SEND_SIZE) {
- dmesgln("NE2000NetworkAdapter: Packet to send was too big; discarding");
+ dmesgln_pci(*this, "Packet to send was too big; discarding");
return;
}
while (in8(REG_RW_COMMAND) & BIT_COMMAND_TXP)
- m_wait_queue.wait_forever("NE2000NetworkAdapter"sv);
+ m_wait_queue.wait_forever(device_name());
disable_irq();
size_t packet_size = payload.size();
diff --git a/Kernel/Net/NE2000/NetworkAdapter.h b/Kernel/Net/NE2000/NetworkAdapter.h
index ee37fdd6a2..33328fa0a2 100644
--- a/Kernel/Net/NE2000/NetworkAdapter.h
+++ b/Kernel/Net/NE2000/NetworkAdapter.h
@@ -39,6 +39,7 @@ public:
virtual bool link_full_duplex() override { return true; }
virtual StringView purpose() const override { return class_name(); }
+ virtual StringView device_name() const override { return class_name(); }
private:
NE2000NetworkAdapter(PCI::Address, u8, NonnullOwnPtr<IOWindow> registers_io_window, NonnullOwnPtr<KString>);
diff --git a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp
index 3d2fecdb89..b856814511 100644
--- a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp
+++ b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp
@@ -133,12 +133,12 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre
{
m_tx_buffers.ensure_capacity(RTL8139_TX_BUFFER_COUNT);
- dmesgln("RTL8139: Found @ {}", pci_address());
+ dmesgln_pci(*this, "Found @ {}", pci_address());
enable_bus_mastering(pci_address());
- dmesgln("RTL8139: I/O port base: {}", m_registers_io_window);
- dmesgln("RTL8139: Interrupt line: {}", interrupt_number());
+ dmesgln_pci(*this, "I/O port base: {}", m_registers_io_window);
+ dmesgln_pci(*this, "Interrupt line: {}", interrupt_number());
// we add space to account for overhang from the last packet - the rtl8139
// can optionally guarantee that packets will be contiguous by
@@ -154,7 +154,7 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre
read_mac_address();
auto const& mac = mac_address();
- dmesgln("RTL8139: MAC address: {}", mac.to_string());
+ dmesgln_pci(*this, "MAC address: {}", mac.to_string());
enable_irq();
}
@@ -181,31 +181,31 @@ bool RTL8139NetworkAdapter::handle_irq(RegisterState const&)
receive();
}
if (status & INT_RXERR) {
- dmesgln("RTL8139: RX error - resetting device");
+ dmesgln_pci(*this, "RX error - resetting device");
reset();
}
if (status & INT_TXOK) {
dbgln_if(RTL8139_DEBUG, "RTL8139: TX complete");
}
if (status & INT_TXERR) {
- dmesgln("RTL8139: TX error - resetting device");
+ dmesgln_pci(*this, "TX error - resetting device");
reset();
}
if (status & INT_RX_BUFFER_OVERFLOW) {
- dmesgln("RTL8139: RX buffer overflow");
+ dmesgln_pci(*this, "RX buffer overflow");
}
if (status & INT_LINK_CHANGE) {
m_link_up = (in8(REG_MSR) & MSR_LINKB) == 0;
- dmesgln("RTL8139: Link status changed up={}", m_link_up);
+ dmesgln_pci(*this, "Link status changed up={}", m_link_up);
}
if (status & INT_RX_FIFO_OVERFLOW) {
- dmesgln("RTL8139: RX FIFO overflow");
+ dmesgln_pci(*this, "RX FIFO overflow");
}
if (status & INT_LENGTH_CHANGE) {
- dmesgln("RTL8139: Cable length change");
+ dmesgln_pci(*this, "Cable length change");
}
if (status & INT_SYSTEM_ERROR) {
- dmesgln("RTL8139: System error - resetting device");
+ dmesgln_pci(*this, "System error - resetting device");
reset();
}
}
@@ -278,7 +278,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
dbgln_if(RTL8139_DEBUG, "RTL8139: send_raw length={}", payload.size());
if (payload.size() > PACKET_SIZE_MAX) {
- dmesgln("RTL8139: Packet was too big; discarding");
+ dmesgln_pci(*this, "Packet was too big; discarding");
return;
}
@@ -294,7 +294,7 @@ void RTL8139NetworkAdapter::send_raw(ReadonlyBytes payload)
}
if (hw_buffer == -1) {
- dmesgln("RTL8139: Hardware buffers full; discarding packet");
+ dmesgln_pci(*this, "Hardware buffers full; discarding packet");
return;
}
@@ -327,7 +327,7 @@ void RTL8139NetworkAdapter::receive()
dbgln_if(RTL8139_DEBUG, "RTL8139: receive, status={:#04x}, length={}, offset={}", status, length, m_rx_buffer_offset);
if (!(status & RX_OK) || (status & (RX_INVALID_SYMBOL_ERROR | RX_CRC_ERROR | RX_FRAME_ALIGNMENT_ERROR)) || (length >= PACKET_SIZE_MAX) || (length < PACKET_SIZE_MIN)) {
- dmesgln("RTL8139: receive got bad packet, status={:#04x}, length={}", status, length);
+ dmesgln_pci(*this, "receive got bad packet, status={:#04x}, length={}", status, length);
reset();
return;
}
diff --git a/Kernel/Net/Realtek/RTL8139NetworkAdapter.h b/Kernel/Net/Realtek/RTL8139NetworkAdapter.h
index 6d95c85785..b1062b8f4b 100644
--- a/Kernel/Net/Realtek/RTL8139NetworkAdapter.h
+++ b/Kernel/Net/Realtek/RTL8139NetworkAdapter.h
@@ -32,6 +32,7 @@ public:
virtual bool link_full_duplex() override;
virtual StringView purpose() const override { return class_name(); }
+ virtual StringView device_name() const override { return "RTL8139"sv; }
private:
RTL8139NetworkAdapter(PCI::Address, u8 irq, NonnullOwnPtr<IOWindow> registers_io_window, NonnullOwnPtr<KString>);
diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp
index d61d0f629d..5d5f7d8a25 100644
--- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp
+++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp
@@ -247,14 +247,14 @@ UNMAP_AFTER_INIT RTL8168NetworkAdapter::RTL8168NetworkAdapter(PCI::Address addre
, m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX"sv, Memory::Region::Access::ReadWrite).release_value())
, m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX"sv, Memory::Region::Access::ReadWrite).release_value())
{
- dmesgln("RTL8168: Found @ {}", pci_address());
- dmesgln("RTL8168: I/O port base: {}", m_registers_io_window);
+ dmesgln_pci(*this, "Found @ {}", pci_address());
+ dmesgln_pci(*this, "I/O port base: {}", m_registers_io_window);
identify_chip_version();
- dmesgln("RTL8168: Version detected - {} ({}{})", possible_device_name(), (u8)m_version, m_version_uncertain ? "?" : "");
+ dmesgln_pci(*this, "Version detected - {} ({}{})", possible_device_name(), (u8)m_version, m_version_uncertain ? "?" : "");
if (!determine_supported_version()) {
- dmesgln("RTL8168: Aborting initialization! Support for your chip version ({}) is not implemented yet, please open a GH issue and include this message.", (u8)m_version);
+ dmesgln_pci(*this, "Aborting initialization! Support for your chip version ({}) is not implemented yet, please open a GH issue and include this message.", (u8)m_version);
return; // Each ChipVersion requires a specific implementation of configure_phy and hardware_quirks
}
@@ -332,7 +332,7 @@ void RTL8168NetworkAdapter::initialize()
enable_bus_mastering(pci_address());
read_mac_address();
- dmesgln("RTL8168: MAC address: {}", mac_address().to_string());
+ dmesgln_pci(*this, "MAC address: {}", mac_address().to_string());
// notify about driver start
if (m_version >= ChipVersion::Version11 && m_version <= ChipVersion::Version13) {
@@ -1155,19 +1155,19 @@ bool RTL8168NetworkAdapter::handle_irq(RegisterState const&)
dbgln_if(RTL8168_DEBUG, "RTL8168: TX error - invalid packet");
}
if (status & INT_RX_OVERFLOW) {
- dmesgln("RTL8168: RX descriptor unavailable (packet lost)");
+ dmesgln_pci(*this, "RX descriptor unavailable (packet lost)");
receive();
}
if (status & INT_LINK_CHANGE) {
m_link_up = (in8(REG_PHYSTATUS) & PHY_LINK_STATUS) != 0;
- dmesgln("RTL8168: Link status changed up={}", m_link_up);
+ dmesgln_pci(*this, "Link status changed up={}", m_link_up);
}
if (status & INT_RX_FIFO_OVERFLOW) {
- dmesgln("RTL8168: RX FIFO overflow");
+ dmesgln_pci(*this, "RX FIFO overflow");
receive();
}
if (status & INT_SYS_ERR) {
- dmesgln("RTL8168: Fatal system error");
+ dmesgln_pci(*this, "Fatal system error");
}
}
return was_handled;
@@ -1193,7 +1193,7 @@ void RTL8168NetworkAdapter::send_raw(ReadonlyBytes payload)
dbgln_if(RTL8168_DEBUG, "RTL8168: send_raw length={}", payload.size());
if (payload.size() > TX_BUFFER_SIZE) {
- dmesgln("RTL8168: Packet was too big; discarding");
+ dmesgln_pci(*this, "Packet was too big; discarding");
return;
}
@@ -1237,7 +1237,7 @@ void RTL8168NetworkAdapter::receive()
dbgln_if(RTL8168_DEBUG, "RTL8168: receive, flags={:#04x}, length={}, descriptor={}", flags, length, descriptor_index);
if (length > RX_BUFFER_SIZE || (flags & RXDescriptor::ErrorSummary) != 0) {
- dmesgln("RTL8168: receive got bad packet, flags={:#04x}, length={}", flags, length);
+ dmesgln_pci(*this, "receive got bad packet, flags={:#04x}, length={}", flags, length);
} else if ((flags & RXDescriptor::FirstSegment) != 0 && (flags & RXDescriptor::LastSegment) == 0) {
VERIFY_NOT_REACHED();
// Our maximum received packet size is smaller than the descriptor buffer size, so packets should never be segmented
diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h
index b075c25aee..3a552306f9 100644
--- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h
+++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h
@@ -32,6 +32,7 @@ public:
virtual i32 link_speed() override;
virtual StringView purpose() const override { return class_name(); }
+ virtual StringView device_name() const override { return class_name(); }
private:
// FIXME: should this be increased? (maximum allowed here is 1024) - memory usage vs packet loss chance tradeoff
diff --git a/Kernel/Storage/ATA/AHCI/Controller.cpp b/Kernel/Storage/ATA/AHCI/Controller.cpp
index d05f1c8e91..d9866ff663 100644
--- a/Kernel/Storage/ATA/AHCI/Controller.cpp
+++ b/Kernel/Storage/ATA/AHCI/Controller.cpp
@@ -27,7 +27,7 @@ UNMAP_AFTER_INIT NonnullLockRefPtr<AHCIController> AHCIController::initialize(PC
bool AHCIController::reset()
{
- dmesgln("{}: AHCI controller reset", pci_address());
+ dmesgln_pci(*this, "{}: AHCI controller reset", pci_address());
{
SpinlockLocker locker(m_hba_control_lock);
hba().control_regs.ghc = 1;
diff --git a/Kernel/Storage/ATA/AHCI/Controller.h b/Kernel/Storage/ATA/AHCI/Controller.h
index b4916b197d..eb80a54401 100644
--- a/Kernel/Storage/ATA/AHCI/Controller.h
+++ b/Kernel/Storage/ATA/AHCI/Controller.h
@@ -27,6 +27,8 @@ public:
static NonnullLockRefPtr<AHCIController> initialize(PCI::DeviceIdentifier const& pci_device_identifier);
virtual ~AHCIController() override;
+ virtual StringView device_name() const override { return "AHCI"sv; }
+
virtual LockRefPtr<StorageDevice> device(u32 index) const override;
virtual bool reset() override;
virtual bool shutdown() override;
diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp
index e03ae9e809..e1151f5725 100644
--- a/Kernel/Storage/NVMe/NVMeController.cpp
+++ b/Kernel/Storage/NVMe/NVMeController.cpp
@@ -169,7 +169,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::identify_and_init_namespaces()
sub.identify.cns = NVMe_CNS_ID_ACTIVE_NS & 0xff;
status = submit_admin_command(sub, true);
if (status) {
- dmesgln("Failed to identify active namespace command");
+ dmesgln_pci(*this, "Failed to identify active namespace command");
return EFAULT;
}
if (void* fault_at; !safe_memcpy(active_namespace_list, prp_dma_region->vaddr().as_ptr(), NVMe_IDENTIFY_SIZE, fault_at)) {
@@ -192,7 +192,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::identify_and_init_namespaces()
sub.identify.nsid = nsid;
status = submit_admin_command(sub, true);
if (status) {
- dmesgln("Failed identify namespace with nsid {}", nsid);
+ dmesgln_pci(*this, "Failed identify namespace with nsid {}", nsid);
return EFAULT;
}
static_assert(sizeof(IdentifyNamespace) == NVMe_IDENTIFY_SIZE);
@@ -263,7 +263,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
auto cq_size = round_up_to_power_of_two(CQ_SIZE(qdepth), 4096);
auto sq_size = round_up_to_power_of_two(SQ_SIZE(qdepth), 4096);
if (!reset_controller()) {
- dmesgln("Failed to reset the NVMe controller");
+ dmesgln_pci(*this, "Failed to reset the NVMe controller");
return EFAULT;
}
{
@@ -285,7 +285,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_admin_queue(Optional<u8> i
m_controller_regs->asq = reinterpret_cast<u64>(AK::convert_between_host_and_little_endian(sq_dma_pages.first().paddr().as_ptr()));
if (!start_controller()) {
- dmesgln("Failed to restart the NVMe controller");
+ dmesgln_pci(*this, "Failed to restart the NVMe controller");
return EFAULT;
}
set_admin_queue_ready_flag();
diff --git a/Kernel/Storage/NVMe/NVMeController.h b/Kernel/Storage/NVMe/NVMeController.h
index d260c72572..39087dc527 100644
--- a/Kernel/Storage/NVMe/NVMeController.h
+++ b/Kernel/Storage/NVMe/NVMeController.h
@@ -30,6 +30,7 @@ public:
ErrorOr<void> initialize(bool is_queue_polled);
LockRefPtr<StorageDevice> device(u32 index) const override;
size_t devices_count() const override;
+ virtual StringView device_name() const override { return "NVMeController"sv; }
protected:
bool reset() override;