From 05c2a3e7313870811c8a7ec9837f5e75d40ea080 Mon Sep 17 00:00:00 2001 From: bellard Date: Wed, 8 Feb 2006 22:39:17 +0000 Subject: [PATCH] kqemu/qvm86 must now be compiled outside QEMU git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1750 c046a42c-6fe2-441c-8c8c-71466251a162 --- Makefile | 13 ------- configure | 74 ++++++----------------------------- kqemu.h | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 76 deletions(-) create mode 100644 kqemu.h diff --git a/Makefile b/Makefile index cfa7df5..e69cf47 100644 --- a/Makefile +++ b/Makefile @@ -17,13 +17,6 @@ all: dyngen$(EXESUF) $(TOOLS) $(DOCS) for d in $(TARGET_DIRS); do \ $(MAKE) -C $$d $@ || exit 1 ; \ done -ifdef CONFIG_KQEMU -ifdef CONFIG_WIN32 - $(MAKE) -C kqemu -f Makefile.winnt -else - $(MAKE) -C kqemu -endif -endif qemu-img$(EXESUF): qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c $(CC) -DQEMU_TOOL $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $@ $^ -lz $(LIBS) @@ -39,9 +32,6 @@ clean: for d in $(TARGET_DIRS); do \ $(MAKE) -C $$d $@ || exit 1 ; \ done -ifdef CONFIG_KQEMU - $(MAKE) -C kqemu clean -endif distclean: clean rm -f config-host.mak config-host.h @@ -73,9 +63,6 @@ endif for d in $(TARGET_DIRS); do \ $(MAKE) -C $$d $@ || exit 1 ; \ done -ifdef CONFIG_KQEMU - cd kqemu ; ./install.sh -endif # various test targets test speed test2: all diff --git a/configure b/configure index fa05bbf..64cb745 100755 --- a/configure +++ b/configure @@ -85,6 +85,7 @@ fmod_lib="" fmod_inc="" linux="no" kqemu="no" +profiler="no" kernel_path="" cocoa="no" check_gfx="yes" @@ -197,6 +198,8 @@ for opt do ;; --disable-kqemu) kqemu="no" ;; + --enable-profiler) profiler="yes" + ;; --kernel-path=*) kernel_path=${opt#--kernel-path=} ;; --enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no" @@ -365,7 +368,7 @@ echo " use %M for cpu name [$interp_prefix]" echo " --target-list=LIST set target list [$target_list]" echo "" echo "kqemu kernel acceleration support:" -echo " --disable-kqemu disable kqemu build" +echo " --disable-kqemu disable kqemu support" echo " --kernel-path=PATH set the kernel path (configure probes it)" echo "" echo "Advanced options (experts only):" @@ -407,48 +410,6 @@ docdir="$prefix/share/doc/qemu" bindir="$prefix/bin" fi -# kqemu support -if test $kqemu = "yes" ; then - # test if the source code is installed - if test '!' -f "kqemu/Makefile" ; then - kqemu="no" - fi -fi - -# Linux specific kqemu configuration -if test $kqemu = "yes" -a $linux = "yes" ; then -# find the kernel path -if test -z "$kernel_path" ; then -kernel_version=`uname -r` -kernel_path="/lib/modules/$kernel_version/build" -if test '!' -d "$kernel_path/include" ; then - kernel_path="/usr/src/linux" - if test '!' -d "$kernel_path/include" ; then - echo "Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module" - kqemu="no" - fi -fi -fi - -if test $kqemu = "yes" ; then - -# test that the kernel config is present -if test '!' -f "$kernel_path/Makefile" ; then - echo "No Makefile file present in $kernel_path - kqemu cannot be built" - kqemu="no" -fi - -# find build system (2.6 or legacy) -kbuild26="yes" -if grep -q "PATCHLEVEL = 4" $kernel_path/Makefile ; then -kbuild26="no" -fi - -fi # kqemu - -fi # kqemu and linux - - echo "Install prefix $prefix" echo "BIOS directory $datadir" echo "binary directory $bindir" @@ -464,6 +425,7 @@ echo "host CPU $cpu" echo "host big endian $bigendian" echo "target list $target_list" echo "gprof enabled $gprof" +echo "profiler $profiler" echo "static build $static" if test "$darwin" = "yes" ; then echo "Cocoa support $cocoa" @@ -490,17 +452,6 @@ if test "$fmod" = "yes"; then fi echo "" echo "kqemu support $kqemu" -if test $kqemu = "yes" -a $linux = "yes" ; then -echo "" -echo "KQEMU Linux module configuration:" -echo "kernel sources $kernel_path" -echo -n "kbuild type " -if test $kbuild26 = "yes"; then -echo "2.6" -else -echo "2.4" -fi -fi if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -601,6 +552,9 @@ if test "$static" = "yes" ; then echo "CONFIG_STATIC=yes" >> $config_mak echo "#define CONFIG_STATIC 1" >> $config_h fi +if test $profiler = "yes" ; then + echo "#define CONFIG_PROFILER 1" >> $config_h +fi if test "$slirp" = "yes" ; then echo "CONFIG_SLIRP=yes" >> $config_mak echo "#define CONFIG_SLIRP 1" >> $config_h @@ -638,15 +592,6 @@ echo -n "#define QEMU_VERSION \"" >> $config_h head $source_path/VERSION >> $config_h echo "\"" >> $config_h -if test $kqemu = "yes" ; then - echo "CONFIG_KQEMU=yes" >> $config_mak - if test $linux = "yes" ; then - echo "KERNEL_PATH=$kernel_path" >> $config_mak - if test $kbuild26 = "yes" ; then - echo "CONFIG_KBUILD26=yes" >> $config_mak - fi - fi -fi echo "SRC_PATH=$source_path" >> $config_mak echo "TARGET_DIRS=$target_list" >> $config_mak @@ -746,6 +691,9 @@ elif test "$target_cpu" = "x86_64" ; then echo "#define TARGET_X86_64 1" >> $config_h if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64" ; then echo "#define USE_KQEMU 1" >> $config_h + if test $kqemu_profile = "yes" ; then + echo "#define CONFIG_KQEMU_PROFILE 1" >> $config_h + fi fi elif test "$target_cpu" = "mips" -o "$target_cpu" = "mipsel" ; then echo "TARGET_ARCH=mips" >> $config_mak diff --git a/kqemu.h b/kqemu.h new file mode 100644 index 0000000..892e335 --- /dev/null +++ b/kqemu.h @@ -0,0 +1,132 @@ +/* + * KQEMU header + * + * Copyright (c) 2004-2006 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 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. + */ +#ifndef KQEMU_H +#define KQEMU_H + +#define KQEMU_VERSION 0x010300 + +struct kqemu_segment_cache { + uint32_t selector; + unsigned long base; + uint32_t limit; + uint32_t flags; +}; + +struct kqemu_cpu_state { +#ifdef __x86_64__ + unsigned long regs[16]; +#else + unsigned long regs[8]; +#endif + unsigned long eip; + unsigned long eflags; + + uint32_t dummy0, dummy1, dumm2, dummy3, dummy4; + + struct kqemu_segment_cache segs[6]; /* selector values */ + struct kqemu_segment_cache ldt; + struct kqemu_segment_cache tr; + struct kqemu_segment_cache gdt; /* only base and limit are used */ + struct kqemu_segment_cache idt; /* only base and limit are used */ + + unsigned long cr0; + unsigned long dummy5; + unsigned long cr2; + unsigned long cr3; + unsigned long cr4; + uint32_t a20_mask; + + /* sysenter registers */ + uint32_t sysenter_cs; + uint32_t sysenter_esp; + uint32_t sysenter_eip; + uint64_t efer __attribute__((aligned(8))); + uint64_t star; +#ifdef __x86_64__ + unsigned long lstar; + unsigned long cstar; + unsigned long fmask; + unsigned long kernelgsbase; +#endif + uint64_t tsc_offset; + + unsigned long dr0; + unsigned long dr1; + unsigned long dr2; + unsigned long dr3; + unsigned long dr6; + unsigned long dr7; + + uint8_t cpl; + uint8_t user_only; + + uint32_t error_code; /* error_code when exiting with an exception */ + unsigned long next_eip; /* next eip value when exiting with an interrupt */ + unsigned int nb_pages_to_flush; /* number of pages to flush, + KQEMU_FLUSH_ALL means full flush */ +#define KQEMU_MAX_PAGES_TO_FLUSH 512 +#define KQEMU_FLUSH_ALL (KQEMU_MAX_PAGES_TO_FLUSH + 1) + + long retval; + + /* number of ram_dirty entries to update */ + unsigned int nb_ram_pages_to_update; +#define KQEMU_MAX_RAM_PAGES_TO_UPDATE 512 +#define KQEMU_RAM_PAGES_UPDATE_ALL (KQEMU_MAX_RAM_PAGES_TO_UPDATE + 1) + +#define KQEMU_MAX_MODIFIED_RAM_PAGES 512 + unsigned int nb_modified_ram_pages; +}; + +struct kqemu_init { + uint8_t *ram_base; /* must be page aligned */ + unsigned long ram_size; /* must be multiple of 4 KB */ + uint8_t *ram_dirty; /* must be page aligned */ + uint32_t **phys_to_ram_map; /* must be page aligned */ + unsigned long *pages_to_flush; /* must be page aligned */ + unsigned long *ram_pages_to_update; /* must be page aligned */ + unsigned long *modified_ram_pages; /* must be page aligned */ +}; + +#define KQEMU_RET_ABORT (-1) +#define KQEMU_RET_EXCEPTION 0x0000 /* 8 low order bit are the exception */ +#define KQEMU_RET_INT 0x0100 /* 8 low order bit are the interrupt */ +#define KQEMU_RET_SOFTMMU 0x0200 /* emulation needed (I/O or + unsupported INSN) */ +#define KQEMU_RET_INTR 0x0201 /* interrupted by a signal */ +#define KQEMU_RET_SYSCALL 0x0300 /* syscall insn */ + +#ifdef _WIN32 +#define KQEMU_EXEC CTL_CODE(FILE_DEVICE_UNKNOWN, 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define KQEMU_INIT CTL_CODE(FILE_DEVICE_UNKNOWN, 2, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#define KQEMU_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 3, METHOD_BUFFERED, FILE_READ_ACCESS) +#define KQEMU_MODIFY_RAM_PAGES CTL_CODE(FILE_DEVICE_UNKNOWN, 4, METHOD_BUFFERED, FILE_WRITE_ACCESS) +#else +#define KQEMU_EXEC _IOWR('q', 1, struct kqemu_cpu_state) +#define KQEMU_INIT _IOW('q', 2, struct kqemu_init) +#define KQEMU_GET_VERSION _IOR('q', 3, int) +#define KQEMU_MODIFY_RAM_PAGES _IOW('q', 4, int) +#endif + +#endif /* KQEMU_H */ -- 2.7.4