diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/core/hle/service/am/lock_accessor.cpp | 71 | ||||
| -rw-r--r-- | src/core/hle/service/am/lock_accessor.h | 28 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/common_state_getter.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/lock_accessor.cpp | 75 | ||||
| -rw-r--r-- | src/core/hle/service/am/service/lock_accessor.h | 32 |
6 files changed, 110 insertions, 102 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f8e093be7..073e42e00 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -431,8 +431,6 @@ add_library(core STATIC | |||
| 431 | hle/service/am/idle.h | 431 | hle/service/am/idle.h |
| 432 | hle/service/am/library_applet_storage.cpp | 432 | hle/service/am/library_applet_storage.cpp |
| 433 | hle/service/am/library_applet_storage.h | 433 | hle/service/am/library_applet_storage.h |
| 434 | hle/service/am/lock_accessor.cpp | ||
| 435 | hle/service/am/lock_accessor.h | ||
| 436 | hle/service/am/managed_layer_holder.cpp | 434 | hle/service/am/managed_layer_holder.cpp |
| 437 | hle/service/am/managed_layer_holder.h | 435 | hle/service/am/managed_layer_holder.h |
| 438 | hle/service/am/omm.cpp | 436 | hle/service/am/omm.cpp |
| @@ -471,6 +469,8 @@ add_library(core STATIC | |||
| 471 | hle/service/am/service/library_applet_proxy.h | 469 | hle/service/am/service/library_applet_proxy.h |
| 472 | hle/service/am/service/library_applet_self_accessor.cpp | 470 | hle/service/am/service/library_applet_self_accessor.cpp |
| 473 | hle/service/am/service/library_applet_self_accessor.h | 471 | hle/service/am/service/library_applet_self_accessor.h |
| 472 | hle/service/am/service/lock_accessor.cpp | ||
| 473 | hle/service/am/service/lock_accessor.h | ||
| 474 | hle/service/am/service/process_winding_controller.cpp | 474 | hle/service/am/service/process_winding_controller.cpp |
| 475 | hle/service/am/service/process_winding_controller.h | 475 | hle/service/am/service/process_winding_controller.h |
| 476 | hle/service/am/service/self_controller.cpp | 476 | hle/service/am/service/self_controller.cpp |
diff --git a/src/core/hle/service/am/lock_accessor.cpp b/src/core/hle/service/am/lock_accessor.cpp deleted file mode 100644 index d0bd8d95e..000000000 --- a/src/core/hle/service/am/lock_accessor.cpp +++ /dev/null | |||
| @@ -1,71 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/am/lock_accessor.h" | ||
| 5 | #include "core/hle/service/ipc_helpers.h" | ||
| 6 | |||
| 7 | namespace Service::AM { | ||
| 8 | |||
| 9 | ILockAccessor::ILockAccessor(Core::System& system_) | ||
| 10 | : ServiceFramework{system_, "ILockAccessor"}, service_context{system_, "ILockAccessor"} { | ||
| 11 | // clang-format off | ||
| 12 | static const FunctionInfo functions[] = { | ||
| 13 | {1, &ILockAccessor::TryLock, "TryLock"}, | ||
| 14 | {2, &ILockAccessor::Unlock, "Unlock"}, | ||
| 15 | {3, &ILockAccessor::GetEvent, "GetEvent"}, | ||
| 16 | {4,&ILockAccessor::IsLocked, "IsLocked"}, | ||
| 17 | }; | ||
| 18 | // clang-format on | ||
| 19 | |||
| 20 | RegisterHandlers(functions); | ||
| 21 | |||
| 22 | lock_event = service_context.CreateEvent("ILockAccessor::LockEvent"); | ||
| 23 | } | ||
| 24 | |||
| 25 | ILockAccessor::~ILockAccessor() { | ||
| 26 | service_context.CloseEvent(lock_event); | ||
| 27 | }; | ||
| 28 | |||
| 29 | void ILockAccessor::TryLock(HLERequestContext& ctx) { | ||
| 30 | IPC::RequestParser rp{ctx}; | ||
| 31 | const auto return_handle = rp.Pop<bool>(); | ||
| 32 | |||
| 33 | LOG_WARNING(Service_AM, "(STUBBED) called, return_handle={}", return_handle); | ||
| 34 | |||
| 35 | // TODO: When return_handle is true this function should return the lock handle | ||
| 36 | |||
| 37 | is_locked = true; | ||
| 38 | |||
| 39 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 40 | rb.Push(ResultSuccess); | ||
| 41 | rb.Push<u8>(is_locked); | ||
| 42 | } | ||
| 43 | |||
| 44 | void ILockAccessor::Unlock(HLERequestContext& ctx) { | ||
| 45 | LOG_INFO(Service_AM, "called"); | ||
| 46 | |||
| 47 | is_locked = false; | ||
| 48 | |||
| 49 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 50 | rb.Push(ResultSuccess); | ||
| 51 | } | ||
| 52 | |||
| 53 | void ILockAccessor::GetEvent(HLERequestContext& ctx) { | ||
| 54 | LOG_INFO(Service_AM, "called"); | ||
| 55 | |||
| 56 | lock_event->Signal(); | ||
| 57 | |||
| 58 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 59 | rb.Push(ResultSuccess); | ||
| 60 | rb.PushCopyObjects(lock_event->GetReadableEvent()); | ||
| 61 | } | ||
| 62 | |||
| 63 | void ILockAccessor::IsLocked(HLERequestContext& ctx) { | ||
| 64 | LOG_INFO(Service_AM, "called"); | ||
| 65 | |||
| 66 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 67 | rb.Push(ResultSuccess); | ||
| 68 | rb.Push<u8>(is_locked); | ||
| 69 | } | ||
| 70 | |||
| 71 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/lock_accessor.h b/src/core/hle/service/am/lock_accessor.h deleted file mode 100644 index 626f60e07..000000000 --- a/src/core/hle/service/am/lock_accessor.h +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/kernel_helpers.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service::AM { | ||
| 10 | |||
| 11 | class ILockAccessor final : public ServiceFramework<ILockAccessor> { | ||
| 12 | public: | ||
| 13 | explicit ILockAccessor(Core::System& system_); | ||
| 14 | ~ILockAccessor() override; | ||
| 15 | |||
| 16 | private: | ||
| 17 | void TryLock(HLERequestContext& ctx); | ||
| 18 | void Unlock(HLERequestContext& ctx); | ||
| 19 | void GetEvent(HLERequestContext& ctx); | ||
| 20 | void IsLocked(HLERequestContext& ctx); | ||
| 21 | |||
| 22 | bool is_locked{}; | ||
| 23 | |||
| 24 | Kernel::KEvent* lock_event; | ||
| 25 | KernelHelpers::ServiceContext service_context; | ||
| 26 | }; | ||
| 27 | |||
| 28 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/service/common_state_getter.cpp b/src/core/hle/service/am/service/common_state_getter.cpp index ac05b457b..12d7e8cb1 100644 --- a/src/core/hle/service/am/service/common_state_getter.cpp +++ b/src/core/hle/service/am/service/common_state_getter.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 5 | #include "core/hle/service/am/am_results.h" | 5 | #include "core/hle/service/am/am_results.h" |
| 6 | #include "core/hle/service/am/applet.h" | 6 | #include "core/hle/service/am/applet.h" |
| 7 | #include "core/hle/service/am/lock_accessor.h" | ||
| 8 | #include "core/hle/service/am/service/common_state_getter.h" | 7 | #include "core/hle/service/am/service/common_state_getter.h" |
| 8 | #include "core/hle/service/am/service/lock_accessor.h" | ||
| 9 | #include "core/hle/service/apm/apm_interface.h" | 9 | #include "core/hle/service/apm/apm_interface.h" |
| 10 | #include "core/hle/service/cmif_serialization.h" | 10 | #include "core/hle/service/cmif_serialization.h" |
| 11 | #include "core/hle/service/pm/pm.h" | 11 | #include "core/hle/service/pm/pm.h" |
diff --git a/src/core/hle/service/am/service/lock_accessor.cpp b/src/core/hle/service/am/service/lock_accessor.cpp new file mode 100644 index 000000000..8e556fdd6 --- /dev/null +++ b/src/core/hle/service/am/service/lock_accessor.cpp | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/am/service/lock_accessor.h" | ||
| 5 | #include "core/hle/service/cmif_serialization.h" | ||
| 6 | |||
| 7 | namespace Service::AM { | ||
| 8 | |||
| 9 | ILockAccessor::ILockAccessor(Core::System& system_) | ||
| 10 | : ServiceFramework{system_, "ILockAccessor"}, m_context{system_, "ILockAccessor"}, | ||
| 11 | m_event{m_context} { | ||
| 12 | // clang-format off | ||
| 13 | static const FunctionInfo functions[] = { | ||
| 14 | {1, D<&ILockAccessor::TryLock>, "TryLock"}, | ||
| 15 | {2, D<&ILockAccessor::Unlock>, "Unlock"}, | ||
| 16 | {3, D<&ILockAccessor::GetEvent>, "GetEvent"}, | ||
| 17 | {4, D<&ILockAccessor::IsLocked>, "IsLocked"}, | ||
| 18 | }; | ||
| 19 | // clang-format on | ||
| 20 | |||
| 21 | RegisterHandlers(functions); | ||
| 22 | |||
| 23 | m_event.Signal(); | ||
| 24 | } | ||
| 25 | |||
| 26 | ILockAccessor::~ILockAccessor() = default; | ||
| 27 | |||
| 28 | Result ILockAccessor::TryLock(Out<bool> out_is_locked, | ||
| 29 | OutCopyHandle<Kernel::KReadableEvent> out_handle, | ||
| 30 | bool return_handle) { | ||
| 31 | LOG_INFO(Service_AM, "called, return_handle={}", return_handle); | ||
| 32 | |||
| 33 | { | ||
| 34 | std::scoped_lock lk{m_mutex}; | ||
| 35 | if (m_is_locked) { | ||
| 36 | *out_is_locked = false; | ||
| 37 | } else { | ||
| 38 | m_is_locked = true; | ||
| 39 | *out_is_locked = true; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | if (return_handle) { | ||
| 44 | *out_handle = m_event.GetHandle(); | ||
| 45 | } | ||
| 46 | |||
| 47 | R_SUCCEED(); | ||
| 48 | } | ||
| 49 | |||
| 50 | Result ILockAccessor::Unlock() { | ||
| 51 | LOG_INFO(Service_AM, "called"); | ||
| 52 | |||
| 53 | { | ||
| 54 | std::scoped_lock lk{m_mutex}; | ||
| 55 | m_is_locked = false; | ||
| 56 | } | ||
| 57 | |||
| 58 | m_event.Signal(); | ||
| 59 | R_SUCCEED(); | ||
| 60 | } | ||
| 61 | |||
| 62 | Result ILockAccessor::GetEvent(OutCopyHandle<Kernel::KReadableEvent> out_handle) { | ||
| 63 | LOG_INFO(Service_AM, "called"); | ||
| 64 | *out_handle = m_event.GetHandle(); | ||
| 65 | R_SUCCEED(); | ||
| 66 | } | ||
| 67 | |||
| 68 | Result ILockAccessor::IsLocked(Out<bool> out_is_locked) { | ||
| 69 | LOG_INFO(Service_AM, "called"); | ||
| 70 | std::scoped_lock lk{m_mutex}; | ||
| 71 | *out_is_locked = m_is_locked; | ||
| 72 | R_SUCCEED(); | ||
| 73 | } | ||
| 74 | |||
| 75 | } // namespace Service::AM | ||
diff --git a/src/core/hle/service/am/service/lock_accessor.h b/src/core/hle/service/am/service/lock_accessor.h new file mode 100644 index 000000000..9bfb5c050 --- /dev/null +++ b/src/core/hle/service/am/service/lock_accessor.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/kernel_helpers.h" | ||
| 8 | #include "core/hle/service/os/event.h" | ||
| 9 | #include "core/hle/service/service.h" | ||
| 10 | |||
| 11 | namespace Service::AM { | ||
| 12 | |||
| 13 | class ILockAccessor final : public ServiceFramework<ILockAccessor> { | ||
| 14 | public: | ||
| 15 | explicit ILockAccessor(Core::System& system_); | ||
| 16 | ~ILockAccessor() override; | ||
| 17 | |||
| 18 | private: | ||
| 19 | Result TryLock(Out<bool> out_is_locked, OutCopyHandle<Kernel::KReadableEvent> out_handle, | ||
| 20 | bool return_handle); | ||
| 21 | Result Unlock(); | ||
| 22 | Result GetEvent(OutCopyHandle<Kernel::KReadableEvent> out_handle); | ||
| 23 | Result IsLocked(Out<bool> out_is_locked); | ||
| 24 | |||
| 25 | private: | ||
| 26 | KernelHelpers::ServiceContext m_context; | ||
| 27 | Event m_event; | ||
| 28 | std::mutex m_mutex{}; | ||
| 29 | bool m_is_locked{}; | ||
| 30 | }; | ||
| 31 | |||
| 32 | } // namespace Service::AM | ||