1 | /* GStreamer |
---|
2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * 2000 Wim Taymans <wtay@chello.be> |
---|
4 | * |
---|
5 | * gstarch.h: Architecture-specific inclusions |
---|
6 | * |
---|
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. |
---|
11 | * |
---|
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. |
---|
16 | * |
---|
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. |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef __GST_GSTARCH_H__ |
---|
24 | #define __GST_GSTARCH_H__ |
---|
25 | |
---|
26 | #ifdef HAVE_CONFIG_H |
---|
27 | #include "config.h" |
---|
28 | #endif |
---|
29 | |
---|
30 | |
---|
31 | |
---|
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) ); |
---|
36 | |
---|
37 | #define GST_ARCH_CALL(target) \ |
---|
38 | __asm__("call *%0" : : "r"(target) ); |
---|
39 | |
---|
40 | /* assuming the stackframe is 16 bytes */ |
---|
41 | #define GST_ARCH_SETUP_STACK(sp) sp -= 4 |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | /***** PowerPC *****/ |
---|
46 | #elif defined (HAVE_CPU_PPC) && defined(__GNUC__) |
---|
47 | |
---|
48 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
49 | __asm__("lwz r1,%0" : : "m"(stackpointer)) |
---|
50 | |
---|
51 | #define GST_ARCH_CALL(target) \ |
---|
52 | __asm__( "mr r0,%0\n\t" \ |
---|
53 | "mtlr r0\n\t" \ |
---|
54 | "blrl" : : "r"(target) ); |
---|
55 | |
---|
56 | struct minimal_ppc_stackframe { |
---|
57 | unsigned long back_chain; |
---|
58 | unsigned long LR_save; |
---|
59 | unsigned long unused1; |
---|
60 | unsigned long unused2; |
---|
61 | }; |
---|
62 | |
---|
63 | #define GST_ARCH_SETUP_STACK(sp) \ |
---|
64 | sp = ((unsigned long *)(sp)) - 4; \ |
---|
65 | ((struct minimal_ppc_stackframe *)sp)->back_chain = 0; |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | /***** DEC[/Compaq/HP?/Intel?] Alpha *****/ |
---|
70 | #elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__) |
---|
71 | |
---|
72 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
73 | __asm__("bis $31,%0,$30" : : "r"(stackpointer)); |
---|
74 | |
---|
75 | #define GST_ARCH_CALL(target) \ |
---|
76 | __asm__( "bis $31,%0,$27\n\t" \ |
---|
77 | "jsr $26,($27),0" : : "r"(target) ); |
---|
78 | |
---|
79 | /* Need to get more information about the stackframe format |
---|
80 | * and get the fields more correct. Check GDB sources maybe? |
---|
81 | */ |
---|
82 | struct minimal_stackframe { |
---|
83 | unsigned long back_chain; |
---|
84 | unsigned long LR_save; |
---|
85 | unsigned long unused1; |
---|
86 | unsigned long unused2; |
---|
87 | }; |
---|
88 | |
---|
89 | #define GST_ARCH_SETUP_STACK(sp) \ |
---|
90 | sp = ((unsigned long *)(sp)) - 4; \ |
---|
91 | ((struct minimal_stackframe *)sp)->back_chain = 0; |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | /***** ARM *****/ |
---|
96 | #elif defined(HAVE_CPU_ARM) && defined(__GNUC__) |
---|
97 | |
---|
98 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
99 | __asm__( "mov sp, %0" : : "r"(stackpointer)); |
---|
100 | |
---|
101 | #define GST_ARCH_CALL(target) \ |
---|
102 | __asm__( "mov pc, %0" : : "r"(target) ); |
---|
103 | |
---|
104 | /* Need to get more information about the stackframe format |
---|
105 | * and get the fields more correct. Check GDB sources maybe? |
---|
106 | */ |
---|
107 | #define GST_ARCH_SETUP_STACK(sp) sp -= 4 |
---|
108 | |
---|
109 | |
---|
110 | |
---|
111 | /***** Sun SPARC *****/ |
---|
112 | #elif defined(HAVE_CPU_SPARC) && defined(__GNUC__) |
---|
113 | |
---|
114 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
115 | __asm__( "ta 3\n\t" \ |
---|
116 | "mov %0, %%sp" : : "r"(stackpointer)); |
---|
117 | |
---|
118 | #define GST_ARCH_CALL(target) \ |
---|
119 | __asm__( "call %0,0\n\t" \ |
---|
120 | "nop" : : "r"(target) ); |
---|
121 | |
---|
122 | #define GST_ARCH_PRESETJMP() \ |
---|
123 | __asm__( "ta 3" ); |
---|
124 | |
---|
125 | /* Need to get more information about the stackframe format |
---|
126 | * and get the fields more correct. Check GDB sources maybe? |
---|
127 | */ |
---|
128 | #define GST_ARCH_SETUP_STACK(sp) sp -= 4 |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | /***** MIPS *****/ |
---|
133 | #elif defined(HAVE_CPU_MIPS) && defined(__GNUC__) |
---|
134 | |
---|
135 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
136 | __asm__("lw $sp,0(%0)\n\t" : : "r"(stackpointer)); |
---|
137 | |
---|
138 | #define GST_ARCH_CALL(target) \ |
---|
139 | __asm__("lw $25,0(%0)\n\t" /* call via $25 */ \ |
---|
140 | "jal $25\n\t" : : "r"(target)); |
---|
141 | |
---|
142 | /* assuming the stackframe is 16 bytes */ |
---|
143 | #define GST_ARCH_SETUP_STACK(sp) sp -= 4 |
---|
144 | |
---|
145 | |
---|
146 | |
---|
147 | /***** HP-PA *****/ |
---|
148 | #elif defined(HAVE_CPU_HPPA) && defined(__GNUC__) |
---|
149 | |
---|
150 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
151 | __asm__("copy %0,%%sp\n\t" : : "r"(stackpointer)); |
---|
152 | |
---|
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)); |
---|
157 | |
---|
158 | /* assume stackframe is 16 bytes */ |
---|
159 | #define GST_ARCH_SETUP_STACK(sp) sp -= 4 |
---|
160 | |
---|
161 | /***** S/390 *****/ |
---|
162 | #elif defined(HAVE_CPU_S390) && defined(__GNUC__) |
---|
163 | |
---|
164 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
165 | __asm__("lr 15,%0" : : "r"(stackpointer)) |
---|
166 | |
---|
167 | #define GST_ARCH_CALL(target) \ |
---|
168 | __asm__( "basr 14,%0" : : "a"(target) ); |
---|
169 | |
---|
170 | struct minimal_s390_stackframe { |
---|
171 | unsigned long back_chain; |
---|
172 | unsigned long reserved; |
---|
173 | unsigned long greg[14]; |
---|
174 | double freg[4]; |
---|
175 | }; |
---|
176 | |
---|
177 | #define GST_ARCH_SETUP_STACK(sp) \ |
---|
178 | sp = ((unsigned long *)(sp)) - 24; \ |
---|
179 | ((struct minimal_s390_stackframe *)sp)->back_chain = 0; |
---|
180 | |
---|
181 | |
---|
182 | /***** M68K *****/ |
---|
183 | #elif defined(HAVE_CPU_M68K) && defined(__GNUC__) |
---|
184 | |
---|
185 | /* From Matthias Urlichs <smurf@smurf.noris.de> */ |
---|
186 | |
---|
187 | #define GST_ARCH_SET_SP(stackpointer) \ |
---|
188 | __asm__( "move.l %0, %%sp\n" : : "r" (stackpointer)) |
---|
189 | |
---|
190 | #define GST_ARCH_CALL(target) \ |
---|
191 | __asm__( "jbsr (%0)" : : "r" (target)) |
---|
192 | |
---|
193 | #define GST_ARCH_SETUP_STACK(sp) sp -= 4 |
---|
194 | |
---|
195 | #elif defined(HAVE_MAKECONTEXT) |
---|
196 | |
---|
197 | /* If we have makecontext(), we'll be using that. */ |
---|
198 | #define USE_MAKECONTEXT 1 |
---|
199 | |
---|
200 | #else |
---|
201 | #error Need to know about this architecture, or have a generic implementation |
---|
202 | #endif |
---|
203 | |
---|
204 | #endif /* __GST_GSTARCH_H__ */ |
---|