From 3b0a54437c0d473202c88cf0d1dcfc41922e3ad7 Mon Sep 17 00:00:00 2001 From: JamePeng Date: Thu, 11 Feb 2016 02:09:41 +0800 Subject: [PATCH] Implement ReplySleepQuery() and ListDataTitleTicketInfos() Correct AppletUtility() parameter! Signed-off-by: JamePeng --- src/core/hle/service/am/am.cpp | 14 ++++++++++++++ src/core/hle/service/am/am.h | 14 ++++++++++++++ src/core/hle/service/am/am_app.cpp | 16 ++++++++-------- src/core/hle/service/apt/apt.cpp | 28 ++++++++++++++++++---------- src/core/hle/service/apt/apt.h | 30 +++++++++++++++++++++++++----- src/core/hle/service/apt/apt_a.cpp | 2 +- src/core/hle/service/apt/apt_s.cpp | 2 +- src/core/hle/service/apt/apt_u.cpp | 2 +- 8 files changed, 82 insertions(+), 26 deletions(-) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 06be9940e..90fdde6c7 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -44,6 +44,20 @@ void GetNumContentInfos(Service::Interface* self) { LOG_WARNING(Service_AM, "(STUBBED) called"); } +void ListDataTitleTicketInfos(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + u32 ticket_count = cmd_buff[1]; + u64 title_id = cmd_buff[2]; + title_id = (title_id << 32) | cmd_buff[3]; + u32 start_index = cmd_buff[4]; + u32 tipointer = cmd_buff[6]; + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0x18; + LOG_WARNING(Service_AM, "(STUBBED) TicketCount=0x%08X TitleID==0x%16X StartIndex=0x%08X", + "TicketInfosPointer=0x%08X",ticket_count, title_id, start_index, tipointer); +} + void Init() { using namespace Kernel; diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 15e63bc7b..d9540e747 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -50,6 +50,20 @@ void GetTitleIDList(Service::Interface* self); */ void GetNumContentInfos(Service::Interface* self); +/** +* AM::ListDataTitleTicketInfos service function +* Inputs: +* 1 : Ticket count +* 2-3 : u64, Title ID +* 4 : Start Index? +* 5 : (TicketCount * 24) << 8 | 0x4 +* 6 : Ticket Infos pointer +* Outputs: +* 1 : Result, 0 on success, otherwise error code +* 2 : Number of content infos plus one ,0x18 +*/ +void ListDataTitleTicketInfos(Service::Interface* self); + /// Initialize AM service void Init(); diff --git a/src/core/hle/service/am/am_app.cpp b/src/core/hle/service/am/am_app.cpp index 16c76a1eb..06747e6c1 100644 --- a/src/core/hle/service/am/am_app.cpp +++ b/src/core/hle/service/am/am_app.cpp @@ -9,14 +9,14 @@ namespace Service { namespace AM { const Interface::FunctionInfo FunctionTable[] = { - {0x100100C0, GetNumContentInfos, "GetNumContentInfos"}, - {0x10020104, nullptr, "FindContentInfos"}, - {0x10030142, nullptr, "ListContentInfos"}, - {0x10040102, nullptr, "DeleteContents"}, - {0x10050084, nullptr, "GetDataTitleInfos"}, - {0x10070102, nullptr, "ListDataTitleTicketInfos"}, - {0x100900C0, nullptr, "IsDataTitleInUse"}, - {0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"}, + {0x100100C0, GetNumContentInfos, "GetNumContentInfos"}, + {0x10020104, nullptr, "FindContentInfos"}, + {0x10030142, nullptr, "ListContentInfos"}, + {0x10040102, nullptr, "DeleteContents"}, + {0x10050084, nullptr, "GetDataTitleInfos"}, + {0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"}, + {0x100900C0, nullptr, "IsDataTitleInUse"}, + {0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"}, }; AM_APP_Interface::AM_APP_Interface() { diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index d0e3fe372..97f2d616e 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -92,11 +92,20 @@ void GetSharedFont(Service::Interface* self) { } } +void ReplySleepQuery(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + u32 app_id = cmd_buff[1]; + QueryReply qr = static_cast(cmd_buff[2]); + cmd_buff[1] = RESULT_SUCCESS.raw; // No error + LOG_WARNING(Service_APT, "(STUBBED) app_id=0x%08X QueryReply=0x%08X", app_id,qr); +} + + void NotifyToWait(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 app_id = cmd_buff[1]; cmd_buff[1] = RESULT_SUCCESS.raw; // No error - LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id); + LOG_WARNING(Service_APT, "(STUBBED) app_id=0x%08X", app_id); } void GetLockHandle(Service::Interface* self) { @@ -289,18 +298,17 @@ void StartApplication(Service::Interface* self) { void AppletUtility(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - // These are from 3dbrew - I'm not really sure what they're used for. - u32 command = cmd_buff[1]; - u32 buffer1_size = cmd_buff[2]; - u32 buffer2_size = cmd_buff[3]; - u32 buffer1_addr = cmd_buff[5]; - u32 buffer2_addr = cmd_buff[65]; + u32 util = cmd_buff[1]; + u32 i_size = cmd_buff[2]; + u32 o_size = cmd_buff[3]; + u32 td = cmd_buff[5]; + u32 i_addr = cmd_buff[65]; cmd_buff[1] = RESULT_SUCCESS.raw; // No error + cmd_buff[2] = RESULT_SUCCESS.raw; // No error - LOG_WARNING(Service_APT, "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " - "buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size, - buffer1_addr, buffer2_addr); + LOG_WARNING(Service_APT, "(STUBBED) called Utility=0x%08X, InputSize=0x%08X, OutputSize=0x%08X, " + "TranslationDescriptor=0x%08X, InputAddress=0x%08X", util, i_size, o_size, td, i_addr); } void SetAppCpuTimeLimit(Service::Interface* self) { diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index 01ef154fb..87607d05c 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -31,6 +31,13 @@ struct AppletStartupParameter { u8* data = nullptr; }; +enum class QueryReply : u32 +{ + REPLY_REJECT = 0x0, + REPLY_ACCEPT = 0x1, + REPLY_LATER = 0x2 +}; + /// Signals used by APT functions enum class SignalType : u32 { None = 0x0, @@ -98,6 +105,17 @@ void Initialize(Service::Interface* self); */ void GetSharedFont(Service::Interface* self); +/** +* APT::ReplySleepQuery service function +* Inputs: +* 1 : AppID +* 2 : ReplySleepQuery +* Outputs: +* 1 : Result of function, 0 on success, otherwise error code +*/ + +void ReplySleepQuery(Service::Interface* self); + /** * APT::NotifyToWait service function * Inputs: @@ -105,6 +123,7 @@ void GetSharedFont(Service::Interface* self); * Outputs: * 1 : Result of function, 0 on success, otherwise error code */ + void NotifyToWait(Service::Interface* self); /** @@ -270,13 +289,14 @@ void StartApplication(Service::Interface* self); /** * APT::AppletUtility service function * Inputs: - * 1 : Unknown, but clearly used for something - * 2 : Buffer 1 size (purpose is unknown) - * 3 : Buffer 2 size (purpose is unknown) - * 5 : Buffer 1 address (purpose is unknown) - * 65 : Buffer 2 address (purpose is unknown) + * 1 : Utility + * 2 : Input Size + * 3 : Output Size + * 4: Translation descriptor: (Input Size << 14) | 0x402 + * 5 : void*, Input * Outputs: * 1 : Result of function, 0 on success, otherwise error code + * 2 : Applet Result */ void AppletUtility(Service::Interface* self); diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp index c5b0b112f..346bdbc5b 100644 --- a/src/core/hle/service/apt/apt_a.cpp +++ b/src/core/hle/service/apt/apt_a.cpp @@ -70,7 +70,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x003B0040, nullptr, "CancelLibraryApplet" }, {0x003C0042, nullptr, "SendDspSleep" }, {0x003D0042, nullptr, "SendDspWakeUp" }, - {0x003E0080, nullptr, "ReplySleepQuery" }, + {0x003E0080, ReplySleepQuery, "ReplySleepQuery" }, {0x003F0040, nullptr, "ReplySleepNotificationComplete" }, {0x00400042, nullptr, "SendCaptureBufferInfo" }, {0x00410040, nullptr, "ReceiveCaptureBufferInfo" }, diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp index 9a21a4dfc..3170232b9 100644 --- a/src/core/hle/service/apt/apt_s.cpp +++ b/src/core/hle/service/apt/apt_s.cpp @@ -70,7 +70,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x003B0040, nullptr, "CancelLibraryApplet"}, {0x003C0042, nullptr, "SendDspSleep"}, {0x003D0042, nullptr, "SendDspWakeUp"}, - {0x003E0080, nullptr, "ReplySleepQuery"}, + {0x003E0080, ReplySleepQuery, "ReplySleepQuery"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"}, {0x00400042, nullptr, "SendCaptureBufferInfo"}, {0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index 50b4958bc..2a7e23475 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp @@ -70,7 +70,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x003B0040, nullptr, "CancelLibraryApplet"}, {0x003C0042, nullptr, "SendDspSleep"}, {0x003D0042, nullptr, "SendDspWakeUp"}, - {0x003E0080, nullptr, "ReplySleepQuery"}, + {0x003E0080, ReplySleepQuery, "ReplySleepQuery"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"}, {0x00400042, nullptr, "SendCaptureBufferInfo"}, {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},