kernel/arm: store current thread pointer in TPIDRPRW register

Use the Privileged Only Thread ID Register aka TPIDRPRW to store
the current thread pointer.

The Privileged Only Thread ID Register is only accessible
in privileged modes, and is read/write.

see: ARMv7 Architecture Reference Manual,
section B3.12.46 CP15 c13 Software Thread ID registers

Change-Id: I5273bee8a80b78cdc547b2f6c96632d120eb3d55
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5608
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
David Karoly
2022-09-02 16:23:53 +00:00
committed by waddlesplash
parent 2eab9be564
commit c0a7601219
2 changed files with 7 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2006, Haiku Inc. All rights reserved.
* Copyright 2003-2022, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -20,20 +20,22 @@ void arm_push_iframe(struct iframe_stack *stack, struct iframe *frame);
void arm_pop_iframe(struct iframe_stack *stack);
struct iframe *arm_get_user_iframe(void);
/* TODO fix this global once we support SMP ARM... */
extern Thread *gCurrentThread;
extern inline Thread *
arch_thread_get_current_thread(void)
{
return gCurrentThread;
// read pointer to thread data structure from TPIDRPRW
Thread* t;
asm volatile("MRC p15, 0, %0, c13, c0, 4" : "=r" (t));
return t;
}
extern inline void
arch_thread_set_current_thread(Thread *t)
{
gCurrentThread = t;
// set TPIDRPRW to point to thread data structure
asm volatile("MCR p15, 0, %0, c13, c0, 4" : : "r" (t));
}
#ifdef __cplusplus
@@ -43,8 +43,6 @@
// a new thread structure.
static struct arch_thread sInitialState;
Thread *gCurrentThread;
void
arm_push_iframe(struct iframe_stack *stack, struct iframe *frame)