summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Morph2020-12-03 22:57:28 -0500
committerGravatar Morph2020-12-08 08:19:05 -0500
commite15039372ea63efb37cdaa70833b2d080931ee3c (patch)
tree978997c532d32f3861ab25e06d128ddcaad65a0f /src/core
parentfile_sys: Consolidate common Title ID operations (diff)
downloadyuzu-e15039372ea63efb37cdaa70833b2d080931ee3c.tar.gz
yuzu-e15039372ea63efb37cdaa70833b2d080931ee3c.tar.xz
yuzu-e15039372ea63efb37cdaa70833b2d080931ee3c.zip
fsp_srv: Implement OpenDataStorageWithProgramIndex
- Used by RollerCoaster Tycoon 3: Complete Edition
Diffstat (limited to 'src/core')
-rw-r--r--src/core/file_sys/romfs_factory.cpp22
-rw-r--r--src/core/file_sys/romfs_factory.h4
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp25
-rw-r--r--src/core/hle/service/filesystem/filesystem.h4
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp28
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.h1
6 files changed, 83 insertions, 1 deletions
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index 987199747..f4e16e4be 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -7,6 +7,7 @@
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/file_sys/card_image.h" 9#include "core/file_sys/card_image.h"
10#include "core/file_sys/common_funcs.h"
10#include "core/file_sys/content_archive.h" 11#include "core/file_sys/content_archive.h"
11#include "core/file_sys/nca_metadata.h" 12#include "core/file_sys/nca_metadata.h"
12#include "core/file_sys/patch_manager.h" 13#include "core/file_sys/patch_manager.h"
@@ -47,6 +48,27 @@ ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess(u64 current_process_titl
47 patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw)); 48 patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw));
48} 49}
49 50
51ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFS(u64 title_id, ContentRecordType type) const {
52 auto nca = content_provider.GetEntry(title_id, type);
53
54 if (nca == nullptr) {
55 // TODO: Find the right error code to use here
56 return RESULT_UNKNOWN;
57 }
58
59 const PatchManager patch_manager{title_id, filesystem_controller, content_provider};
60
61 return MakeResult<VirtualFile>(
62 patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), type));
63}
64
65ResultVal<VirtualFile> RomFSFactory::OpenPatchedRomFSWithProgramIndex(
66 u64 title_id, u8 program_index, ContentRecordType type) const {
67 const auto res_title_id = GetBaseTitleIDWithProgramIndex(title_id, program_index);
68
69 return OpenPatchedRomFS(res_title_id, type);
70}
71
50ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, 72ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage,
51 ContentRecordType type) const { 73 ContentRecordType type) const {
52 const std::shared_ptr<NCA> res = GetEntry(title_id, storage, type); 74 const std::shared_ptr<NCA> res = GetEntry(title_id, storage, type);
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h
index ec704dfa8..96dd0d578 100644
--- a/src/core/file_sys/romfs_factory.h
+++ b/src/core/file_sys/romfs_factory.h
@@ -42,6 +42,10 @@ public:
42 42
43 void SetPackedUpdate(VirtualFile update_raw); 43 void SetPackedUpdate(VirtualFile update_raw);
44 [[nodiscard]] ResultVal<VirtualFile> OpenCurrentProcess(u64 current_process_title_id) const; 44 [[nodiscard]] ResultVal<VirtualFile> OpenCurrentProcess(u64 current_process_title_id) const;
45 [[nodiscard]] ResultVal<VirtualFile> OpenPatchedRomFS(u64 title_id,
46 ContentRecordType type) const;
47 [[nodiscard]] ResultVal<VirtualFile> OpenPatchedRomFSWithProgramIndex(
48 u64 title_id, u8 program_index, ContentRecordType type) const;
45 [[nodiscard]] ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, 49 [[nodiscard]] ResultVal<VirtualFile> Open(u64 title_id, StorageId storage,
46 ContentRecordType type) const; 50 ContentRecordType type) const;
47 51
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index ca93062cf..0e9e06267 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -298,6 +298,31 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess()
298 return romfs_factory->OpenCurrentProcess(system.CurrentProcess()->GetTitleID()); 298 return romfs_factory->OpenCurrentProcess(system.CurrentProcess()->GetTitleID());
299} 299}
300 300
301ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFS(
302 u64 title_id, FileSys::ContentRecordType type) const {
303 LOG_TRACE(Service_FS, "Opening patched RomFS for title_id={:016X}", title_id);
304
305 if (romfs_factory == nullptr) {
306 // TODO: Find a better error code for this
307 return RESULT_UNKNOWN;
308 }
309
310 return romfs_factory->OpenPatchedRomFS(title_id, type);
311}
312
313ResultVal<FileSys::VirtualFile> FileSystemController::OpenPatchedRomFSWithProgramIndex(
314 u64 title_id, u8 program_index, FileSys::ContentRecordType type) const {
315 LOG_TRACE(Service_FS, "Opening patched RomFS for title_id={:016X}, program_index={}", title_id,
316 program_index);
317
318 if (romfs_factory == nullptr) {
319 // TODO: Find a better error code for this
320 return RESULT_UNKNOWN;
321 }
322
323 return romfs_factory->OpenPatchedRomFSWithProgramIndex(title_id, program_index, type);
324}
325
301ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS( 326ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS(
302 u64 title_id, FileSys::StorageId storage_id, FileSys::ContentRecordType type) const { 327 u64 title_id, FileSys::StorageId storage_id, FileSys::ContentRecordType type) const {
303 LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}", 328 LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}",
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index 6dbbf0b2b..7102d3f9a 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -66,6 +66,10 @@ public:
66 66
67 void SetPackedUpdate(FileSys::VirtualFile update_raw); 67 void SetPackedUpdate(FileSys::VirtualFile update_raw);
68 ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const; 68 ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const;
69 ResultVal<FileSys::VirtualFile> OpenPatchedRomFS(u64 title_id,
70 FileSys::ContentRecordType type) const;
71 ResultVal<FileSys::VirtualFile> OpenPatchedRomFSWithProgramIndex(
72 u64 title_id, u8 program_index, FileSys::ContentRecordType type) const;
69 ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id, 73 ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
70 FileSys::ContentRecordType type) const; 74 FileSys::ContentRecordType type) const;
71 ResultVal<FileSys::VirtualDir> CreateSaveData( 75 ResultVal<FileSys::VirtualDir> CreateSaveData(
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index b3480494c..a3623e0be 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -718,7 +718,7 @@ FSP_SRV::FSP_SRV(Core::System& system_)
718 {202, &FSP_SRV::OpenDataStorageByDataId, "OpenDataStorageByDataId"}, 718 {202, &FSP_SRV::OpenDataStorageByDataId, "OpenDataStorageByDataId"},
719 {203, &FSP_SRV::OpenPatchDataStorageByCurrentProcess, "OpenPatchDataStorageByCurrentProcess"}, 719 {203, &FSP_SRV::OpenPatchDataStorageByCurrentProcess, "OpenPatchDataStorageByCurrentProcess"},
720 {204, nullptr, "OpenDataFileSystemByProgramIndex"}, 720 {204, nullptr, "OpenDataFileSystemByProgramIndex"},
721 {205, nullptr, "OpenDataStorageByProgramIndex"}, 721 {205, &FSP_SRV::OpenDataStorageWithProgramIndex, "OpenDataStorageWithProgramIndex"},
722 {400, nullptr, "OpenDeviceOperator"}, 722 {400, nullptr, "OpenDeviceOperator"},
723 {500, nullptr, "OpenSdCardDetectionEventNotifier"}, 723 {500, nullptr, "OpenSdCardDetectionEventNotifier"},
724 {501, nullptr, "OpenGameCardDetectionEventNotifier"}, 724 {501, nullptr, "OpenGameCardDetectionEventNotifier"},
@@ -997,6 +997,32 @@ void FSP_SRV::OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ct
997 rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); 997 rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND);
998} 998}
999 999
1000void FSP_SRV::OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx) {
1001 IPC::RequestParser rp{ctx};
1002
1003 const auto program_index = rp.PopRaw<u8>();
1004
1005 LOG_DEBUG(Service_FS, "called, program_index={}", program_index);
1006
1007 auto romfs = fsc.OpenPatchedRomFSWithProgramIndex(
1008 system.CurrentProcess()->GetTitleID(), program_index, FileSys::ContentRecordType::Program);
1009
1010 if (romfs.Failed()) {
1011 // TODO: Find the right error code to use here
1012 LOG_ERROR(Service_FS, "could not open storage with program_index={}", program_index);
1013
1014 IPC::ResponseBuilder rb{ctx, 2};
1015 rb.Push(RESULT_UNKNOWN);
1016 return;
1017 }
1018
1019 auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap()));
1020
1021 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
1022 rb.Push(RESULT_SUCCESS);
1023 rb.PushIpcInterface<IStorage>(std::move(storage));
1024}
1025
1000void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { 1026void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
1001 IPC::RequestParser rp{ctx}; 1027 IPC::RequestParser rp{ctx};
1002 log_mode = rp.PopEnum<LogMode>(); 1028 log_mode = rp.PopEnum<LogMode>();
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h
index 472286d6e..8ed933279 100644
--- a/src/core/hle/service/filesystem/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp_srv.h
@@ -49,6 +49,7 @@ private:
49 void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); 49 void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
50 void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx); 50 void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx);
51 void OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); 51 void OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
52 void OpenDataStorageWithProgramIndex(Kernel::HLERequestContext& ctx);
52 void SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); 53 void SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx);
53 void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); 54 void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx);
54 void OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx); 55 void OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx);