]> xenbits.xensource.com Git - qemu-xen-4.0-testing.git/commitdiff
Make vl.c compile. Still very WIP
authorIan Jackson <iwj@mariner.uk.xensource.com>
Tue, 11 Mar 2008 18:01:25 +0000 (18:01 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 12 May 2008 11:20:10 +0000 (12:20 +0100)
hw/boards.h
i386-dm/cpu.h
i386-dm/hooks.mak
vl.c
wip-make-vl-compile [new file with mode: 0644]
xen-hooks.mak
xen-vl-extra.c [new file with mode: 0644]

index affcaa655621879db8889f4b139f319a409490b8..c87cfff55a76b0940a00dd928188768e51192630 100644 (file)
@@ -26,6 +26,10 @@ extern QEMUMachine bareetraxfs_machine;
 extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
 
+/* Xen */
+extern QEMUMachine xenpv_machine;
+extern QEMUMachine xenfv_machine;
+
 /* ppc.c */
 extern QEMUMachine prep_machine;
 extern QEMUMachine core99_machine;
index cfc693f33707ad3c6c74ddb9f1d10b3062a8f664..711512dc9603041ec30bdc2d31d4f38a7a022bd5 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "config.h"
 
+struct CPUX86State;
+
 #ifdef TARGET_X86_64
 #define TARGET_LONG_BITS 64
 #else
    close to the modifying instruction */
 #define TARGET_HAS_PRECISE_SMC
 
+/* MMU modes definitions
+ */
+/* We aren't handling the MMU in Qemu; all the addresses we deal with
+ * are guest physical.  So as far as qemu
+ * is concerned there is only the one MMU mode.
+ */
+#define NB_MMU_MODES 1
+#define MMU_MODE0_SUFFIX _xen
+static inline int cpu_mmu_index(struct CPUX86State *env) { return 0; }
+
 #include "cpu-defs.h"
 
 #ifdef CONFIG_SOFTFLOAT
@@ -53,7 +65,12 @@ typedef float64 CPU86_LDouble;
 #endif
 #endif
 
-#define NB_MMU_MODES 2
+typedef struct SegmentCache {
+    uint32_t selector;
+    target_ulong base;
+    uint32_t limit;
+    uint32_t flags;
+} SegmentCache;
 
 /* Empty for now */
 typedef struct CPUX86State {
@@ -100,16 +117,6 @@ int main_loop(void);
 #define cpu_exec cpu_x86_exec
 #define cpu_gen_code cpu_x86_gen_code
 #define cpu_signal_handler cpu_x86_signal_handler
-#define cpu_list x86_cpu_list
-
-/* MMU modes definitions */
-#define MMU_MODE0_SUFFIX _kernel
-#define MMU_MODE1_SUFFIX _user
-#define MMU_USER_IDX 1
-static inline int cpu_mmu_index (CPUState *env)
-{
-    return (env->hflags & HF_CPL_MASK) == 3 ? 1 : 0;
-}
 
 #include "cpu-all.h"
 
index bb21544da78fc3e0c68df2f72761dce4e4adc891..5d593f4e945cbd9183fd5c75071856b17d1cc76f 100644 (file)
@@ -1,3 +1,4 @@
 OBJS += $(SOUND_HW) $(AUDIODRV) mixeng.o 
 CPPFLAGS += -DHAS_AUDIO
 QEMU_PROG=qemu-dm
+include ../xen-hooks.mak
diff --git a/vl.c b/vl.c
index e666a8971e228687ab68bdb18acd422add951acf..ec7674e8189eece82e11afbc3f0a296ecf9c4e86 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -243,6 +243,8 @@ static int event_pending = 1;
 
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
+#include "xen-vl-extra.c"
+
 /***********************************************************/
 /* x86 ISA bus support */
 
@@ -473,7 +475,7 @@ void hw_error(const char *fmt, ...)
     fprintf(stderr, "\n");
     for(env = first_cpu; env != NULL; env = env->next_cpu) {
         fprintf(stderr, "CPU #%d:\n", env->cpu_index);
-#ifdef TARGET_I386
+#if defined(TARGET_I386) && !defined(CONFIG_DM)
         cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU);
 #else
         cpu_dump_state(env, stderr, fprintf, 0);
@@ -863,7 +865,7 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t);
 static int unix_start_timer(struct qemu_alarm_timer *t);
 static void unix_stop_timer(struct qemu_alarm_timer *t);
 
-#ifdef __linux__
+#if defined(__linux__) && !defined(CONFIG_DM)
 
 static int dynticks_start_timer(struct qemu_alarm_timer *t);
 static void dynticks_stop_timer(struct qemu_alarm_timer *t);
@@ -881,7 +883,7 @@ static void rtc_stop_timer(struct qemu_alarm_timer *t);
 
 static struct qemu_alarm_timer alarm_timers[] = {
 #ifndef _WIN32
-#ifdef __linux__
+#if defined(__linux__) && !defined(CONFIG_DM)
     {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
      dynticks_stop_timer, dynticks_rearm_timer, NULL},
     /* HPET - if available - is preferred */
@@ -1128,8 +1130,10 @@ static void timer_save(QEMUFile *f, void *opaque)
     if (cpu_ticks_enabled) {
         hw_error("cannot save state if virtual timers are running");
     }
+#ifndef CONFIG_DM
     qemu_put_be64(f, cpu_ticks_offset);
     qemu_put_be64(f, ticks_per_sec);
+#endif
     qemu_put_be64(f, cpu_clock_offset);
 }
 
@@ -1140,14 +1144,19 @@ static int timer_load(QEMUFile *f, void *opaque, int version_id)
     if (cpu_ticks_enabled) {
         return -EINVAL;
     }
+#ifndef CONFIG_DM
     cpu_ticks_offset=qemu_get_be64(f);
     ticks_per_sec=qemu_get_be64(f);
     if (version_id == 2) {
+#else
+    if (version_id == 1 || version_id == 2) {
+#endif
         cpu_clock_offset=qemu_get_be64(f);
     }
     return 0;
 }
 
+#ifndef CONFIG_DM
 #ifdef _WIN32
 void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg,
                                  DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
@@ -1535,6 +1544,7 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t)
 }
 
 #endif /* _WIN32 */
