summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2015-05-12 23:10:54 -0400
committerGravatar bunnei2015-05-12 23:10:54 -0400
commit7d21b0663bf7b7eac070dd5a7307ded6584ba3b5 (patch)
treeb2c52a550854f3a29f83f87110989656a21c783b
parentMerge pull request #760 from yuriks/gpu-profile (diff)
parentPTM: Changed the way the ptm services are handled to be like the (diff)
downloadyuzu-7d21b0663bf7b7eac070dd5a7307ded6584ba3b5.tar.gz
yuzu-7d21b0663bf7b7eac070dd5a7307ded6584ba3b5.tar.xz
yuzu-7d21b0663bf7b7eac070dd5a7307ded6584ba3b5.zip
Merge pull request #756 from purpasmart96/ptm_service_changes
PTM: Changed the ptm services to be like the IR, HID, and APT services.
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/ptm/ptm.cpp50
-rw-r--r--src/core/hle/service/ptm/ptm.h42
-rw-r--r--src/core/hle/service/ptm/ptm_play.cpp8
-rw-r--r--src/core/hle/service/ptm/ptm_sysm.cpp75
-rw-r--r--src/core/hle/service/ptm/ptm_u.cpp62
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
24static bool battery_is_charging; 26static bool battery_is_charging;
25 27
26u32 GetAdapterState() { 28void 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
32u32 GetShellState() { 40void 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
36ChargeLevels GetBatteryLevel() { 47void 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
59void 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
71void 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
42void Init() { 80void 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
10namespace Service { 11namespace 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 */
44u32 GetAdapterState(); 47void 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 */
50u32 GetShellState(); 55void 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 */
56ChargeLevels GetBatteryLevel(); 64void 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 */
72void 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 */
80void IsLegacyPowerOff(Interface* self);
57 81
58/// Initialize the PTM service 82/// Initialize the PTM service
59void Init(); 83void 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 {
9namespace PTM { 9namespace PTM {
10 10
11const Interface::FunctionInfo FunctionTable[] = { 11const 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
18PTM_Play_Interface::PTM_Play_Interface() { 18PTM_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
10namespace Service { 9namespace Service {
11namespace PTM { 10namespace 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 */
19static 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
25const Interface::FunctionInfo FunctionTable[] = { 12const 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
58PTM_Sysm_Interface::PTM_Sysm_Interface() { 45PTM_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 @@
11namespace Service { 11namespace Service {
12namespace PTM { 12namespace 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 */
20static 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 */
35static 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 */
49static 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 */
64static 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
76const Interface::FunctionInfo FunctionTable[] = { 14const Interface::FunctionInfo FunctionTable[] = {
77 {0x00010002, nullptr, "RegisterAlarmClient"}, 15 {0x00010002, nullptr, "RegisterAlarmClient"},
78 {0x00020080, nullptr, "SetRtcAlarm"}, 16 {0x00020080, nullptr, "SetRtcAlarm"},