Add x86_64 task switching (to be updated to new-style scheduler).
[bertos.git] / kern / switch_x86_64.s
1 /*!
2  * \file
3  * <!--
4  * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
6  * This file is part of DevLib - See devlib/README for information.
7  * -->
8  *
9  * \brief i386 context switch
10  *
11  * \version $Id$
12  *
13  * \author Bernardo Innocenti <bernie@develer.com>
14  */
15
16 /*
17  * $Log$
18  * Revision 1.1  2005/11/27 03:06:15  bernie
19  * Add x86_64 task switching (to be updated to new-style scheduler).
20  *
21  * Revision 1.1  2005/11/14 21:06:38  bernie
22  * Add x86_64 support.
23  *
24  * Revision 1.2  2004/06/06 16:14:12  bernie
25  * Add DevLib license information.
26  *
27  * Revision 1.1  2004/05/23 17:27:00  bernie
28  * Import kern/ subdirectory.
29  *
30  */
31
32 !!!!!! THIS FILE HAS NOT BEEN REVISED FOR THE NEW SCHEDULER API !!!!!!
33
34 /* I know it's ugly... */
35 #.intel_syntax
36
37 /* void AsmSwitchContext(void * new_sp, void ** save_sp) */
38 .globl AsmSwitchContext
39 AsmSwitchContext:
40         pushq   %rax
41         pushq   %rbx
42         pushq   %rcx
43         pushq   %rdx
44         pushq   %rsi
45         pushq   %rdi
46         pushq   %rbp
47         movq    %rsp,(%rsi)             /* *save_sp = rsp */
48         movq    %rdi,%rsp               /* rsp = new_sp */
49         popq    %rbp
50         popq    %rdi
51         popq    %rsi
52         popq    %rdx
53         popq    %rcx
54         popq    %rbx
55         popq    %rax
56         ret
57
58 /* void AsmReplaceContext(void * new_sp, void ** dummy) */
59 .globl AsmReplaceContext
60 AsmReplaceContext:
61         movq    %rdi,%rsp                /* rsp = new_sp */
62         popq    %rbp
63         popq    %rdi
64         popq    %rsi
65         popq    %rdx
66         popq    %rcx
67         popq    %rbx
68         popq    %rax
69         ret
70