X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Femul%2Fswitch_x86_64.s;h=ea76d2c98ed9d1246652f3aac29f1ad2152c0f19;hb=fb5863ca8d0db3ff2e84721f7c902b031157ebb0;hp=de0f8f65ad4315cb77974ddf67718233fed2c8de;hpb=32d1445272120a254d77ce8d1af1f527da7a2c17;p=bertos.git diff --git a/bertos/emul/switch_x86_64.s b/bertos/emul/switch_x86_64.s index de0f8f65..ea76d2c9 100644 --- a/bertos/emul/switch_x86_64.s +++ b/bertos/emul/switch_x86_64.s @@ -30,10 +30,22 @@ * Copyright 1999, 2000, 2001 Bernie Innocenti * --> * - * \version $Id$ * \author Bernie Innocenti * - * \brief i386 context switch + * \brief x86_64 context switch + * + * x86_64 function call convention: + * -------------------------------- + * arguments | callee-saved | extra caller-saved | return + * [callee-clobbered] | | [callee-clobbered] | + * ------------------------------------------------------------------------- + * rdi rsi rdx rcx r8-9 | rbx rbp [*] r12-15 | r10-11 | rax, rdx + * + * [*] In the frame-pointers case rbp must hold a base address for the + * current stack frame. + * + * asm_switch_context() can be considered as a normal function call, so we need + * to save all the callee-clobbered registers minus the return registers. */ /* void asm_switch_context(void **new_sp [%rdi], void **save_sp [%rsi]) */ @@ -42,7 +54,7 @@ asm_switch_context: pushq %rbp pushq %rdi pushq %rsi - pushq %rbx + pushq %rcx pushq %r8 pushq %r9 pushq %r10 @@ -53,7 +65,7 @@ asm_switch_context: popq %r10 popq %r9 popq %r8 - popq %rbx + popq %rcx popq %rsi popq %rdi popq %rbp