summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/arm/arm_interface.h3
-rw-r--r--src/core/arm/dyncom/arm_dyncom.cpp5
-rw-r--r--src/core/arm/dyncom/arm_dyncom.h2
-rw-r--r--src/core/core.h2
-rw-r--r--src/core/hle/kernel/thread.cpp7
-rw-r--r--src/core/hle/kernel/thread.h2
6 files changed, 10 insertions, 11 deletions
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 976c339e8..85ed2c698 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -99,9 +99,8 @@ public:
99 * @param stack_top Pointer to the top of the stack 99 * @param stack_top Pointer to the top of the stack
100 * @param entry_point Entry point for execution 100 * @param entry_point Entry point for execution
101 * @param arg User argument for thread 101 * @param arg User argument for thread
102 * @param tls_address Address of the Thread Local Storage for the thread
103 */ 102 */
104 virtual void ResetContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg, u32 tls_address) = 0; 103 virtual void ResetContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg) = 0;
105 104
106 /** 105 /**
107 * Saves the current CPU context 106 * Saves the current CPU context
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp
index 1de1d2612..0072ae533 100644
--- a/src/core/arm/dyncom/arm_dyncom.cpp
+++ b/src/core/arm/dyncom/arm_dyncom.cpp
@@ -90,14 +90,13 @@ void ARM_DynCom::ExecuteInstructions(int num_instructions) {
90 AddTicks(ticks_executed); 90 AddTicks(ticks_executed);
91} 91}
92 92
93void ARM_DynCom::ResetContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg, u32 tls_address) { 93void ARM_DynCom::ResetContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg) {
94 memset(&context, 0, sizeof(Core::ThreadContext)); 94 memset(&context, 0, sizeof(Core::ThreadContext));
95 95
96 context.cpu_registers[0] = arg; 96 context.cpu_registers[0] = arg;
97 context.pc = entry_point; 97 context.pc = entry_point;
98 context.sp = stack_top; 98 context.sp = stack_top;
99 context.cpsr = 0x1F; // Usermode 99 context.cpsr = 0x1F; // Usermode
100 context.tls = tls_address;
101} 100}
102 101
103void ARM_DynCom::SaveContext(Core::ThreadContext& ctx) { 102void ARM_DynCom::SaveContext(Core::ThreadContext& ctx) {
@@ -124,8 +123,6 @@ void ARM_DynCom::LoadContext(const Core::ThreadContext& ctx) {
124 123
125 state->VFP[1] = ctx.fpscr; 124 state->VFP[1] = ctx.fpscr;
126 state->VFP[2] = ctx.fpexc; 125 state->VFP[2] = ctx.fpexc;
127
128 SetCP15Register(CP15_THREAD_URO, ctx.tls);
129} 126}
130 127
131void ARM_DynCom::PrepareReschedule() { 128void ARM_DynCom::PrepareReschedule() {
diff --git a/src/core/arm/dyncom/arm_dyncom.h b/src/core/arm/dyncom/arm_dyncom.h
index b3fd708f1..2488c879c 100644
--- a/src/core/arm/dyncom/arm_dyncom.h
+++ b/src/core/arm/dyncom/arm_dyncom.h
@@ -27,7 +27,7 @@ public:
27 27
28 void AddTicks(u64 ticks) override; 28 void AddTicks(u64 ticks) override;
29 29
30 void ResetContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg, u32 tls_address) override; 30 void ResetContext(Core::ThreadContext& context, u32 stack_top, u32 entry_point, u32 arg) override;
31 void SaveContext(Core::ThreadContext& ctx) override; 31 void SaveContext(Core::ThreadContext& ctx) override;
32 void LoadContext(const Core::ThreadContext& ctx) override; 32 void LoadContext(const Core::ThreadContext& ctx) override;
33 33
diff --git a/src/core/core.h b/src/core/core.h
index 215b5a49f..278f0f1cc 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -21,8 +21,6 @@ struct ThreadContext {
21 u32 fpu_registers[32]; 21 u32 fpu_registers[32];
22 u32 fpscr; 22 u32 fpscr;
23 u32 fpexc; 23 u32 fpexc;
24
25 u32 tls;
26}; 24};
27 25
28extern ARM_Interface* g_app_core; ///< ARM11 application core 26extern ARM_Interface* g_app_core; ///< ARM11 application core
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 61199c12a..5de8f9a73 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -197,6 +197,7 @@ static void SwitchContext(Thread* new_thread) {
197 new_thread->current_priority = new_thread->nominal_priority; 197 new_thread->current_priority = new_thread->nominal_priority;
198 198
199 Core::g_app_core->LoadContext(new_thread->context); 199 Core::g_app_core->LoadContext(new_thread->context);
200 Core::g_app_core->SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
200 } else { 201 } else {
201 current_thread = nullptr; 202 current_thread = nullptr;
202 } 203 }
@@ -406,9 +407,11 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
406 407
407 ASSERT_MSG(tls_address < Memory::TLS_AREA_VADDR_END, "Too many threads"); 408 ASSERT_MSG(tls_address < Memory::TLS_AREA_VADDR_END, "Too many threads");
408 409
410 thread->tls_address = tls_address;
411
409 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used 412 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
410 // to initialize the context 413 // to initialize the context
411 Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg, tls_address); 414 Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg);
412 415
413 ready_queue.push_back(thread->current_priority, thread.get()); 416 ready_queue.push_back(thread->current_priority, thread.get());
414 thread->status = THREADSTATUS_READY; 417 thread->status = THREADSTATUS_READY;
@@ -500,7 +503,7 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
500} 503}
501 504
502VAddr Thread::GetTLSAddress() const { 505VAddr Thread::GetTLSAddress() const {
503 return context.tls; 506 return tls_address;
504} 507}
505 508
506//////////////////////////////////////////////////////////////////////////////////////////////////// 509////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 17bb69f45..6891c8c2f 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -156,6 +156,8 @@ public:
156 156
157 s32 processor_id; 157 s32 processor_id;
158 158
159 VAddr tls_address; ///< Address of the Thread Local Storage of the thread
160
159 /// Mutexes currently held by this thread, which will be released when it exits. 161 /// Mutexes currently held by this thread, which will be released when it exits.
160 boost::container::flat_set<SharedPtr<Mutex>> held_mutexes; 162 boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
161 163