diff options
| -rw-r--r-- | src/core/hle/service/ptm/ptm.cpp | 50 | ||||
| -rw-r--r-- | src/core/hle/service/ptm/ptm.h | 42 | ||||
| -rw-r--r-- | src/core/hle/service/ptm/ptm_play.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/ptm/ptm_sysm.cpp | 75 | ||||
| -rw-r--r-- | src/core/hle/service/ptm/ptm_u.cpp | 62 |
5 files changed, 112 insertions, 125 deletions
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 6480a323d..2c7d49c9f 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | ||
| 6 | |||
| 5 | #include "core/file_sys/file_backend.h" | 7 | #include "core/file_sys/file_backend.h" |
| 6 | #include "core/hle/service/fs/archive.h" | 8 | #include "core/hle/service/fs/archive.h" |
| 7 | #include "core/hle/service/ptm/ptm.h" | 9 | #include "core/hle/service/ptm/ptm.h" |
| @@ -23,20 +25,56 @@ static bool shell_open; | |||
| 23 | 25 | ||
| 24 | static bool battery_is_charging; | 26 | static bool battery_is_charging; |
| 25 | 27 | ||
| 26 | u32 GetAdapterState() { | 28 | void GetAdapterState(Service::Interface* self) { |
| 29 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 30 | |||
| 27 | // TODO(purpasmart96): This function is only a stub, | 31 | // TODO(purpasmart96): This function is only a stub, |
| 28 | // it returns a valid result without implementing full functionality. | 32 | // it returns a valid result without implementing full functionality. |
| 29 | return battery_is_charging ? 1 : 0; | 33 | |
| 34 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 35 | cmd_buff[2] = battery_is_charging ? 1 : 0; | ||
| 36 | |||
| 37 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 30 | } | 38 | } |
| 31 | 39 | ||
| 32 | u32 GetShellState() { | 40 | void GetShellState(Service::Interface* self) { |
| 33 | return shell_open ? 1 : 0; | 41 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 42 | |||
| 43 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 44 | cmd_buff[2] = shell_open ? 1 : 0; | ||
| 34 | } | 45 | } |
| 35 | 46 | ||
| 36 | ChargeLevels GetBatteryLevel() { | 47 | void GetBatteryLevel(Service::Interface* self) { |
| 48 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 49 | |||
| 37 | // TODO(purpasmart96): This function is only a stub, | 50 | // TODO(purpasmart96): This function is only a stub, |
| 38 | // it returns a valid result without implementing full functionality. | 51 | // it returns a valid result without implementing full functionality. |
| 39 | return ChargeLevels::CompletelyFull; // Set to a completely full battery | 52 | |
| 53 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 54 | cmd_buff[2] = static_cast<u32>(ChargeLevels::CompletelyFull); // Set to a completely full battery | ||
| 55 | |||
| 56 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 57 | } | ||
| 58 | |||
| 59 | void GetBatteryChargeState(Service::Interface* self) { | ||
| 60 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 61 | |||
| 62 | // TODO(purpasmart96): This function is only a stub, | ||
| 63 | // it returns a valid result without implementing full functionality. | ||
| 64 | |||
| 65 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 66 | cmd_buff[2] = battery_is_charging ? 1 : 0; | ||
| 67 | |||
| 68 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 69 | } | ||
| 70 | |||
| 71 | void IsLegacyPowerOff(Service::Interface* self) { | ||
| 72 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 73 | |||
| 74 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 75 | cmd_buff[2] = 0; | ||
| 76 | |||
| 77 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 40 | } | 78 | } |
| 41 | 79 | ||
| 42 | void Init() { | 80 | void Init() { |
diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index 3c776aa8a..493e6a11f 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include "core/hle/service/service.h" | ||
| 8 | #include "core/hle/result.h" | 9 | #include "core/hle/result.h" |
| 9 | 10 | ||
| 10 | namespace Service { | 11 | namespace Service { |
| @@ -35,25 +36,48 @@ struct GameCoin { | |||
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | /** | 38 | /** |
| 38 | * Returns whether the battery is charging or not. | ||
| 39 | * It is unknown if GetAdapterState is the same as GetBatteryChargeState, | 39 | * It is unknown if GetAdapterState is the same as GetBatteryChargeState, |
| 40 | * it is likely to just be a duplicate function of GetBatteryChargeState | 40 | * it is likely to just be a duplicate function of GetBatteryChargeState |
| 41 | * that controls another part of the HW. | 41 | * that controls another part of the HW. |
| 42 | * @returns 1 if the battery is charging, and 0 otherwise. | 42 | * PTM::GetAdapterState service function |
| 43 | * Outputs: | ||
| 44 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 45 | * 2 : Output of function, 0 = not charging, 1 = charging. | ||
| 43 | */ | 46 | */ |
| 44 | u32 GetAdapterState(); | 47 | void GetAdapterState(Interface* self); |
| 45 | 48 | ||
| 46 | /** | 49 | /** |
| 47 | * Returns whether the 3DS's physical shell casing is open or closed | 50 | * PTM::GetShellState service function. |
| 48 | * @returns 1 if the shell is open, and 0 if otherwise | 51 | * Outputs: |
| 52 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 53 | * 2 : Whether the 3DS's physical shell casing is open (1) or closed (0) | ||
| 49 | */ | 54 | */ |
| 50 | u32 GetShellState(); | 55 | void GetShellState(Interface* self); |
| 51 | 56 | ||
| 52 | /** | 57 | /** |
| 53 | * Get the current battery's charge level. | 58 | * PTM::GetBatteryLevel service function |
| 54 | * @returns The battery's charge level. | 59 | * Outputs: |
| 60 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 61 | * 2 : Battery level, 5 = completely full battery, 4 = mostly full battery, | ||
| 62 | * 3 = half full battery, 2 = low battery, 1 = critical battery. | ||
| 55 | */ | 63 | */ |
| 56 | ChargeLevels GetBatteryLevel(); | 64 | void GetBatteryLevel(Interface* self); |
| 65 | |||
| 66 | /** | ||
| 67 | * PTM::GetBatteryChargeState service function | ||
| 68 | * Outputs: | ||
| 69 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 70 | * 2 : Output of function, 0 = not charging, 1 = charging. | ||
| 71 | */ | ||
| 72 | void GetBatteryChargeState(Interface* self); | ||
| 73 | |||
| 74 | /** | ||
| 75 | * PTM::IsLegacyPowerOff service function | ||
| 76 | * Outputs: | ||
| 77 | * 1: Result code, 0 on success, otherwise error code | ||
| 78 | * 2: Whether the system is going through a power off | ||
| 79 | */ | ||
| 80 | void IsLegacyPowerOff(Interface* self); | ||
| 57 | 81 | ||
| 58 | /// Initialize the PTM service | 82 | /// Initialize the PTM service |
| 59 | void Init(); | 83 | void Init(); |
diff --git a/src/core/hle/service/ptm/ptm_play.cpp b/src/core/hle/service/ptm/ptm_play.cpp index 8e8ae8558..48e68a3d8 100644 --- a/src/core/hle/service/ptm/ptm_play.cpp +++ b/src/core/hle/service/ptm/ptm_play.cpp | |||
| @@ -9,10 +9,10 @@ namespace Service { | |||
| 9 | namespace PTM { | 9 | namespace PTM { |
| 10 | 10 | ||
| 11 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const Interface::FunctionInfo FunctionTable[] = { |
| 12 | { 0x08070082, nullptr, "GetPlayHistory" }, | 12 | {0x08070082, nullptr, "GetPlayHistory"}, |
| 13 | { 0x08080000, nullptr, "GetPlayHistoryStart" }, | 13 | {0x08080000, nullptr, "GetPlayHistoryStart"}, |
| 14 | { 0x08090000, nullptr, "GetPlayHistoryLength" }, | 14 | {0x08090000, nullptr, "GetPlayHistoryLength"}, |
| 15 | { 0x080B0080, nullptr, "CalcPlayHistoryStart" }, | 15 | {0x080B0080, nullptr, "CalcPlayHistoryStart"}, |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | PTM_Play_Interface::PTM_Play_Interface() { | 18 | PTM_Play_Interface::PTM_Play_Interface() { |
diff --git a/src/core/hle/service/ptm/ptm_sysm.cpp b/src/core/hle/service/ptm/ptm_sysm.cpp index 13322bdbb..655658f3b 100644 --- a/src/core/hle/service/ptm/ptm_sysm.cpp +++ b/src/core/hle/service/ptm/ptm_sysm.cpp | |||
| @@ -2,57 +2,44 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/make_unique.h" | ||
| 6 | #include "core/file_sys/archive_extsavedata.h" | ||
| 7 | #include "core/hle/hle.h" | 5 | #include "core/hle/hle.h" |
| 6 | #include "core/hle/service/ptm/ptm.h" | ||
| 8 | #include "core/hle/service/ptm/ptm_sysm.h" | 7 | #include "core/hle/service/ptm/ptm_sysm.h" |
| 9 | 8 | ||
| 10 | namespace Service { | 9 | namespace Service { |
| 11 | namespace PTM { | 10 | namespace PTM { |
| 12 | 11 | ||
| 13 | /** | ||
| 14 | * Returns whether the system is powering off (?) | ||
| 15 | * Outputs: | ||
| 16 | * 1: Result code, 0 on success, otherwise error code | ||
| 17 | * 2: Whether the system is going through a power off | ||
| 18 | */ | ||
| 19 | static void IsLegacyPowerOff(Service::Interface* self) { | ||
| 20 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 21 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 22 | cmd_buff[2] = 0; | ||
| 23 | } | ||
| 24 | |||
| 25 | const Interface::FunctionInfo FunctionTable[] = { | 12 | const Interface::FunctionInfo FunctionTable[] = { |
| 26 | {0x040100C0, nullptr, "SetRtcAlarmEx"}, | 13 | {0x040100C0, nullptr, "SetRtcAlarmEx"}, |
| 27 | {0x04020042, nullptr, "ReplySleepQuery"}, | 14 | {0x04020042, nullptr, "ReplySleepQuery"}, |
| 28 | {0x04030042, nullptr, "NotifySleepPreparationComplete"}, | 15 | {0x04030042, nullptr, "NotifySleepPreparationComplete"}, |
| 29 | {0x04040102, nullptr, "SetWakeupTrigger"}, | 16 | {0x04040102, nullptr, "SetWakeupTrigger"}, |
| 30 | {0x04050000, nullptr, "GetAwakeReason"}, | 17 | {0x04050000, nullptr, "GetAwakeReason"}, |
| 31 | {0x04060000, nullptr, "RequestSleep"}, | 18 | {0x04060000, nullptr, "RequestSleep"}, |
| 32 | {0x040700C0, nullptr, "ShutdownAsync"}, | 19 | {0x040700C0, nullptr, "ShutdownAsync"}, |
| 33 | {0x04080000, nullptr, "Awake"}, | 20 | {0x04080000, nullptr, "Awake"}, |
| 34 | {0x04090080, nullptr, "RebootAsync"}, | 21 | {0x04090080, nullptr, "RebootAsync"}, |
| 35 | {0x040A0000, nullptr, "CheckNew3DS"}, | 22 | {0x040A0000, nullptr, "CheckNew3DS"}, |
| 36 | {0x08010640, nullptr, "SetInfoLEDPattern"}, | 23 | {0x08010640, nullptr, "SetInfoLEDPattern"}, |
| 37 | {0x08020040, nullptr, "SetInfoLEDPatternHeader"}, | 24 | {0x08020040, nullptr, "SetInfoLEDPatternHeader"}, |
| 38 | {0x08030000, nullptr, "GetInfoLEDStatus"}, | 25 | {0x08030000, nullptr, "GetInfoLEDStatus"}, |
| 39 | {0x08040040, nullptr, "SetBatteryEmptyLEDPattern"}, | 26 | {0x08040040, nullptr, "SetBatteryEmptyLEDPattern"}, |
| 40 | {0x08050000, nullptr, "ClearStepHistory"}, | 27 | {0x08050000, nullptr, "ClearStepHistory"}, |
| 41 | {0x080600C2, nullptr, "SetStepHistory"}, | 28 | {0x080600C2, nullptr, "SetStepHistory"}, |
| 42 | {0x08070082, nullptr, "GetPlayHistory"}, | 29 | {0x08070082, nullptr, "GetPlayHistory"}, |
| 43 | {0x08080000, nullptr, "GetPlayHistoryStart"}, | 30 | {0x08080000, nullptr, "GetPlayHistoryStart"}, |
| 44 | {0x08090000, nullptr, "GetPlayHistoryLength"}, | 31 | {0x08090000, nullptr, "GetPlayHistoryLength"}, |
| 45 | {0x080A0000, nullptr, "ClearPlayHistory"}, | 32 | {0x080A0000, nullptr, "ClearPlayHistory"}, |
| 46 | {0x080B0080, nullptr, "CalcPlayHistoryStart"}, | 33 | {0x080B0080, nullptr, "CalcPlayHistoryStart"}, |
| 47 | {0x080C0080, nullptr, "SetUserTime"}, | 34 | {0x080C0080, nullptr, "SetUserTime"}, |
| 48 | {0x080D0000, nullptr, "InvalidateSystemTime"}, | 35 | {0x080D0000, nullptr, "InvalidateSystemTime"}, |
| 49 | {0x080E0140, nullptr, "NotifyPlayEvent"}, | 36 | {0x080E0140, nullptr, "NotifyPlayEvent"}, |
| 50 | {0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"}, | 37 | {0x080F0000, IsLegacyPowerOff, "IsLegacyPowerOff"}, |
| 51 | {0x08100000, nullptr, "ClearLegacyPowerOff"}, | 38 | {0x08100000, nullptr, "ClearLegacyPowerOff"}, |
| 52 | {0x08110000, nullptr, "GetShellStatus"}, | 39 | {0x08110000, nullptr, "GetShellStatus"}, |
| 53 | {0x08120000, nullptr, "IsShutdownByBatteryEmpty"}, | 40 | {0x08120000, nullptr, "IsShutdownByBatteryEmpty"}, |
| 54 | {0x08130000, nullptr, "FormatSavedata"}, | 41 | {0x08130000, nullptr, "FormatSavedata"}, |
| 55 | {0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"} | 42 | {0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"} |
| 56 | }; | 43 | }; |
| 57 | 44 | ||
| 58 | PTM_Sysm_Interface::PTM_Sysm_Interface() { | 45 | PTM_Sysm_Interface::PTM_Sysm_Interface() { |
diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp index 9d6a5b0d7..3f5e9c7c1 100644 --- a/src/core/hle/service/ptm/ptm_u.cpp +++ b/src/core/hle/service/ptm/ptm_u.cpp | |||
| @@ -11,68 +11,6 @@ | |||
| 11 | namespace Service { | 11 | namespace Service { |
| 12 | namespace PTM { | 12 | namespace PTM { |
| 13 | 13 | ||
| 14 | /** | ||
| 15 | * PTM_U::GetAdapterState service function | ||
| 16 | * Outputs: | ||
| 17 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 18 | * 2 : Output of function, 0 = not charging, 1 = charging. | ||
| 19 | */ | ||
| 20 | static void GetAdapterState(Service::Interface* self) { | ||
| 21 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 22 | |||
| 23 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 24 | cmd_buff[2] = GetAdapterState(); | ||
| 25 | |||
| 26 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 27 | } | ||
| 28 | |||
| 29 | /* | ||
| 30 | * PTM_User::GetShellState service function. | ||
| 31 | * Outputs: | ||
| 32 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 33 | * 2 : Whether the 3DS's physical shell casing is open (1) or closed (0) | ||
| 34 | */ | ||
| 35 | static void GetShellState(Service::Interface* self) { | ||
| 36 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 37 | |||
| 38 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 39 | cmd_buff[2] = GetShellState(); | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * PTM_U::GetBatteryLevel service function | ||
| 44 | * Outputs: | ||
| 45 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 46 | * 2 : Battery level, 5 = completely full battery, 4 = mostly full battery, | ||
| 47 | * 3 = half full battery, 2 = low battery, 1 = critical battery. | ||
| 48 | */ | ||
| 49 | static void GetBatteryLevel(Service::Interface* self) { | ||
| 50 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 51 | |||
| 52 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 53 | cmd_buff[2] = static_cast<u32>(GetBatteryLevel()); | ||
| 54 | |||
| 55 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 56 | } | ||
| 57 | |||
| 58 | /** | ||
| 59 | * PTM_U::GetBatteryChargeState service function | ||
| 60 | * Outputs: | ||
| 61 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 62 | * 2 : Output of function, 0 = not charging, 1 = charging. | ||
| 63 | */ | ||
| 64 | static void GetBatteryChargeState(Service::Interface* self) { | ||
| 65 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 66 | |||
| 67 | // TODO(purpasmart96): This function is only a stub, | ||
| 68 | // it returns a valid result without implementing full functionality. | ||
| 69 | |||
| 70 | cmd_buff[1] = RESULT_SUCCESS.raw; | ||
| 71 | cmd_buff[2] = GetAdapterState(); | ||
| 72 | |||
| 73 | LOG_WARNING(Service_PTM, "(STUBBED) called"); | ||
| 74 | } | ||
| 75 | |||
| 76 | const Interface::FunctionInfo FunctionTable[] = { | 14 | const Interface::FunctionInfo FunctionTable[] = { |
| 77 | {0x00010002, nullptr, "RegisterAlarmClient"}, | 15 | {0x00010002, nullptr, "RegisterAlarmClient"}, |
| 78 | {0x00020080, nullptr, "SetRtcAlarm"}, | 16 | {0x00020080, nullptr, "SetRtcAlarm"}, |