summaryrefslogtreecommitdiffstats
path: root/src/core/loader/ncch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/loader/ncch.cpp')
-rw-r--r--src/core/loader/ncch.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 9bce2b79d..531000137 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -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;