summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/apt
diff options
context:
space:
mode:
authorpurpasmart96 <kanzoconfigz@hotmail.com>2015-03-08 02:54:16 +0100
committerpurpasmart96 <kanzoconfigz@hotmail.com>2015-04-03 05:05:11 +0200
commit198c0ddc72d59f8e288c1074ee0bb1169f706cac (patch)
tree5ecee1d8a979d0e7aeed4de12ae85ed935d31932 /src/core/hle/service/apt
parentMerge pull request #656 from Subv/nz (diff)
downloadyuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.tar
yuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.tar.gz
yuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.tar.bz2
yuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.tar.lz
yuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.tar.xz
yuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.tar.zst
yuzu-198c0ddc72d59f8e288c1074ee0bb1169f706cac.zip
Diffstat (limited to 'src/core/hle/service/apt')
-rw-r--r--src/core/hle/service/apt/apt.cpp74
-rw-r--r--src/core/hle/service/apt/apt.h49
-rw-r--r--src/core/hle/service/apt/apt_a.cpp6
3 files changed, 102 insertions, 27 deletions
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 5971f860b..4861d9e5f 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -28,16 +28,21 @@ namespace APT {
static const VAddr SHARED_FONT_VADDR = 0x18000000;
/// Handle to shared memory region designated to for shared system font
-static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem;
+static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem = nullptr;
-static Kernel::SharedPtr<Kernel::Mutex> lock;
-static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event
-static Kernel::SharedPtr<Kernel::Event> pause_event = 0; ///< APT pause event
+static Kernel::SharedPtr<Kernel::Mutex> lock = nullptr;
+static Kernel::SharedPtr<Kernel::Event> notification_event = nullptr; ///< APT notification event
+static Kernel::SharedPtr<Kernel::Event> pause_event = nullptr; ///< APT pause event
static std::vector<u8> shared_font;
+static u32 cpu_percent = 0; ///< CPU time available to the running application
+
void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
+ u32 app_id = cmd_buff[1];
+ u32 flags = cmd_buff[2];
+ cmd_buff[2] = 0x04000000; // According to 3dbrew, this value should be 0x04000000
cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom();
cmd_buff[4] = Kernel::g_handle_table.Create(pause_event).MoveFrom();
@@ -49,6 +54,8 @@ void Initialize(Service::Interface* self) {
lock->Release();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+
+ LOG_TRACE(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags);
}
void GetSharedFont(Service::Interface* self) {
@@ -190,7 +197,38 @@ void CancelParameter(Service::Interface* self) {
cmd_buff[2] = 1; // Set to Success
LOG_WARNING(Service_APT, "(STUBBED) called flag1=0x%08X, unk=0x%08X, flag2=0x%08X, app_id=0x%08X",
- flag1, unk, flag2, app_id);
+ flag1, unk, flag2, app_id);
+}
+
+void PrepareToStartApplication(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+ u32 title_info1 = cmd_buff[1];
+ u32 title_info2 = cmd_buff[2];
+ u32 title_info3 = cmd_buff[3];
+ u32 title_info4 = cmd_buff[4];
+ u32 flags = cmd_buff[5];
+
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+
+ LOG_WARNING(Service_APT, "(STUBBED) called title_info1=0x%08X, title_info2=0x%08X, title_info3=0x%08X,"
+ "title_info4=0x%08X, flags=0x%08X", title_info1, title_info2, title_info3, title_info4, flags);
+}
+
+void StartApplication(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+ u32 buffer1_size = cmd_buff[1];
+ u32 buffer2_size = cmd_buff[2];
+ u32 flag = cmd_buff[3];
+ u32 size1 = cmd_buff[4];
+ u32 buffer1_ptr = cmd_buff[5];
+ u32 size2 = cmd_buff[6];
+ u32 buffer2_ptr = cmd_buff[7];
+
+ cmd_buff[1] = RESULT_SUCCESS.raw; // No error
+
+ LOG_WARNING(Service_APT, "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
+ "size1=0x%08X, buffer1_ptr=0x%08X, size2=0x%08X, buffer2_ptr=0x%08X",
+ buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
}
void AppletUtility(Service::Interface* self) {
@@ -205,15 +243,15 @@ void AppletUtility(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, "
- "buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size,
+ LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, "
+ "buffer1_addr=0x%08X, buffer2_addr=0x%08X", unk, buffer1_size, buffer2_size,
buffer1_addr, buffer2_addr);
}
void SetAppCpuTimeLimit(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- u32 value = cmd_buff[1];
- u32 percent = cmd_buff[2];
+ u32 value = cmd_buff[1];
+ cpu_percent = cmd_buff[2];
if (value != 1) {
LOG_ERROR(Service_APT, "This value should be one, but is actually %u!", value);
@@ -221,27 +259,26 @@ void SetAppCpuTimeLimit(Service::Interface* self) {
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- LOG_WARNING(Service_APT, "(STUBBED) called percent=0x%08X, value=0x%08x", percent, value);
+ LOG_WARNING(Service_APT, "(STUBBED) called cpu_percent=%u, value=%u", cpu_percent, value);
}
void GetAppCpuTimeLimit(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 value = cmd_buff[1];
+ ASSERT(cpu_percent != 0);
+
if (value != 1) {
LOG_ERROR(Service_APT, "This value should be one, but is actually %u!", value);
}
- // TODO(purpasmart96): This is incorrect, I'm pretty sure the percentage should
- // be set by the application.
-
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
- cmd_buff[2] = 0x80; // Set to 80%
+ cmd_buff[2] = cpu_percent;
- LOG_WARNING(Service_APT, "(STUBBED) called value=0x%08x", value);
+ LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value);
}
-void APTInit() {
+void Init() {
AddService(new APT_A_Interface);
AddService(new APT_S_Interface);
AddService(new APT_U_Interface);
@@ -271,13 +308,14 @@ void APTInit() {
}
lock = Kernel::Mutex::Create(false, "APT_U:Lock");
-
+ cpu_percent = 0;
+
// TODO(bunnei): Check if these are created in Initialize or on APT process startup.
notification_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Notification");
pause_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Pause");
}
-void APTShutdown() {
+void Shutdown() {
}
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
index a39adbff9..e7fa39325 100644
--- a/src/core/hle/service/apt/apt.h
+++ b/src/core/hle/service/apt/apt.h
@@ -13,10 +13,13 @@ namespace APT {
/// Signals used by APT functions
enum class SignalType : u32 {
- None = 0x0,
- AppJustStarted = 0x1,
- ReturningToApp = 0xB,
- ExitingApp = 0xC,
+ None = 0x0,
+ AppJustStarted = 0x1,
+ LibAppJustStarted = 0x2,
+ LibAppFinished = 0x3,
+ LibAppClosed = 0xA,
+ ReturningToApp = 0xB,
+ ExitingApp = 0xC,
};
/// App Id's used by APT functions
@@ -179,6 +182,40 @@ void GlanceParameter(Service::Interface* self);
void CancelParameter(Service::Interface* self);
/**
+ * APT::PrepareToStartApplication service function. When the input title-info programID is zero,
+ * NS will load the actual program ID via AMNet:GetTitleIDList. After doing some checks with the
+ * programID, NS will then set a NS state flag to value 1, then set the programID for AppID
+ * 0x300(application) to the input program ID(or the one from GetTitleIDList). A media-type field
+ * in the NS state is also set to the input media-type value
+ * (other state fields are set at this point as well). With 8.0.0-18, NS will set an u8 NS state
+ * field to value 1 when input flags bit8 is set
+ * Inputs:
+ * 1-4 : 0x10-byte title-info struct
+ * 4 : Flags
+ * Outputs:
+ * 0 : Return header
+ * 1 : Result of function, 0 on success, otherwise error code
+ */
+void PrepareToStartApplication(Service::Interface* self);
+
+/**
+ * APT::StartApplication service function. Buf0 is copied to NS FIRMparams+0x0, then Buf1 is copied
+ * to the NS FIRMparams+0x480. Then the application is launched.
+ * Inputs:
+ * 1 : Buffer 0 size, max size is 0x300
+ * 2 : Buffer 1 size, max size is 0x20 (this can be zero)
+ * 3 : u8 flag
+ * 4 : (Size0<<14) | 2
+ * 5 : Buffer 0 pointer
+ * 6 : (Size1<<14) | 0x802
+ * 7 : Buffer 1 pointer
+ * Outputs:
+ * 0 : Return Header
+ * 1 : Result of function, 0 on success, otherwise error code
+*/
+void StartApplication(Service::Interface* self);
+
+/**
* APT::AppletUtility service function
* Inputs:
* 1 : Unknown, but clearly used for something
@@ -213,10 +250,10 @@ void SetAppCpuTimeLimit(Service::Interface* self);
void GetAppCpuTimeLimit(Service::Interface* self);
/// Initialize the APT service
-void APTInit();
+void Init();
/// Shutdown the APT service
-void APTShutdown();
+void Shutdown();
} // namespace APT
} // namespace Service
diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp
index dbe5c1d87..864934245 100644
--- a/src/core/hle/service/apt/apt_a.cpp
+++ b/src/core/hle/service/apt/apt_a.cpp
@@ -12,16 +12,16 @@ namespace APT {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle?"},
{0x00020080, Initialize, "Initialize?"},
- {0x00030040, nullptr, "Enable?"},
+ {0x00030040, Enable, "Enable?"},
{0x00040040, nullptr, "Finalize?"},
{0x00050040, nullptr, "GetAppletManInfo?"},
{0x00060040, nullptr, "GetAppletInfo?"},
{0x000D0080, ReceiveParameter, "ReceiveParameter?"},
{0x000E0080, GlanceParameter, "GlanceParameter?"},
{0x003B0040, nullptr, "CancelLibraryApplet?"},
- {0x00430040, nullptr, "NotifyToWait?"},
+ {0x00430040, NotifyToWait, "NotifyToWait?"},
{0x00440000, GetSharedFont, "GetSharedFont?"},
- {0x004B00C2, nullptr, "AppletUtility?"},
+ {0x004B00C2, AppletUtility, "AppletUtility?"},
{0x00550040, nullptr, "WriteInputToNsState?"},
};