diff options
| author | Liam <byteslice@airmail.cc> | 2023-12-30 20:51:23 -0500 |
|---|---|---|
| committer | Liam <byteslice@airmail.cc> | 2024-01-29 18:43:45 -0500 |
| commit | 7de6b410305fcfcd34078e62fbe0ceedb43663f9 (patch) | |
| tree | b5f3dc0d7631852a64466f3765e62e0707b8d0c8 /src/core/hle/service/am/storage.cpp | |
| parent | 8ddfecfbaea7b08e300350fd2f14fb6b2e79634b (diff) | |
service: split am into components
Diffstat (limited to 'src/core/hle/service/am/storage.cpp')
| -rw-r--r-- | src/core/hle/service/am/storage.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/core/hle/service/am/storage.cpp b/src/core/hle/service/am/storage.cpp new file mode 100644 index 000000000..9a86c867a --- /dev/null +++ b/src/core/hle/service/am/storage.cpp @@ -0,0 +1,60 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#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 { + +IStorageImpl::~IStorageImpl() = default; + +class StorageDataImpl final : public IStorageImpl { +public: + explicit StorageDataImpl(std::vector<u8>&& buffer_) : buffer{std::move(buffer_)} {} + + std::vector<u8>& GetData() override { + return buffer; + } + + const std::vector<u8>& GetData() const override { + return buffer; + } + + std::size_t GetSize() const override { + return buffer.size(); + } + +private: + std::vector<u8> buffer; +}; + +IStorage::IStorage(Core::System& system_, std::vector<u8>&& buffer) + : ServiceFramework{system_, "IStorage"}, + impl{std::make_shared<StorageDataImpl>(std::move(buffer))} { + Register(); +} + +void IStorage::Register() { + // clang-format off + static const FunctionInfo functions[] = { + {0, &IStorage::Open, "Open"}, + {1, nullptr, "OpenTransferStorage"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IStorage::~IStorage() = default; + +void IStorage::Open(HLERequestContext& ctx) { + LOG_DEBUG(Service_AM, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + + rb.Push(ResultSuccess); + rb.PushIpcInterface<IStorageAccessor>(system, *this); +} + +} // namespace Service::AM |
