diff --git a/NootedRed/DYLDPatches.cpp b/NootedRed/DYLDPatches.cpp index 57d4e637..7e38d16c 100644 --- a/NootedRed/DYLDPatches.cpp +++ b/NootedRed/DYLDPatches.cpp @@ -16,7 +16,7 @@ void DYLDPatches::processPatcher(KernelPatcher &patcher) { auto *entry = IORegistryEntry::fromPath("/", gIODTPlane); if (entry) { - DBGLOG("dyld", "Setting hwgva-id to iMacPro1,1"); + DBGLOG("DYLD", "Setting hwgva-id to iMacPro1,1"); entry->setProperty("hwgva-id", const_cast(kHwGvaId), arrsize(kHwGvaId)); entry->release(); } @@ -24,12 +24,12 @@ void DYLDPatches::processPatcher(KernelPatcher &patcher) { if (getKernelVersion() == KernelVersion::Catalina) { KernelPatcher::RouteRequest request {"_cs_validate_range", wrapCsValidateRange, this->orgCsValidate}; - PANIC_COND(!patcher.routeMultipleLong(KernelPatcher::KernelID, &request, 1), "dyld", + PANIC_COND(!patcher.routeMultipleLong(KernelPatcher::KernelID, &request, 1), "DYLD", "Failed to route kernel symbols"); } else { KernelPatcher::RouteRequest request {"_cs_validate_page", wrapCsValidatePage, this->orgCsValidate}; - PANIC_COND(!patcher.routeMultipleLong(KernelPatcher::KernelID, &request, 1), "dyld", + PANIC_COND(!patcher.routeMultipleLong(KernelPatcher::KernelID, &request, 1), "DYLD", "Failed to route kernel symbols"); } } @@ -47,7 +47,7 @@ void DYLDPatches::apply(char *path, void *data, size_t size) { if (UNLIKELY(KernelPatcher::findAndReplace(data, size, kVideoToolboxDRMModelOriginal, arrsize(kVideoToolboxDRMModelOriginal), BaseDeviceInfo::get().modelIdentifier, 20))) { - DBGLOG("dyld", "Applied 'VideoToolbox DRM model check' patch"); + DBGLOG("DYLD", "Applied 'VideoToolbox DRM model check' patch"); } const DYLDPatch patches[] = { diff --git a/NootedRed/DYLDPatches.hpp b/NootedRed/DYLDPatches.hpp index cd695a36..00a36403 100644 --- a/NootedRed/DYLDPatches.hpp +++ b/NootedRed/DYLDPatches.hpp @@ -40,7 +40,7 @@ class DYLDPatch { if (UNLIKELY(KernelPatcher::findAndReplaceWithMask(data, size, this->find, this->size, this->findMask, this->findMask ? this->size : 0, this->replace, this->size, this->replaceMask, this->replaceMask ? this->size : 0))) { - DBGLOG("dyld", "Applied '%s' patch", this->comment); + DBGLOG("DYLD", "Applied '%s' patch", this->comment); } } diff --git a/NootedRed/Firmware.hpp b/NootedRed/Firmware.hpp index ea88164c..dbc373a2 100644 --- a/NootedRed/Firmware.hpp +++ b/NootedRed/Firmware.hpp @@ -19,5 +19,5 @@ inline const FWDescriptor &getFWDescByName(const char *name) { for (size_t i = 0; i < firmwareCount; i++) { if (!strcmp(firmware[i].name, name)) { return firmware[i]; } } - PANIC("nred", "getFWDescByName: '%s' not found", name); + PANIC("FW", "'%s' not found", name); } diff --git a/NootedRed/HDMI.cpp b/NootedRed/HDMI.cpp index e099c4ad..27f4cb81 100644 --- a/NootedRed/HDMI.cpp +++ b/NootedRed/HDMI.cpp @@ -33,13 +33,13 @@ bool HDMI::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slid {&kextAppleGFXHDA, kCreateAppleHDAWidget1Original, kCreateAppleHDAWidget1OriginalMask, kCreateAppleHDAWidget1Patched, kCreateAppleHDAWidget1PatchedMask, catalina ? 2U : 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "agfxhda", "Failed to apply patches"); + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "AGFXHDA", "Failed to apply patches"); if (catalina) { const LookupPatchPlus patch {&kextAppleGFXHDA, kCreateAppleHDACatalinaOriginal, kCreateAppleHDACatalinaOriginalMask, kCreateAppleHDACatalinaPatched, kCreateAppleHDACatalinaPatchedMask, 1}; - PANIC_COND(!patch.apply(patcher, slide, size), "agfxhda", "Failed to apply patch"); + PANIC_COND(!patch.apply(patcher, slide, size), "AGFXHDA", "Failed to apply patch"); } else { const LookupPatchPlus patches[] = { {&kextAppleGFXHDA, kCreateAppleHDAFunctionGroup1Original, kCreateAppleHDAFunctionGroup1Patched, 1}, @@ -51,7 +51,7 @@ bool HDMI::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slid {&kextAppleGFXHDA, kCreateAppleHDA2Original, kCreateAppleHDA2OriginalMask, kCreateAppleHDA2Patched, kCreateAppleHDA2PatchedMask, 2}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "agfxhda", "Failed to apply patches"); + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "AGFXHDA", "Failed to apply patches"); } return true; @@ -62,7 +62,7 @@ bool HDMI::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slid kAHDACreate2PatchedMask, 2}, {&kextAppleHDA, kAHDACreate3Original, kAHDACreate3Mask, kAHDACreate3Patched, 2}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "ahda", "Failed to apply patches"); + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "AHDA", "Failed to apply patches"); return true; } diff --git a/NootedRed/HWLibs.cpp b/NootedRed/HWLibs.cpp index fdf6f95b..04d46b70 100644 --- a/NootedRed/HWLibs.cpp +++ b/NootedRed/HWLibs.cpp @@ -36,7 +36,7 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address {"__ZN20AMDFirmwareDirectory11putFirmwareE16_AMD_DEVICE_TYPEP11AMDFirmware", this->orgPutFirmware, kPutFirmwarePattern}, }; - PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "hwlibs", + PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "HWLibs", "Failed to resolve symbols"); } @@ -45,7 +45,7 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address {"_CAILAsicCapsInitTable", orgCapsInitTable, kCAILAsicCapsInitTablePattern}, {"_DeviceCapabilityTbl", orgDevCapTable, kDeviceCapabilityTblPattern}, }; - PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "hwlibs", + PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "HWLibs", "Failed to resolve symbols"); bool ventura = getKernelVersion() >= KernelVersion::Ventura; @@ -54,7 +54,7 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address RouteRequestPlus request {"__ZN16AmdTtlFwServices7getIpFwEjPKcP10_TtlFwInfo", wrapGetIpFw, this->orgGetIpFw}; - PANIC_COND(!request.route(patcher, id, slide, size), "hwlibs", "Failed to route symbols"); + PANIC_COND(!request.route(patcher, id, slide, size), "HWLibs", "Failed to route symbols"); } else { RouteRequestPlus requests[] = { {"__ZN35AMDRadeonX5000_AMDRadeonHWLibsX500025populateFirmwareDirectoryEv", @@ -71,7 +71,7 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address ventura ? kPspSecurityFeatureCapsSet31VenturaPattern : kPspSecurityFeatureCapsSet31Pattern}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "hwlibs", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "HWLibs", "Failed to route symbols"); } @@ -85,10 +85,10 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address {"_update_sdma_power_gating", wrapUpdateSdmaPowerGating, this->orgUpdateSdmaPowerGating, kUpdateSdmaPowerGatingPattern, kUpdateSdmaPowerGatingMask}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "hwlibs", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "HWLibs", "Failed to route symbols"); - PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "hwlibs", + PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "HWLibs", "Failed to enable kernel writing"); if (orgDeviceTypeTable) { *orgDeviceTypeTable = {.deviceId = NRed::callback->deviceId, .deviceType = 6}; } @@ -111,7 +111,7 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address break; } } - PANIC_COND(orgCapsInitTable->deviceId == 0xFFFFFFFF, "hwlibs", "Failed to find init caps table entry"); + PANIC_COND(orgCapsInitTable->deviceId == 0xFFFFFFFF, "HWLibs", "Failed to find init caps table entry"); for (; orgDevCapTable->familyId; orgDevCapTable++) { if (orgDevCapTable->familyId == AMDGPU_FAMILY_RAVEN && orgDevCapTable->deviceId == targetDeviceId) { orgDevCapTable->deviceId = NRed::callback->deviceId; @@ -122,9 +122,9 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address break; } } - PANIC_COND(!orgDevCapTable->familyId, "hwlibs", "Failed to find device capability table entry"); + PANIC_COND(!orgDevCapTable->familyId, "HWLibs", "Failed to find device capability table entry"); MachInfo::setKernelWriting(false, KernelPatcher::kernelWriteLock); - DBGLOG("hwlibs", "Applied DDI Caps patches"); + DBGLOG("HWLibs", "Applied DDI Caps patches"); if (!catalina) { const LookupPatchPlus patches[] = { @@ -136,18 +136,18 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address {&kextRadeonX5000HWLibs, kGcSetFwEntryInfoOriginal, kGcSetFwEntryInfoOriginalMask, kGcSetFwEntryInfoPatched, kGcSetFwEntryInfoPatchedMask, 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "hwlibs", + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "HWLibs", "Failed to apply spoof patches"); } if (getKernelVersion() >= KernelVersion::Monterey) { const LookupPatchPlus patch {&kextRadeonX5000HWLibs, kCreatePowerTuneServicesMontereyOriginal1, kCreatePowerTuneServicesMontereyPatched1, 1}; - PANIC_COND(!patch.apply(patcher, slide, size), "hwlibs", "Failed to apply PowerTuneServices patch"); + PANIC_COND(!patch.apply(patcher, slide, size), "HWLibs", "Failed to apply PowerTuneServices patch"); } else { const LookupPatchPlus patch {&kextRadeonX5000HWLibs, kCreatePowerTuneServicesOriginal1, kCreatePowerTuneServicesPatched1, 1}; - PANIC_COND(!patch.apply(patcher, slide, size), "hwlibs", "Failed to apply PowerTuneServices patch"); + PANIC_COND(!patch.apply(patcher, slide, size), "HWLibs", "Failed to apply PowerTuneServices patch"); } const LookupPatchPlus patches[] = { @@ -157,14 +157,14 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address {&kextRadeonX5000HWLibs, kCreatePowerTuneServicesOriginal2, kCreatePowerTuneServicesMask2, kCreatePowerTuneServicesPatched2, 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "hwlibs", "Failed to apply patches"); + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "HWLibs", "Failed to apply patches"); if (ventura) { const LookupPatchPlus patches[] = { {&kextRadeonX5000HWLibs, kCailQueryAdapterInfoOriginal, kCailQueryAdapterInfoPatched, 1}, {&kextRadeonX5000HWLibs, kSDMAInitFunctionPointerListOriginal, kSDMAInitFunctionPointerListPatched, 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "hwlibs", + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "HWLibs", "Failed to apply Ventura patches"); } @@ -181,13 +181,13 @@ void X5000HWLibs::wrapPopulateFirmwareDirectory(void *that) { auto *filename = isRenoirDerivative ? "ativvaxy_nv.dat" : "ativvaxy_rv.dat"; auto &fwDesc = getFWDescByName(filename); - DBGLOG("hwlibs", "VCN firmware filename is %s", filename); + DBGLOG("HWLibs", "VCN firmware filename is %s", filename); /** VCN 2.2, VCN 1.0 */ auto *fw = callback->orgCreateFirmware(fwDesc.data, fwDesc.size, isRenoirDerivative ? 0x0202 : 0x0100, filename); - PANIC_COND(!fw, "hwlibs", "Failed to create '%s' firmware", filename); + PANIC_COND(!fw, "HWLibs", "Failed to create '%s' firmware", filename); auto *fwDir = getMember(that, getKernelVersion() > KernelVersion::BigSur ? 0xB0 : 0xB8); - PANIC_COND(!callback->orgPutFirmware(fwDir, 6, fw), "hwlibs", "Failed to insert '%s' firmware", filename); + PANIC_COND(!callback->orgPutFirmware(fwDir, 6, fw), "HWLibs", "Failed to insert '%s' firmware", filename); } bool X5000HWLibs::wrapGetIpFw(void *that, UInt32 ipVersion, char *name, void *out) { @@ -243,7 +243,7 @@ CAILResult X5000HWLibs::pspSecurityFeatureCapsSet10(void *psp) { auto &tOSVer = getMember(psp, fieldBase + 0x8); if ((tOSVer & 0xFFFF0000) == 0x80000 && (tOSVer & 0xFF) > 0x50) { auto policyVer = NRed::callback->readReg32(MP_BASE + 0x9B); - SYSLOG_COND((policyVer & 0xFF000000) != 0x0A000000, "hwlibs", "Invalid security policy version: 0x%X", + SYSLOG_COND((policyVer & 0xFF000000) != 0x0A000000, "HWLibs", "Invalid security policy version: 0x%X", policyVer); if (policyVer == 0xA02031A || ((policyVer & 0xFFFFFF00) == 0xA020400 && (policyVer & 0xFC) > 0x23) || ((policyVer & 0xFFFFFF00) == 0xA020300 && (policyVer & 0xFE) > 0x1D)) { @@ -273,7 +273,7 @@ CAILResult X5000HWLibs::pspSecurityFeatureCapsSet12(void *psp) { auto &tOSVer = getMember(psp, fieldBase + 0x8); if ((tOSVer & 0xFFFF0000) == 0x110000 && (tOSVer & 0xFF) > 0x2A) { auto policyVer = NRed::callback->readReg32(MP_BASE + 0x9B); - SYSLOG_COND((policyVer & 0xFF000000) != 0xB000000, "hwlibs", "Invalid security policy version: 0x%X", + SYSLOG_COND((policyVer & 0xFF000000) != 0xB000000, "HWLibs", "Invalid security policy version: 0x%X", policyVer); if ((policyVer & 0xFFFF0000) == 0xB090000 && (policyVer & 0xFE) > 0x35) { securityCaps |= 1; } } diff --git a/NootedRed/NRed.cpp b/NootedRed/NRed.cpp index f52bcb9e..06e9f4d4 100644 --- a/NootedRed/NRed.cpp +++ b/NootedRed/NRed.cpp @@ -35,7 +35,7 @@ static DYLDPatches dyldpatches; static HDMI agfxhda; void NRed::init() { - SYSLOG("nred", "Copyright 2022-2023 ChefKiss Inc. If you've paid for this, you've been scammed."); + SYSLOG("NRed", "Copyright 2022-2023 ChefKiss Inc. If you've paid for this, you've been scammed."); callback = this; lilu.onKextLoadForce(&kextAGDP); @@ -74,13 +74,13 @@ void NRed::processPatcher(KernelPatcher &patcher) { break; } } - PANIC_COND(!this->iGPU, "nred", "No iGPU found"); + PANIC_COND(!this->iGPU, "NRed", "No iGPU found"); } else { - PANIC_COND(!devInfo->videoBuiltin, "nred", "videoBuiltin null"); + PANIC_COND(!devInfo->videoBuiltin, "NRed", "videoBuiltin null"); this->iGPU = OSDynamicCast(IOPCIDevice, devInfo->videoBuiltin); - PANIC_COND(!this->iGPU, "nred", "videoBuiltin is not IOPCIDevice"); + PANIC_COND(!this->iGPU, "NRed", "videoBuiltin is not IOPCIDevice"); PANIC_COND(WIOKit::readPCIConfigValue(this->iGPU, WIOKit::kIOPCIConfigVendorID) != WIOKit::VendorID::ATIAMD, - "nred", "videoBuiltin is not AMD"); + "NRed", "videoBuiltin is not AMD"); } WIOKit::renameDevice(this->iGPU, "IGPU"); @@ -109,22 +109,22 @@ void NRed::processPatcher(KernelPatcher &patcher) { auto *prop = OSDynamicCast(OSData, this->iGPU->getProperty("ATY,bin_image")); if (prop) { - DBGLOG("nred", "VBIOS manually overridden"); + DBGLOG("NRed", "VBIOS manually overridden"); this->vbiosData = OSData::withBytes(prop->getBytesNoCopy(), prop->getLength()); - PANIC_COND(UNLIKELY(!this->vbiosData), "nred", "Failed to allocate VBIOS data"); + PANIC_COND(UNLIKELY(!this->vbiosData), "NRed", "Failed to allocate VBIOS data"); } else if (!this->getVBIOSFromVFCT()) { - SYSLOG("nred", "Failed to get VBIOS from VFCT."); - PANIC_COND(!this->getVBIOSFromVRAM(), "nred", "Failed to get VBIOS from VRAM"); + SYSLOG("NRed", "Failed to get VBIOS from VFCT."); + PANIC_COND(!this->getVBIOSFromVRAM(), "NRed", "Failed to get VBIOS from VRAM"); } auto len = this->vbiosData->getLength(); if (len < 65536) { - DBGLOG("nred", "Padding VBIOS to 65536 bytes (was %u)", len); + DBGLOG("NRed", "Padding VBIOS to 65536 bytes (was %u)", len); this->vbiosData->appendByte(0, 65536 - len); } DeviceInfo::deleter(devInfo); } else { - SYSLOG("nred", "Failed to create DeviceInfo"); + SYSLOG("NRed", "Failed to create DeviceInfo"); } KernelPatcher::RouteRequest request {"__ZN15OSMetaClassBase12safeMetaCastEPKS_PK11OSMetaClass", wrapSafeMetaCast, @@ -153,7 +153,7 @@ void NRed::setRMMIOIfNecessary() { if (this->rmmio && this->rmmio->getLength()) { return; } this->rmmio = this->iGPU->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress5, kIOInhibitCache | kIOMapAnywhere); - PANIC_COND(UNLIKELY(!this->rmmio || !this->rmmio->getLength()), "nred", "Failed to map RMMIO"); + PANIC_COND(UNLIKELY(!this->rmmio || !this->rmmio->getLength()), "NRed", "Failed to map RMMIO"); this->rmmioPtr = reinterpret_cast(this->rmmio->getVirtualAddress()); this->fbOffset = static_cast(this->readReg32(0x296B)) << 24; @@ -190,22 +190,22 @@ void NRed::setRMMIOIfNecessary() { this->enumRevision = 0xA1; break; default: - PANIC("nred", "Unknown device ID"); + PANIC("NRed", "Unknown device ID"); } } void NRed::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slide, size_t size) { if (kextAGDP.loadIndex == id) { const LookupPatchPlus patch {&kextAGDP, kAGDPBoardIDKeyOriginal, kAGDPBoardIDKeyPatched, 1}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "nred", "Failed to apply AGDP board-id patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "NRed", "Failed to apply AGDP board-id patch"); if (getKernelVersion() == KernelVersion::Ventura) { const LookupPatchPlus patch {&kextAGDP, kAGDPFBCountCheckVenturaOriginal, kAGDPFBCountCheckVenturaPatched, 1}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "nred", "Failed to apply AGDP fb count check patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "NRed", "Failed to apply AGDP fb count check patch"); } else { const LookupPatchPlus patch {&kextAGDP, kAGDPFBCountCheckOriginal, kAGDPFBCountCheckPatched, 1}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "nred", "Failed to apply AGDP fb count check patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "NRed", "Failed to apply AGDP fb count check patch"); } } else if (kextBacklight.loadIndex == id) { KernelPatcher::RouteRequest request {"__ZN15AppleIntelPanel10setDisplayEP9IODisplay", wrapApplePanelSetDisplay, @@ -214,7 +214,7 @@ void NRed::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slid const UInt8 find[] = {"F%uT%04x"}; const UInt8 replace[] = {"F%uTxxxx"}; const LookupPatchPlus patch {&kextBacklight, find, replace, 1}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "nred", "Failed to apply backlight patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "NRed", "Failed to apply backlight patch"); } } else if (kextMCCSControl.loadIndex == id) { KernelPatcher::RouteRequest requests[] = { @@ -224,15 +224,15 @@ void NRed::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slid patcher.routeMultiple(id, requests, slide, size); patcher.clearError(); } else if (agfxhda.processKext(patcher, id, slide, size)) { - DBGLOG("nred", "Processed AppleGFXHDA"); + DBGLOG("NRed", "Processed AppleGFXHDA"); } else if (x6000fb.processKext(patcher, id, slide, size)) { - DBGLOG("nred", "Processed AMDRadeonX6000Framebuffer"); + DBGLOG("NRed", "Processed AMDRadeonX6000Framebuffer"); } else if (hwlibs.processKext(patcher, id, slide, size)) { - DBGLOG("nred", "Processed AMDRadeonX5000HWLibs"); + DBGLOG("NRed", "Processed AMDRadeonX5000HWLibs"); } else if (x6000.processKext(patcher, id, slide, size)) { - DBGLOG("nred", "Processed AMDRadeonX6000"); + DBGLOG("NRed", "Processed AMDRadeonX6000"); } else if (x5000.processKext(patcher, id, slide, size)) { - DBGLOG("nred", "Processed AMDRadeonX5000"); + DBGLOG("NRed", "Processed AMDRadeonX5000"); } } @@ -283,7 +283,7 @@ bool NRed::wrapApplePanelSetDisplay(IOService *that, IODisplay *display) { panels->setObject(entry.deviceName, pd); // No release required by current AppleBacklight implementation. } else { - SYSLOG("nred", "setDisplay: Cannot allocate data for %s", entry.deviceName); + SYSLOG("NRed", "setDisplay: Cannot allocate data for %s", entry.deviceName); } } that->setProperty("ApplePanels", panels); @@ -291,11 +291,11 @@ bool NRed::wrapApplePanelSetDisplay(IOService *that, IODisplay *display) { OSSafeReleaseNULL(rawPanels); } else { - SYSLOG("nred", "setDisplay: Missing ApplePanels property"); + SYSLOG("NRed", "setDisplay: Missing ApplePanels property"); } } bool ret = FunctionCast(wrapApplePanelSetDisplay, callback->orgApplePanelSetDisplay)(that, display); - DBGLOG("nred", "setDisplay >> %d", ret); + DBGLOG("NRed", "setDisplay >> %d", ret); return ret; } diff --git a/NootedRed/NRed.hpp b/NootedRed/NRed.hpp index 172da0da..d90df233 100644 --- a/NootedRed/NRed.hpp +++ b/NootedRed/NRed.hpp @@ -37,29 +37,29 @@ static bool checkAtomBios(const UInt8 *bios, size_t size) { UInt16 tmp, bios_header_start; if (size < 0x49) { - DBGLOG("nred", "VBIOS size is invalid"); + DBGLOG("NRed", "VBIOS size is invalid"); return false; } if (bios[0] != 0x55 || bios[1] != 0xAA) { - DBGLOG("nred", "VBIOS signature <%x %x> is invalid", bios[0], bios[1]); + DBGLOG("NRed", "VBIOS signature <%x %x> is invalid", bios[0], bios[1]); return false; } bios_header_start = bios[0x48] | (bios[0x49] << 8); if (!bios_header_start) { - DBGLOG("nred", "Unable to locate VBIOS header"); + DBGLOG("NRed", "Unable to locate VBIOS header"); return false; } tmp = bios_header_start + 4; if (size < tmp) { - DBGLOG("nred", "BIOS header is broken"); + DBGLOG("NRed", "BIOS header is broken"); return false; } if (!memcmp(bios + tmp, "ATOM", 4) || !memcmp(bios + tmp, "MOTA", 4)) { - DBGLOG("nred", "ATOMBIOS detected"); + DBGLOG("NRed", "ATOMBIOS detected"); return true; } @@ -84,43 +84,43 @@ class NRed { private: static const char *getChipName() { - PANIC_COND(callback->chipType == ChipType::Unknown, "nred", "Unknown chip type"); + PANIC_COND(callback->chipType == ChipType::Unknown, "NRed", "Unknown chip type"); static const char *chipNames[] = {"raven", "picasso", "raven2", "renoir", "green_sardine"}; return chipNames[static_cast(callback->chipType)]; } static const char *getGCPrefix() { - PANIC_COND(callback->chipType == ChipType::Unknown, "nred", "Unknown chip type"); + PANIC_COND(callback->chipType == ChipType::Unknown, "NRed", "Unknown chip type"); static const char *gcPrefixes[] = {"gc_9_1_", "gc_9_1_", "gc_9_2_", "gc_9_3_", "gc_9_3_"}; return gcPrefixes[static_cast(callback->chipType)]; } bool getVBIOSFromVFCT() { - DBGLOG("nred", "Fetching VBIOS from VFCT table"); + DBGLOG("NRed", "Fetching VBIOS from VFCT table"); auto *expert = reinterpret_cast(this->iGPU->getPlatform()); - PANIC_COND(!expert, "nred", "Failed to get AppleACPIPlatformExpert"); + PANIC_COND(!expert, "NRed", "Failed to get AppleACPIPlatformExpert"); auto *vfctData = expert->getACPITableData("VFCT", 0); if (!vfctData) { - DBGLOG("nred", "No VFCT from AppleACPIPlatformExpert"); + DBGLOG("NRed", "No VFCT from AppleACPIPlatformExpert"); return false; } auto *vfct = static_cast(vfctData->getBytesNoCopy()); - PANIC_COND(!vfct, "nred", "VFCT OSData::getBytesNoCopy returned null"); + PANIC_COND(!vfct, "NRed", "VFCT OSData::getBytesNoCopy returned null"); for (auto offset = vfct->vbiosImageOffset; offset < vfctData->getLength();) { auto *vHdr = static_cast(vfctData->getBytesNoCopy(offset, sizeof(GOPVideoBIOSHeader))); if (!vHdr) { - DBGLOG("nred", "VFCT header out of bounds"); + DBGLOG("NRed", "VFCT header out of bounds"); return false; } auto *vContent = static_cast( vfctData->getBytesNoCopy(offset + sizeof(GOPVideoBIOSHeader), vHdr->imageLength)); if (!vContent) { - DBGLOG("nred", "VFCT VBIOS image out of bounds"); + DBGLOG("NRed", "VFCT VBIOS image out of bounds"); return false; } @@ -128,11 +128,11 @@ class NRed { if (vHdr->deviceID == this->deviceId) { if (!checkAtomBios(vContent, vHdr->imageLength)) { - DBGLOG("nred", "VFCT VBIOS is not an ATOMBIOS"); + DBGLOG("NRed", "VFCT VBIOS is not an ATOMBIOS"); return false; } this->vbiosData = OSData::withBytes(vContent, vHdr->imageLength); - PANIC_COND(UNLIKELY(!this->vbiosData), "nred", "VFCT OSData::withBytes failed"); + PANIC_COND(UNLIKELY(!this->vbiosData), "NRed", "VFCT OSData::withBytes failed"); this->iGPU->setProperty("ATY,bin_image", this->vbiosData); return true; } @@ -145,19 +145,19 @@ class NRed { auto *bar0 = this->iGPU->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0, kIOInhibitCache | kIOMapAnywhere); if (!bar0 || !bar0->getLength()) { - DBGLOG("nred", "FB BAR not enabled"); + DBGLOG("NRed", "FB BAR not enabled"); OSSafeReleaseNULL(bar0); return false; } auto *fb = reinterpret_cast(bar0->getVirtualAddress()); UInt32 size = 256 * 1024; // ??? if (!checkAtomBios(fb, size)) { - DBGLOG("nred", "VRAM VBIOS is not an ATOMBIOS"); + DBGLOG("NRed", "VRAM VBIOS is not an ATOMBIOS"); bar0->release(); return false; } this->vbiosData = OSData::withBytes(fb, size); - PANIC_COND(UNLIKELY(!this->vbiosData), "nred", "VRAM OSData::withBytes failed"); + PANIC_COND(UNLIKELY(!this->vbiosData), "NRed", "VRAM OSData::withBytes failed"); this->iGPU->setProperty("ATY,bin_image", this->vbiosData); bar0->release(); return true; @@ -194,13 +194,13 @@ class NRed { return ret; }; - PANIC_COND(smuWaitForResp() != 1, "nred", "Msg issuing pre-check failed; SMU may be in an improper state"); + PANIC_COND(smuWaitForResp() != 1, "NRed", "Msg issuing pre-check failed; SMU may be in an improper state"); this->writeReg32(MP_BASE + mmMP1_SMN_C2PMSG_90, 0); this->writeReg32(MP_BASE + mmMP1_SMN_C2PMSG_82, param); this->writeReg32(MP_BASE + mmMP1_SMN_C2PMSG_66, msg); - PANIC_COND(smuWaitForResp() != 1, "nred", "No response from SMU"); + PANIC_COND(smuWaitForResp() != 1, "NRed", "No response from SMU"); return this->readReg32(MP_BASE + mmMP1_SMN_C2PMSG_82); } diff --git a/NootedRed/PatcherPlus.cpp b/NootedRed/PatcherPlus.cpp index cc265dad..cf01373a 100644 --- a/NootedRed/PatcherPlus.cpp +++ b/NootedRed/PatcherPlus.cpp @@ -4,14 +4,14 @@ #include "PatcherPlus.hpp" bool SolveRequestPlus::solve(KernelPatcher &patcher, size_t id, mach_vm_address_t address, size_t maxSize) { - PANIC_COND(!this->address, "patcher+", "this->address is null"); + PANIC_COND(!this->address, "Patcher+", "this->address is null"); *this->address = patcher.solveSymbol(id, this->symbol); if (*this->address) { return true; } patcher.clearError(); if (!this->pattern || !this->patternSize) { - DBGLOG("patcher+", "Failed to solve %s using symbol", safeString(this->symbol)); + DBGLOG("Patcher+", "Failed to solve %s using symbol", safeString(this->symbol)); return false; } @@ -19,7 +19,7 @@ bool SolveRequestPlus::solve(KernelPatcher &patcher, size_t id, mach_vm_address_ if (!KernelPatcher::findPattern(this->pattern, this->mask, this->patternSize, reinterpret_cast(address), maxSize, &offset) || !offset) { - DBGLOG("patcher+", "Failed to solve %s using pattern", safeString(this->symbol)); + DBGLOG("Patcher+", "Failed to solve %s using pattern", safeString(this->symbol)); return false; } @@ -40,7 +40,7 @@ bool RouteRequestPlus::route(KernelPatcher &patcher, size_t id, mach_vm_address_ patcher.clearError(); if (!this->pattern || !this->patternSize) { - DBGLOG("patcher+", "Failed to route %s using symbol", safeString(this->symbol)); + DBGLOG("Patcher+", "Failed to route %s using symbol", safeString(this->symbol)); return false; } @@ -48,13 +48,13 @@ bool RouteRequestPlus::route(KernelPatcher &patcher, size_t id, mach_vm_address_ if (!KernelPatcher::findPattern(this->pattern, this->mask, this->patternSize, reinterpret_cast(address), maxSize, &offset) || !offset) { - DBGLOG("patcher+", "Failed to route %s using pattern", safeString(this->symbol)); + DBGLOG("Patcher+", "Failed to route %s using pattern", safeString(this->symbol)); return false; } auto org = patcher.routeFunction(address + offset, this->to, true); if (!org) { - DBGLOG("patcher+", "Failed to route %s using pattern: %d", safeString(this->symbol), patcher.getError()); + DBGLOG("Patcher+", "Failed to route %s using pattern: %d", safeString(this->symbol), patcher.getError()); return false; } if (this->org) { *this->org = org; } @@ -84,9 +84,9 @@ bool LookupPatchPlus::applyAll(KernelPatcher &patcher, const LookupPatchPlus *pa mach_vm_address_t address, size_t maxSize) { for (size_t i = 0; i < count; i++) { if (patches[i].apply(patcher, address, maxSize)) { - DBGLOG("patcher+", "Applied patches[%zu]", i); + DBGLOG("Patcher+", "Applied patches[%zu]", i); } else { - DBGLOG("patcher+", "Failed to apply patches[%zu]", i); + DBGLOG("Patcher+", "Failed to apply patches[%zu]", i); return false; } } diff --git a/NootedRed/PluginStart.cpp b/NootedRed/PluginStart.cpp index 36d2b825..03f73e0c 100644 --- a/NootedRed/PluginStart.cpp +++ b/NootedRed/PluginStart.cpp @@ -40,29 +40,29 @@ bool PRODUCT_NAME::start(IOService *provider) { if (!ADDPR(startSuccess)) { return false; } if (!IOService::start(provider)) { - SYSLOG("init", "Failed to start the parent"); + SYSLOG("Init", "Failed to start the parent"); return false; } if (!(lilu.getRunMode() & LiluAPI::RunningInstallerRecovery)) { auto *prop = OSDynamicCast(OSArray, this->getProperty("Drivers")); if (!prop) { - SYSLOG("init", "Failed to get Drivers property"); + SYSLOG("Init", "Failed to get Drivers property"); return false; } auto *propCopy = prop->copyCollection(); if (!propCopy) { - SYSLOG("init", "Failed to copy Drivers property"); + SYSLOG("Init", "Failed to copy Drivers property"); return false; } auto *drivers = OSDynamicCast(OSArray, propCopy); if (!drivers) { - SYSLOG("init", "Failed to cast Drivers property"); + SYSLOG("Init", "Failed to cast Drivers property"); OSSafeReleaseNULL(propCopy); return false; } if (!gIOCatalogue->addDrivers(drivers)) { - SYSLOG("init", "Failed to add drivers"); + SYSLOG("Init", "Failed to add drivers"); OSSafeReleaseNULL(drivers); return false; } diff --git a/NootedRed/X5000.cpp b/NootedRed/X5000.cpp index e7d885ae..c04fabc1 100644 --- a/NootedRed/X5000.cpp +++ b/NootedRed/X5000.cpp @@ -45,7 +45,7 @@ bool X5000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli this->orgSetupAndInitializeHWCapabilities}, {"__ZN26AMDRadeonX5000_AMDHardware14startHWEnginesEv", startHWEngines}, }; - PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "x5000", + PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "X5000", "Failed to resolve symbols"); RouteRequestPlus requests[] = { @@ -66,7 +66,7 @@ bool X5000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {"__ZN30AMDRadeonX5000_AMDGFX9Hardware20writeASICHangLogInfoEPPv", wrapReturnZero}, {"__ZN4Addr2V27Gfx9Lib20HwlConvertChipFamilyEjj", wrapHwlConvertChipFamily, kHwlConvertChipFamilyPattern}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x5000", "Failed to route symbols"); + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X5000", "Failed to route symbols"); bool ventura = getKernelVersion() >= KernelVersion::Ventura; bool ventura1304 = (ventura && getKernelMinorVersion() >= 5) || getKernelVersion() > KernelVersion::Ventura; @@ -75,34 +75,34 @@ bool X5000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {"__ZN37AMDRadeonX5000_AMDGraphicsAccelerator9newSharedEv", wrapNewShared}, {"__ZN37AMDRadeonX5000_AMDGraphicsAccelerator19newSharedUserClientEv", wrapNewSharedUserClient}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x5000", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X5000", "Failed to route newShared routes"); if (ventura1304) { RouteRequestPlus request {"__ZN37AMDRadeonX5000_AMDGraphicsAccelerator23obtainAccelChannelGroupE11SS_" "PRIORITYP27AMDRadeonX5000_AMDAccelTask", wrapObtainAccelChannelGroup1304, this->orgObtainAccelChannelGroup}; - PANIC_COND(!request.route(patcher, id, slide, size), "x5000", + PANIC_COND(!request.route(patcher, id, slide, size), "X5000", "Failed to route obtainAccelChannelGroup"); } else { RouteRequestPlus request { "__ZN37AMDRadeonX5000_AMDGraphicsAccelerator23obtainAccelChannelGroupE11SS_PRIORITY", wrapObtainAccelChannelGroup, this->orgObtainAccelChannelGroup}; - PANIC_COND(!request.route(patcher, id, slide, size), "x5000", + PANIC_COND(!request.route(patcher, id, slide, size), "X5000", "Failed to route obtainAccelChannelGroup"); } } if (catalina || ventura1304) { const LookupPatchPlus patch {&kextRadeonX5000, kAddrLibCreateOriginal, kAddrLibCreatePatched, 1}; - PANIC_COND(!patch.apply(patcher, slide, size), "x5000", + PANIC_COND(!patch.apply(patcher, slide, size), "X5000", "Failed to apply Catalina & Ventura 13.4+ Addr::Lib::Create patch"); } if (catalina) { const LookupPatchPlus patch {&kextRadeonX5000, kCreateAccelChannelsOriginal, kCreateAccelChannelsPatched, 2}; - PANIC_COND(!patch.apply(patcher, slide, size), "x5000", "Failed to patch createAccelChannels"); + PANIC_COND(!patch.apply(patcher, slide, size), "X5000", "Failed to patch createAccelChannels"); auto dcn2 = NRed::callback->chipType >= ChipType::Renoir; UInt32 findNonBpp64 = 0x22222221; @@ -119,18 +119,18 @@ bool X5000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {&kextRadeonX5000, reinterpret_cast(&findBpp64Pt2), reinterpret_cast(&replBpp64Pt2), sizeof(UInt32), 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x5000", + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X5000", "Failed to patch swizzle mode"); - PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "x5000", + PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "X5000", "Failed to enable kernel writing"); *orgChannelTypes = 1; // Make VMPT use SDMA0 instead of SDMA1 MachInfo::setKernelWriting(false, KernelPatcher::kernelWriteLock); - DBGLOG("x5000", "Applied SDMA1 patches"); + DBGLOG("X5000", "Applied SDMA1 patches"); } else { const LookupPatchPlus patch {&kextRadeonX5000, kStartHWEnginesOriginal, kStartHWEnginesMask, kStartHWEnginesPatched, kStartHWEnginesMask, ventura ? 2U : 1}; - PANIC_COND(!patch.apply(patcher, startHWEngines, PAGE_SIZE), "x5000", "Failed to patch startHWEngines"); + PANIC_COND(!patch.apply(patcher, startHWEngines, PAGE_SIZE), "X5000", "Failed to patch startHWEngines"); if (NRed::callback->chipType >= ChipType::Renoir) { UInt32 findBpp64 = Dcn1Bpp64SwModeMask, replBpp64 = Dcn2Bpp64SwModeMask; @@ -141,17 +141,17 @@ bool X5000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {&kextRadeonX5000, reinterpret_cast(&findNonBpp64), reinterpret_cast(&replNonBpp64), sizeof(UInt32), ventura1304 ? 2U : 4}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x5000", + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X5000", "Failed to patch swizzle mode"); } - PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "x5000", + PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "X5000", "Failed to enable kernel writing"); orgChannelTypes[5] = 1; // Fix createAccelChannels so that it only starts SDMA0 orgChannelTypes[(getKernelVersion() >= KernelVersion::Monterey) ? 12 : 11] = 0; // Fix getPagingChannel so that it gets SDMA0 MachInfo::setKernelWriting(false, KernelPatcher::kernelWriteLock); - DBGLOG("x5000", "Applied SDMA1 patches"); + DBGLOG("X5000", "Applied SDMA1 patches"); } return true; diff --git a/NootedRed/X6000.cpp b/NootedRed/X6000.cpp index 45af9c7f..f9d32d1c 100644 --- a/NootedRed/X6000.cpp +++ b/NootedRed/X6000.cpp @@ -36,7 +36,7 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {"__ZN33AMDRadeonX6000_AMDHWAlignManager224getPreferredSwizzleMode2EP33_ADDR2_COMPUTE_SURFACE_INFO_INPUT", this->orgGetPreferredSwizzleMode2}, }; - PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "x6000", + PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "X6000", "Failed to resolve symbols"); RouteRequestPlus requests[] = { @@ -48,7 +48,7 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {"__ZN27AMDRadeonX6000_AMDHWDisplay14getDisplayInfoEjbbPvP17_FRAMEBUFFER_INFO", wrapGetDisplayInfo, this->orgGetDisplayInfo}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x6000", "Failed to route symbols"); + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000", "Failed to route symbols"); bool catalina = getKernelVersion() == KernelVersion::Catalina; if (!catalina) { @@ -56,7 +56,7 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {"__ZN37AMDRadeonX6000_AMDGraphicsAccelerator9newSharedEv", this->orgNewShared}, {"__ZN37AMDRadeonX6000_AMDGraphicsAccelerator19newSharedUserClientEv", this->orgNewSharedUserClient}, }; - PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "x6000", + PANIC_COND(!SolveRequestPlus::solveAll(patcher, id, solveRequests, slide, size), "X6000", "Failed to resolve newShared symbols"); RouteRequestPlus requests[] = { @@ -65,21 +65,21 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {"__ZN29AMDRadeonX6000_AMDAccelShared11SurfaceCopyEPjyP12IOAccelEvent", wrapAccelSharedSurfaceCopy, this->orgAccelSharedSurfaceCopy}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x6000", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000", "Failed to route AccelShared symbols"); } if (NRed::callback->chipType < ChipType::Renoir) { RouteRequestPlus request = {"__ZN30AMDRadeonX6000_AMDGFX10Display23initDCNRegistersOffsetsEv", wrapInitDCNRegistersOffsets, this->orgInitDCNRegistersOffsets}; - PANIC_COND(!request.route(patcher, id, slide, size), "x6000", "Failed to route initDCNRegistersOffsets"); + PANIC_COND(!request.route(patcher, id, slide, size), "X6000", "Failed to route initDCNRegistersOffsets"); } auto ventura = getKernelVersion() >= KernelVersion::Ventura; if (!ventura) { RouteRequestPlus request {"__ZN27AMDRadeonX6000_AMDHWDisplay17allocateScanoutFBEjP16IOAccelResource2S1_Py", wrapAllocateScanoutFB, this->orgAllocateScanoutFB}; - PANIC_COND(!request.route(patcher, id, slide, size), "x6000", "Failed to route allocateScanout"); + PANIC_COND(!request.route(patcher, id, slide, size), "X6000", "Failed to route allocateScanout"); } if (catalina) { @@ -88,12 +88,12 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli kHWChannelSubmitCommandBufferCatalinaPatched, 1}, {&kextRadeonX6000, kDummyWPTRUpdateDiagCallOriginal, kDummyWPTRUpdateDiagCallPatched, 1}, }; - SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000", "Failed to apply patches"); + SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000", "Failed to apply patches"); patcher.clearError(); } else { const LookupPatchPlus patch {&kextRadeonX6000, kHWChannelSubmitCommandBufferOriginal, kHWChannelSubmitCommandBufferPatched, 1}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "x6000", "Failed to apply submitCommandBuffer patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "X6000", "Failed to apply submitCommandBuffer patch"); patcher.clearError(); } @@ -109,7 +109,7 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli ventura ? 3 : 1}, }; - SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000", "Failed to apply patches"); + SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000", "Failed to apply patches"); patcher.clearError(); if (catalina) { @@ -149,19 +149,19 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {&kextRadeonX6000, kDumpASICHangStateCallOriginal, kDumpASICHangStateCallPatched, 2}, {&kextRadeonX6000, kGetSchedulerCallCatalinaOriginal, kGetSchedulerCallCatalinaPatched, 22}, }; - SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000", "Failed to apply patches"); + SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000", "Failed to apply patches"); patcher.clearError(); } if (ventura) { const LookupPatchPlus patch {&kextRadeonX6000, kGetSchedulerCallVenturaOriginal, kGetSchedulerCallVenturaPatched, 24}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "x6000", "Failed to apply getScheduler patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "X6000", "Failed to apply getScheduler patch"); patcher.clearError(); } else if (!catalina) { const LookupPatchPlus patch {&kextRadeonX6000, kGetSchedulerCallOriginal, kGetSchedulerCallPatched, monterey ? 21U : 22}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "x6000", "Failed to apply getScheduler patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "X6000", "Failed to apply getScheduler patch"); patcher.clearError(); } @@ -176,7 +176,7 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli {&kextRadeonX6000, kGetUbmSwizzleModeCallOriginal, kGetUbmSwizzleModeCallPatched, 1}, {&kextRadeonX6000, kGetUbmTileModeCallOriginal, kGetUbmTileModeCallPatched, 1}, }; - SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000", "Failed to apply patches"); + SYSLOG_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000", "Failed to apply patches"); patcher.clearError(); } else { const LookupPatchPlus patch {&kextRadeonX6000, kGetGpuDebugPolicyCallOriginal, @@ -184,7 +184,7 @@ bool X6000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli (getKernelVersion() == KernelVersion::Ventura && getKernelMinorVersion() >= 5) ? 38U : ventura ? 37 : 28}; - SYSLOG_COND(!patch.apply(patcher, slide, size), "x6000", "Failed to apply getGpuDebugPolicy patch"); + SYSLOG_COND(!patch.apply(patcher, slide, size), "X6000", "Failed to apply getGpuDebugPolicy patch"); patcher.clearError(); } diff --git a/NootedRed/X6000FB.cpp b/NootedRed/X6000FB.cpp index 5b3a0816..0d1ba80f 100644 --- a/NootedRed/X6000FB.cpp +++ b/NootedRed/X6000FB.cpp @@ -25,13 +25,13 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s CAILAsicCapsEntry *orgAsicCapsTable = nullptr; SolveRequestPlus solveRequest {"__ZL20CAIL_ASIC_CAPS_TABLE", orgAsicCapsTable, kCailAsicCapsTablePattern}; - PANIC_COND(!solveRequest.solve(patcher, id, slide, size), "x6000fb", "Failed to resolve CAIL_ASIC_CAPS_TABLE"); + PANIC_COND(!solveRequest.solve(patcher, id, slide, size), "X6000FB", "Failed to resolve CAIL_ASIC_CAPS_TABLE"); bool catalina = getKernelVersion() == KernelVersion::Catalina; if (!catalina) { SolveRequestPlus solveRequest {"_dce_driver_set_backlight", this->orgDceDriverSetBacklight, kDceDriverSetBacklight}; - PANIC_COND(!solveRequest.solve(patcher, id, slide, size), "x6000fb", + PANIC_COND(!solveRequest.solve(patcher, id, slide, size), "X6000FB", "Failed to resolve dce_driver_set_backlight"); } @@ -40,7 +40,7 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s SolveRequestPlus solveRequest { "__ZNK34AMDRadeonX6000_AmdRadeonController18messageAcceleratorE25_eAMDAccelIOFBRequestTypePvS1_S1_", this->orgMessageAccelerator}; - PANIC_COND(!solveRequest.solve(patcher, id, slide, size), "x6000fb", + PANIC_COND(!solveRequest.solve(patcher, id, slide, size), "X6000FB", "Failed to resolve messageAccelerator"); } @@ -51,7 +51,7 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s {"__ZNK22AmdAtomObjectInfo_V1_421getNumberOfConnectorsEv", wrapGetNumberOfConnectors, this->orgGetNumberOfConnectors, kGetNumberOfConnectorsPattern, kGetNumberOfConnectorsMask}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x6000fb", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000FB", "Failed to route symbols"); if (ADDPR(debugEnabled)) { @@ -60,13 +60,13 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s this->orgInitWithPciInfo}, {"__ZN34AMDRadeonX6000_AmdRadeonController10doGPUPanicEPKcz", wrapDoGPUPanic}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x6000fb", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000FB", "Failed to route debug symbols"); } if (checkKernelArgument("-nreddmlogger")) { RouteRequestPlus request {"_dm_logger_write", wrapDmLoggerWrite, kDmLoggerWritePattern}; - PANIC_COND(!request.route(patcher, id, slide, size), "x6000fb", "Failed to route dm_logger_write"); + PANIC_COND(!request.route(patcher, id, slide, size), "X6000FB", "Failed to route dm_logger_write"); } bool renoir = NRed::callback->chipType >= ChipType::Renoir; @@ -77,14 +77,14 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s {"_IRQMGR_WriteRegister", wrapIRQMGRWriteRegister, this->orgIRQMGRWriteRegister, kIRQMGRWriteRegisterPattern}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x6000fb", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000FB", "Failed to route IH symbols"); } if (ventura) { RouteRequestPlus request {"__ZN34AMDRadeonX6000_AmdRadeonController7powerUpEv", wrapControllerPowerUp, this->orgControllerPowerUp}; - PANIC_COND(!request.route(patcher, id, slide, size), "x6000fb", "Failed to route powerUp"); + PANIC_COND(!request.route(patcher, id, slide, size), "X6000FB", "Failed to route powerUp"); } if (!catalina) { @@ -96,7 +96,7 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s {"__ZN35AMDRadeonX6000_AmdRadeonFramebuffer25getAttributeForConnectionEijPm", wrapFramebufferGetAttribute, this->orgFramebufferGetAttribute}, }; - PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "x6000fb", + PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000FB", "Failed to route backlight symbols"); } @@ -108,19 +108,19 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s {&kextRadeonX6000Framebuffer, kAgdcServicesGetVendorInfoOriginal, kAgdcServicesGetVendorInfoMask, kAgdcServicesGetVendorInfoPatched, kAgdcServicesGetVendorInfoMask, 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000fb", "Failed to apply patches"); + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000FB", "Failed to apply patches"); if (catalina) { const LookupPatchPlus patch {&kextRadeonX6000Framebuffer, kAmdAtomVramInfoNullCheckCatalinaOriginal, kAmdAtomVramInfoNullCheckCatalinaMask, kAmdAtomVramInfoNullCheckCatalinaPatched, 1}; - PANIC_COND(!patch.apply(patcher, slide, size), "x6000fb", "Failed to apply null check patch"); + PANIC_COND(!patch.apply(patcher, slide, size), "X6000FB", "Failed to apply null check patch"); } else { const LookupPatchPlus patches[] = { {&kextRadeonX6000Framebuffer, kAmdAtomVramInfoNullCheckOriginal, kAmdAtomVramInfoNullCheckPatched, 1}, {&kextRadeonX6000Framebuffer, kAmdAtomPspDirectoryNullCheckOriginal, kAmdAtomPspDirectoryNullCheckPatched, 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000fb", + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000FB", "Failed to apply null check patches"); } @@ -130,7 +130,7 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s kControllerPowerUpReplace, kControllerPowerUpReplaceMask, 1}, {&kextRadeonX6000Framebuffer, kValidateDetailedTimingOriginal, kValidateDetailedTimingPatched, 1}, }; - PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "x6000fb", + PANIC_COND(!LookupPatchPlus::applyAll(patcher, patches, slide, size), "X6000FB", "Failed to apply logic revert patches"); } @@ -145,7 +145,7 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s .pciRevision = NRed::callback->pciRevision, }; MachInfo::setKernelWriting(false, KernelPatcher::kernelWriteLock); - DBGLOG("x6000fb", "Applied DDI Caps patches"); + DBGLOG("X6000FB", "Applied DDI Caps patches"); return true; } @@ -160,7 +160,7 @@ IOReturn X6000FB::wrapPopulateVramInfo(void *, void *fwInfo) { auto *table = NRed::callback->getVBIOSDataTable(0x1E); UInt8 memoryType = 0; if (table) { - DBGLOG("x6000fb", "Fetching VRAM info from iGPU System Info"); + DBGLOG("X6000FB", "Fetching VRAM info from iGPU System Info"); switch (table->header.formatRev) { case 1: switch (table->header.contentRev) { @@ -171,7 +171,7 @@ IOReturn X6000FB::wrapPopulateVramInfo(void *, void *fwInfo) { memoryType = table->infoV11.memoryType; break; default: - DBGLOG("x6000fb", "Unsupported contentRev %d", table->header.contentRev); + DBGLOG("X6000FB", "Unsupported contentRev %d", table->header.contentRev); break; } break; @@ -184,16 +184,16 @@ IOReturn X6000FB::wrapPopulateVramInfo(void *, void *fwInfo) { memoryType = table->infoV2.memoryType; break; default: - DBGLOG("x6000fb", "Unsupported contentRev %d", table->header.contentRev); + DBGLOG("X6000FB", "Unsupported contentRev %d", table->header.contentRev); break; } break; default: - DBGLOG("x6000fb", "Unsupported formatRev %d", table->header.formatRev); + DBGLOG("X6000FB", "Unsupported formatRev %d", table->header.formatRev); break; } } else { - DBGLOG("x6000fb", "No iGPU System Info in Master Data Table"); + DBGLOG("X6000FB", "No iGPU System Info in Master Data Table"); } auto &videoMemoryType = getMember(fwInfo, 0x1C); switch (memoryType) { @@ -219,7 +219,7 @@ IOReturn X6000FB::wrapPopulateVramInfo(void *, void *fwInfo) { videoMemoryType = kVideoMemoryTypeDDR4; break; default: - DBGLOG("x6000fb", "Unsupported memory type %d. Assuming DDR4", memoryType); + DBGLOG("X6000FB", "Unsupported memory type %d. Assuming DDR4", memoryType); videoMemoryType = kVideoMemoryTypeDDR4; break; } @@ -238,24 +238,24 @@ bool X6000FB::wrapInitWithPciInfo(void *that, void *param1) { bool X6000FB::OnAppleBacklightDisplayLoad(void *, void *, IOService *newService, IONotifier *) { OSDictionary *params = OSDynamicCast(OSDictionary, newService->getProperty("IODisplayParameters")); if (!params) { - DBGLOG("x6000fb", "OnAppleBacklightDisplayLoad: No 'IODisplayParameters' property"); + DBGLOG("X6000FB", "OnAppleBacklightDisplayLoad: No 'IODisplayParameters' property"); return false; } OSDictionary *linearBrightness = OSDynamicCast(OSDictionary, params->getObject("linear-brightness")); if (!linearBrightness) { - DBGLOG("x6000fb", "OnAppleBacklightDisplayLoad: No 'linear-brightness' property"); + DBGLOG("X6000FB", "OnAppleBacklightDisplayLoad: No 'linear-brightness' property"); return false; } OSNumber *maxBrightness = OSDynamicCast(OSNumber, linearBrightness->getObject("max")); if (!maxBrightness) { - DBGLOG("x6000fb", "OnAppleBacklightDisplayLoad: No 'max' property"); + DBGLOG("X6000FB", "OnAppleBacklightDisplayLoad: No 'max' property"); return false; } callback->maxPwmBacklightLvl = maxBrightness->unsigned32BitValue(); - DBGLOG("x6000fb", "OnAppleBacklightDisplayLoad: Max brightness: 0x%X", callback->maxPwmBacklightLvl); + DBGLOG("X6000FB", "OnAppleBacklightDisplayLoad: Max brightness: 0x%X", callback->maxPwmBacklightLvl); return true; } @@ -265,18 +265,18 @@ void X6000FB::registerDispMaxBrightnessNotif() { auto *matching = IOService::serviceMatching("AppleBacklightDisplay"); if (!matching) { - SYSLOG("x6000fb", "registerDispMaxBrightnessNotif: Failed to create match dictionary"); + SYSLOG("X6000FB", "registerDispMaxBrightnessNotif: Failed to create match dictionary"); return; } callback->dispNotif = IOService::addMatchingNotification(gIOFirstMatchNotification, matching, OnAppleBacklightDisplayLoad, nullptr); - SYSLOG_COND(!callback->dispNotif, "x6000fb", "registerDispMaxBrightnessNotif: Failed to register notification"); + SYSLOG_COND(!callback->dispNotif, "X6000FB", "registerDispMaxBrightnessNotif: Failed to register notification"); matching->release(); } void X6000FB::wrapDoGPUPanic() { - DBGLOG("x6000fb", "doGPUPanic << ()"); + DBGLOG("X6000FB", "doGPUPanic << ()"); while (true) { IOSleep(3600000); } } @@ -292,17 +292,17 @@ IOReturn X6000FB::wrapFramebufferSetAttribute(IOService *framebuffer, IOIndex co if (attribute != static_cast('bklt')) { return ret; } if (!callback->maxPwmBacklightLvl) { - DBGLOG("x6000fb", "wrapFramebufferSetAttribute: maxPwmBacklightLvl is 0"); + DBGLOG("X6000FB", "wrapFramebufferSetAttribute: maxPwmBacklightLvl is 0"); return kIOReturnSuccess; } if (!callback->panelCntlPtr) { - DBGLOG("x6000fb", "wrapFramebufferSetAttribute: panelCntl is null"); + DBGLOG("X6000FB", "wrapFramebufferSetAttribute: panelCntl is null"); return kIOReturnSuccess; } if (!callback->orgDceDriverSetBacklight) { - DBGLOG("x6000fb", "wrapFramebufferSetAttribute: orgDceDriverSetBacklight is null"); + DBGLOG("X6000FB", "wrapFramebufferSetAttribute: orgDceDriverSetBacklight is null"); return kIOReturnSuccess; } @@ -333,7 +333,6 @@ IOReturn X6000FB::wrapFramebufferGetAttribute(IOService *framebuffer, IOIndex co auto ret = FunctionCast(wrapFramebufferGetAttribute, callback->orgFramebufferGetAttribute)(framebuffer, connectIndex, attribute, value); if (attribute == static_cast('bklt')) { - // Enable the backlight feature of AMD navi10 driver *value = callback->curPwmBacklightLvl; return kIOReturnSuccess; } @@ -346,7 +345,7 @@ UInt32 X6000FB::wrapGetNumberOfConnectors(void *that) { once = true; struct DispObjInfoTableV1_4 *objInfo = getMember(that, 0x28); if (objInfo->formatRev == 1 && (objInfo->contentRev == 4 || objInfo->contentRev == 5)) { - DBGLOG("nred", "Fixing VBIOS connectors"); + DBGLOG("X6000FB", "Fixing VBIOS connectors"); auto n = objInfo->pathCount; for (size_t i = 0, j = 0; i < n; i++) { // Skip invalid device tags @@ -387,7 +386,7 @@ void X6000FB::wrapIRQMGRWriteRegister(void *ctx, UInt64 index, UInt32 value) { if (index == mmIH_CLK_CTRL) { value |= (value & (1U << mmIH_DBUS_MUX_CLK_SOFT_OVERRIDE_SHIFT)) >> (mmIH_DBUS_MUX_CLK_SOFT_OVERRIDE_SHIFT - mmIH_IH_BUFFER_MEM_CLK_SOFT_OVERRIDE_SHIFT); - DBGLOG("x6000fb", "_IRQMGR_WriteRegister: Set IH_BUFFER_MEM_CLK_SOFT_OVERRIDE"); + DBGLOG("X6000FB", "_IRQMGR_WriteRegister: Set IH_BUFFER_MEM_CLK_SOFT_OVERRIDE"); } FunctionCast(wrapIRQMGRWriteRegister, callback->orgIRQMGRWriteRegister)(ctx, index, value); }