1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
$NetBSD: patch-ah,v 1.1 2002/03/14 07:44:23 jmc Exp $
--- ../ffcall/callback/trampoline_r/trampoline.c.orig Thu Mar 14 07:23:32 2002
+++ ../ffcall/callback/trampoline_r/trampoline.c Thu Mar 14 07:23:35 2002
@@ -21,12 +21,16 @@
#endif
#endif
#if defined(__rs6000__)
+#if defined(__NetBSD__)
+#define __powerpcnetbsd__
+#else
#if !defined(_AIX)
#define __rs6000sysv4__ /* SysV.4 ABI, real machine code. */
#else
#define __rs6000aix__ /* AIX ABI, just a closure. */
#endif
#endif
+#endif
#if defined(__hppanew__)
/*
* A function pointer is a biased pointer to a data area whose first word
@@ -259,7 +263,7 @@
#include <sys/syslocal.h>
#endif
/* Inline assembly function for instruction cache flush. */
-#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__rs6000sysv4__) || defined(__convex__)
+#if defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__hppaold__) || defined(__rs6000sysv4__) || defined(__convex__) || defined(__powerpcnetbsd__)
#ifdef __GNUC__
extern inline
#if defined(__sparc__) || defined(__sparc64__)
@@ -336,7 +340,7 @@
#define TRAMP_LENGTH 32
#define TRAMP_ALIGN 4
#endif
-#ifdef __rs6000sysv4__
+#if defined(__rs6000sysv4__) || defined(__powerpcnetbsd__)
#define TRAMP_LENGTH 24
#define TRAMP_ALIGN 4
#endif
@@ -872,6 +876,39 @@
#define is_tramp(function) \
*(unsigned short *) (function + 0) == 0x3D60 && \
*(unsigned short *) (function + 4) == 0x616B && \
+ *(unsigned short *) (function + 8) == 0x3C00 && \
+ *(unsigned short *) (function +12) == 0x6000 && \
+ *(unsigned long *) (function +16) == 0x7C0903A6 && \
+ *(unsigned long *) (function +20) == 0x4E800420
+#define hilo(hiword,loword) \
+ (((unsigned long) (hiword) << 16) | (unsigned long) (loword))
+#define tramp_address(function) \
+ hilo(*(unsigned short *) (function +10), *(unsigned short *) (function +14))
+#define tramp_data(function) \
+ hilo(*(unsigned short *) (function + 2), *(unsigned short *) (function + 6))
+#endif
+#ifdef __powerpcnetbsd__
+ /* function:
+ * {liu|lis} 13,hi16(<data>) 3D A0 hi16(<data>)
+ * {oril|ori} 13,13,lo16(<data>) 61 AD lo16(<data>)
+ * {liu|lis} 0,hi16(<address>) 3C 00 hi16(<address>)
+ * {oril|ori} 0,0,lo16(<address>) 60 00 lo16(<address>)
+ * mtctr 0 7C 09 03 A6
+ * bctr 4E 80 04 20
+ */
+ *(short *) (function + 0) = 0x3DA0;
+ *(short *) (function + 2) = (unsigned long) data >> 16;
+ *(short *) (function + 4) = 0x61AD;
+ *(short *) (function + 6) = (unsigned long) data & 0xffff;
+ *(short *) (function + 8) = 0x3C00;
+ *(short *) (function +10) = (unsigned long) address >> 16;
+ *(short *) (function +12) = 0x6000;
+ *(short *) (function +14) = (unsigned long) address & 0xffff;
+ *(long *) (function +16) = 0x7C0903A6;
+ *(long *) (function +20) = 0x4E800420;
+#define is_tramp(function) \
+ *(unsigned short *) (function + 0) == 0x3DA0 && \
+ *(unsigned short *) (function + 4) == 0x61AD && \
*(unsigned short *) (function + 8) == 0x3C00 && \
*(unsigned short *) (function +12) == 0x6000 && \
*(unsigned long *) (function +16) == 0x7C0903A6 && \
|