+#endif /* !CONFIG_DM */
 
 static void init_timer_alarm(void)
 {
@@ -6035,6 +6045,8 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
     return ret;
 }
 
+#ifndef CONFIG_DM
+
 void do_savevm(const char *name)
 {
     BlockDriverState *bs, *bs1;
@@ -6204,6 +6216,8 @@ void do_loadvm(const char *name)
         vm_start();
 }
 
+#endif /* !CONFIG_DM */
+
 void do_delvm(const char *name)
 {
     BlockDriverState *bs, *bs1;
@@ -6270,7 +6284,10 @@ void do_info_snapshots(void)
 /***********************************************************/
 /* cpu save/restore */
 
-#if defined(TARGET_I386)
+#if defined(CONFIG_DM)
+void cpu_save(QEMUFile *f, void *opaque) { }
+int cpu_load(QEMUFile *f, void *opaque, int version_id) { return 0; }
+#elif defined(TARGET_I386)
 
 static void cpu_put_seg(QEMUFile *f, SegmentCache *dt)
 {
@@ -6821,6 +6838,11 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
 /***********************************************************/
 /* ram save/restore */
 
+#ifdef CONFIG_DM
+static void ram_save(QEMUFile *f, void *opaque) { }
+static int ram_load(QEMUFile *f, void *opaque, int version_id) { return 0; }
+#else /* !CONFIG_DM */
+
 static int ram_get_page(QEMUFile *f, uint8_t *buf, int len)
 {
     int v;
@@ -7076,6 +7098,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
+#endif /* !CONFIG_DM */
+
 /***********************************************************/
 /* bottom halves (can be seen as timers which expire ASAP) */
 
@@ -7493,6 +7517,8 @@ void main_loop_wait(int timeout)
 
 }
 
+#ifndef CONFIG_DM
+
 static int main_loop(void)
 {
     int ret, timeout;
@@ -7572,6 +7598,7 @@ static int main_loop(void)
     cpu_disable_ticks();
     return ret;
 }
+#endif /* !CONFIG_DM */
 
 static void help(int exitcode)
 {
@@ -7967,7 +7994,10 @@ static void read_passwords(void)
 /* XXX: currently we cannot use simultaneously different CPUs */
 static void register_machines(void)
 {
-#if defined(TARGET_I386)
+#if defined(CONFIG_DM)
+    qemu_register_machine(&xenfv_machine);
+    qemu_register_machine(&xenpv_machine);
+#elif defined(TARGET_I386)
     qemu_register_machine(&pc_machine);
     qemu_register_machine(&isapc_machine);
 #elif defined(TARGET_PPC)
@@ -8032,7 +8062,7 @@ static void register_machines(void)
 #ifdef HAS_AUDIO
 struct soundhw soundhw[] = {
 #ifdef HAS_AUDIO_CHOICE
-#ifdef TARGET_I386
+#if defined(TARGET_I386) && !defined(CONFIG_DM)
     {
         "pcspk",
         "PC speaker",
@@ -8894,7 +8924,7 @@ int main(int argc, char **argv)
                     vlan->id);
     }
 
-#ifdef TARGET_I386
+#if defined(TARGET_I386) && !defined(CONFIG_DM)
     /* XXX: this should be moved in the PC machine instantiation code */
     if (net_boot != 0) {
         int netroms = 0;
diff --git a/wip-make-vl-compile b/wip-make-vl-compile
new file mode 100644 (file)
index 0000000..4dc48d9
--- /dev/null
@@ -0,0 +1,170 @@
+    1  cd work/qemu-iwj.git/
+    2  git status
+    3  emacs19&
+    4  emacs&
+    5  ./configure 
+    6  git status
+    7  ls i386
+    8  ls i386-d
+    9  ls i386-dm/
+   10  PATH=~/junk/tricks:$PATH
+   11  ./configure 
+   12  git status
+   13  make -C i386-dm
+   14  ll i386-d
+   15  ll i386-dm/
+   16  ./xen-dm-make-target-dir i386-dm/
+   17  ls i386d-
+   18  ls i386-d
+   19  ls i386-dm/
+   20  rm i386-dm/xen-*
+   21  make -C i386-dm
+   22  ls i386-dm/
+   23  ll -L i386-dm/
+   24  ll i386-dm/
+   25  ll xen-config.mak
+   26  xterm&
+   27  ls -L i386-dm/
+   28  ls -l -L i386-dm/
+   29  ls -l i386-dm/
+   30  ls -l xen-config.mak
+   31  dpkg -S `/bin/ls`
+   32  dpkg -S `type -p /bin/ls`
+   33  dkpg -s coreutils
+   34  dpkg -s coreutils
+   35  ls
+   36  less i386-softmmu/config.mak 
+   37  less loader.c 
+   38  mkdir i386-stubdom
+   39  rm i386-dm/config.mak 
+   40  rm i386-dm/hooks.mak 
+   41  ll xen*
+   42  ll xen*[!~]
+   43  ll hw/xen*[!~]
+   44  make -C i386-dm
+   45  ls i386-dm
+   46  ls i386-stubdom/
+   47  cat i386-stubdom/config.mak 
+   48  make -C i386-dm XENROOT=../xen-unstable.hg
+   49  mv xen-dm-make-target-dir xen-make-target-dir
+   50  rm xen-dm-make-target-dir~ 
+   51  ./xen-make-target-dir i386-dm
+   52  make -C i386-dm XEN_ROOT=../xen-unstable.hg
+   53  make -C i386-dm XEN_ROOT=../../xen-unstable.hg
+   54  make -C i386-dm XEN_ROOT=../../xen-unstable.hg
+   55  ll i386-softmmu/config.
+   56  ll i386-softmmu/config.mak 
+   57  less i386-softmmu/config.mak 
+   58  less config-host.mak 
+   59  make -C i386-dm XEN_ROOT=../../xen-unstable.hg
+   60  find -name cpu.h
+   61  git status target-i386/cpu.h 
+   62  git ann target-i386/cpu.h 
+   63  git blame target-i386/cpu.h 
+   64  make -C i386-dm XEN_ROOT=../../xen-unstable.hg
+   65  find -name config.h
+   66  less i386-softmmu/config.h 
+   67  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+   68  hg status
+   69  git status
+   70  mkdir ../old-qemu-test
+   71  mv floppy.bin big.bin before.png history image.cow initrd* middle.png now.bin strace-grep-history t test.img ../old-qemu-test/
+   72  rm *.rej
+   73  rm *.orig
+   74  rm */*.orig
+   75  rm */*.rej
+   76  git status
+   77  git branch
+   78  git-add i386-dm/config.yh
+   79  git-add i386-dm/config.h
+   80  git-add i386-dm/config.mak 
+   81  git-add i386-dm/hooks.mak
+   82  git-add i386-dm/cpu.h 
+   83  git status
+   84  git add hw/xen*.c
+   85  git-add xen-*.mak
+   86  git-add xen-make-target-dir xenstore.c 
+   87  git status
+   88  git-add hw/xen_console.h hw/xenfb.h i386-stubdom/hooks.mak
+   89  git-add i386-stubdom/config.mak
+   90  git status
+   91  git status
+   92  git ci -m 'wip xen landing from xen-unstable 17192:59b8768d0d0d'
+   93  git ci -m 'wip xen landing from xen-unstable 17192:59b8768d0d0d'
+   94  git-commit -a -m 'wip xen landing from xen-unstable 17192:59b8768d0d0d'
+   95  git-status 
+   96  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+   97  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+   98  xterm&
+   99  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  100  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  101  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  102  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  103  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  104  git-status 
+  105  git-commit -a -m 'WIP make xen compile'
+  106  git-branch 
+  107  git-checkout master
+  108  git-log
+  109  fgrep '()' *.c
+  110  fgrep '()' *.c |less
+  111  fgrep '^[^ ].*()' *.c |less
+  112  egrep '^[^ ].*()' *.c |less
+  113  egrep '^[^ ].*\(\)' *.c |less
+  114  egrep '^[^ ].*\(\)' *.c |less
+  115  egrep '^[^ \t].*\(\)' *.c |less
+  116  egrep '^[^ ].*\(\)' *.c |less
+  117  egrep '^[^      ].*\(\)' *.c |less
+  118  git-status 
+  119  git-diff
+  120  egrep '^[^      ].*\(\)' */*.c |less
+  121  egrep '^[^      ].*\(\)' */*.[ch] |less
+  122  grep pic_info *.c
+  123  grep pic_info *.[ch]
+  124  git-diff
+  125  git-diff
+  126  egrep '^[^      ].*\(\)' */*.[ch] |less
+  127  egrep '^[^      ].*\(\)' */*.[ch] |less
+  128  grep helper *.[ch]
+  129  less hostregs_helper.h 
+  130  grep single_step *.[ch]
+  131  grep helper_cpuid *.[ch]
+  132  grep helper_cpuid */*.[ch]
+  133  grep helper_single_step */*.[ch]
+  134  egrep '^[^      ].*\(\)' */*.[ch] |less
+  135  egrep '^[^      ].*\(\)' */*.[ch] |less
+  136  git-diff
+  137  make clean
+  138  echo $PATH
+  139  ./configure 
+  140  make -j4
+  141  git-diff >../Patches/qemu-void-prototypes.patch
+  142  git-commit -a
+  143  git-status 
+  144  git-branch 
+  145  git-checkout xen
+  146  git-pull master
+  147  git-pull . master
+  148  git-status 
+  149  git-diff
+  150  git-diff HEAD
+  151  git-lo
+  152  git-log 
+  153  make clean
+  154  ./xen-make-target-dir i386-dm
+  155  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  156  find -name helper2.c
+  157  grep phys_ram_addr */*.c
+  158  grep qemu_map_cache */*.c
+  159  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  160  grep SegmentCache */*.c
+  161  grep SegmentCache */*.[ch]
+  162  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  163  git-diff
+  164  git-diff
+  165  git-diff
+  166  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  167  gcc -I. -I.. -I/u/iwj/work/qemu-iwj.git/target- -I/u/iwj/work/qemu-iwj.git -MMD -MP -DNEED_CPU_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DHAS_AUDIO -I/u/iwj/work/qemu-iwj.git/tcg -I/u/iwj/work/qemu-iwj.git/tcg/i386 -I/u/iwj/work/qemu-iwj.git/fpu  -I/u/iwj/work/qemu-iwj.git/slirp -Wall -O2 -g -fno-strict-aliasing -m32 -march=i686 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -mno-tls-direct-seg-refs  -m32 -c -o vl.o /u/iwj/work/qemu-iwj.git/vl.c
+  168  gcc -I. -I.. -I/u/iwj/work/qemu-iwj.git/target- -I/u/iwj/work/qemu-iwj.git -MMD -MP -DNEED_CPU_H -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DHAS_AUDIO -I/u/iwj/work/qemu-iwj.git/tcg -I/u/iwj/work/qemu-iwj.git/tcg/i386 -I/u/iwj/work/qemu-iwj.git/fpu  -I/u/iwj/work/qemu-iwj.git/slirp -Wall -O2 -g -fno-strict-aliasing -m32 -march=i686 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-value -Wdeclaration-after-statement  -D__XEN_TOOLS__ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -mno-tls-direct-seg-refs  -m32 -c -E /u/iwj/work/qemu-iwj.git/vl.c |less
+  169  make -C i386-dm XEN_ROOT=../../xen-unstable.hg 2>&1 |head -40
+  170  history >wip-make-vl-compile
index 9804a05a3c4c9d428a175cd34e722a2e20dd2d92..a09b84c5efe35cec7f069beb453349401ff657f1 100644 (file)
@@ -9,6 +9,8 @@ endif
 
 QEMU_PROG=qemu-dm
 
+CFLAGS += -Wno-unused -Werror
+
 LIBS += -L../../libxc -lxenctrl -lxenguest
 LIBS += -L../../xenstore -lxenstore
 
@@ -22,3 +24,4 @@ OBJS += xen_machine_fv.o
 OBJS += xen_machine_pv.o
 OBJS += xenfb.o
 OBJS += xen_console.o
+OBJS += xen_machine_fv.o
diff --git a/xen-vl-extra.c b/xen-vl-extra.c
new file mode 100644 (file)
index 0000000..ecbd830
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * We #include this from vl.c.
+ *
+ * This is a bit yucky, but it means that the line numbers and other
+ * textual differences in vl.c remain small.
+ */
+/* There is no need for multiple-inclusion protection since
+ * there is only one place where this file is included. */
+
+
+/* forward declarations of things in vl.c */
+
+static int qemu_savevm_state(QEMUFile *f);
+static int qemu_loadvm_state(QEMUFile *f);
+
+/* We use simpler state save/load functions for Xen */
+
+void do_savevm(const char *name)
+{
+    QEMUFile *f;
+    int saved_vm_running, ret;
+
+    f = qemu_fopen(name, "wb");
+    
+    /* ??? Should this occur after vm_stop?  */
+    qemu_aio_flush();
+
+    saved_vm_running = vm_running;
+    vm_stop(0);
+
+    if (!f) {
+        fprintf(logfile, "Failed to open savevm file '%s'\n", name);
+        goto the_end;
+    }
+    
+    ret = qemu_savevm_state(f);
+    qemu_fclose(f);
+
+    if (ret < 0)
+        fprintf(logfile, "Error %d while writing VM to savevm file '%s'\n",
+                ret, name);
+
+ the_end:
+    if (saved_vm_running)
+        vm_start();
+
+    return;
+}
+void do_loadvm(const char *name)
+{
+    QEMUFile *f;
+    int saved_vm_running, ret;
+
+    /* Flush all IO requests so they don't interfere with the new state.  */
+    qemu_aio_flush();
+
+    saved_vm_running = vm_running;
+    vm_stop(0);
+
+    /* restore the VM state */
+    f = qemu_fopen(name, "rb");
+    if (!f) {
+        fprintf(logfile, "Could not open VM state file\n");
+        goto the_end;
+    }
+
+    ret = qemu_loadvm_state(f);
+    qemu_fclose(f);
+    if (ret < 0) {
+        fprintf(logfile, "Error %d while loading savevm file '%s'\n",
+                ret, name);
+        goto the_end; 
+    }
+
+#if 0 
+    /* del tmp file */
+    if (unlink(name) == -1)
+        fprintf(stderr, "delete tmp qemu state file failed.\n");
+#endif
+
+
+ the_end:
+    if (saved_vm_running)
+        vm_start();
+}
+
+struct qemu_alarm_timer;
+static int unix_start_timer(struct qemu_alarm_timer *t) { return 0; }
+static void unix_stop_timer(struct qemu_alarm_timer *t) { }