arm64: Implement kernel thread switching.
Change-Id: I87cca66ad89cfa85ba98a9ec828c5e357d7406b2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5263 Reviewed-by: Adrien Destugues <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -10,12 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
struct arch_thread {
|
struct arch_thread {
|
||||||
uint64 x[31];
|
uint64 regs[13]; // x19-x30, sp
|
||||||
uint64 pc;
|
|
||||||
uint64 sp;
|
|
||||||
uint64 tpidr_el0;
|
|
||||||
uint64 tpidrro_el0;
|
|
||||||
int last_vfp_cpu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arch_team {
|
struct arch_team {
|
||||||
@@ -26,5 +21,4 @@ struct arch_fork_arg {
|
|||||||
int dummy;
|
int dummy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_ */
|
#endif /* _KERNEL_ARCH_ARM64_ARCH_THREAD_TYPES_H_ */
|
||||||
|
|||||||
@@ -7,6 +7,31 @@
|
|||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
|
FUNCTION(_arch_context_swap):
|
||||||
|
stp x19, x20, [x0], #16
|
||||||
|
stp x21, x22, [x0], #16
|
||||||
|
stp x23, x24, [x0], #16
|
||||||
|
stp x25, x26, [x0], #16
|
||||||
|
stp x27, x28, [x0], #16
|
||||||
|
stp x29, x30, [x0], #16
|
||||||
|
|
||||||
|
mov x2, sp
|
||||||
|
str x2, [x0]
|
||||||
|
|
||||||
|
ldp x19, x20, [x1], #16
|
||||||
|
ldp x21, x22, [x1], #16
|
||||||
|
ldp x23, x24, [x1], #16
|
||||||
|
ldp x25, x26, [x1], #16
|
||||||
|
ldp x27, x28, [x1], #16
|
||||||
|
ldp x29, x30, [x1], #16
|
||||||
|
|
||||||
|
ldr x2, [x1]
|
||||||
|
mov sp, x2
|
||||||
|
|
||||||
|
mov x0, x29
|
||||||
|
ret
|
||||||
|
FUNCTION_END(_arch_context_swap)
|
||||||
|
|
||||||
/* status_t arch_cpu_user_memcpy(void *to, const void *from, size_t size, addr_t *faultHandler) */
|
/* status_t arch_cpu_user_memcpy(void *to, const void *from, size_t size, addr_t *faultHandler) */
|
||||||
FUNCTION(_arch_cpu_user_memcpy):
|
FUNCTION(_arch_cpu_user_memcpy):
|
||||||
mov x0, xzr
|
mov x0, xzr
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ void
|
|||||||
arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop,
|
arch_thread_init_kthread_stack(Thread* thread, void* _stack, void* _stackTop,
|
||||||
void (*function)(void*), const void* data)
|
void (*function)(void*), const void* data)
|
||||||
{
|
{
|
||||||
|
memset(&thread->arch_info, 0, sizeof(arch_thread));
|
||||||
|
thread->arch_info.regs[10] = (uint64_t)data;
|
||||||
|
thread->arch_info.regs[11] = (uint64_t)function;
|
||||||
|
thread->arch_info.regs[12] = (uint64_t)_stackTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,9 +65,13 @@ arch_thread_init_tls(Thread *thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" void _arch_context_swap(arch_thread *from, arch_thread *to);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
arch_thread_context_switch(Thread *from, Thread *to)
|
arch_thread_context_switch(Thread *from, Thread *to)
|
||||||
{
|
{
|
||||||
|
_arch_context_swap(&from->arch_info, &to->arch_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user