VERY experimental Nintendo Switch 2 emulator
C++
services: Pass FileSystemController as reference to services that need it
Zach Hilmane443d76a29f1
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cppindex eae052ce0d..7f8514b0de 100644--- a/src/core/hle/service/am/am.cpp+++ b/src/core/hle/service/am/am.cpp@@ -1268,7 +1268,7 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {"new_journal={:016X}",static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);- fsc.WriteSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id,+ fsc.WriteSaveDataSize(type, system.CurrentProcess()->GetTitleID(), user_id,{new_normal_size, new_journal_size});IPC::ResponseBuilder rb{ctx, 4};@@ -1288,7 +1288,8 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type),user_id[1], user_id[0]);- const auto size = fsc.ReadSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id);+ const auto size = system.FileSystemController().ReadSaveDataSize(+ type, system.CurrentProcess()->GetTitleID(), user_id);IPC::ResponseBuilder rb{ctx, 6};rb.Push(RESULT_SUCCESS);diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cppindex e454b77d80..d04476ae0f 100644--- a/src/core/hle/service/am/applet_ae.cpp+++ b/src/core/hle/service/am/applet_ae.cpp@@ -106,7 +106,7 @@ private:IPC::ResponseBuilder rb{ctx, 2, 0, 1};rb.Push(RESULT_SUCCESS);- rb.PushIpcInterface<IApplicationFunctions>(system);+ rb.PushIpcInterface<IApplicationFunctions>(system.FileSystemController());}std::shared_ptr<NVFlinger::NVFlinger> nvflinger;diff --git a/src/core/hle/service/am/applet_ae.h b/src/core/hle/service/am/applet_ae.hindex 9e006cd9d8..0e0d108586 100644--- a/src/core/hle/service/am/applet_ae.h+++ b/src/core/hle/service/am/applet_ae.h@@ -9,6 +9,10 @@#include "core/hle/service/service.h"namespace Service {+namespace FileSystem {+class FileSystemController;+}+namespace NVFlinger {class NVFlinger;}diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cppindex a2ffaa4408..2ee21620b5 100644--- a/src/core/hle/service/am/applet_oe.cpp+++ b/src/core/hle/service/am/applet_oe.cpp@@ -95,7 +95,7 @@ private:IPC::ResponseBuilder rb{ctx, 2, 0, 1};rb.Push(RESULT_SUCCESS);- rb.PushIpcInterface<IApplicationFunctions>(system);+ rb.PushIpcInterface<IApplicationFunctions>(system.FileSystemController());}std::shared_ptr<NVFlinger::NVFlinger> nvflinger;diff --git a/src/core/hle/service/am/applet_oe.h b/src/core/hle/service/am/applet_oe.hindex 22c05419d7..99a65e7b50 100644--- a/src/core/hle/service/am/applet_oe.h+++ b/src/core/hle/service/am/applet_oe.h@@ -9,6 +9,10 @@#include "core/hle/service/service.h"namespace Service {+namespace FileSystem {+class FileSystemController;+}+namespace NVFlinger {class NVFlinger;}diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cppindex ce88a29415..13121c4f1c 100644--- a/src/core/hle/service/ns/ns.cpp+++ b/src/core/hle/service/ns/ns.cpp@@ -617,7 +617,7 @@ public:}};-void InstallInterfaces(SM::ServiceManager& service_manager) {+void InstallInterfaces(SM::ServiceManager& service_manager, FileSystem::FileSystemController& fsc) {std::make_shared<NS>("ns:am2")->InstallAsService(service_manager);std::make_shared<NS>("ns:ec")->InstallAsService(service_manager);std::make_shared<NS>("ns:rid")->InstallAsService(service_manager);@@ -628,7 +628,7 @@ void InstallInterfaces(SM::ServiceManager& service_manager) {std::make_shared<NS_SU>()->InstallAsService(service_manager);std::make_shared<NS_VM>()->InstallAsService(service_manager);- std::make_shared<PL_U>()->InstallAsService(service_manager);+ std::make_shared<PL_U>(fsc)->InstallAsService(service_manager);}} // namespace Service::NSdiff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.hindex 0e8256cb4a..d067e7a9a3 100644--- a/src/core/hle/service/ns/ns.h+++ b/src/core/hle/service/ns/ns.h@@ -6,7 +6,13 @@#include "core/hle/service/service.h"-namespace Service::NS {+namespace Service {++namespace FileSystem {+class FileSystemController;+} // namespace FileSystem++namespace NS {class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> {public:@@ -91,6 +97,8 @@ private:};/// Registers all NS services with the specified service manager.-void InstallInterfaces(SM::ServiceManager& service_manager);+void InstallInterfaces(SM::ServiceManager& service_manager, FileSystem::FileSystemController& fsc);++} // namespace NS-} // namespace Service::NS+} // namespace Servicediff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cppindex 2a522136d0..9d49f36e8a 100644--- a/src/core/hle/service/ns/pl_u.cpp+++ b/src/core/hle/service/ns/pl_u.cpp@@ -150,7 +150,8 @@ struct PL_U::Impl {std::vector<FontRegion> shared_font_regions;};-PL_U::PL_U() : ServiceFramework("pl:u"), impl{std::make_unique<Impl>()} {+PL_U::PL_U(FileSystem::FileSystemController& fsc)+ : ServiceFramework("pl:u"), impl{std::make_unique<Impl>()} {static const FunctionInfo functions[] = {{0, &PL_U::RequestLoad, "RequestLoad"},{1, &PL_U::GetLoadState, "GetLoadState"},@@ -161,7 +162,7 @@ PL_U::PL_U() : ServiceFramework("pl:u"), impl{std::make_unique<Impl>()} {};RegisterHandlers(functions);// Attempt to load shared font data from disk- const auto* nand = FileSystem::GetSystemNANDContents();+ const auto* nand = fsc.GetSystemNANDContents();std::size_t offset = 0;// Rebuild shared fonts from data ncasif (nand->HasEntry(static_cast<u64>(FontArchives::Standard),diff --git a/src/core/hle/service/ns/pl_u.h b/src/core/hle/service/ns/pl_u.hindex 253f26a2ac..35ca424d29 100644--- a/src/core/hle/service/ns/pl_u.h+++ b/src/core/hle/service/ns/pl_u.h@@ -7,11 +7,17 @@#include <memory>#include "core/hle/service/service.h"-namespace Service::NS {+namespace Service {++namespace FileSystem {+class FileSystemController;+} // namespace FileSystem++namespace NS {class PL_U final : public ServiceFramework<PL_U> {public:- PL_U();+ PL_U(FileSystem::FileSystemController& fsc);~PL_U() override;private:@@ -26,4 +32,6 @@ private:std::unique_ptr<Impl> impl;};-} // namespace Service::NS+} // namespace NS++} // namespace Servicediff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cppindex 3a0f8c3f68..8bf033c885 100644--- a/src/core/hle/service/service.cpp+++ b/src/core/hle/service/service.cpp@@ -199,6 +199,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {// NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it// here and pass it into the respective InstallInterfaces functions.auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system.CoreTiming());+ fsc.CreateFactories(*system.GetFilesystem(), false);SM::ServiceManager::InstallInterfaces(sm);@@ -229,13 +230,13 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {Migration::InstallInterfaces(*sm);Mii::InstallInterfaces(*sm);MM::InstallInterfaces(*sm);- NCM::InstallInterfaces(*sm);+ NCM::InstallInterfaces(*sm, fsc);NFC::InstallInterfaces(*sm);NFP::InstallInterfaces(*sm);NIFM::InstallInterfaces(*sm);NIM::InstallInterfaces(*sm);NPNS::InstallInterfaces(*sm);- NS::InstallInterfaces(*sm);+ NS::InstallInterfaces(*sm, fsc);Nvidia::InstallInterfaces(*sm, *nv_flinger, system);PCIe::InstallInterfaces(*sm);PCTL::InstallInterfaces(*sm);diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.hindex c6c4bdae5a..aef9648615 100644--- a/src/core/hle/service/service.h+++ b/src/core/hle/service/service.h@@ -18,10 +18,6 @@ namespace Core {class System;}-namespace FileSys {-class VfsFilesystem;-}-namespace Kernel {class ClientPort;class ServerPort;@@ -31,6 +27,10 @@ class HLERequestContext;namespace Service {+namespace FileSystem {+class FileSystemController;+} // namespace FileSystem+namespace SM {class ServiceManager;}