diff options
Diffstat (limited to 'src/core/loader/loader.cpp')
-rw-r--r-- | src/core/loader/loader.cpp | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index aca09b374..8b14edf00 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -4,19 +4,26 @@ #include <string> +#include "common/logging/log.h" #include "common/make_unique.h" #include "core/file_sys/archive_romfs.h" +#include "core/hle/kernel/process.h" +#include "core/hle/service/fs/archive.h" #include "core/loader/3dsx.h" #include "core/loader/elf.h" #include "core/loader/ncch.h" -#include "core/hle/service/fs/archive.h" -#include "core/mem_map.h" //////////////////////////////////////////////////////////////////////////////////////////////////// namespace Loader { +const std::initializer_list<Kernel::AddressMapping> default_address_mappings = { + { 0x1FF50000, 0x8000, true }, // part of DSP RAM + { 0x1FF70000, 0x8000, true }, // part of DSP RAM + { 0x1F000000, 0x600000, false }, // entire VRAM +}; + /** * Identifies the type of a bootable file * @param file open file @@ -41,19 +48,11 @@ static FileType IdentifyFile(FileUtil::IOFile& file) { /** * Guess the type of a bootable file from its extension - * @param filename String filename of bootable file + * @param extension String extension of bootable file * @return FileType of file */ -static FileType GuessFromFilename(const std::string& filename) { - if (filename.size() == 0) { - LOG_ERROR(Loader, "invalid filename %s", filename.c_str()); - return FileType::Error; - } - - size_t extension_loc = filename.find_last_of('.'); - if (extension_loc == std::string::npos) - return FileType::Unknown; - std::string extension = Common::ToLower(filename.substr(extension_loc)); +static FileType GuessFromExtension(const std::string& extension_) { + std::string extension = Common::ToLower(extension_); if (extension == ".elf") return FileType::ELF; @@ -63,8 +62,6 @@ static FileType GuessFromFilename(const std::string& filename) { return FileType::CXI; else if (extension == ".cci") return FileType::CCI; - else if (extension == ".bin") - return FileType::BIN; else if (extension == ".3ds") return FileType::CCI; else if (extension == ".3dsx") @@ -82,8 +79,6 @@ static const char* GetFileTypeString(FileType type) { return "ELF"; case FileType::THREEDSX: return "3DSX"; - case FileType::BIN: - return "raw"; case FileType::Error: case FileType::Unknown: break; @@ -99,8 +94,11 @@ ResultStatus LoadFile(const std::string& filename) { return ResultStatus::Error; } + std::string filename_filename, filename_extension; + Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension); + FileType type = IdentifyFile(*file); - FileType filename_type = GuessFromFilename(filename); + FileType filename_type = GuessFromExtension(filename_extension); if (type != filename_type) { LOG_WARNING(Loader, "File %s has a different type than its extension.", filename.c_str()); @@ -114,11 +112,11 @@ ResultStatus LoadFile(const std::string& filename) { //3DSX file format... case FileType::THREEDSX: - return AppLoader_THREEDSX(std::move(file)).Load(); + return AppLoader_THREEDSX(std::move(file), filename_filename).Load(); // Standard ELF file format... case FileType::ELF: - return AppLoader_ELF(std::move(file)).Load(); + return AppLoader_ELF(std::move(file), filename_filename).Load(); // NCCH/NCSD container formats... case FileType::CXI: @@ -128,24 +126,12 @@ ResultStatus LoadFile(const std::string& filename) { // Load application and RomFS if (ResultStatus::Success == app_loader.Load()) { - Kernel::g_program_id = app_loader.GetProgramId(); Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); return ResultStatus::Success; } break; } - // Raw BIN file format... - case FileType::BIN: - { - size_t size = (size_t)file->GetSize(); - if (file->ReadBytes(Memory::GetPointer(Memory::EXEFS_CODE_VADDR), size) != size) - return ResultStatus::Error; - - Kernel::LoadExec(Memory::EXEFS_CODE_VADDR); - return ResultStatus::Success; - } - // Error occurred durring IdentifyFile... case FileType::Error: |