summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/applets/applet.cpp9
-rw-r--r--src/core/hle/applets/applet.h3
-rw-r--r--src/core/hle/service/apt/apt.cpp53
-rw-r--r--src/core/hle/service/apt/apt.h30
-rw-r--r--src/core/hle/service/apt/apt_a.cpp1
-rw-r--r--src/core/hle/service/apt/apt_s.cpp4
-rw-r--r--src/core/hle/service/apt/apt_u.cpp2
7 files changed, 84 insertions, 18 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp
index 826f6cbb6..bc2a1829e 100644
--- a/src/core/hle/applets/applet.cpp
+++ b/src/core/hle/applets/applet.cpp
@@ -89,12 +89,21 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
89 return result; 89 return result;
90} 90}
91 91
92bool IsLibraryAppletRunning() {
93 // Check the applets map for instances of any applet
94 for (auto itr = applets.begin(); itr != applets.end(); ++itr)
95 if (itr->second != nullptr)
96 return true;
97 return false;
98}
99
92void Init() { 100void Init() {
93 // Register the applet update callback 101 // Register the applet update callback
94 applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent); 102 applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent);
95} 103}
96 104
97void Shutdown() { 105void Shutdown() {
106 CoreTiming::RemoveEvent(applet_update_event);
98} 107}
99 108
100} 109}
diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h
index b235d0b8a..af442f81d 100644
--- a/src/core/hle/applets/applet.h
+++ b/src/core/hle/applets/applet.h
@@ -67,6 +67,9 @@ protected:
67 Service::APT::AppletId id; ///< Id of this Applet 67 Service::APT::AppletId id; ///< Id of this Applet
68}; 68};
69 69
70/// Returns whether a library applet is currently running
71bool IsLibraryAppletRunning();
72
70/// Initializes the HLE applets 73/// Initializes the HLE applets
71void Init(); 74void Init();
72 75
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 7b6ab4ce0..35402341b 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -101,18 +101,19 @@ void NotifyToWait(Service::Interface* self) {
101 101
102void GetLockHandle(Service::Interface* self) { 102void GetLockHandle(Service::Interface* self) {
103 u32* cmd_buff = Kernel::GetCommandBuffer(); 103 u32* cmd_buff = Kernel::GetCommandBuffer();
104 u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field 104 // Bits [0:2] are the applet type (System, Library, etc)
105 // Bit 5 tells the application that there's a pending APT parameter,
106 // this will cause the app to wait until parameter_event is signaled.
107 u32 applet_attributes = cmd_buff[1];
105 108
106 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 109 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
107 110
108 // Not sure what these parameters are used for, but retail apps check that they are 0 after 111 cmd_buff[2] = applet_attributes; // Applet Attributes, this value is passed to Enable.
109 // GetLockHandle has been called. 112 cmd_buff[3] = 0; // Least significant bit = power button state
110 cmd_buff[2] = 0; // Applet Attributes, this value is passed to Enable. 113 cmd_buff[4] = IPC::CopyHandleDesc();
111 cmd_buff[3] = 0;
112 cmd_buff[4] = 0;
113
114 cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom(); 114 cmd_buff[5] = Kernel::g_handle_table.Create(lock).MoveFrom();
115 LOG_TRACE(Service_APT, "called handle=0x%08X", cmd_buff[5]); 115
116 LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", cmd_buff[5], applet_attributes);
116} 117}
117 118
118void Enable(Service::Interface* self) { 119void Enable(Service::Interface* self) {
@@ -139,13 +140,16 @@ void IsRegistered(Service::Interface* self) {
139 u32* cmd_buff = Kernel::GetCommandBuffer(); 140 u32* cmd_buff = Kernel::GetCommandBuffer();
140 u32 app_id = cmd_buff[1]; 141 u32 app_id = cmd_buff[1];
141 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 142 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
142 /// TODO(Subv): It is currently unknown what this value (0x400) means, 143
143 /// but i believe it is used as a global "LibraryApplet" id, to verify if there's 144 // TODO(Subv): An application is considered "registered" if it has already called APT::Enable
144 /// any LibApplet currently running. This is not verified. 145 // handle this properly once we implement multiprocess support.
145 if (app_id != 0x400) 146 cmd_buff[2] = 0; // Set to not registered by default
147
148 if (app_id == static_cast<u32>(AppletId::AnyLibraryApplet)) {
149 cmd_buff[2] = HLE::Applets::IsLibraryAppletRunning() ? 1 : 0;
150 } else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) {
146 cmd_buff[2] = 1; // Set to registered 151 cmd_buff[2] = 1; // Set to registered
147 else 152 }
148 cmd_buff[2] = 0; // Set to not registered
149 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); 153 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
150} 154}
151 155
@@ -330,7 +334,26 @@ void GetAppCpuTimeLimit(Service::Interface* self) {
330void PrepareToStartLibraryApplet(Service::Interface* self) { 334void PrepareToStartLibraryApplet(Service::Interface* self) {
331 u32* cmd_buff = Kernel::GetCommandBuffer(); 335 u32* cmd_buff = Kernel::GetCommandBuffer();
332 AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); 336 AppletId applet_id = static_cast<AppletId>(cmd_buff[1]);
333 cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw; 337 auto applet = HLE::Applets::Applet::Get(applet_id);
338 if (applet) {
339 LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
340 cmd_buff[1] = RESULT_SUCCESS.raw;
341 } else {
342 cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw;
343 }
344 LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
345}
346
347void PreloadLibraryApplet(Service::Interface* self) {
348 u32* cmd_buff = Kernel::GetCommandBuffer();
349 AppletId applet_id = static_cast<AppletId>(cmd_buff[1]);
350 auto applet = HLE::Applets::Applet::Get(applet_id);
351 if (applet) {
352 LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
353 cmd_buff[1] = RESULT_SUCCESS.raw;
354 } else {
355 cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw;
356 }
334 LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); 357 LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
335} 358}
336 359
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index 72972d05b..4a72b6b5c 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -62,6 +62,7 @@ enum class AppletId : u32 {
62 Extrapad = 0x208, 62 Extrapad = 0x208,
63 Memolib = 0x209, 63 Memolib = 0x209,
64 Application = 0x300, 64 Application = 0x300,
65 AnyLibraryApplet = 0x400,
65 SoftwareKeyboard2 = 0x401, 66 SoftwareKeyboard2 = 0x401,
66}; 67};
67 68
@@ -96,8 +97,26 @@ void GetSharedFont(Service::Interface* self);
96 */ 97 */
97void NotifyToWait(Service::Interface* self); 98void NotifyToWait(Service::Interface* self);
98 99
100/**
101 * APT::GetLockHandle service function
102 * Inputs:
103 * 1 : Applet attributes
104 * Outputs:
105 * 1 : Result of function, 0 on success, otherwise error code
106 * 2 : Applet attributes
107 * 3 : Power button state
108 * 4 : IPC handle descriptor
109 * 5 : APT mutex handle
110 */
99void GetLockHandle(Service::Interface* self); 111void GetLockHandle(Service::Interface* self);
100 112
113/**
114 * APT::Enable service function
115 * Inputs:
116 * 1 : Applet attributes
117 * Outputs:
118 * 1 : Result of function, 0 on success, otherwise error code
119 */
101void Enable(Service::Interface* self); 120void Enable(Service::Interface* self);
102 121
103/** 122/**
@@ -284,6 +303,17 @@ void GetAppCpuTimeLimit(Service::Interface* self);
284void PrepareToStartLibraryApplet(Service::Interface* self); 303void PrepareToStartLibraryApplet(Service::Interface* self);
285 304
286/** 305/**
306 * APT::PreloadLibraryApplet service function
307 * Inputs:
308 * 0 : Command header [0x00160040]
309 * 1 : Id of the applet to start
310 * Outputs:
311 * 0 : Return header
312 * 1 : Result of function, 0 on success, otherwise error code
313 */
314void PreloadLibraryApplet(Service::Interface* self);
315
316/**
287 * APT::StartLibraryApplet service function 317 * APT::StartLibraryApplet service function
288 * Inputs: 318 * Inputs:
289 * 0 : Command header [0x001E0084] 319 * 0 : Command header [0x001E0084]
diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp
index 88de339f9..22800c56f 100644
--- a/src/core/hle/service/apt/apt_a.cpp
+++ b/src/core/hle/service/apt/apt_a.cpp
@@ -21,6 +21,7 @@ const Interface::FunctionInfo FunctionTable[] = {
21 {0x000D0080, ReceiveParameter, "ReceiveParameter"}, 21 {0x000D0080, ReceiveParameter, "ReceiveParameter"},
22 {0x000E0080, GlanceParameter, "GlanceParameter"}, 22 {0x000E0080, GlanceParameter, "GlanceParameter"},
23 {0x000F0100, CancelParameter, "CancelParameter"}, 23 {0x000F0100, CancelParameter, "CancelParameter"},
24 {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
24 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, 25 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
25 {0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, 26 {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
26 {0x003B0040, nullptr, "CancelLibraryApplet?"}, 27 {0x003B0040, nullptr, "CancelLibraryApplet?"},
diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp
index 396d1f04a..3ac6ff94f 100644
--- a/src/core/hle/service/apt/apt_s.cpp
+++ b/src/core/hle/service/apt/apt_s.cpp
@@ -32,9 +32,9 @@ const Interface::FunctionInfo FunctionTable[] = {
32 {0x00130000, nullptr, "GetPreparationState"}, 32 {0x00130000, nullptr, "GetPreparationState"},
33 {0x00140040, nullptr, "SetPreparationState"}, 33 {0x00140040, nullptr, "SetPreparationState"},
34 {0x00150140, nullptr, "PrepareToStartApplication"}, 34 {0x00150140, nullptr, "PrepareToStartApplication"},
35 {0x00160040, nullptr, "PreloadLibraryApplet"}, 35 {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
36 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, 36 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
37 {0x00180040, nullptr, "PrepareToStartLibraryApplet"}, 37 {0x00180040, PrepareToStartLibraryApplet,"PrepareToStartLibraryApplet"},
38 {0x00190040, nullptr, "PrepareToStartSystemApplet"}, 38 {0x00190040, nullptr, "PrepareToStartSystemApplet"},
39 {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"}, 39 {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
40 {0x001B00C4, nullptr, "StartApplication"}, 40 {0x001B00C4, nullptr, "StartApplication"},
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp
index b724cd72b..146bfd595 100644
--- a/src/core/hle/service/apt/apt_u.cpp
+++ b/src/core/hle/service/apt/apt_u.cpp
@@ -33,7 +33,7 @@ const Interface::FunctionInfo FunctionTable[] = {
33 {0x00130000, nullptr, "GetPreparationState"}, 33 {0x00130000, nullptr, "GetPreparationState"},
34 {0x00140040, nullptr, "SetPreparationState"}, 34 {0x00140040, nullptr, "SetPreparationState"},
35 {0x00150140, nullptr, "PrepareToStartApplication"}, 35 {0x00150140, nullptr, "PrepareToStartApplication"},
36 {0x00160040, nullptr, "PreloadLibraryApplet"}, 36 {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
37 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, 37 {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
38 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, 38 {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
39 {0x00190040, nullptr, "PrepareToStartSystemApplet"}, 39 {0x00190040, nullptr, "PrepareToStartSystemApplet"},