mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2026-06-05 19:56:57 +00:00
kern: write thread handle to tls +0x110 on creation
This commit is contained in:
parent
9cc82c6f80
commit
0ee6277be9
@ -976,6 +976,9 @@ namespace ams::kern {
|
|||||||
/* Set the thread arguments. */
|
/* Set the thread arguments. */
|
||||||
main_thread->GetContext().SetArguments(0, thread_handle);
|
main_thread->GetContext().SetArguments(0, thread_handle);
|
||||||
|
|
||||||
|
/* Pass the thread handle to the thread local region. */
|
||||||
|
static_cast<ams::svc::ThreadLocalRegion *>(main_thread->GetThreadLocalRegionHeapAddress())->thread_handle = thread_handle;
|
||||||
|
|
||||||
/* Update our state. */
|
/* Update our state. */
|
||||||
this->ChangeState((state == State_Created) ? State_Running : State_RunningAttached);
|
this->ChangeState((state == State_Created) ? State_Running : State_RunningAttached);
|
||||||
ON_RESULT_FAILURE_2 { this->ChangeState(state); };
|
ON_RESULT_FAILURE_2 { this->ChangeState(state); };
|
||||||
|
|||||||
@ -66,6 +66,9 @@ namespace ams::kern::svc {
|
|||||||
/* Add the thread to the handle table. */
|
/* Add the thread to the handle table. */
|
||||||
R_TRY(process.GetHandleTable().Add(out, thread));
|
R_TRY(process.GetHandleTable().Add(out, thread));
|
||||||
|
|
||||||
|
/* Pass the thread handle to the thread local region. */
|
||||||
|
static_cast<ams::svc::ThreadLocalRegion *>(thread->GetThreadLocalRegionHeapAddress())->thread_handle = *out;
|
||||||
|
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,8 +27,9 @@ namespace ams::svc::arch::arm {
|
|||||||
volatile u16 interrupt_flag;
|
volatile u16 interrupt_flag;
|
||||||
volatile u8 cache_maintenance_flag;
|
volatile u8 cache_maintenance_flag;
|
||||||
volatile s64 thread_cpu_time;
|
volatile s64 thread_cpu_time;
|
||||||
|
volatile ams::svc::Handle thread_handle;
|
||||||
/* TODO: Should we bother adding the Nintendo aarch32 thread local context here? */
|
/* TODO: Should we bother adding the Nintendo aarch32 thread local context here? */
|
||||||
uintptr_t TODO[(0x200 - 0x110) / sizeof(uintptr_t)];
|
uintptr_t TODO[(0x200 - 0x114) / sizeof(uintptr_t)];
|
||||||
};
|
};
|
||||||
|
|
||||||
ALWAYS_INLINE ThreadLocalRegion *GetThreadLocalRegion() {
|
ALWAYS_INLINE ThreadLocalRegion *GetThreadLocalRegion() {
|
||||||
|
|||||||
@ -27,8 +27,9 @@ namespace ams::svc::arch::arm64 {
|
|||||||
volatile u16 interrupt_flag;
|
volatile u16 interrupt_flag;
|
||||||
volatile u8 cache_maintenance_flag;
|
volatile u8 cache_maintenance_flag;
|
||||||
volatile s64 thread_cpu_time;
|
volatile s64 thread_cpu_time;
|
||||||
|
volatile ams::svc::Handle thread_handle;
|
||||||
/* TODO: How should we handle libnx vs Nintendo user thread local space? */
|
/* TODO: How should we handle libnx vs Nintendo user thread local space? */
|
||||||
uintptr_t TODO[(0x200 - 0x110) / sizeof(uintptr_t)];
|
uintptr_t TODO[(0x200 - 0x114) / sizeof(uintptr_t)];
|
||||||
};
|
};
|
||||||
static_assert(__builtin_offsetof(ThreadLocalRegion, disable_count) == 0x100);
|
static_assert(__builtin_offsetof(ThreadLocalRegion, disable_count) == 0x100);
|
||||||
static_assert(__builtin_offsetof(ThreadLocalRegion, interrupt_flag) == 0x102);
|
static_assert(__builtin_offsetof(ThreadLocalRegion, interrupt_flag) == 0x102);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user