stratosphere: all in on enum class CommandId

This commit is contained in:
Michael Scire
2019-06-27 23:34:26 -07:00
parent 67c0f4527e
commit 18ca8aaf5b
38 changed files with 665 additions and 658 deletions

View File

@@ -18,12 +18,12 @@
#include <switch.h>
#include <stratosphere.hpp>
enum BootModeCmd {
BootMode_Cmd_GetBootMode = 0,
BootMode_Cmd_SetMaintenanceBoot = 1
};
class BootModeService final : public IServiceObject {
private:
enum class CommandId {
GetBootMode = 0,
SetMaintenanceBoot = 1,
};
private:
/* Actual commands. */
void GetBootMode(Out<u32> out);
@@ -32,7 +32,7 @@ class BootModeService final : public IServiceObject {
static void SetMaintenanceBootForEmbeddedBoot2();
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MakeServiceCommandMeta<BootMode_Cmd_GetBootMode, &BootModeService::GetBootMode>(),
MakeServiceCommandMeta<BootMode_Cmd_SetMaintenanceBoot, &BootModeService::SetMaintenanceBoot>(),
MAKE_SERVICE_COMMAND_META(BootModeService, GetBootMode),
MAKE_SERVICE_COMMAND_META(BootModeService, SetMaintenanceBoot),
};
};

View File

