Skip to content

Commit

Permalink
fix: Fix register offsets for AmdRegisterAccess::readRom
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualEhrmanntraut committed Oct 22, 2024
1 parent 83f377c commit 54f1891
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions NootedRed/AMDCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ constexpr UInt32 AMDGPU_MAX_USEC_TIMEOUT = 100000;

constexpr UInt32 MP_BASE = 0x16000;
constexpr UInt32 MP1_Public = 0x3B00000;
constexpr UInt32 SMUIO_BASE = 0x16800;

//-------- Generic Registers --------//

Expand Down Expand Up @@ -226,6 +227,11 @@ constexpr UInt32 mmIH_DBUS_MUX_CLK_SOFT_OVERRIDE_SHIFT = 0x1B;
constexpr UInt32 mmIH_CHICKEN = 0x122C;
constexpr UInt32 mmIH_MC_SPACE_GPA_ENABLE = 0x10;

//-------- SMUIO Registers --------//

constexpr UInt32 mmROM_INDEX = 0x28;
constexpr UInt32 mmROM_DATA = 0x29;

//-------- AMD Catalyst Data Types --------//

struct CAILAsicCapsEntry {
Expand Down
8 changes: 8 additions & 0 deletions NootedRed/X6000FB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ bool X6000FB::processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t s
{"__ZNK32AMDRadeonX6000_AmdAsicInfoNavi1027getEnumeratedRevisionNumberEv", wrapGetEnumeratedRevision},
{"__ZNK22AmdAtomObjectInfo_V1_421getNumberOfConnectorsEv", wrapGetNumberOfConnectors,
this->orgGetNumberOfConnectors, kGetNumberOfConnectorsPattern, kGetNumberOfConnectorsMask},
{"__ZN32AMDRadeonX6000_AmdRegisterAccess20createRegisterAccessERNS_8InitDataE", wrapCreateRegisterAccess,
this->orgCreateRegisterAccess},
};
PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "X6000FB",
"Failed to route symbols");
Expand Down Expand Up @@ -600,3 +602,9 @@ void X6000FB::wrapDmLoggerWrite(void *, const UInt32 logType, const char *fmt, .
}
IOFree(message, 0x1000);
}

void *X6000FB::wrapCreateRegisterAccess(void *initData) {
getMember<UInt32>(initData, 0x24) = SMUIO_BASE + mmROM_INDEX;
getMember<UInt32>(initData, 0x28) = SMUIO_BASE + mmROM_DATA;
return FunctionCast(wrapCreateRegisterAccess, callback->orgCreateRegisterAccess)(initData);
}
2 changes: 2 additions & 0 deletions NootedRed/X6000FB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class X6000FB {
t_DcLinkSetBacklightLevel orgDcLinkSetBacklightLevel {0};
t_DcLinkSetBacklightLevelNits orgDcLinkSetBacklightLevelNits {0};
mach_vm_address_t orgInitWithPciInfo {0};
mach_vm_address_t orgCreateRegisterAccess {0};

static bool OnAppleBacklightDisplayLoad(void *target, void *refCon, IOService *newService, IONotifier *notifier);
void registerDispMaxBrightnessNotif();
Expand All @@ -67,6 +68,7 @@ class X6000FB {
static bool wrapInitWithPciInfo(void *that, void *pciDevice);
static void wrapDoGPUPanic(void *that, char const *fmt, ...);
static void wrapDmLoggerWrite(void *logger, const UInt32 logType, const char *fmt, ...);
static void *wrapCreateRegisterAccess(void *initData);
};

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

0 comments on commit 54f1891

Please sign in to comment.