Skip to content

Commit 892f0c1

Browse files
committed
Fixed PCI class-code masking not detecting HDEF devices
1 parent 8159c8b commit 892f0c1

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Lilu Changelog
77
- Added disk log dump in DEBUG builds via `liludump=N` boot-arg (requires plugin rebuild)
88
- Fixed multiple Mach-O parsing issues
99
- Fixed support of PCI devices without compatible property
10+
- Fixed PCI `class-code` masking not detecting HDEF devices
1011

1112
#### v1.2.6
1213
- Added Cannon Lake and Ice Lake definitions

Lilu/Headers/kern_iokit.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,15 @@ namespace WIOKit {
148148
*/
149149
struct ClassCode {
150150
enum : uint32_t {
151-
VGAController = 0x30000,
152-
DisplayController = 0x38000,
153-
PCIBridge = 0x60400,
154-
HDADevice = 0x040300,
151+
VGAController = 0x030000,
152+
DisplayController = 0x038000,
153+
PCIBridge = 0x060400,
154+
// Watch out for PCISubclassMask, 0x040380 is common on laptops.
155+
HDADevice = 0x040300,
155156
// This does not seem to be documented. It works on Haswell at least.
156-
IMEI = 0x78000
157+
IMEI = 0x078000,
158+
// To ignore device subclasses.
159+
PCISubclassMask = 0xFFFF00,
157160
};
158161
};
159162

Lilu/Sources/kern_devinfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) {
218218
auto name = obj->getName();
219219
DBGLOG("dev", "found pci device %s 0x%x 0x%x", safeString(name), vendor, code);
220220

221+
// Strip interface, as we only care about class and subclass
222+
code &= WIOKit::ClassCode::PCISubclassMask;
223+
221224
if (!gotVendor || !gotClass || (vendor != WIOKit::VendorID::Intel && vendor != WIOKit::VendorID::ATIAMD))
222225
continue;
223226

@@ -312,6 +315,13 @@ DeviceInfo *DeviceInfo::create() {
312315

313316
if (isPciRoot) {
314317
DBGLOG("dev", "found PCI root %s", safeString(pciRootObj->getName()));
318+
319+
// PCI is strictly not guaranteed to be ready at this time, check it just in case.
320+
while (OSDynamicCast(OSBoolean, pciRootObj->getProperty("IOPCIConfigured")) != kOSBooleanTrue) {
321+
DBGLOG("dev", "waiting on PCI root %s configuration", safeString(pciRootObj->getName()));
322+
IOSleep(1);
323+
}
324+
315325
list->grabDevicesFromPciRoot(pciRootObj);
316326
}
317327
}

0 commit comments

Comments
 (0)