@@ -20,30 +20,23 @@
#include "pm_registration.hpp"
enum DmntCmd {
Dmnt_Cmd_GetUnknownStub = 0,
Dmnt_Cmd_GetDebugProcessIds = 1,
Dmnt_Cmd_LaunchDebugProcess = 2,
Dmnt_Cmd_GetTitleProcessId = 3,
Dmnt_Cmd_EnableDebugForTitleId = 4,
Dmnt_Cmd_GetApplicationProcessId = 5,
Dmnt_Cmd_EnableDebugForApplication = 6,
Dmnt_Cmd_5X_GetDebugProcessIds = 0,
Dmnt_Cmd_5X_LaunchDebugProcess = 1,
Dmnt_Cmd_5X_GetTitleProcessId = 2,
Dmnt_Cmd_5X_EnableDebugForTitleId = 3,
Dmnt_Cmd_5X_GetApplicationProcessId = 4,
Dmnt_Cmd_5X_EnableDebugForApplication = 5,
Dmnt_Cmd_6X_DisableDebug = 6,
Dmnt_Cmd_AtmosphereGetProcessInfo = 65000,
Dmnt_Cmd_AtmosphereGetCurrentLimitInfo = 65001,
};
class DebugMonitorService final : public IServiceObject {
/* Represents modern DebugMonitorService (5.0.0+) */
class DebugMonitorService : public IServiceObject {
private:
enum class CommandId {
GetDebugProcessIds = 0,
LaunchDebugProcess = 1,
GetTitleProcessId = 2,
EnableDebugForTitleId = 3,
GetApplicationProcessId = 4,
EnableDebugForApplication = 5,
DisableDebug = 6,
AtmosphereGetProcessInfo = 65000,
AtmosphereGetCurrentLimitInfo = 65001,
};
protected:
/* Actual commands. */
Result GetUnknownStub(Out<u32> count, OutBuffer<u8> out_buf, u64 in_unk);
Result GetDebugProcessIds(Out<u32> count, OutBuffer<u64> out_pids);
@@ -59,28 +52,51 @@ class DebugMonitorService final : public IServiceObject {
Result AtmosphereGetCurrentLimitInfo(Out<u64> cur_val, Out<u64> lim_val, u32 category, u32 resource);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0-4.1.0 */
MakeServiceCommandMeta<Dmnt_Cmd_GetUnknownStub, &DebugMonitorService::GetUnknownStub, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Dmnt_Cmd_GetDebugProcessIds, &DebugMonitorService::GetDebugProcessIds, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Dmnt_Cmd_LaunchDebugProcess, &DebugMonitorService::LaunchDebugProcess, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Dmnt_Cmd_GetTitleProcessId, &DebugMonitorService::GetTitleProcessId, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Dmnt_Cmd_EnableDebugForTitleId, &DebugMonitorService::EnableDebugForTitleId, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Dmnt_Cmd_GetApplicationProcessId, &DebugMonitorService::GetApplicationProcessId, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Dmnt_Cmd_EnableDebugForApplication, &DebugMonitorService::EnableDebugForApplication, FirmwareVersion_Min, FirmwareVersion_400>(),
/* 5.0.0-* */
MakeServiceCommandMeta<Dmnt_Cmd_5X_GetDebugProcessIds, &DebugMonitorService::GetDebugProcessIds, FirmwareVersion_500>(),
MakeServiceCommandMeta<Dmnt_Cmd_5X_LaunchDebugProcess, &DebugMonitorService::LaunchDebugProcess, FirmwareVersion_500>(),
MakeServiceCommandMeta<Dmnt_Cmd_5X_GetTitleProcessId, &DebugMonitorService::GetTitleProcessId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Dmnt_Cmd_5X_EnableDebugForTitleId, &DebugMonitorService::EnableDebugForTitleId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Dmnt_Cmd_5X_GetApplicationProcessId, &DebugMonitorService::GetApplicationProcessId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Dmnt_Cmd_5X_EnableDebugForApplication, &DebugMonitorService::EnableDebugForApplication, FirmwareVersion_500>(),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, GetDebugProcessIds),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, LaunchDebugProcess),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, GetTitleProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, EnableDebugForTitleId),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, GetApplicationProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, EnableDebugForApplication),
/* 6.0.0-* */
MakeServiceCommandMeta<Dmnt_Cmd_6X_DisableDebug, &DebugMonitorService::DisableDebug, FirmwareVersion_600>(),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, DisableDebug, FirmwareVersion_600),
/* Atmosphere extensions. */
MakeServiceCommandMeta<Dmnt_Cmd_AtmosphereGetProcessInfo, &DebugMonitorService::AtmosphereGetProcessInfo>(),
MakeServiceCommandMeta<Dmnt_Cmd_AtmosphereGetCurrentLimitInfo, &DebugMonitorService::AtmosphereGetCurrentLimitInfo>(),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, AtmosphereGetProcessInfo),
MAKE_SERVICE_COMMAND_META(DebugMonitorService, AtmosphereGetCurrentLimitInfo),
};
};
/* Represents deprecated DebugMonitorService (1.0.0-4.1.0). */
class DebugMonitorServiceDeprecated : public DebugMonitorService {
private:
enum class CommandId {
GetUnknownStub = 0,
GetDebugProcessIds = 1,
LaunchDebugProcess = 2,
GetTitleProcessId = 3,
EnableDebugForTitleId = 4,
GetApplicationProcessId = 5,
EnableDebugForApplication = 6,
AtmosphereGetProcessInfo = 65000,
AtmosphereGetCurrentLimitInfo = 65001,
};
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0-4.1.0 */
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetUnknownStub),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetDebugProcessIds),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, LaunchDebugProcess),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetTitleProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, EnableDebugForTitleId),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, GetApplicationProcessId),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, EnableDebugForApplication),
/* Atmosphere extensions. */
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, AtmosphereGetProcessInfo),
MAKE_SERVICE_COMMAND_META(DebugMonitorServiceDeprecated, AtmosphereGetCurrentLimitInfo),
};
};

View File

@@ -18,14 +18,13 @@
#include <switch.h>
#include <stratosphere.hpp>
enum InformationCmd {
Information_Cmd_GetTitleId = 0,
Information_Cmd_AtmosphereGetProcessId = 65000,
Information_Cmd_AtmosphereHasCreatedTitle = 65001,
};
class InformationService final : public IServiceObject {
private:
enum class CommandId {
GetTitleId = 0,
AtmosphereGetProcessId = 65000,
AtmosphereHasLaunchedTitle = 65001,
};
private:
/* Actual commands. */
Result GetTitleId(Out<u64> tid, u64 pid);
@@ -35,8 +34,8 @@ class InformationService final : public IServiceObject {
Result AtmosphereHasLaunchedTitle(Out<bool> out, u64 tid);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MakeServiceCommandMeta<Information_Cmd_GetTitleId, &InformationService::GetTitleId>(),
MakeServiceCommandMeta<Information_Cmd_AtmosphereGetProcessId, &InformationService::AtmosphereGetProcessId>(),
MakeServiceCommandMeta<Information_Cmd_AtmosphereHasCreatedTitle, &InformationService::AtmosphereHasLaunchedTitle>(),
MAKE_SERVICE_COMMAND_META(InformationService, GetTitleId),
MAKE_SERVICE_COMMAND_META(InformationService, AtmosphereGetProcessId),
MAKE_SERVICE_COMMAND_META(InformationService, AtmosphereHasLaunchedTitle),
};
};

