summaryrefslogtreecommitdiff
path: root/source/ap/libx86
diff options
context:
space:
mode:
Diffstat (limited to 'source/ap/libx86')
-rw-r--r--source/ap/libx86/libx86-add-pkgconfig.patch64
-rw-r--r--source/ap/libx86/libx86-mmap-offset.patch187
-rwxr-xr-xsource/ap/libx86/libx86.SlackBuild14
-rw-r--r--source/ap/libx86/lrmi.c.diff18
4 files changed, 258 insertions, 25 deletions
diff --git a/source/ap/libx86/libx86-add-pkgconfig.patch b/source/ap/libx86/libx86-add-pkgconfig.patch
new file mode 100644
index 00000000..3aeaff79
--- /dev/null
+++ b/source/ap/libx86/libx86-add-pkgconfig.patch
@@ -0,0 +1,64 @@
+From fc4f25c4d16aaff7dcb5dd42cc20b292f4eb2218 Mon Sep 17 00:00:00 2001
+From: Dave Airlie <airlied@redhat.com>
+Date: Tue, 4 Aug 2009 13:08:42 +1000
+Subject: [PATCH] git add x86.pc
+
+---
+ Makefile | 15 ++++++++++++---
+ x86.pc.in | 10 ++++++++++
+ 2 files changed, 22 insertions(+), 3 deletions(-)
+ create mode 100644 x86.pc.in
+
+diff --git a/Makefile b/Makefile
+index 951b617..953a499 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,6 +1,7 @@
+ OBJECTS = x86-common.o
+ CFLAGS ?= -O2 -Wall -DDEBUG -g
+ LIBDIR ?= /usr/lib
++INCLUDEDIR ?= /usr/include
+
+ ifeq ($(BACKEND),x86emu)
+ OBJECTS += thunk.o x86emu/decode.o x86emu/debug.o x86emu/fpu.o \
+@@ -29,10 +30,18 @@ objclean:
+ rm -f *.o *~
+
+ clean: objclean
+- rm -f *.so.1 *.a
++ rm -f *.so.1 *.a x86.pc
+
+-install: libx86.so.1
++x86.pc:
++ sed -e's,@prefix@,/usr,' x86.pc.in > x86.pc
++ sed -e's,@exec_prefix@,/usr,' -i x86.pc
++ sed -e's,@libdir@,${LIBDIR},' -i x86.pc
++ sed -e's,@includedir@,${INCLUDEDIR},' -i x86.pc
++ sed -e's,@PACKAGE_VERSION@,1.1,' -i x86.pc
++
++install: libx86.so.1 x86.pc
+ install -D libx86.so.1 $(DESTDIR)$(LIBDIR)/libx86.so.1
+ install -D libx86.a $(DESTDIR)$(LIBDIR)/libx86.a
++ install -D x86.pc $(DESTDIR)$(LIBDIR)/pkgconfig/x86.pc
+ ln -sf libx86.so.1 $(DESTDIR)$(LIBDIR)/libx86.so
+- install -p -m 0644 -D lrmi.h $(DESTDIR)/usr/include/libx86.h
++ install -p -m 0644 -D lrmi.h $(DESTDIR)$(INCLUDEDIR)/libx86.h
+diff --git a/x86.pc.in b/x86.pc.in
+new file mode 100644
+index 0000000..711d90d
+--- /dev/null
++++ b/x86.pc.in
+@@ -0,0 +1,10 @@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++includedir=@includedir@
++
++Name: x86
++Description: Library providing x86 emulator access
++Version: @PACKAGE_VERSION@
++Cflags: -I${includedir}
++Libs: -L${libdir} -lx86
+--
+1.5.4.1
+
diff --git a/source/ap/libx86/libx86-mmap-offset.patch b/source/ap/libx86/libx86-mmap-offset.patch
new file mode 100644
index 00000000..881bc661
--- /dev/null
+++ b/source/ap/libx86/libx86-mmap-offset.patch
@@ -0,0 +1,187 @@
+diff -ur libx86-1.1/lrmi.c libx86-1.1.hack/lrmi.c
+--- libx86-1.1/lrmi.c 2006-10-30 15:10:16.000000000 -0500
++++ libx86-1.1.hack/lrmi.c 2009-10-26 15:55:42.000000000 -0400
+@@ -136,7 +136,7 @@
+ if (context.ready)
+ return 1;
+
+- if (!LRMI_common_init())
++ if (!LRMI_common_init(0))
+ return 0;
+
+ /*
+diff -ur libx86-1.1/thunk.c libx86-1.1.hack/thunk.c
+--- libx86-1.1/thunk.c 2008-04-02 20:48:00.000000000 -0400
++++ libx86-1.1.hack/thunk.c 2009-10-26 16:05:39.000000000 -0400
+@@ -139,11 +139,11 @@
+ int i;
+ X86EMU_intrFuncs intFuncs[256];
+
+- if (!LRMI_common_init())
++ mmap_addr = LRMI_common_init(1);
++
++ if (!mmap_addr)
+ return 0;
+
+- mmap_addr = 0;
+-
+ X86EMU_pioFuncs pioFuncs = {
+ (&x_inb),
+ (&x_inw),
+@@ -169,10 +169,10 @@
+ X86_ESP = 0xFFF9;
+ memset (stack, 0, 64*1024);
+
+- *((char *)0) = 0x4f; /* Make sure that we end up jumping back to a
+- halt instruction */
++ *mmap_addr = 0x4f; /* Make sure that we end up jumping back to a
++ halt instruction */
+
+- M.mem_base = 0;
++ M.mem_base = (unsigned long)mmap_addr;
+ M.mem_size = 1024*1024;
+
+ return 1;
+diff -ur libx86-1.1/x86-common.c libx86-1.1.hack/x86-common.c
+--- libx86-1.1/x86-common.c 2008-05-16 12:56:23.000000000 -0400
++++ libx86-1.1.hack/x86-common.c 2009-10-26 16:03:21.000000000 -0400
+@@ -45,14 +45,15 @@
+ static struct {
+ int ready;
+ int count;
++ void *offset;
+ struct mem_block blocks[REAL_MEM_BLOCKS];
+ } mem_info = { 0 };
+
+ static int
+-real_mem_init(void)
++real_mem_init(int high_page)
+ {
+ void *m;
+- int fd_zero;
++ int fd_zero, flags = MAP_SHARED;
+
+ if (mem_info.ready)
+ return 1;
+@@ -63,9 +64,12 @@
+ return 0;
+ }
+
++ if (!high_page)
++ flags |= MAP_FIXED;
++
+ m = mmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE,
+- PROT_READ | PROT_WRITE | PROT_EXEC,
+- MAP_FIXED | MAP_SHARED, fd_zero, 0);
++ PROT_READ | PROT_WRITE | PROT_EXEC,
++ flags, fd_zero, 0);
+
+ if (m == (void *)-1) {
+ perror("mmap /dev/zero");
+@@ -76,6 +80,7 @@
+ close(fd_zero);
+
+ mem_info.ready = 1;
++ mem_info.offset = m;
+ mem_info.count = 1;
+ mem_info.blocks[0].size = REAL_MEM_SIZE;
+ mem_info.blocks[0].free = 1;
+@@ -87,7 +92,7 @@
+ real_mem_deinit(void)
+ {
+ if (mem_info.ready) {
+- munmap((void *)REAL_MEM_BASE, REAL_MEM_SIZE);
++ munmap(mem_info.offset, REAL_MEM_SIZE);
+ mem_info.ready = 0;
+ }
+ }
+@@ -119,7 +124,7 @@
+ LRMI_alloc_real(int size)
+ {
+ int i;
+- char *r = (char *)REAL_MEM_BASE;
++ char *r = (char *)mem_info.offset;
+
+ if (!mem_info.ready)
+ return NULL;
+@@ -151,7 +156,7 @@
+ LRMI_free_real(void *m)
+ {
+ int i;
+- char *r = (char *)REAL_MEM_BASE;
++ char *r = (char *)mem_info.offset;
+
+ if (!mem_info.ready)
+ return;
+@@ -200,13 +205,15 @@
+ return *(unsigned short *)(i * 4);
+ }
+
+-int LRMI_common_init(void)
++void *LRMI_common_init(int high_page)
+ {
+- void *m;
++ void *m, *offset;
+ int fd_mem;
+
+- if (!real_mem_init())
+- return 0;
++ if (!real_mem_init(high_page))
++ return NULL;
++
++ offset = mem_info.offset - REAL_MEM_BASE;
+
+ /*
+ Map the Interrupt Vectors (0x0 - 0x400) + BIOS data (0x400 - 0x502)
+@@ -217,33 +224,33 @@
+ if (fd_mem == -1) {
+ real_mem_deinit();
+ perror("open /dev/mem");
+- return 0;
++ return NULL;
+ }
+
+- m = mmap((void *)0, 0x502,
+- PROT_READ | PROT_WRITE | PROT_EXEC,
+- MAP_FIXED | MAP_SHARED, fd_mem, 0);
++ m = mmap(offset, 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;
++ return NULL;
+ }
+
+- m = mmap((void *)0xa0000, 0x100000 - 0xa0000,
++ m = mmap(offset+0xa0000, 0x100000 - 0xa0000,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_FIXED | MAP_SHARED, fd_mem, 0xa0000);
+
+ if (m == (void *)-1) {
+- munmap((void *)0, 0x502);
++ munmap(offset, 0x502);
+ close(fd_mem);
+ real_mem_deinit();
+ perror("mmap /dev/mem");
+- return 0;
++ return NULL;
+ }
+
+ close(fd_mem);
+
+- return 1;
++ return offset;
+ }
+diff -ur libx86-1.1/x86-common.h libx86-1.1.hack/x86-common.h
+--- libx86-1.1/x86-common.h 2006-09-07 18:44:27.000000000 -0400
++++ libx86-1.1.hack/x86-common.h 2009-10-26 16:01:19.000000000 -0400
+@@ -40,4 +40,4 @@
+
+ void *LRMI_alloc_real(int size);
+ void LRMI_free_real(void *m);
+-int LRMI_common_init(void);
++void *LRMI_common_init(int high_page);
diff --git a/source/ap/libx86/libx86.SlackBuild b/source/ap/libx86/libx86.SlackBuild
index bd075348..2f5426e3 100755
--- a/source/ap/libx86/libx86.SlackBuild
+++ b/source/ap/libx86/libx86.SlackBuild
@@ -24,12 +24,12 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
VERSION=${VERSION:-1.1}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-2}
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
- i?86) export ARCH=i486 ;;
+ i?86) export ARCH=i586 ;;
arm*) export ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) export ARCH=$( uname -m ) ;;
@@ -40,8 +40,8 @@ CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-libx86
-if [ "$ARCH" = "i486" ]; then
- SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
@@ -67,10 +67,10 @@ find . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
-# Add a patch from Gentoo to make this build on 2.6.26+
-zcat $CWD/lrmi.c.diff.gz | patch -p1 || exit 1
+zcat $CWD/libx86-add-pkgconfig.patch.gz | patch -p1 --verbose || exit 1
+zcat $CWD/libx86-mmap-offset.patch.gz | patch -p1 --verbose || exit 1
-make BACKEND=x86emu LIBDIR=/usr/lib${LIBDIRSUFFIX} || exit 1
+make CFLAGS="$SLKCFLAGS" BACKEND=x86emu LIBDIR=/usr/lib${LIBDIRSUFFIX} || exit 1
make install DESTDIR=$PKG LIBDIR=/usr/lib${LIBDIRSUFFIX}
# Kill the static library; we shouldn't need it
diff --git a/source/ap/libx86/lrmi.c.diff b/source/ap/libx86/lrmi.c.diff
deleted file mode 100644
index 24f4510f..00000000
--- a/source/ap/libx86/lrmi.c.diff
+++ /dev/null
@@ -1,18 +0,0 @@
-# Patch from Gentoo: http://bugs.gentoo.org/235599
-
---- old/lrmi.c 2006-10-30 21:10:16.000000000 +0100
-+++ new/lrmi.c 2008-08-27 11:32:40.000000000 +0200
-@@ -64,6 +64,13 @@
- #define DEFAULT_STACK_SIZE 0x1000
- #define RETURN_TO_32_INT 255
-
-+#ifndef IF_MASK
-+#define IF_MASK X86_EFLAGS_VIF
-+#define IOPL_MASK X86_EFLAGS_IOPL
-+#define VIF_MASK X86_EFLAGS_VIF
-+#define TF_MASK X86_EFLAGS_TF
-+#endif
-+
- #if defined(__linux__)
- #define CONTEXT_REGS context.vm.regs
- #define REG(x)