yuzu-emu
/
yuzu
Archived
1
0
Fork 0

core: Port current uses of RegisteredCache to ContentProvider

This commit is contained in:
Zach Hilman 2018-12-28 00:03:38 -05:00
parent 45cb41f517
commit 60f39060c6
8 changed files with 32 additions and 27 deletions

View File

@ -22,6 +22,7 @@
#include "common/file_util.h" #include "common/file_util.h"
#include "common/hex_util.h" #include "common/hex_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h"
#include "core/crypto/aes_util.h" #include "core/crypto/aes_util.h"
#include "core/crypto/key_manager.h" #include "core/crypto/key_manager.h"
#include "core/crypto/partition_data_manager.h" #include "core/crypto/partition_data_manager.h"
@ -794,7 +795,7 @@ void KeyManager::DeriveBase() {
void KeyManager::DeriveETicket(PartitionDataManager& data) { void KeyManager::DeriveETicket(PartitionDataManager& data) {
// ETicket keys // ETicket keys
const auto es = Service::FileSystem::GetUnionContents().GetEntry( const auto es = Core::System::GetInstance().GetContentProvider().GetEntry(
0x0100000000000033, FileSys::ContentRecordType::Program); 0x0100000000000033, FileSys::ContentRecordType::Program);
if (es == nullptr) if (es == nullptr)

View File

@ -10,6 +10,7 @@
#include "common/file_util.h" #include "common/file_util.h"
#include "common/hex_util.h" #include "common/hex_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h"
#include "core/file_sys/content_archive.h" #include "core/file_sys/content_archive.h"
#include "core/file_sys/control_metadata.h" #include "core/file_sys/control_metadata.h"
#include "core/file_sys/ips_layer.h" #include "core/file_sys/ips_layer.h"
@ -69,7 +70,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
} }
} }
const auto installed = Service::FileSystem::GetUnionContents(); const auto& installed = Core::System::GetInstance().GetContentProvider();
const auto& disabled = Settings::values.disabled_addons[title_id]; const auto& disabled = Settings::values.disabled_addons[title_id];
const auto update_disabled = const auto update_disabled =
@ -345,7 +346,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content
if (romfs == nullptr) if (romfs == nullptr)
return romfs; return romfs;
const auto installed = Service::FileSystem::GetUnionContents(); const auto& installed = Core::System::GetInstance().GetContentProvider();
// Game Updates // Game Updates
const auto update_tid = GetUpdateTitleID(title_id); const auto update_tid = GetUpdateTitleID(title_id);
@ -392,7 +393,7 @@ static bool IsDirValidAndNonEmpty(const VirtualDir& dir) {
std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames( std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNames(
VirtualFile update_raw) const { VirtualFile update_raw) const {
std::map<std::string, std::string, std::less<>> out; std::map<std::string, std::string, std::less<>> out;
const auto installed = Service::FileSystem::GetUnionContents(); const auto& installed = Core::System::GetInstance().GetContentProvider();
const auto& disabled = Settings::values.disabled_addons[title_id]; const auto& disabled = Settings::values.disabled_addons[title_id];
// Game Updates // Game Updates
@ -466,10 +467,10 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
// DLC // DLC
const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data);
std::vector<RegisteredCacheEntry> dlc_match; std::vector<ContentProviderEntry> dlc_match;
dlc_match.reserve(dlc_entries.size()); dlc_match.reserve(dlc_entries.size());
std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match),
[this, &installed](const RegisteredCacheEntry& entry) { [this, &installed](const ContentProviderEntry& entry) {
return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id &&
installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success; installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success;
}); });
@ -492,7 +493,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam
} }
std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const { std::pair<std::unique_ptr<NACP>, VirtualFile> PatchManager::GetControlMetadata() const {
const auto installed{Service::FileSystem::GetUnionContents()}; const auto& installed = Core::System::GetInstance().GetContentProvider();
const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control); const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control);
if (base_control_nca == nullptr) if (base_control_nca == nullptr)

View File

