diff options
| author | 2021-05-07 23:30:17 -0700 | |
|---|---|---|
| committer | 2021-05-07 23:30:17 -0700 | |
| commit | faa067f175cbf5e916ed75776817f0046e6731c4 (patch) | |
| tree | 8ab02a72a6e4d6578848c8da2c02af02684aeec7 /src/core/hle/ipc_helpers.h | |
| parent | Merge pull request #6287 from lioncash/ldr-copy (diff) | |
| parent | hle: kernel: KPageTable: CanContain should not be constexpr. (diff) | |
| download | yuzu-faa067f175cbf5e916ed75776817f0046e6731c4.tar.gz yuzu-faa067f175cbf5e916ed75776817f0046e6731c4.tar.xz yuzu-faa067f175cbf5e916ed75776817f0046e6731c4.zip | |
Merge pull request #6266 from bunnei/kautoobject-refactor
Kernel Rework: Migrate kernel objects to KAutoObject
Diffstat (limited to 'src/core/hle/ipc_helpers.h')
| -rw-r--r-- | src/core/hle/ipc_helpers.h | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 56cc911d1..0906b8cfb 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -13,12 +13,9 @@ | |||
| 13 | #include "common/assert.h" | 13 | #include "common/assert.h" |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "core/hle/ipc.h" | 15 | #include "core/hle/ipc.h" |
| 16 | #include "core/hle/kernel/client_port.h" | ||
| 17 | #include "core/hle/kernel/client_session.h" | ||
| 18 | #include "core/hle/kernel/hle_ipc.h" | 16 | #include "core/hle/kernel/hle_ipc.h" |
| 19 | #include "core/hle/kernel/object.h" | 17 | #include "core/hle/kernel/k_client_port.h" |
| 20 | #include "core/hle/kernel/server_session.h" | 18 | #include "core/hle/kernel/k_session.h" |
| 21 | #include "core/hle/kernel/session.h" | ||
| 22 | #include "core/hle/result.h" | 19 | #include "core/hle/result.h" |
| 23 | 20 | ||
| 24 | namespace IPC { | 21 | namespace IPC { |
| @@ -137,9 +134,11 @@ public: | |||
| 137 | if (context->Session()->IsDomain()) { | 134 | if (context->Session()->IsDomain()) { |
| 138 | context->AddDomainObject(std::move(iface)); | 135 | context->AddDomainObject(std::move(iface)); |
| 139 | } else { | 136 | } else { |
| 140 | auto [client, server] = Kernel::Session::Create(kernel, iface->GetServiceName()); | 137 | auto* session = Kernel::KSession::Create(kernel); |
| 141 | context->AddMoveObject(std::move(client)); | 138 | session->Initialize(nullptr, iface->GetServiceName()); |
| 142 | iface->ClientConnected(std::move(server)); | 139 | |
| 140 | context->AddMoveObject(&session->GetClientSession()); | ||
| 141 | iface->ClientConnected(&session->GetServerSession()); | ||
| 143 | } | 142 | } |
| 144 | } | 143 | } |
| 145 | 144 | ||
| @@ -215,10 +214,16 @@ public: | |||
| 215 | void PushRaw(const T& value); | 214 | void PushRaw(const T& value); |
| 216 | 215 | ||
| 217 | template <typename... O> | 216 | template <typename... O> |
| 218 | void PushMoveObjects(std::shared_ptr<O>... pointers); | 217 | void PushMoveObjects(O*... pointers); |
| 218 | |||
| 219 | template <typename... O> | ||
| 220 | void PushMoveObjects(O&... pointers); | ||
| 219 | 221 | ||
| 220 | template <typename... O> | 222 | template <typename... O> |
| 221 | void PushCopyObjects(std::shared_ptr<O>... pointers); | 223 | void PushCopyObjects(O*... pointers); |
| 224 | |||
| 225 | template <typename... O> | ||
| 226 | void PushCopyObjects(O&... pointers); | ||
| 222 | 227 | ||
| 223 | private: | 228 | private: |
| 224 | u32 normal_params_size{}; | 229 | u32 normal_params_size{}; |
| @@ -301,18 +306,34 @@ void ResponseBuilder::Push(const First& first_value, const Other&... other_value | |||
| 301 | } | 306 | } |
| 302 | 307 | ||
| 303 | template <typename... O> | 308 | template <typename... O> |
| 304 | inline void ResponseBuilder::PushCopyObjects(std::shared_ptr<O>... pointers) { | 309 | inline void ResponseBuilder::PushCopyObjects(O*... pointers) { |
| 305 | auto objects = {pointers...}; | 310 | auto objects = {pointers...}; |
| 306 | for (auto& object : objects) { | 311 | for (auto& object : objects) { |
| 307 | context->AddCopyObject(std::move(object)); | 312 | context->AddCopyObject(object); |
| 308 | } | 313 | } |
| 309 | } | 314 | } |
| 310 | 315 | ||
| 311 | template <typename... O> | 316 | template <typename... O> |
| 312 | inline void ResponseBuilder::PushMoveObjects(std::shared_ptr<O>... pointers) { | 317 | inline void ResponseBuilder::PushCopyObjects(O&... pointers) { |
| 318 | auto objects = {&pointers...}; | ||
| 319 | for (auto& object : objects) { | ||
| 320 | context->AddCopyObject(object); | ||
| 321 | } | ||
| 322 | } | ||
| 323 | |||
| 324 | template <typename... O> | ||
| 325 | inline void ResponseBuilder::PushMoveObjects(O*... pointers) { | ||
| 313 | auto objects = {pointers...}; | 326 | auto objects = {pointers...}; |
| 314 | for (auto& object : objects) { | 327 | for (auto& object : objects) { |
| 315 | context->AddMoveObject(std::move(object)); | 328 | context->AddMoveObject(object); |
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | template <typename... O> | ||
| 333 | inline void ResponseBuilder::PushMoveObjects(O&... pointers) { | ||
| 334 | auto objects = {&pointers...}; | ||
| 335 | for (auto& object : objects) { | ||
| 336 | context->AddMoveObject(object); | ||
| 316 | } | 337 | } |
| 317 | } | 338 | } |
| 318 | 339 | ||
| @@ -359,12 +380,6 @@ public: | |||
| 359 | template <typename T> | 380 | template <typename T> |
| 360 | T PopRaw(); | 381 | T PopRaw(); |
| 361 | 382 | ||
| 362 | template <typename T> | ||
| 363 | std::shared_ptr<T> GetMoveObject(std::size_t index); | ||
| 364 | |||
| 365 | template <typename T> | ||
| 366 | std::shared_ptr<T> GetCopyObject(std::size_t index); | ||
| 367 | |||
| 368 | template <class T> | 383 | template <class T> |
| 369 | std::shared_ptr<T> PopIpcInterface() { | 384 | std::shared_ptr<T> PopIpcInterface() { |
| 370 | ASSERT(context->Session()->IsDomain()); | 385 | ASSERT(context->Session()->IsDomain()); |
| @@ -469,14 +484,4 @@ void RequestParser::Pop(First& first_value, Other&... other_values) { | |||
| 469 | Pop(other_values...); | 484 | Pop(other_values...); |
| 470 | } | 485 | } |
| 471 | 486 | ||
| 472 | template <typename T> | ||
| 473 | std::shared_ptr<T> RequestParser::GetMoveObject(std::size_t index) { | ||
| 474 | return context->GetMoveObject<T>(index); | ||
| 475 | } | ||
| 476 | |||
| 477 | template <typename T> | ||
| 478 | std::shared_ptr<T> RequestParser::GetCopyObject(std::size_t index) { | ||
| 479 | return context->GetCopyObject<T>(index); | ||
| 480 | } | ||
| 481 | |||
| 482 | } // namespace IPC | 487 | } // namespace IPC |