summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/core/CMakeLists.txt3
-rw-r--r--src/core/hle/ipc_helpers.h115
-rw-r--r--src/core/hle/kernel/client_session.h6
-rw-r--r--src/core/hle/kernel/domain.cpp63
-rw-r--r--src/core/hle/kernel/domain.h45
-rw-r--r--src/core/hle/kernel/handle_table.cpp10
-rw-r--r--src/core/hle/kernel/handle_table.h7
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp11
-rw-r--r--src/core/hle/kernel/hle_ipc.h27
-rw-r--r--src/core/hle/kernel/kernel.h16
-rw-r--r--src/core/hle/kernel/server_session.cpp47
-rw-r--r--src/core/hle/kernel/server_session.h18
-rw-r--r--src/core/hle/kernel/svc.cpp3
-rw-r--r--src/core/hle/kernel/sync_object.h35
-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
32 files changed, 311 insertions, 452 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 242c2db0c..70547c8b2 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -36,8 +36,6 @@ add_library(core STATIC
36 hle/kernel/client_session.h 36 hle/kernel/client_session.h
37 hle/kernel/condition_variable.cpp 37 hle/kernel/condition_variable.cpp
38 hle/kernel/condition_variable.h 38 hle/kernel/condition_variable.h
39 hle/kernel/domain.cpp
40 hle/kernel/domain.h
41 hle/kernel/errors.h 39 hle/kernel/errors.h
42 hle/kernel/event.cpp 40 hle/kernel/event.cpp
43 hle/kernel/event.h 41 hle/kernel/event.h
@@ -67,7 +65,6 @@ add_library(core STATIC
67 hle/kernel/svc.cpp 65 hle/kernel/svc.cpp
68 hle/kernel/svc.h 66 hle/kernel/svc.h
69 hle/kernel/svc_wrap.h 67 hle/kernel/svc_wrap.h
70 hle/kernel/sync_object.h
71 hle/kernel/thread.cpp 68 hle/kernel/thread.cpp
72 hle/kernel/thread.h 69 hle/kernel/thread.h
73 hle/kernel/timer.cpp 70 hle/kernel/timer.cpp
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index ab479b49b..6066d8a18 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -11,7 +11,6 @@
11#include "core/hle/ipc.h" 11#include "core/hle/ipc.h"
12#include "core/hle/kernel/client_port.h" 12#include "core/hle/kernel/client_port.h"
13#include "core/hle/kernel/client_session.h" 13#include "core/hle/kernel/client_session.h"
14#include "core/hle/kernel/domain.h"
15#include "core/hle/kernel/handle_table.h" 14#include "core/hle/kernel/handle_table.h"
16#include "core/hle/kernel/hle_ipc.h" 15#include "core/hle/kernel/hle_ipc.h"
17#include "core/hle/kernel/kernel.h" 16#include "core/hle/kernel/kernel.h"
@@ -31,11 +30,6 @@ public:
31 RequestHelperBase(Kernel::HLERequestContext& context) 30 RequestHelperBase(Kernel::HLERequestContext& context)
32 : context(&context), cmdbuf(context.CommandBuffer()) {} 31 : context(&context), cmdbuf(context.CommandBuffer()) {}
33 32
34 void ValidateHeader() {
35 // DEBUG_ASSERT_MSG(index == TotalSize(), "Operations do not match the header (cmd 0x%x)",
36 // header.raw);
37 }
38
39 void Skip(unsigned size_in_words, bool set_to_null) { 33 void Skip(unsigned size_in_words, bool set_to_null) {
40 if (set_to_null) 34 if (set_to_null)
41 memset(cmdbuf + index, 0, size_in_words * sizeof(u32)); 35 memset(cmdbuf + index, 0, size_in_words * sizeof(u32));
@@ -60,14 +54,30 @@ public:
60 } 54 }
61}; 55};
62 56
63class RequestBuilder : public RequestHelperBase { 57class ResponseBuilder : public RequestHelperBase {
64public: 58public:
65 RequestBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {} 59 ResponseBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {}
60
61 u32 normal_params_size{};
62 u32 num_handles_to_copy{};
63 u32 num_objects_to_move{}; ///< Domain objects or move handles, context dependent
64 std::ptrdiff_t datapayload_index{};
65
66 /// Flags used for customizing the behavior of ResponseBuilder
67 enum class Flags : u32 {
68 None = 0,
69 /// Uses move handles to move objects in the response, even when in a domain. This is
70 /// required when PushMoveObjects is used.
71 AlwaysMoveHandles = 1,
72 };
73
74 ResponseBuilder(Kernel::HLERequestContext& context, u32 normal_params_size,
75 u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0,
76 Flags flags = Flags::None)
77
78 : RequestHelperBase(context), normal_params_size(normal_params_size),
79 num_handles_to_copy(num_handles_to_copy), num_objects_to_move(num_objects_to_move) {
66 80
67 RequestBuilder(Kernel::HLERequestContext& context, unsigned normal_params_size,
68 u32 num_handles_to_copy = 0, u32 num_handles_to_move = 0,
69 u32 num_domain_objects = 0)
70 : RequestHelperBase(context) {
71 memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH); 81 memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH);
72 82
73 context.ClearIncomingObjects(); 83 context.ClearIncomingObjects();
@@ -77,12 +87,19 @@ public:
77 // The entire size of the raw data section in u32 units, including the 16 bytes of mandatory 87 // The entire size of the raw data section in u32 units, including the 16 bytes of mandatory
78 // padding. 88 // padding.
79 u32 raw_data_size = sizeof(IPC::DataPayloadHeader) / 4 + 4 + normal_params_size; 89 u32 raw_data_size = sizeof(IPC::DataPayloadHeader) / 4 + 4 + normal_params_size;
80 if (context.IsDomain()) { 90
81 raw_data_size += sizeof(DomainMessageHeader) / 4 + num_domain_objects; 91 u32 num_handles_to_move{};
92 u32 num_domain_objects{};
93 const bool always_move_handles{
94 (static_cast<u32>(flags) & static_cast<u32>(Flags::AlwaysMoveHandles)) != 0};
95 if (!context.Session()->IsDomain() || always_move_handles) {
96 num_handles_to_move = num_objects_to_move;
82 } else { 97 } else {
83 // If we're not in a domain, turn the domain object parameters into move handles. 98 num_domain_objects = num_objects_to_move;
84 num_handles_to_move += num_domain_objects; 99 }
85 num_domain_objects = 0; 100
101 if (context.Session()->IsDomain()) {
102 raw_data_size += sizeof(DomainMessageHeader) / 4 + num_domain_objects;
86 } 103 }
87 104
88 header.data_size.Assign(raw_data_size); 105 header.data_size.Assign(raw_data_size);
@@ -101,7 +118,7 @@ public:
101 118
102 AlignWithPadding(); 119 AlignWithPadding();
103 120
104 if (context.IsDomain()) { 121 if (context.Session()->IsDomain()) {
105 IPC::DomainMessageHeader domain_header{}; 122 IPC::DomainMessageHeader domain_header{};
106 domain_header.num_objects = num_domain_objects; 123 domain_header.num_objects = num_domain_objects;
107 PushRaw(domain_header); 124 PushRaw(domain_header);
@@ -110,12 +127,13 @@ public:
110 IPC::DataPayloadHeader data_payload_header{}; 127 IPC::DataPayloadHeader data_payload_header{};
111 data_payload_header.magic = Common::MakeMagic('S', 'F', 'C', 'O'); 128 data_payload_header.magic = Common::MakeMagic('S', 'F', 'C', 'O');
112 PushRaw(data_payload_header); 129 PushRaw(data_payload_header);
130
131 datapayload_index = index;
113 } 132 }
114 133
115 template <class T, class... Args> 134 template <class T>
116 void PushIpcInterface(Args&&... args) { 135 void PushIpcInterface(std::shared_ptr<T> iface) {
117 auto iface = std::make_shared<T>(std::forward<Args>(args)...); 136 if (context->Session()->IsDomain()) {
118 if (context->IsDomain()) {
119 context->AddDomainObject(std::move(iface)); 137 context->AddDomainObject(std::move(iface));
120 } else { 138 } else {
121 auto sessions = Kernel::ServerSession::CreateSessionPair(iface->GetServiceName()); 139 auto sessions = Kernel::ServerSession::CreateSessionPair(iface->GetServiceName());
@@ -126,8 +144,26 @@ public:
126 } 144 }
127 } 145 }
128 146
147 template <class T, class... Args>
148 void PushIpcInterface(Args&&... args) {
149 PushIpcInterface<T>(std::make_shared<T>(std::forward<Args>(args)...));
150 }
151
152 void ValidateHeader() {
153 const size_t num_domain_objects = context->NumDomainObjects();
154 const size_t num_move_objects = context->NumMoveObjects();
155 ASSERT_MSG(!num_domain_objects || !num_move_objects,
156 "cannot move normal handles and domain objects");
157 ASSERT_MSG((index - datapayload_index) == normal_params_size,
158 "normal_params_size value is incorrect");
159 ASSERT_MSG((num_domain_objects + num_move_objects) == num_objects_to_move,
160 "num_objects_to_move value is incorrect");
161 ASSERT_MSG(context->NumCopyObjects() == num_handles_to_copy,
162 "num_handles_to_copy value is incorrect");
163 }
164
129 // Validate on destruction, as there shouldn't be any case where we don't want it 165 // Validate on destruction, as there shouldn't be any case where we don't want it
130 ~RequestBuilder() { 166 ~ResponseBuilder() {
131 ValidateHeader(); 167 ValidateHeader();
132 } 168 }
133 169
@@ -155,52 +191,52 @@ public:
155/// Push /// 191/// Push ///
156 192
157template <> 193template <>
158inline void RequestBuilder::Push(u32 value) { 194inline void ResponseBuilder::Push(u32 value) {
159 cmdbuf[index++] = value; 195 cmdbuf[index++] = value;
160} 196}
161 197
162template <typename T> 198template <typename T>
163void RequestBuilder::PushRaw(const T& value) { 199void ResponseBuilder::PushRaw(const T& value) {
164 std::memcpy(cmdbuf + index, &value, sizeof(T)); 200 std::memcpy(cmdbuf + index, &value, sizeof(T));
165 index += (sizeof(T) + 3) / 4; // round up to word length 201 index += (sizeof(T) + 3) / 4; // round up to word length
166} 202}
167 203
168template <> 204template <>
169inline void RequestBuilder::Push(ResultCode value) { 205inline void ResponseBuilder::Push(ResultCode value) {
170 // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded. 206 // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded.
171 Push(value.raw); 207 Push(value.raw);
172 Push<u32>(0); 208 Push<u32>(0);
173} 209}
174 210
175template <> 211template <>
176inline void RequestBuilder::Push(u8 value) { 212inline void ResponseBuilder::Push(u8 value) {
177 PushRaw(value); 213 PushRaw(value);
178} 214}
179 215
180template <> 216template <>
181inline void RequestBuilder::Push(u16 value) { 217inline void ResponseBuilder::Push(u16 value) {
182 PushRaw(value); 218 PushRaw(value);
183} 219}
184 220
185template <> 221template <>
186inline void RequestBuilder::Push(u64 value) { 222inline void ResponseBuilder::Push(u64 value) {
187 Push(static_cast<u32>(value)); 223 Push(static_cast<u32>(value));
188 Push(static_cast<u32>(value >> 32)); 224 Push(static_cast<u32>(value >> 32));
189} 225}
190 226
191template <> 227template <>
192inline void RequestBuilder::Push(bool value) { 228inline void ResponseBuilder::Push(bool value) {
193 Push(static_cast<u8>(value)); 229 Push(static_cast<u8>(value));
194} 230}
195 231
196template <typename First, typename... Other> 232template <typename First, typename... Other>
197void RequestBuilder::Push(const First& first_value, const Other&... other_values) { 233void ResponseBuilder::Push(const First& first_value, const Other&... other_values) {
198 Push(first_value); 234 Push(first_value);
199 Push(other_values...); 235 Push(other_values...);
200} 236}
201 237
202template <typename... O> 238template <typename... O>
203inline void RequestBuilder::PushCopyObjects(Kernel::SharedPtr<O>... pointers) { 239inline void ResponseBuilder::PushCopyObjects(Kernel::SharedPtr<O>... pointers) {
204 auto objects = {pointers...}; 240 auto objects = {pointers...};
205 for (auto& object : objects) { 241 for (auto& object : objects) {
206 context->AddCopyObject(std::move(object)); 242 context->AddCopyObject(std::move(object));
@@ -208,7 +244,7 @@ inline void RequestBuilder::PushCopyObjects(Kernel::SharedPtr<O>... pointers) {
208} 244}
209 245
210template <typename... O> 246template <typename... O>
211inline void RequestBuilder::PushMoveObjects(Kernel::SharedPtr<O>... pointers) { 247inline void ResponseBuilder::PushMoveObjects(Kernel::SharedPtr<O>... pointers) {
212 auto objects = {pointers...}; 248 auto objects = {pointers...};
213 for (auto& object : objects) { 249 for (auto& object : objects) {
214 context->AddMoveObject(std::move(object)); 250 context->AddMoveObject(std::move(object));
@@ -227,15 +263,10 @@ public:
227 Skip(CommandIdSize, false); 263 Skip(CommandIdSize, false);
228 } 264 }
229 265
230 RequestBuilder MakeBuilder(u32 normal_params_size, u32 num_handles_to_copy, 266 ResponseBuilder MakeBuilder(u32 normal_params_size, u32 num_handles_to_copy,
231 u32 num_handles_to_move, u32 num_domain_objects, 267 u32 num_handles_to_move,
232 bool validate_header = true) { 268 ResponseBuilder::Flags flags = ResponseBuilder::Flags::None) {
233 if (validate_header) { 269 return {*context, normal_params_size, num_handles_to_copy, num_handles_to_move, flags};
234 ValidateHeader();
235 }
236
237 return {*context, normal_params_size, num_handles_to_copy, num_handles_to_move,
238 num_domain_objects};
239 } 270 }
240 271
241 template <typename T> 272 template <typename T>
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index d6ab4f893..2258f95bc 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -7,7 +7,7 @@
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "core/hle/kernel/sync_object.h" 10#include "core/hle/kernel/kernel.h"
11#include "core/hle/result.h" 11#include "core/hle/result.h"
12 12
13namespace Kernel { 13namespace Kernel {
@@ -16,7 +16,7 @@ class ServerSession;
16class Session; 16class Session;
17class Thread; 17class Thread;
18 18
19class ClientSession final : public SyncObject { 19class ClientSession final : public Object {
20public: 20public:
21 friend class ServerSession; 21 friend class ServerSession;
22 22
@@ -33,7 +33,7 @@ public:
33 return HANDLE_TYPE; 33 return HANDLE_TYPE;
34 } 34 }
35 35
36 ResultCode SendSyncRequest(SharedPtr<Thread> thread) override; 36 ResultCode SendSyncRequest(SharedPtr<Thread> thread);
37 37
38 std::string name; ///< Name of client port (optional) 38 std::string name; ///< Name of client port (optional)
39 39
diff --git a/src/core/hle/kernel/domain.cpp b/src/core/hle/kernel/domain.cpp
deleted file mode 100644
index 5035e9c08..000000000
--- a/src/core/hle/kernel/domain.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/logging/log.h"
6#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/client_port.h"
8#include "core/hle/kernel/domain.h"
9#include "core/hle/kernel/handle_table.h"
10#include "core/hle/kernel/hle_ipc.h"
11#include "core/hle/kernel/process.h"
12#include "core/hle/kernel/session.h"
13#include "core/hle/kernel/thread.h"
14
15namespace Kernel {
16
17ResultVal<SharedPtr<Domain>> Domain::Create(std::string name) {
18 SharedPtr<Domain> domain(new Domain);
19 domain->name = std::move(name);
20 return MakeResult(std::move(domain));
21}
22
23ResultVal<SharedPtr<Domain>> Domain::CreateFromSession(const Session& session) {
24 auto res = Create(session.port->GetName() + "_Domain");
25 auto& domain = res.Unwrap();
26 domain->request_handlers.push_back(std::move(session.server->hle_handler));
27 Kernel::g_handle_table.ConvertSessionToDomain(session, domain);
28 return res;
29}
30
31ResultCode Domain::SendSyncRequest(SharedPtr<Thread> thread) {
32 Kernel::HLERequestContext context(this);
33 u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
34 context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
35 Kernel::g_handle_table);
36
37 auto& domain_message_header = context.GetDomainMessageHeader();
38 if (domain_message_header) {
39 // If there is a DomainMessageHeader, then this is CommandType "Request"
40 const u32 object_id{context.GetDomainMessageHeader()->object_id};
41 switch (domain_message_header->command) {
42 case IPC::DomainMessageHeader::CommandType::SendMessage:
43 return request_handlers[object_id - 1]->HandleSyncRequest(context);
44
45 case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: {
46 LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id);
47
48 request_handlers[object_id - 1] = nullptr;
49
50 IPC::RequestBuilder rb{context, 2};
51 rb.Push(RESULT_SUCCESS);
52
53 return RESULT_SUCCESS;
54 }
55 }
56
57 LOG_CRITICAL(IPC, "Unknown domain command=%d", domain_message_header->command.Value());
58 UNIMPLEMENTED();
59 }
60 return request_handlers.front()->HandleSyncRequest(context);
61}
62
63} // namespace Kernel
diff --git a/src/core/hle/kernel/domain.h b/src/core/hle/kernel/domain.h
deleted file mode 100644
index 3fec3b0b2..000000000
--- a/src/core/hle/kernel/domain.h
+++ /dev/null
@@ -1,45 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <string>
9#include <vector>
10#include "core/hle/kernel/sync_object.h"
11#include "core/hle/result.h"
12
13namespace Kernel {
14
15class Session;
16class SessionRequestHandler;
17
18class Domain final : public SyncObject {
19public:
20 std::string GetTypeName() const override {
21 return "Domain";
22 }
23
24 static const HandleType HANDLE_TYPE = HandleType::Domain;
25 HandleType GetHandleType() const override {
26 return HANDLE_TYPE;
27 }
28
29 static ResultVal<SharedPtr<Domain>> CreateFromSession(const Session& server);
30
31 ResultCode SendSyncRequest(SharedPtr<Thread> thread) override;
32
33 /// The name of this domain (optional)
34 std::string name;
35
36 std::vector<std::shared_ptr<SessionRequestHandler>> request_handlers;
37
38private:
39 Domain() = default;
40 ~Domain() override = default;
41
42 static ResultVal<SharedPtr<Domain>> Create(std::string name = "Unknown");
43};
44
45} // namespace Kernel
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index 74d3d0514..3beb55753 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -5,12 +5,10 @@
5#include <utility> 5#include <utility>
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "core/hle/kernel/client_session.h"
9#include "core/hle/kernel/errors.h" 8#include "core/hle/kernel/errors.h"
10#include "core/hle/kernel/handle_table.h" 9#include "core/hle/kernel/handle_table.h"
11#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/process.h" 11#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/session.h"
14#include "core/hle/kernel/thread.h" 12#include "core/hle/kernel/thread.h"
15 13
16namespace Kernel { 14namespace Kernel {
@@ -55,14 +53,6 @@ ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
55 return Create(std::move(object)); 53 return Create(std::move(object));
56} 54}
57 55
58void HandleTable::ConvertSessionToDomain(const Session& session, SharedPtr<Object> domain) {
59 for (auto& object : objects) {
60 if (DynamicObjectCast<ClientSession>(object) == session.client) {
61 object = domain;
62 }
63 }
64}
65
66ResultCode HandleTable::Close(Handle handle) { 56ResultCode HandleTable::Close(Handle handle) {
67 if (!IsValid(handle)) 57 if (!IsValid(handle))
68 return ERR_INVALID_HANDLE; 58 return ERR_INVALID_HANDLE;
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h
index 935cc22b5..ba968c666 100644
--- a/src/core/hle/kernel/handle_table.h
+++ b/src/core/hle/kernel/handle_table.h
@@ -17,8 +17,6 @@ enum KernelHandle : Handle {
17 CurrentProcess = 0xFFFF8001, 17 CurrentProcess = 0xFFFF8001,
18}; 18};
19 19
20class Session;
21
22/** 20/**
23 * This class allows the creation of Handles, which are references to objects that can be tested 21 * This class allows the creation of Handles, which are references to objects that can be tested
24 * for validity and looked up. Here they are used to pass references to kernel objects to/from the 22 * for validity and looked up. Here they are used to pass references to kernel objects to/from the
@@ -62,11 +60,6 @@ public:
62 ResultVal<Handle> Duplicate(Handle handle); 60 ResultVal<Handle> Duplicate(Handle handle);
63 61
64 /** 62 /**
65 * Convert all handles of the specified Session to the specified Domain.
66 */
67 void ConvertSessionToDomain(const Session& session, SharedPtr<Object> domain);
68
69 /**
70 * Closes a handle, removing it from the table and decreasing the object's ref-count. 63 * Closes a handle, removing it from the table and decreasing the object's ref-count.
71 * @return `RESULT_SUCCESS` or one of the following errors: 64 * @return `RESULT_SUCCESS` or one of the following errors:
72 * - `ERR_INVALID_HANDLE`: an invalid handle was passed in. 65 * - `ERR_INVALID_HANDLE`: an invalid handle was passed in.
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index ecf32c18a..db104e8a2 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -7,7 +7,6 @@
7#include "common/common_funcs.h" 7#include "common/common_funcs.h"
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/domain.h"
11#include "core/hle/kernel/handle_table.h" 10#include "core/hle/kernel/handle_table.h"
12#include "core/hle/kernel/hle_ipc.h" 11#include "core/hle/kernel/hle_ipc.h"
13#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
@@ -26,10 +25,6 @@ void SessionRequestHandler::ClientDisconnected(SharedPtr<ServerSession> server_s
26 boost::range::remove_erase(connected_sessions, server_session); 25 boost::range::remove_erase(connected_sessions, server_session);
27} 26}
28 27
29HLERequestContext::HLERequestContext(SharedPtr<Kernel::Domain> domain) : domain(std::move(domain)) {
30 cmd_buf[0] = 0;
31}
32
33HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session) 28HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session)
34 : server_session(std::move(server_session)) { 29 : server_session(std::move(server_session)) {
35 cmd_buf[0] = 0; 30 cmd_buf[0] = 0;
@@ -87,7 +82,7 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
87 // Padding to align to 16 bytes 82 // Padding to align to 16 bytes
88 rp.AlignWithPadding(); 83 rp.AlignWithPadding();
89 84
90 if (IsDomain() && (command_header->type == IPC::CommandType::Request || !incoming)) { 85 if (Session()->IsDomain() && (command_header->type == IPC::CommandType::Request || !incoming)) {
91 // If this is an incoming message, only CommandType "Request" has a domain header 86 // If this is an incoming message, only CommandType "Request" has a domain header
92 // All outgoing domain messages have the domain header 87 // All outgoing domain messages have the domain header
93 domain_message_header = 88 domain_message_header =
@@ -200,12 +195,12 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P
200 195
201 // TODO(Subv): Translate the X/A/B/W buffers. 196 // TODO(Subv): Translate the X/A/B/W buffers.
202 197
203 if (IsDomain()) { 198 if (Session()->IsDomain()) {
204 ASSERT(domain_message_header->num_objects == domain_objects.size()); 199 ASSERT(domain_message_header->num_objects == domain_objects.size());
205 // Write the domain objects to the command buffer, these go after the raw untranslated data. 200 // Write the domain objects to the command buffer, these go after the raw untranslated data.
206 // TODO(Subv): This completely ignores C buffers. 201 // TODO(Subv): This completely ignores C buffers.
207 size_t domain_offset = size - domain_message_header->num_objects; 202 size_t domain_offset = size - domain_message_header->num_objects;
208 auto& request_handlers = domain->request_handlers; 203 auto& request_handlers = server_session->domain_request_handlers;
209 204
210 for (auto& object : domain_objects) { 205 for (auto& object : domain_objects) {
211 request_handlers.emplace_back(object); 206 request_handlers.emplace_back(object);
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 80fa48d7f..da8335b35 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -86,7 +86,6 @@ protected:
86 */ 86 */
87class HLERequestContext { 87class HLERequestContext {
88public: 88public:
89 HLERequestContext(SharedPtr<Kernel::Domain> domain);
90 HLERequestContext(SharedPtr<Kernel::ServerSession> session); 89 HLERequestContext(SharedPtr<Kernel::ServerSession> session);
91 ~HLERequestContext(); 90 ~HLERequestContext();
92 91
@@ -96,17 +95,10 @@ public:
96 } 95 }
97 96
98 /** 97 /**
99 * Returns the domain through which this request was made.
100 */
101 const SharedPtr<Kernel::Domain>& Domain() const {
102 return domain;
103 }
104
105 /**
106 * Returns the session through which this request was made. This can be used as a map key to 98 * Returns the session through which this request was made. This can be used as a map key to
107 * access per-client data on services. 99 * access per-client data on services.
108 */ 100 */
109 const SharedPtr<Kernel::ServerSession>& ServerSession() const { 101 const SharedPtr<Kernel::ServerSession>& Session() const {
110 return server_session; 102 return server_session;
111 } 103 }
112 104
@@ -151,10 +143,6 @@ public:
151 return domain_message_header; 143 return domain_message_header;
152 } 144 }
153 145
154 bool IsDomain() const {
155 return domain != nullptr;
156 }
157
158 template <typename T> 146 template <typename T>
159 SharedPtr<T> GetCopyObject(size_t index) { 147 SharedPtr<T> GetCopyObject(size_t index) {
160 ASSERT(index < copy_objects.size()); 148 ASSERT(index < copy_objects.size());
@@ -187,9 +175,20 @@ public:
187 domain_objects.clear(); 175 domain_objects.clear();
188 } 176 }
189 177
178 size_t NumMoveObjects() const {
179 return move_objects.size();
180 }
181
182 size_t NumCopyObjects() const {
183 return copy_objects.size();
184 }
185
186 size_t NumDomainObjects() const {
187 return domain_objects.size();
188 }
189
190private: 190private:
191 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; 191 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
192 SharedPtr<Kernel::Domain> domain;
193 SharedPtr<Kernel::ServerSession> server_session; 192 SharedPtr<Kernel::ServerSession> server_session;
194 // TODO(yuriks): Check common usage of this and optimize size accordingly 193 // TODO(yuriks): Check common usage of this and optimize size accordingly
195 boost::container::small_vector<SharedPtr<Object>, 8> move_objects; 194 boost::container::small_vector<SharedPtr<Object>, 8> move_objects;
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 4d9549e45..c77e58f3c 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -31,7 +31,6 @@ enum class HandleType : u32 {
31 ServerPort, 31 ServerPort,
32 ClientSession, 32 ClientSession,
33 ServerSession, 33 ServerSession,
34 Domain,
35}; 34};
36 35
37enum { 36enum {
@@ -84,27 +83,12 @@ public:
84 case HandleType::CodeSet: 83 case HandleType::CodeSet:
85 case HandleType::ClientPort: 84 case HandleType::ClientPort:
86 case HandleType::ClientSession: 85 case HandleType::ClientSession:
87 case HandleType::Domain:
88 return false; 86 return false;
89 } 87 }
90 88
91 UNREACHABLE(); 89 UNREACHABLE();
92 } 90 }
93 91
94 /**
95 * Check if svcSendSyncRequest can be called on the object
96 * @return True svcSendSyncRequest can be called on the object, otherwise false
97 */
98 bool IsSyncable() const {
99 switch (GetHandleType()) {
100 case HandleType::ClientSession:
101 case HandleType::Domain:
102 return true;
103 }
104
105 UNREACHABLE();
106 }
107
108public: 92public:
109 static unsigned int next_object_id; 93 static unsigned int next_object_id;
110 94
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index 09d02a691..54481f7f1 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -4,6 +4,7 @@
4 4
5#include <tuple> 5#include <tuple>
6 6
7#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/client_port.h" 8#include "core/hle/kernel/client_port.h"
8#include "core/hle/kernel/client_session.h" 9#include "core/hle/kernel/client_session.h"
9#include "core/hle/kernel/handle_table.h" 10#include "core/hle/kernel/handle_table.h"
@@ -61,6 +62,38 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
61 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or 62 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
62 // similar. 63 // similar.
63 64
65 Kernel::HLERequestContext context(this);
66 u32* cmd_buf = (u32*)Memory::GetPointer(thread->GetTLSAddress());
67 context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
68 Kernel::g_handle_table);
69
70 // If the session has been converted to a domain, handle the doomain request
71 if (IsDomain()) {
72 auto& domain_message_header = context.GetDomainMessageHeader();
73 if (domain_message_header) {
74 // If there is a DomainMessageHeader, then this is CommandType "Request"
75 const u32 object_id{context.GetDomainMessageHeader()->object_id};
76 switch (domain_message_header->command) {
77 case IPC::DomainMessageHeader::CommandType::SendMessage:
78 return domain_request_handlers[object_id - 1]->HandleSyncRequest(context);
79
80 case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: {
81 LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id);
82
83 domain_request_handlers[object_id - 1] = nullptr;
84
85 IPC::ResponseBuilder rb{context, 2};
86 rb.Push(RESULT_SUCCESS);
87 return RESULT_SUCCESS;
88 }
89 }
90
91 LOG_CRITICAL(IPC, "Unknown domain command=%d", domain_message_header->command.Value());
92 ASSERT(false);
93 }
94 // If there is no domain header, the regular session handler is used
95 }
96
64 // If this ServerSession has an associated HLE handler, forward the request to it. 97 // If this ServerSession has an associated HLE handler, forward the request to it.
65 ResultCode result{RESULT_SUCCESS}; 98 ResultCode result{RESULT_SUCCESS};
66 if (hle_handler != nullptr) { 99 if (hle_handler != nullptr) {
@@ -69,11 +102,6 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
69 if (translate_result.IsError()) 102 if (translate_result.IsError())
70 return translate_result; 103 return translate_result;
71 104
72 Kernel::HLERequestContext context(this);
73 u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
74 context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
75 Kernel::g_handle_table);
76
77 result = hle_handler->HandleSyncRequest(context); 105 result = hle_handler->HandleSyncRequest(context);
78 } else { 106 } else {
79 // Add the thread to the list of threads that have issued a sync request with this 107 // Add the thread to the list of threads that have issued a sync request with this
@@ -84,6 +112,15 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
84 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting 112 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting
85 // on it. 113 // on it.
86 WakeupAllWaitingThreads(); 114 WakeupAllWaitingThreads();
115
116 // Handle scenario when ConvertToDomain command was issued, as we must do the conversion at the
117 // end of the command such that only commands following this one are handled as domains
118 if (convert_to_domain) {
119 ASSERT_MSG(domain_request_handlers.empty(), "already a domain");
120 domain_request_handlers = {hle_handler};
121 convert_to_domain = false;
122 }
123
87 return result; 124 return result;
88} 125}
89 126
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 6ff4ef8c1..144692106 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -79,7 +79,10 @@ public:
79 std::string name; ///< The name of this session (optional) 79 std::string name; ///< The name of this session (optional)
80 std::shared_ptr<Session> parent; ///< The parent session, which links to the client endpoint. 80 std::shared_ptr<Session> parent; ///< The parent session, which links to the client endpoint.
81 std::shared_ptr<SessionRequestHandler> 81 std::shared_ptr<SessionRequestHandler>
82 hle_handler; ///< This session's HLE request handler (optional) 82 hle_handler; ///< This session's HLE request handler (applicable when not a domain)
83
84 /// This is the list of domain request handlers (after conversion to a domain)
85 std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers;
83 86
84 /// List of threads that are pending a response after a sync request. This list is processed in 87 /// List of threads that are pending a response after a sync request. This list is processed in
85 /// a LIFO manner, thus, the last request will be dispatched first. 88 /// a LIFO manner, thus, the last request will be dispatched first.
@@ -91,6 +94,16 @@ public:
91 /// TODO(Subv): Find a better name for this. 94 /// TODO(Subv): Find a better name for this.
92 SharedPtr<Thread> currently_handling; 95 SharedPtr<Thread> currently_handling;
93 96
97 /// Returns true if the session has been converted to a domain, otherwise False
98 bool IsDomain() const {
99 return !domain_request_handlers.empty();
100 }
101
102 /// Converts the session to a domain at the end of the current command
103 void ConvertToDomain() {
104 convert_to_domain = true;
105 }
106
94private: 107private:
95 ServerSession(); 108 ServerSession();
96 ~ServerSession() override; 109 ~ServerSession() override;
@@ -102,6 +115,9 @@ private:
102 * @return The created server session 115 * @return The created server session
103 */ 116 */
104 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown"); 117 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown");
118
119 /// When set to True, converts the session to a domain at the end of the command
120 bool convert_to_domain{};
105}; 121};
106 122
107/** 123/**
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 516309036..4c0276cf0 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -20,7 +20,6 @@
20#include "core/hle/kernel/shared_memory.h" 20#include "core/hle/kernel/shared_memory.h"
21#include "core/hle/kernel/svc.h" 21#include "core/hle/kernel/svc.h"
22#include "core/hle/kernel/svc_wrap.h" 22#include "core/hle/kernel/svc_wrap.h"
23#include "core/hle/kernel/sync_object.h"
24#include "core/hle/kernel/thread.h" 23#include "core/hle/kernel/thread.h"
25#include "core/hle/lock.h" 24#include "core/hle/lock.h"
26#include "core/hle/result.h" 25#include "core/hle/result.h"
@@ -87,7 +86,7 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address
87 86
88/// Makes a blocking IPC call to an OS service. 87/// Makes a blocking IPC call to an OS service.
89static ResultCode SendSyncRequest(Handle handle) { 88static ResultCode SendSyncRequest(Handle handle) {
90 SharedPtr<SyncObject> session = g_handle_table.Get<SyncObject>(handle); 89 SharedPtr<ClientSession> session = g_handle_table.Get<ClientSession>(handle);
91 if (!session) { 90 if (!session) {
92 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle); 91 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle);
93 return ERR_INVALID_HANDLE; 92 return ERR_INVALID_HANDLE;
diff --git a/src/core/hle/kernel/sync_object.h b/src/core/hle/kernel/sync_object.h
deleted file mode 100644
index f2befa2ea..000000000
--- a/src/core/hle/kernel/sync_object.h
+++ /dev/null
@@ -1,35 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <boost/smart_ptr/intrusive_ptr.hpp>
8#include "core/hle/kernel/kernel.h"
9#include "core/hle/result.h"
10
11namespace Kernel {
12
13class Thread;
14
15/// Class that represents a Kernel object that svcSendSyncRequest can be called on
16class SyncObject : public Object {
17public:
18 /**
19 * Handle a sync request from the emulated application.
20 * @param thread Thread that initiated the request.
21 * @returns ResultCode from the operation.
22 */
23 virtual ResultCode SendSyncRequest(SharedPtr<Thread> thread) = 0;
24};
25
26// Specialization of DynamicObjectCast for SyncObjects
27template <>
28inline SharedPtr<SyncObject> DynamicObjectCast<SyncObject>(SharedPtr<Object> object) {
29 if (object != nullptr && object->IsSyncable()) {
30 return boost::static_pointer_cast<SyncObject>(std::move(object));
31 }
32 return nullptr;
33}
34
35} // namespace Kernel
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