Last active
October 6, 2020 04:07
-
-
Save John-K/8cae1523dc1e29c3293752496a3bf59a to your computer and use it in GitHub Desktop.
me_wrapper.prx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// func_00002070 | |
// sceMeWrapper_driver_0x24317CD0 | |
int module_start(void) { | |
int tachyonVersion; | |
float pllFreq; | |
undefined4 local_20; | |
int local_1c; | |
initMEAtomicsAndInterruptHandler(); | |
sceLfatfsWaitReady(); | |
sceMeBootStart660(2); | |
pllFreq = (float)sceSysregPllGetFrequency(); | |
_DAT_bfc00710 = (int)pllFreq; | |
sceKernelRegisterSysEventHandler(); | |
sceMePowerControlAvcPower(0); | |
tachyonVersion = sceSysregGetTachyonVersion(); | |
if (0x4fffff < tachyonVersion) { | |
local_20 = 0x10; | |
tachyonVersion = sceKernelQueryMemoryPartitionInfo(4,&local_20); | |
if ((tachyonVersion < 0) || (local_1c != -0x77d00000)) { | |
sceKernelAllocPartitionMemory(1,"old ME partition",2,0x100000,0x88300000); | |
} | |
} | |
return 0; | |
} | |
// func_000014e0 | |
void * initMEAtomicsAndInterruptHandler(void) { | |
void *pvVar1; | |
pvVar1 = (void *)sceKernelCreateMutex("SceMediaEngineRpc",0x101,0,0); | |
SceMediaEngineRpc_Mutex = pvVar1; | |
if (-1 < (int)pvVar1) { | |
pvVar1 = (void *)sceKernelCreateSema("SceMediaEngineAvcPower",0x101,1,1,0); | |
SceMediaEngineAvcPower_Sema = pvVar1; | |
if (-1 < (int)pvVar1) { | |
pvVar1 = (void *)sceKernelCreateEventFlag("SceMediaEngineRpcWait",0x201,0,0); | |
SceMediaEngineRpcWait_Flag = pvVar1; | |
if (-1 < (int)pvVar1) { | |
sceSysregIntrEnd(); | |
pvVar1 = (void *)sceKernelRegisterIntrHandler | |
(0x1f,2,RpcWaitIntrHandler,SceMediaEngineRpcWait_Flag,(void *)0x0 | |
); | |
if (-1 < (int)pvVar1) { | |
pvVar1 = (void *)sceKernelEnableIntr(0x1f); | |
} | |
} | |
} | |
} | |
return pvVar1; | |
} | |
// func_00001acc | |
int RpcWaitIntrHandler(void *unk,SceUID flag) { | |
sceKernelSetEventFlag(flag,1); | |
return -1; | |
} | |
// func_00001d6c | |
int sceMeBootStart660(int param_1) { | |
SceUID fd; | |
int iVar1; | |
int iVar2; | |
char *file; | |
u32 offset; | |
uint local_s6_336; | |
SceOff SVar3; | |
iVar2 = -0x7ffffefe; | |
if (param_1 - 1U < 4) { | |
iVar2 = sceSysregGetTachyonVersion(); | |
if ((0x4fffff < iVar2) && (param_1 != 2)) { | |
param_1 = 3; | |
} | |
iVar2 = 0; | |
if ((DAT_0000004c != param_1) && (iVar2 = FUN_0000172c(), -1 < iVar2)) { | |
if (((param_1 != 3) || (DAT_0000004c != 2)) && ((param_1 != 2 || (DAT_0000004c != 3)))) { | |
iVar2 = sceSysregGetTachyonVersion(); | |
file = "flash0:/kd/resource/me_t2img.img"; //load this file on Slim models or later | |
if ((iVar2 < 0x500000) && // Tachyon 0x500000 is Slim, so load one of the following on Fat PSPs | |
((file = "flash0:/kd/resource/me_sdimg.img", param_1 != 1 && | |
(file = "flash0:/kd/resource/me_blimg.img", param_1 != 4)))) { | |
file = "flash0:/kd/resource/meimg.img"; | |
} | |
offset = 0x4000001; | |
fd = sceIoOpen(file,0x4000001,0); | |
if (fd < 0) { | |
unlockRPCMutex(); | |
return fd; | |
} | |
SVar3 = sceIoLseek(fd,offset,0); | |
iVar2 = (int)((ulonglong)SVar3 >> 0x20); | |
sceIoLseek(fd,offset,0); | |
if (0x63fff < iVar2) { | |
sceIoClose(fd); | |
unlockRPCMutex(); | |
return 0x80000022; | |
} | |
sceSysregMeResetEnable(); | |
local_s6_336 = 0x883ff000 - iVar2; | |
iVar1 = sceIoRead(fd,local_s6_336,iVar2); | |
sceIoClose(fd); | |
if (iVar1 != iVar2) { | |
unlockRPCMutex(); | |
if (-1 < iVar1) { | |
return 0x80000022; | |
} | |
return iVar1; | |
} | |
maybeDecryptDecompressMEFW(local_s6_336,iVar1); | |
bootME(local_s6_336,1); | |
} | |
DAT_0000004c = param_1; | |
unlockRPCMutex(); | |
sceMeRequest(0x185,(uint)(param_1 != 2)); | |
iVar2 = 0; | |
} | |
} | |
return iVar2; | |
} | |
// func_00001754 | |
void unlockRPCMutex(void) { | |
sceKernelUnlockMutex(SceMediaEngineRpc_Mutex,1); | |
return; | |
} | |
// func_00001c04 | |
u32 maybeDecryptDecompressMEFW(void *param_1,u32 param_2) { | |
u32 uVar1; | |
u32 local_20 [4]; | |
uVar1 = sceWmd_driver_0x7A0E484C(param_1,param_2,local_20); | |
if ((int)uVar1 < 0) { | |
local_20[0] = uVar1; | |
} | |
return local_20[0]; | |
} | |
// func_00001c30 | |
int bootME(uint param_1,int param_2) { | |
sceSysregMeResetEnable(); | |
sceSysregMeBusClockEnable(); | |
memcpy(0xbfc00040,0,0xd4); | |
_DAT_bfc00060 = _DAT_bfc00060 | _DAT_bc100040 & 3; | |
_DAT_bfc00064 = _DAT_bfc00064 | param_1 >> 0x10; | |
_DAT_bfc00068 = _DAT_bfc00068 | param_1 & 0xffff; | |
sceKernelDcacheWritebackInvalidateAll(); | |
sceDdrFlush(4); | |
if (param_2 != 0) { | |
_DAT_bfc0070c = 0x1ff01ff; | |
_DAT_bfc00714 = 2; | |
} | |
_DAT_bfc00700 = -3; | |
sceSysregVmeResetDisable(); | |
sceSysregMeResetDisable(); | |
if (param_2 != 0) { | |
while (_DAT_bfc00700 == -3) { | |
sceKernelDelayThread(1000); | |
} | |
} | |
_DAT_bfc00700 = 0; | |
sceSysregAvcResetDisable(); | |
sceDdrFlush(8); | |
return 0; | |
} | |
// func_00001778 | |
int sceMeRequest(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4, | |
undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8, | |
undefined4 param_9) { | |
int iVar1; | |
iVar1 = sceKernelLockMutex(SceMediaEngineRpc_Mutex,1,0); | |
if (-1 < iVar1) { | |
_DAT_bfc00624 = param_9; | |
_DAT_bfc00600 = param_1; | |
_DAT_bfc00608 = param_2; | |
_DAT_bfc0060c = param_3; | |
_DAT_bfc00610 = param_4; | |
_DAT_bfc00614 = param_5; | |
_DAT_bfc00618 = param_6; | |
_DAT_bfc0061c = param_7; | |
_DAT_bfc00620 = param_8; | |
sceDdrFlush(5); | |
sceSysregInterruptToOther(); | |
sceKernelWaitEventFlag(SceMediaEngineRpcWait_Flag,1,0x20,(u32 *)0x0,(SceUInt *)0x0); | |
iVar1 = _DAT_bfc00628; | |
sceKernelUnlockMutex(SceMediaEngineRpc_Mutex,1); | |
} | |
return iVar1; | |
} | |
// func_00001890 | |
void sceMeRequestWithDcacheInvalidate | |
(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4, | |
undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8, | |
undefined4 param_9) { | |
sceKernelDcacheWritebackInvalidateAll(); | |
sceMeRequest(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment