From 8c16df695ca1668aa407fbbb3d5b9ebf91b57cb8 Mon Sep 17 00:00:00 2001 From: Gareth Higgins Date: Fri, 10 Apr 2015 01:59:36 -0400 Subject: [PATCH] Added Service to ATP, and PTM Added stubbed ATP::Uknown_0x01010000 Added PTM::CheckNew3Ds --- src/core/hle/service/apt/apt.cpp | 18 ++++++++++++++++++ src/core/hle/service/apt/apt.h | 9 +++++++++ src/core/hle/service/apt/apt_s.cpp | 1 + src/core/hle/service/apt/apt_u.cpp | 1 + src/core/hle/service/ptm/ptm.cpp | 4 ++++ src/core/hle/service/ptm/ptm.h | 6 ++++++ src/core/hle/service/ptm/ptm_sysm.cpp | 16 +++++++++++++++- src/core/hle/service/ptm/ptm_sysm.h | 6 ++++++ 8 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 4861d9e5f..73c398941 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -16,6 +16,8 @@ #include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/thread.h" +#include "core/hle/service/ptm/ptm.h" + namespace Service { namespace APT { @@ -278,6 +280,22 @@ void GetAppCpuTimeLimit(Service::Interface* self) { LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value); } +void Unknown_0x01010000(Service::Interface* self){ + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + + // When a certain NS state field (internal NS state in .data/.bss.) is non-zero, the output value is zero + if (false){ + cmd_buff[2] = 0; + } + else{ + cmd_buff[2] = PTM::CheckNew3Ds(); + } + + LOG_WARNING(Service_APT, "(STUBBED) does not check internal NS state field"); +} + void Init() { AddService(new APT_A_Interface); AddService(new APT_S_Interface); diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index e7fa39325..2684b9b00 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -249,6 +249,15 @@ void SetAppCpuTimeLimit(Service::Interface* self); */ void GetAppCpuTimeLimit(Service::Interface* self); +/** +* From 3Ds Brew: +* This writes an output u8 to cmdreply indexword[2]. +* This uses PTMSYSM:CheckNew3DS. +* When a certain NS state field (internal NS state in .data/.bss.) is non-zero, the output value is zero, otherwise the output is from PTMSYSM:CheckNew3DS. +* Normally this NS state field is zero, however this state field is set to 1 when APT:PrepareToStartApplication is used with flags bit8 is set. +*/ +void Unknown_0x01010000(Service::Interface* self); + /// Initialize the APT service void Init(); diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp index 3fd348651..c576714d3 100644 --- a/src/core/hle/service/apt/apt_s.cpp +++ b/src/core/hle/service/apt/apt_s.cpp @@ -94,6 +94,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x004E0000, nullptr, "HardwareResetAsync"}, {0x004F0080, nullptr, "SetApplicationCpuTimeLimit"}, {0x00500040, nullptr, "GetApplicationCpuTimeLimit"}, + {0x01010000, Unknown_0x01010000, "Unknown_0x01010000" }, }; APT_S_Interface::APT_S_Interface() { diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index 5ab23801e..4fe29f2bf 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp @@ -93,6 +93,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x004E0000, nullptr, "HardwareResetAsync"}, {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"}, {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"}, + {0x01010000, Unknown_0x01010000, "Unknown_0x01010000"}, }; APT_U_Interface::APT_U_Interface() { diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 57a301bec..891605c37 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -38,6 +38,10 @@ ChargeLevels GetBatteryLevel() { return ChargeLevels::CompletelyFull; // Set to a completely full battery } +u8 CheckNew3Ds(){ + return static_cast(PhysicalVersion::Old3Ds); +} + void Init() { AddService(new PTM_Play_Interface); AddService(new PTM_Sysm_Interface); diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index 3c776aa8a..3bb8208b1 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h @@ -55,6 +55,12 @@ u32 GetShellState(); */ ChargeLevels GetBatteryLevel(); +/** +* Checks the physical version of the 3Ds +* @returns The physical version of the 3Ds +*/ +u8 CheckNew3Ds(void); + /// Initialize the PTM service void Init(); diff --git a/src/core/hle/service/ptm/ptm_sysm.cpp b/src/core/hle/service/ptm/ptm_sysm.cpp index 2d841f69c..012823359 100644 --- a/src/core/hle/service/ptm/ptm_sysm.cpp +++ b/src/core/hle/service/ptm/ptm_sysm.cpp @@ -6,6 +6,7 @@ #include "core/file_sys/archive_extsavedata.h" #include "core/hle/hle.h" #include "core/hle/service/ptm/ptm_sysm.h" +#include "core/hle/service/ptm/ptm.h" namespace Service { namespace PTM { @@ -22,6 +23,19 @@ void IsLegacyPowerOff(Service::Interface* self) { cmd_buff[2] = 0; } +/** +* Checks the physical version of the 3Ds +* Outputs: +* 0 : Return header +* 1 : 0 if old 3Ds, 1 if new 3DS +*/ +void CheckNew3Ds(Service::Interface* self){ + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = PTM::CheckNew3Ds(); +} + const Interface::FunctionInfo FunctionTable[] = { {0x040100C0, nullptr, "SetRtcAlarmEx"}, {0x04020042, nullptr, "ReplySleepQuery"}, @@ -32,7 +46,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x040700C0, nullptr, "ShutdownAsync"}, {0x04080000, nullptr, "Awake"}, {0x04090080, nullptr, "RebootAsync"}, - {0x040A0000, nullptr, "CheckNew3DS"}, + {0x040A0000, CheckNew3Ds, "CheckNew3DS"}, {0x08010640, nullptr, "SetInfoLEDPattern"}, {0x08020040, nullptr, "SetInfoLEDPatternHeader"}, {0x08030000, nullptr, "GetInfoLEDStatus"}, diff --git a/src/core/hle/service/ptm/ptm_sysm.h b/src/core/hle/service/ptm/ptm_sysm.h index e37f20546..2b557a885 100644 --- a/src/core/hle/service/ptm/ptm_sysm.h +++ b/src/core/hle/service/ptm/ptm_sysm.h @@ -9,6 +9,12 @@ namespace Service { namespace PTM { +/// Physical version of the 3Ds +enum class PhysicalVersion : u8 { + Old3Ds = 0, + New3Ds = 1, +}; + class PTM_Sysm_Interface : public Interface { public: PTM_Sysm_Interface();