aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tests
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-03-31 14:21:13 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-03-31 14:21:13 +0100
commitc0b0636f388fcbdc168e8254188d7f145ecdab98 (patch)
tree8d83d984c434cce73eafb2d535a23a702c7c6727 /tools/tests
parente358d917c40addf8ad81fdcc7933bd68c174e841 (diff)
downloadxen-c0b0636f388fcbdc168e8254188d7f145ecdab98.tar.gz
xen-c0b0636f388fcbdc168e8254188d7f145ecdab98.tar.bz2
xen-c0b0636f388fcbdc168e8254188d7f145ecdab98.zip
x86_emulate: Remove environment-specific definitions from core
emulator source files. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/tests')
-rw-r--r--tools/tests/Makefile10
-rw-r--r--tools/tests/test_x86_emulator.c29
-rw-r--r--tools/tests/x86_emulate.c13
3 files changed, 30 insertions, 22 deletions
diff --git a/tools/tests/Makefile b/tools/tests/Makefile
index 45d4294f9a..cf32ef91df 100644
--- a/tools/tests/Makefile
+++ b/tools/tests/Makefile
@@ -21,13 +21,17 @@ $(TARGET): x86_emulate.o test_x86_emulator.o
.PHONY: clean
clean:
- rm -rf $(TARGET) *.o *~ core blowfish.h blowfish.bin
+ rm -rf $(TARGET) *.o *~ core blowfish.h blowfish.bin x86_emulate
.PHONY: install
install:
-x86_emulate.o: $(XEN_ROOT)/xen/arch/x86/x86_emulate.c
+.PHONY: x86_emulate
+x86_emulate:
+ [ -L x86_emulate ] || ln -sf $(XEN_ROOT)/xen/arch/x86/x86_emulate .
+
+x86_emulate.o: x86_emulate.c x86_emulate
$(HOSTCC) $(HOSTCFLAGS) -I$(XEN_ROOT)/xen/include -c -o $@ $<
-test_x86_emulator.o: test_x86_emulator.c blowfish.h
+test_x86_emulator.o: test_x86_emulator.c blowfish.h x86_emulate
$(HOSTCC) $(HOSTCFLAGS) -I$(XEN_ROOT)/xen/include -c -o $@ $<
diff --git a/tools/tests/test_x86_emulator.c b/tools/tests/test_x86_emulator.c
index fe48921b59..4ad5677dd4 100644
--- a/tools/tests/test_x86_emulator.c
+++ b/tools/tests/test_x86_emulator.c
@@ -1,20 +1,11 @@
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-typedef int8_t s8;
-typedef int16_t s16;
-typedef int32_t s32;
-typedef int64_t s64;
#include <public/xen.h>
-#include <asm-x86/x86_emulate.h>
#include <sys/mman.h>
+#include "x86_emulate/x86_emulate.h"
#include "blowfish.h"
#define MMAP_SZ 16384
@@ -38,9 +29,9 @@ static int read(
unsigned long addr = offset;
switch ( bytes )
{
- case 1: *val = *(u8 *)addr; break;
- case 2: *val = *(u16 *)addr; break;
- case 4: *val = *(u32 *)addr; break;
+ case 1: *val = *(uint8_t *)addr; break;
+ case 2: *val = *(uint16_t *)addr; break;
+ case 4: *val = *(uint32_t *)addr; break;
case 8: *val = *(unsigned long *)addr; break;
}
return X86EMUL_OKAY;
@@ -56,9 +47,9 @@ static int write(
unsigned long addr = offset;
switch ( bytes )
{
- case 1: *(u8 *)addr = (u8)val; break;
- case 2: *(u16 *)addr = (u16)val; break;
- case 4: *(u32 *)addr = (u32)val; break;
+ case 1: *(uint8_t *)addr = (uint8_t)val; break;
+ case 2: *(uint16_t *)addr = (uint16_t)val; break;
+ case 4: *(uint32_t *)addr = (uint32_t)val; break;
case 8: *(unsigned long *)addr = val; break;
}
return X86EMUL_OKAY;
@@ -75,9 +66,9 @@ static int cmpxchg(
unsigned long addr = offset;
switch ( bytes )
{
- case 1: *(u8 *)addr = (u8)new; break;
- case 2: *(u16 *)addr = (u16)new; break;
- case 4: *(u32 *)addr = (u32)new; break;
+ case 1: *(uint8_t *)addr = (uint8_t)new; break;
+ case 2: *(uint16_t *)addr = (uint16_t)new; break;
+ case 4: *(uint32_t *)addr = (uint32_t)new; break;
case 8: *(unsigned long *)addr = new; break;
}
return X86EMUL_OKAY;
diff --git a/tools/tests/x86_emulate.c b/tools/tests/x86_emulate.c
new file mode 100644
index 0000000000..d58f65a38e
--- /dev/null
+++ b/tools/tests/x86_emulate.c
@@ -0,0 +1,13 @@
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <public/xen.h>
+
+#include "x86_emulate/x86_emulate.h"
+
+#define __emulate_fpu_insn(_op) \
+do{ rc = X86EMUL_UNHANDLEABLE; \
+ goto done; \
+} while (0)
+
+#include "x86_emulate/x86_emulate.c"