summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@nokia.com>2009-12-30 20:33:23 +0200
committerTiago Vignatti <tiago.vignatti@nokia.com>2009-12-30 20:33:23 +0200
commit46e90216028779ae1f890af8989874f60a9b3d2e (patch)
treeb828abed5ae5ffa514953b4b7b24c97770d603d5 /src
parente75d1f56c3d2f74c4c6e3b2010aaa700333e5abb (diff)
Import vm86 code from X
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/lrmi/Makefile.am4
-rw-r--r--src/lrmi/backend-vm86.c29
-rw-r--r--src/lrmi/backend-x86emu.c89
-rw-r--r--src/lrmi/common_helper.c66
-rw-r--r--src/lrmi/common_helper.h2
-rw-r--r--src/lrmi/common_io.c94
-rw-r--r--src/lrmi/linux_vm86.c402
-rw-r--r--src/vm86/Makefile.am1
-rw-r--r--src/vm86/vm86.c3
9 files changed, 596 insertions, 94 deletions
diff --git a/src/lrmi/Makefile.am b/src/lrmi/Makefile.am
index afdd224..57cab11 100644
--- a/src/lrmi/Makefile.am
+++ b/src/lrmi/Makefile.am
@@ -6,12 +6,12 @@ BACKEND_LIBRARY = $(top_srcdir)/src/x86emu/libx86emu.la
BACKEND_INCLUDES = -I$(top_srcdir)/src/x86emu
else # VM86
AM_CFLAGS = -D_VM86
-BACKEND_SRC = backend-vm86.c
+BACKEND_SRC = backend-vm86.c linux_vm86.c
BACKEND_LIBRARY = $(top_srcdir)/src/vm86/libvm86.la
BACKEND_INCLUDES = -I$(top_srcdir)/src/vm86
endif
-libx86_la_SOURCES = common.c common_helper.c $(BACKEND_SRC)
+libx86_la_SOURCES = common.c common_io.c common_helper.c $(BACKEND_SRC)
libx86_la_LIBADD = $(BACKEND_LIBRARY) $(PCIACCESS_LIBS)
INCLUDES = -I$(top_srcdir)/include $(BACKEND_INCLUDES) $(PCIACCESS_CFLAGS)
diff --git a/src/lrmi/backend-vm86.c b/src/lrmi/backend-vm86.c
index c8c14a2..ec0dd21 100644
--- a/src/lrmi/backend-vm86.c
+++ b/src/lrmi/backend-vm86.c
@@ -26,10 +26,10 @@ OTHER DEALINGS IN THE SOFTWARE.
#if defined(__i386__) && (defined(__linux__) || defined(__NetBSD__) \
|| defined(__FreeBSD__) || defined(__OpenBSD__))
+#include <stdio.h>
#include <string.h>
#include "libx86.h"
#include "common.h"
-#include "vm86.h"
#if defined(__linux__)
#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK)
@@ -49,6 +49,7 @@ set_bit(unsigned int bit, void *array)
void
LRMI_init(xf86Int10InfoPtr pInt)
{
+ xxxf86Int10ExecSetup(pInt);
#if 0
void *m;
@@ -168,7 +169,31 @@ LRMI_call(struct LRMI_regs *r)
void
LRMI_int(xf86Int10InfoPtr pInt)
{
-#if 0
+ int num = pInt->num;
+ int ret = 0;
+
+ pre_int(pInt);
+
+ switch (num) {
+ case 0xe6:
+ ret = intE6_handler(pInt);
+ break;
+ default:
+ break;
+ }
+
+ if (!ret)
+ ret = run_bios_int(num, pInt);
+
+ if (!ret) {
+ fprintf(stderr, "Halting on int 0x%2.2x!\n", num);
+ }
+
+ while(do_vm86(pInt)) {};
+
+ pos_int(pInt);
+
+#if 0
int
LRMI_int(int i, struct LRMI_regs *r)
{
diff --git a/src/lrmi/backend-x86emu.c b/src/lrmi/backend-x86emu.c
index f65dc40..24cdd2a 100644
--- a/src/lrmi/backend-x86emu.c
+++ b/src/lrmi/backend-x86emu.c
@@ -7,7 +7,7 @@
#include "common_helper.h"
-xf86Int10InfoPtr Int10Current = NULL;
+extern Int10Current;
#define CARD8 unsigned char
#define CARD16 unsigned short
@@ -157,52 +157,6 @@ LRMI_base_addr(xf86Int10InfoPtr pInt, CARD32 addr)
}
static CARD8
-x_inb(CARD16 port)
-{
- CARD8 val;
-
- val = inb_local(Int10Current->ioBase + port);
- return val;
-}
-
-static CARD16
-x_inw(CARD16 port)
-{
- CARD16 val;
-
- val = inw_local(Int10Current->ioBase + port);
-
- return val;
-}
-
-static CARD32
-x_inl(CARD16 port)
-{
- CARD32 val;
-
- val = inl_local(Int10Current->ioBase + port);
- return val;
-}
-
-static void
-x_outl(CARD16 port, CARD32 val)
-{
- outl_local(Int10Current->ioBase + port, val);
-}
-
-static void
-x_outb(CARD16 port, CARD8 val)
-{
- outb_local(Int10Current->ioBase + port, val);
-}
-
-static void
-x_outw(CARD16 port, CARD16 val)
-{
- outw_local(Int10Current->ioBase + port, val);
-}
-
-static CARD8
Mem_rb(CARD32 addr)
{
return (*Int10Current->mem->rb)(Int10Current, addr);
@@ -239,13 +193,6 @@ Mem_wl(CARD32 addr, CARD32 val)
}
static void
-pushw(xf86Int10InfoPtr pInt, CARD16 val)
-{
- X86_ESP -= 2;
- MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val);
-}
-
-static void
x86emu_do_int(int num)
{
Int10Current->num = num;
@@ -253,40 +200,6 @@ x86emu_do_int(int num)
run_bios_int(num, Int10Current);
}
-static void
-pre_int(xf86Int10InfoPtr pInt)
-{
- Int10Current = pInt;
- X86_EAX = (CARD32) pInt->ax;
- X86_EBX = (CARD32) pInt->bx;
- X86_ECX = (CARD32) pInt->cx;
- X86_EDX = (CARD32) pInt->dx;
- X86_ESI = (CARD32) pInt->si;
- X86_EDI = (CARD32) pInt->di;
- X86_EBP = (CARD32) pInt->bp;
- X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
- X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
- X86_DS = 0x40; /* standard pc ds */
- X86_ES = pInt->es;
- X86_FS = 0;
- X86_GS = 0;
- X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
-}
-
-static void
-pos_int(xf86Int10InfoPtr pInt)
-{
- pInt->ax = (CARD32) X86_EAX;
- pInt->bx = (CARD32) X86_EBX;
- pInt->cx = (CARD32) X86_ECX;
- pInt->dx = (CARD32) X86_EDX;
- pInt->si = (CARD32) X86_ESI;
- pInt->di = (CARD32) X86_EDI;
- pInt->es = (CARD16) X86_ES;
- pInt->bp = (CARD32) X86_EBP;
- pInt->flags = (CARD32) X86_FLAGS;
-}
-
void
LRMI_int(xf86Int10InfoPtr pInt)
{
diff --git a/src/lrmi/common_helper.c b/src/lrmi/common_helper.c
index 24b095b..8de7d14 100644
--- a/src/lrmi/common_helper.c
+++ b/src/lrmi/common_helper.c
@@ -1,7 +1,45 @@
+#include <stdio.h>
#include <inttypes.h>
#include <pciaccess.h>
+
+#include "libx86.h"
#include "common_helper.h"
+xf86Int10InfoPtr Int10Current = NULL;
+
+void
+pre_int(xf86Int10InfoPtr pInt)
+{
+ Int10Current = pInt;
+ X86_EAX = (uint32_t) pInt->ax;
+ X86_EBX = (uint32_t) pInt->bx;
+ X86_ECX = (uint32_t) pInt->cx;
+ X86_EDX = (uint32_t) pInt->dx;
+ X86_ESI = (uint32_t) pInt->si;
+ X86_EDI = (uint32_t) pInt->di;
+ X86_EBP = (uint32_t) pInt->bp;
+ X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
+ X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
+ X86_DS = 0x40; /* standard pc ds */
+ X86_ES = pInt->es;
+ X86_FS = 0;
+ X86_GS = 0;
+ X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
+}
+
+void
+pos_int(xf86Int10InfoPtr pInt)
+{
+ pInt->ax = (uint32_t) X86_EAX;
+ pInt->bx = (uint32_t) X86_EBX;
+ pInt->cx = (uint32_t) X86_ECX;
+ pInt->dx = (uint32_t) X86_EDX;
+ pInt->si = (uint32_t) X86_ESI;
+ pInt->di = (uint32_t) X86_EDI;
+ pInt->es = (uint32_t) X86_ES;
+ pInt->bp = (uint32_t) X86_EBP;
+ pInt->flags = (uint32_t) X86_FLAGS;
+}
int
run_bios_int(int num, xf86Int10InfoPtr pInt)
@@ -34,3 +72,31 @@ intE6_handler(xf86Int10InfoPtr pInt)
X86_ES = 0; /* standard pc es */
return 1;
}
+
+void
+pushw(xf86Int10InfoPtr pInt, uint16_t val)
+{
+ X86_ESP -= 2;
+ MEM_WW(pInt, ((uint32_t) X86_SS << 4) + X86_SP, val);
+}
+
+int
+int_handler(xf86Int10InfoPtr pInt)
+{
+ int num = pInt->num;
+ int ret = 0;
+
+ switch (num) {
+ case 0xe6:
+ ret = intE6_handler(pInt);
+ break;
+ default:
+ break;
+ }
+
+ if (!ret)
+ ret = run_bios_int(num, pInt);
+
+ return ret;
+}
+
diff --git a/src/lrmi/common_helper.h b/src/lrmi/common_helper.h
index b3fd90d..9f72694 100644
--- a/src/lrmi/common_helper.h
+++ b/src/lrmi/common_helper.h
@@ -1,4 +1,4 @@
-#include "libx86.h"
+//#include "libx86.h"
#ifdef _VM86
diff --git a/src/lrmi/common_io.c b/src/lrmi/common_io.c
new file mode 100644
index 0000000..372d504
--- /dev/null
+++ b/src/lrmi/common_io.c
@@ -0,0 +1,94 @@
+#include <inttypes.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "libx86.h"
+#include "common.h"
+#include "common_helper.h"
+
+extern xf86Int10InfoPtr Int10Current;
+
+static uint8_t
+x_inb(uint16_t port)
+{
+ uint8_t val;
+
+ val = inb_local(Int10Current->ioBase + port);
+ return val;
+}
+
+static uint16_t
+x_inw(uint16_t port)
+{
+ uint16_t val;
+
+ val = inw_local(Int10Current->ioBase + port);
+
+ return val;
+}
+
+static uint32_t
+x_inl(uint16_t port)
+{
+ uint32_t val;
+
+ val = inl_local(Int10Current->ioBase + port);
+ return val;
+}
+
+static void
+x_outl(uint16_t port, uint32_t val)
+{
+ outl_local(Int10Current->ioBase + port, val);
+}
+
+static void
+x_outb(uint16_t port, uint8_t val)
+{
+ outb_local(Int10Current->ioBase + port, val);
+}
+
+static void
+x_outw(uint16_t port, uint16_t val)
+{
+ outw_local(Int10Current->ioBase + port, val);
+}
+
+static uint8_t
+Mem_rb(uint32_t addr)
+{
+ return (*Int10Current->mem->rb)(Int10Current, addr);
+}
+
+static uint16_t
+Mem_rw(uint32_t addr)
+{
+ return (*Int10Current->mem->rw)(Int10Current, addr);
+}
+
+#if 0
+static uint32_t
+Mem_rl(uint32_t addr)
+{
+ return (*Int10Current->mem->rl)(Int10Current, addr);
+}
+
+static void
+Mem_wb(uint32_t addr, uint8_t val)
+{
+ (*Int10Current->mem->wb)(Int10Current, addr, val);
+}
+
+static void
+Mem_ww(uint32_t addr, uint16_t val)
+{
+ (*Int10Current->mem->ww)(Int10Current, addr, val);
+}
+
+static void
+Mem_wl(uint32_t addr, uint32_t val)
+{
+ (*Int10Current->mem->wl)(Int10Current, addr, val);
+}
+#endif
diff --git a/src/lrmi/linux_vm86.c b/src/lrmi/linux_vm86.c
new file mode 100644
index 0000000..fc9adf8
--- /dev/null
+++ b/src/lrmi/linux_vm86.c
@@ -0,0 +1,402 @@
+#include <inttypes.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "libx86.h"
+#include "common.h"
+#include "common_helper.h"
+
+
+static int vm86_rep(struct vm86_struct *ptr);
+static struct vm86_struct vm86_s;
+
+int
+port_rep_inb(xf86Int10InfoPtr pInt,
+ uint16_t port, uint32_t base, int d_f, uint32_t count)
+{
+ register int inc = d_f ? -1 : 1;
+ uint32_t dst = base;
+ while (count--) {
+ MEM_WB(pInt, dst, x_inb(port));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_inw(xf86Int10InfoPtr pInt,
+ uint16_t port, uint32_t base, int d_f, uint32_t count)
+{
+ register int inc = d_f ? -2 : 2;
+ uint32_t dst = base;
+ while (count--) {
+ MEM_WW(pInt, dst, x_inw(port));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_inl(xf86Int10InfoPtr pInt,
+ uint16_t port, uint32_t base, int d_f, uint32_t count)
+{
+ register int inc = d_f ? -4 : 4;
+ uint32_t dst = base;
+ while (count--) {
+ MEM_WL(pInt, dst, x_inl(port));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_outb(xf86Int10InfoPtr pInt,
+ uint16_t port, uint32_t base, int d_f, uint32_t count)
+{
+ register int inc = d_f ? -1 : 1;
+ uint32_t dst = base;
+ while (count--) {
+ x_outb(port, MEM_RB(pInt, dst));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_outw(xf86Int10InfoPtr pInt,
+ uint16_t port, uint32_t base, int d_f, uint32_t count)
+{
+ register int inc = d_f ? -2 : 2;
+ uint32_t dst = base;
+ while (count--) {
+ x_outw(port, MEM_RW(pInt, dst));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+port_rep_outl(xf86Int10InfoPtr pInt,
+ uint16_t port, uint32_t base, int d_f, uint32_t count)
+{
+ register int inc = d_f ? -4 : 4;
+ uint32_t dst = base;
+ while (count--) {
+ x_outl(port, MEM_RL(pInt, dst));
+ dst += inc;
+ }
+ return dst - base;
+}
+
+int
+xxxf86Int10ExecSetup(xf86Int10InfoPtr pInt)
+{
+#define VM86S ((struct vm86_struct *)pInt->cpuRegs)
+
+ pInt->cpuRegs = &vm86_s;
+ VM86S->flags = 0;
+ VM86S->screen_bitmap = 0;
+ VM86S->cpu_type = CPU_586;
+ memset(&VM86S->int_revectored, 0xff, sizeof(VM86S->int_revectored));
+ memset(&VM86S->int21_revectored, 0xff, sizeof(VM86S->int21_revectored));
+ return 1;
+}
+
+/* get the linear address */
+#define LIN_PREF_SI ((pref_seg << 4) + X86_SI)
+#define LWECX ((prefix66 ^ prefix67) ? X86_ECX : X86_CX)
+#define LWECX_ZERO {if (prefix66 ^ prefix67) X86_ECX = 0; else X86_CX = 0;}
+#define DF (1 << 10)
+
+/* vm86 fault handling */
+static int
+vm86_GP_fault(xf86Int10InfoPtr pInt)
+{
+ unsigned char *csp, *lina;
+ uint32_t org_eip;
+ int pref_seg;
+ int done, is_rep, prefix66, prefix67;
+
+ csp = lina = SEG_ADR((unsigned char *), X86_CS, IP);
+
+ is_rep = 0;
+ prefix66 = prefix67 = 0;
+ pref_seg = -1;
+
+ /* eat up prefixes */
+ done = 0;
+ do {
+ switch (MEM_RB(pInt, (int)csp++)) {
+ case 0x66: /* operand prefix */ prefix66=1; break;
+ case 0x67: /* address prefix */ prefix67=1; break;
+ case 0x2e: /* CS */ pref_seg=X86_CS; break;
+ case 0x3e: /* DS */ pref_seg=X86_DS; break;
+ case 0x26: /* ES */ pref_seg=X86_ES; break;
+ case 0x36: /* SS */ pref_seg=X86_SS; break;
+ case 0x65: /* GS */ pref_seg=X86_GS; break;
+ case 0x64: /* FS */ pref_seg=X86_FS; break;
+ case 0xf0: /* lock */ break;
+ case 0xf2: /* repnz */
+ case 0xf3: /* rep */ is_rep=1; break;
+ default: done=1;
+ }
+ } while (!done);
+ csp--; /* oops one too many */
+ org_eip = X86_EIP;
+ X86_IP += (csp - lina);
+
+ switch (MEM_RB(pInt, (int)csp)) {
+ case 0x6c: /* insb */
+ /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx
+ * but is anyone using extended regs in real mode? */
+ /* WARNING: no test for DI wrapping! */
+ X86_EDI += port_rep_inb(pInt, X86_DX, SEG_EADR((uint32_t), X86_ES, DI),
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6d: /* (rep) insw / insd */
+ /* NOTE: ES can't be overwritten */
+ /* WARNING: no test for _DI wrapping! */
+ if (prefix66) {
+ X86_DI += port_rep_inl(pInt, X86_DX, SEG_ADR((uint32_t), X86_ES, DI),
+ X86_EFLAGS & DF, is_rep ? LWECX : 1);
+ }
+ else {
+ X86_DI += port_rep_inw(pInt, X86_DX, SEG_ADR((uint32_t), X86_ES, DI),
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ }
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6e: /* (rep) outsb */
+ if (pref_seg < 0) pref_seg = X86_DS;
+ /* WARNING: no test for _SI wrapping! */
+ X86_SI += port_rep_outb(pInt, X86_DX, (uint32_t)LIN_PREF_SI,
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0x6f: /* (rep) outsw / outsd */
+ if (pref_seg < 0) pref_seg = X86_DS;
+ /* WARNING: no test for _SI wrapping! */
+ if (prefix66) {
+ X86_SI += port_rep_outl(pInt, X86_DX, (uint32_t)LIN_PREF_SI,
+ X86_EFLAGS & DF, is_rep ? LWECX : 1);
+ }
+ else {
+ X86_SI += port_rep_outw(pInt, X86_DX, (uint32_t)LIN_PREF_SI,
+ X86_FLAGS & DF, is_rep ? LWECX : 1);
+ }
+ if (is_rep) LWECX_ZERO;
+ X86_IP++;
+ break;
+
+ case 0xe5: /* inw xx, inl xx */
+ if (prefix66) X86_EAX = x_inl(csp[1]);
+ else X86_AX = x_inw(csp[1]);
+ X86_IP += 2;
+ break;
+
+ case 0xe4: /* inb xx */
+ X86_AL = x_inb(csp[1]);
+ X86_IP += 2;
+ break;
+
+ case 0xed: /* inw dx, inl dx */
+ if (prefix66) X86_EAX = x_inl(X86_DX);
+ else X86_AX = x_inw(X86_DX);
+ X86_IP += 1;
+ break;
+
+ case 0xec: /* inb dx */
+ X86_AL = x_inb(X86_DX);
+ X86_IP += 1;
+ break;
+
+ case 0xe7: /* outw xx */
+ if (prefix66) x_outl(csp[1], X86_EAX);
+ else x_outw(csp[1], X86_AX);
+ X86_IP += 2;
+ break;
+
+ case 0xe6: /* outb xx */
+ x_outb(csp[1], X86_AL);
+ X86_IP += 2;
+ break;
+
+ case 0xef: /* outw dx */
+ if (prefix66) x_outl(X86_DX, X86_EAX);
+ else x_outw(X86_DX, X86_AX);
+ X86_IP += 1;
+ break;
+
+ case 0xee: /* outb dx */
+ x_outb(X86_DX, X86_AL);
+ X86_IP += 1;
+ break;
+
+ case 0xf4:
+ fprintf(stderr, "hlt at %p\n", lina);
+ return 0;
+
+ case 0x0f:
+ fprintf(stderr,
+ "CPU 0x0f Trap at CS:EIP=0x%4.4x:0x%8.8lx\n", X86_CS, X86_EIP);
+ goto op0ferr;
+
+ default:
+ fprintf(stderr, "unknown reason for exception\n");
+
+ op0ferr:
+ fprintf(stderr, "cannot continue\n");
+ return 0;
+ } /* end of switch() */
+ return 1;
+}
+
+int
+do_vm86(xf86Int10InfoPtr pInt)
+{
+ int retval, signo;
+
+// xf86InterceptSignals(&signo);
+ retval = vm86_rep(VM86S);
+// xf86InterceptSignals(NULL);
+
+/*
+ if (signo >= 0) {
+ xf86DrvMsg(pInt->scrnIndex, X_ERROR,
+ "vm86() syscall generated signal %d.\n", signo);
+ return 0;
+ }
+*/
+ switch (VM86_TYPE(retval)) {
+ case VM86_UNKNOWN:
+ if (!vm86_GP_fault(pInt)) return 0;
+ break;
+ case VM86_STI:
+ fprintf(stderr, "vm86_sti :-((\n");
+ return 0;
+ case VM86_INTx:
+ pInt->num = VM86_ARG(retval);
+ if (!int_handler(pInt)) {
+ fprintf(stderr,
+ "Unknown vm86_int: 0x%X\n\n", VM86_ARG(retval));
+ return 0;
+ }
+ /* I'm not sure yet what to do if we can handle ints */
+ break;
+ case VM86_SIGNAL:
+ return 1;
+ /*
+ * we used to warn here and bail out - but now the sigio stuff
+ * always fires signals at us. So we just ignore them for now.
+ */
+ fprintf(stderr, "received signal\n");
+ return 0;
+ default:
+ fprintf(stderr, "unknown type(0x%x)=0x%x\n",
+ VM86_ARG(retval), VM86_TYPE(retval));
+ return 0;
+ }
+
+ return 1;
+}
+
+void
+xf86ExecX86int10(xf86Int10InfoPtr pInt)
+{
+#if 0
+ int sig = setup_int(pInt);
+
+ if (int_handler(pInt))
+ while(do_vm86(pInt)) {};
+
+ finish_int(pInt, sig);
+#endif
+ LRMI_int(pInt);
+}
+
+static int
+vm86_rep(struct vm86_struct *ptr)
+{
+ int __res;
+
+#ifdef __PIC__
+ /* When compiling with -fPIC, we can't use asm constraint "b" because
+ %ebx is already taken by gcc. */
+ __asm__ __volatile__("pushl %%ebx\n\t"
+ "push %%gs\n\t"
+ "movl %2,%%ebx\n\t"
+ "movl %1,%%eax\n\t"
+ "int $0x80\n\t"
+ "pop %%gs\n\t"
+ "popl %%ebx"
+ :"=a" (__res)
+ :"n" ((int)113), "r" ((struct vm86_struct *)ptr));
+#else
+ __asm__ __volatile__("push %%gs\n\t"
+ "int $0x80\n\t"
+ "pop %%gs"
+ :"=a" (__res):"a" ((int)113),
+ "b" ((struct vm86_struct *)ptr));
+#endif
+
+ if (__res < 0) {
+ errno = -__res;
+ __res = -1;
+ }
+ else errno = 0;
+ return __res;
+}
+
+/* general software interrupt handler */
+uint32_t
+getIntVect(xf86Int10InfoPtr pInt,int num)
+{
+ return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
+}
+
+
+#if 0
+uint8_t
+Mem_rb(uint32_t addr)
+{
+ return (*Int10Current->mem->rb)(Int10Current, addr);
+}
+
+uint16_t
+Mem_rw(uint32_t addr)
+{
+ return (*Int10Current->mem->rw)(Int10Current, addr);
+}
+
+uint32_t
+Mem_rl(uint32_t addr)
+{
+ return (*Int10Current->mem->rl)(Int10Current, addr);
+}
+
+void
+Mem_wb(uint32_t addr, uint8_t val)
+{
+ (*Int10Current->mem->wb)(Int10Current, addr, val);
+}
+
+void
+Mem_ww(uint32_t addr, uint16_t val)
+{
+ (*Int10Current->mem->ww)(Int10Current, addr, val);
+}
+
+void
+Mem_wl(uint32_t addr, uint32_t val)
+{
+ (*Int10Current->mem->wl)(Int10Current, addr, val);
+}
+#endif
diff --git a/src/vm86/Makefile.am b/src/vm86/Makefile.am
index 6fad12b..f80b344 100644
--- a/src/vm86/Makefile.am
+++ b/src/vm86/Makefile.am
@@ -1,3 +1,4 @@
+
lib_LTLIBRARIES = libvm86.la
libvm86_la_SOURCES = vm86.c
diff --git a/src/vm86/vm86.c b/src/vm86/vm86.c
index ad421c3..82c25b2 100644
--- a/src/vm86/vm86.c
+++ b/src/vm86/vm86.c
@@ -45,7 +45,7 @@ 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 0
#include "vm86.h"
@@ -630,3 +630,4 @@ run_vm86(void)
return (0);
}
#endif /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ */
+#endif