diff options
author | Liam <byteslice@airmail.cc> | 2024-02-12 02:41:48 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-02-12 15:17:25 +0100 |
commit | 927fa532e5459502a10767f58a7d2f48338e7963 (patch) | |
tree | a34675ed8522f3b2ed9c93d74f06c1797f385fe8 /src/core/hle | |
parent | am: rewrite IWindowController (diff) | |
download | yuzu-927fa532e5459502a10767f58a7d2f48338e7963.tar yuzu-927fa532e5459502a10767f58a7d2f48338e7963.tar.gz yuzu-927fa532e5459502a10767f58a7d2f48338e7963.tar.bz2 yuzu-927fa532e5459502a10767f58a7d2f48338e7963.tar.lz yuzu-927fa532e5459502a10767f58a7d2f48338e7963.tar.xz yuzu-927fa532e5459502a10767f58a7d2f48338e7963.tar.zst yuzu-927fa532e5459502a10767f58a7d2f48338e7963.zip |
Diffstat (limited to 'src/core/hle')
-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 |
5 files changed, 108 insertions, 100 deletions
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 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/am/lock_accessor.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::AM { - -ILockAccessor::ILockAccessor(Core::System& system_) - : ServiceFramework{system_, "ILockAccessor"}, service_context{system_, "ILockAccessor"} { - // clang-format off - static const FunctionInfo functions[] = { - {1, &ILockAccessor::TryLock, "TryLock"}, - {2, &ILockAccessor::Unlock, "Unlock"}, - {3, &ILockAccessor::GetEvent, "GetEvent"}, - {4,&ILockAccessor::IsLocked, "IsLocked"}, - }; - // clang-format on - - RegisterHandlers(functions); - - lock_event = service_context.CreateEvent("ILockAccessor::LockEvent"); -} - -ILockAccessor::~ILockAccessor() { - service_context.CloseEvent(lock_event); -}; - -void ILockAccessor::TryLock(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto return_handle = rp.Pop<bool>(); - - LOG_WARNING(Service_AM, "(STUBBED) called, return_handle={}", return_handle); - - // TODO: When return_handle is true this function should return the lock handle - - is_locked = true; - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push<u8>(is_locked); -} - -void ILockAccessor::Unlock(HLERequestContext& ctx) { - LOG_INFO(Service_AM, "called"); - - is_locked = false; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} - -void ILockAccessor::GetEvent(HLERequestContext& ctx) { - LOG_INFO(Service_AM, "called"); - - lock_event->Signal(); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(lock_event->GetReadableEvent()); -} - -void ILockAccessor::IsLocked(HLERequestContext& ctx) { - LOG_INFO(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - rb.Push<u8>(is_locked); -} - -} // 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 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/kernel_helpers.h" -#include "core/hle/service/service.h" - -namespace Service::AM { - -class ILockAccessor final : public ServiceFramework<ILockAccessor> { -public: - explicit ILockAccessor(Core::System& system_); - ~ILockAccessor() override; - -private: - void TryLock(HLERequestContext& ctx); - void Unlock(HLERequestContext& ctx); - void GetEvent(HLERequestContext& ctx); - void IsLocked(HLERequestContext& ctx); - - bool is_locked{}; - - Kernel::KEvent* lock_event; - KernelHelpers::ServiceContext service_context; -}; - -} // 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 @@ #include "common/settings.h" #include "core/hle/service/am/am_results.h" #include "core/hle/service/am/applet.h" -#include "core/hle/service/am/lock_accessor.h" #include "core/hle/service/am/service/common_state_getter.h" +#include "core/hle/service/am/service/lock_accessor.h" #include "core/hle/service/apm/apm_interface.h" #include "core/hle/service/cmif_serialization.h" #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 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/am/service/lock_accessor.h" +#include "core/hle/service/cmif_serialization.h" + +namespace Service::AM { + +ILockAccessor::ILockAccessor(Core::System& system_) + : ServiceFramework{system_, "ILockAccessor"}, m_context{system_, "ILockAccessor"}, + m_event{m_context} { + // clang-format off + static const FunctionInfo functions[] = { + {1, D<&ILockAccessor::TryLock>, "TryLock"}, + {2, D<&ILockAccessor::Unlock>, "Unlock"}, + {3, D<&ILockAccessor::GetEvent>, "GetEvent"}, + {4, D<&ILockAccessor::IsLocked>, "IsLocked"}, + }; + // clang-format on + + RegisterHandlers(functions); + + m_event.Signal(); +} + +ILockAccessor::~ILockAccessor() = default; + +Result ILockAccessor::TryLock(Out<bool> out_is_locked, + OutCopyHandle<Kernel::KReadableEvent> out_handle, + bool return_handle) { + LOG_INFO(Service_AM, "called, return_handle={}", return_handle); + + { + std::scoped_lock lk{m_mutex}; + if (m_is_locked) { + *out_is_locked = false; + } else { + m_is_locked = true; + *out_is_locked = true; + } + } + + if (return_handle) { + *out_handle = m_event.GetHandle(); + } + + R_SUCCEED(); +} + +Result ILockAccessor::Unlock() { + LOG_INFO(Service_AM, "called"); + + { + std::scoped_lock lk{m_mutex}; + m_is_locked = false; + } + + m_event.Signal(); + R_SUCCEED(); +} + +Result ILockAccessor::GetEvent(OutCopyHandle<Kernel::KReadableEvent> out_handle) { + LOG_INFO(Service_AM, "called"); + *out_handle = m_event.GetHandle(); + R_SUCCEED(); +} + +Result ILockAccessor::IsLocked(Out<bool> out_is_locked) { + LOG_INFO(Service_AM, "called"); + std::scoped_lock lk{m_mutex}; + *out_is_locked = m_is_locked; + R_SUCCEED(); +} + +} // 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 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/os/event.h" +#include "core/hle/service/service.h" + +namespace Service::AM { + +class ILockAccessor final : public ServiceFramework<ILockAccessor> { +public: + explicit ILockAccessor(Core::System& system_); + ~ILockAccessor() override; + +private: + Result TryLock(Out<bool> out_is_locked, OutCopyHandle<Kernel::KReadableEvent> out_handle, + bool return_handle); + Result Unlock(); + Result GetEvent(OutCopyHandle<Kernel::KReadableEvent> out_handle); + Result IsLocked(Out<bool> out_is_locked); + +private: + KernelHelpers::ServiceContext m_context; + Event m_event; + std::mutex m_mutex{}; + bool m_is_locked{}; +}; + +} // namespace Service::AM |