diff options
| author | 2018-08-20 20:17:57 -0400 | |
|---|---|---|
| committer | 2018-08-20 20:17:57 -0400 | |
| commit | dd70ddad7edb7cfbdddaed0ac657544a613d46e2 (patch) | |
| tree | 76145c48a1f92f64ef53ef8527df392b0fac10a6 /src/core/hle | |
| parent | Merge pull request #1127 from yuzu-emu/revert-838-port-3616 (diff) | |
| parent | registration: Add Data_Unknown5 NCAContentType (diff) | |
| download | yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.gz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.xz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.zip | |
Merge pull request #1095 from DarkLordZach/sysarchives
filesystem: Add support for loading of system archives
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 42 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.h | 1 |
4 files changed, 50 insertions, 16 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index da658cbe6..f374111c1 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -256,15 +256,28 @@ ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory) { | |||
| 256 | return RESULT_SUCCESS; | 256 | return RESULT_SUCCESS; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id) { | 259 | ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() { |
| 260 | LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}", title_id); | 260 | LOG_TRACE(Service_FS, "Opening RomFS for current process"); |
| 261 | 261 | ||
| 262 | if (romfs_factory == nullptr) { | 262 | if (romfs_factory == nullptr) { |
| 263 | // TODO(bunnei): Find a better error code for this | 263 | // TODO(bunnei): Find a better error code for this |
| 264 | return ResultCode(-1); | 264 | return ResultCode(-1); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | return romfs_factory->Open(title_id); | 267 | return romfs_factory->OpenCurrentProcess(); |
| 268 | } | ||
| 269 | |||
| 270 | ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id, | ||
| 271 | FileSys::ContentRecordType type) { | ||
| 272 | LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}", | ||
| 273 | title_id, static_cast<u8>(storage_id), static_cast<u8>(type)); | ||
| 274 | |||
| 275 | if (romfs_factory == nullptr) { | ||
| 276 | // TODO(bunnei): Find a better error code for this | ||
| 277 | return ResultCode(-1); | ||
| 278 | } | ||
| 279 | |||
| 280 | return romfs_factory->Open(title_id, storage_id, type); | ||
| 268 | } | 281 | } |
| 269 | 282 | ||
| 270 | ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, | 283 | ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, |
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 1d6f922dd..37a2878b0 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -27,7 +27,9 @@ ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory) | |||
| 27 | ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory); | 27 | ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory); |
| 28 | ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory); | 28 | ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory); |
| 29 | 29 | ||
| 30 | ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id); | 30 | ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess(); |
| 31 | ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id, | ||
| 32 | FileSys::ContentRecordType type); | ||
| 31 | ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, | 33 | ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, |
| 32 | FileSys::SaveDataDescriptor save_struct); | 34 | FileSys::SaveDataDescriptor save_struct); |
| 33 | ResultVal<FileSys::VirtualDir> OpenSDMC(); | 35 | ResultVal<FileSys::VirtualDir> OpenSDMC(); |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 1470f9017..2f8a7a3c1 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -23,15 +23,6 @@ | |||
| 23 | 23 | ||
| 24 | namespace Service::FileSystem { | 24 | namespace Service::FileSystem { |
| 25 | 25 | ||
| 26 | enum class StorageId : u8 { | ||
| 27 | None = 0, | ||
| 28 | Host = 1, | ||
| 29 | GameCard = 2, | ||
| 30 | NandSystem = 3, | ||
| 31 | NandUser = 4, | ||
| 32 | SdCard = 5, | ||
| 33 | }; | ||
| 34 | |||
| 35 | class IStorage final : public ServiceFramework<IStorage> { | 26 | class IStorage final : public ServiceFramework<IStorage> { |
| 36 | public: | 27 | public: |
| 37 | explicit IStorage(FileSys::VirtualFile backend_) | 28 | explicit IStorage(FileSys::VirtualFile backend_) |
| @@ -467,7 +458,7 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { | |||
| 467 | {110, nullptr, "OpenContentStorageFileSystem"}, | 458 | {110, nullptr, "OpenContentStorageFileSystem"}, |
| 468 | {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"}, | 459 | {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"}, |
| 469 | {201, nullptr, "OpenDataStorageByProgramId"}, | 460 | {201, nullptr, "OpenDataStorageByProgramId"}, |
| 470 | {202, nullptr, "OpenDataStorageByDataId"}, | 461 | {202, &FSP_SRV::OpenDataStorageByDataId, "OpenDataStorageByDataId"}, |
| 471 | {203, &FSP_SRV::OpenRomStorage, "OpenRomStorage"}, | 462 | {203, &FSP_SRV::OpenRomStorage, "OpenRomStorage"}, |
| 472 | {400, nullptr, "OpenDeviceOperator"}, | 463 | {400, nullptr, "OpenDeviceOperator"}, |
| 473 | {500, nullptr, "OpenSdCardDetectionEventNotifier"}, | 464 | {500, nullptr, "OpenSdCardDetectionEventNotifier"}, |
| @@ -580,7 +571,7 @@ void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { | |||
| 580 | void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { | 571 | void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { |
| 581 | LOG_DEBUG(Service_FS, "called"); | 572 | LOG_DEBUG(Service_FS, "called"); |
| 582 | 573 | ||
| 583 | auto romfs = OpenRomFS(Core::System::GetInstance().CurrentProcess()->program_id); | 574 | auto romfs = OpenRomFSCurrentProcess(); |
| 584 | if (romfs.Failed()) { | 575 | if (romfs.Failed()) { |
| 585 | // TODO (bunnei): Find the right error code to use here | 576 | // TODO (bunnei): Find the right error code to use here |
| 586 | LOG_CRITICAL(Service_FS, "no file system interface available!"); | 577 | LOG_CRITICAL(Service_FS, "no file system interface available!"); |
| @@ -596,10 +587,37 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { | |||
| 596 | rb.PushIpcInterface<IStorage>(std::move(storage)); | 587 | rb.PushIpcInterface<IStorage>(std::move(storage)); |
| 597 | } | 588 | } |
| 598 | 589 | ||
| 590 | void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) { | ||
| 591 | IPC::RequestParser rp{ctx}; | ||
| 592 | const auto storage_id = rp.PopRaw<FileSys::StorageId>(); | ||
| 593 | const auto unknown = rp.PopRaw<u32>(); | ||
| 594 | const auto title_id = rp.PopRaw<u64>(); | ||
| 595 | |||
| 596 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, unknown={:08X}, title_id={:016X}", | ||
| 597 | static_cast<u8>(storage_id), unknown, title_id); | ||
| 598 | |||
| 599 | auto data = OpenRomFS(title_id, storage_id, FileSys::ContentRecordType::Data); | ||
| 600 | if (data.Failed()) { | ||
| 601 | // TODO(DarkLordZach): Find the right error code to use here | ||
| 602 | LOG_ERROR(Service_FS, | ||
| 603 | "could not open data storage with title_id={:016X}, storage_id={:02X}", title_id, | ||
| 604 | static_cast<u8>(storage_id)); | ||
| 605 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 606 | rb.Push(ResultCode(-1)); | ||
| 607 | return; | ||
| 608 | } | ||
| 609 | |||
| 610 | IStorage storage(std::move(data.Unwrap())); | ||
| 611 | |||
| 612 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 613 | rb.Push(RESULT_SUCCESS); | ||
| 614 | rb.PushIpcInterface<IStorage>(std::move(storage)); | ||
| 615 | } | ||
| 616 | |||
| 599 | void FSP_SRV::OpenRomStorage(Kernel::HLERequestContext& ctx) { | 617 | void FSP_SRV::OpenRomStorage(Kernel::HLERequestContext& ctx) { |
| 600 | IPC::RequestParser rp{ctx}; | 618 | IPC::RequestParser rp{ctx}; |
| 601 | 619 | ||
| 602 | auto storage_id = rp.PopRaw<StorageId>(); | 620 | auto storage_id = rp.PopRaw<FileSys::StorageId>(); |
| 603 | auto title_id = rp.PopRaw<u64>(); | 621 | auto title_id = rp.PopRaw<u64>(); |
| 604 | 622 | ||
| 605 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, title_id={:016X}", | 623 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, title_id={:016X}", |
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h index 07f99c93d..f073ac523 100644 --- a/src/core/hle/service/filesystem/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp_srv.h | |||
| @@ -25,6 +25,7 @@ private: | |||
| 25 | void MountSaveData(Kernel::HLERequestContext& ctx); | 25 | void MountSaveData(Kernel::HLERequestContext& ctx); |
| 26 | void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); | 26 | void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); |
| 27 | void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); | 27 | void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); |
| 28 | void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx); | ||
| 28 | void OpenRomStorage(Kernel::HLERequestContext& ctx); | 29 | void OpenRomStorage(Kernel::HLERequestContext& ctx); |
| 29 | 30 | ||
| 30 | FileSys::VirtualFile romfs; | 31 | FileSys::VirtualFile romfs; |