]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/l4sys/include/ARCH-x86/ipc-invoke.h
Update
[l4.git] / l4 / pkg / l4re-core / l4sys / include / ARCH-x86 / ipc-invoke.h
1 /**
2  * \internal
3  * \file
4  * \brief   L4 IPC System Call Invoking in Assembler.
5  * \ingroup l4_api
6  *
7  * This file can also be used in asm-files, so don't include C statements.
8  */
9 /*
10  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
11  *               Alexander Warg <warg@os.inf.tu-dresden.de>,
12  *               Björn Döbel <doebel@os.inf.tu-dresden.de>
13  *     economic rights: Technische Universität Dresden (Germany)
14  *
15  * This file is part of TUD:OS and distributed under the terms of the
16  * GNU General Public License 2.
17  * Please see the COPYING-GPL-2 file for details.
18  *
19  * As a special exception, you may use this file as part of a free software
20  * library without restriction.  Specifically, if other files instantiate
21  * templates or use macros or inline functions from this file, or you compile
22  * this file and link it with other files to produce an executable, this
23  * file does not by itself cause the resulting executable to be covered by
24  * the GNU General Public License.  This exception does not however
25  * invalidate any other reasons why the executable file might be covered by
26  * the GNU General Public License.
27  */
28
29 #pragma once
30
31 /*
32  * Some words about the sysenter entry frame: Since the sysenter instruction
33  * automatically reloads the instruction pointer (eip) and the stack pointer
34  * (esp) after kernel entry, we have to save both registers preliminary to
35  * that instruction. We use ecx to store the user-level esp and save eip onto
36  * the stack. The ecx register contains the IPC timeout and has to be saved
37  * onto the stack, too. The ebp register is saved for compatibility reasons
38  * with the Hazelnut kernel. Both the esp and the ss register are also pushed
39  * onto the stack to be able to return using the "lret" instruction from the
40  * sysexit trampoline page if Small Address Spaces are enabled.
41  */
42
43 #ifdef __PIC__
44 #  define L4S_PIC_SAVE "push %%ebx; "
45 #  define L4S_PIC_RESTORE "pop %%ebx; "
46 #  define L4S_PIC_CLOBBER
47 #  define L4S_PIC_SYSCALL , [func] "m" (__l4sys_invoke_indirect)
48 #if 1
49
50 #ifdef __PIC__
51 extern void (*__l4sys_invoke_indirect)(void);
52 #endif
53 #  define IPC_SYSENTER      "# indirect sys invoke \n\t" \
54                             "call *%[func]    \n\t"
55 #else
56 #  define L4S_PIC_SYSCALL
57 #  define IPC_SYSENTER      "call __l4sys_invoke_direct@plt    \n\t"
58 #endif
59 #  define IPC_SYSENTER_ASM   call __l4sys_invoke_direct@plt
60 #else
61 /**
62  * \internal
63  * \brief Kernel entry code for inline assembly.
64  */
65 #define IPC_SYSENTER      "call __l4sys_invoke_direct    \n\t"
66 /**
67  * \internal
68  * \brief Kernel entry code for assembler code.
69  */
70 #define IPC_SYSENTER_ASM   call __l4sys_invoke_direct
71 /**
72  * \internal
73  * \brief Save PIC register, if needed.
74  */
75 #  define L4S_PIC_SAVE
76 /**
77  * \internal
78  * \brief Restore PIC register, if needed.
79  */
80 #  define L4S_PIC_RESTORE
81 /**
82  * \internal
83  * \brief PIC clobber list.
84  */
85 #  define L4S_PIC_CLOBBER ,"ebx"
86 #  define L4S_PIC_SYSCALL
87
88 #endif
89 /**
90  * \internal
91  * \brief Kernel entry code for inline assembly.
92  */
93 #define L4_ENTER_KERNEL L4S_PIC_SAVE "push %%ebp; " \
94                         IPC_SYSENTER                \
95                         " pop %%ebp; " L4S_PIC_RESTORE
96