diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 4 | ||||
| -rw-r--r-- | src/core/core.h | 4 | ||||
| -rw-r--r-- | src/core/file_sys/bis_factory.cpp | 10 | ||||
| -rw-r--r-- | src/core/file_sys/bis_factory.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 50 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.h | 21 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 2 | ||||
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/nca.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/nro.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 3 |
11 files changed, 61 insertions, 47 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 05b1d2b92..44aaba242 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -629,11 +629,11 @@ Loader::AppLoader& System::GetAppLoader() const { | |||
| 629 | return *impl->app_loader; | 629 | return *impl->app_loader; |
| 630 | } | 630 | } |
| 631 | 631 | ||
| 632 | void System::SetFilesystem(std::shared_ptr<FileSys::VfsFilesystem> vfs) { | 632 | void System::SetFilesystem(FileSys::VirtualFilesystem vfs) { |
| 633 | impl->virtual_filesystem = std::move(vfs); | 633 | impl->virtual_filesystem = std::move(vfs); |
| 634 | } | 634 | } |
| 635 | 635 | ||
| 636 | std::shared_ptr<FileSys::VfsFilesystem> System::GetFilesystem() const { | 636 | FileSys::VirtualFilesystem System::GetFilesystem() const { |
| 637 | return impl->virtual_filesystem; | 637 | return impl->virtual_filesystem; |
| 638 | } | 638 | } |
| 639 | 639 | ||
diff --git a/src/core/core.h b/src/core/core.h index 5c6cfbffe..83ded63a5 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -316,9 +316,9 @@ public: | |||
| 316 | Service::SM::ServiceManager& ServiceManager(); | 316 | Service::SM::ServiceManager& ServiceManager(); |
| 317 | const Service::SM::ServiceManager& ServiceManager() const; | 317 | const Service::SM::ServiceManager& ServiceManager() const; |
| 318 | 318 | ||
| 319 | void SetFilesystem(std::shared_ptr<FileSys::VfsFilesystem> vfs); | 319 | void SetFilesystem(FileSys::VirtualFilesystem vfs); |
| 320 | 320 | ||
| 321 | std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; | 321 | FileSys::VirtualFilesystem GetFilesystem() const; |
| 322 | 322 | ||
| 323 | void RegisterCheatList(const std::vector<Memory::CheatEntry>& list, | 323 | void RegisterCheatList(const std::vector<Memory::CheatEntry>& list, |
| 324 | const std::array<u8, 0x20>& build_id, VAddr main_region_begin, | 324 | const std::array<u8, 0x20>& build_id, VAddr main_region_begin, |
diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index e04a54c3c..7c6304ff0 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #include <fmt/format.h> | 5 | #include <fmt/format.h> |
| 6 | #include "common/file_util.h" | 6 | #include "common/file_util.h" |
| 7 | #include "core/core.h" | ||
| 8 | #include "core/file_sys/bis_factory.h" | 7 | #include "core/file_sys/bis_factory.h" |
| 9 | #include "core/file_sys/mode.h" | 8 | #include "core/file_sys/mode.h" |
| 10 | #include "core/file_sys/registered_cache.h" | 9 | #include "core/file_sys/registered_cache.h" |
| 10 | #include "core/file_sys/vfs.h" | ||
| 11 | 11 | ||
| 12 | namespace FileSys { | 12 | namespace FileSys { |
| 13 | 13 | ||
| @@ -81,11 +81,11 @@ VirtualDir BISFactory::OpenPartition(BisPartitionId id) const { | |||
| 81 | } | 81 | } |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | VirtualFile BISFactory::OpenPartitionStorage(BisPartitionId id) const { | 84 | VirtualFile BISFactory::OpenPartitionStorage(BisPartitionId id, |
| 85 | VirtualFilesystem file_system) const { | ||
| 85 | auto& keys = Core::Crypto::KeyManager::Instance(); | 86 | auto& keys = Core::Crypto::KeyManager::Instance(); |
| 86 | Core::Crypto::PartitionDataManager pdm{ | 87 | Core::Crypto::PartitionDataManager pdm{file_system->OpenDirectory( |
| 87 | Core::System::GetInstance().GetFilesystem()->OpenDirectory( | 88 | Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir), Mode::Read)}; |
| 88 | Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir), Mode::Read)}; | ||
| 89 | keys.PopulateFromPartitionData(pdm); | 89 | keys.PopulateFromPartitionData(pdm); |
| 90 | 90 | ||
| 91 | switch (id) { | 91 | switch (id) { |
diff --git a/src/core/file_sys/bis_factory.h b/src/core/file_sys/bis_factory.h index 438d3f8d8..136485881 100644 --- a/src/core/file_sys/bis_factory.h +++ b/src/core/file_sys/bis_factory.h | |||
| @@ -52,7 +52,7 @@ public: | |||
| 52 | VirtualDir GetModificationDumpRoot(u64 title_id) const; | 52 | VirtualDir GetModificationDumpRoot(u64 title_id) const; |
| 53 | 53 | ||
| 54 | VirtualDir OpenPartition(BisPartitionId id) const; | 54 | VirtualDir OpenPartition(BisPartitionId id) const; |
| 55 | VirtualFile OpenPartitionStorage(BisPartitionId id) const; | 55 | VirtualFile OpenPartitionStorage(BisPartitionId id, VirtualFilesystem file_system) const; |
| 56 | 56 | ||
| 57 | VirtualDir GetImageDirectory() const; | 57 | VirtualDir GetImageDirectory() const; |
| 58 | 58 | ||
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 418a39a7e..e967a254e 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | ||
| 10 | #include "core/file_sys/card_image.h" | 9 | #include "core/file_sys/card_image.h" |
| 11 | #include "core/file_sys/content_archive.h" | 10 | #include "core/file_sys/content_archive.h" |
| 12 | #include "core/file_sys/nca_metadata.h" | 11 | #include "core/file_sys/nca_metadata.h" |
| @@ -19,7 +18,9 @@ | |||
| 19 | 18 | ||
| 20 | namespace FileSys { | 19 | namespace FileSys { |
| 21 | 20 | ||
| 22 | RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) { | 21 | RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader, ContentProvider& provider, |
| 22 | Service::FileSystem::FileSystemController& controller) | ||
| 23 | : content_provider{provider}, filesystem_controller{controller} { | ||
| 23 | // Load the RomFS from the app | 24 | // Load the RomFS from the app |
| 24 | if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { | 25 | if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { |
| 25 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); | 26 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); |
| @@ -46,39 +47,38 @@ ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_titl | |||
| 46 | 47 | ||
| 47 | ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, | 48 | ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, |
| 48 | ContentRecordType type) const { | 49 | ContentRecordType type) const { |
| 49 | std::shared_ptr<NCA> res; | 50 | const std::shared_ptr<NCA> res = GetEntry(title_id, storage, type); |
| 50 | |||
| 51 | switch (storage) { | ||
| 52 | case StorageId::None: | ||
| 53 | res = Core::System::GetInstance().GetContentProvider().GetEntry(title_id, type); | ||
| 54 | break; | ||
| 55 | case StorageId::NandSystem: | ||
| 56 | res = | ||
| 57 | Core::System::GetInstance().GetFileSystemController().GetSystemNANDContents()->GetEntry( | ||
| 58 | title_id, type); | ||
| 59 | break; | ||
| 60 | case StorageId::NandUser: | ||
| 61 | res = Core::System::GetInstance().GetFileSystemController().GetUserNANDContents()->GetEntry( | ||
| 62 | title_id, type); | ||
| 63 | break; | ||
| 64 | case StorageId::SdCard: | ||
| 65 | res = Core::System::GetInstance().GetFileSystemController().GetSDMCContents()->GetEntry( | ||
| 66 | title_id, type); | ||
| 67 | break; | ||
| 68 | default: | ||
| 69 | UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage)); | ||
| 70 | } | ||
| 71 | |||
| 72 | if (res == nullptr) { | 51 | if (res == nullptr) { |
| 73 | // TODO(DarkLordZach): Find the right error code to use here | 52 | // TODO(DarkLordZach): Find the right error code to use here |
| 74 | return RESULT_UNKNOWN; | 53 | return RESULT_UNKNOWN; |
| 75 | } | 54 | } |
| 55 | |||
| 76 | const auto romfs = res->GetRomFS(); | 56 | const auto romfs = res->GetRomFS(); |
| 77 | if (romfs == nullptr) { | 57 | if (romfs == nullptr) { |
| 78 | // TODO(DarkLordZach): Find the right error code to use here | 58 | // TODO(DarkLordZach): Find the right error code to use here |
| 79 | return RESULT_UNKNOWN; | 59 | return RESULT_UNKNOWN; |
| 80 | } | 60 | } |
| 61 | |||
| 81 | return MakeResult<VirtualFile>(romfs); | 62 | return MakeResult<VirtualFile>(romfs); |
| 82 | } | 63 | } |
| 83 | 64 | ||
| 65 | std::shared_ptr<NCA> RomFSFactory::GetEntry(u64 title_id, StorageId storage, | ||
| 66 | ContentRecordType type) const { | ||
| 67 | switch (storage) { | ||
| 68 | case StorageId::None: | ||
| 69 | return content_provider.GetEntry(title_id, type); | ||
| 70 | case StorageId::NandSystem: | ||
| 71 | return filesystem_controller.GetSystemNANDContents()->GetEntry(title_id, type); | ||
| 72 | case StorageId::NandUser: | ||
| 73 | return filesystem_controller.GetUserNANDContents()->GetEntry(title_id, type); | ||
| 74 | case StorageId::SdCard: | ||
| 75 | return filesystem_controller.GetSDMCContents()->GetEntry(title_id, type); | ||
| 76 | case StorageId::Host: | ||
| 77 | case StorageId::GameCard: | ||
| 78 | default: | ||
| 79 | UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage)); | ||
| 80 | return nullptr; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | } // namespace FileSys | 84 | } // namespace FileSys |
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h index c5d40285c..ec704dfa8 100644 --- a/src/core/file_sys/romfs_factory.h +++ b/src/core/file_sys/romfs_factory.h | |||
| @@ -13,8 +13,15 @@ namespace Loader { | |||
| 13 | class AppLoader; | 13 | class AppLoader; |
| 14 | } // namespace Loader | 14 | } // namespace Loader |
| 15 | 15 | ||
| 16 | namespace Service::FileSystem { | ||
| 17 | class FileSystemController; | ||
| 18 | } | ||
| 19 | |||
| 16 | namespace FileSys { | 20 | namespace FileSys { |
| 17 | 21 | ||
| 22 | class ContentProvider; | ||
| 23 | class NCA; | ||
| 24 | |||
| 18 | enum class ContentRecordType : u8; | 25 | enum class ContentRecordType : u8; |
| 19 | 26 | ||
| 20 | enum class StorageId : u8 { | 27 | enum class StorageId : u8 { |
| @@ -29,18 +36,26 @@ enum class StorageId : u8 { | |||
| 29 | /// File system interface to the RomFS archive | 36 | /// File system interface to the RomFS archive |
| 30 | class RomFSFactory { | 37 | class RomFSFactory { |
| 31 | public: | 38 | public: |
| 32 | explicit RomFSFactory(Loader::AppLoader& app_loader); | 39 | explicit RomFSFactory(Loader::AppLoader& app_loader, ContentProvider& provider, |
| 40 | Service::FileSystem::FileSystemController& controller); | ||
| 33 | ~RomFSFactory(); | 41 | ~RomFSFactory(); |
| 34 | 42 | ||
| 35 | void SetPackedUpdate(VirtualFile update_raw); | 43 | void SetPackedUpdate(VirtualFile update_raw); |
| 36 | ResultVal<VirtualFile> OpenCurrentProcess(u64 current_process_title_id) const; | 44 | [[nodiscard]] ResultVal<VirtualFile> OpenCurrentProcess(u64 current_process_title_id) const; |
| 37 | ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type) const; | 45 | [[nodiscard]] ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, |
| 46 | ContentRecordType type) const; | ||
| 38 | 47 | ||
| 39 | private: | 48 | private: |
| 49 | [[nodiscard]] std::shared_ptr<NCA> GetEntry(u64 title_id, StorageId storage, | ||
| 50 | ContentRecordType type) const; | ||
| 51 | |||
| 40 | VirtualFile file; | 52 | VirtualFile file; |
| 41 | VirtualFile update_raw; | 53 | VirtualFile update_raw; |
| 42 | bool updatable; | 54 | bool updatable; |
| 43 | u64 ivfc_offset; | 55 | u64 ivfc_offset; |
| 56 | |||
| 57 | ContentProvider& content_provider; | ||
| 58 | Service::FileSystem::FileSystemController& filesystem_controller; | ||
| 44 | }; | 59 | }; |
| 45 | 60 | ||
| 46 | } // namespace FileSys | 61 | } // namespace FileSys |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 2cee1193c..54a5fb84b 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -379,7 +379,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage( | |||
| 379 | return FileSys::ERROR_ENTITY_NOT_FOUND; | 379 | return FileSys::ERROR_ENTITY_NOT_FOUND; |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | auto part = bis_factory->OpenPartitionStorage(id); | 382 | auto part = bis_factory->OpenPartitionStorage(id, system.GetFilesystem()); |
| 383 | if (part == nullptr) { | 383 | if (part == nullptr) { |
| 384 | return FileSys::ERROR_INVALID_ARGUMENT; | 384 | return FileSys::ERROR_INVALID_ARGUMENT; |
| 385 | } | 385 | } |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 56dda425c..394a1bf26 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -192,8 +192,8 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect | |||
| 192 | // Register the RomFS if a ".romfs" file was found | 192 | // Register the RomFS if a ".romfs" file was found |
| 193 | if (romfs_iter != files.end() && *romfs_iter != nullptr) { | 193 | if (romfs_iter != files.end() && *romfs_iter != nullptr) { |
| 194 | romfs = *romfs_iter; | 194 | romfs = *romfs_iter; |
| 195 | system.GetFileSystemController().RegisterRomFS( | 195 | system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>( |
| 196 | std::make_unique<FileSys::RomFSFactory>(*this)); | 196 | *this, system.GetContentProvider(), system.GetFileSystemController())); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | is_loaded = true; | 199 | is_loaded = true; |
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 50d7a0f32..fa694de37 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp | |||
| @@ -58,8 +58,8 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process, Core::Sy | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) { | 60 | if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) { |
| 61 | system.GetFileSystemController().RegisterRomFS( | 61 | system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>( |
| 62 | std::make_unique<FileSys::RomFSFactory>(*this)); | 62 | *this, system.GetContentProvider(), system.GetFileSystemController())); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | is_loaded = true; | 65 | is_loaded = true; |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 5ce279f81..9fb5eddad 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -218,8 +218,8 @@ AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process, Core::Sy | |||
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | if (romfs != nullptr) { | 220 | if (romfs != nullptr) { |
| 221 | system.GetFileSystemController().RegisterRomFS( | 221 | system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>( |
| 222 | std::make_unique<FileSys::RomFSFactory>(*this)); | 222 | *this, system.GetContentProvider(), system.GetFileSystemController())); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | is_loaded = true; | 225 | is_loaded = true; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 2610cea34..60373cc5f 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -165,8 +165,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, Core::S | |||
| 165 | return load_base + image_size; | 165 | return load_base + image_size; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process, | 168 | AppLoader_NSO::LoadResult AppLoader_NSO::Load(Kernel::Process& process, Core::System& system) { |
| 169 | [[maybe_unused]] Core::System& system) { | ||
| 170 | if (is_loaded) { | 169 | if (is_loaded) { |
| 171 | return {ResultStatus::ErrorAlreadyLoaded, {}}; | 170 | return {ResultStatus::ErrorAlreadyLoaded, {}}; |
| 172 | } | 171 | } |