diff options
-rw-r--r-- | Kernel/Bus/PCI/IDs.h | 2 | ||||
-rw-r--r-- | Kernel/Bus/VirtIO/Device.cpp | 35 |
2 files changed, 30 insertions, 7 deletions
diff --git a/Kernel/Bus/PCI/IDs.h b/Kernel/Bus/PCI/IDs.h index 531e2d7826..ddad4992e8 100644 --- a/Kernel/Bus/PCI/IDs.h +++ b/Kernel/Bus/PCI/IDs.h @@ -19,6 +19,8 @@ enum VendorID { }; enum DeviceID { + VirtIONetAdapter = 0x1000, + VirtIOBlockDevice = 0x1001, VirtIOConsole = 0x1003, VirtIOEntropy = 0x1005, VirtIOGPU = 0x1050, diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp index fad217e65e..fccf363607 100644 --- a/Kernel/Bus/VirtIO/Device.cpp +++ b/Kernel/Bus/VirtIO/Device.cpp @@ -47,18 +47,39 @@ UNMAP_AFTER_INIT void detect() StringView determine_device_class(const PCI::Address& address) { - auto subsystem_device_id = PCI::get_subsystem_id(address); - switch (subsystem_device_id) { - case 1: + if (PCI::get_revision_id(address) == 0) { + // Note: If the device is a legacy (or transitional) device, therefore, + // probe the subsystem ID in the PCI header and figure out the + auto subsystem_device_id = PCI::get_subsystem_id(address); + switch (subsystem_device_id) { + case 1: + return "VirtIONetAdapter"; + case 2: + return "VirtIOBlockDevice"; + case 3: + return "VirtIOConsole"; + case 4: + return "VirtIORNG"; + } + dbgln("VirtIO: Unknown subsystem_device_id {}", subsystem_device_id); + VERIFY_NOT_REACHED(); + } + + auto id = PCI::get_id(address); + VERIFY(id.vendor_id == PCI::VendorID::VirtIO); + switch (id.device_id) { + case PCI::DeviceID::VirtIONetAdapter: return "VirtIONetAdapter"; - case 2: + case PCI::DeviceID::VirtIOBlockDevice: return "VirtIOBlockDevice"; - case 3: + case PCI::DeviceID::VirtIOConsole: return "VirtIOConsole"; - case 4: + case PCI::DeviceID::VirtIOEntropy: return "VirtIORNG"; + case PCI::DeviceID::VirtIOGPU: + return "VirtIOGPU"; } - dbgln("VirtIO: Unknown subsystem_device_id {}", subsystem_device_id); + dbgln("VirtIO: Unknown device_id {}", id.vendor_id); VERIFY_NOT_REACHED(); } |