summaryrefslogtreecommitdiffstats
path: root/sys/contrib/x86emu
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-09-09 05:53:26 +0000
committerdelphij <delphij@FreeBSD.org>2009-09-09 05:53:26 +0000
commitf44ea64745d859e498568576f62e9248974ade60 (patch)
treeaae468ed255b56ac5362d99c2c2a0ac6f27b992a /sys/contrib/x86emu
parent65e0b4852aee57de465fd1ae3934b80f45962b4b (diff)
downloadFreeBSD-src-f44ea64745d859e498568576f62e9248974ade60.zip
FreeBSD-src-f44ea64745d859e498568576f62e9248974ade60.tar.gz
- Port x86emu to FreeBSD.
- Connect x86emu to build. Tested with: make universe Submitted by: swell.k at gmail com
Diffstat (limited to 'sys/contrib/x86emu')
-rw-r--r--sys/contrib/x86emu/x86emu.c49
-rw-r--r--sys/contrib/x86emu/x86emu.h8
-rw-r--r--sys/contrib/x86emu/x86emu_util.c13
3 files changed, 47 insertions, 23 deletions
diff --git a/sys/contrib/x86emu/x86emu.c b/sys/contrib/x86emu/x86emu.c
index d99367e..a26044a 100644
--- a/sys/contrib/x86emu/x86emu.c
+++ b/sys/contrib/x86emu/x86emu.c
@@ -1,5 +1,6 @@
/* $OpenBSD: x86emu.c,v 1.4 2009/06/18 14:19:21 pirofti Exp $ */
/* $NetBSD: x86emu.c,v 1.7 2009/02/03 19:26:29 joerg Exp $ */
+/* $FreeBSD$ */
/*
*
@@ -32,8 +33,12 @@
*
*/
-#include <dev/x86emu/x86emu.h>
-#include <dev/x86emu/x86emu_regs.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <contrib/x86emu/x86emu.h>
+#include <contrib/x86emu/x86emu_regs.h>
static void x86emu_intr_raise (struct x86emu *, uint8_t type);
@@ -45,7 +50,7 @@ static uint8_t fetch_byte_imm (struct x86emu *);
static uint16_t fetch_word_imm (struct x86emu *);
static uint32_t fetch_long_imm (struct x86emu *);
static uint8_t fetch_data_byte (struct x86emu *, uint32_t offset);
-static uint8_t fetch_byte (struct x86emu *, uint segment, uint32_t offset);
+static uint8_t fetch_byte (struct x86emu *, u_int segment, uint32_t offset);
static uint16_t fetch_data_word (struct x86emu *, uint32_t offset);
static uint16_t fetch_word (struct x86emu *, uint32_t segment, uint32_t offset);
static uint32_t fetch_data_long (struct x86emu *, uint32_t offset);
@@ -227,13 +232,8 @@ x86emu_exec(struct x86emu *emu)
{
emu->x86.intr = 0;
-#ifdef _KERNEL
- if (setjmp(&emu->exec_state))
- return;
-#else
if (setjmp(emu->exec_state))
return;
-#endif
for (;;) {
if (emu->x86.intr) {
@@ -282,11 +282,7 @@ x86emu_exec_intr(struct x86emu *emu, uint8_t intr)
void
x86emu_halt_sys(struct x86emu *emu)
{
-#ifdef _KERNEL
- longjmp(&emu->exec_state);
-#else
longjmp(emu->exec_state, 1);
-#endif
}
/*
@@ -8339,3 +8335,32 @@ pop_long(struct x86emu *emu)
emu->x86.R_SP += 4;
return res;
}
+
+static int
+x86emu_modevent(module_t mod __unused, int type, void *data __unused)
+{
+ int err = 0;
+
+ switch (type) {
+ case MOD_LOAD:
+ break;
+
+ case MOD_UNLOAD:
+ break;
+
+ default:
+ err = ENOTSUP;
+ break;
+
+ }
+ return (err);
+}
+
+static moduledata_t x86emu_mod = {
+ "x86emu",
+ x86emu_modevent,
+ NULL,
+};
+
+DECLARE_MODULE(x86emu, x86emu_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
+MODULE_VERSION(x86emu, 1);
diff --git a/sys/contrib/x86emu/x86emu.h b/sys/contrib/x86emu/x86emu.h
index 4fd0f8a..f25a95b 100644
--- a/sys/contrib/x86emu/x86emu.h
+++ b/sys/contrib/x86emu/x86emu.h
@@ -1,5 +1,6 @@
/* $NetBSD: x86emu.h,v 1.1 2007/12/01 20:14:10 joerg Exp $ */
/* $OpenBSD: x86emu.h,v 1.3 2009/06/06 03:45:05 matthieu Exp $ */
+/* $FreeBSD$ */
/****************************************************************************
*
@@ -40,6 +41,7 @@
#ifdef _KERNEL
#include <sys/systm.h>
+#include <machine/setjmp.h>
#else
#include <setjmp.h>
#endif
@@ -140,11 +142,7 @@ struct x86emu {
void *sys_private;
struct x86emu_regs x86;
-#ifdef _KERNEL
- label_t exec_state;
-#else
jmp_buf exec_state;
-#endif
uint64_t cur_cycles;
@@ -179,7 +177,7 @@ void x86emu_init_default(struct x86emu *);
void x86emu_exec(struct x86emu *);
void x86emu_exec_call(struct x86emu *, uint16_t, uint16_t);
void x86emu_exec_intr(struct x86emu *, uint8_t);
-void x86emu_halt_sys(struct x86emu *) __dead;
+void x86emu_halt_sys(struct x86emu *) __dead2;
__END_DECLS
diff --git a/sys/contrib/x86emu/x86emu_util.c b/sys/contrib/x86emu/x86emu_util.c
index e96efc2..41a9f72 100644
--- a/sys/contrib/x86emu/x86emu_util.c
+++ b/sys/contrib/x86emu/x86emu_util.c
@@ -1,5 +1,6 @@
/* $OpenBSD: x86emu_util.c,v 1.5 2009/06/18 14:19:21 pirofti Exp $ */
/* $NetBSD: x86emu_util.c,v 1.2 2007/12/04 17:32:22 joerg Exp $ */
+/* $FreeBSD$ */
/*
*
@@ -35,8 +36,8 @@
#include <sys/param.h>
#include <sys/endian.h>
-#include <dev/x86emu/x86emu.h>
-#include <dev/x86emu/x86emu_regs.h>
+#include <contrib/x86emu/x86emu.h>
+#include <contrib/x86emu/x86emu_regs.h>
@@ -82,9 +83,9 @@ rdw(struct x86emu *emu, uint32_t addr)
((*(a + 1) << 8) & 0xff00);
return r;
} else
- return letoh32(*(u_int32_t *)(emu->mem_base + addr));
+ return le32toh(*(u_int32_t *)(emu->mem_base + addr));
#else
- return letoh16(*(u_int16_t *)(emu->mem_base + addr));
+ return le16toh(*(u_int16_t *)(emu->mem_base + addr));
#endif
}
@@ -113,9 +114,9 @@ rdl(struct x86emu *emu, uint32_t addr)
((*(a + 3) << 24) & 0xff000000);
return r;
} else
- return letoh32(*(u_int32_t *)(emu->mem_base + addr));
+ return le32toh(*(u_int32_t *)(emu->mem_base + addr));
#else
- return letoh32(*(u_int32_t *)(emu->mem_base + addr));
+ return le32toh(*(u_int32_t *)(emu->mem_base + addr));
#endif
}
OpenPOWER on IntegriCloud