WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging)

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging)
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2008 01:11:32 -0800
Delivery-date: Wed, 23 Jan 2008 01:19:28 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1201015840 25200
# Node ID 603ea719d73a0f99334ec832f84979df605b52f9
# Parent  29268e3fc7ab6d566d95397fa38870ff08432b82
# Parent  0ededc85e6b4f4887e37575794e529043a2612be
merge with xen-unstable.hg (staging)
---
 Makefile                                |    8 
 config/StdGNU.mk                        |   10 
 config/SunOS.mk                         |   15 
 config/ia64.mk                          |    2 
 config/powerpc64.mk                     |    1 
 config/x86_32.mk                        |    1 
 config/x86_64.mk                        |    5 
 extras/mini-os/Makefile                 |   29 +
 extras/mini-os/arch/ia64/time.c         |   27 
 extras/mini-os/arch/x86/mm.c            |   10 
 extras/mini-os/arch/x86/time.c          |   14 
 extras/mini-os/blkfront.c               |    6 
 extras/mini-os/daytime.c                |   64 ++
 extras/mini-os/fs-front.c               |    4 
 extras/mini-os/include/arch/cc.h        |   83 +++
 extras/mini-os/include/arch/perf.h      |   15 
 extras/mini-os/include/arch/sys_arch.h  |   35 +
 extras/mini-os/include/blkfront.h       |    4 
 extras/mini-os/include/console.h        |    3 
 extras/mini-os/include/fs.h             |    1 
 extras/mini-os/include/ia64/arch_mm.h   |    2 
 extras/mini-os/include/ia64/os.h        |    2 
 extras/mini-os/include/lib.h            |   12 
 extras/mini-os/include/lwipopts.h       |   22 
 extras/mini-os/include/netfront.h       |   12 
 extras/mini-os/include/sched.h          |    2 
 extras/mini-os/include/sys/time.h       |   38 +
 extras/mini-os/include/time.h           |   12 
 extras/mini-os/include/types.h          |   21 
 extras/mini-os/include/x86/arch_mm.h    |   29 +
 extras/mini-os/include/x86/arch_sched.h |    2 
 extras/mini-os/include/xmalloc.h        |   21 
 extras/mini-os/kernel.c                 |  167 +++++-
 extras/mini-os/lib/math.c               |   17 
 extras/mini-os/lib/xmalloc.c            |  149 +++--
 extras/mini-os/lwip-arch.c              |  293 ++++++++++
 extras/mini-os/lwip-net.c               |  360 +++++++++++++
 extras/mini-os/minios.mk                |    2 
 extras/mini-os/sched.c                  |    6 
 tools/Makefile                          |   15 
 tools/blktap/drivers/Makefile           |    3 
 tools/blktap/lib/Makefile               |   14 
 tools/check/check_brctl                 |   24 
 tools/check/check_crypto_lib            |   20 
 tools/check/check_curl                  |   41 -
 tools/check/check_iproute               |   25 
 tools/check/check_openssl_devel         |   12 
 tools/check/check_python                |   11 
 tools/check/check_python_devel          |   11 
 tools/check/check_python_xml            |    9 
 tools/check/check_udev                  |   31 -
 tools/check/check_x11_devel             |   15 
 tools/check/check_xgettext              |   12 
 tools/check/check_xml2                  |   34 -
 tools/check/check_zlib_devel            |   12 
 tools/check/check_zlib_lib              |   18 
 tools/check/chk                         |    9 
 tools/check/funcs.sh                    |   85 +++
 tools/console/Makefile                  |    7 
 tools/debugger/xenitp/Makefile          |   19 
 tools/firmware/hvmloader/acpi/Makefile  |    2 
 tools/firmware/hvmloader/acpi/build.c   |    8 
 tools/firmware/hvmloader/acpi/dsdt.asl  |   22 
 tools/firmware/hvmloader/acpi/dsdt.c    |  884 ++++++++++++++++----------------
 tools/firmware/hvmloader/hvmloader.c    |  113 ++--
 tools/flask/libflask/Makefile           |   14 
 tools/flask/loadpolicy/Makefile         |    4 
 tools/fs-back/Makefile                  |    3 
 tools/guest-headers/Makefile            |    4 
 tools/ioemu/configure                   |   36 -
 tools/ioemu/hw/ide.c                    |    5 
 tools/libfsimage/Rules.mk               |    4 
 tools/libfsimage/common/Makefile        |   16 
 tools/libxc/Makefile                    |   24 
 tools/libxen/Makefile                   |   14 
 tools/libxen/Makefile.dist              |   14 
 tools/misc/Makefile                     |    8 
 tools/misc/lomount/Makefile             |    2 
 tools/misc/miniterm/Makefile            |    4 
 tools/python/xen/xend/XendDomainInfo.py |   10 
 tools/security/Makefile                 |    6 
 tools/vnet/doc/Makefile                 |    8 
 tools/vnet/libxutil/Makefile            |   10 
 tools/vnet/scripts/Makefile             |    6 
 tools/vnet/vnetd/Makefile               |    6 
 tools/xcutils/Makefile                  |    2 
 tools/xenmon/Makefile                   |   10 
 tools/xenstat/xentop/Makefile           |   12 
 tools/xenstore/Makefile                 |   28 -
 tools/xentrace/Makefile                 |   19 
 xen/arch/x86/cpu/intel_cacheinfo.c      |  347 +++++++++++-
 xen/arch/x86/hvm/vmx/vtd/Makefile       |    1 
 xen/arch/x86/hvm/vmx/vtd/extern.h       |   55 +
 xen/arch/x86/hvm/vmx/vtd/intel-iommu.c  |  165 ++++-
 xen/arch/x86/hvm/vmx/vtd/qinval.c       |  456 ++++++++++++++++
 xen/arch/x86/hvm/vmx/vtd/vtd.h          |   54 +
 xen/arch/x86/oprofile/nmi_int.c         |   13 
 xen/include/asm-x86/iommu.h             |    4 
 xen/include/public/physdev.h            |    6 
 xen/include/public/xen-compat.h         |    7 
 xen/include/public/xen.h                |    6 
 101 files changed, 3258 insertions(+), 1087 deletions(-)

diff -r 29268e3fc7ab -r 603ea719d73a Makefile
--- a/Makefile  Tue Jan 22 08:27:29 2008 -0700
+++ b/Makefile  Tue Jan 22 08:30:40 2008 -0700
@@ -188,10 +188,10 @@ uninstall:
        rm -rf $(D)/usr/include/xenctrl.h $(D)/usr/include/xenguest.h
        rm -rf $(D)/usr/include/xs_lib.h $(D)/usr/include/xs.h
        rm -rf $(D)/usr/include/xen
-       rm -rf $(D)/usr/$(LIBDIR)/libxenctrl* $(D)/usr/$(LIBDIR)/libxenguest*
-       rm -rf $(D)/usr/$(LIBDIR)/libxenstore*
-       rm -rf $(D)/usr/$(LIBDIR)/python/xen $(D)/usr/$(LIBDIR)/python/grub
-       rm -rf $(D)/usr/$(LIBDIR)/xen/
+       rm -rf $(D)$(LIBDIR)/libxenctrl* $(D)$(LIBDIR)/libxenguest*
+       rm -rf $(D)$(LIBDIR)/libxenstore*
+       rm -rf $(D)$(LIBDIR)/python/xen $(D)$(LIBDIR)/python/grub
+       rm -rf $(D)$(LIBDIR)/xen/
        rm -rf $(D)/usr/lib/xen/
        rm -rf $(D)/usr/local/sbin/setmask $(D)/usr/local/sbin/xen*
        rm -rf $(D)/usr/sbin/xen* $(D)/usr/sbin/netfix $(D)/usr/sbin/xm
diff -r 29268e3fc7ab -r 603ea719d73a config/StdGNU.mk
--- a/config/StdGNU.mk  Tue Jan 22 08:27:29 2008 -0700
+++ b/config/StdGNU.mk  Tue Jan 22 08:30:40 2008 -0700
@@ -17,7 +17,15 @@ INSTALL_DATA = $(INSTALL) -m0644 -p
 INSTALL_DATA = $(INSTALL) -m0644 -p
 INSTALL_PROG = $(INSTALL) -m0755 -p
 
-LIB64DIR = lib64
+PREFIX ?= /usr
+BINDIR = $(PREFIX)/bin
+INCLUDEDIR = $(PREFIX)/include
+LIBDIR = $(PREFIX)/lib
+LIBDIR_x86_64 = $(PREFIX)/lib64
+MANDIR = $(PREFIX)/share/man
+MAN1DIR = $(MANDIR)/man1
+MAN8DIR = $(MANDIR)/man8
+SBINDIR = $(PREFIX)/sbin
 
 SOCKET_LIBS =
 CURSES_LIBS = -lncurses
diff -r 29268e3fc7ab -r 603ea719d73a config/SunOS.mk
--- a/config/SunOS.mk   Tue Jan 22 08:27:29 2008 -0700
+++ b/config/SunOS.mk   Tue Jan 22 08:30:40 2008 -0700
@@ -18,13 +18,24 @@ INSTALL_DATA = $(INSTALL) -m0644 -p
 INSTALL_DATA = $(INSTALL) -m0644 -p
 INSTALL_PROG = $(INSTALL) -m0755 -p
 
-LIB64DIR = lib/amd64
+PREFIX ?= /usr
+BINDIR = $(PREFIX)/bin
+INCLUDEDIR = $(PREFIX)/include
+LIBDIR = $(PREFIX)/lib
+LIBDIR_x86_64 = $(PREFIX)/lib/amd64
+MANDIR = $(PREFIX)/share/man
+MAN1DIR = $(MANDIR)/man1
+MAN8DIR = $(MANDIR)/man8
+SBINDIR = $(PREFIX)/sbin
+
+SunOS_LIBDIR = /usr/sfw/lib
+SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64
 
 SOCKET_LIBS = -lsocket
 CURSES_LIBS = -lcurses
 UTIL_LIBS =
 SONAME_LDFLAG = -h
-SHLIB_CFLAGS = -R /usr/sfw/$(LIBDIR) -shared
+SHLIB_CFLAGS = -R $(SunOS_LIBDIR) -shared
 
 ifneq ($(debug),y)
 # Optimisation flags are overridable
diff -r 29268e3fc7ab -r 603ea719d73a config/ia64.mk
--- a/config/ia64.mk    Tue Jan 22 08:27:29 2008 -0700
+++ b/config/ia64.mk    Tue Jan 22 08:30:40 2008 -0700
@@ -4,5 +4,3 @@ CONFIG_IOEMU := y
 CONFIG_IOEMU := y
 CONFIG_XCUTILS := y
 CONFIG_XENCOMM := y
-
-LIBDIR := lib
diff -r 29268e3fc7ab -r 603ea719d73a config/powerpc64.mk
--- a/config/powerpc64.mk       Tue Jan 22 08:27:29 2008 -0700
+++ b/config/powerpc64.mk       Tue Jan 22 08:30:40 2008 -0700
@@ -4,4 +4,3 @@ CONFIG_XENCOMM := y
 CONFIG_XENCOMM := y
 
 CFLAGS += -DELFSIZE=64
-LIBDIR := lib
diff -r 29268e3fc7ab -r 603ea719d73a config/x86_32.mk
--- a/config/x86_32.mk  Tue Jan 22 08:27:29 2008 -0700
+++ b/config/x86_32.mk  Tue Jan 22 08:30:40 2008 -0700
@@ -8,7 +8,6 @@ CONFIG_IOEMU := y
 CONFIG_IOEMU := y
 
 CFLAGS += -m32 -march=i686
-LIBDIR := lib
 
 # Use only if calling $(LD) directly.
 LDFLAGS_DIRECT_OpenBSD = _obsd
diff -r 29268e3fc7ab -r 603ea719d73a config/x86_64.mk
--- a/config/x86_64.mk  Tue Jan 22 08:27:29 2008 -0700
+++ b/config/x86_64.mk  Tue Jan 22 08:30:40 2008 -0700
@@ -9,7 +9,10 @@ CONFIG_IOEMU := y
 CONFIG_IOEMU := y
 
 CFLAGS += -m64
-LIBDIR = $(LIB64DIR)
+
+LIBDIR = $(LIBDIR_x86_64)
+
+SunOS_LIBDIR = $(SunOS_LIBDIR_x86_64)
 
 # Use only if calling $(LD) directly.
 ifeq ($(XEN_OS),OpenBSD)
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/Makefile
--- a/extras/mini-os/Makefile   Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/Makefile   Tue Jan 22 08:30:40 2008 -0700
@@ -47,8 +47,18 @@ EXTRA_INC =
 # This must be before include minios.mk!
 include $(TARGET_ARCH_DIR)/arch.mk
 
+ifneq ($(LWIPDIR),)
+lwip=y
+DEF_CFLAGS += -DHAVE_LWIP
+DEF_CFLAGS += -I$(LWIPDIR)/src/include
+DEF_CFLAGS += -I$(LWIPDIR)/src/include/ipv4
+endif
+
 # Include common mini-os makerules.
 include minios.mk
+
+# Set tester flags
+# CFLAGS += -DBLKTEST_WRITE
 
 # Define some default flags for linking.
 LDLIBS := 
@@ -90,6 +100,24 @@ arch_lib:
 arch_lib:
        $(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
 
+ifeq ($(lwip),y)
+# lwIP library
+LWC    := $(shell find $(LWIPDIR)/ -type f -name '*.c')
+LWC    := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
+LWC    += lwip-arch.c lwip-net.c
+LWO    := $(patsubst %.c,%.o,$(LWC))
+
+lwip.a: $(LWO)
+       $(RM) $@
+       $(AR) cqs $@ $^
+
+OBJS += lwip.a
+
+OBJS := $(filter-out $(LWO), $(OBJS))
+else
+OBJS := $(filter-out daytime.o lwip%.o, $(OBJS))
+endif
+
 $(TARGET): links $(OBJS) arch_lib
        $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) -o $@.o
        $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
@@ -107,6 +135,7 @@ clean:      arch_clean
        done
        rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
        find . -type l | xargs rm -f
+       $(RM) lwip.a $(LWO)
        rm -f tags TAGS
 
 
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/arch/ia64/time.c
--- a/extras/mini-os/arch/ia64/time.c   Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/arch/ia64/time.c   Tue Jan 22 08:30:40 2008 -0700
@@ -76,7 +76,7 @@ static uint64_t itm_val;
  * will already get problems at other places on 2038-01-19 03:14:08)
  */
 static unsigned long
-mktime(const unsigned int year0, const unsigned int mon0,
+_mktime(const unsigned int year0, const unsigned int mon0,
        const unsigned int day, const unsigned int hour,
        const unsigned int min, const unsigned int sec)
 {
@@ -147,10 +147,10 @@ calculate_time(void)
                new = itc_new - itc_alt;
        itc_alt = itc_new;
        new = ns_from_cycles(new);
-       os_time.ts_nsec += new;
-       if (os_time.ts_nsec > 1000000000) {     /* On overflow. */
-               os_time.ts_sec++;
-               os_time.ts_nsec -= 1000000000;
+       os_time.tv_nsec += new;
+       if (os_time.tv_nsec > 1000000000) {     /* On overflow. */
+               os_time.tv_sec++;
+               os_time.tv_nsec -= 1000000000;
        }
 }
 
@@ -177,12 +177,13 @@ monotonic_clock(void)
        return delta;
 }
 
-void
-gettimeofday(struct timeval *tv)
+int
+gettimeofday(struct timeval *tv, void *tz)
 {
        calculate_time();
-       tv->tv_sec = os_time.ts_sec;                    /* seconds */
-       tv->tv_usec = NSEC_TO_USEC(os_time.ts_nsec);    /* microseconds */
+       tv->tv_sec = os_time.tv_sec;                    /* seconds */
+       tv->tv_usec = NSEC_TO_USEC(os_time.tv_nsec);    /* microseconds */
+        return 0;
 };
 
 /*
@@ -253,16 +254,16 @@ init_time(void)
        itm_val = (itc_frequency + HZ/2) / HZ;
        printk("  itm_val: %ld\n", itm_val);
 
-       os_time.ts_sec = 0;
-       os_time.ts_nsec = 0;
+       os_time.tv_sec = 0;
+       os_time.tv_nsec = 0;
 
        if (efi_get_time(&tm)) {
                printk("  EFI-Time: %d.%d.%d   %d:%d:%d\n", tm.Day,
                       tm.Month, tm.Year, tm.Hour, tm.Minute, tm.Second);
-               os_time.ts_sec = mktime(SWAP(tm.Year), SWAP(tm.Month),
+               os_time.tv_sec = _mktime(SWAP(tm.Year), SWAP(tm.Month),
                                        SWAP(tm.Day), SWAP(tm.Hour),
                                        SWAP(tm.Minute), SWAP(tm.Second));
-               os_time.ts_nsec = tm.Nanosecond;
+               os_time.tv_nsec = tm.Nanosecond;
        } else
                printk("efi_get_time() failed\n");
 
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/arch/x86/mm.c
--- a/extras/mini-os/arch/x86/mm.c      Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/arch/x86/mm.c      Tue Jan 22 08:30:40 2008 -0700
@@ -497,11 +497,11 @@ static void clear_bootstrap(void)
     int n = sizeof(mfns)/sizeof(*mfns);
     pte_t nullpte = { };
 
-    /* Use page 0 as the CoW zero page */
-    memset(NULL, 0, PAGE_SIZE);
-    mfn_zero = pfn_to_mfn(0);
-    if (HYPERVISOR_update_va_mapping(0, nullpte, UVMF_INVLPG))
-       printk("Unable to unmap page 0\n");
+    /* Use first page as the CoW zero page */
+    memset(&_text, 0, PAGE_SIZE);
+    mfn_zero = pfn_to_mfn((unsigned long) &_text);
+    if (HYPERVISOR_update_va_mapping((unsigned long) &_text, nullpte, 
UVMF_INVLPG))
+       printk("Unable to unmap first page\n");
 
     set_xen_guest_handle(reservation.extent_start, mfns);
     reservation.nr_extents = n;
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/arch/x86/time.c
--- a/extras/mini-os/arch/x86/time.c    Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/arch/x86/time.c    Tue Jan 22 08:30:40 2008 -0700
@@ -175,30 +175,32 @@ static void update_wallclock(void)
        do {
                shadow_ts_version = s->wc_version;
                rmb();
-               shadow_ts.ts_sec  = s->wc_sec;
-               shadow_ts.ts_nsec = s->wc_nsec;
+               shadow_ts.tv_sec  = s->wc_sec;
+               shadow_ts.tv_nsec = s->wc_nsec;
                rmb();
        }
        while ((s->wc_version & 1) | (shadow_ts_version ^ s->wc_version));
 }
 
 
-void gettimeofday(struct timeval *tv)
+int gettimeofday(struct timeval *tv, void *tz)
 {
     u64 nsec = monotonic_clock();
-    nsec += shadow_ts.ts_nsec;
+    nsec += shadow_ts.tv_nsec;
     
     
-    tv->tv_sec = shadow_ts.ts_sec;
+    tv->tv_sec = shadow_ts.tv_sec;
     tv->tv_sec += NSEC_TO_SEC(nsec);
     tv->tv_usec = NSEC_TO_USEC(nsec % 1000000000UL);
+
+    return 0;
 }
 
 
 void block_domain(s_time_t until)
 {
     struct timeval tv;
-    gettimeofday(&tv);
+    gettimeofday(&tv, NULL);
     if(monotonic_clock() < until)
     {
         HYPERVISOR_set_timer_op(until);
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/blkfront.c Tue Jan 22 08:30:40 2008 -0700
@@ -71,8 +71,8 @@ struct blkfront_dev *init_blkfront(char 
 
     struct blkfront_dev *dev;
 
-    ASSERT(!strncmp(nodename, "/local/domain/", 14));
-    nodename = strchr(nodename + 14, '/') + 1;
+    if (!nodename)
+        nodename = "device/vbd/768";
 
     char path[strlen(nodename) + 1 + 10 + 1];
 
@@ -88,7 +88,7 @@ struct blkfront_dev *init_blkfront(char 
     SHARED_RING_INIT(s);
     FRONT_RING_INIT(&dev->ring, s, PAGE_SIZE);
 
-    dev->ring_ref = gnttab_grant_access(0,virt_to_mfn(s),0);
+    dev->ring_ref = gnttab_grant_access(0,virtual_to_mfn(s),0);
 
     evtchn_alloc_unbound_t op;
     op.dom = DOMID_SELF;
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/daytime.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/daytime.c  Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,64 @@
+/* 
+ * daytime.c: a simple network service based on lwIP and mini-os
+ * 
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ */
+
+#include <os.h>
+#include <xmalloc.h>
+#include <console.h>
+#include <netfront.h>
+#include <lwip/api.h>
+
+static char message[29];
+
+void run_server(void *p)
+{
+    struct ip_addr listenaddr = { 0 };
+    struct ip_addr ipaddr = { htonl(0x0a000001) };
+    struct ip_addr netmask = { htonl(0xff000000) };
+    struct ip_addr gw = { 0 };
+    struct netconn *listener;
+    struct netconn *session;
+    struct timeval tv;
+    err_t rc;
+
+    start_networking();
+    networking_set_addr(&ipaddr, &netmask, &gw);
+
+    tprintk("Opening connection\n");
+
+    listener = netconn_new(NETCONN_TCP);
+    tprintk("Connection at %p\n", listener);
+
+    rc = netconn_bind(listener, &listenaddr, 13);
+    if (rc != ERR_OK) {
+        tprintk("Failed to bind connection: %i\n", rc);
+        return;
+    }
+
+    rc = netconn_listen(listener);
+    if (rc != ERR_OK) {
+        tprintk("Failed to listen on connection: %i\n", rc);
+        return;
+    }
+
+    while (1) {
+        session = netconn_accept(listener);
+        if (session == NULL) 
+            continue;
+
+        gettimeofday(&tv, NULL);
+        sprintf(message, "%20lu.%6.6lu\n", tv.tv_sec, tv.tv_usec);
+        (void) netconn_write(session, message, strlen(message), NETCONN_COPY);
+        (void) netconn_disconnect(session);
+        (void) netconn_delete(session);
+    }
+}
+
+
+int app_main(start_info_t *si)
+{
+    create_thread("server", run_server, NULL);
+    return 0;
+}
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/fs-front.c
--- a/extras/mini-os/fs-front.c Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/fs-front.c Tue Jan 22 08:30:40 2008 -0700
@@ -817,7 +817,7 @@ void test_fs_import(void *data)
     long ret64;
    
     /* Sleep for 1s and then try to open a file */
-    sleep(1000);
+    msleep(1000);
     ret = fs_create(import, "mini-os-created-directory", 1, 0777);
     printk("Directory create: %d\n", ret);
 
@@ -1013,7 +1013,7 @@ done:
             printk("Backend found at %s\n", import->backend);
             break;
         }
-       sleep(WAIT_PERIOD);
+       msleep(WAIT_PERIOD);
     }        
     
     if(!import->backend)
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/arch/cc.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/include/arch/cc.h  Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,83 @@
+/* 
+ * lwip/arch/cc.h
+ *
+ * Compiler-specific types and macros for lwIP running on mini-os 
+ *
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ */
+
+#ifndef __LWIP_ARCH_CC_H__
+#define __LWIP_ARCH_CC_H__
+
+/*   Typedefs for the types used by lwip - */
+#include <os.h>
+#include <types.h>
+#include <time.h>
+typedef  u8  u8_t;
+typedef  s8  s8_t;
+typedef u16 u16_t;
+typedef s16 s16_t;
+typedef u32 u32_t;
+typedef s32 s32_t;
+typedef u64 u64_t;
+typedef s64 s64_t;
+typedef uintptr_t mem_ptr_t;
+
+typedef u16 u_short;
+
+/*   Compiler hints for packing lwip's structures - */
+#define PACK_STRUCT_FIELD(_x)  _x
+#define PACK_STRUCT_STRUCT     __attribute__ ((packed))
+#define PACK_STRUCT_BEGIN 
+#define PACK_STRUCT_END
+
+/*   Platform specific diagnostic output - */
+
+extern void lwip_printk(char *fmt, ...);
+#define LWIP_PLATFORM_DIAG(_x) do { lwip_printk _x ; } while (0)
+
+extern void lwip_die(char *fmt, ...);
+#define LWIP_PLATFORM_ASSERT(_x) do { lwip_die(_x); } while(0)
+
+/*   "lightweight" synchronization mechanisms - */
+/*     SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable. */
+/*     SYS_ARCH_PROTECT(x)      - enter protection mode. */
+/*     SYS_ARCH_UNPROTECT(x)    - leave protection mode. */
+
+/*   If the compiler does not provide memset() this file must include a */
+/*   definition of it, or include a file which defines it. */
+#include <lib.h>
+
+/*   This file must either include a system-local <errno.h> which defines */
+/*   the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO */
+/*   to make lwip/arch.h define the codes which are used throughout. */
+#include <errno.h>
+
+/*   Not required by the docs, but needed for network-order calculations */
+#include <endian.h>
+
+#include <inttypes.h>
+#define S16_F PRIi16
+#define U16_F PRIu16
+#define X16_F PRIx16
+#define S32_F PRIi32
+#define U32_F PRIu32
+#define X32_F PRIx32
+
+#if 0
+#ifndef DBG_ON
+#define DBG_ON LWIP_DBG_ON
+#endif
+#define LWIP_DEBUG     DBG_ON
+//#define IP_DEBUG     DBG_ON
+#define TCP_DEBUG      DBG_ON
+#define TCP_INPUT_DEBUG        DBG_ON
+#define TCP_QLEN_DEBUG DBG_ON
+#define TCPIP_DEBUG    DBG_ON
+#define DBG_TYPES_ON   DBG_ON
+#endif
+
+/* TODO: checksum doesn't work fine?! */
+#define CHECKSUM_CHECK_TCP     0
+
+#endif /* __LWIP_ARCH_CC_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/arch/perf.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/include/arch/perf.h        Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,15 @@
+/* 
+ * lwip/arch/perf.h
+ *
+ * Arch-specific performance measurement for lwIP running on mini-os 
+ *
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ */
+
+#ifndef __LWIP_ARCH_PERF_H__
+#define __LWIP_ARCH_PERF_H__
+
+#define PERF_START    do { } while(0)
+#define PERF_STOP(_x) do { (void)(_x); } while (0)
+
+#endif /* __LWIP_ARCH_PERF_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/arch/sys_arch.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/include/arch/sys_arch.h    Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,35 @@
+/* 
+ * lwip/arch/sys_arch.h
+ *
+ * Arch-specific semaphores and mailboxes for lwIP running on mini-os 
+ *
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ */
+
+#ifndef __LWIP_ARCH_SYS_ARCH_H__
+#define __LWIP_ARCH_SYS_ARCH_H__
+
+#include <os.h>
+#include <xmalloc.h>
+#include <semaphore.h>
+
+typedef struct semaphore *sys_sem_t;
+#define SYS_SEM_NULL ((sys_sem_t) NULL)
+
+struct mbox {
+    int count;
+    void **messages;
+    struct semaphore read_sem;
+    struct semaphore write_sem;
+    int writer;
+    int reader;
+};
+
+typedef struct mbox *sys_mbox_t;
+#define SYS_MBOX_NULL ((sys_mbox_t) 0)
+
+typedef struct thread *sys_thread_t;
+
+typedef unsigned long sys_prot_t;
+
+#endif /*__LWIP_ARCH_SYS_ARCH_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/blkfront.h
--- a/extras/mini-os/include/blkfront.h Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/blkfront.h Tue Jan 22 08:30:40 2008 -0700
@@ -7,7 +7,7 @@ struct blkfront_aiocb
     struct blkfront_dev *aio_dev;
     uint8_t *aio_buf;
     size_t aio_nbytes;
-    uint64_t aio_offset;
+    off_t aio_offset;
     void *data;
 
     grant_ref_t gref[BLKIF_MAX_SEGMENTS_PER_REQUEST];
@@ -15,7 +15,9 @@ struct blkfront_aiocb
     void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret);
 };
 struct blkfront_dev *init_blkfront(char *nodename, uint64_t *sectors, unsigned 
*sector_size, int *mode);
+#ifdef HAVE_LIBC
 int blkfront_open(struct blkfront_dev *dev);
+#endif
 void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
 void blkfront_aio_read(struct blkfront_aiocb *aiocbp);
 void blkfront_aio_write(struct blkfront_aiocb *aiocbp);
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/console.h
--- a/extras/mini-os/include/console.h  Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/console.h  Tue Jan 22 08:30:40 2008 -0700
@@ -38,8 +38,11 @@
 
 #include<traps.h>
 
+void print(int direct, const char *fmt, va_list args);
 void printk(const char *fmt, ...);
 void xprintk(const char *fmt, ...);
+
+#define tprintk(_fmt, _args...) printk("[%s] " _fmt, current->name, ##_args) 
 
 void xencons_rx(char *buf, unsigned len, struct pt_regs *regs);
 void xencons_tx(void);
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/fs.h
--- a/extras/mini-os/include/fs.h       Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/fs.h       Tue Jan 22 08:30:40 2008 -0700
@@ -3,6 +3,7 @@
 
 #include <xen/io/fsif.h>
 #include <semaphore.h>
+#include <types.h>
 
 struct fs_import 
 {
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/ia64/arch_mm.h
--- a/extras/mini-os/include/ia64/arch_mm.h     Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/ia64/arch_mm.h     Tue Jan 22 08:30:40 2008 -0700
@@ -25,6 +25,7 @@
 #define __ARCH_MM_H__
 
 #include "page.h"
+#include "ia64_cpu.h"
 
 #define PFN_PHYS(x)    (pfn_to_page(x))
 #define PHYS_PFN(x)    (page_to_pfn(x))
@@ -32,6 +33,7 @@
 #define to_phys(x)     __pa(x)
 
 #define virt_to_mfn(x) virt_to_pfn(x)
+#define virtual_to_mfn(x)      (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT)
 
 #define STACK_SIZE_PAGE_ORDER   1
 #define STACK_SIZE              (PAGE_SIZE * (1 << STACK_SIZE_PAGE_ORDER))
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/ia64/os.h
--- a/extras/mini-os/include/ia64/os.h  Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/ia64/os.h  Tue Jan 22 08:30:40 2008 -0700
@@ -38,7 +38,9 @@
 
 
 typedef uint64_t paddr_t;              /* Physical address. */
+#ifndef HAVE_LIBC
 typedef uint64_t caddr_t;              /* rr7/kernel memory address. */
+#endif
 
 #include "page.h"
 #include "mm.h"
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/lib.h
--- a/extras/mini-os/include/lib.h      Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/lib.h      Tue Jan 22 08:30:40 2008 -0700
@@ -59,6 +59,9 @@
 #include <stddef.h>
 #include <console.h>
 
+#ifdef HAVE_LIBC
+#include <stdio.h>
+#else
 /* printing */
 #define _p(_x) ((void *)(unsigned long)(_x))
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
@@ -69,13 +72,16 @@ int sprintf(char * buf, const char *fmt,
 int sprintf(char * buf, const char *fmt, ...);
 int vsscanf(const char * buf, const char * fmt, va_list args);
 int sscanf(const char * buf, const char * fmt, ...);
+#endif
 
 long simple_strtol(const char *cp,char **endp,unsigned int base);
 unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
 long long simple_strtoll(const char *cp,char **endp,unsigned int base);
 unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int 
base);
 
-
+#ifdef HAVE_LIBC
+#include <string.h>
+#else
 /* string and memory manipulation */
 int    memcmp(const void *cs, const void *ct, size_t count);
 void  *memcpy(void *dest, const void *src, size_t count);
@@ -91,7 +97,11 @@ char  *strstr(const char *s1, const char
 char  *strstr(const char *s1, const char *s2);
 char * strcat(char * dest, const char * src);
 char  *strdup(const char *s);
+#endif
 
+#define RAND_MIX 2654435769U
+
+int rand(void);
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/lwipopts.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/include/lwipopts.h Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,22 @@
+/*
+ * lwipopts.h
+ *
+ * Configuration for lwIP running on mini-os 
+ *
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ */
+
+#ifndef __LWIP_LWIPOPTS_H__
+#define __LWIP_LWIPOPTS_H__
+
+#define SYS_LIGHTWEIGHT_PROT 1
+#define MEM_LIBC_MALLOC 1
+#define LWIP_TIMEVAL_PRIVATE 0
+#define LWIP_DHCP 1
+#define LWIP_COMPAT_SOCKETS 0
+#define LWIP_IGMP 1
+#define MEMP_NUM_SYS_TIMEOUT 10
+#define TCP_SND_BUF 3000
+#define TCP_MSS 1500
+
+#endif /* __LWIP_LWIPOPTS_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/netfront.h
--- a/extras/mini-os/include/netfront.h Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/netfront.h Tue Jan 22 08:30:40 2008 -0700
@@ -1,7 +1,19 @@
 #include <wait.h>
+#ifdef HAVE_LWIP
+#include <lwip/netif.h>
+#endif
 struct netfront_dev;
 struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(unsigned 
char *data, int len), unsigned char rawmac[6]);
 void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
 void shutdown_netfront(struct netfront_dev *dev);
 
 extern struct wait_queue_head netfront_queue;
+
+#ifdef HAVE_LWIP
+/* Call this to bring up the netfront interface and the lwIP stack.
+ * N.B. _must_ be called from a thread; it's not safe to call this from 
+ * app_main(). */
+void start_networking(void);
+
+void networking_set_addr(struct ip_addr *ipaddr, struct ip_addr *netmask, 
struct ip_addr *gw);
+#endif
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/sched.h
--- a/extras/mini-os/include/sched.h    Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/sched.h    Tue Jan 22 08:30:40 2008 -0700
@@ -47,6 +47,6 @@ void schedule(void);
 
 void wake(struct thread *thread);
 void block(struct thread *thread);
-void sleep(u32 millisecs);
+void msleep(u32 millisecs);
 
 #endif /* __SCHED_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/sys/time.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/include/sys/time.h Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,38 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+ ****************************************************************************
+ * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
+ * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
+ ****************************************************************************
+ *
+ *        File: time.h
+ *      Author: Rolf Neugebauer (neugebar@xxxxxxxxxxxxx)
+ *     Changes: Grzegorz Milos (gm281@xxxxxxxxx)
+ *              Robert Kaiser (kaiser@xxxxxxxxxxxxxxxxxxxxxxxxxx)
+ *              
+ *        Date: Jul 2003, changes: Jun 2005, Sep 2006
+ * 
+ * Environment: Xen Minimal OS
+ * Description: Time and timer functions
+ *
+ ****************************************************************************
+ */
+
+#ifndef _MINIOS_SYS_TIME_H_
+#define _MINIOS_SYS_TIME_H_
+
+struct timespec {
+    time_t      tv_sec;
+    long        tv_nsec;
+};
+
+struct timezone {
+};
+
+struct timeval {
+       time_t          tv_sec;         /* seconds */
+       suseconds_t     tv_usec;        /* microseconds */
+};
+
+int      gettimeofday(struct timeval *tv, void *tz);
+
+#endif /* _MINIOS_SYS_TIME_H_ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/time.h
--- a/extras/mini-os/include/time.h     Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/time.h     Tue Jan 22 08:30:40 2008 -0700
@@ -38,20 +38,13 @@ typedef s64 s_time_t;
 #define Time_Max                ((s_time_t) 0x7fffffffffffffffLL)
 #define FOREVER                 Time_Max
 #define NSEC_TO_USEC(_nsec)     ((_nsec) / 1000UL)
+#define NSEC_TO_MSEC(_nsec)     ((_nsec) / 1000000ULL)
 #define NSEC_TO_SEC(_nsec)      ((_nsec) / 1000000000ULL)
 
 /* wall clock time  */
 typedef long time_t;
 typedef long suseconds_t;
-struct timeval {
-       time_t          tv_sec;         /* seconds */
-       suseconds_t     tv_usec;        /* microseconds */
-};
-
-struct timespec {
-    time_t      ts_sec;
-    long        ts_nsec;
-};
+#include <sys/time.h>
 
 
 /* prototypes */
@@ -59,7 +52,6 @@ s_time_t get_s_time(void);
 s_time_t get_s_time(void);
 s_time_t get_v_time(void);
 u64      monotonic_clock(void);
-void     gettimeofday(struct timeval *tv);
 void     block_domain(s_time_t until);
 
 #endif /* _TIME_H_ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/types.h
--- a/extras/mini-os/include/types.h    Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/types.h    Tue Jan 22 08:30:40 2008 -0700
@@ -19,6 +19,7 @@
 
 #ifndef _TYPES_H_
 #define _TYPES_H_
+#include <stddef.h>
 
 typedef signed char         s8;
 typedef unsigned char       u8;
@@ -41,7 +42,6 @@ typedef unsigned long       u_long;
 #ifdef __i386__
 typedef long long           quad_t;
 typedef unsigned long long  u_quad_t;
-typedef unsigned int        uintptr_t;
 
 #if !defined(CONFIG_X86_PAE)
 typedef struct { unsigned long pte_low; } pte_t;
@@ -52,7 +52,6 @@ typedef struct { unsigned long pte_low, 
 #elif defined(__x86_64__) || defined(__ia64__)
 typedef long                quad_t;
 typedef unsigned long       u_quad_t;
-typedef unsigned long       uintptr_t;
 
 typedef struct { unsigned long pte; } pte_t;
 #endif /* __i386__ || __x86_64__ */
@@ -64,19 +63,31 @@ typedef struct { unsigned long pte; } pt
     ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })
 #endif
 
