Kernel: pass ref to session pair
This commit is contained in:
parent
1213a298df
commit
13c26b4371
18 changed files with 71 additions and 48 deletions
|
@ -1026,8 +1026,8 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
|
|||
// Create our CIAFile handle for the app to write to, and while the app writes
|
||||
// Citra will store contents out to sdmc/nand
|
||||
const FileSys::Path cia_path = {};
|
||||
auto file =
|
||||
std::make_shared<Service::FS::File>(std::make_unique<CIAFile>(media_type), cia_path);
|
||||
auto file = std::make_shared<Service::FS::File>(
|
||||
am->system, std::make_unique<CIAFile>(media_type), cia_path);
|
||||
|
||||
am->cia_installing = true;
|
||||
|
||||
|
@ -1053,8 +1053,8 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
|
|||
// Create our CIAFile handle for the app to write to, and while the app writes Citra will store
|
||||
// contents out to sdmc/nand
|
||||
const FileSys::Path cia_path = {};
|
||||
auto file = std::make_shared<Service::FS::File>(std::make_unique<CIAFile>(FS::MediaType::NAND),
|
||||
cia_path);
|
||||
auto file = std::make_shared<Service::FS::File>(
|
||||
am->system, std::make_unique<CIAFile>(FS::MediaType::NAND), cia_path);
|
||||
|
||||
am->cia_installing = true;
|
||||
|
||||
|
@ -1455,7 +1455,7 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
|
|||
rb.PushMappedBuffer(output_buffer);
|
||||
}
|
||||
|
||||
Module::Module(Core::System& system) {
|
||||
Module::Module(Core::System& system) : system(system) {
|
||||
ScanForAllTitles();
|
||||
system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex");
|
||||
}
|
||||
|
|
|
@ -573,6 +573,7 @@ private:
|
|||
*/
|
||||
void ScanForAllTitles();
|
||||
|
||||
Core::System& system;
|
||||
bool cia_installing = false;
|
||||
std::array<std::vector<u64_le>, 3> am_title_list;
|
||||
Kernel::SharedPtr<Kernel::Mutex> system_updater_mutex;
|
||||
|
|
|
@ -87,7 +87,7 @@ ResultVal<std::shared_ptr<File>> ArchiveManager::OpenFileFromArchive(ArchiveHand
|
|||
if (backend.Failed())
|
||||
return backend.Code();
|
||||
|
||||
auto file = std::shared_ptr<File>(new File(std::move(backend).Unwrap(), path));
|
||||
auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path));
|
||||
return MakeResult<std::shared_ptr<File>>(std::move(file));
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ void ArchiveManager::RegisterSelfNCCH(Loader::AppLoader& app_loader) {
|
|||
factory->Register(app_loader);
|
||||
}
|
||||
|
||||
ArchiveManager::ArchiveManager() {
|
||||
ArchiveManager::ArchiveManager(Core::System& system) : system(system) {
|
||||
RegisterArchiveTypes();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ namespace Loader {
|
|||
class AppLoader;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::FS {
|
||||
|
||||
/// Supported archive types
|
||||
|
@ -50,7 +54,8 @@ using FileSys::ArchiveFactory;
|
|||
|
||||
class ArchiveManager {
|
||||
public:
|
||||
ArchiveManager();
|
||||
explicit ArchiveManager(Core::System& system);
|
||||
|
||||
/**
|
||||
* Opens an archive
|
||||
* @param id_code IdCode of the archive to open
|
||||
|
@ -224,6 +229,8 @@ public:
|
|||
void RegisterSelfNCCH(Loader::AppLoader& app_loader);
|
||||
|
||||
private:
|
||||
Core::System& system;
|
||||
|
||||
/**
|
||||
* Registers an Archive type, instances of which can later be opened using its IdCode.
|
||||
* @param factory File system backend interface to the archive
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/errors.h"
|
||||
#include "core/file_sys/file_backend.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
|
@ -14,8 +15,9 @@
|
|||
|
||||
namespace Service::FS {
|
||||
|
||||
File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path)
|
||||
: ServiceFramework("", 1), path(path), backend(std::move(backend)) {
|
||||
File::File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
|
||||
const FileSys::Path& path)
|
||||
: ServiceFramework("", 1), path(path), backend(std::move(backend)), system(system) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x08010100, &File::OpenSubFile, "OpenSubFile"},
|
||||
{0x080200C2, &File::Read, "Read"},
|
||||
|
@ -195,7 +197,7 @@ void File::OpenLinkFile(Kernel::HLERequestContext& ctx) {
|
|||
using Kernel::SharedPtr;
|
||||
IPC::RequestParser rp(ctx, 0x080C, 0, 0);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
auto sessions = ServerSession::CreateSessionPair(GetName());
|
||||
auto sessions = system.Kernel().CreateSessionPair(GetName());
|
||||
auto server = std::get<SharedPtr<ServerSession>>(sessions);
|
||||
ClientConnected(server);
|
||||
|
||||
|
@ -243,7 +245,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
|
|||
using Kernel::ClientSession;
|
||||
using Kernel::ServerSession;
|
||||
using Kernel::SharedPtr;
|
||||
auto sessions = ServerSession::CreateSessionPair(GetName());
|
||||
auto sessions = system.Kernel().CreateSessionPair(GetName());
|
||||
auto server = std::get<SharedPtr<ServerSession>>(sessions);
|
||||
ClientConnected(server);
|
||||
|
||||
|
@ -258,7 +260,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
|
|||
}
|
||||
|
||||
Kernel::SharedPtr<Kernel::ClientSession> File::Connect() {
|
||||
auto sessions = Kernel::ServerSession::CreateSessionPair(GetName());
|
||||
auto sessions = system.Kernel().CreateSessionPair(GetName());
|
||||
auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions);
|
||||
ClientConnected(server);
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::FS {
|
||||
|
||||
struct FileSessionSlot : public Kernel::SessionRequestHandler::SessionDataBase {
|
||||
|
@ -21,7 +25,8 @@ struct FileSessionSlot : public Kernel::SessionRequestHandler::SessionDataBase {
|
|||
// Consider splitting ServiceFramework interface.
|
||||
class File final : public ServiceFramework<File, FileSessionSlot> {
|
||||
public:
|
||||
File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path);
|
||||
File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
|
||||
const FileSys::Path& path);
|
||||
~File() = default;
|
||||
|
||||
std::string GetName() const {
|
||||
|
@ -53,6 +58,8 @@ private:
|
|||
void GetPriority(Kernel::HLERequestContext& ctx);
|
||||
void OpenLinkFile(Kernel::HLERequestContext& ctx);
|
||||
void OpenSubFile(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace Service::FS
|
||||
|
|
|
@ -286,7 +286,7 @@ void FS_USER::OpenDirectory(Kernel::HLERequestContext& ctx) {
|
|||
rb.Push(dir_res.Code());
|
||||
if (dir_res.Succeeded()) {
|
||||
std::shared_ptr<Directory> directory = *dir_res;
|
||||
auto sessions = ServerSession::CreateSessionPair(directory->GetName());
|
||||
auto sessions = system.Kernel().CreateSessionPair(directory->GetName());
|
||||
directory->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));
|
||||
rb.PushMoveObjects(std::get<SharedPtr<ClientSession>>(sessions));
|
||||
} else {
|
||||
|
@ -741,7 +741,8 @@ void FS_USER::GetSaveDataSecureValue(Kernel::HLERequestContext& ctx) {
|
|||
rb.Push<u64>(0); // the secure value
|
||||
}
|
||||
|
||||
FS_USER::FS_USER(ArchiveManager& archives) : ServiceFramework("fs:USER", 30), archives(archives) {
|
||||
FS_USER::FS_USER(Core::System& system)
|
||||
: ServiceFramework("fs:USER", 30), system(system), archives(system.ArchiveManager()) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0x000100C6, nullptr, "Dummy1"},
|
||||
{0x040100C4, nullptr, "Control"},
|
||||
|
@ -860,6 +861,6 @@ FS_USER::FS_USER(ArchiveManager& archives) : ServiceFramework("fs:USER", 30), ar
|
|||
|
||||
void InstallInterfaces(Core::System& system) {
|
||||
auto& service_manager = system.ServiceManager();
|
||||
std::make_shared<FS_USER>(system.ArchiveManager())->InstallAsService(service_manager);
|
||||
std::make_shared<FS_USER>(system)->InstallAsService(service_manager);
|
||||
}
|
||||
} // namespace Service::FS
|
||||
|
|
|
@ -17,7 +17,7 @@ class ArchiveManager;
|
|||
|
||||
class FS_USER final : public ServiceFramework<FS_USER> {
|
||||
public:
|
||||
explicit FS_USER(ArchiveManager& archives);
|
||||
explicit FS_USER(Core::System& system);
|
||||
|
||||
private:
|
||||
void Initialize(Kernel::HLERequestContext& ctx);
|
||||
|
@ -534,6 +534,7 @@ private:
|
|||
|
||||
u32 priority = -1; ///< For SetPriority and GetPriority service functions
|
||||
|
||||
Core::System& system;
|
||||
ArchiveManager& archives;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue