Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / arch / i386-all / exec / execstubs.s
blobab6e7d2a6fbb4355352ebdc82fd3661a3a75d77b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Stubs to call C functions while preserving all registers
6 Lang: english
7 */
8 #include "aros/i386/asm.h"
11 Macros:
12 PUSH - Save all registers on the stack
13 POP - Restore all registers from the stack
15 STUB_ARG0(name) - Call a function preserving all registers
16 which gets no arguments
17 STUB_ARG1(name) - Call a function preserving all registers
18 which gets a single argument
19 STUB_ARG2(name) - Call a function preserving all registers
20 which gets two arguments
24 #define NUM_REGS 3
25 #define FIRST_ARG ((NUM_REGS+2)*4)
26 #define SECOND_ARG (FIRST_ARG+4)
28 #define PUSH \
29 pushl %eax ; \
30 pushl %ecx ; \
31 pushl %edx ; \
33 #define POP \
34 popl %edx ; \
35 popl %ecx ; \
36 popl %eax
38 #define STUB_ARG0(name) \
39 pushl %ebp ; \
40 movl %esp,%ebp ; \
41 PUSH ; \
42 call name ; \
43 POP ; \
44 leave ; \
45 ret
47 #define STUB_ARG1(name) \
48 pushl %ebp ; \
49 movl %esp,%ebp ; \
50 PUSH ; \
51 movl FIRST_ARG(%esp),%edx ; \
52 pushl %edx ; \
53 call name ; \
54 addl $4,%esp ; \
55 POP ; \
56 leave ; \
57 ret
59 #define STUB_ARG2(name) \
60 pushl %ebp ; \
61 movl %esp,%ebp ; \
62 PUSH ; \
63 movl SECOND_ARG(%esp),%edx ; \
64 pushl %edx ; \
65 movl SECOND_ARG(%esp),%edx ; \
66 pushl %edx ; \
67 call name ; \
68 addl $8,%esp ; \
69 POP ; \
70 leave ; \
71 ret
73 /* To save typing work */
74 #define STUB0(cname,name) \
75 .globl cname ; \
76 _FUNCTION(cname) ; \
77 cname: ; \
78 STUB_ARG0(name)
80 #define STUB1(cname,name) \
81 .globl cname ; \
82 _FUNCTION(cname) ; \
83 cname: ; \
84 STUB_ARG1(name)
87 #define STUB2(cname,name) \
88 .globl cname ; \
89 _FUNCTION(cname) ; \
90 cname: ; \
91 STUB_ARG2(name)
93 .text
94 _ALIGNMENT
96 /* Call functions and preserve registers */
97 #ifdef UseExecstubs
98 STUB0(AROS_SLIB_ENTRY(Forbid,Exec,22),AROS_CSYMNAME(_Exec_22_Forbid))
99 STUB0(AROS_SLIB_ENTRY(Permit,Exec,23),AROS_CSYMNAME(_Exec_23_Permit))
100 STUB0(AROS_SLIB_ENTRY(Disable,Exec,20),AROS_CSYMNAME(_Exec_20_Disable))
101 STUB0(AROS_SLIB_ENTRY(Enable,Exec,21),AROS_CSYMNAME(_Exec_21_Enable))
103 STUB1(AROS_SLIB_ENTRY(ObtainSemaphore,Exec,94),AROS_CSYMNAME(_Exec_94_ObtainSemaphore))
104 STUB1(AROS_SLIB_ENTRY(ReleaseSemaphore,Exec,95),AROS_CSYMNAME(_Exec_95_ReleaseSemaphore))
105 STUB1(AROS_SLIB_ENTRY(ObtainSemaphoreShared,Exec,113),AROS_CSYMNAME(_Exec_113_ObtainSemaphoreShared))
106 #endif