xen: Update xen.h to upstream + provide stubs.

Change-Id: Id6b3da4ac62f1ffaf35155adb3f70589a359cab1
diff --git a/Makefile.target b/Makefile.target
index 583d7df..b4fb714 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -162,6 +162,7 @@
     memory-android.c \
     monitor-android.c \
     translate-all.c \
+    xen-stub.c \
 
 ##############################################################################
 # CPU-specific emulation.
diff --git a/exec.c b/exec.c
index 9998487..d716614 100644
--- a/exec.c
+++ b/exec.c
@@ -43,6 +43,7 @@
 #include "qemu/osdep.h"
 #include "qemu/tls.h"
 #include "sysemu/kvm.h"
+#include "sysemu/xen-mapcache.h"
 #include "exec/cputlb.h"
 #include "exec/hax.h"
 #include "exec/ram_addr.h"
@@ -1210,7 +1211,7 @@
             if (block->flags & RAM_PREALLOC_MASK) {
                 ;
             } else if (xen_enabled()) {
-                //xen_invalidate_map_cache_entry(block->host);
+                xen_invalidate_map_cache_entry(block->host);
 #ifndef _WIN32
             } else if (block->fd >= 0) {
                 munmap(block->host, block->length);
@@ -1293,7 +1294,6 @@
 void *qemu_get_ram_ptr(ram_addr_t addr)
 {
     RAMBlock *block = qemu_get_ram_block(addr);
-#if 0
     if (xen_enabled()) {
         /* We need to check if the requested address is in the RAM
          * because we don't want to map the entire memory in QEMU.
@@ -1306,7 +1306,6 @@
                 xen_map_cache(block->offset, block->length, 1);
         }
     }
-#endif
     return block->host + (addr - block->offset);
 }
 
@@ -1335,12 +1334,10 @@
 {
     RAMBlock *block;
     uint8_t *host = ptr;
-#if 0
     if (xen_enabled()) {
         *ram_addr = xen_ram_addr_from_mapcache(ptr);
-        return qemu_get_ram_block(*ram_addr)->mr;
+        return 0;
     }
-#endif
     block = ram_list.mru_block;
     if (block && block->host && host - block->host < block->length) {
         goto found;
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 2c85a9b..319f821 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -87,7 +87,7 @@
     bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
     bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
     bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_CODE], page, end - page);
-    //xen_modified_memory(start, length);
+    xen_modified_memory(start, length);
 }
 
 #if !defined(_WIN32)
@@ -118,7 +118,7 @@
                 ram_list.dirty_memory[DIRTY_MEMORY_CODE][page + k] |= temp;
             }
         }
-        //xen_modified_memory(start, pages);
+        xen_modified_memory(start, pages);
     } else {
         /*
          * bitmap-traveling is faster than memory-traveling (for addr...)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 2077a7c..807a99c 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -12,7 +12,7 @@
                                  const char *initrd_filename,
                                  const char *cpu_model);
 
-typedef struct QEMUMachine {
+struct QEMUMachine {
     const char *name;
     const char *desc;
     QEMUMachineInitFunc *init;
@@ -20,7 +20,7 @@
     int max_cpus;
     int is_default;
     struct QEMUMachine *next;
-} QEMUMachine;
+};
 
 int qemu_register_machine(QEMUMachine *m);
 
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index e1f88bf..9d549fc 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -36,7 +36,7 @@
 
 qemu_irq *xen_interrupt_controller_init(void);
 
-int xen_init(void);
+int xen_init(QEMUMachine *machine);
 int xen_hvm_init(MemoryRegion **ram_memory);
 void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
 
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 3638e37..5420df5 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -29,6 +29,7 @@
 
 typedef struct MemoryMappingList MemoryMappingList;
 
+typedef struct QEMUMachine QEMUMachine;
 typedef struct NICInfo NICInfo;
 typedef struct HCIInfo HCIInfo;
 typedef struct AudioState AudioState;
diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h
new file mode 100644
index 0000000..c598040
--- /dev/null
+++ b/include/sysemu/xen-mapcache.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011       Citrix Ltd.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef XEN_MAPCACHE_H
+#define XEN_MAPCACHE_H
+
+#include <stdlib.h>
+
+typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr start_addr,
+                                                     ram_addr_t size,
+                                                     void *opaque);
+#ifdef CONFIG_XEN
+
+void xen_map_cache_init(phys_offset_to_gaddr_t f,
+                        void *opaque);
+uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size,
+                       uint8_t lock);
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
+void xen_invalidate_map_cache_entry(uint8_t *buffer);
+void xen_invalidate_map_cache(void);
+
+#else
+
+static inline void xen_map_cache_init(phys_offset_to_gaddr_t f,
+                                      void *opaque)
+{
+}
+
+static inline uint8_t *xen_map_cache(hwaddr phys_addr,
+                                     hwaddr size,
+                                     uint8_t lock)
+{
+    abort();
+}
+
+static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
+{
+    abort();
+}
+
+static inline void xen_invalidate_map_cache_entry(uint8_t *buffer)
+{
+}
+
+static inline void xen_invalidate_map_cache(void)
+{
+}
+
+#endif
+
+#endif /* !XEN_MAPCACHE_H */
diff --git a/xen-stub.c b/xen-stub.c
new file mode 100644
index 0000000..8093943
--- /dev/null
+++ b/xen-stub.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010       Citrix Ltd.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Contributions after 2012-01-13 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ */
+
+#include "qemu-common.h"
+#include "exec/cpu-common.h"
+#include "hw/xen/xen.h"
+#include "exec/memory.h"
+#include "qmp-commands.h"
+
+void xenstore_store_pv_console_info(int i, CharDriverState *chr)
+{
+}
+
+int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+{
+    return -1;
+}
+
+void xen_piix3_set_irq(void *opaque, int irq_num, int level)
+{
+}
+
+void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len)
+{
+}
+
+void xen_hvm_inject_msi(uint64_t addr, uint32_t data)
+{
+}
+
+void xen_cmos_set_s3_resume(void *opaque, int irq, int level)
+{
+}
+
+void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr)
+{
+}
+
+qemu_irq *xen_interrupt_controller_init(void)
+{
+    return NULL;
+}
+
+int xen_init(QEMUMachine *machine)
+{
+    return -ENOSYS;
+}
+
+void xen_register_framebuffer(MemoryRegion *mr)
+{
+}
+
+void qmp_xen_set_global_dirty_log(bool enable, Error **errp)
+{
+}
+
+void xen_modified_memory(ram_addr_t start, ram_addr_t length)
+{
+}
+
+int xen_hvm_init(MemoryRegion **ram_memory)
+{
+    return 0;
+}