sysmodules: introduce "luma shared config", rewrite ndmu workaround
This commit is contained in:
@@ -82,13 +82,15 @@ void initSystem(void)
|
||||
isN3DS = svcGetSystemInfo(&out, 0x10001, 0) == 0;
|
||||
|
||||
svcGetSystemInfo(&out, 0x10000, 0x100);
|
||||
HBLDR_3DSX_TID = out == 0 ? HBLDR_DEFAULT_3DSX_TID : (u64)out;
|
||||
Luma_SharedConfig->hbldr_3dsx_tid = out == 0 ? HBLDR_DEFAULT_3DSX_TID : (u64)out;
|
||||
Luma_SharedConfig->use_hbldr = true;
|
||||
|
||||
svcGetSystemInfo(&out, 0x10000, 0x101);
|
||||
menuCombo = out == 0 ? DEFAULT_MENU_COMBO : (u32)out;
|
||||
|
||||
miscellaneousMenu.items[0].title = HBLDR_3DSX_TID == HBLDR_DEFAULT_3DSX_TID ? "Switch the hb. title to the current app." :
|
||||
"Switch the hb. title to hblauncher_loader";
|
||||
miscellaneousMenu.items[0].title = Luma_SharedConfig->hbldr_3dsx_tid == HBLDR_DEFAULT_3DSX_TID ?
|
||||
"Switch the hb. title to the current app." :
|
||||
"Switch the hb. title to hblauncher_loader";
|
||||
|
||||
for(res = 0xD88007FA; res == (Result)0xD88007FA; svcSleepThread(500 * 1000LL))
|
||||
{
|
||||
@@ -141,7 +143,7 @@ static void handleSleepNotification(u32 notificationId)
|
||||
{
|
||||
case PTMNOTIFID_SLEEP_REQUESTED:
|
||||
menuShouldExit = true;
|
||||
PTMSYSM_ReplyToSleepQuery(ROSALINA_PREVENT_DISCONNECT); // deny sleep request if we have network stuff running
|
||||
PTMSYSM_ReplyToSleepQuery(miniSocEnabled); // deny sleep request if we have network stuff running
|
||||
break;
|
||||
case PTMNOTIFID_GOING_TO_SLEEP:
|
||||
case PTMNOTIFID_SLEEP_ALLOWED:
|
||||
|
||||
@@ -54,7 +54,7 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
|
||||
Result res;
|
||||
char failureReason[64];
|
||||
|
||||
if(HBLDR_3DSX_TID == HBLDR_DEFAULT_3DSX_TID)
|
||||
if(Luma_SharedConfig->hbldr_3dsx_tid == HBLDR_DEFAULT_3DSX_TID)
|
||||
{
|
||||
FS_ProgramInfo progInfo;
|
||||
u32 pid;
|
||||
@@ -62,7 +62,7 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
|
||||
res = PMDBG_GetCurrentAppInfo(&progInfo, &pid, &launchFlags);
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
HBLDR_3DSX_TID = progInfo.programId;
|
||||
Luma_SharedConfig->hbldr_3dsx_tid = progInfo.programId;
|
||||
miscellaneousMenu.items[0].title = "Switch the hb. title to hblauncher_loader";
|
||||
}
|
||||
else
|
||||
@@ -74,7 +74,7 @@ void MiscellaneousMenu_SwitchBoot3dsxTargetTitle(void)
|
||||
else
|
||||
{
|
||||
res = 0;
|
||||
HBLDR_3DSX_TID = HBLDR_DEFAULT_3DSX_TID;
|
||||
Luma_SharedConfig->hbldr_3dsx_tid = HBLDR_DEFAULT_3DSX_TID;
|
||||
miscellaneousMenu.items[0].title = "Switch the hb. title to the current app.";
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ void MiscellaneousMenu_SaveSettings(void)
|
||||
configData.config = config;
|
||||
configData.multiConfig = multiConfig;
|
||||
configData.bootConfig = bootConfig;
|
||||
configData.hbldr3dsxTitleId = HBLDR_3DSX_TID;
|
||||
configData.hbldr3dsxTitleId = Luma_SharedConfig->hbldr_3dsx_tid;
|
||||
configData.rosalinaMenuCombo = menuCombo;
|
||||
|
||||
FS_ArchiveID archiveId = isSdMode ? ARCHIVE_SDMC : ARCHIVE_NAND_RW;
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
|
||||
#include "minisoc.h"
|
||||
#include <sys/socket.h>
|
||||
#include <3ds/ipc.h>
|
||||
#include <3ds/os.h>
|
||||
#include <3ds/synchronization.h>
|
||||
#include <3ds/result.h>
|
||||
#include <3ds.h>
|
||||
#include <string.h>
|
||||
#include "csvc.h"
|
||||
#include "utils.h"
|
||||
|
||||
s32 miniSocRefCount = 0;
|
||||
static u32 socContextAddr = 0x08000000;
|
||||
@@ -24,6 +21,22 @@ bool miniSocEnabled = false;
|
||||
|
||||
s32 _net_convert_error(s32 sock_retval);
|
||||
|
||||
// To prevent ndm:u from disconnecting us
|
||||
static Result srvExtAddToNdmuWorkaroundCount(s32 count)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x1000,1,0);
|
||||
cmdbuf[1] = (u32)count;
|
||||
|
||||
ret = svcSendSyncRequest(*srvGetSessionHandle());
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
return cmdbuf[1];
|
||||
}
|
||||
|
||||
static Result SOCU_Initialize(Handle memhandle, u32 memsize)
|
||||
{
|
||||
Result ret = 0;
|
||||
@@ -91,7 +104,8 @@ Result miniSocInit(void)
|
||||
|
||||
svcKernelSetState(0x10000, 2);
|
||||
miniSocEnabled = true;
|
||||
ROSALINA_PREVENT_DISCONNECT = true;
|
||||
srvExtAddToNdmuWorkaroundCount(1);
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
@@ -133,9 +147,9 @@ Result miniSocExitDirect(void)
|
||||
svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE);
|
||||
if(ret == 0)
|
||||
{
|
||||
svcKernelSetState(0x10000, 2);
|
||||
miniSocEnabled = false;
|
||||
ROSALINA_PREVENT_DISCONNECT = false;
|
||||
srvExtAddToNdmuWorkaroundCount(-1);
|
||||
svcKernelSetState(0x10000, 2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user