+#ifdef HAVE_LIBC
+#include <limits.h>
+#include <stdint.h>
+#else
+#ifdef __i386__
+typedef unsigned int        uintptr_t;
+typedef int                 intptr_t;
+#elif defined(__x86_64__) || defined(__ia64__)
+typedef unsigned long       uintptr_t;
+typedef long                intptr_t;
+#endif /* __i386__ || __x86_64__ */
 typedef  u8 uint8_t;
 typedef  s8 int8_t;
 typedef u16 uint16_t;
 typedef s16 int16_t;
 typedef u32 uint32_t;
 typedef s32 int32_t;
-typedef u64 uint64_t;
-typedef s64 int64_t;
+typedef u64 uint64_t, uintmax_t;
+typedef s64 int64_t, intmax_t;
+typedef u64 off_t;
 
 
 #define INT_MAX         ((int)(~0U>>1))
 #define UINT_MAX            (~0U)
 
 typedef long ssize_t;
-typedef unsigned long size_t;
+#endif
 #endif /* _TYPES_H_ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/x86/arch_mm.h
--- a/extras/mini-os/include/x86/arch_mm.h      Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/x86/arch_mm.h      Tue Jan 22 08:30:40 2008 -0700
@@ -226,6 +226,35 @@ static __inline__ paddr_t machine_to_phy
 #define pte_to_mfn(_pte)           (((_pte) & (PADDR_MASK&PAGE_MASK)) >> 
L1_PAGETABLE_SHIFT)
 #define pte_to_virt(_pte)          to_virt(mfn_to_pfn(pte_to_mfn(_pte)) << 
PAGE_SHIFT)
 
+
+#define PT_BASE                           ((pgentry_t *)start_info.pt_base)
+
+#ifdef __x86_64__
+#define virtual_to_l3(_virt)      ((pgentry_t 
*)pte_to_virt(PT_BASE[l4_table_offset(_virt)]))
+#else
+#define virtual_to_l3(_virt)      PT_BASE
+#endif
+
+#if defined(__x86_64__) || defined(CONFIG_X86_PAE)
+#define virtual_to_l2(_virt)      ({ \
+       unsigned long __virt2 = (_virt); \
+       (pgentry_t *) 
pte_to_virt(virtual_to_l3(__virt2)[l3_table_offset(__virt2)]); \
+})
+#else
+#define virtual_to_l2(_virt)      PT_BASE
+#endif
+
+#define virtual_to_l1(_virt)      ({ \
+       unsigned long __virt1 = (_virt); \
+       (pgentry_t *) 
pte_to_virt(virtual_to_l2(__virt1)[l2_table_offset(__virt1)]); \
+})
+
+#define virtual_to_pte(_virt)     ({ \
+       unsigned long __virt0 = (unsigned long) (_virt); \
+       virtual_to_l1(__virt0)[l1_table_offset(__virt0)]; \
+})
+#define virtual_to_mfn(_virt)     pte_to_mfn(virtual_to_pte(_virt))
+
 #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, L1_PROT)
 #define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, 
L1_PROT_RO)
 
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/x86/arch_sched.h
--- a/extras/mini-os/include/x86/arch_sched.h   Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/x86/arch_sched.h   Tue Jan 22 08:30:40 2008 -0700
@@ -12,7 +12,7 @@ static inline struct thread* get_current
 #else
     register unsigned long sp asm("rsp");
 #endif 
-    current = (void *)(sp & ~(STACK_SIZE-1));
+    current = (void *)(unsigned long)(sp & ~(STACK_SIZE-1));
     return *current;
 }
 
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/include/xmalloc.h
--- a/extras/mini-os/include/xmalloc.h  Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/include/xmalloc.h  Tue Jan 22 08:30:40 2008 -0700
@@ -1,13 +1,18 @@
 #ifndef __XMALLOC_H__
 #define __XMALLOC_H__
 
+#ifdef HAVE_LIBC
+
+#include <stdlib.h>
+#include <malloc.h>
 /* Allocate space for typed object. */
-#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
+#define _xmalloc(size, align) memalign(align, size)
+#define xfree(ptr) free(ptr)
 
-/* Allocate space for array of typed objects. */
-#define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), 
__alignof__(_type), _num))
+#else
 
-#define malloc(size) _xmalloc(size, 4)
+#define DEFAULT_ALIGN (sizeof(unsigned long))
+#define malloc(size) _xmalloc(size, DEFAULT_ALIGN)
 #define free(ptr) xfree(ptr)
 #define realloc(ptr, size) _realloc(ptr, size)
 
@@ -18,6 +23,8 @@ extern void *_xmalloc(size_t size, size_
 extern void *_xmalloc(size_t size, size_t align);
 extern void *_realloc(void *ptr, size_t size);
 
+#endif
+
 static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
 {
        /* Check for overflow. */
@@ -26,4 +33,10 @@ static inline void *_xmalloc_array(size_
        return _xmalloc(size * num, align);
 }
 
+/* Allocate space for typed object. */
+#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
+
+/* Allocate space for array of typed objects. */
+#define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), 
__alignof__(_type), _num))
+
 #endif /* __XMALLOC_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c   Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/kernel.c   Tue Jan 22 08:30:40 2008 -0700
@@ -38,7 +38,10 @@
 #include <xenbus.h>
 #include <gnttab.h>
 #include <netfront.h>
+#include <blkfront.h>
 #include <fs.h>
+#include <xmalloc.h>
+#include <fcntl.h>
 #include <xen/features.h>
 #include <xen/version.h>
 
@@ -75,15 +78,174 @@ static void periodic_thread(void *p)
     printk("Periodic thread started.\n");
     for(;;)
     {
-        gettimeofday(&tv);
+        gettimeofday(&tv, NULL);
         printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
-        sleep(1000);
+        msleep(1000);
     }
 }
 
 static void netfront_thread(void *p)
 {
     init_netfront(NULL, NULL, NULL);
+}
+
+static struct blkfront_dev *blk_dev;
+static uint64_t blk_sectors;
+static unsigned blk_sector_size;
+static int blk_mode;
+static uint64_t blk_size_read;
+static uint64_t blk_size_write;
+
+struct blk_req {
+    struct blkfront_aiocb aiocb;
+    int rand_value;
+    struct blk_req *next;
+};
+
+#ifdef BLKTEST_WRITE
+static struct blk_req *blk_to_read;
+#endif
+
+static struct blk_req *blk_alloc_req(uint64_t sector)
+{
+    struct blk_req *req = xmalloc(struct blk_req);
+    req->aiocb.aio_dev = blk_dev;
+    req->aiocb.aio_buf = _xmalloc(blk_sector_size, blk_sector_size);
+    req->aiocb.aio_nbytes = blk_sector_size;
+    req->aiocb.aio_offset = sector * blk_sector_size;
+    req->aiocb.data = req;
+    req->next = NULL;
+    return req;
+}
+
+static void blk_read_completed(struct blkfront_aiocb *aiocb, int ret)
+{
+    struct blk_req *req = aiocb->data;
+    if (ret)
+        printk("got error code %d when reading at offset %ld\n", ret, 
aiocb->aio_offset);
+    else
+        blk_size_read += blk_sector_size;
+    free(aiocb->aio_buf);
+    free(req);
+}
+
+static void blk_read_sector(uint64_t sector)
+{
+    struct blk_req *req;
+
+    req = blk_alloc_req(sector);
+    req->aiocb.aio_cb = blk_read_completed;
+
+    blkfront_aio_read(&req->aiocb);
+}
+
+#ifdef BLKTEST_WRITE
+static void blk_write_read_completed(struct blkfront_aiocb *aiocb, int ret)
+{
+    struct blk_req *req = aiocb->data;
+    int rand_value;
+    int i;
+    int *buf;
+
+    if (ret) {
+        printk("got error code %d when reading back at offset %ld\n", ret, 
aiocb->aio_offset);
+        free(aiocb->aio_buf);
+        free(req);
+        return;
+    }
+    blk_size_read += blk_sector_size;
+    buf = (int*) aiocb->aio_buf;
+    rand_value = req->rand_value;
+    for (i = 0; i < blk_sector_size / sizeof(int); i++) {
+        if (buf[i] != rand_value) {
+            printk("bogus data at offset %ld\n", aiocb->aio_offset + i);
+            break;
+        }
+        rand_value *= RAND_MIX;
+    }
+    free(aiocb->aio_buf);
+    free(req);
+}
+
+static void blk_write_completed(struct blkfront_aiocb *aiocb, int ret)
+{
+    struct blk_req *req = aiocb->data;
+    if (ret) {
+        printk("got error code %d when writing at offset %ld\n", ret, 
aiocb->aio_offset);
+        free(aiocb->aio_buf);
+        free(req);
+        return;
+    }
+    blk_size_write += blk_sector_size;
+    /* Push write check */
+    req->next = blk_to_read;
+    blk_to_read = req;
+}
+
+static void blk_write_sector(uint64_t sector)
+{
+    struct blk_req *req;
+    int rand_value;
+    int i;
+    int *buf;
+
+    req = blk_alloc_req(sector);
+    req->aiocb.aio_cb = blk_write_completed;
+    req->rand_value = rand_value = rand();
+
+    buf = (int*) req->aiocb.aio_buf;
+    for (i = 0; i < blk_sector_size / sizeof(int); i++) {
+        buf[i] = rand_value;
+        rand_value *= RAND_MIX;
+    }
+
+    blkfront_aio_write(&req->aiocb);
+}
+#endif
+
+static void blkfront_thread(void *p)
+{
+    time_t lasttime = 0;
+    blk_dev = init_blkfront(NULL, &blk_sectors, &blk_sector_size, &blk_mode);
+    if (!blk_dev)
+        return;
+
+#ifdef BLKTEST_WRITE
+    if (blk_mode == O_RDWR) {
+        blk_write_sector(0);
+        blk_write_sector(blk_sectors-1);
+    } else
+#endif
+    {
+        blk_read_sector(0);
+        blk_read_sector(blk_sectors-1);
+    }
+
+    while (1) {
+        uint64_t sector = rand() % blk_sectors;
+        struct timeval tv;
+#ifdef BLKTEST_WRITE
+        if (blk_mode == O_RDWR)
+            blk_write_sector(sector);
+        else
+#endif
+            blk_read_sector(sector);
+        blkfront_aio_poll(blk_dev);
+        gettimeofday(&tv, NULL);
+        if (tv.tv_sec > lasttime + 10) {
+            printk("%llu read, %llu write\n", blk_size_read, blk_size_write);
+            lasttime = tv.tv_sec;
+        }
+
+#ifdef BLKTEST_WRITE
+        while (blk_to_read) {
+            struct blk_req *req = blk_to_read;
+            blk_to_read = blk_to_read->next;
+            req->aiocb.aio_cb = blk_write_read_completed;
+            blkfront_aio_read(&req->aiocb);
+        }
+#endif
+    }
 }
 
 static void fs_thread(void *p)
@@ -98,6 +260,7 @@ __attribute__((weak)) int app_main(start
     create_thread("xenbus_tester", xenbus_tester, si);
     create_thread("periodic_thread", periodic_thread, si);
     create_thread("netfront", netfront_thread, si);
+    create_thread("blkfront", blkfront_thread, si);
     create_thread("fs-frontend", fs_thread, si);
     return 0;
 }
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/lib/math.c
--- a/extras/mini-os/lib/math.c Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/lib/math.c Tue Jan 22 08:30:40 2008 -0700
@@ -56,6 +56,8 @@
 */
 
 #include <types.h>
+#include <lib.h>
+#include <time.h>
 
        /* On ia64 these functions lead to crashes. These are replaced by
         * assembler functions. */
@@ -85,7 +87,9 @@ union uu {
  * These are used for shifting, and also below for halfword extraction
  * and assembly.
  */
+#ifndef HAVE_LIBC
 #define CHAR_BIT        8               /* number of bits in a char */
+#endif
 #define QUAD_BITS       (sizeof(s64) * CHAR_BIT)
 #define LONG_BITS       (sizeof(long) * CHAR_BIT)
 #define HALF_BITS       (sizeof(long) * CHAR_BIT / 2)
@@ -385,3 +389,16 @@ __umoddi3(u_quad_t a, u_quad_t b)
 }
 
 #endif /* !defined(__ia64__) */
+
+#ifndef HAVE_LIBC
+/* Should be random enough for our uses */
+int rand(void)
+{
+    static unsigned int previous;
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    previous += tv.tv_sec + tv.tv_usec;
+    previous *= RAND_MIX;
+    return previous;
+}
+#endif
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/lib/xmalloc.c
--- a/extras/mini-os/lib/xmalloc.c      Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/lib/xmalloc.c      Tue Jan 22 08:30:40 2008 -0700
@@ -5,9 +5,11 @@
  *
  *        File: xmaloc.c
  *      Author: Grzegorz Milos (gm281@xxxxxxxxx)
+ *              Samuel Thibault (samuel.thibault@xxxxxxxxxxxxx)
  *     Changes: 
  *              
  *        Date: Aug 2005
+ *              Jan 2008
  * 
  * Environment: Xen Minimal OS
  * Description: simple memory allocator
@@ -39,22 +41,26 @@
 #include <types.h>
 #include <lib.h>
 #include <list.h>
-
+#include <xmalloc.h>
+
+#ifndef HAVE_LIBC
 static LIST_HEAD(freelist);
 /* static spinlock_t freelist_lock = SPIN_LOCK_UNLOCKED; */
 
 struct xmalloc_hdr
 {
-    /* Total including this hdr. */
+    /* Total including this hdr, unused padding and second hdr. */
     size_t size;
     struct list_head freelist;
-#if defined(__ia64__)
-               // Needed for ia64 as long as the align parameter in _xmalloc()
-               // is not supported.
-    uint64_t pad;
-#endif
-
 } __cacheline_aligned;
+
+/* Unused padding data between the two hdrs. */
+
+struct xmalloc_pad
+{
+    /* Size including both hdrs. */
+    size_t hdr_size;
+};
 
 static void maybe_split(struct xmalloc_hdr *hdr, size_t size, size_t block)
 {
@@ -62,11 +68,13 @@ static void maybe_split(struct xmalloc_h
     size_t leftover = block - size;
 
     /* If enough is left to make a block, put it on free list. */
-    if ( leftover >= (2 * sizeof(struct xmalloc_hdr)) )
+    if ( leftover >= (2 * (sizeof(struct xmalloc_hdr) + sizeof(struct 
xmalloc_pad))) )
     {
         extra = (struct xmalloc_hdr *)((unsigned long)hdr + size);
         extra->size = leftover;
+        /* spin_lock_irqsave(&freelist_lock, flags); */
         list_add(&extra->freelist, &freelist);
+        /* spin_unlock_irqrestore(&freelist_lock, flags); */
     }
     else
     {
@@ -78,7 +86,7 @@ static void maybe_split(struct xmalloc_h
     hdr->freelist.next = hdr->freelist.prev = NULL;
 }
 
-static void *xmalloc_new_page(size_t size)
+static struct xmalloc_hdr *xmalloc_new_page(size_t size)
 {
     struct xmalloc_hdr *hdr;
     /* unsigned long flags; */
@@ -87,18 +95,30 @@ static void *xmalloc_new_page(size_t siz
     if ( hdr == NULL )
         return NULL;
 
-    /* spin_lock_irqsave(&freelist_lock, flags); */
     maybe_split(hdr, size, PAGE_SIZE);
-    /* spin_unlock_irqrestore(&freelist_lock, flags); */
-
-    return hdr+1;
+
+    return hdr;
+}
+
+/* Return size, increased to alignment with align. */
+static inline size_t align_up(size_t size, size_t align)
+{
+    return (size + align - 1) & ~(align - 1);
 }
 
 /* Big object?  Just use the page allocator. */
-static void *xmalloc_whole_pages(size_t size)
-{
-    struct xmalloc_hdr *hdr;
-    unsigned int pageorder = get_order(size);
+static void *xmalloc_whole_pages(size_t size, size_t align)
+{
+    struct xmalloc_hdr *hdr;
+    struct xmalloc_pad *pad;
+    unsigned int pageorder;
+    void *ret;
+    /* Room for headers */
+    size_t hdr_size = sizeof(struct xmalloc_hdr) + sizeof(struct xmalloc_pad);
+    /* Align for actual beginning of data */
+    hdr_size = align_up(hdr_size, align);
+
+    pageorder = get_order(hdr_size + size);
 
     hdr = (struct xmalloc_hdr *)alloc_pages(pageorder);
     if ( hdr == NULL )
@@ -108,54 +128,82 @@ static void *xmalloc_whole_pages(size_t 
     /* Debugging aid. */
     hdr->freelist.next = hdr->freelist.prev = NULL;
 
-    return hdr+1;
-}
-
-/* Return size, increased to alignment with align. */
-static inline size_t align_up(size_t size, size_t align)
-{
-    return (size + align - 1) & ~(align - 1);
+    ret = (char*)hdr + hdr_size;
+    pad = (struct xmalloc_pad *) ret - 1;
+    pad->hdr_size = hdr_size;
+    return ret;
 }
 
 void *_xmalloc(size_t size, size_t align)
 {
-    struct xmalloc_hdr *i;
-    /* unsigned long flags; */
-
-    /* Add room for header, pad to align next header. */
-    size += sizeof(struct xmalloc_hdr);
-    size = align_up(size, __alignof__(struct xmalloc_hdr));
+    struct xmalloc_hdr *i, *hdr = NULL;
+    uintptr_t data_begin;
+    size_t hdr_size;
+    /* unsigned long flags; */
+
+    hdr_size = sizeof(struct xmalloc_hdr) + sizeof(struct xmalloc_pad);
+    /* Align on headers requirements. */
+    align = align_up(align, __alignof__(struct xmalloc_hdr));
+    align = align_up(align, __alignof__(struct xmalloc_pad));
 
     /* For big allocs, give them whole pages. */
-    if ( size >= PAGE_SIZE )
-        return xmalloc_whole_pages(size);
+    if ( size + align_up(hdr_size, align) >= PAGE_SIZE )
+        return xmalloc_whole_pages(size, align);
 
     /* Search free list. */
     /* spin_lock_irqsave(&freelist_lock, flags); */
     list_for_each_entry( i, &freelist, freelist )
     {
-        if ( i->size < size )
+        data_begin = align_up((uintptr_t)i + hdr_size, align);
+
+        if ( data_begin + size > (uintptr_t)i + i->size )
             continue;
+
         list_del(&i->freelist);
-        maybe_split(i, size, i->size);
-        /* spin_unlock_irqrestore(&freelist_lock, flags); */
-        return i+1;
-    }
-    /* spin_unlock_irqrestore(&freelist_lock, flags); */
-
-    /* Alloc a new page and return from that. */
-    return xmalloc_new_page(size);
+        /* spin_unlock_irqrestore(&freelist_lock, flags); */
+
+        uintptr_t size_before = (data_begin - hdr_size) - (uintptr_t)i;
+
+        if (size_before >= 2 * hdr_size) {
+            /* Worth splitting the beginning */
+            struct xmalloc_hdr *new_i = (void*)(data_begin - hdr_size);
+            new_i->size = i->size - size_before;
+            i->size = size_before;
+            /* spin_lock_irqsave(&freelist_lock, flags); */
+            list_add(&i->freelist, &freelist);
+            /* spin_unlock_irqrestore(&freelist_lock, flags); */
+            i = new_i;
+        }
+        maybe_split(i, (data_begin + size) - (uintptr_t)i, i->size);
+        hdr = i;
+        break;
+    }
+
+    if (!hdr) {
+        /* spin_unlock_irqrestore(&freelist_lock, flags); */
+
+        /* Alloc a new page and return from that. */
+        hdr = xmalloc_new_page(align_up(hdr_size, align) + size);
+        data_begin = (uintptr_t)hdr + align_up(hdr_size, align);
+    }
+
+    struct xmalloc_pad *pad = (struct xmalloc_pad *) data_begin - 1;
+    pad->hdr_size = data_begin - (uintptr_t)hdr;
+    BUG_ON(data_begin % align);
+    return (void*)data_begin;
 }
 
 void xfree(const void *p)
 {
     /* unsigned long flags; */
     struct xmalloc_hdr *i, *tmp, *hdr;
+    struct xmalloc_pad *pad;
 
     if ( p == NULL )
         return;
 
-    hdr = (struct xmalloc_hdr *)p - 1;
+    pad = (struct xmalloc_pad *)p - 1;
+    hdr = (struct xmalloc_hdr *)((char *)p - pad->hdr_size);
 
     /* We know hdr will be on same page. */
     if(((long)p & PAGE_MASK) != ((long)hdr & PAGE_MASK))
@@ -227,15 +275,19 @@ void *_realloc(void *ptr, size_t size)
 {
     void *new;
     struct xmalloc_hdr *hdr;
+    struct xmalloc_pad *pad;
 
     if (ptr == NULL)
-        return _xmalloc(size, 4);
-
-    hdr = (struct xmalloc_hdr *)ptr - 1;
-    if (hdr->size >= size) 
+        return _xmalloc(size, DEFAULT_ALIGN);
+
+    pad = (struct xmalloc_pad *)ptr - 1;
+    hdr = (struct xmalloc_hdr *)((char*)ptr - pad->hdr_size);
+    if (hdr->size >= size) {
+        maybe_split(hdr, size, hdr->size);
         return ptr;
+    }
     
-    new = _xmalloc(size, 4);
+    new = _xmalloc(size, DEFAULT_ALIGN);
     if (new == NULL) 
         return NULL;
 
@@ -244,3 +296,4 @@ void *_realloc(void *ptr, size_t size)
 
     return new;
 }
+#endif
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/lwip-arch.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/lwip-arch.c        Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,293 @@
+/* 
+ * lwip-arch.c
+ *
+ * Arch-specific semaphores and mailboxes for lwIP running on mini-os 
+ *
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ */
+
+#include <os.h>
+#include <time.h>
+#include <console.h>
+#include <xmalloc.h>
+#include <lwip/sys.h>
+#include <stdarg.h>
+
+/* Is called to initialize the sys_arch layer */
+void sys_init(void)
+{
+}
+
+/* Creates and returns a new semaphore. The "count" argument specifies
+ * the initial state of the semaphore. */
+sys_sem_t sys_sem_new(u8_t count)
+{
+    struct semaphore *sem = xmalloc(struct semaphore);
+    sem->count = count;
+    init_waitqueue_head(&sem->wait);
+    return sem;
+}
+
+/* Deallocates a semaphore. */
+void sys_sem_free(sys_sem_t sem)
+{
+    xfree(sem);
+}
+
+/* Signals a semaphore. */
+void sys_sem_signal(sys_sem_t sem)
+{
+    up(sem);
+}
+
+/* Blocks the thread while waiting for the semaphore to be
+ * signaled. If the "timeout" argument is non-zero, the thread should
+ * only be blocked for the specified time (measured in
+ * milliseconds).
+ * 
+ * If the timeout argument is non-zero, the return value is the number of
+ * milliseconds spent waiting for the semaphore to be signaled. If the
+ * semaphore wasn't signaled within the specified time, the return value is
+ * SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
+ * (i.e., it was already signaled), the function may return zero. */
+u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
+{
+    /* Slightly more complicated than the normal minios semaphore:
+     * need to wake on timeout *or* signal */
+    sys_prot_t prot;
+    s64_t then = NOW();
+    s64_t deadline;
+
+    if (timeout == 0)
+       deadline = 0;
+    else
+       deadline = then + MILLISECS(timeout);
+
+    while(1) {
+        wait_event_deadline(sem->wait, (sem->count > 0), deadline);
+
+        prot = sys_arch_protect();
+       /* Atomically check that we can proceed */
+       if (sem->count > 0 || (deadline && NOW() >= deadline))
+           break;
+        sys_arch_unprotect(prot);
+    }
+
+    if (sem->count > 0) {
+        sem->count--;
+        sys_arch_unprotect(prot);
+        return NSEC_TO_MSEC(NOW() - then); 
+    }
+    
+    sys_arch_unprotect(prot);
+    return SYS_ARCH_TIMEOUT;
+}
+
+/* Creates an empty mailbox. */
+sys_mbox_t sys_mbox_new(int size)
+{
+    struct mbox *mbox = xmalloc(struct mbox);
+    if (!size)
+        size = 32;
+    else if (size == 1)
+        size = 2;
+    mbox->count = size;
+    mbox->messages = xmalloc_array(void*, size);
+    init_SEMAPHORE(&mbox->read_sem, 0);
+    mbox->reader = 0;
+    init_SEMAPHORE(&mbox->write_sem, size);
+    mbox->writer = 0;
+    return mbox;
+}
+
+/* Deallocates a mailbox. If there are messages still present in the
+ * mailbox when the mailbox is deallocated, it is an indication of a
+ * programming error in lwIP and the developer should be notified. */
+void sys_mbox_free(sys_mbox_t mbox)
+{
+    ASSERT(mbox->reader == mbox->writer);
+    xfree(mbox->messages);
+    xfree(mbox);
+}
+
+/* Posts the "msg" to the mailbox, internal version that actually does the
+ * post. */
+static void do_mbox_post(sys_mbox_t mbox, void *msg)
+{
+    /* The caller got a semaphore token, so we are now allowed to increment
+     * writer, but we still need to prevent concurrency between writers
+     * (interrupt handler vs main) */
+    sys_prot_t prot = sys_arch_protect();
+    mbox->messages[mbox->writer] = msg;
+    mbox->writer = (mbox->writer + 1) % mbox->count;
+    ASSERT(mbox->reader != mbox->writer);
+    sys_arch_unprotect(prot);
+    up(&mbox->read_sem);
+}
+
+/* Posts the "msg" to the mailbox. */
+void sys_mbox_post(sys_mbox_t mbox, void *msg)
+{
+    if (mbox == SYS_MBOX_NULL)
+        return;
+    down(&mbox->write_sem);
+    do_mbox_post(mbox, msg);
+}
+
+/* Try to post the "msg" to the mailbox. */
+err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg)
+{
+    if (mbox == SYS_MBOX_NULL)
+        return ERR_BUF;
+    if (!trydown(&mbox->write_sem))
+        return ERR_MEM;
+    do_mbox_post(mbox, msg);
+    return ERR_OK;
+}
+
+/*
+ * Fetch a message from a mailbox. Internal version that actually does the
+ * fetch.
+ */
+static void do_mbox_fetch(sys_mbox_t mbox, void **msg)
+{
+    sys_prot_t prot;
+    /* The caller got a semaphore token, so we are now allowed to increment
+     * reader, but we may still need to prevent concurrency between readers.
+     * FIXME: can there be concurrent readers? */
+    prot = sys_arch_protect();
+    ASSERT(mbox->reader != mbox->writer);
+    if (msg != NULL)
+        *msg = mbox->messages[mbox->reader];
+    mbox->reader = (mbox->reader + 1) % mbox->count;
+    sys_arch_unprotect(prot);
+    up(&mbox->write_sem);
+}
+
+/* Blocks the thread until a message arrives in the mailbox, but does
+ * not block the thread longer than "timeout" milliseconds (similar to
+ * the sys_arch_sem_wait() function). The "msg" argument is a result
+ * parameter that is set by the function (i.e., by doing "*msg =
+ * ptr"). The "msg" parameter maybe NULL to indicate that the message
+ * should be dropped.
+ *
+ * The return values are the same as for the sys_arch_sem_wait() function:
+ * Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
+ * timeout. */
+u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
+{
+    u32 rv;
+    if (mbox == SYS_MBOX_NULL)
+        return SYS_ARCH_TIMEOUT;
+
+    rv = sys_arch_sem_wait(&mbox->read_sem, timeout);
+    if ( rv == SYS_ARCH_TIMEOUT )
+        return rv;
+
+    do_mbox_fetch(mbox, msg);
+    return 0;
+}
+
+/* This is similar to sys_arch_mbox_fetch, however if a message is not
+ * present in the mailbox, it immediately returns with the code
+ * SYS_MBOX_EMPTY. On success 0 is returned.
+ *
+ * To allow for efficient implementations, this can be defined as a
+ * function-like macro in sys_arch.h instead of a normal function. For
+ * example, a naive implementation could be:
+ *   #define sys_arch_mbox_tryfetch(mbox,msg) \
+ *     sys_arch_mbox_fetch(mbox,msg,1)
+ * although this would introduce unnecessary delays. */
+
+u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg) {
+    if (mbox == SYS_MBOX_NULL)
+        return SYS_ARCH_TIMEOUT;
+
+    if (!trydown(&mbox->read_sem))
+       return SYS_MBOX_EMPTY;
+
+    do_mbox_fetch(mbox, msg);
+    return 0;
+}
+
+
+/* Returns a pointer to the per-thread sys_timeouts structure. In lwIP,
+ * each thread has a list of timeouts which is repressented as a linked
+ * list of sys_timeout structures. The sys_timeouts structure holds a
+ * pointer to a linked list of timeouts. This function is called by
+ * the lwIP timeout scheduler and must not return a NULL value. 
+ *
+ * In a single threadd sys_arch implementation, this function will
+ * simply return a pointer to a global sys_timeouts variable stored in
+ * the sys_arch module. */
+struct sys_timeouts *sys_arch_timeouts(void) 
+{
+    static struct sys_timeouts timeout;
+    return &timeout;
+}
+
+
+/* Starts a new thread with priority "prio" that will begin its execution in 
the
+ * function "thread()". The "arg" argument will be passed as an argument to the
+ * thread() function. The id of the new thread is returned. Both the id and
+ * the priority are system dependent. */
+static struct thread *lwip_thread;
+sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, 
int stacksize, int prio)
+{
+    struct thread *t;
+    if (stacksize > STACK_SIZE) {
+       printk("Can't start lwIP thread: stack size %d is too large for our 
%d\n", stacksize, STACK_SIZE);
+       do_exit();
+    }
+    lwip_thread = t = create_thread(name, thread, arg);
+    return t;
+}
+
+/* This optional function does a "fast" critical region protection and returns
+ * the previous protection level. This function is only called during very 
short
+ * critical regions. An embedded system which supports ISR-based drivers might
+ * want to implement this function by disabling interrupts. Task-based systems
+ * might want to implement this by using a mutex or disabling tasking. This
+ * function should support recursive calls from the same task or interrupt. In
+ * other words, sys_arch_protect() could be called while already protected. In
+ * that case the return value indicates that it is already protected.
+ *
+ * sys_arch_protect() is only required if your port is supporting an operating
+ * system. */
+sys_prot_t sys_arch_protect(void)
+{
+    unsigned long flags;
+    local_irq_save(flags);
+    return flags;
+}
+
+/* This optional function does a "fast" set of critical region protection to 
the
+ * value specified by pval. See the documentation for sys_arch_protect() for
+ * more information. This function is only required if your port is supporting
+ * an operating system. */
+void sys_arch_unprotect(sys_prot_t pval)
+{
+    local_irq_restore(pval);
+}
+
+/* non-fatal, print a message. */
+void lwip_printk(char *fmt, ...)
+{
+    va_list args;
+    va_start(args, fmt);
+    printk("lwIP: ");
+    print(0, fmt, args);
+    va_end(args);
+}
+
+/* fatal, print message and abandon execution. */
+void lwip_die(char *fmt, ...)
+{
+    va_list args;
+    va_start(args, fmt);
+    printk("lwIP assertion failed: ");
+    print(0, fmt, args);
+    va_end(args);
+    printk("\n");
+    BUG();
+}
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/lwip-net.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/lwip-net.c Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,360 @@
+/* 
+ * lwip-net.c
+ *
+ * interface between lwIP's ethernet and Mini-os's netfront.
+ * For now, support only one network interface, as mini-os does.
+ *
+ * Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, July 2007
+ * based on lwIP's ethernetif.c skeleton file, copyrights as below.
+ */
+
+
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without 
modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@xxxxxxx>
+ *
+ */
+
+#include <os.h>
+
+#include "lwip/opt.h"
+#include "lwip/def.h"
+#include "lwip/mem.h"
+#include "lwip/pbuf.h"
+#include "lwip/sys.h"
+
+#include <lwip/stats.h>
+#include <lwip/sys.h>
+#include <lwip/mem.h>
+#include <lwip/memp.h>
+#include <lwip/pbuf.h>
+#include <netif/etharp.h>
+#include <lwip/tcpip.h>
+#include <lwip/tcp.h>
+#include <lwip/netif.h>
+#include <lwip/dhcp.h>
+
+#include "netif/etharp.h"
+
+#include <netfront.h>
+
+/* Define those to better describe your network interface. */
+#define IFNAME0 'e'
+#define IFNAME1 'n'
+
+#define IF_IPADDR      0x00000000
+#define IF_NETMASK     0x00000000
+
+/* Only have one network interface at a time. */
+static struct netif *the_interface = NULL;
+
+static unsigned char rawmac[6];
+static struct netfront_dev *dev;
+
+/* Forward declarations. */
+static err_t netfront_output(struct netif *netif, struct pbuf *p,
+             struct ip_addr *ipaddr);
+
+/*
+ * low_level_output():
+ *
+ * Should do the actual transmission of the packet. The packet is
+ * contained in the pbuf that is passed to the function. This pbuf
+ * might be chained.
+ *
+ */
+
+static err_t
+low_level_output(struct netif *netif, struct pbuf *p)
+{
+#ifdef ETH_PAD_SIZE
+  pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
+#endif
+
+  /* Send the data from the pbuf to the interface, one pbuf at a
+     time. The size of the data in each pbuf is kept in the ->len
+     variable. */
+  if (!p->next) {
+    /* Only one fragment, can send it directly */
+      netfront_xmit(dev, p->payload, p->len);
+  } else {
+    unsigned char data[p->tot_len], *cur;
+    struct pbuf *q;
+
+    for(q = p, cur = data; q != NULL; cur += q->len, q = q->next)
+      memcpy(cur, q->payload, q->len);
+    netfront_xmit(dev, data, p->tot_len);
+  }
+
+#if ETH_PAD_SIZE
+  pbuf_header(p, ETH_PAD_SIZE);                        /* reclaim the padding 
word */
+#endif
+  
+  LINK_STATS_INC(link.xmit);
+
+  return ERR_OK;
+}
+
+
+
+/*
+ * netfront_output():
+ *
+ * This function is called by the TCP/IP stack when an IP packet
+ * should be sent. It calls the function called low_level_output() to
+ * do the actual transmission of the packet.
+ *
+ */
+
+static err_t
+netfront_output(struct netif *netif, struct pbuf *p,
+      struct ip_addr *ipaddr)
+{
+  
+ /* resolve hardware address, then send (or queue) packet */
+  return etharp_output(netif, p, ipaddr);
+ 
+}
+
+/*
+ * netfront_input():
+ *
+ * This function should be called when a packet is ready to be read
+ * from the interface. 
+ *
+ */
+
+static void
+netfront_input(struct netif *netif, unsigned char* data, int len)
+{
+  struct eth_hdr *ethhdr;
+  struct pbuf *p, *q;
+
+#if ETH_PAD_SIZE
+  len += ETH_PAD_SIZE; /* allow room for Ethernet padding */
+#endif
+  
+  /* move received packet into a new pbuf */
+  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+  if (p == NULL) {
+    LINK_STATS_INC(link.memerr);
+    LINK_STATS_INC(link.drop);
+    return;
+  }
+
+#if ETH_PAD_SIZE
+  pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
+#endif
+  
+  /* We iterate over the pbuf chain until we have read the entire
+   * packet into the pbuf. */
+  for(q = p; q != NULL && len > 0; q = q->next) {
+    /* Read enough bytes to fill this pbuf in the chain. The
+     * available data in the pbuf is given by the q->len
+     * variable. */
+    memcpy(q->payload, data, len < q->len ? len : q->len);
+    data += q->len;
+    len -= q->len;
+  }
+
+#if ETH_PAD_SIZE
+  pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
+#endif
+
+  LINK_STATS_INC(link.recv);
+
+  /* points to packet payload, which starts with an Ethernet header */
+  ethhdr = p->payload;
+
+  ethhdr = p->payload;
+    
+  switch (htons(ethhdr->type)) {
+  /* IP packet? */
+  case ETHTYPE_IP:
+#if 0
+/* CSi disabled ARP table update on ingress IP packets.
+   This seems to work but needs thorough testing. */
+    /* update ARP table */
+    etharp_ip_input(netif, p);
+#endif
+    /* skip Ethernet header */
+    pbuf_header(p, -(s16)sizeof(struct eth_hdr));
+    /* pass to network layer */
+    tcpip_input(p, netif);
+    break;
+      
+  case ETHTYPE_ARP:
+    /* pass p to ARP module  */
+    etharp_arp_input(netif, (struct eth_addr *) netif->hwaddr, p);
+    break;
+  default:
+    pbuf_free(p);
+    p = NULL;
+    break;
+  }
+}
+
+
+/* 
+ * netif_rx(): overrides the default netif_rx behaviour in the netfront driver.
+ * 
+ * Pull received packets into a pbuf queue for the low_level_input() 
+ * function to pass up to lwIP.
+ */
+
+void netif_rx(unsigned char* data, int len)
+{
+  if (the_interface != NULL) {
+    netfront_input(the_interface, data, len);
+    wake_up(&netfront_queue);
+  }
+  /* By returning, we ack the packet and relinquish the RX ring slot */
+}
+
+/*
+ * Set the IP, mask and gateway of the IF
+ */
+void networking_set_addr(struct ip_addr *ipaddr, struct ip_addr *netmask, 
struct ip_addr *gw)
+{
+  netif_set_ipaddr(the_interface, ipaddr);
+  netif_set_netmask(the_interface, netmask);
+  netif_set_gw(the_interface, gw);
+}
+
+
+static void
+arp_timer(void *arg)
+{
+  etharp_tmr();
+  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
+}
+
+/*
+ * netif_netfront_init():
+ *
+ * Should be called at the beginning of the program to set up the
+ * network interface. It calls the function low_level_init() to do the
+ * actual setup of the hardware.
+ *
+ */
+
+err_t
+netif_netfront_init(struct netif *netif)
+{
+  unsigned char *mac = netif->state;
+
+#if LWIP_SNMP
+  /* ifType ethernetCsmacd(6) @see RFC1213 */
+  netif->link_type = 6;
+  /* your link speed here */
+  netif->link_speed = ;
+  netif->ts = 0;
+  netif->ifinoctets = 0;
+  netif->ifinucastpkts = 0;
+  netif->ifinnucastpkts = 0;
+  netif->ifindiscards = 0;
+  netif->ifoutoctets = 0;
+  netif->ifoutucastpkts = 0;
+  netif->ifoutnucastpkts = 0;
+  netif->ifoutdiscards = 0;
+#endif
+  
+  netif->name[0] = IFNAME0;
+  netif->name[1] = IFNAME1;
+  netif->output = netfront_output;
+  netif->linkoutput = low_level_output;
+  
+  the_interface = netif;
+  
+  /* set MAC hardware address */
+  netif->hwaddr_len = 6;
+  netif->hwaddr[0] = mac[0];
+  netif->hwaddr[1] = mac[1];
+  netif->hwaddr[2] = mac[2];
+  netif->hwaddr[3] = mac[3];
+  netif->hwaddr[4] = mac[4];
+  netif->hwaddr[5] = mac[5];
+
+  /* No interesting per-interface state */
+  netif->state = NULL;
+
+  /* maximum transfer unit */
+  netif->mtu = 1500;
+  
+  /* broadcast capability */
+  netif->flags = NETIF_FLAG_BROADCAST;
+
+  etharp_init();
+
+  sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
+
+  return ERR_OK;
+}
+
+/*
+ * Thread run by netfront: bring up the IP address and fire lwIP timers.
+ */
+static __DECLARE_SEMAPHORE_GENERIC(tcpip_is_up, 0);
+static void tcpip_bringup_finished(void *p)
+{
+  tprintk("TCP/IP bringup ends.\n");
+  up(&tcpip_is_up);
+}
+
+/* 
+ * Utility function to bring the whole lot up.  Call this from app_main() 
+ * or similar -- it starts netfront and have lwIP start its thread,
+ * which calls back to tcpip_bringup_finished(), which 
+ * lets us know it's OK to continue.
+ */
+void start_networking(void)
+{
+  struct netif *netif;
+  struct ip_addr ipaddr = { htonl(IF_IPADDR) };
+  struct ip_addr netmask = { htonl(IF_NETMASK) };
+  struct ip_addr gw = { 0 };
+
+  tprintk("Waiting for network.\n");
+
+  dev = init_netfront(NULL, NULL, rawmac);
+  
+  tprintk("TCP/IP bringup begins.\n");
+  
+  netif = xmalloc(struct netif);
+  tcpip_init(tcpip_bringup_finished, netif);
+    
+  netif_add(netif, &ipaddr, &netmask, &gw, rawmac, 
+            netif_netfront_init, ip_input);
+  netif_set_default(netif);
+  netif_set_up(netif);
+
+  down(&tcpip_is_up);
+
+  tprintk("Network is ready.\n");
+}
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/minios.mk
--- a/extras/mini-os/minios.mk  Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/minios.mk  Tue Jan 22 08:30:40 2008 -0700
@@ -6,7 +6,7 @@ debug = y
 
 # Define some default flags.
 # NB. '-Wcast-qual' is nasty, so I omitted it.
-DEF_CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
+DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
 DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
 DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
 DEF_CFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
diff -r 29268e3fc7ab -r 603ea719d73a extras/mini-os/sched.c
--- a/extras/mini-os/sched.c    Tue Jan 22 08:27:29 2008 -0700
+++ b/extras/mini-os/sched.c    Tue Jan 22 08:30:40 2008 -0700
@@ -211,7 +211,7 @@ void block(struct thread *thread)
     clear_runnable(thread);
 }
 
-void sleep(u32 millisecs)
+void msleep(u32 millisecs)
 {
     struct thread *thread = get_current();
     thread->wakeup_time = NOW()  + MILLISECS(millisecs);
@@ -270,10 +270,10 @@ void th_f1(void *data)
         up(&mutex);
         
         
-        gettimeofday(&tv1);
+        gettimeofday(&tv1, NULL);
         for(;;)
         {
-            gettimeofday(&tv2);
+            gettimeofday(&tv2, NULL);
             if(tv2.tv_sec - tv1.tv_sec > 2) break;
         }
                 
diff -r 29268e3fc7ab -r 603ea719d73a tools/Makefile
--- a/tools/Makefile    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/Makefile    Tue Jan 22 08:30:40 2008 -0700
@@ -26,6 +26,12 @@ ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_A
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
 SUBDIRS-$(PYTHON_TOOLS) += python
 SUBDIRS-$(PYTHON_TOOLS) += pygrub
+endif
+
+# For the sake of linking, set the sys-root
+ifneq ($(CROSS_COMPILE),)
+CROSS_SYS_ROOT ?= /usr/$(CROSS_COMPILE:-=)/sys-root
+export CROSS_SYS_ROOT
 endif
 
 .PHONY: all
@@ -65,10 +71,15 @@ check_clean:
 
 .PHONY: ioemu ioemuinstall ioemuclean
 ifeq ($(CONFIG_IOEMU),y)
-export IOEMU_DIR ?= ioemu
+IOEMU_DIR ?= ioemu
+ifneq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
+IOEMU_CONFIGURE_CROSS ?= --cross-prefix=$(CROSS_COMPILE) \
+                        --interp-prefix=$(CROSS_SYS_ROOT)
+endif
 ioemu ioemuinstall:
        [ -f $(IOEMU_DIR)/config-host.mak ] || \
-         (cd $(IOEMU_DIR) && sh configure --prefix=/usr)
+         ( cd $(IOEMU_DIR) && XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure 
--prefix=/usr \
+               $(IOEMU_CONFIGURE_CROSS) )
        $(MAKE) -C $(IOEMU_DIR) $(patsubst ioemu%,%,$@)
 ioemuclean:
        $(MAKE) -C $(IOEMU_DIR) distclean
diff -r 29268e3fc7ab -r 603ea719d73a tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/blktap/drivers/Makefile     Tue Jan 22 08:30:40 2008 -0700
@@ -5,7 +5,6 @@ INCLUDES += -I.. -I../lib
 
 IBIN         = blktapctrl tapdisk
 QCOW_UTIL    = img2qcow qcow2raw qcow-create
-INST_DIR     = /usr/sbin
 LIBAIO_DIR   = ../../libaio/src
 
 CFLAGS   += -Werror
@@ -53,7 +52,7 @@ img2qcow qcow2raw qcow-create: %: $(BLK-
        $(CC) $(CFLAGS) -o $* $(BLK-OBJS-y) $*.c $(LDFLAGS) $(AIOLIBS) $(LIBS)
 
 install: all
-       $(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(VHD_UTIL) $(DESTDIR)$(INST_DIR)
+       $(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(VHD_UTIL) $(DESTDIR)$(SBINDIR)
 
 clean:
        rm -rf *.o *~ $(DEPS) xen TAGS $(IBIN) $(LIB) $(QCOW_UTIL) $(VHD_UTIL)
diff -r 29268e3fc7ab -r 603ea719d73a tools/blktap/lib/Makefile
--- a/tools/blktap/lib/Makefile Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/blktap/lib/Makefile Tue Jan 22 08:30:40 2008 -0700
@@ -4,8 +4,6 @@ MAJOR    = 3.0
 MAJOR    = 3.0
 MINOR    = 0
 SONAME   = libblktap.so.$(MAJOR)
-
-BLKTAP_INSTALL_DIR = /usr/sbin
 
 INCLUDES += -I. -I.. -I $(XEN_LIBXC) -I $(XEN_XENSTORE)
 
@@ -40,12 +38,12 @@ libblktap: libblktap.a
 libblktap: libblktap.a
 
 install: all
-       $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_DIR) $(DESTDIR)/usr/include
-       $(INSTALL_DATA) $(LIB) $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libblktap.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libblktap.so.$(MAJOR)
-       ln -sf libblktap.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libblktap.so
-       $(INSTALL_DATA) blktaplib.h $(DESTDIR)/usr/include
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_DATA) $(LIB) $(DESTDIR)$(LIBDIR)
+       ln -sf libblktap.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libblktap.so.$(MAJOR)
+       ln -sf libblktap.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libblktap.so
+       $(INSTALL_DATA) blktaplib.h $(DESTDIR)$(INCLUDEDIR)
 
 clean:
        rm -rf *.a *.so* *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_brctl
--- a/tools/check/check_brctl   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_brctl   Tue Jan 22 08:30:40 2008 -0700
@@ -1,27 +1,13 @@
 #!/bin/sh
 # CHECK-INSTALL
 
-RC=0
+. funcs.sh
 
-case ${OS} in
+case $OS in
 OpenBSD|NetBSD|FreeBSD)
-       # These systems have a bridge builtin
-       TOOL="brconfig"
-       which ${TOOL} 1>/dev/null 2>&1 || RC=1 
-       ;;
+       has_or_fail brconfig ;;
 Linux)
-       TOOL="brctl"
-       which ${TOOL} 1>/dev/null 2>&1 || RC=1
-       ;;
+       has_or_fail brctl ;;
 *)
-       TOOL=""
-       echo "Unknown OS" && RC=1
-       ;;
+       fail "unknown OS" ;;
 esac
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for the bridge control utils (${TOOL}) FAILED"
-fi
-
-exit ${RC} 
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_crypto_lib
--- a/tools/check/check_crypto_lib      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_crypto_lib      Tue Jan 22 08:30:40 2008 -0700
@@ -1,23 +1,11 @@
 #!/bin/sh
 # CHECK-BUILD CHECK-INSTALL
 
-RC=0
+. funcs.sh
 
-case $(uname -s) in
+case $OS in
 FreeBSD|NetBSD|OpenBSD)
-       exit 0
-       ;;
-*)
-       ;;
+       exit 0 ;;
 esac
 
-PATH=/sbin:$PATH
-set -e
-ldconfig -p 2>&1 | grep -q libcrypto.so || RC=1
-
-if test ${RC} -ne 0; then
-        echo
-        echo " *** Check for crypto library FAILED"
-fi
-
-exit ${RC}
+has_lib libcrypto.so || fail "missing libcrypto.so"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_curl
--- a/tools/check/check_curl    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_curl    Tue Jan 22 08:30:40 2008 -0700
@@ -1,38 +1,13 @@
 #!/bin/sh
 # CHECK-BUILD CHECK-INSTALL
 
-if [ ! "$LIBXENAPI_BINDINGS" = "y" ]
-then
-    echo -n "unused, "
-    exit 0
+. funcs.sh
+
+if [ "$LIBXENAPI_BINDINGS" != "y" ]; then
+       echo -n "unused, "
+       exit 0
 fi
 
-RC=0
-
-CURL_CONFIG="$(which curl-config)"
-tmpfile=$(mktemp)
-
-if test -z ${CURL_CONFIG}; then
-    RC=1
-else
-    ${CURL_CONFIG} --libs 2>&1 > /dev/null
-    RC=$?
-fi
-
-if test $RC -ne 0; then
-    echo "FAILED"
-       echo " *** curl-config is missing. "
-    echo " *** Please install curl-devel."
-elif ! ld $($CURL_CONFIG --libs) -o $tmpfile >/dev/null 2>&1; then
-    echo "FAILED"
-    echo " *** dependency libraries for curl are missing: "
-    RC=1
-    for i in $(ld $($CURL_CONFIG --libs) -o $tmpfile 2>&1 >/dev/null); do
-        case $i in
-        -l*) echo lib${i#-l}
-        esac
-    done
-fi
-rm -f $tmpfile
-
-exit $RC
+has_or_fail curl-config
+curl_libs=`curl-config --libs` || fail "curl-config --libs failed"
+test_link $curl_libs || fail "dependency libraries for curl are missing"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_iproute
--- a/tools/check/check_iproute Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_iproute Tue Jan 22 08:30:40 2008 -0700
@@ -1,26 +1,15 @@
 #!/bin/sh
 # CHECK-INSTALL
 
-RC=0
+. funcs.sh
 
-case ${OS} in
+PATH=/sbin:$PATH
+
+case $OS in
 OpenBSD|NetBSD|FreeBSD)
-       TOOL="ifconfig"
-       eval ${TOOL} -a 1>/dev/null 2>&1 || RC=1 
-       ;;
+       has_or_fail ifconfig ;;
 Linux)
-       TOOL="ip addr"
-       eval ${TOOL} list 1>/dev/null 2>&1 || RC=1 
-       ;;
+       has_or_fail ip ;;
 *)
-       TOOL=""
-       echo "Unknown OS" && RC=1 
-       ;;
+       fail "unknown OS" ;;
 esac
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for iproute (${TOOL}) FAILED"
-fi
-
-exit ${RC} 
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_openssl_devel
--- a/tools/check/check_openssl_devel   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_openssl_devel   Tue Jan 22 08:30:40 2008 -0700
@@ -1,14 +1,6 @@
 #!/bin/sh
 # CHECK-BUILD
 
-RC=0
+. funcs.sh
 
-set -e
-test -r /usr/include/openssl/md5.h || RC=1 
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for openssl headers FAILED"
-fi
-
-exit ${RC}
+has_header openssl/md5.h || fail "missing openssl headers"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_python
--- a/tools/check/check_python  Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_python  Tue Jan 22 08:30:40 2008 -0700
@@ -1,16 +1,9 @@
 #!/bin/sh
 # CHECK-BUILD CHECK-INSTALL
 
-RC=0
+. funcs.sh
 
 python -c '
 import sys
 sys.exit(sys.version_info[0] < 2 or sys.version_info[1] < 2)
-' || RC=1
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for Python version >= 2.2 FAILED"
-fi
-
-exit ${RC} 
+' || fail "need python version >= 2.2"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_python_devel
--- a/tools/check/check_python_devel    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_python_devel    Tue Jan 22 08:30:40 2008 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 # CHECK-BUILD
 
-RC=0
+. funcs.sh
 
 python -c '
 import os.path, sys
@@ -9,11 +9,4 @@ for p in sys.path:
        if os.path.exists(p + "/config/Makefile"):
                sys.exit(0)
 sys.exit(1)
-' || RC=1 
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for python development environment FAILED"
-fi
-
-exit ${RC}
+' || fail "can't find python devel files"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_python_xml
--- a/tools/check/check_python_xml      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_python_xml      Tue Jan 22 08:30:40 2008 -0700
@@ -1,8 +1,7 @@
 #!/bin/sh
 # CHECK-INSTALL
 
-python -c 'import xml.dom.minidom' 2>/dev/null || {
-    echo
-    echo "  *** Check for python-xml package FAILED"
-    exit 1
-}
+. funcs.sh
+
+python -c 'import xml.dom.minidom' 2>/dev/null || \
+fail "can't import xml.dom.minidom"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_udev
--- a/tools/check/check_udev    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_udev    Tue Jan 22 08:30:40 2008 -0700
@@ -1,34 +1,19 @@
 #!/bin/sh
 # CHECK-INSTALL
 
-RC=0
+. funcs.sh
 
-case ${OS} in
+case $OS in
 OpenBSD|NetBSD|FreeBSD)
-       TOOL="vnconfig"
-       which ${TOOL} 1>/dev/null 2>&1 || RC=1
+       has_or_fail vnconfig
        ;;
 Linux)
-       TOOL="udevinfo"
-       UDEV_VERSION="0"
-       test -x "$(which ${TOOL} 2>/dev/null)" && \
-               UDEV_VERSION=$(${TOOL} -V | sed -e 's/^[^0-9]* 
\([0-9]\{1,\}\)[^0-9]\{0,\}/\1/')
-       if test "${UDEV_VERSION}" -ge 059; then
-               RC=0
-       else
-               TOOL="hotplug"
-               which ${TOOL} 1>/dev/null 2>&1 || RC=1
-       fi
+       has_or_fail udevinfo
+       [ "`udevinfo -V | awk '{print $NF}'`" -ge 59 ] 2>/dev/null || \
+               has hotplug || \
+               fail "udev is too old, upgrade to version 59 or later"
        ;;
 *)
-       TOOL=""
-       echo "Unknown OS" && RC=1
+       fail "unknown OS"
        ;;
 esac
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for ${TOOL} FAILED"
-fi
-
-exit ${RC}
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_x11_devel
--- a/tools/check/check_x11_devel       Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_x11_devel       Tue Jan 22 08:30:40 2008 -0700
@@ -1,15 +1,8 @@
 #!/bin/sh
 # CHECK-BUILD
 
-RC=0
+. funcs.sh
 
-set -e
-test -r /usr/include/X11/keysymdef.h || \
-test -r /usr/X11R6/include/X11/keysymdef.h || RC=1
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for x11 headers FAILED"
-fi
-
-exit ${RC}
+has_header X11/keysymdef.h || \
+has_header /usr/X11R6/include/X11/keysymdef.h || \
+fail "can't find X11 headers"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_xgettext
--- a/tools/check/check_xgettext        Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_xgettext        Tue Jan 22 08:30:40 2008 -0700
@@ -1,14 +1,6 @@
 #!/bin/sh
 # CHECK-BUILD
 
-RC=0
+. funcs.sh
 
-TOOL="xgettext"
-which ${TOOL} 1>/dev/null 2>&1 || RC=1 
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for the gettext utility (${TOOL}) FAILED"
-fi
-
-exit ${RC} 
+has_or_fail xgettext
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_xml2
--- a/tools/check/check_xml2    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_xml2    Tue Jan 22 08:30:40 2008 -0700
@@ -1,5 +1,7 @@
 #!/bin/sh
 # CHECK-BUILD CHECK-INSTALL
+
+. funcs.sh
 
 if [ ! "$LIBXENAPI_BINDINGS" = "y" -a ! "$ACM_SECURITY" = "y" ]
 then
@@ -7,32 +9,6 @@ then
     exit 0
 fi
 
-RC=0
-
-XML2_CONFIG="$(which xml2-config)"
-tmpfile=$(mktemp)
-
-if test -z ${XML2_CONFIG}; then
-    RC=1
-else
-    ${XML2_CONFIG} --libs 2>&1 > /dev/null
-    RC=$?
-fi
-
-if test $RC -ne 0; then
-    echo "FAILED"
-       echo " *** xml2-config is missing. "
-    echo " *** Please install libxml2-devel."
-elif ! ld $($XML2_CONFIG --libs) -o $tmpfile >/dev/null 2>&1; then
-    echo "FAILED"
-    echo " *** dependency libraries for xml2 are missing: "
-    RC=1
-    for i in $(ld $($XML2_CONFIG --libs) -o $tmpfile 2>&1 >/dev/null); do
-        case $i in
-        -l*) echo lib${i#-l}
-        esac
-    done
-fi
-rm -f $tmpfile
-
-exit $RC
+has_or_fail xml2-config
+xml2_libs=`xml2-config --libs` || fail "xml2-config --libs failed"
+test_link $xml2_libs || fail "dependency libraries for xml2 are missing"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_zlib_devel
--- a/tools/check/check_zlib_devel      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_zlib_devel      Tue Jan 22 08:30:40 2008 -0700
@@ -1,14 +1,6 @@
 #!/bin/sh
 # CHECK-BUILD
 
-RC=0
+. funcs.sh
 
-set -e
-test -r /usr/include/zlib.h || RC=1
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for zlib headers FAILED"
-fi 
-
-exit ${RC}
+has_header zlib.h || fail "can't find zlib headers"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/check_zlib_lib
--- a/tools/check/check_zlib_lib        Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/check_zlib_lib        Tue Jan 22 08:30:40 2008 -0700
@@ -1,24 +1,12 @@
 #!/bin/sh
 # CHECK-BUILD CHECK-INSTALL
 
-RC=0
+. funcs.sh
 
-case $(uname -s) in
+case $OS in
 FreeBSD|NetBSD|OpenBSD)
        exit 0
        ;;
-*)
-       ;;
 esac
 
-PATH=/sbin:$PATH
-
-set -e
-ldconfig -p 2>&1 | grep -q libz.so || RC=1
-
-if test ${RC} -ne 0; then
-       echo
-       echo " *** Check for zlib library FAILED"
-fi
-
-exit ${RC} 
+has_lib libz.so || fail "can't find zlib"
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/chk
--- a/tools/check/chk   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/check/chk   Tue Jan 22 08:30:40 2008 -0700
@@ -7,17 +7,16 @@ func_usage ()
     echo
     echo "Check suitability for Xen build or install."
     echo "Exit with 0 if OK, 1 if not."
-    echo "Prints only failed tests."
     echo
     echo "Calling with 'clean' removes generated files."
     exit 1
 }
 
-PATH=${PATH}:/sbin:/usr/sbin
+PATH=$PATH:/sbin:/usr/sbin
 OS=`uname -s`
 export PATH OS
 
-if test "${OS}" = "SunOS"; then
+if [ "$OS" = "SunOS" ]; then
        exit 0
 fi
 
@@ -38,7 +37,7 @@ esac
 
 failed=0
 
-echo "Xen ${check} " $(date)
+echo "Xen ${check} " `date`
 for f in check_* ; do
     case $f in
         *~)
@@ -50,7 +49,7 @@ for f in check_* ; do
     if ! [ -x $f ] ; then
         continue
     fi
-    if ! grep -q ${check} $f ; then
+    if ! grep -Fq "$check" $f ; then
         continue
     fi
     echo -n "Checking $f: "
diff -r 29268e3fc7ab -r 603ea719d73a tools/check/funcs.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/check/funcs.sh      Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,85 @@
+# has is the same as which, except it handles cross environments
+has() {
+       if [ -z "$CROSS_COMPILE" ]; then
+               command which "$@"
+               return $?
+       fi
+
+       check_sys_root || return 1
+
+       # subshell to prevent pollution of caller's IFS
+       (
+       IFS=:
+       for p in $PATH; do
+               if [ -x "$CROSS_SYS_ROOT/$p/$1" ]; then
+                       echo "$CROSS_SYS_ROOT/$p/$1"
+                       return 0
+               fi
+       done
+       return 1
+       )
+}
+
+has_or_fail() {
+       has "$1" >/dev/null || fail "can't find $1"
+}
+
+has_header() {
+       case $1 in
+               /*) ;;
+               *) set -- "/usr/include/$1" ;;
+       esac
+
+       check_sys_root || return 1
+
+       test -r "$CROSS_SYS_ROOT$1"
+       return $?
+}
+
+has_lib() {
+       check_sys_root || return 1
+
+       # subshell to prevent pollution of caller's environment
+       (
+       PATH=/sbin:$PATH        # for ldconfig
+
+       # This relatively common in a sys-root; libs are installed but
+       # ldconfig hasn't run there, so ldconfig -p won't work.
+       if [ "$OS" = Linux -a ! -f "$CROSS_SYS_ROOT/etc/ld.so.cache" ]; then
+           echo "Please run ldconfig -r \"$CROSS_SYS_ROOT\" to generate 
ld.so.cache"
+           # fall through; ldconfig test below should fail
+       fi
+       ldconfig -p ${CROSS_SYS_ROOT+-r "$CROSS_SYS_ROOT"} | grep -Fq "$1"
+       return $?
+       )
+}
+
+test_link() {
+       # subshell to trap removal of tmpfile
+       (
+       unset tmpfile
+       trap 'rm -f "$tmpfile"; exit' 0 1 2 15
+       tmpfile=`mktemp` || return 1
+       ld "$@" -o "$tmpfile" >/dev/null 2>&1
+       return $?
+       )
+}
+
+# this function is used commonly above
+check_sys_root() {
+       [ -z "$CROSS_COMPILE" ] && return 0
+       if [ -z "$CROSS_SYS_ROOT" ]; then
+               echo "please set CROSS_SYS_ROOT in the environment"
+               return 1
+       fi
+       if [ ! -d "$CROSS_SYS_ROOT" ]; then
+               echo "no sys-root found at $CROSS_SYS_ROOT"
+               return 1
+       fi
+}
+
+fail() {
+       echo
+       echo " *** `basename "$0"` FAILED${*+: $*}"
+       exit 1
+}
diff -r 29268e3fc7ab -r 603ea719d73a tools/console/Makefile
--- a/tools/console/Makefile    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/console/Makefile    Tue Jan 22 08:30:40 2008 -0700
@@ -2,8 +2,7 @@ XEN_ROOT=../..
 XEN_ROOT=../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-DAEMON_INSTALL_DIR = /usr/sbin
-CLIENT_INSTALL_DIR = /usr/$(LIBDIR)/xen/bin
+CLIENT_INSTALL_DIR = $(LIBDIR)/xen/bin
 
 CFLAGS  += -Werror
 
@@ -30,7 +29,7 @@ xenconsole: $(patsubst %.c,%.o,$(wildcar
 
 .PHONY: install
 install: $(BIN)
-       $(INSTALL_DIR) $(DESTDIR)/$(DAEMON_INSTALL_DIR)
-       $(INSTALL_PROG) xenconsoled $(DESTDIR)/$(DAEMON_INSTALL_DIR)
+       $(INSTALL_DIR) $(DESTDIR)/$(SBINDIR)
+       $(INSTALL_PROG) xenconsoled $(DESTDIR)/$(SBINDIR)
        $(INSTALL_DIR) $(DESTDIR)/$(CLIENT_INSTALL_DIR)
        $(INSTALL_PROG) xenconsole $(DESTDIR)/$(CLIENT_INSTALL_DIR)
diff -r 29268e3fc7ab -r 603ea719d73a tools/debugger/xenitp/Makefile
--- a/tools/debugger/xenitp/Makefile    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/debugger/xenitp/Makefile    Tue Jan 22 08:30:40 2008 -0700
@@ -26,17 +26,14 @@ build: $(BIN) $(LIBBIN)
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
-       [ -z "$(LIBBIN)" ] || [ -d $(DESTDIR)/usr/$(LIBDIR)/xen/bin ] || \
-               $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)/xen/bin
-       [ -d $(DESTDIR)/usr/share/man/man1 ] || \
-               $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man1
-       [ -d $(DESTDIR)/usr/share/man/man8 ] || \
-               $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man8
-       $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)/usr/bin
-       [ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) 
$(DESTDIR)/usr/$(LIBDIR)/xen/bin
-       $(INSTALL_DATA) $(MAN1) $(DESTDIR)/usr/share/man/man1
-       $(INSTALL_DATA) $(MAN8) $(DESTDIR)/usr/share/man/man8
+       $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
+       [ -z "$(LIBBIN)" ] || $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)/xen/bin
+       $(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
+       $(INSTALL_DIR) $(DESTDIR)$(MAN8DIR)
+       $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
+       [ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) 
$(DESTDIR)$(LIBDIR)/xen/bin
+       $(INSTALL_DATA) $(MAN1) $(DESTDIR)$(MAN1DIR)
+       $(INSTALL_DATA) $(MAN8) $(DESTDIR)$(MAN8DIR)
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/firmware/hvmloader/acpi/Makefile
--- a/tools/firmware/hvmloader/acpi/Makefile    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/firmware/hvmloader/acpi/Makefile    Tue Jan 22 08:30:40 2008 -0700
@@ -60,7 +60,7 @@ iasl:
        wget $(IASL_URL)
        tar xzf $(IASL_VER).tar.gz
        make -C $(IASL_VER)/compiler
-       $(INSTALL_PROG) $(IASL_VER)/compiler/iasl /usr/bin/iasl
+       $(INSTALL_PROG) $(IASL_VER)/compiler/iasl $(DESTDIR)$(BINDIR)/iasl
 
 acpi.a: $(OBJS)
        $(AR) rc $@ $(OBJS)
diff -r 29268e3fc7ab -r 603ea719d73a tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/firmware/hvmloader/acpi/build.c     Tue Jan 22 08:30:40 2008 -0700
@@ -65,14 +65,18 @@ static int construct_bios_info_table(uin
 static int construct_bios_info_table(uint8_t *buf)
 {
     struct bios_info {
-        uint8_t com1_present:1;
-        uint8_t com2_present:1;
+        uint8_t  com1_present:1;
+        uint8_t  com2_present:1;
+        uint32_t pci_min, pci_len;
     } *bios_info = (struct bios_info *)buf;
 
     memset(bios_info, 0, sizeof(*bios_info));
 
     bios_info->com1_present = uart_exists(0x3f8);
     bios_info->com2_present = uart_exists(0x2f8);
+
+    bios_info->pci_min = 0xf0000000;
+    bios_info->pci_len = 0x0c000000;
 
     return align16(sizeof(*bios_info));
 }
diff -r 29268e3fc7ab -r 603ea719d73a tools/firmware/hvmloader/acpi/dsdt.asl
--- a/tools/firmware/hvmloader/acpi/dsdt.asl    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/firmware/hvmloader/acpi/dsdt.asl    Tue Jan 22 08:30:40 2008 -0700
@@ -48,7 +48,10 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
        OperationRegion(BIOS, SystemMemory, 0xEA000, 16)
        Field(BIOS, ByteAcc, NoLock, Preserve) {
            UAR1, 1,
-           UAR2, 1
+           UAR2, 1,
+           Offset(4),
+           PMIN, 32,
+           PLEN, 32
        }
 
         /* Fix HCT test for 0x400 pci memory:
@@ -82,7 +85,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                {
                    /* bus number is from 0 - 255*/
                    WordBusNumber(
-                        ResourceConsumer, MinFixed, MaxFixed, SubDecode,
+                        ResourceProducer, MinFixed, MaxFixed, SubDecode,
                         0x0000,
                         0x0000,
                         0x00FF,
@@ -117,14 +120,25 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
                         0x00020000)
 
                     DWordMemory(
-                        ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                        ResourceProducer, PosDecode, MinFixed, MaxFixed,
                         Cacheable, ReadWrite,
                         0x00000000,
                         0xF0000000,
                         0xF4FFFFFF,
                         0x00000000,
-                        0x05000000)
+                        0x05000000,
+                        ,, _Y01)
                 })
+
+                CreateDWordField(PRT0, \_SB.PCI0._CRS._Y01._MIN, MMIN)
+                CreateDWordField(PRT0, \_SB.PCI0._CRS._Y01._MAX, MMAX)
+                CreateDWordField(PRT0, \_SB.PCI0._CRS._Y01._LEN, MLEN)
+
+                Store(\_SB.PMIN, MMIN)
+                Store(\_SB.PLEN, MLEN)
+                Add(MMIN, MLEN, MMAX)
+                Subtract(MMAX, One, MMAX)
+
                 Return (PRT0)
             }
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/firmware/hvmloader/acpi/dsdt.c
--- a/tools/firmware/hvmloader/acpi/dsdt.c      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/firmware/hvmloader/acpi/dsdt.c      Tue Jan 22 08:30:40 2008 -0700
@@ -5,15 +5,15 @@
  * Copyright (C) 2000 - 2006 Intel Corporation
  * Supports ACPI Specification Revision 3.0a
  * 
- * Compilation of "dsdt.asl" - Tue Sep 11 16:12:28 2007
+ * Compilation of "dsdt.asl" - Mon Jan 21 14:11:31 2008
  * 
  * C source code output
  *
  */
 unsigned char AmlCode[] =
 {
-    0x44,0x53,0x44,0x54,0x19,0x0E,0x00,0x00,  /* 00000000    "DSDT...." */
-    0x02,0x6A,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    ".jXen..." */
+    0x44,0x53,0x44,0x54,0x6F,0x0E,0x00,0x00,  /* 00000000    "DSDTo..." */
+    0x02,0xE1,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    "..Xen..." */
     0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "HVM....." */
     0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
     0x07,0x07,0x06,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
@@ -27,442 +27,452 @@ unsigned char AmlCode[] =
     0x04,0x0A,0x07,0x0A,0x07,0x00,0x00,0x08,  /* 00000060    "........" */
     0x50,0x49,0x43,0x44,0x00,0x14,0x0C,0x5F,  /* 00000068    "PICD..._" */
     0x50,0x49,0x43,0x01,0x70,0x68,0x50,0x49,  /* 00000070    "PIC.phPI" */
-    0x43,0x44,0x10,0x4E,0xD9,0x5F,0x53,0x42,  /* 00000078    "CD.N._SB" */
+    0x43,0x44,0x10,0x44,0xDF,0x5F,0x53,0x42,  /* 00000078    "CD.D._SB" */
     0x5F,0x5B,0x80,0x42,0x49,0x4F,0x53,0x00,  /* 00000080    "_[.BIOS." */
     0x0C,0x00,0xA0,0x0E,0x00,0x0A,0x10,0x5B,  /* 00000088    ".......[" */
-    0x81,0x10,0x42,0x49,0x4F,0x53,0x01,0x55,  /* 00000090    "..BIOS.U" */
+    0x81,0x1C,0x42,0x49,0x4F,0x53,0x01,0x55,  /* 00000090    "..BIOS.U" */
     0x41,0x52,0x31,0x01,0x55,0x41,0x52,0x32,  /* 00000098    "AR1.UAR2" */
-    0x01,0x5B,0x82,0x49,0x04,0x4D,0x45,0x4D,  /* 000000A0    ".[.I.MEM" */
-    0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 000000A8    "0._HID.A" */
-    0xD0,0x0C,0x02,0x08,0x5F,0x43,0x52,0x53,  /* 000000B0    "...._CRS" */
-    0x11,0x33,0x0A,0x30,0x8A,0x2B,0x00,0x00,  /* 000000B8    ".3.0.+.." */
-    0x0D,0x03,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000C0    "........" */
-    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000C8    "........" */
-    0x00,0x00,0xFF,0xFF,0x09,0x00,0x00,0x00,  /* 000000D0    "........" */
-    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000D8    "........" */
-    0x00,0x00,0x00,0x00,0x0A,0x00,0x00,0x00,  /* 000000E0    "........" */
-    0x00,0x00,0x79,0x00,0x5B,0x82,0x4B,0xD2,  /* 000000E8    "..y.[.K." */
-    0x50,0x43,0x49,0x30,0x08,0x5F,0x48,0x49,  /* 000000F0    "PCI0._HI" */
-    0x44,0x0C,0x41,0xD0,0x0A,0x03,0x08,0x5F,  /* 000000F8    "D.A...._" */
-    0x55,0x49,0x44,0x00,0x08,0x5F,0x41,0x44,  /* 00000100    "UID.._AD" */
-    0x52,0x00,0x08,0x5F,0x42,0x42,0x4E,0x00,  /* 00000108    "R.._BBN." */
-    0x14,0x44,0x08,0x5F,0x43,0x52,0x53,0x00,  /* 00000110    ".D._CRS." */
-    0x08,0x50,0x52,0x54,0x30,0x11,0x42,0x07,  /* 00000118    ".PRT0.B." */
-    0x0A,0x6E,0x88,0x0D,0x00,0x02,0x0F,0x00,  /* 00000120    ".n......" */
-    0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,  /* 00000128    "........" */
-    0x00,0x01,0x47,0x01,0xF8,0x0C,0xF8,0x0C,  /* 00000130    "..G....." */
-    0x01,0x08,0x88,0x0D,0x00,0x01,0x0C,0x03,  /* 00000138    "........" */
-    0x00,0x00,0x00,0x00,0xF7,0x0C,0x00,0x00,  /* 00000140    "........" */
-    0xF8,0x0C,0x88,0x0D,0x00,0x01,0x0C,0x03,  /* 00000148    "........" */
-    0x00,0x00,0x00,0x0D,0xFF,0xFF,0x00,0x00,  /* 00000150    "........" */
-    0x00,0xF3,0x87,0x17,0x00,0x00,0x0C,0x03,  /* 00000158    "........" */
-    0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,  /* 00000160    "........" */
-    0xFF,0xFF,0x0B,0x00,0x00,0x00,0x00,0x00,  /* 00000168    "........" */
-    0x00,0x00,0x02,0x00,0x87,0x17,0x00,0x00,  /* 00000170    "........" */
-    0x0D,0x03,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000178    "........" */
-    0x00,0xF0,0xFF,0xFF,0xFF,0xF4,0x00,0x00,  /* 00000180    "........" */
-    0x00,0x00,0x00,0x00,0x00,0x05,0x79,0x00,  /* 00000188    "......y." */
-    0xA4,0x50,0x52,0x54,0x30,0x08,0x42,0x55,  /* 00000190    ".PRT0.BU" */
-    0x46,0x41,0x11,0x09,0x0A,0x06,0x23,0x20,  /* 00000198    "FA....# " */
-    0x0C,0x18,0x79,0x00,0x08,0x42,0x55,0x46,  /* 000001A0    "..y..BUF" */
-    0x42,0x11,0x09,0x0A,0x06,0x23,0x00,0x00,  /* 000001A8    "B....#.." */
-    0x18,0x79,0x00,0x8B,0x42,0x55,0x46,0x42,  /* 000001B0    ".y..BUFB" */
-    0x01,0x49,0x52,0x51,0x56,0x5B,0x82,0x48,  /* 000001B8    ".IRQV[.H" */
-    0x08,0x4C,0x4E,0x4B,0x41,0x08,0x5F,0x48,  /* 000001C0    ".LNKA._H" */
-    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,  /* 000001C8    "ID.A...." */
-    0x5F,0x55,0x49,0x44,0x01,0x14,0x1C,0x5F,  /* 000001D0    "_UID..._" */
-    0x53,0x54,0x41,0x00,0x7B,0x50,0x49,0x52,  /* 000001D8    "STA.{PIR" */
-    0x41,0x0A,0x80,0x60,0xA0,0x08,0x93,0x60,  /* 000001E0    "A..`...`" */
-    0x0A,0x80,0xA4,0x0A,0x09,0xA1,0x04,0xA4,  /* 000001E8    "........" */
-    0x0A,0x0B,0x14,0x0B,0x5F,0x50,0x52,0x53,  /* 000001F0    "...._PRS" */
-    0x00,0xA4,0x42,0x55,0x46,0x41,0x14,0x11,  /* 000001F8    "..BUFA.." */
-    0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,0x49,  /* 00000200    "_DIS.}PI" */
-    0x52,0x41,0x0A,0x80,0x50,0x49,0x52,0x41,  /* 00000208    "RA..PIRA" */
-    0x14,0x1A,0x5F,0x43,0x52,0x53,0x00,0x7B,  /* 00000210    ".._CRS.{" */
-    0x50,0x49,0x52,0x41,0x0A,0x0F,0x60,0x79,  /* 00000218    "PIRA..`y" */
-    0x01,0x60,0x49,0x52,0x51,0x56,0xA4,0x42,  /* 00000220    ".`IRQV.B" */
-    0x55,0x46,0x42,0x14,0x1B,0x5F,0x53,0x52,  /* 00000228    "UFB.._SR" */
-    0x53,0x01,0x8B,0x68,0x01,0x49,0x52,0x51,  /* 00000230    "S..h.IRQ" */
-    0x31,0x82,0x49,0x52,0x51,0x31,0x60,0x76,  /* 00000238    "1.IRQ1`v" */
-    0x60,0x70,0x60,0x50,0x49,0x52,0x41,0x5B,  /* 00000240    "`p`PIRA[" */
-    0x82,0x49,0x08,0x4C,0x4E,0x4B,0x42,0x08,  /* 00000248    ".I.LNKB." */
-    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,  /* 00000250    "_HID.A.." */
-    0x0F,0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,  /* 00000258    ".._UID.." */
-    0x14,0x1C,0x5F,0x53,0x54,0x41,0x00,0x7B,  /* 00000260    ".._STA.{" */
-    0x50,0x49,0x52,0x42,0x0A,0x80,0x60,0xA0,  /* 00000268    "PIRB..`." */
-    0x08,0x93,0x60,0x0A,0x80,0xA4,0x0A,0x09,  /* 00000270    "..`....." */
-    0xA1,0x04,0xA4,0x0A,0x0B,0x14,0x0B,0x5F,  /* 00000278    "......._" */
-    0x50,0x52,0x53,0x00,0xA4,0x42,0x55,0x46,  /* 00000280    "PRS..BUF" */
-    0x41,0x14,0x11,0x5F,0x44,0x49,0x53,0x00,  /* 00000288    "A.._DIS." */
-    0x7D,0x50,0x49,0x52,0x42,0x0A,0x80,0x50,  /* 00000290    "}PIRB..P" */
-    0x49,0x52,0x42,0x14,0x1A,0x5F,0x43,0x52,  /* 00000298    "IRB.._CR" */
-    0x53,0x00,0x7B,0x50,0x49,0x52,0x42,0x0A,  /* 000002A0    "S.{PIRB." */
-    0x0F,0x60,0x79,0x01,0x60,0x49,0x52,0x51,  /* 000002A8    ".`y.`IRQ" */
-    0x56,0xA4,0x42,0x55,0x46,0x42,0x14,0x1B,  /* 000002B0    "V.BUFB.." */
-    0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,0x01,  /* 000002B8    "_SRS..h." */
-    0x49,0x52,0x51,0x31,0x82,0x49,0x52,0x51,  /* 000002C0    "IRQ1.IRQ" */
-    0x31,0x60,0x76,0x60,0x70,0x60,0x50,0x49,  /* 000002C8    "1`v`p`PI" */
-    0x52,0x42,0x5B,0x82,0x49,0x08,0x4C,0x4E,  /* 000002D0    "RB[.I.LN" */
-    0x4B,0x43,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 000002D8    "KC._HID." */
-    0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,0x49,  /* 000002E0    "A...._UI" */
-    0x44,0x0A,0x03,0x14,0x1C,0x5F,0x53,0x54,  /* 000002E8    "D...._ST" */
-    0x41,0x00,0x7B,0x50,0x49,0x52,0x43,0x0A,  /* 000002F0    "A.{PIRC." */
-    0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,0x80,  /* 000002F8    ".`...`.." */
-    0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,0x0B,  /* 00000300    "........" */
-    0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,0xA4,  /* 00000308    ".._PRS.." */
-    0x42,0x55,0x46,0x41,0x14,0x11,0x5F,0x44,  /* 00000310    "BUFA.._D" */
-    0x49,0x53,0x00,0x7D,0x50,0x49,0x52,0x43,  /* 00000318    "IS.}PIRC" */
-    0x0A,0x80,0x50,0x49,0x52,0x43,0x14,0x1A,  /* 00000320    "..PIRC.." */
-    0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,0x49,  /* 00000328    "_CRS.{PI" */
-    0x52,0x43,0x0A,0x0F,0x60,0x79,0x01,0x60,  /* 00000330    "RC..`y.`" */
-    0x49,0x52,0x51,0x56,0xA4,0x42,0x55,0x46,  /* 00000338    "IRQV.BUF" */
-    0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,  /* 00000340    "B.._SRS." */
-    0x8B,0x68,0x01,0x49,0x52,0x51,0x31,0x82,  /* 00000348    ".h.IRQ1." */
-    0x49,0x52,0x51,0x31,0x60,0x76,0x60,0x70,  /* 00000350    "IRQ1`v`p" */
-    0x60,0x50,0x49,0x52,0x43,0x5B,0x82,0x49,  /* 00000358    "`PIRC[.I" */
-    0x08,0x4C,0x4E,0x4B,0x44,0x08,0x5F,0x48,  /* 00000360    ".LNKD._H" */
-    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,  /* 00000368    "ID.A...." */
-    0x5F,0x55,0x49,0x44,0x0A,0x04,0x14,0x1C,  /* 00000370    "_UID...." */
-    0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,0x49,  /* 00000378    "_STA.{PI" */
-    0x52,0x44,0x0A,0x80,0x60,0xA0,0x08,0x93,  /* 00000380    "RD..`..." */
-    0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,0x04,  /* 00000388    "`......." */
-    0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,0x52,  /* 00000390    "....._PR" */
-    0x53,0x00,0xA4,0x42,0x55,0x46,0x41,0x14,  /* 00000398    "S..BUFA." */
-    0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,  /* 000003A0    "._DIS.}P" */
-    0x49,0x52,0x44,0x0A,0x80,0x50,0x49,0x52,  /* 000003A8    "IRD..PIR" */
-    0x44,0x14,0x1A,0x5F,0x43,0x52,0x53,0x00,  /* 000003B0    "D.._CRS." */
-    0x7B,0x50,0x49,0x52,0x44,0x0A,0x0F,0x60,  /* 000003B8    "{PIRD..`" */
-    0x79,0x01,0x60,0x49,0x52,0x51,0x56,0xA4,  /* 000003C0    "y.`IRQV." */
-    0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,0x53,  /* 000003C8    "BUFB.._S" */
-    0x52,0x53,0x01,0x8B,0x68,0x01,0x49,0x52,  /* 000003D0    "RS..h.IR" */
-    0x51,0x31,0x82,0x49,0x52,0x51,0x31,0x60,  /* 000003D8    "Q1.IRQ1`" */
-    0x76,0x60,0x70,0x60,0x50,0x49,0x52,0x44,  /* 000003E0    "v`p`PIRD" */
-    0x5B,0x82,0x3A,0x48,0x50,0x45,0x54,0x08,  /* 000003E8    "[.:HPET." */
-    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x01,  /* 000003F0    "_HID.A.." */
-    0x03,0x08,0x5F,0x55,0x49,0x44,0x00,0x08,  /* 000003F8    ".._UID.." */
-    0x5F,0x43,0x52,0x53,0x11,0x1F,0x0A,0x1C,  /* 00000400    "_CRS...." */
-    0x87,0x17,0x00,0x00,0x0D,0x01,0x00,0x00,  /* 00000408    "........" */
-    0x00,0x00,0x00,0x00,0xD0,0xFE,0xFF,0x03,  /* 00000410    "........" */
-    0xD0,0xFE,0x00,0x00,0x00,0x00,0x00,0x04,  /* 00000418    "........" */
-    0x00,0x00,0x79,0x00,0x14,0x16,0x5F,0x50,  /* 00000420    "..y..._P" */
-    0x52,0x54,0x00,0xA0,0x0A,0x50,0x49,0x43,  /* 00000428    "RT...PIC" */
-    0x44,0xA4,0x50,0x52,0x54,0x41,0xA4,0x50,  /* 00000430    "D.PRTA.P" */
-    0x52,0x54,0x50,0x08,0x50,0x52,0x54,0x50,  /* 00000438    "RTP.PRTP" */
-    0x12,0x49,0x36,0x3C,0x12,0x0D,0x04,0x0C,  /* 00000440    ".I6<...." */
-    0xFF,0xFF,0x01,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000448    ".....LNK" */
-    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000450    "B......." */
-    0x01,0x00,0x01,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000458    "...LNKC." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 00000460    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x44,0x00,0x12,  /* 00000468    "..LNKD.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,  /* 00000470    "........" */
-    0x03,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000478    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x02,0x00,0x00,0x4C,  /* 00000480    ".......L" */
-    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 00000488    "NKC....." */
-    0xFF,0xFF,0x02,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000490    ".....LNK" */
-    0x44,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000498    "D......." */
-    0x02,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x41,  /* 000004A0    "....LNKA" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,  /* 000004A8    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x42,0x00,  /* 000004B0    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 000004B8    "........" */
-    0x00,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 000004C0    ".LNKD..." */
-    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x01,0x4C,  /* 000004C8    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,  /* 000004D0    "NKA....." */
-    0xFF,0xFF,0x03,0x00,0x0A,0x02,0x4C,0x4E,  /* 000004D8    "......LN" */
-    0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000004E0    "KB......" */
-    0xFF,0x03,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000004E8    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000004F0    "C......." */
-    0x04,0x00,0x00,0x4C,0x4E,0x4B,0x41,0x00,  /* 000004F8    "...LNKA." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000500    "........" */
-    0x01,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,  /* 00000508    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,0x02,  /* 00000510    "........" */
-    0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,0x04,  /* 00000518    "LNKC...." */
-    0x0C,0xFF,0xFF,0x04,0x00,0x0A,0x03,0x4C,  /* 00000520    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000528    "NKD....." */
-    0xFF,0xFF,0x05,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000530    ".....LNK" */
-    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000538    "B......." */
-    0x05,0x00,0x01,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000540    "...LNKC." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x05,0x00,  /* 00000548    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x44,0x00,0x12,  /* 00000550    "..LNKD.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,  /* 00000558    "........" */
-    0x03,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000560    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x06,0x00,0x00,0x4C,  /* 00000568    ".......L" */
-    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 00000570    "NKC....." */
-    0xFF,0xFF,0x06,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000578    ".....LNK" */
-    0x44,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000580    "D......." */
-    0x06,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x41,  /* 00000588    "....LNKA" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x06,  /* 00000590    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000598    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x07,0x00,  /* 000005A0    "........" */
-    0x00,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 000005A8    ".LNKD..." */
-    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x01,0x4C,  /* 000005B0    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,  /* 000005B8    "NKA....." */
-    0xFF,0xFF,0x07,0x00,0x0A,0x02,0x4C,0x4E,  /* 000005C0    "......LN" */
-    0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000005C8    "KB......" */
-    0xFF,0x07,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000005D0    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000005D8    "C......." */
-    0x08,0x00,0x00,0x4C,0x4E,0x4B,0x41,0x00,  /* 000005E0    "...LNKA." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 000005E8    "........" */
-    0x01,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,  /* 000005F0    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,0x02,  /* 000005F8    "........" */
-    0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,0x04,  /* 00000600    "LNKC...." */
-    0x0C,0xFF,0xFF,0x08,0x00,0x0A,0x03,0x4C,  /* 00000608    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000610    "NKD....." */
-    0xFF,0xFF,0x09,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000618    ".....LNK" */
-    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000620    "B......." */
-    0x09,0x00,0x01,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000628    "...LNKC." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x09,0x00,  /* 00000630    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x44,0x00,0x12,  /* 00000638    "..LNKD.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,  /* 00000640    "........" */
-    0x03,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000648    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x00,0x4C,  /* 00000650    ".......L" */
-    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 00000658    "NKC....." */
-    0xFF,0xFF,0x0A,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000660    ".....LNK" */
-    0x44,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000668    "D......." */
-    0x0A,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x41,  /* 00000670    "....LNKA" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0A,  /* 00000678    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000680    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0B,0x00,  /* 00000688    "........" */
-    0x00,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000690    ".LNKD..." */
-    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x01,0x4C,  /* 00000698    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,  /* 000006A0    "NKA....." */
-    0xFF,0xFF,0x0B,0x00,0x0A,0x02,0x4C,0x4E,  /* 000006A8    "......LN" */
-    0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000006B0    "KB......" */
-    0xFF,0x0B,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000006B8    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006C0    "C......." */
-    0x0C,0x00,0x00,0x4C,0x4E,0x4B,0x41,0x00,  /* 000006C8    "...LNKA." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 000006D0    "........" */
-    0x01,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,  /* 000006D8    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,0x02,  /* 000006E0    "........" */
-    0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,0x04,  /* 000006E8    "LNKC...." */
-    0x0C,0xFF,0xFF,0x0C,0x00,0x0A,0x03,0x4C,  /* 000006F0    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 000006F8    "NKD....." */
-    0xFF,0xFF,0x0D,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000700    ".....LNK" */
-    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000708    "B......." */
-    0x0D,0x00,0x01,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000710    "...LNKC." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0D,0x00,  /* 00000718    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x44,0x00,0x12,  /* 00000720    "..LNKD.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,  /* 00000728    "........" */
-    0x03,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000730    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x00,0x4C,  /* 00000738    ".......L" */
-    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 00000740    "NKC....." */
-    0xFF,0xFF,0x0E,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000748    ".....LNK" */
-    0x44,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000750    "D......." */
-    0x0E,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x41,  /* 00000758    "....LNKA" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0E,  /* 00000760    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000768    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0F,0x00,  /* 00000770    "........" */
-    0x00,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000778    ".LNKD..." */
-    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x01,0x4C,  /* 00000780    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,  /* 00000788    "NKA....." */
-    0xFF,0xFF,0x0F,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000790    "......LN" */
-    0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000798    "KB......" */
-    0xFF,0x0F,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000007A0    ".....LNK" */
-    0x43,0x00,0x08,0x50,0x52,0x54,0x41,0x12,  /* 000007A8    "C..PRTA." */
-    0x41,0x2F,0x3C,0x12,0x0B,0x04,0x0C,0xFF,  /* 000007B0    "A/<....." */
-    0xFF,0x01,0x00,0x00,0x00,0x0A,0x14,0x12,  /* 000007B8    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x01,0x00,0x01,  /* 000007C0    "........" */
-    0x00,0x0A,0x15,0x12,0x0C,0x04,0x0C,0xFF,  /* 000007C8    "........" */
-    0xFF,0x01,0x00,0x0A,0x02,0x00,0x0A,0x16,  /* 000007D0    "........" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 000007D8    "........" */
-    0x0A,0x03,0x00,0x0A,0x17,0x12,0x0B,0x04,  /* 000007E0    "........" */
-    0x0C,0xFF,0xFF,0x02,0x00,0x00,0x00,0x0A,  /* 000007E8    "........" */
-    0x18,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x02,  /* 000007F0    "........" */
-    0x00,0x01,0x00,0x0A,0x19,0x12,0x0C,0x04,  /* 000007F8    "........" */
-    0x0C,0xFF,0xFF,0x02,0x00,0x0A,0x02,0x00,  /* 00000800    "........" */
-    0x0A,0x1A,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000808    "........" */
-    0x02,0x00,0x0A,0x03,0x00,0x0A,0x1B,0x12,  /* 00000810    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x03,0x00,0x00,  /* 00000818    "........" */
-    0x00,0x0A,0x1C,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000820    "........" */
-    0xFF,0x03,0x00,0x01,0x00,0x0A,0x1D,0x12,  /* 00000828    "........" */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,  /* 00000830    "........" */
-    0x02,0x00,0x0A,0x1E,0x12,0x0C,0x04,0x0C,  /* 00000838    "........" */
-    0xFF,0xFF,0x03,0x00,0x0A,0x03,0x00,0x0A,  /* 00000840    "........" */
-    0x1F,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x04,  /* 00000848    "........" */
-    0x00,0x00,0x00,0x0A,0x20,0x12,0x0B,0x04,  /* 00000850    ".... ..." */
-    0x0C,0xFF,0xFF,0x04,0x00,0x01,0x00,0x0A,  /* 00000858    "........" */
-    0x21,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x04,  /* 00000860    "!......." */
-    0x00,0x0A,0x02,0x00,0x0A,0x22,0x12,0x0C,  /* 00000868    ".....".." */
-    0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,0x03,  /* 00000870    "........" */
-    0x00,0x0A,0x23,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000878    "..#....." */
-    0xFF,0x05,0x00,0x00,0x00,0x0A,0x24,0x12,  /* 00000880    "......$." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x05,0x00,0x01,  /* 00000888    "........" */
-    0x00,0x0A,0x25,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000890    "..%....." */
-    0xFF,0x05,0x00,0x0A,0x02,0x00,0x0A,0x26,  /* 00000898    ".......&" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x05,0x00,  /* 000008A0    "........" */
-    0x0A,0x03,0x00,0x0A,0x27,0x12,0x0B,0x04,  /* 000008A8    "....'..." */
-    0x0C,0xFF,0xFF,0x06,0x00,0x00,0x00,0x0A,  /* 000008B0    "........" */
-    0x28,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x06,  /* 000008B8    "(......." */
-    0x00,0x01,0x00,0x0A,0x29,0x12,0x0C,0x04,  /* 000008C0    "....)..." */
-    0x0C,0xFF,0xFF,0x06,0x00,0x0A,0x02,0x00,  /* 000008C8    "........" */
-    0x0A,0x2A,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000008D0    ".*......" */
-    0x06,0x00,0x0A,0x03,0x00,0x0A,0x2B,0x12,  /* 000008D8    "......+." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x07,0x00,0x00,  /* 000008E0    "........" */
-    0x00,0x0A,0x2C,0x12,0x0B,0x04,0x0C,0xFF,  /* 000008E8    "..,....." */
-    0xFF,0x07,0x00,0x01,0x00,0x0A,0x2D,0x12,  /* 000008F0    "......-." */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x07,0x00,0x0A,  /* 000008F8    "........" */
-    0x02,0x00,0x0A,0x2E,0x12,0x0C,0x04,0x0C,  /* 00000900    "........" */
-    0xFF,0xFF,0x07,0x00,0x0A,0x03,0x00,0x0A,  /* 00000908    "........" */
-    0x2F,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x08,  /* 00000910    "/......." */
-    0x00,0x00,0x00,0x0A,0x11,0x12,0x0B,0x04,  /* 00000918    "........" */
-    0x0C,0xFF,0xFF,0x08,0x00,0x01,0x00,0x0A,  /* 00000920    "........" */
-    0x12,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x08,  /* 00000928    "........" */
-    0x00,0x0A,0x02,0x00,0x0A,0x13,0x12,0x0C,  /* 00000930    "........" */
-    0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,0x03,  /* 00000938    "........" */
-    0x00,0x0A,0x14,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000940    "........" */
-    0xFF,0x09,0x00,0x00,0x00,0x0A,0x15,0x12,  /* 00000948    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x09,0x00,0x01,  /* 00000950    "........" */
-    0x00,0x0A,0x16,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000958    "........" */
-    0xFF,0x09,0x00,0x0A,0x02,0x00,0x0A,0x17,  /* 00000960    "........" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x09,0x00,  /* 00000968    "........" */
-    0x0A,0x03,0x00,0x0A,0x18,0x12,0x0B,0x04,  /* 00000970    "........" */
-    0x0C,0xFF,0xFF,0x0A,0x00,0x00,0x00,0x0A,  /* 00000978    "........" */
-    0x19,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0A,  /* 00000980    "........" */
-    0x00,0x01,0x00,0x0A,0x1A,0x12,0x0C,0x04,  /* 00000988    "........" */
-    0x0C,0xFF,0xFF,0x0A,0x00,0x0A,0x02,0x00,  /* 00000990    "........" */
-    0x0A,0x1B,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000998    "........" */
-    0x0A,0x00,0x0A,0x03,0x00,0x0A,0x1C,0x12,  /* 000009A0    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x00,  /* 000009A8    "........" */
-    0x00,0x0A,0x1D,0x12,0x0B,0x04,0x0C,0xFF,  /* 000009B0    "........" */
-    0xFF,0x0B,0x00,0x01,0x00,0x0A,0x1E,0x12,  /* 000009B8    "........" */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x0A,  /* 000009C0    "........" */
-    0x02,0x00,0x0A,0x1F,0x12,0x0C,0x04,0x0C,  /* 000009C8    "........" */
-    0xFF,0xFF,0x0B,0x00,0x0A,0x03,0x00,0x0A,  /* 000009D0    "........" */
-    0x20,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0C,  /* 000009D8    " ......." */
-    0x00,0x00,0x00,0x0A,0x21,0x12,0x0B,0x04,  /* 000009E0    "....!..." */
-    0x0C,0xFF,0xFF,0x0C,0x00,0x01,0x00,0x0A,  /* 000009E8    "........" */
-    0x22,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0C,  /* 000009F0    ""......." */
-    0x00,0x0A,0x02,0x00,0x0A,0x23,0x12,0x0C,  /* 000009F8    ".....#.." */
-    0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,0x03,  /* 00000A00    "........" */
-    0x00,0x0A,0x24,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A08    "..$....." */
-    0xFF,0x0D,0x00,0x00,0x00,0x0A,0x25,0x12,  /* 00000A10    "......%." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x01,  /* 00000A18    "........" */
-    0x00,0x0A,0x26,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000A20    "..&....." */
-    0xFF,0x0D,0x00,0x0A,0x02,0x00,0x0A,0x27,  /* 00000A28    ".......'" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0D,0x00,  /* 00000A30    "........" */
-    0x0A,0x03,0x00,0x0A,0x28,0x12,0x0B,0x04,  /* 00000A38    "....(..." */
-    0x0C,0xFF,0xFF,0x0E,0x00,0x00,0x00,0x0A,  /* 00000A40    "........" */
-    0x29,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0E,  /* 00000A48    ")......." */
-    0x00,0x01,0x00,0x0A,0x2A,0x12,0x0C,0x04,  /* 00000A50    "....*..." */
-    0x0C,0xFF,0xFF,0x0E,0x00,0x0A,0x02,0x00,  /* 00000A58    "........" */
-    0x0A,0x2B,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000A60    ".+......" */
-    0x0E,0x00,0x0A,0x03,0x00,0x0A,0x2C,0x12,  /* 00000A68    "......,." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x00,  /* 00000A70    "........" */
-    0x00,0x0A,0x2D,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A78    "..-....." */
-    0xFF,0x0F,0x00,0x01,0x00,0x0A,0x2E,0x12,  /* 00000A80    "........" */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A,  /* 00000A88    "........" */
-    0x02,0x00,0x0A,0x2F,0x12,0x0C,0x04,0x0C,  /* 00000A90    ".../...." */
-    0xFF,0xFF,0x0F,0x00,0x0A,0x03,0x00,0x0A,  /* 00000A98    "........" */
-    0x10,0x5B,0x82,0x46,0x37,0x49,0x53,0x41,  /* 00000AA0    ".[.F7ISA" */
-    0x5F,0x08,0x5F,0x41,0x44,0x52,0x0C,0x00,  /* 00000AA8    "_._ADR.." */
-    0x00,0x01,0x00,0x5B,0x80,0x50,0x49,0x52,  /* 00000AB0    "...[.PIR" */
-    0x51,0x02,0x0A,0x60,0x0A,0x04,0x10,0x2E,  /* 00000AB8    "Q..`...." */
-    0x5C,0x00,0x5B,0x81,0x29,0x5C,0x2F,0x04,  /* 00000AC0    "\.[.)\/." */
-    0x5F,0x53,0x42,0x5F,0x50,0x43,0x49,0x30,  /* 00000AC8    "_SB_PCI0" */
-    0x49,0x53,0x41,0x5F,0x50,0x49,0x52,0x51,  /* 00000AD0    "ISA_PIRQ" */
-    0x01,0x50,0x49,0x52,0x41,0x08,0x50,0x49,  /* 00000AD8    ".PIRA.PI" */
-    0x52,0x42,0x08,0x50,0x49,0x52,0x43,0x08,  /* 00000AE0    "RB.PIRC." */
-    0x50,0x49,0x52,0x44,0x08,0x5B,0x82,0x46,  /* 00000AE8    "PIRD.[.F" */
-    0x0B,0x53,0x59,0x53,0x52,0x08,0x5F,0x48,  /* 00000AF0    ".SYSR._H" */
-    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x02,0x08,  /* 00000AF8    "ID.A...." */
-    0x5F,0x55,0x49,0x44,0x01,0x08,0x43,0x52,  /* 00000B00    "_UID..CR" */
-    0x53,0x5F,0x11,0x4E,0x08,0x0A,0x8A,0x47,  /* 00000B08    "S_.N...G" */
-    0x01,0x10,0x00,0x10,0x00,0x00,0x10,0x47,  /* 00000B10    ".......G" */
-    0x01,0x22,0x00,0x22,0x00,0x00,0x0C,0x47,  /* 00000B18    "."."...G" */
-    0x01,0x30,0x00,0x30,0x00,0x00,0x10,0x47,  /* 00000B20    ".0.0...G" */
-    0x01,0x44,0x00,0x44,0x00,0x00,0x1C,0x47,  /* 00000B28    ".D.D...G" */
-    0x01,0x62,0x00,0x62,0x00,0x00,0x02,0x47,  /* 00000B30    ".b.b...G" */
-    0x01,0x65,0x00,0x65,0x00,0x00,0x0B,0x47,  /* 00000B38    ".e.e...G" */
-    0x01,0x72,0x00,0x72,0x00,0x00,0x0E,0x47,  /* 00000B40    ".r.r...G" */
-    0x01,0x80,0x00,0x80,0x00,0x00,0x01,0x47,  /* 00000B48    ".......G" */
-    0x01,0x84,0x00,0x84,0x00,0x00,0x03,0x47,  /* 00000B50    ".......G" */
-    0x01,0x88,0x00,0x88,0x00,0x00,0x01,0x47,  /* 00000B58    ".......G" */
-    0x01,0x8C,0x00,0x8C,0x00,0x00,0x03,0x47,  /* 00000B60    ".......G" */
-    0x01,0x90,0x00,0x90,0x00,0x00,0x10,0x47,  /* 00000B68    ".......G" */
-    0x01,0xA2,0x00,0xA2,0x00,0x00,0x1C,0x47,  /* 00000B70    ".......G" */
-    0x01,0xE0,0x00,0xE0,0x00,0x00,0x10,0x47,  /* 00000B78    ".......G" */
-    0x01,0xA0,0x08,0xA0,0x08,0x00,0x04,0x47,  /* 00000B80    ".......G" */
-    0x01,0xC0,0x0C,0xC0,0x0C,0x00,0x10,0x47,  /* 00000B88    ".......G" */
-    0x01,0xD0,0x04,0xD0,0x04,0x00,0x02,0x79,  /* 00000B90    ".......y" */
-    0x00,0x14,0x0B,0x5F,0x43,0x52,0x53,0x00,  /* 00000B98    "..._CRS." */
-    0xA4,0x43,0x52,0x53,0x5F,0x5B,0x82,0x2B,  /* 00000BA0    ".CRS_[.+" */
-    0x50,0x49,0x43,0x5F,0x08,0x5F,0x48,0x49,  /* 00000BA8    "PIC_._HI" */
-    0x44,0x0B,0x41,0xD0,0x08,0x5F,0x43,0x52,  /* 00000BB0    "D.A.._CR" */
-    0x53,0x11,0x18,0x0A,0x15,0x47,0x01,0x20,  /* 00000BB8    "S....G. " */
-    0x00,0x20,0x00,0x01,0x02,0x47,0x01,0xA0,  /* 00000BC0    ". ...G.." */
-    0x00,0xA0,0x00,0x01,0x02,0x22,0x04,0x00,  /* 00000BC8    ".....".." */
-    0x79,0x00,0x5B,0x82,0x47,0x05,0x44,0x4D,  /* 00000BD0    "y.[.G.DM" */
-    0x41,0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000BD8    "A0._HID." */
-    0x41,0xD0,0x02,0x00,0x08,0x5F,0x43,0x52,  /* 00000BE0    "A...._CR" */
-    0x53,0x11,0x41,0x04,0x0A,0x3D,0x2A,0x10,  /* 00000BE8    "S.A..=*." */
-    0x04,0x47,0x01,0x00,0x00,0x00,0x00,0x00,  /* 00000BF0    ".G......" */
-    0x10,0x47,0x01,0x81,0x00,0x81,0x00,0x00,  /* 00000BF8    ".G......" */
-    0x03,0x47,0x01,0x87,0x00,0x87,0x00,0x00,  /* 00000C00    ".G......" */
-    0x01,0x47,0x01,0x89,0x00,0x89,0x00,0x00,  /* 00000C08    ".G......" */
-    0x03,0x47,0x01,0x8F,0x00,0x8F,0x00,0x00,  /* 00000C10    ".G......" */
-    0x01,0x47,0x01,0xC0,0x00,0xC0,0x00,0x00,  /* 00000C18    ".G......" */
-    0x20,0x47,0x01,0x80,0x04,0x80,0x04,0x00,  /* 00000C20    " G......" */
-    0x10,0x79,0x00,0x5B,0x82,0x25,0x54,0x4D,  /* 00000C28    ".y.[.%TM" */
-    0x52,0x5F,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000C30    "R_._HID." */
-    0x41,0xD0,0x01,0x00,0x08,0x5F,0x43,0x52,  /* 00000C38    "A...._CR" */
-    0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,0x40,  /* 00000C40    "S....G.@" */
-    0x00,0x40,0x00,0x00,0x04,0x22,0x01,0x00,  /* 00000C48    ".@...".." */
-    0x79,0x00,0x5B,0x82,0x25,0x52,0x54,0x43,  /* 00000C50    "y.[.%RTC" */
-    0x5F,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000C58    "_._HID.A" */
-    0xD0,0x0B,0x00,0x08,0x5F,0x43,0x52,0x53,  /* 00000C60    "...._CRS" */
-    0x11,0x10,0x0A,0x0D,0x47,0x01,0x70,0x00,  /* 00000C68    "....G.p." */
-    0x70,0x00,0x00,0x02,0x22,0x00,0x01,0x79,  /* 00000C70    "p..."..y" */
-    0x00,0x5B,0x82,0x22,0x53,0x50,0x4B,0x52,  /* 00000C78    ".[."SPKR" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000C80    "._HID.A." */
-    0x08,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000C88    "..._CRS." */
-    0x0D,0x0A,0x0A,0x47,0x01,0x61,0x00,0x61,  /* 00000C90    "...G.a.a" */
-    0x00,0x00,0x01,0x79,0x00,0x5B,0x82,0x31,  /* 00000C98    "...y.[.1" */
-    0x50,0x53,0x32,0x4D,0x08,0x5F,0x48,0x49,  /* 00000CA0    "PS2M._HI" */
-    0x44,0x0C,0x41,0xD0,0x0F,0x13,0x08,0x5F,  /* 00000CA8    "D.A...._" */
-    0x43,0x49,0x44,0x0C,0x41,0xD0,0x0F,0x13,  /* 00000CB0    "CID.A..." */
-    0x14,0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,  /* 00000CB8    ".._STA.." */
-    0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000CC0    "..._CRS." */
-    0x08,0x0A,0x05,0x22,0x00,0x10,0x79,0x00,  /* 00000CC8    "..."..y." */
-    0x5B,0x82,0x42,0x04,0x50,0x53,0x32,0x4B,  /* 00000CD0    "[.B.PS2K" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000CD8    "._HID.A." */
-    0x03,0x03,0x08,0x5F,0x43,0x49,0x44,0x0C,  /* 00000CE0    "..._CID." */
-    0x41,0xD0,0x03,0x0B,0x14,0x09,0x5F,0x53,  /* 00000CE8    "A....._S" */
-    0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,  /* 00000CF0    "TA....._" */
-    0x43,0x52,0x53,0x11,0x18,0x0A,0x15,0x47,  /* 00000CF8    "CRS....G" */
-    0x01,0x60,0x00,0x60,0x00,0x00,0x01,0x47,  /* 00000D00    ".`.`...G" */
-    0x01,0x64,0x00,0x64,0x00,0x00,0x01,0x22,  /* 00000D08    ".d.d..."" */
-    0x02,0x00,0x79,0x00,0x5B,0x82,0x3A,0x46,  /* 00000D10    "..y.[.:F" */
-    0x44,0x43,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 00000D18    "DC0._HID" */
-    0x0C,0x41,0xD0,0x07,0x00,0x14,0x09,0x5F,  /* 00000D20    ".A....._" */
-    0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,  /* 00000D28    "STA....." */
-    0x5F,0x43,0x52,0x53,0x11,0x1B,0x0A,0x18,  /* 00000D30    "_CRS...." */
-    0x47,0x01,0xF0,0x03,0xF0,0x03,0x01,0x06,  /* 00000D38    "G......." */
-    0x47,0x01,0xF7,0x03,0xF7,0x03,0x01,0x01,  /* 00000D40    "G......." */
-    0x22,0x40,0x00,0x2A,0x04,0x00,0x79,0x00,  /* 00000D48    ""@.*..y." */
-    0x5B,0x82,0x46,0x04,0x55,0x41,0x52,0x31,  /* 00000D50    "[.F.UAR1" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000D58    "._HID.A." */
-    0x05,0x01,0x08,0x5F,0x55,0x49,0x44,0x01,  /* 00000D60    "..._UID." */
-    0x14,0x19,0x5F,0x53,0x54,0x41,0x00,0xA0,  /* 00000D68    ".._STA.." */
-    0x0D,0x93,0x5E,0x5E,0x5E,0x5E,0x55,0x41,  /* 00000D70    "..^^^^UA" */
-    0x52,0x31,0x00,0xA4,0x00,0xA1,0x04,0xA4,  /* 00000D78    "R1......" */
-    0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000D80    "..._CRS." */
-    0x10,0x0A,0x0D,0x47,0x01,0xF8,0x03,0xF8,  /* 00000D88    "...G...." */
-    0x03,0x08,0x08,0x22,0x10,0x00,0x79,0x00,  /* 00000D90    "..."..y." */
-    0x5B,0x82,0x47,0x04,0x55,0x41,0x52,0x32,  /* 00000D98    "[.G.UAR2" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000DA0    "._HID.A." */
-    0x05,0x01,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 00000DA8    "..._UID." */
-    0x02,0x14,0x19,0x5F,0x53,0x54,0x41,0x00,  /* 00000DB0    "..._STA." */
-    0xA0,0x0D,0x93,0x5E,0x5E,0x5E,0x5E,0x55,  /* 00000DB8    "...^^^^U" */
-    0x41,0x52,0x32,0x00,0xA4,0x00,0xA1,0x04,  /* 00000DC0    "AR2....." */
-    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000DC8    "...._CRS" */
-    0x11,0x10,0x0A,0x0D,0x47,0x01,0xF8,0x02,  /* 00000DD0    "....G..." */
-    0xF8,0x02,0x08,0x08,0x22,0x08,0x00,0x79,  /* 00000DD8    "...."..y" */
-    0x00,0x5B,0x82,0x36,0x4C,0x54,0x50,0x31,  /* 00000DE0    ".[.6LTP1" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000DE8    "._HID.A." */
-    0x04,0x00,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 00000DF0    "..._UID." */
-    0x02,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000DF8    "..._STA." */
-    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000E00    "...._CRS" */
-    0x11,0x10,0x0A,0x0D,0x47,0x01,0x78,0x03,  /* 00000E08    "....G.x." */
-    0x78,0x03,0x08,0x08,0x22,0x80,0x00,0x79,  /* 00000E10    "x..."..y" */
-    0x00,
+    0x01,0x00,0x1E,0x50,0x4D,0x49,0x4E,0x20,  /* 000000A0    "...PMIN " */
+    0x50,0x4C,0x45,0x4E,0x20,0x5B,0x82,0x49,  /* 000000A8    "PLEN [.I" */
+    0x04,0x4D,0x45,0x4D,0x30,0x08,0x5F,0x48,  /* 000000B0    ".MEM0._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x02,0x08,  /* 000000B8    "ID.A...." */
+    0x5F,0x43,0x52,0x53,0x11,0x33,0x0A,0x30,  /* 000000C0    "_CRS.3.0" */
+    0x8A,0x2B,0x00,0x00,0x0D,0x03,0x00,0x00,  /* 000000C8    ".+......" */
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000D0    "........" */
+    0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,  /* 000000D8    "........" */
+    0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000E0    "........" */
+    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000E8    "........" */
+    0x0A,0x00,0x00,0x00,0x00,0x00,0x79,0x00,  /* 000000F0    "......y." */
+    0x5B,0x82,0x45,0xD7,0x50,0x43,0x49,0x30,  /* 000000F8    "[.E.PCI0" */
+    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000100    "._HID.A." */
+    0x0A,0x03,0x08,0x5F,0x55,0x49,0x44,0x00,  /* 00000108    "..._UID." */
+    0x08,0x5F,0x41,0x44,0x52,0x00,0x08,0x5F,  /* 00000110    "._ADR.._" */
+    0x42,0x42,0x4E,0x00,0x14,0x4E,0x0C,0x5F,  /* 00000118    "BBN..N._" */
+    0x43,0x52,0x53,0x00,0x08,0x50,0x52,0x54,  /* 00000120    "CRS..PRT" */
+    0x30,0x11,0x42,0x07,0x0A,0x6E,0x88,0x0D,  /* 00000128    "0.B..n.." */
+    0x00,0x02,0x0E,0x00,0x00,0x00,0x00,0x00,  /* 00000130    "........" */
+    0xFF,0x00,0x00,0x00,0x00,0x01,0x47,0x01,  /* 00000138    "......G." */
+    0xF8,0x0C,0xF8,0x0C,0x01,0x08,0x88,0x0D,  /* 00000140    "........" */
+    0x00,0x01,0x0C,0x03,0x00,0x00,0x00,0x00,  /* 00000148    "........" */
+    0xF7,0x0C,0x00,0x00,0xF8,0x0C,0x88,0x0D,  /* 00000150    "........" */
+    0x00,0x01,0x0C,0x03,0x00,0x00,0x00,0x0D,  /* 00000158    "........" */
+    0xFF,0xFF,0x00,0x00,0x00,0xF3,0x87,0x17,  /* 00000160    "........" */
+    0x00,0x00,0x0C,0x03,0x00,0x00,0x00,0x00,  /* 00000168    "........" */
+    0x00,0x00,0x0A,0x00,0xFF,0xFF,0x0B,0x00,  /* 00000170    "........" */
+    0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,  /* 00000178    "........" */
+    0x87,0x17,0x00,0x00,0x0C,0x03,0x00,0x00,  /* 00000180    "........" */
+    0x00,0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,  /* 00000188    "........" */
+    0xFF,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000190    "........" */
+    0x00,0x05,0x79,0x00,0x8A,0x50,0x52,0x54,  /* 00000198    "..y..PRT" */
+    0x30,0x0A,0x5C,0x4D,0x4D,0x49,0x4E,0x8A,  /* 000001A0    "0.\MMIN." */
+    0x50,0x52,0x54,0x30,0x0A,0x60,0x4D,0x4D,  /* 000001A8    "PRT0.`MM" */
+    0x41,0x58,0x8A,0x50,0x52,0x54,0x30,0x0A,  /* 000001B0    "AX.PRT0." */
+    0x68,0x4D,0x4C,0x45,0x4E,0x70,0x50,0x4D,  /* 000001B8    "hMLENpPM" */
+    0x49,0x4E,0x4D,0x4D,0x49,0x4E,0x70,0x50,  /* 000001C0    "INMMINpP" */
+    0x4C,0x45,0x4E,0x4D,0x4C,0x45,0x4E,0x72,  /* 000001C8    "LENMLENr" */
+    0x4D,0x4D,0x49,0x4E,0x4D,0x4C,0x45,0x4E,  /* 000001D0    "MMINMLEN" */
+    0x4D,0x4D,0x41,0x58,0x74,0x4D,0x4D,0x41,  /* 000001D8    "MMAXtMMA" */
+    0x58,0x01,0x4D,0x4D,0x41,0x58,0xA4,0x50,  /* 000001E0    "X.MMAX.P" */
+    0x52,0x54,0x30,0x08,0x42,0x55,0x46,0x41,  /* 000001E8    "RT0.BUFA" */
+    0x11,0x09,0x0A,0x06,0x23,0x20,0x0C,0x18,  /* 000001F0    "....# .." */
+    0x79,0x00,0x08,0x42,0x55,0x46,0x42,0x11,  /* 000001F8    "y..BUFB." */
+    0x09,0x0A,0x06,0x23,0x00,0x00,0x18,0x79,  /* 00000200    "...#...y" */
+    0x00,0x8B,0x42,0x55,0x46,0x42,0x01,0x49,  /* 00000208    "..BUFB.I" */
+    0x52,0x51,0x56,0x5B,0x82,0x48,0x08,0x4C,  /* 00000210    "RQV[.H.L" */
+    0x4E,0x4B,0x41,0x08,0x5F,0x48,0x49,0x44,  /* 00000218    "NKA._HID" */
+    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 00000220    ".A...._U" */
+    0x49,0x44,0x01,0x14,0x1C,0x5F,0x53,0x54,  /* 00000228    "ID..._ST" */
+    0x41,0x00,0x7B,0x50,0x49,0x52,0x41,0x0A,  /* 00000230    "A.{PIRA." */
+    0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,0x80,  /* 00000238    ".`...`.." */
+    0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,0x0B,  /* 00000240    "........" */
+    0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,0xA4,  /* 00000248    ".._PRS.." */
+    0x42,0x55,0x46,0x41,0x14,0x11,0x5F,0x44,  /* 00000250    "BUFA.._D" */
+    0x49,0x53,0x00,0x7D,0x50,0x49,0x52,0x41,  /* 00000258    "IS.}PIRA" */
+    0x0A,0x80,0x50,0x49,0x52,0x41,0x14,0x1A,  /* 00000260    "..PIRA.." */
+    0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,0x49,  /* 00000268    "_CRS.{PI" */
+    0x52,0x41,0x0A,0x0F,0x60,0x79,0x01,0x60,  /* 00000270    "RA..`y.`" */
+    0x49,0x52,0x51,0x56,0xA4,0x42,0x55,0x46,  /* 00000278    "IRQV.BUF" */
+    0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,  /* 00000280    "B.._SRS." */
+    0x8B,0x68,0x01,0x49,0x52,0x51,0x31,0x82,  /* 00000288    ".h.IRQ1." */
+    0x49,0x52,0x51,0x31,0x60,0x76,0x60,0x70,  /* 00000290    "IRQ1`v`p" */
+    0x60,0x50,0x49,0x52,0x41,0x5B,0x82,0x49,  /* 00000298    "`PIRA[.I" */
+    0x08,0x4C,0x4E,0x4B,0x42,0x08,0x5F,0x48,  /* 000002A0    ".LNKB._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,  /* 000002A8    "ID.A...." */
+    0x5F,0x55,0x49,0x44,0x0A,0x02,0x14,0x1C,  /* 000002B0    "_UID...." */
+    0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,0x49,  /* 000002B8    "_STA.{PI" */
+    0x52,0x42,0x0A,0x80,0x60,0xA0,0x08,0x93,  /* 000002C0    "RB..`..." */
+    0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,0x04,  /* 000002C8    "`......." */
+    0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,0x52,  /* 000002D0    "....._PR" */
+    0x53,0x00,0xA4,0x42,0x55,0x46,0x41,0x14,  /* 000002D8    "S..BUFA." */
+    0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,  /* 000002E0    "._DIS.}P" */
+    0x49,0x52,0x42,0x0A,0x80,0x50,0x49,0x52,  /* 000002E8    "IRB..PIR" */
+    0x42,0x14,0x1A,0x5F,0x43,0x52,0x53,0x00,  /* 000002F0    "B.._CRS." */
+    0x7B,0x50,0x49,0x52,0x42,0x0A,0x0F,0x60,  /* 000002F8    "{PIRB..`" */
+    0x79,0x01,0x60,0x49,0x52,0x51,0x56,0xA4,  /* 00000300    "y.`IRQV." */
+    0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,0x53,  /* 00000308    "BUFB.._S" */
+    0x52,0x53,0x01,0x8B,0x68,0x01,0x49,0x52,  /* 00000310    "RS..h.IR" */
+    0x51,0x31,0x82,0x49,0x52,0x51,0x31,0x60,  /* 00000318    "Q1.IRQ1`" */
+    0x76,0x60,0x70,0x60,0x50,0x49,0x52,0x42,  /* 00000320    "v`p`PIRB" */
+    0x5B,0x82,0x49,0x08,0x4C,0x4E,0x4B,0x43,  /* 00000328    "[.I.LNKC" */
+    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000330    "._HID.A." */
+    0x0C,0x0F,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 00000338    "..._UID." */
+    0x03,0x14,0x1C,0x5F,0x53,0x54,0x41,0x00,  /* 00000340    "..._STA." */
+    0x7B,0x50,0x49,0x52,0x43,0x0A,0x80,0x60,  /* 00000348    "{PIRC..`" */
+    0xA0,0x08,0x93,0x60,0x0A,0x80,0xA4,0x0A,  /* 00000350    "...`...." */
+    0x09,0xA1,0x04,0xA4,0x0A,0x0B,0x14,0x0B,  /* 00000358    "........" */
+    0x5F,0x50,0x52,0x53,0x00,0xA4,0x42,0x55,  /* 00000360    "_PRS..BU" */
+    0x46,0x41,0x14,0x11,0x5F,0x44,0x49,0x53,  /* 00000368    "FA.._DIS" */
+    0x00,0x7D,0x50,0x49,0x52,0x43,0x0A,0x80,  /* 00000370    ".}PIRC.." */
+    0x50,0x49,0x52,0x43,0x14,0x1A,0x5F,0x43,  /* 00000378    "PIRC.._C" */
+    0x52,0x53,0x00,0x7B,0x50,0x49,0x52,0x43,  /* 00000380    "RS.{PIRC" */
+    0x0A,0x0F,0x60,0x79,0x01,0x60,0x49,0x52,  /* 00000388    "..`y.`IR" */
+    0x51,0x56,0xA4,0x42,0x55,0x46,0x42,0x14,  /* 00000390    "QV.BUFB." */
+    0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,  /* 00000398    "._SRS..h" */
+    0x01,0x49,0x52,0x51,0x31,0x82,0x49,0x52,  /* 000003A0    ".IRQ1.IR" */
+    0x51,0x31,0x60,0x76,0x60,0x70,0x60,0x50,  /* 000003A8    "Q1`v`p`P" */
+    0x49,0x52,0x43,0x5B,0x82,0x49,0x08,0x4C,  /* 000003B0    "IRC[.I.L" */
+    0x4E,0x4B,0x44,0x08,0x5F,0x48,0x49,0x44,  /* 000003B8    "NKD._HID" */
+    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 000003C0    ".A...._U" */
+    0x49,0x44,0x0A,0x04,0x14,0x1C,0x5F,0x53,  /* 000003C8    "ID...._S" */
+    0x54,0x41,0x00,0x7B,0x50,0x49,0x52,0x44,  /* 000003D0    "TA.{PIRD" */
+    0x0A,0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,  /* 000003D8    "..`...`." */
+    0x80,0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,  /* 000003E0    "........" */
+    0x0B,0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,  /* 000003E8    "..._PRS." */
+    0xA4,0x42,0x55,0x46,0x41,0x14,0x11,0x5F,  /* 000003F0    ".BUFA.._" */
+    0x44,0x49,0x53,0x00,0x7D,0x50,0x49,0x52,  /* 000003F8    "DIS.}PIR" */
+    0x44,0x0A,0x80,0x50,0x49,0x52,0x44,0x14,  /* 00000400    "D..PIRD." */
+    0x1A,0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,  /* 00000408    "._CRS.{P" */
+    0x49,0x52,0x44,0x0A,0x0F,0x60,0x79,0x01,  /* 00000410    "IRD..`y." */
+    0x60,0x49,0x52,0x51,0x56,0xA4,0x42,0x55,  /* 00000418    "`IRQV.BU" */
+    0x46,0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,  /* 00000420    "FB.._SRS" */
+    0x01,0x8B,0x68,0x01,0x49,0x52,0x51,0x31,  /* 00000428    "..h.IRQ1" */
+    0x82,0x49,0x52,0x51,0x31,0x60,0x76,0x60,  /* 00000430    ".IRQ1`v`" */
+    0x70,0x60,0x50,0x49,0x52,0x44,0x5B,0x82,  /* 00000438    "p`PIRD[." */
+    0x3A,0x48,0x50,0x45,0x54,0x08,0x5F,0x48,  /* 00000440    ":HPET._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x01,0x03,0x08,  /* 00000448    "ID.A...." */
+    0x5F,0x55,0x49,0x44,0x00,0x08,0x5F,0x43,  /* 00000450    "_UID.._C" */
+    0x52,0x53,0x11,0x1F,0x0A,0x1C,0x87,0x17,  /* 00000458    "RS......" */
+    0x00,0x00,0x0D,0x01,0x00,0x00,0x00,0x00,  /* 00000460    "........" */
+    0x00,0x00,0xD0,0xFE,0xFF,0x03,0xD0,0xFE,  /* 00000468    "........" */
+    0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,  /* 00000470    "........" */
+    0x79,0x00,0x14,0x16,0x5F,0x50,0x52,0x54,  /* 00000478    "y..._PRT" */
+    0x00,0xA0,0x0A,0x50,0x49,0x43,0x44,0xA4,  /* 00000480    "...PICD." */
+    0x50,0x52,0x54,0x41,0xA4,0x50,0x52,0x54,  /* 00000488    "PRTA.PRT" */
+    0x50,0x08,0x50,0x52,0x54,0x50,0x12,0x49,  /* 00000490    "P.PRTP.I" */
+    0x36,0x3C,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000498    "6<......" */
+    0x01,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 000004A0    "...LNKB." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 000004A8    "........" */
+    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 000004B0    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x02,  /* 000004B8    "........" */
+    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 000004C0    "LNKD...." */
+    0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,0x4C,  /* 000004C8    ".......L" */
+    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 000004D0    "NKA....." */
+    0xFF,0xFF,0x02,0x00,0x00,0x4C,0x4E,0x4B,  /* 000004D8    ".....LNK" */
+    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000004E0    "C......." */
+    0x02,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 000004E8    "...LNKD." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 000004F0    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 000004F8    "..LNKA.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x0A,  /* 00000500    "........" */
+    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000508    ".LNKB..." */
+    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x00,0x4C,  /* 00000510    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000518    "NKD....." */
+    0xFF,0xFF,0x03,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000520    ".....LNK" */
+    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000528    "A......." */
+    0x03,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000530    "....LNKB" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000538    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000540    "...LNKC." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000548    "........" */
+    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000550    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x04,0x00,0x01,0x4C,  /* 00000558    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 00000560    "NKB....." */
+    0xFF,0xFF,0x04,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000568    "......LN" */
+    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000570    "KC......" */
+    0xFF,0x04,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000578    ".....LNK" */
+    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000580    "D......." */
+    0x05,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000588    "...LNKB." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x05,0x00,  /* 00000590    "........" */
+    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000598    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x02,  /* 000005A0    "........" */
+    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 000005A8    "LNKD...." */
+    0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x03,0x4C,  /* 000005B0    ".......L" */
+    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 000005B8    "NKA....." */
+    0xFF,0xFF,0x06,0x00,0x00,0x4C,0x4E,0x4B,  /* 000005C0    ".....LNK" */
+    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000005C8    "C......." */
+    0x06,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 000005D0    "...LNKD." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 000005D8    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 000005E0    "..LNKA.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x0A,  /* 000005E8    "........" */
+    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 000005F0    ".LNKB..." */
+    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x00,0x4C,  /* 000005F8    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000600    "NKD....." */
+    0xFF,0xFF,0x07,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000608    ".....LNK" */
+    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000610    "A......." */
+    0x07,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000618    "....LNKB" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x07,  /* 00000620    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000628    "...LNKC." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 00000630    "........" */
+    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000638    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x08,0x00,0x01,0x4C,  /* 00000640    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 00000648    "NKB....." */
+    0xFF,0xFF,0x08,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000650    "......LN" */
+    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000658    "KC......" */
+    0xFF,0x08,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000660    ".....LNK" */
+    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000668    "D......." */
+    0x09,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000670    "...LNKB." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x09,0x00,  /* 00000678    "........" */
+    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000680    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x02,  /* 00000688    "........" */
+    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000690    "LNKD...." */
+    0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x03,0x4C,  /* 00000698    ".......L" */
+    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 000006A0    "NKA....." */
+    0xFF,0xFF,0x0A,0x00,0x00,0x4C,0x4E,0x4B,  /* 000006A8    ".....LNK" */
+    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006B0    "C......." */
+    0x0A,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 000006B8    "...LNKD." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 000006C0    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 000006C8    "..LNKA.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x0A,  /* 000006D0    "........" */
+    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 000006D8    ".LNKB..." */
+    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x00,0x4C,  /* 000006E0    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 000006E8    "NKD....." */
+    0xFF,0xFF,0x0B,0x00,0x01,0x4C,0x4E,0x4B,  /* 000006F0    ".....LNK" */
+    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 000006F8    "A......." */
+    0x0B,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000700    "....LNKB" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0B,  /* 00000708    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000710    "...LNKC." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 00000718    "........" */
+    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 00000720    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x01,0x4C,  /* 00000728    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 00000730    "NKB....." */
+    0xFF,0xFF,0x0C,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000738    "......LN" */
+    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000740    "KC......" */
+    0xFF,0x0C,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000748    ".....LNK" */
+    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000750    "D......." */
+    0x0D,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000758    "...LNKB." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0D,0x00,  /* 00000760    "........" */
+    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000768    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x02,  /* 00000770    "........" */
+    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000778    "LNKD...." */
+    0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x03,0x4C,  /* 00000780    ".......L" */
+    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000788    "NKA....." */
+    0xFF,0xFF,0x0E,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000790    ".....LNK" */
+    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000798    "C......." */
+    0x0E,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 000007A0    "...LNKD." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 000007A8    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 000007B0    "..LNKA.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x0A,  /* 000007B8    "........" */
+    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 000007C0    ".LNKB..." */
+    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x00,0x4C,  /* 000007C8    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 000007D0    "NKD....." */
+    0xFF,0xFF,0x0F,0x00,0x01,0x4C,0x4E,0x4B,  /* 000007D8    ".....LNK" */
+    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 000007E0    "A......." */
+    0x0F,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 000007E8    "....LNKB" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0F,  /* 000007F0    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 000007F8    "...LNKC." */
+    0x08,0x50,0x52,0x54,0x41,0x12,0x41,0x2F,  /* 00000800    ".PRTA.A/" */
+    0x3C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000808    "<......." */
+    0x00,0x00,0x00,0x0A,0x14,0x12,0x0B,0x04,  /* 00000810    "........" */
+    0x0C,0xFF,0xFF,0x01,0x00,0x01,0x00,0x0A,  /* 00000818    "........" */
+    0x15,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000820    "........" */
+    0x00,0x0A,0x02,0x00,0x0A,0x16,0x12,0x0C,  /* 00000828    "........" */
+    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,  /* 00000830    "........" */
+    0x00,0x0A,0x17,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000838    "........" */
+    0xFF,0x02,0x00,0x00,0x00,0x0A,0x18,0x12,  /* 00000840    "........" */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,  /* 00000848    "........" */
+    0x00,0x0A,0x19,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000850    "........" */
+    0xFF,0x02,0x00,0x0A,0x02,0x00,0x0A,0x1A,  /* 00000858    "........" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000860    "........" */
+    0x0A,0x03,0x00,0x0A,0x1B,0x12,0x0B,0x04,  /* 00000868    "........" */
+    0x0C,0xFF,0xFF,0x03,0x00,0x00,0x00,0x0A,  /* 00000870    "........" */
+    0x1C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000878    "........" */
+    0x00,0x01,0x00,0x0A,0x1D,0x12,0x0C,0x04,  /* 00000880    "........" */
+    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,0x00,  /* 00000888    "........" */
+    0x0A,0x1E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000890    "........" */
+    0x03,0x00,0x0A,0x03,0x00,0x0A,0x1F,0x12,  /* 00000898    "........" */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x00,  /* 000008A0    "........" */
+    0x00,0x0A,0x20,0x12,0x0B,0x04,0x0C,0xFF,  /* 000008A8    ".. ....." */
+    0xFF,0x04,0x00,0x01,0x00,0x0A,0x21,0x12,  /* 000008B0    "......!." */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,  /* 000008B8    "........" */
+    0x02,0x00,0x0A,0x22,0x12,0x0C,0x04,0x0C,  /* 000008C0    "..."...." */
+    0xFF,0xFF,0x04,0x00,0x0A,0x03,0x00,0x0A,  /* 000008C8    "........" */
+    0x23,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x05,  /* 000008D0    "#......." */
+    0x00,0x00,0x00,0x0A,0x24,0x12,0x0B,0x04,  /* 000008D8    "....$..." */
+    0x0C,0xFF,0xFF,0x05,0x00,0x01,0x00,0x0A,  /* 000008E0    "........" */
+    0x25,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x05,  /* 000008E8    "%......." */
+    0x00,0x0A,0x02,0x00,0x0A,0x26,0x12,0x0C,  /* 000008F0    ".....&.." */
+    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x03,  /* 000008F8    "........" */
+    0x00,0x0A,0x27,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000900    "..'....." */
+    0xFF,0x06,0x00,0x00,0x00,0x0A,0x28,0x12,  /* 00000908    "......(." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x01,  /* 00000910    "........" */
+    0x00,0x0A,0x29,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000918    "..)....." */
+    0xFF,0x06,0x00,0x0A,0x02,0x00,0x0A,0x2A,  /* 00000920    ".......*" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 00000928    "........" */
+    0x0A,0x03,0x00,0x0A,0x2B,0x12,0x0B,0x04,  /* 00000930    "....+..." */
+    0x0C,0xFF,0xFF,0x07,0x00,0x00,0x00,0x0A,  /* 00000938    "........" */
+    0x2C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x07,  /* 00000940    ",......." */
+    0x00,0x01,0x00,0x0A,0x2D,0x12,0x0C,0x04,  /* 00000948    "....-..." */
+    0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x02,0x00,  /* 00000950    "........" */
+    0x0A,0x2E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000958    "........" */
+    0x07,0x00,0x0A,0x03,0x00,0x0A,0x2F,0x12,  /* 00000960    "....../." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x00,  /* 00000968    "........" */
+    0x00,0x0A,0x11,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000970    "........" */
+    0xFF,0x08,0x00,0x01,0x00,0x0A,0x12,0x12,  /* 00000978    "........" */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,  /* 00000980    "........" */
+    0x02,0x00,0x0A,0x13,0x12,0x0C,0x04,0x0C,  /* 00000988    "........" */
+    0xFF,0xFF,0x08,0x00,0x0A,0x03,0x00,0x0A,  /* 00000990    "........" */
+    0x14,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000998    "........" */
+    0x00,0x00,0x00,0x0A,0x15,0x12,0x0B,0x04,  /* 000009A0    "........" */
+    0x0C,0xFF,0xFF,0x09,0x00,0x01,0x00,0x0A,  /* 000009A8    "........" */
+    0x16,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x09,  /* 000009B0    "........" */
+    0x00,0x0A,0x02,0x00,0x0A,0x17,0x12,0x0C,  /* 000009B8    "........" */
+    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x03,  /* 000009C0    "........" */
+    0x00,0x0A,0x18,0x12,0x0B,0x04,0x0C,0xFF,  /* 000009C8    "........" */
+    0xFF,0x0A,0x00,0x00,0x00,0x0A,0x19,0x12,  /* 000009D0    "........" */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x01,  /* 000009D8    "........" */
+    0x00,0x0A,0x1A,0x12,0x0C,0x04,0x0C,0xFF,  /* 000009E0    "........" */
+    0xFF,0x0A,0x00,0x0A,0x02,0x00,0x0A,0x1B,  /* 000009E8    "........" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 000009F0    "........" */
+    0x0A,0x03,0x00,0x0A,0x1C,0x12,0x0B,0x04,  /* 000009F8    "........" */
+    0x0C,0xFF,0xFF,0x0B,0x00,0x00,0x00,0x0A,  /* 00000A00    "........" */
+    0x1D,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0B,  /* 00000A08    "........" */
+    0x00,0x01,0x00,0x0A,0x1E,0x12,0x0C,0x04,  /* 00000A10    "........" */
+    0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x02,0x00,  /* 00000A18    "........" */
+    0x0A,0x1F,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000A20    "........" */
+    0x0B,0x00,0x0A,0x03,0x00,0x0A,0x20,0x12,  /* 00000A28    "...... ." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x00,  /* 00000A30    "........" */
+    0x00,0x0A,0x21,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A38    "..!....." */
+    0xFF,0x0C,0x00,0x01,0x00,0x0A,0x22,0x12,  /* 00000A40    "......"." */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,  /* 00000A48    "........" */
+    0x02,0x00,0x0A,0x23,0x12,0x0C,0x04,0x0C,  /* 00000A50    "...#...." */
+    0xFF,0xFF,0x0C,0x00,0x0A,0x03,0x00,0x0A,  /* 00000A58    "........" */
+    0x24,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000A60    "$......." */
+    0x00,0x00,0x00,0x0A,0x25,0x12,0x0B,0x04,  /* 00000A68    "....%..." */
+    0x0C,0xFF,0xFF,0x0D,0x00,0x01,0x00,0x0A,  /* 00000A70    "........" */
+    0x26,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000A78    "&......." */
+    0x00,0x0A,0x02,0x00,0x0A,0x27,0x12,0x0C,  /* 00000A80    ".....'.." */
+    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x03,  /* 00000A88    "........" */
+    0x00,0x0A,0x28,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A90    "..(....." */
+    0xFF,0x0E,0x00,0x00,0x00,0x0A,0x29,0x12,  /* 00000A98    "......)." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x01,  /* 00000AA0    "........" */
+    0x00,0x0A,0x2A,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000AA8    "..*....." */
+    0xFF,0x0E,0x00,0x0A,0x02,0x00,0x0A,0x2B,  /* 00000AB0    ".......+" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000AB8    "........" */
+    0x0A,0x03,0x00,0x0A,0x2C,0x12,0x0B,0x04,  /* 00000AC0    "....,..." */
+    0x0C,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x0A,  /* 00000AC8    "........" */
+    0x2D,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000AD0    "-......." */
+    0x00,0x01,0x00,0x0A,0x2E,0x12,0x0C,0x04,  /* 00000AD8    "........" */
+    0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x02,0x00,  /* 00000AE0    "........" */
+    0x0A,0x2F,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000AE8    "./......" */
+    0x0F,0x00,0x0A,0x03,0x00,0x0A,0x10,0x5B,  /* 00000AF0    ".......[" */
+    0x82,0x46,0x37,0x49,0x53,0x41,0x5F,0x08,  /* 00000AF8    ".F7ISA_." */
+    0x5F,0x41,0x44,0x52,0x0C,0x00,0x00,0x01,  /* 00000B00    "_ADR...." */
+    0x00,0x5B,0x80,0x50,0x49,0x52,0x51,0x02,  /* 00000B08    ".[.PIRQ." */
+    0x0A,0x60,0x0A,0x04,0x10,0x2E,0x5C,0x00,  /* 00000B10    ".`....\." */
+    0x5B,0x81,0x29,0x5C,0x2F,0x04,0x5F,0x53,  /* 00000B18    "[.)\/._S" */
+    0x42,0x5F,0x50,0x43,0x49,0x30,0x49,0x53,  /* 00000B20    "B_PCI0IS" */
+    0x41,0x5F,0x50,0x49,0x52,0x51,0x01,0x50,  /* 00000B28    "A_PIRQ.P" */
+    0x49,0x52,0x41,0x08,0x50,0x49,0x52,0x42,  /* 00000B30    "IRA.PIRB" */
+    0x08,0x50,0x49,0x52,0x43,0x08,0x50,0x49,  /* 00000B38    ".PIRC.PI" */
+    0x52,0x44,0x08,0x5B,0x82,0x46,0x0B,0x53,  /* 00000B40    "RD.[.F.S" */
+    0x59,0x53,0x52,0x08,0x5F,0x48,0x49,0x44,  /* 00000B48    "YSR._HID" */
+    0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x55,  /* 00000B50    ".A...._U" */
+    0x49,0x44,0x01,0x08,0x43,0x52,0x53,0x5F,  /* 00000B58    "ID..CRS_" */
+    0x11,0x4E,0x08,0x0A,0x8A,0x47,0x01,0x10,  /* 00000B60    ".N...G.." */
+    0x00,0x10,0x00,0x00,0x10,0x47,0x01,0x22,  /* 00000B68    ".....G."" */
+    0x00,0x22,0x00,0x00,0x0C,0x47,0x01,0x30,  /* 00000B70    "."...G.0" */
+    0x00,0x30,0x00,0x00,0x10,0x47,0x01,0x44,  /* 00000B78    ".0...G.D" */
+    0x00,0x44,0x00,0x00,0x1C,0x47,0x01,0x62,  /* 00000B80    ".D...G.b" */
+    0x00,0x62,0x00,0x00,0x02,0x47,0x01,0x65,  /* 00000B88    ".b...G.e" */
+    0x00,0x65,0x00,0x00,0x0B,0x47,0x01,0x72,  /* 00000B90    ".e...G.r" */
+    0x00,0x72,0x00,0x00,0x0E,0x47,0x01,0x80,  /* 00000B98    ".r...G.." */
+    0x00,0x80,0x00,0x00,0x01,0x47,0x01,0x84,  /* 00000BA0    ".....G.." */
+    0x00,0x84,0x00,0x00,0x03,0x47,0x01,0x88,  /* 00000BA8    ".....G.." */
+    0x00,0x88,0x00,0x00,0x01,0x47,0x01,0x8C,  /* 00000BB0    ".....G.." */
+    0x00,0x8C,0x00,0x00,0x03,0x47,0x01,0x90,  /* 00000BB8    ".....G.." */
+    0x00,0x90,0x00,0x00,0x10,0x47,0x01,0xA2,  /* 00000BC0    ".....G.." */
+    0x00,0xA2,0x00,0x00,0x1C,0x47,0x01,0xE0,  /* 00000BC8    ".....G.." */
+    0x00,0xE0,0x00,0x00,0x10,0x47,0x01,0xA0,  /* 00000BD0    ".....G.." */
+    0x08,0xA0,0x08,0x00,0x04,0x47,0x01,0xC0,  /* 00000BD8    ".....G.." */
+    0x0C,0xC0,0x0C,0x00,0x10,0x47,0x01,0xD0,  /* 00000BE0    ".....G.." */
+    0x04,0xD0,0x04,0x00,0x02,0x79,0x00,0x14,  /* 00000BE8    ".....y.." */
+    0x0B,0x5F,0x43,0x52,0x53,0x00,0xA4,0x43,  /* 00000BF0    "._CRS..C" */
+    0x52,0x53,0x5F,0x5B,0x82,0x2B,0x50,0x49,  /* 00000BF8    "RS_[.+PI" */
+    0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,0x0B,  /* 00000C00    "C_._HID." */
+    0x41,0xD0,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000C08    "A.._CRS." */
+    0x18,0x0A,0x15,0x47,0x01,0x20,0x00,0x20,  /* 00000C10    "...G. . " */
+    0x00,0x01,0x02,0x47,0x01,0xA0,0x00,0xA0,  /* 00000C18    "...G...." */
+    0x00,0x01,0x02,0x22,0x04,0x00,0x79,0x00,  /* 00000C20    "..."..y." */
+    0x5B,0x82,0x47,0x05,0x44,0x4D,0x41,0x30,  /* 00000C28    "[.G.DMA0" */
+    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000C30    "._HID.A." */
+    0x02,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000C38    "..._CRS." */
+    0x41,0x04,0x0A,0x3D,0x2A,0x10,0x04,0x47,  /* 00000C40    "A..=*..G" */
+    0x01,0x00,0x00,0x00,0x00,0x00,0x10,0x47,  /* 00000C48    ".......G" */
+    0x01,0x81,0x00,0x81,0x00,0x00,0x03,0x47,  /* 00000C50    ".......G" */
+    0x01,0x87,0x00,0x87,0x00,0x00,0x01,0x47,  /* 00000C58    ".......G" */
+    0x01,0x89,0x00,0x89,0x00,0x00,0x03,0x47,  /* 00000C60    ".......G" */
+    0x01,0x8F,0x00,0x8F,0x00,0x00,0x01,0x47,  /* 00000C68    ".......G" */
+    0x01,0xC0,0x00,0xC0,0x00,0x00,0x20,0x47,  /* 00000C70    "...... G" */
+    0x01,0x80,0x04,0x80,0x04,0x00,0x10,0x79,  /* 00000C78    ".......y" */
+    0x00,0x5B,0x82,0x25,0x54,0x4D,0x52,0x5F,  /* 00000C80    ".[.%TMR_" */
+    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000C88    "._HID.A." */
+    0x01,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000C90    "..._CRS." */
+    0x10,0x0A,0x0D,0x47,0x01,0x40,0x00,0x40,  /* 00000C98    "...G.@.@" */
+    0x00,0x00,0x04,0x22,0x01,0x00,0x79,0x00,  /* 00000CA0    "..."..y." */
+    0x5B,0x82,0x25,0x52,0x54,0x43,0x5F,0x08,  /* 00000CA8    "[.%RTC_." */
+    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0B,  /* 00000CB0    "_HID.A.." */
+    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000CB8    ".._CRS.." */
+    0x0A,0x0D,0x47,0x01,0x70,0x00,0x70,0x00,  /* 00000CC0    "..G.p.p." */
+    0x00,0x02,0x22,0x00,0x01,0x79,0x00,0x5B,  /* 00000CC8    ".."..y.[" */
+    0x82,0x22,0x53,0x50,0x4B,0x52,0x08,0x5F,  /* 00000CD0    "."SPKR._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x08,0x00,  /* 00000CD8    "HID.A..." */
+    0x08,0x5F,0x43,0x52,0x53,0x11,0x0D,0x0A,  /* 00000CE0    "._CRS..." */
+    0x0A,0x47,0x01,0x61,0x00,0x61,0x00,0x00,  /* 00000CE8    ".G.a.a.." */
+    0x01,0x79,0x00,0x5B,0x82,0x31,0x50,0x53,  /* 00000CF0    ".y.[.1PS" */
+    0x32,0x4D,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000CF8    "2M._HID." */
+    0x41,0xD0,0x0F,0x13,0x08,0x5F,0x43,0x49,  /* 00000D00    "A...._CI" */
+    0x44,0x0C,0x41,0xD0,0x0F,0x13,0x14,0x09,  /* 00000D08    "D.A....." */
+    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 00000D10    "_STA...." */
+    0x08,0x5F,0x43,0x52,0x53,0x11,0x08,0x0A,  /* 00000D18    "._CRS..." */
+    0x05,0x22,0x00,0x10,0x79,0x00,0x5B,0x82,  /* 00000D20    "."..y.[." */
+    0x42,0x04,0x50,0x53,0x32,0x4B,0x08,0x5F,  /* 00000D28    "B.PS2K._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x03,0x03,  /* 00000D30    "HID.A..." */
+    0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,0xD0,  /* 00000D38    "._CID.A." */
+    0x03,0x0B,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000D40    "...._STA" */
+    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 00000D48    "....._CR" */
+    0x53,0x11,0x18,0x0A,0x15,0x47,0x01,0x60,  /* 00000D50    "S....G.`" */
+    0x00,0x60,0x00,0x00,0x01,0x47,0x01,0x64,  /* 00000D58    ".`...G.d" */
+    0x00,0x64,0x00,0x00,0x01,0x22,0x02,0x00,  /* 00000D60    ".d...".." */
+    0x79,0x00,0x5B,0x82,0x3A,0x46,0x44,0x43,  /* 00000D68    "y.[.:FDC" */
+    0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000D70    "0._HID.A" */
+    0xD0,0x07,0x00,0x14,0x09,0x5F,0x53,0x54,  /* 00000D78    "....._ST" */
+    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 00000D80    "A....._C" */
+    0x52,0x53,0x11,0x1B,0x0A,0x18,0x47,0x01,  /* 00000D88    "RS....G." */
+    0xF0,0x03,0xF0,0x03,0x01,0x06,0x47,0x01,  /* 00000D90    "......G." */
+    0xF7,0x03,0xF7,0x03,0x01,0x01,0x22,0x40,  /* 00000D98    "......"@" */
+    0x00,0x2A,0x04,0x00,0x79,0x00,0x5B,0x82,  /* 00000DA0    ".*..y.[." */
+    0x46,0x04,0x55,0x41,0x52,0x31,0x08,0x5F,  /* 00000DA8    "F.UAR1._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,  /* 00000DB0    "HID.A..." */
+    0x08,0x5F,0x55,0x49,0x44,0x01,0x14,0x19,  /* 00000DB8    "._UID..." */
+    0x5F,0x53,0x54,0x41,0x00,0xA0,0x0D,0x93,  /* 00000DC0    "_STA...." */
+    0x5E,0x5E,0x5E,0x5E,0x55,0x41,0x52,0x31,  /* 00000DC8    "^^^^UAR1" */
+    0x00,0xA4,0x00,0xA1,0x04,0xA4,0x0A,0x0F,  /* 00000DD0    "........" */
+    0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,  /* 00000DD8    "._CRS..." */
+    0x0D,0x47,0x01,0xF8,0x03,0xF8,0x03,0x08,  /* 00000DE0    ".G......" */
+    0x08,0x22,0x10,0x00,0x79,0x00,0x5B,0x82,  /* 00000DE8    "."..y.[." */
+    0x47,0x04,0x55,0x41,0x52,0x32,0x08,0x5F,  /* 00000DF0    "G.UAR2._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,  /* 00000DF8    "HID.A..." */
+    0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,0x14,  /* 00000E00    "._UID..." */
+    0x19,0x5F,0x53,0x54,0x41,0x00,0xA0,0x0D,  /* 00000E08    "._STA..." */
+    0x93,0x5E,0x5E,0x5E,0x5E,0x55,0x41,0x52,  /* 00000E10    ".^^^^UAR" */
+    0x32,0x00,0xA4,0x00,0xA1,0x04,0xA4,0x0A,  /* 00000E18    "2......." */
+    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000E20    ".._CRS.." */
+    0x0A,0x0D,0x47,0x01,0xF8,0x02,0xF8,0x02,  /* 00000E28    "..G....." */
+    0x08,0x08,0x22,0x08,0x00,0x79,0x00,0x5B,  /* 00000E30    ".."..y.[" */
+    0x82,0x36,0x4C,0x54,0x50,0x31,0x08,0x5F,  /* 00000E38    ".6LTP1._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x04,0x00,  /* 00000E40    "HID.A..." */
+    0x08,0x5F,0x55,0x49,0x44,0x0A,0x02,0x14,  /* 00000E48    "._UID..." */
+    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000E50    "._STA..." */
+    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000E58    ".._CRS.." */
+    0x0A,0x0D,0x47,0x01,0x78,0x03,0x78,0x03,  /* 00000E60    "..G.x.x." */
+    0x08,0x08,0x22,0x80,0x00,0x79,0x00,
 };
 int DsdtLen=sizeof(AmlCode);
diff -r 29268e3fc7ab -r 603ea719d73a tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Jan 22 08:30:40 2008 -0700
@@ -183,10 +183,22 @@ static void apic_setup(void)
 
 static void pci_setup(void)
 {
-    uint32_t devfn, bar_reg, bar_data, bar_sz, cmd;
-    uint32_t *base, io_base = 0xc000, mem_base = HVM_BELOW_4G_MMIO_START;
+    uint32_t base, devfn, bar_reg, bar_data, bar_sz, cmd;
     uint16_t class, vendor_id, device_id;
     unsigned int bar, pin, link, isa_irq;
+
+    /* Resources assignable to PCI devices via BARs. */
+    struct resource {
+        uint32_t base, max;
+    } *resource;
+    struct resource mem_resource = { 0xf0000000, 0xfc000000 };
+    struct resource io_resource  = { 0xc000, 0x10000 };
+
+    /* Create a list of device BARs in descending order of size. */
+    struct bars {
+        uint32_t devfn, bar_reg, bar_sz;
+    } *bars = (struct bars *)0xc0000;
+    unsigned int i, nr_bars = 0;
 
     /* Program PCI-ISA bridge with appropriate link routes. */
     isa_irq = 0;
@@ -242,44 +254,30 @@ static void pci_setup(void)
                     bar_reg = PCI_ROM_ADDRESS;
 
                 bar_data = pci_readl(devfn, bar_reg);
-
                 pci_writel(devfn, bar_reg, ~0);
                 bar_sz = pci_readl(devfn, bar_reg);
+                pci_writel(devfn, bar_reg, bar_data);
                 if ( bar_sz == 0 )
                     continue;
 
-                if ( (bar_data & PCI_BASE_ADDRESS_SPACE) ==
-                     PCI_BASE_ADDRESS_SPACE_MEMORY )
-                {
-                    base = &mem_base;
-                    bar_sz &= PCI_BASE_ADDRESS_MEM_MASK;
-                    bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
-                }
-                else
-                {
-                    base = &io_base;
-                    bar_sz &= PCI_BASE_ADDRESS_IO_MASK & 0xffff;
-                    bar_data &= ~PCI_BASE_ADDRESS_IO_MASK;
-                }
+                bar_sz &= (((bar_data & PCI_BASE_ADDRESS_SPACE) ==
+                           PCI_BASE_ADDRESS_SPACE_MEMORY) ?
+                           PCI_BASE_ADDRESS_MEM_MASK :
+                           (PCI_BASE_ADDRESS_IO_MASK & 0xffff));
                 bar_sz &= ~(bar_sz - 1);
 
-                *base = (*base + bar_sz - 1) & ~(bar_sz - 1);
-                bar_data |= *base;
-                *base += bar_sz;
-
-                pci_writel(devfn, bar_reg, bar_data);
-                printf("pci dev %02x:%x bar %02x size %08x: %08x\n",
-                       devfn>>3, devfn&7, bar_reg, bar_sz, bar_data);
-
-                /* Now enable the memory or I/O mapping. */
-                cmd = pci_readw(devfn, PCI_COMMAND);
-                if ( (bar_reg == PCI_ROM_ADDRESS) ||
-                     ((bar_data & PCI_BASE_ADDRESS_SPACE) ==
-                      PCI_BASE_ADDRESS_SPACE_MEMORY) )
-                    cmd |= PCI_COMMAND_MEMORY;
-                else
-                    cmd |= PCI_COMMAND_IO;
-                pci_writew(devfn, PCI_COMMAND, cmd);
+                for ( i = 0; i < nr_bars; i++ )
+                    if ( bars[i].bar_sz < bar_sz )
+                        break;
+
+                if ( i != nr_bars )
+                    memmove(&bars[i+1], &bars[i], (nr_bars-i) * sizeof(*bars));
+
+                bars[i].devfn   = devfn;
+                bars[i].bar_reg = bar_reg;
+                bars[i].bar_sz  = bar_sz;
+
+                nr_bars++;
             }
             break;
         }
@@ -295,6 +293,55 @@ static void pci_setup(void)
             printf("pci dev %02x:%x INT%c->IRQ%u\n",
                    devfn>>3, devfn&7, 'A'+pin-1, isa_irq);
         }
+    }
+
+    /* Assign iomem and ioport resources in descending order of size. */
+    for ( i = 0; i < nr_bars; i++ )
+    {
+        devfn   = bars[i].devfn;
+        bar_reg = bars[i].bar_reg;
+        bar_sz  = bars[i].bar_sz;
+
+        bar_data = pci_readl(devfn, bar_reg);
+
+        if ( (bar_data & PCI_BASE_ADDRESS_SPACE) ==
+             PCI_BASE_ADDRESS_SPACE_MEMORY )
+        {
+            resource = &mem_resource;
+            bar_data &= ~PCI_BASE_ADDRESS_MEM_MASK;
+        }
+        else
+        {
+            resource = &io_resource;
+            bar_data &= ~PCI_BASE_ADDRESS_IO_MASK;
+        }
+
+        base = (resource->base + bar_sz - 1) & ~(bar_sz - 1);
+        bar_data |= base;
+        base += bar_sz;
+
+        if ( (base < resource->base) || (base > resource->max) )
+        {
+            printf("pci dev %02x:%x bar %02x size %08x: no space for "
+                   "resource!\n", devfn>>3, devfn&7, bar_reg, bar_sz);
+            continue;
+        }
+
+        resource->base = base;
+
+        pci_writel(devfn, bar_reg, bar_data);
+        printf("pci dev %02x:%x bar %02x size %08x: %08x\n",
+               devfn>>3, devfn&7, bar_reg, bar_sz, bar_data);
+
+        /* Now enable the memory or I/O mapping. */
+        cmd = pci_readw(devfn, PCI_COMMAND);
+        if ( (bar_reg == PCI_ROM_ADDRESS) ||
+             ((bar_data & PCI_BASE_ADDRESS_SPACE) ==
+              PCI_BASE_ADDRESS_SPACE_MEMORY) )
+            cmd |= PCI_COMMAND_MEMORY;
+        else
+            cmd |= PCI_COMMAND_IO;
+        pci_writew(devfn, PCI_COMMAND, cmd);
     }
 }
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/flask/libflask/Makefile
--- a/tools/flask/libflask/Makefile     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/flask/libflask/Makefile     Tue Jan 22 08:30:40 2008 -0700
@@ -33,13 +33,13 @@ build:
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) 
$(DESTDIR)/usr/$(LIBDIR)
-       [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
-       $(INSTALL_PROG) libflask.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_DATA) libflask.a $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libflask.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libflask.so.$(MAJOR)
-       ln -sf libflask.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libflask.so
-       $(INSTALL_DATA) include/flask.h $(DESTDIR)/usr/include
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_PROG) libflask.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DATA) libflask.a $(DESTDIR)$(LIBDIR)
+       ln -sf libflask.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libflask.so.$(MAJOR)
+       ln -sf libflask.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libflask.so
+       $(INSTALL_DATA) include/flask.h $(DESTDIR)$(INCLUDEDIR)
 
 .PHONY: TAGS
 TAGS:
diff -r 29268e3fc7ab -r 603ea719d73a tools/flask/loadpolicy/Makefile
--- a/tools/flask/loadpolicy/Makefile   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/flask/loadpolicy/Makefile   Tue Jan 22 08:30:40 2008 -0700
@@ -51,8 +51,8 @@ print-end:
 
 .PHONY: install
 install: all
-       $(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
-       $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/sbin
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(SBINDIR)
 
 -include $(PROG_DEP)
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/fs-back/Makefile
--- a/tools/fs-back/Makefile    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/fs-back/Makefile    Tue Jan 22 08:30:40 2008 -0700
@@ -4,7 +4,6 @@ INCLUDES += -I.. -I../lib
 INCLUDES += -I.. -I../lib
 
 IBIN         = fs-backend 
-INST_DIR     = /usr/sbin
 
 CFLAGS   += -Werror
 CFLAGS   += -Wno-unused
@@ -30,7 +29,7 @@ fs-backend: $(OBJS) fs-backend.c
        $(CC) $(CFLAGS) -o fs-backend $(OBJS) $(LIBS) fs-backend.c
 
 install: all
-       $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR)
+       $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(SBINDIR)
 
 clean:
        rm -rf *.o *~ $(DEPS) xen $(IBIN) $(LIB)
diff -r 29268e3fc7ab -r 603ea719d73a tools/guest-headers/Makefile
--- a/tools/guest-headers/Makefile      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/guest-headers/Makefile      Tue Jan 22 08:30:40 2008 -0700
@@ -10,8 +10,8 @@ check:
 .PHONY: install
 
 install:
-       mkdir -p $(DESTDIR)/usr/include/xen/sys
-       $(INSTALL_DATA) $(XEN_ROOT)/tools/include/$(XEN_OS)/*.h 
$(DESTDIR)/usr/include/xen/sys
+       mkdir -p $(DESTDIR)$(INCLUDEDIR)/xen/sys
+       $(INSTALL_DATA) $(XEN_ROOT)/tools/include/$(XEN_OS)/*.h 
$(DESTDIR)$(INCLUDEDIR)/xen/sys
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/ioemu/configure
--- a/tools/ioemu/configure     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/ioemu/configure     Tue Jan 22 08:30:40 2008 -0700
@@ -29,43 +29,15 @@ make="make"
 make="make"
 install="install"
 strip="strip"
-cpu=`uname -m`
 target_list=""
-case "$cpu" in
-  i386|i486|i586|i686|i86pc|BePC)
+case "$XEN_TARGET_ARCH" in
+  x86_32)
     cpu="i386"
   ;;
-  armv*b)
-    cpu="armv4b"
-  ;;
-  armv*l)
-    cpu="armv4l"
-  ;;
-  alpha)
-    cpu="alpha"
-  ;;
-  "Power Macintosh"|ppc|ppc64)
+  powerpc)
     cpu="powerpc"
   ;;
-  mips)
-    cpu="mips"
-  ;;
-  s390)
-    cpu="s390"
-  ;;
-  sparc|sun4[muv])
-    cpu="sparc"
-  ;;
-  sparc64)
-    cpu="sparc64"
-  ;;
-  ia64)
-    cpu="ia64"
-  ;;
-  m68k)
-    cpu="m68k"
-  ;;
-  x86_64|amd64)
+  x86_64)
     cpu="x86_64"
     libdir="lib64"
   ;;
diff -r 29268e3fc7ab -r 603ea719d73a tools/ioemu/hw/ide.c
--- a/tools/ioemu/hw/ide.c      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/ioemu/hw/ide.c      Tue Jan 22 08:30:40 2008 -0700
@@ -756,7 +756,9 @@ static void ide_transfer_start(IDEState 
     s->end_transfer_func = end_transfer_func;
     s->data_ptr = buf;
     s->data_end = buf + size;
-    s->status |= DRQ_STAT;
+    /* don't violate the HSM */
+    if (!(s->status & ERR_STAT))
+        s->status |= DRQ_STAT;
     buffered_pio_reset(s);
 }
 
@@ -2011,6 +2013,7 @@ static void ide_ioport_write(void *opaqu
             /* overlapping commands not supported */
             if (s->feature & 0x02)
                 goto abort_cmd;
+            s->status = READY_STAT;
             s->atapi_dma = s->feature & 1;
             s->nsector = 1;
             ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE, 
diff -r 29268e3fc7ab -r 603ea719d73a tools/libfsimage/Rules.mk
--- a/tools/libfsimage/Rules.mk Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/libfsimage/Rules.mk Tue Jan 22 08:30:40 2008 -0700
@@ -20,8 +20,8 @@ fs-all: $(FSLIB)
 
 .PHONY: fs-install
 fs-install: fs-all
-       $(INSTALL_DIR) $(DESTDIR)/usr/$(FSDIR)
-       $(INSTALL_PROG) $(FSLIB) $(DESTDIR)/usr/$(FSDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(FSDIR)
+       $(INSTALL_PROG) $(FSLIB) $(DESTDIR)$(FSDIR)
 
 $(FSLIB): $(PIC_OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(SHLIB_CFLAGS) -o $@ $^ -lfsimage 
$(FS_LIBDEPS)
diff -r 29268e3fc7ab -r 603ea719d73a tools/libfsimage/common/Makefile
--- a/tools/libfsimage/common/Makefile  Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/libfsimage/common/Makefile  Tue Jan 22 08:30:40 2008 -0700
@@ -22,14 +22,14 @@ all: $(LIB)
 
 .PHONY: install
 install: all
-       [ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) 
$(DESTDIR)/usr/$(LIBDIR)
-       [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
-       $(INSTALL_PROG) libfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libfsimage.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libfsimage.so.$(MAJOR)
-       ln -sf libfsimage.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libfsimage.so
-       $(INSTALL_DATA) fsimage.h $(DESTDIR)/usr/include
-       $(INSTALL_DATA) fsimage_plugin.h $(DESTDIR)/usr/include
-       $(INSTALL_DATA) fsimage_grub.h $(DESTDIR)/usr/include
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_PROG) libfsimage.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       ln -sf libfsimage.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libfsimage.so.$(MAJOR)
+       ln -sf libfsimage.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libfsimage.so
+       $(INSTALL_DATA) fsimage.h $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_DATA) fsimage_plugin.h $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_DATA) fsimage_grub.h $(DESTDIR)$(INCLUDEDIR)
 
 clean distclean:
        rm -f $(PIC_OBJS) $(LIB) $(DEPS)
diff -r 29268e3fc7ab -r 603ea719d73a tools/libxc/Makefile
--- a/tools/libxc/Makefile      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/libxc/Makefile      Tue Jan 22 08:30:40 2008 -0700
@@ -103,19 +103,19 @@ check-for-zlib:
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) 
$(DESTDIR)/usr/$(LIBDIR)
-       [ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
-       $(INSTALL_PROG) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_DATA) libxenctrl.a $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libxenctrl.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libxenctrl.so.$(MAJOR)
-       ln -sf libxenctrl.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenctrl.so
-       $(INSTALL_DATA) xenctrl.h $(DESTDIR)/usr/include
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_PROG) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(LIBDIR)
+       ln -sf libxenctrl.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libxenctrl.so.$(MAJOR)
+       ln -sf libxenctrl.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenctrl.so
+       $(INSTALL_DATA) xenctrl.h $(DESTDIR)$(INCLUDEDIR)
 
-       $(INSTALL_PROG) libxenguest.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_DATA) libxenguest.a $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libxenguest.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libxenguest.so.$(MAJOR)
-       ln -sf libxenguest.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenguest.so
-       $(INSTALL_DATA) xenguest.h $(DESTDIR)/usr/include
+       $(INSTALL_PROG) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DATA) libxenguest.a $(DESTDIR)$(LIBDIR)
+       ln -sf libxenguest.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libxenguest.so.$(MAJOR)
+       ln -sf libxenguest.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenguest.so
+       $(INSTALL_DATA) xenguest.h $(DESTDIR)$(INCLUDEDIR)
 
 .PHONY: TAGS
 TAGS:
diff -r 29268e3fc7ab -r 603ea719d73a tools/libxen/Makefile
--- a/tools/libxen/Makefile     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/libxen/Makefile     Tue Jan 22 08:30:40 2008 -0700
@@ -55,14 +55,14 @@ libxenapi.a: $(LIBXENAPI_OBJS)
 
 .PHONY: install
 install: all
-       $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/api
-       $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_PROG) libxenapi.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libxenapi.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libxenapi.so.$(MAJOR)
-       ln -sf libxenapi.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenapi.so
-       $(INSTALL_DATA) libxenapi.a $(DESTDIR)/usr/$(LIBDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)/xen/api
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_PROG) libxenapi.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       ln -sf libxenapi.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libxenapi.so.$(MAJOR)
+       ln -sf libxenapi.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenapi.so
+       $(INSTALL_DATA) libxenapi.a $(DESTDIR)$(LIBDIR)
        set -e; for i in $(LIBXENAPI_HDRS); do \
-           $(INSTALL_DATA) $$i $(DESTDIR)/usr/include/xen/api; \
+           $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEDIR)/xen/api; \
        done
 
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/libxen/Makefile.dist
--- a/tools/libxen/Makefile.dist        Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/libxen/Makefile.dist        Tue Jan 22 08:30:40 2008 -0700
@@ -65,14 +65,14 @@ libxenapi.a: $(LIBXENAPI_OBJS)
 
 .PHONY: install
 install: all
-       $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/api
-       $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_PROG) libxenapi.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libxenapi.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libxenapi.so.$(MAJOR)
-       ln -sf libxenapi.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenapi.so
-       $(INSTALL_DATA) libxenapi.a $(DESTDIR)/usr/$(LIBDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)/xen/api
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_PROG) libxenapi.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       ln -sf libxenapi.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libxenapi.so.$(MAJOR)
+       ln -sf libxenapi.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenapi.so
+       $(INSTALL_DATA) libxenapi.a $(DESTDIR)$(LIBDIR)
        set -e; for i in $(LIBXENAPI_HDRS); do \
-           $(INSTALL_DATA) $$i $(DESTDIR)/usr/include/xen/api; \
+           $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEDIR)/xen/api; \
        done
 
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/misc/Makefile
--- a/tools/misc/Makefile       Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/misc/Makefile       Tue Jan 22 08:30:40 2008 -0700
@@ -29,10 +29,10 @@ build: $(TARGETS)
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
-       [ -d $(DESTDIR)/usr/sbin ] || $(INSTALL_DIR) $(DESTDIR)/usr/sbin
-       $(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin
-       $(INSTALL_PROG) $(INSTALL_SBIN) $(DESTDIR)/usr/sbin
+       $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)$(BINDIR)
+       $(INSTALL_PROG) $(INSTALL_SBIN) $(DESTDIR)$(SBINDIR)
        set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d install-recurse; done
 
 .PHONY: clean
diff -r 29268e3fc7ab -r 603ea719d73a tools/misc/lomount/Makefile
--- a/tools/misc/lomount/Makefile       Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/misc/lomount/Makefile       Tue Jan 22 08:30:40 2008 -0700
@@ -16,7 +16,7 @@ build: $(BIN)
 
 .PHONY: install
 install install-recurse: build
-       $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)/usr/bin
+       $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/misc/miniterm/Makefile
--- a/tools/misc/miniterm/Makefile      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/misc/miniterm/Makefile      Tue Jan 22 08:30:40 2008 -0700
@@ -8,8 +8,8 @@ all: $(TARGET)
 
 .PHONY: install
 install: all
-       [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
-       $(INSTALL_PROG) $(TARGET) $(DESTDIR)/usr/bin
+       $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
+       $(INSTALL_PROG) $(TARGET) $(DESTDIR)$(BINDIR)
 
 .PHONY: install-recurse
        : No sense in installing miniterm on the Xen box.
diff -r 29268e3fc7ab -r 603ea719d73a tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Jan 22 08:30:40 2008 -0700
@@ -535,6 +535,11 @@ class XendDomainInfo:
                     self._createDevice(dev_type, dev_config_dict)
                 self._waitForDevice(dev_type, devid)
             except VmError, ex:
+                del self.info['devices'][dev_uuid]
+                if dev_type == 'tap':
+                    self.info['vbd_refs'].remove(dev_uuid)
+                else:
+                    self.info['%s_refs' % dev_type].remove(dev_uuid)
                 raise ex
         else:
             devid = None
@@ -1650,9 +1655,10 @@ class XendDomainInfo:
         self._recreateDom()
 
         # Set timer configration of domain
-        if hvm:
+        timer_mode = self.info["platform"].get("timer_mode")
+        if hvm and timer_mode is not None:
             xc.hvm_set_param(self.domid, HVM_PARAM_TIMER_MODE,
-                long(self.info["platform"].get("timer_mode")))
+                             long(timer_mode))
 
         # Set maximum number of vcpus in domain
         xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
diff -r 29268e3fc7ab -r 603ea719d73a tools/security/Makefile
--- a/tools/security/Makefile   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/security/Makefile   Tue Jan 22 08:30:40 2008 -0700
@@ -44,9 +44,9 @@ install: LIBPATH=$(shell PYTHONPATH=../p
 install: LIBPATH=$(shell PYTHONPATH=../python/xen/util python -c "import 
auxbin; print auxbin.libpath()")
 endif
 install: all $(ACM_CONFIG_FILE)
-       $(INSTALL_DIR) $(DESTDIR)/usr/sbin
-       $(INSTALL_PROG) $(ACM_INST_TOOLS) $(DESTDIR)/usr/sbin
-       $(INSTALL_PROG) $(ACM_EZPOLICY) $(DESTDIR)/usr/sbin
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) $(ACM_INST_TOOLS) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) $(ACM_EZPOLICY) $(DESTDIR)$(SBINDIR)
        $(INSTALL_DIR) $(DESTDIR)$(ACM_CONFIG_DIR)
        $(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)
        $(INSTALL_DATA) policies/$(ACM_SCHEMA) $(DESTDIR)$(ACM_POLICY_DIR)
diff -r 29268e3fc7ab -r 603ea719d73a tools/vnet/doc/Makefile
--- a/tools/vnet/doc/Makefile   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/vnet/doc/Makefile   Tue Jan 22 08:30:40 2008 -0700
@@ -12,8 +12,6 @@ LATEX2HTML    := latex2html
 LATEX2HTML     := latex2html
 DOXYGEN                := doxygen
 POD2MAN                := pod2man
-
-MAN_DIR                := /usr/share/man
 
 DOC_MAN5SRC    := $(wildcard man/*.pod.5)
 DOC_MAN1SRC    := $(wildcard man/*.pod.1)
@@ -47,7 +45,7 @@ clean:
 
 .PHONY:  install
  install: all
-       $(INSTALL_DIR) $(DESTDIR)$(MAN_DIR)
-       $(CP) -dR man1 $(DESTDIR)$(MAN_DIR)
-       $(CP) -dR man5 $(DESTDIR)$(MAN_DIR)
+       $(INSTALL_DIR) $(DESTDIR)$(MANDIR)
+       $(CP) -dR man1 $(DESTDIR)$(MANDIR)
+       $(CP) -dR man5 $(DESTDIR)$(MANDIR)
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/vnet/libxutil/Makefile
--- a/tools/vnet/libxutil/Makefile      Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/vnet/libxutil/Makefile      Tue Jan 22 08:30:40 2008 -0700
@@ -71,11 +71,11 @@ check-for-zlib:
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)/usr/$(LIBDIR) ] || $(INSTALL_DIR) 
$(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_PROG) libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_DATA) libxutil.a $(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libxutil.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libxutil.so.$(MAJOR)
-       ln -sf libxutil.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxutil.so
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_PROG) libxutil.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DATA) libxutil.a $(DESTDIR)$(LIBDIR)
+       ln -sf libxutil.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libxutil.so.$(MAJOR)
+       ln -sf libxutil.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxutil.so
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/vnet/scripts/Makefile
--- a/tools/vnet/scripts/Makefile       Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/vnet/scripts/Makefile       Tue Jan 22 08:30:40 2008 -0700
@@ -2,16 +2,14 @@
 #============================================================================
 XEN_ROOT        = ../../..
 include $(XEN_ROOT)/tools/Rules.mk
-
-SBIN_DIR        = $(DESTDIR)/usr/sbin
 
 .PHONY: all
 all:
 
 .PHONY: install
 install:
-       $(INSTALL_DIR) $(SBIN_DIR)
-       $(INSTALL_PROG) vn $(SBIN_DIR)
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) vn $(DESTDIR)$(SBINDIR)
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/vnet/vnetd/Makefile
--- a/tools/vnet/vnetd/Makefile Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/vnet/vnetd/Makefile Tue Jan 22 08:30:40 2008 -0700
@@ -28,8 +28,6 @@ all: vnetd
 #include $(XEN_ROOT)/tools/Rules.mk
 
 INSTALL_PROG ?= $(INSTALL) -m0755 -p
-
-VNETD_INSTALL_DIR = /usr/sbin
 
 INCLUDES += -I$(LIBXUTIL_DIR)
 INCLUDES += -I$(VNET_MODULE_DIR)
@@ -111,8 +109,8 @@ vnetd: $(VNETD_OBJ)
 
 .PHONY: install
 install: vnetd
-       mkdir -p $(DESTDIR)$(VNETD_INSTALL_DIR)
-       $(INSTALL_PROG) vnetd $(DESTDIR)$(VNETD_INSTALL_DIR)
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) vnetd $(DESTDIR)$(SBINDIR)
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/xcutils/Makefile
--- a/tools/xcutils/Makefile    Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/xcutils/Makefile    Tue Jan 22 08:30:40 2008 -0700
@@ -11,7 +11,7 @@ XEN_ROOT      = ../..
 XEN_ROOT       = ../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-PROGRAMS_INSTALL_DIR = /usr/$(LIBDIR)/xen/bin
+PROGRAMS_INSTALL_DIR = $(LIBDIR)/xen/bin
 
 INCLUDES += -I $(XEN_LIBXC) -I $(XEN_XENSTORE)
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/xenmon/Makefile
--- a/tools/xenmon/Makefile     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/xenmon/Makefile     Tue Jan 22 08:30:40 2008 -0700
@@ -12,8 +12,6 @@
 
 XEN_ROOT=../..
 include $(XEN_ROOT)/tools/Rules.mk
-
-sbindir=/usr/sbin
 
 CFLAGS  += -Werror
 CFLAGS  += -I $(XEN_XC)
@@ -31,10 +29,10 @@ build: $(BIN)
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)$(sbindir) ] || $(INSTALL_DIR) $(DESTDIR)$(sbindir)
-       $(INSTALL_PROG) xenbaked $(DESTDIR)$(sbindir)/xenbaked
-       $(INSTALL_PROG) xentrace_setmask  $(DESTDIR)$(sbindir)/xentrace_setmask
-       $(INSTALL_PROG) xenmon.py  $(DESTDIR)$(sbindir)/xenmon.py
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) xenbaked $(DESTDIR)$(SBINDIR)/xenbaked
+       $(INSTALL_PROG) xentrace_setmask  $(DESTDIR)$(SBINDIR)/xentrace_setmask
+       $(INSTALL_PROG) xenmon.py  $(DESTDIR)$(SBINDIR)/xenmon.py
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a tools/xenstat/xentop/Makefile
--- a/tools/xenstat/xentop/Makefile     Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/xenstat/xentop/Makefile     Tue Jan 22 08:30:40 2008 -0700
@@ -18,11 +18,6 @@ all install xentop:
 all install xentop:
 else
 
-prefix=/usr
-mandir=$(prefix)/share/man
-man1dir=$(mandir)/man1
-sbindir=$(prefix)/sbin
-
 CFLAGS += -DGCC_PRINTF -Wall -Werror -I$(XEN_LIBXENSTAT)
 LDFLAGS += -L$(XEN_LIBXENSTAT)
 LDLIBS += -lxenstat $(CURSES_LIBS) $(SOCKET_LIBS)
@@ -33,9 +28,10 @@ all: xentop
 
 .PHONY: install
 install: xentop xentop.1
-       $(INSTALL_PROG) xentop $(DESTDIR)$(sbindir)/xentop
-       $(INSTALL_DIR) $(DESTDIR)$(man1dir)
-       $(INSTALL_DATA) xentop.1 $(DESTDIR)$(man1dir)/xentop.1
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) xentop $(DESTDIR)$(SBINDIR)/xentop
+       $(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
+       $(INSTALL_DATA) xentop.1 $(DESTDIR)$(MAN1DIR)/xentop.1
 
 endif
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/xenstore/Makefile
--- a/tools/xenstore/Makefile   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/xenstore/Makefile   Tue Jan 22 08:30:40 2008 -0700
@@ -81,20 +81,20 @@ install: all
 install: all
        $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored
        $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored
-       $(INSTALL_DIR) $(DESTDIR)/usr/bin
-       $(INSTALL_DIR) $(DESTDIR)/usr/sbin
-       $(INSTALL_DIR) $(DESTDIR)/usr/include
-       $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
-       $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/bin
-       $(INSTALL_PROG) xenstore-control $(DESTDIR)/usr/bin
-       $(INSTALL_PROG) xenstore-ls $(DESTDIR)/usr/bin
-       $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)
-       ln -sf libxenstore.so.$(MAJOR).$(MINOR) 
$(DESTDIR)/usr/$(LIBDIR)/libxenstore.so.$(MAJOR)
-       ln -sf libxenstore.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenstore.so
-       $(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR)
-       $(INSTALL_DATA) xs.h $(DESTDIR)/usr/include
-       $(INSTALL_DATA) xs_lib.h $(DESTDIR)/usr/include
+       $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_PROG) xenstored $(DESTDIR)$(SBINDIR)
+       $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(BINDIR)
+       $(INSTALL_PROG) xenstore-control $(DESTDIR)$(BINDIR)
+       $(INSTALL_PROG) xenstore-ls $(DESTDIR)$(BINDIR)
+       $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)
+       $(INSTALL_PROG) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)
+       ln -sf libxenstore.so.$(MAJOR).$(MINOR) 
$(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR)
+       ln -sf libxenstore.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenstore.so
+       $(INSTALL_DATA) libxenstore.a $(DESTDIR)$(LIBDIR)
+       $(INSTALL_DATA) xs.h $(DESTDIR)$(INCLUDEDIR)
+       $(INSTALL_DATA) xs_lib.h $(DESTDIR)$(INCLUDEDIR)
 
 -include $(PROG_DEP)
 
diff -r 29268e3fc7ab -r 603ea719d73a tools/xentrace/Makefile
--- a/tools/xentrace/Makefile   Tue Jan 22 08:27:29 2008 -0700
+++ b/tools/xentrace/Makefile   Tue Jan 22 08:30:40 2008 -0700
@@ -35,17 +35,14 @@ build: $(BIN) $(LIBBIN)
 
 .PHONY: install
 install: build
-       [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin
-       [ -z "$(LIBBIN)" ] || [ -d $(DESTDIR)/usr/$(LIBDIR)/xen/bin ] || \
-               $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR)/xen/bin
-       [ -d $(DESTDIR)/usr/share/man/man1 ] || \
-               $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man1
-       [ -d $(DESTDIR)/usr/share/man/man8 ] || \
-               $(INSTALL_DIR) $(DESTDIR)/usr/share/man/man8
-       $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)/usr/bin
-       [ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) 
$(DESTDIR)/usr/$(LIBDIR)/xen/bin
-       $(INSTALL_DATA) $(MAN1) $(DESTDIR)/usr/share/man/man1
-       $(INSTALL_DATA) $(MAN8) $(DESTDIR)/usr/share/man/man8
+       $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
+       [ -z "$(LIBBIN)" ] || $(INSTALL_DIR) $(DESTDIR)$(LIBDIR)/xen/bin
+       $(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
+       $(INSTALL_DIR) $(DESTDIR)$(MAN8DIR)
+       $(INSTALL_PROG) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
+       [ -z "$(LIBBIN)" ] || $(INSTALL_PROG) $(LIBBIN) 
$(DESTDIR)$(LIBDIR)/xen/bin
+       $(INSTALL_DATA) $(MAN1) $(DESTDIR)$(MAN1DIR)
+       $(INSTALL_DATA) $(MAN8) $(DESTDIR)$(MAN8DIR)
 
 .PHONY: clean
 clean:
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/cpu/intel_cacheinfo.c
--- a/xen/arch/x86/cpu/intel_cacheinfo.c        Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/arch/x86/cpu/intel_cacheinfo.c        Tue Jan 22 08:30:40 2008 -0700
@@ -1,6 +1,16 @@
+/*
+ *      Routines to indentify caches on Intel CPU.
+ *
+ *      Changes:
+ *      Venkatesh Pallipadi    : Adding cache identification through cpuid(4)
+ *             Ashok Raj <ashok.raj@xxxxxxxxx>: Work with CPU hotplug 
infrastructure.
+ *     Andi Kleen / Andreas Herrmann   : CPUID4 emulation on AMD.
+ */
+
 #include <xen/config.h>
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/errno.h>
 #include <asm/processor.h>
 
 #define LVL_1_INST     1
@@ -17,7 +27,7 @@ struct _cache_table
 };
 
 /* all the cache descriptor types we care about (no TLB or trace cache 
entries) */
-static struct _cache_table cache_table[] __devinitdata =
+static struct _cache_table cache_table[] __cpuinitdata =
 {
        { 0x06, LVL_1_INST, 8 },        /* 4-way set assoc, 32 byte line size */
        { 0x08, LVL_1_INST, 16 },       /* 4-way set assoc, 32 byte line size */
@@ -30,13 +40,23 @@ static struct _cache_table cache_table[]
        { 0x2c, LVL_1_DATA, 32 },       /* 8-way set assoc, 64 byte line size */
        { 0x30, LVL_1_INST, 32 },       /* 8-way set assoc, 64 byte line size */
        { 0x39, LVL_2,      128 },      /* 4-way set assoc, sectored cache, 64 
byte line size */
+       { 0x3a, LVL_2,      192 },      /* 6-way set assoc, sectored cache, 64 
byte line size */
        { 0x3b, LVL_2,      128 },      /* 2-way set assoc, sectored cache, 64 
byte line size */
        { 0x3c, LVL_2,      256 },      /* 4-way set assoc, sectored cache, 64 
byte line size */
+       { 0x3d, LVL_2,      384 },      /* 6-way set assoc, sectored cache, 64 
byte line size */
+       { 0x3e, LVL_2,      512 },      /* 4-way set assoc, sectored cache, 64 
byte line size */
        { 0x41, LVL_2,      128 },      /* 4-way set assoc, 32 byte line size */
        { 0x42, LVL_2,      256 },      /* 4-way set assoc, 32 byte line size */
        { 0x43, LVL_2,      512 },      /* 4-way set assoc, 32 byte line size */
        { 0x44, LVL_2,      1024 },     /* 4-way set assoc, 32 byte line size */
        { 0x45, LVL_2,      2048 },     /* 4-way set assoc, 32 byte line size */
+       { 0x46, LVL_3,      4096 },     /* 4-way set assoc, 64 byte line size */
+       { 0x47, LVL_3,      8192 },     /* 8-way set assoc, 64 byte line size */
+       { 0x49, LVL_3,      4096 },     /* 16-way set assoc, 64 byte line size 
*/
+       { 0x4a, LVL_3,      6144 },     /* 12-way set assoc, 64 byte line size 
*/
+       { 0x4b, LVL_3,      8192 },     /* 16-way set assoc, 64 byte line size 
*/
+       { 0x4c, LVL_3,     12288 },     /* 12-way set assoc, 64 byte line size 
*/
+       { 0x4d, LVL_3,     16384 },     /* 16-way set assoc, 64 byte line size 
*/
        { 0x60, LVL_1_DATA, 16 },       /* 8-way set assoc, sectored cache, 64 
byte line size */
        { 0x66, LVL_1_DATA, 8 },        /* 4-way set assoc, sectored cache, 64 
byte line size */
        { 0x67, LVL_1_DATA, 16 },       /* 4-way set assoc, sectored cache, 64 
byte line size */
@@ -44,6 +64,7 @@ static struct _cache_table cache_table[]
        { 0x70, LVL_TRACE,  12 },       /* 8-way set assoc */
        { 0x71, LVL_TRACE,  16 },       /* 8-way set assoc */
        { 0x72, LVL_TRACE,  32 },       /* 8-way set assoc */
+       { 0x73, LVL_TRACE,  64 },       /* 8-way set assoc */
        { 0x78, LVL_2,    1024 },       /* 4-way set assoc, 64 byte line size */
        { 0x79, LVL_2,     128 },       /* 8-way set assoc, sectored cache, 64 
byte line size */
        { 0x7a, LVL_2,     256 },       /* 8-way set assoc, sectored cache, 64 
byte line size */
@@ -60,15 +81,276 @@ static struct _cache_table cache_table[]
        { 0x00, 0, 0}
 };
 
-unsigned int __devinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
+
+enum _cache_type
+{
+       CACHE_TYPE_NULL = 0,
+       CACHE_TYPE_DATA = 1,
+       CACHE_TYPE_INST = 2,
+       CACHE_TYPE_UNIFIED = 3
+};
+
+union _cpuid4_leaf_eax {
+       struct {
+               enum _cache_type        type:5;
+               unsigned int            level:3;
+               unsigned int            is_self_initializing:1;
+               unsigned int            is_fully_associative:1;
+               unsigned int            reserved:4;
+               unsigned int            num_threads_sharing:12;
+               unsigned int            num_cores_on_die:6;
+       } split;
+       u32 full;
+};
+
+union _cpuid4_leaf_ebx {
+       struct {
+               unsigned int            coherency_line_size:12;
+               unsigned int            physical_line_partition:10;
+               unsigned int            ways_of_associativity:10;
+       } split;
+       u32 full;
+};
+
+union _cpuid4_leaf_ecx {
+       struct {
+               unsigned int            number_of_sets:32;
+       } split;
+       u32 full;
+};
+
+struct _cpuid4_info {
+       union _cpuid4_leaf_eax eax;
+       union _cpuid4_leaf_ebx ebx;
+       union _cpuid4_leaf_ecx ecx;
+       unsigned long size;
+       cpumask_t shared_cpu_map;
+};
+
+unsigned short                 num_cache_leaves;
+
+/* AMD doesn't have CPUID4. Emulate it here to report the same
+   information to the user.  This makes some assumptions about the machine:
+   L2 not shared, no SMT etc. that is currently true on AMD CPUs.
+
+   In theory the TLBs could be reported as fake type (they are in "dummy").
+   Maybe later */
+union l1_cache {
+       struct {
+               unsigned line_size : 8;
+               unsigned lines_per_tag : 8;
+               unsigned assoc : 8;
+               unsigned size_in_kb : 8;
+       };
+       unsigned val;
+};
+
+union l2_cache {
+       struct {
+               unsigned line_size : 8;
+               unsigned lines_per_tag : 4;
+               unsigned assoc : 4;
+               unsigned size_in_kb : 16;
+       };
+       unsigned val;
+};
+
+union l3_cache {
+       struct {
+               unsigned line_size : 8;
+               unsigned lines_per_tag : 4;
+               unsigned assoc : 4;
+               unsigned res : 2;
+               unsigned size_encoded : 14;
+       };
+       unsigned val;
+};
+
+static const unsigned short assocs[] = {
+       [1] = 1, [2] = 2, [4] = 4, [6] = 8,
+       [8] = 16, [0xa] = 32, [0xb] = 48,
+       [0xc] = 64,
+       [0xf] = 0xffff // ??
+};
+
+static const unsigned char levels[] = { 1, 1, 2, 3 };
+static const unsigned char types[] = { 1, 2, 3, 3 };
+
+static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
+                      union _cpuid4_leaf_ebx *ebx,
+                      union _cpuid4_leaf_ecx *ecx)
+{
+       unsigned dummy;
+       unsigned line_size, lines_per_tag, assoc, size_in_kb;
+       union l1_cache l1i, l1d;
+       union l2_cache l2;
+       union l3_cache l3;
+       union l1_cache *l1 = &l1d;
+
+       eax->full = 0;
+       ebx->full = 0;
+       ecx->full = 0;
+
+       cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val);
+       cpuid(0x80000006, &dummy, &dummy, &l2.val, &l3.val);
+
+       switch (leaf) {
+       case 1:
+               l1 = &l1i;
+       case 0:
+               if (!l1->val)
+                       return;
+               assoc = l1->assoc;
+               line_size = l1->line_size;
+               lines_per_tag = l1->lines_per_tag;
+               size_in_kb = l1->size_in_kb;
+               break;
+       case 2:
+               if (!l2.val)
+                       return;
+               assoc = l2.assoc;
+               line_size = l2.line_size;
+               lines_per_tag = l2.lines_per_tag;
+               /* cpu_data has errata corrections for K7 applied */
+               size_in_kb = current_cpu_data.x86_cache_size;
+               break;
+       case 3:
+               if (!l3.val)
+                       return;
+               assoc = l3.assoc;
+               line_size = l3.line_size;
+               lines_per_tag = l3.lines_per_tag;
+               size_in_kb = l3.size_encoded * 512;
+               break;
+       default:
+               return;
+       }
+
+       eax->split.is_self_initializing = 1;
+       eax->split.type = types[leaf];
+       eax->split.level = levels[leaf];
+       if (leaf == 3)
+               eax->split.num_threads_sharing = current_cpu_data.x86_max_cores 
- 1;
+       else
+               eax->split.num_threads_sharing = 0;
+       eax->split.num_cores_on_die = current_cpu_data.x86_max_cores - 1;
+
+
+       if (assoc == 0xf)
+               eax->split.is_fully_associative = 1;
+       ebx->split.coherency_line_size = line_size - 1;
+       ebx->split.ways_of_associativity = assocs[assoc] - 1;
+       ebx->split.physical_line_partition = lines_per_tag - 1;
+       ecx->split.number_of_sets = (size_in_kb * 1024) / line_size /
+               (ebx->split.ways_of_associativity + 1) - 1;
+}
+
+static int __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info 
*this_leaf)
+{
+       union _cpuid4_leaf_eax  eax;
+       union _cpuid4_leaf_ebx  ebx;
+       union _cpuid4_leaf_ecx  ecx;
+       unsigned                edx;
+
+       if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+               amd_cpuid4(index, &eax, &ebx, &ecx);
+       else
+               cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full,  &edx);
+       if (eax.split.type == CACHE_TYPE_NULL)
+               return -EIO; /* better error ? */
+
+       this_leaf->eax = eax;
+       this_leaf->ebx = ebx;
+       this_leaf->ecx = ecx;
+       this_leaf->size = (ecx.split.number_of_sets + 1) *
+               (ebx.split.coherency_line_size + 1) *
+               (ebx.split.physical_line_partition + 1) *
+               (ebx.split.ways_of_associativity + 1);
+       return 0;
+}
+
+static int __cpuinit find_num_cache_leaves(void)
+{
+       unsigned int            eax, ebx, ecx, edx;
+       union _cpuid4_leaf_eax  cache_eax;
+       int                     i = -1;
+
+       do {
+               ++i;
+               /* Do cpuid(4) loop to find out num_cache_leaves */
+               cpuid_count(4, i, &eax, &ebx, &ecx, &edx);
+               cache_eax.full = eax;
+       } while (cache_eax.split.type != CACHE_TYPE_NULL);
+       return i;
+}
+
+unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
 {
        unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache 
sizes */
-
-       if (c->cpuid_level > 1) {
+       unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
+       unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
+       unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;
+
+       if (c->cpuid_level > 3) {
+               static int is_initialized;
+
+               if (is_initialized == 0) {
+                       /* Init num_cache_leaves from boot CPU */
+                       num_cache_leaves = find_num_cache_leaves();
+                       is_initialized++;
+               }
+
+               /*
+                * Whenever possible use cpuid(4), deterministic cache
+                * parameters cpuid leaf to find the cache details
+                */
+               for (i = 0; i < num_cache_leaves; i++) {
+                       struct _cpuid4_info this_leaf;
+
+                       int retval;
+
+                       retval = cpuid4_cache_lookup(i, &this_leaf);
+                       if (retval >= 0) {
+                               switch(this_leaf.eax.split.level) {
+                                   case 1:
+                                       if (this_leaf.eax.split.type ==
+                                                       CACHE_TYPE_DATA)
+                                               new_l1d = this_leaf.size/1024;
+                                       else if (this_leaf.eax.split.type ==
+                                                       CACHE_TYPE_INST)
+                                               new_l1i = this_leaf.size/1024;
+                                       break;
+                                   case 2:
+                                       new_l2 = this_leaf.size/1024;
+                                       num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
+                                       index_msb = 
get_count_order(num_threads_sharing);
+                                       l2_id = c->apicid >> index_msb;
+                                       break;
+                                   case 3:
+                                       new_l3 = this_leaf.size/1024;
+                                       num_threads_sharing = 1 + 
this_leaf.eax.split.num_threads_sharing;
+                                       index_msb = 
get_count_order(num_threads_sharing);
+                                       l3_id = c->apicid >> index_msb;
+                                       break;
+                                   default:
+                                       break;
+                               }
+                       }
+               }
+       }
+       /*
+        * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
+        * trace cache
+        */
+       if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
                /* supports eax=2  call */
                int i, j, n;
                int regs[4];
                unsigned char *dp = (unsigned char *)regs;
+               int only_trace = 0;
+
+               if (num_cache_leaves != 0 && c->x86 == 15)
+                       only_trace = 1;
 
                /* Number of times to iterate */
                n = cpuid_eax(2) & 0xFF;
@@ -90,6 +372,8 @@ unsigned int __devinit init_intel_cachei
                                while (cache_table[k].descriptor != 0)
                                {
                                        if (cache_table[k].descriptor == des) {
+                                               if (only_trace && 
cache_table[k].cache_type != LVL_TRACE)
+                                                       break;
                                                switch 
(cache_table[k].cache_type) {
                                                case LVL_1_INST:
                                                        l1i += 
cache_table[k].size;
@@ -115,28 +399,39 @@ unsigned int __devinit init_intel_cachei
                                }
                        }
                }
-
-               if ( trace )
-                       printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
-               else if ( l1i )
-                       printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
-               if ( l1d )
-                       printk(", L1 D cache: %dK\n", l1d);
-               else
-                       printk("\n");
-               if ( l2 )
-                       printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
-               if ( l3 )
-                       printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
-
-               /*
-                * This assumes the L3 cache is shared; it typically lives in
-                * the northbridge.  The L1 caches are included by the L2
-                * cache, and so should not be included for the purpose of
-                * SMP switching weights.
-                */
-               c->x86_cache_size = l2 ? l2 : (l1i+l1d);
-       }
+       }
+
+       if (new_l1d)
+               l1d = new_l1d;
+
+       if (new_l1i)
+               l1i = new_l1i;
+
+       if (new_l2) {
+               l2 = new_l2;
+       }
+
+       if (new_l3) {
+               l3 = new_l3;
+       }
+
+       if (trace)
+               printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
+       else if ( l1i )
+               printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
+
+       if (l1d)
+               printk(", L1 D cache: %dK\n", l1d);
+       else
+               printk("\n");
+
+       if (l2)
+               printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
+
+       if (l3)
+               printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
+
+       c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));
 
        return l2;
 }
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/hvm/vmx/vtd/Makefile
--- a/xen/arch/x86/hvm/vmx/vtd/Makefile Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/arch/x86/hvm/vmx/vtd/Makefile Tue Jan 22 08:30:40 2008 -0700
@@ -2,3 +2,4 @@ obj-y += dmar.o
 obj-y += dmar.o
 obj-y += utils.o
 obj-y += io.o
+obj-y += qinval.o
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/hvm/vmx/vtd/extern.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/hvm/vmx/vtd/extern.h Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Copyright (C) Allen Kay <allen.m.kay@xxxxxxxxx>
+ * Copyright (C) Weidong Han <weidong.han@xxxxxxxxx>
+ */
+
+#ifndef _VTD_EXTERN_H_
+#define _VTD_EXTERN_H_
+
+#include "dmar.h"
+
+extern int iommu_setup_done;
+extern int vtd2_thurley_enabled;
+extern int vtd2_qinval_enabled;
+
+extern spinlock_t ioapic_lock;
+extern struct qi_ctrl *qi_ctrl;
+extern struct ir_ctrl *ir_ctrl;
+
+void print_iommu_regs(struct acpi_drhd_unit *drhd);
+void print_vtd_entries(struct domain *d, struct iommu *iommu,
+                       int bus, int devfn, unsigned long gmfn);
+
+int qinval_setup(struct iommu *iommu);
+int queue_invalidate_context(struct iommu *iommu,
+    u16 did, u16 source_id, u8 function_mask, u8 granu);
+int queue_invalidate_iotlb(struct iommu *iommu,
+    u8 granu, u8 dr, u8 dw, u16 did, u8 am, u8 ih, u64 addr);
+int queue_invalidate_iec(struct iommu *iommu,
+    u8 granu, u8 im, u16 iidx);
+int invalidate_sync(struct iommu *iommu);
+int iommu_flush_iec_global(struct iommu *iommu);
+int iommu_flush_iec_index(struct iommu *iommu, u8 im, u16 iidx);
+void gsi_remapping(unsigned int gsi);
+void print_iommu_regs(struct acpi_drhd_unit *drhd);
+int vtd_hw_check(void);
+struct iommu * ioapic_to_iommu(unsigned int apic_id);
+struct acpi_drhd_unit * ioapic_to_drhd(unsigned int apic_id);
+void clear_fault_bits(struct iommu *iommu);
+
+#endif // _VTD_EXTERN_H_
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/hvm/vmx/vtd/intel-iommu.c
--- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c    Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c    Tue Jan 22 08:30:40 2008 -0700
@@ -34,12 +34,9 @@
 #include "pci-direct.h"
 #include "pci_regs.h"
 #include "msi.h"
+#include "extern.h"
 
 #define domain_iommu_domid(d) ((d)->arch.hvm_domain.hvm_iommu.iommu_domid)
-
-extern void print_iommu_regs(struct acpi_drhd_unit *drhd);
-extern void print_vtd_entries(struct domain *d, int bus, int devfn,
-                              unsigned long gmfn);
 
 static spinlock_t domid_bitmap_lock;    /* protect domain id bitmap */
 static int domid_bitmap_size;           /* domain id bitmap size in bit */
@@ -304,11 +301,12 @@ static void iommu_flush_write_buffer(str
 }
 
 /* return value determine if we need a write buffer flush */
-static int __iommu_flush_context(
-    struct iommu *iommu,
+static int flush_context_reg(
+    void *_iommu,
     u16 did, u16 source_id, u8 function_mask, u64 type,
     int non_present_entry_flush)
 {
+    struct iommu *iommu = (struct iommu *) _iommu;
     u64 val = 0;
     unsigned long flag;
     unsigned long start_time;
@@ -367,14 +365,16 @@ static int inline iommu_flush_context_gl
 static int inline iommu_flush_context_global(
     struct iommu *iommu, int non_present_entry_flush)
 {
-    return __iommu_flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL,
+    struct iommu_flush *flush = iommu_get_flush(iommu);
+    return flush->context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL,
                                  non_present_entry_flush);
 }
 
 static int inline iommu_flush_context_domain(
     struct iommu *iommu, u16 did, int non_present_entry_flush)
 {
-    return __iommu_flush_context(iommu, did, 0, 0, DMA_CCMD_DOMAIN_INVL,
+    struct iommu_flush *flush = iommu_get_flush(iommu);
+    return flush->context(iommu, did, 0, 0, DMA_CCMD_DOMAIN_INVL,
                                  non_present_entry_flush);
 }
 
@@ -382,16 +382,18 @@ static int inline iommu_flush_context_de
     struct iommu *iommu, u16 did, u16 source_id,
     u8 function_mask, int non_present_entry_flush)
 {
-    return __iommu_flush_context(iommu, did, source_id, function_mask,
+    struct iommu_flush *flush = iommu_get_flush(iommu);
+    return flush->context(iommu, did, source_id, function_mask,
                                  DMA_CCMD_DEVICE_INVL,
                                  non_present_entry_flush);
 }
 
 /* return value determine if we need a write buffer flush */
-static int __iommu_flush_iotlb(struct iommu *iommu, u16 did,
+static int flush_iotlb_reg(void *_iommu, u16 did,
                                u64 addr, unsigned int size_order, u64 type,
                                int non_present_entry_flush)
 {
+    struct iommu *iommu = (struct iommu *) _iommu;
     int tlb_offset = ecap_iotlb_offset(iommu->ecap);
     u64 val = 0, val_iva = 0;
     unsigned long flag;
@@ -467,14 +469,16 @@ static int inline iommu_flush_iotlb_glob
 static int inline iommu_flush_iotlb_global(struct iommu *iommu,
                                            int non_present_entry_flush)
 {
-    return __iommu_flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH,
+    struct iommu_flush *flush = iommu_get_flush(iommu);
+    return flush->iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH,
                                non_present_entry_flush);
 }
 
 static int inline iommu_flush_iotlb_dsi(struct iommu *iommu, u16 did,
                                         int non_present_entry_flush)
 {
-    return __iommu_flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH,
+    struct iommu_flush *flush = iommu_get_flush(iommu);
+    return flush->iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH,
                                non_present_entry_flush);
 }
 
@@ -498,6 +502,7 @@ static int inline iommu_flush_iotlb_psi(
     u64 addr, unsigned int pages, int non_present_entry_flush)
 {
     unsigned int align;
+    struct iommu_flush *flush = iommu_get_flush(iommu);
 
     BUG_ON(addr & (~PAGE_MASK_4K));
     BUG_ON(pages == 0);
@@ -520,7 +525,7 @@ static int inline iommu_flush_iotlb_psi(
     addr >>= PAGE_SHIFT_4K + align;
     addr <<= PAGE_SHIFT_4K + align;
 
-    return __iommu_flush_iotlb(iommu, did, addr, align,
+    return flush->iotlb(iommu, did, addr, align,
                                DMA_TLB_PSI_FLUSH, non_present_entry_flush);
 }
 
@@ -701,7 +706,7 @@ static int iommu_enable_translation(stru
     unsigned long flags;
 
     dprintk(XENLOG_INFO VTDPREFIX,
-            "iommu_enable_translation: enabling vt-d translation\n");
+            "iommu_enable_translation: iommu->reg = %p\n", iommu->reg);
     spin_lock_irqsave(&iommu->register_lock, flags);
     iommu->gcmd |= DMA_GCMD_TE;
     dmar_writel(iommu->reg, DMAR_GCMD_REG, iommu->gcmd);
@@ -746,14 +751,47 @@ static int iommu_page_fault_do_one(struc
                                    u8 fault_reason, u16 source_id, u32 addr)
 {
     dprintk(XENLOG_WARNING VTDPREFIX,
-            "iommu_page_fault:%s: DEVICE %x:%x.%x addr %x REASON %x\n",
-            (type ? "DMA Read" : "DMA Write"),
-            (source_id >> 8), PCI_SLOT(source_id & 0xFF),
-            PCI_FUNC(source_id & 0xFF), addr, fault_reason);
-
-    print_vtd_entries(current->domain, (source_id >> 8),(source_id & 0xff),
-                      (addr >> PAGE_SHIFT)); 
+            "iommu_fault:%s: %x:%x.%x addr %x REASON %x iommu->reg = %p\n",
+            (type ? "DMA Read" : "DMA Write"), (source_id >> 8),
+            PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr,
+            fault_reason, iommu->reg);
+
+    if (fault_reason < 0x20) 
+        print_vtd_entries(current->domain, iommu, (source_id >> 8),
+                          (source_id & 0xff), (addr >> PAGE_SHIFT)); 
+
     return 0;
+}
+
+static void iommu_fault_status(u32 fault_status)
+{
+    if (fault_status & DMA_FSTS_PFO)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Fault Overflow\n");
+    else
+    if (fault_status & DMA_FSTS_PPF)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Primary Pending Fault\n");
+    else
+    if (fault_status & DMA_FSTS_AFO)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Advanced Fault Overflow\n");
+    else
+    if (fault_status & DMA_FSTS_APF)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Advanced Pending Fault\n");
+    else
+    if (fault_status & DMA_FSTS_IQE)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Invalidation Queue Error\n");
+    else
+    if (fault_status & DMA_FSTS_ICE)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Invalidation Completion Error\n");
+    else
+    if (fault_status & DMA_FSTS_ITE)
+        dprintk(XENLOG_ERR VTDPREFIX,
+            "iommu_fault_status: Invalidation Time-out Error\n");
 }
 
 #define PRIMARY_FAULT_REG_LEN (16)
@@ -771,6 +809,8 @@ static void iommu_page_fault(int vector,
     spin_lock_irqsave(&iommu->register_lock, flags);
     fault_status = dmar_readl(iommu->reg, DMAR_FSTS_REG);
     spin_unlock_irqrestore(&iommu->register_lock, flags);
+
+    iommu_fault_status(fault_status);
 
     /* FIXME: ignore advanced fault log */
     if ( !(fault_status & DMA_FSTS_PPF) )
@@ -936,6 +976,8 @@ struct iommu *iommu_alloc(void *hw_data)
 {
     struct acpi_drhd_unit *drhd = (struct acpi_drhd_unit *) hw_data;
     struct iommu *iommu;
+    struct qi_ctrl *qi_ctrl;
+    struct ir_ctrl *ir_ctrl;
 
     if ( nr_iommus > MAX_IOMMUS )
     {
@@ -951,9 +993,10 @@ struct iommu *iommu_alloc(void *hw_data)
 
     set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, drhd->address);
     iommu->reg = (void *) fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus);
-    dprintk(XENLOG_INFO VTDPREFIX,
-            "iommu_alloc: iommu->reg = %p drhd->address = %lx\n",
-            iommu->reg, drhd->address);
+
+    printk("iommu_alloc: iommu->reg = %p drhd->address = %lx\n",
+           iommu->reg, drhd->address);
+
     nr_iommus++;
 
     if ( !iommu->reg )
@@ -965,8 +1008,18 @@ struct iommu *iommu_alloc(void *hw_data)
     iommu->cap = dmar_readq(iommu->reg, DMAR_CAP_REG);
     iommu->ecap = dmar_readq(iommu->reg, DMAR_ECAP_REG);
 
+    printk("iommu_alloc: cap = %"PRIx64"\n",iommu->cap);
+    printk("iommu_alloc: ecap = %"PRIx64"\n", iommu->ecap);
+
     spin_lock_init(&iommu->lock);
     spin_lock_init(&iommu->register_lock);
+
+    qi_ctrl = iommu_qi_ctrl(iommu);
+    spin_lock_init(&qi_ctrl->qinval_lock);
+    spin_lock_init(&qi_ctrl->qinval_poll_lock);
+
+    ir_ctrl = iommu_ir_ctrl(iommu);
+    spin_lock_init(&ir_ctrl->iremap_lock);
 
     drhd->iommu = iommu;
     return iommu;
@@ -1071,8 +1124,10 @@ static int domain_context_mapping_one(
 
     if ( ecap_pass_thru(iommu->ecap) )
         context_set_translation_type(*context, CONTEXT_TT_PASS_THRU);
+#ifdef CONTEXT_PASSTHRU
     else
     {
+#endif
         if ( !hd->pgd )
         {
             struct dma_pte *pgd = (struct dma_pte *)alloc_xenheap_page();
@@ -1087,7 +1142,9 @@ static int domain_context_mapping_one(
  
         context_set_address_root(*context, virt_to_maddr(hd->pgd));
         context_set_translation_type(*context, CONTEXT_TT_MULTI_LEVEL);
-    }
+#ifdef CONTEXT_PASSTHRU
+    }
+#endif
 
     context_set_fault_enable(*context);
     context_set_present(*context);
@@ -1462,7 +1519,6 @@ void iommu_domain_teardown(struct domain
                 if ( pgd[0].val != 0 )
                     free_xenheap_page((void*)maddr_to_virt(
                         dma_pte_addr(pgd[0])));
-
                 free_xenheap_page((void *)hd->pgd);
             }
             break;
@@ -1503,9 +1559,11 @@ int iommu_map_page(struct domain *d, pad
     drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list);
     iommu = drhd->iommu;
 
+#ifdef CONTEXT_PASSTHRU
     /* do nothing if dom0 and iommu supports pass thru */
     if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
         return 0;
+#endif
 
     pg = addr_to_dma_page(d, gfn << PAGE_SHIFT_4K);
     if ( !pg )
@@ -1538,9 +1596,11 @@ int iommu_unmap_page(struct domain *d, d
     drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list);
     iommu = drhd->iommu;
 
+#ifdef CONTEXT_PASSTHRU
     /* do nothing if dom0 and iommu supports pass thru */
     if ( ecap_pass_thru(iommu->ecap) && (d->domain_id == 0) )
         return 0;
+#endif
 
     dma_pte_clear_one(d, gfn << PAGE_SHIFT_4K);
 
@@ -1711,7 +1771,7 @@ void __init setup_dom0_devices(void)
                 pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
 }
 
-void clear_fault_bit(struct iommu *iommu)
+void clear_fault_bits(struct iommu *iommu)
 {
     u64 val;
 
@@ -1722,13 +1782,15 @@ void clear_fault_bit(struct iommu *iommu
         iommu->reg,
         cap_fault_reg_offset(dmar_readq(iommu->reg,DMAR_CAP_REG))+8,
         val);
-    dmar_writel(iommu->reg, DMAR_FSTS_REG, DMA_FSTS_PFO);
+    dmar_writel(iommu->reg, DMAR_FSTS_REG, DMA_FSTS_FAULTS);
 }
 
 static int init_vtd_hw(void)
 {
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu;
+    struct iommu_flush *flush = NULL;
+    int vector;
     int ret;
 
     for_each_drhd_unit ( drhd )
@@ -1740,29 +1802,37 @@ static int init_vtd_hw(void)
             gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: set root entry failed\n");
             return -EIO;
         }
-    }
-
-    return 0;
-}
-
-static int enable_vtd_translation(void)
-{
-    struct acpi_drhd_unit *drhd;
-    struct iommu *iommu;
-    int vector = 0;
-
-    for_each_drhd_unit ( drhd )
-    {
-        iommu = drhd->iommu;
+
         vector = iommu_set_interrupt(iommu);
         dma_msi_data_init(iommu, vector);
         dma_msi_addr_init(iommu, cpu_physical_id(first_cpu(cpu_online_map)));
         iommu->vector = vector;
-        clear_fault_bit(iommu);
+        clear_fault_bits(iommu);
+        dmar_writel(iommu->reg, DMAR_FECTL_REG, 0);
+
+        /* initialize flush functions */
+        flush = iommu_get_flush(iommu);
+        flush->context = flush_context_reg;
+        flush->iotlb = flush_iotlb_reg;
+
+        if ( qinval_setup(iommu) != 0);
+            dprintk(XENLOG_ERR VTDPREFIX,
+                    "Queued Invalidation hardware not found\n");
+    }
+    return 0;
+}
+
+static int enable_vtd_translation(void)
+{
+    struct acpi_drhd_unit *drhd;
+    struct iommu *iommu;
+
+    for_each_drhd_unit ( drhd )
+    {
+        iommu = drhd->iommu;
         if ( iommu_enable_translation(iommu) )
             return -EIO;
     }
-
     return 0;
 }
 
@@ -1792,9 +1862,6 @@ int iommu_setup(void)
 
     spin_lock_init(&domid_bitmap_lock);
     INIT_LIST_HEAD(&hd->pdev_list);
-
-    /* start from scratch */
-    iommu_flush_all();
 
     /* setup clflush size */
     x86_clflush_size = ((cpuid_ebx(1) >> 8) & 0xff) * 8;
@@ -1815,12 +1882,12 @@ int iommu_setup(void)
     for ( i = 0; i < max_page; i++ )
         iommu_map_page(dom0, i, i);
 
+    enable_vtd_translation();
     if ( init_vtd_hw() )
         goto error;
     setup_dom0_devices();
     setup_dom0_rmrr();
-    if ( enable_vtd_translation() )
-        goto error;
+    iommu_flush_all();
 
     return 0;
 
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/hvm/vmx/vtd/qinval.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/hvm/vmx/vtd/qinval.c Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Copyright (C) Allen Kay <allen.m.kay@xxxxxxxxx>
+ * Copyright (C) Xiaohui Xin <xiaohui.xin@xxxxxxxxx>
+ */
+
+
+#include <xen/init.h>
+#include <xen/irq.h>
+#include <xen/spinlock.h>
+#include <xen/sched.h>
+#include <xen/xmalloc.h>
+#include <xen/domain_page.h>
+#include <asm/delay.h>
+#include <asm/string.h>
+#include <asm/iommu.h>
+#include <asm/hvm/vmx/intel-iommu.h>
+#include "dmar.h"
+#include "vtd.h"
+#include "pci-direct.h"
+#include "pci_regs.h"
+#include "msi.h"
+#include "extern.h"
+
+static void print_qi_regs(struct iommu *iommu)
+{
+    u64 val;
+
+    val = dmar_readq(iommu->reg, DMAR_IQA_REG);
+    printk("DMAR_IAQ_REG = %"PRIx64"\n", val);
+
+    val = dmar_readq(iommu->reg, DMAR_IQH_REG);
+    printk("DMAR_IAH_REG = %"PRIx64"\n", val);
+
+    val = dmar_readq(iommu->reg, DMAR_IQT_REG);
+    printk("DMAR_IAT_REG = %"PRIx64"\n", val);
+}
+
+static int qinval_next_index(struct iommu *iommu)
+{
+    u64 val;
+    val = dmar_readq(iommu->reg, DMAR_IQT_REG);
+    return (val >> 4);
+}
+
+static int qinval_update_qtail(struct iommu *iommu, int index)
+{
+    u64 val;
+
+    /* Need an ASSERT to insure that we have got register lock */
+    val = (index < (QINVAL_ENTRY_NR-1)) ? (index + 1) : 0;
+    dmar_writeq(iommu->reg, DMAR_IQT_REG, (val << 4));
+    return 0;
+}
+
+static int gen_cc_inv_dsc(struct iommu *iommu, int index,
+    u16 did, u16 source_id, u8 function_mask, u8 granu)
+{
+    u64 *ptr64;
+    unsigned long flags;
+    struct qinval_entry * qinval_entry = NULL;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    spin_lock_irqsave(&qi_ctrl->qinval_lock, flags);
+    qinval_entry = &qi_ctrl->qinval[index];
+    qinval_entry->q.cc_inv_dsc.lo.type = TYPE_INVAL_CONTEXT;
+    qinval_entry->q.cc_inv_dsc.lo.granu = granu;
+    qinval_entry->q.cc_inv_dsc.lo.res_1 = 0;
+    qinval_entry->q.cc_inv_dsc.lo.did = did;
+    qinval_entry->q.cc_inv_dsc.lo.sid = source_id;
+    qinval_entry->q.cc_inv_dsc.lo.fm = function_mask;
+    qinval_entry->q.cc_inv_dsc.lo.res_2 = 0;
+    qinval_entry->q.cc_inv_dsc.hi.res = 0;
+    spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags);
+
+    ptr64 = (u64 *)qinval_entry;
+    return 0;
+}
+
+int queue_invalidate_context(struct iommu *iommu,
+    u16 did, u16 source_id, u8 function_mask, u8 granu)
+{
+    int ret = -1;
+    unsigned long flags;
+    int index = -1;
+
+    spin_lock_irqsave(&iommu->register_lock, flags);
+    index = qinval_next_index(iommu);
+    if (index == -1)
+        return -EBUSY;
+    ret = gen_cc_inv_dsc(iommu, index, did, source_id,
+                         function_mask, granu);
+    ret |= qinval_update_qtail(iommu, index);
+    spin_unlock_irqrestore(&iommu->register_lock, flags);
+    return ret;
+}
+
+static int gen_iotlb_inv_dsc(struct iommu *iommu, int index,
+    u8 granu, u8 dr, u8 dw, u16 did, u8 am, u8 ih, u64 addr)
+{
+    unsigned long flags;
+    struct qinval_entry * qinval_entry = NULL;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    if ( index == -1 )
+        return -1;
+    spin_lock_irqsave(&qi_ctrl->qinval_lock, flags);
+
+    qinval_entry = &qi_ctrl->qinval[index];
+    qinval_entry->q.iotlb_inv_dsc.lo.type = TYPE_INVAL_IOTLB;
+    qinval_entry->q.iotlb_inv_dsc.lo.granu = granu;
+    qinval_entry->q.iotlb_inv_dsc.lo.dr = 0;
+    qinval_entry->q.iotlb_inv_dsc.lo.dw = 0;
+    qinval_entry->q.iotlb_inv_dsc.lo.res_1 = 0;
+    qinval_entry->q.iotlb_inv_dsc.lo.did = did;
+    qinval_entry->q.iotlb_inv_dsc.lo.res_2 = 0;
+
+    qinval_entry->q.iotlb_inv_dsc.hi.am = am;
+    qinval_entry->q.iotlb_inv_dsc.hi.ih = ih;
+    qinval_entry->q.iotlb_inv_dsc.hi.res_1 = 0;
+    qinval_entry->q.iotlb_inv_dsc.hi.addr = addr;
+
+    spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags);
+    return 0;
+}
+
+int queue_invalidate_iotlb(struct iommu *iommu,
+    u8 granu, u8 dr, u8 dw, u16 did, u8 am, u8 ih, u64 addr)
+{
+    int ret = -1;
+    unsigned long flags;
+    int index = -1;
+
+    spin_lock_irqsave(&iommu->register_lock, flags);
+
+    index = qinval_next_index(iommu);
+    ret = gen_iotlb_inv_dsc(iommu, index, granu, dr, dw, did,
+                            am, ih, addr);
+    ret |= qinval_update_qtail(iommu, index);
+    spin_unlock_irqrestore(&iommu->register_lock, flags);
+    return ret;
+}
+
+static int gen_wait_dsc(struct iommu *iommu, int index,
+    u8 iflag, u8 sw, u8 fn, u32 sdata, volatile u32 *saddr)
+{
+    u64 *ptr64;
+    unsigned long flags;
+    struct qinval_entry * qinval_entry = NULL;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    if ( index == -1 )
+        return -1;
+    spin_lock_irqsave(&qi_ctrl->qinval_lock, flags);
+    qinval_entry = &qi_ctrl->qinval[index];
+    qinval_entry->q.inv_wait_dsc.lo.type = TYPE_INVAL_WAIT;
+    qinval_entry->q.inv_wait_dsc.lo.iflag = iflag;
+    qinval_entry->q.inv_wait_dsc.lo.sw = sw;
+    qinval_entry->q.inv_wait_dsc.lo.fn = fn;
+    qinval_entry->q.inv_wait_dsc.lo.res_1 = 0;
+    qinval_entry->q.inv_wait_dsc.lo.sdata = sdata;
+    qinval_entry->q.inv_wait_dsc.hi.res_1 = 0;
+    qinval_entry->q.inv_wait_dsc.hi.saddr = virt_to_maddr(saddr) >> 2;
+    spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags);
+    ptr64 = (u64 *)qinval_entry;
+    return 0;
+}
+
+static int queue_invalidate_wait(struct iommu *iommu,
+    u8 iflag, u8 sw, u8 fn, u32 sdata, volatile u32 *saddr)
+{
+    unsigned long flags;
+    unsigned long start_time;
+    int index = -1;
+    int ret = -1;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    spin_lock_irqsave(&qi_ctrl->qinval_poll_lock, flags);
+    spin_lock_irqsave(&iommu->register_lock, flags);
+    index = qinval_next_index(iommu);
+    if (*saddr == 1)
+        *saddr = 0;
+    ret = gen_wait_dsc(iommu, index, iflag, sw, fn, sdata, saddr);
+    ret |= qinval_update_qtail(iommu, index);
+    spin_unlock_irqrestore(&iommu->register_lock, flags);
+
+    /* Now we don't support interrupt method */
+    if ( sw )
+    {
+        /* In case all wait descriptor writes to same addr with same data */
+        start_time = jiffies;
+        while ( *saddr != 1 ) {
+            if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT)) {
+                print_qi_regs(iommu);
+                panic("queue invalidate wait descriptor was not executed\n");
+            }
+            cpu_relax();
+        }
+    }
+    spin_unlock_irqrestore(&qi_ctrl->qinval_poll_lock, flags);
+    return ret;
+}
+
+int invalidate_sync(struct iommu *iommu)
+{
+    int ret = -1;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    if (qi_ctrl->qinval)
+    {
+        ret = queue_invalidate_wait(iommu,
+            0, 1, 1, 1, &qi_ctrl->qinval_poll_status);
+        return ret;
+    }
+    return 0;
+}
+
+static int gen_dev_iotlb_inv_dsc(struct iommu *iommu, int index,
+    u32 max_invs_pend, u16 sid, u16 size, u64 addr)
+{
+    unsigned long flags;
+    struct qinval_entry * qinval_entry = NULL;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    if ( index == -1 )
+        return -1;
+    spin_lock_irqsave(&qi_ctrl->qinval_lock, flags);
+
+    qinval_entry = &qi_ctrl->qinval[index];
+    qinval_entry->q.dev_iotlb_inv_dsc.lo.type = TYPE_INVAL_DEVICE_IOTLB;
+    qinval_entry->q.dev_iotlb_inv_dsc.lo.res_1 = 0;
+    qinval_entry->q.dev_iotlb_inv_dsc.lo.max_invs_pend = max_invs_pend;
+    qinval_entry->q.dev_iotlb_inv_dsc.lo.res_2 = 0;
+    qinval_entry->q.dev_iotlb_inv_dsc.lo.sid = sid;
+    qinval_entry->q.dev_iotlb_inv_dsc.lo.res_3 = 0;
+
+    qinval_entry->q.dev_iotlb_inv_dsc.hi.size = size;
+    qinval_entry->q.dev_iotlb_inv_dsc.hi.addr = addr;
+
+    spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags);
+    return 0;
+}
+
+int queue_invalidate_device_iotlb(struct iommu *iommu,
+    u32 max_invs_pend, u16 sid, u16 size, u64 addr)
+{
+    int ret = -1;
+    unsigned long flags;
+    int index = -1;
+
+    spin_lock_irqsave(&iommu->register_lock, flags);
+    index = qinval_next_index(iommu);
+    ret = gen_dev_iotlb_inv_dsc(iommu, index, max_invs_pend,
+                                sid, size, addr);
+    ret |= qinval_update_qtail(iommu, index);
+    spin_unlock_irqrestore(&iommu->register_lock, flags);
+    return ret;
+}
+
+static int gen_iec_inv_dsc(struct iommu *iommu, int index,
+    u8 granu, u8 im, u16 iidx)
+{
+    unsigned long flags;
+    struct qinval_entry * qinval_entry = NULL;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    if ( index == -1 )
+        return -1;
+    spin_lock_irqsave(&qi_ctrl->qinval_lock, flags);
+
+    qinval_entry = &qi_ctrl->qinval[index];
+    qinval_entry->q.iec_inv_dsc.lo.type = TYPE_INVAL_IEC;
+    qinval_entry->q.iec_inv_dsc.lo.granu = granu;
+    qinval_entry->q.iec_inv_dsc.lo.res_1 = 0;
+    qinval_entry->q.iec_inv_dsc.lo.im = im;
+    qinval_entry->q.iec_inv_dsc.lo.iidx = iidx;
+    qinval_entry->q.iec_inv_dsc.lo.res_2 = 0;
+    qinval_entry->q.iec_inv_dsc.hi.res = 0;
+
+    spin_unlock_irqrestore(&qi_ctrl->qinval_lock, flags);
+    return 0;
+}
+
+int queue_invalidate_iec(struct iommu *iommu, u8 granu, u8 im, u16 iidx)
+{
+    int ret;
+    unsigned long flags;
+    int index = -1;
+
+    spin_lock_irqsave(&iommu->register_lock, flags);
+    index = qinval_next_index(iommu);
+    ret = gen_iec_inv_dsc(iommu, index, granu, im, iidx);
+    ret |= qinval_update_qtail(iommu, index);
+    spin_unlock_irqrestore(&iommu->register_lock, flags);
+    return ret;
+}
+
+u64 iec_cap;
+int __iommu_flush_iec(struct iommu *iommu, u8 granu, u8 im, u16 iidx)
+{
+    int ret;
+    ret = queue_invalidate_iec(iommu, granu, im, iidx);
+    ret |= invalidate_sync(iommu);
+
+    /*
+     * reading vt-d architecture register will ensure
+     * draining happens in implementation independent way.
+     */
+    iec_cap = dmar_readq(iommu->reg, DMAR_CAP_REG);
+    return ret;
+}
+
+int iommu_flush_iec_global(struct iommu *iommu)
+{
+    return __iommu_flush_iec(iommu, IEC_GLOBAL_INVL, 0, 0);
+}
+
+int iommu_flush_iec_index(struct iommu *iommu, u8 im, u16 iidx)
+{
+   return __iommu_flush_iec(iommu, IEC_INDEX_INVL, im, iidx);
+}
+
+static int flush_context_qi(
+    void *_iommu, u16 did, u16 sid, u8 fm, u64 type,
+    int non_present_entry_flush)
+{
+    int ret = 0;
+    struct iommu *iommu = (struct iommu *)_iommu;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    /*
+     * In the non-present entry flush case, if hardware doesn't cache
+     * non-present entry we do nothing and if hardware cache non-present
+     * entry, we flush entries of domain 0 (the domain id is used to cache
+     * any non-present entries)
+     */
+    if ( non_present_entry_flush )
+    {
+        if ( !cap_caching_mode(iommu->cap) )
+            return 1;
+        else
+            did = 0;
+    }
+
+    if (qi_ctrl->qinval)
+    {
+        ret = queue_invalidate_context(iommu, did, sid, fm,
+                                       type >> DMA_CCMD_INVL_GRANU_OFFSET);
+        ret |= invalidate_sync(iommu);
+    }
+    return ret;
+}
+
+static int flush_iotlb_qi(
+    void *_iommu, u16 did,
+    u64 addr, unsigned int size_order, u64 type,
+    int non_present_entry_flush)
+{
+    u8 dr = 0, dw = 0;
+    int ret = 0;
+    struct iommu *iommu = (struct iommu *)_iommu;
+    struct qi_ctrl *qi_ctrl = iommu_qi_ctrl(iommu);
+
+    /*
+     * In the non-present entry flush case, if hardware doesn't cache
+     * non-present entry we do nothing and if hardware cache non-present
+     * entry, we flush entries of domain 0 (the domain id is used to cache
+     * any non-present entries)
+     */
+    if ( non_present_entry_flush )
+    {
+        if ( !cap_caching_mode(iommu->cap) )
+            return 1;
+        else
+            did = 0;
+    }
+
+    if (qi_ctrl->qinval) {
+        /* use queued invalidation */
+        if (cap_write_drain(iommu->cap))
+            dw = 1;
+        if (cap_read_drain(iommu->cap))
+            dr = 1;
+        /* Need to conside the ih bit later */
+        ret = queue_invalidate_iotlb(iommu,
+                  (type >> DMA_TLB_FLUSH_GRANU_OFFSET), dr,
+                  dw, did, (u8)size_order, 0, addr);
+        ret |= invalidate_sync(iommu);
+    }
+    return ret;
+}
+
+int qinval_setup(struct iommu *iommu)
+{
+    unsigned long start_time;
+    u64 paddr;
+    u32 status = 0;
+    struct qi_ctrl *qi_ctrl;
+    struct iommu_flush *flush;
+
+    qi_ctrl = iommu_qi_ctrl(iommu);
+    flush = iommu_get_flush(iommu);
+
+    if ( !ecap_queued_inval(iommu->ecap) )
+        return -ENODEV;
+
+    if (qi_ctrl->qinval == NULL) {
+        qi_ctrl->qinval = alloc_xenheap_page();
+        if (qi_ctrl->qinval == NULL)
+            panic("Cannot allocate memory for qi_ctrl->qinval\n");
+        memset((u8*)qi_ctrl->qinval, 0, PAGE_SIZE_4K);
+        flush->context = flush_context_qi;
+        flush->iotlb = flush_iotlb_qi;
+    }
+    paddr = virt_to_maddr(qi_ctrl->qinval);
+
+    /* Setup Invalidation Queue Address(IQA) register with the
+     * address of the page we just allocated.  QS field at
+     * bits[2:0] to indicate size of queue is one 4KB page.
+     * That's 256 entries.  Queued Head (IQH) and Queue Tail (IQT)
+     * registers are automatically reset to 0 with write
+     * to IQA register.
+     */
+    dmar_writeq(iommu->reg, DMAR_IQA_REG, paddr);
+
+    /* enable queued invalidation hardware */
+    iommu->gcmd |= DMA_GCMD_QIE;
+    dmar_writel(iommu->reg, DMAR_GCMD_REG, iommu->gcmd);
+
+    /* Make sure hardware complete it */
+    start_time = jiffies;
+    while (1) {
+        status = dmar_readl(iommu->reg, DMAR_GSTS_REG);
+        if (status & DMA_GSTS_QIES)
+            break;
+        if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))
+            panic("Cannot set QIE field for queue invalidation\n");
+        cpu_relax();
+    }
+    status = 0;
+    return status;
+}
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/hvm/vmx/vtd/vtd.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/hvm/vmx/vtd/vtd.h    Tue Jan 22 08:30:40 2008 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2006, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * Copyright (C) Allen Kay <allen.m.kay@xxxxxxxxx>
+ * Copyright (C) Weidong Han <weidong.han@xxxxxxxxx>
+ */
+
+#ifndef _VTD_H_
+#define _VTD_H_
+
+#include <xen/list.h>
+#include <asm/iommu.h>
+
+#define VTDPREFIX "[VT-D]" 
+
+#define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */
+#define time_after(a,b)         \
+        (typecheck(unsigned long, a) && \
+         typecheck(unsigned long, b) && \
+         ((long)(b) - (long)(a) < 0))
+
+struct IO_APIC_route_remap_entry {
+    union {
+        u64 val;
+        struct {
+            u64 vector:8,
+            delivery_mode:3,
+            index_15:1,
+            delivery_status:1,
+            polarity:1,
+            irr:1,
+            trigger:1,
+            mask:1,
+            reserved:31,
+            format:1,
+            index_0_14:15;
+        };
+    };
+};
+
+#endif // _VTD_H_
diff -r 29268e3fc7ab -r 603ea719d73a xen/arch/x86/oprofile/nmi_int.c
--- a/xen/arch/x86/oprofile/nmi_int.c   Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/arch/x86/oprofile/nmi_int.c   Tue Jan 22 08:30:40 2008 -0700
@@ -295,17 +295,16 @@ static int __init ppro_init(char ** cpu_
 {
        __u8 cpu_model = current_cpu_data.x86_model;
 
-       if (cpu_model > 15) {
+       if (cpu_model == 15 || cpu_model == 23)
+               *cpu_type = "i386/core_2";
+       else if (cpu_model == 14)
+               *cpu_type = "i386/core";
+       else if (cpu_model > 13) {
                printk("xenoprof: Initialization failed. "
                       "Intel processor model %d for P6 class family is not "
                       "supported\n", cpu_model);
                return 0;
-       }
-       else if (cpu_model == 15)
-               *cpu_type = "i386/core_2";
-       else if (cpu_model == 14)
-               *cpu_type = "i386/core";
-       else if (cpu_model == 9)
+       } else if (cpu_model == 9)
                *cpu_type = "i386/p6_mobile";
        else if (cpu_model > 5)
                *cpu_type = "i386/piii";
diff -r 29268e3fc7ab -r 603ea719d73a xen/include/asm-x86/iommu.h
--- a/xen/include/asm-x86/iommu.h       Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/include/asm-x86/iommu.h       Tue Jan 22 08:30:40 2008 -0700
@@ -31,6 +31,9 @@ extern int vtd_enabled;
 
 #define domain_hvm_iommu(d)     (&d->arch.hvm_domain.hvm_iommu)
 #define domain_vmx_iommu(d)     (&d->arch.hvm_domain.hvm_iommu.vmx_iommu)
+#define iommu_qi_ctrl(iommu)    (&(iommu->intel.qi_ctrl));
+#define iommu_ir_ctrl(iommu)    (&(iommu->intel.ir_ctrl));
+#define iommu_get_flush(iommu)  (&(iommu->intel.flush));
 
 /*
  * The PCI interface treats multi-function devices as independent
@@ -61,6 +64,7 @@ struct iommu {
     spinlock_t register_lock; /* protect iommu register handling */
     struct root_entry *root_entry; /* virtual address */
     unsigned int vector;
+    struct intel_iommu intel;
 };
 
 int iommu_setup(void);
diff -r 29268e3fc7ab -r 603ea719d73a xen/include/public/physdev.h
--- a/xen/include/public/physdev.h      Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/include/public/physdev.h      Tue Jan 22 08:30:40 2008 -0700
@@ -81,7 +81,11 @@ DEFINE_XEN_GUEST_HANDLE(physdev_set_iopl
 #define PHYSDEVOP_set_iobitmap           7
 struct physdev_set_iobitmap {
     /* IN */
-    XEN_GUEST_HANDLE_00030205(uint8) bitmap;
+#if __XEN_INTERFACE_VERSION__ >= 0x00030205
+    XEN_GUEST_HANDLE(uint8) bitmap;
+#else
+    uint8_t *bitmap;
+#endif
     uint32_t nr_ports;
 };
 typedef struct physdev_set_iobitmap physdev_set_iobitmap_t;
diff -r 29268e3fc7ab -r 603ea719d73a xen/include/public/xen-compat.h
--- a/xen/include/public/xen-compat.h   Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/include/public/xen-compat.h   Tue Jan 22 08:30:40 2008 -0700
@@ -41,11 +41,4 @@
 #error "These header files do not support the requested interface version."
 #endif
 
-/* Fields defined as a Xen guest handle since 0x00030205. */
-#if __XEN_INTERFACE_VERSION__ >= 0x00030205
-#define XEN_GUEST_HANDLE_00030205(type) XEN_GUEST_HANDLE(type)
-#else
-#define XEN_GUEST_HANDLE_00030205(type) type *
-#endif
-
 #endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
diff -r 29268e3fc7ab -r 603ea719d73a xen/include/public/xen.h
--- a/xen/include/public/xen.h  Tue Jan 22 08:27:29 2008 -0700
+++ b/xen/include/public/xen.h  Tue Jan 22 08:30:40 2008 -0700
@@ -263,7 +263,11 @@ struct mmuext_op {
         /* SET_LDT */
         unsigned int nr_ents;
         /* TLB_FLUSH_MULTI, INVLPG_MULTI */
-        XEN_GUEST_HANDLE_00030205(void) vcpumask;
+#if __XEN_INTERFACE_VERSION__ >= 0x00030205
+        XEN_GUEST_HANDLE(void) vcpumask;
+#else
+        void *vcpumask;
+#endif
     } arg2;
 };
 typedef struct mmuext_op mmuext_op_t;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging), Xen patchbot-unstable <=