implement function ListDataTitleTicketInfos

implement function GetOutputFormat and GetInputFormat

fixed ListDataTitleTicketInfos

fixed ListDataTitleTicketInfos again!

Remove unnecessary local variable from GetOutputFormat and GetInputFormat

Align the code in am.cpp!

Restore last defined variate

fixed : commit wrong code last time

Implement function ReplySleepQuery

Update the APT FunctionTable

Correct APT::AppletUtility Parameter and comment

Correct and Update SRV code: implement function Subscribe

fixed some typo

Align the code in apt.h

fix some typo ,and update AppletUtility process way

Remove the addtion last commit

Signed-off-by: JamePeng <jame_peng@sina.com>
This commit is contained in:
JamePeng 2016-02-11 03:26:22 +08:00
parent c6198deec8
commit a48f10a20c
9 changed files with 303 additions and 78 deletions

View file

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cinttypes>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
@ -47,15 +49,14 @@ void GetNumContentInfos(Service::Interface* self) {
void ListDataTitleTicketInfos(Service::Interface* self) { void ListDataTitleTicketInfos(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
u32 ticket_count = cmd_buff[1]; u32 ticket_count = cmd_buff[1];
u64 title_id = cmd_buff[2]; u64 title_id = static_cast<u64>(cmd_buff[2]) << 32 | cmd_buff[3];
title_id = (title_id << 32) | cmd_buff[3];
u32 start_index = cmd_buff[4]; u32 start_index = cmd_buff[4];
u32 tipointer = cmd_buff[6]; u32 ticket_info_pointer = cmd_buff[6];
cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = 0x18; cmd_buff[2] = 0x18;
LOG_WARNING(Service_AM, "(STUBBED) TicketCount=0x%08X TitleID==0x%16X StartIndex=0x%08X", LOG_WARNING(Service_AM, "(STUBBED) TicketCount=0x%08X TitleID=0x%016" PRIx64 " StartIndex=0x%08X TicketInfosPointer=0x%08X",
"TicketInfosPointer=0x%08X",ticket_count, title_id, start_index, tipointer); ticket_count, title_id, start_index, ticket_info_pointer);
} }
void Init() { void Init() {

View file

@ -92,11 +92,19 @@ void GetSharedFont(Service::Interface* self) {
} }
} }
void ReplySleepQuery(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
QueryReply query_reply = static_cast<QueryReply>(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, query_reply);
}
void NotifyToWait(Service::Interface* self) { void NotifyToWait(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1]; u32 app_id = cmd_buff[1];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error 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) { void GetLockHandle(Service::Interface* self) {
@ -145,7 +153,7 @@ void IsRegistered(Service::Interface* self) {
// handle this properly once we implement multiprocess support. // handle this properly once we implement multiprocess support.
cmd_buff[2] = 0; // Set to not registered by default cmd_buff[2] = 0; // Set to not registered by default
if (app_id == static_cast<u32>(AppletId::AnyLibraryApplet)) { if (app_id == static_cast<u32>(AppletId::AnyLibrary)) {
cmd_buff[2] = HLE::Applets::IsLibraryAppletRunning() ? 1 : 0; cmd_buff[2] = HLE::Applets::IsLibraryAppletRunning() ? 1 : 0;
} else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) { } else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) {
cmd_buff[2] = 1; // Set to registered cmd_buff[2] = 1; // Set to registered
@ -288,19 +296,18 @@ void StartApplication(Service::Interface* self) {
void AppletUtility(Service::Interface* self) { void AppletUtility(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
u32 utility = cmd_buff[1];
// These are from 3dbrew - I'm not really sure what they're used for. u32 input_size = cmd_buff[2];
u32 command = cmd_buff[1]; u32 output_size = cmd_buff[3];
u32 buffer1_size = cmd_buff[2]; u32 translation_descriptor = cmd_buff[4];
u32 buffer2_size = cmd_buff[3]; u32 input_address = cmd_buff[5];
u32 buffer1_addr = cmd_buff[5];
u32 buffer2_addr = cmd_buff[65];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error 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, " LOG_WARNING(Service_APT, "(STUBBED) called Utility=0x%08X, InputSize=0x%08X, OutputSize=0x%08X, "
"buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size, "TranslationDescriptor=0x%08X, InputAddress=0x%08X", utility,
buffer1_addr, buffer2_addr); input_size, output_size, translation_descriptor, input_address);
} }
void SetAppCpuTimeLimit(Service::Interface* self) { void SetAppCpuTimeLimit(Service::Interface* self) {

View file

@ -31,6 +31,13 @@ struct AppletStartupParameter {
u8* data = nullptr; u8* data = nullptr;
}; };
enum class QueryReply : u32
{
Reject,
Accept,
Later
};
/// Signals used by APT functions /// Signals used by APT functions
enum class SignalType : u32 { enum class SignalType : u32 {
None = 0x0, None = 0x0,
@ -53,17 +60,27 @@ enum class AppletId : u32 {
InstructionManual = 0x115, InstructionManual = 0x115,
Notifications = 0x116, Notifications = 0x116,
Miiverse = 0x117, Miiverse = 0x117,
MiiversePosting = 0x118,
AmiiboSettings = 0x119,
SoftwareKeyboard1 = 0x201, SoftwareKeyboard1 = 0x201,
Ed = 0x202, MiiSelectorEd1 = 0x202,
PnoteApp = 0x204, PhotoSelector1 = 0x204,
SnoteApp = 0x205, SoundSelector1 = 0x205,
Error = 0x206, ErrorDisplay1 = 0x206,
Mint = 0x207, EShopMint1 = 0x207,
Extrapad = 0x208, Extrapad1 = 0x208,
Memolib = 0x209, Notepad1 = 0x209,
Application = 0x300, Application = 0x300,
AnyLibraryApplet = 0x400, EShopTiger = 0x301,
AnyLibrary = 0x400,
SoftwareKeyboard2 = 0x401, SoftwareKeyboard2 = 0x401,
MiiSelectorEd2 = 0x402,
PhotoSelector2 = 0x404,
SoundSelector2 = 0x405,
ErrorDisplay2 = 0x406,
EShopMint2 = 0x407,
Extrapad2 = 0x408,
Notepad2 = 0x409
}; };
/// Send a parameter to the currently-running application, which will read it via ReceiveParameter /// Send a parameter to the currently-running application, which will read it via ReceiveParameter
@ -88,6 +105,16 @@ void Initialize(Service::Interface* self);
*/ */
void GetSharedFont(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 * APT::NotifyToWait service function
* Inputs: * Inputs:
@ -260,13 +287,14 @@ void StartApplication(Service::Interface* self);
/** /**
* APT::AppletUtility service function * APT::AppletUtility service function
* Inputs: * Inputs:
* 1 : Unknown, but clearly used for something * 1 : Utility
* 2 : Buffer 1 size (purpose is unknown) * 2 : Input Size
* 3 : Buffer 2 size (purpose is unknown) * 3 : Output Size
* 5 : Buffer 1 address (purpose is unknown) * 4: Translation descriptor: (Input Size << 14) | 0x402
* 65 : Buffer 2 address (purpose is unknown) * 5 : void*, Input
* Outputs: * Outputs:
* 1 : Result of function, 0 on success, otherwise error code * 1 : Result of function, 0 on success, otherwise error code
* 2 : Applet Result
*/ */
void AppletUtility(Service::Interface* self); void AppletUtility(Service::Interface* self);

View file

@ -9,25 +9,95 @@ namespace Service {
namespace APT { namespace APT {
const Interface::FunctionInfo FunctionTable[] = { const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle?"}, {0x00010040, GetLockHandle, "GetLockHandle" },
{0x00020080, Initialize, "Initialize?"}, {0x00020080, Initialize, "Initialize" },
{0x00030040, Enable, "Enable?"}, {0x00030040, Enable, "Enable" },
{0x00040040, nullptr, "Finalize?"}, {0x00040040, nullptr, "Finalize" },
{0x00050040, nullptr, "GetAppletManInfo?"}, {0x00050040, GetAppletManInfo, "GetAppletManInfo" },
{0x00060040, nullptr, "GetAppletInfo?"}, {0x00060040, nullptr, "GetAppletInfo" },
{0x00070000, nullptr, "GetLastSignaledAppletId" },
{0x00080000, nullptr, "CountRegisteredApplet" },
{0x00090040, IsRegistered, "IsRegistered" }, {0x00090040, IsRegistered, "IsRegistered" },
{0x000A0040, nullptr, "GetAttribute" },
{0x000B0040, InquireNotification, "InquireNotification" },
{0x000C0104, SendParameter, "SendParameter" }, {0x000C0104, SendParameter, "SendParameter" },
{0x000D0080, ReceiveParameter, "ReceiveParameter" }, {0x000D0080, ReceiveParameter, "ReceiveParameter" },
{0x000E0080, GlanceParameter, "GlanceParameter" }, {0x000E0080, GlanceParameter, "GlanceParameter" },
{0x000F0100, CancelParameter, "CancelParameter" }, {0x000F0100, CancelParameter, "CancelParameter" },
{0x001000C2, nullptr, "DebugFunc" },
{0x001100C0, nullptr, "MapProgramIdForDebug" },
{0x00120040, nullptr, "SetHomeMenuAppletIdForDebug" },
{0x00130000, nullptr, "GetPreparationState" },
{0x00140040, nullptr, "SetPreparationState" },
{0x00150140, nullptr, "PrepareToStartApplication" },
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet" }, {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet" },
{0x00170040, nullptr, "FinishPreloadingLibraryApplet" },
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet" }, {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet" },
{0x00190040, nullptr, "PrepareToStartSystemApplet" },
{0x001A0000, nullptr, "PrepareToStartNewestHomeMenu" },
{0x001B00C4, nullptr, "StartApplication" },
{0x001C0000, nullptr, "WakeupApplication" },
{0x001D0000, nullptr, "CancelApplication" },
{0x001E0084, StartLibraryApplet, "StartLibraryApplet" }, {0x001E0084, StartLibraryApplet, "StartLibraryApplet" },
{0x003B0040, nullptr, "CancelLibraryApplet?"}, {0x001F0084, nullptr, "StartSystemApplet" },
{0x00430040, NotifyToWait, "NotifyToWait?"}, {0x00200044, nullptr, "StartNewestHomeMenu" },
{0x00440000, GetSharedFont, "GetSharedFont?"}, {0x00210000, nullptr, "OrderToCloseApplication" },
{0x004B00C2, AppletUtility, "AppletUtility?"}, {0x00220040, nullptr, "PrepareToCloseApplication" },
{0x00550040, nullptr, "WriteInputToNsState?"}, {0x00230040, nullptr, "PrepareToJumpToApplication" },
{0x00240044, nullptr, "JumpToApplication" },
{0x002500C0, nullptr, "PrepareToCloseLibraryApplet" },
{0x00260000, nullptr, "PrepareToCloseSystemApplet" },
{0x00270044, nullptr, "CloseApplication" },
{0x00280044, nullptr, "CloseLibraryApplet" },
{0x00290044, nullptr, "CloseSystemApplet" },
{0x002A0000, nullptr, "OrderToCloseSystemApplet" },
{0x002B0000, nullptr, "PrepareToJumpToHomeMenu" },
{0x002C0044, nullptr, "JumpToHomeMenu" },
{0x002D0000, nullptr, "PrepareToLeaveHomeMenu" },
{0x002E0044, nullptr, "LeaveHomeMenu" },
{0x002F0040, nullptr, "PrepareToLeaveResidentApplet" },
{0x00300044, nullptr, "LeaveResidentApplet" },
{0x00310100, nullptr, "PrepareToDoApplicationJump" },
{0x00320084, nullptr, "DoApplicationJump" },
{0x00330000, nullptr, "GetProgramIdOnApplicationJump" },
{0x00340084, nullptr, "SendDeliverArg" },
{0x00350080, nullptr, "ReceiveDeliverArg" },
{0x00360040, nullptr, "LoadSysMenuArg" },
{0x00370042, nullptr, "StoreSysMenuArg" },
{0x00380040, nullptr, "PreloadResidentApplet" },
{0x00390040, nullptr, "PrepareToStartResidentApplet" },
{0x003A0044, nullptr, "StartResidentApplet" },
{0x003B0040, nullptr, "CancelLibraryApplet" },
{0x003C0042, nullptr, "SendDspSleep" },
{0x003D0042, nullptr, "SendDspWakeUp" },
{0x003E0080, ReplySleepQuery, "ReplySleepQuery" },
{0x003F0040, nullptr, "ReplySleepNotificationComplete" },
{0x00400042, nullptr, "SendCaptureBufferInfo" },
{0x00410040, nullptr, "ReceiveCaptureBufferInfo" },
{0x00420080, nullptr, "SleepSystem" },
{0x00430040, NotifyToWait, "NotifyToWait" },
{0x00440000, GetSharedFont, "GetSharedFont" },
{0x00450040, nullptr, "GetWirelessRebootInfo" },
{0x00460104, nullptr, "Wrap" },
{0x00470104, nullptr, "Unwrap" },
{0x00480100, nullptr, "GetProgramInfo" },
{0x00490180, nullptr, "Reboot" },
{0x004A0040, nullptr, "GetCaptureInfo" },
{0x004B00C2, AppletUtility, "AppletUtility" },
{0x004C0000, nullptr, "SetFatalErrDispMode" },
{0x004D0080, nullptr, "GetAppletProgramInfo" },
{0x004E0000, nullptr, "HardwareResetAsync" },
{0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit" },
{0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit" },
{0x00510080, nullptr, "GetStartupArgument" },
{0x00520104, nullptr, "Wrap1" },
{0x00530104, nullptr, "Unwrap1" },
{0x00580002, nullptr, "GetProgramID" },
{0x01010000, nullptr, "CheckNew3DSApp" },
{0x01020000, nullptr, "CheckNew3DS" },
{0x01040000, nullptr, "IsStandardMemoryLayout" },
{0x01050100, nullptr, "IsTitleAllowed" }
}; };
APT_A_Interface::APT_A_Interface() { APT_A_Interface::APT_A_Interface() {

View file

@ -13,17 +13,17 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00020080, Initialize, "Initialize"}, {0x00020080, Initialize, "Initialize"},
{0x00030040, Enable, "Enable"}, {0x00030040, Enable, "Enable"},
{0x00040040, nullptr, "Finalize"}, {0x00040040, nullptr, "Finalize"},
{0x00050040, nullptr, "GetAppletManInfo"}, {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
{0x00060040, nullptr, "GetAppletInfo"}, {0x00060040, nullptr, "GetAppletInfo"},
{0x00070000, nullptr, "GetLastSignaledAppletId"}, {0x00070000, nullptr, "GetLastSignaledAppletId"},
{0x00080000, nullptr, "CountRegisteredApplet"}, {0x00080000, nullptr, "CountRegisteredApplet"},
{0x00090040, nullptr, "IsRegistered"}, {0x00090040, IsRegistered, "IsRegistered"},
{0x000A0040, nullptr, "GetAttribute"}, {0x000A0040, nullptr, "GetAttribute"},
{0x000B0040, InquireNotification, "InquireNotification"}, {0x000B0040, InquireNotification, "InquireNotification"},
{0x000C0104, nullptr, "SendParameter"}, {0x000C0104, nullptr, "SendParameter"},
{0x000D0080, ReceiveParameter, "ReceiveParameter"}, {0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"}, {0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, nullptr, "CancelParameter"}, {0x000F0100, CancelParameter, "CancelParameter"},
{0x001000C2, nullptr, "DebugFunc"}, {0x001000C2, nullptr, "DebugFunc"},
{0x001100C0, nullptr, "MapProgramIdForDebug"}, {0x001100C0, nullptr, "MapProgramIdForDebug"},
{0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"}, {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
@ -38,7 +38,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x001B00C4, nullptr, "StartApplication"}, {0x001B00C4, nullptr, "StartApplication"},
{0x001C0000, nullptr, "WakeupApplication"}, {0x001C0000, nullptr, "WakeupApplication"},
{0x001D0000, nullptr, "CancelApplication"}, {0x001D0000, nullptr, "CancelApplication"},
{0x001E0084, nullptr, "StartLibraryApplet"}, {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
{0x001F0084, nullptr, "StartSystemApplet"}, {0x001F0084, nullptr, "StartSystemApplet"},
{0x00200044, nullptr, "StartNewestHomeMenu"}, {0x00200044, nullptr, "StartNewestHomeMenu"},
{0x00210000, nullptr, "OrderToCloseApplication"}, {0x00210000, nullptr, "OrderToCloseApplication"},
@ -70,7 +70,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x003B0040, nullptr, "CancelLibraryApplet"}, {0x003B0040, nullptr, "CancelLibraryApplet"},
{0x003C0042, nullptr, "SendDspSleep"}, {0x003C0042, nullptr, "SendDspSleep"},
{0x003D0042, nullptr, "SendDspWakeUp"}, {0x003D0042, nullptr, "SendDspWakeUp"},
{0x003E0080, nullptr, "ReplySleepQuery"}, {0x003E0080, ReplySleepQuery, "ReplySleepQuery"},
{0x003F0040, nullptr, "ReplySleepNotificationComplete"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
{0x00400042, nullptr, "SendCaptureBufferInfo"}, {0x00400042, nullptr, "SendCaptureBufferInfo"},
{0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
@ -87,14 +87,16 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x004C0000, nullptr, "SetFatalErrDispMode"}, {0x004C0000, nullptr, "SetFatalErrDispMode"},
{0x004D0080, nullptr, "GetAppletProgramInfo"}, {0x004D0080, nullptr, "GetAppletProgramInfo"},
{0x004E0000, nullptr, "HardwareResetAsync"}, {0x004E0000, nullptr, "HardwareResetAsync"},
{0x004F0080, nullptr, "SetApplicationCpuTimeLimit"}, {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit" },
{0x00500040, nullptr, "GetApplicationCpuTimeLimit"}, {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit" },
{0x00510080, nullptr, "GetStartupArgument"}, {0x00510080, nullptr, "GetStartupArgument"},
{0x00520104, nullptr, "Wrap1"}, {0x00520104, nullptr, "Wrap1"},
{0x00530104, nullptr, "Unwrap1"}, {0x00530104, nullptr, "Unwrap1"},
{0x00580002, nullptr, "GetProgramID"}, {0x00580002, nullptr, "GetProgramID"},
{0x01010000, nullptr, "CheckNew3DSApp"}, {0x01010000, nullptr, "CheckNew3DSApp"},
{0x01020000, nullptr, "CheckNew3DS"} {0x01020000, nullptr, "CheckNew3DS"},
{0x01040000, nullptr, "IsStandardMemoryLayout" },
{0x01050100, nullptr, "IsTitleAllowed" }
}; };
APT_S_Interface::APT_S_Interface() { APT_S_Interface::APT_S_Interface() {

View file

@ -70,7 +70,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x003B0040, nullptr, "CancelLibraryApplet"}, {0x003B0040, nullptr, "CancelLibraryApplet"},
{0x003C0042, nullptr, "SendDspSleep"}, {0x003C0042, nullptr, "SendDspSleep"},
{0x003D0042, nullptr, "SendDspWakeUp"}, {0x003D0042, nullptr, "SendDspWakeUp"},
{0x003E0080, nullptr, "ReplySleepQuery"}, {0x003E0080, ReplySleepQuery, "ReplySleepQuery"},
{0x003F0040, nullptr, "ReplySleepNotificationComplete"}, {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
{0x00400042, nullptr, "SendCaptureBufferInfo"}, {0x00400042, nullptr, "SendCaptureBufferInfo"},
{0x00410040, nullptr, "ReceiveCaptureBufferInfo"}, {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
@ -94,7 +94,9 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00530104, nullptr, "Unwrap1"}, {0x00530104, nullptr, "Unwrap1"},
{0x00580002, nullptr, "GetProgramID"}, {0x00580002, nullptr, "GetProgramID"},
{0x01010000, nullptr, "CheckNew3DSApp"}, {0x01010000, nullptr, "CheckNew3DSApp"},
{0x01020000, nullptr, "CheckNew3DS"} {0x01020000, nullptr, "CheckNew3DS"},
{0x01040000, nullptr, "IsStandardMemoryLayout"},
{0x01050100, nullptr, "IsTitleAllowed" }
}; };
APT_U_Interface::APT_U_Interface() { APT_U_Interface::APT_U_Interface() {

View file

@ -10,32 +10,34 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace SRV // Namespace SRV
namespace SRV { namespace SRV {
static Kernel::SharedPtr<Kernel::Event> event_handle; static Kernel::SharedPtr<Kernel::Event> event_handle;
static void Initialize(Service::Interface* self) { static void RegisterClient(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = 0; // No error u32 translate_header = cmd_buff[1];
u32 current_pid = cmd_buff[2];
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_HID, "(STUBBED) called TranslateHeader=0x%08X , CurrentPID=0x%08X ",translate_header,current_pid);
} }
static void GetProcSemaphore(Service::Interface* self) { static void EnableNotification(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
// TODO(bunnei): Change to a semaphore once these have been implemented // TODO(bunnei): Change to a semaphore once these have been implemented
event_handle = Kernel::Event::Create(RESETTYPE_ONESHOT, "SRV:Event"); event_handle = Kernel::Event::Create(RESETTYPE_ONESHOT, "SRV:Event");
event_handle->Clear(); event_handle->Clear();
cmd_buff[1] = 0; // No error cmd_buff[1] = RESULT_SUCCESS.raw; // No error
cmd_buff[3] = Kernel::g_handle_table.Create(event_handle).MoveFrom(); cmd_buff[3] = Kernel::g_handle_table.Create(event_handle).MoveFrom();
} }
static void GetServiceHandle(Service::Interface* self) { static void GetServiceHandle(Service::Interface* self) {
ResultCode res = RESULT_SUCCESS;
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
ResultCode res = RESULT_SUCCESS;
std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize);
auto it = Service::g_srv_services.find(port_name); auto it = Service::g_srv_services.find(port_name);
@ -49,16 +51,84 @@ static void GetServiceHandle(Service::Interface* self) {
cmd_buff[1] = res.raw; cmd_buff[1] = res.raw;
} }
static void Subscribe(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
NotificationID notification_id = static_cast<NotificationID>(cmd_buff[1]);
std::string notification_act;
switch (notification_id)
{
case NotificationID::Terminate:
notification_act = "All processes must terminate: power-off, reboot, or FIRM-launch";
break;
case NotificationID::EnterSleepMode:
notification_act = "The system is entering sleep mode";
break;
case NotificationID::ExitSleepMode:
notification_act = "The system has exited sleep mode";
break;
case NotificationID::ErrorAtBoot:
notification_act = "Error at boot";
break;
case NotificationID::PowerButtonPressed:
notification_act = "POWER button pressed";
break;
case NotificationID::PowerButtonHeldLong:
notification_act = "POWER button held long";
break;
case NotificationID::HomeButtonPressed:
notification_act = "HOME button pressed";
break;
case NotificationID::HomeButtonReleased:
notification_act = "HOME button released";
break;
case NotificationID::WirelessEnabled:
notification_act = "The physical Wi-Fi slider is enabled";
break;
case NotificationID::SDCardInserted:
notification_act = "SD card inserted";
break;
case NotificationID::GameCartInserted:
notification_act = "Game cartridge inserted";
break;
case NotificationID::SDCardRemoved:
notification_act = "SD card removed";
break;
case NotificationID::GameCartRemoved:
notification_act = "Game cartridge removed";
break;
case NotificationID::GameCartInsertOrRemoved:
notification_act = "Game cartridge inserted or removed";
break;
default:
notification_act = "Unknown Notification ID";
break;
}
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_HID, "(STUBBED) called NotificationID=0x%08X , NotificationAct: %s ", notification_id, notification_act.c_str());
}
const Interface::FunctionInfo FunctionTable[] = { const Interface::FunctionInfo FunctionTable[] = {
{0x00010002, Initialize, "Initialize"}, {0x00010002, RegisterClient, "RegisterClient"},
{0x00020000, GetProcSemaphore, "GetProcSemaphore"}, {0x00020000, EnableNotification, "EnableNotification"},
{0x00030100, nullptr, "RegisterService"}, {0x00030100, nullptr, "RegisterService"},
{0x000400C0, nullptr, "UnregisterService"}, {0x000400C0, nullptr, "UnregisterService"},
{0x00050100, GetServiceHandle, "GetServiceHandle"}, {0x00050100, GetServiceHandle, "GetServiceHandle"},
{0x000600C2, nullptr, "RegisterHandle"}, {0x000600C2, nullptr, "RegisterHandle"},
{0x00090040, nullptr, "Subscribe"}, {0x000700C0, nullptr, "UnregisterPort" },
{0x00080100, nullptr, "GetPort" },
{0x00090040, Subscribe, "Subscribe"},
{0x000A0040, nullptr, "Unsubscribe" },
{0x000B0000, nullptr, "ReceiveNotification"}, {0x000B0000, nullptr, "ReceiveNotification"},
{0x000C0080, nullptr, "PublishToSubscriber"}, {0x000C0080, nullptr, "PublishToSubscriber"},
{0x000D0040, nullptr, "PublishAndGetSubscriber" },
{0x000E00C0, nullptr, "IsServiceRegistered" }
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -9,6 +9,33 @@
namespace SRV { namespace SRV {
enum class NotificationID : u32
{
Terminate = 0x100,
EnterSleepMode = 0x104,
ExitSleepMode = 0x105,
ErrorAtBoot = 0x108,
LaunchFlags0 = 0x110,
LaunchFlags1 = 0x111,
LaunchFlags2 = 0x112,
LaunchFlags3 = 0x113,
LaunchFlags4 = 0x114,
LaunchFlags5 = 0x115,
LaunchFlags6 = 0x116,
LaunchFlags7 = 0x117,
LaunchFlagsF = 0x11F,
PowerButtonPressed = 0x202,
PowerButtonHeldLong = 0x203,
HomeButtonPressed = 0x204,
HomeButtonReleased = 0x205,
WirelessEnabled = 0x206,
SDCardInserted = 0x207,
GameCartInserted = 0x208,
SDCardRemoved = 0x209,
GameCartRemoved = 0x20A,
GameCartInsertOrRemoved = 0x20B
};
/// Interface to "srv:" service /// Interface to "srv:" service
class Interface : public Service::Interface { class Interface : public Service::Interface {
public: public:

View file

@ -91,6 +91,15 @@ static void SetInputFormat(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[1] = RESULT_SUCCESS.raw;
} }
static void GetInputFormat(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
LOG_DEBUG(Service_Y2R, "Get input_format=%hhu", conversion.input_format);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = static_cast<u32>(conversion.input_format);
}
static void SetOutputFormat(Service::Interface* self) { static void SetOutputFormat(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
@ -100,6 +109,15 @@ static void SetOutputFormat(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; cmd_buff[1] = RESULT_SUCCESS.raw;
} }
static void GetOutputFormat(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
LOG_DEBUG(Service_Y2R, "Get output_format=%hhu", conversion.output_format);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = static_cast<u32>(conversion.output_format);
}
static void SetRotation(Service::Interface* self) { static void SetRotation(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
@ -375,9 +393,9 @@ static void DriverFinalize(Service::Interface* self) {
const Interface::FunctionInfo FunctionTable[] = { const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, SetInputFormat, "SetInputFormat"}, {0x00010040, SetInputFormat, "SetInputFormat"},
{0x00020000, nullptr, "GetInputFormat"}, {0x00020000, GetInputFormat, "GetInputFormat"},
{0x00030040, SetOutputFormat, "SetOutputFormat"}, {0x00030040, SetOutputFormat, "SetOutputFormat"},
{0x00040000, nullptr, "GetOutputFormat"}, {0x00040000, GetOutputFormat, "GetOutputFormat"},
{0x00050040, SetRotation, "SetRotation"}, {0x00050040, SetRotation, "SetRotation"},
{0x00060000, nullptr, "GetRotation"}, {0x00060000, nullptr, "GetRotation"},
{0x00070040, SetBlockAlignment, "SetBlockAlignment"}, {0x00070040, SetBlockAlignment, "SetBlockAlignment"},