[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] merge with xen-unstable.hg



# HG changeset patch
# User awilliam@xxxxxxxxxxxx
# Date 1168443647 25200
# Node ID 58633caeece9df2d36c395c9c926521bcbd6fcd8
# Parent  42babffffba5b0ec0a9e6dd2501a8fc65c8c9b84
# Parent  0b679a6d8ad083022d2a0463ff3a5fa5a852c7c4
merge with xen-unstable.hg
---
 .hgignore                                                            |    2 
 .hgtags                                                              |    1 
 Config.mk                                                            |    2 
 buildconfigs/mk.linux-2.6-xen                                        |   31 
 config/StdGNU.mk                                                     |    2 
 config/SunOS.mk                                                      |    2 
 config/x86_64.mk                                                     |    1 
 docs/xen-api/wire-protocol.tex                                       |   83 
 docs/xen-api/xenapi-datamodel.tex                                    | 1234 
+++++-----
 linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c                  |    5 
 linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c                  |   46 
 linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c                      |   20 
 linux-2.6-xen-sparse/arch/i386/pci/irq-xen.c                         |    5 
 linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c                |   49 
 linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c                      |   28 
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c                   |    6 
 linux-2.6-xen-sparse/drivers/xen/blkback/common.h                    |    1 
 linux-2.6-xen-sparse/drivers/xen/blkback/interface.c                 |   21 
 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c                 |   19 
 linux-2.6-xen-sparse/drivers/xen/blkfront/block.h                    |    2 
 linux-2.6-xen-sparse/drivers/xen/blktap/Makefile                     |    4 
 linux-2.6-xen-sparse/drivers/xen/blktap/common.h                     |    1 
 linux-2.6-xen-sparse/drivers/xen/blktap/interface.c                  |   21 
 linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c              |    2 
 linux-2.6-xen-sparse/drivers/xen/core/evtchn.c                       |  196 +
 linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c                |    4 
 linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c                     |   18 
 linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c                    |   16 
 linux-2.6-xen-sparse/drivers/xen/netback/common.h                    |    1 
 linux-2.6-xen-sparse/drivers/xen/netback/interface.c                 |   17 
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c                 |  124 -
 linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c                    |   10 
 linux-2.6-xen-sparse/drivers/xen/tpmback/common.h                    |    1 
 linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c                 |   21 
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c              |   22 
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c               |    2 
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h         |    2 
 linux-2.6-xen-sparse/include/asm-ia64/swiotlb.h                      |   45 
 linux-2.6-xen-sparse/include/xen/evtchn.h                            |   43 
 linux-2.6-xen-sparse/include/xen/xenbus.h                            |    8 
 linux-2.6-xen-sparse/kernel/kexec.c                                  |    8 
 linux-2.6-xen-sparse/net/core/dev.c                                  |    3 
 patches/linux-2.6.16.33/vsnprintf.patch                              |    1 
 tools/Rules.mk                                                       |    2 
 tools/blktap/drivers/block-qcow.c                                    |  133 -
 tools/blktap/drivers/qcow-create.c                                   |   26 
 tools/examples/Makefile                                              |    1 
 tools/examples/blktap                                                |    2 
 tools/examples/block                                                 |    2 
 tools/examples/block-enbd                                            |    2 
 tools/examples/block-nbd                                             |    2 
 tools/examples/external-device-migrate                               |    2 
 tools/examples/network-bridge                                        |    2 
 tools/examples/network-nat                                           |    2 
 tools/examples/network-route                                         |    2 
 tools/examples/vif-bridge                                            |    2 
 tools/examples/vif-common.sh                                         |    8 
 tools/examples/vif-nat                                               |    2 
 tools/examples/vif-route                                             |    2 
 tools/examples/vtpm                                                  |    2 
 tools/examples/vtpm-delete                                           |    2 
 tools/examples/xen-backend.agent                                     |    2 
 tools/examples/xen-hotplug-cleanup                                   |    2 
 tools/examples/xm-config.xml                                         |    2 
 tools/examples/xmexample.hvm                                         |    4 
 tools/firmware/etherboot/README                                      |    7 
 tools/firmware/hvmloader/Makefile                                    |    3 
 tools/firmware/hvmloader/acpi/Makefile                               |    2 
 tools/firmware/hvmloader/acpi/acpi2_0.h                              |   44 
 tools/firmware/hvmloader/acpi/build.c                                |   69 
 tools/firmware/hvmloader/acpi/dsdt.asl                               |   18 
 tools/firmware/hvmloader/acpi/dsdt.c                                 |  648 
++---
 tools/firmware/hvmloader/acpi/ssdt_tpm.asl                           |    4 
 tools/firmware/hvmloader/acpi/ssdt_tpm.h                             |   10 
 tools/firmware/hvmloader/acpi/static_tables.c                        |    4 
 tools/firmware/hvmloader/config.h                                    |    3 
 tools/firmware/hvmloader/hvmloader.c                                 |   29 
 tools/firmware/hvmloader/mp_tables.c                                 |    4 
 tools/firmware/rombios/rombios.c                                     |  482 ++-
 tools/firmware/vmxassist/vm86.c                                      |   24 
 tools/ioemu/hw/pc.c                                                  |    2 
 tools/ioemu/hw/vga.c                                                 |   11 
 tools/ioemu/hw/vga_int.h                                             |    1 
 tools/ioemu/patches/domain-timeoffset                                |   10 
 tools/ioemu/patches/fix-interrupt-routing                            |   17 
 tools/ioemu/patches/ioemu-ia64                                       |   38 
 tools/ioemu/patches/qemu-bootorder                                   |   26 
 tools/ioemu/patches/series                                           |    2 
 tools/ioemu/patches/tpm-tis-device                                   |    9 
 tools/ioemu/patches/vnc-display-find-unused                          |    8 
 tools/ioemu/patches/vnc-fixes                                        |    8 
 tools/ioemu/patches/vnc-listen-specific-interface                    |    8 
 tools/ioemu/patches/vnc-password                                     |   14 
 tools/ioemu/patches/vnc-start-vncviewer                              |    8 
 tools/ioemu/patches/xen-mapcache                                     |  285 --
 tools/ioemu/patches/xen-support-buffered-ioreqs                      |    6 
 tools/ioemu/patches/xenstore-block-device-config                     |   19 
 tools/ioemu/patches/xenstore-write-vnc-port                          |    8 
 tools/ioemu/target-i386-dm/exec-dm.c                                 |    1 
 tools/ioemu/target-i386-dm/helper2.c                                 |   21 
 tools/ioemu/vl.c                                                     |    2 
 tools/ioemu/vnc.c                                                    |   51 
 tools/ioemu/vnchextile.h                                             |    4 
 tools/libxc/xc_hvm_build.c                                           |    3 
 tools/libxc/xc_linux_build.c                                         |    4 
 tools/libxc/xc_linux_restore.c                                       |    2 
 tools/libxc/xc_linux_save.c                                          |   64 
 tools/libxc/xc_load_bin.c                                            |   26 
 tools/libxc/xc_load_elf.c                                            |   91 
 tools/libxc/xg_private.h                                             |    6 
 tools/libxc/xg_save_restore.h                                        |   15 
 tools/libxen/include/xen_cpu_feature.h                               |    4 
 tools/libxen/src/xen_common.c                                        |   48 
 tools/libxen/src/xen_cpu_feature.c                                   |    4 
 tools/pygrub/src/pygrub                                              |  232 +
 tools/python/Makefile                                                |   18 
 tools/python/scripts/xapi.py                                         |   95 
 tools/python/xen/lowlevel/acm/acm.c                                  |   33 
 tools/python/xen/util/Brctl.py                                       |   25 
 tools/python/xen/util/security.py                                    |   12 
 tools/python/xen/util/xmlrpclib2.py                                  |   46 
 tools/python/xen/xend/XendAPI.py                                     | 1015 
++++----
 tools/python/xen/xend/XendAPIConstants.py                            |    3 
 tools/python/xen/xend/XendAuthSessions.py                            |   13 
 tools/python/xen/xend/XendBootloader.py                              |    6 
 tools/python/xen/xend/XendConfig.py                                  |   90 
 tools/python/xen/xend/XendConstants.py                               |    1 
 tools/python/xen/xend/XendDomain.py                                  |   51 
 tools/python/xen/xend/XendDomainInfo.py                              |   84 
 tools/python/xen/xend/XendError.py                                   |   11 
 tools/python/xen/xend/XendLogging.py                                 |   23 
 tools/python/xen/xend/XendNetwork.py                                 |  112 
 tools/python/xen/xend/XendNode.py                                    |  234 +
 tools/python/xen/xend/XendPIF.py                                     |  198 +
 tools/python/xen/xend/XendRoot.py                                    |    8 
 tools/python/xen/xend/XendStateStore.py                              |  210 +
 tools/python/xen/xend/XendStorageRepository.py                       |  184 -
 tools/python/xen/xend/XendVDI.py                                     |   15 
 tools/python/xen/xend/image.py                                       |   18 
 tools/python/xen/xend/osdep.py                                       |    5 
 tools/python/xen/xend/server/SrvDaemon.py                            |    2 
 tools/python/xen/xend/server/SrvServer.py                            |   16 
 tools/python/xen/xend/server/XMLRPCServer.py                         |   15 
 tools/python/xen/xend/server/netif.py                                |    8 
 tools/python/xen/xend/server/vfbif.py                                |    2 
 tools/python/xen/xm/XenAPI.py                                        |   75 
 tools/python/xen/xm/create.py                                        |   22 
 tools/python/xen/xm/main.py                                          |   49 
 tools/python/xen/xm/messages/en/xen-xm.po                            |   72 
 tools/python/xen/xm/migrate.py                                       |    1 
 tools/python/xen/xm/opts.py                                          |    8 
 tools/python/xen/xm/shutdown.py                                      |    1 
 tools/tests/test_x86_emulator.c                                      |  180 +
 tools/xenstat/xentop/Makefile                                        |    1 
 tools/xenstat/xentop/xentop.c                                        |   11 
 tools/xenstore/Makefile                                              |    2 
 tools/xenstore/list.h                                                |    2 
 tools/xm-test/lib/XmTestLib/DomainTracking.py                        |   43 
 tools/xm-test/lib/XmTestLib/XenDomain.py                             |   28 
 tools/xm-test/ramdisk/Makefile.am                                    |   13 
 tools/xm-test/ramdisk/skel/etc/init.d/rcS                            |   11 
 tools/xm-test/tests/block-destroy/06_block-destroy_check_list_pos.py |    8 
 tools/xm-test/tests/sched-credit/01_sched_credit_weight_cap_pos.py   |   33 
 unmodified_drivers/linux-2.6/platform-pci/evtchn.c                   |   75 
 xen/Makefile                                                         |   18 
 xen/Rules.mk                                                         |    1 
 xen/arch/ia64/xen/domain.c                                           |   22 
 xen/arch/ia64/xen/xenmisc.c                                          |   20 
 xen/arch/powerpc/domain.c                                            |    4 
 xen/arch/powerpc/domain_build.c                                      |    2 
 xen/arch/powerpc/domctl.c                                            |    6 
 xen/arch/powerpc/setup.c                                             |   13 
 xen/arch/powerpc/xen.lds.S                                           |    4 
 xen/arch/x86/boot/x86_32.S                                           |    2 
 xen/arch/x86/boot/x86_64.S                                           |   29 
 xen/arch/x86/compat.c                                                |   14 
 xen/arch/x86/crash.c                                                 |    3 
 xen/arch/x86/domain.c                                                |  711 
++++-
 xen/arch/x86/domain_build.c                                          |  236 +
 xen/arch/x86/domctl.c                                                |  113 
 xen/arch/x86/e820.c                                                  |   35 
 xen/arch/x86/hvm/Makefile                                            |    2 
 xen/arch/x86/hvm/hpet.c                                              |  409 +++
 xen/arch/x86/hvm/hvm.c                                               |  119 
 xen/arch/x86/hvm/i8254.c                                             |   59 
 xen/arch/x86/hvm/instrlen.c                                          |   32 
 xen/arch/x86/hvm/intercept.c                                         |   98 
 xen/arch/x86/hvm/io.c                                                |   33 
 xen/arch/x86/hvm/irq.c                                               |   65 
 xen/arch/x86/hvm/platform.c                                          |   24 
 xen/arch/x86/hvm/pmtimer.c                                           |    8 
 xen/arch/x86/hvm/rtc.c                                               |   80 
 xen/arch/x86/hvm/svm/intr.c                                          |   47 
 xen/arch/x86/hvm/svm/svm.c                                           |  182 -
 xen/arch/x86/hvm/vioapic.c                                           |    4 
 xen/arch/x86/hvm/vlapic.c                                            |  228 -
 xen/arch/x86/hvm/vmx/intr.c                                          |   12 
 xen/arch/x86/hvm/vmx/vmx.c                                           |  132 -
 xen/arch/x86/hvm/vpic.c                                              |   16 
 xen/arch/x86/hvm/vpt.c                                               |  234 +
 xen/arch/x86/irq.c                                                   |   12 
 xen/arch/x86/mm.c                                                    |  458 ++-
 xen/arch/x86/mm/shadow/common.c                                      |  401 +--
 xen/arch/x86/mm/shadow/multi.c                                       |  214 +
 xen/arch/x86/mm/shadow/multi.h                                       |    4 
 xen/arch/x86/mm/shadow/private.h                                     |  164 +
 xen/arch/x86/mm/shadow/types.h                                       |    4 
 xen/arch/x86/physdev.c                                               |   13 
 xen/arch/x86/platform_hypercall.c                                    |   19 
 xen/arch/x86/setup.c                                                 |   16 
 xen/arch/x86/sysctl.c                                                |    8 
 xen/arch/x86/time.c                                                  |   16 
 xen/arch/x86/traps.c                                                 |  342 ++
 xen/arch/x86/x86_32/mm.c                                             |   12 
 xen/arch/x86/x86_32/seg_fixup.c                                      |    5 
 xen/arch/x86/x86_32/traps.c                                          |    6 
 xen/arch/x86/x86_32/xen.lds.S                                        |   17 
 xen/arch/x86/x86_64/Makefile                                         |   19 
 xen/arch/x86/x86_64/asm-offsets.c                                    |   39 
 xen/arch/x86/x86_64/compat.c                                         |   30 
 xen/arch/x86/x86_64/compat/entry.S                                   |  365 ++
 xen/arch/x86/x86_64/compat/mm.c                                      |  329 ++
 xen/arch/x86/x86_64/compat/traps.c                                   |  338 ++
 xen/arch/x86/x86_64/domain.c                                         |   68 
 xen/arch/x86/x86_64/domctl.c                                         |  111 
 xen/arch/x86/x86_64/entry.S                                          |   29 
 xen/arch/x86/x86_64/mm.c                                             |   93 
 xen/arch/x86/x86_64/physdev.c                                        |   48 
 xen/arch/x86/x86_64/platform_hypercall.c                             |   29 
 xen/arch/x86/x86_64/sysctl.c                                         |   33 
 xen/arch/x86/x86_64/traps.c                                          |   19 
 xen/arch/x86/x86_64/xen.lds.S                                        |   17 
 xen/arch/x86/x86_emulate.c                                           |  843 
++++--
 xen/common/Makefile                                                  |   12 
 xen/common/acm_ops.c                                                 |   21 
 xen/common/compat/Makefile                                           |   13 
 xen/common/compat/acm_ops.c                                          |   47 
 xen/common/compat/domain.c                                           |   91 
 xen/common/compat/domctl.c                                           |  137 +
 xen/common/compat/grant_table.c                                      |  218 +
 xen/common/compat/kernel.c                                           |   59 
 xen/common/compat/kexec.c                                            |   33 
 xen/common/compat/memory.c                                           |  364 ++
 xen/common/compat/multicall.c                                        |   31 
 xen/common/compat/schedule.c                                         |   51 
 xen/common/compat/sysctl.c                                           |   95 
 xen/common/compat/xenoprof.c                                         |   40 
 xen/common/compat/xlat.c                                             |   73 
 xen/common/domain.c                                                  |   53 
 xen/common/domctl.c                                                  |   98 
 xen/common/elf.c                                                     |   65 
 xen/common/elf32.c                                                   |   19 
 xen/common/event_channel.c                                           |   21 
 xen/common/gdbstub.c                                                 |    2 
 xen/common/grant_table.c                                             |    4 
 xen/common/kernel.c                                                  |   31 
 xen/common/kexec.c                                                   |  166 -
 xen/common/keyhandler.c                                              |   13 
 xen/common/lib.c                                                     |   17 
 xen/common/memory.c                                                  |   22 
 xen/common/multicall.c                                               |    5 
 xen/common/page_alloc.c                                              |    2 
 xen/common/schedule.c                                                |   38 
 xen/common/symbols.c                                                 |    9 
 xen/common/sysctl.c                                                  |   18 
 xen/common/time.c                                                    |    4 
 xen/common/trace.c                                                   |   78 
 xen/common/vsprintf.c                                                |   18 
 xen/common/xenoprof.c                                                |   70 
 xen/common/xmalloc.c                                                 |    4 
 xen/drivers/char/ns16550.c                                           |    2 
 xen/include/Makefile                                                 |   69 
 xen/include/asm-ia64/init.h                                          |   25 
 xen/include/asm-ia64/shared.h                                        |    4 
 xen/include/asm-powerpc/init.h                                       |   19 
 xen/include/asm-powerpc/shared.h                                     |    4 
 xen/include/asm-x86/bitops.h                                         |   11 
 xen/include/asm-x86/compat.h                                         |    8 
 xen/include/asm-x86/config.h                                         |   63 
 xen/include/asm-x86/desc.h                                           |   99 
 xen/include/asm-x86/domain.h                                         |    5 
 xen/include/asm-x86/event.h                                          |   14 
 xen/include/asm-x86/hvm/hvm.h                                        |    6 
 xen/include/asm-x86/hvm/io.h                                         |    2 
 xen/include/asm-x86/hvm/irq.h                                        |   10 
 xen/include/asm-x86/hvm/support.h                                    |    1 
 xen/include/asm-x86/hvm/svm/vmcb.h                                   |    1 
 xen/include/asm-x86/hvm/vcpu.h                                       |    1 
 xen/include/asm-x86/hvm/vlapic.h                                     |   26 
 xen/include/asm-x86/hvm/vmx/cpu.h                                    |   13 
 xen/include/asm-x86/hvm/vpt.h                                        |  135 -
 xen/include/asm-x86/hypercall.h                                      |   20 
 xen/include/asm-x86/init.h                                           |   25 
 xen/include/asm-x86/ldt.h                                            |    3 
 xen/include/asm-x86/mm.h                                             |   28 
 xen/include/asm-x86/multicall.h                                      |   25 
 xen/include/asm-x86/page.h                                           |    5 
 xen/include/asm-x86/processor.h                                      |    6 
 xen/include/asm-x86/regs.h                                           |    3 
 xen/include/asm-x86/shadow.h                                         |  503 
+---
 xen/include/asm-x86/shared.h                                         |   78 
 xen/include/asm-x86/system.h                                         |    2 
 xen/include/asm-x86/uaccess.h                                        |   10 
 xen/include/asm-x86/x86_32/kexec.h                                   |    1 
 xen/include/asm-x86/x86_32/page-2level.h                             |    2 
 xen/include/asm-x86/x86_32/page-3level.h                             |    2 
 xen/include/asm-x86/x86_32/regs.h                                    |    2 
 xen/include/asm-x86/x86_32/uaccess.h                                 |    2 
 xen/include/asm-x86/x86_64/kexec.h                                   |    1 
 xen/include/asm-x86/x86_64/page.h                                    |    7 
 xen/include/asm-x86/x86_64/regs.h                                    |    7 
 xen/include/asm-x86/x86_64/uaccess.h                                 |   15 
 xen/include/asm-x86/x86_emulate.h                                    |   24 
 xen/include/public/arch-x86/xen-x86_32.h                             |  151 +
 xen/include/public/arch-x86/xen-x86_64.h                             |  211 +
 xen/include/public/arch-x86/xen.h                                    |  200 +
 xen/include/public/arch-x86_32.h                                     |  247 --
 xen/include/public/arch-x86_64.h                                     |  316 --
 xen/include/public/domctl.h                                          |    5 
 xen/include/public/hvm/ioreq.h                                       |    5 
 xen/include/public/xen.h                                             |   10 
 xen/include/public/xenoprof.h                                        |    2 
 xen/include/xen/compat.h                                             |  180 +
 xen/include/xen/domain.h                                             |   17 
 xen/include/xen/elf.h                                                |   11 
 xen/include/xen/elfcore.h                                            |   57 
 xen/include/xen/hypercall.h                                          |   19 
 xen/include/xen/init.h                                               |   19 
 xen/include/xen/kernel.h                                             |   31 
 xen/include/xen/lib.h                                                |   10 
 xen/include/xen/multicall.h                                          |   10 
 xen/include/xen/perfc.h                                              |    3 
 xen/include/xen/sched.h                                              |   47 
 xen/include/xen/shared.h                                             |   54 
 xen/include/xen/symbols.h                                            |    5 
 xen/include/xen/xenoprof.h                                           |   26 
 xen/include/xen/xmalloc.h                                            |    2 
 xen/include/xlat.lst                                                 |   52 
 xen/tools/get-fields.sh                                              |  425 +++
 xen/tools/symbols.c                                                  |  479 +--
 firmware/etherboot/eb-rtl8139.zrom                                   |    0 
 341 files changed, 14517 insertions(+), 6479 deletions(-)

diff -r 42babffffba5 -r 58633caeece9 .hgignore
--- a/.hgignore Wed Jan 10 08:00:50 2007 -0700
+++ b/.hgignore Wed Jan 10 08:40:47 2007 -0700
@@ -20,6 +20,7 @@
 ^\.config$
 ^TAGS$
 ^tags$
+^build.*$
 ^dist/.*$
 ^docs/.*\.aux$
 ^docs/.*\.dvi$
@@ -205,6 +206,7 @@
 ^xen/ddb/.*$
 ^xen/include/asm$
 ^xen/include/asm-.*/asm-offsets\.h$
+^xen/include/compat/.*$
 ^xen/include/hypervisor-ifs/arch$
 ^xen/include/public/public$
 ^xen/include/xen/.*\.new$
diff -r 42babffffba5 -r 58633caeece9 .hgtags
--- a/.hgtags   Wed Jan 10 08:00:50 2007 -0700
+++ b/.hgtags   Wed Jan 10 08:40:47 2007 -0700
@@ -16,3 +16,4 @@ af0573e9e5258db0a9d28aa954dd302ddd2c2d23
 af0573e9e5258db0a9d28aa954dd302ddd2c2d23 3.0.2-rc
 d0d3fef37685be264a7f52201f8ef44c030daad3 3.0.2-branched
 6ed4368b4a9e1924c983774c4b1a2b6baf8e98a6 3.0.3-branched
+057f7c4dbed1c75a3fbe446d346cee04cff31497 3.0.4-branched
diff -r 42babffffba5 -r 58633caeece9 Config.mk
--- a/Config.mk Wed Jan 10 08:00:50 2007 -0700
+++ b/Config.mk Wed Jan 10 08:40:47 2007 -0700
@@ -10,6 +10,8 @@ XEN_OS              ?= $(shell uname -s)
 XEN_OS              ?= $(shell uname -s)
 
 CONFIG_$(XEN_OS) := y
+
+SHELL     ?= /bin/sh
 
 # Tools to run on system hosting the build
 HOSTCC     = gcc
diff -r 42babffffba5 -r 58633caeece9 buildconfigs/mk.linux-2.6-xen
--- a/buildconfigs/mk.linux-2.6-xen     Wed Jan 10 08:00:50 2007 -0700
+++ b/buildconfigs/mk.linux-2.6-xen     Wed Jan 10 08:40:47 2007 -0700
@@ -3,7 +3,8 @@ LINUX_VER    = 2.6.16.33
 
 EXTRAVERSION ?= xen
 
-LINUX_DIR    = linux-$(LINUX_VER)-$(EXTRAVERSION)
+LINUX_SRCDIR = linux-$(LINUX_VER)-xen
+LINUX_DIR    = build-linux-$(LINUX_VER)-$(EXTRAVERSION)_$(XEN_TARGET_ARCH)
 
 IMAGE_TARGET ?= vmlinuz
 INSTALL_BOOT_PATH ?= $(DESTDIR)
@@ -23,24 +24,31 @@ build: $(LINUX_DIR)/include/linux/autoco
        mkdir -p $(INSTALL_BOOT_PATH)
        $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) 
INSTALL_PATH=$(INSTALL_BOOT_PATH) install
 
-$(LINUX_DIR)/include/linux/autoconf.h: ref-linux-$(LINUX_VER)/.valid-ref
-       rm -rf $(LINUX_DIR)
-       cp -al $(<D) $(LINUX_DIR)
+$(LINUX_SRCDIR)/.valid-src: ref-linux-$(LINUX_VER)/.valid-ref
+       rm -rf $(LINUX_SRCDIR)
+       cp -al $(<D) $(LINUX_SRCDIR)
        # Apply arch-xen patches
        ( cd linux-$(LINUX_SERIES)-xen-sparse && \
-          LINUX_ARCH=$(LINUX_ARCH) bash ./mkbuildtree ../$(LINUX_DIR) )
+          LINUX_ARCH=$(LINUX_ARCH) bash ./mkbuildtree ../$(LINUX_SRCDIR) )
+       # Patch kernel Makefile to set EXTRAVERSION
+       ( cd $(LINUX_SRCDIR) ; \
+         sed -e 's,^EXTRAVERSION.*,&$$(XENGUEST),' \
+             -e 's,^KERNELRELEASE,XENGUEST := $$(shell [ -r 
$$(objtree)/.xenguest ] \&\& cat $$(objtree)/.xenguest)\n&,' Makefile >Mk.tmp ; 
\
+         rm -f Makefile ; mv Mk.tmp Makefile )
+       touch $@
+
+$(LINUX_DIR)/include/linux/autoconf.h: $(LINUX_SRCDIR)/.valid-src
+       rm -rf $(LINUX_DIR)
+       mkdir -p $(LINUX_DIR)
        # Re-use config from install dir if one exits else use default config
-       CONFIG_VERSION=$$(sed -ne 's/^EXTRAVERSION = //p' 
$(LINUX_DIR)/Makefile); \
+       CONFIG_VERSION=$$(sed -ne 's/$$(XENGUEST)//; s/^EXTRAVERSION = //p' 
$(LINUX_SRCDIR)/Makefile); \
        [ -r 
$(DESTDIR)/boot/config-$(LINUX_VER3)$$CONFIG_VERSION-$(EXTRAVERSION) ] && \
          cp 
$(DESTDIR)/boot/config-$(LINUX_VER3)$$CONFIG_VERSION-$(EXTRAVERSION) 
$(LINUX_DIR)/.config \
          || sh buildconfigs/create_config.sh $(LINUX_DIR)/.config 
$(EXTRAVERSION) $(XEN_TARGET_ARCH) $(XEN_SYSTYPE)
        # See if we need to munge config to enable PAE
        $(MAKE) CONFIG_FILE=$(LINUX_DIR)/.config -f buildconfigs/Rules.mk 
config-update-pae
-       # Patch kernel Makefile to set EXTRAVERSION
-       ( cd $(LINUX_DIR) ; \
-         sed -e 's/^EXTRAVERSION.*/&$$(XENGUEST)\nXENGUEST = 
-$(EXTRAVERSION)/' Makefile >Mk.tmp ; \
-         rm -f Makefile ; mv Mk.tmp Makefile )
-       $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) oldconfig
+       echo "-$(EXTRAVERSION)" >$(LINUX_DIR)/.xenguest
+       $(MAKE) -C $(LINUX_SRCDIR) ARCH=$(LINUX_ARCH) oldconfig 
O=$$(/bin/pwd)/$(LINUX_DIR)
 
 .PHONY: prep
 prep: $(LINUX_DIR)/include/linux/autoconf.h
@@ -62,4 +70,5 @@ delete:
 
 .PHONY: mrpropper
 mrpropper:
+       rm -rf $(LINUX_SRCDIR)
        rm -f linux-$(LINUX_VER).tar.bz2
diff -r 42babffffba5 -r 58633caeece9 config/StdGNU.mk
--- a/config/StdGNU.mk  Wed Jan 10 08:00:50 2007 -0700
+++ b/config/StdGNU.mk  Wed Jan 10 08:40:47 2007 -0700
@@ -8,6 +8,8 @@ STRIP      = $(CROSS_COMPILE)strip
 STRIP      = $(CROSS_COMPILE)strip
 OBJCOPY    = $(CROSS_COMPILE)objcopy
 OBJDUMP    = $(CROSS_COMPILE)objdump
+
+MSGFMT     = msgfmt
 
 INSTALL      = install
 INSTALL_DIR  = $(INSTALL) -d -m0755
diff -r 42babffffba5 -r 58633caeece9 config/SunOS.mk
--- a/config/SunOS.mk   Wed Jan 10 08:00:50 2007 -0700
+++ b/config/SunOS.mk   Wed Jan 10 08:40:47 2007 -0700
@@ -8,6 +8,8 @@ STRIP      = $(CROSS_COMPILE)gstrip
 STRIP      = $(CROSS_COMPILE)gstrip
 OBJCOPY    = $(CROSS_COMPILE)gobjcopy
 OBJDUMP    = $(CROSS_COMPILE)gobjdump
+
+MSGFMT     = gmsgfmt
 
 SHELL      = bash
 
diff -r 42babffffba5 -r 58633caeece9 config/x86_64.mk
--- a/config/x86_64.mk  Wed Jan 10 08:00:50 2007 -0700
+++ b/config/x86_64.mk  Wed Jan 10 08:40:47 2007 -0700
@@ -2,6 +2,7 @@ CONFIG_X86_64 := y
 CONFIG_X86_64 := y
 CONFIG_X86_$(XEN_OS) := y
 
+CONFIG_COMPAT := y
 CONFIG_HVM := y
 CONFIG_MIGRATE := y
 CONFIG_XCUTILS := y
diff -r 42babffffba5 -r 58633caeece9 docs/xen-api/wire-protocol.tex
--- a/docs/xen-api/wire-protocol.tex    Wed Jan 10 08:00:50 2007 -0700
+++ b/docs/xen-api/wire-protocol.tex    Wed Jan 10 08:40:47 2007 -0700
@@ -105,11 +105,13 @@ the struct contains a second element nam
 the struct contains a second element named {\tt ErrorDescription}:
 \begin{itemize}
 \item The element of the struct named {\tt ErrorDescription} contains
-an array of string values. The first element of the array is an XML-RPC 32-bit 
{\tt i4} and represents an error code;
-the remainder of the array are strings representing error parameters relating 
to that code.
-\end{itemize}
-
-For example, an XML-RPC return value from the {\tt Host.ListAllVMs} function 
above
+an array of string values. The first element of the array is an error code;
+the remainder of the array are strings representing error parameters relating
+to that code.
+\end{itemize}
+
+For example, an XML-RPC return value from the {\tt host.get\_resident\_VMs}
+function above
 may look like this:
 \begin{verbatim}
     <struct>
@@ -122,9 +124,9 @@ may look like this:
           <value>
             <array>
                <data>
-                 <value>vm-id-1</value>
-                 <value>vm-id-2</value>
-                 <value>vm-id-3</value>
+                 <value>81547a35-205c-a551-c577-00b982c5fe00</value>
+                 <value>61c85a22-05da-b8a2-2e55-06b0847da503</value>
+                 <value>1d401ec4-3c17-35a6-fc79-cee6bd9811fe</value>
                </data>
             </array>
          </value>
@@ -147,16 +149,16 @@ The XML-RPC interface is session-based; 
 The XML-RPC interface is session-based; before you can make arbitrary RPC calls
 you must login and initiate a session. For example:
 \begin{verbatim}
-   session_id    Session.login_with_password(string uname, string pwd)
+   session_id    session.login_with_password(string uname, string pwd)
 \end{verbatim}
 Where {\tt uname} and {\tt password} refer to your username and password
 respectively, as defined by the Xen administrator.
-The {\tt session\_id} returned by {\tt Session.Login} is passed to subequent
-RPC calls as an authentication token.
-
-A session can be terminated with the {\tt Session.Logout} function:
-\begin{verbatim}
-   void          Session.Logout(session_id session)
+The {\tt session\_id} returned by {\tt session.login_with_password} is passed
+to subequent RPC calls as an authentication token.
+
+A session can be terminated with the {\tt session.logout} function:
+\begin{verbatim}
+   void          session.logout(session_id session)
 \end{verbatim}
 
 \subsection{Synchronous and Asynchronous invocation}
@@ -214,10 +216,12 @@ Create a python object referencing the r
 >>> xen = xmlrpclib.Server("http://test:4464";)
 \end{verbatim}
 
-Acquire a session token by logging in with a username and password 
(error-handling ommitted for brevity; the session token is pointed to by the 
key {\tt 'Value'} in the returned dictionary)
-
-\begin{verbatim}
->>> session = xen.Session.do_login_with_password("user", "passwd")['Value']
+Acquire a session token by logging in with a username and password
+(error-handling ommitted for brevity; the session token is pointed to by the
+key {\tt 'Value'} in the returned dictionary)
+
+\begin{verbatim}
+>>> session = session.login_with_password("user", "passwd")['Value']
 \end{verbatim}
 
 When serialised, this call looks like the following:
@@ -225,7 +229,7 @@ When serialised, this call looks like th
 \begin{verbatim}
 <?xml version='1.0'?>
 <methodCall>
-  <methodName>Session.do_login_with_password</methodName>
+  <methodName>session.login_with_password</methodName>
   <params>
     <param>
       <value><string>user</string></value>
@@ -237,27 +241,34 @@ When serialised, this call looks like th
 </methodCall>
 \end{verbatim}
 
-Next, the user may acquire a list of all the VMs known to the host: (Note the 
call takes the session token as the only parameter)
-
-\begin{verbatim}
->>> all_vms = xen.VM.do_list(session)['Value']
+Next, the user may acquire a list of all the VMs known to the host: (Note the
+call takes the session token as the only parameter)
+
+\begin{verbatim}
+>>> all_vms = host.get_resident_VMs(session)['Value']
 >>> all_vms
 ['b7b92d9e-d442-4710-92a5-ab039fd7d89b', 
'23e1e837-abbf-4675-b077-d4007989b0cc',
   '2045dbc0-0734-4eea-9cb2-b8218c6b5bf2', 
'3202ae18-a046-4c32-9fda-e32e9631866e']
 \end{verbatim}
 
-Note the VM references are internally UUIDs. Once a reference to a VM has been 
acquired a lifecycle operation may be invoked:
-
-\begin{verbatim}
->>> xen.VM.do_start(session, all_vms[3], False)
-{'Status': 'Failure', 'ErrorDescription': 'Operation not implemented'}
-\end{verbatim}
-
-In this case the {\tt start} message has not been implemented and an error 
response has been returned. Currently these high-level errors are returned as 
structured data (rather than as XMLRPC faults), allowing for internationalised 
errors in future. Finally, here are some examples of using accessors for object 
fields:
-
-\begin{verbatim}
->>> xen.VM.getname_label(session, all_vms[3])['Value']
+The VM references here are UUIDs, though they may not be that simple in the
+future, and you should treat them as opaque strings.  Once a reference to a VM
+has been acquired a lifecycle operation may be invoked:
+
+\begin{verbatim}
+>>> xen.VM.start(session, all_vms[3], False)
+{'Status': 'Failure', 'ErrorDescription': ['VM_BAD_POWER_STATE', 'Halted', 
'Running']}
+\end{verbatim}
+
+In this case the {\tt start} message has been rejected, because the VM is
+already running, and so an error response has been returned.  These high-level
+errors are returned as structured data (rather than as XML-RPC faults),
+allowing them to be internationalised.  Finally, here are some examples of
+using accessors for object fields:
+
+\begin{verbatim}
+>>> xen.VM.get_name_label(session, all_vms[3])['Value']
 'SMP'
->>> xen.VM.getname_description(session, all_vms[3])['Value']
+>>> xen.VM.get_name_description(session, all_vms[3])['Value']
 'Debian for Xen'
 \end{verbatim}
diff -r 42babffffba5 -r 58633caeece9 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Wed Jan 10 08:00:50 2007 -0700
+++ b/docs/xen-api/xenapi-datamodel.tex Wed Jan 10 08:40:47 2007 -0700
@@ -184,8 +184,8 @@ The following enumeration types are used
 \hspace{0.5cm}{\tt NX} &  Execute Disable  \\
 \hspace{0.5cm}{\tt MMXEXT} &  AMD MMX extensions  \\
 \hspace{0.5cm}{\tt LM} &  Long Mode (x86-64)  \\
-\hspace{0.5cm}{\tt 3DNOWEXT} &  AMD 3DNow! extensions  \\
-\hspace{0.5cm}{\tt 3DNOW} &  3DNow!  \\
+\hspace{0.5cm}{\tt THREEDNOWEXT} &  AMD 3DNow! extensions  \\
+\hspace{0.5cm}{\tt THREEDNOW} &  3DNow!  \\
 \hspace{0.5cm}{\tt RECOVERY} &  CPU in recovery mode  \\
 \hspace{0.5cm}{\tt LONGRUN} &  Longrun power control  \\
 \hspace{0.5cm}{\tt LRTI} &  LongRun table interface  \\
@@ -244,18 +244,6 @@ The following enumeration types are used
 \vspace{1cm}
 \begin{longtable}{|ll|}
 \hline
-{\tt enum boot\_type} & \\
-\hline
-\hspace{0.5cm}{\tt bios} & boot an HVM guest using an emulated BIOS \\
-\hspace{0.5cm}{\tt grub} & boot from inside the machine using grub \\
-\hspace{0.5cm}{\tt kernel\_external} & boot from an external kernel \\
-\hspace{0.5cm}{\tt kernel\_internal} & boot from a kernel inside the guest 
filesystem \\
-\hline
-\end{longtable}
-
-\vspace{1cm}
-\begin{longtable}{|ll|}
-\hline
 {\tt enum vbd\_mode} & \\
 \hline
 \hspace{0.5cm}{\tt RO} & disk is mounted read-only \\
@@ -298,6 +286,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object 
reference \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt this\_host} & host ref & Currently 
connected host \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt this\_user} & user ref & Currently 
connected user \\
+$\mathit{RO}_\mathit{run}$ &  {\tt last\_active} & int & Timestamp for last 
time session was active \\
 \hline
 \end{longtable}
 \subsection{Additional RPCs associated with class: session}
@@ -452,45 +441,13 @@ value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~create}
-
-{\bf Overview:} 
-Create a new session instance, and return its handle.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} (session ref) create (session_id s, session record 
args)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt session record } & args & All constructor arguments \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-session ref
-}
-
-
-reference to the newly created object
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~destroy}
-
-{\bf Overview:} 
-Destroy the specified session instance.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void destroy (session_id s, session ref self)\end{verbatim}
+\subsubsection{RPC name:~get\_last\_active}
+
+{\bf Overview:} 
+Get the last\_active field of the given session.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_last_active (session_id s, session ref 
self)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -508,11 +465,11 @@ Destroy the specified session instance.
 
  \noindent {\bf Return Type:} 
 {\tt 
-void
-}
-
-
-
+int
+}
+
+
+value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -608,7 +565,7 @@ Quals & Field & Type & Description \\
 \subsubsection{RPC name:~get\_all}
 
 {\bf Overview:} 
-Return a list of all the tasks known to the system
+Return a list of all the tasks known to the system.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} ((task ref) Set) get_all (session_id s)\end{verbatim}
@@ -1011,70 +968,6 @@ string Set
 
 
 value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~create}
-
-{\bf Overview:} 
-Create a new task instance, and return its handle.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} (task ref) create (session_id s, task record 
args)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt task record } & args & All constructor arguments \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-task ref
-}
-
-
-reference to the newly created object
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~destroy}
-
-{\bf Overview:} 
-Destroy the specified task instance.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void destroy (session_id s, task ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt task ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
@@ -1182,7 +1075,34 @@ references to objects with match names
 \begin{longtable}{|lllp{0.38\textwidth}|}
 \hline
 \multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VM} \\
-\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A 
virtual machine (or 'guest')}} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A 
virtual machine (or 'guest').
+
+VM booting is controlled by setting one of the two mutually exclusive
+groups: "PV", and "HVM".  If HVM.boot is the empty string, then paravirtual
+domain building and booting will be used; otherwise the VM will be loaded
+as an HVM domain, and booted using an emulated BIOS.
+
+When paravirtual booting is in use, the PV/bootloader field indicates the
+bootloader to use.  It may be "pygrub", in which case the platform's
+default installation of pygrub will be used, or a full path within the
+control domain to some other bootloader.  The other fields, PV/kernel,
+PV/ramdisk, PV/args and PV/bootloader\_args will be passed to the
+bootloader unmodified, and interpretation of those fields is then specific
+to the bootloader itself, including the possibility that the bootloader
+will ignore some or all of those given values.
+
+If the bootloader is pygrub, then the menu.lst is parsed if present in the
+guest's filesystem, otherwise the specified kernel and ramdisk are used, or
+an autodetected kernel is used if nothing is specified and autodetection is
+possible.  PV/args is appended to the kernel command line, no matter which
+mechanism is used for finding the kernel.
+
+If PV/bootloader is empty but PV/kernel is specified, then the kernel and
+ramdisk values will be treated as paths within the control domain.  If both
+PV/bootloader and PV/kernel are empty, then the behaviour is as if
+PV/bootloader was specified as "pygrub".
+
+When using HVM booting, HVM/boot specifies the order of the boot devices}} \\
 \hline
 Quals & Field & Type & Description \\
 \hline
@@ -1215,18 +1135,17 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VIFs} & (VIF ref) Set & virtual network 
interfaces \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VBDs} & (VBD ref) Set & virtual block 
devices \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VTPMs} & (VTPM ref) Set & virtual TPMs \\
-$\mathit{RW}$ &  {\tt bios/boot} & string & device to boot the guest from \\
+$\mathit{RW}$ &  {\tt PV/bootloader} & string & name of or path to bootloader 
\\
+$\mathit{RW}$ &  {\tt PV/kernel} & string & path to the kernel \\
+$\mathit{RW}$ &  {\tt PV/ramdisk} & string & path to the initrd \\
+$\mathit{RW}$ &  {\tt PV/args} & string & kernel command-line arguments \\
+$\mathit{RW}$ &  {\tt PV/bootloader\_args} & string & miscellaneous arguments 
for the bootloader \\
+$\mathit{RW}$ &  {\tt HVM/boot} & string & device boot order \\
 $\mathit{RW}$ &  {\tt platform/std\_VGA} & bool & emulate standard VGA instead 
of cirrus logic \\
 $\mathit{RW}$ &  {\tt platform/serial} & string & redirect serial port to pty 
\\
 $\mathit{RW}$ &  {\tt platform/localtime} & bool & set RTC to local time \\
 $\mathit{RW}$ &  {\tt platform/clock\_offset} & bool & timeshift applied to 
guest's clock \\
 $\mathit{RW}$ &  {\tt platform/enable\_audio} & bool & emulate audio \\
-$\mathit{RW}$ &  {\tt builder} & string & domain builder to use \\
-$\mathit{RW}$ &  {\tt boot\_method} & boot\_type & select how this machine 
should boot \\
-$\mathit{RW}$ &  {\tt kernel/kernel} & string & path to kernel e.g. 
/boot/vmlinuz \\
-$\mathit{RW}$ &  {\tt kernel/initrd} & string & path to the initrd e.g. 
/boot/initrd.img \\
-$\mathit{RW}$ &  {\tt kernel/args} & string & extra kernel command-line 
arguments \\
-$\mathit{RW}$ &  {\tt grub/cmdline} & string & grub command-line \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for 
pass-through devices \\
 $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ 
string) Map & versions of installed paravirtualised drivers \\
 $\mathit{RW}$ &  {\tt otherConfig} & (string $\rightarrow$ string) Map & 
additional configuration \\
@@ -1265,8 +1184,10 @@ VM ref
 
 The ID of the newly created VM.
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~start}
 
 {\bf Overview:} 
@@ -1299,8 +1220,10 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~pause}
 
 {\bf Overview:} 
@@ -1331,8 +1254,10 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~unpause}
 
 {\bf Overview:} 
@@ -1349,7 +1274,7 @@ Resume the specified VM. This can only b
 \begin{tabular}{|c|c|p{7cm}|}
  \hline
 {\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & vm & The VM to pause \\ \hline 
+{\tt VM ref } & vm & The VM to unpause \\ \hline 
 
 \end{tabular}
 
@@ -1363,8 +1288,10 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~clean\_shutdown}
 
 {\bf Overview:} 
@@ -1372,6 +1299,8 @@ Attempt to cleanly shutdown the specifie
 
 Once shutdown has been completed perform poweroff action specified in guest 
configuration.
 
+This can only be called when the specified VM is in the Running state.
+
  \noindent {\bf Signature:} 
 \begin{verbatim} void clean_shutdown (session_id s, VM ref vm)\end{verbatim}
 
@@ -1397,8 +1326,10 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~clean\_reboot}
 
 {\bf Overview:} 
@@ -1406,6 +1337,8 @@ Attempt to cleanly shutdown the specifie
 
 Once shutdown has been completed perform reboot action specified in guest 
configuration.
 
+This can only be called when the specified VM is in the Running state.
+
  \noindent {\bf Signature:} 
 \begin{verbatim} void clean_reboot (session_id s, VM ref vm)\end{verbatim}
 
@@ -1431,8 +1364,10 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~hard\_shutdown}
 
 {\bf Overview:} 
@@ -1500,7 +1435,7 @@ void
 \subsubsection{RPC name:~suspend}
 
 {\bf Overview:} 
-Suspend the specified VM to disk.
+Suspend the specified VM to disk.  This can only be called when the specified 
VM is in the Running state.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void suspend (session_id s, VM ref vm)\end{verbatim}
@@ -1527,12 +1462,14 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~resume}
 
 {\bf Overview:} 
-Awaken the specified VM and resume it.
+Awaken the specified VM and resume it.  This can only be called when the 
specified VM is in the Suspended state.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void resume (session_id s, VM ref vm, bool 
start_paused)\end{verbatim}
@@ -1561,8 +1498,10 @@ void
 
 
 \vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~get\_all}
 
 {\bf Overview:} 
@@ -2601,7 +2540,7 @@ void
 \subsubsection{RPC name:~add\_VCPUs\_features\_force\_on}
 
 {\bf Overview:} 
-set add message derived from field VCPUs/features/force\_on of object VM
+Add the given value to the VCPUs/features/force\_on field of the given VM.  If 
the value is already in that Set, then do nothing.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void add_VCPUs_features_force_on (session_id s, VM ref self, 
cpu_feature value)\end{verbatim}
@@ -2635,7 +2574,7 @@ void
 \subsubsection{RPC name:~remove\_VCPUs\_features\_force\_on}
 
 {\bf Overview:} 
-set remove message derived from field VCPUs/features/force\_on of object VM
+Remove the given value from the VCPUs/features/force\_on field of the given 
VM.  If the value is not in that Set, then do nothing.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void remove_VCPUs_features_force_on (session_id s, VM ref 
self, cpu_feature value)\end{verbatim}
@@ -2735,7 +2674,7 @@ void
 \subsubsection{RPC name:~add\_VCPUs\_features\_force\_off}
 
 {\bf Overview:} 
-set add message derived from field VCPUs/features/force\_off of object VM
+Add the given value to the VCPUs/features/force\_off field of the given VM.  
If the value is already in that Set, then do nothing.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void add_VCPUs_features_force_off (session_id s, VM ref self, 
cpu_feature value)\end{verbatim}
@@ -2769,7 +2708,7 @@ void
 \subsubsection{RPC name:~remove\_VCPUs\_features\_force\_off}
 
 {\bf Overview:} 
-set remove message derived from field VCPUs/features/force\_off of object VM
+Remove the given value from the VCPUs/features/force\_off field of the given 
VM.  If the value is not in that Set, then do nothing.
 
  \noindent {\bf Signature:} 
 \begin{verbatim} void remove_VCPUs_features_force_off (session_id s, VM ref 
self, cpu_feature value)\end{verbatim}
@@ -3192,13 +3131,13 @@ value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~get\_bios\_boot}
-
-{\bf Overview:} 
-Get the bios/boot field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} string get_bios_boot (session_id s, VM ref self)\end{verbatim}
+\subsubsection{RPC name:~get\_PV\_bootloader}
+
+{\bf Overview:} 
+Get the PV/bootloader field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_PV_bootloader (session_id s, VM ref 
self)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -3224,13 +3163,13 @@ value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
-\subsubsection{RPC name:~set\_bios\_boot}
-
-{\bf Overview:} 
-Set the bios/boot field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_bios_boot (session_id s, VM ref self, string 
value)\end{verbatim}
+\subsubsection{RPC name:~set\_PV\_bootloader}
+
+{\bf Overview:} 
+Set the PV/bootloader field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_PV_bootloader (session_id s, VM ref self, string 
value)\end{verbatim}
 
 
 \noindent{\bf Arguments:}
@@ -3258,6 +3197,336 @@ void
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
+\subsubsection{RPC name:~get\_PV\_kernel}
+
+{\bf Overview:} 
+Get the PV/kernel field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_PV_kernel (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_PV\_kernel}
+
+{\bf Overview:} 
+Set the PV/kernel field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_PV_kernel (session_id s, VM ref self, string 
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_PV\_ramdisk}
+
+{\bf Overview:} 
+Get the PV/ramdisk field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_PV_ramdisk (session_id s, VM ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_PV\_ramdisk}
+
+{\bf Overview:} 
+Set the PV/ramdisk field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_PV_ramdisk (session_id s, VM ref self, string 
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_PV\_args}
+
+{\bf Overview:} 
+Get the PV/args field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_PV_args (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_PV\_args}
+
+{\bf Overview:} 
+Set the PV/args field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_PV_args (session_id s, VM ref self, string 
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_PV\_bootloader\_args}
+
+{\bf Overview:} 
+Get the PV/bootloader\_args field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_PV_bootloader_args (session_id s, VM ref 
self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_PV\_bootloader\_args}
+
+{\bf Overview:} 
+Set the PV/bootloader\_args field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_PV_bootloader_args (session_id s, VM ref self, 
string value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_HVM\_boot}
+
+{\bf Overview:} 
+Get the HVM/boot field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} string get_HVM_boot (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~set\_HVM\_boot}
+
+{\bf Overview:} 
+Set the HVM/boot field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void set_HVM_boot (session_id s, VM ref self, string 
value)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+{\tt string } & value & New value to set \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
 \subsubsection{RPC name:~get\_platform\_std\_VGA}
 
 {\bf Overview:} 
@@ -3573,402 +3842,6 @@ Set the platform/enable\_audio field of 
 {\tt VM ref } & self & reference to the object \\ \hline 
 
 {\tt bool } & value & New value to set \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_builder}
-
-{\bf Overview:} 
-Get the builder field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} string get_builder (session_id s, VM ref self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-string
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_builder}
-
-{\bf Overview:} 
-Set the builder field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_builder (session_id s, VM ref self, string 
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-{\tt string } & value & New value to set \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_boot\_method}
-
-{\bf Overview:} 
-Get the boot\_method field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} (boot_type) get_boot_method (session_id s, VM ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-boot\_type
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_boot\_method}
-
-{\bf Overview:} 
-Set the boot\_method field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_boot_method (session_id s, VM ref self, boot_type 
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-{\tt boot\_type } & value & New value to set \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_kernel\_kernel}
-
-{\bf Overview:} 
-Get the kernel/kernel field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} string get_kernel_kernel (session_id s, VM ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-string
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_kernel\_kernel}
-
-{\bf Overview:} 
-Set the kernel/kernel field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_kernel_kernel (session_id s, VM ref self, string 
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-{\tt string } & value & New value to set \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_kernel\_initrd}
-
-{\bf Overview:} 
-Get the kernel/initrd field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} string get_kernel_initrd (session_id s, VM ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-string
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_kernel\_initrd}
-
-{\bf Overview:} 
-Set the kernel/initrd field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_kernel_initrd (session_id s, VM ref self, string 
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-{\tt string } & value & New value to set \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_kernel\_args}
-
-{\bf Overview:} 
-Get the kernel/args field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} string get_kernel_args (session_id s, VM ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-string
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_kernel\_args}
-
-{\bf Overview:} 
-Set the kernel/args field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_kernel_args (session_id s, VM ref self, string 
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-{\tt string } & value & New value to set \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-void
-}
-
-
-
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~get\_grub\_cmdline}
-
-{\bf Overview:} 
-Get the grub/cmdline field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} string get_grub_cmdline (session_id s, VM ref 
self)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-\end{tabular}
-
-\vspace{0.3cm}
-
- \noindent {\bf Return Type:} 
-{\tt 
-string
-}
-
-
-value of the field
-\vspace{0.3cm}
-\vspace{0.3cm}
-\vspace{0.3cm}
-\subsubsection{RPC name:~set\_grub\_cmdline}
-
-{\bf Overview:} 
-Set the grub/cmdline field of the given VM.
-
- \noindent {\bf Signature:} 
-\begin{verbatim} void set_grub_cmdline (session_id s, VM ref self, string 
value)\end{verbatim}
-
-
-\noindent{\bf Arguments:}
-
- 
-\vspace{0.3cm}
-\begin{tabular}{|c|c|p{7cm}|}
- \hline
-{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VM ref } & self & reference to the object \\ \hline 
-
-{\tt string } & value & New value to set \\ \hline 
 
 \end{tabular}
 
@@ -10480,6 +10353,239 @@ all fields from the object
 \vspace{0.3cm}
 
 \vspace{1cm}
+\newpage
+\section{Error Handling}
+When a low-level transport error occurs, or a request is malformed at the HTTP
+or XML-RPC level, the server may send an XML-RPC Fault response, or the client
+may simulate the same.  The client must be prepared to handle these errors,
+though they may be treated as fatal.  On the wire, these are transmitted in a
+form similar to this:
+
+\begin{verbatim}
+    <methodResponse>
+      <fault>
+        <value>
+          <struct>
+            <member>
+                <name>faultCode</name>
+                <value><int>-1</int></value>
+              </member>
+              <member>
+                <name>faultString</name>
+                <value><string>Malformed request</string></value>
+            </member>
+          </struct>
+        </value>
+      </fault>
+    </methodResponse>
+\end{verbatim}
+
+All other failures are reported with a more structured error response, to
+allow better automatic response to failures, proper internationalisation of
+any error message, and easier debugging.  On the wire, these are transmitted
+like this:
+
+\begin{verbatim}
+    <struct>
+      <member>
+        <name>Status</name>
+        <value>Failure</value>
+      </member>
+      <member>
+        <name>ErrorDescription</name>
+        <value>
+          <array>
+            <data>
+              <value>MAP_DUPLICATE_KEY</value>
+              <value>Customer</value>
+              <value>eSpeil Inc.</value>
+              <value>eSpeil Incorporated</value>
+            </data>
+          </array>
+        </value>
+      </member>
+    </struct>
+\end{verbatim}
+
+Note that {\tt ErrorDescription} value is an array of string values. The
+first element of the array is an error code; the remainder of the array are
+strings representing error parameters relating to that code.  In this case,
+the client has attempted to add the mapping {\tt Customer $\rightarrow$
+eSpiel Incorporated} to a Map, but it already contains the mapping
+{\tt Customer $\rightarrow$ eSpiel Inc.}, and so the request has failed.
+
+Each possible error code is documented in the following section.
+
+\subsection{Error Codes}
+
+\subsubsection{HOST\_CPU\_HANDLE\_INVALID}
+
+You gave an invalid host\_cpu handle.  The host\_cpu may have recently been
+deleted.  The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}HOST_CPU_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{HOST\_HANDLE\_INVALID}
+
+You gave an invalid host handle.  The host may have recently been deleted. 
+The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}HOST_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{INTERNAL\_ERROR}
+
+The server failed to handle your request, due to an internal error.  The
+given message may give details useful for debugging the problem.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}INTERNAL_ERROR(message)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{MAP\_DUPLICATE\_KEY}
+
+You tried to add a key-value pair to a map, but that key is already there. 
+The key, current value, and the new value that you tried to set are all
+echoed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}MAP_DUPLICATE_KEY(key, current value, new value)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{MESSAGE\_METHOD\_UNKNOWN}
+
+You tried to call a method that does not exist.  The method name that you
+used is echoed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}MESSAGE_METHOD_UNKNOWN(method)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{MESSAGE\_PARAMETER\_COUNT\_MISMATCH}
+
+You tried to call a method with the incorrect number of parameters.  The
+fully-qualified method name that you used, and the number of received and
+expected parameters are returned.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}MESSAGE_PARAMETER_COUNT_MISMATCH(method, expected, 
received)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{NETWORK\_ALREADY\_CONNECTED}
+
+You tried to create a PIF, but the network you tried to attach it to is
+already attached to some other PIF, and so the creation failed.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}NETWORK_ALREADY_CONNECTED(network, connected PIF)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SESSION\_AUTHENTICATION\_FAILED}
+
+The credentials given by the user are incorrect, so access has been denied,
+and you have not been issued a session handle.
+
+\vspace{0.3cm}
+No parameters.
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SESSION\_INVALID}
+
+You gave an invalid session handle.  It may have been invalidated by a
+server restart, or timed out.  You should get a new session handle, using
+one of the session.login\_ calls.  This error does not invalidate the
+current connection.  The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}SESSION_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{SR\_HANDLE\_INVALID}
+
+You gave an invalid SR handle.  The SR may have recently been deleted.  The
+handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}SR_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VBD\_HANDLE\_INVALID}
+
+You gave an invalid VBD handle.  The VBD may have recently been deleted. 
+The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VBD_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VDI\_HANDLE\_INVALID}
+
+You gave an invalid VDI handle.  The VDI may have recently been deleted. 
+The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VDI_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VIF\_HANDLE\_INVALID}
+
+You gave an invalid VIF handle.  The VIF may have recently been deleted. 
+The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VIF_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VM\_BAD\_POWER\_STATE}
+
+You attempted an operation on a VM that was not in an appropriate power
+state at the time; for example, you attempted to start a VM that was
+already running.  The parameters returned are the VM's UUID, and the
+expected and actual VM state at the time of the call.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VM_BAD_POWER_STATE(vm, expected, actual)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VM\_HANDLE\_INVALID}
+
+You gave an invalid VM handle.  The VM may have recently been deleted.  The
+handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VM_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+\subsubsection{VTPM\_HANDLE\_INVALID}
+
+You gave an invalid VTPM handle.  The VTPM may have recently been deleted. 
+The handle parameter echoes the bad value given.
+
+\vspace{0.3cm}
+{\bf Signature:}
+\begin{verbatim}VTPM_HANDLE_INVALID(handle)\end{verbatim}
+\begin{center}\rule{10em}{0.1pt}\end{center}
+
+
+
+\newpage
 \section{DTD}
 General notes:
 \begin{itemize}
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c       Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c       Wed Jan 10 
08:40:47 2007 -0700
@@ -15,6 +15,7 @@
 #include <linux/version.h>
 #include <asm/io.h>
 #include <xen/balloon.h>
+#include <asm/swiotlb.h>
 #include <asm/tlbflush.h>
 #include <asm-i386/mach-xen/asm/swiotlb.h>
 #include <asm/bug.h>
@@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device *
        ret = (void *)vstart;
 
        if (ret != NULL) {
-               /* NB. Hardcode 31 address bits for now: aacraid limitation. */
-               if (xen_create_contiguous_region(vstart, order, 31) != 0) {
+               if (xen_create_contiguous_region(vstart, order,
+                                                dma_bits) != 0) {
                        free_pages(vstart, order);
                        return NULL;
                }
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c       Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c       Wed Jan 10 
08:40:47 2007 -0700
@@ -101,8 +101,24 @@ void enable_hlt(void)
 
 EXPORT_SYMBOL(enable_hlt);
 
-/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
-void xen_idle(void)
+/*
+ * On SMP it's slightly faster (but much more power-consuming!)
+ * to poll the ->work.need_resched flag instead of waiting for the
+ * cross-CPU IPI to arrive. Use this option with caution.
+ */
+static void poll_idle(void)
+{
+       local_irq_enable();
+
+       asm volatile(
+               "2:"
+               "testl %0, %1;"
+               "rep; nop;"
+               "je 2b;"
+               : : "i"(_TIF_NEED_RESCHED), "m" (current_thread_info()->flags));
+}
+
+static void xen_idle(void)
 {
        local_irq_disable();
 
@@ -152,17 +168,22 @@ void cpu_idle(void)
        /* endless idle loop with no priority at all */
        while (1) {
                while (!need_resched()) {
+                       void (*idle)(void);
 
                        if (__get_cpu_var(cpu_idle_state))
                                __get_cpu_var(cpu_idle_state) = 0;
 
                        rmb();
+                       idle = pm_idle;
+
+                       if (!idle)
+                               idle = xen_idle;
 
                        if (cpu_is_offline(cpu))
                                play_dead();
 
                        __get_cpu_var(irq_stat).idle_timestamp = jiffies;
-                       xen_idle();
+                       idle();
                }
                preempt_enable_no_resched();
                schedule();
@@ -198,9 +219,22 @@ void cpu_idle_wait(void)
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
 
-/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */
-/* Always use xen_idle() instead. */
-void __devinit select_idle_routine(const struct cpuinfo_x86 *c) {}
+void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
+{
+}
+
+static int __init idle_setup (char *str)
+{
+       if (!strncmp(str, "poll", 4)) {
+               printk("using polling idle threads.\n");
+               pm_idle = poll_idle;
+       }
+
+       boot_option_idle_override = 1;
+       return 1;
+}
+
+__setup("idle=", idle_setup);
 
 void show_regs(struct pt_regs * regs)
 {
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c   Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c   Wed Jan 10 08:40:47 
2007 -0700
@@ -47,8 +47,8 @@ EXPORT_SYMBOL(swiotlb);
  */
 #define IO_TLB_SHIFT 11
 
-/* Width of DMA addresses in the IO TLB. 30 bits is a b44 limitation. */
-#define DEFAULT_IO_TLB_DMA_BITS 30
+/* Width of DMA addresses. 30 bits is a b44 limitation. */
+#define DEFAULT_DMA_BITS 30
 
 static int swiotlb_force;
 static char *iotlb_virt_start;
@@ -98,14 +98,14 @@ static struct phys_addr {
  */
 static DEFINE_SPINLOCK(io_tlb_lock);
 
-static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
+unsigned int dma_bits = DEFAULT_DMA_BITS;
 static int __init
-setup_io_tlb_bits(char *str)
-{
-       io_tlb_dma_bits = simple_strtoul(str, NULL, 0);
+setup_dma_bits(char *str)
+{
+       dma_bits = simple_strtoul(str, NULL, 0);
        return 0;
 }
-__setup("swiotlb_bits=", setup_io_tlb_bits);
+__setup("dma_bits=", setup_dma_bits);
 
 static int __init
 setup_io_tlb_npages(char *str)
@@ -167,7 +167,7 @@ swiotlb_init_with_default_size (size_t d
                int rc = xen_create_contiguous_region(
                        (unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
                        get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
-                       io_tlb_dma_bits);
+                       dma_bits);
                BUG_ON(rc);
        }
 
@@ -197,7 +197,7 @@ swiotlb_init_with_default_size (size_t d
               bytes >> 20,
               (unsigned long)iotlb_virt_start,
               (unsigned long)iotlb_virt_start + bytes,
-              io_tlb_dma_bits);
+              dma_bits);
 }
 
 void
@@ -665,7 +665,7 @@ int
 int
 swiotlb_dma_supported (struct device *hwdev, u64 mask)
 {
-       return (mask >= ((1UL << io_tlb_dma_bits) - 1));
+       return (mask >= ((1UL << dma_bits) - 1));
 }
 
 EXPORT_SYMBOL(swiotlb_init);
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/arch/i386/pci/irq-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/pci/irq-xen.c      Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/arch/i386/pci/irq-xen.c      Wed Jan 10 08:40:47 
2007 -0700
@@ -110,7 +110,6 @@ static struct irq_routing_table * __init
                if (rt)
                        return rt;
        }
-       
        return NULL;
 }
 
@@ -261,13 +260,13 @@ static int pirq_via_set(struct pci_dev *
  */
 static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int 
pirq)
 {
-       static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
+       static unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
        return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
 }
 
 static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int 
pirq, int irq)
 {
-       static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
+       static unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
        write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
        return 1;
 }
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c     Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c     Wed Jan 10 
08:40:47 2007 -0700
@@ -119,8 +119,26 @@ void exit_idle(void)
        __exit_idle();
 }
 
-/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
-void xen_idle(void)
+/*
+ * On SMP it's slightly faster (but much more power-consuming!)
+ * to poll the ->need_resched flag instead of waiting for the
+ * cross-CPU IPI to arrive. Use this option with caution.
+ */
+static void poll_idle(void)
+{
+       local_irq_enable();
+
+       asm volatile(
+               "2:"
+               "testl %0,%1;"
+               "rep; nop;"
+               "je 2b;"
+               : :
+               "i" (_TIF_NEED_RESCHED),
+               "m" (current_thread_info()->flags));
+}
+
+static void xen_idle(void)
 {
        local_irq_disable();
 
@@ -164,14 +182,18 @@ void cpu_idle (void)
        /* endless idle loop with no priority at all */
        while (1) {
                while (!need_resched()) {
+                       void (*idle)(void);
+
                        if (__get_cpu_var(cpu_idle_state))
                                __get_cpu_var(cpu_idle_state) = 0;
                        rmb();
-                       
+                       idle = pm_idle;
+                       if (!idle)
+                               idle = xen_idle;
                        if (cpu_is_offline(smp_processor_id()))
                                play_dead();
                        enter_idle();
-                       xen_idle();
+                       idle();
                        __exit_idle();
                }
 
@@ -210,9 +232,22 @@ void cpu_idle_wait(void)
 }
 EXPORT_SYMBOL_GPL(cpu_idle_wait);
 
-/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */
-/* Always use xen_idle() instead. */
-void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) {}
+void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 
+{
+}
+
+static int __init idle_setup (char *str)
+{
+       if (!strncmp(str, "poll", 4)) {
+               printk("using polling idle threads.\n");
+               pm_idle = poll_idle;
+       }
+
+       boot_option_idle_override = 1;
+       return 1;
+}
+
+__setup("idle=", idle_setup);
 
 /* Prints also some state that isn't saved in the pt_regs */ 
 void __show_regs(struct pt_regs * regs)
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
--- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c   Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c   Wed Jan 10 08:40:47 
2007 -0700
@@ -54,7 +54,6 @@ struct tpm_private {
 
        tpmif_tx_interface_t *tx;
        atomic_t refcnt;
-       unsigned int evtchn;
        unsigned int irq;
        u8 is_connected;
        u8 is_suspended;
@@ -271,7 +270,7 @@ static void destroy_tpmring(struct tpm_p
        if (tp->irq)
                unbind_from_irqhandler(tp->irq, tp);
 
-       tp->evtchn = tp->irq = 0;
+       tp->irq = 0;
 }
 
 
@@ -302,8 +301,8 @@ again:
                goto abort_transaction;
        }
 
-       err = xenbus_printf(xbt, dev->nodename,
-                           "event-channel", "%u", tp->evtchn);
+       err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+                           irq_to_evtchn_port(tp->irq));
        if (err) {
                message = "writing event-channel";
                goto abort_transaction;
@@ -459,19 +458,15 @@ static int tpmif_connect(struct xenbus_d
 
        tp->backend_id = domid;
 
-       err = xenbus_alloc_evtchn(dev, &tp->evtchn);
-       if (err)
+       err = bind_listening_port_to_irqhandler(
+               domid, tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
+       if (err <= 0) {
+               WPRINTK("bind_listening_port_to_irqhandler failed "
+                       "(err=%d)\n", err);
                return err;
-
-       err = bind_evtchn_to_irqhandler(tp->evtchn,
-                                       tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
-                                       tp);
-       if (err <= 0) {
-               WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
-               return err;
-       }
-
+       }
        tp->irq = err;
+
        return 0;
 }
 
@@ -656,9 +651,6 @@ static int tpm_xmit(struct tpm_private *
 
        mb();
 
-       DPRINTK("Notifying backend via event channel %d\n",
-               tp->evtchn);
-
        notify_remote_via_irq(tp->irq);
 
        spin_unlock_irq(&tp->tx_lock);
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Jan 10 
08:40:47 2007 -0700
@@ -446,8 +446,10 @@ static struct notifier_block xenstore_no
 
 static int __init balloon_init(void)
 {
+#ifdef CONFIG_X86
        unsigned long pfn;
        struct page *page;
+#endif
 
        if (!is_running_on_xen())
                return -ENODEV;
@@ -476,13 +478,15 @@ static int __init balloon_init(void)
        balloon_pde->write_proc = balloon_write;
 #endif
        balloon_sysfs_init();
-    
+
+#ifdef CONFIG_X86
        /* Initialise the balloon with excess memory space. */
        for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
                page = pfn_to_page(pfn);
                if (!PageReserved(page))
                        balloon_append(page);
        }
+#endif
 
        target_watch.callback = watch_target;
        xenstore_notifier.notifier_call = balloon_init_watcher;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Jan 10 08:40:47 
2007 -0700
@@ -65,7 +65,6 @@ typedef struct blkif_st {
        domid_t           domid;
        unsigned int      handle;
        /* Physical parameters of the comms window. */
-       unsigned int      evtchn;
        unsigned int      irq;
        /* Comms information. */
        blkif_back_ring_t blk_ring;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Jan 10 
08:40:47 2007 -0700
@@ -97,7 +97,6 @@ int blkif_map(blkif_t *blkif, unsigned l
 {
        blkif_sring_t *sring;
        int err;
-       struct evtchn_bind_interdomain bind_interdomain;
 
        /* Already connected through? */
        if (blkif->irq)
@@ -112,24 +111,18 @@ int blkif_map(blkif_t *blkif, unsigned l
                return err;
        }
 
-       bind_interdomain.remote_dom  = blkif->domid;
-       bind_interdomain.remote_port = evtchn;
+       sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+       BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
 
-       err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-                                         &bind_interdomain);
-       if (err) {
+       err = bind_interdomain_evtchn_to_irqhandler(
+               blkif->domid, evtchn, blkif_be_int, 0, "blkif-backend", blkif);
+       if (err < 0)
+       {
                unmap_frontend_page(blkif);
                free_vm_area(blkif->blk_ring_area);
                return err;
        }
-
-       blkif->evtchn = bind_interdomain.local_port;
-
-       sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
-       BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-
-       blkif->irq = bind_evtchn_to_irqhandler(
-               blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
+       blkif->irq = err;
 
        return 0;
 }
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Wed Jan 10 
08:40:47 2007 -0700
@@ -174,8 +174,8 @@ again:
                message = "writing ring-ref";
                goto abort_transaction;
        }
-       err = xenbus_printf(xbt, dev->nodename,
-                           "event-channel", "%u", info->evtchn);
+       err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
+                           irq_to_evtchn_port(info->irq));
        if (err) {
                message = "writing event-channel";
                goto abort_transaction;
@@ -228,15 +228,11 @@ static int setup_blkring(struct xenbus_d
        }
        info->ring_ref = err;
 
-       err = xenbus_alloc_evtchn(dev, &info->evtchn);
-       if (err)
-               goto fail;
-
-       err = bind_evtchn_to_irqhandler(
-               info->evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
+       err = bind_listening_port_to_irqhandler(
+               dev->otherend_id, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
        if (err <= 0) {
                xenbus_dev_fatal(dev, err,
-                                "bind_evtchn_to_irqhandler failed");
+                                "bind_listening_port_to_irqhandler");
                goto fail;
        }
        info->irq = err;
@@ -310,7 +306,7 @@ static void connect(struct blkfront_info
        DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend);
 
        err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
-                           "sectors", "%llu", &sectors,
+                           "sectors", "%Lu", &sectors,
                            "info", "%u", &binfo,
                            "sector-size", "%lu", &sector_size,
                            NULL);
@@ -775,8 +771,7 @@ static void blkif_free(struct blkfront_i
        }
        if (info->irq)
                unbind_from_irqhandler(info->irq, info);
-       info->evtchn = info->irq = 0;
-
+       info->irq = 0;
 }
 
 static void blkif_completion(struct blk_shadow *s)
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Wed Jan 10 08:40:47 
2007 -0700
@@ -119,7 +119,7 @@ struct blkfront_info
        int connected;
        int ring_ref;
        blkif_front_ring_t ring;
-       unsigned int evtchn, irq;
+       unsigned int irq;
        struct xlbd_major_info *mi;
        request_queue_t *rq;
        struct work_struct work;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blktap/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile  Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile  Wed Jan 10 08:40:47 
2007 -0700
@@ -1,3 +1,5 @@ LINUXINCLUDE += -I../xen/include/public/
 LINUXINCLUDE += -I../xen/include/public/io
-obj-y  := xenbus.o interface.o blktap.o 
 
+obj-$(CONFIG_XEN_BLKDEV_TAP) := xenblktap.o
+
+xenblktap-y := xenbus.o interface.o blktap.o 
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Jan 10 08:40:47 
2007 -0700
@@ -56,7 +56,6 @@ typedef struct blkif_st {
        domid_t           domid;
        unsigned int      handle;
        /* Physical parameters of the comms window. */
-       unsigned int      evtchn;
        unsigned int      irq;
        /* Comms information. */
        blkif_back_ring_t blk_ring;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Jan 10 
08:40:47 2007 -0700
@@ -98,7 +98,6 @@ int tap_blkif_map(blkif_t *blkif, unsign
 {
        blkif_sring_t *sring;
        int err;
-       struct evtchn_bind_interdomain bind_interdomain;
 
        /* Already connected through? */
        if (blkif->irq)
@@ -113,24 +112,18 @@ int tap_blkif_map(blkif_t *blkif, unsign
                return err;
        }
 
-       bind_interdomain.remote_dom  = blkif->domid;
-       bind_interdomain.remote_port = evtchn;
+       sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
+       BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
 
-       err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-                                         &bind_interdomain);
-       if (err) {
+       err = bind_interdomain_evtchn_to_irqhandler(
+               blkif->domid, evtchn, tap_blkif_be_int,
+               0, "blkif-backend", blkif);
+       if (err < 0) {
                unmap_frontend_page(blkif);
                free_vm_area(blkif->blk_ring_area);
                return err;
        }
-
-       blkif->evtchn = bind_interdomain.local_port;
-
-       sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
-       BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
-
-       blkif->irq = bind_evtchn_to_irqhandler(
-               blkif->evtchn, tap_blkif_be_int, 0, "blkif-backend", blkif);
+       blkif->irq = err;
 
        return 0;
 }
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c   Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c   Wed Jan 10 
08:40:47 2007 -0700
@@ -121,7 +121,7 @@ int xencons_ring_init(void)
            !xen_start_info->console.domU.evtchn)
                return -ENODEV;
 
-       irq = bind_evtchn_to_irqhandler(
+       irq = bind_caller_port_to_irqhandler(
                xen_start_info->console.domU.evtchn,
                handle_input, 0, "xencons", NULL);
        if (irq < 0) {
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c    Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c    Wed Jan 10 08:40:47 
2007 -0700
@@ -61,7 +61,14 @@ static u32 irq_info[NR_IRQS];
 static u32 irq_info[NR_IRQS];
 
 /* Binding types. */
-enum { IRQT_UNBOUND, IRQT_PIRQ, IRQT_VIRQ, IRQT_IPI, IRQT_EVTCHN };
+enum {
+       IRQT_UNBOUND,
+       IRQT_PIRQ,
+       IRQT_VIRQ,
+       IRQT_IPI,
+       IRQT_LOCAL_PORT,
+       IRQT_CALLER_PORT
+};
 
 /* Constructor for packed IRQ information. */
 static inline u32 mk_irq_info(u32 type, u32 index, u32 evtchn)
@@ -208,38 +215,51 @@ void force_evtchn_callback(void)
 /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
 EXPORT_SYMBOL(force_evtchn_callback);
 
+static DEFINE_PER_CPU(unsigned int, upcall_count) = { 0 };
+
 /* NB. Interrupts are disabled on entry. */
 asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
 {
        unsigned long  l1, l2;
-       unsigned int   l1i, l2i, port;
+       unsigned int   l1i, l2i, port, count;
        int            irq, cpu = smp_processor_id();
        shared_info_t *s = HYPERVISOR_shared_info;
        vcpu_info_t   *vcpu_info = &s->vcpu_info[cpu];
 
-       vcpu_info->evtchn_upcall_pending = 0;
+       do {
+               /* Avoid a callback storm when we reenable delivery. */
+               vcpu_info->evtchn_upcall_pending = 0;
+
+               /* Nested invocations bail immediately. */
+               if (unlikely(per_cpu(upcall_count, cpu)++))
+                       return;
 
 #ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
-       /* Clear master pending flag /before/ clearing selector flag. */
-       rmb();
+               /* Clear master flag /before/ clearing selector flag. */
+               rmb();
 #endif
-       l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
-       while (l1 != 0) {
-               l1i = __ffs(l1);
-               l1 &= ~(1UL << l1i);
-
-               while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
-                       l2i = __ffs(l2);
-
-                       port = (l1i * BITS_PER_LONG) + l2i;
-                       if ((irq = evtchn_to_irq[port]) != -1)
-                               do_IRQ(irq, regs);
-                       else {
-                               exit_idle();
-                               evtchn_device_upcall(port);
+               l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
+               while (l1 != 0) {
+                       l1i = __ffs(l1);
+                       l1 &= ~(1UL << l1i);
+
+                       while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
+                               l2i = __ffs(l2);
+
+                               port = (l1i * BITS_PER_LONG) + l2i;
+                               if ((irq = evtchn_to_irq[port]) != -1)
+                                       do_IRQ(irq, regs);
+                               else {
+                                       exit_idle();
+                                       evtchn_device_upcall(port);
+                               }
                        }
                }
-       }
+
+               /* If there were nested callbacks then we have more to do. */
+               count = per_cpu(upcall_count, cpu);
+               per_cpu(upcall_count, cpu) = 0;
+       } while (unlikely(count != 1));
 }
 
 static int find_unbound_irq(void)
@@ -262,18 +282,18 @@ static int find_unbound_irq(void)
        return -ENOSPC;
 }
 
-static int bind_evtchn_to_irq(unsigned int evtchn)
+static int bind_caller_port_to_irq(unsigned int caller_port)
 {
        int irq;
 
        spin_lock(&irq_mapping_update_lock);
 
-       if ((irq = evtchn_to_irq[evtchn]) == -1) {
+       if ((irq = evtchn_to_irq[caller_port]) == -1) {
                if ((irq = find_unbound_irq()) < 0)
                        goto out;
 
-               evtchn_to_irq[evtchn] = irq;
-               irq_info[irq] = mk_irq_info(IRQT_EVTCHN, 0, evtchn);
+               evtchn_to_irq[caller_port] = irq;
+               irq_info[irq] = mk_irq_info(IRQT_CALLER_PORT, 0, caller_port);
        }
 
        irq_bindcount[irq]++;
@@ -281,6 +301,59 @@ static int bind_evtchn_to_irq(unsigned i
  out:
        spin_unlock(&irq_mapping_update_lock);
        return irq;
+}
+
+static int bind_local_port_to_irq(unsigned int local_port)
+{
+       int irq;
+
+       spin_lock(&irq_mapping_update_lock);
+
+       BUG_ON(evtchn_to_irq[local_port] != -1);
+
+       if ((irq = find_unbound_irq()) < 0) {
+               struct evtchn_close close = { .port = local_port };
+               if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
+                       BUG();
+               goto out;
+       }
+
+       evtchn_to_irq[local_port] = irq;
+       irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
+       irq_bindcount[irq]++;
+
+ out:
+       spin_unlock(&irq_mapping_update_lock);
+       return irq;
+}
+
+static int bind_listening_port_to_irq(unsigned int remote_domain)
+{
+       struct evtchn_alloc_unbound alloc_unbound;
+       int err;
+
+       alloc_unbound.dom        = DOMID_SELF;
+       alloc_unbound.remote_dom = remote_domain;
+
+       err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
+                                         &alloc_unbound);
+
+       return err ? : bind_local_port_to_irq(alloc_unbound.port);
+}
+
+static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,
+                                         unsigned int remote_port)
+{
+       struct evtchn_bind_interdomain bind_interdomain;
+       int err;
+
+       bind_interdomain.remote_dom  = remote_domain;
+       bind_interdomain.remote_port = remote_port;
+
+       err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
+                                         &bind_interdomain);
+
+       return err ? : bind_local_port_to_irq(bind_interdomain.local_port);
 }
 
 static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
@@ -357,7 +430,8 @@ static void unbind_from_irq(unsigned int
 
        if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) {
                close.port = evtchn;
-               if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
+               if ((type_from_irq(irq) != IRQT_CALLER_PORT) &&
+                   HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
                        BUG();
 
                switch (type_from_irq(irq)) {
@@ -383,17 +457,16 @@ static void unbind_from_irq(unsigned int
        spin_unlock(&irq_mapping_update_lock);
 }
 
-int bind_evtchn_to_irqhandler(
-       unsigned int evtchn,
+int bind_caller_port_to_irqhandler(
+       unsigned int caller_port,
        irqreturn_t (*handler)(int, void *, struct pt_regs *),
        unsigned long irqflags,
        const char *devname,
        void *dev_id)
 {
-       unsigned int irq;
-       int retval;
-
-       irq = bind_evtchn_to_irq(evtchn);
+       int irq, retval;
+
+       irq = bind_caller_port_to_irq(caller_port);
        if (irq < 0)
                return irq;
 
@@ -405,7 +478,54 @@ int bind_evtchn_to_irqhandler(
 
        return irq;
 }
-EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler);
+EXPORT_SYMBOL_GPL(bind_caller_port_to_irqhandler);
+
+int bind_listening_port_to_irqhandler(
+       unsigned int remote_domain,
+       irqreturn_t (*handler)(int, void *, struct pt_regs *),
+       unsigned long irqflags,
+       const char *devname,
+       void *dev_id)
+{
+       int irq, retval;
+
+       irq = bind_listening_port_to_irq(remote_domain);
+       if (irq < 0)
+               return irq;
+
+       retval = request_irq(irq, handler, irqflags, devname, dev_id);
+       if (retval != 0) {
+               unbind_from_irq(irq);
+               return retval;
+       }
+
+       return irq;
+}
+EXPORT_SYMBOL_GPL(bind_listening_port_to_irqhandler);
+
+int bind_interdomain_evtchn_to_irqhandler(
+       unsigned int remote_domain,
+       unsigned int remote_port,
+       irqreturn_t (*handler)(int, void *, struct pt_regs *),
+       unsigned long irqflags,
+       const char *devname,
+       void *dev_id)
+{
+       int irq, retval;
+
+       irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
+       if (irq < 0)
+               return irq;
+
+       retval = request_irq(irq, handler, irqflags, devname, dev_id);
+       if (retval != 0) {
+               unbind_from_irq(irq);
+               return retval;
+       }
+
+       return irq;
+}
+EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler);
 
 int bind_virq_to_irqhandler(
        unsigned int virq,
@@ -415,8 +535,7 @@ int bind_virq_to_irqhandler(
        const char *devname,
        void *dev_id)
 {
-       unsigned int irq;
-       int retval;
+       int irq, retval;
 
        irq = bind_virq_to_irq(virq, cpu);
        if (irq < 0)
@@ -440,8 +559,7 @@ int bind_ipi_to_irqhandler(
        const char *devname,
        void *dev_id)
 {
-       unsigned int irq;
-       int retval;
+       int irq, retval;
 
        irq = bind_ipi_to_irq(ipi, cpu);
        if (irq < 0)
@@ -716,6 +834,12 @@ void notify_remote_via_irq(int irq)
 }
 EXPORT_SYMBOL_GPL(notify_remote_via_irq);
 
+int irq_to_evtchn_port(int irq)
+{
+       return evtchn_from_irq(irq);
+}
+EXPORT_SYMBOL_GPL(irq_to_evtchn_port);
+
 void mask_evtchn(int port)
 {
        shared_info_t *s = HYPERVISOR_shared_info;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c     Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c     Wed Jan 10 
08:40:47 2007 -0700
@@ -98,8 +98,8 @@ void xen_machine_kexec_setup_resources(v
  err:
        /*
         * It isn't possible to free xen_phys_cpus this early in the
-        * boot. Since failure at this stage is unexpected and the
-        * amount is small we leak the memory.
+        * boot. Failure at this stage is unexpected and the amount of
+        * memory is small therefore we tolerate the potential leak.
          */
        xen_max_nr_phys_cpus = 0;
        return;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c
--- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c  Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c  Wed Jan 10 08:40:47 
2007 -0700
@@ -56,7 +56,6 @@ struct xenfb_info
        struct page             **pages;
        struct list_head        mappings; /* protected by mm_lock */
 
-       unsigned                evtchn;
        int                     irq;
        struct xenfb_page       *page;
        unsigned long           *mfns;
@@ -156,7 +155,7 @@ static void xenfb_do_update(struct xenfb
        wmb();                  /* ensure ring contents visible */
        info->page->out_prod = prod + 1;
 
-       notify_remote_via_evtchn(info->evtchn);
+       notify_remote_via_irq(info->irq);
 }
 
 static int xenfb_queue_full(struct xenfb_info *info)
@@ -429,7 +428,7 @@ static irqreturn_t xenfb_event_handler(i
 
        if (page->in_cons != page->in_prod) {
                info->page->in_cons = info->page->in_prod;
-               notify_remote_via_evtchn(info->evtchn);
+               notify_remote_via_irq(info->irq);
        }
        return IRQ_HANDLED;
 }
@@ -618,14 +617,11 @@ static int xenfb_connect_backend(struct 
        int ret;
        struct xenbus_transaction xbt;
 
-       ret = xenbus_alloc_evtchn(dev, &info->evtchn);
-       if (ret)
-               return ret;
-       ret = bind_evtchn_to_irqhandler(info->evtchn, xenfb_event_handler,
-                                       0, "xenfb", info);
+       ret = bind_listening_port_to_irqhandler(
+               dev->otherend_id, xenfb_event_handler, 0, "xenfb", info);
        if (ret < 0) {
-               xenbus_free_evtchn(dev, info->evtchn);
-               xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
+               xenbus_dev_fatal(dev, ret,
+                                "bind_listening_port_to_irqhandler");
                return ret;
        }
        info->irq = ret;
@@ -641,7 +637,7 @@ static int xenfb_connect_backend(struct 
        if (ret)
                goto error_xenbus;
        ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
-                           info->evtchn);
+                           irq_to_evtchn_port(info->irq));
        if (ret)
                goto error_xenbus;
        ret = xenbus_printf(xbt, dev->nodename, "feature-update", "1");
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c Wed Jan 10 08:40:47 
2007 -0700
@@ -31,7 +31,6 @@ struct xenkbd_info
 {
        struct input_dev *dev;
        struct xenkbd_page *page;
-       unsigned evtchn;
        int irq;
        struct xenbus_device *xbdev;
 };
@@ -76,7 +75,7 @@ static irqreturn_t input_handler(int rq,
        input_sync(info->dev);
        mb();                   /* ensure we got ring contents */
        page->in_cons = cons;
-       notify_remote_via_evtchn(info->evtchn);
+       notify_remote_via_irq(info->irq);
 
        return IRQ_HANDLED;
 }
@@ -168,14 +167,11 @@ static int xenkbd_connect_backend(struct
        int ret;
        struct xenbus_transaction xbt;
 
-       ret = xenbus_alloc_evtchn(dev, &info->evtchn);
-       if (ret)
-               return ret;
-       ret = bind_evtchn_to_irqhandler(info->evtchn, input_handler, 0,
-                                       "xenkbd", info);
+       ret = bind_listening_port_to_irqhandler(
+               dev->otherend_id, input_handler, 0, "xenkbd", info);
        if (ret < 0) {
-               xenbus_free_evtchn(dev, info->evtchn);
-               xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
+               xenbus_dev_fatal(dev, ret,
+                                "bind_listening_port_to_irqhandler");
                return ret;
        }
        info->irq = ret;
@@ -191,7 +187,7 @@ static int xenkbd_connect_backend(struct
        if (ret)
                goto error_xenbus;
        ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
-                           info->evtchn);
+                           irq_to_evtchn_port(info->irq));
        if (ret)
                goto error_xenbus;
        ret = xenbus_transaction_end(xbt, 0);
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Wed Jan 10 08:40:47 
2007 -0700
@@ -67,7 +67,6 @@ typedef struct netif_st {
        grant_ref_t      tx_shmem_ref;
        grant_handle_t   rx_shmem_handle;
        grant_ref_t      rx_shmem_ref;
-       unsigned int     evtchn;
        unsigned int     irq;
 
        /* The shared rings and indexes. */
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Jan 10 
08:40:47 2007 -0700
@@ -259,7 +259,6 @@ int netif_map(netif_t *netif, unsigned l
        int err = -ENOMEM;
        netif_tx_sring_t *txs;
        netif_rx_sring_t *rxs;
-       struct evtchn_bind_interdomain bind_interdomain;
 
        /* Already connected through? */
        if (netif->irq)
@@ -276,18 +275,12 @@ int netif_map(netif_t *netif, unsigned l
        if (err)
                goto err_map;
 
-       bind_interdomain.remote_dom = netif->domid;
-       bind_interdomain.remote_port = evtchn;
-
-       err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-                                         &bind_interdomain);
-       if (err)
+       err = bind_interdomain_evtchn_to_irqhandler(
+               netif->domid, evtchn, netif_be_int, 0,
+               netif->dev->name, netif);
+       if (err < 0)
                goto err_hypervisor;
-
-       netif->evtchn = bind_interdomain.local_port;
-
-       netif->irq = bind_evtchn_to_irqhandler(
-               netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
+       netif->irq = err;
        disable_irq(netif->irq);
 
        txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Wed Jan 10 
08:40:47 2007 -0700
@@ -153,7 +153,7 @@ struct netfront_info {
        spinlock_t   tx_lock;
        spinlock_t   rx_lock;
 
-       unsigned int evtchn, irq;
+       unsigned int irq;
        unsigned int copying_receiver;
 
        /* Receive-ring batched refills. */
@@ -244,12 +244,8 @@ static int setup_device(struct xenbus_de
 static int setup_device(struct xenbus_device *, struct netfront_info *);
 static struct net_device *create_netdev(struct xenbus_device *);
 
-static void netfront_closing(struct xenbus_device *);
-
 static void end_access(int, void *);
 static void netif_disconnect_backend(struct netfront_info *);
-static int open_netdev(struct netfront_info *);
-static void close_netdev(struct netfront_info *);
 
 static int network_connect(struct net_device *);
 static void network_tx_buf_gc(struct net_device *);
@@ -293,9 +289,20 @@ static int __devinit netfront_probe(stru
        info = netdev_priv(netdev);
        dev->dev.driver_data = info;
 
-       err = open_netdev(info);
-       if (err)
+       err = register_netdev(info->netdev);
+       if (err) {
+               printk(KERN_WARNING "%s: register_netdev err=%d\n",
+                      __FUNCTION__, err);
                goto fail;
+       }
+
+       err = xennet_sysfs_addif(info->netdev);
+       if (err) {
+               unregister_netdev(info->netdev);
+               printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
+                      __FUNCTION__, err);
+               goto fail;
+       }
 
        return 0;
 
@@ -305,6 +312,24 @@ static int __devinit netfront_probe(stru
        return err;
 }
 
+static int __devexit netfront_remove(struct xenbus_device *dev)
+{
+       struct netfront_info *info = dev->dev.driver_data;
+
+       DPRINTK("%s\n", dev->nodename);
+
+       netif_disconnect_backend(info);
+
+       del_timer_sync(&info->rx_refill_timer);
+
+       xennet_sysfs_delif(info->netdev);
+
+       unregister_netdev(info->netdev);
+
+       free_netdev(info->netdev);
+
+       return 0;
+}
 
 /**
  * We are reconnecting to the backend, due to a suspend/resume, or a backend
@@ -383,7 +408,8 @@ again:
                goto abort_transaction;
        }
        err = xenbus_printf(xbt, dev->nodename,
-                           "event-channel", "%u", info->evtchn);
+                           "event-channel", "%u",
+                           irq_to_evtchn_port(info->irq));
        if (err) {
                message = "writing event-channel";
                goto abort_transaction;
@@ -488,17 +514,15 @@ static int setup_device(struct xenbus_de
        }
        info->rx_ring_ref = err;
 
-       err = xenbus_alloc_evtchn(dev, &info->evtchn);
-       if (err)
-               goto fail;
-
        memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
-       err = bind_evtchn_to_irqhandler(info->evtchn, netif_int,
-                                       SA_SAMPLE_RANDOM, netdev->name,
-                                       netdev);
+
+       err = bind_listening_port_to_irqhandler(
+               dev->otherend_id, netif_int, SA_SAMPLE_RANDOM, netdev->name,
+               netdev);
        if (err < 0)
                goto fail;
        info->irq = err;
+
        return 0;
 
  fail:
@@ -534,9 +558,7 @@ static void backend_changed(struct xenbu
                break;
 
        case XenbusStateClosing:
-               if (dev->state == XenbusStateClosed)
-                       break;
-               netfront_closing(dev);
+               xenbus_frontend_closed(dev);
                break;
        }
 }
@@ -1995,70 +2017,6 @@ inetdev_notify(struct notifier_block *th
 }
 
 
-/* ** Close down ** */
-
-
-/**
- * Handle the change of state of the backend to Closing.  We must delete our
- * device-layer structures now, to ensure that writes are flushed through to
- * the backend.  Once is this done, we can switch to Closed in
- * acknowledgement.
- */
-static void netfront_closing(struct xenbus_device *dev)
-{
-       struct netfront_info *info = dev->dev.driver_data;
-
-       DPRINTK("%s\n", dev->nodename);
-
-       close_netdev(info);
-       xenbus_frontend_closed(dev);
-}
-
-
-static int __devexit netfront_remove(struct xenbus_device *dev)
-{
-       struct netfront_info *info = dev->dev.driver_data;
-
-       DPRINTK("%s\n", dev->nodename);
-
-       netif_disconnect_backend(info);
-       free_netdev(info->netdev);
-
-       return 0;
-}
-
-
-static int open_netdev(struct netfront_info *info)
-{
-       int err;
-       
-       err = register_netdev(info->netdev);
-       if (err) {
-               printk(KERN_WARNING "%s: register_netdev err=%d\n",
-                      __FUNCTION__, err);
-               return err;
-       }
-
-       err = xennet_sysfs_addif(info->netdev);
-       if (err) {
-               unregister_netdev(info->netdev);
-               printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
-                      __FUNCTION__, err);
-               return err;
-       }
-
-       return 0;
-}
-
-static void close_netdev(struct netfront_info *info)
-{
-       del_timer_sync(&info->rx_refill_timer);
-
-       xennet_sysfs_delif(info->netdev);
-       unregister_netdev(info->netdev);
-}
-
-
 static void netif_disconnect_backend(struct netfront_info *info)
 {
        /* Stop old i/f to prevent errors whilst we rebuild the state. */
@@ -2070,7 +2028,7 @@ static void netif_disconnect_backend(str
 
        if (info->irq)
                unbind_from_irqhandler(info->irq, info->netdev);
-       info->evtchn = info->irq = 0;
+       info->irq = 0;
 
        end_access(info->tx_ring_ref, info->tx.sring);
        end_access(info->rx_ring_ref, info->rx.sring);
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c Wed Jan 10 08:40:47 
2007 -0700
@@ -71,7 +71,6 @@ static int pciback_do_attach(struct pcib
                             int remote_evtchn)
 {
        int err = 0;
-       int evtchn;
        struct vm_struct *area;
 
        dev_dbg(&pdev->xdev->dev,
@@ -86,12 +85,9 @@ static int pciback_do_attach(struct pcib
        pdev->sh_area = area;
        pdev->sh_info = area->addr;
 
-       err = xenbus_bind_evtchn(pdev->xdev, remote_evtchn, &evtchn);
-       if (err)
-               goto out;
-
-       err = bind_evtchn_to_irqhandler(evtchn, pciback_handle_event,
-                                       SA_SAMPLE_RANDOM, "pciback", pdev);
+       err = bind_interdomain_evtchn_to_irqhandler(
+               pdev->xdev->otherend_id, remote_evtchn, pciback_handle_event,
+               SA_SAMPLE_RANDOM, "pciback", pdev);
        if (err < 0) {
                xenbus_dev_fatal(pdev->xdev, err,
                                 "Error binding event channel to IRQ");
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Wed Jan 10 08:00:50 
2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Wed Jan 10 08:40:47 
2007 -0700
@@ -30,7 +30,6 @@ typedef struct tpmif_st {
        unsigned int handle;
 
        /* Physical parameters of the comms window. */
-       unsigned int evtchn;
        unsigned int irq;
 
        /* The shared rings and indexes. */
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Jan 10 
08:40:47 2007 -0700
@@ -118,11 +118,9 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
 int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
 {
        int err;
-       struct evtchn_bind_interdomain bind_interdomain;
 
-       if (tpmif->irq) {
+       if (tpmif->irq)
                return 0;
-       }
 
        if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
                return -ENOMEM;
@@ -133,24 +131,17 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
                return err;
        }
 
+       tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
 
-       bind_interdomain.remote_dom  = tpmif->domid;
-       bind_interdomain.remote_port = evtchn;
-
-       err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-                                         &bind_interdomain);
-       if (err) {
+       err = bind_interdomain_evtchn_to_irqhandler(
+               tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
+       if (err < 0) {
                unmap_frontend_page(tpmif);
                free_vm_area(tpmif->tx_area);
                return err;
        }
+       tpmif->irq = err;
 
-       tpmif->evtchn = bind_interdomain.local_port;
-
-       tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
-
-       tpmif->irq = bind_evtchn_to_irqhandler(
-               tpmif->evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
        tpmif->shmem_ref = shared_page;
        tpmif->active = 1;
 
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c   Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c   Wed Jan 10 
08:40:47 2007 -0700
@@ -254,28 +254,6 @@ EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
 EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
 
 
-int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
-{
-       struct evtchn_bind_interdomain bind_interdomain;
-       int err;
-
-       bind_interdomain.remote_dom  = dev->otherend_id;
-       bind_interdomain.remote_port = remote_port,
-
-       err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-                                         &bind_interdomain);
-       if (err)
-               xenbus_dev_fatal(dev, err,
-                                "binding to event channel %d from domain %d",
-                                remote_port, dev->otherend_id);
-       else
-               *port = bind_interdomain.local_port;
-
-       return err;
-}
-EXPORT_SYMBOL_GPL(xenbus_bind_evtchn);
-
-
 int xenbus_free_evtchn(struct xenbus_device *dev, int port)
 {
        struct evtchn_close close;
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Wed Jan 10 
08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Wed Jan 10 
08:40:47 2007 -0700
@@ -196,7 +196,7 @@ int xb_init_comms(void)
        if (xenbus_irq)
                unbind_from_irqhandler(xenbus_irq, &xb_waitq);
 
-       err = bind_evtchn_to_irqhandler(
+       err = bind_caller_port_to_irqhandler(
                xen_store_evtchn, wake_waiting,
                0, "xenbus", &xb_waitq);
        if (err <= 0) {
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h      Wed Jan 
10 08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h      Wed Jan 
10 08:40:47 2007 -0700
@@ -34,6 +34,8 @@ extern int swiotlb_dma_supported(struct 
 extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
 extern void swiotlb_init(void);
 
+extern unsigned int dma_bits;
+
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
 #else
diff -r 42babffffba5 -r 58633caeece9 
linux-2.6-xen-sparse/include/asm-ia64/swiotlb.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/linux-2.6-xen-sparse/include/asm-ia64/swiotlb.h   Wed Jan 10 08:40:47 
2007 -0700
@@ -0,0 +1,45 @@
+#ifndef _ASM_SWIOTLB_H
+#define _ASM_SWIOTLB_H 1
+
+#include <linux/config.h>
+
+/* SWIOTLB interface */
+
+extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t 
size,
+                                     int dir);
+extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
+                                 size_t size, int dir);
+extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
+                                        dma_addr_t dev_addr,
+                                        size_t size, int dir);
+extern void swiotlb_sync_single_for_device(struct device *hwdev,
+                                           dma_addr_t dev_addr,
+                                           size_t size, int dir);
+extern void swiotlb_sync_sg_for_cpu(struct device *hwdev,
+                                    struct scatterlist *sg, int nelems,
+                                    int dir);
+extern void swiotlb_sync_sg_for_device(struct device *hwdev,
+                                       struct scatterlist *sg, int nelems,
+                                       int dir);
+extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg,
+                     int nents, int direction);
+extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
+                        int nents, int direction);
+extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
+extern dma_addr_t swiotlb_map_page(struct device *hwdev, struct page *page,
+                                   unsigned long offset, size_t size,
+                                   enum dma_data_direction direction);
+extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dma_address,
+                               size_t size, enum dma_data_direction direction);
+extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
+extern void swiotlb_init(void);
+
+extern unsigned int dma_bits;
+
+#ifdef CONFIG_SWIOTLB
+extern int swiotlb;
+#else
+#define swiotlb 0
+#endif
+
+#endif
diff -r 42babffffba5 -r 58633caeece9 linux-2.6-xen-sparse/include/xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/xen/evtchn.h Wed Jan 10 08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/include/xen/evtchn.h Wed Jan 10 08:40:47 2007 -0700
@@ -52,22 +52,34 @@
  * The IRQ argument passed to the callback handler is the same as returned
  * from the bind call. It may not correspond to a Linux IRQ number.
  * Returns IRQ or negative errno.
- * UNBIND: Takes IRQ to unbind from; automatically closes the event channel.
  */
-extern int bind_evtchn_to_irqhandler(
-       unsigned int evtchn,
+int bind_caller_port_to_irqhandler(
+       unsigned int caller_port,
        irqreturn_t (*handler)(int, void *, struct pt_regs *),
        unsigned long irqflags,
        const char *devname,
        void *dev_id);
-extern int bind_virq_to_irqhandler(
+int bind_listening_port_to_irqhandler(
+       unsigned int remote_domain,
+       irqreturn_t (*handler)(int, void *, struct pt_regs *),
+       unsigned long irqflags,
+       const char *devname,
+       void *dev_id);
+int bind_interdomain_evtchn_to_irqhandler(
+       unsigned int remote_domain,
+       unsigned int remote_port,
+       irqreturn_t (*handler)(int, void *, struct pt_regs *),
+       unsigned long irqflags,
+       const char *devname,
+       void *dev_id);
+int bind_virq_to_irqhandler(
        unsigned int virq,
        unsigned int cpu,
        irqreturn_t (*handler)(int, void *, struct pt_regs *),
        unsigned long irqflags,
        const char *devname,
        void *dev_id);
-extern int bind_ipi_to_irqhandler(
+int bind_ipi_to_irqhandler(
        unsigned int ipi,
        unsigned int cpu,
        irqreturn_t (*handler)(int, void *, struct pt_regs *),
@@ -77,21 +89,21 @@ extern int bind_ipi_to_irqhandler(
 
 /*
  * Common unbind function for all event sources. Takes IRQ to unbind from.
- * Automatically closes the underlying event channel (even for bindings
- * made with bind_evtchn_to_irqhandler()).
+ * Automatically closes the underlying event channel (except for bindings
+ * made with bind_caller_port_to_irqhandler()).
  */
-extern void unbind_from_irqhandler(unsigned int irq, void *dev_id);
+void unbind_from_irqhandler(unsigned int irq, void *dev_id);
 
-extern void irq_resume(void);
+void irq_resume(void);
 
 /* Entry point for notifications into Linux subsystems. */
 asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
 
 /* Entry point for notifications into the userland character device. */
-extern void evtchn_device_upcall(int port);
+void evtchn_device_upcall(int port);
 
-extern void mask_evtchn(int port);
-extern void unmask_evtchn(int port);
+void mask_evtchn(int port);
+void unmask_evtchn(int port);
 
 static inline void clear_evtchn(int port)
 {
@@ -106,9 +118,10 @@ static inline void notify_remote_via_evt
 }
 
 /*
- * Unlike notify_remote_via_evtchn(), this is safe to use across
- * save/restore. Notifications on a broken connection are silently dropped.
+ * Use these to access the event channel underlying the IRQ handle returned
+ * by bind_*_to_irqhandler().
  */
-extern void notify_remote_via_irq(int irq);
+void notify_remote_via_irq(int irq);
+int irq_to_evtchn_port(int irq);
 
 #endif /* __ASM_EVTCHN_H__ */
diff -r 42babffffba5 -r 58633caeece9 linux-2.6-xen-sparse/include/xen/xenbus.h
--- a/linux-2.6-xen-sparse/include/xen/xenbus.h Wed Jan 10 08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Wed Jan 10 08:40:47 2007 -0700
@@ -262,14 +262,6 @@ int xenbus_alloc_evtchn(struct xenbus_de
 
 
 /**
- * Bind to an existing interdomain event channel in another domain. Returns 0
- * on success and stores the local port in *port. On error, returns -errno,
- * switches the device to XenbusStateClosing, and saves the error in XenStore.
- */
-int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port);
-
-
-/**
  * Free an existing event channel. Returns 0 on success or -errno on error.
  */
 int xenbus_free_evtchn(struct xenbus_device *dev, int port);
diff -r 42babffffba5 -r 58633caeece9 linux-2.6-xen-sparse/kernel/kexec.c
--- a/linux-2.6-xen-sparse/kernel/kexec.c       Wed Jan 10 08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/kernel/kexec.c       Wed Jan 10 08:40:47 2007 -0700
@@ -1012,9 +1012,11 @@ asmlinkage long sys_kexec_load(unsigned 
                        goto out;
        }
 #ifdef CONFIG_XEN
-       result = xen_machine_kexec_load(image);
-       if (result)
-               goto out;
+       if (image) {
+               result = xen_machine_kexec_load(image);
+               if (result)
+                       goto out;
+       }
 #endif
        /* Install the new kernel, and  Uninstall the old */
        image = xchg(dest_image, image);
diff -r 42babffffba5 -r 58633caeece9 linux-2.6-xen-sparse/net/core/dev.c
--- a/linux-2.6-xen-sparse/net/core/dev.c       Wed Jan 10 08:00:50 2007 -0700
+++ b/linux-2.6-xen-sparse/net/core/dev.c       Wed Jan 10 08:40:47 2007 -0700
@@ -1248,14 +1248,13 @@ static int dev_gso_segment(struct sk_buf
        /* Verifying header integrity only. */
        if (!segs)
                return 0;
-
+  
        if (unlikely(IS_ERR(segs)))
                return PTR_ERR(segs);
 
        skb->next = segs;
        DEV_GSO_CB(skb)->destructor = skb->destructor;
        skb->destructor = dev_gso_skb_destructor;
-
        return 0;
 }
 
diff -r 42babffffba5 -r 58633caeece9 patches/linux-2.6.16.33/vsnprintf.patch
--- a/patches/linux-2.6.16.33/vsnprintf.patch   Wed Jan 10 08:00:50 2007 -0700
+++ b/patches/linux-2.6.16.33/vsnprintf.patch   Wed Jan 10 08:40:47 2007 -0700
@@ -203,7 +203,7 @@ index b07db5c..f595947 100644
 +              if (str < end)
 +                      *str = '\0';
 +              else
-+                      *end = '\0';
++                      end[-1] = '\0';
 +      }
 +      /* the trailing null byte doesn't count towards the total */
        return str-buf;
diff -r 42babffffba5 -r 58633caeece9 tools/Rules.mk
--- a/tools/Rules.mk    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/Rules.mk    Wed Jan 10 08:40:47 2007 -0700
@@ -50,5 +50,7 @@ mk-symlinks-xen:
        ( cd xen/hvm && ln -sf ../../$(XEN_ROOT)/xen/include/public/hvm/*.h . )
        mkdir -p xen/io
        ( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
+       mkdir -p xen/arch-x86
+       ( cd xen/arch-x86 && ln -sf 
../../$(XEN_ROOT)/xen/include/public/arch-x86/*.h . )
 
 mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
diff -r 42babffffba5 -r 58633caeece9 tools/blktap/drivers/block-qcow.c
--- a/tools/blktap/drivers/block-qcow.c Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/blktap/drivers/block-qcow.c Wed Jan 10 08:40:47 2007 -0700
@@ -47,6 +47,11 @@
 #define ASSERT(_p) ((void)0)
 #endif
 
+#define ROUNDUP(l, s) \
+({ \
+    (uint64_t)( \
+        (l + (s - 1)) - ((l + (s - 1)) % s)); \
+})
 
 /******AIO DEFINES******/
 #define REQUEST_ASYNC_FD 1
@@ -76,9 +81,9 @@ struct pending_aio {
 
 #define QCOW_CRYPT_NONE 0x00
 #define QCOW_CRYPT_AES  0x01
-#define QCOW_SPARSE_FILE 0x02
 
 #define QCOW_OFLAG_COMPRESSED (1LL << 63)
+#define SPARSE_FILE 0x01
 
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -418,8 +423,9 @@ static void encrypt_sectors(struct tdqco
 
 static int qtruncate(int fd, off_t length, int sparse)
 {
-       int current, ret, i; 
-       int sectors = length/DEFAULT_SECTOR_SIZE;
+       int ret, i; 
+       int current = 0, rem = 0;
+       int sectors = (length + DEFAULT_SECTOR_SIZE - 1)/DEFAULT_SECTOR_SIZE;
        struct stat st;
        char buf[DEFAULT_SECTOR_SIZE];
 
@@ -429,22 +435,45 @@ static int qtruncate(int fd, off_t lengt
         */
        memset(buf, 0x00, DEFAULT_SECTOR_SIZE);
        ret = fstat(fd, &st);
-       if((ret == -1) || S_ISBLK(st.st_mode))
+       if (ret == -1)
                return -1;
-
-       if(st.st_size < length) {
+       if (S_ISBLK(st.st_mode))
+               return 0;
+
+       current = (st.st_size + DEFAULT_SECTOR_SIZE - 1)/DEFAULT_SECTOR_SIZE;
+       rem = st.st_size % DEFAULT_SECTOR_SIZE;
+
+       /* If we are extending this file, we write zeros to the end --
+        * this tries to ensure that the extents allocated wind up being
+        * contiguous on disk.
+        */
+       if(st.st_size < sectors * DEFAULT_SECTOR_SIZE) {
                /*We are extending the file*/
-               lseek(fd, 0, SEEK_END);
-               for (i = 0; i < sectors; i++ ) {
+               if (lseek(fd, 0, SEEK_END)==-1) {
+                       fprintf(stderr, 
+                               "Lseek EOF failed (%d), internal error\n",
+                               errno);
+                       return -1;
+               }
+               if (rem) {
+                       ret = write(fd, buf, rem);
+                       if (ret != rem)
+                               return -1;
+               }
+               for (i = current; i < sectors; i++ ) {
                        ret = write(fd, buf, DEFAULT_SECTOR_SIZE);
                        if (ret != DEFAULT_SECTOR_SIZE)
                                return -1;
                }
                
-       } else if(sparse && (st.st_size > length))
-               ftruncate(fd, length);
-
-       return 1;
+       } else if(sparse && (st.st_size > sectors * DEFAULT_SECTOR_SIZE))
+               if (ftruncate(fd, sectors * DEFAULT_SECTOR_SIZE)==-1) {
+                       fprintf(stderr,
+                               "Ftruncate failed (%d), internal error\n",
+                                errno);
+                       return -1;
+               }
+       return 0;
 }
 
 
@@ -497,7 +526,12 @@ static uint64_t get_cluster_offset(struc
                
                /*Truncate file for L2 table 
                 *(initialised to zero in case we crash)*/
-               qtruncate(s->fd, l2_offset + (s->l2_size * sizeof(uint64_t)), 
s->sparse);
+               if (qtruncate(s->fd, 
+                             l2_offset + (s->l2_size * sizeof(uint64_t)),
+                             s->sparse) != 0) {
+                       DPRINTF("ERROR truncating file\n");
+                       return 0;
+               }
                s->fd_end = l2_offset + (s->l2_size * sizeof(uint64_t));
 
                /*Update the L1 table entry on disk
@@ -564,8 +598,12 @@ cache_miss:
                                (s->l2_size * sizeof(uint64_t));
                        cluster_offset = (cluster_offset + s->cluster_size - 1)
                                & ~(s->cluster_size - 1);
-                       qtruncate(s->fd, cluster_offset + 
-                                 (s->cluster_size * s->l2_size), s->sparse);
+                       if (qtruncate(s->fd, cluster_offset + 
+                                 (s->cluster_size * s->l2_size), 
+                                     s->sparse) != 0) {
+                               DPRINTF("ERROR truncating file\n");
+                               return 0;
+                       }
                        s->fd_end = cluster_offset + 
                                (s->cluster_size * s->l2_size);
                        for (i = 0; i < s->l2_size; i++) {
@@ -623,8 +661,11 @@ found:
                                cluster_offset = 
                                        (cluster_offset + s->cluster_size - 1) 
                                        & ~(s->cluster_size - 1);
-                               qtruncate(s->fd, cluster_offset + 
-                                         s->cluster_size, s->sparse);
+                               if (qtruncate(s->fd, cluster_offset + 
+                                             s->cluster_size, s->sparse)!=0) {
+                                       DPRINTF("ERROR truncating file\n");
+                                       return 0;
+                               }
                                s->fd_end = (cluster_offset + s->cluster_size);
                                /* if encrypted, we must initialize the cluster
                                   content which won't be written */
@@ -909,15 +950,14 @@ int tdqcow_open (struct td_state *bs, co
 
                /*Finally check the L1 table cksum*/
                be32_to_cpus(&exthdr->cksum);
-               cksum = gen_cksum((char *)s->l1_table, s->l1_size * 
sizeof(uint64_t));
-               if(exthdr->cksum != cksum) {
+               cksum = gen_cksum((char *)s->l1_table, 
+                                 s->l1_size * sizeof(uint64_t));
+               if(exthdr->cksum != cksum)
                        goto end_xenhdr;
-               }
                        
                be32_to_cpus(&exthdr->min_cluster_alloc);
                be32_to_cpus(&exthdr->flags);
-               if (exthdr->flags & QCOW_SPARSE_FILE)
-                       s->sparse = 1;
+               s->sparse = (exthdr->flags & SPARSE_FILE);
                s->min_cluster_alloc = exthdr->min_cluster_alloc; 
        }
 
@@ -1210,10 +1250,10 @@ int tdqcow_do_callbacks(struct td_state 
 }
 
 int qcow_create(const char *filename, uint64_t total_size,
-                      const char *backing_file, int flags)
+                      const char *backing_file, int sparse)
 {
        int fd, header_size, backing_filename_len, l1_size, i;
-       int shift, length, adjust, ret = 0;
+       int shift, length, adjust, flags = 0, ret = 0;
        QCowHeader header;
        QCowHeader_ext exthdr;
        char backing_filename[1024], *ptr;
@@ -1305,41 +1345,41 @@ int qcow_create(const char *filename, ui
        DPRINTF("L1 Table offset: %d, size %d\n",
                header_size,
                (int)(l1_size * sizeof(uint64_t)));
-       if (flags & QCOW_CRYPT_AES) {
-               header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
-       } else {
-               header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
-       }
+       header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
 
        ptr = calloc(1, l1_size * sizeof(uint64_t));
        exthdr.cksum = cpu_to_be32(gen_cksum(ptr, l1_size * sizeof(uint64_t)));
        printf("Created cksum: %d\n",exthdr.cksum);
        free(ptr);
 
-       /*adjust file length to 4 KByte boundary*/
-       length = header_size + l1_size * sizeof(uint64_t);
-       if (length % 4096 > 0) {
-               length = ((length >> 12) + 1) << 12;
-               qtruncate(fd, length, 0);
-               DPRINTF("Adjusted filelength to %d for 4 "
-                       "Kbyte alignment\n",length);
-       }
-
-       if (!(flags & QCOW_SPARSE_FILE)) {
-               /*Filesize is length +  l1_size * (1 << s->l2_bits) + 
(size*512)*/
+       /*adjust file length to system page size boundary*/
+       length = ROUNDUP(header_size + (l1_size * sizeof(uint64_t)),
+               getpagesize());
+       if (qtruncate(fd, length, 0)!=0) {
+               DPRINTF("ERROR truncating file\n");
+               return -1;
+       }
+
+       if (sparse == 0) {
+               /*Filesize is length+l1_size*(1 << s->l2_bits)+(size*512)*/
                total_length = length + (l1_size * (1 << 9)) + (size * 512);
-               qtruncate(fd, total_length, 0);
+               if (qtruncate(fd, total_length, 0)!=0) {
+                        DPRINTF("ERROR truncating file\n");
+                        return -1;
+               }
                printf("File truncated to length %"PRIu64"\n",total_length);
-       }
+       } else
+               flags = SPARSE_FILE;
+
        exthdr.flags = cpu_to_be32(flags);
        
        /* write all the data */
        lseek(fd, 0, SEEK_SET);
        ret += write(fd, &header, sizeof(header));
        ret += write(fd, &exthdr, sizeof(exthdr));
-       if (backing_file) {
+       if (backing_file)
                ret += write(fd, backing_filename, backing_filename_len);
-       }
+
        lseek(fd, header_size, SEEK_SET);
        tmp = 0;
        for (i = 0;i < l1_size; i++) {
@@ -1360,7 +1400,10 @@ int qcow_make_empty(struct td_state *bs)
        lseek(s->fd, s->l1_table_offset, SEEK_SET);
        if (write(s->fd, s->l1_table, l1_length) < 0)
                return -1;
-       qtruncate(s->fd, s->l1_table_offset + l1_length, s->sparse);
+       if (qtruncate(s->fd, s->l1_table_offset + l1_length, s->sparse)!=0) {
+               DPRINTF("ERROR truncating file\n");
+               return -1;
+       }
 
        memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
        memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t));
diff -r 42babffffba5 -r 58633caeece9 tools/blktap/drivers/qcow-create.c
--- a/tools/blktap/drivers/qcow-create.c        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/blktap/drivers/qcow-create.c        Wed Jan 10 08:40:47 2007 -0700
@@ -47,15 +47,13 @@
 #define DFPRINTF(_f, _a...) ((void)0)
 #endif
 
-#define QCOW_NONSPARSE_FILE 0x00
-#define QCOW_SPARSE_FILE 0x02
 #define MAX_NAME_LEN 1000
 
 void help(void)
 {
        fprintf(stderr, "Qcow-utils: v1.0.0\n");
        fprintf(stderr, 
-               "usage: qcow-create [-h help] [-p reserve] <SIZE(MB)> 
<FILENAME> "
+               "usage: qcow-create [-h help] [-r reserve] <SIZE(MB)> 
<FILENAME> "
                "[<BACKING_FILENAME>]\n"); 
        exit(-1);
 }
@@ -63,12 +61,12 @@ int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
        int ret = -1, c, backed = 0;
-       int flags =  QCOW_SPARSE_FILE;
+       int sparse =  1;
        uint64_t size;
        char filename[MAX_NAME_LEN], bfilename[MAX_NAME_LEN];
 
         for(;;) {
-                c = getopt(argc, argv, "hp");
+                c = getopt(argc, argv, "hr");
                 if (c == -1)
                         break;
                 switch(c) {
@@ -76,9 +74,12 @@ int main(int argc, char *argv[])
                         help();
                         exit(0);
                         break;
-                case 'p':
-                       flags = QCOW_NONSPARSE_FILE;
+                case 'r':
+                       sparse = 0;
                        break;
+               default:
+                       fprintf(stderr, "Unknown option\n");
+                       help();
                }
        }
 
@@ -96,6 +97,7 @@ int main(int argc, char *argv[])
        }
 
        if (optind != argc) {
+               /*Backing file argument*/
                backed = 1;
                if (snprintf(bfilename, MAX_NAME_LEN, "%s",argv[optind++]) >=
                        MAX_NAME_LEN) {
@@ -106,12 +108,14 @@ int main(int argc, char *argv[])
 
        DFPRINTF("Creating file size %llu, name %s\n",(long long unsigned)size, 
filename);
        if (!backed)
-               ret = qcow_create(filename,size,NULL,flags);
+               ret = qcow_create(filename,size,NULL,sparse);
        else
-               ret = qcow_create(filename,size,bfilename,flags);
+               ret = qcow_create(filename,size,bfilename,sparse);
 
-       if (ret < 0) DPRINTF("Unable to create QCOW file\n");
-       else DPRINTF("QCOW file successfully created\n");
+       if (ret < 0)
+               DPRINTF("Unable to create QCOW file\n");
+       else
+               DPRINTF("QCOW file successfully created\n");
 
        return 0;
 }
diff -r 42babffffba5 -r 58633caeece9 tools/examples/Makefile
--- a/tools/examples/Makefile   Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/Makefile   Wed Jan 10 08:40:47 2007 -0700
@@ -9,6 +9,7 @@ XENDOMAINS_SYSCONFIG = init.d/sysconfig.
 # Xen configuration dir and configs to go there.
 XEN_CONFIG_DIR = /etc/xen
 XEN_CONFIGS = xend-config.sxp
+XEN_CONFIGS += xm-config.xml
 XEN_CONFIGS += xmexample1 
 XEN_CONFIGS += xmexample2
 XEN_CONFIGS += xmexample.hvm
diff -r 42babffffba5 -r 58633caeece9 tools/examples/blktap
--- a/tools/examples/blktap     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/blktap     Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Copyright (c) 2005, XenSource Ltd.
 
diff -r 42babffffba5 -r 58633caeece9 tools/examples/block
--- a/tools/examples/block      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/block      Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 dir=$(dirname "$0")
 . "$dir/block-common.sh"
diff -r 42babffffba5 -r 58633caeece9 tools/examples/block-enbd
--- a/tools/examples/block-enbd Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/block-enbd Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Usage: block-enbd [bind server ctl_port |unbind node]
 #
diff -r 42babffffba5 -r 58633caeece9 tools/examples/block-nbd
--- a/tools/examples/block-nbd  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/block-nbd  Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Usage: block-nbd [bind server ctl_port |unbind node]
 #
diff -r 42babffffba5 -r 58633caeece9 tools/examples/external-device-migrate
--- a/tools/examples/external-device-migrate    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/external-device-migrate    Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Copyright (c) 2005 IBM Corporation
 #
diff -r 42babffffba5 -r 58633caeece9 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/network-bridge     Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #============================================================================
 # Default Xen network start/stop script.
 # Xend calls a network script when it starts.
diff -r 42babffffba5 -r 58633caeece9 tools/examples/network-nat
--- a/tools/examples/network-nat        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/network-nat        Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #============================================================================
 # Default Xen network start/stop script when using NAT.
 # Xend calls a network script when it starts.
diff -r 42babffffba5 -r 58633caeece9 tools/examples/network-route
--- a/tools/examples/network-route      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/network-route      Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #============================================================================
 # Default Xen network start/stop script.
 # Xend calls a network script when it starts.
diff -r 42babffffba5 -r 58633caeece9 tools/examples/vif-bridge
--- a/tools/examples/vif-bridge Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/vif-bridge Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #============================================================================
 # /etc/xen/vif-bridge
 #
diff -r 42babffffba5 -r 58633caeece9 tools/examples/vif-common.sh
--- a/tools/examples/vif-common.sh      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/vif-common.sh      Wed Jan 10 08:40:47 2007 -0700
@@ -64,7 +64,7 @@ fi
 fi
 
 
-function frob_iptable()
+frob_iptable()
 {
   if [ "$command" == "online" ]
   then
@@ -89,7 +89,7 @@ If you are using iptables, this may affe
 # to those coming from the specified networks, though we allow DHCP requests
 # as well.
 #
-function handle_iptable()
+handle_iptable()
 {
   # Check for a working iptables installation.  Checking for the iptables
   # binary is not sufficient, because the user may not have the appropriate
@@ -123,7 +123,7 @@ function handle_iptable()
 # Print the IP address currently in use at the given interface, or nothing if
 # the interface is not up.
 #
-function ip_of()
+ip_of()
 {
   ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed -n '1 s,/.*,,p'
 }
@@ -137,7 +137,7 @@ function ip_of()
 # to these scripts, or eth0 by default.  This function will call fatal if no
 # such interface could be found.
 #
-function dom0_ip()
+dom0_ip()
 {
   local nd=${netdev:-eth0}
   local result=$(ip_of "$nd")
diff -r 42babffffba5 -r 58633caeece9 tools/examples/vif-nat
--- a/tools/examples/vif-nat    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/vif-nat    Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #============================================================================
 # /etc/xen/vif-nat
 #
diff -r 42babffffba5 -r 58633caeece9 tools/examples/vif-route
--- a/tools/examples/vif-route  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/vif-route  Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #============================================================================
 # /etc/xen/vif-route
 #
diff -r 42babffffba5 -r 58633caeece9 tools/examples/vtpm
--- a/tools/examples/vtpm       Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/vtpm       Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 dir=$(dirname "$0")
 . "$dir/vtpm-hotplug-common.sh"
diff -r 42babffffba5 -r 58633caeece9 tools/examples/vtpm-delete
--- a/tools/examples/vtpm-delete        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/vtpm-delete        Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # This scripts must be called the following way:
 # vtpm-delete <domain name>
diff -r 42babffffba5 -r 58633caeece9 tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/xen-backend.agent  Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 
 PATH=/etc/xen/scripts:$PATH
 
diff -r 42babffffba5 -r 58633caeece9 tools/examples/xen-hotplug-cleanup
--- a/tools/examples/xen-hotplug-cleanup        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/xen-hotplug-cleanup        Wed Jan 10 08:40:47 2007 -0700
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 
 dir=$(dirname "$0")
 . "$dir/xen-hotplug-common.sh"
diff -r 42babffffba5 -r 58633caeece9 tools/examples/xm-config.xml
--- a/tools/examples/xm-config.xml      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/xm-config.xml      Wed Jan 10 08:40:47 2007 -0700
@@ -36,8 +36,10 @@ most useful for experimenting with the X
        The username and password attributes will be used to log in if Xen-API
        is being used.
     -->
+  <!--
   <server type='Xen-API'
           uri='http://localhost:9363/'
           username='me'
           password='mypassword' />
+   -->
 </xm>
diff -r 42babffffba5 -r 58633caeece9 tools/examples/xmexample.hvm
--- a/tools/examples/xmexample.hvm      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/examples/xmexample.hvm      Wed Jan 10 08:40:47 2007 -0700
@@ -29,7 +29,7 @@ memory = 128
 
 # Shadow pagetable memory for the domain, in MB.
 # Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
-shadow_memory = 8
+# shadow_memory = 8
 
 # A name for your domain. All domains must have different names.
 name = "ExampleHVMDomain"
@@ -116,7 +116,7 @@ device_model = '/usr/' + arch_libdir + '
 device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
 
 #-----------------------------------------------------------------------------
-# boot on floppy (a), hard disk (c) or CD-ROM (d) 
+# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) 
 # default: hard disk, cd-rom, floppy
 #boot="cda"
 
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/etherboot/README
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/etherboot/README   Wed Jan 10 08:40:47 2007 -0700
@@ -0,0 +1,7 @@
+
+This is an Etherboot option ROM for the rtl8139 NIC.  It has a few
+non-standard settings, just to do with timeouts and when to give up.
+
+Rom-o-matic.net will provide this image at the following URL:
+
+http://rom-o-matic.net/5.4.2/build.php?version=5.4.2&F=ignore&nic=rtl8139%3Artl8139+--+%5B0x10ec%2C0x8139%5D&ofmt=Binary+ROM+Image%28.zrom%29&arch=i386&ASK_BOOT=-1&BOOT_FIRST=BOOT_NIC&BOOT_SECOND=BOOT_NOTHING&BOOT_THIRD=BOOT_NOTHING&BOOT_INDEX=0&STATIC_CLIENT_IP=&STATIC_SUBNET_MASK=&STATIC_SERVER_IP=&STATIC_GATEWAY_IP=&STATIC_BOOTFILE=&EXIT_ON_FILE_LOAD_ERROR=on&DHCP_CLIENT_ID=&DHCP_CLIENT_ID_LEN=&DHCP_CLIENT_ID_TYPE=&DHCP_USER_CLASS=&DHCP_USER_CLASS_LEN=&ALLOW_ONLY_ENCAPSULATED=on&DEFAULT_BOOTFILE=&CONGESTED=on&BACKOFF_LIMIT=7&TIMEOUT=180&TRY_FLOPPY_FIRST=0&EXIT_IF_NO_OFFER=on&TAGGED_IMAGE=on&ELF_IMAGE=on&PXE_IMAGE=on&DOWNLOAD_PROTO_TFTP=on&COMCONSOLE=0x3F8&CONSPEED=9600&COMPARM=0x03&PXE_EXPORT=on&CONFIG_PCI=on&CONFIG_ISA=on&BUILD_ID=&PCBIOS=on&A=Get+ROM
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/etherboot/eb-rtl8139.zrom
Binary file tools/firmware/etherboot/eb-rtl8139.zrom has changed
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/Makefile Wed Jan 10 08:40:47 2007 -0700
@@ -51,11 +51,12 @@ acpi/acpi.a:
 acpi/acpi.a:
        $(MAKE) -C acpi
 
-roms.h:        ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin 
../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin
+roms.h:        ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin 
../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin 
../etherboot/eb-rtl8139.zrom
        sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
        sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
        sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin 
>> roms.h
        sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h
+       sh ./mkhex etherboot ../etherboot/eb-rtl8139.zrom >> roms.h
 
 .PHONY: clean
 clean:
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/Makefile
--- a/tools/firmware/hvmloader/acpi/Makefile    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/acpi/Makefile    Wed Jan 10 08:40:47 2007 -0700
@@ -24,7 +24,7 @@ H_SRC = $(wildcard *.h)
 H_SRC = $(wildcard *.h)
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
-IASL_VER = acpica-unix-20050513
+IASL_VER = acpica-unix-20060707
 IASL_URL = 
http://developer.intel.com/technology/iapc/acpi/downloads/$(IASL_VER).tar.gz
 
 # Disable PIE/SSP if GCC supports them. They can break us.
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/acpi2_0.h
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h   Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h   Wed Jan 10 08:40:47 2007 -0700
@@ -50,17 +50,18 @@ struct acpi_header {
     uint8_t  revision;
     uint8_t  checksum;
     uint8_t  oem_id[6];
-    uint64_t oem_table_id;
+    uint8_t  oem_table_id[8];
     uint32_t oem_revision;
     uint32_t creator_id;
     uint32_t creator_revision;
 };
 
-#define ACPI_OEM_ID             {'I','N','T','E','L',' '}
-#define ACPI_OEM_TABLE_ID       ASCII32(' ','T','B','D')
-#define ACPI_OEM_REVISION       0x00000002
-#define ACPI_CREATOR_ID         0x00       /* TBD */
-#define ACPI_CREATOR_REVISION   0x00000002
+#define ACPI_OEM_ID             "Xen"
+#define ACPI_OEM_TABLE_ID       "HVM"
+#define ACPI_OEM_REVISION       0
+
+#define ACPI_CREATOR_ID         ASCII32('H','V','M','L') /* HVMLoader */
+#define ACPI_CREATOR_REVISION   0
 
 /*
  * ACPI 2.0 Generic Address Space definition.
@@ -121,7 +122,6 @@ struct acpi_20_rsdt {
     struct acpi_header header;
     uint32_t entry[1];
 };
-#define ACPI_2_0_RSDT_REVISION 0x01
 
 /*
  * Extended System Description Table (XSDT).
@@ -130,7 +130,6 @@ struct acpi_20_xsdt {
     struct acpi_header header;
     uint64_t entry[1];
 };
-#define ACPI_2_0_XSDT_REVISION 0x01
 
 /*
  * TCG Hardware Interface Table (TCPA)
@@ -141,8 +140,6 @@ struct acpi_20_tcpa {
     uint32_t laml;
     uint64_t lasa;
 };
-
-#define ACPI_2_0_TCPA_REVISION 0x02
 #define ACPI_2_0_TCPA_LAML_SIZE (64*1024)
 
 /*
@@ -202,7 +199,6 @@ struct acpi_20_fadt {
     struct acpi_20_generic_address x_gpe0_blk;
     struct acpi_20_generic_address x_gpe1_blk;
 };
-#define ACPI_2_0_FADT_REVISION 0x03
 
 /*
  * FADT Boot Architecture Flags.
@@ -254,7 +250,19 @@ struct acpi_20_madt {
     uint32_t flags;
 };
 
-#define ACPI_2_0_MADT_REVISION 0x01
+
+/*
+ * HPET Description Table
+ */
+struct acpi_20_hpet {
+    struct acpi_header header;
+    uint32_t           timer_block_id;
+    struct acpi_20_generic_address addr;
+    uint8_t            hpet_number;
+    uint16_t           min_tick;
+    uint8_t            page_protect;
+};
+#define ACPI_HPET_ADDRESS 0xFED00000UL
 
 /*
  * Multiple APIC Flags.
@@ -325,6 +333,18 @@ struct acpi_20_madt_intsrcovr {
 #define ACPI_2_0_RSDT_SIGNATURE ASCII32('R','S','D','T')
 #define ACPI_2_0_XSDT_SIGNATURE ASCII32('X','S','D','T')
 #define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A')
+#define ACPI_2_0_HPET_SIGNATURE ASCII32('H','P','E','T')
+
+/*
+ * Table revision numbers.
+ */
+#define ACPI_2_0_RSDP_REVISION 0x02
+#define ACPI_2_0_FADT_REVISION 0x04
+#define ACPI_2_0_MADT_REVISION 0x02
+#define ACPI_2_0_RSDT_REVISION 0x01
+#define ACPI_2_0_XSDT_REVISION 0x01
+#define ACPI_2_0_TCPA_REVISION 0x02
+#define ACPI_2_0_HPET_REVISION 0x01
 
 #pragma pack ()
 
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/acpi/build.c     Wed Jan 10 08:40:47 2007 -0700
@@ -57,8 +57,8 @@ int construct_madt(struct acpi_20_madt *
     memset(madt, 0, sizeof(*madt));
     madt->header.signature    = ACPI_2_0_MADT_SIGNATURE;
     madt->header.revision     = ACPI_2_0_MADT_REVISION;
-    strncpy(madt->header.oem_id, "INTEL ", 6);
-    madt->header.oem_table_id = ACPI_OEM_TABLE_ID;
+    strncpy(madt->header.oem_id, ACPI_OEM_ID, 6);
+    strncpy(madt->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
     madt->header.oem_revision = ACPI_OEM_REVISION;
     madt->header.creator_id   = ACPI_CREATOR_ID;
     madt->header.creator_revision = ACPI_CREATOR_REVISION;
@@ -69,16 +69,28 @@ int construct_madt(struct acpi_20_madt *
     intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
     for ( i = 0; i < 16; i++ )
     {
-        if ( !(PCI_ISA_IRQ_MASK & (1U << i)) )
-            continue;
-
-        /* PCI: active-low level-triggered */
         memset(intsrcovr, 0, sizeof(*intsrcovr));
         intsrcovr->type   = ACPI_INTERRUPT_SOURCE_OVERRIDE;
         intsrcovr->length = sizeof(*intsrcovr);
         intsrcovr->source = i;
-        intsrcovr->gsi    = i;
-        intsrcovr->flags  = 0xf;
+
+        if ( i == 0 )
+        {
+            /* ISA IRQ0 routed to IOAPIC GSI 2. */
+            intsrcovr->gsi    = 2;
+            intsrcovr->flags  = 0x0;
+        }
+        else if ( PCI_ISA_IRQ_MASK & (1U << i) )
+        {
+            /* PCI: active-low level-triggered. */
+            intsrcovr->gsi    = i;
+            intsrcovr->flags  = 0xf;
+        }
+        else
+        {
+            /* No need for a INT source override structure. */
+            continue;
+        }
 
         offset += sizeof(*intsrcovr);
         intsrcovr++;
@@ -98,7 +110,7 @@ int construct_madt(struct acpi_20_madt *
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
         lapic->length  = sizeof(*lapic);
-        lapic->acpi_processor_id = lapic->apic_id = i + 1;
+        lapic->acpi_processor_id = lapic->apic_id = LAPIC_ID(i);
         lapic->flags   = ACPI_LOCAL_APIC_ENABLED;
         offset += sizeof(*lapic);
         lapic++;
@@ -110,10 +122,33 @@ int construct_madt(struct acpi_20_madt *
     return align16(offset);
 }
 
+int construct_hpet(struct acpi_20_hpet *hpet)
+{
+    int offset;
+
+    memset(hpet, 0, sizeof(*hpet));
+    hpet->header.signature    = ACPI_2_0_HPET_SIGNATURE;
+    hpet->header.revision     = ACPI_2_0_HPET_REVISION;
+    strncpy(hpet->header.oem_id, ACPI_OEM_ID, 6);
+    strncpy(hpet->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
+    hpet->header.oem_revision = ACPI_OEM_REVISION;
+    hpet->header.creator_id   = ACPI_CREATOR_ID;
+    hpet->header.creator_revision = ACPI_CREATOR_REVISION;
+    hpet->timer_block_id      = 0x8086a201;
+    hpet->addr.address        = ACPI_HPET_ADDRESS;
+    offset = sizeof(*hpet);
+
+    hpet->header.length = offset;
+    set_checksum(hpet, offsetof(struct acpi_header, checksum), offset);
+
+    return offset;
+}
+
 int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
 {
     int offset = 0, nr_tables = 0;
     struct acpi_20_madt *madt;
+    struct acpi_20_hpet *hpet;
     struct acpi_20_tcpa *tcpa;
     static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
     uint16_t *tis_hdr;
@@ -125,6 +160,11 @@ int construct_secondary_tables(uint8_t *
         offset += construct_madt(madt);
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
+
+    /* HPET. */
+    hpet = (struct acpi_20_hpet *)&buf[offset];
+    offset += construct_hpet(hpet);
+    table_ptrs[nr_tables++] = (unsigned long)hpet;
 
     /* TPM TCPA and SSDT. */
     tis_hdr = (uint16_t *)0xFED40F00;
@@ -144,12 +184,11 @@ int construct_secondary_tables(uint8_t *
         tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
         tcpa->header.length    = sizeof(*tcpa);
         tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
-        strncpy(tcpa->header.oem_id, "IBM   ", 6);
-        tcpa->header.oem_table_id = ASCII64(' ', ' ', ' ', ' ',
-                                            ' ', 'x', 'e', 'n');
-        tcpa->header.oem_revision = 1;
-        tcpa->header.creator_id   = ASCII32('I', 'B', 'M', ' ');
-        tcpa->header.creator_revision = 1;
+        strncpy(tcpa->header.oem_id, ACPI_OEM_ID, 6);
+        strncpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
+        tcpa->header.oem_revision = ACPI_OEM_REVISION;
+        tcpa->header.creator_id   = ACPI_CREATOR_ID;
+        tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
         tcpa->lasa = e820_malloc(
             ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
         if ( tcpa->lasa )
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/dsdt.asl
--- a/tools/firmware/hvmloader/acpi/dsdt.asl    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/acpi/dsdt.asl    Wed Jan 10 08:40:47 2007 -0700
@@ -17,7 +17,7 @@
  * Place - Suite 330, Boston, MA 02111-1307 USA.
  */
 
-DefinitionBlock ("DSDT.aml", "DSDT", 1, "INTEL","int-xen", 2006)
+DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
 {
     Name (\PMBS, 0x0C00)
     Name (\PMLN, 0x08)
@@ -278,6 +278,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
                     Decrement(Local0) 
                     Store(Local0, PIRD) 
                 }
+            }
+
+            Device(HPET) {
+                Name(_HID,  EISAID("PNP0103"))
+                Name(_UID, 0)
+                Name(_CRS, ResourceTemplate() {
+                    DWordMemory(
+                        ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                        NonCacheable, ReadWrite,
+                        0x00000000,
+                        0xFED00000,
+                        0xFED003FF,
+                        0x00000000,
+                        0x00000400 /* 1K memory: FED00000 - FED003FF */
+                    )
+                })
             }
 
             Method(_PRT,0) {
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/dsdt.c
--- a/tools/firmware/hvmloader/acpi/dsdt.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/acpi/dsdt.c      Wed Jan 10 08:40:47 2007 -0700
@@ -1,22 +1,22 @@
 /*
  * 
  * Intel ACPI Component Architecture
- * ASL Optimizing Compiler / AML Disassembler version 20050513 [Nov 16 2006]
- * Copyright (C) 2000 - 2005 Intel Corporation
- * Supports ACPI Specification Revision 3.0
+ * ASL Optimizing Compiler version 20060707 [Dec 30 2006]
+ * Copyright (C) 2000 - 2006 Intel Corporation
+ * Supports ACPI Specification Revision 3.0a
  * 
- * Compilation of "dsdt.asl" - Wed Nov 22 18:26:19 2006
+ * Compilation of "dsdt.asl" - Sat Dec 30 15:31:23 2006
  * 
  * C source code output
  *
  */
-unsigned char AmlCode[] = 
+unsigned char AmlCode[] =
 {
-    0x44,0x53,0x44,0x54,0x9D,0x0D,0x00,0x00,  /* 00000000    "DSDT...." */
-    0x01,0x83,0x49,0x4E,0x54,0x45,0x4C,0x00,  /* 00000008    "..INTEL." */
-    0x69,0x6E,0x74,0x2D,0x78,0x65,0x6E,0x00,  /* 00000010    "int-xen." */
-    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
-    0x13,0x05,0x05,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
+    0x44,0x53,0x44,0x54,0xD9,0x0D,0x00,0x00,  /* 00000000    "DSDT...." */
+    0x02,0xFB,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" */
     0x53,0x0B,0x00,0x0C,0x08,0x50,0x4D,0x4C,  /* 00000028    "S....PML" */
     0x4E,0x0A,0x08,0x08,0x49,0x4F,0x42,0x31,  /* 00000030    "N...IOB1" */
     0x00,0x08,0x49,0x4F,0x4C,0x31,0x00,0x08,  /* 00000038    "..IOL1.." */
@@ -34,7 +34,7 @@ unsigned char AmlCode[] =
     0x12,0x08,0x04,0x0A,0x07,0x0A,0x07,0x00,  /* 00000098    "........" */
     0x00,0x08,0x50,0x49,0x43,0x44,0x00,0x14,  /* 000000A0    "..PICD.." */
     0x0C,0x5F,0x50,0x49,0x43,0x01,0x70,0x68,  /* 000000A8    "._PIC.ph" */
-    0x50,0x49,0x43,0x44,0x10,0x48,0xCE,0x5F,  /* 000000B0    "PICD.H._" */
+    0x50,0x49,0x43,0x44,0x10,0x44,0xD2,0x5F,  /* 000000B0    "PICD.D._" */
     0x53,0x42,0x5F,0x5B,0x82,0x49,0x04,0x4D,  /* 000000B8    "SB_[.I.M" */
     0x45,0x4D,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 000000C0    "EM0._HID" */
     0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x43,  /* 000000C8    ".A...._C" */
@@ -45,7 +45,7 @@ unsigned char AmlCode[] =
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000F0    "........" */
     0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,  /* 000000F8    "........" */
     0x00,0x00,0x00,0x00,0x79,0x00,0x5B,0x82,  /* 00000100    "....y.[." */
-    0x45,0xC9,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "E.PCI0._" */
+    0x41,0xCD,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "A.PCI0._" */
     0x48,0x49,0x44,0x0C,0x41,0xD0,0x0A,0x03,  /* 00000110    "HID.A..." */
     0x08,0x5F,0x55,0x49,0x44,0x00,0x08,0x5F,  /* 00000118    "._UID.._" */
     0x41,0x44,0x52,0x00,0x08,0x5F,0x42,0x42,  /* 00000120    "ADR.._BB" */
@@ -140,313 +140,321 @@ unsigned char AmlCode[] =
     0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,0x01,  /* 000003E8    "_SRS..h." */
     0x49,0x52,0x51,0x31,0x82,0x49,0x52,0x51,  /* 000003F0    "IRQ1.IRQ" */
     0x31,0x60,0x76,0x60,0x70,0x60,0x50,0x49,  /* 000003F8    "1`v`p`PI" */
-    0x52,0x44,0x14,0x16,0x5F,0x50,0x52,0x54,  /* 00000400    "RD.._PRT" */
-    0x00,0xA0,0x0A,0x50,0x49,0x43,0x44,0xA4,  /* 00000408    "...PICD." */
-    0x50,0x52,0x54,0x41,0xA4,0x50,0x52,0x54,  /* 00000410    "PRTA.PRT" */
-    0x50,0x08,0x50,0x52,0x54,0x50,0x12,0x49,  /* 00000418    "P.PRTP.I" */
-    0x36,0x3C,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000420    "6<......" */
-    0x01,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000428    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 00000430    "........" */
-    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000438    ".LNKC..." */
-    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x02,  /* 00000440    "........" */
-    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000448    "LNKD...." */
-    0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,0x4C,  /* 00000450    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000458    "NKA....." */
-    0xFF,0xFF,0x02,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000460    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000468    "C......." */
-    0x02,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000470    "...LNKD." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000478    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000480    "..LNKA.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x0A,  /* 00000488    "........" */
-    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000490    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x00,0x4C,  /* 00000498    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 000004A0    "NKD....." */
-    0xFF,0xFF,0x03,0x00,0x01,0x4C,0x4E,0x4B,  /* 000004A8    ".....LNK" */
-    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 000004B0    "A......." */
-    0x03,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 000004B8    "....LNKB" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x03,  /* 000004C0    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 000004C8    "...LNKC." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 000004D0    "........" */
-    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 000004D8    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x04,0x00,0x01,0x4C,  /* 000004E0    ".......L" */
-    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 000004E8    "NKB....." */
-    0xFF,0xFF,0x04,0x00,0x0A,0x02,0x4C,0x4E,  /* 000004F0    "......LN" */
-    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000004F8    "KC......" */
-    0xFF,0x04,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000500    ".....LNK" */
-    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000508    "D......." */
-    0x05,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000510    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x05,0x00,  /* 00000518    "........" */
-    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000520    ".LNKC..." */
-    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x02,  /* 00000528    "........" */
-    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000530    "LNKD...." */
-    0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x03,0x4C,  /* 00000538    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000540    "NKA....." */
-    0xFF,0xFF,0x06,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000548    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000550    "C......." */
-    0x06,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000558    "...LNKD." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 00000560    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000568    "..LNKA.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x0A,  /* 00000570    "........" */
-    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000578    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x00,0x4C,  /* 00000580    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000588    "NKD....." */
-    0xFF,0xFF,0x07,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000590    ".....LNK" */
-    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000598    "A......." */
-    0x07,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 000005A0    "....LNKB" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x07,  /* 000005A8    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 000005B0    "...LNKC." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 000005B8    "........" */
-    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 000005C0    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x08,0x00,0x01,0x4C,  /* 000005C8    ".......L" */
-    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 000005D0    "NKB....." */
-    0xFF,0xFF,0x08,0x00,0x0A,0x02,0x4C,0x4E,  /* 000005D8    "......LN" */
-    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000005E0    "KC......" */
-    0xFF,0x08,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000005E8    ".....LNK" */
-    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000005F0    "D......." */
-    0x09,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 000005F8    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x09,0x00,  /* 00000600    "........" */
-    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000608    ".LNKC..." */
-    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x02,  /* 00000610    "........" */
-    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000618    "LNKD...." */
-    0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x03,0x4C,  /* 00000620    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000628    "NKA....." */
-    0xFF,0xFF,0x0A,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000630    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000638    "C......." */
-    0x0A,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000640    "...LNKD." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 00000648    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000650    "..LNKA.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x0A,  /* 00000658    "........" */
-    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000660    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x00,0x4C,  /* 00000668    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000670    "NKD....." */
-    0xFF,0xFF,0x0B,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000678    ".....LNK" */
-    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000680    "A......." */
-    0x0B,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000688    "....LNKB" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0B,  /* 00000690    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000698    "...LNKC." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 000006A0    "........" */
-    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 000006A8    ".LNKA..." */
-    0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x01,0x4C,  /* 000006B0    ".......L" */
-    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 000006B8    "NKB....." */
-    0xFF,0xFF,0x0C,0x00,0x0A,0x02,0x4C,0x4E,  /* 000006C0    "......LN" */
-    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000006C8    "KC......" */
-    0xFF,0x0C,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000006D0    ".....LNK" */
-    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006D8    "D......." */
-    0x0D,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 000006E0    "...LNKB." */
-    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0D,0x00,  /* 000006E8    "........" */
-    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 000006F0    ".LNKC..." */
-    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x02,  /* 000006F8    "........" */
-    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000700    "LNKD...." */
-    0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x03,0x4C,  /* 00000708    ".......L" */
-    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000710    "NKA....." */
-    0xFF,0xFF,0x0E,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000718    ".....LNK" */
-    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000720    "C......." */
-    0x0E,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000728    "...LNKD." */
-    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000730    "........" */
-    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000738    "..LNKA.." */
-    0x0E,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x0A,  /* 00000740    "........" */
-    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000748    ".LNKB..." */
-    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x00,0x4C,  /* 00000750    ".......L" */
-    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000758    "NKD....." */
-    0xFF,0xFF,0x0F,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000760    ".....LNK" */
-    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000768    "A......." */
-    0x0F,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000770    "....LNKB" */
-    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000778    "........" */
-    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000780    "...LNKC." */
-    0x08,0x50,0x52,0x54,0x41,0x12,0x41,0x2F,  /* 00000788    ".PRTA.A/" */
-    0x3C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000790    "<......." */
-    0x00,0x00,0x00,0x0A,0x14,0x12,0x0B,0x04,  /* 00000798    "........" */
-    0x0C,0xFF,0xFF,0x01,0x00,0x01,0x00,0x0A,  /* 000007A0    "........" */
-    0x15,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x01,  /* 000007A8    "........" */
-    0x00,0x0A,0x02,0x00,0x0A,0x16,0x12,0x0C,  /* 000007B0    "........" */
-    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,  /* 000007B8    "........" */
-    0x00,0x0A,0x17,0x12,0x0B,0x04,0x0C,0xFF,  /* 000007C0    "........" */
-    0xFF,0x02,0x00,0x00,0x00,0x0A,0x18,0x12,  /* 000007C8    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,  /* 000007D0    "........" */
-    0x00,0x0A,0x19,0x12,0x0C,0x04,0x0C,0xFF,  /* 000007D8    "........" */
-    0xFF,0x02,0x00,0x0A,0x02,0x00,0x0A,0x1A,  /* 000007E0    "........" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 000007E8    "........" */
-    0x0A,0x03,0x00,0x0A,0x1B,0x12,0x0B,0x04,  /* 000007F0    "........" */
-    0x0C,0xFF,0xFF,0x03,0x00,0x00,0x00,0x0A,  /* 000007F8    "........" */
-    0x1C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000800    "........" */
-    0x00,0x01,0x00,0x0A,0x1D,0x12,0x0C,0x04,  /* 00000808    "........" */
-    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,0x00,  /* 00000810    "........" */
-    0x0A,0x1E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000818    "........" */
-    0x03,0x00,0x0A,0x03,0x00,0x0A,0x1F,0x12,  /* 00000820    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x00,  /* 00000828    "........" */
-    0x00,0x0A,0x20,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000830    ".. ....." */
-    0xFF,0x04,0x00,0x01,0x00,0x0A,0x21,0x12,  /* 00000838    "......!." */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,  /* 00000840    "........" */
-    0x02,0x00,0x0A,0x22,0x12,0x0C,0x04,0x0C,  /* 00000848    "..."...." */
-    0xFF,0xFF,0x04,0x00,0x0A,0x03,0x00,0x0A,  /* 00000850    "........" */
-    0x23,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x05,  /* 00000858    "#......." */
-    0x00,0x00,0x00,0x0A,0x24,0x12,0x0B,0x04,  /* 00000860    "....$..." */
-    0x0C,0xFF,0xFF,0x05,0x00,0x01,0x00,0x0A,  /* 00000868    "........" */
-    0x25,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x05,  /* 00000870    "%......." */
-    0x00,0x0A,0x02,0x00,0x0A,0x26,0x12,0x0C,  /* 00000878    ".....&.." */
-    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x03,  /* 00000880    "........" */
-    0x00,0x0A,0x27,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000888    "..'....." */
-    0xFF,0x06,0x00,0x00,0x00,0x0A,0x28,0x12,  /* 00000890    "......(." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x01,  /* 00000898    "........" */
-    0x00,0x0A,0x29,0x12,0x0C,0x04,0x0C,0xFF,  /* 000008A0    "..)....." */
-    0xFF,0x06,0x00,0x0A,0x02,0x00,0x0A,0x2A,  /* 000008A8    ".......*" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 000008B0    "........" */
-    0x0A,0x03,0x00,0x0A,0x2B,0x12,0x0B,0x04,  /* 000008B8    "....+..." */
-    0x0C,0xFF,0xFF,0x07,0x00,0x00,0x00,0x0A,  /* 000008C0    "........" */
-    0x2C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x07,  /* 000008C8    ",......." */
-    0x00,0x01,0x00,0x0A,0x2D,0x12,0x0C,0x04,  /* 000008D0    "....-..." */
-    0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x02,0x00,  /* 000008D8    "........" */
-    0x0A,0x2E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000008E0    "........" */
-    0x07,0x00,0x0A,0x03,0x00,0x0A,0x2F,0x12,  /* 000008E8    "....../." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x00,  /* 000008F0    "........" */
-    0x00,0x0A,0x11,0x12,0x0B,0x04,0x0C,0xFF,  /* 000008F8    "........" */
-    0xFF,0x08,0x00,0x01,0x00,0x0A,0x12,0x12,  /* 00000900    "........" */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,  /* 00000908    "........" */
-    0x02,0x00,0x0A,0x13,0x12,0x0C,0x04,0x0C,  /* 00000910    "........" */
-    0xFF,0xFF,0x08,0x00,0x0A,0x03,0x00,0x0A,  /* 00000918    "........" */
-    0x14,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000920    "........" */
-    0x00,0x00,0x00,0x0A,0x15,0x12,0x0B,0x04,  /* 00000928    "........" */
-    0x0C,0xFF,0xFF,0x09,0x00,0x01,0x00,0x0A,  /* 00000930    "........" */
-    0x16,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000938    "........" */
-    0x00,0x0A,0x02,0x00,0x0A,0x17,0x12,0x0C,  /* 00000940    "........" */
-    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x03,  /* 00000948    "........" */
-    0x00,0x0A,0x18,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000950    "........" */
-    0xFF,0x0A,0x00,0x00,0x00,0x0A,0x19,0x12,  /* 00000958    "........" */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x01,  /* 00000960    "........" */
-    0x00,0x0A,0x1A,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000968    "........" */
-    0xFF,0x0A,0x00,0x0A,0x02,0x00,0x0A,0x1B,  /* 00000970    "........" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 00000978    "........" */
-    0x0A,0x03,0x00,0x0A,0x1C,0x12,0x0B,0x04,  /* 00000980    "........" */
-    0x0C,0xFF,0xFF,0x0B,0x00,0x00,0x00,0x0A,  /* 00000988    "........" */
-    0x1D,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0B,  /* 00000990    "........" */
-    0x00,0x01,0x00,0x0A,0x1E,0x12,0x0C,0x04,  /* 00000998    "........" */
-    0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x02,0x00,  /* 000009A0    "........" */
-    0x0A,0x1F,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000009A8    "........" */
-    0x0B,0x00,0x0A,0x03,0x00,0x0A,0x20,0x12,  /* 000009B0    "...... ." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x00,  /* 000009B8    "........" */
-    0x00,0x0A,0x21,0x12,0x0B,0x04,0x0C,0xFF,  /* 000009C0    "..!....." */
-    0xFF,0x0C,0x00,0x01,0x00,0x0A,0x22,0x12,  /* 000009C8    "......"." */
-    0x0C,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,  /* 000009D0    "........" */
-    0x02,0x00,0x0A,0x23,0x12,0x0C,0x04,0x0C,  /* 000009D8    "...#...." */
-    0xFF,0xFF,0x0C,0x00,0x0A,0x03,0x00,0x0A,  /* 000009E0    "........" */
-    0x24,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0D,  /* 000009E8    "$......." */
-    0x00,0x00,0x00,0x0A,0x25,0x12,0x0B,0x04,  /* 000009F0    "....%..." */
-    0x0C,0xFF,0xFF,0x0D,0x00,0x01,0x00,0x0A,  /* 000009F8    "........" */
-    0x26,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000A00    "&......." */
-    0x00,0x0A,0x02,0x00,0x0A,0x27,0x12,0x0C,  /* 00000A08    ".....'.." */
-    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x03,  /* 00000A10    "........" */
-    0x00,0x0A,0x28,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A18    "..(....." */
-    0xFF,0x0E,0x00,0x00,0x00,0x0A,0x29,0x12,  /* 00000A20    "......)." */
-    0x0B,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x01,  /* 00000A28    "........" */
-    0x00,0x0A,0x2A,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000A30    "..*....." */
-    0xFF,0x0E,0x00,0x0A,0x02,0x00,0x0A,0x2B,  /* 00000A38    ".......+" */
-    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000A40    "........" */
-    0x0A,0x03,0x00,0x0A,0x2C,0x12,0x0B,0x04,  /* 00000A48    "....,..." */
-    0x0C,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x0A,  /* 00000A50    "........" */
-    0x2D,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000A58    "-......." */
-    0x00,0x01,0x00,0x0A,0x2E,0x12,0x0C,0x04,  /* 00000A60    "........" */
-    0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x02,0x00,  /* 00000A68    "........" */
-    0x0A,0x2F,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000A70    "./......" */
-    0x0F,0x00,0x0A,0x03,0x00,0x0A,0x10,0x5B,  /* 00000A78    ".......[" */
-    0x82,0x4C,0x31,0x49,0x53,0x41,0x5F,0x08,  /* 00000A80    ".L1ISA_." */
-    0x5F,0x41,0x44,0x52,0x0C,0x00,0x00,0x01,  /* 00000A88    "_ADR...." */
-    0x00,0x5B,0x80,0x50,0x49,0x52,0x51,0x02,  /* 00000A90    ".[.PIRQ." */
-    0x0A,0x60,0x0A,0x04,0x10,0x2E,0x5C,0x00,  /* 00000A98    ".`....\." */
-    0x5B,0x81,0x29,0x5C,0x2F,0x04,0x5F,0x53,  /* 00000AA0    "[.)\/._S" */
-    0x42,0x5F,0x50,0x43,0x49,0x30,0x49,0x53,  /* 00000AA8    "B_PCI0IS" */
-    0x41,0x5F,0x50,0x49,0x52,0x51,0x01,0x50,  /* 00000AB0    "A_PIRQ.P" */
-    0x49,0x52,0x41,0x08,0x50,0x49,0x52,0x42,  /* 00000AB8    "IRA.PIRB" */
-    0x08,0x50,0x49,0x52,0x43,0x08,0x50,0x49,  /* 00000AC0    ".PIRC.PI" */
-    0x52,0x44,0x08,0x5B,0x82,0x46,0x0B,0x53,  /* 00000AC8    "RD.[.F.S" */
-    0x59,0x53,0x52,0x08,0x5F,0x48,0x49,0x44,  /* 00000AD0    "YSR._HID" */
-    0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x55,  /* 00000AD8    ".A...._U" */
-    0x49,0x44,0x01,0x08,0x43,0x52,0x53,0x5F,  /* 00000AE0    "ID..CRS_" */
-    0x11,0x4E,0x08,0x0A,0x8A,0x47,0x01,0x10,  /* 00000AE8    ".N...G.." */
-    0x00,0x10,0x00,0x00,0x10,0x47,0x01,0x22,  /* 00000AF0    ".....G."" */
-    0x00,0x22,0x00,0x00,0x0C,0x47,0x01,0x30,  /* 00000AF8    "."...G.0" */
-    0x00,0x30,0x00,0x00,0x10,0x47,0x01,0x44,  /* 00000B00    ".0...G.D" */
-    0x00,0x44,0x00,0x00,0x1C,0x47,0x01,0x62,  /* 00000B08    ".D...G.b" */
-    0x00,0x62,0x00,0x00,0x02,0x47,0x01,0x65,  /* 00000B10    ".b...G.e" */
-    0x00,0x65,0x00,0x00,0x0B,0x47,0x01,0x72,  /* 00000B18    ".e...G.r" */
-    0x00,0x72,0x00,0x00,0x0E,0x47,0x01,0x80,  /* 00000B20    ".r...G.." */
-    0x00,0x80,0x00,0x00,0x01,0x47,0x01,0x84,  /* 00000B28    ".....G.." */
-    0x00,0x84,0x00,0x00,0x03,0x47,0x01,0x88,  /* 00000B30    ".....G.." */
-    0x00,0x88,0x00,0x00,0x01,0x47,0x01,0x8C,  /* 00000B38    ".....G.." */
-    0x00,0x8C,0x00,0x00,0x03,0x47,0x01,0x90,  /* 00000B40    ".....G.." */
-    0x00,0x90,0x00,0x00,0x10,0x47,0x01,0xA2,  /* 00000B48    ".....G.." */
-    0x00,0xA2,0x00,0x00,0x1C,0x47,0x01,0xE0,  /* 00000B50    ".....G.." */
-    0x00,0xE0,0x00,0x00,0x10,0x47,0x01,0xA0,  /* 00000B58    ".....G.." */
-    0x08,0xA0,0x08,0x00,0x04,0x47,0x01,0xC0,  /* 00000B60    ".....G.." */
-    0x0C,0xC0,0x0C,0x00,0x10,0x47,0x01,0xD0,  /* 00000B68    ".....G.." */
-    0x04,0xD0,0x04,0x00,0x02,0x79,0x00,0x14,  /* 00000B70    ".....y.." */
-    0x0B,0x5F,0x43,0x52,0x53,0x00,0xA4,0x43,  /* 00000B78    "._CRS..C" */
-    0x52,0x53,0x5F,0x5B,0x82,0x2B,0x50,0x49,  /* 00000B80    "RS_[.+PI" */
-    0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,0x0B,  /* 00000B88    "C_._HID." */
-    0x41,0xD0,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000B90    "A.._CRS." */
-    0x18,0x0A,0x15,0x47,0x01,0x20,0x00,0x20,  /* 00000B98    "...G. . " */
-    0x00,0x01,0x02,0x47,0x01,0xA0,0x00,0xA0,  /* 00000BA0    "...G...." */
-    0x00,0x01,0x02,0x22,0x04,0x00,0x79,0x00,  /* 00000BA8    "..."..y." */
-    0x5B,0x82,0x47,0x05,0x44,0x4D,0x41,0x30,  /* 00000BB0    "[.G.DMA0" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000BB8    "._HID.A." */
-    0x02,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000BC0    "..._CRS." */
-    0x41,0x04,0x0A,0x3D,0x2A,0x10,0x04,0x47,  /* 00000BC8    "A..=*..G" */
-    0x01,0x00,0x00,0x00,0x00,0x00,0x10,0x47,  /* 00000BD0    ".......G" */
-    0x01,0x81,0x00,0x81,0x00,0x00,0x03,0x47,  /* 00000BD8    ".......G" */
-    0x01,0x87,0x00,0x87,0x00,0x00,0x01,0x47,  /* 00000BE0    ".......G" */
-    0x01,0x89,0x00,0x89,0x00,0x00,0x03,0x47,  /* 00000BE8    ".......G" */
-    0x01,0x8F,0x00,0x8F,0x00,0x00,0x01,0x47,  /* 00000BF0    ".......G" */
-    0x01,0xC0,0x00,0xC0,0x00,0x00,0x20,0x47,  /* 00000BF8    "...... G" */
-    0x01,0x80,0x04,0x80,0x04,0x00,0x10,0x79,  /* 00000C00    ".......y" */
-    0x00,0x5B,0x82,0x25,0x54,0x4D,0x52,0x5F,  /* 00000C08    ".[.%TMR_" */
-    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000C10    "._HID.A." */
-    0x01,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000C18    "..._CRS." */
-    0x10,0x0A,0x0D,0x47,0x01,0x40,0x00,0x40,  /* 00000C20    "...G.@.@" */
-    0x00,0x00,0x04,0x22,0x01,0x00,0x79,0x00,  /* 00000C28    "..."..y." */
-    0x5B,0x82,0x25,0x52,0x54,0x43,0x5F,0x08,  /* 00000C30    "[.%RTC_." */
-    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0B,  /* 00000C38    "_HID.A.." */
-    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000C40    ".._CRS.." */
-    0x0A,0x0D,0x47,0x01,0x70,0x00,0x70,0x00,  /* 00000C48    "..G.p.p." */
-    0x00,0x02,0x22,0x00,0x01,0x79,0x00,0x5B,  /* 00000C50    ".."..y.[" */
-    0x82,0x22,0x53,0x50,0x4B,0x52,0x08,0x5F,  /* 00000C58    "."SPKR._" */
-    0x48,0x49,0x44,0x0C,0x41,0xD0,0x08,0x00,  /* 00000C60    "HID.A..." */
-    0x08,0x5F,0x43,0x52,0x53,0x11,0x0D,0x0A,  /* 00000C68    "._CRS..." */
-    0x0A,0x47,0x01,0x61,0x00,0x61,0x00,0x00,  /* 00000C70    ".G.a.a.." */
-    0x01,0x79,0x00,0x5B,0x82,0x31,0x50,0x53,  /* 00000C78    ".y.[.1PS" */
-    0x32,0x4D,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000C80    "2M._HID." */
-    0x41,0xD0,0x0F,0x13,0x08,0x5F,0x43,0x49,  /* 00000C88    "A...._CI" */
-    0x44,0x0C,0x41,0xD0,0x0F,0x13,0x14,0x09,  /* 00000C90    "D.A....." */
-    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 00000C98    "_STA...." */
-    0x08,0x5F,0x43,0x52,0x53,0x11,0x08,0x0A,  /* 00000CA0    "._CRS..." */
-    0x05,0x22,0x00,0x10,0x79,0x00,0x5B,0x82,  /* 00000CA8    "."..y.[." */
-    0x42,0x04,0x50,0x53,0x32,0x4B,0x08,0x5F,  /* 00000CB0    "B.PS2K._" */
-    0x48,0x49,0x44,0x0C,0x41,0xD0,0x03,0x03,  /* 00000CB8    "HID.A..." */
-    0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,0xD0,  /* 00000CC0    "._CID.A." */
-    0x03,0x0B,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000CC8    "...._STA" */
-    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 00000CD0    "....._CR" */
-    0x53,0x11,0x18,0x0A,0x15,0x47,0x01,0x60,  /* 00000CD8    "S....G.`" */
-    0x00,0x60,0x00,0x00,0x01,0x47,0x01,0x64,  /* 00000CE0    ".`...G.d" */
-    0x00,0x64,0x00,0x00,0x01,0x22,0x02,0x00,  /* 00000CE8    ".d...".." */
-    0x79,0x00,0x5B,0x82,0x3A,0x46,0x44,0x43,  /* 00000CF0    "y.[.:FDC" */
-    0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000CF8    "0._HID.A" */
-    0xD0,0x07,0x00,0x14,0x09,0x5F,0x53,0x54,  /* 00000D00    "....._ST" */
-    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 00000D08    "A....._C" */
-    0x52,0x53,0x11,0x1B,0x0A,0x18,0x47,0x01,  /* 00000D10    "RS....G." */
-    0xF0,0x03,0xF0,0x03,0x01,0x06,0x47,0x01,  /* 00000D18    "......G." */
-    0xF7,0x03,0xF7,0x03,0x01,0x01,0x22,0x40,  /* 00000D20    "......"@" */
-    0x00,0x2A,0x04,0x00,0x79,0x00,0x5B,0x82,  /* 00000D28    ".*..y.[." */
-    0x35,0x55,0x41,0x52,0x31,0x08,0x5F,0x48,  /* 00000D30    "5UAR1._H" */
-    0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,0x08,  /* 00000D38    "ID.A...." */
-    0x5F,0x55,0x49,0x44,0x01,0x14,0x09,0x5F,  /* 00000D40    "_UID..._" */
-    0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,  /* 00000D48    "STA....." */
-    0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,  /* 00000D50    "_CRS...." */
-    0x47,0x01,0xF8,0x03,0xF8,0x03,0x01,0x08,  /* 00000D58    "G......." */
-    0x22,0x10,0x00,0x79,0x00,0x5B,0x82,0x36,  /* 00000D60    ""..y.[.6" */
-    0x4C,0x54,0x50,0x31,0x08,0x5F,0x48,0x49,  /* 00000D68    "LTP1._HI" */
-    0x44,0x0C,0x41,0xD0,0x04,0x00,0x08,0x5F,  /* 00000D70    "D.A...._" */
-    0x55,0x49,0x44,0x0A,0x02,0x14,0x09,0x5F,  /* 00000D78    "UID...._" */
-    0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,  /* 00000D80    "STA....." */
-    0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,  /* 00000D88    "_CRS...." */
-    0x47,0x01,0x78,0x03,0x78,0x03,0x08,0x08,  /* 00000D90    "G.x.x..." */
-    0x22,0x80,0x00,0x79,0x00,
+    0x52,0x44,0x5B,0x82,0x3A,0x48,0x50,0x45,  /* 00000400    "RD[.:HPE" */
+    0x54,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000408    "T._HID.A" */
+    0xD0,0x01,0x03,0x08,0x5F,0x55,0x49,0x44,  /* 00000410    "...._UID" */
+    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x1F,  /* 00000418    ".._CRS.." */
+    0x0A,0x1C,0x87,0x17,0x00,0x00,0x0D,0x01,  /* 00000420    "........" */
+    0x00,0x00,0x00,0x00,0x00,0x00,0xD0,0xFE,  /* 00000428    "........" */
+    0xFF,0x03,0xD0,0xFE,0x00,0x00,0x00,0x00,  /* 00000430    "........" */
+    0x00,0x04,0x00,0x00,0x79,0x00,0x14,0x16,  /* 00000438    "....y..." */
+    0x5F,0x50,0x52,0x54,0x00,0xA0,0x0A,0x50,  /* 00000440    "_PRT...P" */
+    0x49,0x43,0x44,0xA4,0x50,0x52,0x54,0x41,  /* 00000448    "ICD.PRTA" */
+    0xA4,0x50,0x52,0x54,0x50,0x08,0x50,0x52,  /* 00000450    ".PRTP.PR" */
+    0x54,0x50,0x12,0x49,0x36,0x3C,0x12,0x0D,  /* 00000458    "TP.I6<.." */
+    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x00,0x4C,  /* 00000460    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000468    "NKB....." */
+    0xFF,0xFF,0x01,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000470    ".....LNK" */
+    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000478    "C......." */
+    0x01,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000480    "....LNKD" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000488    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000490    "...LNKA." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000498    "........" */
+    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 000004A0    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,0x4C,  /* 000004A8    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 000004B0    "NKD....." */
+    0xFF,0xFF,0x02,0x00,0x0A,0x02,0x4C,0x4E,  /* 000004B8    "......LN" */
+    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000004C0    "KA......" */
+    0xFF,0x02,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000004C8    ".....LNK" */
+    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000004D0    "B......." */
+    0x03,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 000004D8    "...LNKD." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 000004E0    "........" */
+    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000004E8    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,  /* 000004F0    "........" */
+    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000004F8    "LNKB...." */
+    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x03,0x4C,  /* 00000500    ".......L" */
+    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 00000508    "NKC....." */
+    0xFF,0xFF,0x04,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000510    ".....LNK" */
+    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000518    "A......." */
+    0x04,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000520    "...LNKB." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000528    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 00000530    "..LNKC.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,  /* 00000538    "........" */
+    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000540    ".LNKD..." */
+    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x00,0x4C,  /* 00000548    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000550    "NKB....." */
+    0xFF,0xFF,0x05,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000558    ".....LNK" */
+    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000560    "C......." */
+    0x05,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000568    "....LNKD" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x05,  /* 00000570    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000578    "...LNKA." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 00000580    "........" */
+    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000588    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x06,0x00,0x01,0x4C,  /* 00000590    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000598    "NKD....." */
+    0xFF,0xFF,0x06,0x00,0x0A,0x02,0x4C,0x4E,  /* 000005A0    "......LN" */
+    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000005A8    "KA......" */
+    0xFF,0x06,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000005B0    ".....LNK" */
+    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000005B8    "B......." */
+    0x07,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 000005C0    "...LNKD." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x07,0x00,  /* 000005C8    "........" */
+    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000005D0    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x02,  /* 000005D8    "........" */
+    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000005E0    "LNKB...." */
+    0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x03,0x4C,  /* 000005E8    ".......L" */
+    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 000005F0    "NKC....." */
+    0xFF,0xFF,0x08,0x00,0x00,0x4C,0x4E,0x4B,  /* 000005F8    ".....LNK" */
+    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000600    "A......." */
+    0x08,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000608    "...LNKB." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 00000610    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 00000618    "..LNKC.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,  /* 00000620    "........" */
+    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000628    ".LNKD..." */
+    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x00,0x4C,  /* 00000630    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000638    "NKB....." */
+    0xFF,0xFF,0x09,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000640    ".....LNK" */
+    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000648    "C......." */
+    0x09,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000650    "....LNKD" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000658    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000660    "...LNKA." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 00000668    "........" */
+    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000670    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x01,0x4C,  /* 00000678    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000680    "NKD....." */
+    0xFF,0xFF,0x0A,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000688    "......LN" */
+    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000690    "KA......" */
+    0xFF,0x0A,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000698    ".....LNK" */
+    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006A0    "B......." */
+    0x0B,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 000006A8    "...LNKD." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0B,0x00,  /* 000006B0    "........" */
+    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000006B8    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x02,  /* 000006C0    "........" */
+    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000006C8    "LNKB...." */
+    0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x03,0x4C,  /* 000006D0    ".......L" */
+    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 000006D8    "NKC....." */
+    0xFF,0xFF,0x0C,0x00,0x00,0x4C,0x4E,0x4B,  /* 000006E0    ".....LNK" */
+    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006E8    "A......." */
+    0x0C,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 000006F0    "...LNKB." */
+    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 000006F8    "........" */
+    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 00000700    "..LNKC.." */
+    0x0E,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,  /* 00000708    "........" */
+    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000710    ".LNKD..." */
+    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x00,0x4C,  /* 00000718    ".......L" */
+    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000720    "NKB....." */
+    0xFF,0xFF,0x0D,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000728    ".....LNK" */
+    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000730    "C......." */
+    0x0D,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000738    "....LNKD" */
+    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000740    "........" */
+    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000748    "...LNKA." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000750    "........" */
+    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000758    ".LNKC..." */
+    0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x01,0x4C,  /* 00000760    ".......L" */
+    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000768    "NKD....." */
+    0xFF,0xFF,0x0E,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000770    "......LN" */
+    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000778    "KA......" */
+    0xFF,0x0E,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000780    ".....LNK" */
+    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000788    "B......." */
+    0x0F,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000790    "...LNKD." */
+    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0F,0x00,  /* 00000798    "........" */
+    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000007A0    ".LNKA..." */
+    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x02,  /* 000007A8    "........" */
+    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000007B0    "LNKB...." */
+    0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x03,0x4C,  /* 000007B8    ".......L" */
+    0x4E,0x4B,0x43,0x00,0x08,0x50,0x52,0x54,  /* 000007C0    "NKC..PRT" */
+    0x41,0x12,0x41,0x2F,0x3C,0x12,0x0B,0x04,  /* 000007C8    "A.A/<..." */
+    0x0C,0xFF,0xFF,0x01,0x00,0x00,0x00,0x0A,  /* 000007D0    "........" */
+    0x14,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,  /* 000007D8    "........" */
+    0x00,0x01,0x00,0x0A,0x15,0x12,0x0C,0x04,  /* 000007E0    "........" */
+    0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x02,0x00,  /* 000007E8    "........" */
+    0x0A,0x16,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000007F0    "........" */
+    0x01,0x00,0x0A,0x03,0x00,0x0A,0x17,0x12,  /* 000007F8    "........" */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x00,  /* 00000800    "........" */
+    0x00,0x0A,0x18,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000808    "........" */
+    0xFF,0x02,0x00,0x01,0x00,0x0A,0x19,0x12,  /* 00000810    "........" */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x0A,  /* 00000818    "........" */
+    0x02,0x00,0x0A,0x1A,0x12,0x0C,0x04,0x0C,  /* 00000820    "........" */
+    0xFF,0xFF,0x02,0x00,0x0A,0x03,0x00,0x0A,  /* 00000828    "........" */
+    0x1B,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000830    "........" */
+    0x00,0x00,0x00,0x0A,0x1C,0x12,0x0B,0x04,  /* 00000838    "........" */
+    0x0C,0xFF,0xFF,0x03,0x00,0x01,0x00,0x0A,  /* 00000840    "........" */
+    0x1D,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000848    "........" */
+    0x00,0x0A,0x02,0x00,0x0A,0x1E,0x12,0x0C,  /* 00000850    "........" */
+    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x03,  /* 00000858    "........" */
+    0x00,0x0A,0x1F,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000860    "........" */
+    0xFF,0x04,0x00,0x00,0x00,0x0A,0x20,0x12,  /* 00000868    "...... ." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x01,  /* 00000870    "........" */
+    0x00,0x0A,0x21,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000878    "..!....." */
+    0xFF,0x04,0x00,0x0A,0x02,0x00,0x0A,0x22,  /* 00000880    "......."" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000888    "........" */
+    0x0A,0x03,0x00,0x0A,0x23,0x12,0x0B,0x04,  /* 00000890    "....#..." */
+    0x0C,0xFF,0xFF,0x05,0x00,0x00,0x00,0x0A,  /* 00000898    "........" */
+    0x24,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x05,  /* 000008A0    "$......." */
+    0x00,0x01,0x00,0x0A,0x25,0x12,0x0C,0x04,  /* 000008A8    "....%..." */
+    0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x02,0x00,  /* 000008B0    "........" */
+    0x0A,0x26,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000008B8    ".&......" */
+    0x05,0x00,0x0A,0x03,0x00,0x0A,0x27,0x12,  /* 000008C0    "......'." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x00,  /* 000008C8    "........" */
+    0x00,0x0A,0x28,0x12,0x0B,0x04,0x0C,0xFF,  /* 000008D0    "..(....." */
+    0xFF,0x06,0x00,0x01,0x00,0x0A,0x29,0x12,  /* 000008D8    "......)." */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x0A,  /* 000008E0    "........" */
+    0x02,0x00,0x0A,0x2A,0x12,0x0C,0x04,0x0C,  /* 000008E8    "...*...." */
+    0xFF,0xFF,0x06,0x00,0x0A,0x03,0x00,0x0A,  /* 000008F0    "........" */
+    0x2B,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x07,  /* 000008F8    "+......." */
+    0x00,0x00,0x00,0x0A,0x2C,0x12,0x0B,0x04,  /* 00000900    "....,..." */
+    0x0C,0xFF,0xFF,0x07,0x00,0x01,0x00,0x0A,  /* 00000908    "........" */
+    0x2D,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x07,  /* 00000910    "-......." */
+    0x00,0x0A,0x02,0x00,0x0A,0x2E,0x12,0x0C,  /* 00000918    "........" */
+    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x03,  /* 00000920    "........" */
+    0x00,0x0A,0x2F,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000928    "../....." */
+    0xFF,0x08,0x00,0x00,0x00,0x0A,0x11,0x12,  /* 00000930    "........" */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x01,  /* 00000938    "........" */
+    0x00,0x0A,0x12,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000940    "........" */
+    0xFF,0x08,0x00,0x0A,0x02,0x00,0x0A,0x13,  /* 00000948    "........" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 00000950    "........" */
+    0x0A,0x03,0x00,0x0A,0x14,0x12,0x0B,0x04,  /* 00000958    "........" */
+    0x0C,0xFF,0xFF,0x09,0x00,0x00,0x00,0x0A,  /* 00000960    "........" */
+    0x15,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000968    "........" */
+    0x00,0x01,0x00,0x0A,0x16,0x12,0x0C,0x04,  /* 00000970    "........" */
+    0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x02,0x00,  /* 00000978    "........" */
+    0x0A,0x17,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000980    "........" */
+    0x09,0x00,0x0A,0x03,0x00,0x0A,0x18,0x12,  /* 00000988    "........" */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x00,  /* 00000990    "........" */
+    0x00,0x0A,0x19,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000998    "........" */
+    0xFF,0x0A,0x00,0x01,0x00,0x0A,0x1A,0x12,  /* 000009A0    "........" */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x0A,  /* 000009A8    "........" */
+    0x02,0x00,0x0A,0x1B,0x12,0x0C,0x04,0x0C,  /* 000009B0    "........" */
+    0xFF,0xFF,0x0A,0x00,0x0A,0x03,0x00,0x0A,  /* 000009B8    "........" */
+    0x1C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0B,  /* 000009C0    "........" */
+    0x00,0x00,0x00,0x0A,0x1D,0x12,0x0B,0x04,  /* 000009C8    "........" */
+    0x0C,0xFF,0xFF,0x0B,0x00,0x01,0x00,0x0A,  /* 000009D0    "........" */
+    0x1E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0B,  /* 000009D8    "........" */
+    0x00,0x0A,0x02,0x00,0x0A,0x1F,0x12,0x0C,  /* 000009E0    "........" */
+    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x03,  /* 000009E8    "........" */
+    0x00,0x0A,0x20,0x12,0x0B,0x04,0x0C,0xFF,  /* 000009F0    ".. ....." */
+    0xFF,0x0C,0x00,0x00,0x00,0x0A,0x21,0x12,  /* 000009F8    "......!." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x01,  /* 00000A00    "........" */
+    0x00,0x0A,0x22,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000A08    ".."....." */
+    0xFF,0x0C,0x00,0x0A,0x02,0x00,0x0A,0x23,  /* 00000A10    ".......#" */
+    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 00000A18    "........" */
+    0x0A,0x03,0x00,0x0A,0x24,0x12,0x0B,0x04,  /* 00000A20    "....$..." */
+    0x0C,0xFF,0xFF,0x0D,0x00,0x00,0x00,0x0A,  /* 00000A28    "........" */
+    0x25,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000A30    "%......." */
+    0x00,0x01,0x00,0x0A,0x26,0x12,0x0C,0x04,  /* 00000A38    "....&..." */
+    0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x02,0x00,  /* 00000A40    "........" */
+    0x0A,0x27,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000A48    ".'......" */
+    0x0D,0x00,0x0A,0x03,0x00,0x0A,0x28,0x12,  /* 00000A50    "......(." */
+    0x0B,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x00,  /* 00000A58    "........" */
+    0x00,0x0A,0x29,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A60    "..)....." */
+    0xFF,0x0E,0x00,0x01,0x00,0x0A,0x2A,0x12,  /* 00000A68    "......*." */
+    0x0C,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x0A,  /* 00000A70    "........" */
+    0x02,0x00,0x0A,0x2B,0x12,0x0C,0x04,0x0C,  /* 00000A78    "...+...." */
+    0xFF,0xFF,0x0E,0x00,0x0A,0x03,0x00,0x0A,  /* 00000A80    "........" */
+    0x2C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000A88    ",......." */
+    0x00,0x00,0x00,0x0A,0x2D,0x12,0x0B,0x04,  /* 00000A90    "....-..." */
+    0x0C,0xFF,0xFF,0x0F,0x00,0x01,0x00,0x0A,  /* 00000A98    "........" */
+    0x2E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000AA0    "........" */
+    0x00,0x0A,0x02,0x00,0x0A,0x2F,0x12,0x0C,  /* 00000AA8    "...../.." */
+    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x03,  /* 00000AB0    "........" */
+    0x00,0x0A,0x10,0x5B,0x82,0x4C,0x31,0x49,  /* 00000AB8    "...[.L1I" */
+    0x53,0x41,0x5F,0x08,0x5F,0x41,0x44,0x52,  /* 00000AC0    "SA_._ADR" */
+    0x0C,0x00,0x00,0x01,0x00,0x5B,0x80,0x50,  /* 00000AC8    ".....[.P" */
+    0x49,0x52,0x51,0x02,0x0A,0x60,0x0A,0x04,  /* 00000AD0    "IRQ..`.." */
+    0x10,0x2E,0x5C,0x00,0x5B,0x81,0x29,0x5C,  /* 00000AD8    "..\.[.)\" */
+    0x2F,0x04,0x5F,0x53,0x42,0x5F,0x50,0x43,  /* 00000AE0    "/._SB_PC" */
+    0x49,0x30,0x49,0x53,0x41,0x5F,0x50,0x49,  /* 00000AE8    "I0ISA_PI" */
+    0x52,0x51,0x01,0x50,0x49,0x52,0x41,0x08,  /* 00000AF0    "RQ.PIRA." */
+    0x50,0x49,0x52,0x42,0x08,0x50,0x49,0x52,  /* 00000AF8    "PIRB.PIR" */
+    0x43,0x08,0x50,0x49,0x52,0x44,0x08,0x5B,  /* 00000B00    "C.PIRD.[" */
+    0x82,0x46,0x0B,0x53,0x59,0x53,0x52,0x08,  /* 00000B08    ".F.SYSR." */
+    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,  /* 00000B10    "_HID.A.." */
+    0x02,0x08,0x5F,0x55,0x49,0x44,0x01,0x08,  /* 00000B18    ".._UID.." */
+    0x43,0x52,0x53,0x5F,0x11,0x4E,0x08,0x0A,  /* 00000B20    "CRS_.N.." */
+    0x8A,0x47,0x01,0x10,0x00,0x10,0x00,0x00,  /* 00000B28    ".G......" */
+    0x10,0x47,0x01,0x22,0x00,0x22,0x00,0x00,  /* 00000B30    ".G.".".." */
+    0x0C,0x47,0x01,0x30,0x00,0x30,0x00,0x00,  /* 00000B38    ".G.0.0.." */
+    0x10,0x47,0x01,0x44,0x00,0x44,0x00,0x00,  /* 00000B40    ".G.D.D.." */
+    0x1C,0x47,0x01,0x62,0x00,0x62,0x00,0x00,  /* 00000B48    ".G.b.b.." */
+    0x02,0x47,0x01,0x65,0x00,0x65,0x00,0x00,  /* 00000B50    ".G.e.e.." */
+    0x0B,0x47,0x01,0x72,0x00,0x72,0x00,0x00,  /* 00000B58    ".G.r.r.." */
+    0x0E,0x47,0x01,0x80,0x00,0x80,0x00,0x00,  /* 00000B60    ".G......" */
+    0x01,0x47,0x01,0x84,0x00,0x84,0x00,0x00,  /* 00000B68    ".G......" */
+    0x03,0x47,0x01,0x88,0x00,0x88,0x00,0x00,  /* 00000B70    ".G......" */
+    0x01,0x47,0x01,0x8C,0x00,0x8C,0x00,0x00,  /* 00000B78    ".G......" */
+    0x03,0x47,0x01,0x90,0x00,0x90,0x00,0x00,  /* 00000B80    ".G......" */
+    0x10,0x47,0x01,0xA2,0x00,0xA2,0x00,0x00,  /* 00000B88    ".G......" */
+    0x1C,0x47,0x01,0xE0,0x00,0xE0,0x00,0x00,  /* 00000B90    ".G......" */
+    0x10,0x47,0x01,0xA0,0x08,0xA0,0x08,0x00,  /* 00000B98    ".G......" */
+    0x04,0x47,0x01,0xC0,0x0C,0xC0,0x0C,0x00,  /* 00000BA0    ".G......" */
+    0x10,0x47,0x01,0xD0,0x04,0xD0,0x04,0x00,  /* 00000BA8    ".G......" */
+    0x02,0x79,0x00,0x14,0x0B,0x5F,0x43,0x52,  /* 00000BB0    ".y..._CR" */
+    0x53,0x00,0xA4,0x43,0x52,0x53,0x5F,0x5B,  /* 00000BB8    "S..CRS_[" */
+    0x82,0x2B,0x50,0x49,0x43,0x5F,0x08,0x5F,  /* 00000BC0    ".+PIC_._" */
+    0x48,0x49,0x44,0x0B,0x41,0xD0,0x08,0x5F,  /* 00000BC8    "HID.A.._" */
+    0x43,0x52,0x53,0x11,0x18,0x0A,0x15,0x47,  /* 00000BD0    "CRS....G" */
+    0x01,0x20,0x00,0x20,0x00,0x01,0x02,0x47,  /* 00000BD8    ". . ...G" */
+    0x01,0xA0,0x00,0xA0,0x00,0x01,0x02,0x22,  /* 00000BE0    "......."" */
+    0x04,0x00,0x79,0x00,0x5B,0x82,0x47,0x05,  /* 00000BE8    "..y.[.G." */
+    0x44,0x4D,0x41,0x30,0x08,0x5F,0x48,0x49,  /* 00000BF0    "DMA0._HI" */
+    0x44,0x0C,0x41,0xD0,0x02,0x00,0x08,0x5F,  /* 00000BF8    "D.A...._" */
+    0x43,0x52,0x53,0x11,0x41,0x04,0x0A,0x3D,  /* 00000C00    "CRS.A..=" */
+    0x2A,0x10,0x04,0x47,0x01,0x00,0x00,0x00,  /* 00000C08    "*..G...." */
+    0x00,0x00,0x10,0x47,0x01,0x81,0x00,0x81,  /* 00000C10    "...G...." */
+    0x00,0x00,0x03,0x47,0x01,0x87,0x00,0x87,  /* 00000C18    "...G...." */
+    0x00,0x00,0x01,0x47,0x01,0x89,0x00,0x89,  /* 00000C20    "...G...." */
+    0x00,0x00,0x03,0x47,0x01,0x8F,0x00,0x8F,  /* 00000C28    "...G...." */
+    0x00,0x00,0x01,0x47,0x01,0xC0,0x00,0xC0,  /* 00000C30    "...G...." */
+    0x00,0x00,0x20,0x47,0x01,0x80,0x04,0x80,  /* 00000C38    ".. G...." */
+    0x04,0x00,0x10,0x79,0x00,0x5B,0x82,0x25,  /* 00000C40    "...y.[.%" */
+    0x54,0x4D,0x52,0x5F,0x08,0x5F,0x48,0x49,  /* 00000C48    "TMR_._HI" */
+    0x44,0x0C,0x41,0xD0,0x01,0x00,0x08,0x5F,  /* 00000C50    "D.A...._" */
+    0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,  /* 00000C58    "CRS....G" */
+    0x01,0x40,0x00,0x40,0x00,0x00,0x04,0x22,  /* 00000C60    ".@.@..."" */
+    0x01,0x00,0x79,0x00,0x5B,0x82,0x25,0x52,  /* 00000C68    "..y.[.%R" */
+    0x54,0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000C70    "TC_._HID" */
+    0x0C,0x41,0xD0,0x0B,0x00,0x08,0x5F,0x43,  /* 00000C78    ".A...._C" */
+    0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,  /* 00000C80    "RS....G." */
+    0x70,0x00,0x70,0x00,0x00,0x02,0x22,0x00,  /* 00000C88    "p.p..."." */
+    0x01,0x79,0x00,0x5B,0x82,0x22,0x53,0x50,  /* 00000C90    ".y.[."SP" */
+    0x4B,0x52,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000C98    "KR._HID." */
+    0x41,0xD0,0x08,0x00,0x08,0x5F,0x43,0x52,  /* 00000CA0    "A...._CR" */
+    0x53,0x11,0x0D,0x0A,0x0A,0x47,0x01,0x61,  /* 00000CA8    "S....G.a" */
+    0x00,0x61,0x00,0x00,0x01,0x79,0x00,0x5B,  /* 00000CB0    ".a...y.[" */
+    0x82,0x31,0x50,0x53,0x32,0x4D,0x08,0x5F,  /* 00000CB8    ".1PS2M._" */
+    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0F,0x13,  /* 00000CC0    "HID.A..." */
+    0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,0xD0,  /* 00000CC8    "._CID.A." */
+    0x0F,0x13,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000CD0    "...._STA" */
+    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 00000CD8    "....._CR" */
+    0x53,0x11,0x08,0x0A,0x05,0x22,0x00,0x10,  /* 00000CE0    "S....".." */
+    0x79,0x00,0x5B,0x82,0x42,0x04,0x50,0x53,  /* 00000CE8    "y.[.B.PS" */
+    0x32,0x4B,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000CF0    "2K._HID." */
+    0x41,0xD0,0x03,0x03,0x08,0x5F,0x43,0x49,  /* 00000CF8    "A...._CI" */
+    0x44,0x0C,0x41,0xD0,0x03,0x0B,0x14,0x09,  /* 00000D00    "D.A....." */
+    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 00000D08    "_STA...." */
+    0x08,0x5F,0x43,0x52,0x53,0x11,0x18,0x0A,  /* 00000D10    "._CRS..." */
+    0x15,0x47,0x01,0x60,0x00,0x60,0x00,0x00,  /* 00000D18    ".G.`.`.." */
+    0x01,0x47,0x01,0x64,0x00,0x64,0x00,0x00,  /* 00000D20    ".G.d.d.." */
+    0x01,0x22,0x02,0x00,0x79,0x00,0x5B,0x82,  /* 00000D28    "."..y.[." */
+    0x3A,0x46,0x44,0x43,0x30,0x08,0x5F,0x48,  /* 00000D30    ":FDC0._H" */
+    0x49,0x44,0x0C,0x41,0xD0,0x07,0x00,0x14,  /* 00000D38    "ID.A...." */
+    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000D40    "._STA..." */
+    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x1B,  /* 00000D48    ".._CRS.." */
+    0x0A,0x18,0x47,0x01,0xF0,0x03,0xF0,0x03,  /* 00000D50    "..G....." */
+    0x01,0x06,0x47,0x01,0xF7,0x03,0xF7,0x03,  /* 00000D58    "..G....." */
+    0x01,0x01,0x22,0x40,0x00,0x2A,0x04,0x00,  /* 00000D60    ".."@.*.." */
+    0x79,0x00,0x5B,0x82,0x35,0x55,0x41,0x52,  /* 00000D68    "y.[.5UAR" */
+    0x31,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000D70    "1._HID.A" */
+    0xD0,0x05,0x01,0x08,0x5F,0x55,0x49,0x44,  /* 00000D78    "...._UID" */
+    0x01,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000D80    "..._STA." */
+    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000D88    "...._CRS" */
+    0x11,0x10,0x0A,0x0D,0x47,0x01,0xF8,0x03,  /* 00000D90    "....G..." */
+    0xF8,0x03,0x01,0x08,0x22,0x10,0x00,0x79,  /* 00000D98    "...."..y" */
+    0x00,0x5B,0x82,0x36,0x4C,0x54,0x50,0x31,  /* 00000DA0    ".[.6LTP1" */
+    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000DA8    "._HID.A." */
+    0x04,0x00,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 00000DB0    "..._UID." */
+    0x02,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000DB8    "..._STA." */
+    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000DC0    "...._CRS" */
+    0x11,0x10,0x0A,0x0D,0x47,0x01,0x78,0x03,  /* 00000DC8    "....G.x." */
+    0x78,0x03,0x08,0x08,0x22,0x80,0x00,0x79,  /* 00000DD0    "x..."..y" */
+    0x00,
 };
 int DsdtLen=sizeof(AmlCode);
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/ssdt_tpm.asl
--- a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl        Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl        Wed Jan 10 08:40:47 
2007 -0700
@@ -17,7 +17,7 @@
 
 //*  SSDT for TPM TIS Interface for Xen with Qemu device model
 
-DefinitionBlock ("SSDT_TPM.aml", "SSDT", 1, "IBM","xen", 2006)
+DefinitionBlock ("SSDT_TPM.aml", "SSDT", 2, "Xen", "HVM", 0)
 {
     Device (TPM) {
         Name (_HID, EisaId ("PNP0C31"))
@@ -26,4 +26,4 @@ DefinitionBlock ("SSDT_TPM.aml", "SSDT",
             Memory32Fixed (ReadWrite, 0xFED40000, 0x5000,)
         })
     }
-}
\ No newline at end of file
+}
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/acpi/ssdt_tpm.h
--- a/tools/firmware/hvmloader/acpi/ssdt_tpm.h  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.h  Wed Jan 10 08:40:47 2007 -0700
@@ -1,11 +1,11 @@
 /*
  * 
  * Intel ACPI Component Architecture
- * ASL Optimizing Compiler version 20060707 [Sep 11 2006]
+ * ASL Optimizing Compiler version 20060707 [Dec 30 2006]
  * Copyright (C) 2000 - 2006 Intel Corporation
  * Supports ACPI Specification Revision 3.0a
  * 
- * Compilation of "acpi_ssdt_tpm.asl" - Mon Oct 30 11:28:27 2006
+ * Compilation of "ssdt_tpm.asl" - Sat Dec 30 15:31:27 2006
  * 
  * C source code output
  *
@@ -13,9 +13,9 @@ unsigned char AmlCode_TPM[] =
 unsigned char AmlCode_TPM[] =
 {
     0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00,  /* 00000000    "SSDTL..." */
-    0x01,0x6D,0x49,0x42,0x4D,0x00,0x00,0x00,  /* 00000008    ".mIBM..." */
-    0x78,0x65,0x6E,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "xen....." */
-    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
+    0x02,0x56,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    ".VXen..." */
+    0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "HVM....." */
+    0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
     0x07,0x07,0x06,0x20,0x5B,0x82,0x26,0x54,  /* 00000020    "... [.&T" */
     0x50,0x4D,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000028    "PM_._HID" */
     0x0C,0x41,0xD0,0x0C,0x31,0x08,0x5F,0x43,  /* 00000030    ".A..1._C" */
diff -r 42babffffba5 -r 58633caeece9 
tools/firmware/hvmloader/acpi/static_tables.c
--- a/tools/firmware/hvmloader/acpi/static_tables.c     Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/firmware/hvmloader/acpi/static_tables.c     Wed Jan 10 08:40:47 
2007 -0700
@@ -118,7 +118,7 @@ struct acpi_20_xsdt Xsdt = {
         .signature    = ACPI_2_0_XSDT_SIGNATURE,
         .length       = sizeof(struct acpi_header),
         .revision     = ACPI_2_0_XSDT_REVISION,
-        .oem_id       = ACPI_OEM_ID, 
+        .oem_id       = ACPI_OEM_ID,
         .oem_table_id = ACPI_OEM_TABLE_ID,
         .oem_revision = ACPI_OEM_REVISION,
         .creator_id   = ACPI_CREATOR_ID,
@@ -130,7 +130,7 @@ struct acpi_20_rsdp Rsdp = {
 struct acpi_20_rsdp Rsdp = {
     .signature = ACPI_2_0_RSDP_SIGNATURE,
     .oem_id    = ACPI_OEM_ID,
-    .revision  = ACPI_OEM_REVISION, 
+    .revision  = ACPI_2_0_RSDP_REVISION,
     .length    = sizeof(struct acpi_20_rsdp)
 };
 
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/config.h Wed Jan 10 08:40:47 2007 -0700
@@ -2,10 +2,11 @@
 #define __HVMLOADER_CONFIG_H__
 
 #define IOAPIC_BASE_ADDRESS 0xfec00000
-#define IOAPIC_ID           0x00
+#define IOAPIC_ID           0x01
 #define IOAPIC_VERSION      0x11
 
 #define LAPIC_BASE_ADDRESS  0xfee00000
+#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
 
 #define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
 #define PCI_ISA_IRQ_MASK    0x0c60U /* ISA IRQs 5,6,10,11 are PCI connected */
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/hvmloader.c      Wed Jan 10 08:40:47 2007 -0700
@@ -34,6 +34,7 @@
 /* memory map */
 #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
 #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
+#define ETHERBOOT_PHYSICAL_ADDRESS    0x000C8000
 #define VMXASSIST_PHYSICAL_ADDRESS    0x000D0000
 #define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
 
@@ -279,6 +280,27 @@ static void pci_setup(void)
     }
 }
 
+static 
+int must_load_nic(void) 
+{
+    /* If the network card is in the boot order, load the Etherboot 
+     * option ROM.  Read the boot order bytes from CMOS and check 
+     * if any of them are 0x4. */
+    uint8_t boot_order;
+
+    /* Read CMOS register 0x3d (boot choices 0 and 1) */
+    outb(0x70, 0x3d);
+    boot_order = inb(0x71);
+    if ( (boot_order & 0xf) == 0x4 || (boot_order & 0xf0) == 0x40 ) 
+        return 1;
+    /* Read CMOS register 0x38 (boot choice 2 and FDD test flag) */
+    outb(0x70, 0x38);
+    boot_order = inb(0x71);
+    if ( (boot_order & 0xf0) == 0x40 ) 
+        return 1;
+    return 0;
+}
+
 int main(void)
 {
     int acpi_sz;
@@ -310,6 +332,13 @@ int main(void)
         printf("Loading Standard VGABIOS ...\n");
         memcpy((void *)VGABIOS_PHYSICAL_ADDRESS,
                vgabios_stdvga, sizeof(vgabios_stdvga));
+    }
+
+    if ( must_load_nic() )
+    {
+        printf("Loading ETHERBOOT ...\n");
+        memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS,
+               etherboot, sizeof(etherboot));
     }
 
     if ( get_acpi_enabled() != 0 )
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/hvmloader/mp_tables.c
--- a/tools/firmware/hvmloader/mp_tables.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/hvmloader/mp_tables.c      Wed Jan 10 08:40:47 2007 -0700
@@ -222,7 +222,7 @@ void fill_mp_proc_entry(struct mp_proc_e
 void fill_mp_proc_entry(struct mp_proc_entry *mppe, int vcpu_id)
 {
     mppe->type = ENTRY_TYPE_PROCESSOR;
-    mppe->lapic_id = vcpu_id + 1;
+    mppe->lapic_id = LAPIC_ID(vcpu_id);
     mppe->lapic_version = 0x11;
     mppe->cpu_flags = CPU_FLAG_ENABLED;
     if ( vcpu_id == 0 )
@@ -373,7 +373,7 @@ void create_mp_tables(void)
     {
         if ( i == 2 ) continue; /* skip the slave PIC connection */
         fill_mp_io_intr_entry((struct mp_io_intr_entry *)p, 
-                              BUS_ID_ISA, i, IOAPIC_ID, i);
+                              BUS_ID_ISA, i, IOAPIC_ID, (i == 0) ? 2 : i);
         p += sizeof(struct mp_io_intr_entry);
     }
 
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/rombios/rombios.c
--- a/tools/firmware/rombios/rombios.c  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/rombios/rombios.c  Wed Jan 10 08:40:47 2007 -0700
@@ -278,7 +278,6 @@ typedef unsigned short bx_bool;
 typedef unsigned short bx_bool;
 typedef unsigned long  Bit32u;
 
-#if BX_USE_ATADRV
 
   void memsetb(seg,offset,value,count);
   void memcpyb(dseg,doffset,sseg,soffset,count);
@@ -418,7 +417,6 @@ typedef unsigned long  Bit32u;
   ASM_END
   }
 #endif
-#endif //BX_USE_ATADRV
 
   // read_dword and write_dword functions
   static Bit32u         read_dword();
@@ -728,6 +726,8 @@ typedef struct {
   //     The EBDA structure should conform to 
   //     http://www.cybertrails.com/~fys/rombios.htm document
   //     I made the ata and cdemu structs begin at 0x121 in the EBDA seg
+  // EBDA must be at most 768 bytes; it lives at 0x9fc00, and the boot 
+  // device tables are at 0x9ff00 -- 0x9ffff
   typedef struct {
     unsigned char filler1[0x3D];
 
@@ -885,7 +885,7 @@ static void           int15_function();
 static void           int15_function();
 static void           int16_function();
 static void           int17_function();
-static Bit32u         int19_function();
+static void           int19_function();
 static void           int1a_function();
 static void           int70_function();
 static void           int74_function();
@@ -1435,10 +1435,17 @@ copy_e820_table()
 copy_e820_table()
 {
   Bit8u nr_entries = read_byte(0x9000, 0x1e8);
+  Bit32u base_mem;
   if (nr_entries > 32)
        nr_entries = 32;
   write_word(0xe000, 0x8, nr_entries);
   memcpyb(0xe000, 0x10, 0x9000, 0x2d0, nr_entries * 0x14);
+  /* Report the proper base memory size at address 0x0413: otherwise
+   * non-e820 code will clobber things if BASE_MEM_IN_K is bigger than
+   * the first e820 entry.  Get the size by reading the second 64bit 
+   * field of the first e820 slot. */ 
+  base_mem = read_dword(0x9000, 0x2d0 + 8);
+  write_word(0x40, 0x13, base_mem >> 10);
 }
 #endif /* HVMASSIST */
 
@@ -1847,28 +1854,100 @@ print_bios_banner()
   printf("\n");
 }
 
+
+//--------------------------------------------------------------------------
+// BIOS Boot Specification 1.0.1 compatibility
+//
+// Very basic support for the BIOS Boot Specification, which allows expansion 
+// ROMs to register themselves as boot devices, instead of just stealing the 
+// INT 19h boot vector.
+// 
+// This is a hack: to do it properly requires a proper PnP BIOS and we aren't
+// one; we just lie to the option ROMs to make them behave correctly. 
+// We also don't support letting option ROMs register as bootable disk 
+// drives (BCVs), only as bootable devices (BEVs). 
+//
+// 
http://www.phoenix.com/en/Customer+Services/White+Papers-Specs/pc+industry+specifications.htm
+//--------------------------------------------------------------------------
+
+/* 256 bytes at 0x9ff00 -- 0x9ffff is used for the IPL boot table. */
+#define IPL_SEG              0x9ff0
+#define IPL_TABLE_OFFSET     0x0000
+#define IPL_TABLE_ENTRIES    8
+#define IPL_COUNT_OFFSET     0x0080  /* u16: number of valid table entries */
+#define IPL_SEQUENCE_OFFSET  0x0082  /* u16: next boot device */
+
+struct ipl_entry {
+  Bit16u type;
+  Bit16u flags;
+  Bit32u vector;
+  Bit32u description;
+  Bit32u reserved;
+};
+
+static void 
+init_boot_vectors() 
+{
+  struct ipl_entry e; 
+  Bit16u count = 0;
+  Bit16u ss = get_SS();
+
+  /* Clear out the IPL table. */
+  memsetb(IPL_SEG, IPL_TABLE_OFFSET, 0, 0xff);
+
+  /* Floppy drive */
+  e.type = 1; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
+  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
+  count++;
+
+  /* First HDD */
+  e.type = 2; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
+  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
+  count++;
+
+#if BX_ELTORITO_BOOT
+  /* CDROM */
+  e.type = 3; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
+  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
+  count++;
+#endif  
+
+  /* Remember how many devices we have */
+  write_word(IPL_SEG, IPL_COUNT_OFFSET, count);
+  /* Not tried booting anything yet */
+  write_word(IPL_SEG, IPL_SEQUENCE_OFFSET, 0xffff);
+}
+
+static Bit8u
+get_boot_vector(i, e)
+Bit16u i; struct ipl_entry *e; 
+{
+  Bit16u count;
+  Bit16u ss = get_SS();
+  /* Get the count of boot devices, and refuse to overrun the array */
+  count = read_word(IPL_SEG, IPL_COUNT_OFFSET);
+  if (i >= count) return 0;
+  /* OK to read this device */
+  memcpyb(ss, e, IPL_SEG, IPL_TABLE_OFFSET + i * sizeof (*e), sizeof (*e));
+  return 1;
+}
+
+
 //--------------------------------------------------------------------------
 // print_boot_device
 //   displays the boot device
 //--------------------------------------------------------------------------
 
-static char drivetypes[][10]={"Floppy","Hard Disk","CD-Rom"};
+static char drivetypes[][10]={"", "Floppy","Hard Disk","CD-Rom", "Network"};
 
 void
-print_boot_device(cdboot, drive)
-  Bit8u cdboot; Bit16u drive;
+print_boot_device(type)
+  Bit16u type;
 {
-  Bit8u i;
-
-  // cdboot contains 0 if floppy/harddisk, 1 otherwise
-  // drive contains real/emulated boot drive
-
-  if(cdboot)i=2;                    // CD-Rom
-  else if((drive&0x0080)==0x00)i=0; // Floppy
-  else if((drive&0x0080)==0x80)i=1; // Hard drive
-  else return;
-  
-  printf("Booting from %s...\n",drivetypes[i]);
+  /* NIC appears as type 0x80 */ 
+  if (type == 0x80 ) type = 0x4;
+  if (type == 0 || type > 0x4) BX_PANIC("Bad drive type\n"); 
+  printf("Booting from %s...\n", drivetypes[type]);
 }
 
 //--------------------------------------------------------------------------
@@ -1876,29 +1955,20 @@ print_boot_device(cdboot, drive)
 //   displays the reason why boot failed
 //--------------------------------------------------------------------------
   void
-print_boot_failure(cdboot, drive, reason, lastdrive)
-  Bit8u cdboot; Bit8u drive; Bit8u lastdrive;
+print_boot_failure(type, reason)
+  Bit16u type; Bit8u reason;
 {
-  Bit16u drivenum = drive&0x7f;
-
-  // cdboot: 1 if boot from cd, 0 otherwise
-  // drive : drive number
-  // reason: 0 signature check failed, 1 read error
-  // lastdrive: 1 boot drive is the last one in boot sequence
- 
-  if (cdboot)
-    bios_printf(BIOS_PRINTF_INFO | BIOS_PRINTF_SCREEN, "Boot from %s 
failed\n",drivetypes[2]);
-  else if (drive & 0x80)
-    bios_printf(BIOS_PRINTF_INFO | BIOS_PRINTF_SCREEN, "Boot from %s %d 
failed\n", drivetypes[1],drivenum);
+  if (type == 0 || type > 0x3) BX_PANIC("Bad drive type\n"); 
+
+  printf("Boot from %s failed", drivetypes[type]);
+  if (type < 4) {
+    /* Report the reason too */
+  if (reason==0) 
+    printf(": not a bootable disk");
   else
-    bios_printf(BIOS_PRINTF_INFO | BIOS_PRINTF_SCREEN, "Boot from %s %d 
failed\n", drivetypes[0],drivenum);
-
-  if (lastdrive==1) {
-    if (reason==0)
-      BX_PANIC("Not a bootable disk\n");
-    else
-      BX_PANIC("Could not read the boot disk\n");
+    printf(": could not read the boot disk");
   }
+  printf("\n");
 }
 
 //--------------------------------------------------------------------------
@@ -7546,19 +7616,19 @@ int17_function(regs, ds, iret_addr)
   }
 }
 
-// returns bootsegment in ax, drive in bl
-  Bit32u 
-int19_function(bseqnr)
-Bit8u bseqnr;
+void
+int19_function(seq_nr)
+Bit16u seq_nr;
 {
   Bit16u ebda_seg=read_word(0x0040,0x000E);
-  Bit16u bootseq;
+  Bit16u bootdev;
   Bit8u  bootdrv;
-  Bit8u  bootcd;
   Bit8u  bootchk;
   Bit16u bootseg;
+  Bit16u bootip;
   Bit16u status;
-  Bit8u  lastdrive=0;
+
+  struct ipl_entry e;
 
   // if BX_ELTORITO_BOOT is not defined, old behavior
   //   check bit 5 in CMOS reg 0x2d.  load either 0x00 or 0x80 into DL
@@ -7575,62 +7645,54 @@ Bit8u bseqnr;
   //     0x01 : first floppy 
   //     0x02 : first harddrive
   //     0x03 : first cdrom
+  //     0x04 - 0x0f : PnP expansion ROMs (e.g. Etherboot)
   //     else : boot failure
 
   // Get the boot sequence
 #if BX_ELTORITO_BOOT
-  bootseq=inb_cmos(0x3d);
-  bootseq|=((inb_cmos(0x38) & 0xf0) << 4);
-
-  if (bseqnr==2) bootseq >>= 4;
-  if (bseqnr==3) bootseq >>= 8;
-  if (bootseq<0x10) lastdrive = 1;
-  bootdrv=0x00; bootcd=0;
-  switch(bootseq & 0x0f) {
-    case 0x01: bootdrv=0x00; bootcd=0; break;
-    case 0x02: bootdrv=0x80; bootcd=0; break;
-    case 0x03: bootdrv=0x00; bootcd=1; break;
-    default:   return 0x00000000;
-    }
-#else
-  bootseq=inb_cmos(0x2d);
-
-  if (bseqnr==2) {
-    bootseq ^= 0x20;
-    lastdrive = 1;
+  bootdev = inb_cmos(0x3d);
+  bootdev |= ((inb_cmos(0x38) & 0xf0) << 4);
+  bootdev >>= 4 * seq_nr;
+  bootdev &= 0xf;
+  if (bootdev == 0) BX_PANIC("No bootable device.\n");
+  
+  /* Translate from CMOS runes to an IPL table offset by subtracting 1 */
+  bootdev -= 1;
+#else  
+  if (seq_nr ==2) BX_PANIC("No more boot devices.");
+  if (!!(inb_cmos(0x2d) & 0x20) ^ (seq_nr == 1)) 
+      /* Boot from floppy if the bit is set or it's the second boot */
+    bootdev = 0x00;
+  else 
+    bootdev = 0x01;
+#endif
+
+  /* Read the boot device from the IPL table */
+  if (get_boot_vector(bootdev, &e) == 0) {
+    BX_INFO("Invalid boot device (0x%x)\n", bootdev);
+    return;
   }
-  bootdrv=0x00; bootcd=0;
-  if((bootseq&0x20)==0) bootdrv=0x80;
-#endif // BX_ELTORITO_BOOT
-
-#if BX_ELTORITO_BOOT
-  // We have to boot from cd
-  if (bootcd != 0) {
-    status = cdrom_boot();
-
-    // If failure
-    if ( (status & 0x00ff) !=0 ) {
-      print_cdromboot_failure(status);
-      print_boot_failure(bootcd, bootdrv, 1, lastdrive);
-      return 0x00000000;
-      }
-
-    bootseg = read_word(ebda_seg,&EbdaData->cdemu.load_segment);
-    bootdrv = (Bit8u)(status>>8);
-    }
-
-#endif // BX_ELTORITO_BOOT
-
-  // We have to boot from harddisk or floppy
-  if (bootcd == 0) {
-    bootseg=0x07c0;
+
+  /* Do the loading, and set up vector as a far pointer to the boot
+   * address, and bootdrv as the boot drive */
+  print_boot_device(e.type);
+
+  switch(e.type) {
+  case 0x01: /* FDD */
+  case 0x02: /* HDD */
+
+    bootdrv = (e.type == 0x02) ? 0x80 : 0x00;
+    bootseg = 0x07c0;
+    status = 0;
 
 ASM_START
     push bp
     mov  bp, sp
-
-    mov  ax, #0x0000
-    mov  _int19_function.status + 2[bp], ax
+    push ax
+    push bx
+    push cx
+    push dx
+
     mov  dl, _int19_function.bootdrv + 2[bp]
     mov  ax, _int19_function.bootseg + 2[bp]
     mov  es, ax         ;; segment
@@ -7646,43 +7708,83 @@ ASM_START
     mov  _int19_function.status + 2[bp], ax
 
 int19_load_done:
+    pop  dx
+    pop  cx
+    pop  bx
+    pop  ax
     pop  bp
 ASM_END
     
     if (status != 0) {
-      print_boot_failure(bootcd, bootdrv, 1, lastdrive);
-      return 0x00000000;
+      print_boot_failure(e.type, 1);
+      return;
+    }
+
+    /* Always check the signature on a HDD boot sector; on FDD, only do
+     * the check if the CMOS doesn't tell us to skip it */
+    if (e.type != 0x00 || !((inb_cmos(0x38) & 0x01))) {
+      if (read_word(bootseg,0x1fe) != 0xaa55) {
+        print_boot_failure(e.type, 0);
+        return;
       }
     }
 
-  // check signature if instructed by cmos reg 0x38, only for floppy
-  // bootchk = 1 : signature check disabled
-  // bootchk = 0 : signature check enabled
-  if (bootdrv != 0) bootchk = 0;
-  else bootchk = inb_cmos(0x38) & 0x01;
+    /* Canonicalize bootseg:bootip */
+    bootip = (bootseg & 0x0fff) << 4;
+    bootseg &= 0xf000;
+  break;
 
 #if BX_ELTORITO_BOOT
-  // if boot from cd, no signature check
-  if (bootcd != 0)
-    bootchk = 1;
-#endif // BX_ELTORITO_BOOT
-
-  if (bootchk == 0) {
-    if (read_word(bootseg,0x1fe) != 0xaa55) {
-      print_boot_failure(bootcd, bootdrv, 0, lastdrive);
-      return 0x00000000;
-      }
+  case 0x03: /* CD-ROM */
+    status = cdrom_boot();
+
+    // If failure
+    if ( (status & 0x00ff) !=0 ) {
+      print_cdromboot_failure(status);
+      print_boot_failure(e.type, 1);
+      return;
     }
+
+    bootdrv = (Bit8u)(status>>8);
+    bootseg = read_word(ebda_seg,&EbdaData->cdemu.load_segment);
+    /* Canonicalize bootseg:bootip */
+    bootip = (bootseg & 0x0fff) << 4;
+    bootseg &= 0xf000;
+    break;
+#endif
+
+  case 0x80: /* Expansion ROM with a Bootstrap Entry Vector (a far pointer) */
+    bootseg = e.vector >> 16;
+    bootip = e.vector & 0xffff;
+    break;
+
+  default: return;
+  }
+
+  /* Debugging info */
+  printf("Booting from %x:%x\n", bootseg, bootip);
   
-#if BX_ELTORITO_BOOT
-  // Print out the boot string
-  print_boot_device(bootcd, bootdrv);
-#else // BX_ELTORITO_BOOT
-  print_boot_device(0, bootdrv);
-#endif // BX_ELTORITO_BOOT
-
-  // return the boot segment
-  return (((Bit32u)bootdrv) << 16) + bootseg;
+  /* Jump to the boot vector */
+ASM_START
+    mov  bp, sp
+    ;; Build an iret stack frame that will take us to the boot vector.
+    ;; iret pops ip, then cs, then flags, so push them in the opposite order.
+    pushf
+    mov  ax, _int19_function.bootseg + 0[bp] 
+    push ax
+    mov  ax, _int19_function.bootip + 0[bp] 
+    push ax
+    ;; Set the magic number in ax and the boot drive in dl.
+    mov  ax, #0xaa55
+    mov  dl, _int19_function.bootdrv + 0[bp]
+    ;; Zero some of the other registers.
+    xor  bx, bx
+    mov  ds, bx
+    mov  es, bx
+    mov  bp, bx
+    ;; Go!
+    iret
+ASM_END
 }
 
   void
@@ -8139,14 +8241,29 @@ int13_out:
   popa
   iret 
 
-
 ;----------
 ;- INT18h -
 ;----------
-int18_handler: ;; Boot Failure routing
-  call _int18_panic_msg
-  hlt
-  iret
+int18_handler: ;; Boot Failure recovery: try the next device.
+
+  ;; Reset SP and SS
+  mov  ax, #0xfffe
+  mov  sp, ax
+  xor  ax, ax
+  mov  ss, ax
+
+  ;; Get the boot sequence number out of the IPL memory
+  mov  bx, #IPL_SEG 
+  mov  ds, bx                     ;; Set segment
+  mov  bx, IPL_SEQUENCE_OFFSET    ;; BX is now the sequence number
+  inc  bx                         ;; ++
+  mov  IPL_SEQUENCE_OFFSET, bx    ;; Write it back
+  mov  ds, ax                     ;; and reset the segment to zero. 
+
+  ;; Carry on in the INT 19h handler, using the new sequence number
+  push bx
+
+  jmp  int19_next_boot
 
 ;----------
 ;- INT19h -
@@ -8154,62 +8271,32 @@ int19_relocated: ;; Boot function, reloc
 int19_relocated: ;; Boot function, relocated
 
   ;; int19 was beginning to be really complex, so now it
-  ;; just calls an C function, that does the work
-  ;; it returns in BL the boot drive, and in AX the boot segment
-  ;; the boot segment will be 0x0000 if something has failed
+  ;; just calls a C function that does the work
 
   push bp
   mov  bp, sp
-
-  ;; drop ds
+  
+  ;; Reset SS and SP
+  mov  ax, #0xfffe
+  mov  sp, ax
   xor  ax, ax
-  mov  ds, ax
-
-  ;; 1st boot device
-  mov  ax, #0x0001
+  mov  ss, ax
+
+  ;; Start from the first boot device (0, in AX)
+  mov  bx, #IPL_SEG 
+  mov  ds, bx                     ;; Set segment to write to the IPL memory
+  mov  IPL_SEQUENCE_OFFSET, ax    ;; Save the sequence number 
+  mov  ds, ax                     ;; and reset the segment.
+
   push ax
+
+int19_next_boot:
+
+  ;; Call the C code for the next boot device
   call _int19_function
-  inc  sp
-  inc  sp
-  ;; bl contains the boot drive
-  ;; ax contains the boot segment or 0 if failure
-
-  test       ax, ax  ;; if ax is 0 try next boot device
-  jnz        boot_setup
-
-  ;; 2nd boot device
-  mov  ax, #0x0002
-  push ax
-  call _int19_function
-  inc  sp
-  inc  sp
-  test       ax, ax  ;; if ax is 0 try next boot device
-  jnz        boot_setup
-
-  ;; 3rd boot device
-  mov  ax, #0x0003
-  push ax
-  call _int19_function
-  inc  sp
-  inc  sp
-  test       ax, ax  ;; if ax is 0 call int18
-  jz         int18_handler
-
-boot_setup:
-  mov dl,    bl      ;; set drive so guest os find it
-  shl eax,   #0x04   ;; convert seg to ip
-  mov 2[bp], ax      ;; set ip
-
-  shr eax,   #0x04   ;; get cs back
-  and ax,    #0xF000 ;; remove what went in ip
-  mov 4[bp], ax      ;; set cs
-  xor ax,    ax
-  mov es,    ax      ;; set es to zero fixes [ 549815 ]
-  mov [bp],  ax      ;; set bp to zero
-  mov ax,    #0xaa55 ;; set ok flag
-
-  pop bp
-  iret               ;; Beam me up Scotty
+
+  ;; Boot failed: invoke the boot recovery function
+  int  #0x18
 
 ;----------
 ;- INT1Ch -
@@ -9387,6 +9474,15 @@ checksum_loop:
   pop  ax
   ret
 
+
+;; We need a copy of this string, but we are not actually a PnP BIOS, 
+;; so make sure it is *not* aligned, so OSes will not see it if they scan.
+.align 16
+  db 0
+pnp_string:
+  .ascii "$PnP"
+
+
 rom_scan:
   ;; Scan for existence of valid expansion ROMS.
   ;;   Video ROM:   from 0xC0000..0xC7FFF in 2k increments
@@ -9421,9 +9517,17 @@ block_count_rounded:
   xor  bx, bx   ;; Restore DS back to 0000:
   mov  ds, bx
   push ax       ;; Save AX
+  push di       ;; Save DI
   ;; Push addr of ROM entry point
   push cx       ;; Push seg
   push #0x0003  ;; Push offset
+
+  ;; Point ES:DI at "$PnP", which tells the ROM that we are a PnP BIOS.  
+  ;; That should stop it grabbing INT 19h; we will use its BEV instead.
+  mov  ax, #0xf000
+  mov  es, ax
+  lea  di, pnp_string 
+
   mov  bp, sp   ;; Call ROM init routine using seg:off on stack
   db   0xff     ;; call_far ss:[bp+0]
   db   0x5e
@@ -9431,6 +9535,38 @@ block_count_rounded:
   cli           ;; In case expansion ROM BIOS turns IF on
   add  sp, #2   ;; Pop offset value
   pop  cx       ;; Pop seg value (restore CX)
+
+  ;; Look at the ROM's PnP Expansion header.  Properly, we're supposed 
+  ;; to init all the ROMs and then go back and build an IPL table of 
+  ;; all the bootable devices, but we can get away with one pass.
+  mov  ds, cx       ;; ROM base
+  mov  bx, 0x001a   ;; 0x1A is the offset into ROM header that contains...
+  mov  ax, [bx]     ;; the offset of PnP expansion header, where...
+  cmp  ax, #0x5024  ;; we look for signature "$PnP"
+  jne  no_bev
+  mov  ax, 2[bx]
+  cmp  ax, #0x506e 
+  jne  no_bev
+  mov  ax, 0x1a[bx] ;; 0x1A is also the offset into the expansion header of...
+  cmp  ax, #0x0000  ;; the Bootstrap Entry Vector, or zero if there is none.
+  je   no_bev
+
+  ;; Found a device that thinks it can boot the system.  Record its BEV.
+  mov  bx, #IPL_SEG            ;; Go to the segment where the IPL table lives 
+  mov  ds, bx
+  mov  bx, IPL_COUNT_OFFSET    ;; Read the number of entries so far
+  cmp  bx, #IPL_TABLE_ENTRIES
+  je   no_bev                  ;; Get out if the table is full
+  shl  bx, #0x4                ;; Turn count into offset (entries are 16 bytes)
+  mov  0[bx], #0x80            ;; This entry is a BEV device
+  mov  6[bx], cx               ;; Build a far pointer from the segment...
+  mov  4[bx], ax               ;; and the offset
+  shr  bx, #0x4                ;; Turn the offset back into a count
+  inc  bx                      ;; We have one more entry now
+  mov  IPL_COUNT_OFFSET, bx    ;; Remember that.
+
+no_bev:
+  pop  di       ;; Restore DI
   pop  ax       ;; Restore AX
 rom_scan_increment:
   shl  ax, #5   ;; convert 512-bytes blocks to 16-byte increments
@@ -9763,6 +9899,8 @@ post_default_ints:
   call _copy_e820_table
   call smbios_init
 #endif
+
+  call _init_boot_vectors
 
   call rom_scan
 
diff -r 42babffffba5 -r 58633caeece9 tools/firmware/vmxassist/vm86.c
--- a/tools/firmware/vmxassist/vm86.c   Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/firmware/vmxassist/vm86.c   Wed Jan 10 08:40:47 2007 -0700
@@ -297,7 +297,7 @@ getreg32(struct regs *regs, int r)
        case 1: return regs->ecx;
        case 2: return regs->edx;
        case 3: return regs->ebx;
-       case 4: return regs->esp;
+       case 4: return regs->uesp;
        case 5: return regs->ebp;
        case 6: return regs->esi;
        case 7: return regs->edi;
@@ -319,10 +319,10 @@ getreg8(struct regs *regs, int r)
        case 1: return regs->ecx & 0xFF; /* cl */
        case 2: return regs->edx & 0xFF; /* dl */
        case 3: return regs->ebx & 0xFF; /* bl */
-       case 4: return (regs->esp >> 8) & 0xFF; /* ah */
-       case 5: return (regs->ebp >> 8) & 0xFF; /* ch */
-       case 6: return (regs->esi >> 8) & 0xFF; /* dh */
-       case 7: return (regs->edi >> 8) & 0xFF; /* bh */
+       case 4: return (regs->eax >> 8) & 0xFF; /* ah */
+       case 5: return (regs->ecx >> 8) & 0xFF; /* ch */
+       case 6: return (regs->edx >> 8) & 0xFF; /* dh */
+       case 7: return (regs->ebx >> 8) & 0xFF; /* bh */
        }
        return ~0;
 }
@@ -335,7 +335,7 @@ setreg32(struct regs *regs, int r, unsig
        case 1: regs->ecx = v; break;
        case 2: regs->edx = v; break;
        case 3: regs->ebx = v; break;
-       case 4: regs->esp = v; break;
+       case 4: regs->uesp = v; break;
        case 5: regs->ebp = v; break;
        case 6: regs->esi = v; break;
        case 7: regs->edi = v; break;
@@ -357,10 +357,10 @@ setreg8(struct regs *regs, int r, unsign
        case 1: regs->ecx = (regs->ecx & ~0xFF) | v; break;
        case 2: regs->edx = (regs->edx & ~0xFF) | v; break;
        case 3: regs->ebx = (regs->ebx & ~0xFF) | v; break;
-       case 4: regs->esp = (regs->esp & ~0xFF00) | (v << 8); break;
-       case 5: regs->ebp = (regs->ebp & ~0xFF00) | (v << 8); break;
-       case 6: regs->esi = (regs->esi & ~0xFF00) | (v << 8); break;
-       case 7: regs->edi = (regs->edi & ~0xFF00) | (v << 8); break;
+       case 4: regs->eax = (regs->eax & ~0xFF00) | (v << 8); break;
+       case 5: regs->ecx = (regs->ecx & ~0xFF00) | (v << 8); break;
+       case 6: regs->edx = (regs->edx & ~0xFF00) | (v << 8); break;
+       case 7: regs->ebx = (regs->ebx & ~0xFF00) | (v << 8); break;
        }
 }
 
@@ -961,9 +961,9 @@ protected_mode(struct regs *regs)
 
        /* initialize jump environment to warp back to protected mode */
        regs->uss = DATA_SELECTOR;
-       regs->uesp = stack_top;
+       regs->uesp = (unsigned long)stack_top;
        regs->cs = CODE_SELECTOR;
-       regs->eip = (unsigned) switch_to_protected_mode;
+       regs->eip = (unsigned long)switch_to_protected_mode;
 
        /* this should get us into 32-bit mode */
 }
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/hw/pc.c
--- a/tools/ioemu/hw/pc.c       Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/hw/pc.c       Wed Jan 10 08:40:47 2007 -0700
@@ -168,6 +168,8 @@ static int get_bios_disk(char *boot_devi
             return 0x02;            /* hard drive */
         case 'd':
             return 0x03;            /* cdrom */
+        case 'n':
+            return 0x04;            /* network */
         }
     }
     return 0x00;                /* no device */
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/hw/vga.c
--- a/tools/ioemu/hw/vga.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/hw/vga.c      Wed Jan 10 08:40:47 2007 -0700
@@ -2002,7 +2002,10 @@ void vga_common_init(VGAState *s, Displa
     s->vram_shadow = (uint8_t *)((long)(s->vram_shadow + TARGET_PAGE_SIZE - 1)
                                  & ~(TARGET_PAGE_SIZE - 1));
 
-    s->vram_ptr = qemu_malloc(vga_ram_size);
+    /* Video RAM must be 128-bit aligned for SSE optimizations later */
+    s->vram_alloc = qemu_malloc(vga_ram_size + 15);
+    s->vram_ptr = (uint8_t *)((long)(s->vram_alloc + 15) & ~15L);
+
     s->vram_offset = vga_ram_offset;
     s->vram_size = vga_ram_size;
     s->ds = ds;
@@ -2126,7 +2129,7 @@ void *vga_update_vram(VGAState *s, void 
     }
 
     if (!vga_ram_base) {
-        vga_ram_base = qemu_malloc(vga_ram_size);
+        vga_ram_base = qemu_malloc(vga_ram_size + TARGET_PAGE_SIZE + 1);
         if (!vga_ram_base) {
             fprintf(stderr, "reallocate error\n");
             return NULL;
@@ -2134,8 +2137,10 @@ void *vga_update_vram(VGAState *s, void 
     }
 
     /* XXX lock needed? */
+    old_pointer = s->vram_alloc;
+    s->vram_alloc = vga_ram_base;
+    vga_ram_base = (uint8_t *)((long)(vga_ram_base + 15) & ~15L);
     memcpy(vga_ram_base, s->vram_ptr, vga_ram_size);
-    old_pointer = s->vram_ptr;
     s->vram_ptr = vga_ram_base;
 
     return old_pointer;
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/hw/vga_int.h
--- a/tools/ioemu/hw/vga_int.h  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/hw/vga_int.h  Wed Jan 10 08:40:47 2007 -0700
@@ -78,6 +78,7 @@
 #define VGA_MAX_HEIGHT 2048
 
 #define VGA_STATE_COMMON                                                \
+    uint8_t *vram_alloc;                                                \
     uint8_t *vram_ptr;                                                  \
     uint8_t *vram_shadow;                                               \
     unsigned long vram_offset;                                          \
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/domain-timeoffset
--- a/tools/ioemu/patches/domain-timeoffset     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/domain-timeoffset     Wed Jan 10 08:40:47 2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/hw/mc146818rtc.c
 Index: ioemu/hw/mc146818rtc.c
 ===================================================================
---- ioemu.orig/hw/mc146818rtc.c        2006-12-08 18:36:31.000000000 +0000
-+++ ioemu/hw/mc146818rtc.c     2006-12-08 18:36:36.000000000 +0000
+--- ioemu.orig/hw/mc146818rtc.c        2006-12-20 15:21:33.000000000 +0000
++++ ioemu/hw/mc146818rtc.c     2006-12-20 15:21:50.000000000 +0000
 @@ -178,10 +178,27 @@
      }
  }
@@ -46,8 +46,8 @@ Index: ioemu/hw/mc146818rtc.c
  static void rtc_copy_date(RTCState *s)
 Index: ioemu/hw/pc.c
 ===================================================================
---- ioemu.orig/hw/pc.c 2006-12-08 18:36:35.000000000 +0000
-+++ ioemu/hw/pc.c      2006-12-08 18:36:36.000000000 +0000
+--- ioemu.orig/hw/pc.c 2006-12-20 15:21:49.000000000 +0000
++++ ioemu/hw/pc.c      2006-12-20 15:21:50.000000000 +0000
 @@ -159,7 +159,7 @@
  }
  
@@ -117,8 +117,8 @@ Index: ioemu/hw/pc.c
  QEMUMachine pc_machine = {
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 18:36:35.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 18:36:36.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:49.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:50.000000000 +0000
 @@ -163,6 +163,8 @@
  
  int xc_handle;
@@ -162,7 +162,7 @@ Index: ioemu/vl.c
              }
          }
      }
-@@ -6492,7 +6500,8 @@
+@@ -6484,7 +6492,8 @@
  
      machine->init(ram_size, vga_ram_size, boot_device,
                    ds, fd_filename, snapshot,
@@ -174,8 +174,8 @@ Index: ioemu/vl.c
      if (usb_enabled) {
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 18:36:35.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 18:36:36.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:49.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:50.000000000 +0000
 @@ -576,7 +576,7 @@
                                   int boot_device,
               DisplayState *ds, const char **fd_filename, int snapshot,
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/fix-interrupt-routing
--- a/tools/ioemu/patches/fix-interrupt-routing Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/fix-interrupt-routing Wed Jan 10 08:40:47 2007 -0700
@@ -17,23 +17,21 @@ Signed-off-by: Keir Fraser <keir@xensour
 
 Index: ioemu/Makefile.target
 ===================================================================
---- ioemu.orig/Makefile.target 2006-12-08 18:21:56.000000000 +0000
-+++ ioemu/Makefile.target      2006-12-08 18:22:35.000000000 +0000
-@@ -298,7 +298,7 @@
+--- ioemu.orig/Makefile.target 2006-12-20 15:04:55.000000000 +0000
++++ ioemu/Makefile.target      2006-12-20 15:08:16.000000000 +0000
+@@ -296,9 +296,9 @@
+ 
+ # qemu-dm objects
  ifeq ($(ARCH),ia64)
- LIBOBJS=helper2.o exec-dm.o i8259-dm.o
+-LIBOBJS=helper2.o exec-dm.o i8259-dm.o
++LIBOBJS=helper2.o exec-dm.o i8259-dm.o piix_pci-dm.o
  else
 -LIBOBJS=helper2.o exec-dm.o i8259-dm.o rtc-dm.o
 +LIBOBJS=helper2.o exec-dm.o i8259-dm.o rtc-dm.o piix_pci-dm.o
  endif
  
  all: $(PROGS)
-@@ -360,11 +360,11 @@
- # Hardware support
- VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
- ifeq ($(ARCH),ia64)
--VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
-+VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o piix_pci.o
+@@ -364,7 +364,7 @@
  else
  VL_OBJS+= fdc.o serial.o pc.o
  endif
@@ -44,8 +42,8 @@ Index: ioemu/Makefile.target
  VL_OBJS+= xenstore.o
 Index: ioemu/target-i386-dm/i8259-dm.c
 ===================================================================
---- ioemu.orig/target-i386-dm/i8259-dm.c       2006-12-08 18:21:36.000000000 
+0000
-+++ ioemu/target-i386-dm/i8259-dm.c    2006-12-08 18:22:35.000000000 +0000
+--- ioemu.orig/target-i386-dm/i8259-dm.c       2006-12-20 15:04:54.000000000 
+0000
++++ ioemu/target-i386-dm/i8259-dm.c    2006-12-20 15:04:55.000000000 +0000
 @@ -33,7 +33,7 @@
  
  void pic_set_irq_new(void *opaque, int irq, int level)
@@ -58,7 +56,7 @@ Index: ioemu/target-i386-dm/piix_pci-dm.
 Index: ioemu/target-i386-dm/piix_pci-dm.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/target-i386-dm/piix_pci-dm.c 2006-12-08 18:22:35.000000000 +0000
++++ ioemu/target-i386-dm/piix_pci-dm.c 2006-12-20 15:08:13.000000000 +0000
 @@ -0,0 +1,397 @@
 +/*
 + * QEMU i440FX/PIIX3 PCI Bridge Emulation
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/ioemu-ia64
--- a/tools/ioemu/patches/ioemu-ia64    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/ioemu-ia64    Wed Jan 10 08:40:47 2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/hw/iommu.c
 Index: ioemu/hw/iommu.c
 ===================================================================
---- ioemu.orig/hw/iommu.c      2006-12-08 02:02:07.000000000 +0000
-+++ ioemu/hw/iommu.c   2006-12-08 02:02:34.000000000 +0000
+--- ioemu.orig/hw/iommu.c      2006-12-20 15:04:54.000000000 +0000
++++ ioemu/hw/iommu.c   2006-12-20 15:04:54.000000000 +0000
 @@ -82,7 +82,11 @@
  #define IOPTE_VALID         0x00000002 /* IOPTE is valid */
  #define IOPTE_WAZ           0x00000001 /* Write as zeros */
@@ -16,8 +16,8 @@ Index: ioemu/hw/iommu.c
  
 Index: ioemu/cpu-all.h
 ===================================================================
---- ioemu.orig/cpu-all.h       2006-12-08 02:02:07.000000000 +0000
-+++ ioemu/cpu-all.h    2006-12-08 02:02:34.000000000 +0000
+--- ioemu.orig/cpu-all.h       2006-12-20 15:04:54.000000000 +0000
++++ ioemu/cpu-all.h    2006-12-20 15:04:54.000000000 +0000
 @@ -835,6 +835,31 @@
                  :"=m" (*(volatile long *)addr)
                  :"dIr" (nr));
@@ -52,13 +52,17 @@ Index: ioemu/cpu-all.h
  /* memory API */
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:28.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:34.000000000 +0000
-@@ -6137,6 +6137,11 @@
+--- ioemu.orig/vl.c    2006-12-20 15:04:54.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:12:00.000000000 +0000
+@@ -6137,6 +6137,15 @@
              exit(1);
      }
  
 +#if defined (__ia64__)
++    /* ram_size passed from xend has added on GFW memory,
++       so we must subtract it here */
++    ram_size -= 16 * MEM_M;
++
 +    if (ram_size > MMIO_START)
 +        ram_size += 1 * MEM_G; /* skip 3G-4G MMIO, LEGACY_IO_SPACE etc. */
 +#endif
@@ -66,7 +70,7 @@ Index: ioemu/vl.c
      /* init the memory */
      phys_ram_size = ram_size + vga_ram_size + bios_size;
  
-@@ -6161,6 +6166,7 @@
+@@ -6161,6 +6170,7 @@
          exit(-1);
      }
  
@@ -74,41 +78,29 @@ Index: ioemu/vl.c
      for ( i = 0; i < tmp_nr_pages; i++)
          page_array[i] = i;
  
-@@ -6185,6 +6191,48 @@
+@@ -6185,6 +6195,36 @@
  
      free(page_array);
  
 +#elif defined(__ia64__)
 +  
-+    if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
-+                             IO_PAGE_START >> PAGE_SHIFT, 3) != 3) {
-+        fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
-+        exit(-1);
-+    }
-+
 +    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
 +                                       PROT_READ|PROT_WRITE,
-+                                       page_array[0]);
-+
-+    fprintf(logfile, "shared page at pfn:%lx, mfn: %016lx\n",
-+            IO_PAGE_START >> PAGE_SHIFT, page_array[0]);
++                                       IO_PAGE_START >> PAGE_SHIFT);
 +
 +    buffered_io_page =xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
 +                                       PROT_READ|PROT_WRITE,
-+                                       page_array[2]);
-+    fprintf(logfile, "Buffered IO page at pfn:%lx, mfn: %016lx\n",
-+            BUFFER_IO_PAGE_START >> PAGE_SHIFT, page_array[2]);
-+
-+    if (xc_ia64_get_pfn_list(xc_handle, domid,
-+                             page_array, 0, nr_pages) != nr_pages) {
-+        fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
-+        exit(-1);
-+    }
-+
++                                       BUFFER_IO_PAGE_START >> PAGE_SHIFT);
++
++    for (i = 0; i < tmp_nr_pages; i++)
++        page_array[i] = i;
++      
++    /* VTI will not use memory between 3G~4G, so we just pass a legal pfn
++       to make QEMU map continuous virtual memory space */
 +    if (ram_size > MMIO_START) {      
 +        for (i = 0 ; i < (MEM_G >> PAGE_SHIFT); i++)
 +            page_array[(MMIO_START >> PAGE_SHIFT) + i] =
-+                page_array[(IO_PAGE_START >> PAGE_SHIFT) + 1];
++                (STORE_PAGE_START >> PAGE_SHIFT); 
 +    }
 +
 +    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
@@ -125,8 +117,8 @@ Index: ioemu/vl.c
      phys_ram_base = qemu_vmalloc(phys_ram_size);
 Index: ioemu/exec-all.h
 ===================================================================
---- ioemu.orig/exec-all.h      2006-12-08 02:02:07.000000000 +0000
-+++ ioemu/exec-all.h   2006-12-08 02:02:34.000000000 +0000
+--- ioemu.orig/exec-all.h      2006-12-20 15:04:54.000000000 +0000
++++ ioemu/exec-all.h   2006-12-20 15:04:54.000000000 +0000
 @@ -462,12 +462,13 @@
  }
  #endif
@@ -146,8 +138,8 @@ Index: ioemu/exec-all.h
  
 Index: ioemu/target-i386-dm/cpu.h
 ===================================================================
---- ioemu.orig/target-i386-dm/cpu.h    2006-12-08 02:02:07.000000000 +0000
-+++ ioemu/target-i386-dm/cpu.h 2006-12-08 02:02:34.000000000 +0000
+--- ioemu.orig/target-i386-dm/cpu.h    2006-12-20 15:04:54.000000000 +0000
++++ ioemu/target-i386-dm/cpu.h 2006-12-20 15:10:13.000000000 +0000
 @@ -78,7 +78,11 @@
  /* helper2.c */
  int main_loop(void);
@@ -163,7 +155,7 @@ Index: ioemu/ia64_intrinsic.h
 Index: ioemu/ia64_intrinsic.h
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/ia64_intrinsic.h     2006-12-08 02:02:34.000000000 +0000
++++ ioemu/ia64_intrinsic.h     2006-12-20 15:04:54.000000000 +0000
 @@ -0,0 +1,276 @@
 +#ifndef IA64_INTRINSIC_H
 +#define IA64_INTRINSIC_H
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/qemu-bootorder
--- a/tools/ioemu/patches/qemu-bootorder        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/qemu-bootorder        Wed Jan 10 08:40:47 2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/vl.c
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:38.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:38.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:12:08.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:19.000000000 +0000
 @@ -125,7 +125,7 @@
  struct sockaddr_in vnclisten_addr;
  const char* keyboard_layout = NULL;
@@ -17,15 +17,17 @@ Index: ioemu/vl.c
              case QEMU_OPTION_boot:
 -                boot_device = optarg[0];
 -                if (boot_device != 'a' && 
+-#ifdef TARGET_SPARC
+-                  // Network boot
+-                  boot_device != 'n' &&
+-#endif
+-                    boot_device != 'c' && boot_device != 'd') {
+-                    fprintf(stderr, "qemu: invalid boot device '%c'\n", 
boot_device);
 +                boot_device = strdup(optarg);
 +                if (strspn(boot_device, "acd"
- #ifdef TARGET_SPARC
--                  // Network boot
--                  boot_device != 'n' &&
++#if defined(TARGET_SPARC) || defined(TARGET_I386)
 +                           "n"
- #endif
--                    boot_device != 'c' && boot_device != 'd') {
--                    fprintf(stderr, "qemu: invalid boot device '%c'\n", 
boot_device);
++#endif
 +                        ) != strlen(boot_device)) {
 +                    fprintf(stderr, "qemu: invalid boot device in '%s'\n",
 +                            boot_device);
@@ -48,7 +50,7 @@ Index: ioemu/vl.c
  #endif /* !CONFIG_DM */
  
      setvbuf(stdout, NULL, _IOLBF, 0);
-@@ -6598,6 +6600,7 @@
+@@ -6590,6 +6592,7 @@
                    ds, fd_filename, snapshot,
                    kernel_filename, kernel_cmdline, initrd_filename,
                    timeoffset);
@@ -58,8 +60,8 @@ Index: ioemu/vl.c
      if (usb_enabled) {
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:38.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:38.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:12:08.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:14.000000000 +0000
 @@ -578,7 +578,7 @@
  #ifndef QEMU_TOOL
  
@@ -80,9 +82,9 @@ Index: ioemu/vl.h
                            uint32_t initrd_image, uint32_t initrd_size,
 Index: ioemu/hw/pc.c
 ===================================================================
---- ioemu.orig/hw/pc.c 2006-12-08 02:02:38.000000000 +0000
-+++ ioemu/hw/pc.c      2006-12-08 02:02:38.000000000 +0000
-@@ -158,8 +158,23 @@
+--- ioemu.orig/hw/pc.c 2006-12-20 15:12:08.000000000 +0000
++++ ioemu/hw/pc.c      2006-12-20 15:21:19.000000000 +0000
+@@ -158,8 +158,25 @@
      rtc_set_memory(s, info_ofs + 8, sectors);
  }
  
@@ -96,6 +98,8 @@ Index: ioemu/hw/pc.c
 +            return 0x02;            /* hard drive */
 +        case 'd':
 +            return 0x03;            /* cdrom */
++        case 'n':
++            return 0x04;            /* network */
 +        }
 +    }
 +    return 0x00;                /* no device */
@@ -107,7 +111,7 @@ Index: ioemu/hw/pc.c
  {
      RTCState *s = rtc_state;
      int val;
-@@ -205,21 +220,14 @@
+@@ -205,21 +222,14 @@
      rtc_set_memory(s, 0x34, val);
      rtc_set_memory(s, 0x35, val >> 8);
      
@@ -137,7 +141,7 @@ Index: ioemu/hw/pc.c
  
      /* floppy type */
  
-@@ -617,7 +625,7 @@
+@@ -617,7 +627,7 @@
  #define NOBIOS 1
  
  /* PC hardware initialisation */
@@ -146,7 +150,7 @@ Index: ioemu/hw/pc.c
                       DisplayState *ds, const char **fd_filename, int snapshot,
                       const char *kernel_filename, const char *kernel_cmdline,
                       const char *initrd_filename, time_t timeoffset,
-@@ -919,7 +927,7 @@
+@@ -919,7 +929,7 @@
      }
  }
  
@@ -155,7 +159,7 @@ Index: ioemu/hw/pc.c
                          DisplayState *ds, const char **fd_filename, 
                          int snapshot, 
                          const char *kernel_filename, 
-@@ -933,7 +941,7 @@
+@@ -933,7 +943,7 @@
               initrd_filename, timeoffset, 1);
  }
  
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/series
--- a/tools/ioemu/patches/series        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/series        Wed Jan 10 08:40:47 2007 -0700
@@ -67,5 +67,5 @@ vnc-monitor-shift-key-processing
 vnc-monitor-shift-key-processing
 ide-error-reporting
 vnc-numpad-handling
-xen-mapcache -p3
+xen-mapcache
 usb-mouse-tablet-status-check -p3
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/tpm-tis-device
--- a/tools/ioemu/patches/tpm-tis-device        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/tpm-tis-device        Wed Jan 10 08:40:47 2007 -0700
@@ -22,8 +22,8 @@ Signed-off-by: Stefan Berger <stefanb@us
 
 Index: ioemu/Makefile.target
 ===================================================================
---- ioemu.orig/Makefile.target 2006-12-08 18:33:48.000000000 +0000
-+++ ioemu/Makefile.target      2006-12-08 18:35:14.000000000 +0000
+--- ioemu.orig/Makefile.target 2006-12-20 15:21:55.000000000 +0000
++++ ioemu/Makefile.target      2006-12-20 15:21:55.000000000 +0000
 @@ -369,6 +369,7 @@
  VL_OBJS+= piix4acpi.o
  VL_OBJS+= xenstore.o
@@ -34,9 +34,9 @@ Index: ioemu/Makefile.target
  ifeq ($(TARGET_BASE_ARCH), ppc)
 Index: ioemu/hw/pc.c
 ===================================================================
---- ioemu.orig/hw/pc.c 2006-12-08 18:33:47.000000000 +0000
-+++ ioemu/hw/pc.c      2006-12-08 18:33:48.000000000 +0000
-@@ -875,6 +875,9 @@
+--- ioemu.orig/hw/pc.c 2006-12-20 15:21:54.000000000 +0000
++++ ioemu/hw/pc.c      2006-12-20 15:21:55.000000000 +0000
+@@ -877,6 +877,9 @@
          }
      }
  
@@ -49,7 +49,7 @@ Index: ioemu/hw/tpm_tis.c
 Index: ioemu/hw/tpm_tis.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/hw/tpm_tis.c 2006-12-08 18:35:25.000000000 +0000
++++ ioemu/hw/tpm_tis.c 2006-12-20 15:21:55.000000000 +0000
 @@ -0,0 +1,1120 @@
 +/*
 + * tpm_tis.c - QEMU emulator for a 1.2 TPM with TIS interface
@@ -1173,8 +1173,8 @@ Index: ioemu/hw/tpm_tis.c
 +}
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 18:33:48.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 18:35:14.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:55.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:55.000000000 +0000
 @@ -932,6 +932,10 @@
  void piix4_pm_init(PCIBus *bus, int devfn);
  void acpi_bios_init(void);
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/vnc-display-find-unused
--- a/tools/ioemu/patches/vnc-display-find-unused       Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/ioemu/patches/vnc-display-find-unused       Wed Jan 10 08:40:47 
2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/vnc.c
 Index: ioemu/vnc.c
 ===================================================================
---- ioemu.orig/vnc.c   2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vnc.c        2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vnc.c   2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vnc.c        2006-12-20 15:21:52.000000000 +0000
 @@ -1197,7 +1197,7 @@
      }
  }
@@ -50,8 +50,8 @@ Index: ioemu/vnc.c
  int vnc_start_viewer(int port)
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:52.000000000 +0000
 @@ -121,6 +121,7 @@
  static DisplayState display_state;
  int nographic;
@@ -104,7 +104,7 @@ Index: ioemu/vl.c
              }
          }
      }
-@@ -6468,7 +6478,7 @@
+@@ -6460,7 +6470,7 @@
      if (nographic) {
          dumb_display_init(ds);
      } else if (vnc_display != -1) {
@@ -115,8 +115,8 @@ Index: ioemu/vl.c
      } else {
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:52.000000000 +0000
 @@ -785,7 +785,7 @@
  void cocoa_display_init(DisplayState *ds, int full_screen);
  
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/vnc-fixes
--- a/tools/ioemu/patches/vnc-fixes     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/vnc-fixes     Wed Jan 10 08:40:47 2007 -0700
@@ -1,8 +1,8 @@ Index: ioemu/vl.c
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:36.000000000 +0000
-@@ -6519,8 +6519,10 @@
+--- ioemu.orig/vl.c    2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:51.000000000 +0000
+@@ -6511,8 +6511,10 @@
          }
      }
  
@@ -17,8 +17,8 @@ Index: ioemu/vl.c
      if (use_gdbstub) {
 Index: ioemu/vnc.c
 ===================================================================
---- ioemu.orig/vnc.c   2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vnc.c        2006-12-08 02:02:36.000000000 +0000
+--- ioemu.orig/vnc.c   2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vnc.c        2006-12-20 15:21:51.000000000 +0000
 @@ -3,6 +3,7 @@
   * 
   * Copyright (C) 2006 Anthony Liguori <anthony@xxxxxxxxxxxxx>
@@ -531,8 +531,8 @@ Index: ioemu/vnc.c
  }
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:36.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:51.000000000 +0000
 @@ -319,6 +319,7 @@
  int is_graphic_console(void);
  CharDriverState *text_console_init(DisplayState *ds);
diff -r 42babffffba5 -r 58633caeece9 
tools/ioemu/patches/vnc-listen-specific-interface
--- a/tools/ioemu/patches/vnc-listen-specific-interface Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/ioemu/patches/vnc-listen-specific-interface Wed Jan 10 08:40:47 
2007 -0700
@@ -20,8 +20,8 @@ Signed-off-by:  Daniel P. Berrange <berr
 
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:52.000000000 +0000
 @@ -122,6 +122,7 @@
  int nographic;
  int vncviewer;
@@ -114,7 +114,7 @@ Index: ioemu/vl.c
              }
          }
      }
-@@ -6478,7 +6493,7 @@
+@@ -6470,7 +6485,7 @@
      if (nographic) {
          dumb_display_init(ds);
      } else if (vnc_display != -1) {
@@ -125,8 +125,8 @@ Index: ioemu/vl.c
      } else {
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:52.000000000 +0000
 @@ -37,6 +37,8 @@
  #include <unistd.h>
  #include <fcntl.h>
@@ -147,8 +147,8 @@ Index: ioemu/vl.h
  /* ide.c */
 Index: ioemu/vnc.c
 ===================================================================
---- ioemu.orig/vnc.c   2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vnc.c        2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vnc.c   2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vnc.c        2006-12-20 15:21:52.000000000 +0000
 @@ -1197,9 +1197,8 @@
      }
  }
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/vnc-password
--- a/tools/ioemu/patches/vnc-password  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/vnc-password  Wed Jan 10 08:40:47 2007 -0700
@@ -17,8 +17,8 @@ Signed-off-by: Masami Watanabe <masami.w
 
 Index: ioemu/Makefile.target
 ===================================================================
---- ioemu.orig/Makefile.target 2006-12-08 18:20:53.000000000 +0000
-+++ ioemu/Makefile.target      2006-12-08 18:20:53.000000000 +0000
+--- ioemu.orig/Makefile.target 2006-12-20 15:21:55.000000000 +0000
++++ ioemu/Makefile.target      2006-12-20 15:21:55.000000000 +0000
 @@ -407,6 +407,7 @@
  VL_OBJS+=sdl.o
  endif
@@ -39,8 +39,8 @@ Index: ioemu/Makefile.target
  
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 18:20:52.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 18:20:53.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:54.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:55.000000000 +0000
 @@ -171,6 +171,9 @@
  char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'};
  extern int domid;
@@ -59,7 +59,7 @@ Index: ioemu/vl.c
  #ifndef CONFIG_DM
  #ifdef TARGET_PPC
      cdrom_index = 1;
-@@ -6543,6 +6547,10 @@
+@@ -6535,6 +6539,10 @@
  
      init_ioports();
  
@@ -72,8 +72,8 @@ Index: ioemu/vl.c
          dumb_display_init(ds);
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 18:20:52.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 18:20:53.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:54.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:55.000000000 +0000
 @@ -1214,6 +1214,7 @@
  void xenstore_process_event(void *opaque);
  void xenstore_check_new_media_present(int timeout);
@@ -92,8 +92,8 @@ Index: ioemu/vl.h
  #endif /* VL_H */
 Index: ioemu/vnc.c
 ===================================================================
---- ioemu.orig/vnc.c   2006-12-08 18:20:52.000000000 +0000
-+++ ioemu/vnc.c        2006-12-08 18:20:53.000000000 +0000
+--- ioemu.orig/vnc.c   2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vnc.c        2006-12-20 15:21:55.000000000 +0000
 @@ -44,6 +44,7 @@
  
  #include "vnc_keysym.h"
@@ -244,8 +244,8 @@ Index: ioemu/vnc.c
 +}
 Index: ioemu/xenstore.c
 ===================================================================
---- ioemu.orig/xenstore.c      2006-12-08 18:20:52.000000000 +0000
-+++ ioemu/xenstore.c   2006-12-08 18:20:53.000000000 +0000
+--- ioemu.orig/xenstore.c      2006-12-20 15:21:54.000000000 +0000
++++ ioemu/xenstore.c   2006-12-20 15:21:55.000000000 +0000
 @@ -213,3 +213,54 @@
      free(portstr);
      free(buf);
@@ -304,7 +304,7 @@ Index: ioemu/d3des.c
 Index: ioemu/d3des.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/d3des.c      2006-12-08 18:20:53.000000000 +0000
++++ ioemu/d3des.c      2006-12-20 15:21:55.000000000 +0000
 @@ -0,0 +1,434 @@
 +/*
 + * This is D3DES (V5.09) by Richard Outerbridge with the double and
@@ -743,7 +743,7 @@ Index: ioemu/d3des.h
 Index: ioemu/d3des.h
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/d3des.h      2006-12-08 18:20:53.000000000 +0000
++++ ioemu/d3des.h      2006-12-20 15:21:55.000000000 +0000
 @@ -0,0 +1,51 @@
 +/*
 + * This is D3DES (V5.09) by Richard Outerbridge with the double and
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/vnc-start-vncviewer
--- a/tools/ioemu/patches/vnc-start-vncviewer   Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/vnc-start-vncviewer   Wed Jan 10 08:40:47 2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/vnc.c
 Index: ioemu/vnc.c
 ===================================================================
---- ioemu.orig/vnc.c   2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vnc.c        2006-12-08 02:02:36.000000000 +0000
+--- ioemu.orig/vnc.c   2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vnc.c        2006-12-20 15:21:51.000000000 +0000
 @@ -1189,3 +1189,25 @@
  
      vnc_dpy_resize(vs->ds, 640, 400);
@@ -30,8 +30,8 @@ Index: ioemu/vnc.c
 +}
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:36.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:51.000000000 +0000
 @@ -120,6 +120,7 @@
  int bios_size;
  static DisplayState display_state;
@@ -82,7 +82,7 @@ Index: ioemu/vl.c
              }
          }
      }
-@@ -6461,6 +6469,8 @@
+@@ -6453,6 +6461,8 @@
          dumb_display_init(ds);
      } else if (vnc_display != -1) {
        vnc_display_init(ds, vnc_display);
@@ -93,8 +93,8 @@ Index: ioemu/vl.c
          sdl_display_init(ds, full_screen);
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:36.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:51.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:51.000000000 +0000
 @@ -786,6 +786,7 @@
  
  /* vnc.c */
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/xen-mapcache
--- a/tools/ioemu/patches/xen-mapcache  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/patches/xen-mapcache  Wed Jan 10 08:40:47 2007 -0700
@@ -15,22 +15,179 @@ Signed-off-by: Dexuan Cui <dexuan.cui@in
 Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>
 Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
 
-diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/target-i386-dm/cpu.h
---- a/tools/ioemu/target-i386-dm/cpu.h Thu Dec 07 10:54:43 2006 +0000
-+++ b/tools/ioemu/target-i386-dm/cpu.h Thu Dec 07 11:12:52 2006 +0000
-@@ -25,7 +25,8 @@
- #ifdef TARGET_X86_64
- #define TARGET_LONG_BITS 64
- #else
--#define TARGET_LONG_BITS 32
-+/* #define TARGET_LONG_BITS 32 */
-+#define TARGET_LONG_BITS 64 /* for Qemu map cache */
- #endif
- 
- /* target supports implicit self modifying code */
-diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/target-i386-dm/exec-dm.c
---- a/tools/ioemu/target-i386-dm/exec-dm.c     Thu Dec 07 10:54:43 2006 +0000
-+++ b/tools/ioemu/target-i386-dm/exec-dm.c     Thu Dec 07 11:12:52 2006 +0000
+Index: ioemu/vl.c
+===================================================================
+--- ioemu.orig/vl.c    2006-12-20 15:21:55.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:56.000000000 +0000
+@@ -5808,6 +5808,91 @@
+     return 0;
+ }
+ 
++#if defined(__i386__) || defined(__x86_64__)
++static struct map_cache *mapcache_entry;
++static unsigned long nr_buckets;
++
++static int qemu_map_cache_init(unsigned long nr_pages)
++{
++    unsigned long max_pages = MAX_MCACHE_SIZE >> PAGE_SHIFT;
++    int i;
++
++    if (nr_pages < max_pages)
++        max_pages = nr_pages;
++
++    nr_buckets   = max_pages + (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 
1;
++    nr_buckets >>= (MCACHE_BUCKET_SHIFT - PAGE_SHIFT);
++    fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
++
++    mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
++    if (mapcache_entry == NULL) {
++        errno = ENOMEM;
++        return -1;
++    }
++
++    memset(mapcache_entry, 0, nr_buckets * sizeof(struct map_cache));
++
++    /*
++     * To avoid ENOMEM from xc_map_foreign_batch() at runtime, we
++     * pre-fill all the map caches in advance.
++     */
++    for (i = 0; i < nr_buckets; i++)
++       (void)qemu_map_cache(((target_phys_addr_t)i) << MCACHE_BUCKET_SHIFT);
++
++    return 0;
++}
++
++uint8_t *qemu_map_cache(target_phys_addr_t phys_addr)
++{
++    struct map_cache *entry;
++    unsigned long address_index  = phys_addr >> MCACHE_BUCKET_SHIFT;
++    unsigned long address_offset = phys_addr & (MCACHE_BUCKET_SIZE-1);
++
++    /* For most cases (>99.9%), the page address is the same. */
++    static unsigned long last_address_index = ~0UL;
++    static uint8_t      *last_address_vaddr;
++
++    if (address_index == last_address_index)
++        return last_address_vaddr + address_offset;
++
++    entry = &mapcache_entry[address_index % nr_buckets];
++
++    if (entry->vaddr_base == NULL || entry->paddr_index != address_index) {
++        /* We need to remap a bucket. */
++        uint8_t *vaddr_base;
++        unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];
++        unsigned int i;
++
++        if (entry->vaddr_base != NULL) {
++            errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
++            if (errno) {
++                fprintf(logfile, "unmap fails %d\n", errno);
++                exit(-1);
++            }
++        }
++
++        for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i++)
++            pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-PAGE_SHIFT)) + i;
++
++        vaddr_base = xc_map_foreign_batch(
++            xc_handle, domid, PROT_READ|PROT_WRITE,
++            pfns, MCACHE_BUCKET_SIZE >> PAGE_SHIFT);
++        if (vaddr_base == NULL) {
++            fprintf(logfile, "xc_map_foreign_batch error %d\n", errno);
++            exit(-1);
++        }
++
++        entry->vaddr_base  = vaddr_base;
++        entry->paddr_index = address_index;;
++    }
++
++    last_address_index = address_index;
++    last_address_vaddr = entry->vaddr_base;
++
++    return last_address_vaddr + address_offset;
++}
++#endif
++
+ int main(int argc, char **argv)
+ {
+ #ifdef CONFIG_GDBSTUB
+@@ -6130,6 +6215,7 @@
+                 break;
+             case QEMU_OPTION_m:
+                 ram_size = atol(optarg) * 1024 * 1024;
++                ram_size = (uint64_t)atol(optarg) * 1024 * 1024;
+                 if (ram_size <= 0)
+                     help();
+ #ifndef CONFIG_DM
+@@ -6404,50 +6490,41 @@
+         shared_page_nr = nr_pages - 1;
+ #endif
+ 
+-    page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
+-    if (page_array == NULL) {
+-        fprintf(logfile, "malloc returned error %d\n", errno);
+-        exit(-1);
+-    }
+-
+ #if defined(__i386__) || defined(__x86_64__)
+-    for ( i = 0; i < tmp_nr_pages; i++)
+-        page_array[i] = i;
+ 
+-    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
+-                                         PROT_READ|PROT_WRITE, page_array,
+-                                         tmp_nr_pages);
+-    if (phys_ram_base == NULL) {
+-        fprintf(logfile, "batch map guest memory returned error %d\n", errno);
++    if ( qemu_map_cache_init(tmp_nr_pages) )
++    {
++        fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
+         exit(-1);
+     }
+ 
+     shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+-                                       PROT_READ|PROT_WRITE,
+-                                       page_array[shared_page_nr]);
++                                       PROT_READ|PROT_WRITE, shared_page_nr);
+     if (shared_page == NULL) {
+         fprintf(logfile, "map shared IO page returned error %d\n", errno);
+         exit(-1);
+     }
+ 
+-    fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n",
+-            shared_page_nr, (uint64_t)(page_array[shared_page_nr]));
++    fprintf(logfile, "shared page at pfn:%lx\n", shared_page_nr);
+ 
+     buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                             PROT_READ|PROT_WRITE,
+-                                            page_array[shared_page_nr - 2]);
++                                            shared_page_nr - 2);
+     if (buffered_io_page == NULL) {
+         fprintf(logfile, "map buffered IO page returned error %d\n", errno);
+         exit(-1);
+     }
+ 
+-    fprintf(logfile, "buffered io page at pfn:%lx, mfn: %"PRIx64"\n",
+-            shared_page_nr - 2, (uint64_t)(page_array[shared_page_nr - 2]));
+-
+-    free(page_array);
++    fprintf(logfile, "buffered io page at pfn:%lx\n", shared_page_nr - 2);
+ 
+ #elif defined(__ia64__)
+-  
++
++    page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
++    if (page_array == NULL) {
++        fprintf(logfile, "malloc returned error %d\n", errno);
++        exit(-1);
++    }
++
+     shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                        PROT_READ|PROT_WRITE,
+                                        IO_PAGE_START >> PAGE_SHIFT);
+Index: ioemu/target-i386-dm/exec-dm.c
+===================================================================
+--- ioemu.orig/target-i386-dm/exec-dm.c        2006-12-20 15:21:42.000000000 
+0000
++++ ioemu/target-i386-dm/exec-dm.c     2006-12-21 11:32:29.000000000 +0000
 @@ -36,6 +36,7 @@
  
  #include "cpu.h"
@@ -39,7 +196,52 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  
  //#define DEBUG_TB_INVALIDATE
  //#define DEBUG_FLUSH
-@@ -426,6 +427,12 @@ static inline int paddr_is_ram(target_ph
+@@ -127,10 +128,29 @@
+ FILE *logfile;
+ int loglevel;
+ 
++
++#if defined(__i386__) || defined(__x86_64__)
++#define MAPCACHE
++#endif
++
++#ifdef MAPCACHE
++#include <pthread.h>
++static pthread_mutex_t mapcache_mutex;
++#define mapcache_lock() pthread_mutex_lock(&mapcache_mutex)
++#define mapcache_unlock() pthread_mutex_unlock(&mapcache_mutex)
++#else 
++#define mapcache_lock() ( (void)0 )
++#define mapcache_unlock() ( (void)0 )
++#endif
++
++
+ void cpu_exec_init(CPUState *env)
+ {
+     CPUState **penv;
+     int cpu_index;
++#ifdef MAPCACHE
++    pthread_mutexattr_t mxattr; 
++#endif
+ 
+     env->next_cpu = NULL;
+     penv = &first_cpu;
+@@ -144,6 +164,14 @@
+ 
+     /* alloc dirty bits array */
+     phys_ram_dirty = qemu_malloc(phys_ram_size >> TARGET_PAGE_BITS);
++
++#ifdef MAPCACHE
++    /* setup memory access mutex to protect mapcache */
++    pthread_mutexattr_init(&mxattr); 
++    pthread_mutexattr_settype(&mxattr, PTHREAD_MUTEX_RECURSIVE);
++    pthread_mutex_init(&mapcache_mutex, &mxattr); 
++    pthread_mutexattr_destroy(&mxattr); 
++#endif
+ }
+ 
+ /* enable or disable low levels log */
+@@ -426,19 +454,27 @@
  #endif
  }
  
@@ -52,7 +254,15 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, 
                              int len, int is_write)
  {
-@@ -438,7 +445,7 @@ void cpu_physical_memory_rw(target_phys_
+     int l, io_index;
+     uint8_t *ptr;
+     uint32_t val;
+-    
++
++    mapcache_lock();
++
+     while (len > 0) {
+         /* How much can we copy before the next page boundary? */
          l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK); 
          if (l > len)
              l = len;
@@ -61,7 +271,7 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
          io_index = iomem_index(addr);
          if (is_write) {
              if (io_index) {
-@@ -460,9 +467,10 @@ void cpu_physical_memory_rw(target_phys_
+@@ -460,9 +496,10 @@
                  }
              } else if (paddr_is_ram(addr)) {
                  /* Reading from RAM */
@@ -74,7 +284,7 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  #endif 
              }
          } else {
-@@ -485,7 +493,8 @@ void cpu_physical_memory_rw(target_phys_
+@@ -485,7 +522,8 @@
                  }
              } else if (paddr_is_ram(addr)) {
                  /* Reading from RAM */
@@ -84,194 +294,20 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
              } else {
                  /* Neither RAM nor known MMIO space */
                  memset(buf, 0xff, len); 
-diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/vl.c
---- a/tools/ioemu/vl.c Thu Dec 07 10:54:43 2006 +0000
-+++ b/tools/ioemu/vl.c Thu Dec 07 11:12:52 2006 +0000
-@@ -5807,6 +5807,92 @@ int set_mm_mapping(int xc_handle, uint32
- 
-     return 0;
- }
-+
-+#if defined(__i386__) || defined(__x86_64__)
-+static struct map_cache *mapcache_entry;
-+static unsigned long nr_buckets;
-+
-+static int qemu_map_cache_init(unsigned long nr_pages)
-+{
-+    unsigned long max_pages = MAX_MCACHE_SIZE >> PAGE_SHIFT;
-+    int i;
-+
-+    if (nr_pages < max_pages)
-+        max_pages = nr_pages;
-+
-+    nr_buckets = (max_pages << PAGE_SHIFT) >> MCACHE_BUCKET_SHIFT;
-+
-+    fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
-+
-+    mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
-+    if (mapcache_entry == NULL) {
-+        errno = ENOMEM;
-+        return -1;
-+    }
-+
-+    memset(mapcache_entry, 0, nr_buckets * sizeof(struct map_cache));
-+
-+    /*
-+     * To avoid ENOMEM from xc_map_foreign_batch() at runtime, we
-+     * pre-fill all the map caches in advance.
-+     */
-+    for (i = 0; i < nr_buckets; i++)
-+       (void)qemu_map_cache(((target_phys_addr_t)i) << MCACHE_BUCKET_SHIFT);
-+
-+    return 0;
-+}
-+
-+uint8_t *qemu_map_cache(target_phys_addr_t phys_addr)
-+{
-+    struct map_cache *entry;
-+    unsigned long address_index  = phys_addr >> MCACHE_BUCKET_SHIFT;
-+    unsigned long address_offset = phys_addr & (MCACHE_BUCKET_SIZE-1);
-+
-+    /* For most cases (>99.9%), the page address is the same. */
-+    static unsigned long last_address_index = ~0UL;
-+    static uint8_t      *last_address_vaddr;
-+
-+    if (address_index == last_address_index)
-+        return last_address_vaddr + address_offset;
-+
-+    entry = &mapcache_entry[address_index % nr_buckets];
-+
-+    if (entry->vaddr_base == NULL || entry->paddr_index != address_index)
-+    { 
-+        /* We need to remap a bucket. */
-+        uint8_t *vaddr_base;
-+        unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];
-+        unsigned int i;
-+
-+        if (entry->vaddr_base != NULL) {
-+            errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
-+            if (errno) {
-+                fprintf(logfile, "unmap fails %d\n", errno);
-+                exit(-1);
-+            }
-+        }
-+
-+        for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i++)
-+            pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-PAGE_SHIFT)) + i;
-+
-+        vaddr_base = xc_map_foreign_batch(
-+            xc_handle, domid, PROT_READ|PROT_WRITE,
-+            pfns, MCACHE_BUCKET_SIZE >> PAGE_SHIFT);
-+        if (vaddr_base == NULL) {
-+            fprintf(logfile, "xc_map_foreign_batch error %d\n", errno);
-+            exit(-1);
-+        }
-+
-+        entry->vaddr_base  = vaddr_base;
-+        entry->paddr_index = address_index;;
-+    }
-+
-+    last_address_index = address_index;
-+    last_address_vaddr = entry->vaddr_base;
-+
-+    return last_address_vaddr + address_offset;
-+}
-+#endif
- 
- int main(int argc, char **argv)
- {
-@@ -6130,6 +6216,7 @@ int main(int argc, char **argv)
-                 break;
-             case QEMU_OPTION_m:
-                 ram_size = atol(optarg) * 1024 * 1024;
-+                ram_size = (uint64_t)atol(optarg) * 1024 * 1024;
-                 if (ram_size <= 0)
-                     help();
- #ifndef CONFIG_DM
-@@ -6400,50 +6487,41 @@ int main(int argc, char **argv)
-         shared_page_nr = nr_pages - 1;
- #endif
- 
-+#if defined(__i386__) || defined(__x86_64__)
-+
-+    if ( qemu_map_cache_init(tmp_nr_pages) )
-+    {
-+        fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
-+        exit(-1);
-+    }
-+
-+    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-+                                       PROT_READ|PROT_WRITE, shared_page_nr);
-+    if (shared_page == NULL) {
-+        fprintf(logfile, "map shared IO page returned error %d\n", errno);
-+        exit(-1);
-+    }
-+
-+    fprintf(logfile, "shared page at pfn:%lx\n", shared_page_nr);
-+
-+    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-+                                            PROT_READ|PROT_WRITE,
-+                                            shared_page_nr - 2);
-+    if (buffered_io_page == NULL) {
-+        fprintf(logfile, "map buffered IO page returned error %d\n", errno);
-+        exit(-1);
-+    }
-+
-+    fprintf(logfile, "buffered io page at pfn:%lx\n", shared_page_nr - 2);
-+
-+#elif defined(__ia64__)
-+
-     page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
-     if (page_array == NULL) {
-         fprintf(logfile, "malloc returned error %d\n", errno);
-         exit(-1);
-     }
- 
--#if defined(__i386__) || defined(__x86_64__)
--    for ( i = 0; i < tmp_nr_pages; i++)
--        page_array[i] = i;
--
--    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
--                                         PROT_READ|PROT_WRITE, page_array,
--                                         tmp_nr_pages);
--    if (phys_ram_base == NULL) {
--        fprintf(logfile, "batch map guest memory returned error %d\n", errno);
--        exit(-1);
--    }
--
--    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
--                                       PROT_READ|PROT_WRITE,
--                                       page_array[shared_page_nr]);
--    if (shared_page == NULL) {
--        fprintf(logfile, "map shared IO page returned error %d\n", errno);
--        exit(-1);
--    }
--
--    fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n",
--            shared_page_nr, (uint64_t)(page_array[shared_page_nr]));
--
--    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
--                                            PROT_READ|PROT_WRITE,
--                                            page_array[shared_page_nr - 2]);
--    if (buffered_io_page == NULL) {
--        fprintf(logfile, "map buffered IO page returned error %d\n", errno);
--        exit(-1);
--    }
--
--    fprintf(logfile, "buffered io page at pfn:%lx, mfn: %"PRIx64"\n",
--            shared_page_nr - 2, (uint64_t)(page_array[shared_page_nr - 2]));
--
--    free(page_array);
--
--#elif defined(__ia64__)
--  
-     if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
-                              IO_PAGE_START >> PAGE_SHIFT, 3) != 3) {
-         fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
-diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/vl.h
---- a/tools/ioemu/vl.h Thu Dec 07 10:54:43 2006 +0000
-+++ b/tools/ioemu/vl.h Thu Dec 07 11:12:52 2006 +0000
-@@ -156,6 +156,26 @@ extern void *shared_vram;
+@@ -495,6 +533,8 @@
+         buf += l;
+         addr += l;
+     }
++
++    mapcache_unlock();
+ }
+ #endif
+ 
+Index: ioemu/vl.h
+===================================================================
+--- ioemu.orig/vl.h    2006-12-20 15:21:55.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:56.000000000 +0000
+@@ -156,6 +156,26 @@
  
  extern FILE *logfile;
  
@@ -298,3 +334,17 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  extern int xc_handle;
  extern int domid;
  
+Index: ioemu/target-i386-dm/cpu.h
+===================================================================
+--- ioemu.orig/target-i386-dm/cpu.h    2006-12-20 15:21:45.000000000 +0000
++++ ioemu/target-i386-dm/cpu.h 2006-12-20 15:21:56.000000000 +0000
+@@ -25,7 +25,8 @@
+ #ifdef TARGET_X86_64
+ #define TARGET_LONG_BITS 64
+ #else
+-#define TARGET_LONG_BITS 32
++/* #define TARGET_LONG_BITS 32 */
++#define TARGET_LONG_BITS 64 /* for Qemu map cache */
+ #endif
+ 
+ /* target supports implicit self modifying code */
diff -r 42babffffba5 -r 58633caeece9 
tools/ioemu/patches/xen-support-buffered-ioreqs
--- a/tools/ioemu/patches/xen-support-buffered-ioreqs   Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/ioemu/patches/xen-support-buffered-ioreqs   Wed Jan 10 08:40:47 
2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/vl.c
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:54.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:54.000000000 +0000
 @@ -5838,6 +5838,7 @@
      unsigned long nr_pages, tmp_nr_pages, shared_page_nr;
      xen_pfn_t *page_array;
@@ -10,7 +10,7 @@ Index: ioemu/vl.c
  
      char qemu_dm_logfilename[64];
  
-@@ -6418,6 +6419,17 @@
+@@ -6422,6 +6423,17 @@
      fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n",
              shared_page_nr, (uint64_t)(page_array[shared_page_nr]));
  
@@ -30,8 +30,8 @@ Index: ioemu/vl.c
  #elif defined(__ia64__)
 Index: ioemu/target-i386-dm/helper2.c
 ===================================================================
---- ioemu.orig/target-i386-dm/helper2.c        2006-12-08 02:02:35.000000000 
+0000
-+++ ioemu/target-i386-dm/helper2.c     2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/target-i386-dm/helper2.c        2006-12-20 15:21:47.000000000 
+0000
++++ ioemu/target-i386-dm/helper2.c     2006-12-20 15:21:54.000000000 +0000
 @@ -76,6 +76,10 @@
  
  shared_iopage_t *shared_page = NULL;
diff -r 42babffffba5 -r 58633caeece9 
tools/ioemu/patches/xenstore-block-device-config
--- a/tools/ioemu/patches/xenstore-block-device-config  Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/ioemu/patches/xenstore-block-device-config  Wed Jan 10 08:40:47 
2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/Makefile.target
 Index: ioemu/Makefile.target
 ===================================================================
---- ioemu.orig/Makefile.target 2006-12-08 02:02:36.000000000 +0000
-+++ ioemu/Makefile.target      2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/Makefile.target 2006-12-20 15:21:51.000000000 +0000
++++ ioemu/Makefile.target      2006-12-20 15:21:53.000000000 +0000
 @@ -359,6 +359,7 @@
  VL_OBJS+= cirrus_vga.o mixeng.o parallel.o acpi.o piix_pci.o
  VL_OBJS+= usb-uhci.o
@@ -13,7 +13,7 @@ Index: ioemu/xenstore.c
 Index: ioemu/xenstore.c
 ===================================================================
 --- /dev/null  1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/xenstore.c   2006-12-08 02:02:37.000000000 +0000
++++ ioemu/xenstore.c   2006-12-20 15:21:53.000000000 +0000
 @@ -0,0 +1,187 @@
 +/*
 + * This file is subject to the terms and conditions of the GNU General
@@ -204,8 +204,8 @@ Index: ioemu/xenstore.c
 +}
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.c    2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:53.000000000 +0000
 @@ -5256,9 +5256,11 @@
             "Standard options:\n"
             "-M machine      select emulated machine (-M ? for list)\n"
@@ -359,7 +359,7 @@ Index: ioemu/vl.c
  
      setvbuf(stdout, NULL, _IOLBF, 0);
      
-@@ -6441,6 +6472,7 @@
+@@ -6433,6 +6464,7 @@
  
  #endif /* !CONFIG_DM */
  
@@ -367,7 +367,7 @@ Index: ioemu/vl.c
      /* we always create the cdrom drive, even if no disk is there */
      bdrv_init();
      if (cdrom_index >= 0) {
-@@ -6467,6 +6499,7 @@
+@@ -6459,6 +6491,7 @@
              }
          }
      }
@@ -375,7 +375,7 @@ Index: ioemu/vl.c
  
      /* we always create at least one floppy disk */
      fd_table[0] = bdrv_new("fda");
-@@ -6545,6 +6578,8 @@
+@@ -6537,6 +6570,8 @@
          }
      }
  
@@ -386,8 +386,8 @@ Index: ioemu/vl.c
                    kernel_filename, kernel_cmdline, initrd_filename,
 Index: ioemu/monitor.c
 ===================================================================
---- ioemu.orig/monitor.c       2006-12-08 02:02:35.000000000 +0000
-+++ ioemu/monitor.c    2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/monitor.c       2006-12-20 15:21:47.000000000 +0000
++++ ioemu/monitor.c    2006-12-20 15:21:53.000000000 +0000
 @@ -24,6 +24,7 @@
  #include "vl.h"
  #include "disas.h"
@@ -416,8 +416,8 @@ Index: ioemu/monitor.c
      int i;
 Index: ioemu/block.c
 ===================================================================
---- ioemu.orig/block.c 2006-12-08 02:02:06.000000000 +0000
-+++ ioemu/block.c      2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/block.c 2006-12-20 15:21:31.000000000 +0000
++++ ioemu/block.c      2006-12-20 15:21:53.000000000 +0000
 @@ -758,6 +758,7 @@
  static void raw_close(BlockDriverState *bs)
  {
@@ -428,8 +428,8 @@ Index: ioemu/block.c
  
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:52.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:53.000000000 +0000
 @@ -1191,6 +1191,8 @@
  void term_print_help(void);
  void monitor_readline(const char *prompt, int is_password,
@@ -455,8 +455,8 @@ Index: ioemu/vl.h
  extern char domain_name[];
 Index: ioemu/hw/ide.c
 ===================================================================
---- ioemu.orig/hw/ide.c        2006-12-08 02:02:35.000000000 +0000
-+++ ioemu/hw/ide.c     2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/hw/ide.c        2006-12-20 15:21:49.000000000 +0000
++++ ioemu/hw/ide.c     2006-12-20 15:21:53.000000000 +0000
 @@ -1158,6 +1158,7 @@
          } else {
              ide_atapi_cmd_error(s, SENSE_NOT_READY, 
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/patches/xenstore-write-vnc-port
--- a/tools/ioemu/patches/xenstore-write-vnc-port       Wed Jan 10 08:00:50 
2007 -0700
+++ b/tools/ioemu/patches/xenstore-write-vnc-port       Wed Jan 10 08:40:47 
2007 -0700
@@ -1,7 +1,7 @@ Index: ioemu/xenstore.c
 Index: ioemu/xenstore.c
 ===================================================================
---- ioemu.orig/xenstore.c      2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/xenstore.c   2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/xenstore.c      2006-12-20 15:21:53.000000000 +0000
++++ ioemu/xenstore.c   2006-12-20 15:21:54.000000000 +0000
 @@ -185,3 +185,31 @@
      free(image);
      free(vec);
@@ -36,9 +36,9 @@ Index: ioemu/xenstore.c
 +}
 Index: ioemu/vl.c
 ===================================================================
---- ioemu.orig/vl.c    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.c 2006-12-08 02:02:37.000000000 +0000
-@@ -6535,6 +6535,7 @@
+--- ioemu.orig/vl.c    2006-12-20 15:21:53.000000000 +0000
++++ ioemu/vl.c 2006-12-20 15:21:54.000000000 +0000
+@@ -6527,6 +6527,7 @@
        vnc_display = vnc_display_init(ds, vnc_display, vncunused, 
&vnclisten_addr);
        if (vncviewer)
            vnc_start_viewer(vnc_display);
@@ -48,8 +48,8 @@ Index: ioemu/vl.c
          sdl_display_init(ds, full_screen);
 Index: ioemu/vl.h
 ===================================================================
---- ioemu.orig/vl.h    2006-12-08 02:02:37.000000000 +0000
-+++ ioemu/vl.h 2006-12-08 02:02:37.000000000 +0000
+--- ioemu.orig/vl.h    2006-12-20 15:21:53.000000000 +0000
++++ ioemu/vl.h 2006-12-20 15:21:54.000000000 +0000
 @@ -1210,6 +1210,7 @@
  int xenstore_fd(void);
  void xenstore_process_event(void *opaque);
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/target-i386-dm/exec-dm.c      Wed Jan 10 08:40:47 2007 -0700
@@ -134,6 +134,7 @@ int loglevel;
 #endif
 
 #ifdef MAPCACHE
+#include <pthread.h>
 static pthread_mutex_t mapcache_mutex;
 #define mapcache_lock() pthread_mutex_lock(&mapcache_mutex)
 #define mapcache_unlock() pthread_mutex_unlock(&mapcache_mutex)
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/target-i386-dm/helper2.c
--- a/tools/ioemu/target-i386-dm/helper2.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/target-i386-dm/helper2.c      Wed Jan 10 08:40:47 2007 -0700
@@ -498,6 +498,8 @@ void handle_buffered_io(void *opaque)
 
 void cpu_handle_ioreq(void *opaque)
 {
+    extern int vm_running;
+    extern int shutdown_requested;
     CPUState *env = opaque;
     ioreq_t *req = cpu_get_ioreq();
 
@@ -516,6 +518,25 @@ void cpu_handle_ioreq(void *opaque)
         }
 
         wmb(); /* Update ioreq contents /then/ update state. */
+
+       /*
+         * We do this before we send the response so that the tools
+         * have the opportunity to pick up on the reset before the
+         * guest resumes and does a hlt with interrupts disabled which
+         * causes Xen to powerdown the domain.
+         */
+        if (vm_running) {
+            if (shutdown_requested) {
+               fprintf(logfile, "shutdown requested in cpu_handle_ioreq\n");
+               destroy_hvm_domain();
+           }
+           if (reset_requested) {
+               fprintf(logfile, "reset requested in cpu_handle_ioreq.\n");
+               qemu_system_reset();
+               reset_requested = 0;
+           }
+       }
+
         req->state = STATE_IORESP_READY;
         xc_evtchn_notify(xce_handle, ioreq_local_port[send_vcpu]);
     }
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/vl.c  Wed Jan 10 08:40:47 2007 -0700
@@ -6153,7 +6153,7 @@ int main(int argc, char **argv)
             case QEMU_OPTION_boot:
                 boot_device = strdup(optarg);
                 if (strspn(boot_device, "acd"
-#ifdef TARGET_SPARC
+#if defined(TARGET_SPARC) || defined(TARGET_I386)
                            "n"
 #endif
                         ) != strlen(boot_device)) {
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/vnc.c Wed Jan 10 08:40:47 2007 -0700
@@ -54,12 +54,12 @@ typedef struct Buffer
 {
     size_t capacity;
     size_t offset;
-    char *buffer;
+    uint8_t *buffer;
 } Buffer;
 
 typedef struct VncState VncState;
 
-typedef int VncReadEvent(VncState *vs, char *data, size_t len);
+typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len);
 
 typedef void VncWritePixels(VncState *vs, void *data, int size);
 
@@ -90,7 +90,7 @@ struct VncState
     uint64_t *update_row;      /* outstanding updates */
     int has_update;            /* there's outstanding updates in the
                                 * visible area */
-    char *old_data;
+    uint8_t *old_data;
     int depth; /* internal VNC frame buffer byte per pixel */
     int has_resize;
     int has_hextile;
@@ -140,7 +140,7 @@ static void vnc_update_client(void *opaq
 static void vnc_update_client(void *opaque);
 static void vnc_client_read(void *opaque);
 static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h);
-static int make_challenge(char *random, int size);
+static int make_challenge(unsigned char *random, int size);
 static void set_seed(unsigned int *seedp);
 static void get_random(int len, unsigned char *buf);
 
@@ -330,7 +330,7 @@ static void send_framebuffer_update_raw(
 static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int 
h)
 {
     int i;
-    char *row;
+    uint8_t *row;
 
     vnc_framebuffer_update(vs, x, y, w, h, 0);
 
@@ -394,9 +394,9 @@ static void vnc_copy(DisplayState *ds, i
 static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int 
dst_y, int w, int h)
 {
     int src, dst;
-    char *src_row;
-    char *dst_row;
-    char *old_row;
+    uint8_t *src_row;
+    uint8_t *dst_row;
+    uint8_t *old_row;
     int y = 0;
     int pitch = ds->linesize;
     VncState *vs = ds->opaque;
@@ -465,8 +465,8 @@ static void _vnc_update_client(void *opa
     VncState *vs = opaque;
     int64_t now;
     int y;
-    char *row;
-    char *old_row;
+    uint8_t *row;
+    uint8_t *old_row;
     uint64_t width_mask;
     int n_rectangles;
     int saved_offset;
@@ -491,7 +491,7 @@ static void _vnc_update_client(void *opa
     for (y = 0; y < vs->ds->height; y++) {
        if (vs->dirty_row[y] & width_mask) {
            int x;
-           char *ptr, *old_ptr;
+           uint8_t *ptr, *old_ptr;
 
            ptr = row;
            old_ptr = old_row;
@@ -654,7 +654,7 @@ static int buffer_empty(Buffer *buffer)
     return buffer->offset == 0;
 }
 
-static char *buffer_end(Buffer *buffer)
+static uint8_t *buffer_end(Buffer *buffer)
 {
     return buffer->buffer + buffer->offset;
 }
@@ -778,7 +778,7 @@ static void vnc_write_u32(VncState *vs, 
 
 static void vnc_write_u16(VncState *vs, uint16_t value)
 {
-    char buf[2];
+    uint8_t buf[2];
 
     buf[0] = (value >> 8) & 0xFF;
     buf[1] = value & 0xFF;
@@ -788,7 +788,7 @@ static void vnc_write_u16(VncState *vs, 
 
 static void vnc_write_u8(VncState *vs, uint8_t value)
 {
-    vnc_write(vs, (char *)&value, 1);
+    vnc_write(vs, &value, 1);
 }
 
 static void vnc_flush(VncState *vs)
@@ -797,23 +797,23 @@ static void vnc_flush(VncState *vs)
        vnc_client_write(vs);
 }
 
-static uint8_t read_u8(char *data, size_t offset)
+static uint8_t read_u8(uint8_t *data, size_t offset)
 {
     return data[offset];
 }
 
-static uint16_t read_u16(char *data, size_t offset)
+static uint16_t read_u16(uint8_t *data, size_t offset)
 {
     return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
 }
 
-static int32_t read_s32(char *data, size_t offset)
+static int32_t read_s32(uint8_t *data, size_t offset)
 {
     return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
                     (data[offset + 2] << 8) | data[offset + 3]);
 }
 
-static uint32_t read_u32(char *data, size_t offset)
+static uint32_t read_u32(uint8_t *data, size_t offset)
 {
     return ((data[offset] << 24) | (data[offset + 1] << 16) |
            (data[offset + 2] << 8) | data[offset + 3]);
@@ -1115,11 +1115,10 @@ static void set_pixel_format(VncState *v
     vga_hw_update();
 }
 
-static int protocol_client_msg(VncState *vs, char *data, size_t len)
+static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
 {
     int i;
     uint16_t limit;
-    int64_t now;
 
     switch (data[0]) {
     case 0:
@@ -1188,7 +1187,7 @@ static int protocol_client_msg(VncState 
                return 8 + v;
        }
 
-       client_cut_text(vs, read_u32(data, 4), data + 8);
+       client_cut_text(vs, read_u32(data, 4), (char *)(data + 8));
        break;
     default:
        printf("Msg: %d\n", data[0]);
@@ -1200,7 +1199,7 @@ static int protocol_client_msg(VncState 
     return 0;
 }
 
-static int protocol_client_init(VncState *vs, char *data, size_t len)
+static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
 {
     size_t l;
     char pad[3] = { 0, 0, 0 };
@@ -1261,7 +1260,7 @@ static int protocol_client_init(VncState
     return 0;
 }
 
-static int protocol_response(VncState *vs, char *client_response, size_t len)
+static int protocol_response(VncState *vs, uint8_t *client_response, size_t 
len)
 {
     extern char vncpasswd[64];
     extern unsigned char challenge[AUTHCHALLENGESIZE];
@@ -1299,7 +1298,7 @@ static int protocol_response(VncState *v
     return 0;
 }
 
-static int protocol_version(VncState *vs, char *version, size_t len)
+static int protocol_version(VncState *vs, uint8_t *version, size_t len)
 {
     extern char vncpasswd[64];
     extern unsigned char challenge[AUTHCHALLENGESIZE];
@@ -1318,7 +1317,7 @@ static int protocol_version(VncState *vs
 
 
     support = 0;
-    if (maj = 3) {
+    if (maj == 3) {
        if (min == 3 || min ==4) {
            support = 1;
        }
@@ -1468,7 +1467,7 @@ int vnc_start_viewer(int port)
 
 unsigned int seed;
 
-static int make_challenge(char *random, int size)
+static int make_challenge(unsigned char *random, int size)
 {
  
     set_seed(&seed);
diff -r 42babffffba5 -r 58633caeece9 tools/ioemu/vnchextile.h
--- a/tools/ioemu/vnchextile.h  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/ioemu/vnchextile.h  Wed Jan 10 08:40:47 2007 -0700
@@ -13,7 +13,7 @@ static void CONCAT(send_hextile_tile_, N
                                              uint32_t *last_fg32,
                                              int *has_bg, int *has_fg)
 {
-    char *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
+    uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
     pixel_t *irow = (pixel_t *)row;
     int j, i;
     pixel_t *last_bg = (pixel_t *)last_bg32;
@@ -119,7 +119,7 @@ static void CONCAT(send_hextile_tile_, N
        for (j = 0; j < h; j++) {
            int has_color = 0;
            int min_x = -1;
-           pixel_t color;
+           pixel_t color = 0;
 
            for (i = 0; i < w; i++) {
                if (!has_color) {
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xc_hvm_build.c        Wed Jan 10 08:40:47 2007 -0700
@@ -233,8 +233,7 @@ static int setup_guest(int xc_handle,
              SCRATCH_PFN)) == NULL) )
         goto error_out;
     memset(shared_info, 0, PAGE_SIZE);
-    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
-        shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
+    /* NB. evtchn_upcall_mask is unused: leave as zero. */
     memset(&shared_info->evtchn_mask[0], 0xff,
            sizeof(shared_info->evtchn_mask));
     munmap(shared_info, PAGE_SIZE);
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xc_linux_build.c      Wed Jan 10 08:40:47 2007 -0700
@@ -595,6 +595,7 @@ static int compat_check(int xc_handle, s
         return 0;
     }
 
+#ifndef __x86_64__//temp
     if (strstr(xen_caps, "xen-3.0-x86_32p")) {
         if (dsi->pae_kernel == PAEKERN_bimodal) {
             dsi->pae_kernel = PAEKERN_extended_cr3;
@@ -612,6 +613,7 @@ static int compat_check(int xc_handle, s
             return 0;
         }
     }
+#endif
 
     return 1;
 }
@@ -1079,7 +1081,7 @@ static int xc_linux_build_internal(int x
 static int xc_linux_build_internal(int xc_handle,
                                    uint32_t domid,
                                    unsigned int mem_mb,
-                                   char *image,
+                                   const char *image,
                                    unsigned long image_size,
                                    struct initrd_info *initrd,
                                    const char *cmdline,
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xc_linux_restore.c    Wed Jan 10 08:40:47 2007 -0700
@@ -709,7 +709,7 @@ int xc_linux_restore(int xc_handle, int 
         goto out;
     }
 
-    for (i = 0; i < ctxt.gdt_ents; i += 512) {
+    for (i = 0; (512*i) < ctxt.gdt_ents; i++) {
         pfn = ctxt.gdt_frames[i];
         if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
             ERROR("GDT frame number is bad");
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c       Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xc_linux_save.c       Wed Jan 10 08:40:47 2007 -0700
@@ -44,6 +44,7 @@ static xen_pfn_t *live_p2m = NULL;
 
 /* Live mapping of system MFN to PFN table. */
 static xen_pfn_t *live_m2p = NULL;
+static unsigned long m2p_mfn0;
 
 /* grep fodder: machine_to_phys */
 
@@ -80,7 +81,7 @@ static xen_pfn_t *live_m2p = NULL;
 #define BITMAP_SIZE   ((max_pfn + BITS_PER_LONG - 1) / 8)
 
 #define BITMAP_ENTRY(_nr,_bmap) \
-   ((unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]
+   ((volatile unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]
 
 #define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
 
@@ -112,7 +113,7 @@ static inline int count_bits ( int nr, v
 static inline int count_bits ( int nr, volatile void *addr)
 {
     int i, count = 0;
-    unsigned long *p = (unsigned long *)addr;
+    volatile unsigned long *p = (volatile unsigned long *)addr;
     /* We know that the array is padded to unsigned long. */
     for( i = 0; i < (nr / (sizeof(unsigned long)*8)); i++, p++ )
         count += hweight32(*p);
@@ -440,13 +441,23 @@ static int canonicalize_pagetable(unsign
     ** that this check will fail for other L2s.
     */
     if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L2TAB) {
-
-/* XXX index of the L2 entry in PAE mode which holds the guest LPT */
-#define PAE_GLPT_L2ENTRY (495)
-        pte = ((uint64_t*)spage)[PAE_GLPT_L2ENTRY];
-
-        if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn])
-            xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
+        int hstart;
+        unsigned long he;
+
+        hstart = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
+        he = ((const uint64_t *) spage)[hstart];
+
+        if ( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 ) {
+            /* hvirt starts with xen stuff... */
+            xen_start = hstart;
+        } else if ( hvirt_start != 0xf5800000 ) {
+            /* old L2s from before hole was shrunk... */
+            hstart = (0xf5800000 >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
+            he = ((const uint64_t *) spage)[hstart];
+
+            if( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 )
+                xen_start = hstart;
+        }
     }
 
     if (pt_levels == 4 && type == XEN_DOMCTL_PFINFO_L4TAB) {
@@ -464,9 +475,9 @@ static int canonicalize_pagetable(unsign
         unsigned long pfn, mfn;
 
         if (pt_levels == 2)
-            pte = ((uint32_t*)spage)[i];
+            pte = ((const uint32_t*)spage)[i];
         else
-            pte = ((uint64_t*)spage)[i];
+            pte = ((const uint64_t*)spage)[i];
 
         if (i >= xen_start && i < xen_end)
             pte = 0;
@@ -549,6 +560,8 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
         ERROR("xc_mmap_foreign_ranges failed (rc = %d)", rc);
         return NULL;
     }
+
+    m2p_mfn0 = entries[0].mfn;
 
     free(extent_start);
     free(entries);
@@ -915,14 +928,14 @@ int xc_linux_save(int xc_handle, int io_
 
                 if(!is_mapped(pfn_type[batch])) {
 
-                    /* not currently in pusedo-physical map -- set bit
-                       in to_fix that we must send this page in last_iter
-                       unless its sent sooner anyhow */
+                    /*
+                    ** not currently in psuedo-physical map -- set bit
+                    ** in to_fix since we must send this page in last_iter
+                    ** unless its sent sooner anyhow, or it never enters
+                    ** pseudo-physical map (e.g. for ballooned down domains)
+                    */
 
                     set_bit(n, to_fix);
-                    if( (iter > 1) && IS_REAL_PFN(n) )
-                        DPRINTF("netbuf race: iter %d, pfn %x. mfn %lx\n",
-                                iter, n, pfn_type[batch]);
                     continue;
                 }
 
@@ -1052,7 +1065,7 @@ int xc_linux_save(int xc_handle, int io_
             DPRINTF("(of which %ld were fixups)\n", needed_to_fix  );
         }
 
-        if (last_iter && debug){
+        if (last_iter && debug) {
             int minusone = -1;
             memset(to_send, 0xff, BITMAP_SIZE);
             debug = 0;
@@ -1068,17 +1081,14 @@ int xc_linux_save(int xc_handle, int io_
             continue;
         }
 
-        if (last_iter) break;
+        if (last_iter)
+            break;
 
         if (live) {
-
-
-            if(
-                ((sent_this_iter > sent_last_iter) && RATE_IS_MAX()) ||
+            if (((sent_this_iter > sent_last_iter) && RATE_IS_MAX()) ||
                 (iter >= max_iters) ||
                 (sent_this_iter+skip_this_iter < 50) ||
-                (total_sent > max_pfn*max_factor) ) {
-
+                (total_sent > max_pfn*max_factor)) {
                 DPRINTF("Start last iteration\n");
                 last_iter = 1;
 
@@ -1106,8 +1116,6 @@ int xc_linux_save(int xc_handle, int io_
             print_stats(xc_handle, dom, sent_this_iter, &stats, 1);
 
         }
-
-
     } /* end of while 1 */
 
     DPRINTF("All memory is saved\n");
@@ -1159,7 +1167,7 @@ int xc_linux_save(int xc_handle, int io_
     }
 
     /* Canonicalise each GDT frame number. */
-    for ( i = 0; i < ctxt.gdt_ents; i += 512 ) {
+    for ( i = 0; (512*i) < ctxt.gdt_ents; i++ ) {
         if ( !translate_mfn_to_pfn(&ctxt.gdt_frames[i]) ) {
             ERROR("GDT frame is not in range of pseudophys map");
             goto out;
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xc_load_bin.c
--- a/tools/libxc/xc_load_bin.c Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xc_load_bin.c Wed Jan 10 08:40:47 2007 -0700
@@ -98,7 +98,7 @@ struct xen_bin_image_table
 #define FLAGS_MASK     ((~ 0) & (~ XEN_REACTOS_FLAG_ALIGN4K))
 #define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID
 
-static struct xen_bin_image_table *
+static const struct xen_bin_image_table *
 findtable(const char *image, unsigned long image_size);
 static int
 parsebinimage(
@@ -122,11 +122,11 @@ int probe_bin(const char *image,
     return 0;
 }
 
-static struct xen_bin_image_table *
+static const struct xen_bin_image_table *
 findtable(const char *image, unsigned long image_size)
 {
-    struct xen_bin_image_table *table;
-    unsigned long *probe_ptr;
+    const struct xen_bin_image_table *table;
+    const unsigned long *probe_ptr;
     unsigned probe_index;
     unsigned probe_count;
 
@@ -142,13 +142,13 @@ findtable(const char *image, unsigned lo
                   sizeof(unsigned long);
 
     /* Search for the magic header */
-    probe_ptr = (unsigned long *) image;
+    probe_ptr = (const unsigned long *) image;
     table = NULL;
     for ( probe_index = 0; probe_index < probe_count; probe_index++ )
     {
         if ( XEN_REACTOS_MAGIC3 == *probe_ptr )
         {
-            table = (struct xen_bin_image_table *) probe_ptr;
+            table = (const struct xen_bin_image_table *) probe_ptr;
             /* Checksum correct? */
             if ( 0 == table->magic + table->flags + table->checksum )
             {
@@ -165,7 +165,7 @@ static int parsebinimage(const char *ima
                          unsigned long image_size,
                          struct domain_setup_info *dsi)
 {
-    struct xen_bin_image_table *image_info;
+    const struct xen_bin_image_table *image_info;
     unsigned long start_addr;
     unsigned long end_addr;
 
@@ -186,13 +186,13 @@ static int parsebinimage(const char *ima
 
     /* Sanity check on the addresses */
     if ( image_info->header_addr < image_info->load_addr ||
-         ((char *) image_info - image) <
+         ((const char *) image_info - image) <
          (image_info->header_addr - image_info->load_addr) )
     {
         ERROR("Invalid header_addr.");
         return -EINVAL;
     }
-    start_addr = image_info->header_addr - ((char *) image_info - image);
+    start_addr = image_info->header_addr - ((const char *) image_info - image);
     if ( 0 != image_info->load_end_addr &&
          ( image_info->load_end_addr < image_info->load_end_addr ||
            start_addr + image_size < image_info->load_end_addr ) )
@@ -221,7 +221,7 @@ static int parsebinimage(const char *ima
     else
     {
         dsi->v_end = image_info->load_addr + image_size -
-                     (((char *) image_info - image) -
+                     (((const char *) image_info - image) -
                       (image_info->header_addr - image_info->load_addr));
     }
     dsi->v_kernstart = dsi->v_start;
@@ -240,7 +240,7 @@ loadbinimage(
     unsigned long size;
     char         *va;
     unsigned long done, chunksz;
-    struct xen_bin_image_table *image_info;
+    const struct xen_bin_image_table *image_info;
 
     image_info = findtable(image, image_size);
     if ( NULL == image_info )
@@ -252,7 +252,7 @@ loadbinimage(
     /* Determine image size */
     if ( 0 == image_info->load_end_addr )
     {
-        size = image_size  - (((char *) image_info - image) -
+        size = image_size  - (((const char *)image_info - image) -
                               (image_info->header_addr -
                                image_info->load_addr));
     }
@@ -262,7 +262,7 @@ loadbinimage(
     }
 
     /* It's possible that we need to skip the first part of the image */
-    image += ((char *)image_info - image) -
+    image += ((const char *)image_info - image) -
              (image_info->header_addr - image_info->load_addr);
 
     for ( done = 0; done < size; done += chunksz )
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xc_load_elf.c Wed Jan 10 08:40:47 2007 -0700
@@ -75,7 +75,7 @@ int probe_elf(const char *image,
               unsigned long image_size,
               struct load_funcs *load_funcs)
 {
-    Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
+    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
 
     if ( !IS_ELF(*ehdr) )
         return -EINVAL;
@@ -86,7 +86,7 @@ int probe_elf(const char *image,
     return 0;
 }
 
-static inline int is_loadable_phdr(Elf_Phdr *phdr)
+static inline int is_loadable_phdr(const Elf_Phdr *phdr)
 {
     return ((phdr->p_type == PT_LOAD) &&
             ((phdr->p_flags & (PF_W|PF_X)) != 0));
@@ -96,12 +96,13 @@ static inline int is_loadable_phdr(Elf_P
  * Fallback for kernels containing only the legacy __xen_guest string
  * and no ELF notes.
  */
-static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab)
+static int is_xen_guest_section(const Elf_Shdr *shdr, const char *shstrtab)
 {
     return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0;
 }
 
-static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type)
+static const char *xen_guest_lookup(
+    const struct domain_setup_info *dsi, int type)
 {
     const char *xenguest_fallbacks[] = {
         [XEN_ELFNOTE_ENTRY] = "VIRT_ENTRY=",
@@ -134,7 +135,8 @@ static const char *xen_guest_lookup(stru
     return p + strlen(fallback);
 }
 
-static const char *xen_guest_string(struct domain_setup_info *dsi, int type)
+static const char *xen_guest_string(
+    const struct domain_setup_info *dsi, int type)
 {
     const char *p = xen_guest_lookup(dsi, type);
 
@@ -148,8 +150,8 @@ static const char *xen_guest_string(stru
     return p;
 }
 
-static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
-                                                   int type, int *defined)
+static unsigned long long xen_guest_numeric(
+    const struct domain_setup_info *dsi, int type, int *defined)
 {
     const char *p = xen_guest_lookup(dsi, type);
     unsigned long long value;
@@ -175,19 +177,19 @@ static unsigned long long xen_guest_nume
 /*
  * Interface to the Xen ELF notes.
  */
-#define ELFNOTE_NAME(_n_)   ((void*)(_n_) + sizeof(*(_n_)))
+#define ELFNOTE_NAME(_n_)   ((const void*)(_n_) + sizeof(*(_n_)))
 #define ELFNOTE_DESC(_n_)   (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
 #define ELFNOTE_NEXT(_n_)   (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
 
-static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
-{
-    Elf_Note *note;
+static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr)
+{
+    const Elf_Note *note;
 
     if ( shdr->sh_type != SHT_NOTE )
         return 0;
 
-    for ( note = (Elf_Note *)(image + shdr->sh_offset);
-          note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
+    for ( note = (const Elf_Note *)(image + shdr->sh_offset);
+          note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
           note = ELFNOTE_NEXT(note) )
     {
         if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) )
@@ -197,15 +199,16 @@ static int is_xen_elfnote_section(const 
     return 0;
 }
 
-static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
-{
-    Elf_Note *note;
+static const Elf_Note *xen_elfnote_lookup(
+    const struct domain_setup_info *dsi, int type)
+{
+    const Elf_Note *note;
 
     if ( !dsi->__elfnote_section )
         return NULL;
 
-    for ( note = (Elf_Note *)dsi->__elfnote_section;
-          note < (Elf_Note *)dsi->__elfnote_section_end;
+    for ( note = (const Elf_Note *)dsi->__elfnote_section;
+          note < (const Elf_Note *)dsi->__elfnote_section_end;
           note = ELFNOTE_NEXT(note) )
     {
         if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) )
@@ -218,9 +221,9 @@ static Elf_Note *xen_elfnote_lookup(stru
     return NULL;
 }
 
-const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
-{
-    Elf_Note *note;
+const char *xen_elfnote_string(const struct domain_setup_info *dsi, int type)
+{
+    const Elf_Note *note;
 
     if ( !dsi->__elfnote_section )
         return xen_guest_string(dsi, type);
@@ -232,10 +235,10 @@ const char *xen_elfnote_string(struct do
     return (const char *)ELFNOTE_DESC(note);
 }
 
-unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
+unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi,
                                        int type, int *defined)
 {
-    Elf_Note *note;
+    const Elf_Note *note;
 
     *defined = 0;
 
@@ -252,10 +255,10 @@ unsigned long long xen_elfnote_numeric(s
     {
     case 4:
         *defined = 1;
-        return *(uint32_t*)ELFNOTE_DESC(note);
+        return *(const uint32_t*)ELFNOTE_DESC(note);
     case 8:
         *defined = 1;
-        return *(uint64_t*)ELFNOTE_DESC(note);
+        return *(const uint64_t*)ELFNOTE_DESC(note);
     default:
         xc_set_error(XC_INVALID_KERNEL,
                      "elfnotes: unknown data size %#x for numeric type note 
%#x\n",
@@ -268,9 +271,9 @@ static int parseelfimage(const char *ima
                          unsigned long image_len,
                          struct domain_setup_info *dsi)
 {
-    Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
-    Elf_Phdr *phdr;
-    Elf_Shdr *shdr;
+    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
+    const Elf_Phdr *phdr;
+    const Elf_Shdr *shdr;
     Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry;
     const char *shstrtab, *p;
     int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined;
@@ -331,12 +334,13 @@ static int parseelfimage(const char *ima
     /* Look for .notes segment containing at least one Xen note */
     for ( h = 0; h < ehdr->e_shnum; h++ )
     {
-        shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
+        shdr = (const Elf_Shdr *)(
+            image + ehdr->e_shoff + (h*ehdr->e_shentsize));
         if ( !is_xen_elfnote_section(image, shdr) )
             continue;
-        dsi->__elfnote_section = (void *)image + shdr->sh_offset;
+        dsi->__elfnote_section = (const void *)image + shdr->sh_offset;
         dsi->__elfnote_section_end =
-            (void *)image + shdr->sh_offset + shdr->sh_size;
+            (const void *)image + shdr->sh_offset + shdr->sh_size;
         break;
     }
 
@@ -350,16 +354,18 @@ static int parseelfimage(const char *ima
                          "ELF image has no section-header strings table.");
             return -EINVAL;
         }
-        shdr = (Elf_Shdr *)(image + ehdr->e_shoff +
+        shdr = (const Elf_Shdr *)(image + ehdr->e_shoff +
                             (ehdr->e_shstrndx*ehdr->e_shentsize));
         shstrtab = image + shdr->sh_offset;
 
         for ( h = 0; h < ehdr->e_shnum; h++ )
         {
-            shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
+            shdr = (const Elf_Shdr *)(
+                image + ehdr->e_shoff + (h*ehdr->e_shentsize));
             if ( is_xen_guest_section(shdr, shstrtab) )
             {
-                dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
+                dsi->__xen_guest_string =
+                    (const char *)image + shdr->sh_offset;
                 break;
             }
         }
@@ -442,8 +448,8 @@ static int parseelfimage(const char *ima
      * If we are using the modern ELF notes interface then the default
      * is 0.
      */
-    dsi->elf_paddr_offset =
-        xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET, 
&elf_pa_off_defined);
+    dsi->elf_paddr_offset = xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET,
+                                                &elf_pa_off_defined);
     if ( !elf_pa_off_defined )
     {
         if ( dsi->__elfnote_section )
@@ -462,7 +468,8 @@ static int parseelfimage(const char *ima
 
     for ( h = 0; h < ehdr->e_phnum; h++ )
     {
-        phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
+        phdr = (const Elf_Phdr *)(
+            image + ehdr->e_phoff + (h*ehdr->e_phentsize));
         if ( !is_loadable_phdr(phdr) )
             continue;
         vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
@@ -514,8 +521,8 @@ loadelfimage(
     const char *image, unsigned long elfsize, int xch, uint32_t dom,
     xen_pfn_t *parray, struct domain_setup_info *dsi)
 {
-    Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
-    Elf_Phdr *phdr;
+    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
+    const Elf_Phdr *phdr;
     int h;
 
     char         *va;
@@ -523,7 +530,8 @@ loadelfimage(
 
     for ( h = 0; h < ehdr->e_phnum; h++ )
     {
-        phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
+        phdr = (const Elf_Phdr *)(
+            image + ehdr->e_phoff + (h*ehdr->e_phentsize));
         if ( !is_loadable_phdr(phdr) )
             continue;
 
@@ -569,7 +577,8 @@ loadelfsymtab(
     const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
     struct domain_setup_info *dsi)
 {
-    Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr;
+    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
+    Elf_Ehdr *sym_ehdr;
     Elf_Shdr *shdr;
     unsigned long maxva, symva;
     char *p;
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xg_private.h
--- a/tools/libxc/xg_private.h  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xg_private.h  Wed Jan 10 08:40:47 2007 -0700
@@ -146,7 +146,7 @@ struct domain_setup_info
      * You should use the xen_elfnote_* accessors below in order to
      * pickup the correct one and retain backwards compatibility.
      */
-    void *__elfnote_section, *__elfnote_section_end;
+    const void *__elfnote_section, *__elfnote_section_end;
     const char *__xen_guest_string;
 };
 
@@ -162,14 +162,14 @@ typedef int (*loadimagefunc)(const char 
  * in the note is returned and *defined is set to non-zero. If no such
  * note is found then *defined is set to 0 and 0 is returned.
  */
-extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
+extern unsigned long long xen_elfnote_numeric(const struct domain_setup_info 
*dsi,
                                              int type, int *defined);
 
 /*
  * If an ELF note of the given type is found then the string contained
  * in the value is returned, otherwise NULL is returned.
  */
-extern const char * xen_elfnote_string(struct domain_setup_info *dsi,
+extern const char * xen_elfnote_string(const struct domain_setup_info *dsi,
                                       int type);
 
 struct load_funcs
diff -r 42babffffba5 -r 58633caeece9 tools/libxc/xg_save_restore.h
--- a/tools/libxc/xg_save_restore.h     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxc/xg_save_restore.h     Wed Jan 10 08:40:47 2007 -0700
@@ -53,8 +53,17 @@ static int get_platform_info(int xc_hand
 
     *hvirt_start = xen_params.virt_start;
 
+    /*
+     * XXX For now, 32bit dom0's can only save/restore 32bit domUs
+     * on 64bit hypervisors, so no need to check which type of domain
+     * we're dealing with.
+     */
     if (strstr(xen_caps, "xen-3.0-x86_64"))
+#if defined(__i386__)
+        *pt_levels = 3;
+#else
         *pt_levels = 4;
+#endif
     else if (strstr(xen_caps, "xen-3.0-x86_32p"))
         *pt_levels = 3;
     else if (strstr(xen_caps, "xen-3.0-x86_32"))
@@ -101,12 +110,6 @@ static int get_platform_info(int xc_hand
 /* Number of entries in the pfn_to_mfn_frame_list_list */
 #define P2M_FLL_ENTRIES (((max_pfn)+(fpp*fpp)-1)/(fpp*fpp))
 
-/* Current guests allow 8MB 'slack' in their P2M */
-#define NR_SLACK_ENTRIES   ((8 * 1024 * 1024) / PAGE_SIZE)
-
-/* Is the given PFN within the 'slack' region at the top of the P2M? */
-#define IS_REAL_PFN(_pfn)  ((max_pfn - (_pfn)) > NR_SLACK_ENTRIES)
-
 /* Returns TRUE if the PFN is currently mapped */
 #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
 
diff -r 42babffffba5 -r 58633caeece9 tools/libxen/include/xen_cpu_feature.h
--- a/tools/libxen/include/xen_cpu_feature.h    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxen/include/xen_cpu_feature.h    Wed Jan 10 08:40:47 2007 -0700
@@ -198,12 +198,12 @@ enum xen_cpu_feature
     /**
      *  AMD 3DNow! extensions
      */
-    XEN_CPU_FEATURE_3DNOWEXT,
+    XEN_CPU_FEATURE_THREEDNOWEXT,
 
     /**
      *  3DNow!
      */
-    XEN_CPU_FEATURE_3DNOW,
+    XEN_CPU_FEATURE_THREEDNOW,
 
     /**
      *  CPU in recovery mode
diff -r 42babffffba5 -r 58633caeece9 tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxen/src/xen_common.c     Wed Jan 10 08:40:47 2007 -0700
@@ -373,11 +373,18 @@ static void server_error_2(xen_session *
 }
 
 
-static bool is_container_node(xmlNode *n, char *type)
+static bool is_node(xmlNode *n, char *type)
 {
     return
         n->type == XML_ELEMENT_NODE &&
-        0 == strcmp((char *)n->name, type) &&
+        0 == strcmp((char *)n->name, type);
+}
+
+
+static bool is_container_node(xmlNode *n, char *type)
+{
+    return
+        is_node(n, type) &&
         n->children != NULL &&
         n->children == n->last &&
         n->children->type == XML_ELEMENT_NODE;
@@ -390,13 +397,30 @@ static bool is_container_node(xmlNode *n
  */
 static xmlChar *string_from_value(xmlNode *n, char *type)
 {
-    return
-        is_container_node(n, "value") &&
-        0 == strcmp((char *)n->children->name, type) ?
-          (n->children->children == NULL ?
-             xmlStrdup(BAD_CAST("")) :
-             xmlNodeGetContent(n->children->children)) :
-          NULL;
+    /*
+      <value><type>XYZ</type></value> is normal, but the XML-RPC spec also
+      allows <value>XYZ</value> where XYZ is to be interpreted as a string.
+    */
+
+    if (is_container_node(n, "value") &&
+        0 == strcmp((char *)n->children->name, type))
+    {
+        return
+            n->children->children == NULL ?
+                xmlStrdup(BAD_CAST("")) :
+                xmlNodeGetContent(n->children->children);
+    }
+    else if (0 == strcmp(type, "string") && is_node(n, "value"))
+    {
+        return
+            n->children == NULL ?
+                xmlStrdup(BAD_CAST("")) :
+                xmlNodeGetContent(n->children);
+    }
+    else
+    {
+        return NULL;
+    }
 }
 
 
@@ -557,8 +581,14 @@ static void parse_into(xen_session *s, x
         xmlChar *string = string_from_value(value_node, "double");
         if (string == NULL)
         {
+#if PERMISSIVE
+            fprintf(stderr,
+                    "Expected a Float from the server, but didn't get one\n");
+            ((double *)value)[slot] = 0.0;
+#else
             server_error(
                 s, "Expected a Float from the server, but didn't get one");
+#endif
         }
         else
         {
diff -r 42babffffba5 -r 58633caeece9 tools/libxen/src/xen_cpu_feature.c
--- a/tools/libxen/src/xen_cpu_feature.c        Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/libxen/src/xen_cpu_feature.c        Wed Jan 10 08:40:47 2007 -0700
@@ -62,8 +62,8 @@ static const char *lookup_table[] =
     "NX",
     "MMXEXT",
     "LM",
-    "3DNOWEXT",
-    "3DNOW",
+    "THREEDNOWEXT",
+    "THREEDNOW",
     "RECOVERY",
     "LONGRUN",
     "LRTI",
diff -r 42babffffba5 -r 58633caeece9 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub   Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/pygrub/src/pygrub   Wed Jan 10 08:40:47 2007 -0700
@@ -13,7 +13,7 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 
-import os, sys, string, struct, tempfile
+import os, sys, string, struct, tempfile, re
 import copy
 import logging
 
@@ -65,6 +65,15 @@ def get_active_offset(file):
     # the first partition
     P1 = 446
     return struct.unpack("<L", buf[P1+8:P1+12])[0] * SECTOR_SIZE
+
+def open_fs(file):
+    offset = 0
+    if is_disk_image(file):
+        offset = get_active_offset(file)
+        if offset == -1:
+            raise RuntimeError, "Unable to find active partition on disk"
+
+    return fsimage.open(file, offset)
 
 class GrubLineEditor(curses.textpad.Textbox):
     def __init__(self, screen, startx, starty, line = ""):
@@ -143,12 +152,12 @@ class GrubLineEditor(curses.textpad.Text
         
 
 class Grub:
-    def __init__(self, file, isconfig = False):
+    def __init__(self, file, fs = None):
         self.screen = None
         self.entry_win = None
         self.text_win = None
         if file:
-            self.read_config(file, isconfig)
+            self.read_config(file, fs)
 
     def draw_main_windows(self):
         if self.screen is None: #only init stuff once
@@ -295,8 +304,8 @@ class Grub:
             # else, we cancelled and should just go back
             break
 
-    def read_config(self, fn, isConfig = False):
-        """Read the given file to parse the config.  If isconfig, then
+    def read_config(self, fn, fs = None):
+        """Read the given file to parse the config.  If fs = None, then
         we're being given a raw config file rather than a disk image."""
         
         if not os.access(fn, os.R_OK):
@@ -304,38 +313,25 @@ class Grub:
 
         self.cf = grub.GrubConf.GrubConfigFile()
 
-        if isConfig:
+        if not fs:
             # set the config file and parse it
             self.cf.filename = fn
             self.cf.parse()
             return
 
-        offset = 0
-        if is_disk_image(fn):
-            offset = get_active_offset(fn)
-            if offset == -1:
-                raise RuntimeError, "Unable to find active partition on disk"
-
-        # open the image and read the grub config
-        fs = fsimage.open(fn, offset)
-
-        if fs is not None:
-            grubfile = None
-            for f in ("/boot/grub/menu.lst", "/boot/grub/grub.conf",
-                      "/grub/menu.lst", "/grub/grub.conf"):
-                if fs.file_exists(f):
-                    grubfile = f
-                    break
-            if grubfile is None:
-                raise RuntimeError, "we couldn't find grub config file in the 
image provided."
-            f = fs.open_file(grubfile)
-            buf = f.read()
-            del f
-            del fs
-            # then parse the grub config
-            self.cf.parse(buf)
-        else:
-            raise RuntimeError, "Unable to read filesystem" 
+        grubfile = None
+        for f in ("/boot/grub/menu.lst", "/boot/grub/grub.conf",
+                  "/grub/menu.lst", "/grub/grub.conf"):
+            if fs.file_exists(f):
+                grubfile = f
+                break
+        if grubfile is None:
+            raise RuntimeError, "we couldn't find grub config file in the 
image provided."
+        f = fs.open_file(grubfile)
+        buf = f.read()
+        del f
+        # then parse the grub config
+        self.cf.parse(buf)
 
     def run(self):
         timeout = int(self.cf.timeout)
@@ -431,19 +427,93 @@ def get_entry_idx(cf, entry):
 
     return None
 
+def run_grub(file, entry, fs):
+    global g
+    global sel
+
+    def run_main(scr, *args):
+        global sel
+        global g
+        sel = g.run()
+
+    g = Grub(file, fs)
+    if interactive:
+        curses.wrapper(run_main)
+    else:
+        sel = g.cf.default
+
+    # set the entry to boot as requested
+    if entry is not None:
+        idx = get_entry_idx(g.cf, entry)
+        if idx is not None and idx > 0 and idx < len(g.cf.images):
+           sel = idx
+
+    if sel == -1:
+        print "No kernel image selected!"
+        sys.exit(1)
+
+    img = g.cf.images[sel]
+
+    grubcfg = { "kernel": None, "ramdisk": None, "args": None }
+
+    grubcfg["kernel"] = img.kernel[1]
+    if img.initrd:
+        grubcfg["ramdisk"] = img.initrd[1]
+    if img.args:
+        grubcfg["args"] = img.args
+
+    return grubcfg
+
+# If nothing has been specified, look for a Solaris domU. If found, perform the
+# necessary tweaks.
+def sniff_solaris(fs, cfg):
+    if not fs.file_exists("/platform/i86xen/kernel/unix"):
+        return cfg
+    
+    # darned python
+    longmode = (sys.maxint != 2147483647L)
+    if not longmode:
+        longmode = os.uname()[4] == "x86_64"
+    if not longmode:
+        if (os.access("/usr/bin/isainfo", os.R_OK) and
+            os.popen("/usr/bin/isainfo -b").read() == "64\n"):
+            longmode = True
+
+    if not cfg["kernel"]:
+        cfg["kernel"] = "/platform/i86xen/kernel/unix"
+        cfg["ramdisk"] = "/platform/i86pc/boot_archive"
+        if longmode:
+            cfg["kernel"] = "/platform/i86xen/kernel/amd64/unix"
+            cfg["ramdisk"] = "/platform/i86pc/amd64/boot_archive"
+
+    # Unpleasant. Typically we'll have 'root=foo -k' or 'root=foo /kernel -k',
+    # and we need to maintain Xen properties (root= and ip=) and the kernel
+    # before any user args.
+    
+    xenargs = ""
+    userargs = ""
+    
+    if not cfg["args"]:
+        cfg["args"] = cfg["kernel"]
+    else:
+        for arg in cfg["args"].split():
+            if re.match("^root=", arg) or re.match("^ip=", arg):
+                xenargs += arg + " "
+            elif arg != cfg["kernel"]:
+                userargs += arg + " "
+        cfg["args"] = xenargs + " " + cfg["kernel"] + " " + userargs
+
+    return cfg
+ 
 if __name__ == "__main__":
     sel = None
     
-    def run_main(scr, *args):
-        global sel
-        sel = g.run()
-
     def usage():
-        print >> sys.stderr, "Usage: %s [-q|--quiet] [--output=] [--entry=] 
<image>" %(sys.argv[0],)
+        print >> sys.stderr, "Usage: %s [-q|--quiet] [--output=] [--kernel=] 
[--ramdisk=] [--args=] [--entry=] <image>" %(sys.argv[0],)
 
     try:
         opts, args = getopt.gnu_getopt(sys.argv[1:], 'qh::',
-                                   ["quiet", "help", "output=", "entry=",
+                                   ["quiet", "help", "output=", "entry=", 
"kernel=", "ramdisk=", "args=",
                                     "isconfig"])
     except getopt.GetoptError:
         usage()
@@ -458,6 +528,14 @@ if __name__ == "__main__":
     entry = None
     interactive = True
     isconfig = False
+
+    # what was passed in
+    incfg = { "kernel": None, "ramdisk": None, "args": None }
+    # what grub or sniffing chose
+    chosencfg = { "kernel": None, "ramdisk": None, "args": None }
+    # what to boot
+    bootcfg = { "kernel": None, "ramdisk": None, "args": None }
+
     for o, a in opts:
         if o in ("-q", "--quiet"):
             interactive = False
@@ -466,6 +544,12 @@ if __name__ == "__main__":
             sys.exit()
         elif o in ("--output",):
             output = a
+        elif o in ("--kernel",):
+            incfg["kernel"] = a
+        elif o in ("--ramdisk",):
+            incfg["ramdisk"] = a
+        elif o in ("--args",):
+            incfg["args"] = a
         elif o in ("--entry",):
             entry = a
             # specifying the entry to boot implies non-interactive
@@ -478,58 +562,42 @@ if __name__ == "__main__":
     else:
         fd = os.open(output, os.O_WRONLY)
 
-    g = Grub(file, isconfig)
-    if interactive:
-        curses.wrapper(run_main)
-    else:
-        sel = g.cf.default
-
-    # set the entry to boot as requested
-    if entry is not None:
-        idx = get_entry_idx(g.cf, entry)
-        if idx is not None and idx > 0 and idx < len(g.cf.images):
-            sel = idx
-
-    if sel == -1:
-        print "No kernel image selected!"
-        sys.exit(1)
-
-    img = g.cf.images[sel]
-    print "Going to boot %s" %(img.title)
-    print "  kernel: %s" %(img.kernel[1],)
-    if img.initrd:
-        print "  initrd: %s" %(img.initrd[1],)
-
+    # debug
     if isconfig:
-        print "  args: %s" %(img.args,)
+        chosencfg = run_grub(file, entry)
+        print "  kernel: %s" % chosencfg["kernel"]
+        if img.initrd:
+            print "  initrd: %s" % chosencfg["ramdisk"]
+        print "  args: %s" % chosencfg["args"]
         sys.exit(0)
-        
-    offset = 0
-    if is_disk_image(file):
-        offset = get_active_offset(file)
-        if offset == -1:
-            raise RuntimeError, "Unable to find active partition on disk"
-
-    # read the kernel and initrd onto the hostfs
-    fs = fsimage.open(file, offset)
-
-    kernel = fs.open_file(img.kernel[1],).read()
-    (tfd, fn) = tempfile.mkstemp(prefix="boot_kernel.",
+
+    fs = open_fs(file)
+
+    chosencfg = sniff_solaris(fs, incfg)
+
+    if not chosencfg["kernel"]:
+        chosencfg = run_grub(file, entry, fs)
+
+    data = fs.open_file(chosencfg["kernel"]).read()
+    (tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.",
         dir="/var/run/xend/boot")
-    os.write(tfd, kernel)
+    os.write(tfd, data)
     os.close(tfd)
-    sxp = "linux (kernel %s)" %(fn,)
-
-    if img.initrd:
-        initrd = fs.open_file(img.initrd[1],).read()
-        (tfd, fn) = tempfile.mkstemp(prefix="boot_ramdisk.",
+
+    if chosencfg["ramdisk"]:
+        data = fs.open_file(chosencfg["ramdisk"],).read()
+        (tfd, bootcfg["ramdisk"]) = tempfile.mkstemp(prefix="boot_ramdisk.",
             dir="/var/run/xend/boot")
-        os.write(tfd, initrd)
+        os.write(tfd, data)
         os.close(tfd)
-        sxp += "(ramdisk %s)" %(fn,)
     else:
         initrd = None
-    sxp += "(args '%s')" %(img.args,)
+
+    sxp = "linux (kernel %s)" % bootcfg["kernel"]
+    if bootcfg["ramdisk"]:
+        sxp += "(ramdisk %s)" % bootcfg["ramdisk"]
+    if chosencfg["args"]:
+        sxp += "(args \"%s\")" % chosencfg["args"]
 
     sys.stdout.flush()
     os.write(fd, sxp)
diff -r 42babffffba5 -r 58633caeece9 tools/python/Makefile
--- a/tools/python/Makefile     Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/Makefile     Wed Jan 10 08:40:47 2007 -0700
@@ -7,15 +7,29 @@ all: build
 .PHONY: build
 build:
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
+       if which $(MSGFMT) >/dev/null ; then \
+          for file in `cd xen/xm; find messages -name xen-xm.po`; do \
+            dest=`echo "build/$$file" | \
+                  sed -e 's#xen-xm.po#LC_MESSAGES/xen-xm.mo#'`; \
+            mkdir -p `dirname "$$dest"`; \
+            $(MSGFMT) -c -o "$$dest" "xen/xm/$$file"; \
+          done; \
+        fi
 
 .PHONY: install
 ifndef XEN_PYTHON_NATIVE_INSTALL
-install: all
+install: install-messages
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--home="$(DESTDIR)/usr" --prefix="" --force
 else
-install: all
+install: install-messages
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)" --force
 endif
+
+install-messages: all
+       if which $(MSGFMT) >/dev/null ; then \
+         mkdir -p "$(DESTDIR)/usr/share/locale"; \
+         cp -R build/messages/* "$(DESTDIR)/usr/share/locale/"; \
+       fi
 
 .PHONY: test
 test:
diff -r 42babffffba5 -r 58633caeece9 tools/python/scripts/xapi.py
--- a/tools/python/scripts/xapi.py      Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/scripts/xapi.py      Wed Jan 10 08:40:47 2007 -0700
@@ -41,6 +41,7 @@ COMMANDS = {
 COMMANDS = {
     'host-info': ('', 'Get Xen Host Info'),
     'host-set-name': ('', 'Set host name'),
+    'pif-list': ('', 'List all PIFs'),
     'sr-list':   ('', 'List all SRs'),
     'vbd-list':  ('', 'List all VBDs'),
     'vbd-create': ('<domname> <pycfg> [opts]',
@@ -63,6 +64,15 @@ COMMANDS = {
 }
 
 OPTIONS = {
+    'sr-list': [(('-l', '--long'),
+                 {'action':'store_true',
+                  'help':'List all properties of SR'})
+               ],
+
+    'vdi-list': [(('-l', '--long'),
+                  {'action':'store_true',
+                   'help':'List all properties of VDI'})
+               ],        
     'vm-list': [(('-l', '--long'),
                  {'action':'store_true',
                   'help':'List all properties of VMs'})
@@ -145,7 +155,7 @@ def _connect(*args):
 def _connect(*args):
     global _server, _session, _initialised
     if not _initialised:
-        _server = ServerProxy('httpu:///var/run/xend/xmlrpc.sock')
+        _server = ServerProxy('httpu:///var/run/xend/xen-api.sock')
         login = raw_input("Login: ")
         password = getpass()
         creds = (login, password)
@@ -361,29 +371,53 @@ def xapi_vbd_list(*args):
         print VBD_LIST_FORMAT % vbd_struct
 
 def xapi_vdi_list(*args):
+    opts, args = parse_args('vdi-list', args, set_defaults = True)
+    is_long = opts and opts.long
+
     server, session = _connect()
     vdis = execute(server.VDI.get_all, session)
 
-    print VDI_LIST_FORMAT % {'name_label': 'VDI Label',
-                             'uuid' : 'UUID',
-                             'virtual_size': 'Sectors',
-                             'sector_size': 'Sector Size'}
-    
-    for vdi in vdis:
-        vdi_struct = execute(server.VDI.get_record, session, vdi)
-        print VDI_LIST_FORMAT % vdi_struct
+    if not is_long:
+        print VDI_LIST_FORMAT % {'name_label': 'VDI Label',
+                                 'uuid' : 'UUID',
+                                 'virtual_size': 'Sectors',
+                                 'sector_size': 'Sector Size'}
+        
+        for vdi in vdis:
+            vdi_struct = execute(server.VDI.get_record, session, vdi)
+            print VDI_LIST_FORMAT % vdi_struct
+
+    else:
+
+        for vdi in vdis:
+            vdi_struct = execute(server.VDI.get_record, session, vdi)
+            pprint(vdi_struct)
 
 def xapi_sr_list(*args):
+    opts, args = parse_args('sr-list', args, set_defaults = True)
+    is_long = opts and opts.long
+    
     server, session = _connect()
     srs = execute(server.SR.get_all, session)
-    print SR_LIST_FORMAT % {'name_label': 'SR Label',
-                            'uuid' : 'UUID',
-                            'physical_size': 'Size',
-                            'type': 'Type'}
-    for sr in srs:
-        sr_struct = execute(server.SR.get_record, session, sr)
-        sr_struct['physical_size'] = int(sr_struct['physical_size'])/MB
-        print SR_LIST_FORMAT % sr_struct
+    if not is_long:
+        print SR_LIST_FORMAT % {'name_label': 'SR Label',
+                                'uuid' : 'UUID',
+                                'physical_size': 'Size (MB)',
+                                'type': 'Type'}
+        
+        for sr in srs:
+            sr_struct = execute(server.SR.get_record, session, sr)
+            sr_struct['physical_size'] = int(sr_struct['physical_size'])/MB
+            print SR_LIST_FORMAT % sr_struct
+    else:
+        for sr in srs:
+            sr_struct = execute(server.SR.get_record, session, sr)        
+            pprint(sr_struct)
+
+def xapi_sr_rename(*args):
+    server, session = _connect()
+    sr = execute(server.SR.get_by_name_label, session, args[0])
+    execute(server.SR.set_name_label, session, sr[0], args[1])
 
 def xapi_vdi_create(*args):
     opts, args = parse_args('vdi-create', args)
@@ -421,10 +455,11 @@ def xapi_vdi_rename(*args):
     if len(args) < 2:
         raise OptionError('Not enough arguments')
 
-    vdi_uuid = args[0]
+    vdi_uuid = execute(server.VDI.get_by_name_label, session, args[0])
     vdi_name = args[1]
-    print 'Renaming VDI %s to %s' % (vdi_uuid, vdi_name)
-    result = execute(server.VDI.set_name_label, session, vdi_uuid, vdi_name)
+    
+    print 'Renaming VDI %s to %s' % (vdi_uuid[0], vdi_name)
+    result = execute(server.VDI.set_name_label, session, vdi_uuid[0], vdi_name)
     print 'Done.'
 
 
@@ -447,6 +482,14 @@ def xapi_vtpm_create(*args):
     vtpm_rec = execute(server.VTPM.get_record, session, vtpm_uuid)
     print "Has vtpm record '%s'" % vtpm_rec
 
+
+def xapi_pif_list(*args):
+    server, session = _connect()
+    pif_uuids = execute(server.PIF.get_all, session)
+    for pif_uuid in pif_uuids:
+        pif = execute(server.PIF.get_record, session, pif_uuid)
+        print pif
+    
 
 #
 # Command Line Utils
@@ -517,10 +560,12 @@ def usage(command = None, print_usage = 
             print
             print 'Subcommands:'
             print
-        sorted_commands = sorted(COMMANDS.keys())
-        for command  in sorted_commands:
-            args, description = COMMANDS[command]
-            print '%-16s  %-40s' % (command, description)
+
+        for func in sorted(globals().keys()):
+            if func.startswith('xapi_'):
+                command = func[5:].replace('_', '-')
+                args, description = COMMANDS.get(command, ('', ''))
+                print '%-16s  %-40s' % (command, description)
         print
     else:
         parse_args(command, ['-h'])
@@ -549,7 +594,7 @@ def main(args):
     try:
         subcmd_func(*args[1:])
     except XenAPIError, e:
-        print 'Error: %s' % str(e.args[1])
+        print 'Error: %s' % str(e.args[0])
         sys.exit(2)
     except OptionError, e:
         print 'Error: %s' % e
diff -r 42babffffba5 -r 58633caeece9 tools/python/xen/lowlevel/acm/acm.c
--- a/tools/python/xen/lowlevel/acm/acm.c       Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/xen/lowlevel/acm/acm.c       Wed Jan 10 08:40:47 2007 -0700
@@ -35,6 +35,8 @@ fprintf(stderr, "ERROR: " _m " (%d = %s)
 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a ,    \
     errno, strerror(errno))
 
+static PyObject *acm_error_obj;
+
 /* generic shared function */
 void * __getssid(int domid, uint32_t *buflen)
 {
@@ -80,28 +82,26 @@ static PyObject *policy(PyObject * self,
 {
     /* out */
     char *policyreference;
-    PyObject *ret = NULL;
+    PyObject *ret;
     void *ssid_buffer;
     uint32_t buf_len;
 
     if (!PyArg_ParseTuple(args, "", NULL)) {
-    goto out1;
+        return NULL;
     }
     ssid_buffer =  __getssid(0, &buf_len);
-    if (ssid_buffer == NULL) {
-        goto out1;
-    } else if (buf_len < sizeof(struct acm_ssid_buffer)) {
-        goto out2;
-    } else {
+    if (ssid_buffer == NULL || buf_len < sizeof(struct acm_ssid_buffer)) {
+        free(ssid_buffer);
+        return PyErr_SetFromErrno(acm_error_obj);
+    }
+    else {
         struct acm_ssid_buffer *ssid = (struct acm_ssid_buffer *)ssid_buffer;
         policyreference = (char *)(ssid_buffer + ssid->policy_reference_offset
                        + sizeof (struct acm_policy_reference_buffer));
-    }
-    ret = Py_BuildValue("s", policyreference);
- out2:
-    free(ssid_buffer);
- out1:
-    return ret;
+        ret = Py_BuildValue("s", policyreference);
+        free(ssid_buffer);
+        return ret;
+    }
 }
 
 
@@ -213,5 +213,8 @@ static PyMethodDef acmMethods[] = {
 /* inits */
 PyMODINIT_FUNC initacm(void)
 {
-    Py_InitModule("acm", acmMethods);
-}
+    PyObject *m = Py_InitModule("acm", acmMethods);
+    acm_error_obj = PyErr_NewException("acm.Error", PyExc_RuntimeError, NULL);
+    Py_INCREF(acm_error_obj);
+    PyModule_AddObject(m, "Error", acm_error_obj);
+}
diff -r 42babffffba5 -r 58633caeece9 tools/python/xen/util/Brctl.py
--- a/tools/python/xen/util/Brctl.py    Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/xen/util/Brctl.py    Wed Jan 10 08:40:47 2007 -0700
@@ -27,6 +27,31 @@ def cmd(p, s):
     if opts.verbose: print c
     if not opts.dryrun:
         os.system(c)
+
+bridgeRE = re.compile(r'([^\t]*)\t*[^\t]*\t*[^\t]*\t*([^\t]*)')
+def get_state():
+    fin = os.popen(CMD_BRCTL + ' show', 'r')
+    try:
+        bridges = {}
+        brlist = None
+        brname = None
+        first = True
+        for line in fin:
+            if first:
+                first = False
+            elif line[0] == '\t':
+                brlist.append(line.strip())
+            else:
+                if brname:
+                    bridges[brname] = brlist
+                m = bridgeRE.match(line)
+                brname = m.group(1)
+                brlist = [m.group(2).strip()]
+        if brname:
+            bridges[brname] = brlist
+        return bridges
+    finally:
+        fin.close()
 
 def vif_bridge_add(params):
     """Add the network interface for vif on dom to a bridge.
diff -r 42babffffba5 -r 58633caeece9 tools/python/xen/util/security.py
--- a/tools/python/xen/util/security.py Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/xen/util/security.py Wed Jan 10 08:40:47 2007 -0700
@@ -115,7 +115,7 @@ def get_security_info(info, field):
     if isinstance(info, dict):
         security = info['security']
     elif isinstance(info, list):
-        security = sxp.child_value(info, 'security', )
+        security = sxp.child_value(info, 'security')
     if not security:
         if field == 'ssidref':
             #return default ssid
@@ -357,7 +357,7 @@ def refresh_ssidref(config):
     if isinstance(config, dict):
         security = config['security']
     elif isinstance(config, list):
-        security = sxp.child_value(config, 'security',)
+        security = sxp.child_value(config, 'security')
     else:
         err("Instance type of config parameter not supported.")
     if not security:
@@ -637,11 +637,11 @@ def res_security_check(resource, domain_
     """
     rtnval = 1
 
-    #build canonical resource name
-    resource = unify_resname(resource)
-
     # if security is on, ask the hypervisor for a decision
     if on():
+        #build canonical resource name
+        resource = unify_resname(resource)
+
         (label, ssidref, policy) = get_res_security_details(resource)
         domac = ['access_control']
         domac.append(['policy', active_policy])
@@ -660,6 +660,8 @@ def res_security_check(resource, domain_
 
     # security is off, make sure resource isn't labeled
     else:
+        # Note, we can't canonicalise the resource here, because people using
+        # xm without ACM are free to use relative paths.
         (label, policy) = get_res_label(resource)
         if policy != 'NULL':
             raise ACMError("Security is off, but '"+resource+"' is labeled")
diff -r 42babffffba5 -r 58633caeece9 tools/python/xen/util/xmlrpclib2.py
--- a/tools/python/xen/util/xmlrpclib2.py       Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/xen/util/xmlrpclib2.py       Wed Jan 10 08:40:47 2007 -0700
@@ -20,6 +20,7 @@ An enhanced XML-RPC client/server interf
 An enhanced XML-RPC client/server interface for Python.
 """
 
+import re
 import string
 import fcntl
 from types import *
@@ -49,13 +50,15 @@ except ImportError:
 
 
 def stringify(value):
-    if isinstance(value, IntType) and not isinstance(value, BooleanType):
+    if isinstance(value, float) or \
+       isinstance(value, long) or \
+       (isinstance(value, int) and not isinstance(value, bool)):
         return str(value)
-    elif isinstance(value, DictType):
+    elif isinstance(value, dict):
         for k, v in value.items():
             value[k] = stringify(v)
         return value
-    elif isinstance(value, (TupleType, ListType)):
+    elif isinstance(value, (tuple, list)):
         return [stringify(v) for v in value]
     else:
         return value
@@ -163,8 +166,10 @@ class TCPXMLRPCServer(SocketServer.Threa
 class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
     allow_reuse_address = True
 
-    def __init__(self, addr, allowed, requestHandler=None,
+    def __init__(self, addr, allowed, xenapi, requestHandler=None,
                  logRequests = 1):
+        self.xenapi = xenapi
+        
         if requestHandler is None:
             requestHandler = XMLRPCRequestHandler
         SimpleXMLRPCServer.__init__(self, addr,
@@ -182,7 +187,7 @@ class TCPXMLRPCServer(SocketServer.Threa
         flags |= fcntl.FD_CLOEXEC
         fcntl.fcntl(client.fileno(), fcntl.F_SETFD, flags)
         return (client, addr)
-                                                                               
 
+
     def _marshaled_dispatch(self, data, dispatch_method = None):
         params, method = xmlrpclib.loads(data)
         if False:
@@ -214,12 +219,29 @@ class TCPXMLRPCServer(SocketServer.Threa
         except xmlrpclib.Fault, fault:
             response = xmlrpclib.dumps(fault)
         except Exception, exn:
-            import xen.xend.XendClient
-            log.exception(exn)
-            response = xmlrpclib.dumps(
-                xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
-
+            if self.xenapi:
+                if _is_not_supported(exn):
+                    errdesc = ['MESSAGE_METHOD_UNKNOWN', method]
+                else:
+                    log.exception('Internal error handling %s', method)
+                    errdesc = ['INTERNAL_ERROR', str(exn)]
+                response = xmlrpclib.dumps(
+                    ({ "Status": "Failure",
+                       "ErrorDescription": errdesc },),
+                    methodresponse = 1)
+            else:
+                log.exception('Internal error handling %s', method)
+                import xen.xend.XendClient
+                response = xmlrpclib.dumps(
+                    xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, 
str(exn)))
         return response
+
+
+notSupportedRE = re.compile(r'method "(.*)" is not supported')
+def _is_not_supported(exn):
+    m = notSupportedRE.search(exn[0])
+    return m is not None
+
 
 # This is a XML-RPC server that sits on a Unix domain socket.
 # It implements proper support for allow_reuse_address by
@@ -235,10 +257,10 @@ class UnixXMLRPCServer(TCPXMLRPCServer):
 class UnixXMLRPCServer(TCPXMLRPCServer):
     address_family = socket.AF_UNIX
 
-    def __init__(self, addr, allowed, logRequests = 1):
+    def __init__(self, addr, allowed, xenapi, logRequests = 1):
         mkdir.parents(os.path.dirname(addr), stat.S_IRWXU, True)
         if self.allow_reuse_address and os.path.exists(addr):
             os.unlink(addr)
 
-        TCPXMLRPCServer.__init__(self, addr, allowed,
+        TCPXMLRPCServer.__init__(self, addr, allowed, xenapi,
                                  UnixXMLRPCRequestHandler, logRequests)
diff -r 42babffffba5 -r 58633caeece9 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Wed Jan 10 08:00:50 2007 -0700
+++ b/tools/python/xen/xend/XendAPI.py  Wed Jan 10 08:40:47 2007 -0700
@@ -15,11 +15,16 @@
 # Copyright (C) 2006 XenSource Ltd.
 #============================================================================
 
+import inspect
+import os
+import string
+import sys
+import traceback
+
 from xen.xend import XendDomain, XendDomainInfo, XendNode
 from xen.xend import XendLogging
 
 from xen.xend.XendAuthSessions import instance as auth_manager
-from xen.xend.XendAuthSessions import session_required
 from xen.xend.XendError import *
 from xen.xend.XendClient import ERROR_INVALID_DOMAIN
 from xen.xend.XendLogging import log
@@ -30,13 +35,19 @@ AUTH_NONE = 'none'
 AUTH_NONE = 'none'
 AUTH_PAM = 'pam'
 
+argcounts = {}
+
 # ------------------------------------------
 # Utility Methods for Xen API Implementation
 # ------------------------------------------
 
 def xen_api_success(value):
     """Wraps a return value in XenAPI format."""
-    return {"Status": "Success", "Value": stringify(value)}
+    if value is None:
+        s = ''
+    else:
+        s = stringify(value)
+    return {"Status": "Success", "Value": s}
 
 def xen_api_success_void():
     """Return success, but caller expects no return value."""
@@ -44,7 +55,16 @@ def xen_api_success_void():
 
 def xen_api_error(error):
     """Wraps an error value in XenAPI format."""
-    return {"Status": "Error", "ErrorDescription": error}
+    if type(error) == tuple:
+        error = list(error)
+    if type(error) != list:
+        error = [error]
+    if len(error) == 0:
+        error = ['INTERNAL_ERROR', 'Empty list given to xen_api_error']
+
+    return { "Status": "Failure",
+             "ErrorDescription": [str(x) for x in error] }
+
 
 def xen_api_todo():
     """Temporary method to make sure we track down all the TODOs"""
@@ -68,186 +88,164 @@ def trace(func, api_name = ''):
     trace_func.api = api_name
     return trace_func
 
-def valid_host(func):
-    """Decorator to verify if host_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, host_ref)
+
+def catch_typeerror(func):
+    """Decorator to catch any TypeErrors and translate them into Xen-API
+    errors.
+
+    @param func: function with params: (self, ...)
+    @rtype: callable object
+    """
+    def f(self, *args, **kwargs):
+        try:
+            return func(self, *args, **kwargs)
+        except TypeError, exn:
+            #log.exception('catch_typeerror')
+            if hasattr(func, 'api') and func.api in argcounts:
+                # Assume that if the exception was thrown inside this
+                # file, then it is due to an invalid call from the client,
+                # but if it was thrown elsewhere, then it's an internal
+                # error (which will be handled further up).
+                tb = sys.exc_info()[2]
+                try:
+                    sourcefile = traceback.extract_tb(tb)[-1][0]
+                    if sourcefile == inspect.getsourcefile(XendAPI):
+                        return xen_api_error(
+                            ['MESSAGE_PARAMETER_COUNT_MISMATCH',
+                             func.api, argcounts[func.api],
+                             len(args) + len(kwargs)])
+                finally:
+                    del tb
+            raise
+
+    return f
+
+
+def session_required(func):
+    """Decorator to verify if session is valid before calling method.
+
+    @param func: function with params: (self, session, ...)
     @rtype: callable object
     """    
-    def check_host_ref(self, session, host_ref, *args, **kwargs):
-        xennode = XendNode.instance()
-        if type(host_ref) == type(str()) and xennode.is_valid_host(host_ref):
-            return func(self, session, host_ref, *args, **kwargs)
+    def check_session(self, session, *args, **kwargs):
+        if auth_manager().is_session_valid(session):
+            return func(self, session, *args, **kwargs)
         else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_HOST_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_host_ref.api = func.api
-        
-    return check_host_ref
+            return xen_api_error(['SESSION_INVALID', session])
+
+    return check_session
+
+
+def _is_valid_ref(ref, validator):
+    return type(ref) == str and validator(ref)
+
+def _check_ref(validator, errcode, func, api, session, ref, *args, **kwargs):
+    if _is_valid_ref(ref, validator):
+        return func(api, session, ref, *args, **kwargs)
+    else:
+        return xen_api_error([errcode, ref])
+
+
+def valid_host(func):
+    """Decorator to verify if host_ref is valid before calling method.
+
+    @param func: function with params: (self, session, host_ref, ...)
+    @rtype: callable object
+    """
+    return lambda *args, **kwargs: \
+           _check_ref(XendNode.instance().is_valid_host,
+                      'HOST_HANDLE_INVALID', func, *args, **kwargs)
 
 def valid_host_cpu(func):
-    """Decorator to verify if host_cpu_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, host_cpu_ref)
+    """Decorator to verify if host_cpu_ref is valid before calling method.
+
+    @param func: function with params: (self, session, host_cpu_ref, ...)
     @rtype: callable object
     """    
-    def check_host_cpu_ref(self, session, host_cpu_ref, *args, **kwargs):
-        xennode = XendNode.instance()
-        if type(host_cpu_ref) == type(str()) and \
-               xennode.is_valid_cpu(host_cpu_ref):
-            return func(self, session, host_cpu_ref, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_HOST_CPU_INVALID}
-        
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_host_cpu_ref.api = func.api
-        
-    return check_host_cpu_ref
+    return lambda *args, **kwargs: \
+           _check_ref(XendNode.instance().is_valid_cpu,
+                      'HOST_CPU_HANDLE_INVALID', func, *args, **kwargs)
 
 def valid_vm(func):
-    """Decorator to verify if vm_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, vm_ref)
+    """Decorator to verify if vm_ref is valid before calling method.
+
+    @param func: function with params: (self, session, vm_ref, ...)
     @rtype: callable object
     """    
-    def check_vm_ref(self, session, *args, **kwargs):
-        if len(args) == 0:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_VM_INVALID}
-
-        vm_ref = args[0]
-        xendom = XendDomain.instance()
-        if type(vm_ref) == type(str()) and \
-               xendom.is_valid_vm(vm_ref):
-            return func(self, session, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_VM_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_vm_ref.api = func.api
-        
-    return check_vm_ref
-
-def valid_vbd(func):
-    """Decorator to verify if vbd_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, vbd_ref)
+    return lambda *args, **kwargs: \
+           _check_ref(XendDomain.instance().is_valid_vm,
+                      'VM_HANDLE_INVALID', func, *args, **kwargs)
+
+def valid_network(func):
+    """Decorator to verify if network_ref is valid before calling method.
+
+    @param func: function with params: (self, session, network_ref, ...)
     @rtype: callable object
     """    
-    def check_vbd_ref(self, session, vbd_ref, *args, **kwargs):
-        xendom = XendDomain.instance()
-        if type(vbd_ref) == type(str()) and \
-               xendom.is_valid_dev('vbd', vbd_ref):
-            return func(self, session, vbd_ref, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_VBD_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_vbd_ref.api = func.api
-        
-    return check_vbd_ref
+    return lambda *args, **kwargs: \
+           _check_ref(XendNode.instance().is_valid_network,
+                      'NETWORK_HANDLE_INVALID', func, *args, **kwargs)
+
+def valid_vbd(func):
+    """Decorator to verify if vbd_ref is valid before calling method.
+
+    @param func: function with params: (self, session, vbd_ref, ...)
+    @rtype: callable object
+    """    
+    return lambda *args, **kwargs: \
+           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
+                      'VBD_HANDLE_INVALID', func, *args, **kwargs)
 
 def valid_vif(func):
-    """Decorator to verify if vif_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, vif_ref)
+    """Decorator to verify if vif_ref is valid before calling method.
+
+    @param func: function with params: (self, session, vif_ref, ...)
     @rtype: callable object
     """
-    def check_vif_ref(self, session, vif_ref, *args, **kwargs):
-        xendom = XendDomain.instance()
-        if type(vif_ref) == type(str()) and \
-               xendom.is_valid_dev('vif', vif_ref):
-            return func(self, session, vif_ref, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_VIF_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_vif_ref.api = func.api
-        
-    return check_vif_ref
-
+    return lambda *args, **kwargs: \
+           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vif', r),
+                      'VIF_HANDLE_INVALID', func, *args, **kwargs)
 
 def valid_vdi(func):
-    """Decorator to verify if vdi_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, vdi_ref)
+    """Decorator to verify if vdi_ref is valid before calling method.
+
+    @param func: function with params: (self, session, vdi_ref, ...)
     @rtype: callable object
     """
-    def check_vdi_ref(self, session, vdi_ref, *args, **kwargs):
-        xennode = XendNode.instance()
-        if type(vdi_ref) == type(str()) and \
-               xennode.get_sr().is_valid_vdi(vdi_ref):
-            return func(self, session, vdi_ref, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_VDI_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_vdi_ref.api = func.api
-        
-    return check_vdi_ref
+    return lambda *args, **kwargs: \
+           _check_ref(XendNode.instance().get_sr().is_valid_vdi,
+                      'VDI_HANDLE_INVALID', func, *args, **kwargs)
 
 def valid_vtpm(func):
-    """Decorator to verify if vtpm_ref is valid before calling
-    method.
-
-    @param func: function with params: (self, session, vtpm_ref)
+    """Decorator to verify if vtpm_ref is valid before calling method.
+
+    @param func: function with params: (self, session, vtpm_ref, ...)
     @rtype: callable object
     """
-    def check_vtpm_ref(self, session, vtpm_ref, *args, **kwargs):
-        xendom = XendDomain.instance()
-        if type(vtpm_ref) == type(str()) and \
-               xendom.is_valid_dev('vtpm', vtpm_ref):
-            return func(self, session, vtpm_ref, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_VTPM_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_vtpm_ref.api = func.api
-
-    return check_vtpm_ref
+    return lambda *args, **kwargs: \
+           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vtpm', r),
+                      'VTPM_HANDLE_INVALID', func, *args, **kwargs)
 
 def valid_sr(func):
+    """Decorator to verify if sr_ref is valid before calling method.
+
+    @param func: function with params: (self, session, sr_ref, ...)
+    @rtype: callable object
+    """
+    return lambda *args, **kwargs: \
+           _check_ref(lambda r: XendNode.instance().get_sr().uuid == r,
+                      'SR_HANDLE_INVALID', func, *args, **kwargs)
+
+def valid_pif(func):
     """Decorator to verify if sr_ref is valid before calling
     method.
 
     @param func: function with params: (self, session, sr_ref)
     @rtype: callable object
     """
-    def check_sr_ref(self, session, sr_ref, *args, **kwargs):
-        xennode = XendNode.instance()
-        if type(sr_ref) == type(str()) and \
-               xennode.get_sr().uuid == sr_ref:
-            return func(self, session, sr_ref, *args, **kwargs)
-        else:
-            return {'Status': 'Failure',
-                    'ErrorDescription': XEND_ERROR_SR_INVALID}
-
-    # make sure we keep the 'api' attribute
-    if hasattr(func, 'api'):
-        check_sr_ref.api = func.api
-        
-    return check_sr_ref
+    return lambda *args, **kwargs: \
+           _check_ref(lambda r: r in XendNode.instance().pifs,
+                      'PIF_HANDLE_INVALID', func, *args, **kwargs)
 
 # -----------------------------
 # Bridge to Legacy XM API calls
@@ -263,10 +261,14 @@ def do_vm_func(fn_name, vm_ref, *args, *
     @param *args: more arguments
     @type *args: tuple
     """
-    xendom = XendDomain.instance()
-    fn = getattr(xendom, fn_name)
-    xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs)
-    return xen_api_success_void()
+    try:
+        xendom = XendDomain.instance()
+        fn = getattr(xendom, fn_name)
+        xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs)
+        return xen_api_success_void()
+    except VMBadState, exn:
+        return xen_api_error(['VM_BAD_POWER_STATE', vm_ref, exn.expected,
+                              exn.actual])
 
 
 class XendAPI:
@@ -274,7 +276,7 @@ class XendAPI:
     used via XMLRPCServer.
 
     All methods that need a valid session are marked with
-    a L{XendAuthManager.session_required} decorator that will
+    a L{session_required} decorator that will
     transparently perform the required session authentication.
 
     We need to support Python <2.4, so we use the old decorator syntax.
@@ -284,109 +286,13 @@ class XendAPI:
     """
 
     def __init__(self, auth):
-        """Initialised Xen API wrapper by making sure all functions
-        have the correct validation decorators such as L{valid_host}
-        and L{session_required}.
-        """
         self.auth = auth
-
-        classes = {
-            'session': (session_required,),
-            'host': (valid_host, session_required),
-            'host_cpu': (valid_host_cpu, session_required),
-            'VM': (valid_vm, session_required),
-            'VBD': (valid_vbd, session_required),
-            'VIF': (valid_vif, session_required),
-            'VDI': (valid_vdi, session_required),
-            'VTPM':(valid_vtpm, session_required),
-            'SR':  (valid_sr, session_required)}
-        
-        # Cheat methods
-        # -------------
-        # Methods that have a trivial implementation for all classes.
-        # 1. get_by_uuid == getting by ref, so just return uuid for
-        #    all get_by_uuid() methods.
-        
-        for cls in classes.keys():
-            get_by_uuid = '%s_get_by_uuid' % cls
-            get_uuid = '%s_get_uuid' % cls
-            setattr(XendAPI, get_by_uuid,
-                    lambda s, sess, obj_ref: xen_api_success(obj_ref))
-            setattr(XendAPI, get_uuid,
-                    lambda s, sess, obj_ref: xen_api_success(obj_ref))
-
-        # 2. get_record is just getting all the attributes, so provide
-        #    a fake template implementation.
-        # 
-        # TODO: ...
-
-
-        # Wrapping validators around XMLRPC calls
-        # ---------------------------------------
-        
-        for cls, validators in classes.items():
-            ro_attrs = getattr(self, '%s_attr_ro' % cls, [])
-            rw_attrs = getattr(self, '%s_attr_rw' % cls, [])
-            methods  = getattr(self, '%s_methods' % cls, [])
-            funcs    = getattr(self, '%s_funcs' % cls, [])
-
-            # wrap validators around readable class attributes
-            for attr_name in ro_attrs + rw_attrs + self.Base_attr_ro:
-                getter_name = '%s_get_%s' % (cls, attr_name)
-                try:
-                    getter = getattr(XendAPI, getter_name)
-                    for validator in validators:
-                        getter = validator(getter)
-                    getter.api = '%s.get_%s' % (cls, attr_name)
-                    setattr(XendAPI, getter_name, getter)
-                except AttributeError:
-                    pass
-                    #log.warn("API call: %s not found" % getter_name)
-
-            # wrap validators around writable class attrributes
-            for attr_name in rw_attrs + self.Base_attr_rw:
-                setter_name = '%s_set_%s' % (cls, attr_name)
-                try:
-                    setter = getattr(XendAPI, setter_name)
-                    for validator in validators:
-                        setter = validator(setter)
-                    setter.api = '%s.set_%s' % (cls, attr_name)
-                    setattr(XendAPI, setter_name, setter)
-                except AttributeError:
-                    pass
-                    #log.warn("API call: %s not found" % setter_name)
-
-            # wrap validators around methods
-            for method_name in methods + self.Base_methods:
-                method_full_name = '%s_%s' % (cls, method_name)
-
-                try:
-                    method = getattr(XendAPI, method_full_name)
-                    for validator in validators:
-                        method = validator(method)
-                    method.api = '%s.%s' % (cls, method_name)
-                    setattr(XendAPI, method_full_name, method)
-                except AttributeError:
-                    pass
-                    #log.warn('API call: %s not found' % method_full_name)
-
-            # wrap validators around class functions
-            for func_name in funcs + self.Base_funcs:
-                func_full_name = '%s_%s' % (cls, func_name)
-                try:
-                    method = getattr(XendAPI, func_full_name)
-                    method = session_required(method)
-                    method.api = '%s.%s' % (cls, func_name)
-                    setattr(XendAPI, func_full_name, method)
-                except AttributeError:
-                    pass
-                    #log.warn('API call: %s not found' % func_full_name)
 
 
     Base_attr_ro = ['uuid']
     Base_attr_rw = []
-    Base_methods = ['destroy', 'get_record']
-    Base_funcs   = ['create', 'get_by_uuid', 'get_all']
+    Base_methods = ['destroy', 'get_by_uuid', 'get_record']
+    Base_funcs   = ['create', 'get_all']
 
     # Xen API: Class Session
     # ----------------------------------------------------------------
@@ -396,14 +302,20 @@ class XendAPI:
     session_methods = ['logout']
     # session_funcs = ['login_with_password']    
 
-    def session_login_with_password(self, username, password):
+    def session_login_with_password(self, *args):
+        if len(args) != 2:
+            return xen_api_error(
+                ['MESSAGE_PARAMETER_COUNT_MISMATCH',
+                 'session.login_with_password', 2, len(args)])
+        username = args[0]
+        password = args[1]
         try:
             session = (self.auth == AUTH_NONE and
                        auth_manager().login_unconditionally(username) or
                        auth_manager().login_with_password(username, password))
             return xen_api_success(session)
         except XendError, e:
-            return xen_api_error(XEND_ERROR_AUTHENTICATION_FAILED)
+            return xen_api_error(['SESSION_AUTHENTICATION_FAILED'])
     session_login_with_password.api = 'session.login_with_password'
 
 
@@ -425,7 +337,7 @@ class XendAPI:
         user = auth_manager().get_user(session)
         if user:
             return xen_api_success(user)
-        return xen_api_error(XEND_ERROR_SESSION_INVALID)
+        return xen_api_error(['SESSION_INVALID', session])
 
 
     # Xen API: Class User
@@ -548,17 +460,155 @@ class XendAPI:
         return xen_api_error(XEND_ERROR_UNSUPPORTED)
 
 
-    # Xen API: Class Network
+    # Xen API: Class network
     # ----------------------------------------------------------------
-    # TODO: NOT IMPLEMENTED
-
-    Network_attr_ro = ['VIFs']
-    Network_attr_rw = ['name_label',
+
+    network_attr_ro = ['VIFs', 'PIFs']
+    network_attr_rw = ['name_label',
                        'name_description',
-                       'NIC',
-                       'VLAN',
                        'default_gateway',
                        'default_netmask']
+
+    def network_create(self, _, name_label, name_description,
+                       default_gateway, default_netmask):
+        return xen_api_success(
+            XendNode.instance().network_create(name_label, name_description,
+                                               default_gateway,
+                                               default_netmask))
+
+    def network_destroy(self, _, ref):
+        return xen_api_success(XendNode.instance().network_destroy(ref))
+
+    def _get_network(self, ref):
+        return XendNode.instance().get_network(ref)
+
+    def network_get_all(self, _):
+        return xen_api_success(XendNode.instance().get_network_refs())
+
+    def network_get_record(self, _, ref):
+        return xen_api_success(
+            XendNode.instance().get_network(ref).get_record())
+
+    def network_get_name_label(self, _, ref):
+        return xen_api_success(self._get_network(ref).name_label)
+
+    def network_get_name_description(self, _, ref):
+        return xen_api_success(self._get_network(ref).name_description)
+
+    def network_get_default_gateway(self, _, ref):
+        return xen_api_success(self._get_network(ref).default_gateway)
+
+    def network_get_default_netmask(self, _, ref):
+        return xen_api_success(self._get_network(ref).default_netmask)
+
+    def network_get_VIFs(self, _, ref):
+        return xen_api_success(self._get_network(ref).get_VIF_UUIDs())
+
+    def network_get_PIFs(self, session, ref):
+        return xen_api_success(self._get_network(ref).get_PIF_UUIDs())
+
+    def network_set_name_label(self, _, ref, val):
+        return xen_api_success(self._get_network(ref).set_name_label(val))
+
+    def network_set_name_description(self, _, ref, val):
+        return 
xen_api_success(self._get_network(ref).set_name_description(val))
+
+    def network_set_default_gateway(self, _, ref, val):
+        return xen_api_success(self._get_network(ref).set_default_gateway(val))
+
+    def network_set_default_netmask(self, _, ref, val):
+        return xen_api_success(self._get_network(ref).set_default_netmask(val))
+
+
+    # Xen API: Class PIF
+    # ----------------------------------------------------------------
+
+    PIF_attr_ro = ['io_read_kbs',
+                   'io_write_kbs']
+    PIF_attr_rw = ['name',
+                   'network',
+                   'host',
+                   'MAC',
+                   'MTU',
+                   'VLAN']
+
+    PIF_attr_inst = PIF_attr_rw
+
+    PIF_methods = ['create_VLAN']
+
+    def _get_PIF(self, ref):
+        return XendNode.instance().pifs[ref]
+
+    def PIF_create(self, _, name, network_uuid, host_uuid, mac, mtu, vlan):
+        try:
+            node = XendNode.instance()
+            if host_uuid != node.uuid:
+                return xen_api_error(['HOST_HANDLE_INVALID', host_uuid])
+
+            elif _is_valid_ref(network_uuid, node.is_valid_network):
+                network = node.get_network(network_uuid)
+                return xen_api_success(node.PIF_create(name, mtu, vlan, mac,
+                                                       network))
+            else:
+                return xen_api_error(['NETWORK_HANDLE_INVALID', network_uuid])
+        except NetworkAlreadyConnected, exn:
+            return xen_api_error(['NETWORK_ALREADY_CONNECTED',
+                                  network_uuid, exn.pif_uuid])
+
+    def PIF_destroy(self, _, ref):
+        return xen_api_success(XendNode.instance().PIF_destroy(ref))
+
+    # object methods
+    def PIF_get_record(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).get_record())
+
+    def PIF_get_all(self, _):
+        return xen_api_success(XendNode.instance().pifs.keys())
+
+    def PIF_get_name(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).name)
+
+    def PIF_get_network(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).network.uuid)
+
+    def PIF_get_host(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).host.uuid)
+
+    def PIF_get_MAC(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).mac)
+
+    def PIF_get_MTU(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).mtu)
+
+    def PIF_get_VLAN(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).vlan)
+
+    def PIF_get_io_read_kbs(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).get_io_read_kbs())
+
+    def PIF_get_io_write_kbs(self, _, ref):
+        return xen_api_success(self._get_PIF(ref).get_io_write_kbs())
+    
+    def PIF_set_name(self, _, ref, name):
+        return xen_api_success(self._get_PIF(ref).set_name(name))
+
+    def PIF_set_MAC(self, _, ref, mac):
+        return xen_api_success(self._get_PIF(ref).set_mac(mac))
+
+    def PIF_set_MTU(self, _, ref, mtu):
+        return xen_api_success(self._get_PIF(ref).set_mtu(mtu))
+
+    def PIF_create_VLAN(self, _, ref, network, vlan):
+        try:
+            if _is_valid_ref(network, XendNode.instance().is_valid_network):
+                return xen_api_success(XendNode.instance().PIF_create_VLAN(
+                    ref, network, vlan))
+            else:
+                return xen_api_error(['NETWORK_HANDLE_INVALID', network])
+        except NetworkAlreadyConnected, exn:
+            return xen_api_error(['NETWORK_ALREADY_CONNECTED',
+                                  network, exn.pif_uuid])
+
 
     # Xen API: Class VM
     # ----------------------------------------------------------------        
@@ -833,55 +883,55 @@ class XendAPI:
         dom.setName(label)
         return xen_api_success_void()
     
-    def VM_set_name_description(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_user_version(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_is_a_template(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_memory_dynamic_max(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_memory_dynamic_min(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_VCPUs_policy(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_VCPUs_params(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_VCPUs_features_force_on(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_VCPUs_features_force_off(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_actions_after_shutdown(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()
-    
-    def VM_set_actions_after_reboot(self, session, vm_ref):
-        dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
-        return xen_api_success_void()

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.