--- qemu-0.5.0/Makefile.target.amd64 2003-11-07 09:33:23.000000000 +0100 +++ qemu-0.5.0/Makefile.target 2003-11-07 09:33:23.000000000 +0100 @@ -56,6 +56,11 @@ LDFLAGS+=-Wl,-shared endif endif +ifeq ($(ARCH),amd64) +OP_CFLAGS=$(CFLAGS) -falign-functions=0 +LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld +endif + ifeq ($(ARCH),ppc) OP_CFLAGS=$(CFLAGS) LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld @@ -140,6 +145,9 @@ LIBOBJS+=disas.o ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) LIBOBJS+=i386-dis.o endif +ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64) +LIBOBJS+=i386-dis.o +endif ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) LIBOBJS+=alpha-dis.o endif --- qemu-0.5.0/exec-all.h.amd64 2003-10-28 01:53:12.000000000 +0100 +++ qemu-0.5.0/exec-all.h 2003-11-07 09:33:23.000000000 +0100 @@ -132,7 +132,7 @@ void tb_link(TranslationBlock *tb); extern TranslationBlock *tb_hash[CODE_GEN_HASH_SIZE]; -extern uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE]; +//extern uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE]; extern uint8_t *code_gen_ptr; /* find a translation block in the translation cache. If not found, @@ -309,6 +309,20 @@ static inline int testandset (int *p) } #endif +#ifdef __x86_64__ +static inline int testandset (int *p) +{ + char ret; + int readval; + + __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0" + : "=q" (ret), "=m" (*p), "=a" (readval) + : "r" (1), "m" (*p), "a" (0) + : "memory"); + return ret; +} +#endif + #ifdef __s390__ static inline int testandset (int *p) { --- qemu-0.5.0/dyngen.h.amd64 2003-10-28 01:53:12.000000000 +0100 +++ qemu-0.5.0/dyngen.h 2003-11-07 09:33:23.000000000 +0100 @@ -27,6 +27,12 @@ static inline void flush_icache_range(un } #endif +#ifdef __x86_64__ +static inline void flush_icache_range(unsigned long start, unsigned long stop) +{ +} +#endif + #ifdef __s390__ static inline void flush_icache_range(unsigned long start, unsigned long stop) { --- qemu-0.5.0/exec.c.amd64 2003-10-28 01:53:12.000000000 +0100 +++ qemu-0.5.0/exec.c 2003-11-07 09:33:23.000000000 +0100 @@ -47,8 +47,12 @@ int nb_tbs; /* any access to the tbs or the page table must use this lock */ spinlock_t tb_lock = SPIN_LOCK_UNLOCKED; -uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE]; -uint8_t *code_gen_ptr; +#if defined(__x86_64__) +static uint8_t *code_gen_buffer; +#else +static uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE]; +#endif +uint8_t *code_gen_ptr = NULL; /* XXX: pack the flags in the low bits of the pointer ? */ typedef struct PageDesc { @@ -206,6 +210,12 @@ void page_set_flags(unsigned long start, void cpu_exec_init(void) { if (!code_gen_ptr) { +#if defined(__x86_64__) + code_gen_buffer = mmap(0, CODE_GEN_BUFFER_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, + MAP_SHARED|MAP_32BIT|MAP_ANONYMOUS, -1, 0); + if (code_gen_buffer == MAP_FAILED) + exit(1); +#endif code_gen_ptr = code_gen_buffer; page_init(); io_mem_init();