ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/sigregs.h
Revision: 1.3
Committed: 2009-02-11T19:22:16Z (15 years, 8 months ago) by asvitkine
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +23 -13 lines
Log Message:
[Patch from Mike Sliczniak]

This first patch gets B2 and SS to build under Leopard and Tiger.

I tested this on a 32-bit intel 10.5.6 mac like so:

B2
./autogen.sh --disable-standalone-gui --enable-vosf --enable-sdl-video --enable-sdl-audio --enable-addressing=real --without-esd --without-gtk --without-mon --without-x

SS
./autogen.sh --disable-standalone-gui --enable-vosf -enable-sdl-video --disable-sdl-audio --enable-addressing=real --without-esd --without-gtk --without-mon --without-x --enable-jit

There is also a little tweak so that you can use sdl audio in SheepShaver when building for Mac OS X.

File Contents

# Content
1 /*
2 * sigregs.h - Extract machine registers from a signal frame
3 *
4 * SheepShaver (C) 1997-2008 Christian Bauer and Marc Hellwig
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef SIGREGS_H
22 #define SIGREGS_H
23
24 #ifndef EMULATED_PPC
25
26 // Common representation of machine registers
27 struct sigregs {
28 uint32 nip;
29 uint32 link;
30 uint32 ctr;
31 uint32 msr;
32 uint32 xer;
33 uint32 ccr;
34 uint32 gpr[32];
35 };
36
37 // Extract machine registers from Linux signal frame
38 #if defined(__linux__)
39 #include <sys/ucontext.h>
40 #define MACHINE_REGISTERS(scp) ((machine_regs *)(((ucontext_t *)scp)->uc_mcontext.regs))
41
42 struct machine_regs : public pt_regs
43 {
44 u_long & cr() { return pt_regs::ccr; }
45 uint32 cr() const { return pt_regs::ccr; }
46 uint32 lr() const { return pt_regs::link; }
47 uint32 ctr() const { return pt_regs::ctr; }
48 uint32 xer() const { return pt_regs::xer; }
49 uint32 msr() const { return pt_regs::msr; }
50 uint32 dar() const { return pt_regs::dar; }
51 u_long & pc() { return pt_regs::nip; }
52 uint32 pc() const { return pt_regs::nip; }
53 u_long & gpr(int i) { return pt_regs::gpr[i]; }
54 uint32 gpr(int i) const { return pt_regs::gpr[i]; }
55 };
56 #endif
57
58 // Extract machine registers from NetBSD signal frame
59 #if defined(__NetBSD__)
60 #include <sys/ucontext.h>
61 #define MACHINE_REGISTERS(scp) ((machine_regs *)&(((ucontext_t *)scp)->uc_mcontext))
62
63 struct machine_regs : public mcontext_t
64 {
65 long & cr() { return __gregs[_REG_CR]; }
66 uint32 cr() const { return __gregs[_REG_CR]; }
67 uint32 lr() const { return __gregs[_REG_LR]; }
68 uint32 ctr() const { return __gregs[_REG_CTR]; }
69 uint32 xer() const { return __gregs[_REG_XER]; }
70 uint32 msr() const { return __gregs[_REG_MSR]; }
71 uint32 dar() const { return (uint32)(((siginfo_t *)(((unsigned long)this) - offsetof(ucontext_t, uc_mcontext))) - 1)->si_addr; } /* HACK */
72 long & pc() { return __gregs[_REG_PC]; }
73 uint32 pc() const { return __gregs[_REG_PC]; }
74 long & gpr(int i) { return __gregs[_REG_R0 + i]; }
75 uint32 gpr(int i) const { return __gregs[_REG_R0 + i]; }
76 };
77 #endif
78
79 // Extract machine registers from Darwin signal frame
80 #if defined(__APPLE__) && defined(__MACH__)
81 #include <sys/signal.h>
82
83 #define MACHINE_REGISTERS(scp) ((machine_regs *)(((ucontext_t *)scp)->uc_mcontext))
84
85 #if __DARWIN_UNIX03
86 #define __(x) __CONCAT(__,x)
87 #else
88 #define __(x) x
89 #endif
90
91 #include <sys/ucontext.h>
92
93 #if __DARWIN_UNIX03
94 struct machine_regs : public __darwin_mcontext
95 #else
96 struct machine_regs : public mcontext
97 #endif
98 {
99 uint32 & cr() { return __(ss).__(cr); }
100 uint32 cr() const { return __(ss).__(cr); }
101 uint32 lr() const { return __(ss).__(lr); }
102 uint32 ctr() const { return __(ss).__(ctr); }
103 uint32 xer() const { return __(ss).__(xer); }
104 uint32 msr() const { return __(ss).__(srr1); }
105 uint32 dar() const { return __(es).__(dar); }
106 uint32 & pc() { return __(ss).__(srr0); }
107 uint32 pc() const { return __(ss).__(srr0); }
108 uint32 & gpr(int i) { return (&__(ss).__(r0))[i]; }
109 uint32 gpr(int i) const { return (&__(ss).__(r0))[i]; }
110 };
111 #endif
112
113 // Convert system-dependent machine registers to generic sigregs
114 static void build_sigregs(sigregs *srp, machine_regs *mrp)
115 {
116 srp->nip = mrp->pc();
117 srp->link = mrp->lr();
118 srp->ctr = mrp->ctr();
119 srp->msr = mrp->msr();
120 srp->xer = mrp->xer();
121 srp->ccr = mrp->cr();
122 for (int i = 0; i < 32; i++)
123 srp->gpr[i] = mrp->gpr(i);
124 }
125
126 #endif
127
128 #endif /* SIGREGS_H */