]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/ARCH-x86/ipc-invoke.h
5e7b1b3e422a6829aa6321840a5d8b9cf069dfb4
[l4.git] / l4 / pkg / 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 Technische Universität Dresden
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU General Public License 2.
13  * Please see the COPYING-GPL-2 file for details.
14  *
15  * As a special exception, you may use this file as part of a free software
16  * library without restriction.  Specifically, if other files instantiate
17  * templates or use macros or inline functions from this file, or you compile
18  * this file and link it with other files to produce an executable, this
19  * file does not by itself cause the resulting executable to be covered by
20  * the GNU General Public License.  This exception does not however
21  * invalidate any other reasons why the executable file might be covered by
22  * the GNU General Public License.
23  */
24
25 #pragma once
26
27 /*
28  * Some words about the sysenter entry frame: Since the sysenter instruction
29  * automatically reloads the instruction pointer (eip) and the stack pointer
30  * (esp) after kernel entry, we have to save both registers preliminary to
31  * that instruction. We use ecx to store the user-level esp and save eip onto
32  * the stack. The ecx register contains the IPC timeout and has to be saved
33  * onto the stack, too. The ebp register is saved for compatibility reasons
34  * with the Hazelnut kernel. Both the esp and the ss register are also pushed
35  * onto the stack to be able to return using the "lret" instruction from the
36  * sysexit trampoline page if Small Address Spaces are enabled.
37  */
38
39 #ifdef __PIC__
40 #  define L4S_PIC_SAVE "push %%ebx; "
41 #  define L4S_PIC_RESTORE "pop %%ebx; "
42 #  define L4S_PIC_CLOBBER
43 #  define IPC_SYSENTER      "# indirect sys invoke \n\t" \
44                             "call *__l4sys_invoke_indirect@GOTOFF(%%ebx)    \n\t"
45 //#  define IPC_SYSENTER      "call __l4sys_invoke_direct@plt    \n\t"
46 #  define IPC_SYSENTER_ASM   call __l4sys_invoke_direct@plt
47 #else
48 /**
49  * \internal
50  * \brief Kernel entry code for inline assembly.
51  */
52 #define IPC_SYSENTER      "call __l4sys_invoke_direct    \n\t"
53 /**
54  * \internal
55  * \brief Kernel entry code for assembler code.
56  */
57 #define IPC_SYSENTER_ASM   call __l4sys_invoke_direct
58 /**
59  * \internal
60  * \brief Save PIC register, if needed.
61  */
62 #  define L4S_PIC_SAVE
63 /**
64  * \internal
65  * \brief Restore PIC register, if needed.
66  */
67 #  define L4S_PIC_RESTORE
68 /**
69  * \internal
70  * \brief PIC clobber list.
71  */
72 #  define L4S_PIC_CLOBBER ,"ebx"
73 #endif
74 /**
75  * \internal
76  * \brief Kernel entry code for inline assembly.
77  */
78 #define L4_ENTER_KERNEL L4S_PIC_SAVE "push %%ebp; " \
79                         IPC_SYSENTER                \
80                         " pop %%ebp; " L4S_PIC_RESTORE
81