ladybird/Kernel/Bus/PCI/IDs.h
Liav A e606ff3751 Kernel/VirtIO: Determine VirtIO device class also with the PCI device ID
According to the VirtIO 1.0 specification:
"Non-transitional devices SHOULD have a PCI Device ID in the range
0x1040 to 0x107f. Non-transitional devices SHOULD have a PCI Revision ID
of 1 or higher. Non-transitional devices SHOULD have a PCI Subsystem
Device ID of 0x40 or higher."

It also says that:
"Transitional devices MUST have a PCI Revision ID of 0. Transitional
devices MUST have the PCI Subsystem Device ID matching the Virtio
Device ID, as indicated in section 5. Transitional devices MUST have the
Transitional PCI Device ID in the range 0x1000 to 0x103f."

So, for legacy devices, we know that revision ID in the PCI header won't
be 1, so we probe for PCI_SUBSYSTEM_ID value.
Instead of using the subsystem device ID, we can probe the DEVICE_ID
value directly in case it's not a legacy device.
This should cover all possibilities for identifying VirtIO devices, both
per the specification of 0.9.5, and future revisions from 1.0 onwards.
2021-09-04 20:53:26 +02:00

29 lines
488 B
C++

/*
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Kernel::PCI {
enum VendorID {
VirtIO = 0x1af4,
Intel = 0x8086,
WCH = 0x1c00,
RedHat = 0x1b36,
Realtek = 0x10ec,
QEMUOld = 0x1234,
VirtualBox = 0x80ee
};
enum DeviceID {
VirtIONetAdapter = 0x1000,
VirtIOBlockDevice = 0x1001,
VirtIOConsole = 0x1003,
VirtIOEntropy = 0x1005,
VirtIOGPU = 0x1050,
};
}