summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2016-09-02 14:53:42 +0200
committerbunnei <bunneidev@gmail.com>2016-09-15 23:49:30 +0200
commit05e120a4cc380db318a5ee194579053b850f14fe (patch)
tree86f0801b9b79adf9832a328bf0981433d199b0ff /src/core/hle/kernel
parentarm_dynarmic/arm_dyncom: Remove unnecessary "virtual" keyword. (diff)
downloadyuzu-05e120a4cc380db318a5ee194579053b850f14fe.tar
yuzu-05e120a4cc380db318a5ee194579053b850f14fe.tar.gz
yuzu-05e120a4cc380db318a5ee194579053b850f14fe.tar.bz2
yuzu-05e120a4cc380db318a5ee194579053b850f14fe.tar.lz
yuzu-05e120a4cc380db318a5ee194579053b850f14fe.tar.xz
yuzu-05e120a4cc380db318a5ee194579053b850f14fe.tar.zst
yuzu-05e120a4cc380db318a5ee194579053b850f14fe.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/thread.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 9dea995f4..f1e5cf3cb 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -441,6 +441,22 @@ std::tuple<u32, u32, bool> GetFreeThreadLocalSlot(std::vector<std::bitset<8>>& t
return std::make_tuple(0, 0, true);
}
+/**
+ * Resets a thread context, making it ready to be scheduled and run by the CPU
+ * @param context Thread context to reset
+ * @param stack_top Address of the top of the stack
+ * @param entry_point Address of entry point for execution
+ * @param arg User argument for thread
+ */
+static void ResetThreadContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg) {
+ memset(&context, 0, sizeof(Core::ThreadContext));
+
+ context.cpu_registers[0] = arg;
+ context.pc = entry_point;
+ context.sp = stack_top;
+ context.cpsr = USER32MODE | ((entry_point & 1) << 5); // Usermode and THUMB mode
+}
+
ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority,
u32 arg, s32 processor_id, VAddr stack_top) {
if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) {
@@ -525,7 +541,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
// TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
// to initialize the context
- Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg);
+ ResetThreadContext(thread->context, stack_top, entry_point, arg);
ready_queue.push_back(thread->current_priority, thread.get());
thread->status = THREADSTATUS_READY;