1/* 2 * Trap Handlers 3 */ 4 5#include <machine/asm.h> 6 7.text 8 9# switch(uint64_t *oldsp, uint64_t newsp) 10# %rdi: oldsp 11# %rsi: newsp 12FUNC_BEGIN(switchstack) 13 # Save callee saved registers of old thread 14 pushq %rbp 15 pushq %rdi 16 pushq %rbx 17 pushq %r12 18 pushq %r13 19 pushq %r14 20 pushq %r15 21 22 # Switch stack from old to new thread 23 movq %rsp, (%rdi) 24 movq %rsi, %rsp 25 26 # Restore callee saved registers of new thread 27 popq %r15 28 popq %r14 29 popq %r13 30 popq %r12 31 popq %rbx 32 popq %rdi 33 popq %rbp 34 ret 35FUNC_END(switchstack) 36 37