Skip to content

Commit edfb7ae

Browse files
committed
extend Xhci port limit patch to Tahoe
Signed-off-by: Slice <sergey.slice@gmail.com>
1 parent cb6230f commit edfb7ae

2 files changed

Lines changed: 56 additions & 6 deletions

File tree

Include/Acidanthera/Library/OcAppleKernelLib.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ typedef enum KERNEL_CACHE_TYPE_ {
129129
#define KERNEL_VERSION_BIG_SUR 20
130130
#define KERNEL_VERSION_MONTEREY 21
131131
#define KERNEL_VERSION_VENTURA 22
132+
#define KERNEL_VERSION_SONOMA 23
133+
#define KERNEL_VERSION_SEQUOIA 24
134+
#define KERNEL_VERSION_TAHOE 25
132135

133136
//
134137
// Minimum kernel versions for each release.
@@ -148,6 +151,10 @@ typedef enum KERNEL_CACHE_TYPE_ {
148151
#define KERNEL_VERSION_BIG_SUR_MIN KERNEL_VERSION (KERNEL_VERSION_BIG_SUR, 0, 0)
149152
#define KERNEL_VERSION_MONTEREY_MIN KERNEL_VERSION (KERNEL_VERSION_MONTEREY, 0, 0)
150153
#define KERNEL_VERSION_VENTURA_MIN KERNEL_VERSION (KERNEL_VERSION_VENTURA, 0, 0)
154+
#define KERNEL_VERSION_SONOMA_MIN KERNEL_VERSION (KERNEL_VERSION_SONOMA, 0, 0)
155+
#define KERNEL_VERSION_SEQUOIA_MIN KERNEL_VERSION (KERNEL_VERSION_SEQUOIA, 0, 0)
156+
#define KERNEL_VERSION_TAHOE_MIN KERNEL_VERSION (KERNEL_VERSION_TAHOE, 0, 0)
157+
151158

152159
//
153160
// Maximum kernel versions for each release.
@@ -166,6 +173,10 @@ typedef enum KERNEL_CACHE_TYPE_ {
166173
#define KERNEL_VERSION_CATALINA_MAX (KERNEL_VERSION_BIG_SUR_MIN - 1)
167174
#define KERNEL_VERSION_BIG_SUR_MAX (KERNEL_VERSION_MONTEREY_MIN - 1)
168175
#define KERNEL_VERSION_MONTEREY_MAX (KERNEL_VERSION_VENTURA_MIN - 1)
176+
#define KERNEL_VERSION_VENTURA_MAX (KERNEL_VERSION_SONOMA_MIN - 1)
177+
#define KERNEL_VERSION_SONOMA_MAX (KERNEL_VERSION_SEQUOIA_MIN - 1)
178+
#define KERNEL_VERSION_SEQUOIA_MAX (KERNEL_VERSION_TAHOE_MIN - 1)
179+
//#define KERNEL_VERSION_MONTEREY_MAX (KERNEL_VERSION_VENTURA_MIN - 1)
169180

170181
//
171182
// Prelinked context used for kernel modification.

Library/OcAppleKernelLib/CommonPatches.c

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,22 @@ PATCHER_GENERIC_PATCH
670670
.Limit = 4096
671671
};
672672

673+
STATIC
674+
PATCHER_GENERIC_PATCH
675+
mRemoveUsbLimitIoP1Patch1Tahoe = {
676+
.Comment = DEBUG_POINTER ("RemoveUsbLimitIoP1 part 1"),
677+
.Base = "__ZN16AppleUSBHostPort15setPortLocationEv",
678+
.Find = mRemoveUsbLimitIoP1Find1,
679+
.Mask = NULL,
680+
.Replace = mRemoveUsbLimitIoP1Replace1,
681+
.ReplaceMask = NULL,
682+
.Size = sizeof (mRemoveUsbLimitIoP1Replace1),
683+
.Count = 1,
684+
.Skip = 0,
685+
.Limit = 4096
686+
};
687+
688+
673689
STATIC
674690
CONST UINT8
675691
mRemoveUsbLimitIoP1Find2[] = {
@@ -740,12 +756,35 @@ PatchUsbXhciPortLimit1 (
740756
return EFI_NOT_FOUND;
741757
}
742758

743-
Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1);
744-
if (EFI_ERROR (Status)) {
745-
DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
746-
} else {
747-
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success port com.apple.iokit.IOUSBHostFamily part 1\n"));
748-
}
759+
// Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1);
760+
// if (EFI_ERROR (Status)) {
761+
// DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
762+
// } else {
763+
// DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success port com.apple.iokit.IOUSBHostFamily part 1\n"));
764+
// }
765+
766+
767+
// For macOS 26.0 (Darwin 25.0.0) and above use Tahoe-specific patch,
768+
// otherwise use the original patch.
769+
//
770+
if (OcMatchDarwinVersion (KernelVersion, KERNEL_VERSION_TAHOE_MIN, 0)) {
771+
Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1Tahoe);
772+
if (EFI_ERROR (Status)) {
773+
DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply Tahoe port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
774+
} else {
775+
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success Tahoe port com.apple.iokit.IOUSBHostFamily part 1\n"));
776+
}
777+
} else {
778+
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success port com.apple.iokit.IOUSBHostFamily part 1\n"));
779+
Status = PatcherApplyGenericPatch (Patcher, &mRemoveUsbLimitIoP1Patch1);
780+
if (EFI_ERROR (Status)) {
781+
DEBUG ((DEBUG_INFO, "OCAK: [FAIL] Failed to apply pre-Tahoe port patch com.apple.iokit.IOUSBHostFamily part 1 - %r\n", Status));
782+
} else {
783+
DEBUG ((DEBUG_INFO, "OCAK: [OK] Patch success pre-Tahoe port com.apple.iokit.IOUSBHostFamily part 1\n"));
784+
}
785+
}
786+
787+
749788

750789
//
751790
// The following patch is only needed on macOS 11.1 (Darwin 20.2.0) and above; skip it otherwise.

0 commit comments

Comments
 (0)