View File

@@ -142,8 +142,13 @@ int main(int argc, char **argv)
static auto s_server_manager = WaitableManager(1);
/* TODO: Create services. */
s_server_manager.AddWaitable(new ServiceServer<ShellService>("pm:shell", 3));
s_server_manager.AddWaitable(new ServiceServer<DebugMonitorService>("pm:dmnt", 3));
if (GetRuntimeFirmwareVersion() <= FirmwareVersion_400) {
s_server_manager.AddWaitable(new ServiceServer<ShellServiceDeprecated>("pm:shell", 3));
s_server_manager.AddWaitable(new ServiceServer<DebugMonitorServiceDeprecated>("pm:dmnt", 3));
} else {
s_server_manager.AddWaitable(new ServiceServer<ShellService>("pm:shell", 3));
s_server_manager.AddWaitable(new ServiceServer<DebugMonitorService>("pm:dmnt", 3));
}
s_server_manager.AddWaitable(new ServiceServer<BootModeService>("pm:bm", 6));
s_server_manager.AddWaitable(new ServiceServer<InformationService>("pm:info", 19));

View File

@@ -20,35 +20,22 @@
#include "pm_registration.hpp"
enum ShellCmd {
Shell_Cmd_LaunchProcess = 0,
Shell_Cmd_TerminateProcessId = 1,
Shell_Cmd_TerminateTitleId = 2,
Shell_Cmd_GetProcessWaitEvent = 3,
Shell_Cmd_GetProcessEventType = 4,
Shell_Cmd_FinalizeExitedProcess = 5,
Shell_Cmd_ClearProcessNotificationFlag = 6,
Shell_Cmd_NotifyBootFinished = 7,
Shell_Cmd_GetApplicationProcessId = 8,
Shell_Cmd_BoostSystemMemoryResourceLimit = 9
};
enum ShellCmd_5X {
Shell_Cmd_5X_LaunchProcess = 0,
Shell_Cmd_5X_TerminateProcessId = 1,
Shell_Cmd_5X_TerminateTitleId = 2,
Shell_Cmd_5X_GetProcessWaitEvent = 3,
Shell_Cmd_5X_GetProcessEventType = 4,
Shell_Cmd_5X_NotifyBootFinished = 5,
Shell_Cmd_5X_GetApplicationProcessId = 6,
Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7,
Shell_Cmd_BoostSystemThreadsResourceLimit = 8,
Shell_Cmd_GetBootFinishedEvent = 9,
};
class ShellService final : public IServiceObject {
/* Represents modern ShellService (5.0.0+) */
class ShellService : public IServiceObject {
private:
enum class CommandId {
LaunchProcess = 0,
TerminateProcessId = 1,
TerminateTitleId = 2,
GetProcessWaitEvent = 3,
GetProcessEventType = 4,
NotifyBootFinished = 5,
GetApplicationProcessId = 6,
BoostSystemMemoryResourceLimit = 7,
BoostSystemThreadsResourceLimit = 8,
GetBootFinishedEvent = 9,
};
protected:
/* Actual commands. */
Result LaunchProcess(Out<u64> pid, Registration::TidSid tid_sid, u32 launch_flags);
Result TerminateProcessId(u64 pid);
@@ -64,34 +51,53 @@ class ShellService final : public IServiceObject {
void GetBootFinishedEvent(Out<CopiedHandle> event);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0-4.0.0 */
MakeServiceCommandMeta<Shell_Cmd_LaunchProcess, &ShellService::LaunchProcess, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_TerminateProcessId, &ShellService::TerminateProcessId, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_TerminateTitleId, &ShellService::TerminateTitleId, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_GetProcessWaitEvent, &ShellService::GetProcessWaitEvent, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_GetProcessEventType, &ShellService::GetProcessEventType, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_FinalizeExitedProcess, &ShellService::FinalizeExitedProcess, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_ClearProcessNotificationFlag, &ShellService::ClearProcessNotificationFlag, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_NotifyBootFinished, &ShellService::NotifyBootFinished, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_GetApplicationProcessId, &ShellService::GetApplicationProcessId, FirmwareVersion_Min, FirmwareVersion_400>(),
/* 4.0.0-4.0.0 */
MakeServiceCommandMeta<Shell_Cmd_BoostSystemMemoryResourceLimit, &ShellService::BoostSystemMemoryResourceLimit, FirmwareVersion_400, FirmwareVersion_400>(),
/* 5.0.0-* */
MakeServiceCommandMeta<Shell_Cmd_5X_LaunchProcess, &ShellService::LaunchProcess, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_TerminateProcessId, &ShellService::TerminateProcessId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_TerminateTitleId, &ShellService::TerminateTitleId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_GetProcessWaitEvent, &ShellService::GetProcessWaitEvent, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_GetProcessEventType, &ShellService::GetProcessEventType, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_NotifyBootFinished, &ShellService::NotifyBootFinished, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_GetApplicationProcessId, &ShellService::GetApplicationProcessId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_BoostSystemMemoryResourceLimit, &ShellService::BoostSystemMemoryResourceLimit, FirmwareVersion_500>(),
MAKE_SERVICE_COMMAND_META(ShellService, LaunchProcess),
MAKE_SERVICE_COMMAND_META(ShellService, TerminateProcessId),
MAKE_SERVICE_COMMAND_META(ShellService, TerminateTitleId),
MAKE_SERVICE_COMMAND_META(ShellService, GetProcessWaitEvent),
MAKE_SERVICE_COMMAND_META(ShellService, GetProcessEventType),
MAKE_SERVICE_COMMAND_META(ShellService, NotifyBootFinished),
MAKE_SERVICE_COMMAND_META(ShellService, GetApplicationProcessId),
MAKE_SERVICE_COMMAND_META(ShellService, BoostSystemMemoryResourceLimit),
/* 7.0.0-* */
MakeServiceCommandMeta<Shell_Cmd_BoostSystemThreadsResourceLimit, &ShellService::BoostSystemThreadsResourceLimit, FirmwareVersion_700>(),
MAKE_SERVICE_COMMAND_META(ShellService, BoostSystemThreadsResourceLimit, FirmwareVersion_700),
/* 8.0.0-* */
MakeServiceCommandMeta<Shell_Cmd_GetBootFinishedEvent, &ShellService::GetBootFinishedEvent, FirmwareVersion_800>(),
MAKE_SERVICE_COMMAND_META(ShellService, GetBootFinishedEvent, FirmwareVersion_800),
};
};
/* Represents deprecated ShellService (1.0.0-4.1.0). */
class ShellServiceDeprecated : public ShellService {
private:
enum class CommandId {
LaunchProcess = 0,
TerminateProcessId = 1,
TerminateTitleId = 2,
GetProcessWaitEvent = 3,
GetProcessEventType = 4,
FinalizeExitedProcess = 5,
ClearProcessNotificationFlag = 6,
NotifyBootFinished = 7,
GetApplicationProcessId = 8,
BoostSystemMemoryResourceLimit = 9,
};
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0- */
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, LaunchProcess),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, TerminateProcessId),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, TerminateTitleId),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetProcessWaitEvent),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetProcessEventType),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, FinalizeExitedProcess),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, ClearProcessNotificationFlag),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, NotifyBootFinished),
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, GetApplicationProcessId),
/* 4.0.0- */
MAKE_SERVICE_COMMAND_META(ShellServiceDeprecated, BoostSystemMemoryResourceLimit, FirmwareVersion_400),
};
};