summaryrefslogtreecommitdiffstats
path: root/src/core/loader/loader.cpp
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2015-05-04 05:01:16 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2015-05-09 03:11:02 +0200
commit6d60acf0f1afcae873988da5218f2f1c7bc9d151 (patch)
treecec75198ab74759002dd1da78f6ac2af5e61949f /src/core/loader/loader.cpp
parentCommon: Add StringFromFixedZeroTerminatedBuffer (diff)
downloadyuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.gz
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.bz2
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.lz
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.xz
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.tar.zst
yuzu-6d60acf0f1afcae873988da5218f2f1c7bc9d151.zip
Diffstat (limited to '')
-rw-r--r--src/core/loader/loader.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index de0ab540a..97525fbeb 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -8,16 +8,23 @@
#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::StaticAddressMapping> 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
@@ -42,19 +49,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;
@@ -100,8 +99,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());
@@ -115,11 +117,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:
@@ -139,11 +141,14 @@ ResultStatus LoadFile(const std::string& filename) {
// Raw BIN file format...
case FileType::BIN:
{
+ Kernel::g_current_process = Kernel::Process::Create(filename_filename, 0);
+ Kernel::g_current_process->static_address_mappings = default_address_mappings;
+
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);
+ Kernel::g_current_process->Run(Memory::EXEFS_CODE_VADDR, 0x30, Kernel::DEFAULT_STACK_SIZE);
return ResultStatus::Success;
}