summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@nokia.com>2009-11-10 20:30:48 +0200
committerTiago Vignatti <tiago.vignatti@nokia.com>2009-11-10 21:32:52 +0200
commit743b308cd426a27da66ba181481a1bcd3e043ee8 (patch)
treeabfa18f675634ba422c2078dc98ecd7e324c6d4c
parentfd3b986d2e819293f6288a243259f2fdc831b394 (diff)
code rebased again
yeah, I know is not the best way to do it... also debian package system was removed. Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
-rw-r--r--.gitignore59
-rw-r--r--AUTHORS (renamed from build-stamp)0
-rw-r--r--ChangeLog (renamed from configure-stamp)0
-rw-r--r--NEWS (renamed from debian/docs)0
-rw-r--r--README0
-rw-r--r--configure.ac2
-rw-r--r--debian/changelog6
-rw-r--r--debian/compat1
-rw-r--r--debian/control24
-rw-r--r--debian/copyright59
-rw-r--r--debian/dirs2
-rw-r--r--debian/files2
-rw-r--r--debian/libx86-1.dirs1
-rw-r--r--debian/libx86-1.install1
-rw-r--r--debian/libx86-1.postinst.debhelper5
-rw-r--r--debian/libx86-1.postrm.debhelper5
-rw-r--r--debian/libx86-1.substvars1
-rw-r--r--debian/libx86-1/DEBIAN/control12
-rw-r--r--debian/libx86-1/DEBIAN/md5sums3
-rwxr-xr-xdebian/libx86-1/DEBIAN/postinst7
-rwxr-xr-xdebian/libx86-1/DEBIAN/postrm7
-rw-r--r--debian/libx86-1/DEBIAN/shlibs1
-rw-r--r--debian/libx86-1/usr/lib/libx86.so.1bin7628 -> 0 bytes
-rw-r--r--debian/libx86-1/usr/share/doc/libx86-1/changelog.Debian.gzbin161 -> 0 bytes
-rw-r--r--debian/libx86-1/usr/share/doc/libx86-1/copyright59
-rw-r--r--debian/libx86-dev.dirs2
-rw-r--r--debian/libx86-dev.install3
-rw-r--r--debian/libx86-dev/DEBIAN/control14
-rw-r--r--debian/libx86-dev/DEBIAN/md5sums4
-rw-r--r--debian/libx86-dev/usr/include/libx86.h100
-rw-r--r--debian/libx86-dev/usr/lib/libx86.abin8032 -> 0 bytes
l---------debian/libx86-dev/usr/lib/libx86.so1
-rw-r--r--debian/libx86-dev/usr/share/doc/libx86-dev/changelog.Debian.gzbin161 -> 0 bytes
-rw-r--r--debian/libx86-dev/usr/share/doc/libx86-dev/copyright59
-rwxr-xr-xdebian/rules108
-rwxr-xr-xdebian/tmp/usr/include/libx86.h100
-rwxr-xr-xdebian/tmp/usr/lib/libx86.abin8080 -> 0 bytes
l---------debian/tmp/usr/lib/libx86.so1
-rwxr-xr-xdebian/tmp/usr/lib/libx86.so.1bin11401 -> 0 bytes
-rw-r--r--include/libx86.h12
-rw-r--r--src/Makefile.am19
-rw-r--r--src/lrmi/Makefile.am18
-rw-r--r--src/lrmi/backend-vm86.c219
-rw-r--r--src/lrmi/backend-x86emu.c (renamed from src/thunk.c)4
-rw-r--r--src/lrmi/common.c (renamed from src/x86-common.c)154
-rw-r--r--src/lrmi/common.h (renamed from src/x86-common.h)0
-rw-r--r--src/vm86/Makefile.am3
-rw-r--r--src/vm86/vm86.c (renamed from src/lrmi.c)348
-rw-r--r--src/vm86/vm86.h102
-rw-r--r--src/x86emu/Makefile.am14
-rw-r--r--src/x86emu/ops2.c67
-rw-r--r--src/x86emu/prim_ops.c2
-rw-r--r--src/x86emu/sys.c68
-rw-r--r--src/x86emu/validate.c4
-rw-r--r--src/x86emu/x86emu/debug.h11
-rw-r--r--src/x86emu/x86emu/prim_ops.h90
-rw-r--r--src/x86emu/x86emu/prim_x86_gcc.h2
-rw-r--r--src/x86emu/x86emu/types.h5
58 files changed, 613 insertions, 1178 deletions
diff --git a/.gitignore b/.gitignore
index bad5791..e726c2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,3 @@
-libx86.a
-libx86.so.1
-lrmi.o
-thunk.o
-x86-common.o
-x86emu/debug.o
-x86emu/decode.o
-x86emu/fpu.o
-x86emu/ops.o
-x86emu/ops2.o
-x86emu/prim_ops.o
-x86emu/sys.o
Makefile
Makefile.in
aclocal.m4
@@ -26,37 +14,36 @@ install-sh
libtool
ltmain.sh
missing
-src/.deps
-src/.libs
+src/Makefile
src/Makefile.in
-src/libx86.la
-src/lrmi.lo
-src/x86-common.lo
-stamp-h1
-x86.pc
-src/debug.lo
-src/debug.o
-src/decode.lo
-src/decode.o
-src/fpu.lo
-src/fpu.o
-src/ops.lo
-src/ops.o
-src/ops2.lo
-src/ops2.o
-src/prim_ops.lo
-src/prim_ops.o
-src/sys.lo
-src/sys.o
-src/thunk.lo
-compile
-src/decode.loT
+src/lrmi/.deps
+src/lrmi/.libs
+src/lrmi/Makefile
+src/lrmi/Makefile.in
+src/lrmi/backend-x86emu.lo
+src/lrmi/backend-x86emu.o
+src/lrmi/common.lo
+src/lrmi/common.o
+src/lrmi/libx86.la
src/x86emu/.deps
+src/x86emu/.libs
+src/x86emu/Makefile
+src/x86emu/Makefile.in
+src/x86emu/debug.lo
src/x86emu/debug.o
+src/x86emu/decode.lo
src/x86emu/decode.o
+src/x86emu/fpu.lo
src/x86emu/fpu.o
src/x86emu/libx86emu.a
+src/x86emu/libx86emu.la
+src/x86emu/ops.lo
src/x86emu/ops.o
+src/x86emu/ops2.lo
src/x86emu/ops2.o
+src/x86emu/prim_ops.lo
src/x86emu/prim_ops.o
+src/x86emu/sys.lo
src/x86emu/sys.o
+stamp-h1
+x86.pc
diff --git a/build-stamp b/AUTHORS
index e69de29..e69de29 100644
--- a/build-stamp
+++ b/AUTHORS
diff --git a/configure-stamp b/ChangeLog
index e69de29..e69de29 100644
--- a/configure-stamp
+++ b/ChangeLog
diff --git a/debian/docs b/NEWS
index e69de29..e69de29 100644
--- a/debian/docs
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/configure.ac b/configure.ac
index dd507a0..f4a13fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,7 +62,9 @@ fi
AC_OUTPUT([Makefile
src/Makefile
+ src/lrmi/Makefile
src/x86emu/Makefile
+ src/vm86/Makefile
x86.pc])
dnl Configuration output
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 4fbb639..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,6 +0,0 @@
-libx86 (0.99-1) unstable; urgency=low
-
- * Initial release
-
- -- Matthew Garrett <mjg59@srcf.ucam.org> Sun, 29 Oct 2006 18:43:31 +0000
-
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/debian/control b/debian/control
deleted file mode 100644
index ad3f232..0000000
--- a/debian/control
+++ /dev/null
@@ -1,24 +0,0 @@
-Source: libx86
-Priority: optional
-Maintainer: Matthew Garrett <mjg59@srcf.ucam.org>
-Build-Depends: debhelper (>= 5)
-Standards-Version: 3.7.2
-Section: libs
-
-Package: libx86-dev
-Section: libdevel
-Architecture: any
-Depends: libx86-1 (= ${Source-Version})
-Description: x86 real-mode library - development files
- A library to provide support for making real-mode calls x86 calls. On x86
- hardware, vm86 mode is used. On other platforms, x86 emulation is provided.
- .
- This package contains the development files for libx86.
-
-Package: libx86-1
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: x86 real-mode library
- A library to provide support for making real-mode calls x86 calls. On x86
- hardware, vm86 mode is used. On other platforms, x86 emulation is provided.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index a682c9a..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,59 +0,0 @@
-This package was debianized by Matthew Garrett <mjg59@srcf.ucam.org> on
-Sun, 29 Oct 2006 18:43:31 +0000.
-
-Upstream Authors: Jonathan McDowell, Matthew Garrett
-
-Copyright:
-Copyright (C) 1998 by Josh Vanderhoof
-Copyright (C) 2005-2006 by Matthew Garrett
-Copyright (C) 2005-2006 by Jonathan McDowell
-
-License:
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-libx86emu makes use of x86emu.
-
-x86emu copyright:
-Copyright (C) 1996-1999 SciTech Software, Inc.
-Copyright (C) David Mosberger-Tang
-Copyright (C) 1999 Egbert Eich
-
-x86emu license:
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of the authors not be used
-in advertising or publicity pertaining to distribution of the software
-without specific, written prior permission. The authors makes no
-representations about the suitability of this software for any purpose.
-It is provided "as is" without express or implied warranty.
-
-THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-The Debian packaging is (C) 2006, Matthew Garrett <mjg59@srcf.ucam.org> and
-is licensed under the same terms as the rest of the code.
-
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644
index ca882bb..0000000
--- a/debian/dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin
-usr/sbin
diff --git a/debian/files b/debian/files
deleted file mode 100644
index b81723a..0000000
--- a/debian/files
+++ /dev/null
@@ -1,2 +0,0 @@
-libx86-dev_0.99-1_i386.deb libdevel optional
-libx86-1_0.99-1_i386.deb libs optional
diff --git a/debian/libx86-1.dirs b/debian/libx86-1.dirs
deleted file mode 100644
index 6845771..0000000
--- a/debian/libx86-1.dirs
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib
diff --git a/debian/libx86-1.install b/debian/libx86-1.install
deleted file mode 100644
index d0dbfd1..0000000
--- a/debian/libx86-1.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/lib*.so.*
diff --git a/debian/libx86-1.postinst.debhelper b/debian/libx86-1.postinst.debhelper
deleted file mode 100644
index 3d89d3e..0000000
--- a/debian/libx86-1.postinst.debhelper
+++ /dev/null
@@ -1,5 +0,0 @@
-# Automatically added by dh_makeshlibs
-if [ "$1" = "configure" ]; then
- ldconfig
-fi
-# End automatically added section
diff --git a/debian/libx86-1.postrm.debhelper b/debian/libx86-1.postrm.debhelper
deleted file mode 100644
index 7f44047..0000000
--- a/debian/libx86-1.postrm.debhelper
+++ /dev/null
@@ -1,5 +0,0 @@
-# Automatically added by dh_makeshlibs
-if [ "$1" = "remove" ]; then
- ldconfig
-fi
-# End automatically added section
diff --git a/debian/libx86-1.substvars b/debian/libx86-1.substvars
deleted file mode 100644
index 2dcc9c4..0000000
--- a/debian/libx86-1.substvars
+++ /dev/null
@@ -1 +0,0 @@
-shlibs:Depends=libc6 (>= 2.4-1)
diff --git a/debian/libx86-1/DEBIAN/control b/debian/libx86-1/DEBIAN/control
deleted file mode 100644
index 099f9ab..0000000
--- a/debian/libx86-1/DEBIAN/control
+++ /dev/null
@@ -1,12 +0,0 @@
-Package: libx86-1
-Version: 0.99-1
-Section: libs
-Priority: optional
-Architecture: i386
-Depends: libc6 (>= 2.4-1)
-Installed-Size: 56
-Maintainer: Matthew Garrett <mjg59@srcf.ucam.org>
-Source: libx86
-Description: x86 real-mode library
- A library to provide support for making real-mode calls x86 calls. On x86
- hardware, vm86 mode is used. On other platforms, x86 emulation is provided.
diff --git a/debian/libx86-1/DEBIAN/md5sums b/debian/libx86-1/DEBIAN/md5sums
deleted file mode 100644
index b61abb4..0000000
--- a/debian/libx86-1/DEBIAN/md5sums
+++ /dev/null
@@ -1,3 +0,0 @@
-013d5c55fb4b82e2ac4306c89c828e80 usr/lib/libx86.so.1
-96aeb528937e6011cf2e500d62d328f6 usr/share/doc/libx86-1/copyright
-2b947c7ccbb364be47e368f00ec4608a usr/share/doc/libx86-1/changelog.Debian.gz
diff --git a/debian/libx86-1/DEBIAN/postinst b/debian/libx86-1/DEBIAN/postinst
deleted file mode 100755
index 379f1fa..0000000
--- a/debian/libx86-1/DEBIAN/postinst
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-set -e
-# Automatically added by dh_makeshlibs
-if [ "$1" = "configure" ]; then
- ldconfig
-fi
-# End automatically added section
diff --git a/debian/libx86-1/DEBIAN/postrm b/debian/libx86-1/DEBIAN/postrm
deleted file mode 100755
index 3e73d38..0000000
--- a/debian/libx86-1/DEBIAN/postrm
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-set -e
-# Automatically added by dh_makeshlibs
-if [ "$1" = "remove" ]; then
- ldconfig
-fi
-# End automatically added section
diff --git a/debian/libx86-1/DEBIAN/shlibs b/debian/libx86-1/DEBIAN/shlibs
deleted file mode 100644
index 94ccd87..0000000
--- a/debian/libx86-1/DEBIAN/shlibs
+++ /dev/null
@@ -1 +0,0 @@
-libx86 1 libx86-1
diff --git a/debian/libx86-1/usr/lib/libx86.so.1 b/debian/libx86-1/usr/lib/libx86.so.1
deleted file mode 100644
index a6d8658..0000000
--- a/debian/libx86-1/usr/lib/libx86.so.1
+++ /dev/null
Binary files differ
diff --git a/debian/libx86-1/usr/share/doc/libx86-1/changelog.Debian.gz b/debian/libx86-1/usr/share/doc/libx86-1/changelog.Debian.gz
deleted file mode 100644
index 2c52cbb..0000000
--- a/debian/libx86-1/usr/share/doc/libx86-1/changelog.Debian.gz
+++ /dev/null
Binary files differ
diff --git a/debian/libx86-1/usr/share/doc/libx86-1/copyright b/debian/libx86-1/usr/share/doc/libx86-1/copyright
deleted file mode 100644
index a682c9a..0000000
--- a/debian/libx86-1/usr/share/doc/libx86-1/copyright
+++ /dev/null
@@ -1,59 +0,0 @@
-This package was debianized by Matthew Garrett <mjg59@srcf.ucam.org> on
-Sun, 29 Oct 2006 18:43:31 +0000.
-
-Upstream Authors: Jonathan McDowell, Matthew Garrett
-
-Copyright:
-Copyright (C) 1998 by Josh Vanderhoof
-Copyright (C) 2005-2006 by Matthew Garrett
-Copyright (C) 2005-2006 by Jonathan McDowell
-
-License:
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-libx86emu makes use of x86emu.
-
-x86emu copyright:
-Copyright (C) 1996-1999 SciTech Software, Inc.
-Copyright (C) David Mosberger-Tang
-Copyright (C) 1999 Egbert Eich
-
-x86emu license:
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of the authors not be used
-in advertising or publicity pertaining to distribution of the software
-without specific, written prior permission. The authors makes no
-representations about the suitability of this software for any purpose.
-It is provided "as is" without express or implied warranty.
-
-THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-The Debian packaging is (C) 2006, Matthew Garrett <mjg59@srcf.ucam.org> and
-is licensed under the same terms as the rest of the code.
-
diff --git a/debian/libx86-dev.dirs b/debian/libx86-dev.dirs
deleted file mode 100644
index 4418816..0000000
--- a/debian/libx86-dev.dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib
-usr/include
diff --git a/debian/libx86-dev.install b/debian/libx86-dev.install
deleted file mode 100644
index d1bffed..0000000
--- a/debian/libx86-dev.install
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/include/*
-usr/lib/lib*.a
-usr/lib/lib*.so
diff --git a/debian/libx86-dev/DEBIAN/control b/debian/libx86-dev/DEBIAN/control
deleted file mode 100644
index a727f43..0000000
--- a/debian/libx86-dev/DEBIAN/control
+++ /dev/null
@@ -1,14 +0,0 @@
-Package: libx86-dev
-Version: 0.99-1
-Section: libdevel
-Priority: optional
-Architecture: i386
-Depends: libx86-1 (= 0.99-1)
-Installed-Size: 52
-Maintainer: Matthew Garrett <mjg59@srcf.ucam.org>
-Source: libx86
-Description: x86 real-mode library - development files
- A library to provide support for making real-mode calls x86 calls. On x86
- hardware, vm86 mode is used. On other platforms, x86 emulation is provided.
- .
- This package contains the development files for libx86.
diff --git a/debian/libx86-dev/DEBIAN/md5sums b/debian/libx86-dev/DEBIAN/md5sums
deleted file mode 100644
index f51f44a..0000000
--- a/debian/libx86-dev/DEBIAN/md5sums
+++ /dev/null
@@ -1,4 +0,0 @@
-a48a2bb678dfd144aa5a4eef00d1ef00 usr/lib/libx86.a
-dbea0dca2198a57273aaeb1de28b50b0 usr/include/libx86.h
-96aeb528937e6011cf2e500d62d328f6 usr/share/doc/libx86-dev/copyright
-2b947c7ccbb364be47e368f00ec4608a usr/share/doc/libx86-dev/changelog.Debian.gz
diff --git a/debian/libx86-dev/usr/include/libx86.h b/debian/libx86-dev/usr/include/libx86.h
deleted file mode 100644
index 182864f..0000000
--- a/debian/libx86-dev/usr/include/libx86.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-Linux Real Mode Interface - A library of DPMI-like functions for Linux.
-
-Copyright (C) 1998 by Josh Vanderhoof
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef LRMI_H
-#define LRMI_H
-
-#define LRMI_PREFIX LRMI_
-
-struct LRMI_regs {
- unsigned int edi;
- unsigned int esi;
- unsigned int ebp;
- unsigned int reserved;
- unsigned int ebx;
- unsigned int edx;
- unsigned int ecx;
- unsigned int eax;
- unsigned short int flags;
- unsigned short int es;
- unsigned short int ds;
- unsigned short int fs;
- unsigned short int gs;
- unsigned short int ip;
- unsigned short int cs;
- unsigned short int sp;
- unsigned short int ss;
-};
-
-#define LRMI_CONCAT2(a, b) a ## b
-#define LRMI_CONCAT(a, b) LRMI_CONCAT2(a, b)
-#define LRMI_MAKENAME(a) LRMI_CONCAT(LRMI_PREFIX, a)
-
-/*
- Initialize
- returns 1 if sucessful, 0 for failure
-*/
-#define LRMI_init LRMI_MAKENAME(init)
-int
-LRMI_init(void);
-
-/*
- Simulate a 16 bit far call
- returns 1 if sucessful, 0 for failure
-*/
-#define LRMI_call LRMI_MAKENAME(call)
-int
-LRMI_call(struct LRMI_regs *r);
-
-/*
- Simulate a 16 bit interrupt
- returns 1 if sucessful, 0 for failure
-*/
-#define LRMI_int LRMI_MAKENAME(int)
-int
-LRMI_int(int interrupt, struct LRMI_regs *r);
-
-/*
- Allocate real mode memory
- The returned block is paragraph (16 byte) aligned
-*/
-#define LRMI_alloc_real LRMI_MAKENAME(alloc_real)
-void *
-LRMI_alloc_real(int size);
-
-/*
- Free real mode memory
-*/
-#define LRMI_free_real LRMI_MAKENAME(free_real)
-void
-LRMI_free_real(void *m);
-
-/*
- * Get the base address of the real memory address space block.
- */
-size_t
-LRMI_base_addr(void);
-
-#endif
diff --git a/debian/libx86-dev/usr/lib/libx86.a b/debian/libx86-dev/usr/lib/libx86.a
deleted file mode 100644
index 5b3f137..0000000
--- a/debian/libx86-dev/usr/lib/libx86.a
+++ /dev/null
Binary files differ
diff --git a/debian/libx86-dev/usr/lib/libx86.so b/debian/libx86-dev/usr/lib/libx86.so
deleted file mode 120000
index 69a3c42..0000000
--- a/debian/libx86-dev/usr/lib/libx86.so
+++ /dev/null
@@ -1 +0,0 @@
-libx86.so.1 \ No newline at end of file
diff --git a/debian/libx86-dev/usr/share/doc/libx86-dev/changelog.Debian.gz b/debian/libx86-dev/usr/share/doc/libx86-dev/changelog.Debian.gz
deleted file mode 100644
index 2c52cbb..0000000
--- a/debian/libx86-dev/usr/share/doc/libx86-dev/changelog.Debian.gz
+++ /dev/null
Binary files differ
diff --git a/debian/libx86-dev/usr/share/doc/libx86-dev/copyright b/debian/libx86-dev/usr/share/doc/libx86-dev/copyright
deleted file mode 100644
index a682c9a..0000000
--- a/debian/libx86-dev/usr/share/doc/libx86-dev/copyright
+++ /dev/null
@@ -1,59 +0,0 @@
-This package was debianized by Matthew Garrett <mjg59@srcf.ucam.org> on
-Sun, 29 Oct 2006 18:43:31 +0000.
-
-Upstream Authors: Jonathan McDowell, Matthew Garrett
-
-Copyright:
-Copyright (C) 1998 by Josh Vanderhoof
-Copyright (C) 2005-2006 by Matthew Garrett
-Copyright (C) 2005-2006 by Jonathan McDowell
-
-License:
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-libx86emu makes use of x86emu.
-
-x86emu copyright:
-Copyright (C) 1996-1999 SciTech Software, Inc.
-Copyright (C) David Mosberger-Tang
-Copyright (C) 1999 Egbert Eich
-
-x86emu license:
-Permission to use, copy, modify, distribute, and sell this software and
-its documentation for any purpose is hereby granted without fee,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of the authors not be used
-in advertising or publicity pertaining to distribution of the software
-without specific, written prior permission. The authors makes no
-representations about the suitability of this software for any purpose.
-It is provided "as is" without express or implied warranty.
-
-THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-
-The Debian packaging is (C) 2006, Matthew Garrett <mjg59@srcf.ucam.org> and
-is licensed under the same terms as the rest of the code.
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 780448b..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-ifeq ($(DEB_HOST_ARCH), $(findstring $(DEB_HOST_ARCH),i386))
- BACKEND =
-else
- BACKEND = "BACKEND=x86emu"
-endif
-
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-# shared library versions, option 1
-version=2.0.5
-major=2
-# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
-#version=`ls src/.libs/lib*.so.* | \
-# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
-#major=`ls src/.libs/lib*.so.* | \
-# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
-
- touch configure-stamp
-
-
-build: build-stamp
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Add here commands to clean up after the build process.
- -$(MAKE) clean
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/tmp
- $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_python
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/debian/tmp/usr/include/libx86.h b/debian/tmp/usr/include/libx86.h
deleted file mode 100755
index 182864f..0000000
--- a/debian/tmp/usr/include/libx86.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-Linux Real Mode Interface - A library of DPMI-like functions for Linux.
-
-Copyright (C) 1998 by Josh Vanderhoof
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#ifndef LRMI_H
-#define LRMI_H
-
-#define LRMI_PREFIX LRMI_
-
-struct LRMI_regs {
- unsigned int edi;
- unsigned int esi;
- unsigned int ebp;
- unsigned int reserved;
- unsigned int ebx;
- unsigned int edx;
- unsigned int ecx;
- unsigned int eax;
- unsigned short int flags;
- unsigned short int es;
- unsigned short int ds;
- unsigned short int fs;
- unsigned short int gs;
- unsigned short int ip;
- unsigned short int cs;
- unsigned short int sp;
- unsigned short int ss;
-};
-
-#define LRMI_CONCAT2(a, b) a ## b
-#define LRMI_CONCAT(a, b) LRMI_CONCAT2(a, b)
-#define LRMI_MAKENAME(a) LRMI_CONCAT(LRMI_PREFIX, a)
-
-/*
- Initialize
- returns 1 if sucessful, 0 for failure
-*/
-#define LRMI_init LRMI_MAKENAME(init)
-int
-LRMI_init(void);
-
-/*
- Simulate a 16 bit far call
- returns 1 if sucessful, 0 for failure
-*/
-#define LRMI_call LRMI_MAKENAME(call)
-int
-LRMI_call(struct LRMI_regs *r);
-
-/*
- Simulate a 16 bit interrupt
- returns 1 if sucessful, 0 for failure
-*/
-#define LRMI_int LRMI_MAKENAME(int)
-int
-LRMI_int(int interrupt, struct LRMI_regs *r);
-
-/*
- Allocate real mode memory
- The returned block is paragraph (16 byte) aligned
-*/
-#define LRMI_alloc_real LRMI_MAKENAME(alloc_real)
-void *
-LRMI_alloc_real(int size);
-
-/*
- Free real mode memory
-*/
-#define LRMI_free_real LRMI_MAKENAME(free_real)
-void
-LRMI_free_real(void *m);
-
-/*
- * Get the base address of the real memory address space block.
- */
-size_t
-LRMI_base_addr(void);
-
-#endif
diff --git a/debian/tmp/usr/lib/libx86.a b/debian/tmp/usr/lib/libx86.a
deleted file mode 100755
index c308443..0000000
--- a/debian/tmp/usr/lib/libx86.a
+++ /dev/null
Binary files differ
diff --git a/debian/tmp/usr/lib/libx86.so b/debian/tmp/usr/lib/libx86.so
deleted file mode 120000
index f642b3c..0000000
--- a/debian/tmp/usr/lib/libx86.so
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/libx86.so.1 \ No newline at end of file
diff --git a/debian/tmp/usr/lib/libx86.so.1 b/debian/tmp/usr/lib/libx86.so.1
deleted file mode 100755
index 2441a23..0000000
--- a/debian/tmp/usr/lib/libx86.so.1
+++ /dev/null
Binary files differ
diff --git a/include/libx86.h b/include/libx86.h
index 182864f..31fb3cf 100644
--- a/include/libx86.h
+++ b/include/libx86.h
@@ -26,7 +26,15 @@ OTHER DEALINGS IN THE SOFTWARE.
#ifndef LRMI_H
#define LRMI_H
+
+#if defined(__i386__) && (defined(__linux__) || defined(__NetBSD__) \
+ || defined(__FreeBSD__) || defined(__OpenBSD__))
+
+#include <stdlib.h>
+
+#ifndef LRMI_PREFIX
#define LRMI_PREFIX LRMI_
+#endif
struct LRMI_regs {
unsigned int edi;
@@ -97,4 +105,8 @@ LRMI_free_real(void *m);
size_t
LRMI_base_addr(void);
+#else /* (__linux__ || __NetBSD__ || __FreeBSD__) && __i386__ */
+#warning "LRMI is not supported on your system!"
+#endif
+
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 86f71da..0894488 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,17 +1,8 @@
-lib_LTLIBRARIES = libx86.la
+COMMON_DIR= lrmi
+# which backend?
if X86EMU
-SUBDIRS = x86emu
-
-libx86_la_SOURCES = x86-common.c thunk.c
-libx86_la_LIBADD = x86emu/libx86emu.la
-else
-libx86_la_SOURCES = x86-common.c lrmi.c
+SUBDIRS = x86emu $(COMMON_DIR)
+else # VM86
+SUBDIRS = vm86 $(COMMON_DIR)
endif
-
-INCLUDES = -I$(top_srcdir)/include
-
-libx86includedir = $(includedir)
-libx86include_HEADERS = \
- $(top_srcdir)/include/libx86.h
-
diff --git a/src/lrmi/Makefile.am b/src/lrmi/Makefile.am
new file mode 100644
index 0000000..fd73483
--- /dev/null
+++ b/src/lrmi/Makefile.am
@@ -0,0 +1,18 @@
+lib_LTLIBRARIES = libx86.la
+
+if X86EMU
+BACKEND_SRC = backend-x86emu.c
+BACKEND_LIBRARY = $(top_srcdir)/src/x86emu/libx86emu.la
+BACKEND_INCLUDES = -I$(top_srcdir)/src/x86emu
+else # VM86
+BACKEND_SRC = backend-vm86.c
+BACKEND_LIBRARY = $(top_srcdir)/src/vm86/libvm86.la
+BACKEND_INCLUDES = -I$(top_srcdir)/src/vm86
+endif
+
+libx86_la_SOURCES = common.c $(BACKEND_SRC)
+libx86_la_LIBADD = $(BACKEND_LIBRARY)
+INCLUDES = -I$(top_srcdir)/include $(BACKEND_INCLUDES)
+
+libx86includedir = $(includedir)
+libx86include_HEADERS = $(top_srcdir)/include/libx86.h
diff --git a/src/lrmi/backend-vm86.c b/src/lrmi/backend-vm86.c
new file mode 100644
index 0000000..29342b1
--- /dev/null
+++ b/src/lrmi/backend-vm86.c
@@ -0,0 +1,219 @@
+/*
+Linux Real Mode Interface - A library of DPMI-like functions for Linux.
+
+Copyright (C) 1998 by Josh Vanderhoof
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#if defined(__i386__) && (defined(__linux__) || defined(__NetBSD__) \
+ || defined(__FreeBSD__) || defined(__OpenBSD__))
+
+#include <string.h>
+#include "libx86.h"
+#include "common.h"
+#include "vm86.h"
+
+#if defined(__linux__)
+#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#define DEFAULT_VM86_FLAGS (PSL_I | PSL_IOPL)
+#endif
+#define DEFAULT_STACK_SIZE 0x1000
+
+extern vm86context context;
+
+static inline void
+set_bit(unsigned int bit, void *array)
+{
+ unsigned char *a = array;
+
+ a[bit / 8] |= (1 << (bit % 8));
+}
+
+int
+LRMI_init(void)
+{
+ void *m;
+
+ if (context.ready)
+ return 1;
+
+ if (!LRMI_common_init())
+ return 0;
+
+ /*
+ Allocate a stack
+ */
+ m = LRMI_alloc_real(DEFAULT_STACK_SIZE);
+
+ context.stack_seg = (unsigned int)m >> 4;
+ context.stack_off = DEFAULT_STACK_SIZE;
+
+ /*
+ Allocate the return to 32 bit routine
+ */
+ m = LRMI_alloc_real(2);
+
+ context.ret_seg = (unsigned int)m >> 4;
+ context.ret_off = (unsigned int)m & 0xf;
+
+ ((unsigned char *)m)[0] = 0xcd; /* int opcode */
+ ((unsigned char *)m)[1] = RETURN_TO_32_INT;
+
+ memset(&context.vm, 0, sizeof(context.vm));
+
+ /*
+ Enable kernel emulation of all ints except RETURN_TO_32_INT
+ */
+#if defined(__linux__)
+ memset(&context.vm.int_revectored, 0, sizeof(context.vm.int_revectored));
+ set_bit(RETURN_TO_32_INT, &context.vm.int_revectored);
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
+ set_bit(RETURN_TO_32_INT, &context.vm.int_byuser);
+#elif defined(__FreeBSD__)
+ set_bit(RETURN_TO_32_INT, &context.vm.init.int_map);
+#endif
+
+ context.ready = 1;
+
+ return 1;
+}
+
+static void
+set_regs(struct LRMI_regs *r)
+{
+ CONTEXT_REGS.REG(edi) = r->edi;
+ CONTEXT_REGS.REG(esi) = r->esi;
+ CONTEXT_REGS.REG(ebp) = r->ebp;
+ CONTEXT_REGS.REG(ebx) = r->ebx;
+ CONTEXT_REGS.REG(edx) = r->edx;
+ CONTEXT_REGS.REG(ecx) = r->ecx;
+ CONTEXT_REGS.REG(eax) = r->eax;
+ CONTEXT_REGS.REG(eflags) = DEFAULT_VM86_FLAGS;
+ CONTEXT_REGS.REG(es) = r->es;
+ CONTEXT_REGS.REG(ds) = r->ds;
+ CONTEXT_REGS.REG(fs) = r->fs;
+ CONTEXT_REGS.REG(gs) = r->gs;
+}
+
+
+static void
+get_regs(struct LRMI_regs *r)
+{
+ r->edi = CONTEXT_REGS.REG(edi);
+ r->esi = CONTEXT_REGS.REG(esi);
+ r->ebp = CONTEXT_REGS.REG(ebp);
+ r->ebx = CONTEXT_REGS.REG(ebx);
+ r->edx = CONTEXT_REGS.REG(edx);
+ r->ecx = CONTEXT_REGS.REG(ecx);
+ r->eax = CONTEXT_REGS.REG(eax);
+ r->flags = CONTEXT_REGS.REG(eflags);
+ r->es = CONTEXT_REGS.REG(es);
+ r->ds = CONTEXT_REGS.REG(ds);
+ r->fs = CONTEXT_REGS.REG(fs);
+ r->gs = CONTEXT_REGS.REG(gs);
+}
+
+int
+LRMI_call(struct LRMI_regs *r)
+{
+ unsigned int vret;
+
+ memset(&CONTEXT_REGS, 0, sizeof(CONTEXT_REGS));
+
+ set_regs(r);
+
+ CONTEXT_REGS.REG(cs) = r->cs;
+ CONTEXT_REGS.REG(eip) = r->ip;
+
+ if (r->ss == 0 && r->sp == 0) {
+ CONTEXT_REGS.REG(ss) = context.stack_seg;
+ CONTEXT_REGS.REG(esp) = context.stack_off;
+ } else {
+ CONTEXT_REGS.REG(ss) = r->ss;
+ CONTEXT_REGS.REG(esp) = r->sp;
+ }
+
+ pushw(context.ret_seg);
+ pushw(context.ret_off);
+
+ vret = run_vm86();
+
+ get_regs(r);
+
+ return vret;
+}
+
+int
+LRMI_int(int i, struct LRMI_regs *r)
+{
+ unsigned int vret;
+ unsigned int seg, off;
+
+ seg = get_int_seg(i);
+ off = get_int_off(i);
+
+ /*
+ If the interrupt is in regular memory, it's probably
+ still pointing at a dos TSR (which is now gone).
+ */
+ if (seg < 0xa000 || (seg << 4) + off >= 0x100000) {
+#ifdef LRMI_DEBUG
+ fprintf(stderr, "Int 0x%x is not in rom (%04x:%04x)\n", i, seg, off);
+#endif
+ return 0;
+ }
+
+ memset(&CONTEXT_REGS, 0, sizeof(CONTEXT_REGS));
+
+ set_regs(r);
+
+ CONTEXT_REGS.REG(cs) = seg;
+ CONTEXT_REGS.REG(eip) = off;
+
+ if (r->ss == 0 && r->sp == 0) {
+ CONTEXT_REGS.REG(ss) = context.stack_seg;
+ CONTEXT_REGS.REG(esp) = context.stack_off;
+ } else {
+ CONTEXT_REGS.REG(ss) = r->ss;
+ CONTEXT_REGS.REG(esp) = r->sp;
+ }
+
+ pushw(DEFAULT_VM86_FLAGS);
+ pushw(context.ret_seg);
+ pushw(context.ret_off);
+
+ vret = run_vm86();
+
+ get_regs(r);
+
+ return vret;
+}
+
+size_t
+LRMI_base_addr(void)
+{
+ return 0;
+}
+
+#else /* (__linux__ || __NetBSD__ || __FreeBSD__ || __OpenBSD__) && __i386__ */
+#warning "LRMI is not supported on your system!"
+#endif
diff --git a/src/thunk.c b/src/lrmi/backend-x86emu.c
index 4f392d0..3e2a7b0 100644
--- a/src/thunk.c
+++ b/src/lrmi/backend-x86emu.c
@@ -1,9 +1,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
-#include "x86emu/x86emu.h"
+#include "x86emu.h"
#include "libx86.h"
-#include "x86-common.h"
+#include "common.h"
#define M _X86EMU_env
diff --git a/src/x86-common.c b/src/lrmi/common.c
index ea6cb9e..85c744c 100644
--- a/src/x86-common.c
+++ b/src/lrmi/common.c
@@ -49,38 +49,70 @@ static struct {
} mem_info = { 0 };
static int
-real_mem_init(void)
+read_file(char *name, void *p, size_t n)
{
- void *m;
- int fd_zero;
+ int fd;
- if (mem_info.ready)
- return 1;
+ fd = open(name, O_RDONLY);
- fd_zero = open("/dev/zero", O_RDWR);
- if (fd_zero == -1) {
- perror("open /dev/zero");
- return 0;
- }
+ if (fd == -1) {
+ perror("open");
+ return 0;
+ }
- m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_FIXED | MAP_SHARED, fd_zero, 0);
+ if (read(fd, p, n) != n) {
+ perror("read");
+ close(fd);
+ return 0;
+ }
- if (m == (void *)-1) {
- perror("mmap /dev/zero");
- close(fd_zero);
- return 0;
- }
+ close(fd);
- close(fd_zero);
+ return 1;
+}
+
+static int
+map_file(void *start, size_t length, int prot, int flags, char *name, long offset)
+{
+ void *m;
+ int fd;
- mem_info.ready = 1;
- mem_info.count = 1;
- mem_info.blocks[0].size = REAL_MEM_SIZE;
- mem_info.blocks[0].free = 1;
+ fd = open(name, (flags & MAP_SHARED) ? O_RDWR : O_RDONLY);
- return 1;
+ if (fd == -1) {
+ perror("open");
+ return 0;
+ }
+
+ m = mmap(start, length, prot, flags, fd, offset);
+
+ if (m == (void *)-1) {
+ perror("mmap");
+ close(fd);
+ return 0;
+ }
+
+ close(fd);
+ return 1;
+}
+
+static int
+real_mem_init(void)
+{
+ if (mem_info.ready)
+ return 1;
+
+ if (!map_file((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_FIXED | MAP_PRIVATE, "/dev/zero", 0))
+ return 0;
+
+ mem_info.ready = 1;
+ mem_info.count = 1;
+ mem_info.blocks[0].size = REAL_MEM_SIZE;
+ mem_info.blocks[0].free = 1;
+
+ return 1;
}
static void
@@ -92,7 +124,6 @@ real_mem_deinit(void)
}
}
-
static void
insert_block(int i)
{
@@ -177,29 +208,6 @@ LRMI_free_real(void *m)
}
}
-#define DEFAULT_STACK_SIZE 0x1000
-
-static inline void
-set_bit(unsigned int bit, void *array)
-{
- unsigned char *a = array;
-
- a[bit / 8] |= (1 << (bit % 8));
-}
-
-static inline unsigned int
-get_int_seg(int i)
-{
- return *(unsigned short *)(i * 4 + 2);
-}
-
-
-static inline unsigned int
-get_int_off(int i)
-{
- return *(unsigned short *)(i * 4);
-}
-
int LRMI_common_init(void)
{
void *m;
@@ -212,36 +220,26 @@ int LRMI_common_init(void)
Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502)
and the ROM (0xa0000 - 0x100000)
*/
- fd_mem = open("/dev/mem", O_RDWR);
-
- if (fd_mem == -1) {
- real_mem_deinit();
- perror("open /dev/mem");
- return 0;
- }
-
- m = mmap((void *)0, 0x502,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_FIXED | MAP_SHARED, fd_mem, 0);
-
- if (m == (void *)-1) {
- close(fd_mem);
- real_mem_deinit();
- perror("mmap /dev/mem");
- return 0;
- }
-
- m = mmap((void *)0xa0000, 0x100000 - 0xa0000,
- PROT_READ | PROT_WRITE,
- MAP_FIXED | MAP_SHARED, fd_mem, 0xa0000);
-
- if (m == (void *)-1) {
- munmap((void *)0, 0x502);
- close(fd_mem);
- real_mem_deinit();
- perror("mmap /dev/mem");
- return 0;
- }
+ if (!map_file((void *)0, 0x502,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_FIXED | MAP_PRIVATE, "/dev/zero", 0)) {
+ real_mem_deinit();
+ return 0;
+ }
+
+ if (!read_file("/dev/mem", (void *)0, 0x502)) {
+ munmap((void *)0, 0x502);
+ real_mem_deinit();
+ return 0;
+ }
+
+ if (!map_file((void *)0xa0000, 0x100000 - 0xa0000,
+ PROT_READ | PROT_WRITE,
+ MAP_FIXED | MAP_SHARED, "/dev/mem", 0xa0000)) {
+ munmap((void *)0, 0x502);
+ real_mem_deinit();
+ return 0;
+ }
close(fd_mem);
diff --git a/src/x86-common.h b/src/lrmi/common.h
index 99bf883..99bf883 100644
--- a/src/x86-common.h
+++ b/src/lrmi/common.h
diff --git a/src/vm86/Makefile.am b/src/vm86/Makefile.am
new file mode 100644
index 0000000..6fad12b
--- /dev/null
+++ b/src/vm86/Makefile.am
@@ -0,0 +1,3 @@
+lib_LTLIBRARIES = libvm86.la
+
+libvm86_la_SOURCES = vm86.c
diff --git a/src/lrmi.c b/src/vm86/vm86.c
index 082f721..2d6f12c 100644
--- a/src/lrmi.c
+++ b/src/vm86/vm86.c
@@ -1,4 +1,5 @@
/*
+Code stolen from:
Linux Real Mode Interface - A library of DPMI-like functions for Linux.
Copyright (C) 1998 by Josh Vanderhoof
@@ -22,104 +23,52 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
+/*
+Copyright (C) 2008 by Tiago Vignatti <vignatti (at) c3sl ufpr br>
-#include <stdio.h>
-#include <string.h>
-
-#if defined(__linux__) && defined(__i386__)
-
-#include <asm/vm86.h>
-
-#ifdef USE_LIBC_VM86
-#include <sys/vm86.h>
-#endif
-
-#elif defined(__NetBSD__) || defined(__FreeBSD__)
-
-#include <sys/param.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <machine/psl.h>
-#include <machine/vm86.h>
-#include <machine/sysarch.h>
-
-#endif /* __NetBSD__ || __FreeBSD__ */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "libx86.h"
-#include "x86-common.h"
-
-#if defined(__linux__)
-#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
-#elif defined(__NetBSD__) || defined(__FreeBSD__)
-#define DEFAULT_VM86_FLAGS (PSL_I | PSL_IOPL)
-#define TF_MASK PSL_T
-#define VIF_MASK PSL_VIF
-#endif
-#define DEFAULT_STACK_SIZE 0x1000
-#define RETURN_TO_32_INT 255
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
-#if defined(__linux__)
-#define CONTEXT_REGS context.vm.regs
-#define REG(x) x
-#elif defined(__NetBSD__)
-#define CONTEXT_REGS context.vm.substr.regs
-#define REG(x) vmsc.sc_ ## x
-#elif defined(__FreeBSD__)
-#define CONTEXT_REGS context.vm.uc
-#define REG(x) uc_mcontext.mc_ ## x
-#endif
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
-static struct {
- int ready;
- unsigned short ret_seg, ret_off;
- unsigned short stack_seg, stack_off;
-#if defined(__linux__) || defined(__NetBSD__)
- struct vm86_struct vm;
-#elif defined(__FreeBSD__)
- struct {
- struct vm86_init_args init;
- ucontext_t uc;
- } vm;
-#endif
-#if defined(__NetBSD__) || defined(__FreeBSD__)
- int success;
- jmp_buf env;
- void *old_sighandler;
- int vret;
-#endif
-} context = { 0 };
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+#if defined(__i386__) && (defined(__linux__) || defined(__NetBSD__) \
+ || defined(__FreeBSD__) || defined(__OpenBSD__))
-static inline void
-set_bit(unsigned int bit, void *array)
-{
- unsigned char *a = array;
+#include "vm86.h"
- a[bit / 8] |= (1 << (bit % 8));
-}
+vm86context context = { 0 };
-static inline unsigned int
+unsigned int
get_int_seg(int i)
{
return *(unsigned short *)(i * 4 + 2);
}
-static inline unsigned int
+unsigned int
get_int_off(int i)
{
return *(unsigned short *)(i * 4);
}
-static inline void
+void
pushw(unsigned short i)
{
CONTEXT_REGS.REG(esp) -= 2;
@@ -127,92 +76,6 @@ pushw(unsigned short i)
CONTEXT_REGS.REG(esp)) = i;
}
-
-int
-LRMI_init(void)
-{
- void *m;
-
- if (context.ready)
- return 1;
-
- if (!LRMI_common_init())
- return 0;
-
- /*
- Allocate a stack
- */
- m = LRMI_alloc_real(DEFAULT_STACK_SIZE);
-
- context.stack_seg = (unsigned int)m >> 4;
- context.stack_off = DEFAULT_STACK_SIZE;
-
- /*
- Allocate the return to 32 bit routine
- */
- m = LRMI_alloc_real(2);
-
- context.ret_seg = (unsigned int)m >> 4;
- context.ret_off = (unsigned int)m & 0xf;
-
- ((unsigned char *)m)[0] = 0xcd; /* int opcode */
- ((unsigned char *)m)[1] = RETURN_TO_32_INT;
-
- memset(&context.vm, 0, sizeof(context.vm));
-
- /*
- Enable kernel emulation of all ints except RETURN_TO_32_INT
- */
-#if defined(__linux__)
- memset(&context.vm.int_revectored, 0, sizeof(context.vm.int_revectored));
- set_bit(RETURN_TO_32_INT, &context.vm.int_revectored);
-#elif defined(__NetBSD__)
- set_bit(RETURN_TO_32_INT, &context.vm.int_byuser);
-#elif defined(__FreeBSD__)
- set_bit(RETURN_TO_32_INT, &context.vm.init.int_map);
-#endif
-
- context.ready = 1;
-
- return 1;
-}
-
-
-static void
-set_regs(struct LRMI_regs *r)
-{
- CONTEXT_REGS.REG(edi) = r->edi;
- CONTEXT_REGS.REG(esi) = r->esi;
- CONTEXT_REGS.REG(ebp) = r->ebp;
- CONTEXT_REGS.REG(ebx) = r->ebx;
- CONTEXT_REGS.REG(edx) = r->edx;
- CONTEXT_REGS.REG(ecx) = r->ecx;
- CONTEXT_REGS.REG(eax) = r->eax;
- CONTEXT_REGS.REG(eflags) = DEFAULT_VM86_FLAGS;
- CONTEXT_REGS.REG(es) = r->es;
- CONTEXT_REGS.REG(ds) = r->ds;
- CONTEXT_REGS.REG(fs) = r->fs;
- CONTEXT_REGS.REG(gs) = r->gs;
-}
-
-
-static void
-get_regs(struct LRMI_regs *r)
-{
- r->edi = CONTEXT_REGS.REG(edi);
- r->esi = CONTEXT_REGS.REG(esi);
- r->ebp = CONTEXT_REGS.REG(ebp);
- r->ebx = CONTEXT_REGS.REG(ebx);
- r->edx = CONTEXT_REGS.REG(edx);
- r->ecx = CONTEXT_REGS.REG(ecx);
- r->eax = CONTEXT_REGS.REG(eax);
- r->flags = CONTEXT_REGS.REG(eflags);
- r->es = CONTEXT_REGS.REG(es);
- r->ds = CONTEXT_REGS.REG(ds);
- r->fs = CONTEXT_REGS.REG(fs);
- r->gs = CONTEXT_REGS.REG(gs);
-}
-
#define DIRECTION_FLAG (1 << 10)
enum {
@@ -506,7 +369,6 @@ emulate(void)
return 1;
}
-
#if defined(__linux__)
/*
I don't know how to make sure I get the right vm86() from libc.
@@ -583,51 +445,54 @@ debug_info(int vret)
#if defined(__linux__)
-static int
+int
run_vm86(void)
{
- unsigned int vret;
+ unsigned int vret;
+ sigset_t all_sigs, old_sigs;
+ unsigned long old_gs, old_fs;
- while (1) {
- vret = lrmi_vm86(&context.vm);
+ while (1) {
+ // FIXME: may apply this to BSD equivalents?
+ sigfillset(&all_sigs);
+ sigprocmask(SIG_SETMASK, &all_sigs, &old_sigs);
+ asm volatile ("mov %%gs, %0" : "=rm" (old_gs));
+ asm volatile ("mov %%fs, %0" : "=rm" (old_fs));
+ vret = lrmi_vm86(&context.vm);
+ asm volatile ("mov %0, %%gs" :: "rm" (old_gs));
+ asm volatile ("mov %0, %%fs" :: "rm" (old_fs));
+ sigprocmask(SIG_SETMASK, &old_sigs, NULL);
- if (VM86_TYPE(vret) == VM86_INTx) {
- unsigned int v = VM86_ARG(vret);
+ if (VM86_TYPE(vret) == VM86_INTx) {
+ unsigned int v = VM86_ARG(vret);
- if (v == RETURN_TO_32_INT)
- return 1;
+ if (v == RETURN_TO_32_INT)
+ return 1;
- /* fprintf(stderr, "Calling INT 0x%X (%04X:%04X)\n",
- v,
- get_int_seg(v),
- get_int_off(v));
- fprintf(stderr, " EAX is 0x%lX\n",
- CONTEXT_REGS.REG(eax));
- */
- pushw(CONTEXT_REGS.REG(eflags));
- pushw(CONTEXT_REGS.REG(cs));
- pushw(CONTEXT_REGS.REG(eip));
+ pushw(CONTEXT_REGS.REG(eflags));
+ pushw(CONTEXT_REGS.REG(cs));
+ pushw(CONTEXT_REGS.REG(eip));
- CONTEXT_REGS.REG(cs) = get_int_seg(v);
- CONTEXT_REGS.REG(eip) = get_int_off(v);
- CONTEXT_REGS.REG(eflags) &= ~(VIF_MASK | TF_MASK);
+ CONTEXT_REGS.REG(cs) = get_int_seg(v);
+ CONTEXT_REGS.REG(eip) = get_int_off(v);
+ CONTEXT_REGS.REG(eflags) &= ~(VIF_MASK | TF_MASK);
- continue;
- }
+ continue;
+ }
- if (VM86_TYPE(vret) != VM86_UNKNOWN)
- break;
+ if (VM86_TYPE(vret) != VM86_UNKNOWN)
+ break;
- if (!emulate())
- break;
- }
+ if (!emulate())
+ break;
+ }
debug_info(vret);
return 0;
}
-#elif defined(__NetBSD__) || defined(__FreeBSD__)
-#if defined(__NetBSD__)
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
static void
vm86_callback(int sig, int code, struct sigcontext *sc)
{
@@ -717,7 +582,7 @@ vm86_callback(int sig, int code, struct sigcontext *sc)
}
#endif /* __FreeBSD__ */
-static int
+int
run_vm86(void)
{
if (context.old_sighandler) {
@@ -727,7 +592,7 @@ run_vm86(void)
return (0);
}
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
context.old_sighandler = signal(SIGURG, (void (*)(int))vm86_callback);
#elif defined(__FreeBSD__)
context.old_sighandler = signal(SIGBUS, (void (*)(int))vm86_callback);
@@ -742,7 +607,7 @@ run_vm86(void)
}
if (setjmp(context.env)) {
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
(void) signal(SIGURG, context.old_sighandler);
#elif defined(__FreeBSD__)
(void) signal(SIGBUS, context.old_sighandler);
@@ -755,7 +620,7 @@ run_vm86(void)
return (0);
}
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
if (i386_vm86(&context.vm) == -1)
return (0);
#elif defined(__FreeBSD__)
@@ -769,87 +634,8 @@ run_vm86(void)
/* NOTREACHED */
return (0);
}
-#endif /* __NetBSD__ || __FreeBSD__ */
+#endif /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ */
-int
-LRMI_call(struct LRMI_regs *r)
-{
- unsigned int vret;
-
- memset(&CONTEXT_REGS, 0, sizeof(CONTEXT_REGS));
-
- set_regs(r);
-
- CONTEXT_REGS.REG(cs) = r->cs;
- CONTEXT_REGS.REG(eip) = r->ip;
-
- if (r->ss == 0 && r->sp == 0) {
- CONTEXT_REGS.REG(ss) = context.stack_seg;
- CONTEXT_REGS.REG(esp) = context.stack_off;
- } else {
- CONTEXT_REGS.REG(ss) = r->ss;
- CONTEXT_REGS.REG(esp) = r->sp;
- }
-
- pushw(context.ret_seg);
- pushw(context.ret_off);
-
- vret = run_vm86();
-
- get_regs(r);
-
- return vret;
-}
-
-
-int
-LRMI_int(int i, struct LRMI_regs *r)
-{
- unsigned int vret;
- unsigned int seg, off;
-
- seg = get_int_seg(i);
- off = get_int_off(i);
-
- /*
- If the interrupt is in regular memory, it's probably
- still pointing at a dos TSR (which is now gone).
- */
- if (seg < 0xa000 || (seg << 4) + off >= 0x100000) {
-#ifdef LRMI_DEBUG
- fprintf(stderr, "Int 0x%x is not in rom (%04x:%04x)\n", i, seg, off);
+#else /* (__linux__ || __NetBSD__ || __FreeBSD__ || __OpenBSD__) && __i386__ */
+#warning "LRMI is not supported on your system!"
#endif
- return 0;
- }
-
- memset(&CONTEXT_REGS, 0, sizeof(CONTEXT_REGS));
-
- set_regs(r);
-
- CONTEXT_REGS.REG(cs) = seg;
- CONTEXT_REGS.REG(eip) = off;
-
- if (r->ss == 0 && r->sp == 0) {
- CONTEXT_REGS.REG(ss) = context.stack_seg;
- CONTEXT_REGS.REG(esp) = context.stack_off;
- } else {
- CONTEXT_REGS.REG(ss) = r->ss;
- CONTEXT_REGS.REG(esp) = r->sp;
- }
-
- pushw(DEFAULT_VM86_FLAGS);
- pushw(context.ret_seg);
- pushw(context.ret_off);
-
- vret = run_vm86();
-
- get_regs(r);
-
- return vret;
-}
-
-size_t
-LRMI_base_addr(void)
-{
- return 0;
-}
diff --git a/src/vm86/vm86.h b/src/vm86/vm86.h
new file mode 100644
index 0000000..0652cff
--- /dev/null
+++ b/src/vm86/vm86.h
@@ -0,0 +1,102 @@
+/*
+Copyright (C) 2008 by Tiago Vignatti <vignatti (at) c3sl ufpr br>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL JOSH VANDERHOOF BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#if defined(__linux__)
+
+#include <asm/vm86.h>
+#include <signal.h>
+
+#ifdef USE_LIBC_VM86
+#include <sys/vm86.h>
+#endif
+
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+
+#include <sys/param.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <machine/psl.h>
+#include <machine/vm86.h>
+#include <machine/sysarch.h>
+
+#endif /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ */
+
+#if defined(__FreeBSD__)
+#include <sys/ucontext.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#if defined(__linux__) && !defined(TF_MASK)
+#define TF_MASK X86_EFLAGS_TF
+#define IF_MASK X86_EFLAGS_IF
+#define VIF_MASK X86_EFLAGS_VIF
+#define IOPL_MASK X86_EFLAGS_IOPL
+#endif
+
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#define TF_MASK PSL_T
+#define VIF_MASK PSL_VIF
+#endif
+#define RETURN_TO_32_INT 255
+
+#if defined(__linux__)
+#define CONTEXT_REGS context.vm.regs
+#define REG(x) x
+#elif defined(__NetBSD__)
+#define CONTEXT_REGS context.vm.substr.regs
+#define REG(x) vmsc.sc_ ## x
+#elif defined(__FreeBSD__)
+#define CONTEXT_REGS context.vm.uc
+#define REG(x) uc_mcontext.mc_ ## x
+#endif
+
+
+typedef struct _vm86context {
+ int ready;
+ unsigned short ret_seg, ret_off;
+ unsigned short stack_seg, stack_off;
+#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ struct vm86_struct vm;
+#elif defined(__FreeBSD__)
+ struct {
+ struct vm86_init_args init;
+ ucontext_t uc;
+ } vm;
+#endif
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ int success;
+ jmp_buf env;
+ void *old_sighandler;
+ int vret;
+#endif
+} vm86context;
+
+
diff --git a/src/x86emu/Makefile.am b/src/x86emu/Makefile.am
index 2fc9337..c6ecc1b 100644
--- a/src/x86emu/Makefile.am
+++ b/src/x86emu/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libx86emu.la
+lib_LTLIBRARIES = libx86emu.la
libx86emu_la_SOURCES = debug.c \
decode.c \
@@ -6,10 +6,14 @@ libx86emu_la_SOURCES = debug.c \
ops2.c \
ops.c \
prim_ops.c \
- sys.c \
- x86emu.h
+ sys.c
-EXTRA_DIST = validate.c \
+INCLUDES =
+
+EXTRA_DIST = validate.c
+
+sdkdir = $(includedir)/x86emu
+sdk_HEADERS= x86emu.h \
x86emu/debug.h \
x86emu/decode.h \
x86emu/fpu.h \
@@ -17,7 +21,7 @@ EXTRA_DIST = validate.c \
x86emu/ops.h \
x86emu/prim_asm.h \
x86emu/prim_ops.h \
- x86emu/prim_x86_gcc.h \
+ x86emu/prim_x86_gcc.h \
x86emu/regs.h \
x86emu/types.h \
x86emu/x86emui.h
diff --git a/src/x86emu/ops2.c b/src/x86emu/ops2.c
index 324de8a..39bd041 100644
--- a/src/x86emu/ops2.c
+++ b/src/x86emu/ops2.c
@@ -40,6 +40,12 @@
#include "x86emu/x86emui.h"
+#undef bswap_32
+#define bswap_32(x) (((x & 0xff000000) >> 24) | \
+ ((x & 0x00ff0000) >> 8) | \
+ ((x & 0x0000ff00) << 8) | \
+ ((x & 0x000000ff) << 24))
+
/*----------------------------- Implementation ----------------------------*/
/****************************************************************************
@@ -104,7 +110,7 @@ Handles opcode 0x0f,0x80-0x8F
static void x86emuOp2_long_jump(u8 op2)
{
s32 target;
- char *name = 0;
+ char *name = NULL;
int cond = 0;
/* conditional jump to word offset. */
@@ -198,7 +204,7 @@ static void x86emuOp2_set_byte(u8 op2)
int mod, rl, rh;
uint destoffset;
u8 *destreg;
- char *name = 0;
+ char *name = NULL;
int cond = 0;
START_OF_INSTR();
@@ -2571,6 +2577,47 @@ static void x86emuOp2_movsx_word_R_RM(u8 X86EMU_UNUSED(op2))
END_OF_INSTR();
}
+/* Handles opcodes 0xc8-0xcf */
+static void x86emuOp2_bswap(u8 X86EMU_UNUSED(op2))
+{
+ START_OF_INSTR();
+ DECODE_PRINTF("BSWAP\n");
+ TRACE_AND_STEP();
+
+ switch (op2) {
+ case 0xc8:
+ M.x86.R_EAX = bswap_32(M.x86.R_EAX);
+ break;
+ case 0xc9:
+ M.x86.R_ECX = bswap_32(M.x86.R_ECX);
+ break;
+ case 0xca:
+ M.x86.R_EDX = bswap_32(M.x86.R_EDX);
+ break;
+ case 0xcb:
+ M.x86.R_EBX = bswap_32(M.x86.R_EBX);
+ break;
+ case 0xcc:
+ M.x86.R_ESP = bswap_32(M.x86.R_ESP);
+ break;
+ case 0xcd:
+ M.x86.R_EBP = bswap_32(M.x86.R_EBP);
+ break;
+ case 0xce:
+ M.x86.R_ESI = bswap_32(M.x86.R_ESI);
+ break;
+ case 0xcf:
+ M.x86.R_EDI = bswap_32(M.x86.R_EDI);
+ break;
+ default:
+ /* can't happen */
+ break;
+ }
+
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
/***************************************************************************
* Double byte operation code table:
**************************************************************************/
@@ -2788,14 +2835,14 @@ void (*x86emu_optab2[256])(u8) =
/* 0xc5 */ x86emuOp2_illegal_op,
/* 0xc6 */ x86emuOp2_illegal_op,
/* 0xc7 */ x86emuOp2_illegal_op,
-/* 0xc8 */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xc9 */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xca */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcb */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcc */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcd */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xce */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcf */ x86emuOp2_illegal_op, /* TODO: bswap */
+/* 0xc8 */ x86emuOp2_bswap,
+/* 0xc9 */ x86emuOp2_bswap,
+/* 0xca */ x86emuOp2_bswap,
+/* 0xcb */ x86emuOp2_bswap,
+/* 0xcc */ x86emuOp2_bswap,
+/* 0xcd */ x86emuOp2_bswap,
+/* 0xce */ x86emuOp2_bswap,
+/* 0xcf */ x86emuOp2_bswap,
/* 0xd0 */ x86emuOp2_illegal_op,
/* 0xd1 */ x86emuOp2_illegal_op,
diff --git a/src/x86emu/prim_ops.c b/src/x86emu/prim_ops.c
index b42cdc0..4a6ac5d 100644
--- a/src/x86emu/prim_ops.c
+++ b/src/x86emu/prim_ops.c
@@ -103,7 +103,7 @@
#include "x86emu/x86emui.h"
#if defined(__GNUC__)
-# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
+# if defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__amd64__)
# include "x86emu/prim_x86_gcc.h"
# endif
#endif
diff --git a/src/x86emu/sys.c b/src/x86emu/sys.c
index 4d90ea3..e15fb09 100644
--- a/src/x86emu/sys.c
+++ b/src/x86emu/sys.c
@@ -68,7 +68,7 @@ X86EMU_intrFuncs _X86EMU_intrTab[256];
* packed structures to talk about such things with.
*/
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
struct __una_u64 { unsigned long x __attribute__((packed)); };
struct __una_u32 { unsigned int x __attribute__((packed)); };
struct __una_u16 { unsigned short x __attribute__((packed)); };
@@ -76,7 +76,7 @@ struct __una_u16 { unsigned short x __attribute__((packed)); };
static __inline__ unsigned long ldq_u(unsigned long * r11)
{
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
return ptr->x;
#else
@@ -95,7 +95,7 @@ static __inline__ unsigned long ldq_u(unsigned long * r11)
static __inline__ unsigned long ldl_u(unsigned int * r11)
{
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
return ptr->x;
#else
@@ -114,7 +114,7 @@ static __inline__ unsigned long ldl_u(unsigned int * r11)
static __inline__ unsigned long ldw_u(unsigned short * r11)
{
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
return ptr->x;
#else
@@ -137,7 +137,7 @@ static __inline__ unsigned long ldw_u(unsigned short * r11)
static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
{
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
struct __una_u64 *ptr = (struct __una_u64 *) r11;
ptr->x = r5;
#else
@@ -162,7 +162,7 @@ static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
{
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
struct __una_u32 *ptr = (struct __una_u32 *) r11;
ptr->x = r5;
#else
@@ -187,7 +187,7 @@ static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
{
-#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC_MINOR__ >= 91))
+#if defined(__GNUC__)
struct __una_u16 *ptr = (struct __una_u16 *) r11;
ptr->x = r5;
#else
@@ -209,60 +209,6 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
:"r" (r5), "r" (r11));
#endif
}
-
-#elif defined(__GNUC__) && ((__GNUC__ < 3)) && \
- (defined (__ia64__) || defined (ia64__))
-#define IA64_UALOADS
-/*
- * EGCS 1.1 knows about arbitrary unaligned loads. Define some
- * packed structures to talk about such things with.
- */
-struct __una_u64 { unsigned long x __attribute__((packed)); };
-struct __una_u32 { unsigned int x __attribute__((packed)); };
-struct __una_u16 { unsigned short x __attribute__((packed)); };
-
-static __inline__ unsigned long
-__uldq (const unsigned long * r11)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
- return ptr->x;
-}
-
-static __inline__ unsigned long
-uldl (const unsigned int * r11)
-{
- const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
- return ptr->x;
-}
-
-static __inline__ unsigned long
-uldw (const unsigned short * r11)
-{
- const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
- return ptr->x;
-}
-
-static __inline__ void
-ustq (unsigned long r5, unsigned long * r11)
-{
- struct __una_u64 *ptr = (struct __una_u64 *) r11;
- ptr->x = r5;
-}
-
-static __inline__ void
-ustl (unsigned long r5, unsigned int * r11)
-{
- struct __una_u32 *ptr = (struct __una_u32 *) r11;
- ptr->x = r5;
-}
-
-static __inline__ void
-ustw (unsigned long r5, unsigned short * r11)
-{
- struct __una_u16 *ptr = (struct __una_u16 *) r11;
- ptr->x = r5;
-}
-
#endif
/****************************************************************************
diff --git a/src/x86emu/validate.c b/src/x86emu/validate.c
index 5e8860d..239f6c1 100644
--- a/src/x86emu/validate.c
+++ b/src/x86emu/validate.c
@@ -595,8 +595,8 @@ void printk(const char *fmt, ...)
{
va_list argptr;
va_start(argptr, fmt);
- vfprintf(stderr, fmt, argptr);
- fflush(stderr);
+ vfprintf(stdout, fmt, argptr);
+ fflush(stdout);
va_end(argptr);
}
diff --git a/src/x86emu/x86emu/debug.h b/src/x86emu/x86emu/debug.h
index 57f3546..47aacb6 100644
--- a/src/x86emu/x86emu/debug.h
+++ b/src/x86emu/x86emu/debug.h
@@ -101,11 +101,10 @@
#ifdef DEBUG
-# define DECODE_PRINTF(x) if (DEBUG_DECODE()) \
+# define DECODE_PRINTF(x) if (DEBUG_DECODE()) \
x86emu_decode_printf(x)
-
-# define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \
- x86emu_decode_printf2(x,y)
+# define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \
+ x86emu_decode_printf2(x,y)
/*
* The following allow us to look at the bytes of an instruction. The
@@ -125,8 +124,8 @@
}
#else
# define INC_DECODED_INST_LEN(x)
-# define DECODE_PRINTF(x)
-# define DECODE_PRINTF2(x,y)
+# define DECODE_PRINTF(x)
+# define DECODE_PRINTF2(x,y)
# define SAVE_IP_CS(x,y)
#endif
diff --git a/src/x86emu/x86emu/prim_ops.h b/src/x86emu/x86emu/prim_ops.h
index d4441c7..6ac2a29 100644
--- a/src/x86emu/x86emu/prim_ops.h
+++ b/src/x86emu/x86emu/prim_ops.h
@@ -39,8 +39,6 @@
#ifndef __X86EMU_PRIM_OPS_H
#define __X86EMU_PRIM_OPS_H
-#include "prim_asm.h"
-
#ifdef __cplusplus
extern "C" { /* Use "C" linkage when in C++ mode */
#endif
@@ -137,94 +135,6 @@ u16 pop_word (void);
u32 pop_long (void);
void cpuid (void);
-#if defined(__HAVE_INLINE_ASSEMBLER__) && !defined(PRIM_OPS_NO_REDEFINE_ASM)
-
-#define aaa_word(d) aaa_word_asm(&M.x86.R_EFLG,d)
-#define aas_word(d) aas_word_asm(&M.x86.R_EFLG,d)
-#define aad_word(d) aad_word_asm(&M.x86.R_EFLG,d)
-#define aam_word(d) aam_word_asm(&M.x86.R_EFLG,d)
-#define adc_byte(d,s) adc_byte_asm(&M.x86.R_EFLG,d,s)
-#define adc_word(d,s) adc_word_asm(&M.x86.R_EFLG,d,s)
-#define adc_long(d,s) adc_long_asm(&M.x86.R_EFLG,d,s)
-#define add_byte(d,s) add_byte_asm(&M.x86.R_EFLG,d,s)
-#define add_word(d,s) add_word_asm(&M.x86.R_EFLG,d,s)
-#define add_long(d,s) add_long_asm(&M.x86.R_EFLG,d,s)
-#define and_byte(d,s) and_byte_asm(&M.x86.R_EFLG,d,s)
-#define and_word(d,s) and_word_asm(&M.x86.R_EFLG,d,s)
-#define and_long(d,s) and_long_asm(&M.x86.R_EFLG,d,s)
-#define cmp_byte(d,s) cmp_byte_asm(&M.x86.R_EFLG,d,s)
-#define cmp_word(d,s) cmp_word_asm(&M.x86.R_EFLG,d,s)
-#define cmp_long(d,s) cmp_long_asm(&M.x86.R_EFLG,d,s)
-#define daa_byte(d) daa_byte_asm(&M.x86.R_EFLG,d)
-#define das_byte(d) das_byte_asm(&M.x86.R_EFLG,d)
-#define dec_byte(d) dec_byte_asm(&M.x86.R_EFLG,d)
-#define dec_word(d) dec_word_asm(&M.x86.R_EFLG,d)
-#define dec_long(d) dec_long_asm(&M.x86.R_EFLG,d)
-#define inc_byte(d) inc_byte_asm(&M.x86.R_EFLG,d)
-#define inc_word(d) inc_word_asm(&M.x86.R_EFLG,d)
-#define inc_long(d) inc_long_asm(&M.x86.R_EFLG,d)
-#define or_byte(d,s) or_byte_asm(&M.x86.R_EFLG,d,s)
-#define or_word(d,s) or_word_asm(&M.x86.R_EFLG,d,s)
-#define or_long(d,s) or_long_asm(&M.x86.R_EFLG,d,s)
-#define neg_byte(s) neg_byte_asm(&M.x86.R_EFLG,s)
-#define neg_word(s) neg_word_asm(&M.x86.R_EFLG,s)
-#define neg_long(s) neg_long_asm(&M.x86.R_EFLG,s)
-#define not_byte(s) not_byte_asm(&M.x86.R_EFLG,s)
-#define not_word(s) not_word_asm(&M.x86.R_EFLG,s)
-#define not_long(s) not_long_asm(&M.x86.R_EFLG,s)
-#define rcl_byte(d,s) rcl_byte_asm(&M.x86.R_EFLG,d,s)
-#define rcl_word(d,s) rcl_word_asm(&M.x86.R_EFLG,d,s)
-#define rcl_long(d,s) rcl_long_asm(&M.x86.R_EFLG,d,s)
-#define rcr_byte(d,s) rcr_byte_asm(&M.x86.R_EFLG,d,s)
-#define rcr_word(d,s) rcr_word_asm(&M.x86.R_EFLG,d,s)
-#define rcr_long(d,s) rcr_long_asm(&M.x86.R_EFLG,d,s)
-#define rol_byte(d,s) rol_byte_asm(&M.x86.R_EFLG,d,s)
-#define rol_word(d,s) rol_word_asm(&M.x86.R_EFLG,d,s)
-#define rol_long(d,s) rol_long_asm(&M.x86.R_EFLG,d,s)
-#define ror_byte(d,s) ror_byte_asm(&M.x86.R_EFLG,d,s)
-#define ror_word(d,s) ror_word_asm(&M.x86.R_EFLG,d,s)
-#define ror_long(d,s) ror_long_asm(&M.x86.R_EFLG,d,s)
-#define shl_byte(d,s) shl_byte_asm(&M.x86.R_EFLG,d,s)
-#define shl_word(d,s) shl_word_asm(&M.x86.R_EFLG,d,s)
-#define shl_long(d,s) shl_long_asm(&M.x86.R_EFLG,d,s)
-#define shr_byte(d,s) shr_byte_asm(&M.x86.R_EFLG,d,s)
-#define shr_word(d,s) shr_word_asm(&M.x86.R_EFLG,d,s)
-#define shr_long(d,s) shr_long_asm(&M.x86.R_EFLG,d,s)
-#define sar_byte(d,s) sar_byte_asm(&M.x86.R_EFLG,d,s)
-#define sar_word(d,s) sar_word_asm(&M.x86.R_EFLG,d,s)
-#define sar_long(d,s) sar_long_asm(&M.x86.R_EFLG,d,s)
-#define shld_word(d,fill,s) shld_word_asm(&M.x86.R_EFLG,d,fill,s)
-#define shld_long(d,fill,s) shld_long_asm(&M.x86.R_EFLG,d,fill,s)
-#define shrd_word(d,fill,s) shrd_word_asm(&M.x86.R_EFLG,d,fill,s)
-#define shrd_long(d,fill,s) shrd_long_asm(&M.x86.R_EFLG,d,fill,s)
-#define sbb_byte(d,s) sbb_byte_asm(&M.x86.R_EFLG,d,s)
-#define sbb_word(d,s) sbb_word_asm(&M.x86.R_EFLG,d,s)
-#define sbb_long(d,s) sbb_long_asm(&M.x86.R_EFLG,d,s)
-#define sub_byte(d,s) sub_byte_asm(&M.x86.R_EFLG,d,s)
-#define sub_word(d,s) sub_word_asm(&M.x86.R_EFLG,d,s)
-#define sub_long(d,s) sub_long_asm(&M.x86.R_EFLG,d,s)
-#define test_byte(d,s) test_byte_asm(&M.x86.R_EFLG,d,s)
-#define test_word(d,s) test_word_asm(&M.x86.R_EFLG,d,s)
-#define test_long(d,s) test_long_asm(&M.x86.R_EFLG,d,s)
-#define xor_byte(d,s) xor_byte_asm(&M.x86.R_EFLG,d,s)
-#define xor_word(d,s) xor_word_asm(&M.x86.R_EFLG,d,s)
-#define xor_long(d,s) xor_long_asm(&M.x86.R_EFLG,d,s)
-#define imul_byte(s) imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s)
-#define imul_word(s) imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s)
-#define imul_long(s) imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s)
-#define imul_long_direct(res_lo,res_hi,d,s) imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s)
-#define mul_byte(s) mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s)
-#define mul_word(s) mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s)
-#define mul_long(s) mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s)
-#define idiv_byte(s) idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s)
-#define idiv_word(s) idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s)
-#define idiv_long(s) idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s)
-#define div_byte(s) div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s)
-#define div_word(s) div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s)
-#define div_long(s) div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s)
-
-#endif
-
#ifdef __cplusplus
} /* End of "C" linkage for C++ */
#endif
diff --git a/src/x86emu/x86emu/prim_x86_gcc.h b/src/x86emu/x86emu/prim_x86_gcc.h
index af61e20..5530a3a 100644
--- a/src/x86emu/x86emu/prim_x86_gcc.h
+++ b/src/x86emu/x86emu/prim_x86_gcc.h
@@ -42,7 +42,7 @@
#include "x86emu/types.h"
-#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__))
+#if !defined(__GNUC__) || !(defined (__i386__) || defined(__i386) || defined(__AMD64__) || defined(__amd64__))
#error This file is intended to be used by gcc on i386 or x86-64 system
#endif
diff --git a/src/x86emu/x86emu/types.h b/src/x86emu/x86emu/types.h
index c0c09c1..c18e11c 100644
--- a/src/x86emu/x86emu/types.h
+++ b/src/x86emu/x86emu/types.h
@@ -74,9 +74,8 @@
defined(__ia64__) || defined(ia64) || \
defined(__sparc64__) || \
defined(__s390x__) || \
- (defined(__hppa__) && defined(__LP64)) || \
- defined(__amd64__) || defined(amd64) || \
- (defined(__sgi) && (_MIPS_SZLONG == 64))
+ defined(__hppa__) && defined(__LP64) || \
+ defined(__amd64__) || defined(amd64)
#define NUM32 int
#else
#define NUM32 long