fix: fix ACPI hardware-ID endianness bug
This commit is contained in:
@@ -22,7 +22,22 @@ namespace Hal {
|
||||
|
||||
// ============================================================================
|
||||
// ACPI encodes PNP IDs as compressed 32-bit EISAIDs.
|
||||
static constexpr uint32_t ByteSwap32(uint32_t value) {
|
||||
return ((value & 0x000000FFu) << 24) |
|
||||
((value & 0x0000FF00u) << 8) |
|
||||
((value & 0x00FF0000u) >> 8) |
|
||||
((value & 0xFF000000u) >> 24);
|
||||
}
|
||||
|
||||
static_assert(ByteSwap32(0x0301D041u) == 0x41D00103u); // PNP0103
|
||||
static_assert(ByteSwap32(0x090CD041u) == 0x41D00C09u); // PNP0C09
|
||||
|
||||
static void DecodeEisaId(uint32_t id, char* out) {
|
||||
// AML exposes the EISAID integer in little-endian byte order, while
|
||||
// the compressed manufacturer and product fields are defined in
|
||||
// display order. Convert it before extracting either field.
|
||||
id = ByteSwap32(id);
|
||||
|
||||
// EISA ID encoding:
|
||||
// Bits 31-16: 3 compressed letters (5 bits each, '@' based)
|
||||
// Bits 15-0: 4 hex digits (product number)
|
||||
|
||||
Reference in New Issue
Block a user