Kernel: Introduce skeleton Process class to hold process data
This commit is contained in:
parent
8809d02db3
commit
6d60acf0f1
13 changed files with 191 additions and 48 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue