metal-cos/sys/amd64/switch.S
2014-07-23 18:07:07 -07:00

35 lines
490 B
ArmAsm

/*
* Trap Handlers
*/
#include <machine/asm.h>
.text
# switch(uint64_t *oldsp, uint64_t newsp)
# %rdi: oldsp
# %rsi: newsp
FUNC_BEGIN(switchstack)
pushq %rbp
pushq %rdi
pushq %rbx
pushq %r12
pushq %r13
pushq %r14
pushq %r15
# Switch stack
movq %rsp, (%rdi)
movq %rsi, %rsp
popq %r15
popq %r14
popq %r13
popq %r12
popq %rbx
popq %rdi
popq %rbp
ret
FUNC_END(switchstack)