forked from eden-emu/eden
Merge remote-tracking branch 'upstream/master' into nx
# Conflicts: # src/core/CMakeLists.txt # src/core/arm/dynarmic/arm_dynarmic.cpp # src/core/arm/dyncom/arm_dyncom.cpp # src/core/hle/kernel/process.cpp # src/core/hle/kernel/thread.cpp # src/core/hle/kernel/thread.h # src/core/hle/kernel/vm_manager.cpp # src/core/loader/3dsx.cpp # src/core/loader/elf.cpp # src/core/loader/ncch.cpp # src/core/memory.cpp # src/core/memory.h # src/core/memory_setup.h
This commit is contained in:
commit
775cf60729
241 changed files with 20955 additions and 2730 deletions
|
@ -3,12 +3,14 @@
|
|||
// Refer to the license.txt file included.
|
||||
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/file_sys/archive_selfncch.h"
|
||||
#include "core/file_sys/errors.h"
|
||||
#include "core/file_sys/ivfc_archive.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FileSys namespace
|
||||
|
@ -102,8 +104,7 @@ public:
|
|||
|
||||
switch (static_cast<SelfNCCHFilePathType>(file_path.type)) {
|
||||
case SelfNCCHFilePathType::UpdateRomFS:
|
||||
LOG_WARNING(Service_FS, "(STUBBED) open update RomFS");
|
||||
return OpenRomFS();
|
||||
return OpenUpdateRomFS();
|
||||
|
||||
case SelfNCCHFilePathType::RomFS:
|
||||
return OpenRomFS();
|
||||
|
@ -179,6 +180,17 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
ResultVal<std::unique_ptr<FileBackend>> OpenUpdateRomFS() const {
|
||||
if (ncch_data.update_romfs_file) {
|
||||
return MakeResult<std::unique_ptr<FileBackend>>(std::make_unique<IVFCFile>(
|
||||
ncch_data.update_romfs_file, ncch_data.update_romfs_offset,
|
||||
ncch_data.update_romfs_size));
|
||||
} else {
|
||||
LOG_INFO(Service_FS, "Unable to read update RomFS");
|
||||
return ERROR_ROMFS_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
ResultVal<std::unique_ptr<FileBackend>> OpenExeFS(const std::string& filename) const {
|
||||
if (filename == "icon") {
|
||||
if (ncch_data.icon) {
|
||||
|
@ -217,31 +229,59 @@ private:
|
|||
NCCHData ncch_data;
|
||||
};
|
||||
|
||||
ArchiveFactory_SelfNCCH::ArchiveFactory_SelfNCCH(Loader::AppLoader& app_loader) {
|
||||
void ArchiveFactory_SelfNCCH::Register(Loader::AppLoader& app_loader) {
|
||||
u64 program_id = 0;
|
||||
if (app_loader.ReadProgramId(program_id) != Loader::ResultStatus::Success) {
|
||||
LOG_WARNING(
|
||||
Service_FS,
|
||||
"Could not read program id when registering with SelfNCCH, this might be a 3dsx file");
|
||||
}
|
||||
|
||||
LOG_DEBUG(Service_FS, "Registering program %016" PRIX64 " with the SelfNCCH archive factory",
|
||||
program_id);
|
||||
|
||||
if (ncch_data.find(program_id) != ncch_data.end()) {
|
||||
LOG_WARNING(Service_FS, "Registering program %016" PRIX64
|
||||
" with SelfNCCH will override existing mapping",
|
||||
program_id);
|
||||
}
|
||||
|
||||
NCCHData& data = ncch_data[program_id];
|
||||
|
||||
std::shared_ptr<FileUtil::IOFile> romfs_file_;
|
||||
if (Loader::ResultStatus::Success ==
|
||||
app_loader.ReadRomFS(romfs_file_, ncch_data.romfs_offset, ncch_data.romfs_size)) {
|
||||
app_loader.ReadRomFS(romfs_file_, data.romfs_offset, data.romfs_size)) {
|
||||
|
||||
ncch_data.romfs_file = std::move(romfs_file_);
|
||||
data.romfs_file = std::move(romfs_file_);
|
||||
}
|
||||
|
||||
std::shared_ptr<FileUtil::IOFile> update_romfs_file;
|
||||
if (Loader::ResultStatus::Success ==
|
||||
app_loader.ReadUpdateRomFS(update_romfs_file, data.update_romfs_offset,
|
||||
data.update_romfs_size)) {
|
||||
|
||||
data.update_romfs_file = std::move(update_romfs_file);
|
||||
}
|
||||
|
||||
std::vector<u8> buffer;
|
||||
|
||||
if (Loader::ResultStatus::Success == app_loader.ReadIcon(buffer))
|
||||
ncch_data.icon = std::make_shared<std::vector<u8>>(std::move(buffer));
|
||||
data.icon = std::make_shared<std::vector<u8>>(std::move(buffer));
|
||||
|
||||
buffer.clear();
|
||||
if (Loader::ResultStatus::Success == app_loader.ReadLogo(buffer))
|
||||
ncch_data.logo = std::make_shared<std::vector<u8>>(std::move(buffer));
|
||||
data.logo = std::make_shared<std::vector<u8>>(std::move(buffer));
|
||||
|
||||
buffer.clear();
|
||||
if (Loader::ResultStatus::Success == app_loader.ReadBanner(buffer))
|
||||
ncch_data.banner = std::make_shared<std::vector<u8>>(std::move(buffer));
|
||||
data.banner = std::make_shared<std::vector<u8>>(std::move(buffer));
|
||||
}
|
||||
|
||||
ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SelfNCCH::Open(const Path& path) {
|
||||
auto archive = std::make_unique<SelfNCCHArchive>(ncch_data);
|
||||
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
|
||||
//auto archive = std::make_unique<SelfNCCHArchive>(
|
||||
// ncch_data[Kernel::g_current_process->codeset->program_id]);
|
||||
//return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
|
||||
return {};
|
||||
}
|
||||
|
||||
ResultCode ArchiveFactory_SelfNCCH::Format(const Path&, const FileSys::ArchiveFormatInfo&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue