X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Femul%2Fswitch_x86_64.s;h=ea76d2c98ed9d1246652f3aac29f1ad2152c0f19;hb=635385b7e731d1b536a63db4d881f32603c22cfd;hp=61859834cb95f50dfa41aa219fa6c2c5b584544f;hpb=8ae4e430b21973bae9a6bc26b6fd5e08bd07c4c7;p=bertos.git diff --git a/bertos/emul/switch_x86_64.s b/bertos/emul/switch_x86_64.s index 61859834..ea76d2c9 100644 --- a/bertos/emul/switch_x86_64.s +++ b/bertos/emul/switch_x86_64.s @@ -26,45 +26,47 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2004 Develer S.r.l. (http://www.develer.com/) + * Copyright 2004, 2008 Develer S.r.l. (http://www.develer.com/) * Copyright 1999, 2000, 2001 Bernie Innocenti - * This file is part of DevLib - See devlib/README for information. * --> * - * \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. */ -/* I know it's ugly... */ -/* .intel_syntax */ - -/* void AsmSwitchContext(void **new_sp, void **save_sp) */ -/* %rdi %rsi */ +/* void asm_switch_context(void **new_sp [%rdi], void **save_sp [%rsi]) */ .globl asm_switch_context asm_switch_context: - pushq %rax - pushq %rbx - pushq %rcx - pushq %rdx - pushq %rsi - pushq %rdi pushq %rbp + pushq %rdi + pushq %rsi + pushq %rcx + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 movq %rsp,(%rsi) /* *save_sp = rsp */ movq (%rdi),%rsp /* rsp = *new_sp */ - popq %rbp - popq %rdi - popq %rsi - popq %rdx + popq %r11 + popq %r10 + popq %r9 + popq %r8 popq %rcx - popq %rbx - popq %rax - ret - -/* int asm_switch_version(void) */ -.globl asm_switch_version -asm_switch_version: - mov $1,%rax + popq %rsi + popq %rdi + popq %rbp ret -