Kernel: Introduce skeleton Process class to hold process data

This commit is contained in:
Yuri Kunde Schlesner 2015-05-04 00:01:16 -03:00
parent 8809d02db3
commit 6d60acf0f1
13 changed files with 191 additions and 48 deletions

View file

@ -5,9 +5,12 @@
#include <memory>
#include "common/logging/log.h"
#include "common/make_unique.h"
#include "common/string_util.h"
#include "common/swap.h"
#include "core/loader/ncch.h"
#include "core/hle/kernel/kernel.h"
#include "core/loader/ncch.h"
#include "core/mem_map.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -117,8 +120,21 @@ ResultStatus AppLoader_NCCH::LoadExec() const {
std::vector<u8> code;
if (ResultStatus::Success == ReadCode(code)) {
std::string process_name = Common::StringFromFixedZeroTerminatedBuffer(
(const char*)exheader_header.codeset_info.name, 8);
u64 program_id = *reinterpret_cast<u64_le const*>(&ncch_header.program_id[0]);
Kernel::g_current_process = Kernel::Process::Create(process_name, program_id);
// Copy data while converting endianess
std::array<u32, ARRAY_SIZE(exheader_header.arm11_kernel_caps.descriptors)> kernel_caps;
std::copy_n(exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), begin(kernel_caps));
Kernel::g_current_process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size());
Memory::WriteBlock(entry_point, &code[0], code.size());
Kernel::LoadExec(entry_point);
s32 priority = exheader_header.arm11_system_local_caps.priority;
u32 stack_size = exheader_header.codeset_info.stack_size;
Kernel::g_current_process->Run(entry_point, priority, stack_size);
return ResultStatus::Success;
}
return ResultStatus::Error;