Просмотр исходного кода

implement APT::GetStartupArgument

JamePeng 10 лет назад
Родитель
Сommit
af9a8258b9

+ 17 - 0
src/core/hle/service/apt/apt.cpp

@@ -397,6 +397,23 @@ void GetAppletInfo(Service::Interface* self) {
     LOG_WARNING(Service_APT, "(stubbed) called appid=%u", app_id);
 }
 
+void GetStartupArgument(Service::Interface* self) {
+    u32* cmd_buff = Kernel::GetCommandBuffer();
+    u32 parameter_size = cmd_buff[1];
+    StartupArgumentType startup_argument_type = static_cast<StartupArgumentType>(cmd_buff[2]);
+
+    if (parameter_size >= 0x300) {
+        LOG_ERROR(Service_APT, "Parameter size is outside the valid range (capped to 0x300): parameter_size=0x%08x", parameter_size);
+        return;
+    }
+
+    LOG_WARNING(Service_APT,"(stubbed) called startup_argument_type=%u , parameter_size=0x%08x , parameter_value=0x%08x",
+                startup_argument_type, parameter_size, Memory::Read32(cmd_buff[41]));
+
+    cmd_buff[1] = RESULT_SUCCESS.raw;
+    cmd_buff[2] = (parameter_size > 0) ? 1 : 0;
+}
+
 void Init() {
     AddService(new APT_A_Interface);
     AddService(new APT_S_Interface);

+ 17 - 0
src/core/hle/service/apt/apt.h

@@ -67,6 +67,12 @@ enum class AppletId : u32 {
     Ed2                = 0x402,
 };
 
+enum class StartupArgumentType : u32 {
+    OtherApp   = 0,
+    Restart    = 1,
+    OtherMedia = 2,
+};
+
 /// Send a parameter to the currently-running application, which will read it via ReceiveParameter
 void SendParameter(const MessageParameter& parameter);
 
@@ -344,6 +350,17 @@ void PreloadLibraryApplet(Service::Interface* self);
  */
 void StartLibraryApplet(Service::Interface* self);
 
+/**
+* APT::GetStartupArgument service function
+*  Inputs:
+*      1 : Parameter Size (capped to 0x300)
+*      2 : StartupArgumentType
+*  Outputs:
+*      0 : Return header
+*      1 : u8, Exists (0 = does not exist, 1 = exists)
+*/
+void GetStartupArgument(Service::Interface* self);
+
 /// Initialize the APT service
 void Init();
 

+ 1 - 0
src/core/hle/service/apt/apt_a.cpp

@@ -28,6 +28,7 @@ const Interface::FunctionInfo FunctionTable[] = {
     {0x00430040, NotifyToWait,                 "NotifyToWait?"},
     {0x00440000, GetSharedFont,                "GetSharedFont?"},
     {0x004B00C2, AppletUtility,                "AppletUtility?"},
+    {0x00510080, GetStartupArgument,           "GetStartupArgument"},
     {0x00550040, nullptr,                      "WriteInputToNsState?"},
 };
 

+ 1 - 1
src/core/hle/service/apt/apt_s.cpp

@@ -89,7 +89,7 @@ const Interface::FunctionInfo FunctionTable[] = {
     {0x004E0000, nullptr,               "HardwareResetAsync"},
     {0x004F0080, nullptr,               "SetApplicationCpuTimeLimit"},
     {0x00500040, nullptr,               "GetApplicationCpuTimeLimit"},
-    {0x00510080, nullptr,               "GetStartupArgument"},
+    {0x00510080, GetStartupArgument,    "GetStartupArgument"},
     {0x00520104, nullptr,               "Wrap1"},
     {0x00530104, nullptr,               "Unwrap1"},
     {0x00580002, nullptr,               "GetProgramID"},

+ 1 - 1
src/core/hle/service/apt/apt_u.cpp

@@ -89,7 +89,7 @@ const Interface::FunctionInfo FunctionTable[] = {
     {0x004E0000, nullptr,                         "HardwareResetAsync"},
     {0x004F0080, SetAppCpuTimeLimit,              "SetAppCpuTimeLimit"},
     {0x00500040, GetAppCpuTimeLimit,              "GetAppCpuTimeLimit"},
-    {0x00510080, nullptr,                         "GetStartupArgument"},
+    {0x00510080, GetStartupArgument,              "GetStartupArgument"},
     {0x00520104, nullptr,                         "Wrap1"},
     {0x00530104, nullptr,                         "Unwrap1"},
     {0x00580002, nullptr,                         "GetProgramID"},