@ -48,7 +48,7 @@ ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, Conte
switch (storage) { switch (storage) {
case StorageId::None: case StorageId::None:
res = Service::FileSystem::GetUnionContents().GetEntry(title_id, type); res = Core::System::GetInstance().GetContentProvider().GetEntry(title_id, type);
break; break;
case StorageId::NandSystem: case StorageId::NandSystem:
res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type); res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type);

View File

@ -143,11 +143,12 @@ std::multimap<u64, std::shared_ptr<NCA>> NSP::GetNCAsByTitleID() const {
return out; return out;
} }
std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> NSP::GetNCAs() const { std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>>
NSP::GetNCAs() const {
return ncas; return ncas;
} }
std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type) const { std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type, TitleType title_type) const {
if (extracted) if (extracted)
LOG_WARNING(Service_FS, "called on an NSP that is of type extracted."); LOG_WARNING(Service_FS, "called on an NSP that is of type extracted.");
@ -155,14 +156,14 @@ std::shared_ptr<NCA> NSP::GetNCA(u64 title_id, ContentRecordType type) const {
if (title_id_iter == ncas.end()) if (title_id_iter == ncas.end())
return nullptr; return nullptr;
const auto type_iter = title_id_iter->second.find(type); const auto type_iter = title_id_iter->second.find({title_type, type});
if (type_iter == title_id_iter->second.end()) if (type_iter == title_id_iter->second.end())
return nullptr; return nullptr;
return type_iter->second; return type_iter->second;
} }
VirtualFile NSP::GetNCAFile(u64 title_id, ContentRecordType type) const { VirtualFile NSP::GetNCAFile(u64 title_id, ContentRecordType type, TitleType title_type) const {
if (extracted) if (extracted)
LOG_WARNING(Service_FS, "called on an NSP that is of type extracted."); LOG_WARNING(Service_FS, "called on an NSP that is of type extracted.");
const auto nca = GetNCA(title_id, type); const auto nca = GetNCA(title_id, type);
@ -240,7 +241,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
const CNMT cnmt(inner_file); const CNMT cnmt(inner_file);
auto& ncas_title = ncas[cnmt.GetTitleID()]; auto& ncas_title = ncas[cnmt.GetTitleID()];
ncas_title[ContentRecordType::Meta] = nca; ncas_title[{cnmt.GetType(), ContentRecordType::Meta}] = nca;
for (const auto& rec : cnmt.GetContentRecords()) { for (const auto& rec : cnmt.GetContentRecords()) {
const auto id_string = Common::HexArrayToString(rec.nca_id, false); const auto id_string = Common::HexArrayToString(rec.nca_id, false);
const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string)); const auto next_file = pfs->GetFile(fmt::format("{}.nca", id_string));
@ -258,7 +259,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) {
if (next_nca->GetStatus() == Loader::ResultStatus::Success || if (next_nca->GetStatus() == Loader::ResultStatus::Success ||
(next_nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS && (next_nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS &&
(cnmt.GetTitleID() & 0x800) != 0)) { (cnmt.GetTitleID() & 0x800) != 0)) {
ncas_title[rec.type] = std::move(next_nca); ncas_title[{cnmt.GetType(), rec.type}] = std::move(next_nca);
} }
} }

View File

