sysmodules: introduce "luma shared config", rewrite ndmu workaround

This commit is contained in:
TuxSH
2020-07-12 19:36:18 +01:00
parent e3bb1c1b63
commit 768e587b76
13 changed files with 122 additions and 31 deletions

View File

@@ -8,8 +8,9 @@ This is part of 3ds_sm, which is licensed under the MIT license (see LICENSE for
#include "notifications.h"
#include "processes.h"
// 0 by default
#define ROSALINA_PREVENT_DISCONNECT (*(volatile bool*)0x1FF81108)
#include <stdatomic.h>
static atomic_int ndmuWorkaroundCount;
static bool isNotificationInhibited(const ProcessData *processData, u32 notificationId)
{
@@ -19,7 +20,7 @@ static bool isNotificationInhibited(const ProcessData *processData, u32 notifica
// Shell opened, shell closed
case 0x213:
case 0x214:
return pid == ndmuServicePid && ROSALINA_PREVENT_DISCONNECT;
return pid == ndmuServicePid && atomic_load(&ndmuWorkaroundCount) > 0;
default:
return false;
}
@@ -206,3 +207,10 @@ Result PublishToAll(u32 notificationId)
return 0;
}
Result AddToNdmuWorkaroundCount(s32 count)
{
// Note: no check is made to (current value)+count
atomic_fetch_add(&ndmuWorkaroundCount, count);
return 0;
}

View File

@@ -17,3 +17,5 @@ Result PublishToSubscriber(u32 notificationId, u32 flags);
Result PublishAndGetSubscriber(u32 *pidCount, u32 *pidList, u32 notificationId, u32 flags);
Result PublishToProcess(Handle process, u32 notificationId);
Result PublishToAll(u32 notificationId);
Result AddToNdmuWorkaroundCount(s32 count);

View File

@@ -167,6 +167,14 @@ Result srvHandleCommands(SessionData *sessionData)
break;
}
case 0x1000: // Custom command: AddToNdmuWorkaroundCount
{
res = AddToNdmuWorkaroundCount((s32)cmdbuf[1]);
cmdbuf[0] = IPC_MakeHeader(0x1000, 1, 0);;
cmdbuf[1] = (u32)res;
break;
}
default:
goto invalid_command;
break;