diff options
| author | 2015-07-11 23:56:59 -0400 | |
|---|---|---|
| committer | 2015-07-11 23:56:59 -0400 | |
| commit | f4e1d8ea36fc3f8309234b8a4a8c9f659b171c80 (patch) | |
| tree | 8756cd27489dcb424103e443836b6ea8dba3fccd /src/core/hle/service | |
| parent | Merge pull request #912 from yuriks/process-loading (diff) | |
| parent | Applets: Reworked how the Applet update event is handled. (diff) | |
| download | yuzu-f4e1d8ea36fc3f8309234b8a4a8c9f659b171c80.tar.gz yuzu-f4e1d8ea36fc3f8309234b8a4a8c9f659b171c80.tar.xz yuzu-f4e1d8ea36fc3f8309234b8a4a8c9f659b171c80.zip | |
Merge pull request #823 from Subv/applets_drawing
Library applet support (swkbd for now)
Diffstat (limited to 'src/core/hle/service')
| -rw-r--r-- | src/core/hle/service/apt/apt.cpp | 160 | ||||
| -rw-r--r-- | src/core/hle/service/apt/apt.h | 49 | ||||
| -rw-r--r-- | src/core/hle/service/apt/apt_a.cpp | 31 | ||||
| -rw-r--r-- | src/core/hle/service/apt/apt_u.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/gsp_gpu.h | 10 |
6 files changed, 200 insertions, 58 deletions
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index b454a2709..b364beed9 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/file_util.h" | 6 | #include "common/file_util.h" |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | 8 | ||
| 9 | #include "core/hle/applets/applet.h" | ||
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | #include "core/hle/service/apt/apt.h" | 11 | #include "core/hle/service/apt/apt.h" |
| 11 | #include "core/hle/service/apt/apt_a.h" | 12 | #include "core/hle/service/apt/apt_a.h" |
| @@ -34,12 +35,21 @@ static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem; | |||
| 34 | 35 | ||
| 35 | static Kernel::SharedPtr<Kernel::Mutex> lock; | 36 | static Kernel::SharedPtr<Kernel::Mutex> lock; |
| 36 | static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event | 37 | static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event |
| 37 | static Kernel::SharedPtr<Kernel::Event> start_event; ///< APT start event | 38 | static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event |
| 38 | 39 | ||
| 39 | static std::vector<u8> shared_font; | 40 | static std::vector<u8> shared_font; |
| 40 | 41 | ||
| 41 | static u32 cpu_percent; ///< CPU time available to the running application | 42 | static u32 cpu_percent; ///< CPU time available to the running application |
| 42 | 43 | ||
| 44 | /// Parameter data to be returned in the next call to Glance/ReceiveParameter | ||
| 45 | static MessageParameter next_parameter; | ||
| 46 | |||
| 47 | void SendParameter(const MessageParameter& parameter) { | ||
| 48 | next_parameter = parameter; | ||
| 49 | // Signal the event to let the application know that a new parameter is ready to be read | ||
| 50 | parameter_event->Signal(); | ||
| 51 | } | ||
| 52 | |||
| 43 | void Initialize(Service::Interface* self) { | 53 | void Initialize(Service::Interface* self) { |
| 44 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 54 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 45 | u32 app_id = cmd_buff[1]; | 55 | u32 app_id = cmd_buff[1]; |
| @@ -47,18 +57,18 @@ void Initialize(Service::Interface* self) { | |||
| 47 | 57 | ||
| 48 | cmd_buff[2] = IPC::MoveHandleDesc(2); | 58 | cmd_buff[2] = IPC::MoveHandleDesc(2); |
| 49 | cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom(); | 59 | cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom(); |
| 50 | cmd_buff[4] = Kernel::g_handle_table.Create(start_event).MoveFrom(); | 60 | cmd_buff[4] = Kernel::g_handle_table.Create(parameter_event).MoveFrom(); |
| 51 | 61 | ||
| 52 | // TODO(bunnei): Check if these events are cleared every time Initialize is called. | 62 | // TODO(bunnei): Check if these events are cleared every time Initialize is called. |
| 53 | notification_event->Clear(); | 63 | notification_event->Clear(); |
| 54 | start_event->Clear(); | 64 | parameter_event->Clear(); |
| 55 | 65 | ||
| 56 | ASSERT_MSG((nullptr != lock), "Cannot initialize without lock"); | 66 | ASSERT_MSG((nullptr != lock), "Cannot initialize without lock"); |
| 57 | lock->Release(); | 67 | lock->Release(); |
| 58 | 68 | ||
| 59 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 69 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 60 | 70 | ||
| 61 | LOG_TRACE(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags); | 71 | LOG_DEBUG(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags); |
| 62 | } | 72 | } |
| 63 | 73 | ||
| 64 | void GetSharedFont(Service::Interface* self) { | 74 | void GetSharedFont(Service::Interface* self) { |
| @@ -85,9 +95,6 @@ void GetSharedFont(Service::Interface* self) { | |||
| 85 | void NotifyToWait(Service::Interface* self) { | 95 | void NotifyToWait(Service::Interface* self) { |
| 86 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 96 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 87 | u32 app_id = cmd_buff[1]; | 97 | u32 app_id = cmd_buff[1]; |
| 88 | // TODO(Subv): Verify this, it seems to get SWKBD and Home Menu further. | ||
| 89 | start_event->Signal(); | ||
| 90 | |||
| 91 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 98 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 92 | LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id); | 99 | LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id); |
| 93 | } | 100 | } |
| @@ -100,7 +107,7 @@ void GetLockHandle(Service::Interface* self) { | |||
| 100 | 107 | ||
| 101 | // Not sure what these parameters are used for, but retail apps check that they are 0 after | 108 | // Not sure what these parameters are used for, but retail apps check that they are 0 after |
| 102 | // GetLockHandle has been called. | 109 | // GetLockHandle has been called. |
| 103 | cmd_buff[2] = 0; | 110 | cmd_buff[2] = 0; // Applet Attributes, this value is passed to Enable. |
| 104 | cmd_buff[3] = 0; | 111 | cmd_buff[3] = 0; |
| 105 | cmd_buff[4] = 0; | 112 | cmd_buff[4] = 0; |
| 106 | 113 | ||
| @@ -110,9 +117,10 @@ void GetLockHandle(Service::Interface* self) { | |||
| 110 | 117 | ||
| 111 | void Enable(Service::Interface* self) { | 118 | void Enable(Service::Interface* self) { |
| 112 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 119 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 113 | u32 unk = cmd_buff[1]; // TODO(bunnei): What is this field used for? | 120 | u32 attributes = cmd_buff[1]; |
| 114 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 121 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 115 | LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk); | 122 | parameter_event->Signal(); // Let the application know that it has been started |
| 123 | LOG_WARNING(Service_APT, "(STUBBED) called attributes=0x%08X", attributes); | ||
| 116 | } | 124 | } |
| 117 | 125 | ||
| 118 | void GetAppletManInfo(Service::Interface* self) { | 126 | void GetAppletManInfo(Service::Interface* self) { |
| @@ -121,8 +129,8 @@ void GetAppletManInfo(Service::Interface* self) { | |||
| 121 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 129 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 122 | cmd_buff[2] = 0; | 130 | cmd_buff[2] = 0; |
| 123 | cmd_buff[3] = 0; | 131 | cmd_buff[3] = 0; |
| 124 | cmd_buff[4] = static_cast<u32>(AppID::HomeMenu); // Home menu AppID | 132 | cmd_buff[4] = static_cast<u32>(AppletId::HomeMenu); // Home menu AppID |
| 125 | cmd_buff[5] = static_cast<u32>(AppID::Application); // TODO(purpasmart96): Do this correctly | 133 | cmd_buff[5] = static_cast<u32>(AppletId::Application); // TODO(purpasmart96): Do this correctly |
| 126 | 134 | ||
| 127 | LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk); | 135 | LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk); |
| 128 | } | 136 | } |
| @@ -131,7 +139,13 @@ void IsRegistered(Service::Interface* self) { | |||
| 131 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 139 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 132 | u32 app_id = cmd_buff[1]; | 140 | u32 app_id = cmd_buff[1]; |
| 133 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 141 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 134 | cmd_buff[2] = 1; // Set to registered | 142 | /// TODO(Subv): It is currently unknown what this value (0x400) means, |
| 143 | /// but i believe it is used as a global "LibraryApplet" id, to verify if there's | ||
| 144 | /// any LibApplet currently running. This is not verified. | ||
| 145 | if (app_id != 0x400) | ||
| 146 | cmd_buff[2] = 1; // Set to registered | ||
| 147 | else | ||
| 148 | cmd_buff[2] = 0; // Set to not registered | ||
| 135 | LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); | 149 | LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); |
| 136 | } | 150 | } |
| 137 | 151 | ||
| @@ -145,50 +159,82 @@ void InquireNotification(Service::Interface* self) { | |||
| 145 | 159 | ||
| 146 | void SendParameter(Service::Interface* self) { | 160 | void SendParameter(Service::Interface* self) { |
| 147 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 161 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 148 | u32 src_app_id = cmd_buff[1]; | 162 | u32 src_app_id = cmd_buff[1]; |
| 149 | u32 dst_app_id = cmd_buff[2]; | 163 | u32 dst_app_id = cmd_buff[2]; |
| 150 | u32 signal_type = cmd_buff[3]; | 164 | u32 signal_type = cmd_buff[3]; |
| 151 | u32 buffer_size = cmd_buff[4]; | 165 | u32 buffer_size = cmd_buff[4]; |
| 152 | u32 value = cmd_buff[5]; | 166 | u32 value = cmd_buff[5]; |
| 153 | u32 handle = cmd_buff[6]; | 167 | u32 handle = cmd_buff[6]; |
| 154 | u32 size = cmd_buff[7]; | 168 | u32 size = cmd_buff[7]; |
| 155 | u32 in_param_buffer_ptr = cmd_buff[8]; | 169 | u32 buffer = cmd_buff[8]; |
| 170 | |||
| 171 | std::shared_ptr<HLE::Applets::Applet> dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id)); | ||
| 172 | |||
| 173 | if (dest_applet == nullptr) { | ||
| 174 | LOG_ERROR(Service_APT, "Unknown applet id=0x%08X", dst_app_id); | ||
| 175 | cmd_buff[1] = -1; // TODO(Subv): Find the right error code | ||
| 176 | return; | ||
| 177 | } | ||
| 156 | 178 | ||
| 157 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 179 | MessageParameter param; |
| 180 | param.buffer_size = buffer_size; | ||
| 181 | param.destination_id = dst_app_id; | ||
| 182 | param.sender_id = src_app_id; | ||
| 183 | param.object = Kernel::g_handle_table.GetGeneric(handle); | ||
| 184 | param.signal = signal_type; | ||
| 185 | param.data = Memory::GetPointer(buffer); | ||
| 186 | |||
| 187 | cmd_buff[1] = dest_applet->ReceiveParameter(param).raw; | ||
| 158 | 188 | ||
| 159 | LOG_WARNING(Service_APT, "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X," | 189 | LOG_WARNING(Service_APT, "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X," |
| 160 | "buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X", | 190 | "buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X", |
| 161 | src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, in_param_buffer_ptr); | 191 | src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer); |
| 162 | } | 192 | } |
| 163 | 193 | ||
| 164 | void ReceiveParameter(Service::Interface* self) { | 194 | void ReceiveParameter(Service::Interface* self) { |
| 165 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 195 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 166 | u32 app_id = cmd_buff[1]; | 196 | u32 app_id = cmd_buff[1]; |
| 167 | u32 buffer_size = cmd_buff[2]; | 197 | u32 buffer_size = cmd_buff[2]; |
| 198 | VAddr buffer = cmd_buff[0x104 >> 2]; | ||
| 199 | |||
| 168 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 200 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 169 | cmd_buff[2] = 0; | 201 | cmd_buff[2] = next_parameter.sender_id; |
| 170 | cmd_buff[3] = static_cast<u32>(SignalType::AppJustStarted); // Signal type | 202 | cmd_buff[3] = next_parameter.signal; // Signal type |
| 171 | cmd_buff[4] = 0x10; // Parameter buffer size (16) | 203 | cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size |
| 172 | cmd_buff[5] = 0; | 204 | cmd_buff[5] = 0x10; |
| 173 | cmd_buff[6] = 0; | 205 | cmd_buff[6] = 0; |
| 174 | cmd_buff[7] = 0; | 206 | if (next_parameter.object != nullptr) |
| 175 | LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); | 207 | cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom(); |
| 208 | cmd_buff[7] = (next_parameter.buffer_size << 14) | 2; | ||
| 209 | cmd_buff[8] = buffer; | ||
| 210 | |||
| 211 | if (next_parameter.data) | ||
| 212 | memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size)); | ||
| 213 | |||
| 214 | LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); | ||
| 176 | } | 215 | } |
| 177 | 216 | ||
| 178 | void GlanceParameter(Service::Interface* self) { | 217 | void GlanceParameter(Service::Interface* self) { |
| 179 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 218 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 180 | u32 app_id = cmd_buff[1]; | 219 | u32 app_id = cmd_buff[1]; |
| 181 | u32 buffer_size = cmd_buff[2]; | 220 | u32 buffer_size = cmd_buff[2]; |
| 221 | VAddr buffer = cmd_buff[0x104 >> 2]; | ||
| 182 | 222 | ||
| 183 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 223 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 184 | cmd_buff[2] = 0; | 224 | cmd_buff[2] = next_parameter.sender_id; |
| 185 | cmd_buff[3] = static_cast<u32>(SignalType::AppJustStarted); // Signal type | 225 | cmd_buff[3] = next_parameter.signal; // Signal type |
| 186 | cmd_buff[4] = 0x10; // Parameter buffer size (16) | 226 | cmd_buff[4] = next_parameter.buffer_size; // Parameter buffer size |
| 187 | cmd_buff[5] = 0; | 227 | cmd_buff[5] = 0x10; |
| 188 | cmd_buff[6] = 0; | 228 | cmd_buff[6] = 0; |
| 189 | cmd_buff[7] = 0; | 229 | if (next_parameter.object != nullptr) |
| 230 | cmd_buff[6] = Kernel::g_handle_table.Create(next_parameter.object).MoveFrom(); | ||
| 231 | cmd_buff[7] = (next_parameter.buffer_size << 14) | 2; | ||
| 232 | cmd_buff[8] = buffer; | ||
| 233 | |||
| 234 | if (next_parameter.data) | ||
| 235 | memcpy(Memory::GetPointer(buffer), next_parameter.data, std::min(buffer_size, next_parameter.buffer_size)); | ||
| 190 | 236 | ||
| 191 | LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); | 237 | LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); |
| 192 | } | 238 | } |
| 193 | 239 | ||
| 194 | void CancelParameter(Service::Interface* self) { | 240 | void CancelParameter(Service::Interface* self) { |
| @@ -240,7 +286,7 @@ void AppletUtility(Service::Interface* self) { | |||
| 240 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 286 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 241 | 287 | ||
| 242 | // These are from 3dbrew - I'm not really sure what they're used for. | 288 | // These are from 3dbrew - I'm not really sure what they're used for. |
| 243 | u32 unk = cmd_buff[1]; | 289 | u32 command = cmd_buff[1]; |
| 244 | u32 buffer1_size = cmd_buff[2]; | 290 | u32 buffer1_size = cmd_buff[2]; |
| 245 | u32 buffer2_size = cmd_buff[3]; | 291 | u32 buffer2_size = cmd_buff[3]; |
| 246 | u32 buffer1_addr = cmd_buff[5]; | 292 | u32 buffer1_addr = cmd_buff[5]; |
| @@ -248,8 +294,8 @@ void AppletUtility(Service::Interface* self) { | |||
| 248 | 294 | ||
| 249 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 295 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 250 | 296 | ||
| 251 | LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " | 297 | LOG_WARNING(Service_APT, "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " |
| 252 | "buffer1_addr=0x%08X, buffer2_addr=0x%08X", unk, buffer1_size, buffer2_size, | 298 | "buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size, |
| 253 | buffer1_addr, buffer2_addr); | 299 | buffer1_addr, buffer2_addr); |
| 254 | } | 300 | } |
| 255 | 301 | ||
| @@ -281,11 +327,41 @@ void GetAppCpuTimeLimit(Service::Interface* self) { | |||
| 281 | LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value); | 327 | LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value); |
| 282 | } | 328 | } |
| 283 | 329 | ||
| 330 | void PrepareToStartLibraryApplet(Service::Interface* self) { | ||
| 331 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 332 | AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); | ||
| 333 | cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw; | ||
| 334 | LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); | ||
| 335 | } | ||
| 336 | |||
| 337 | void StartLibraryApplet(Service::Interface* self) { | ||
| 338 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 339 | AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); | ||
| 340 | std::shared_ptr<HLE::Applets::Applet> applet = HLE::Applets::Applet::Get(applet_id); | ||
| 341 | |||
| 342 | LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); | ||
| 343 | |||
| 344 | if (applet == nullptr) { | ||
| 345 | LOG_ERROR(Service_APT, "unknown applet id=%08X", applet_id); | ||
| 346 | cmd_buff[1] = -1; // TODO(Subv): Find the right error code | ||
| 347 | return; | ||
| 348 | } | ||
| 349 | |||
| 350 | AppletStartupParameter parameter; | ||
| 351 | parameter.buffer_size = cmd_buff[2]; | ||
| 352 | parameter.object = Kernel::g_handle_table.GetGeneric(cmd_buff[4]); | ||
| 353 | parameter.data = Memory::GetPointer(cmd_buff[6]); | ||
| 354 | |||
| 355 | cmd_buff[1] = applet->Start(parameter).raw; | ||
| 356 | } | ||
| 357 | |||
| 284 | void Init() { | 358 | void Init() { |
| 285 | AddService(new APT_A_Interface); | 359 | AddService(new APT_A_Interface); |
| 286 | AddService(new APT_S_Interface); | 360 | AddService(new APT_S_Interface); |
| 287 | AddService(new APT_U_Interface); | 361 | AddService(new APT_U_Interface); |
| 288 | 362 | ||
| 363 | HLE::Applets::Init(); | ||
| 364 | |||
| 289 | // Load the shared system font (if available). | 365 | // Load the shared system font (if available). |
| 290 | // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header | 366 | // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header |
| 291 | // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided | 367 | // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided |
| @@ -318,7 +394,10 @@ void Init() { | |||
| 318 | 394 | ||
| 319 | // TODO(bunnei): Check if these are created in Initialize or on APT process startup. | 395 | // TODO(bunnei): Check if these are created in Initialize or on APT process startup. |
| 320 | notification_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Notification"); | 396 | notification_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Notification"); |
| 321 | start_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Start"); | 397 | parameter_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Start"); |
| 398 | |||
| 399 | next_parameter.signal = static_cast<u32>(SignalType::AppJustStarted); | ||
| 400 | next_parameter.destination_id = 0x300; | ||
| 322 | } | 401 | } |
| 323 | 402 | ||
| 324 | void Shutdown() { | 403 | void Shutdown() { |
| @@ -326,7 +405,8 @@ void Shutdown() { | |||
| 326 | shared_font_mem = nullptr; | 405 | shared_font_mem = nullptr; |
| 327 | lock = nullptr; | 406 | lock = nullptr; |
| 328 | notification_event = nullptr; | 407 | notification_event = nullptr; |
| 329 | start_event = nullptr; | 408 | parameter_event = nullptr; |
| 409 | HLE::Applets::Shutdown(); | ||
| 330 | } | 410 | } |
| 331 | 411 | ||
| 332 | } // namespace APT | 412 | } // namespace APT |
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index a03e1712a..9f0802508 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h | |||
| @@ -11,6 +11,23 @@ | |||
| 11 | namespace Service { | 11 | namespace Service { |
| 12 | namespace APT { | 12 | namespace APT { |
| 13 | 13 | ||
| 14 | /// Holds information about the parameters used in Send/Glance/ReceiveParameter | ||
| 15 | struct MessageParameter { | ||
| 16 | u32 sender_id = 0; | ||
| 17 | u32 destination_id = 0; | ||
| 18 | u32 signal = 0; | ||
| 19 | u32 buffer_size = 0; | ||
| 20 | Kernel::SharedPtr<Kernel::Object> object = nullptr; | ||
| 21 | u8* data = nullptr; | ||
| 22 | }; | ||
| 23 | |||
| 24 | /// Holds information about the parameters used in StartLibraryApplet | ||
| 25 | struct AppletStartupParameter { | ||
| 26 | u32 buffer_size = 0; | ||
| 27 | Kernel::SharedPtr<Kernel::Object> object = nullptr; | ||
| 28 | u8* data = nullptr; | ||
| 29 | }; | ||
| 30 | |||
| 14 | /// Signals used by APT functions | 31 | /// Signals used by APT functions |
| 15 | enum class SignalType : u32 { | 32 | enum class SignalType : u32 { |
| 16 | None = 0x0, | 33 | None = 0x0, |
| @@ -23,7 +40,7 @@ enum class SignalType : u32 { | |||
| 23 | }; | 40 | }; |
| 24 | 41 | ||
| 25 | /// App Id's used by APT functions | 42 | /// App Id's used by APT functions |
| 26 | enum class AppID : u32 { | 43 | enum class AppletId : u32 { |
| 27 | HomeMenu = 0x101, | 44 | HomeMenu = 0x101, |
| 28 | AlternateMenu = 0x103, | 45 | AlternateMenu = 0x103, |
| 29 | Camera = 0x110, | 46 | Camera = 0x110, |
| @@ -45,6 +62,9 @@ enum class AppID : u32 { | |||
| 45 | SoftwareKeyboard2 = 0x401, | 62 | SoftwareKeyboard2 = 0x401, |
| 46 | }; | 63 | }; |
| 47 | 64 | ||
| 65 | /// Send a parameter to the currently-running application, which will read it via ReceiveParameter | ||
| 66 | void SendParameter(const MessageParameter& parameter); | ||
| 67 | |||
| 48 | /** | 68 | /** |
| 49 | * APT::Initialize service function | 69 | * APT::Initialize service function |
| 50 | * Service function that initializes the APT process for the running application | 70 | * Service function that initializes the APT process for the running application |
| @@ -249,6 +269,33 @@ void SetAppCpuTimeLimit(Service::Interface* self); | |||
| 249 | */ | 269 | */ |
| 250 | void GetAppCpuTimeLimit(Service::Interface* self); | 270 | void GetAppCpuTimeLimit(Service::Interface* self); |
| 251 | 271 | ||
| 272 | /** | ||
| 273 | * APT::PrepareToStartLibraryApplet service function | ||
| 274 | * Inputs: | ||
| 275 | * 0 : Command header [0x00180040] | ||
| 276 | * 1 : Id of the applet to start | ||
| 277 | * Outputs: | ||
| 278 | * 0 : Return header | ||
| 279 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 280 | */ | ||
| 281 | void PrepareToStartLibraryApplet(Service::Interface* self); | ||
| 282 | |||
| 283 | /** | ||
| 284 | * APT::StartLibraryApplet service function | ||
| 285 | * Inputs: | ||
| 286 | * 0 : Command header [0x001E0084] | ||
| 287 | * 1 : Id of the applet to start | ||
| 288 | * 2 : Buffer size | ||
| 289 | * 3 : Always 0? | ||
| 290 | * 4 : Handle passed to the applet | ||
| 291 | * 5 : (Size << 14) | 2 | ||
| 292 | * 6 : Input buffer virtual address | ||
| 293 | * Outputs: | ||
| 294 | * 0 : Return header | ||
| 295 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 296 | */ | ||
| 297 | void StartLibraryApplet(Service::Interface* self); | ||
| 298 | |||
| 252 | /// Initialize the APT service | 299 | /// Initialize the APT service |
| 253 | void Init(); | 300 | void Init(); |
| 254 | 301 | ||
diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp index 864934245..88de339f9 100644 --- a/src/core/hle/service/apt/apt_a.cpp +++ b/src/core/hle/service/apt/apt_a.cpp | |||
| @@ -10,19 +10,24 @@ namespace Service { | |||
| 10 | namespace APT { | 10 | namespace APT { |
| 11 | 11 | ||
| 12 | const Interface::FunctionInfo FunctionTable[] = { | 12 | const Interface::FunctionInfo FunctionTable[] = { |
| 13 | {0x00010040, GetLockHandle, "GetLockHandle?"}, | 13 | {0x00010040, GetLockHandle, "GetLockHandle?"}, |
| 14 | {0x00020080, Initialize, "Initialize?"}, | 14 | {0x00020080, Initialize, "Initialize?"}, |
| 15 | {0x00030040, Enable, "Enable?"}, | 15 | {0x00030040, Enable, "Enable?"}, |
| 16 | {0x00040040, nullptr, "Finalize?"}, | 16 | {0x00040040, nullptr, "Finalize?"}, |
| 17 | {0x00050040, nullptr, "GetAppletManInfo?"}, | 17 | {0x00050040, nullptr, "GetAppletManInfo?"}, |
| 18 | {0x00060040, nullptr, "GetAppletInfo?"}, | 18 | {0x00060040, nullptr, "GetAppletInfo?"}, |
| 19 | {0x000D0080, ReceiveParameter, "ReceiveParameter?"}, | 19 | {0x00090040, IsRegistered, "IsRegistered"}, |
| 20 | {0x000E0080, GlanceParameter, "GlanceParameter?"}, | 20 | {0x000C0104, SendParameter, "SendParameter"}, |
| 21 | {0x003B0040, nullptr, "CancelLibraryApplet?"}, | 21 | {0x000D0080, ReceiveParameter, "ReceiveParameter"}, |
| 22 | {0x00430040, NotifyToWait, "NotifyToWait?"}, | 22 | {0x000E0080, GlanceParameter, "GlanceParameter"}, |
| 23 | {0x00440000, GetSharedFont, "GetSharedFont?"}, | 23 | {0x000F0100, CancelParameter, "CancelParameter"}, |
| 24 | {0x004B00C2, AppletUtility, "AppletUtility?"}, | 24 | {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, |
| 25 | {0x00550040, nullptr, "WriteInputToNsState?"}, | 25 | {0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, |
| 26 | {0x003B0040, nullptr, "CancelLibraryApplet?"}, | ||
| 27 | {0x00430040, NotifyToWait, "NotifyToWait?"}, | ||
| 28 | {0x00440000, GetSharedFont, "GetSharedFont?"}, | ||
| 29 | {0x004B00C2, AppletUtility, "AppletUtility?"}, | ||
| 30 | {0x00550040, nullptr, "WriteInputToNsState?"}, | ||
| 26 | }; | 31 | }; |
| 27 | 32 | ||
| 28 | APT_A_Interface::APT_A_Interface() { | 33 | APT_A_Interface::APT_A_Interface() { |
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp index d006b5930..b724cd72b 100644 --- a/src/core/hle/service/apt/apt_u.cpp +++ b/src/core/hle/service/apt/apt_u.cpp | |||
| @@ -35,13 +35,13 @@ const Interface::FunctionInfo FunctionTable[] = { | |||
| 35 | {0x00150140, nullptr, "PrepareToStartApplication"}, | 35 | {0x00150140, nullptr, "PrepareToStartApplication"}, |
| 36 | {0x00160040, nullptr, "PreloadLibraryApplet"}, | 36 | {0x00160040, nullptr, "PreloadLibraryApplet"}, |
| 37 | {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, | 37 | {0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, |
| 38 | {0x00180040, nullptr, "PrepareToStartLibraryApplet"}, | 38 | {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, |
| 39 | {0x00190040, nullptr, "PrepareToStartSystemApplet"}, | 39 | {0x00190040, nullptr, "PrepareToStartSystemApplet"}, |
| 40 | {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"}, | 40 | {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"}, |
| 41 | {0x001B00C4, nullptr, "StartApplication"}, | 41 | {0x001B00C4, nullptr, "StartApplication"}, |
| 42 | {0x001C0000, nullptr, "WakeupApplication"}, | 42 | {0x001C0000, nullptr, "WakeupApplication"}, |
| 43 | {0x001D0000, nullptr, "CancelApplication"}, | 43 | {0x001D0000, nullptr, "CancelApplication"}, |
| 44 | {0x001E0084, nullptr, "StartLibraryApplet"}, | 44 | {0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, |
| 45 | {0x001F0084, nullptr, "StartSystemApplet"}, | 45 | {0x001F0084, nullptr, "StartSystemApplet"}, |
| 46 | {0x00200044, nullptr, "StartNewestHomeMenu"}, | 46 | {0x00200044, nullptr, "StartNewestHomeMenu"}, |
| 47 | {0x00210000, nullptr, "OrderToCloseApplication"}, | 47 | {0x00210000, nullptr, "OrderToCloseApplication"}, |
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index f56bbe50f..f175085e8 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp | |||
| @@ -42,7 +42,7 @@ static inline u8* GetCommandBuffer(u32 thread_id) { | |||
| 42 | return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); | 42 | return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { | 45 | FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { |
| 46 | DEBUG_ASSERT_MSG(screen_index < 2, "Invalid screen index"); | 46 | DEBUG_ASSERT_MSG(screen_index < 2, "Invalid screen index"); |
| 47 | 47 | ||
| 48 | // For each thread there are two FrameBufferUpdate fields | 48 | // For each thread there are two FrameBufferUpdate fields |
| @@ -205,7 +205,7 @@ static void ReadHWRegs(Service::Interface* self) { | |||
| 205 | } | 205 | } |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { | 208 | void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { |
| 209 | u32 base_address = 0x400000; | 209 | u32 base_address = 0x400000; |
| 210 | PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); | 210 | PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); |
| 211 | PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); | 211 | PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); |
diff --git a/src/core/hle/service/gsp_gpu.h b/src/core/hle/service/gsp_gpu.h index d9e9a1a60..268089fdd 100644 --- a/src/core/hle/service/gsp_gpu.h +++ b/src/core/hle/service/gsp_gpu.h | |||
| @@ -173,4 +173,14 @@ public: | |||
| 173 | */ | 173 | */ |
| 174 | void SignalInterrupt(InterruptId interrupt_id); | 174 | void SignalInterrupt(InterruptId interrupt_id); |
| 175 | 175 | ||
| 176 | void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info); | ||
| 177 | |||
| 178 | /** | ||
| 179 | * Retrieves the framebuffer info stored in the GSP shared memory for the | ||
| 180 | * specified screen index and thread id. | ||
| 181 | * @param thread_id GSP thread id of the process that accesses the structure that we are requesting. | ||
| 182 | * @param screen_index Index of the screen we are requesting (Top = 0, Bottom = 1). | ||
| 183 | * @returns FramebufferUpdate Information about the specified framebuffer. | ||
| 184 | */ | ||
| 185 | FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index); | ||
| 176 | } // namespace | 186 | } // namespace |