55 lines
623 B
ArmAsm
55 lines
623 B
ArmAsm
.code64
|
|
|
|
.extern THREAD_sp
|
|
//TASK_threadsp:
|
|
//.long 32
|
|
|
|
.global switch_to
|
|
.type switch_to, @function
|
|
|
|
// %rdi = (struct thread *) current thread.
|
|
// %rsi = (struct thread *) next thread.
|
|
switch_to:
|
|
pushfq
|
|
|
|
push %rax
|
|
push %rcx
|
|
push %rdx
|
|
push %rbx
|
|
pushq $0
|
|
push %rbp
|
|
push %rsi
|
|
push %rdi
|
|
push %r8
|
|
push %r9
|
|
push %r10
|
|
push %r11
|
|
push %r12
|
|
push %r13
|
|
push %r14
|
|
push %r15
|
|
|
|
movq %rsp, THREAD_sp(%rdi)
|
|
movq THREAD_sp(%rsi), %rsp
|
|
|
|
pop %r15
|
|
pop %r14
|
|
pop %r13
|
|
pop %r12
|
|
pop %r11
|
|
pop %r10
|
|
pop %r9
|
|
pop %r8
|
|
pop %rdi
|
|
pop %rsi
|
|
pop %rbp
|
|
add $8, %rsp
|
|
pop %rbx
|
|
pop %rdx
|
|
pop %rcx
|
|
pop %rax
|
|
|
|
popfq
|
|
|
|
ret
|