Skip to content

Commit

Permalink
Fixed PCI class-code masking not detecting HDEF devices
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Sep 3, 2018
1 parent 8159c8b commit 892f0c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Lilu Changelog
- Added disk log dump in DEBUG builds via `liludump=N` boot-arg (requires plugin rebuild)
- Fixed multiple Mach-O parsing issues
- Fixed support of PCI devices without compatible property
- Fixed PCI `class-code` masking not detecting HDEF devices

#### v1.2.6
- Added Cannon Lake and Ice Lake definitions
Expand Down
13 changes: 8 additions & 5 deletions Lilu/Headers/kern_iokit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,15 @@ namespace WIOKit {
*/
struct ClassCode {
enum : uint32_t {
VGAController = 0x30000,
DisplayController = 0x38000,
PCIBridge = 0x60400,
HDADevice = 0x040300,
VGAController = 0x030000,
DisplayController = 0x038000,
PCIBridge = 0x060400,
// Watch out for PCISubclassMask, 0x040380 is common on laptops.
HDADevice = 0x040300,
// This does not seem to be documented. It works on Haswell at least.
IMEI = 0x78000
IMEI = 0x078000,
// To ignore device subclasses.
PCISubclassMask = 0xFFFF00,
};
};

Expand Down
10 changes: 10 additions & 0 deletions Lilu/Sources/kern_devinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ void DeviceInfo::grabDevicesFromPciRoot(IORegistryEntry *pciRoot) {
auto name = obj->getName();
DBGLOG("dev", "found pci device %s 0x%x 0x%x", safeString(name), vendor, code);

// Strip interface, as we only care about class and subclass
code &= WIOKit::ClassCode::PCISubclassMask;

if (!gotVendor || !gotClass || (vendor != WIOKit::VendorID::Intel && vendor != WIOKit::VendorID::ATIAMD))
continue;

Expand Down Expand Up @@ -312,6 +315,13 @@ DeviceInfo *DeviceInfo::create() {

if (isPciRoot) {
DBGLOG("dev", "found PCI root %s", safeString(pciRootObj->getName()));

// PCI is strictly not guaranteed to be ready at this time, check it just in case.
while (OSDynamicCast(OSBoolean, pciRootObj->getProperty("IOPCIConfigured")) != kOSBooleanTrue) {
DBGLOG("dev", "waiting on PCI root %s configuration", safeString(pciRootObj->getName()));
IOSleep(1);
}

list->grabDevicesFromPciRoot(pciRootObj);
}
}
Expand Down

0 comments on commit 892f0c1

Please sign in to comment.