summaryrefslogtreecommitdiff
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorGravatar bunnei2018-01-24 23:09:03 -0500
committerGravatar GitHub2018-01-24 23:09:03 -0500
commit748c0de539674dc8ca4a5a8aadd2a61b0eabe652 (patch)
treeae56efe8654d3aa3a5e75ec04bd9dfdcc06023a9 /src/core/hle/service
parentaudout:u OpenAudioOut and IAudioOut (#138) (diff)
parentaudout_u: Various cleanups. (diff)
downloadyuzu-748c0de539674dc8ca4a5a8aadd2a61b0eabe652.tar.gz
yuzu-748c0de539674dc8ca4a5a8aadd2a61b0eabe652.tar.xz
yuzu-748c0de539674dc8ca4a5a8aadd2a61b0eabe652.zip
Merge pull request #137 from bunnei/improve-ipc
Improve IPC, unify Domains and Sessions, and add validation
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/acc/acc_u0.cpp12
-rw-r--r--src/core/hle/service/am/applet_oe.cpp66
-rw-r--r--src/core/hle/service/apm/apm.cpp6
-rw-r--r--src/core/hle/service/audio/audout_u.cpp60
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp18
-rw-r--r--src/core/hle/service/hid/hid.cpp17
-rw-r--r--src/core/hle/service/lm/lm.cpp20
-rw-r--r--src/core/hle/service/nvdrv/interface.cpp10
-rw-r--r--src/core/hle/service/pctl/pctl_a.cpp2
-rw-r--r--src/core/hle/service/service.cpp2
-rw-r--r--src/core/hle/service/set/set.cpp2
-rw-r--r--src/core/hle/service/sm/controller.cpp20
-rw-r--r--src/core/hle/service/sm/sm.cpp7
-rw-r--r--src/core/hle/service/sockets/bsd_u.cpp8
-rw-r--r--src/core/hle/service/time/time.cpp61
-rw-r--r--src/core/hle/service/time/time.h7
-rw-r--r--src/core/hle/service/vi/vi.cpp36
-rw-r--r--src/core/hle/service/vi/vi_m.cpp3
18 files changed, 159 insertions, 198 deletions
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp
index 7f0192fd3..67f05aad4 100644
--- a/src/core/hle/service/acc/acc_u0.cpp
+++ b/src/core/hle/service/acc/acc_u0.cpp
@@ -22,7 +22,7 @@ private:
22 void GetBase(Kernel::HLERequestContext& ctx) { 22 void GetBase(Kernel::HLERequestContext& ctx) {
23 LOG_WARNING(Service, "(STUBBED) called"); 23 LOG_WARNING(Service, "(STUBBED) called");
24 ProfileBase profile_base{}; 24 ProfileBase profile_base{};
25 IPC::RequestBuilder rb{ctx, 16}; 25 IPC::ResponseBuilder rb{ctx, 16};
26 rb.Push(RESULT_SUCCESS); 26 rb.Push(RESULT_SUCCESS);
27 rb.PushRaw(profile_base); 27 rb.PushRaw(profile_base);
28 } 28 }
@@ -40,7 +40,7 @@ public:
40private: 40private:
41 void CheckAvailability(Kernel::HLERequestContext& ctx) { 41 void CheckAvailability(Kernel::HLERequestContext& ctx) {
42 LOG_WARNING(Service, "(STUBBED) called"); 42 LOG_WARNING(Service, "(STUBBED) called");
43 IPC::RequestBuilder rb{ctx, 3}; 43 IPC::ResponseBuilder rb{ctx, 3};
44 rb.Push(RESULT_SUCCESS); 44 rb.Push(RESULT_SUCCESS);
45 rb.Push(true); // TODO: Check when this is supposed to return true and when not 45 rb.Push(true); // TODO: Check when this is supposed to return true and when not
46 } 46 }
@@ -48,13 +48,13 @@ private:
48 48
49void ACC_U0::GetUserExistence(Kernel::HLERequestContext& ctx) { 49void ACC_U0::GetUserExistence(Kernel::HLERequestContext& ctx) {
50 LOG_WARNING(Service, "(STUBBED) called"); 50 LOG_WARNING(Service, "(STUBBED) called");
51 IPC::RequestBuilder rb{ctx, 3}; 51 IPC::ResponseBuilder rb{ctx, 3};
52 rb.Push(RESULT_SUCCESS); 52 rb.Push(RESULT_SUCCESS);
53 rb.Push(true); // TODO: Check when this is supposed to return true and when not 53 rb.Push(true); // TODO: Check when this is supposed to return true and when not
54} 54}
55 55
56void ACC_U0::GetProfile(Kernel::HLERequestContext& ctx) { 56void ACC_U0::GetProfile(Kernel::HLERequestContext& ctx) {
57 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 57 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
58 rb.Push(RESULT_SUCCESS); 58 rb.Push(RESULT_SUCCESS);
59 rb.PushIpcInterface<IProfile>(); 59 rb.PushIpcInterface<IProfile>();
60 LOG_DEBUG(Service, "called"); 60 LOG_DEBUG(Service, "called");
@@ -62,12 +62,12 @@ void ACC_U0::GetProfile(Kernel::HLERequestContext& ctx) {
62 62
63void ACC_U0::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) { 63void ACC_U0::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
64 LOG_WARNING(Service, "(STUBBED) called"); 64 LOG_WARNING(Service, "(STUBBED) called");
65 IPC::RequestBuilder rb{ctx, 2}; 65 IPC::ResponseBuilder rb{ctx, 2};
66 rb.Push(RESULT_SUCCESS); 66 rb.Push(RESULT_SUCCESS);
67} 67}
68 68
69void ACC_U0::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) { 69void ACC_U0::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) {
70 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 70 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
71 rb.Push(RESULT_SUCCESS); 71 rb.Push(RESULT_SUCCESS);
72 rb.PushIpcInterface<IManagerForApplication>(); 72 rb.PushIpcInterface<IManagerForApplication>();
73 LOG_DEBUG(Service, "called"); 73 LOG_DEBUG(Service, "called");
diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp
index 7d16b45f3..15b7701e0 100644
--- a/src/core/hle/service/am/applet_oe.cpp
+++ b/src/core/hle/service/am/applet_oe.cpp
@@ -25,14 +25,14 @@ public:
25private: 25private:
26 void GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { 26 void GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
27 LOG_WARNING(Service, "(STUBBED) called"); 27 LOG_WARNING(Service, "(STUBBED) called");
28 IPC::RequestBuilder rb{ctx, 4}; 28 IPC::ResponseBuilder rb{ctx, 4};
29 rb.Push(RESULT_SUCCESS); 29 rb.Push(RESULT_SUCCESS);
30 rb.Push<u64>(0); 30 rb.Push<u64>(0);
31 } 31 }
32 32
33 void AcquireForegroundRights(Kernel::HLERequestContext& ctx) { 33 void AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
34 LOG_WARNING(Service, "(STUBBED) called"); 34 LOG_WARNING(Service, "(STUBBED) called");
35 IPC::RequestBuilder rb{ctx, 2}; 35 IPC::ResponseBuilder rb{ctx, 2};
36 rb.Push(RESULT_SUCCESS); 36 rb.Push(RESULT_SUCCESS);
37 } 37 }
38}; 38};
@@ -86,14 +86,14 @@ private:
86 }; 86 };
87 auto flags = rp.PopRaw<FocusHandlingModeParams>(); 87 auto flags = rp.PopRaw<FocusHandlingModeParams>();
88 88
89 IPC::RequestBuilder rb{ctx, 2}; 89 IPC::ResponseBuilder rb{ctx, 2};
90 rb.Push(RESULT_SUCCESS); 90 rb.Push(RESULT_SUCCESS);
91 91
92 LOG_WARNING(Service, "(STUBBED) called"); 92 LOG_WARNING(Service, "(STUBBED) called");
93 } 93 }
94 94
95 void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) { 95 void SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
96 IPC::RequestBuilder rb{ctx, 2}; 96 IPC::ResponseBuilder rb{ctx, 2};
97 rb.Push(RESULT_SUCCESS); 97 rb.Push(RESULT_SUCCESS);
98 98
99 LOG_WARNING(Service, "(STUBBED) called"); 99 LOG_WARNING(Service, "(STUBBED) called");
@@ -104,7 +104,7 @@ private:
104 104
105 bool flag = rp.Pop<bool>(); 105 bool flag = rp.Pop<bool>();
106 106
107 IPC::RequestBuilder rb{ctx, 2}; 107 IPC::ResponseBuilder rb{ctx, 2};
108 rb.Push(RESULT_SUCCESS); 108 rb.Push(RESULT_SUCCESS);
109 109
110 LOG_WARNING(Service, "(STUBBED) called flag=%u", static_cast<u32>(flag)); 110 LOG_WARNING(Service, "(STUBBED) called flag=%u", static_cast<u32>(flag));
@@ -115,7 +115,7 @@ private:
115 115
116 bool flag = rp.Pop<bool>(); 116 bool flag = rp.Pop<bool>();
117 117
118 IPC::RequestBuilder rb{ctx, 2}; 118 IPC::ResponseBuilder rb{ctx, 2};
119 rb.Push(RESULT_SUCCESS); 119 rb.Push(RESULT_SUCCESS);
120 120
121 LOG_WARNING(Service, "(STUBBED) called flag=%u", static_cast<u32>(flag)); 121 LOG_WARNING(Service, "(STUBBED) called flag=%u", static_cast<u32>(flag));
@@ -128,21 +128,21 @@ private:
128 128
129 bool enabled = rp.Pop<bool>(); 129 bool enabled = rp.Pop<bool>();
130 130
131 IPC::RequestBuilder rb{ctx, 2}; 131 IPC::ResponseBuilder rb{ctx, 2};
132 rb.Push(RESULT_SUCCESS); 132 rb.Push(RESULT_SUCCESS);
133 133
134 LOG_WARNING(Service, "(STUBBED) called enabled=%u", static_cast<u32>(enabled)); 134 LOG_WARNING(Service, "(STUBBED) called enabled=%u", static_cast<u32>(enabled));
135 } 135 }
136 136
137 void LockExit(Kernel::HLERequestContext& ctx) { 137 void LockExit(Kernel::HLERequestContext& ctx) {
138 IPC::RequestBuilder rb{ctx, 2}; 138 IPC::ResponseBuilder rb{ctx, 2};
139 rb.Push(RESULT_SUCCESS); 139 rb.Push(RESULT_SUCCESS);
140 140
141 LOG_WARNING(Service, "(STUBBED) called"); 141 LOG_WARNING(Service, "(STUBBED) called");
142 } 142 }
143 143
144 void UnlockExit(Kernel::HLERequestContext& ctx) { 144 void UnlockExit(Kernel::HLERequestContext& ctx) {
145 IPC::RequestBuilder rb{ctx, 2}; 145 IPC::ResponseBuilder rb{ctx, 2};
146 rb.Push(RESULT_SUCCESS); 146 rb.Push(RESULT_SUCCESS);
147 147
148 LOG_WARNING(Service, "(STUBBED) called"); 148 LOG_WARNING(Service, "(STUBBED) called");
@@ -154,7 +154,7 @@ private:
154 u64 display_id = nvflinger->OpenDisplay("Default"); 154 u64 display_id = nvflinger->OpenDisplay("Default");
155 u64 layer_id = nvflinger->CreateLayer(display_id); 155 u64 layer_id = nvflinger->CreateLayer(display_id);
156 156
157 IPC::RequestBuilder rb{ctx, 4}; 157 IPC::ResponseBuilder rb{ctx, 4};
158 rb.Push(RESULT_SUCCESS); 158 rb.Push(RESULT_SUCCESS);
159 rb.Push(layer_id); 159 rb.Push(layer_id);
160 160
@@ -193,7 +193,7 @@ private:
193 void GetEventHandle(Kernel::HLERequestContext& ctx) { 193 void GetEventHandle(Kernel::HLERequestContext& ctx) {
194 event->Signal(); 194 event->Signal();
195 195
196 IPC::RequestBuilder rb{ctx, 2, 1}; 196 IPC::ResponseBuilder rb{ctx, 2, 1};
197 rb.Push(RESULT_SUCCESS); 197 rb.Push(RESULT_SUCCESS);
198 rb.PushCopyObjects(event); 198 rb.PushCopyObjects(event);
199 199
@@ -201,7 +201,7 @@ private:
201 } 201 }
202 202
203 void ReceiveMessage(Kernel::HLERequestContext& ctx) { 203 void ReceiveMessage(Kernel::HLERequestContext& ctx) {
204 IPC::RequestBuilder rb{ctx, 3}; 204 IPC::ResponseBuilder rb{ctx, 3};
205 rb.Push(RESULT_SUCCESS); 205 rb.Push(RESULT_SUCCESS);
206 rb.Push<u32>(15); 206 rb.Push<u32>(15);
207 207
@@ -209,7 +209,7 @@ private:
209 } 209 }
210 210
211 void GetCurrentFocusState(Kernel::HLERequestContext& ctx) { 211 void GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
212 IPC::RequestBuilder rb{ctx, 3}; 212 IPC::ResponseBuilder rb{ctx, 3};
213 rb.Push(RESULT_SUCCESS); 213 rb.Push(RESULT_SUCCESS);
214 rb.Push(static_cast<u8>(FocusState::InFocus)); 214 rb.Push(static_cast<u8>(FocusState::InFocus));
215 215
@@ -217,7 +217,7 @@ private:
217 } 217 }
218 218
219 void GetOperationMode(Kernel::HLERequestContext& ctx) { 219 void GetOperationMode(Kernel::HLERequestContext& ctx) {
220 IPC::RequestBuilder rb{ctx, 3}; 220 IPC::ResponseBuilder rb{ctx, 3};
221 rb.Push(RESULT_SUCCESS); 221 rb.Push(RESULT_SUCCESS);
222 rb.Push(static_cast<u8>(OperationMode::Handheld)); 222 rb.Push(static_cast<u8>(OperationMode::Handheld));
223 223
@@ -225,7 +225,7 @@ private:
225 } 225 }
226 226
227 void GetPerformanceMode(Kernel::HLERequestContext& ctx) { 227 void GetPerformanceMode(Kernel::HLERequestContext& ctx) {
228 IPC::RequestBuilder rb{ctx, 3}; 228 IPC::ResponseBuilder rb{ctx, 3};
229 rb.Push(RESULT_SUCCESS); 229 rb.Push(RESULT_SUCCESS);
230 rb.Push(static_cast<u32>(APM::PerformanceMode::Handheld)); 230 rb.Push(static_cast<u32>(APM::PerformanceMode::Handheld));
231 231
@@ -250,7 +250,7 @@ private:
250 std::vector<u8> buffer; 250 std::vector<u8> buffer;
251 251
252 void GetSize(Kernel::HLERequestContext& ctx) { 252 void GetSize(Kernel::HLERequestContext& ctx) {
253 IPC::RequestBuilder rb{ctx, 4}; 253 IPC::ResponseBuilder rb{ctx, 4};
254 254
255 rb.Push(RESULT_SUCCESS); 255 rb.Push(RESULT_SUCCESS);
256 rb.Push(static_cast<u64>(buffer.size())); 256 rb.Push(static_cast<u64>(buffer.size()));
@@ -269,7 +269,7 @@ private:
269 269
270 Memory::WriteBlock(output_buffer.Address(), buffer.data() + offset, output_buffer.Size()); 270 Memory::WriteBlock(output_buffer.Address(), buffer.data() + offset, output_buffer.Size());
271 271
272 IPC::RequestBuilder rb{ctx, 2}; 272 IPC::ResponseBuilder rb{ctx, 2};
273 273
274 rb.Push(RESULT_SUCCESS); 274 rb.Push(RESULT_SUCCESS);
275 275
@@ -291,7 +291,7 @@ private:
291 std::vector<u8> buffer; 291 std::vector<u8> buffer;
292 292
293 void Open(Kernel::HLERequestContext& ctx) { 293 void Open(Kernel::HLERequestContext& ctx) {
294 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 294 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
295 295
296 rb.Push(RESULT_SUCCESS); 296 rb.Push(RESULT_SUCCESS);
297 rb.PushIpcInterface<AM::IStorageAccessor>(buffer); 297 rb.PushIpcInterface<AM::IStorageAccessor>(buffer);
@@ -328,7 +328,7 @@ private:
328 328
329 std::vector<u8> buffer(data, data + sizeof(data)); 329 std::vector<u8> buffer(data, data + sizeof(data));
330 330
331 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 331 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
332 332
333 rb.Push(RESULT_SUCCESS); 333 rb.Push(RESULT_SUCCESS);
334 rb.PushIpcInterface<AM::IStorage>(buffer); 334 rb.PushIpcInterface<AM::IStorage>(buffer);
@@ -343,34 +343,34 @@ private:
343 IPC::RequestParser rp{ctx}; 343 IPC::RequestParser rp{ctx};
344 u32 result = rp.Pop<u32>(); 344 u32 result = rp.Pop<u32>();
345 345
346 IPC::RequestBuilder rb{ctx, 2}; 346 IPC::ResponseBuilder rb{ctx, 2};
347 rb.Push(RESULT_SUCCESS); 347 rb.Push(RESULT_SUCCESS);
348 348
349 LOG_WARNING(Service, "(STUBBED) called, result=0x%08X", result); 349 LOG_WARNING(Service, "(STUBBED) called, result=0x%08X", result);
350 } 350 }
351 351
352 void GetDesiredLanguage(Kernel::HLERequestContext& ctx) { 352 void GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
353 IPC::RequestBuilder rb{ctx, 4}; 353 IPC::ResponseBuilder rb{ctx, 4};
354 rb.Push(RESULT_SUCCESS); 354 rb.Push(RESULT_SUCCESS);
355 rb.Push<u64>(SystemLanguage::English); 355 rb.Push<u64>(SystemLanguage::English);
356 LOG_WARNING(Service, "(STUBBED) called"); 356 LOG_WARNING(Service, "(STUBBED) called");
357 } 357 }
358 358
359 void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) { 359 void InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
360 IPC::RequestBuilder rb{ctx, 2}; 360 IPC::ResponseBuilder rb{ctx, 2};
361 rb.Push(RESULT_SUCCESS); 361 rb.Push(RESULT_SUCCESS);
362 LOG_WARNING(Service, "(STUBBED) called"); 362 LOG_WARNING(Service, "(STUBBED) called");
363 } 363 }
364 364
365 void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) { 365 void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
366 IPC::RequestBuilder rb{ctx, 2}; 366 IPC::ResponseBuilder rb{ctx, 2};
367 rb.Push(RESULT_SUCCESS); 367 rb.Push(RESULT_SUCCESS);
368 368
369 LOG_WARNING(Service, "(STUBBED) called"); 369 LOG_WARNING(Service, "(STUBBED) called");
370 } 370 }
371 371
372 void NotifyRunning(Kernel::HLERequestContext& ctx) { 372 void NotifyRunning(Kernel::HLERequestContext& ctx) {
373 IPC::RequestBuilder rb{ctx, 3}; 373 IPC::ResponseBuilder rb{ctx, 3};
374 rb.Push(RESULT_SUCCESS); 374 rb.Push(RESULT_SUCCESS);
375 rb.Push<u8>(0); // Unknown, seems to be ignored by official processes 375 rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
376 376
@@ -402,56 +402,56 @@ public:
402 402
403private: 403private:
404 void GetAudioController(Kernel::HLERequestContext& ctx) { 404 void GetAudioController(Kernel::HLERequestContext& ctx) {
405 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 405 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
406 rb.Push(RESULT_SUCCESS); 406 rb.Push(RESULT_SUCCESS);
407 rb.PushIpcInterface<IAudioController>(); 407 rb.PushIpcInterface<IAudioController>();
408 LOG_DEBUG(Service, "called"); 408 LOG_DEBUG(Service, "called");
409 } 409 }
410 410
411 void GetDisplayController(Kernel::HLERequestContext& ctx) { 411 void GetDisplayController(Kernel::HLERequestContext& ctx) {
412 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 412 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
413 rb.Push(RESULT_SUCCESS); 413 rb.Push(RESULT_SUCCESS);
414 rb.PushIpcInterface<IDisplayController>(); 414 rb.PushIpcInterface<IDisplayController>();
415 LOG_DEBUG(Service, "called"); 415 LOG_DEBUG(Service, "called");
416 } 416 }
417 417
418 void GetDebugFunctions(Kernel::HLERequestContext& ctx) { 418 void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
419 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 419 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
420 rb.Push(RESULT_SUCCESS); 420 rb.Push(RESULT_SUCCESS);
421 rb.PushIpcInterface<IDebugFunctions>(); 421 rb.PushIpcInterface<IDebugFunctions>();
422 LOG_DEBUG(Service, "called"); 422 LOG_DEBUG(Service, "called");
423 } 423 }
424 424
425 void GetWindowController(Kernel::HLERequestContext& ctx) { 425 void GetWindowController(Kernel::HLERequestContext& ctx) {
426 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 426 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
427 rb.Push(RESULT_SUCCESS); 427 rb.Push(RESULT_SUCCESS);
428 rb.PushIpcInterface<IWindowController>(); 428 rb.PushIpcInterface<IWindowController>();
429 LOG_DEBUG(Service, "called"); 429 LOG_DEBUG(Service, "called");
430 } 430 }
431 431
432 void GetSelfController(Kernel::HLERequestContext& ctx) { 432 void GetSelfController(Kernel::HLERequestContext& ctx) {
433 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 433 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
434 rb.Push(RESULT_SUCCESS); 434 rb.Push(RESULT_SUCCESS);
435 rb.PushIpcInterface<ISelfController>(nvflinger); 435 rb.PushIpcInterface<ISelfController>(nvflinger);
436 LOG_DEBUG(Service, "called"); 436 LOG_DEBUG(Service, "called");
437 } 437 }
438 438
439 void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { 439 void GetCommonStateGetter(Kernel::HLERequestContext& ctx) {
440 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 440 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
441 rb.Push(RESULT_SUCCESS); 441 rb.Push(RESULT_SUCCESS);
442 rb.PushIpcInterface<ICommonStateGetter>(); 442 rb.PushIpcInterface<ICommonStateGetter>();
443 LOG_DEBUG(Service, "called"); 443 LOG_DEBUG(Service, "called");
444 } 444 }
445 445
446 void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) { 446 void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
447 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 447 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
448 rb.Push(RESULT_SUCCESS); 448 rb.Push(RESULT_SUCCESS);
449 rb.PushIpcInterface<ILibraryAppletCreator>(); 449 rb.PushIpcInterface<ILibraryAppletCreator>();
450 LOG_DEBUG(Service, "called"); 450 LOG_DEBUG(Service, "called");
451 } 451 }
452 452
453 void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { 453 void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
454 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 454 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
455 rb.Push(RESULT_SUCCESS); 455 rb.Push(RESULT_SUCCESS);
456 rb.PushIpcInterface<IApplicationFunctions>(); 456 rb.PushIpcInterface<IApplicationFunctions>();
457 LOG_DEBUG(Service, "called"); 457 LOG_DEBUG(Service, "called");
@@ -461,7 +461,7 @@ private:
461}; 461};
462 462
463void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) { 463void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
464 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 464 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
465 rb.Push(RESULT_SUCCESS); 465 rb.Push(RESULT_SUCCESS);
466 rb.PushIpcInterface<IApplicationProxy>(nvflinger); 466 rb.PushIpcInterface<IApplicationProxy>(nvflinger);
467 LOG_DEBUG(Service, "called"); 467 LOG_DEBUG(Service, "called");
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp
index bf7e12288..c4b1723c5 100644
--- a/src/core/hle/service/apm/apm.cpp
+++ b/src/core/hle/service/apm/apm.cpp
@@ -30,7 +30,7 @@ private:
30 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>()); 30 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
31 u32 config = rp.Pop<u32>(); 31 u32 config = rp.Pop<u32>();
32 32
33 IPC::RequestBuilder rb{ctx, 2}; 33 IPC::ResponseBuilder rb{ctx, 2};
34 rb.Push(RESULT_SUCCESS); 34 rb.Push(RESULT_SUCCESS);
35 35
36 LOG_WARNING(Service, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode), config); 36 LOG_WARNING(Service, "(STUBBED) called mode=%u config=%u", static_cast<u32>(mode), config);
@@ -41,7 +41,7 @@ private:
41 41
42 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>()); 42 auto mode = static_cast<PerformanceMode>(rp.Pop<u32>());
43 43
44 IPC::RequestBuilder rb{ctx, 3}; 44 IPC::ResponseBuilder rb{ctx, 3};
45 rb.Push(RESULT_SUCCESS); 45 rb.Push(RESULT_SUCCESS);
46 rb.Push<u32>(0); // Performance configuration 46 rb.Push<u32>(0); // Performance configuration
47 47
@@ -58,7 +58,7 @@ APM::APM() : ServiceFramework("apm") {
58} 58}
59 59
60void APM::OpenSession(Kernel::HLERequestContext& ctx) { 60void APM::OpenSession(Kernel::HLERequestContext& ctx) {
61 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 61 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
62 rb.Push(RESULT_SUCCESS); 62 rb.Push(RESULT_SUCCESS);
63 rb.PushIpcInterface<ISession>(); 63 rb.PushIpcInterface<ISession>();
64} 64}
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index df04d636e..f56ba2ea1 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -23,7 +23,7 @@ constexpr u64 audio_ticks{static_cast<u64>(BASE_CLOCK_RATE / 500)};
23 23
24class IAudioOut final : public ServiceFramework<IAudioOut> { 24class IAudioOut final : public ServiceFramework<IAudioOut> {
25public: 25public:
26 IAudioOut() : ServiceFramework("IAudioOut"), audio_out_state(Stopped) { 26 IAudioOut() : ServiceFramework("IAudioOut"), audio_out_state(AudioState::Stopped) {
27 static const FunctionInfo functions[] = { 27 static const FunctionInfo functions[] = {
28 {0x0, nullptr, "GetAudioOutState"}, 28 {0x0, nullptr, "GetAudioOutState"},
29 {0x1, &IAudioOut::StartAudioOut, "StartAudioOut"}, 29 {0x1, &IAudioOut::StartAudioOut, "StartAudioOut"},
@@ -58,29 +58,29 @@ private:
58 void StartAudioOut(Kernel::HLERequestContext& ctx) { 58 void StartAudioOut(Kernel::HLERequestContext& ctx) {
59 LOG_WARNING(Service_Audio, "(STUBBED) called"); 59 LOG_WARNING(Service_Audio, "(STUBBED) called");
60 60
61 // start audio 61 // Start audio
62 audio_out_state = Started; 62 audio_out_state = AudioState::Started;
63 63
64 IPC::RequestBuilder rb{ctx, 2}; 64 IPC::ResponseBuilder rb{ctx, 2};
65 rb.Push(RESULT_SUCCESS); 65 rb.Push(RESULT_SUCCESS);
66 } 66 }
67 67
68 void StopAudioOut(Kernel::HLERequestContext& ctx) { 68 void StopAudioOut(Kernel::HLERequestContext& ctx) {
69 LOG_WARNING(Service_Audio, "(STUBBED) called"); 69 LOG_WARNING(Service_Audio, "(STUBBED) called");
70 70
71 // stop audio 71 // Stop audio
72 audio_out_state = Stopped; 72 audio_out_state = AudioState::Stopped;
73 73
74 queue_keys.clear(); 74 queue_keys.clear();
75 75
76 IPC::RequestBuilder rb{ctx, 2}; 76 IPC::ResponseBuilder rb{ctx, 2};
77 rb.Push(RESULT_SUCCESS); 77 rb.Push(RESULT_SUCCESS);
78 } 78 }
79 79
80 void RegisterBufferEvent(Kernel::HLERequestContext& ctx) { 80 void RegisterBufferEvent(Kernel::HLERequestContext& ctx) {
81 LOG_WARNING(Service_Audio, "(STUBBED) called"); 81 LOG_WARNING(Service_Audio, "(STUBBED) called");
82 82
83 IPC::RequestBuilder rb{ctx, 2, 1}; 83 IPC::ResponseBuilder rb{ctx, 2, 1};
84 rb.Push(RESULT_SUCCESS); 84 rb.Push(RESULT_SUCCESS);
85 rb.PushCopyObjects(buffer_event); 85 rb.PushCopyObjects(buffer_event);
86 } 86 }
@@ -89,11 +89,10 @@ private:
89 LOG_WARNING(Service_Audio, "(STUBBED) called"); 89 LOG_WARNING(Service_Audio, "(STUBBED) called");
90 IPC::RequestParser rp{ctx}; 90 IPC::RequestParser rp{ctx};
91 91
92 u64 key = rp.Pop<u64>(); 92 const u64 key{rp.Pop<u64>()};
93
94 queue_keys.insert(queue_keys.begin(), key); 93 queue_keys.insert(queue_keys.begin(), key);
95 94
96 IPC::RequestBuilder rb{ctx, 2}; 95 IPC::ResponseBuilder rb{ctx, 2};
97 rb.Push(RESULT_SUCCESS); 96 rb.Push(RESULT_SUCCESS);
98 } 97 }
99 98
@@ -102,11 +101,10 @@ private:
102 101
103 const auto& buffer = ctx.BufferDescriptorB()[0]; 102 const auto& buffer = ctx.BufferDescriptorB()[0];
104 103
105 // TODO(st4rk): this is how libtransistor currently implements the 104 // TODO(st4rk): This is how libtransistor currently implements the
106 // GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the APP and this address 105 // GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the app and this address
107 // is used to know which buffer should be filled with data and send again to the service 106 // is used to know which buffer should be filled with data and send again to the service
108 // through AppendAudioOutBuffer. Check if this is the proper way to do it. 107 // through AppendAudioOutBuffer. Check if this is the proper way to do it.
109
110 u64 key{0}; 108 u64 key{0};
111 109
112 if (queue_keys.size()) { 110 if (queue_keys.size()) {
@@ -116,7 +114,7 @@ private:
116 114
117 Memory::WriteBlock(buffer.Address(), &key, sizeof(u64)); 115 Memory::WriteBlock(buffer.Address(), &key, sizeof(u64));
118 116
119 IPC::RequestBuilder rb{ctx, 3}; 117 IPC::ResponseBuilder rb{ctx, 3};
120 rb.Push(RESULT_SUCCESS); 118 rb.Push(RESULT_SUCCESS);
121 // TODO(st4rk): This might be the total of released buffers, needs to be verified on 119 // TODO(st4rk): This might be the total of released buffers, needs to be verified on
122 // hardware 120 // hardware
@@ -124,8 +122,7 @@ private:
124 } 122 }
125 123
126 void UpdateAudioBuffersCallback() { 124 void UpdateAudioBuffersCallback() {
127 125 if (audio_out_state != AudioState::Started) {
128 if (audio_out_state != Started) {
129 return; 126 return;
130 } 127 }
131 128
@@ -136,7 +133,7 @@ private:
136 buffer_event->Signal(); 133 buffer_event->Signal();
137 } 134 }
138 135
139 enum AudioState : u32 { 136 enum class AudioState : u32 {
140 Started, 137 Started,
141 Stopped, 138 Stopped,
142 }; 139 };
@@ -148,10 +145,10 @@ private:
148 /// This is the evend handle used to check if the audio buffer was released 145 /// This is the evend handle used to check if the audio buffer was released
149 Kernel::SharedPtr<Kernel::Event> buffer_event; 146 Kernel::SharedPtr<Kernel::Event> buffer_event;
150 147
151 /// (st4rk): this is just a temporary workaround for the future implementation. Libtransistor 148 /// (st4rk): This is just a temporary workaround for the future implementation. Libtransistor
152 /// uses the key as an address in the App, so we need to return when the 149 /// uses the key as an address in the App, so we need to return when the
153 /// GetReleasedAudioOutBuffer_1 is called, otherwise we'll run in problems, because 150 /// GetReleasedAudioOutBuffer_1 is called, otherwise we'll run in problems, because
154 /// libtransistor uses the key returned as an pointer; 151 /// libtransistor uses the key returned as an pointer.
155 std::vector<u64> queue_keys; 152 std::vector<u64> queue_keys;
156 153
157 AudioState audio_out_state; 154 AudioState audio_out_state;
@@ -166,14 +163,12 @@ void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) {
166 163
167 Memory::WriteBlock(buffer.Address(), &audio_interface[0], audio_interface.size()); 164 Memory::WriteBlock(buffer.Address(), &audio_interface[0], audio_interface.size());
168 165
169 IPC::RequestBuilder rb = rp.MakeBuilder(3, 0, 0, 0); 166 IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0);
170 167
171 rb.Push(RESULT_SUCCESS); 168 rb.Push(RESULT_SUCCESS);
172 // TODO(st4rk): we're currently returning only one audio interface 169 // TODO(st4rk): We're currently returning only one audio interface (stringlist size). However,
173 // (stringlist size) 170 // it's highly possible to have more than one interface (despite that libtransistor requires
174 // however, it's highly possible to have more than one interface (despite that 171 // only one).
175 // libtransistor
176 // requires only one).
177 rb.Push<u32>(1); 172 rb.Push<u32>(1);
178} 173}
179 174
@@ -184,20 +179,13 @@ void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) {
184 audio_out_interface = std::make_shared<IAudioOut>(); 179 audio_out_interface = std::make_shared<IAudioOut>();
185 } 180 }
186 181
187 auto sessions = Kernel::ServerSession::CreateSessionPair(audio_out_interface->GetServiceName()); 182 IPC::ResponseBuilder rb{ctx, 6, 0, 1};
188 auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
189 auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
190 audio_out_interface->ClientConnected(server);
191 LOG_DEBUG(Service, "called, initialized IAudioOut -> session=%u", client->GetObjectId());
192 IPC::RequestBuilder rb{ctx, 6, 0, 1};
193
194 rb.Push(RESULT_SUCCESS); 183 rb.Push(RESULT_SUCCESS);
195 rb.Push<u32>(sample_rate); 184 rb.Push<u32>(sample_rate);
196 rb.Push<u32>(audio_channels); 185 rb.Push<u32>(audio_channels);
197 rb.Push<u32>(static_cast<u32>(PcmFormat::Int16)); 186 rb.Push<u32>(static_cast<u32>(PcmFormat::Int16));
198 // this field is unknown 187 rb.Push<u32>(0); // This field is unknown
199 rb.Push<u32>(0); 188 rb.PushIpcInterface<Audio::IAudioOut>(audio_out_interface);
200 rb.PushMoveObjects(std::move(client));
201} 189}
202 190
203AudOutU::AudOutU() : ServiceFramework("audout:u") { 191AudOutU::AudOutU() : ServiceFramework("audout:u") {
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index ef1915e5a..71b82393e 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -40,12 +40,12 @@ private:
40 // Error checking 40 // Error checking
41 ASSERT_MSG(length == descriptor.Size(), "unexpected size difference"); 41 ASSERT_MSG(length == descriptor.Size(), "unexpected size difference");
42 if (length < 0) { 42 if (length < 0) {
43 IPC::RequestBuilder rb{ctx, 2}; 43 IPC::ResponseBuilder rb{ctx, 2};
44 rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidLength)); 44 rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidLength));
45 return; 45 return;
46 } 46 }
47 if (offset < 0) { 47 if (offset < 0) {
48 IPC::RequestBuilder rb{ctx, 2}; 48 IPC::ResponseBuilder rb{ctx, 2};
49 rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidOffset)); 49 rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidOffset));
50 return; 50 return;
51 } 51 }
@@ -54,7 +54,7 @@ private:
54 std::vector<u8> output(length); 54 std::vector<u8> output(length);
55 ResultVal<size_t> res = backend->Read(offset, length, output.data()); 55 ResultVal<size_t> res = backend->Read(offset, length, output.data());
56 if (res.Failed()) { 56 if (res.Failed()) {
57 IPC::RequestBuilder rb{ctx, 2}; 57 IPC::ResponseBuilder rb{ctx, 2};
58 rb.Push(res.Code()); 58 rb.Push(res.Code());
59 return; 59 return;
60 } 60 }
@@ -62,7 +62,7 @@ private:
62 // Write the data to memory 62 // Write the data to memory
63 Memory::WriteBlock(descriptor.Address(), output.data(), descriptor.Size()); 63 Memory::WriteBlock(descriptor.Address(), output.data(), descriptor.Size());
64 64
65 IPC::RequestBuilder rb{ctx, 2}; 65 IPC::ResponseBuilder rb{ctx, 2};
66 rb.Push(RESULT_SUCCESS); 66 rb.Push(RESULT_SUCCESS);
67 } 67 }
68}; 68};
@@ -91,14 +91,14 @@ void FSP_SRV::TryLoadRomFS() {
91void FSP_SRV::Initalize(Kernel::HLERequestContext& ctx) { 91void FSP_SRV::Initalize(Kernel::HLERequestContext& ctx) {
92 LOG_WARNING(Service_FS, "(STUBBED) called"); 92 LOG_WARNING(Service_FS, "(STUBBED) called");
93 93
94 IPC::RequestBuilder rb{ctx, 2}; 94 IPC::ResponseBuilder rb{ctx, 2};
95 rb.Push(RESULT_SUCCESS); 95 rb.Push(RESULT_SUCCESS);
96} 96}
97 97
98void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { 98void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
99 LOG_WARNING(Service_FS, "(STUBBED) called"); 99 LOG_WARNING(Service_FS, "(STUBBED) called");
100 100
101 IPC::RequestBuilder rb{ctx, 4}; 101 IPC::ResponseBuilder rb{ctx, 3};
102 rb.Push(RESULT_SUCCESS); 102 rb.Push(RESULT_SUCCESS);
103 rb.Push<u32>(5); 103 rb.Push<u32>(5);
104} 104}
@@ -110,7 +110,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
110 if (!romfs) { 110 if (!romfs) {
111 // TODO (bunnei): Find the right error code to use here 111 // TODO (bunnei): Find the right error code to use here
112 LOG_CRITICAL(Service_FS, "no file system interface available!"); 112 LOG_CRITICAL(Service_FS, "no file system interface available!");
113 IPC::RequestBuilder rb{ctx, 2}; 113 IPC::ResponseBuilder rb{ctx, 2};
114 rb.Push(ResultCode(-1)); 114 rb.Push(ResultCode(-1));
115 return; 115 return;
116 } 116 }
@@ -119,12 +119,12 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
119 auto storage = romfs->OpenFile({}, {}); 119 auto storage = romfs->OpenFile({}, {});
120 if (storage.Failed()) { 120 if (storage.Failed()) {
121 LOG_CRITICAL(Service_FS, "no storage interface available!"); 121 LOG_CRITICAL(Service_FS, "no storage interface available!");
122 IPC::RequestBuilder rb{ctx, 2}; 122 IPC::ResponseBuilder rb{ctx, 2};
123 rb.Push(storage.Code()); 123 rb.Push(storage.Code());
124 return; 124 return;
125 } 125 }
126 126
127 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 127 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
128 rb.Push(RESULT_SUCCESS); 128 rb.Push(RESULT_SUCCESS);
129 rb.PushIpcInterface<IStorage>(std::move(storage.Unwrap())); 129 rb.PushIpcInterface<IStorage>(std::move(storage.Unwrap()));
130} 130}
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index ae60cc7b4..326e0a4ab 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -46,7 +46,7 @@ public:
46 46
47private: 47private:
48 void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) { 48 void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
49 IPC::RequestBuilder rb{ctx, 2, 1}; 49 IPC::ResponseBuilder rb{ctx, 2, 1};
50 rb.Push(RESULT_SUCCESS); 50 rb.Push(RESULT_SUCCESS);
51 rb.PushCopyObjects(shared_mem); 51 rb.PushCopyObjects(shared_mem);
52 LOG_DEBUG(Service, "called"); 52 LOG_DEBUG(Service, "called");
@@ -169,19 +169,10 @@ private:
169 applet_resource = std::make_shared<IAppletResource>(); 169 applet_resource = std::make_shared<IAppletResource>();
170 } 170 }
171 171
172 // TODO(Subv): Verify if this should return the interface as a domain object when called 172 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
173 // from within a domain.
174
175 auto sessions = Kernel::ServerSession::CreateSessionPair(applet_resource->GetServiceName());
176 auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
177 auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
178 applet_resource->ClientConnected(server);
179
180 LOG_DEBUG(Service, "called, initialized IAppletResource -> session=%u",
181 client->GetObjectId());
182 IPC::RequestBuilder rb{ctx, 2, 0, 1};
183 rb.Push(RESULT_SUCCESS); 173 rb.Push(RESULT_SUCCESS);
184 rb.PushMoveObjects(std::move(client)); 174 rb.PushIpcInterface<IAppletResource>(applet_resource);
175 LOG_DEBUG(Service, "called");
185 } 176 }
186}; 177};
187 178
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp
index b505cdcaf..2843e0e40 100644
--- a/src/core/hle/service/lm/lm.cpp
+++ b/src/core/hle/service/lm/lm.cpp
@@ -65,7 +65,7 @@ private:
65 */ 65 */
66 void Log(Kernel::HLERequestContext& ctx) { 66 void Log(Kernel::HLERequestContext& ctx) {
67 // This function only succeeds - Get that out of the way 67 // This function only succeeds - Get that out of the way
68 IPC::RequestBuilder rb{ctx, 1}; 68 IPC::ResponseBuilder rb{ctx, 2};
69 rb.Push(RESULT_SUCCESS); 69 rb.Push(RESULT_SUCCESS);
70 70
71 // Read MessageHeader, despite not doing anything with it right now 71 // Read MessageHeader, despite not doing anything with it right now
@@ -130,7 +130,7 @@ private:
130 } 130 }
131 output += message; 131 output += message;
132 132
133 LOG_DEBUG(Debug_Emulated, "%s", output.c_str()); 133 LOG_INFO(Debug_Emulated, "%s", output.c_str());
134 } 134 }
135}; 135};
136 136
@@ -146,21 +146,11 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {
146 * 0: ResultCode 146 * 0: ResultCode
147 */ 147 */
148void LM::Initialize(Kernel::HLERequestContext& ctx) { 148void LM::Initialize(Kernel::HLERequestContext& ctx) {
149 // TODO(Subv): Verify if this should return the interface as a domain object when called from 149 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
150 // within a domain.
151
152 auto logger = std::make_shared<Logger>();
153 auto sessions = Kernel::ServerSession::CreateSessionPair(logger->GetServiceName());
154 auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
155 auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
156 logger->ClientConnected(server);
157
158 LOG_DEBUG(Service_SM, "called, initialized logger -> session=%u", client->GetObjectId());
159 IPC::RequestBuilder rb{ctx, 2, 0, 1};
160 rb.Push(RESULT_SUCCESS); 150 rb.Push(RESULT_SUCCESS);
161 rb.PushMoveObjects(std::move(client)); 151 rb.PushIpcInterface<Logger>();
162 152
163 LOG_INFO(Service_SM, "called"); 153 LOG_DEBUG(Service, "called");
164} 154}
165 155
166LM::LM() : ServiceFramework("lm") { 156LM::LM() : ServiceFramework("lm") {
diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp
index 0181d1b4f..85ecde6d2 100644
--- a/src/core/hle/service/nvdrv/interface.cpp
+++ b/src/core/hle/service/nvdrv/interface.cpp
@@ -18,7 +18,7 @@ void NVDRV::Open(Kernel::HLERequestContext& ctx) {
18 std::string device_name = Memory::ReadCString(buffer.Address(), buffer.Size()); 18 std::string device_name = Memory::ReadCString(buffer.Address(), buffer.Size());
19 19
20 u32 fd = nvdrv->Open(device_name); 20 u32 fd = nvdrv->Open(device_name);
21 IPC::RequestBuilder rb{ctx, 4}; 21 IPC::ResponseBuilder rb{ctx, 4};
22 rb.Push(RESULT_SUCCESS); 22 rb.Push(RESULT_SUCCESS);
23 rb.Push<u32>(fd); 23 rb.Push<u32>(fd);
24 rb.Push<u32>(0); 24 rb.Push<u32>(0);
@@ -43,7 +43,7 @@ void NVDRV::Ioctl(Kernel::HLERequestContext& ctx) {
43 43
44 Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.Size()); 44 Memory::WriteBlock(output_buffer.Address(), output.data(), output_buffer.Size());
45 45
46 IPC::RequestBuilder rb{ctx, 3}; 46 IPC::ResponseBuilder rb{ctx, 3};
47 rb.Push(RESULT_SUCCESS); 47 rb.Push(RESULT_SUCCESS);
48 rb.Push(nv_result); 48 rb.Push(nv_result);
49} 49}
@@ -56,13 +56,13 @@ void NVDRV::Close(Kernel::HLERequestContext& ctx) {
56 56
57 auto result = nvdrv->Close(fd); 57 auto result = nvdrv->Close(fd);
58 58
59 IPC::RequestBuilder rb{ctx, 2}; 59 IPC::ResponseBuilder rb{ctx, 2};
60 rb.Push(result); 60 rb.Push(result);
61} 61}
62 62
63void NVDRV::Initialize(Kernel::HLERequestContext& ctx) { 63void NVDRV::Initialize(Kernel::HLERequestContext& ctx) {
64 LOG_WARNING(Service, "(STUBBED) called"); 64 LOG_WARNING(Service, "(STUBBED) called");
65 IPC::RequestBuilder rb{ctx, 3}; 65 IPC::ResponseBuilder rb{ctx, 3};
66 rb.Push(RESULT_SUCCESS); 66 rb.Push(RESULT_SUCCESS);
67 rb.Push<u32>(0); 67 rb.Push<u32>(0);
68} 68}
@@ -72,7 +72,7 @@ void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) {
72 pid = rp.Pop<u64>(); 72 pid = rp.Pop<u64>();
73 73
74 LOG_INFO(Service, "called, pid=0x%lx", pid); 74 LOG_INFO(Service, "called, pid=0x%lx", pid);
75 IPC::RequestBuilder rb{ctx, 3}; 75 IPC::ResponseBuilder rb{ctx, 3};
76 rb.Push(RESULT_SUCCESS); 76 rb.Push(RESULT_SUCCESS);
77 rb.Push<u32>(0); 77 rb.Push<u32>(0);
78} 78}
diff --git a/src/core/hle/service/pctl/pctl_a.cpp b/src/core/hle/service/pctl/pctl_a.cpp
index 7978aecb8..c808b764b 100644
--- a/src/core/hle/service/pctl/pctl_a.cpp
+++ b/src/core/hle/service/pctl/pctl_a.cpp
@@ -15,7 +15,7 @@ public:
15}; 15};
16 16
17void PCTL_A::GetService(Kernel::HLERequestContext& ctx) { 17void PCTL_A::GetService(Kernel::HLERequestContext& ctx) {
18 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 18 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
19 rb.Push(RESULT_SUCCESS); 19 rb.Push(RESULT_SUCCESS);
20 rb.PushIpcInterface<IParentalControlService>(); 20 rb.PushIpcInterface<IParentalControlService>();
21 LOG_DEBUG(Service, "called"); 21 LOG_DEBUG(Service, "called");
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 1b8565351..294351b76 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -132,7 +132,7 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
132ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) { 132ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) {
133 switch (context.GetCommandType()) { 133 switch (context.GetCommandType()) {
134 case IPC::CommandType::Close: { 134 case IPC::CommandType::Close: {
135 IPC::RequestBuilder rb{context, 1}; 135 IPC::ResponseBuilder rb{context, 2};
136 rb.Push(RESULT_SUCCESS); 136 rb.Push(RESULT_SUCCESS);
137 return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead); 137 return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead);
138 } 138 }
diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp
index 3715acd74..e0e157fe1 100644
--- a/src/core/hle/service/set/set.cpp
+++ b/src/core/hle/service/set/set.cpp
@@ -19,7 +19,7 @@ void SET::GetAvailableLanguageCodes(Kernel::HLERequestContext& ctx) {
19 19
20 Memory::WriteBlock(output_buffer.Address(), lang_codes.data(), lang_codes.size()); 20 Memory::WriteBlock(output_buffer.Address(), lang_codes.data(), lang_codes.size());
21 21
22 IPC::RequestBuilder rb{ctx, 4}; 22 IPC::ResponseBuilder rb{ctx, 4};
23 23
24 rb.Push(RESULT_SUCCESS); 24 rb.Push(RESULT_SUCCESS);
25 rb.Push(static_cast<u64>(lang_codes.size())); 25 rb.Push(static_cast<u64>(lang_codes.size()));
diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp
index 7b1c8ee37..a81ff9f49 100644
--- a/src/core/hle/service/sm/controller.cpp
+++ b/src/core/hle/service/sm/controller.cpp
@@ -4,30 +4,26 @@
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/hle/ipc_helpers.h" 6#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/domain.h"
8#include "core/hle/service/sm/controller.h" 7#include "core/hle/service/sm/controller.h"
9 8
10namespace Service { 9namespace Service {
11namespace SM { 10namespace SM {
12 11
13void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) { 12void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
14 auto domain = Kernel::Domain::CreateFromSession(*ctx.ServerSession()->parent).Unwrap(); 13 ASSERT_MSG(!ctx.Session()->IsDomain(), "session is alread a domain");
14 ctx.Session()->ConvertToDomain();
15 15
16 IPC::RequestBuilder rb{ctx, 3}; 16 IPC::ResponseBuilder rb{ctx, 3};
17 rb.Push(RESULT_SUCCESS); 17 rb.Push(RESULT_SUCCESS);
18 rb.Push(static_cast<u32>(domain->request_handlers.size())); 18 rb.Push<u32>(1); // Converted sessions start with 1 request handler
19 19
20 LOG_DEBUG(Service, "called, domain=%d", domain->GetObjectId()); 20 LOG_DEBUG(Service, "called, server_session=%d", ctx.Session()->GetObjectId());
21} 21}
22 22
23void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) { 23void Controller::DuplicateSession(Kernel::HLERequestContext& ctx) {
24 IPC::RequestBuilder rb{ctx, 2, 0, 1}; 24 IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
25 rb.Push(RESULT_SUCCESS); 25 rb.Push(RESULT_SUCCESS);
26 // TODO(Subv): Check if this is correct 26 rb.PushMoveObjects(ctx.Session());
27 if (ctx.IsDomain())
28 rb.PushMoveObjects(ctx.Domain());
29 else
30 rb.PushMoveObjects(ctx.ServerSession());
31 27
32 LOG_DEBUG(Service, "called"); 28 LOG_DEBUG(Service, "called");
33} 29}
@@ -39,7 +35,7 @@ void Controller::DuplicateSessionEx(Kernel::HLERequestContext& ctx) {
39} 35}
40 36
41void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) { 37void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
42 IPC::RequestBuilder rb{ctx, 3}; 38 IPC::ResponseBuilder rb{ctx, 3};
43 rb.Push(RESULT_SUCCESS); 39 rb.Push(RESULT_SUCCESS);
44 rb.Push<u32>(0x500); 40 rb.Push<u32>(0x500);
45 41
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index c4078f02f..73aa013e3 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -83,7 +83,7 @@ std::shared_ptr<ServiceManager> g_service_manager;
83 * 0: ResultCode 83 * 0: ResultCode
84 */ 84 */
85void SM::Initialize(Kernel::HLERequestContext& ctx) { 85void SM::Initialize(Kernel::HLERequestContext& ctx) {
86 IPC::RequestBuilder rb{ctx, 1}; 86 IPC::ResponseBuilder rb{ctx, 2};
87 rb.Push(RESULT_SUCCESS); 87 rb.Push(RESULT_SUCCESS);
88 LOG_DEBUG(Service_SM, "called"); 88 LOG_DEBUG(Service_SM, "called");
89} 89}
@@ -99,7 +99,7 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
99 99
100 auto client_port = service_manager->GetServicePort(name); 100 auto client_port = service_manager->GetServicePort(name);
101 if (client_port.Failed()) { 101 if (client_port.Failed()) {
102 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0); 102 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
103 rb.Push(client_port.Code()); 103 rb.Push(client_port.Code());
104 LOG_ERROR(Service_SM, "called service=%s -> error 0x%08X", name.c_str(), 104 LOG_ERROR(Service_SM, "called service=%s -> error 0x%08X", name.c_str(),
105 client_port.Code().raw); 105 client_port.Code().raw);
@@ -112,7 +112,8 @@ void SM::GetService(Kernel::HLERequestContext& ctx) {
112 if (session.Succeeded()) { 112 if (session.Succeeded()) {
113 LOG_DEBUG(Service_SM, "called service=%s -> session=%u", name.c_str(), 113 LOG_DEBUG(Service_SM, "called service=%s -> session=%u", name.c_str(),
114 (*session)->GetObjectId()); 114 (*session)->GetObjectId());
115 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 1, 0); 115 IPC::ResponseBuilder rb =
116 rp.MakeBuilder(2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles);
116 rb.Push(session.Code()); 117 rb.Push(session.Code());
117 rb.PushMoveObjects(std::move(session).Unwrap()); 118 rb.PushMoveObjects(std::move(session).Unwrap());
118 } 119 }
diff --git a/src/core/hle/service/sockets/bsd_u.cpp b/src/core/hle/service/sockets/bsd_u.cpp
index a819acc96..4fd960bd8 100644
--- a/src/core/hle/service/sockets/bsd_u.cpp
+++ b/src/core/hle/service/sockets/bsd_u.cpp
@@ -11,7 +11,7 @@ namespace Sockets {
11void BSD_U::RegisterClient(Kernel::HLERequestContext& ctx) { 11void BSD_U::RegisterClient(Kernel::HLERequestContext& ctx) {
12 LOG_WARNING(Service, "(STUBBED) called"); 12 LOG_WARNING(Service, "(STUBBED) called");
13 13
14 IPC::RequestBuilder rb{ctx, 3}; 14 IPC::ResponseBuilder rb{ctx, 3};
15 15
16 rb.Push(RESULT_SUCCESS); 16 rb.Push(RESULT_SUCCESS);
17 rb.Push<u32>(0); // bsd errno 17 rb.Push<u32>(0); // bsd errno
@@ -28,7 +28,7 @@ void BSD_U::Socket(Kernel::HLERequestContext& ctx) {
28 28
29 u32 fd = next_fd++; 29 u32 fd = next_fd++;
30 30
31 IPC::RequestBuilder rb{ctx, 4}; 31 IPC::ResponseBuilder rb{ctx, 4};
32 32
33 rb.Push(RESULT_SUCCESS); 33 rb.Push(RESULT_SUCCESS);
34 rb.Push<u32>(fd); 34 rb.Push<u32>(fd);
@@ -38,7 +38,7 @@ void BSD_U::Socket(Kernel::HLERequestContext& ctx) {
38void BSD_U::Connect(Kernel::HLERequestContext& ctx) { 38void BSD_U::Connect(Kernel::HLERequestContext& ctx) {
39 LOG_WARNING(Service, "(STUBBED) called"); 39 LOG_WARNING(Service, "(STUBBED) called");
40 40
41 IPC::RequestBuilder rb{ctx, 4}; 41 IPC::ResponseBuilder rb{ctx, 4};
42 42
43 rb.Push(RESULT_SUCCESS); 43 rb.Push(RESULT_SUCCESS);
44 rb.Push<u32>(0); // ret 44 rb.Push<u32>(0); // ret
@@ -48,7 +48,7 @@ void BSD_U::Connect(Kernel::HLERequestContext& ctx) {
48void BSD_U::SendTo(Kernel::HLERequestContext& ctx) { 48void BSD_U::SendTo(Kernel::HLERequestContext& ctx) {
49 LOG_WARNING(Service, "(STUBBED) called"); 49 LOG_WARNING(Service, "(STUBBED) called");
50 50
51 IPC::RequestBuilder rb{ctx, 4}; 51 IPC::ResponseBuilder rb{ctx, 4};
52 52
53 rb.Push(RESULT_SUCCESS); 53 rb.Push(RESULT_SUCCESS);
54 rb.Push<u32>(0); // ret 54 rb.Push<u32>(0); // ret
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp
index 448ef8544..96ccee50d 100644
--- a/src/core/hle/service/time/time.cpp
+++ b/src/core/hle/service/time/time.cpp
@@ -19,7 +19,7 @@ public:
19 ISystemClock() : ServiceFramework("ISystemClock") { 19 ISystemClock() : ServiceFramework("ISystemClock") {
20 static const FunctionInfo functions[] = { 20 static const FunctionInfo functions[] = {
21 {0, &ISystemClock::GetCurrentTime, "GetCurrentTime"}, 21 {0, &ISystemClock::GetCurrentTime, "GetCurrentTime"},
22 }; 22 {2, &ISystemClock::GetSystemClockContext, "GetSystemClockContext"}};
23 RegisterHandlers(functions); 23 RegisterHandlers(functions);
24 } 24 }
25 25
@@ -28,10 +28,18 @@ private:
28 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( 28 const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>(
29 std::chrono::system_clock::now().time_since_epoch()) 29 std::chrono::system_clock::now().time_since_epoch())
30 .count()}; 30 .count()};
31 IPC::RequestBuilder rb{ctx, 4}; 31 LOG_DEBUG(Service, "called");
32 IPC::ResponseBuilder rb{ctx, 4};
32 rb.Push(RESULT_SUCCESS); 33 rb.Push(RESULT_SUCCESS);
33 rb.Push<u64>(time_since_epoch); 34 rb.Push<u64>(time_since_epoch);
34 LOG_DEBUG(Service, "called"); 35 }
36
37 void GetSystemClockContext(Kernel::HLERequestContext& ctx) {
38 LOG_WARNING(Service, "(STUBBED) called");
39 SystemClockContext system_clock_ontext{};
40 IPC::ResponseBuilder rb{ctx, (sizeof(SystemClockContext) / 4) + 2};
41 rb.Push(RESULT_SUCCESS);
42 rb.PushRaw(system_clock_ontext);
35 } 43 }
36}; 44};
37 45
@@ -55,14 +63,14 @@ private:
55 void GetDeviceLocationName(Kernel::HLERequestContext& ctx) { 63 void GetDeviceLocationName(Kernel::HLERequestContext& ctx) {
56 LOG_WARNING(Service, "(STUBBED) called"); 64 LOG_WARNING(Service, "(STUBBED) called");
57 LocationName location_name{}; 65 LocationName location_name{};
58 IPC::RequestBuilder rb{ctx, (sizeof(LocationName) / 4) + 2}; 66 IPC::ResponseBuilder rb{ctx, (sizeof(LocationName) / 4) + 2};
59 rb.Push(RESULT_SUCCESS); 67 rb.Push(RESULT_SUCCESS);
60 rb.PushRaw(location_name); 68 rb.PushRaw(location_name);
61 } 69 }
62 70
63 void GetTotalLocationNameCount(Kernel::HLERequestContext& ctx) { 71 void GetTotalLocationNameCount(Kernel::HLERequestContext& ctx) {
64 LOG_WARNING(Service, "(STUBBED) called"); 72 LOG_WARNING(Service, "(STUBBED) called");
65 IPC::RequestBuilder rb{ctx, 3}; 73 IPC::ResponseBuilder rb{ctx, 3};
66 rb.Push(RESULT_SUCCESS); 74 rb.Push(RESULT_SUCCESS);
67 rb.Push<u32>(0); 75 rb.Push<u32>(0);
68 } 76 }
@@ -75,7 +83,7 @@ private:
75 83
76 CalendarTime calendar_time{2018, 1, 1, 0, 0, 0}; 84 CalendarTime calendar_time{2018, 1, 1, 0, 0, 0};
77 CalendarAdditionalInfo additional_info{}; 85 CalendarAdditionalInfo additional_info{};
78 IPC::RequestBuilder rb{ctx, 10}; 86 IPC::ResponseBuilder rb{ctx, 10};
79 rb.Push(RESULT_SUCCESS); 87 rb.Push(RESULT_SUCCESS);
80 rb.PushRaw(calendar_time); 88 rb.PushRaw(calendar_time);
81 rb.PushRaw(additional_info); 89 rb.PushRaw(additional_info);
@@ -83,49 +91,28 @@ private:
83}; 91};
84 92
85void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) { 93void Module::Interface::GetStandardUserSystemClock(Kernel::HLERequestContext& ctx) {
86 // TODO(Subv): Verify if this should return the interface as a domain object when called from 94 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
87 // within a domain.
88 auto system_clock = std::make_shared<ISystemClock>();
89 auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
90 auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
91 auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
92 system_clock->ClientConnected(server);
93 LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId());
94 IPC::RequestBuilder rb{ctx, 2, 0, 1};
95 rb.Push(RESULT_SUCCESS); 95 rb.Push(RESULT_SUCCESS);
96 rb.PushMoveObjects(std::move(client)); 96 rb.PushIpcInterface<ISystemClock>();
97 LOG_DEBUG(Service, "called");
97} 98}
98 99
99void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) { 100void Module::Interface::GetStandardNetworkSystemClock(Kernel::HLERequestContext& ctx) {
100 // TODO(Subv): Verify if this should return the interface as a domain object when called from 101 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
101 // within a domain.
102 auto system_clock = std::make_shared<ISystemClock>();
103 auto sessions = Kernel::ServerSession::CreateSessionPair(system_clock->GetServiceName());
104 auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
105 auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
106 system_clock->ClientConnected(server);
107 LOG_DEBUG(Service, "called, initialized ISystemClock -> session=%u", client->GetObjectId());
108 IPC::RequestBuilder rb{ctx, 2, 0, 1};
109 rb.Push(RESULT_SUCCESS); 102 rb.Push(RESULT_SUCCESS);
110 rb.PushMoveObjects(std::move(client)); 103 rb.PushIpcInterface<ISystemClock>();
104 LOG_DEBUG(Service, "called");
111} 105}
112 106
113void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) { 107void Module::Interface::GetStandardSteadyClock(Kernel::HLERequestContext& ctx) {
114 // TODO(Subv): Verify if this should return the interface as a domain object when called from 108 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
115 // within a domain.
116 auto steady_clock = std::make_shared<ISteadyClock>();
117 auto sessions = Kernel::ServerSession::CreateSessionPair(steady_clock->GetServiceName());
118 auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
119 auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions);
120 steady_clock->ClientConnected(server);
121 LOG_DEBUG(Service, "called, initialized ISteadyClock -> session=%u", client->GetObjectId());
122 IPC::RequestBuilder rb{ctx, 2, 0, 1};
123 rb.Push(RESULT_SUCCESS); 109 rb.Push(RESULT_SUCCESS);
124 rb.PushMoveObjects(std::move(client)); 110 rb.PushIpcInterface<ISteadyClock>();
111 LOG_DEBUG(Service, "called");
125} 112}
126 113
127void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) { 114void Module::Interface::GetTimeZoneService(Kernel::HLERequestContext& ctx) {
128 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 115 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
129 rb.Push(RESULT_SUCCESS); 116 rb.Push(RESULT_SUCCESS);
130 rb.PushIpcInterface<ITimeZoneService>(); 117 rb.PushIpcInterface<ITimeZoneService>();
131 LOG_DEBUG(Service, "called"); 118 LOG_DEBUG(Service, "called");
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h
index 399f474d6..cd936a50c 100644
--- a/src/core/hle/service/time/time.h
+++ b/src/core/hle/service/time/time.h
@@ -33,6 +33,13 @@ struct CalendarAdditionalInfo {
33static_assert(sizeof(CalendarAdditionalInfo) == 0x18, 33static_assert(sizeof(CalendarAdditionalInfo) == 0x18,
34 "CalendarAdditionalInfo structure has incorrect size"); 34 "CalendarAdditionalInfo structure has incorrect size");
35 35
36// TODO(bunnei) RE this structure
37struct SystemClockContext {
38 INSERT_PADDING_BYTES(0x20);
39};
40static_assert(sizeof(SystemClockContext) == 0x20,
41 "SystemClockContext structure has incorrect size");
42
36class Module final { 43class Module final {
37public: 44public:
38 class Interface : public ServiceFramework<Interface> { 45 class Interface : public ServiceFramework<Interface> {
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index 6576f81db..3b993f36c 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -486,7 +486,7 @@ private:
486 } 486 }
487 487
488 LOG_WARNING(Service, "(STUBBED) called"); 488 LOG_WARNING(Service, "(STUBBED) called");
489 IPC::RequestBuilder rb{ctx, 2}; 489 IPC::ResponseBuilder rb{ctx, 2};
490 rb.Push(RESULT_SUCCESS); 490 rb.Push(RESULT_SUCCESS);
491 } 491 }
492 492
@@ -497,7 +497,7 @@ private:
497 u32 type = rp.Pop<u32>(); 497 u32 type = rp.Pop<u32>();
498 498
499 LOG_WARNING(Service, "(STUBBED) called id=%u, addval=%08X, type=%08X", id, addval, type); 499 LOG_WARNING(Service, "(STUBBED) called id=%u, addval=%08X, type=%08X", id, addval, type);
500 IPC::RequestBuilder rb{ctx, 2}; 500 IPC::ResponseBuilder rb{ctx, 2};
501 rb.Push(RESULT_SUCCESS); 501 rb.Push(RESULT_SUCCESS);
502 } 502 }
503 503
@@ -511,7 +511,7 @@ private:
511 // TODO(Subv): Find out what this actually is. 511 // TODO(Subv): Find out what this actually is.
512 512
513 LOG_WARNING(Service, "(STUBBED) called id=%u, unknown=%08X", id, unknown); 513 LOG_WARNING(Service, "(STUBBED) called id=%u, unknown=%08X", id, unknown);
514 IPC::RequestBuilder rb{ctx, 2, 1}; 514 IPC::ResponseBuilder rb{ctx, 2, 1};
515 rb.Push(RESULT_SUCCESS); 515 rb.Push(RESULT_SUCCESS);
516 rb.PushCopyObjects(buffer_queue->GetNativeHandle()); 516 rb.PushCopyObjects(buffer_queue->GetNativeHandle());
517 } 517 }
@@ -537,7 +537,7 @@ private:
537 u64 layer_id = rp.Pop<u64>(); 537 u64 layer_id = rp.Pop<u64>();
538 u64 z_value = rp.Pop<u64>(); 538 u64 z_value = rp.Pop<u64>();
539 539
540 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0); 540 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
541 rb.Push(RESULT_SUCCESS); 541 rb.Push(RESULT_SUCCESS);
542 } 542 }
543}; 543};
@@ -562,7 +562,7 @@ private:
562 IPC::RequestParser rp{ctx}; 562 IPC::RequestParser rp{ctx};
563 u64 display = rp.Pop<u64>(); 563 u64 display = rp.Pop<u64>();
564 564
565 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0); 565 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
566 rb.Push(RESULT_SUCCESS); 566 rb.Push(RESULT_SUCCESS);
567 } 567 }
568 568
@@ -576,7 +576,7 @@ private:
576 576
577 u64 layer_id = nv_flinger->CreateLayer(display); 577 u64 layer_id = nv_flinger->CreateLayer(display);
578 578
579 IPC::RequestBuilder rb = rp.MakeBuilder(4, 0, 0, 0); 579 IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
580 rb.Push(RESULT_SUCCESS); 580 rb.Push(RESULT_SUCCESS);
581 rb.Push(layer_id); 581 rb.Push(layer_id);
582 } 582 }
@@ -587,7 +587,7 @@ private:
587 u32 stack = rp.Pop<u32>(); 587 u32 stack = rp.Pop<u32>();
588 u64 layer_id = rp.Pop<u64>(); 588 u64 layer_id = rp.Pop<u64>();
589 589
590 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0); 590 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
591 rb.Push(RESULT_SUCCESS); 591 rb.Push(RESULT_SUCCESS);
592 } 592 }
593 593
@@ -597,7 +597,7 @@ private:
597void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx) { 597void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx) {
598 LOG_WARNING(Service, "(STUBBED) called"); 598 LOG_WARNING(Service, "(STUBBED) called");
599 599
600 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 600 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
601 rb.Push(RESULT_SUCCESS); 601 rb.Push(RESULT_SUCCESS);
602 rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger); 602 rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger);
603} 603}
@@ -605,7 +605,7 @@ void IApplicationDisplayService::GetRelayService(Kernel::HLERequestContext& ctx)
605void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestContext& ctx) { 605void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestContext& ctx) {
606 LOG_WARNING(Service, "(STUBBED) called"); 606 LOG_WARNING(Service, "(STUBBED) called");
607 607
608 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 608 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
609 rb.Push(RESULT_SUCCESS); 609 rb.Push(RESULT_SUCCESS);
610 rb.PushIpcInterface<ISystemDisplayService>(); 610 rb.PushIpcInterface<ISystemDisplayService>();
611} 611}
@@ -613,7 +613,7 @@ void IApplicationDisplayService::GetSystemDisplayService(Kernel::HLERequestConte
613void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestContext& ctx) { 613void IApplicationDisplayService::GetManagerDisplayService(Kernel::HLERequestContext& ctx) {
614 LOG_WARNING(Service, "(STUBBED) called"); 614 LOG_WARNING(Service, "(STUBBED) called");
615 615
616 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 616 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
617 rb.Push(RESULT_SUCCESS); 617 rb.Push(RESULT_SUCCESS);
618 rb.PushIpcInterface<IManagerDisplayService>(nv_flinger); 618 rb.PushIpcInterface<IManagerDisplayService>(nv_flinger);
619} 619}
@@ -622,7 +622,7 @@ void IApplicationDisplayService::GetIndirectDisplayTransactionService(
622 Kernel::HLERequestContext& ctx) { 622 Kernel::HLERequestContext& ctx) {
623 LOG_WARNING(Service, "(STUBBED) called"); 623 LOG_WARNING(Service, "(STUBBED) called");
624 624
625 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 625 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
626 rb.Push(RESULT_SUCCESS); 626 rb.Push(RESULT_SUCCESS);
627 rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger); 627 rb.PushIpcInterface<IHOSBinderDriver>(nv_flinger);
628} 628}
@@ -637,7 +637,7 @@ void IApplicationDisplayService::OpenDisplay(Kernel::HLERequestContext& ctx) {
637 637
638 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet"); 638 ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet");
639 639
640 IPC::RequestBuilder rb = rp.MakeBuilder(4, 0, 0, 0); 640 IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
641 rb.Push(RESULT_SUCCESS); 641 rb.Push(RESULT_SUCCESS);
642 rb.Push<u64>(nv_flinger->OpenDisplay(name)); 642 rb.Push<u64>(nv_flinger->OpenDisplay(name));
643} 643}
@@ -647,7 +647,7 @@ void IApplicationDisplayService::CloseDisplay(Kernel::HLERequestContext& ctx) {
647 IPC::RequestParser rp{ctx}; 647 IPC::RequestParser rp{ctx};
648 u64 display_id = rp.Pop<u64>(); 648 u64 display_id = rp.Pop<u64>();
649 649
650 IPC::RequestBuilder rb = rp.MakeBuilder(4, 0, 0, 0); 650 IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
651 rb.Push(RESULT_SUCCESS); 651 rb.Push(RESULT_SUCCESS);
652} 652}
653 653
@@ -671,7 +671,7 @@ void IApplicationDisplayService::OpenLayer(Kernel::HLERequestContext& ctx) {
671 auto data = native_window.Serialize(); 671 auto data = native_window.Serialize();
672 Memory::WriteBlock(buffer.Address(), data.data(), data.size()); 672 Memory::WriteBlock(buffer.Address(), data.data(), data.size());
673 673
674 IPC::RequestBuilder rb = rp.MakeBuilder(4, 0, 0, 0); 674 IPC::ResponseBuilder rb = rp.MakeBuilder(4, 0, 0);
675 rb.Push(RESULT_SUCCESS); 675 rb.Push(RESULT_SUCCESS);
676 rb.Push<u64>(data.size()); 676 rb.Push<u64>(data.size());
677} 677}
@@ -694,7 +694,7 @@ void IApplicationDisplayService::CreateStrayLayer(Kernel::HLERequestContext& ctx
694 auto data = native_window.Serialize(); 694 auto data = native_window.Serialize();
695 Memory::WriteBlock(buffer.Address(), data.data(), data.size()); 695 Memory::WriteBlock(buffer.Address(), data.data(), data.size());
696 696
697 IPC::RequestBuilder rb = rp.MakeBuilder(6, 0, 0, 0); 697 IPC::ResponseBuilder rb = rp.MakeBuilder(6, 0, 0);
698 rb.Push(RESULT_SUCCESS); 698 rb.Push(RESULT_SUCCESS);
699 rb.Push(layer_id); 699 rb.Push(layer_id);
700 rb.Push<u64>(data.size()); 700 rb.Push<u64>(data.size());
@@ -706,7 +706,7 @@ void IApplicationDisplayService::DestroyStrayLayer(Kernel::HLERequestContext& ct
706 IPC::RequestParser rp{ctx}; 706 IPC::RequestParser rp{ctx};
707 u64 layer_id = rp.Pop<u64>(); 707 u64 layer_id = rp.Pop<u64>();
708 708
709 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0); 709 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
710 rb.Push(RESULT_SUCCESS); 710 rb.Push(RESULT_SUCCESS);
711} 711}
712 712
@@ -716,7 +716,7 @@ void IApplicationDisplayService::SetLayerScalingMode(Kernel::HLERequestContext&
716 u32 scaling_mode = rp.Pop<u32>(); 716 u32 scaling_mode = rp.Pop<u32>();
717 u64 unknown = rp.Pop<u64>(); 717 u64 unknown = rp.Pop<u64>();
718 718
719 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0, 0, 0); 719 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
720 rb.Push(RESULT_SUCCESS); 720 rb.Push(RESULT_SUCCESS);
721} 721}
722 722
@@ -727,7 +727,7 @@ void IApplicationDisplayService::GetDisplayVsyncEvent(Kernel::HLERequestContext&
727 727
728 auto vsync_event = nv_flinger->GetVsyncEvent(display_id); 728 auto vsync_event = nv_flinger->GetVsyncEvent(display_id);
729 729
730 IPC::RequestBuilder rb = rp.MakeBuilder(2, 1, 0, 0); 730 IPC::ResponseBuilder rb = rp.MakeBuilder(2, 1, 0);
731 rb.Push(RESULT_SUCCESS); 731 rb.Push(RESULT_SUCCESS);
732 rb.PushCopyObjects(vsync_event); 732 rb.PushCopyObjects(vsync_event);
733} 733}
diff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cpp
index 20b24658e..bb440cadb 100644
--- a/src/core/hle/service/vi/vi_m.cpp
+++ b/src/core/hle/service/vi/vi_m.cpp
@@ -13,7 +13,8 @@ namespace VI {
13void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) { 13void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) {
14 LOG_WARNING(Service, "(STUBBED) called"); 14 LOG_WARNING(Service, "(STUBBED) called");
15 15
16 IPC::RequestBuilder rb{ctx, 2, 0, 0, 1}; 16 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
17 rb.Push(RESULT_SUCCESS);
17 rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger); 18 rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);
18} 19}
19 20