mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-19 22:00:00 +10:00
Rework BlueToolFixup patch
This commit is contained in:
+8
-4
@@ -586,16 +586,20 @@ class BuildOpenCore:
|
|||||||
if not self.constants.custom_model and self.computer.bluetooth:
|
if not self.constants.custom_model and self.computer.bluetooth:
|
||||||
if self.computer.bluetooth == "BRCM2070 Hub":
|
if self.computer.bluetooth == "BRCM2070 Hub":
|
||||||
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
|
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
|
||||||
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2070_path)
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -brcm2070_patch"
|
||||||
|
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
|
||||||
elif self.computer.bluetooth == "BRCM2046 Hub":
|
elif self.computer.bluetooth == "BRCM2046 Hub":
|
||||||
print("- Enabling Bluetooth BRCM2046 for macOS Monterey")
|
print("- Enabling Bluetooth BRCM2046 for macOS Monterey")
|
||||||
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2046_path)
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -brcm2046_patch"
|
||||||
|
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
|
||||||
elif self.model in ModelArray.Bluetooth_BRCM2070:
|
elif self.model in ModelArray.Bluetooth_BRCM2070:
|
||||||
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
|
print("- Enabling Bluetooth BRCM2070 for macOS Monterey")
|
||||||
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2070_path)
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -brcm2070_patch"
|
||||||
|
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
|
||||||
elif self.model in ModelArray.Bluetooth_BRCM2046:
|
elif self.model in ModelArray.Bluetooth_BRCM2046:
|
||||||
print("- Enabling Bluetooth BRCM2046 for macOS Monterey")
|
print("- Enabling Bluetooth BRCM2046 for macOS Monterey")
|
||||||
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.brcm2046_path)
|
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -brcm2046_patch"
|
||||||
|
self.enable_kext("BlueToolFixup.kext", self.constants.bluetool_version, self.constants.bluetool_path)
|
||||||
|
|
||||||
# Add XhciDxe if firmware doesn't have XHCI controller support and XCHI controller detected
|
# Add XhciDxe if firmware doesn't have XHCI controller support and XCHI controller detected
|
||||||
# TODO: Fix XhciDxe to work on pre UEFI 2.0 Macs
|
# TODO: Fix XhciDxe to work on pre UEFI 2.0 Macs
|
||||||
|
|||||||
+4
-12
@@ -326,6 +326,10 @@ class Constants:
|
|||||||
def debugenhancer_path(self):
|
def debugenhancer_path(self):
|
||||||
return self.payload_kexts_path / Path(f"Acidanthera/DebugEnhancer-v{self.debugenhancer_version}.zip")
|
return self.payload_kexts_path / Path(f"Acidanthera/DebugEnhancer-v{self.debugenhancer_version}.zip")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bluetool_path(self):
|
||||||
|
return self.payload_kexts_path / Path(f"Acidanthera/BlueToolFixup-v{self.bluetool_version}.zip")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def innie_path(self):
|
def innie_path(self):
|
||||||
return self.payload_kexts_path / Path(f"Misc/Innie-v{self.innie_version}.zip")
|
return self.payload_kexts_path / Path(f"Misc/Innie-v{self.innie_version}.zip")
|
||||||
@@ -342,18 +346,6 @@ class Constants:
|
|||||||
def plist_folder_path(self):
|
def plist_folder_path(self):
|
||||||
return self.payload_kexts_path / Path("Plists")
|
return self.payload_kexts_path / Path("Plists")
|
||||||
|
|
||||||
@property
|
|
||||||
def bluetooth_folder_path(self):
|
|
||||||
return self.payload_kexts_path / Path("Bluetooth")
|
|
||||||
|
|
||||||
@property
|
|
||||||
def brcm2046_path(self):
|
|
||||||
return self.bluetooth_folder_path / Path(f"BlueToolFixup-2046-v{self.bluetool_version}.zip")
|
|
||||||
|
|
||||||
@property
|
|
||||||
def brcm2070_path(self):
|
|
||||||
return self.bluetooth_folder_path / Path(f"BlueToolFixup-2070-v{self.bluetool_version}.zip")
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def platform_plugin_plist_path(self):
|
def platform_plugin_plist_path(self):
|
||||||
return self.plist_folder_path / Path("PlatformPlugin")
|
return self.plist_folder_path / Path("PlatformPlugin")
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,42 @@
|
|||||||
|
diff --git a/BrcmPatchRAM/BlueToolFixup.cpp b/BrcmPatchRAM/BlueToolFixup.cpp
|
||||||
|
index 0fa891a..819eb3f 100644
|
||||||
|
--- a/BrcmPatchRAM/BlueToolFixup.cpp
|
||||||
|
+++ b/BrcmPatchRAM/BlueToolFixup.cpp
|
||||||
|
@@ -50,7 +50,15 @@ bool BlueToolFixup::start(IOService *provider) {
|
||||||
|
static const uint8_t kSkipUpdateFilePathOriginal[] = "/etc/bluetool/SkipBluetoothAutomaticFirmwareUpdate";
|
||||||
|
static const uint8_t kSkipUpdateFilePathPatched[] = "/System/Library/CoreServices/boot.efi";
|
||||||
|
|
||||||
|
+static const uint8_t kBluetoothUSBNameOriginal[] = "Bluetooth USB Host Controller";
|
||||||
|
+static const uint8_t kBluetoothUSBNamePatched2070[] = "BRCM2070 Hub Host Controller";
|
||||||
|
+static const uint8_t kBluetoothUSBNamePatched2046[] = "BRCM2046 Hub Host Controller";
|
||||||
|
+
|
||||||
|
static const char *blueToolPath = "/usr/sbin/BlueTool";
|
||||||
|
+static const char *bluetoothdPath = "/usr/sbin/bluetoothd";
|
||||||
|
+
|
||||||
|
+static const char brcm2046_patch = checkKernelArgument("-brcm2046_patch");
|
||||||
|
+static const char brcm2070_patch = checkKernelArgument("-brcm2070_patch");
|
||||||
|
|
||||||
|
static mach_vm_address_t orig_cs_validate {};
|
||||||
|
|
||||||
|
@@ -71,8 +79,19 @@ static void patched_cs_validate_page(vnode_t vp, memory_object_t pager, memory_o
|
||||||
|
char path[PATH_MAX];
|
||||||
|
int pathlen = PATH_MAX;
|
||||||
|
FunctionCast(patched_cs_validate_page, orig_cs_validate)(vp, pager, page_offset, data, validated_p, tainted_p, nx_p);
|
||||||
|
- if (vn_getpath(vp, path, &pathlen) == 0 && UNLIKELY(strcmp(path, blueToolPath) == 0)) {
|
||||||
|
- searchAndPatch(data, PAGE_SIZE, path, kSkipUpdateFilePathOriginal, kSkipUpdateFilePathPatched);
|
||||||
|
+ if (vn_getpath(vp, path, &pathlen) == 0) {
|
||||||
|
+ if (UNLIKELY(strcmp(path, blueToolPath) == 0)) {
|
||||||
|
+ searchAndPatch(data, PAGE_SIZE, path, kSkipUpdateFilePathOriginal, kSkipUpdateFilePathPatched);
|
||||||
|
+ }
|
||||||
|
+ if (UNLIKELY(strcmp(path, bluetoothdPath) == 0)) {
|
||||||
|
+ if (brcm2046_patch) {
|
||||||
|
+ DBGLOG(MODULE_SHORT, "Patching BRCM2046 Hub into bluetoothd");
|
||||||
|
+ searchAndPatch(data, PAGE_SIZE, path, kBluetoothUSBNameOriginal, kBluetoothUSBNamePatched2046);
|
||||||
|
+ } else if (brcm2070_patch) {
|
||||||
|
+ DBGLOG(MODULE_SHORT, "Patching BRCM2070 Hub into bluetoothd");
|
||||||
|
+ searchAndPatch(data, PAGE_SIZE, path, kBluetoothUSBNameOriginal, kBluetoothUSBNamePatched2070);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Binary file not shown.
@@ -1,26 +0,0 @@
|
|||||||
diff --git a/BrcmPatchRAM/BlueToolFixup.cpp b/BrcmPatchRAM/BlueToolFixup.cpp
|
|
||||||
index 0fa891a..e68f28e 100644
|
|
||||||
--- a/BrcmPatchRAM/BlueToolFixup.cpp
|
|
||||||
+++ b/BrcmPatchRAM/BlueToolFixup.cpp
|
|
||||||
@@ -50,7 +50,11 @@ bool BlueToolFixup::start(IOService *provider) {
|
|
||||||
static const uint8_t kSkipUpdateFilePathOriginal[] = "/etc/bluetool/SkipBluetoothAutomaticFirmwareUpdate";
|
|
||||||
static const uint8_t kSkipUpdateFilePathPatched[] = "/System/Library/CoreServices/boot.efi";
|
|
||||||
|
|
||||||
+static const uint8_t kBluetoothUSBNameOriginal[] = "Bluetooth USB Host Controller";
|
|
||||||
+static const uint8_t kBluetoothUSBNamePatched[] = "BRCM2046 Hub Host Controller";
|
|
||||||
+
|
|
||||||
static const char *blueToolPath = "/usr/sbin/BlueTool";
|
|
||||||
+static const char *bluetoothdPath = "/usr/sbin/bluetoothd";
|
|
||||||
|
|
||||||
static mach_vm_address_t orig_cs_validate {};
|
|
||||||
|
|
||||||
@@ -74,6 +78,9 @@ static void patched_cs_validate_page(vnode_t vp, memory_object_t pager, memory_o
|
|
||||||
if (vn_getpath(vp, path, &pathlen) == 0 && UNLIKELY(strcmp(path, blueToolPath) == 0)) {
|
|
||||||
searchAndPatch(data, PAGE_SIZE, path, kSkipUpdateFilePathOriginal, kSkipUpdateFilePathPatched);
|
|
||||||
}
|
|
||||||
+ if (vn_getpath(vp, path, &pathlen) == 0 && UNLIKELY(strcmp(path, bluetoothdPath) == 0)) {
|
|
||||||
+ searchAndPatch(data, PAGE_SIZE, path, kBluetoothUSBNameOriginal, kBluetoothUSBNamePatched);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@@ -1,26 +0,0 @@
|
|||||||
diff --git a/BrcmPatchRAM/BlueToolFixup.cpp b/BrcmPatchRAM/BlueToolFixup.cpp
|
|
||||||
index 0fa891a..6a9d2f3 100644
|
|
||||||
--- a/BrcmPatchRAM/BlueToolFixup.cpp
|
|
||||||
+++ b/BrcmPatchRAM/BlueToolFixup.cpp
|
|
||||||
@@ -50,7 +50,11 @@ bool BlueToolFixup::start(IOService *provider) {
|
|
||||||
static const uint8_t kSkipUpdateFilePathOriginal[] = "/etc/bluetool/SkipBluetoothAutomaticFirmwareUpdate";
|
|
||||||
static const uint8_t kSkipUpdateFilePathPatched[] = "/System/Library/CoreServices/boot.efi";
|
|
||||||
|
|
||||||
+static const uint8_t kBluetoothUSBNameOriginal[] = "Bluetooth USB Host Controller";
|
|
||||||
+static const uint8_t kBluetoothUSBNamePatched[] = "BRCM2070 Hub Host Controller";
|
|
||||||
+
|
|
||||||
static const char *blueToolPath = "/usr/sbin/BlueTool";
|
|
||||||
+static const char *bluetoothdPath = "/usr/sbin/bluetoothd";
|
|
||||||
|
|
||||||
static mach_vm_address_t orig_cs_validate {};
|
|
||||||
|
|
||||||
@@ -74,6 +78,9 @@ static void patched_cs_validate_page(vnode_t vp, memory_object_t pager, memory_o
|
|
||||||
if (vn_getpath(vp, path, &pathlen) == 0 && UNLIKELY(strcmp(path, blueToolPath) == 0)) {
|
|
||||||
searchAndPatch(data, PAGE_SIZE, path, kSkipUpdateFilePathOriginal, kSkipUpdateFilePathPatched);
|
|
||||||
}
|
|
||||||
+ if (vn_getpath(vp, path, &pathlen) == 0 && UNLIKELY(strcmp(path, bluetoothdPath) == 0)) {
|
|
||||||
+ searchAndPatch(data, PAGE_SIZE, path, kBluetoothUSBNameOriginal, kBluetoothUSBNamePatched);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user