Serialize AM services

This commit is contained in:
Hamish Milne 2019-12-24 23:53:51 +00:00 committed by zhupengfei
parent 89e4e49a63
commit e707685c2a
14 changed files with 71 additions and 14 deletions

View file

@ -27,6 +27,7 @@
#include "core/file_sys/file_backend.h"
#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
#include "core/core.h"
namespace Service::FS {
@ -90,7 +91,7 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
if (backend.Failed())
return std::make_tuple(backend.Code(), open_timeout_ns);
auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path));
auto file = std::shared_ptr<File>(new File(system.Kernel(), std::move(backend).Unwrap(), path));
return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
}

View file

@ -15,9 +15,9 @@
namespace Service::FS {
File::File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
File::File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend,
const FileSys::Path& path)
: ServiceFramework("", 1), path(path), backend(std::move(backend)), system(system) {
: ServiceFramework("", 1), path(path), backend(std::move(backend)), kernel(kernel) {
static const FunctionInfo functions[] = {
{0x08010100, &File::OpenSubFile, "OpenSubFile"},
{0x080200C2, &File::Read, "Read"},
@ -197,7 +197,7 @@ void File::OpenLinkFile(Kernel::HLERequestContext& ctx) {
using Kernel::ServerSession;
IPC::RequestParser rp(ctx, 0x080C, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
auto [server, client] = kernel.CreateSessionPair(GetName());
ClientConnected(server);
FileSessionSlot* slot = GetSessionData(server);
@ -243,7 +243,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
using Kernel::ClientSession;
using Kernel::ServerSession;
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
auto [server, client] = kernel.CreateSessionPair(GetName());
ClientConnected(server);
FileSessionSlot* slot = GetSessionData(server);
@ -257,7 +257,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
}
std::shared_ptr<Kernel::ClientSession> File::Connect() {
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
auto [server, client] = kernel.CreateSessionPair(GetName());
ClientConnected(server);
FileSessionSlot* slot = GetSessionData(server);

View file

@ -25,7 +25,7 @@ struct FileSessionSlot : public Kernel::SessionRequestHandler::SessionDataBase {
// Consider splitting ServiceFramework interface.
class File final : public ServiceFramework<File, FileSessionSlot> {
public:
File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend,
const FileSys::Path& path);
~File() = default;
@ -59,7 +59,7 @@ private:
void OpenLinkFile(Kernel::HLERequestContext& ctx);
void OpenSubFile(Kernel::HLERequestContext& ctx);
Core::System& system;
Kernel::KernelSystem& kernel;
};
} // namespace Service::FS