diff options
author | Liam <byteslice@airmail.cc> | 2024-02-12 02:28:51 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-02-12 15:17:25 +0100 |
commit | 2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1 (patch) | |
tree | 8ac4d5e8dae2f976b7bcfb5c9fe866024b2d7ae2 /src/core/hle/service | |
parent | am: rewrite ISelfController (diff) | |
download | yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.tar yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.tar.gz yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.tar.bz2 yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.tar.lz yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.tar.xz yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.tar.zst yuzu-2e614ce08f56f4c49d8070e69ecdb44e2cb9f1c1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/am/service/storage_accessor.cpp | 68 | ||||
-rw-r--r-- | src/core/hle/service/am/service/storage_accessor.h (renamed from src/core/hle/service/am/storage_accessor.h) | 21 | ||||
-rw-r--r-- | src/core/hle/service/am/storage.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/am/storage_accessor.cpp | 90 |
4 files changed, 80 insertions, 101 deletions
diff --git a/src/core/hle/service/am/service/storage_accessor.cpp b/src/core/hle/service/am/service/storage_accessor.cpp new file mode 100644 index 000000000..84577fee4 --- /dev/null +++ b/src/core/hle/service/am/service/storage_accessor.cpp @@ -0,0 +1,68 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/kernel/k_transfer_memory.h" +#include "core/hle/service/am/library_applet_storage.h" +#include "core/hle/service/am/service/storage_accessor.h" +#include "core/hle/service/cmif_serialization.h" + +namespace Service::AM { + +IStorageAccessor::IStorageAccessor(Core::System& system_, + std::shared_ptr<LibraryAppletStorage> impl) + : ServiceFramework{system_, "IStorageAccessor"}, m_impl{std::move(impl)} { + static const FunctionInfo functions[] = { + {0, D<&IStorageAccessor::GetSize>, "GetSize"}, + {10, D<&IStorageAccessor::Write>, "Write"}, + {11, D<&IStorageAccessor::Read>, "Read"}, + }; + + RegisterHandlers(functions); +} + +IStorageAccessor::~IStorageAccessor() = default; + +Result IStorageAccessor::GetSize(Out<s64> out_size) { + LOG_DEBUG(Service_AM, "called"); + *out_size = m_impl->GetSize(); + R_SUCCEED(); +} + +Result IStorageAccessor::Write(InBuffer<BufferAttr_HipcAutoSelect> buffer, s64 offset) { + LOG_DEBUG(Service_AM, "called, offset={} size={}", offset, buffer.size()); + R_RETURN(m_impl->Write(offset, buffer.data(), buffer.size())); +} + +Result IStorageAccessor::Read(OutBuffer<BufferAttr_HipcAutoSelect> out_buffer, s64 offset) { + LOG_DEBUG(Service_AM, "called, offset={} size={}", offset, out_buffer.size()); + R_RETURN(m_impl->Read(offset, out_buffer.data(), out_buffer.size())); +} + +ITransferStorageAccessor::ITransferStorageAccessor(Core::System& system_, + std::shared_ptr<LibraryAppletStorage> impl) + : ServiceFramework{system_, "ITransferStorageAccessor"}, m_impl{std::move(impl)} { + static const FunctionInfo functions[] = { + {0, D<&ITransferStorageAccessor::GetSize>, "GetSize"}, + {1, D<&ITransferStorageAccessor::GetHandle>, "GetHandle"}, + }; + + RegisterHandlers(functions); +} + +ITransferStorageAccessor::~ITransferStorageAccessor() = default; + +Result ITransferStorageAccessor::GetSize(Out<s64> out_size) { + LOG_DEBUG(Service_AM, "called"); + *out_size = m_impl->GetSize(); + R_SUCCEED(); +} + +Result ITransferStorageAccessor::GetHandle(Out<s64> out_size, + OutCopyHandle<Kernel::KTransferMemory> out_handle) { + LOG_INFO(Service_AM, "called"); + *out_size = m_impl->GetSize(); + *out_handle = m_impl->GetHandle(); + R_SUCCEED(); +} + +} // namespace Service::AM diff --git a/src/core/hle/service/am/storage_accessor.h b/src/core/hle/service/am/service/storage_accessor.h index b9aa85a66..1a01730e0 100644 --- a/src/core/hle/service/am/storage_accessor.h +++ b/src/core/hle/service/am/service/storage_accessor.h @@ -3,35 +3,36 @@ #pragma once -#include "core/hle/service/am/storage.h" +#include "core/hle/service/am/library_applet_storage.h" +#include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" namespace Service::AM { class IStorageAccessor final : public ServiceFramework<IStorageAccessor> { public: - explicit IStorageAccessor(Core::System& system_, std::shared_ptr<LibraryAppletStorage> impl_); + explicit IStorageAccessor(Core::System& system_, std::shared_ptr<LibraryAppletStorage> impl); ~IStorageAccessor() override; private: - void GetSize(HLERequestContext& ctx); - void Write(HLERequestContext& ctx); - void Read(HLERequestContext& ctx); + Result GetSize(Out<s64> out_size); + Result Write(InBuffer<BufferAttr_HipcAutoSelect> buffer, s64 offset); + Result Read(OutBuffer<BufferAttr_HipcAutoSelect> out_buffer, s64 offset); - const std::shared_ptr<LibraryAppletStorage> impl; + const std::shared_ptr<LibraryAppletStorage> m_impl; }; class ITransferStorageAccessor final : public ServiceFramework<ITransferStorageAccessor> { public: explicit ITransferStorageAccessor(Core::System& system_, - std::shared_ptr<LibraryAppletStorage> impl_); + std::shared_ptr<LibraryAppletStorage> impl); ~ITransferStorageAccessor() override; private: - void GetSize(HLERequestContext& ctx); - void GetHandle(HLERequestContext& ctx); + Result GetSize(Out<s64> out_size); + Result GetHandle(Out<s64> out_size, OutCopyHandle<Kernel::KTransferMemory> out_handle); - const std::shared_ptr<LibraryAppletStorage> impl; + const std::shared_ptr<LibraryAppletStorage> m_impl; }; } // namespace Service::AM diff --git a/src/core/hle/service/am/storage.cpp b/src/core/hle/service/am/storage.cpp index 4e82afd1c..12d95eebd 100644 --- a/src/core/hle/service/am/storage.cpp +++ b/src/core/hle/service/am/storage.cpp @@ -3,8 +3,8 @@ #include "core/hle/service/am/am_results.h" #include "core/hle/service/am/library_applet_storage.h" +#include "core/hle/service/am/service/storage_accessor.h" #include "core/hle/service/am/storage.h" -#include "core/hle/service/am/storage_accessor.h" #include "core/hle/service/ipc_helpers.h" namespace Service::AM { diff --git a/src/core/hle/service/am/storage_accessor.cpp b/src/core/hle/service/am/storage_accessor.cpp deleted file mode 100644 index a1184b065..000000000 --- a/src/core/hle/service/am/storage_accessor.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/kernel/k_transfer_memory.h" -#include "core/hle/service/am/am_results.h" -#include "core/hle/service/am/library_applet_storage.h" -#include "core/hle/service/am/storage_accessor.h" -#include "core/hle/service/ipc_helpers.h" - -namespace Service::AM { - -IStorageAccessor::IStorageAccessor(Core::System& system_, - std::shared_ptr<LibraryAppletStorage> impl_) - : ServiceFramework{system_, "IStorageAccessor"}, impl{std::move(impl_)} { - static const FunctionInfo functions[] = { - {0, &IStorageAccessor::GetSize, "GetSize"}, - {10, &IStorageAccessor::Write, "Write"}, - {11, &IStorageAccessor::Read, "Read"}, - }; - - RegisterHandlers(functions); -} - -IStorageAccessor::~IStorageAccessor() = default; - -void IStorageAccessor::GetSize(HLERequestContext& ctx) { - LOG_DEBUG(Service_AM, "called"); - - IPC::ResponseBuilder rb{ctx, 4}; - - rb.Push(ResultSuccess); - rb.Push(impl->GetSize()); -} - -void IStorageAccessor::Write(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - const s64 offset{rp.Pop<s64>()}; - const auto data{ctx.ReadBuffer()}; - LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, data.size()); - - const auto res{impl->Write(offset, data.data(), data.size())}; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(res); -} - -void IStorageAccessor::Read(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - const s64 offset{rp.Pop<s64>()}; - std::vector<u8> data(ctx.GetWriteBufferSize()); - - LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, data.size()); - - const auto res{impl->Read(offset, data.data(), data.size())}; - - ctx.WriteBuffer(data); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(res); -} - -ITransferStorageAccessor::ITransferStorageAccessor(Core::System& system_, - std::shared_ptr<LibraryAppletStorage> impl_) - : ServiceFramework{system_, "ITransferStorageAccessor"}, impl{std::move(impl_)} { - static const FunctionInfo functions[] = { - {0, &ITransferStorageAccessor::GetSize, "GetSize"}, - {1, &ITransferStorageAccessor::GetHandle, "GetHandle"}, - }; - - RegisterHandlers(functions); -} - -ITransferStorageAccessor::~ITransferStorageAccessor() = default; - -void ITransferStorageAccessor::GetSize(HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(ResultSuccess); - rb.Push(impl->GetSize()); -} - -void ITransferStorageAccessor::GetHandle(HLERequestContext& ctx) { - IPC::ResponseBuilder rb{ctx, 4, 1}; - rb.Push(ResultSuccess); - rb.Push(impl->GetSize()); - rb.PushCopyObjects(impl->GetHandle()); -} - -} // namespace Service::AM |