Some minor adjustments to ensure alignment of PCI header.
This commit is contained in:
parent
54a5ee720f
commit
00f4e0de3a
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace baos::pci
|
namespace baos::pci
|
||||||
{
|
{
|
||||||
|
// <editor-fold desc="PCI Class Enums">
|
||||||
enum class BaseClass : std::uint8_t
|
enum class BaseClass : std::uint8_t
|
||||||
{
|
{
|
||||||
UNCLASSIFIED = 0x0,
|
UNCLASSIFIED = 0x0,
|
||||||
@ -164,6 +165,7 @@ enum class SubClass : std::uint8_t
|
|||||||
COMMUNICATION_SYNCHRONIZER = 0x10,
|
COMMUNICATION_SYNCHRONIZER = 0x10,
|
||||||
SIGNAL_PROCESSING_MANAGEMENT = 0x20
|
SIGNAL_PROCESSING_MANAGEMENT = 0x20
|
||||||
};
|
};
|
||||||
|
//</editor-fold>
|
||||||
|
|
||||||
enum class HeaderType : std::uint8_t
|
enum class HeaderType : std::uint8_t
|
||||||
{
|
{
|
||||||
@ -172,7 +174,7 @@ enum class HeaderType : std::uint8_t
|
|||||||
PCI_TO_CARDBUS_BRIDGE = 0x2
|
PCI_TO_CARDBUS_BRIDGE = 0x2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Header
|
struct alignas(32) Header
|
||||||
{
|
{
|
||||||
std::uint8_t bus;
|
std::uint8_t bus;
|
||||||
std::uint8_t device;
|
std::uint8_t device;
|
||||||
@ -183,10 +185,12 @@ struct Header
|
|||||||
std::uint16_t deviceID;
|
std::uint16_t deviceID;
|
||||||
std::uint16_t command;
|
std::uint16_t command;
|
||||||
std::uint16_t status;
|
std::uint16_t status;
|
||||||
|
|
||||||
std::uint8_t revisionID;
|
std::uint8_t revisionID;
|
||||||
std::uint8_t progIf;
|
std::uint8_t progIf;
|
||||||
SubClass subClass;
|
SubClass subClass;
|
||||||
BaseClass baseClass;
|
BaseClass baseClass;
|
||||||
|
|
||||||
std::uint8_t cacheLineSize;
|
std::uint8_t cacheLineSize;
|
||||||
std::uint8_t latencyTimer;
|
std::uint8_t latencyTimer;
|
||||||
HeaderType headerType : 7;
|
HeaderType headerType : 7;
|
||||||
|
@ -96,23 +96,23 @@ void enumerateDevice(const Header& header, std::vector<Header>& outHeaders) noex
|
|||||||
|
|
||||||
std::vector<Header> enumerateDevices() noexcept
|
std::vector<Header> enumerateDevices() noexcept
|
||||||
{
|
{
|
||||||
Header header = {};
|
Header hostControllerHeader = {};
|
||||||
if (!getHeader(0, 0, 0, header)) {
|
if (!getHeader(0, 0, 0, hostControllerHeader)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
// also add the controller itself
|
|
||||||
std::vector<Header> headers;
|
std::vector<Header> headers;
|
||||||
|
|
||||||
headers.push_back(header);
|
// also add the controller itself
|
||||||
|
headers.push_back(hostControllerHeader);
|
||||||
enumerateBusDevices(0, headers, /* firstDevice = */ 1);
|
enumerateBusDevices(0, headers, /* firstDevice = */ 1);
|
||||||
if (header.multiFunction)
|
if (hostControllerHeader.multiFunction)
|
||||||
{
|
{
|
||||||
for (std::uint8_t function = 1; function < 8; ++function)
|
for (std::uint8_t function = 1; function < 8; ++function)
|
||||||
{
|
{
|
||||||
if (!getHeader(0, 0, function, header)) {
|
if (!getHeader(0, 0, function, hostControllerHeader)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
headers.push_back(header);
|
headers.push_back(hostControllerHeader);
|
||||||
enumerateBusDevices(function, headers);
|
enumerateBusDevices(function, headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user