@ -42,9 +42,12 @@ public:
// Type 0 Only (Collection of NCAs + Certificate + Ticket + Meta XML) // Type 0 Only (Collection of NCAs + Certificate + Ticket + Meta XML)
std::vector<std::shared_ptr<NCA>> GetNCAsCollapsed() const; std::vector<std::shared_ptr<NCA>> GetNCAsCollapsed() const;
std::multimap<u64, std::shared_ptr<NCA>> GetNCAsByTitleID() const; std::multimap<u64, std::shared_ptr<NCA>> GetNCAsByTitleID() const;
std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> GetNCAs() const; std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> GetNCAs()
std::shared_ptr<NCA> GetNCA(u64 title_id, ContentRecordType type) const; const;
VirtualFile GetNCAFile(u64 title_id, ContentRecordType type) const; std::shared_ptr<NCA> GetNCA(u64 title_id, ContentRecordType type,
TitleType title_type = TitleType::Application) const;
VirtualFile GetNCAFile(u64 title_id, ContentRecordType type,
TitleType title_type = TitleType::Application) const;
std::vector<Core::Crypto::Key128> GetTitlekey() const; std::vector<Core::Crypto::Key128> GetTitlekey() const;
std::vector<VirtualFile> GetFiles() const override; std::vector<VirtualFile> GetFiles() const override;
@ -67,7 +70,7 @@ private:
std::shared_ptr<PartitionFilesystem> pfs; std::shared_ptr<PartitionFilesystem> pfs;
// Map title id -> {map type -> NCA} // Map title id -> {map type -> NCA}
std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas; std::map<u64, std::map<std::pair<TitleType, ContentRecordType>, std::shared_ptr<NCA>>> ncas;
std::vector<VirtualFile> ticket_files; std::vector<VirtualFile> ticket_files;
Core::Crypto::KeyManager keys; Core::Crypto::KeyManager keys;

View File

@ -33,11 +33,11 @@ static bool CheckAOCTitleIDMatchesBase(u64 title_id, u64 base) {
static std::vector<u64> AccumulateAOCTitleIDs() { static std::vector<u64> AccumulateAOCTitleIDs() {
std::vector<u64> add_on_content; std::vector<u64> add_on_content;
const auto rcu = FileSystem::GetUnionContents(); const auto& rcu = Core::System::GetInstance().GetContentProvider();
const auto list = const auto list =
rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); rcu.ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
std::transform(list.begin(), list.end(), std::back_inserter(add_on_content), std::transform(list.begin(), list.end(), std::back_inserter(add_on_content),
[](const FileSys::RegisteredCacheEntry& rce) { return rce.title_id; }); [](const FileSys::ContentProviderEntry& rce) { return rce.title_id; });
add_on_content.erase( add_on_content.erase(
std::remove_if( std::remove_if(
add_on_content.begin(), add_on_content.end(), add_on_content.begin(), add_on_content.end(),

View File

@ -388,11 +388,6 @@ void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value); save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value);
} }
FileSys::RegisteredCacheUnion GetUnionContents() {
return FileSys::RegisteredCacheUnion{
{GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}};
}
FileSys::RegisteredCache* GetSystemNANDContents() { FileSys::RegisteredCache* GetSystemNANDContents() {
LOG_TRACE(Service_FS, "Opening System NAND Contents"); LOG_TRACE(Service_FS, "Opening System NAND Contents");
@ -457,6 +452,10 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
if (bis_factory == nullptr) { if (bis_factory == nullptr) {
bis_factory = bis_factory =
std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory);
Core::System::GetInstance().RegisterContentProvider(
FileSys::ContentProviderUnionSlot::SysNAND, bis_factory->GetSystemNANDContents());
Core::System::GetInstance().RegisterContentProvider(
FileSys::ContentProviderUnionSlot::UserNAND, bis_factory->GetUserNANDContents());
} }
if (save_data_factory == nullptr) { if (save_data_factory == nullptr) {
@ -465,6 +464,8 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
if (sdmc_factory == nullptr) { if (sdmc_factory == nullptr) {
sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory));
Core::System::GetInstance().RegisterContentProvider(FileSys::ContentProviderUnionSlot::SDMC,
sdmc_factory->GetSDMCContents());
} }
} }

View File

@ -54,8 +54,6 @@ FileSys::SaveDataSize ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id,
void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id, void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
FileSys::SaveDataSize new_value); FileSys::SaveDataSize new_value);
FileSys::RegisteredCacheUnion GetUnionContents();
FileSys::RegisteredCache* GetSystemNANDContents(); FileSys::RegisteredCache* GetSystemNANDContents();
FileSys::RegisteredCache* GetUserNANDContents(); FileSys::RegisteredCache* GetUserNANDContents();
FileSys::RegisteredCache* GetSDMCContents(); FileSys::RegisteredCache* GetSDMCContents();