2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstarch.h: Architecture-specific inclusions
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef __GST_GSTARCH_H__
24 #define __GST_GSTARCH_H__
32 /***** Intel x86 *****/
33 #if defined(HAVE_CPU_I386) && defined(__GNUC__)
34 #define GST_ARCH_SET_SP(stackpointer) \
35 __asm__( "movl %0, %%esp\n" : : "r"(stackpointer) );
37 #define GST_ARCH_CALL(target) \
38 __asm__("call *%0" : : "r"(target) );
40 /* assuming the stackframe is 16 bytes */
41 #define GST_ARCH_SETUP_STACK(sp) sp -= 4
46 #elif defined (HAVE_CPU_PPC) && defined(__GNUC__)
48 #define GST_ARCH_SET_SP(stackpointer) \
49 __asm__("lwz r1,%0" : : "m"(stackpointer))
51 #define GST_ARCH_CALL(target) \
52 __asm__( "mr r0,%0\n\t" \
54 "blrl" : : "r"(target) );
56 struct minimal_ppc_stackframe {
57 unsigned long back_chain;
58 unsigned long LR_save;
59 unsigned long unused1;
60 unsigned long unused2;
63 #define GST_ARCH_SETUP_STACK(sp) \
64 sp = ((unsigned long *)(sp)) - 4; \
65 ((struct minimal_ppc_stackframe *)sp)->back_chain = 0;
69 /***** DEC[/Compaq/HP?/Intel?] Alpha *****/
70 #elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__)
72 #define GST_ARCH_SET_SP(stackpointer) \
73 __asm__("bis $31,%0,$30" : : "r"(stackpointer));
75 #define GST_ARCH_CALL(target) \
76 __asm__( "bis $31,%0,$27\n\t" \
77 "jsr $26,($27),0" : : "r"(target) );
79 /* Need to get more information about the stackframe format
80 * and get the fields more correct. Check GDB sources maybe?
82 struct minimal_stackframe {
83 unsigned long back_chain;
84 unsigned long LR_save;
85 unsigned long unused1;
86 unsigned long unused2;
89 #define GST_ARCH_SETUP_STACK(sp) \
90 sp = ((unsigned long *)(sp)) - 4; \
91 ((struct minimal_stackframe *)sp)->back_chain = 0;
96 #elif defined(HAVE_CPU_ARM) && defined(__GNUC__)
98 #define GST_ARCH_SET_SP(stackpointer) \
99 __asm__( "mov sp, %0" : : "r"(stackpointer));
101 #define GST_ARCH_CALL(target) \
102 __asm__( "mov pc, %0" : : "r"(target) );
104 /* Need to get more information about the stackframe format
105 * and get the fields more correct. Check GDB sources maybe?
107 #define GST_ARCH_SETUP_STACK(sp) sp -= 4
111 /***** Sun SPARC *****/
112 #elif defined(HAVE_CPU_SPARC) && defined(__GNUC__)
114 #define GST_ARCH_SET_SP(stackpointer) \
115 __asm__( "ta 3\n\t" \
116 "mov %0, %%sp" : : "r"(stackpointer));
118 #define GST_ARCH_CALL(target) \
119 __asm__( "call %0,0\n\t" \
120 "nop" : : "r"(target) );
122 #define GST_ARCH_PRESETJMP() \
125 /* Need to get more information about the stackframe format
126 * and get the fields more correct. Check GDB sources maybe?
128 #define GST_ARCH_SETUP_STACK(sp) sp -= 4
133 #elif defined(HAVE_CPU_MIPS) && defined(__GNUC__)
135 #define GST_ARCH_SET_SP(stackpointer) \
136 __asm__("lw $sp,0(%0)\n\t" : : "r"(stackpointer));
138 #define GST_ARCH_CALL(target) \
139 __asm__("lw $25,0(%0)\n\t" /* call via $25 */ \
140 "jal $25\n\t" : : "r"(target));
142 /* assuming the stackframe is 16 bytes */
143 #define GST_ARCH_SETUP_STACK(sp) sp -= 4
148 #elif defined(HAVE_CPU_HPPA) && defined(__GNUC__)
150 #define GST_ARCH_SET_SP(stackpointer) \
151 __asm__("copy %0,%%sp\n\t" : : "r"(stackpointer));
153 #define GST_ARCH_CALL(target) \
154 __asm__("copy %0,%%r22\n\t" /* set call address */ \
155 ".CALL\n\t" /* call pseudo insn (why?) */ \
156 "bl $$dyncall,%%r31\n\t" : : "r"(target));
158 /* assume stackframe is 16 bytes */
159 #define GST_ARCH_SETUP_STACK(sp) sp -= 4
162 #elif defined(HAVE_CPU_S390) && defined(__GNUC__)
164 #define GST_ARCH_SET_SP(stackpointer) \
165 __asm__("lr 15,%0" : : "r"(stackpointer))
167 #define GST_ARCH_CALL(target) \
168 __asm__( "basr 14,%0" : : "a"(target) );
170 struct minimal_s390_stackframe {
171 unsigned long back_chain;
172 unsigned long reserved;
173 unsigned long greg[14];
177 #define GST_ARCH_SETUP_STACK(sp) \
178 sp = ((unsigned long *)(sp)) - 24; \
179 ((struct minimal_s390_stackframe *)sp)->back_chain = 0;
183 #elif defined(HAVE_CPU_M68K) && defined(__GNUC__)
185 /* From Matthias Urlichs <smurf@smurf.noris.de> */
187 #define GST_ARCH_SET_SP(stackpointer) \
188 __asm__( "move.l %0, %%sp\n" : : "r" (stackpointer))
190 #define GST_ARCH_CALL(target) \
191 __asm__( "jbsr (%0)" : : "r" (target))
193 #define GST_ARCH_SETUP_STACK(sp) sp -= 4
195 #elif defined(HAVE_MAKECONTEXT)
197 /* If we have makecontext(), we'll be using that. */
198 #define USE_MAKECONTEXT 1
201 #error Need to know about this architecture, or have a generic implementation
204 #endif /* __GST_GSTARCH_H__ */