Improve XhciPortLimit compatibility with macOS Tahoe (#590)

This commit is contained in:
laobamac 2025-11-20 00:27:24 +08:00 committed by GitHub
parent d31ab222ae
commit 000227e411
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 4 deletions

View File

@ -131,6 +131,7 @@ typedef enum KERNEL_CACHE_TYPE_ {
#define KERNEL_VERSION_VENTURA 22
#define KERNEL_VERSION_SONOMA 23
#define KERNEL_VERSION_SEQUOIA 24
#define KERNEL_VERSION_TAHOE 25
//
// Minimum kernel versions for each release.
@ -152,6 +153,7 @@ typedef enum KERNEL_CACHE_TYPE_ {
#define KERNEL_VERSION_VENTURA_MIN KERNEL_VERSION (KERNEL_VERSION_VENTURA, 0, 0)
#define KERNEL_VERSION_SONOMA_MIN KERNEL_VERSION (KERNEL_VERSION_SONOMA, 0, 0)
#define KERNEL_VERSION_SEQUOIA_MIN KERNEL_VERSION (KERNEL_VERSION_SEQUOIA, 0, 0)
#define KERNEL_VERSION_TAHOE_MIN KERNEL_VERSION (KERNEL_VERSION_TAHOE, 0, 0)
//
// Maximum kernel versions for each release.

View File

@ -735,6 +735,21 @@ PATCHER_GENERIC_PATCH
.Limit = 4096
};
STATIC
PATCHER_GENERIC_PATCH
mRemoveUsbLimitIoP1Patch1Tahoe = {
.Comment = DEBUG_POINTER ("RemoveUsbLimitIoP1 part 1"),
.Base = "__ZN16AppleUSBHostPort15setPortLocationEv",
.Find = mRemoveUsbLimitIoP1Find1,
.Mask = NULL,
.Replace = mRemoveUsbLimitIoP1Replace1,
.ReplaceMask = NULL,
.Size = sizeof (mRemoveUsbLimitIoP1Replace1),
.Count = 1,
.Skip = 0,
.Limit = 4096
};
STATIC
CONST UINT8
mRemoveUsbLimitIoP1Find2[] = {
@ -805,11 +820,24 @@ PatchUsbXhciPortLimit1 (
return EFI_NOT_FOUND;
}
Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
//
// For macOS 26.0 (Darwin 25.0.0) and above use Tahoe-specific patch,
// otherwise use the original patch.
//
if (OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_TAHOE_MIN, 0)) {
Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1Tahoe);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply Tahoe port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
} else {
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success Tahoe port com.apple.iokit.IOUSBHostFamily part 1\n"));
}
} else {
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success port com.apple.iokit.IOUSBHostFamily part 1\n"));
Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply pre-Tahoe port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
} else {
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success pre-Tahoe port com.apple.iokit.IOUSBHostFamily part 1\n"));
}
}
//