Use IPC:MakeHeader instead of hardcoded raw values for IPC command tables. (#6453)

* Use IPC:MakeHeader instead of hardcoded values for IPC command tables.

* Use u32 instead of unsigned int in MakeHeader function

Co-authored-by: SachinVin <26602104+SachinVin@users.noreply.github.com>

* Fix clang format

---------

Co-authored-by: SachinVin <26602104+SachinVin@users.noreply.github.com>
This commit is contained in:
PabloMK7
2023-04-28 07:31:03 +02:00
committed by GitHub
parent 9bd8c9290b
commit 63bc0b59bb
74 changed files with 1983 additions and 1896 deletions

View File

@@ -13,23 +13,25 @@ PTM_Gets::PTM_Gets(std::shared_ptr<Module> ptm)
: Module::Interface(std::move(ptm), "ptm:gets", 26) {
static const FunctionInfo functions[] = {
// ptm:u common commands
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, &PTM_Gets::GetAdapterState, "GetAdapterState"},
{0x00060000, &PTM_Gets::GetShellState, "GetShellState"},
{0x00070000, &PTM_Gets::GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, &PTM_Gets::GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, &PTM_Gets::GetStepHistory, "GetStepHistory"},
{0x000C0000, &PTM_Gets::GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// clang-format off
{IPC::MakeHeader(0x0001, 0, 2), nullptr, "RegisterAlarmClient"},
{IPC::MakeHeader(0x0002, 2, 0), nullptr, "SetRtcAlarm"},
{IPC::MakeHeader(0x0003, 0, 0), nullptr, "GetRtcAlarm"},
{IPC::MakeHeader(0x0004, 0, 0), nullptr, "CancelRtcAlarm"},
{IPC::MakeHeader(0x0005, 0, 0), &PTM_Gets::GetAdapterState, "GetAdapterState"},
{IPC::MakeHeader(0x0006, 0, 0), &PTM_Gets::GetShellState, "GetShellState"},
{IPC::MakeHeader(0x0007, 0, 0), &PTM_Gets::GetBatteryLevel, "GetBatteryLevel"},
{IPC::MakeHeader(0x0008, 0, 0), &PTM_Gets::GetBatteryChargeState, "GetBatteryChargeState"},
{IPC::MakeHeader(0x0009, 0, 0), nullptr, "GetPedometerState"},
{IPC::MakeHeader(0x000A, 1, 2), nullptr, "GetStepHistoryEntry"},
{IPC::MakeHeader(0x000B, 3, 2), &PTM_Gets::GetStepHistory, "GetStepHistory"},
{IPC::MakeHeader(0x000C, 0, 0), &PTM_Gets::GetTotalStepCount, "GetTotalStepCount"},
{IPC::MakeHeader(0x000D, 1, 0), nullptr, "SetPedometerRecordingMode"},
{IPC::MakeHeader(0x000E, 0, 0), nullptr, "GetPedometerRecordingMode"},
{IPC::MakeHeader(0x000F, 2, 4), nullptr, "GetStepHistoryAll"},
// ptm:gets
{0x04010000, nullptr, "GetSystemTime"},
{IPC::MakeHeader(0x0401, 0, 0), nullptr, "GetSystemTime"},
// clang-format on
};
RegisterHandlers(functions);
}

View File

@@ -13,26 +13,28 @@ PTM_Play::PTM_Play(std::shared_ptr<Module> ptm)
: Module::Interface(std::move(ptm), "ptm:play", 26) {
static const FunctionInfo functions[] = {
// ptm:u common commands
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, &PTM_Play::GetAdapterState, "GetAdapterState"},
{0x00060000, &PTM_Play::GetShellState, "GetShellState"},
{0x00070000, &PTM_Play::GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, &PTM_Play::GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, &PTM_Play::GetStepHistory, "GetStepHistory"},
{0x000C0000, &PTM_Play::GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// clang-format off
{IPC::MakeHeader(0x0001, 0, 2), nullptr, "RegisterAlarmClient"},
{IPC::MakeHeader(0x0002, 2, 0), nullptr, "SetRtcAlarm"},
{IPC::MakeHeader(0x0003, 0, 0), nullptr, "GetRtcAlarm"},
{IPC::MakeHeader(0x0004, 0, 0), nullptr, "CancelRtcAlarm"},
{IPC::MakeHeader(0x0005, 0, 0), &PTM_Play::GetAdapterState, "GetAdapterState"},
{IPC::MakeHeader(0x0006, 0, 0), &PTM_Play::GetShellState, "GetShellState"},
{IPC::MakeHeader(0x0007, 0, 0), &PTM_Play::GetBatteryLevel, "GetBatteryLevel"},
{IPC::MakeHeader(0x0008, 0, 0), &PTM_Play::GetBatteryChargeState, "GetBatteryChargeState"},
{IPC::MakeHeader(0x0009, 0, 0), nullptr, "GetPedometerState"},
{IPC::MakeHeader(0x000A, 1, 2), nullptr, "GetStepHistoryEntry"},
{IPC::MakeHeader(0x000B, 3, 2), &PTM_Play::GetStepHistory, "GetStepHistory"},
{IPC::MakeHeader(0x000C, 0, 0), &PTM_Play::GetTotalStepCount, "GetTotalStepCount"},
{IPC::MakeHeader(0x000D, 1, 0), nullptr, "SetPedometerRecordingMode"},
{IPC::MakeHeader(0x000E, 0, 0), nullptr, "GetPedometerRecordingMode"},
{IPC::MakeHeader(0x000F, 2, 4), nullptr, "GetStepHistoryAll"},
// ptm:play
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
{IPC::MakeHeader(0x0807, 2, 2), nullptr, "GetPlayHistory"},
{IPC::MakeHeader(0x0808, 0, 0), nullptr, "GetPlayHistoryStart"},
{IPC::MakeHeader(0x0809, 0, 0), nullptr, "GetPlayHistoryLength"},
{IPC::MakeHeader(0x080B, 2, 0), nullptr, "CalcPlayHistoryStart"},
// clang-format on
};
RegisterHandlers(functions);
}

View File

@@ -12,7 +12,9 @@ namespace Service::PTM {
PTM_Sets::PTM_Sets(std::shared_ptr<Module> ptm) : Module::Interface(std::move(ptm), "ptm:sets", 1) {
static const FunctionInfo functions[] = {
// Note that this service does not have access to ptm:u's common commands
{0x00010080, nullptr, "SetSystemTime"},
// clang-format off
{IPC::MakeHeader(0x0001, 2, 0), nullptr, "SetSystemTime"},
// clang-format on
};
RegisterHandlers(functions);
}

View File

@@ -14,53 +14,55 @@ PTM_S_Common::PTM_S_Common(std::shared_ptr<Module> ptm, const char* name)
: Module::Interface(std::move(ptm), name, 26) {
static const FunctionInfo functions[] = {
// ptm:u common commands
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, &PTM_S_Common::GetAdapterState, "GetAdapterState"},
{0x00060000, &PTM_S_Common::GetShellState, "GetShellState"},
{0x00070000, &PTM_S_Common::GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, &PTM_S_Common::GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, &PTM_S_Common::GetStepHistory, "GetStepHistory"},
{0x000C0000, &PTM_S_Common::GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// clang-format off
{IPC::MakeHeader(0x0001, 0, 2), nullptr, "RegisterAlarmClient"},
{IPC::MakeHeader(0x0002, 2, 0), nullptr, "SetRtcAlarm"},
{IPC::MakeHeader(0x0003, 0, 0), nullptr, "GetRtcAlarm"},
{IPC::MakeHeader(0x0004, 0, 0), nullptr, "CancelRtcAlarm"},
{IPC::MakeHeader(0x0005, 0, 0), &PTM_S_Common::GetAdapterState, "GetAdapterState"},
{IPC::MakeHeader(0x0006, 0, 0), &PTM_S_Common::GetShellState, "GetShellState"},
{IPC::MakeHeader(0x0007, 0, 0), &PTM_S_Common::GetBatteryLevel, "GetBatteryLevel"},
{IPC::MakeHeader(0x0008, 0, 0), &PTM_S_Common::GetBatteryChargeState, "GetBatteryChargeState"},
{IPC::MakeHeader(0x0009, 0, 0), nullptr, "GetPedometerState"},
{IPC::MakeHeader(0x000A, 1, 2), nullptr, "GetStepHistoryEntry"},
{IPC::MakeHeader(0x000B, 3, 2), &PTM_S_Common::GetStepHistory, "GetStepHistory"},
{IPC::MakeHeader(0x000C, 0, 0), &PTM_S_Common::GetTotalStepCount, "GetTotalStepCount"},
{IPC::MakeHeader(0x000D, 1, 0), nullptr, "SetPedometerRecordingMode"},
{IPC::MakeHeader(0x000E, 0, 0), nullptr, "GetPedometerRecordingMode"},
{IPC::MakeHeader(0x000F, 2, 4), nullptr, "GetStepHistoryAll"},
// ptm:sysm & ptm:s
{0x040100C0, nullptr, "SetRtcAlarmEx"},
{0x04020042, nullptr, "ReplySleepQuery"},
{0x04030042, nullptr, "NotifySleepPreparationComplete"},
{0x04040102, nullptr, "SetWakeupTrigger"},
{0x04050000, nullptr, "GetAwakeReason"},
{0x04060000, nullptr, "RequestSleep"},
{0x040700C0, nullptr, "ShutdownAsync"},
{0x04080000, nullptr, "Awake"},
{0x04090080, nullptr, "RebootAsync"},
{0x040A0000, &PTM_S_Common::CheckNew3DS, "CheckNew3DS"},
{0x08010640, nullptr, "SetInfoLEDPattern"},
{0x08020040, nullptr, "SetInfoLEDPatternHeader"},
{0x08030000, nullptr, "GetInfoLEDStatus"},
{0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
{0x08050000, nullptr, "ClearStepHistory"},
{0x080600C2, nullptr, "SetStepHistory"},
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080A0000, nullptr, "ClearPlayHistory"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
{0x080C0080, nullptr, "SetUserTime"},
{0x080D0000, nullptr, "InvalidateSystemTime"},
{0x080E0140, nullptr, "NotifyPlayEvent"},
{0x080F0000, &PTM_S_Common::GetSoftwareClosedFlag, "GetSoftwareClosedFlag"},
{0x08100000, nullptr, "ClearSoftwareClosedFlag"},
{0x08110000, &PTM_S_Common::GetShellState, "GetShellState"},
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
{0x08130000, nullptr, "FormatSavedata"},
{0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"},
{0x08180040, nullptr, "ConfigureNew3DSCPU"},
{IPC::MakeHeader(0x0401, 3, 0), nullptr, "SetRtcAlarmEx"},
{IPC::MakeHeader(0x0402, 1, 2), nullptr, "ReplySleepQuery"},
{IPC::MakeHeader(0x0403, 1, 2), nullptr, "NotifySleepPreparationComplete"},
{IPC::MakeHeader(0x0404, 4, 2), nullptr, "SetWakeupTrigger"},
{IPC::MakeHeader(0x0405, 0, 0), nullptr, "GetAwakeReason"},
{IPC::MakeHeader(0x0406, 0, 0), nullptr, "RequestSleep"},
{IPC::MakeHeader(0x0407, 3, 0), nullptr, "ShutdownAsync"},
{IPC::MakeHeader(0x0408, 0, 0), nullptr, "Awake"},
{IPC::MakeHeader(0x0409, 2, 0), nullptr, "RebootAsync"},
{IPC::MakeHeader(0x040A, 0, 0), &PTM_S_Common::CheckNew3DS, "CheckNew3DS"},
{IPC::MakeHeader(0x0801, 25, 0), nullptr, "SetInfoLEDPattern"},
{IPC::MakeHeader(0x0802, 1, 0), nullptr, "SetInfoLEDPatternHeader"},
{IPC::MakeHeader(0x0803, 0, 0), nullptr, "GetInfoLEDStatus"},
{IPC::MakeHeader(0x0804, 1, 0), nullptr, "SetBatteryEmptyLEDPattern"},
{IPC::MakeHeader(0x0805, 0, 0), nullptr, "ClearStepHistory"},
{IPC::MakeHeader(0x0806, 3, 2), nullptr, "SetStepHistory"},
{IPC::MakeHeader(0x0807, 2, 2), nullptr, "GetPlayHistory"},
{IPC::MakeHeader(0x0808, 0, 0), nullptr, "GetPlayHistoryStart"},
{IPC::MakeHeader(0x0809, 0, 0), nullptr, "GetPlayHistoryLength"},
{IPC::MakeHeader(0x080A, 0, 0), nullptr, "ClearPlayHistory"},
{IPC::MakeHeader(0x080B, 2, 0), nullptr, "CalcPlayHistoryStart"},
{IPC::MakeHeader(0x080C, 2, 0), nullptr, "SetUserTime"},
{IPC::MakeHeader(0x080D, 0, 0), nullptr, "InvalidateSystemTime"},
{IPC::MakeHeader(0x080E, 5, 0), nullptr, "NotifyPlayEvent"},
{IPC::MakeHeader(0x080F, 0, 0), &PTM_S_Common::GetSoftwareClosedFlag, "GetSoftwareClosedFlag"},
{IPC::MakeHeader(0x0810, 0, 0), nullptr, "ClearSoftwareClosedFlag"},
{IPC::MakeHeader(0x0811, 0, 0), &PTM_S_Common::GetShellState, "GetShellState"},
{IPC::MakeHeader(0x0812, 0, 0), nullptr, "IsShutdownByBatteryEmpty"},
{IPC::MakeHeader(0x0813, 0, 0), nullptr, "FormatSavedata"},
{IPC::MakeHeader(0x0814, 0, 0), nullptr, "GetLegacyJumpProhibitedFlag"},
{IPC::MakeHeader(0x0818, 1, 0), nullptr, "ConfigureNew3DSCPU"},
// clang-format on
};
RegisterHandlers(functions);
}

View File

@@ -11,21 +11,23 @@ namespace Service::PTM {
PTM_U::PTM_U(std::shared_ptr<Module> ptm) : Module::Interface(std::move(ptm), "ptm:u", 26) {
static const FunctionInfo functions[] = {
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, &PTM_U::GetAdapterState, "GetAdapterState"},
{0x00060000, &PTM_U::GetShellState, "GetShellState"},
{0x00070000, &PTM_U::GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, &PTM_U::GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, &PTM_U::GetPedometerState, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, &PTM_U::GetStepHistory, "GetStepHistory"},
{0x000C0000, &PTM_U::GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// clang-format off
{IPC::MakeHeader(0x0001, 0, 2), nullptr, "RegisterAlarmClient"},
{IPC::MakeHeader(0x0002, 2, 0), nullptr, "SetRtcAlarm"},
{IPC::MakeHeader(0x0003, 0, 0), nullptr, "GetRtcAlarm"},
{IPC::MakeHeader(0x0004, 0, 0), nullptr, "CancelRtcAlarm"},
{IPC::MakeHeader(0x0005, 0, 0), &PTM_U::GetAdapterState, "GetAdapterState"},
{IPC::MakeHeader(0x0006, 0, 0), &PTM_U::GetShellState, "GetShellState"},
{IPC::MakeHeader(0x0007, 0, 0), &PTM_U::GetBatteryLevel, "GetBatteryLevel"},
{IPC::MakeHeader(0x0008, 0, 0), &PTM_U::GetBatteryChargeState, "GetBatteryChargeState"},
{IPC::MakeHeader(0x0009, 0, 0), &PTM_U::GetPedometerState, "GetPedometerState"},
{IPC::MakeHeader(0x000A, 1, 2), nullptr, "GetStepHistoryEntry"},
{IPC::MakeHeader(0x000B, 3, 2), &PTM_U::GetStepHistory, "GetStepHistory"},
{IPC::MakeHeader(0x000C, 0, 0), &PTM_U::GetTotalStepCount, "GetTotalStepCount"},
{IPC::MakeHeader(0x000D, 1, 0), nullptr, "SetPedometerRecordingMode"},
{IPC::MakeHeader(0x000E, 0, 0), nullptr, "GetPedometerRecordingMode"},
{IPC::MakeHeader(0x000F, 2, 4), nullptr, "GetStepHistoryAll"},
// clang-format on
};
RegisterHandlers(functions);
}