summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lectem2017-03-18 11:47:40 +0100
committerGravatar Lectem2017-03-18 11:47:40 +0100
commit12ed7464771e4c6b1992ef4438be9038fb59b2fc (patch)
tree9b9aa325793afff90ba731d48662e69a7ef402be /src
parentfix #2560 and other comments (diff)
downloadyuzu-12ed7464771e4c6b1992ef4438be9038fb59b2fc.tar.gz
yuzu-12ed7464771e4c6b1992ef4438be9038fb59b2fc.tar.xz
yuzu-12ed7464771e4c6b1992ef4438be9038fb59b2fc.zip
IPCHelper Skip method + address comments for apt
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/ipc_helpers.h8
-rw-r--r--src/core/hle/service/apt/apt.cpp74
-rw-r--r--src/core/hle/service/ptm/ptm.cpp2
3 files changed, 46 insertions, 38 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index 98c95a7f3..06c4c5a85 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -28,13 +28,19 @@ public:
28 header.raw); 28 header.raw);
29 } 29 }
30 30
31 void Skip(unsigned size_in_words, bool set_to_null) {
32 if (set_to_null)
33 memset(cmdbuf + index, 0, size_in_words * sizeof(u32));
34 index += size_in_words;
35 }
36
31 /** 37 /**
32 * @brief Retrieves the address of a static buffer, used when a buffer is needed for output 38 * @brief Retrieves the address of a static buffer, used when a buffer is needed for output
33 * @param buffer_id The index of the static buffer 39 * @param buffer_id The index of the static buffer
34 * @param data_size If non-null, will store the size of the buffer 40 * @param data_size If non-null, will store the size of the buffer
35 */ 41 */
36 VAddr PeekStaticBuffer(u8 buffer_id, size_t* data_size = nullptr) const { 42 VAddr PeekStaticBuffer(u8 buffer_id, size_t* data_size = nullptr) const {
37 u32* static_buffer = cmdbuf + Kernel::kStaticBuffersOffset / 4 + buffer_id * 2; 43 u32* static_buffer = cmdbuf + Kernel::kStaticBuffersOffset / sizeof(u32) + buffer_id * 2;
38 if (data_size) 44 if (data_size)
39 *data_size = StaticBufferDescInfo{static_buffer[0]}.size; 45 *data_size = StaticBufferDescInfo{static_buffer[0]}.size;
40 return static_buffer[1]; 46 return static_buffer[1];
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index c323deaa4..48437aa73 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -69,10 +69,11 @@ void Initialize(Service::Interface* self) {
69 69
70void GetSharedFont(Service::Interface* self) { 70void GetSharedFont(Service::Interface* self) {
71 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x44, 0, 0); // 0x00440000 71 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x44, 0, 0); // 0x00440000
72 IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
72 if (!shared_font_mem) { 73 if (!shared_font_mem) {
73 LOG_ERROR(Service_APT, "shared font file missing - go dump it from your 3ds"); 74 LOG_ERROR(Service_APT, "shared font file missing - go dump it from your 3ds");
74 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
75 rb.Push<u32>(-1); // TODO: Find the right error code 75 rb.Push<u32>(-1); // TODO: Find the right error code
76 rb.Skip(1 + 2, true);
76 return; 77 return;
77 } 78 }
78 79
@@ -85,7 +86,6 @@ void GetSharedFont(Service::Interface* self) {
85 shared_font_relocated = true; 86 shared_font_relocated = true;
86 } 87 }
87 88
88 IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
89 rb.Push(RESULT_SUCCESS); // No error 89 rb.Push(RESULT_SUCCESS); // No error
90 // Since the SharedMemory interface doesn't provide the address at which the memory was 90 // Since the SharedMemory interface doesn't provide the address at which the memory was
91 // allocated, the real APT service calculates this address by scanning the entire address space 91 // allocated, the real APT service calculates this address by scanning the entire address space
@@ -113,10 +113,10 @@ void GetLockHandle(Service::Interface* self) {
113 rb.Push(RESULT_SUCCESS); // No error 113 rb.Push(RESULT_SUCCESS); // No error
114 rb.Push(applet_attributes); // Applet Attributes, this value is passed to Enable. 114 rb.Push(applet_attributes); // Applet Attributes, this value is passed to Enable.
115 rb.Push<u32>(0); // Least significant bit = power button state 115 rb.Push<u32>(0); // Least significant bit = power button state
116 Kernel::Handle handleCopy = Kernel::g_handle_table.Create(lock).MoveFrom(); 116 Kernel::Handle handle_copy = Kernel::g_handle_table.Create(lock).MoveFrom();
117 rb.PushCopyHandles(handleCopy); 117 rb.PushCopyHandles(handle_copy);
118 118
119 LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", handleCopy, 119 LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", handle_copy,
120 applet_attributes); 120 applet_attributes);
121} 121}
122 122
@@ -150,14 +150,14 @@ void IsRegistered(Service::Interface* self) {
150 150
151 // TODO(Subv): An application is considered "registered" if it has already called APT::Enable 151 // TODO(Subv): An application is considered "registered" if it has already called APT::Enable
152 // handle this properly once we implement multiprocess support. 152 // handle this properly once we implement multiprocess support.
153 bool isRegistered = false; // Set to not registered by default 153 bool is_registered = false; // Set to not registered by default
154 154
155 if (app_id == static_cast<u32>(AppletId::AnyLibraryApplet)) { 155 if (app_id == static_cast<u32>(AppletId::AnyLibraryApplet)) {
156 isRegistered = HLE::Applets::IsLibraryAppletRunning() ? true : false; 156 is_registered = HLE::Applets::IsLibraryAppletRunning();
157 } else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) { 157 } else if (auto applet = HLE::Applets::Applet::Get(static_cast<AppletId>(app_id))) {
158 isRegistered = true; // Set to registered 158 is_registered = true; // Set to registered
159 } 159 }
160 rb.Push(isRegistered); 160 rb.Push(is_registered);
161 161
162 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id); 162 LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
163} 163}
@@ -177,10 +177,9 @@ void SendParameter(Service::Interface* self) {
177 u32 dst_app_id = rp.Pop<u32>(); 177 u32 dst_app_id = rp.Pop<u32>();
178 u32 signal_type = rp.Pop<u32>(); 178 u32 signal_type = rp.Pop<u32>();
179 u32 buffer_size = rp.Pop<u32>(); 179 u32 buffer_size = rp.Pop<u32>();
180 u32 value = rp.Pop<u32>(); 180 Kernel::Handle handle = rp.PopHandle();
181 u32 handle = rp.Pop<u32>(); 181 size_t size;
182 u32 size = rp.Pop<u32>(); 182 VAddr buffer = rp.PopStaticBuffer(&size);
183 u32 buffer = rp.Pop<u32>();
184 183
185 std::shared_ptr<HLE::Applets::Applet> dest_applet = 184 std::shared_ptr<HLE::Applets::Applet> dest_applet =
186 HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id)); 185 HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id));
@@ -203,11 +202,10 @@ void SendParameter(Service::Interface* self) {
203 202
204 rb.Push(dest_applet->ReceiveParameter(param)); 203 rb.Push(dest_applet->ReceiveParameter(param));
205 204
206 LOG_WARNING( 205 LOG_WARNING(Service_APT,
207 Service_APT, 206 "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X,"
208 "(STUBBED) called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X," 207 "buffer_size=0x%08X, handle=0x%08X, size=0x%08zX, in_param_buffer_ptr=0x%08X",
209 "buffer_size=0x%08X, value=0x%08X, handle=0x%08X, size=0x%08X, in_param_buffer_ptr=0x%08X", 208 src_app_id, dst_app_id, signal_type, buffer_size, handle, size, buffer);
210 src_app_id, dst_app_id, signal_type, buffer_size, value, handle, size, buffer);
211} 209}
212 210
213void ReceiveParameter(Service::Interface* self) { 211void ReceiveParameter(Service::Interface* self) {
@@ -218,8 +216,9 @@ void ReceiveParameter(Service::Interface* self) {
218 size_t static_buff_size; 216 size_t static_buff_size;
219 VAddr buffer = rp.PeekStaticBuffer(0, &static_buff_size); 217 VAddr buffer = rp.PeekStaticBuffer(0, &static_buff_size);
220 if (buffer_size > static_buff_size) 218 if (buffer_size > static_buff_size)
221 LOG_WARNING(Service_APT, "ReceiveParameter: buffer_size is bigger than the size in the " 219 LOG_WARNING(Service_APT,
222 "buffer descriptor (0x%08X > 0x%08X)", 220 "ReceiveParameter: buffer_size is bigger than the size in the "
221 "buffer descriptor (0x%08X > 0x%08zX)",
223 buffer_size, static_buff_size); 222 buffer_size, static_buff_size);
224 223
225 IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); 224 IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
@@ -236,7 +235,7 @@ void ReceiveParameter(Service::Interface* self) {
236 235
237 Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size()); 236 Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size());
238 237
239 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); 238 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size);
240} 239}
241 240
242void GlanceParameter(Service::Interface* self) { 241void GlanceParameter(Service::Interface* self) {
@@ -247,8 +246,9 @@ void GlanceParameter(Service::Interface* self) {
247 size_t static_buff_size; 246 size_t static_buff_size;
248 VAddr buffer = rp.PeekStaticBuffer(0, &static_buff_size); 247 VAddr buffer = rp.PeekStaticBuffer(0, &static_buff_size);
249 if (buffer_size > static_buff_size) 248 if (buffer_size > static_buff_size)
250 LOG_WARNING(Service_APT, "ReceiveParameter: buffer_size is bigger than the size in the " 249 LOG_WARNING(Service_APT,
251 "buffer descriptor (0x%08X > 0x%08X)", 250 "ReceiveParameter: buffer_size is bigger than the size in the "
251 "buffer descriptor (0x%08X > 0x%08zX)",
252 buffer_size, static_buff_size); 252 buffer_size, static_buff_size);
253 253
254 IPC::RequestBuilder rb = rp.MakeBuilder(4, 4); 254 IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
@@ -265,7 +265,7 @@ void GlanceParameter(Service::Interface* self) {
265 265
266 Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size()); 266 Memory::WriteBlock(buffer, next_parameter.buffer.data(), next_parameter.buffer.size());
267 267
268 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08X", app_id, buffer_size); 268 LOG_WARNING(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size);
269} 269}
270 270
271void CancelParameter(Service::Interface* self) { 271void CancelParameter(Service::Interface* self) {
@@ -285,7 +285,7 @@ void CancelParameter(Service::Interface* self) {
285} 285}
286 286
287void PrepareToStartApplication(Service::Interface* self) { 287void PrepareToStartApplication(Service::Interface* self) {
288 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x00150140); 288 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x15, 5, 0); // 0x00150140
289 u32 title_info1 = rp.Pop<u32>(); 289 u32 title_info1 = rp.Pop<u32>();
290 u32 title_info2 = rp.Pop<u32>(); 290 u32 title_info2 = rp.Pop<u32>();
291 u32 title_info3 = rp.Pop<u32>(); 291 u32 title_info3 = rp.Pop<u32>();
@@ -306,26 +306,26 @@ void PrepareToStartApplication(Service::Interface* self) {
306} 306}
307 307
308void StartApplication(Service::Interface* self) { 308void StartApplication(Service::Interface* self) {
309 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x001B00C4); 309 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1B, 3, 4); // 0x001B00C4
310 u32 buffer1_size = rp.Pop<u32>(); 310 u32 buffer1_size = rp.Pop<u32>();
311 u32 buffer2_size = rp.Pop<u32>(); 311 u32 buffer2_size = rp.Pop<u32>();
312 u32 flag = rp.Pop<u32>(); 312 u32 flag = rp.Pop<u32>();
313 u32 size1 = rp.Pop<u32>(); 313 size_t size1;
314 u32 buffer1_ptr = rp.Pop<u32>(); 314 VAddr buffer1_ptr = rp.PopStaticBuffer(&size1);
315 u32 size2 = rp.Pop<u32>(); 315 size_t size2;
316 u32 buffer2_ptr = rp.Pop<u32>(); 316 VAddr buffer2_ptr = rp.PopStaticBuffer(&size2);
317 317
318 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 318 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
319 rb.Push(RESULT_SUCCESS); // No error 319 rb.Push(RESULT_SUCCESS); // No error
320 320
321 LOG_WARNING(Service_APT, 321 LOG_WARNING(Service_APT,
322 "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X," 322 "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
323 "size1=0x%08X, buffer1_ptr=0x%08X, size2=0x%08X, buffer2_ptr=0x%08X", 323 "size1=0x%08zX, buffer1_ptr=0x%08X, size2=0x%08zX, buffer2_ptr=0x%08X",
324 buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr); 324 buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
325} 325}
326 326
327void AppletUtility(Service::Interface* self) { 327void AppletUtility(Service::Interface* self) {
328 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x004B00C2); 328 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x4B, 3, 2); // 0x004B00C2
329 329
330 // These are from 3dbrew - I'm not really sure what they're used for. 330 // These are from 3dbrew - I'm not really sure what they're used for.
331 u32 utility_command = rp.Pop<u32>(); 331 u32 utility_command = rp.Pop<u32>();
@@ -438,7 +438,7 @@ void CancelLibraryApplet(Service::Interface* self) {
438 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 438 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
439 rb.Push<u32>(1); 439 rb.Push<u32>(1);
440 440
441 LOG_WARNING(Service_APT, "(STUBBED) called exiting=%u", exiting); 441 LOG_WARNING(Service_APT, "(STUBBED) called exiting=%d", exiting);
442} 442}
443 443
444void SetScreenCapPostPermission(Service::Interface* self) { 444void SetScreenCapPostPermission(Service::Interface* self) {
@@ -501,8 +501,9 @@ void GetStartupArgument(Service::Interface* self) {
501 size_t static_buff_size; 501 size_t static_buff_size;
502 VAddr addr = rp.PeekStaticBuffer(0, &static_buff_size); 502 VAddr addr = rp.PeekStaticBuffer(0, &static_buff_size);
503 if (parameter_size > static_buff_size) 503 if (parameter_size > static_buff_size)
504 LOG_WARNING(Service_APT, "GetStartupArgument: parameter_size is bigger than the size in " 504 LOG_WARNING(Service_APT,
505 "the buffer descriptor (0x%08X > 0x%08X)", 505 "GetStartupArgument: parameter_size is bigger than the size in "
506 "the buffer descriptor (0x%08X > 0x%08zX)",
506 parameter_size, static_buff_size); 507 parameter_size, static_buff_size);
507 508
508 if (addr && parameter_size) { 509 if (addr && parameter_size) {
@@ -512,9 +513,10 @@ void GetStartupArgument(Service::Interface* self) {
512 LOG_WARNING(Service_APT, "(stubbed) called startup_argument_type=%u , parameter_size=0x%08x", 513 LOG_WARNING(Service_APT, "(stubbed) called startup_argument_type=%u , parameter_size=0x%08x",
513 startup_argument_type, parameter_size); 514 startup_argument_type, parameter_size);
514 515
515 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); 516 IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
516 rb.Push(RESULT_SUCCESS); 517 rb.Push(RESULT_SUCCESS);
517 rb.Push<u32>(0); 518 rb.Push<u32>(0);
519 rb.PushStaticBuffer(addr, parameter_size, 0);
518} 520}
519 521
520void Wrap(Service::Interface* self) { 522void Wrap(Service::Interface* self) {
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
index bdfa7391a..8a343a613 100644
--- a/src/core/hle/service/ptm/ptm.cpp
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -107,7 +107,7 @@ void CheckNew3DS(IPC::RequestBuilder& rb) {
107} 107}
108 108
109void CheckNew3DS(Service::Interface* self) { 109void CheckNew3DS(Service::Interface* self) {
110 IPC::RequestBuilder rb(Kernel::GetCommandBuffer(), 0x040A0000); 110 IPC::RequestBuilder rb(Kernel::GetCommandBuffer(), 0x40A, 0, 0); // 0x040A0000
111 CheckNew3DS(rb); 111 CheckNew3DS(rb);
112} 112}
113 113