diff options
| author | 2019-04-22 17:56:56 -0400 | |
|---|---|---|
| committer | 2019-09-21 16:43:10 -0400 | |
| commit | c6ff4a6f4d05eb380616be57e4088003e7aedfcb (patch) | |
| tree | a923240a1505dd0ebbf476f43fe7e653a07e3217 /src/core/hle | |
| parent | settings: Update LogSettings to show NAND/SDMC paths from FileUtil (diff) | |
| download | yuzu-c6ff4a6f4d05eb380616be57e4088003e7aedfcb.tar.gz yuzu-c6ff4a6f4d05eb380616be57e4088003e7aedfcb.tar.xz yuzu-c6ff4a6f4d05eb380616be57e4088003e7aedfcb.zip | |
yuzu: Port old usages of Filesystem namespace to FilesystemController
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 46 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 2 |
4 files changed, 38 insertions, 15 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index d8debf612..76a860c6d 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "core/hle/service/filesystem/fsp_pr.h" | 26 | #include "core/hle/service/filesystem/fsp_pr.h" |
| 27 | #include "core/hle/service/filesystem/fsp_srv.h" | 27 | #include "core/hle/service/filesystem/fsp_srv.h" |
| 28 | #include "core/loader/loader.h" | 28 | #include "core/loader/loader.h" |
| 29 | #include "core/settings.h" | ||
| 29 | 30 | ||
| 30 | namespace Service::FileSystem { | 31 | namespace Service::FileSystem { |
| 31 | 32 | ||
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 85f8e4a63..525fda19f 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "core/file_sys/mode.h" | 19 | #include "core/file_sys/mode.h" |
| 20 | #include "core/file_sys/nca_metadata.h" | 20 | #include "core/file_sys/nca_metadata.h" |
| 21 | #include "core/file_sys/patch_manager.h" | 21 | #include "core/file_sys/patch_manager.h" |
| 22 | #include "core/file_sys/romfs_factory.h" | ||
| 22 | #include "core/file_sys/savedata_factory.h" | 23 | #include "core/file_sys/savedata_factory.h" |
| 23 | #include "core/file_sys/system_archive/system_archive.h" | 24 | #include "core/file_sys/system_archive/system_archive.h" |
| 24 | #include "core/file_sys/vfs.h" | 25 | #include "core/file_sys/vfs.h" |
| @@ -502,8 +503,8 @@ private: | |||
| 502 | 503 | ||
| 503 | class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { | 504 | class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { |
| 504 | public: | 505 | public: |
| 505 | explicit ISaveDataInfoReader(FileSys::SaveDataSpaceId space) | 506 | explicit ISaveDataInfoReader(FileSys::SaveDataSpaceId space, FileSystemController& fsc) |
| 506 | : ServiceFramework("ISaveDataInfoReader") { | 507 | : ServiceFramework("ISaveDataInfoReader"), fsc(fsc) { |
| 507 | static const FunctionInfo functions[] = { | 508 | static const FunctionInfo functions[] = { |
| 508 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, | 509 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, |
| 509 | }; | 510 | }; |
| @@ -549,8 +550,13 @@ private: | |||
| 549 | } | 550 | } |
| 550 | 551 | ||
| 551 | void FindAllSaves(FileSys::SaveDataSpaceId space) { | 552 | void FindAllSaves(FileSys::SaveDataSpaceId space) { |
| 552 | const auto save_root = OpenSaveDataSpace(space); | 553 | const auto save_root = fsc.OpenSaveDataSpace(space); |
| 553 | ASSERT(save_root.Succeeded()); | 554 | |
| 555 | if (save_root.Failed() || *save_root == nullptr) { | ||
| 556 | LOG_ERROR(Service_FS, "The save root for the space_id={:02X} was invalid!", | ||
| 557 | static_cast<u8>(space)); | ||
| 558 | return; | ||
| 559 | } | ||
| 554 | 560 | ||
| 555 | for (const auto& type : (*save_root)->GetSubdirectories()) { | 561 | for (const auto& type : (*save_root)->GetSubdirectories()) { |
| 556 | if (type->GetName() == "save") { | 562 | if (type->GetName() == "save") { |
| @@ -639,11 +645,12 @@ private: | |||
| 639 | }; | 645 | }; |
| 640 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); | 646 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); |
| 641 | 647 | ||
| 648 | FileSystemController& fsc; | ||
| 642 | std::vector<SaveDataInfo> info; | 649 | std::vector<SaveDataInfo> info; |
| 643 | u64 next_entry_index = 0; | 650 | u64 next_entry_index = 0; |
| 644 | }; | 651 | }; |
| 645 | 652 | ||
| 646 | FSP_SRV::FSP_SRV(const Core::Reporter& reporter) : ServiceFramework("fsp-srv"), reporter(reporter) { | 653 | FSP_SRV::FSP_SRV(FileSystemController& fsc) : ServiceFramework("fsp-srv"), fsc(fsc) { |
| 647 | // clang-format off | 654 | // clang-format off |
| 648 | static const FunctionInfo functions[] = { | 655 | static const FunctionInfo functions[] = { |
| 649 | {0, nullptr, "OpenFileSystem"}, | 656 | {0, nullptr, "OpenFileSystem"}, |
| @@ -783,7 +790,8 @@ void FSP_SRV::OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx) { | |||
| 783 | void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) { | 790 | void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) { |
| 784 | LOG_DEBUG(Service_FS, "called"); | 791 | LOG_DEBUG(Service_FS, "called"); |
| 785 | 792 | ||
| 786 | IFileSystem filesystem(OpenSDMC().Unwrap()); | 793 | IFileSystem filesystem(fsc.OpenSDMC().Unwrap(), |
| 794 | SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard)); | ||
| 787 | 795 | ||
| 788 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 796 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 789 | rb.Push(RESULT_SUCCESS); | 797 | rb.Push(RESULT_SUCCESS); |
| @@ -797,8 +805,10 @@ void FSP_SRV::CreateSaveDataFileSystem(Kernel::HLERequestContext& ctx) { | |||
| 797 | auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>(); | 805 | auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>(); |
| 798 | u128 uid = rp.PopRaw<u128>(); | 806 | u128 uid = rp.PopRaw<u128>(); |
| 799 | 807 | ||
| 800 | LOG_WARNING(Service_FS, "(STUBBED) called save_struct = {}, uid = {:016X}{:016X}", | 808 | LOG_DEBUG(Service_FS, "called save_struct = {}, uid = {:016X}{:016X}", save_struct.DebugInfo(), |
| 801 | save_struct.DebugInfo(), uid[1], uid[0]); | 809 | uid[1], uid[0]); |
| 810 | |||
| 811 | fsc.CreateSaveData(FileSys::SaveDataSpaceId::NandUser, save_struct); | ||
| 802 | 812 | ||
| 803 | IPC::ResponseBuilder rb{ctx, 2}; | 813 | IPC::ResponseBuilder rb{ctx, 2}; |
| 804 | rb.Push(RESULT_SUCCESS); | 814 | rb.Push(RESULT_SUCCESS); |
| @@ -815,14 +825,24 @@ void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) { | |||
| 815 | IPC::RequestParser rp{ctx}; | 825 | IPC::RequestParser rp{ctx}; |
| 816 | const auto parameters = rp.PopRaw<Parameters>(); | 826 | const auto parameters = rp.PopRaw<Parameters>(); |
| 817 | 827 | ||
| 818 | auto dir = OpenSaveData(parameters.save_data_space_id, parameters.descriptor); | 828 | auto dir = fsc.OpenSaveData(parameters.save_data_space_id, parameters.descriptor); |
| 819 | if (dir.Failed()) { | 829 | if (dir.Failed()) { |
| 820 | IPC::ResponseBuilder rb{ctx, 2, 0, 0}; | 830 | IPC::ResponseBuilder rb{ctx, 2, 0, 0}; |
| 821 | rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); | 831 | rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); |
| 822 | return; | 832 | return; |
| 823 | } | 833 | } |
| 824 | 834 | ||
| 825 | IFileSystem filesystem(std::move(dir.Unwrap())); | 835 | FileSys::StorageId id; |
| 836 | if (parameters.save_data_space_id == FileSys::SaveDataSpaceId::NandUser) { | ||
| 837 | id = FileSys::StorageId::NandUser; | ||
| 838 | } else if (parameters.save_data_space_id == FileSys::SaveDataSpaceId::SdCardSystem || | ||
| 839 | parameters.save_data_space_id == FileSys::SaveDataSpaceId::SdCardUser) { | ||
| 840 | id = FileSys::StorageId::SdCard; | ||
| 841 | } else { | ||
| 842 | id = FileSys::StorageId::NandSystem; | ||
| 843 | } | ||
| 844 | |||
| 845 | IFileSystem filesystem(std::move(dir.Unwrap()), SizeGetter::FromStorageId(fsc, id)); | ||
| 826 | 846 | ||
| 827 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 847 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 828 | rb.Push(RESULT_SUCCESS); | 848 | rb.Push(RESULT_SUCCESS); |
| @@ -841,7 +861,7 @@ void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& | |||
| 841 | 861 | ||
| 842 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 862 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 843 | rb.Push(RESULT_SUCCESS); | 863 | rb.Push(RESULT_SUCCESS); |
| 844 | rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space)); | 864 | rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space, fsc)); |
| 845 | } | 865 | } |
| 846 | 866 | ||
| 847 | void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { | 867 | void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { |
| @@ -865,7 +885,7 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { | |||
| 865 | void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { | 885 | void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { |
| 866 | LOG_DEBUG(Service_FS, "called"); | 886 | LOG_DEBUG(Service_FS, "called"); |
| 867 | 887 | ||
| 868 | auto romfs = OpenRomFSCurrentProcess(); | 888 | auto romfs = fsc.OpenRomFSCurrentProcess(); |
| 869 | if (romfs.Failed()) { | 889 | if (romfs.Failed()) { |
| 870 | // TODO (bunnei): Find the right error code to use here | 890 | // TODO (bunnei): Find the right error code to use here |
| 871 | LOG_CRITICAL(Service_FS, "no file system interface available!"); | 891 | LOG_CRITICAL(Service_FS, "no file system interface available!"); |
| @@ -890,7 +910,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) { | |||
| 890 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, unknown={:08X}, title_id={:016X}", | 910 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, unknown={:08X}, title_id={:016X}", |
| 891 | static_cast<u8>(storage_id), unknown, title_id); | 911 | static_cast<u8>(storage_id), unknown, title_id); |
| 892 | 912 | ||
| 893 | auto data = OpenRomFS(title_id, storage_id, FileSys::ContentRecordType::Data); | 913 | auto data = fsc.OpenRomFS(title_id, storage_id, FileSys::ContentRecordType::Data); |
| 894 | 914 | ||
| 895 | if (data.Failed()) { | 915 | if (data.Failed()) { |
| 896 | const auto archive = FileSys::SystemArchive::SynthesizeSystemArchive(title_id); | 916 | const auto archive = FileSys::SystemArchive::SynthesizeSystemArchive(title_id); |
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h index b5486a193..494348598 100644 --- a/src/core/hle/service/filesystem/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp_srv.h | |||
| @@ -32,7 +32,7 @@ enum class LogMode : u32 { | |||
| 32 | 32 | ||
| 33 | class FSP_SRV final : public ServiceFramework<FSP_SRV> { | 33 | class FSP_SRV final : public ServiceFramework<FSP_SRV> { |
| 34 | public: | 34 | public: |
| 35 | explicit FSP_SRV(const Core::Reporter& reporter); | 35 | explicit FSP_SRV(FileSystemController& fsc); |
| 36 | ~FSP_SRV() override; | 36 | ~FSP_SRV() override; |
| 37 | 37 | ||
| 38 | private: | 38 | private: |
| @@ -51,6 +51,8 @@ private: | |||
| 51 | void OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx); | 51 | void OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx); |
| 52 | void GetAccessLogVersionInfo(Kernel::HLERequestContext& ctx); | 52 | void GetAccessLogVersionInfo(Kernel::HLERequestContext& ctx); |
| 53 | 53 | ||
| 54 | FileSystemController& fsc; | ||
| 55 | |||
| 54 | FileSys::VirtualFile romfs; | 56 | FileSys::VirtualFile romfs; |
| 55 | u64 current_process_id = 0; | 57 | u64 current_process_id = 0; |
| 56 | u32 access_log_program_index = 0; | 58 | u32 access_log_program_index = 0; |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 8bf033c88..3d6a5990f 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -230,7 +230,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) { | |||
| 230 | Migration::InstallInterfaces(*sm); | 230 | Migration::InstallInterfaces(*sm); |
| 231 | Mii::InstallInterfaces(*sm); | 231 | Mii::InstallInterfaces(*sm); |
| 232 | MM::InstallInterfaces(*sm); | 232 | MM::InstallInterfaces(*sm); |
| 233 | NCM::InstallInterfaces(*sm, fsc); | 233 | NCM::InstallInterfaces(*sm); |
| 234 | NFC::InstallInterfaces(*sm); | 234 | NFC::InstallInterfaces(*sm); |
| 235 | NFP::InstallInterfaces(*sm); | 235 | NFP::InstallInterfaces(*sm); |
| 236 | NIFM::InstallInterfaces(*sm); | 236 | NIFM::InstallInterfaces(*sm); |