Skip to content

Commit

Permalink
feat: add patch to enable accel traces
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualEhrmanntraut committed Oct 23, 2024
1 parent 41ee3f1 commit 4f01b06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions NootedRed/X5000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ bool X5000::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t sli
};
PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X5000", "Failed to route symbols");

if (ADDPR(debugEnabled)) {
RouteRequestPlus request = {"__ZN37AMDRadeonX5000_AMDGraphicsAccelerator18getNumericPropertyEPKcPj",
wrapGetNumericProperty, this->orgGetNumericProperty};
PANIC_COND(!request.route(patcher, id, slide, size), "X5000", "Failed to route getNumericProperty");
}

if (NRed::callback->attributes.isVentura1304AndLater()) {
RouteRequestPlus request {"__ZN37AMDRadeonX5000_AMDGraphicsAccelerator23obtainAccelChannelGroupE11SS_"
"PRIORITYP27AMDRadeonX5000_AMDAccelTask",
Expand Down Expand Up @@ -350,3 +356,17 @@ UInt32 X5000::wrapHwlConvertChipFamily(void *that, UInt32 family, UInt32 revisio
}
return FunctionCast(wrapHwlConvertChipFamily, callback->orgHwlConvertChipFamily)(that, family, revision);
}

bool X5000::wrapGetNumericProperty(void *that, const char *name, uint32_t *value) {
DBGLOG("X5000", "getNumericProperty << (that: %p name: %s, value: %p)", that, name, value);
auto ret = FunctionCast(wrapGetNumericProperty, callback->orgGetNumericProperty)(that, name, value);
if (name != nullptr && value != nullptr && strncmp(name, "GpuDebugPolicy", 15) == 0) {
if (ret) { // Enable entry traces
*value |= (1U << 6);
} else {
*value = (1U << 6);
}
return true;
}
return ret;
}
2 changes: 2 additions & 0 deletions NootedRed/X5000.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class X5000 {
mach_vm_address_t orgAllocateAMDHWAlignManager {0};
mach_vm_address_t orgObtainAccelChannelGroup {0};
mach_vm_address_t orgHwlConvertChipFamily {0};
mach_vm_address_t orgGetNumericProperty {0};

static bool wrapAllocateHWEngines(void *that);
static void wrapSetupAndInitializeHWCapabilities(void *that);
Expand All @@ -67,6 +68,7 @@ class X5000 {
static void *wrapObtainAccelChannelGroup(void *that, UInt32 priority);
static void *wrapObtainAccelChannelGroup1304(void *that, UInt32 priority, void *task);
static UInt32 wrapHwlConvertChipFamily(void *that, UInt32 family, UInt32 revision);
static bool wrapGetNumericProperty(void *that, const char *name, uint32_t *value);
};

//------ Patterns ------//
Expand Down

0 comments on commit 4f01b06

Please sign in to comment.