mirror of
https://github.com/LumaTeam/Luma3DS.git
synced 2026-02-22 01:44:38 +00:00
plgloader: Code cleanup
This commit is contained in:
parent
db639a80c9
commit
c04c7254ed
@ -20,9 +20,6 @@ static const char *g_title = "Plugin loader";
|
|||||||
PluginLoaderContext PluginLoaderCtx;
|
PluginLoaderContext PluginLoaderCtx;
|
||||||
extern u32 g_blockMenuOpen;
|
extern u32 g_blockMenuOpen;
|
||||||
|
|
||||||
void IR__Patch(void);
|
|
||||||
void IR__Unpatch(void);
|
|
||||||
|
|
||||||
void PluginLoader__Init(void)
|
void PluginLoader__Init(void)
|
||||||
{
|
{
|
||||||
PluginLoaderContext *ctx = &PluginLoaderCtx;
|
PluginLoaderContext *ctx = &PluginLoaderCtx;
|
||||||
@ -96,7 +93,7 @@ void PluginLoader__UpdateMenu(void)
|
|||||||
static ControlApplicationMemoryModeOverrideConfig g_memorymodeoverridebackup = { 0 };
|
static ControlApplicationMemoryModeOverrideConfig g_memorymodeoverridebackup = { 0 };
|
||||||
Result PluginLoader__SetMode3AppMode(bool enable)
|
Result PluginLoader__SetMode3AppMode(bool enable)
|
||||||
{
|
{
|
||||||
Handle loaderHandle;
|
Handle loaderHandle;
|
||||||
Result res = srvGetServiceHandle(&loaderHandle, "Loader");
|
Result res = srvGetServiceHandle(&loaderHandle, "Loader");
|
||||||
|
|
||||||
if (R_FAILED(res)) return res;
|
if (R_FAILED(res)) return res;
|
||||||
@ -105,7 +102,7 @@ Result PluginLoader__SetMode3AppMode(bool enable)
|
|||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
ControlApplicationMemoryModeOverrideConfig* mode = (ControlApplicationMemoryModeOverrideConfig*)&cmdbuf[1];
|
ControlApplicationMemoryModeOverrideConfig* mode = (ControlApplicationMemoryModeOverrideConfig*)&cmdbuf[1];
|
||||||
|
|
||||||
memset(mode, 0, sizeof(ControlApplicationMemoryModeOverrideConfig));
|
memset(mode, 0, sizeof(ControlApplicationMemoryModeOverrideConfig));
|
||||||
mode->query = true;
|
mode->query = true;
|
||||||
cmdbuf[0] = IPC_MakeHeader(0x101, 1, 0); // ControlApplicationMemoryModeOverride
|
cmdbuf[0] = IPC_MakeHeader(0x101, 1, 0); // ControlApplicationMemoryModeOverride
|
||||||
@ -130,16 +127,12 @@ Result PluginLoader__SetMode3AppMode(bool enable)
|
|||||||
res = cmdbuf[1];
|
res = cmdbuf[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
svcCloseHandle(loaderHandle);
|
svcCloseHandle(loaderHandle);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
static void j_PluginLoader__SetMode3AppMode(void* arg) {(void)arg; PluginLoader__SetMode3AppMode(false);}
|
static void j_PluginLoader__SetMode3AppMode(void* arg) {(void)arg; PluginLoader__SetMode3AppMode(false);}
|
||||||
|
|
||||||
void CheckMemory(void);
|
|
||||||
|
|
||||||
void PLG__NotifyEvent(PLG_Event event, bool signal);
|
|
||||||
|
|
||||||
void PluginLoader__HandleCommands(void *_ctx)
|
void PluginLoader__HandleCommands(void *_ctx)
|
||||||
{
|
{
|
||||||
(void)_ctx;
|
(void)_ctx;
|
||||||
@ -176,8 +169,6 @@ void PluginLoader__HandleCommands(void *_ctx)
|
|||||||
}
|
}
|
||||||
REG32(0x10202204) = 0;
|
REG32(0x10202204) = 0;
|
||||||
}
|
}
|
||||||
//if (!ctx->userLoadParameters.noIRPatch)
|
|
||||||
// IR__Patch();
|
|
||||||
PLG__SetConfigMemoryStatus(PLG_CFG_RUNNING);
|
PLG__SetConfigMemoryStatus(PLG_CFG_RUNNING);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -240,14 +231,14 @@ void PluginLoader__HandleCommands(void *_ctx)
|
|||||||
params->pluginMemoryStrategy = (cmdbuf[1] >> 8) & 0xFF;
|
params->pluginMemoryStrategy = (cmdbuf[1] >> 8) & 0xFF;
|
||||||
params->persistent = (cmdbuf[1] >> 16) & 0x1;
|
params->persistent = (cmdbuf[1] >> 16) & 0x1;
|
||||||
params->lowTitleId = cmdbuf[2];
|
params->lowTitleId = cmdbuf[2];
|
||||||
|
|
||||||
strncpy(params->path, (const char *)cmdbuf[4], 255);
|
strncpy(params->path, (const char *)cmdbuf[4], 255);
|
||||||
memcpy(params->config, (void *)cmdbuf[6], 32 * sizeof(u32));
|
memcpy(params->config, (void *)cmdbuf[6], 32 * sizeof(u32));
|
||||||
|
|
||||||
if (params->persistent)
|
if (params->persistent)
|
||||||
{
|
{
|
||||||
IFile file;
|
IFile file;
|
||||||
if (R_SUCCEEDED(IFile_Open(&file, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/luma/plugins/user_param.bin"),
|
if (R_SUCCEEDED(IFile_Open(&file, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, "/luma/plugins/user_param.bin"),
|
||||||
FS_OPEN_CREATE | FS_OPEN_READ | FS_OPEN_WRITE))) {
|
FS_OPEN_CREATE | FS_OPEN_READ | FS_OPEN_WRITE))) {
|
||||||
u64 tempWritten;
|
u64 tempWritten;
|
||||||
u32 magic = PERS_USER_FILE_MAGIC;
|
u32 magic = PERS_USER_FILE_MAGIC;
|
||||||
@ -376,9 +367,9 @@ void PluginLoader__HandleCommands(void *_ctx)
|
|||||||
error(cmdbuf, 0xD9001830);
|
error(cmdbuf, 0xD9001830);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_blockMenuOpen = cmdbuf[1];
|
g_blockMenuOpen = cmdbuf[1];
|
||||||
|
|
||||||
cmdbuf[0] = IPC_MakeHeader(11, 1, 0);
|
cmdbuf[0] = IPC_MakeHeader(11, 1, 0);
|
||||||
cmdbuf[1] = 0;
|
cmdbuf[1] = 0;
|
||||||
break;
|
break;
|
||||||
@ -442,7 +433,7 @@ void PluginLoader__HandleCommands(void *_ctx)
|
|||||||
Reset_3gx_LoadParams();
|
Reset_3gx_LoadParams();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->isExeLoadFunctionset = true;
|
ctx->isExeLoadFunctionset = true;
|
||||||
|
|
||||||
svcInvalidateEntireInstructionCache(); // Could use the range one
|
svcInvalidateEntireInstructionCache(); // Could use the range one
|
||||||
@ -541,7 +532,7 @@ static void WaitForProcessTerminated(void *arg)
|
|||||||
|
|
||||||
// Wait until all threads of the process have finished (svcWaitSynchronization == 0) or 2.5 seconds have passed.
|
// Wait until all threads of the process have finished (svcWaitSynchronization == 0) or 2.5 seconds have passed.
|
||||||
for (u32 i = 0; svcWaitSynchronization(ctx->target, 0) != 0 && i < 50; i++) svcSleepThread(50000000); // 50ms
|
for (u32 i = 0; svcWaitSynchronization(ctx->target, 0) != 0 && i < 50; i++) svcSleepThread(50000000); // 50ms
|
||||||
|
|
||||||
// Unmap plugin's memory before closing the process
|
// Unmap plugin's memory before closing the process
|
||||||
if (!ctx->pluginIsSwapped) {
|
if (!ctx->pluginIsSwapped) {
|
||||||
MemoryBlock__UnmountFromProcess();
|
MemoryBlock__UnmountFromProcess();
|
||||||
@ -561,8 +552,6 @@ static void WaitForProcessTerminated(void *arg)
|
|||||||
ctx->isMemPrivate = false;
|
ctx->isMemPrivate = false;
|
||||||
g_blockMenuOpen = 0;
|
g_blockMenuOpen = 0;
|
||||||
MemoryBlock__ResetSwapSettings();
|
MemoryBlock__ResetSwapSettings();
|
||||||
//if (!ctx->userLoadParameters.noIRPatch)
|
|
||||||
// IR__Unpatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginLoader__HandleKernelEvent(u32 notifId)
|
void PluginLoader__HandleKernelEvent(u32 notifId)
|
||||||
@ -643,12 +632,11 @@ void PluginLoader__HandleKernelEvent(u32 notifId)
|
|||||||
PLG__NotifyEvent(PLG_HOME_ENTER, false);
|
PLG__NotifyEvent(PLG_HOME_ENTER, false);
|
||||||
// Wait for plugin reply
|
// Wait for plugin reply
|
||||||
PLG__WaitForReply();
|
PLG__WaitForReply();
|
||||||
}
|
}
|
||||||
PLG__SetConfigMemoryStatus(PLG_CFG_INHOME);
|
PLG__SetConfigMemoryStatus(PLG_CFG_INHOME);
|
||||||
}
|
}
|
||||||
ctx->pluginIsHome = !ctx->pluginIsHome;
|
ctx->pluginIsHome = !ctx->pluginIsHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
srvPublishToSubscriber(0x1002, 0);
|
srvPublishToSubscriber(0x1002, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user