direct-io.hg

changeset 6852:b2f4823b6ff0

Merge (only) xen-ia64-unstable with latest xen-unstable
author djm@kirby.fc.hp.com
date Fri Sep 09 10:30:54 2005 -0600 (2005-09-09)
parents 10b1d30d3f66 ec4a3f2d060e
children d4d880fcef28
files .hgignore Config.mk Makefile buildconfigs/Rules.mk buildconfigs/mk.linux-2.6-xen buildconfigs/mk.linux-2.6-xen0 buildconfigs/mk.linux-2.6-xenU docs/misc/vtpm.txt docs/src/user.tex extras/mini-os/Makefile extras/mini-os/README extras/mini-os/domain_config extras/mini-os/events.c extras/mini-os/include/ctype.h extras/mini-os/include/err.h extras/mini-os/include/errno-base.h extras/mini-os/include/errno.h extras/mini-os/include/events.h extras/mini-os/include/fcntl.h extras/mini-os/include/hypervisor.h extras/mini-os/include/lib.h extras/mini-os/include/list.h extras/mini-os/include/mm.h extras/mini-os/include/os.h extras/mini-os/include/sched.h extras/mini-os/include/semaphore.h extras/mini-os/include/time.h extras/mini-os/include/traps.h extras/mini-os/include/types.h extras/mini-os/include/wait.h extras/mini-os/include/xenbus.h extras/mini-os/include/xmalloc.h extras/mini-os/kernel.c extras/mini-os/lib/printf.c extras/mini-os/lib/string.c extras/mini-os/lib/xmalloc.c extras/mini-os/mm.c extras/mini-os/sched.c extras/mini-os/time.c extras/mini-os/traps.c extras/mini-os/xenbus/Makefile extras/mini-os/xenbus/xenbus_comms.c extras/mini-os/xenbus/xenbus_comms.h extras/mini-os/xenbus/xenbus_xs.c linux-2.4-xen-sparse/Makefile linux-2.4-xen-sparse/arch/xen/Makefile linux-2.4-xen-sparse/arch/xen/boot/Makefile linux-2.4-xen-sparse/arch/xen/config.in linux-2.4-xen-sparse/arch/xen/defconfig-xen0 linux-2.4-xen-sparse/arch/xen/defconfig-xenU linux-2.4-xen-sparse/arch/xen/drivers/balloon/Makefile linux-2.4-xen-sparse/arch/xen/drivers/blkif/Makefile linux-2.4-xen-sparse/arch/xen/drivers/blkif/backend/Makefile linux-2.4-xen-sparse/arch/xen/drivers/blkif/frontend/Makefile linux-2.4-xen-sparse/arch/xen/drivers/blkif/frontend/common.h linux-2.4-xen-sparse/arch/xen/drivers/blkif/frontend/vbd.c linux-2.4-xen-sparse/arch/xen/drivers/console/Makefile linux-2.4-xen-sparse/arch/xen/drivers/dom0/Makefile linux-2.4-xen-sparse/arch/xen/drivers/evtchn/Makefile linux-2.4-xen-sparse/arch/xen/drivers/netif/Makefile linux-2.4-xen-sparse/arch/xen/drivers/netif/backend/Makefile linux-2.4-xen-sparse/arch/xen/drivers/netif/frontend/Makefile linux-2.4-xen-sparse/arch/xen/kernel/Makefile linux-2.4-xen-sparse/arch/xen/kernel/entry.S linux-2.4-xen-sparse/arch/xen/kernel/head.S linux-2.4-xen-sparse/arch/xen/kernel/i386_ksyms.c linux-2.4-xen-sparse/arch/xen/kernel/irq.c linux-2.4-xen-sparse/arch/xen/kernel/ldt.c linux-2.4-xen-sparse/arch/xen/kernel/pci-pc.c linux-2.4-xen-sparse/arch/xen/kernel/process.c linux-2.4-xen-sparse/arch/xen/kernel/setup.c linux-2.4-xen-sparse/arch/xen/kernel/signal.c linux-2.4-xen-sparse/arch/xen/kernel/time.c linux-2.4-xen-sparse/arch/xen/kernel/traps.c linux-2.4-xen-sparse/arch/xen/lib/Makefile linux-2.4-xen-sparse/arch/xen/lib/delay.c linux-2.4-xen-sparse/arch/xen/mm/Makefile linux-2.4-xen-sparse/arch/xen/mm/fault.c linux-2.4-xen-sparse/arch/xen/mm/init.c linux-2.4-xen-sparse/arch/xen/mm/ioremap.c linux-2.4-xen-sparse/arch/xen/vmlinux.lds linux-2.4-xen-sparse/drivers/block/ll_rw_blk.c linux-2.4-xen-sparse/drivers/char/Makefile linux-2.4-xen-sparse/drivers/char/mem.c linux-2.4-xen-sparse/drivers/char/tty_io.c linux-2.4-xen-sparse/drivers/scsi/aic7xxx/Makefile linux-2.4-xen-sparse/include/asm-xen/bugs.h linux-2.4-xen-sparse/include/asm-xen/desc.h linux-2.4-xen-sparse/include/asm-xen/fixmap.h linux-2.4-xen-sparse/include/asm-xen/highmem.h linux-2.4-xen-sparse/include/asm-xen/hw_irq.h linux-2.4-xen-sparse/include/asm-xen/io.h linux-2.4-xen-sparse/include/asm-xen/irq.h linux-2.4-xen-sparse/include/asm-xen/keyboard.h linux-2.4-xen-sparse/include/asm-xen/mmu_context.h linux-2.4-xen-sparse/include/asm-xen/module.h linux-2.4-xen-sparse/include/asm-xen/page.h linux-2.4-xen-sparse/include/asm-xen/pci.h linux-2.4-xen-sparse/include/asm-xen/pgalloc.h linux-2.4-xen-sparse/include/asm-xen/pgtable-2level.h linux-2.4-xen-sparse/include/asm-xen/pgtable.h linux-2.4-xen-sparse/include/asm-xen/processor.h linux-2.4-xen-sparse/include/asm-xen/queues.h linux-2.4-xen-sparse/include/asm-xen/segment.h linux-2.4-xen-sparse/include/asm-xen/smp.h linux-2.4-xen-sparse/include/asm-xen/system.h linux-2.4-xen-sparse/include/asm-xen/vga.h linux-2.4-xen-sparse/include/asm-xen/xor.h linux-2.4-xen-sparse/include/linux/blk.h linux-2.4-xen-sparse/include/linux/highmem.h linux-2.4-xen-sparse/include/linux/irq.h linux-2.4-xen-sparse/include/linux/mm.h linux-2.4-xen-sparse/include/linux/sched.h linux-2.4-xen-sparse/include/linux/skbuff.h linux-2.4-xen-sparse/include/linux/timer.h linux-2.4-xen-sparse/kernel/time.c linux-2.4-xen-sparse/kernel/timer.c linux-2.4-xen-sparse/mkbuildtree linux-2.4-xen-sparse/mm/highmem.c linux-2.4-xen-sparse/mm/memory.c linux-2.4-xen-sparse/mm/mprotect.c linux-2.4-xen-sparse/mm/mremap.c linux-2.4-xen-sparse/mm/page_alloc.c linux-2.4-xen-sparse/net/core/skbuff.c linux-2.6-xen-sparse/arch/xen/Kconfig linux-2.6-xen-sparse/arch/xen/Kconfig.drivers linux-2.6-xen-sparse/arch/xen/Makefile linux-2.6-xen-sparse/arch/xen/boot/Makefile linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64 linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64 linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32 linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64 linux-2.6-xen-sparse/arch/xen/i386/Kconfig linux-2.6-xen-sparse/arch/xen/i386/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c linux-2.6-xen-sparse/arch/xen/i386/kernel/apic.c linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S linux-2.6-xen-sparse/arch/xen/i386/kernel/i386_ksyms.c linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c linux-2.6-xen-sparse/arch/xen/i386/kernel/io_apic.c linux-2.6-xen-sparse/arch/xen/i386/kernel/ioport.c linux-2.6-xen-sparse/arch/xen/i386/kernel/irq.c linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c linux-2.6-xen-sparse/arch/xen/i386/kernel/microcode.c linux-2.6-xen-sparse/arch/xen/i386/kernel/mpparse.c linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6-xen-sparse/arch/xen/i386/kernel/signal.c linux-2.6-xen-sparse/arch/xen/i386/kernel/smp.c linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c linux-2.6-xen-sparse/arch/xen/i386/kernel/vsyscall.S linux-2.6-xen-sparse/arch/xen/i386/mach-default/Makefile linux-2.6-xen-sparse/arch/xen/i386/mm/Makefile linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c linux-2.6-xen-sparse/arch/xen/i386/mm/highmem.c linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c linux-2.6-xen-sparse/arch/xen/i386/mm/init.c linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile linux-2.6-xen-sparse/arch/xen/i386/pci/irq.c linux-2.6-xen-sparse/arch/xen/kernel/Makefile linux-2.6-xen-sparse/arch/xen/kernel/devmem.c linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c linux-2.6-xen-sparse/arch/xen/kernel/fixup.c linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c linux-2.6-xen-sparse/arch/xen/kernel/reboot.c linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c linux-2.6-xen-sparse/arch/xen/kernel/smp.c linux-2.6-xen-sparse/arch/xen/kernel/xen_proc.c linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig linux-2.6-xen-sparse/arch/xen/x86_64/Makefile linux-2.6-xen-sparse/arch/xen/x86_64/ia32/Makefile linux-2.6-xen-sparse/arch/xen/x86_64/ia32/ia32entry.S linux-2.6-xen-sparse/arch/xen/x86_64/ia32/syscall32.c linux-2.6-xen-sparse/arch/xen/x86_64/ia32/vsyscall-int80.S linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile linux-2.6-xen-sparse/arch/xen/x86_64/kernel/acpi/Makefile linux-2.6-xen-sparse/arch/xen/x86_64/kernel/apic.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/early_printk.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic_xen.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head64.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/io_apic.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ioport.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/irq.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ldt.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/mpparse.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/pci-nommu.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/process.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/signal.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smp.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/traps.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/vsyscall.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S linux-2.6-xen-sparse/arch/xen/x86_64/mm/Makefile linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/pageattr.c linux-2.6-xen-sparse/arch/xen/x86_64/pci/Makefile linux-2.6-xen-sparse/arch/xen/x86_64/pci/Makefile-BUS linux-2.6-xen-sparse/drivers/Makefile linux-2.6-xen-sparse/drivers/acpi/tables.c linux-2.6-xen-sparse/drivers/char/mem.c linux-2.6-xen-sparse/drivers/char/tpm/Kconfig.domU linux-2.6-xen-sparse/drivers/char/tpm/Makefile linux-2.6-xen-sparse/drivers/char/tpm/tpm.c linux-2.6-xen-sparse/drivers/char/tpm/tpm.h linux-2.6-xen-sparse/drivers/char/tpm/tpm_atmel.c linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.c linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.h linux-2.6-xen-sparse/drivers/char/tpm/tpm_nsc.c linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c linux-2.6-xen-sparse/drivers/char/tty_io.c linux-2.6-xen-sparse/drivers/xen/Makefile linux-2.6-xen-sparse/drivers/xen/balloon/Makefile linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/blkback/Makefile linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blkback/common.h linux-2.6-xen-sparse/drivers/xen/blkback/interface.c linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c linux-2.6-xen-sparse/drivers/xen/blkfront/Kconfig linux-2.6-xen-sparse/drivers/xen/blkfront/Makefile linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blkfront/block.h linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c linux-2.6-xen-sparse/drivers/xen/blktap/Makefile linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h linux-2.6-xen-sparse/drivers/xen/blktap/common.h linux-2.6-xen-sparse/drivers/xen/blktap/interface.c linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c linux-2.6-xen-sparse/drivers/xen/console/Makefile linux-2.6-xen-sparse/drivers/xen/console/console.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.h linux-2.6-xen-sparse/drivers/xen/evtchn/Makefile linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c linux-2.6-xen-sparse/drivers/xen/netback/Makefile linux-2.6-xen-sparse/drivers/xen/netback/common.h linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/loopback.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c linux-2.6-xen-sparse/drivers/xen/netfront/Kconfig linux-2.6-xen-sparse/drivers/xen/netfront/Makefile linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/privcmd/Makefile linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c linux-2.6-xen-sparse/drivers/xen/tpmback/Makefile linux-2.6-xen-sparse/drivers/xen/tpmback/common.h linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c linux-2.6-xen-sparse/drivers/xen/tpmfront/Makefile linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.h linux-2.6-xen-sparse/drivers/xen/usbback/common.h linux-2.6-xen-sparse/drivers/xen/usbback/control.c linux-2.6-xen-sparse/drivers/xen/usbback/interface.c linux-2.6-xen-sparse/drivers/xen/usbback/usbback.c linux-2.6-xen-sparse/drivers/xen/usbfront/usbfront.c linux-2.6-xen-sparse/drivers/xen/usbfront/xhci.h linux-2.6-xen-sparse/drivers/xen/xenbus/Makefile linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c linux-2.6-xen-sparse/include/asm-generic/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/agp.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/desc.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/fixmap.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/floppy.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/highmem.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/hw_irq.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypercall.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/io.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/kmap_types.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/mach-xen/irq_vectors.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_post.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/mach-xen/setup_arch_pre.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/mach-xen/smpboot_hooks.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/mmu.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/mmu_context.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/param.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pci.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgalloc.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable-3level.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/processor.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/ptrace.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/scatterlist.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/segment.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/setup.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/spinlock.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/swiotlb.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/synch_bitops.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/tlbflush.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/vga.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/arch_hooks.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/bootsetup.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/desc.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/dma-mapping.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/fixmap.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/floppy.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hw_irq.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypercall.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/io.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/irq.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/io_ports.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/irq_vectors.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/mach_timer.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/setup_arch_post.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/setup_arch_pre.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/smpboot_hooks.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mmu.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mmu_context.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/param.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pci.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgalloc.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/processor.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/ptrace.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/segment.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/smp.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/timer.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/tlbflush.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/vga.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/xor.h linux-2.6-xen-sparse/include/asm-xen/balloon.h linux-2.6-xen-sparse/include/asm-xen/evtchn.h linux-2.6-xen-sparse/include/asm-xen/foreign_page.h linux-2.6-xen-sparse/include/asm-xen/gnttab.h linux-2.6-xen-sparse/include/asm-xen/hypervisor.h linux-2.6-xen-sparse/include/asm-xen/linux-public/privcmd.h linux-2.6-xen-sparse/include/asm-xen/linux-public/xenbus_dev.h linux-2.6-xen-sparse/include/asm-xen/queues.h linux-2.6-xen-sparse/include/asm-xen/synch_bitops.h linux-2.6-xen-sparse/include/asm-xen/xen_proc.h linux-2.6-xen-sparse/include/asm-xen/xenbus.h linux-2.6-xen-sparse/include/linux/gfp.h linux-2.6-xen-sparse/include/linux/highmem.h linux-2.6-xen-sparse/include/linux/irq.h linux-2.6-xen-sparse/include/linux/mm.h linux-2.6-xen-sparse/include/linux/skbuff.h linux-2.6-xen-sparse/include/linux/tpmfe.h linux-2.6-xen-sparse/kernel/irq/manage.c linux-2.6-xen-sparse/mkbuildtree linux-2.6-xen-sparse/mm/highmem.c linux-2.6-xen-sparse/mm/memory.c linux-2.6-xen-sparse/mm/mmap.c linux-2.6-xen-sparse/mm/page_alloc.c linux-2.6-xen-sparse/net/core/dev.c linux-2.6-xen-sparse/net/core/skbuff.c patches/linux-2.6.12/i386-cpu-hotplug-updated-for-mm.patch patches/linux-2.6.12/net-csum.patch patches/linux-2.6.12/patch-2.6.12.5 patches/linux-2.6.12/rcu-nohz.patch patches/linux-2.6.12/smp-alts.patch tools/Makefile tools/Rules.mk tools/blktap/Makefile tools/blktap/README.sept05 tools/blktap/blkdump.c tools/blktap/blkif.c tools/blktap/blktaplib.c tools/blktap/blktaplib.h tools/blktap/list.h tools/blktap/parallax/Makefile tools/blktap/parallax/block-async.h tools/blktap/parallax/blockstore.h tools/blktap/ublkback/Makefile tools/blktap/ublkback/ublkback.c tools/blktap/ublkback/ublkbacklib.c tools/blktap/ublkback/ublkbacklib.h tools/blktap/xenbus.c tools/check/check_brctl tools/check/check_iproute tools/check/check_logging tools/check/check_python tools/check/check_zlib_devel tools/check/check_zlib_lib tools/check/chk tools/console/Makefile tools/console/client/main.c tools/console/daemon/io.c tools/console/daemon/io.h tools/console/daemon/main.c tools/console/daemon/utils.c tools/console/daemon/utils.h tools/console/testsuite/Makefile tools/console/testsuite/README tools/console/testsuite/console-dom0.c tools/console/testsuite/console-domU.c tools/console/testsuite/procpipe.c tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/linux-xen-low.c tools/debugger/gdb/gdbbuild tools/debugger/libxendebug/Makefile tools/debugger/libxendebug/xendebug.c tools/debugger/libxendebug/xendebug.h tools/debugger/pdb/Domain.ml tools/debugger/pdb/Domain.mli tools/debugger/pdb/Makefile tools/debugger/pdb/PDB.ml tools/debugger/pdb/Process.ml tools/debugger/pdb/Process.mli tools/debugger/pdb/Util.ml tools/debugger/pdb/Xen_domain.ml tools/debugger/pdb/Xen_domain.mli tools/debugger/pdb/debugger.ml tools/debugger/pdb/linux-2.6-module/Makefile tools/debugger/pdb/linux-2.6-module/debug.c tools/debugger/pdb/linux-2.6-module/module.c tools/debugger/pdb/linux-2.6-module/pdb_debug.h tools/debugger/pdb/linux-2.6-module/pdb_module.h tools/debugger/pdb/linux-2.6-patches/Makefile tools/debugger/pdb/linux-2.6-patches/i386_ksyms.patch tools/debugger/pdb/linux-2.6-patches/kdebug.patch tools/debugger/pdb/linux-2.6-patches/makefile.patch tools/debugger/pdb/linux-2.6-patches/ptrace.patch tools/debugger/pdb/linux-2.6-patches/traps.patch tools/debugger/pdb/pdb_caml_domain.c tools/debugger/pdb/pdb_caml_evtchn.c tools/debugger/pdb/pdb_caml_process.c tools/debugger/pdb/pdb_caml_xc.c tools/debugger/pdb/pdb_caml_xcs.c tools/debugger/pdb/pdb_caml_xen.h tools/debugger/pdb/pdb_xen.c tools/debugger/pdb/readme tools/debugger/pdb/server.ml tools/examples/Makefile tools/examples/README tools/examples/init.d/xend tools/examples/network-bridge tools/examples/vif-bridge tools/examples/vif-route tools/examples/xen-backend.agent tools/examples/xend-config.sxp tools/examples/xmexample.vmx tools/examples/xmexample1 tools/examples/xmexample2 tools/examples/xmexample3 tools/firmware/acpi/acpi2_0.h tools/firmware/rombios/rombios.c tools/firmware/vmxassist/Makefile tools/firmware/vmxassist/setup.c tools/firmware/vmxassist/vm86.c tools/firmware/vmxassist/vmxloader.c tools/ioemu/cpu-all.h tools/ioemu/exec.c tools/ioemu/hw/i8254.c tools/ioemu/hw/i8259.c tools/ioemu/hw/ide.c tools/ioemu/hw/ioapic.h tools/ioemu/hw/pc.c tools/ioemu/hw/pckbd.c tools/ioemu/hw/pcnet.c tools/ioemu/hw/pcnet.h tools/ioemu/hw/vga.c tools/ioemu/monitor.c tools/ioemu/target-i386-dm/Makefile tools/ioemu/target-i386-dm/helper2.c tools/ioemu/target-i386-dm/qemu-dm.debug tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c tools/libxc/Makefile tools/libxc/linux_boot_params.h tools/libxc/xc_core.c tools/libxc/xc_domain.c tools/libxc/xc_gnttab.c tools/libxc/xc_linux_build.c tools/libxc/xc_linux_restore.c tools/libxc/xc_linux_save.c tools/libxc/xc_load_aout9.c tools/libxc/xc_load_bin.c tools/libxc/xc_load_elf.c tools/libxc/xc_private.c tools/libxc/xc_private.h tools/libxc/xc_ptrace.c tools/libxc/xc_vmx_build.c tools/libxc/xenctrl.h tools/libxc/xenguest.h tools/libxc/xg_private.c tools/libxc/xg_private.h tools/misc/Makefile tools/misc/cpuperf/Makefile tools/misc/cpuperf/cpuperf.c tools/misc/cpuperf/cpuperf_xeno.h tools/misc/mbootpack/Makefile tools/misc/mbootpack/buildimage.c tools/misc/mbootpack/mbootpack.c tools/misc/mbootpack/mbootpack.h tools/misc/xc_shadow.c tools/misc/xend tools/misc/xenperf.c tools/python/setup.py tools/python/xen/lowlevel/xc/xc.c tools/python/xen/lowlevel/xs/xs.c tools/python/xen/sv/CreateDomain.py tools/python/xen/sv/DomInfo.py tools/python/xen/sv/GenTabbed.py tools/python/xen/sv/HTMLBase.py tools/python/xen/sv/Main.py tools/python/xen/sv/NodeInfo.py tools/python/xen/sv/RestoreDomain.py tools/python/xen/sv/Wizard.py tools/python/xen/sv/__init__.py tools/python/xen/sv/util.py tools/python/xen/util/Brctl.py tools/python/xen/web/SrvBase.py tools/python/xen/web/SrvDir.py tools/python/xen/web/__init__.py tools/python/xen/web/connection.py tools/python/xen/web/httpserver.py tools/python/xen/web/protocol.py tools/python/xen/web/reactor.py tools/python/xen/web/resource.py tools/python/xen/web/static.py tools/python/xen/web/tcp.py tools/python/xen/web/unix.py tools/python/xen/xend/Args.py tools/python/xen/xend/EventServer.py tools/python/xen/xend/PrettyPrint.py tools/python/xen/xend/Vifctl.py tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendClient.py tools/python/xen/xend/XendDB.py tools/python/xen/xend/XendDmesg.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/XendError.py tools/python/xen/xend/XendLogging.py tools/python/xen/xend/XendNode.py tools/python/xen/xend/XendProtocol.py tools/python/xen/xend/XendRoot.py tools/python/xen/xend/XendVnet.py tools/python/xen/xend/encode.py tools/python/xen/xend/image.py tools/python/xen/xend/scheduler.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/SrvDmesg.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/SrvDomainDir.py tools/python/xen/xend/server/SrvNode.py tools/python/xen/xend/server/SrvRoot.py tools/python/xen/xend/server/SrvServer.py tools/python/xen/xend/server/SrvVnetDir.py tools/python/xen/xend/server/SrvXendLog.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/channel.py tools/python/xen/xend/server/controller.py tools/python/xen/xend/server/event.py tools/python/xen/xend/server/netif.py tools/python/xen/xend/server/params.py tools/python/xen/xend/server/pciif.py tools/python/xen/xend/server/relocate.py tools/python/xen/xend/server/tpmif.py tools/python/xen/xend/server/usbif.py tools/python/xen/xend/sxp.py tools/python/xen/xend/uuid.py tools/python/xen/xend/xenstore/__init__.py tools/python/xen/xend/xenstore/xsnode.py tools/python/xen/xend/xenstore/xsobj.py tools/python/xen/xend/xenstore/xsresource.py tools/python/xen/xend/xenstore/xstransact.py tools/python/xen/xend/xenstore/xswatch.py tools/python/xen/xm/create.py tools/python/xen/xm/destroy.py tools/python/xen/xm/help.py tools/python/xen/xm/main.py tools/python/xen/xm/migrate.py tools/python/xen/xm/opts.py tools/python/xen/xm/shutdown.py tools/python/xen/xm/sysrq.py tools/security/Makefile tools/security/example.txt tools/security/getlabel.sh tools/security/install.txt tools/security/labelfuncs.sh tools/security/policies/chwall/chwall-security_label_template.xml tools/security/policies/chwall/chwall-security_policy.xml tools/security/policies/chwall_ste/chwall_ste-security_label_template.xml tools/security/policies/chwall_ste/chwall_ste-security_policy.xml tools/security/policies/null/null-security_label_template.xml tools/security/policies/null/null-security_policy.xml tools/security/policies/security_policy.xsd tools/security/policies/ste/ste-security_label_template.xml tools/security/policies/ste/ste-security_policy.xml tools/security/policy.txt tools/security/readme.txt tools/security/secpol_compat.h tools/security/secpol_tool.c tools/security/secpol_xml2bin.c tools/security/secpol_xml2bin.h tools/security/setlabel.sh tools/security/updategrub.sh tools/sv/Makefile tools/sv/images/destroy.png tools/sv/images/finish.png tools/sv/images/next.png tools/sv/images/pause.png tools/sv/images/previous.png tools/sv/images/reboot.png tools/sv/images/shutdown.png tools/sv/images/small-destroy.png tools/sv/images/small-pause.png tools/sv/images/small-unpause.png tools/sv/images/unpause.png tools/sv/images/xen.png tools/sv/inc/script.js tools/sv/inc/style.css tools/sv/index.psp tools/vnet/00INSTALL tools/vnet/Makefile tools/vnet/doc/vnet-module.txt tools/vnet/doc/vnet-xend.txt tools/vnet/examples/Makefile tools/vnet/examples/network-vnet tools/vnet/examples/vnet97.sxp tools/vnet/examples/vnet98.sxp tools/vnet/examples/vnet99.sxp tools/vnet/libxutil/Makefile tools/vnet/libxutil/debug.h tools/vnet/libxutil/sxpr.c tools/vnet/libxutil/sxpr.h tools/vnet/libxutil/sxpr_parser.c tools/vnet/libxutil/sxpr_parser.h tools/vnet/libxutil/sys_string.c tools/vnet/libxutil/sys_string.h tools/vnet/vnet-module/00README tools/vnet/vnet-module/Makefile tools/vnet/vnet-module/Makefile-2.4 tools/vnet/vnet-module/Makefile-2.6 tools/vnet/vnet-module/Makefile.ver tools/vnet/vnet-module/Makefile.vnet tools/vnet/vnet-module/etherip.c tools/vnet/vnet-module/if_etherip.h tools/vnet/vnet-module/if_varp.h tools/vnet/vnet-module/skb_util.h tools/vnet/vnet-module/tunnel.c tools/vnet/vnet-module/tunnel.h tools/vnet/vnet-module/varp.c tools/vnet/vnet-module/varp.h tools/vnet/vnet-module/varp_socket.c tools/vnet/vnet-module/vif.c tools/vnet/vnet-module/vif.h tools/vnet/vnet-module/vnet.c tools/vnet/vnet-module/vnet.h tools/vnet/vnet-module/vnet_dev.c tools/vnet/vnet-module/vnet_dev.h tools/vnet/vnet-module/vnet_ioctl.c tools/vnet/vnetd/Makefile tools/vnet/vnetd/vcache.c tools/vnet/vnetd/vcache.h tools/vnet/vnetd/vnetd.c tools/vnet/vnetd/vnetd.h tools/vtpm/Makefile tools/vtpm/README tools/vtpm/Rules.mk tools/vtpm/tpm_emulator.patch tools/vtpm/vtpm.patch tools/vtpm_manager/COPYING tools/vtpm_manager/Makefile tools/vtpm_manager/README tools/vtpm_manager/Rules.mk tools/vtpm_manager/crypto/Makefile tools/vtpm_manager/crypto/crypto.c tools/vtpm_manager/crypto/crypto.h tools/vtpm_manager/crypto/hash.c tools/vtpm_manager/crypto/rsa.c tools/vtpm_manager/crypto/sym_crypto.c tools/vtpm_manager/crypto/sym_crypto.h tools/vtpm_manager/manager/Makefile tools/vtpm_manager/manager/dmictl.c tools/vtpm_manager/manager/securestorage.c tools/vtpm_manager/manager/tpmpassthrough.c tools/vtpm_manager/manager/vtpm_manager.c tools/vtpm_manager/manager/vtpm_manager.h tools/vtpm_manager/manager/vtpmd.c tools/vtpm_manager/manager/vtpmpriv.h tools/vtpm_manager/manager/vtsp.c tools/vtpm_manager/manager/vtsp.h tools/vtpm_manager/tcs/Makefile tools/vtpm_manager/tcs/contextmgr.c tools/vtpm_manager/tcs/contextmgr.h tools/vtpm_manager/tcs/tcs.c tools/vtpm_manager/tcs/tcs.h tools/vtpm_manager/tcs/tpmddl.h tools/vtpm_manager/tcs/transmit.c tools/vtpm_manager/util/Makefile tools/vtpm_manager/util/bsg.c tools/vtpm_manager/util/bsg.h tools/vtpm_manager/util/buffer.c tools/vtpm_manager/util/buffer.h tools/vtpm_manager/util/depend tools/vtpm_manager/util/hashtable.c tools/vtpm_manager/util/hashtable.h tools/vtpm_manager/util/hashtable_itr.c tools/vtpm_manager/util/hashtable_itr.h tools/vtpm_manager/util/hashtable_private.h tools/vtpm_manager/util/log.c tools/vtpm_manager/util/log.h tools/vtpm_manager/util/tcg.h tools/xcutils/Makefile tools/xcutils/xc_restore.c tools/xcutils/xc_save.c tools/xenstat/Makefile tools/xenstat/libxenstat/COPYING tools/xenstat/libxenstat/Makefile tools/xenstat/libxenstat/bindings/swig/perl/.empty tools/xenstat/libxenstat/bindings/swig/python/.empty tools/xenstat/libxenstat/bindings/swig/xenstat.i tools/xenstat/libxenstat/src/xen-interface.c tools/xenstat/libxenstat/src/xen-interface.h tools/xenstat/libxenstat/src/xenstat.c tools/xenstat/libxenstat/src/xenstat.h tools/xenstat/xentop/Makefile tools/xenstat/xentop/TODO tools/xenstat/xentop/xentop.1 tools/xenstat/xentop/xentop.c tools/xenstore/COPYING tools/xenstore/Makefile tools/xenstore/TODO tools/xenstore/testsuite/01simple.test tools/xenstore/testsuite/02directory.test tools/xenstore/testsuite/03write.test tools/xenstore/testsuite/04rm.test tools/xenstore/testsuite/05filepermissions.test tools/xenstore/testsuite/06dirpermissions.test tools/xenstore/testsuite/07watch.test tools/xenstore/testsuite/08transaction.slowtest tools/xenstore/testsuite/08transaction.test tools/xenstore/testsuite/09domain.test tools/xenstore/testsuite/10domain-homedir.test tools/xenstore/testsuite/11domain-watch.test tools/xenstore/testsuite/12readonly.test tools/xenstore/testsuite/13watch-ack.test tools/xenstore/testsuite/14complexperms.test tools/xenstore/testsuite/15nowait.test tools/xenstore/testsuite/test.sh tools/xenstore/testsuite/vg-suppressions tools/xenstore/utils.c tools/xenstore/utils.h tools/xenstore/xenstore_client.c tools/xenstore/xenstored.h tools/xenstore/xenstored_core.c tools/xenstore/xenstored_core.h tools/xenstore/xenstored_domain.c tools/xenstore/xenstored_domain.h tools/xenstore/xenstored_transaction.c tools/xenstore/xenstored_transaction.h tools/xenstore/xenstored_watch.c tools/xenstore/xenstored_watch.h tools/xenstore/xs.c tools/xenstore/xs.h tools/xenstore/xs_crashme.c tools/xenstore/xs_dom0_test.c tools/xenstore/xs_lib.c tools/xenstore/xs_lib.h tools/xenstore/xs_random.c tools/xenstore/xs_test.c tools/xentrace/Makefile tools/xentrace/formats tools/xentrace/xenctx.c tools/xentrace/xentrace.c xen/Makefile xen/Rules.mk xen/acm/acm_chinesewall_hooks.c xen/acm/acm_core.c xen/acm/acm_null_hooks.c xen/acm/acm_policy.c xen/acm/acm_simple_type_enforcement_hooks.c xen/arch/ia64/Makefile xen/arch/ia64/Rules.mk xen/arch/ia64/asm-offsets.c xen/arch/ia64/asm-xsi-offsets.c xen/arch/ia64/linux-xen/efi.c xen/arch/ia64/linux-xen/entry.S xen/arch/ia64/linux-xen/entry.h xen/arch/ia64/linux-xen/head.S xen/arch/ia64/linux-xen/irq_ia64.c xen/arch/ia64/linux-xen/mm_contig.c xen/arch/ia64/linux-xen/setup.c xen/arch/ia64/linux-xen/unaligned.c xen/arch/ia64/linux/extable.c xen/arch/ia64/linux/ia64_ksyms.c xen/arch/ia64/linux/irq_lsapic.c xen/arch/ia64/linux/pcdp.h xen/arch/ia64/tools/README.xenia64 xen/arch/ia64/tools/README.xenia64linux xen/arch/x86/Makefile xen/arch/x86/Rules.mk xen/arch/x86/acpi/boot.c xen/arch/x86/apic.c xen/arch/x86/audit.c xen/arch/x86/boot/x86_32.S xen/arch/x86/boot/x86_64.S xen/arch/x86/cdb.c xen/arch/x86/cpu/amd.c xen/arch/x86/cpu/common.c xen/arch/x86/dom0_ops.c xen/arch/x86/domain.c xen/arch/x86/domain_build.c xen/arch/x86/genapic/es7000plat.c xen/arch/x86/i8259.c xen/arch/x86/io_apic.c xen/arch/x86/mm.c xen/arch/x86/mpparse.c xen/arch/x86/physdev.c xen/arch/x86/setup.c xen/arch/x86/shadow.c xen/arch/x86/shadow32.c xen/arch/x86/shadow_guest32.c xen/arch/x86/shadow_public.c xen/arch/x86/smpboot.c xen/arch/x86/time.c xen/arch/x86/traps.c xen/arch/x86/vmx.c xen/arch/x86/vmx_intercept.c xen/arch/x86/vmx_io.c xen/arch/x86/vmx_platform.c xen/arch/x86/vmx_vmcs.c xen/arch/x86/x86_32/asm-offsets.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/asm-offsets.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/mm.c xen/arch/x86/x86_64/traps.c xen/common/Makefile xen/common/ac_timer.c xen/common/acm_ops.c xen/common/dom0_ops.c xen/common/domain.c xen/common/event_channel.c xen/common/grant_table.c xen/common/kernel.c xen/common/lib.c xen/common/memory.c xen/common/multicall.c xen/common/page_alloc.c xen/common/perfc.c xen/common/sched_sedf.c xen/common/schedule.c xen/common/symbols.c xen/common/trace.c xen/common/xmalloc.c xen/drivers/char/console.c xen/drivers/char/ns16550.c xen/drivers/char/serial.c xen/include/acm/acm_core.h xen/include/acm/acm_hooks.h xen/include/asm-ia64/config.h xen/include/asm-ia64/domain.h xen/include/asm-ia64/event.h xen/include/asm-ia64/ia64_int.h xen/include/asm-ia64/linux-xen/asm/gcc_intrin.h xen/include/asm-ia64/linux-xen/asm/ia64regs.h xen/include/asm-ia64/linux-xen/asm/io.h xen/include/asm-ia64/linux-xen/asm/kregs.h xen/include/asm-ia64/linux-xen/asm/mca_asm.h xen/include/asm-ia64/linux-xen/asm/page.h xen/include/asm-ia64/linux-xen/asm/pal.h xen/include/asm-ia64/linux-xen/asm/pgalloc.h xen/include/asm-ia64/linux-xen/asm/processor.h xen/include/asm-ia64/linux-xen/asm/system.h xen/include/asm-ia64/linux-xen/asm/types.h xen/include/asm-ia64/linux-xen/asm/uaccess.h xen/include/asm-ia64/linux-xen/linux/cpumask.h xen/include/asm-ia64/linux-xen/linux/hardirq.h xen/include/asm-ia64/linux-xen/linux/interrupt.h xen/include/asm-ia64/linux/asm-generic/bug.h xen/include/asm-ia64/linux/asm-generic/errno.h xen/include/asm-ia64/linux/asm-generic/iomap.h xen/include/asm-ia64/linux/asm-generic/pci.h xen/include/asm-ia64/linux/asm-generic/pgtable-nopud.h xen/include/asm-ia64/linux/asm-generic/pgtable.h xen/include/asm-ia64/linux/asm-generic/sections.h xen/include/asm-ia64/linux/asm-generic/topology.h xen/include/asm-ia64/linux/asm-generic/vmlinux.lds.h xen/include/asm-ia64/linux/asm/acpi.h xen/include/asm-ia64/linux/asm/bitops.h xen/include/asm-ia64/linux/asm/break.h xen/include/asm-ia64/linux/asm/bug.h xen/include/asm-ia64/linux/asm/cacheflush.h xen/include/asm-ia64/linux/asm/param.h xen/include/asm-ia64/linux/asm/pci.h xen/include/asm-ia64/linux/asm/percpu.h xen/include/asm-ia64/linux/asm/sal.h xen/include/asm-ia64/linux/asm/sections.h xen/include/asm-ia64/linux/asm/signal.h xen/include/asm-ia64/linux/asm/smp.h xen/include/asm-ia64/linux/asm/thread_info.h xen/include/asm-ia64/linux/asm/topology.h xen/include/asm-ia64/linux/asm/unaligned.h xen/include/asm-ia64/linux/asm/unistd.h xen/include/asm-ia64/linux/bitmap.h xen/include/asm-ia64/linux/bitops.h xen/include/asm-ia64/linux/dma-mapping.h xen/include/asm-ia64/linux/efi.h xen/include/asm-ia64/linux/err.h xen/include/asm-ia64/linux/gfp.h xen/include/asm-ia64/linux/mmzone.h xen/include/asm-ia64/linux/numa.h xen/include/asm-ia64/linux/page-flags.h xen/include/asm-ia64/linux/slab.h xen/include/asm-ia64/linux/threads.h xen/include/asm-ia64/linux/timex.h xen/include/asm-ia64/linux/topology.h xen/include/asm-ia64/linux/wait.h xen/include/asm-ia64/mm.h xen/include/asm-ia64/mmu_context.h xen/include/asm-ia64/privop.h xen/include/asm-ia64/regionreg.h xen/include/asm-ia64/regs.h xen/include/asm-ia64/time.h xen/include/asm-ia64/tlb.h xen/include/asm-ia64/vcpu.h xen/include/asm-ia64/vhpt.h xen/include/asm-ia64/vmmu.h xen/include/asm-ia64/vmx.h xen/include/asm-ia64/vmx_uaccess.h xen/include/asm-ia64/vmx_vcpu.h xen/include/asm-ia64/vmx_vpd.h xen/include/asm-ia64/xenprocessor.h xen/include/asm-ia64/xensystem.h xen/include/asm-x86/apicdef.h xen/include/asm-x86/asm_defns.h xen/include/asm-x86/bitops.h xen/include/asm-x86/config.h xen/include/asm-x86/e820.h xen/include/asm-x86/event.h xen/include/asm-x86/fixmap.h xen/include/asm-x86/genapic.h xen/include/asm-x86/hpet.h xen/include/asm-x86/io.h xen/include/asm-x86/mach-bigsmp/mach_apic.h xen/include/asm-x86/mach-default/mach_apic.h xen/include/asm-x86/mach-es7000/mach_apic.h xen/include/asm-x86/mach-generic/mach_apic.h xen/include/asm-x86/mach-summit/mach_apic.h xen/include/asm-x86/mach-summit/mach_mpparse.h xen/include/asm-x86/mm.h xen/include/asm-x86/page-guest32.h xen/include/asm-x86/page.h xen/include/asm-x86/processor.h xen/include/asm-x86/shadow.h xen/include/asm-x86/shadow_64.h xen/include/asm-x86/shadow_ops.h xen/include/asm-x86/shadow_public.h xen/include/asm-x86/time.h xen/include/asm-x86/types.h xen/include/asm-x86/uaccess.h xen/include/asm-x86/vmx.h xen/include/asm-x86/vmx_platform.h xen/include/asm-x86/vmx_virpit.h xen/include/asm-x86/vmx_vmcs.h xen/include/asm-x86/x86_32/asm_defns.h xen/include/asm-x86/x86_32/page-3level.h xen/include/asm-x86/x86_32/uaccess.h xen/include/asm-x86/x86_64/asm_defns.h xen/include/asm-x86/x86_64/page.h xen/include/public/acm.h xen/include/public/acm_ops.h xen/include/public/arch-ia64.h xen/include/public/arch-x86_32.h xen/include/public/arch-x86_64.h xen/include/public/dom0_ops.h xen/include/public/grant_table.h xen/include/public/io/blkif.h xen/include/public/io/domain_controller.h xen/include/public/io/ioreq.h xen/include/public/io/netif.h xen/include/public/io/tpmif.h xen/include/public/memory.h xen/include/public/physdev.h xen/include/public/trace.h xen/include/public/version.h xen/include/public/xen.h xen/include/xen/ac_timer.h xen/include/xen/config.h xen/include/xen/domain.h xen/include/xen/event.h xen/include/xen/grant_table.h xen/include/xen/mm.h xen/include/xen/perfc.h xen/include/xen/perfc_defn.h xen/include/xen/sched.h xen/include/xen/serial.h xen/include/xen/symbols.h xen/include/xen/time.h xen/include/xen/trace.h xen/tools/Makefile xen/tools/symbols.c
line diff
     1.1 --- a/.hgignore	Thu Sep 08 09:18:40 2005 -0600
     1.2 +++ b/.hgignore	Fri Sep 09 10:30:54 2005 -0600
     1.3 @@ -82,6 +82,7 @@
     1.4  ^tools/blktap/parallax/vdi_validate$
     1.5  ^tools/blktap/parallax/parallax$
     1.6  ^tools/blktap/parallax/blockstored$
     1.7 +^tools/blktap/ublkback/ublkback$
     1.8  ^tools/blktap/xen/.*$
     1.9  ^tools/check/\..*$
    1.10  ^tools/cmdline/.*$
    1.11 @@ -141,24 +142,28 @@
    1.12  ^tools/vnet/vnet-module/\.tmp_versions/.*$
    1.13  ^tools/vnet/vnet-module/vnet_module\.mod\..*$
    1.14  ^tools/vnetd/vnetd$
    1.15 +^tools/vtpm/vtpm*
    1.16 +^tools/vtpm/tpm_emulator-*
    1.17 +^tools/vtpm_manager/manager/vtpm_managerd
    1.18  ^tools/web-shutdown\.tap$
    1.19  ^tools/x2d2/minixend$
    1.20 -^tools/xcs/xcs$
    1.21 -^tools/xcs/xcsdump$
    1.22  ^tools/xcutils/xc_restore$
    1.23  ^tools/xcutils/xc_save$
    1.24  ^tools/xenstat/xentop/xentop$
    1.25  ^tools/xenstore/testsuite/tmp/.*$
    1.26  ^tools/xenstore/xen$
    1.27 +^tools/xenstore/xenbus_dev.h$
    1.28  ^tools/xenstore/xenstored$
    1.29  ^tools/xenstore/xenstored_test$
    1.30 +^tools/xenstore/xenstore-read$
    1.31 +^tools/xenstore/xenstore-rm$
    1.32 +^tools/xenstore/xenstore-write$
    1.33  ^tools/xenstore/xs_dom0_test$
    1.34  ^tools/xenstore/xs_random$
    1.35  ^tools/xenstore/xs_stress$
    1.36  ^tools/xenstore/xs_test$
    1.37  ^tools/xenstore/xs_watch_stress$
    1.38  ^tools/xentrace/xentrace$
    1.39 -^tools/xfrd/xfrd$
    1.40  ^xen/BLOG$
    1.41  ^xen/TAGS$
    1.42  ^xen/arch/x86/asm-offsets\.s$
     2.1 --- a/Config.mk	Thu Sep 08 09:18:40 2005 -0600
     2.2 +++ b/Config.mk	Fri Sep 09 10:30:54 2005 -0600
     2.3 @@ -48,3 +48,4 @@ ACM_USE_SECURITY_POLICY ?= ACM_NULL_POLI
     2.4  # Optional components
     2.5  XENSTAT_XENTOP ?= y
     2.6  
     2.7 +VTPM_TOOLS ?= n
     3.1 --- a/Makefile	Thu Sep 08 09:18:40 2005 -0600
     3.2 +++ b/Makefile	Fri Sep 09 10:30:54 2005 -0600
     3.3 @@ -35,11 +35,11 @@ ifeq ($(XEN_TARGET_X86_PAE),y)
     3.4  export pae=y
     3.5  endif
     3.6  
     3.7 -.PHONY:	all dist install xen tools kernels docs world clean mkpatches mrproper
     3.8 +.PHONY:	all dist install xen kernels tools docs world clean mkpatches mrproper
     3.9  .PHONY:	kbuild kdelete kclean
    3.10  
    3.11  # build and install everything into the standard system directories
    3.12 -install: install-xen install-tools install-kernels install-docs
    3.13 +install: install-xen install-kernels install-tools install-docs
    3.14  
    3.15  build: kernels
    3.16  	$(MAKE) -C xen build
    3.17 @@ -47,7 +47,7 @@ build: kernels
    3.18  	$(MAKE) -C docs build
    3.19  
    3.20  # build and install everything into local dist directory
    3.21 -dist: xen tools kernels docs
    3.22 +dist: xen kernels tools docs
    3.23  	$(INSTALL_DIR) $(DISTDIR)/check
    3.24  	$(INSTALL_DATA) ./COPYING $(DISTDIR)
    3.25  	$(INSTALL_DATA) ./README $(DISTDIR)
    3.26 @@ -178,6 +178,8 @@ uninstall:
    3.27  	rm -rf $(D)/usr/share/man/man1/xen*
    3.28  	rm -rf $(D)/usr/share/man/man8/xen*
    3.29  	rm -rf $(D)/usr/lib/xen
    3.30 +	rm -rf $(D)/etc/hotplug.d/xen-backend
    3.31 +	rm -rf $(D)/etc/hotplug/xen-backend.agent
    3.32  
    3.33  # Legacy targets for compatibility
    3.34  linux24:
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/docs/misc/vtpm.txt	Fri Sep 09 10:30:54 2005 -0600
     8.3 @@ -0,0 +1,122 @@
     8.4 +Copyright: IBM Corporation (C), Intel Corporation
     8.5 +17 August 2005
     8.6 +Authors: Stefan Berger <stefanb@us.ibm.com> (IBM), 
     8.7 +         Employees of Intel Corp
     8.8 +
     8.9 +This document gives a short introduction to the virtual TPM support
    8.10 +in XEN and goes as far as connecting a user domain to a virtual TPM
    8.11 +instance and doing a short test to verify success. It is assumed
    8.12 +that the user is fairly familiar with compiling and installing XEN
    8.13 +and Linux on a machine. 
    8.14 + 
    8.15 +Production Prerequisites: An x86-based machine machine with an ATMEL or
    8.16 +National Semiconductor (NSC) TPM on the motherboard.
    8.17 +Development Prerequisites: An emulator for TESTING ONLY is provided
    8.18 +
    8.19 +
    8.20 +Compiling XEN tree:
    8.21 +-------------------
    8.22 +
    8.23 +Compile the XEN tree as usual.
    8.24 +
    8.25 +make uninstall; make mrproper; make install 
    8.26 +
    8.27 +After compiling the tree, verify that in the linux-2.6.XX-xen0/.config 
    8.28 +file at least the following entries are set as below (they should be set
    8.29 +by default):
    8.30 +
    8.31 +CONFIG_XEN_TPMDEV_BACKEND=y
    8.32 +CONFIG_XEN_TPMDEV_GRANT=y
    8.33 +
    8.34 +CONFIG_TCG_TPM=m
    8.35 +CONFIG_TCG_NSC=m
    8.36 +CONFIG_TCG_ATMEL=m
    8.37 +
    8.38 +
    8.39 +Verify that in the linux-2.6.XX-xenU/.config file at least the 
    8.40 +Following entries are set as below (they should be set by default):
    8.41 +
    8.42 +CONFIG_XEN_TPMDEV_FRONTEND=y
    8.43 +CONFIG_XEN_TPMDEV_GRANT=y
    8.44 +
    8.45 +CONFIG_TCG_TPM=y
    8.46 +CONFIG_TCG_XEN=y
    8.47 +
    8.48 +
    8.49 +Reboot the machine with the created XEN-0 kernel.
    8.50 +
    8.51 +Note: If you do not want any TPM-related code compiled into your
    8.52 +kernel or built as module then comment all the above lines like
    8.53 +this example:
    8.54 +# CONFIG_TCG_TPM is not set
    8.55 +
    8.56 +
    8.57 +Modifying VM Configuration files:
    8.58 +---------------------------------
    8.59 +
    8.60 +VM configuration files need to be adapted to make a TPM instance
    8.61 +available to a user domain. The following VM configuration file is
    8.62 +an example of how a user domain can be configured to have a TPM
    8.63 +available. It works similar to making a network interface
    8.64 +available to a domain.
    8.65 +
    8.66 +kernel = "/boot/vmlinuz-2.6.12-xenU"
    8.67 +ramdisk = "/xen/initrd_domU/U1_ramdisk.img"
    8.68 +memory = 32
    8.69 +name = "TPMUserDomain0"
    8.70 +vtpm = ['instance=1,backend=0']
    8.71 +root = "/dev/ram0 cosole=tty ro"
    8.72 +vif = ['backend=0']
    8.73 +
    8.74 +In the above configuration file the line 'vtpm = ...' provides
    8.75 +information about the domain where the virtual TPM is running and
    8.76 +where the TPM backend has been compiled into - this has to be 
    8.77 +domain 0  at the moment - and which TPM instance the user domain
    8.78 +is supposed to talk to. Note that each running VM must use a 
    8.79 +different instance and that using instance 0 is NOT allowed.
    8.80 +
    8.81 +Note: If you do not want TPM functionality for your user domain simply
    8.82 +leave out the 'vtpm' line in the configuration file.
    8.83 +
    8.84 +
    8.85 +Running the TPM:
    8.86 +----------------
    8.87 +
    8.88 +To run the vTPM, dev device /dev/vtpm must be available.
    8.89 +Verify that 'ls -l /dev/vtpm' shows the following output:
    8.90 +
    8.91 +crw-------  1 root root 10, 225 Aug 11 06:58 /dev/vtpm
    8.92 +
    8.93 +If it is not available, run the following command as 'root'.
    8.94 +mknod /dev/vtpm c 10 225
    8.95 +
    8.96 +Make sure that the vTPM is running in domain 0. To do this run the
    8.97 +following
    8.98 +
    8.99 +/usr/bin/vtpm_managerd
   8.100 +
   8.101 +Start a user domain using the 'xm create' command. Once you are in the
   8.102 +shell of the user domain, you should be able to do the following:
   8.103 +
   8.104 +> cd /sys/devices/vtpm
   8.105 +> ls
   8.106 +cancel  caps   pcrs    pubek
   8.107 +> cat pcrs
   8.108 +PCR-00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.109 +PCR-01: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.110 +PCR-02: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.111 +PCR-03: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.112 +PCR-04: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.113 +PCR-05: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.114 +PCR-06: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.115 +PCR-07: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.116 +PCR-08: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   8.117 +[...]
   8.118 +
   8.119 +At this point the user domain has been sucessfully connected to its
   8.120 +virtual TPM instance.
   8.121 +
   8.122 +For further information please read the documentation in 
   8.123 +tools/vtpm_manager/README and tools/vtpm/README
   8.124 +
   8.125 +Stefan Berger and Employees of the Intel Corp
    10.1 --- a/extras/mini-os/Makefile	Thu Sep 08 09:18:40 2005 -0600
    10.2 +++ b/extras/mini-os/Makefile	Fri Sep 09 10:30:54 2005 -0600
    10.3 @@ -31,16 +31,18 @@ TARGET := mini-os
    10.4  OBJS := $(TARGET_ARCH).o
    10.5  OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
    10.6  OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
    10.7 -
    10.8 +OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
    10.9 +										   
   10.10  HDRS := $(wildcard include/*.h)
   10.11  HDRS += $(wildcard include/xen/*.h)
   10.12  
   10.13  default: $(TARGET)
   10.14  
   10.15 -xen-public:
   10.16 +links:
   10.17  	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
   10.18 -
   10.19 -$(TARGET): xen-public $(OBJS)
   10.20 +	[ -e xenbus/xenstored.h ] || ln -sf ../../../tools/xenstore/xenstored.h xenbus/xenstored.h
   10.21 +	
   10.22 +$(TARGET): links $(OBJS)
   10.23  	$(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o $@.elf
   10.24  	gzip -f -9 -c $@.elf >$@.gz
   10.25  
   10.26 @@ -55,3 +57,4 @@ clean:
   10.27  %.o: %.S $(HDRS) Makefile
   10.28  	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
   10.29  
   10.30 +
    11.1 --- a/extras/mini-os/README	Thu Sep 08 09:18:40 2005 -0600
    11.2 +++ b/extras/mini-os/README	Fri Sep 09 10:30:54 2005 -0600
    11.3 @@ -23,13 +23,8 @@ Stuff it doesn't show:
    11.4  
    11.5  - to build it just type make.
    11.6  
    11.7 -- copy image.final somewhere where dom0 can access it
    11.8 +- to start it do the following in domain0 (assuming xend is running)
    11.9 +  # xm create domain_config
   11.10  
   11.11 -- in dom0
   11.12 -  # xi_create 16000 test
   11.13 -    <domid>
   11.14 -  # xi_build <domid> image.final 0
   11.15 -  # xi_start <domid>
   11.16 -
   11.17 -this prints out a bunch of stuff and then every 1000 timer interrupts the
   11.18 -system time.
   11.19 +this starts the kernel and prints out a bunch of stuff and then every
   11.20 +1000 timer interrupts the system time.
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/extras/mini-os/domain_config	Fri Sep 09 10:30:54 2005 -0600
    12.3 @@ -0,0 +1,17 @@
    12.4 +#  -*- mode: python; -*-
    12.5 +#============================================================================
    12.6 +# Python configuration setup for 'xm create'.
    12.7 +# This script sets the parameters used when a domain is created using 'xm create'.
    12.8 +# You use a separate script for each domain you want to create, or 
    12.9 +# you can set the parameters for the domain on the xm command line.
   12.10 +#============================================================================
   12.11 +
   12.12 +#----------------------------------------------------------------------------
   12.13 +# Kernel image file.
   12.14 +kernel = "mini-os.elf"
   12.15 +
   12.16 +# Initial memory allocation (in megabytes) for the new domain.
   12.17 +memory = 32
   12.18 +
   12.19 +# A name for your domain. All domains must have different names.
   12.20 +name = "Mini-OS"
    13.1 --- a/extras/mini-os/events.c	Thu Sep 08 09:18:40 2005 -0600
    13.2 +++ b/extras/mini-os/events.c	Fri Sep 09 10:30:54 2005 -0600
    13.3 @@ -17,13 +17,13 @@
    13.4   */
    13.5  
    13.6  #include <os.h>
    13.7 +#include <mm.h>
    13.8  #include <hypervisor.h>
    13.9  #include <events.h>
   13.10  #include <lib.h>
   13.11  
   13.12 -#include <xen/event_channel.h>
   13.13  static ev_action_t ev_actions[NR_EVS];
   13.14 -void default_handler(u32 port, struct pt_regs *regs);
   13.15 +void default_handler(int port, struct pt_regs *regs);
   13.16  
   13.17  
   13.18  /*
   13.19 @@ -32,7 +32,6 @@ void default_handler(u32 port, struct pt
   13.20  int do_event(u32 port, struct pt_regs *regs)
   13.21  {
   13.22      ev_action_t  *action;
   13.23 -
   13.24      if (port >= NR_EVS) {
   13.25          printk("Port number too large: %d\n", port);
   13.26          return 0;
   13.27 @@ -57,11 +56,23 @@ int do_event(u32 port, struct pt_regs *r
   13.28  
   13.29  }
   13.30  
   13.31 +void bind_evtchn( u32 port, void (*handler)(int, struct pt_regs *) )
   13.32 +{
   13.33 + 	if(ev_actions[port].handler)
   13.34 +        printk("WARN: Handler for port %d already registered, replacing\n",
   13.35 +				port);
   13.36 +
   13.37 +	ev_actions[port].handler = handler;
   13.38 +	ev_actions[port].status &= ~EVS_DISABLED;	  
   13.39 + 
   13.40 +	/* Finally unmask the port */
   13.41 +	unmask_evtchn(port);
   13.42 +}
   13.43 +
   13.44  int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) )
   13.45  {
   13.46  	evtchn_op_t op;
   13.47  	int ret = 0;
   13.48 -	u32 port;
   13.49  
   13.50  	/* Try to bind the virq to a port */
   13.51  	op.cmd = EVTCHNOP_bind_virq;
   13.52 @@ -73,22 +84,13 @@ int bind_virq( u32 virq, void (*handler)
   13.53  		printk("Failed to bind virtual IRQ %d\n", virq);
   13.54  		goto out;
   13.55      }
   13.56 -
   13.57 -    port = op.u.bind_virq.port;
   13.58 -	
   13.59 -	if(ev_actions[port].handler)
   13.60 -        printk("WARN: Handler for port %d already registered, replacing\n",
   13.61 -				port);
   13.62 -
   13.63 -	ev_actions[port].handler = handler;
   13.64 -	ev_actions[port].status &= ~EVS_DISABLED;
   13.65 -	
   13.66 -	/* Finally unmask the port */
   13.67 -	unmask_evtchn(port);
   13.68 +    bind_evtchn(op.u.bind_virq.port, handler);	
   13.69  out:
   13.70  	return ret;
   13.71  }
   13.72  
   13.73 +
   13.74 +
   13.75  /*
   13.76   * Initially all events are without a handler and disabled
   13.77   */
   13.78 @@ -100,10 +102,10 @@ void init_events(void)
   13.79      for ( i = 0; i < NR_EVS; i++ )
   13.80      {
   13.81          ev_actions[i].status  = EVS_DISABLED;
   13.82 -        ev_actions[i].handler = NULL;
   13.83 +        ev_actions[i].handler = default_handler;
   13.84      }
   13.85  }
   13.86  
   13.87 -void default_handler(u32 port, struct pt_regs *regs) {
   13.88 +void default_handler(int port, struct pt_regs *regs) {
   13.89      printk("[Port %d] - event received\n", port);
   13.90  }
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/extras/mini-os/include/ctype.h	Fri Sep 09 10:30:54 2005 -0600
    14.3 @@ -0,0 +1,79 @@
    14.4 +#ifndef _CTYPE_H
    14.5 +#define _CTYPE_H
    14.6 +
    14.7 +/*
    14.8 + * NOTE! This ctype does not handle EOF like the standard C
    14.9 + * library is required to.
   14.10 + */
   14.11 +
   14.12 +#define _U	0x01	/* upper */
   14.13 +#define _L	0x02	/* lower */
   14.14 +#define _D	0x04	/* digit */
   14.15 +#define _C	0x08	/* cntrl */
   14.16 +#define _P	0x10	/* punct */
   14.17 +#define _S	0x20	/* white space (space/lf/tab) */
   14.18 +#define _X	0x40	/* hex digit */
   14.19 +#define _SP	0x80	/* hard space (0x20) */
   14.20 +
   14.21 +
   14.22 +unsigned char _ctype[] = {
   14.23 +_C,_C,_C,_C,_C,_C,_C,_C,                        /* 0-7 */
   14.24 +_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,         /* 8-15 */
   14.25 +_C,_C,_C,_C,_C,_C,_C,_C,                        /* 16-23 */
   14.26 +_C,_C,_C,_C,_C,_C,_C,_C,                        /* 24-31 */
   14.27 +_S|_SP,_P,_P,_P,_P,_P,_P,_P,                    /* 32-39 */
   14.28 +_P,_P,_P,_P,_P,_P,_P,_P,                        /* 40-47 */
   14.29 +_D,_D,_D,_D,_D,_D,_D,_D,                        /* 48-55 */
   14.30 +_D,_D,_P,_P,_P,_P,_P,_P,                        /* 56-63 */
   14.31 +_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U,      /* 64-71 */
   14.32 +_U,_U,_U,_U,_U,_U,_U,_U,                        /* 72-79 */
   14.33 +_U,_U,_U,_U,_U,_U,_U,_U,                        /* 80-87 */
   14.34 +_U,_U,_U,_P,_P,_P,_P,_P,                        /* 88-95 */
   14.35 +_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,      /* 96-103 */
   14.36 +_L,_L,_L,_L,_L,_L,_L,_L,                        /* 104-111 */
   14.37 +_L,_L,_L,_L,_L,_L,_L,_L,                        /* 112-119 */
   14.38 +_L,_L,_L,_P,_P,_P,_P,_C,                        /* 120-127 */
   14.39 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,                /* 128-143 */
   14.40 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,                /* 144-159 */
   14.41 +_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
   14.42 +_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
   14.43 +_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
   14.44 +_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
   14.45 +_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
   14.46 +_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
   14.47 +
   14.48 +#define __ismask(x) (_ctype[(int)(unsigned char)(x)])
   14.49 +
   14.50 +#define isalnum(c)	((__ismask(c)&(_U|_L|_D)) != 0)
   14.51 +#define isalpha(c)	((__ismask(c)&(_U|_L)) != 0)
   14.52 +#define iscntrl(c)	((__ismask(c)&(_C)) != 0)
   14.53 +#define isdigit(c)	((__ismask(c)&(_D)) != 0)
   14.54 +#define isgraph(c)	((__ismask(c)&(_P|_U|_L|_D)) != 0)
   14.55 +#define islower(c)	((__ismask(c)&(_L)) != 0)
   14.56 +#define isprint(c)	((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
   14.57 +#define ispunct(c)	((__ismask(c)&(_P)) != 0)
   14.58 +#define isspace(c)	((__ismask(c)&(_S)) != 0)
   14.59 +#define isupper(c)	((__ismask(c)&(_U)) != 0)
   14.60 +#define isxdigit(c)	((__ismask(c)&(_D|_X)) != 0)
   14.61 +
   14.62 +#define isascii(c) (((unsigned char)(c))<=0x7f)
   14.63 +#define toascii(c) (((unsigned char)(c))&0x7f)
   14.64 +
   14.65 +static inline unsigned char __tolower(unsigned char c)
   14.66 +{
   14.67 +	if (isupper(c))
   14.68 +		c -= 'A'-'a';
   14.69 +	return c;
   14.70 +}
   14.71 +
   14.72 +static inline unsigned char __toupper(unsigned char c)
   14.73 +{
   14.74 +	if (islower(c))
   14.75 +		c -= 'a'-'A';
   14.76 +	return c;
   14.77 +}
   14.78 +
   14.79 +#define tolower(c) __tolower(c)
   14.80 +#define toupper(c) __toupper(c)
   14.81 +
   14.82 +#endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/extras/mini-os/include/err.h	Fri Sep 09 10:30:54 2005 -0600
    15.3 @@ -0,0 +1,31 @@
    15.4 +#ifndef _ERR_H
    15.5 +#define _ERR_H
    15.6 +
    15.7 +#include <errno.h>
    15.8 +
    15.9 +/*
   15.10 + * Kernel pointers have redundant information, so we can use a
   15.11 + * scheme where we can return either an error code or a dentry
   15.12 + * pointer with the same return value.
   15.13 + *
   15.14 + * This should be a per-architecture thing, to allow different
   15.15 + * error and pointer decisions.
   15.16 + */
   15.17 +#define IS_ERR_VALUE(x) ((x) > (unsigned long)-1000L)
   15.18 +
   15.19 +static inline void *ERR_PTR(long error)
   15.20 +{
   15.21 +	return (void *) error;
   15.22 +}
   15.23 +
   15.24 +static inline long PTR_ERR(const void *ptr)
   15.25 +{
   15.26 +	return (long) ptr;
   15.27 +}
   15.28 +
   15.29 +static inline long IS_ERR(const void *ptr)
   15.30 +{
   15.31 +	return IS_ERR_VALUE((unsigned long)ptr);
   15.32 +}
   15.33 +
   15.34 +#endif /* _LINUX_ERR_H */
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/extras/mini-os/include/errno-base.h	Fri Sep 09 10:30:54 2005 -0600
    16.3 @@ -0,0 +1,39 @@
    16.4 +#ifndef _ERRNO_BASE_H
    16.5 +#define _ERRNO_BASE_H
    16.6 +
    16.7 +#define	EPERM		 1	/* Operation not permitted */
    16.8 +#define	ENOENT		 2	/* No such file or directory */
    16.9 +#define	ESRCH		 3	/* No such process */
   16.10 +#define	EINTR		 4	/* Interrupted system call */
   16.11 +#define	EIO		 5	/* I/O error */
   16.12 +#define	ENXIO		 6	/* No such device or address */
   16.13 +#define	E2BIG		 7	/* Argument list too long */
   16.14 +#define	ENOEXEC		 8	/* Exec format error */
   16.15 +#define	EBADF		 9	/* Bad file number */
   16.16 +#define	ECHILD		10	/* No child processes */
   16.17 +#define	EAGAIN		11	/* Try again */
   16.18 +#define	ENOMEM		12	/* Out of memory */
   16.19 +#define	EACCES		13	/* Permission denied */
   16.20 +#define	EFAULT		14	/* Bad address */
   16.21 +#define	ENOTBLK		15	/* Block device required */
   16.22 +#define	EBUSY		16	/* Device or resource busy */
   16.23 +#define	EEXIST		17	/* File exists */
   16.24 +#define	EXDEV		18	/* Cross-device link */
   16.25 +#define	ENODEV		19	/* No such device */
   16.26 +#define	ENOTDIR		20	/* Not a directory */
   16.27 +#define	EISDIR		21	/* Is a directory */
   16.28 +#define	EINVAL		22	/* Invalid argument */
   16.29 +#define	ENFILE		23	/* File table overflow */
   16.30 +#define	EMFILE		24	/* Too many open files */
   16.31 +#define	ENOTTY		25	/* Not a typewriter */
   16.32 +#define	ETXTBSY		26	/* Text file busy */
   16.33 +#define	EFBIG		27	/* File too large */
   16.34 +#define	ENOSPC		28	/* No space left on device */
   16.35 +#define	ESPIPE		29	/* Illegal seek */
   16.36 +#define	EROFS		30	/* Read-only file system */
   16.37 +#define	EMLINK		31	/* Too many links */
   16.38 +#define	EPIPE		32	/* Broken pipe */
   16.39 +#define	EDOM		33	/* Math argument out of domain of func */
   16.40 +#define	ERANGE		34	/* Math result not representable */
   16.41 +
   16.42 +#endif
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/extras/mini-os/include/errno.h	Fri Sep 09 10:30:54 2005 -0600
    17.3 @@ -0,0 +1,109 @@
    17.4 +#ifndef _ERRNO_H
    17.5 +#define _ERRNO_H
    17.6 +
    17.7 +#include <errno-base.h>
    17.8 +
    17.9 +#define	EDEADLK		35	/* Resource deadlock would occur */
   17.10 +#define	ENAMETOOLONG	36	/* File name too long */
   17.11 +#define	ENOLCK		37	/* No record locks available */
   17.12 +#define	ENOSYS		38	/* Function not implemented */
   17.13 +#define	ENOTEMPTY	39	/* Directory not empty */
   17.14 +#define	ELOOP		40	/* Too many symbolic links encountered */
   17.15 +#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
   17.16 +#define	ENOMSG		42	/* No message of desired type */
   17.17 +#define	EIDRM		43	/* Identifier removed */
   17.18 +#define	ECHRNG		44	/* Channel number out of range */
   17.19 +#define	EL2NSYNC	45	/* Level 2 not synchronized */
   17.20 +#define	EL3HLT		46	/* Level 3 halted */
   17.21 +#define	EL3RST		47	/* Level 3 reset */
   17.22 +#define	ELNRNG		48	/* Link number out of range */
   17.23 +#define	EUNATCH		49	/* Protocol driver not attached */
   17.24 +#define	ENOCSI		50	/* No CSI structure available */
   17.25 +#define	EL2HLT		51	/* Level 2 halted */
   17.26 +#define	EBADE		52	/* Invalid exchange */
   17.27 +#define	EBADR		53	/* Invalid request descriptor */
   17.28 +#define	EXFULL		54	/* Exchange full */
   17.29 +#define	ENOANO		55	/* No anode */
   17.30 +#define	EBADRQC		56	/* Invalid request code */
   17.31 +#define	EBADSLT		57	/* Invalid slot */
   17.32 +
   17.33 +#define	EDEADLOCK	EDEADLK
   17.34 +
   17.35 +#define	EBFONT		59	/* Bad font file format */
   17.36 +#define	ENOSTR		60	/* Device not a stream */
   17.37 +#define	ENODATA		61	/* No data available */
   17.38 +#define	ETIME		62	/* Timer expired */
   17.39 +#define	ENOSR		63	/* Out of streams resources */
   17.40 +#define	ENONET		64	/* Machine is not on the network */
   17.41 +#define	ENOPKG		65	/* Package not installed */
   17.42 +#define	EREMOTE		66	/* Object is remote */
   17.43 +#define	ENOLINK		67	/* Link has been severed */
   17.44 +#define	EADV		68	/* Advertise error */
   17.45 +#define	ESRMNT		69	/* Srmount error */
   17.46 +#define	ECOMM		70	/* Communication error on send */
   17.47 +#define	EPROTO		71	/* Protocol error */
   17.48 +#define	EMULTIHOP	72	/* Multihop attempted */
   17.49 +#define	EDOTDOT		73	/* RFS specific error */
   17.50 +#define	EBADMSG		74	/* Not a data message */
   17.51 +#define	EOVERFLOW	75	/* Value too large for defined data type */
   17.52 +#define	ENOTUNIQ	76	/* Name not unique on network */
   17.53 +#define	EBADFD		77	/* File descriptor in bad state */
   17.54 +#define	EREMCHG		78	/* Remote address changed */
   17.55 +#define	ELIBACC		79	/* Can not access a needed shared library */
   17.56 +#define	ELIBBAD		80	/* Accessing a corrupted shared library */
   17.57 +#define	ELIBSCN		81	/* .lib section in a.out corrupted */
   17.58 +#define	ELIBMAX		82	/* Attempting to link in too many shared libraries */
   17.59 +#define	ELIBEXEC	83	/* Cannot exec a shared library directly */
   17.60 +#define	EILSEQ		84	/* Illegal byte sequence */
   17.61 +#define	ERESTART	85	/* Interrupted system call should be restarted */
   17.62 +#define	ESTRPIPE	86	/* Streams pipe error */
   17.63 +#define	EUSERS		87	/* Too many users */
   17.64 +#define	ENOTSOCK	88	/* Socket operation on non-socket */
   17.65 +#define	EDESTADDRREQ	89	/* Destination address required */
   17.66 +#define	EMSGSIZE	90	/* Message too long */
   17.67 +#define	EPROTOTYPE	91	/* Protocol wrong type for socket */
   17.68 +#define	ENOPROTOOPT	92	/* Protocol not available */
   17.69 +#define	EPROTONOSUPPORT	93	/* Protocol not supported */
   17.70 +#define	ESOCKTNOSUPPORT	94	/* Socket type not supported */
   17.71 +#define	EOPNOTSUPP	95	/* Operation not supported on transport endpoint */
   17.72 +#define	EPFNOSUPPORT	96	/* Protocol family not supported */
   17.73 +#define	EAFNOSUPPORT	97	/* Address family not supported by protocol */
   17.74 +#define	EADDRINUSE	98	/* Address already in use */
   17.75 +#define	EADDRNOTAVAIL	99	/* Cannot assign requested address */
   17.76 +#define	ENETDOWN	100	/* Network is down */
   17.77 +#define	ENETUNREACH	101	/* Network is unreachable */
   17.78 +#define	ENETRESET	102	/* Network dropped connection because of reset */
   17.79 +#define	ECONNABORTED	103	/* Software caused connection abort */
   17.80 +#define	ECONNRESET	104	/* Connection reset by peer */
   17.81 +#define	ENOBUFS		105	/* No buffer space available */
   17.82 +#define	EISCONN		106	/* Transport endpoint is already connected */
   17.83 +#define	ENOTCONN	107	/* Transport endpoint is not connected */
   17.84 +#define	ESHUTDOWN	108	/* Cannot send after transport endpoint shutdown */
   17.85 +#define	ETOOMANYREFS	109	/* Too many references: cannot splice */
   17.86 +#define	ETIMEDOUT	110	/* Connection timed out */
   17.87 +#define	ECONNREFUSED	111	/* Connection refused */
   17.88 +#define	EHOSTDOWN	112	/* Host is down */
   17.89 +#define	EHOSTUNREACH	113	/* No route to host */
   17.90 +#define	EALREADY	114	/* Operation already in progress */
   17.91 +#define	EINPROGRESS	115	/* Operation now in progress */
   17.92 +#define	ESTALE		116	/* Stale NFS file handle */
   17.93 +#define	EUCLEAN		117	/* Structure needs cleaning */
   17.94 +#define	ENOTNAM		118	/* Not a XENIX named type file */
   17.95 +#define	ENAVAIL		119	/* No XENIX semaphores available */
   17.96 +#define	EISNAM		120	/* Is a named type file */
   17.97 +#define	EREMOTEIO	121	/* Remote I/O error */
   17.98 +#define	EDQUOT		122	/* Quota exceeded */
   17.99 +
  17.100 +#define	ENOMEDIUM	123	/* No medium found */
  17.101 +#define	EMEDIUMTYPE	124	/* Wrong medium type */
  17.102 +#define	ECANCELED	125	/* Operation Canceled */
  17.103 +#define	ENOKEY		126	/* Required key not available */
  17.104 +#define	EKEYEXPIRED	127	/* Key has expired */
  17.105 +#define	EKEYREVOKED	128	/* Key has been revoked */
  17.106 +#define	EKEYREJECTED	129	/* Key was rejected by service */
  17.107 +
  17.108 +/* for robust mutexes */
  17.109 +#define	EOWNERDEAD	130	/* Owner died */
  17.110 +#define	ENOTRECOVERABLE	131	/* State not recoverable */
  17.111 +
  17.112 +#endif
    18.1 --- a/extras/mini-os/include/events.h	Thu Sep 08 09:18:40 2005 -0600
    18.2 +++ b/extras/mini-os/include/events.h	Fri Sep 09 10:30:54 2005 -0600
    18.3 @@ -20,6 +20,7 @@
    18.4  #define _EVENTS_H_
    18.5  
    18.6  #include<traps.h>
    18.7 +#include <xen/event_channel.h>
    18.8  
    18.9  #define NR_EVS 1024
   18.10  
   18.11 @@ -39,6 +40,16 @@ typedef struct _ev_action_t {
   18.12  /* prototypes */
   18.13  int do_event(u32 port, struct pt_regs *regs);
   18.14  int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) );
   18.15 +void bind_evtchn( u32 virq, void (*handler)(int, struct pt_regs *) );
   18.16  void init_events(void);
   18.17  
   18.18 +static inline int notify_via_evtchn(int port)
   18.19 +{
   18.20 +    evtchn_op_t op;
   18.21 +    op.cmd = EVTCHNOP_send;
   18.22 +    op.u.send.local_port = port;
   18.23 +    return HYPERVISOR_event_channel_op(&op);
   18.24 +}
   18.25 +
   18.26 +
   18.27  #endif /* _EVENTS_H_ */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/extras/mini-os/include/fcntl.h	Fri Sep 09 10:30:54 2005 -0600
    19.3 @@ -0,0 +1,89 @@
    19.4 +#ifndef _I386_FCNTL_H
    19.5 +#define _I386_FCNTL_H
    19.6 +
    19.7 +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
    19.8 +   located on an ext2 file system */
    19.9 +#define O_ACCMODE	   0003
   19.10 +#define O_RDONLY	     00
   19.11 +#define O_WRONLY	     01
   19.12 +#define O_RDWR		     02
   19.13 +#define O_CREAT		   0100	/* not fcntl */
   19.14 +#define O_EXCL		   0200	/* not fcntl */
   19.15 +#define O_NOCTTY	   0400	/* not fcntl */
   19.16 +#define O_TRUNC		  01000	/* not fcntl */
   19.17 +#define O_APPEND	  02000
   19.18 +#define O_NONBLOCK	  04000
   19.19 +#define O_NDELAY	O_NONBLOCK
   19.20 +#define O_SYNC		 010000
   19.21 +#define FASYNC		 020000	/* fcntl, for BSD compatibility */
   19.22 +#define O_DIRECT	 040000	/* direct disk access hint */
   19.23 +#define O_LARGEFILE	0100000
   19.24 +#define O_DIRECTORY	0200000	/* must be a directory */
   19.25 +#define O_NOFOLLOW	0400000 /* don't follow links */
   19.26 +#define O_NOATIME	01000000
   19.27 +
   19.28 +#define F_DUPFD		0	/* dup */
   19.29 +#define F_GETFD		1	/* get close_on_exec */
   19.30 +#define F_SETFD		2	/* set/clear close_on_exec */
   19.31 +#define F_GETFL		3	/* get file->f_flags */
   19.32 +#define F_SETFL		4	/* set file->f_flags */
   19.33 +#define F_GETLK		5
   19.34 +#define F_SETLK		6
   19.35 +#define F_SETLKW	7
   19.36 +
   19.37 +#define F_SETOWN	8	/*  for sockets. */
   19.38 +#define F_GETOWN	9	/*  for sockets. */
   19.39 +#define F_SETSIG	10	/*  for sockets. */
   19.40 +#define F_GETSIG	11	/*  for sockets. */
   19.41 +
   19.42 +#define F_GETLK64	12	/*  using 'struct flock64' */
   19.43 +#define F_SETLK64	13
   19.44 +#define F_SETLKW64	14
   19.45 +
   19.46 +/* for F_[GET|SET]FL */
   19.47 +#define FD_CLOEXEC	1	/* actually anything with low bit set goes */
   19.48 +
   19.49 +/* for posix fcntl() and lockf() */
   19.50 +#define F_RDLCK		0
   19.51 +#define F_WRLCK		1
   19.52 +#define F_UNLCK		2
   19.53 +
   19.54 +/* for old implementation of bsd flock () */
   19.55 +#define F_EXLCK		4	/* or 3 */
   19.56 +#define F_SHLCK		8	/* or 4 */
   19.57 +
   19.58 +/* for leases */
   19.59 +#define F_INPROGRESS	16
   19.60 +
   19.61 +/* operations for bsd flock(), also used by the kernel implementation */
   19.62 +#define LOCK_SH		1	/* shared lock */
   19.63 +#define LOCK_EX		2	/* exclusive lock */
   19.64 +#define LOCK_NB		4	/* or'd with one of the above to prevent
   19.65 +				   blocking */
   19.66 +#define LOCK_UN		8	/* remove lock */
   19.67 +
   19.68 +#define LOCK_MAND	32	/* This is a mandatory flock */
   19.69 +#define LOCK_READ	64	/* ... Which allows concurrent read operations */
   19.70 +#define LOCK_WRITE	128	/* ... Which allows concurrent write operations */
   19.71 +#define LOCK_RW		192	/* ... Which allows concurrent read & write ops */
   19.72 +
   19.73 +/*
   19.74 +struct flock {
   19.75 +	short l_type;
   19.76 +	short l_whence;
   19.77 +	off_t l_start;
   19.78 +	off_t l_len;
   19.79 +	pid_t l_pid;
   19.80 +};
   19.81 +
   19.82 +struct flock64 {
   19.83 +	short  l_type;
   19.84 +	short  l_whence;
   19.85 +	loff_t l_start;
   19.86 +	loff_t l_len;
   19.87 +	pid_t  l_pid;
   19.88 +};
   19.89 +
   19.90 +#define F_LINUX_SPECIFIC_BASE	1024
   19.91 +*/
   19.92 +#endif
    20.1 --- a/extras/mini-os/include/hypervisor.h	Thu Sep 08 09:18:40 2005 -0600
    20.2 +++ b/extras/mini-os/include/hypervisor.h	Fri Sep 09 10:30:54 2005 -0600
    20.3 @@ -13,7 +13,6 @@
    20.4  #define _HYPERVISOR_H_
    20.5  
    20.6  #include <types.h>
    20.7 -
    20.8  #include <xen/xen.h>
    20.9  #include <xen/io/domain_controller.h>
   20.10  
   20.11 @@ -40,48 +39,43 @@ void clear_evtchn(u32 port);
   20.12  /*
   20.13   * Assembler stubs for hyper-calls.
   20.14   */
   20.15 -
   20.16 -#ifdef __i386__
   20.17 -#define _a1 "b"
   20.18 -#define _a2 "c"
   20.19 -#define _a3 "d"
   20.20 -#define _a4 "S"
   20.21 -#else
   20.22 -#define _a1 "D"
   20.23 -#define _a2 "S"
   20.24 -#define _a3 "d"
   20.25 -#define _a4 "b"
   20.26 -#endif
   20.27 -
   20.28 -static __inline__ int HYPERVISOR_event_channel_op(
   20.29 -    void *op)
   20.30 +#if defined(__i386__)
   20.31 +static inline int
   20.32 +HYPERVISOR_set_trap_table(
   20.33 +    trap_info_t *table)
   20.34  {
   20.35      int ret;
   20.36      unsigned long ignore;
   20.37 +
   20.38      __asm__ __volatile__ (
   20.39          TRAP_INSTR
   20.40          : "=a" (ret), "=b" (ignore)
   20.41 -	: "0" (__HYPERVISOR_event_channel_op), "1" (op)
   20.42 +	: "0" (__HYPERVISOR_set_trap_table), "1" (table)
   20.43  	: "memory" );
   20.44  
   20.45      return ret;
   20.46  }
   20.47  
   20.48 -static __inline__ int HYPERVISOR_set_trap_table(trap_info_t *table)
   20.49 +static inline int
   20.50 +HYPERVISOR_mmu_update(
   20.51 +    mmu_update_t *req, int count, int *success_count, domid_t domid)
   20.52  {
   20.53      int ret;
   20.54 +    unsigned long ign1, ign2, ign3, ign4;
   20.55 +
   20.56      __asm__ __volatile__ (
   20.57          TRAP_INSTR
   20.58 -        : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
   20.59 -        _a1 (table) : "memory" );
   20.60 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   20.61 +	: "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
   20.62 +        "3" (success_count), "4" (domid)
   20.63 +	: "memory" );
   20.64  
   20.65      return ret;
   20.66  }
   20.67  
   20.68 -static __inline__ int HYPERVISOR_mmu_update(mmu_update_t *req, 
   20.69 -                                            int count, 
   20.70 -                                            int *success_count, 
   20.71 -                                            domid_t domid)
   20.72 +static inline int
   20.73 +HYPERVISOR_mmuext_op(
   20.74 +    struct mmuext_op *op, int count, int *success_count, domid_t domid)
   20.75  {
   20.76      int ret;
   20.77      unsigned long ign1, ign2, ign3, ign4;
   20.78 @@ -89,18 +83,50 @@ static __inline__ int HYPERVISOR_mmu_upd
   20.79      __asm__ __volatile__ (
   20.80          TRAP_INSTR
   20.81          : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   20.82 -        : "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
   20.83 -          "3" (success_count), "4" (domid)
   20.84 -        : "memory" );
   20.85 +	: "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
   20.86 +        "3" (success_count), "4" (domid)
   20.87 +	: "memory" );
   20.88  
   20.89      return ret;
   20.90  }
   20.91  
   20.92 +static inline int
   20.93 +HYPERVISOR_set_gdt(
   20.94 +    unsigned long *frame_list, int entries)
   20.95 +{
   20.96 +    int ret;
   20.97 +    unsigned long ign1, ign2;
   20.98  
   20.99 -static __inline__ int HYPERVISOR_mmuext_op(struct mmuext_op *op, 
  20.100 -                                           int count, 
  20.101 -                                           int *success_count, 
  20.102 -                                           domid_t domid)
  20.103 +    __asm__ __volatile__ (
  20.104 +        TRAP_INSTR
  20.105 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.106 +	: "0" (__HYPERVISOR_set_gdt), "1" (frame_list), "2" (entries)
  20.107 +	: "memory" );
  20.108 +
  20.109 +
  20.110 +    return ret;
  20.111 +}
  20.112 +
  20.113 +static inline int
  20.114 +HYPERVISOR_stack_switch(
  20.115 +    unsigned long ss, unsigned long esp)
  20.116 +{
  20.117 +    int ret;
  20.118 +    unsigned long ign1, ign2;
  20.119 +
  20.120 +    __asm__ __volatile__ (
  20.121 +        TRAP_INSTR
  20.122 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.123 +	: "0" (__HYPERVISOR_stack_switch), "1" (ss), "2" (esp)
  20.124 +	: "memory" );
  20.125 +
  20.126 +    return ret;
  20.127 +}
  20.128 +
  20.129 +static inline int
  20.130 +HYPERVISOR_set_callbacks(
  20.131 +    unsigned long event_selector, unsigned long event_address,
  20.132 +    unsigned long failsafe_selector, unsigned long failsafe_address)
  20.133  {
  20.134      int ret;
  20.135      unsigned long ign1, ign2, ign3, ign4;
  20.136 @@ -108,70 +134,14 @@ static __inline__ int HYPERVISOR_mmuext_
  20.137      __asm__ __volatile__ (
  20.138          TRAP_INSTR
  20.139          : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
  20.140 -        : "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
  20.141 -          "3" (success_count), "4" (domid)
  20.142 -        : "memory" );
  20.143 -
  20.144 -    return ret;
  20.145 -}
  20.146 -
  20.147 -
  20.148 -
  20.149 -static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
  20.150 -{
  20.151 -    int ret;
  20.152 -    __asm__ __volatile__ (
  20.153 -        TRAP_INSTR
  20.154 -        : "=a" (ret) : "0" (__HYPERVISOR_set_gdt), 
  20.155 -        _a1 (frame_list), _a2 (entries) : "memory" );
  20.156 -
  20.157 -
  20.158 -    return ret;
  20.159 -}
  20.160 -
  20.161 -static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
  20.162 -{
  20.163 -    int ret;
  20.164 -    __asm__ __volatile__ (
  20.165 -        TRAP_INSTR
  20.166 -        : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
  20.167 -        _a1 (ss), _a2 (esp) : "memory" );
  20.168 +	: "0" (__HYPERVISOR_set_callbacks), "1" (event_selector),
  20.169 +	  "2" (event_address), "3" (failsafe_selector), "4" (failsafe_address)
  20.170 +	: "memory" );
  20.171  
  20.172      return ret;
  20.173  }
  20.174  
  20.175 -#ifdef __i386__
  20.176 -static __inline__ int HYPERVISOR_set_callbacks(
  20.177 -    unsigned long event_selector, unsigned long event_address,
  20.178 -    unsigned long failsafe_selector, unsigned long failsafe_address)
  20.179 -{
  20.180 -    int ret;
  20.181 -    __asm__ __volatile__ (
  20.182 -        TRAP_INSTR
  20.183 -        : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
  20.184 -        _a1 (event_selector), _a2 (event_address), 
  20.185 -        _a3 (failsafe_selector), _a4 (failsafe_address) : "memory" );
  20.186 -
  20.187 -    return ret;
  20.188 -}
  20.189 -#else
  20.190 -static __inline__ int HYPERVISOR_set_callbacks(
  20.191 -    unsigned long event_address,
  20.192 -    unsigned long failsafe_address,
  20.193 -    unsigned long syscall_address)
  20.194 -{
  20.195 -    int ret;
  20.196 -    __asm__ __volatile__ (
  20.197 -        TRAP_INSTR
  20.198 -        : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
  20.199 -        _a1 (event_address), _a2 (failsafe_address), 
  20.200 -        _a3 (syscall_address) : "memory" );
  20.201 -
  20.202 -    return ret;
  20.203 -}
  20.204 -#endif
  20.205 -
  20.206 -static __inline__ int
  20.207 +static inline int
  20.208  HYPERVISOR_fpu_taskswitch(
  20.209      int set)
  20.210  {
  20.211 @@ -187,67 +157,106 @@ HYPERVISOR_fpu_taskswitch(
  20.212      return ret;
  20.213  }
  20.214  
  20.215 -static __inline__ int HYPERVISOR_yield(void)
  20.216 +static inline int
  20.217 +HYPERVISOR_yield(
  20.218 +    void)
  20.219  {
  20.220      int ret;
  20.221 +    unsigned long ign;
  20.222 +
  20.223      __asm__ __volatile__ (
  20.224          TRAP_INSTR
  20.225 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  20.226 -        _a1 (SCHEDOP_yield) : "memory" );
  20.227 +        : "=a" (ret), "=b" (ign)
  20.228 +	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_yield)
  20.229 +	: "memory", "ecx" );
  20.230  
  20.231      return ret;
  20.232  }
  20.233  
  20.234 -static __inline__ int HYPERVISOR_block(void)
  20.235 +static inline int
  20.236 +HYPERVISOR_block(
  20.237 +    void)
  20.238  {
  20.239      int ret;
  20.240 +    unsigned long ign1;
  20.241      __asm__ __volatile__ (
  20.242          TRAP_INSTR
  20.243 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  20.244 -        _a1 (SCHEDOP_block) : "memory" );
  20.245 +        : "=a" (ret), "=b" (ign1)
  20.246 +	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_block)
  20.247 +	: "memory", "ecx" );
  20.248 +
  20.249 +    return ret;
  20.250 +}
  20.251 +
  20.252 +static inline int
  20.253 +HYPERVISOR_shutdown(
  20.254 +    void)
  20.255 +{
  20.256 +    int ret;
  20.257 +    unsigned long ign1;
  20.258 +    __asm__ __volatile__ (
  20.259 +        TRAP_INSTR
  20.260 +        : "=a" (ret), "=b" (ign1)
  20.261 +	: "0" (__HYPERVISOR_sched_op),
  20.262 +	  "1" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
  20.263 +        : "memory", "ecx" );
  20.264  
  20.265      return ret;
  20.266  }
  20.267  
  20.268 -static __inline__ int HYPERVISOR_shutdown(void)
  20.269 +static inline int
  20.270 +HYPERVISOR_reboot(
  20.271 +    void)
  20.272  {
  20.273      int ret;
  20.274 +    unsigned long ign1;
  20.275      __asm__ __volatile__ (
  20.276          TRAP_INSTR
  20.277 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  20.278 -        _a1 (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
  20.279 -        : "memory" );
  20.280 +        : "=a" (ret), "=b" (ign1)
  20.281 +	: "0" (__HYPERVISOR_sched_op),
  20.282 +	  "1" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
  20.283 +        : "memory", "ecx" );
  20.284  
  20.285      return ret;
  20.286  }
  20.287  
  20.288 -static __inline__ int HYPERVISOR_reboot(void)
  20.289 +static inline int
  20.290 +HYPERVISOR_suspend(
  20.291 +    unsigned long srec)
  20.292  {
  20.293      int ret;
  20.294 +    unsigned long ign1, ign2;
  20.295 +
  20.296 +    /* NB. On suspend, control software expects a suspend record in %esi. */
  20.297      __asm__ __volatile__ (
  20.298          TRAP_INSTR
  20.299 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  20.300 -        _a1 (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
  20.301 -        : "memory" );
  20.302 +        : "=a" (ret), "=b" (ign1), "=S" (ign2)
  20.303 +	: "0" (__HYPERVISOR_sched_op),
  20.304 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
  20.305 +        "S" (srec) : "memory", "ecx");
  20.306  
  20.307      return ret;
  20.308  }
  20.309  
  20.310 -static __inline__ int HYPERVISOR_suspend(unsigned long srec)
  20.311 +static inline int
  20.312 +HYPERVISOR_crash(
  20.313 +    void)
  20.314  {
  20.315      int ret;
  20.316 -    /* NB. On suspend, control software expects a suspend record in %esi. */
  20.317 +    unsigned long ign1;
  20.318      __asm__ __volatile__ (
  20.319          TRAP_INSTR
  20.320 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  20.321 -        _a1 (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
  20.322 -        "S" (srec) : "memory" );
  20.323 +        : "=a" (ret), "=b" (ign1)
  20.324 +	: "0" (__HYPERVISOR_sched_op),
  20.325 +	  "1" (SCHEDOP_shutdown | (SHUTDOWN_crash << SCHEDOP_reasonshift))
  20.326 +        : "memory", "ecx" );
  20.327  
  20.328      return ret;
  20.329  }
  20.330  
  20.331 -#ifdef __i386__
  20.332 -static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
  20.333 +static inline long
  20.334 +HYPERVISOR_set_timer_op(
  20.335 +    u64 timeout)
  20.336  {
  20.337      int ret;
  20.338      unsigned long timeout_hi = (unsigned long)(timeout>>32);
  20.339 @@ -262,8 +271,516 @@ static __inline__ long HYPERVISOR_set_ti
  20.340  
  20.341      return ret;
  20.342  }
  20.343 +
  20.344 +#if 0
  20.345 +static inline int
  20.346 +HYPERVISOR_dom0_op(
  20.347 +    dom0_op_t *dom0_op)
  20.348 +{
  20.349 +    int ret;
  20.350 +    unsigned long ign1;
  20.351 +
  20.352 +    dom0_op->interface_version = DOM0_INTERFACE_VERSION;
  20.353 +    __asm__ __volatile__ (
  20.354 +        TRAP_INSTR
  20.355 +        : "=a" (ret), "=b" (ign1)
  20.356 +	: "0" (__HYPERVISOR_dom0_op), "1" (dom0_op)
  20.357 +	: "memory");
  20.358 +
  20.359 +    return ret;
  20.360 +}
  20.361 +#endif
  20.362 +
  20.363 +static inline int
  20.364 +HYPERVISOR_set_debugreg(
  20.365 +    int reg, unsigned long value)
  20.366 +{
  20.367 +    int ret;
  20.368 +    unsigned long ign1, ign2;
  20.369 +    __asm__ __volatile__ (
  20.370 +        TRAP_INSTR
  20.371 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.372 +	: "0" (__HYPERVISOR_set_debugreg), "1" (reg), "2" (value)
  20.373 +	: "memory" );
  20.374 +
  20.375 +    return ret;
  20.376 +}
  20.377 +
  20.378 +static inline unsigned long
  20.379 +HYPERVISOR_get_debugreg(
  20.380 +    int reg)
  20.381 +{
  20.382 +    unsigned long ret;
  20.383 +    unsigned long ign;
  20.384 +    __asm__ __volatile__ (
  20.385 +        TRAP_INSTR
  20.386 +        : "=a" (ret), "=b" (ign)
  20.387 +	: "0" (__HYPERVISOR_get_debugreg), "1" (reg)
  20.388 +	: "memory" );
  20.389 +
  20.390 +    return ret;
  20.391 +}
  20.392 +
  20.393 +static inline int
  20.394 +HYPERVISOR_update_descriptor(
  20.395 +    u64 ma, u64 desc)
  20.396 +{
  20.397 +    int ret;
  20.398 +    unsigned long ign1, ign2, ign3, ign4;
  20.399 +
  20.400 +    __asm__ __volatile__ (
  20.401 +        TRAP_INSTR
  20.402 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
  20.403 +	: "0" (__HYPERVISOR_update_descriptor),
  20.404 +	  "1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
  20.405 +	  "3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
  20.406 +	: "memory" );
  20.407 +
  20.408 +    return ret;
  20.409 +}
  20.410 +
  20.411 +static inline int
  20.412 +HYPERVISOR_dom_mem_op(
  20.413 +    unsigned int op, unsigned long *extent_list,
  20.414 +    unsigned long nr_extents, unsigned int extent_order)
  20.415 +{
  20.416 +    int ret;
  20.417 +    unsigned long ign1, ign2, ign3, ign4, ign5;
  20.418 +
  20.419 +    __asm__ __volatile__ (
  20.420 +        TRAP_INSTR
  20.421 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4),
  20.422 +	  "=D" (ign5)
  20.423 +	: "0" (__HYPERVISOR_dom_mem_op), "1" (op), "2" (extent_list),
  20.424 +	  "3" (nr_extents), "4" (extent_order), "5" (DOMID_SELF)
  20.425 +        : "memory" );
  20.426 +
  20.427 +    return ret;
  20.428 +}
  20.429 +
  20.430 +static inline int
  20.431 +HYPERVISOR_multicall(
  20.432 +    void *call_list, int nr_calls)
  20.433 +{
  20.434 +    int ret;
  20.435 +    unsigned long ign1, ign2;
  20.436 +
  20.437 +    __asm__ __volatile__ (
  20.438 +        TRAP_INSTR
  20.439 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.440 +	: "0" (__HYPERVISOR_multicall), "1" (call_list), "2" (nr_calls)
  20.441 +	: "memory" );
  20.442 +
  20.443 +    return ret;
  20.444 +}
  20.445 +
  20.446 +static inline int
  20.447 +HYPERVISOR_update_va_mapping(
  20.448 +    unsigned long va, pte_t new_val, unsigned long flags)
  20.449 +{
  20.450 +    int ret;
  20.451 +    unsigned long ign1, ign2, ign3, ign4;
  20.452 +
  20.453 +    __asm__ __volatile__ (
  20.454 +        TRAP_INSTR
  20.455 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
  20.456 +	: "0" (__HYPERVISOR_update_va_mapping), 
  20.457 +          "1" (va), "2" ((new_val).pte_low),
  20.458 +#ifdef CONFIG_X86_PAE
  20.459 +	  "3" ((new_val).pte_high),
  20.460  #else
  20.461 -static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
  20.462 +	  "3" (0),
  20.463 +#endif
  20.464 +	  "4" (flags)
  20.465 +	: "memory" );
  20.466 +
  20.467 +    return ret;
  20.468 +}
  20.469 +
  20.470 +static inline int
  20.471 +HYPERVISOR_event_channel_op(
  20.472 +    void *op)
  20.473 +{
  20.474 +    int ret;
  20.475 +    unsigned long ignore;
  20.476 +    __asm__ __volatile__ (
  20.477 +        TRAP_INSTR
  20.478 +        : "=a" (ret), "=b" (ignore)
  20.479 +	: "0" (__HYPERVISOR_event_channel_op), "1" (op)
  20.480 +	: "memory" );
  20.481 +
  20.482 +    return ret;
  20.483 +}
  20.484 +
  20.485 +static inline int
  20.486 +HYPERVISOR_xen_version(
  20.487 +    int cmd)
  20.488 +{
  20.489 +    int ret;
  20.490 +    unsigned long ignore;
  20.491 +
  20.492 +    __asm__ __volatile__ (
  20.493 +        TRAP_INSTR
  20.494 +        : "=a" (ret), "=b" (ignore)
  20.495 +	: "0" (__HYPERVISOR_xen_version), "1" (cmd)
  20.496 +	: "memory" );
  20.497 +
  20.498 +    return ret;
  20.499 +}
  20.500 +
  20.501 +static inline int
  20.502 +HYPERVISOR_console_io(
  20.503 +    int cmd, int count, char *str)
  20.504 +{
  20.505 +    int ret;
  20.506 +    unsigned long ign1, ign2, ign3;
  20.507 +    __asm__ __volatile__ (
  20.508 +        TRAP_INSTR
  20.509 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
  20.510 +	: "0" (__HYPERVISOR_console_io), "1" (cmd), "2" (count), "3" (str)
  20.511 +	: "memory" );
  20.512 +
  20.513 +    return ret;
  20.514 +}
  20.515 +
  20.516 +static inline int
  20.517 +HYPERVISOR_physdev_op(
  20.518 +    void *physdev_op)
  20.519 +{
  20.520 +    int ret;
  20.521 +    unsigned long ign;
  20.522 +
  20.523 +    __asm__ __volatile__ (
  20.524 +        TRAP_INSTR
  20.525 +        : "=a" (ret), "=b" (ign)
  20.526 +	: "0" (__HYPERVISOR_physdev_op), "1" (physdev_op)
  20.527 +	: "memory" );
  20.528 +
  20.529 +    return ret;
  20.530 +}
  20.531 +
  20.532 +static inline int
  20.533 +HYPERVISOR_grant_table_op(
  20.534 +    unsigned int cmd, void *uop, unsigned int count)
  20.535 +{
  20.536 +    int ret;
  20.537 +    unsigned long ign1, ign2, ign3;
  20.538 +
  20.539 +    __asm__ __volatile__ (
  20.540 +        TRAP_INSTR
  20.541 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
  20.542 +	: "0" (__HYPERVISOR_grant_table_op), "1" (cmd), "2" (uop), "3" (count)
  20.543 +	: "memory" );
  20.544 +
  20.545 +    return ret;
  20.546 +}
  20.547 +
  20.548 +static inline int
  20.549 +HYPERVISOR_update_va_mapping_otherdomain(
  20.550 +    unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
  20.551 +{
  20.552 +    int ret;
  20.553 +    unsigned long ign1, ign2, ign3, ign4, ign5;
  20.554 +
  20.555 +    __asm__ __volatile__ (
  20.556 +        TRAP_INSTR
  20.557 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3),
  20.558 +	  "=S" (ign4), "=D" (ign5)
  20.559 +	: "0" (__HYPERVISOR_update_va_mapping_otherdomain),
  20.560 +          "1" (va), "2" ((new_val).pte_low),
  20.561 +#ifdef CONFIG_X86_PAE
  20.562 +	  "3" ((new_val).pte_high),
  20.563 +#else
  20.564 +	  "3" (0),
  20.565 +#endif
  20.566 +	  "4" (flags), "5" (domid) :
  20.567 +        "memory" );
  20.568 +    
  20.569 +    return ret;
  20.570 +}
  20.571 +
  20.572 +static inline int
  20.573 +HYPERVISOR_vm_assist(
  20.574 +    unsigned int cmd, unsigned int type)
  20.575 +{
  20.576 +    int ret;
  20.577 +    unsigned long ign1, ign2;
  20.578 +
  20.579 +    __asm__ __volatile__ (
  20.580 +        TRAP_INSTR
  20.581 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.582 +	: "0" (__HYPERVISOR_vm_assist), "1" (cmd), "2" (type)
  20.583 +	: "memory" );
  20.584 +
  20.585 +    return ret;
  20.586 +}
  20.587 +
  20.588 +static inline int
  20.589 +HYPERVISOR_boot_vcpu(
  20.590 +    unsigned long vcpu, vcpu_guest_context_t *ctxt)
  20.591 +{
  20.592 +    int ret;
  20.593 +    unsigned long ign1, ign2;
  20.594 +
  20.595 +    __asm__ __volatile__ (
  20.596 +        TRAP_INSTR
  20.597 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.598 +	: "0" (__HYPERVISOR_boot_vcpu), "1" (vcpu), "2" (ctxt)
  20.599 +	: "memory");
  20.600 +
  20.601 +    return ret;
  20.602 +}
  20.603 +
  20.604 +static inline int
  20.605 +HYPERVISOR_vcpu_down(
  20.606 +    int vcpu)
  20.607 +{
  20.608 +    int ret;
  20.609 +    unsigned long ign1;
  20.610 +    /* Yes, I really do want to clobber edx here: when we resume a
  20.611 +       vcpu after unpickling a multi-processor domain, it returns
  20.612 +       here, but clobbers all of the call clobbered registers. */
  20.613 +    __asm__ __volatile__ (
  20.614 +        TRAP_INSTR
  20.615 +        : "=a" (ret), "=b" (ign1)
  20.616 +	: "0" (__HYPERVISOR_sched_op),
  20.617 +	  "1" (SCHEDOP_vcpu_down | (vcpu << SCHEDOP_vcpushift))
  20.618 +        : "memory", "ecx", "edx" );
  20.619 +
  20.620 +    return ret;
  20.621 +}
  20.622 +
  20.623 +static inline int
  20.624 +HYPERVISOR_vcpu_up(
  20.625 +    int vcpu)
  20.626 +{
  20.627 +    int ret;
  20.628 +    unsigned long ign1;
  20.629 +    __asm__ __volatile__ (
  20.630 +        TRAP_INSTR
  20.631 +        : "=a" (ret), "=b" (ign1)
  20.632 +	: "0" (__HYPERVISOR_sched_op),
  20.633 +	  "1" (SCHEDOP_vcpu_up | (vcpu << SCHEDOP_vcpushift))
  20.634 +        : "memory", "ecx" );
  20.635 +
  20.636 +    return ret;
  20.637 +}
  20.638 +
  20.639 +static inline int
  20.640 +HYPERVISOR_vcpu_pickle(
  20.641 +    int vcpu, vcpu_guest_context_t *ctxt)
  20.642 +{
  20.643 +    int ret;
  20.644 +    unsigned long ign1, ign2;
  20.645 +    __asm__ __volatile__ (
  20.646 +        TRAP_INSTR
  20.647 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  20.648 +	: "0" (__HYPERVISOR_sched_op),
  20.649 +	  "1" (SCHEDOP_vcpu_pickle | (vcpu << SCHEDOP_vcpushift)),
  20.650 +	  "2" (ctxt)
  20.651 +        : "memory" );
  20.652 +
  20.653 +    return ret;
  20.654 +}
  20.655 +#elif defined(__x86_64__)
  20.656 +
  20.657 +#define __syscall_clobber "r11","rcx","memory"
  20.658 +
  20.659 +/*
  20.660 + * Assembler stubs for hyper-calls.
  20.661 + */
  20.662 +static inline int
  20.663 +HYPERVISOR_set_trap_table(
  20.664 +    trap_info_t *table)
  20.665 +{
  20.666 +    int ret;
  20.667 +
  20.668 +    __asm__ __volatile__ (
  20.669 +        TRAP_INSTR
  20.670 +        : "=a" (ret)
  20.671 +	: "0" ((unsigned long)__HYPERVISOR_set_trap_table), "D" (table)
  20.672 +	: __syscall_clobber );
  20.673 +
  20.674 +    return ret;
  20.675 +}
  20.676 +
  20.677 +static inline int
  20.678 +HYPERVISOR_mmu_update(
  20.679 +    mmu_update_t *req, int count, int *success_count, domid_t domid)
  20.680 +{
  20.681 +    int ret;
  20.682 +
  20.683 +    __asm__ __volatile__ (
  20.684 +        "movq %5, %%r10;" TRAP_INSTR
  20.685 +        : "=a" (ret)
  20.686 +	: "0" ((unsigned long)__HYPERVISOR_mmu_update), "D" (req), "S" ((long)count),
  20.687 +	  "d" (success_count), "g" ((unsigned long)domid)
  20.688 +	: __syscall_clobber, "r10" );
  20.689 +
  20.690 +    return ret;
  20.691 +}
  20.692 +
  20.693 +static inline int
  20.694 +HYPERVISOR_mmuext_op(
  20.695 +    struct mmuext_op *op, int count, int *success_count, domid_t domid)
  20.696 +{
  20.697 +    int ret;
  20.698 +
  20.699 +    __asm__ __volatile__ (
  20.700 +        "movq %5, %%r10;" TRAP_INSTR
  20.701 +        : "=a" (ret)
  20.702 +        : "0" (__HYPERVISOR_mmuext_op), "D" (op), "S" ((long)count), 
  20.703 +          "d" (success_count), "g" ((unsigned long)domid)
  20.704 +        : __syscall_clobber, "r10" );
  20.705 +
  20.706 +    return ret;
  20.707 +}
  20.708 +
  20.709 +static inline int
  20.710 +HYPERVISOR_set_gdt(
  20.711 +    unsigned long *frame_list, int entries)
  20.712 +{
  20.713 +    int ret;
  20.714 +
  20.715 +    __asm__ __volatile__ (
  20.716 +        TRAP_INSTR
  20.717 +        : "=a" (ret)
  20.718 +	: "0" ((unsigned long)__HYPERVISOR_set_gdt), "D" (frame_list), "S" ((long)entries)
  20.719 +	: __syscall_clobber );
  20.720 +
  20.721 +
  20.722 +    return ret;
  20.723 +}
  20.724 +static inline int
  20.725 +HYPERVISOR_stack_switch(
  20.726 +    unsigned long ss, unsigned long esp)
  20.727 +{
  20.728 +    int ret;
  20.729 +
  20.730 +    __asm__ __volatile__ (
  20.731 +        TRAP_INSTR
  20.732 +        : "=a" (ret)
  20.733 +	: "0" ((unsigned long)__HYPERVISOR_stack_switch), "D" (ss), "S" (esp)
  20.734 +	: __syscall_clobber );
  20.735 +
  20.736 +    return ret;
  20.737 +}
  20.738 +
  20.739 +static inline int
  20.740 +HYPERVISOR_set_callbacks(
  20.741 +    unsigned long event_address, unsigned long failsafe_address, 
  20.742 +    unsigned long syscall_address)
  20.743 +{
  20.744 +    int ret;
  20.745 +
  20.746 +    __asm__ __volatile__ (
  20.747 +        TRAP_INSTR
  20.748 +        : "=a" (ret)
  20.749 +	: "0" ((unsigned long)__HYPERVISOR_set_callbacks), "D" (event_address),
  20.750 +	  "S" (failsafe_address), "d" (syscall_address)
  20.751 +	: __syscall_clobber );
  20.752 +
  20.753 +    return ret;
  20.754 +}
  20.755 +
  20.756 +static inline int
  20.757 +HYPERVISOR_fpu_taskswitch(
  20.758 +    int set)
  20.759 +{
  20.760 +    int ret;
  20.761 +    __asm__ __volatile__ (
  20.762 +        TRAP_INSTR
  20.763 +        : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_fpu_taskswitch),
  20.764 +          "D" ((unsigned long) set) : __syscall_clobber );
  20.765 +
  20.766 +    return ret;
  20.767 +}
  20.768 +
  20.769 +static inline int
  20.770 +HYPERVISOR_yield(
  20.771 +    void)
  20.772 +{
  20.773 +    int ret;
  20.774 +
  20.775 +    __asm__ __volatile__ (
  20.776 +        TRAP_INSTR
  20.777 +        : "=a" (ret)
  20.778 +	: "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_yield)
  20.779 +	: __syscall_clobber );
  20.780 +
  20.781 +    return ret;
  20.782 +}
  20.783 +
  20.784 +static inline int
  20.785 +HYPERVISOR_block(
  20.786 +    void)
  20.787 +{
  20.788 +    int ret;
  20.789 +    __asm__ __volatile__ (
  20.790 +        TRAP_INSTR
  20.791 +        : "=a" (ret)
  20.792 +	: "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_block)
  20.793 +	: __syscall_clobber );
  20.794 +
  20.795 +    return ret;
  20.796 +}
  20.797 +
  20.798 +static inline int
  20.799 +HYPERVISOR_shutdown(
  20.800 +    void)
  20.801 +{
  20.802 +    int ret;
  20.803 +    __asm__ __volatile__ (
  20.804 +        TRAP_INSTR
  20.805 +        : "=a" (ret)
  20.806 +	: "0" ((unsigned long)__HYPERVISOR_sched_op),
  20.807 +	  "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift)))
  20.808 +	: __syscall_clobber );
  20.809 +
  20.810 +    return ret;
  20.811 +}
  20.812 +
  20.813 +static inline int
  20.814 +HYPERVISOR_reboot(
  20.815 +    void)
  20.816 +{
  20.817 +    int ret;
  20.818 +
  20.819 +    __asm__ __volatile__ (
  20.820 +        TRAP_INSTR
  20.821 +        : "=a" (ret)
  20.822 +	: "0" ((unsigned long)__HYPERVISOR_sched_op),
  20.823 +	  "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift)))
  20.824 +	: __syscall_clobber );
  20.825 +
  20.826 +    return ret;
  20.827 +}
  20.828 +
  20.829 +static inline int
  20.830 +HYPERVISOR_suspend(
  20.831 +    unsigned long srec)
  20.832 +{
  20.833 +    int ret;
  20.834 +
  20.835 +    /* NB. On suspend, control software expects a suspend record in %esi. */
  20.836 +    __asm__ __volatile__ (
  20.837 +        TRAP_INSTR
  20.838 +        : "=a" (ret)
  20.839 +	: "0" ((unsigned long)__HYPERVISOR_sched_op),
  20.840 +        "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift))), 
  20.841 +        "S" (srec)
  20.842 +	: __syscall_clobber );
  20.843 +
  20.844 +    return ret;
  20.845 +}
  20.846 +
  20.847 +/*
  20.848 + * We can have the timeout value in a single argument for the hypercall, but
  20.849 + * that will break the common code. 
  20.850 + */
  20.851 +static inline long
  20.852 +HYPERVISOR_set_timer_op(
  20.853 +    u64 timeout)
  20.854  {
  20.855      int ret;
  20.856  
  20.857 @@ -329,7 +846,7 @@ static __inline__ int HYPERVISOR_dom_mem
  20.858      int ret;
  20.859      __asm__ __volatile__ (
  20.860          TRAP_INSTR
  20.861 -        : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
  20.862 +        : "=a" (ret) : "0" (__HYPERVISOR_memory_op),
  20.863          _a1 (dom_mem_op) : "memory" );
  20.864  
  20.865      return ret;
    21.1 --- a/extras/mini-os/include/lib.h	Thu Sep 08 09:18:40 2005 -0600
    21.2 +++ b/extras/mini-os/include/lib.h	Fri Sep 09 10:30:54 2005 -0600
    21.3 @@ -60,10 +60,22 @@
    21.4  /* printing */
    21.5  #define printk  printf
    21.6  #define kprintf printf
    21.7 -int printf(const char *fmt, ...);
    21.8 -int vprintf(const char *fmt, va_list ap);
    21.9 -int sprintf(char *buf, const char *cfmt, ...);
   21.10 -int vsprintf(char *buf, const char *cfmt, va_list ap);
   21.11 +#define _p(_x) ((void *)(unsigned long)(_x))
   21.12 +void printf(const char *fmt, ...);
   21.13 +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
   21.14 +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
   21.15 +int snprintf(char * buf, size_t size, const char *fmt, ...);
   21.16 +int scnprintf(char * buf, size_t size, const char *fmt, ...);
   21.17 +int vsprintf(char *buf, const char *fmt, va_list args);
   21.18 +int sprintf(char * buf, const char *fmt, ...);
   21.19 +int vsscanf(const char * buf, const char * fmt, va_list args);
   21.20 +int sscanf(const char * buf, const char * fmt, ...);
   21.21 +
   21.22 +long simple_strtol(const char *cp,char **endp,unsigned int base);
   21.23 +unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
   21.24 +long long simple_strtoll(const char *cp,char **endp,unsigned int base);
   21.25 +unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
   21.26 +
   21.27  
   21.28  /* string and memory manipulation */
   21.29  int    memcmp(const void *cs, const void *ct, size_t count);
   21.30 @@ -77,6 +89,16 @@ size_t strnlen(const char *s, size_t cou
   21.31  size_t strlen(const char *s);
   21.32  char  *strchr(const char *s, int c);
   21.33  char  *strstr(const char *s1, const char *s2);
   21.34 +char * strcat(char * dest, const char * src);
   21.35 +
   21.36 +
   21.37 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
   21.38 +
   21.39 +struct kvec {
   21.40 +    void *iov_base;
   21.41 +    size_t iov_len;
   21.42 +};
   21.43 +
   21.44  
   21.45  
   21.46  #endif /* _LIB_H_ */
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/extras/mini-os/include/list.h	Fri Sep 09 10:30:54 2005 -0600
    22.3 @@ -0,0 +1,184 @@
    22.4 +#ifndef _LINUX_LIST_H
    22.5 +#define _LINUX_LIST_H
    22.6 +
    22.7 +/*
    22.8 + * Simple doubly linked list implementation.
    22.9 + *
   22.10 + * Some of the internal functions ("__xxx") are useful when
   22.11 + * manipulating whole lists rather than single entries, as
   22.12 + * sometimes we already know the next/prev entries and we can
   22.13 + * generate better code by using them directly rather than
   22.14 + * using the generic single-entry routines.
   22.15 + */
   22.16 +
   22.17 +struct list_head {
   22.18 +	struct list_head *next, *prev;
   22.19 +};
   22.20 +
   22.21 +#define LIST_HEAD_INIT(name) { &(name), &(name) }
   22.22 +
   22.23 +#define LIST_HEAD(name) \
   22.24 +	struct list_head name = LIST_HEAD_INIT(name)
   22.25 +
   22.26 +#define INIT_LIST_HEAD(ptr) do { \
   22.27 +	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
   22.28 +} while (0)
   22.29 +
   22.30 +/*
   22.31 + * Insert a new entry between two known consecutive entries. 
   22.32 + *
   22.33 + * This is only for internal list manipulation where we know
   22.34 + * the prev/next entries already!
   22.35 + */
   22.36 +static __inline__ void __list_add(struct list_head * new,
   22.37 +	struct list_head * prev,
   22.38 +	struct list_head * next)
   22.39 +{
   22.40 +	next->prev = new;
   22.41 +	new->next = next;
   22.42 +	new->prev = prev;
   22.43 +	prev->next = new;
   22.44 +}
   22.45 +
   22.46 +/**
   22.47 + * list_add - add a new entry
   22.48 + * @new: new entry to be added
   22.49 + * @head: list head to add it after
   22.50 + *
   22.51 + * Insert a new entry after the specified head.
   22.52 + * This is good for implementing stacks.
   22.53 + */
   22.54 +static __inline__ void list_add(struct list_head *new, struct list_head *head)
   22.55 +{
   22.56 +	__list_add(new, head, head->next);
   22.57 +}
   22.58 +
   22.59 +/**
   22.60 + * list_add_tail - add a new entry
   22.61 + * @new: new entry to be added
   22.62 + * @head: list head to add it before
   22.63 + *
   22.64 + * Insert a new entry before the specified head.
   22.65 + * This is useful for implementing queues.
   22.66 + */
   22.67 +static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
   22.68 +{
   22.69 +	__list_add(new, head->prev, head);
   22.70 +}
   22.71 +
   22.72 +/*
   22.73 + * Delete a list entry by making the prev/next entries
   22.74 + * point to each other.
   22.75 + *
   22.76 + * This is only for internal list manipulation where we know
   22.77 + * the prev/next entries already!
   22.78 + */
   22.79 +static __inline__ void __list_del(struct list_head * prev,
   22.80 +				  struct list_head * next)
   22.81 +{
   22.82 +	next->prev = prev;
   22.83 +	prev->next = next;
   22.84 +}
   22.85 +
   22.86 +/**
   22.87 + * list_del - deletes entry from list.
   22.88 + * @entry: the element to delete from the list.
   22.89 + * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
   22.90 + */
   22.91 +static __inline__ void list_del(struct list_head *entry)
   22.92 +{
   22.93 +	__list_del(entry->prev, entry->next);
   22.94 +}
   22.95 +
   22.96 +/**
   22.97 + * list_del_init - deletes entry from list and reinitialize it.
   22.98 + * @entry: the element to delete from the list.
   22.99 + */
  22.100 +static __inline__ void list_del_init(struct list_head *entry)
  22.101 +{
  22.102 +	__list_del(entry->prev, entry->next);
  22.103 +	INIT_LIST_HEAD(entry); 
  22.104 +}
  22.105 +
  22.106 +/**
  22.107 + * list_empty - tests whether a list is empty
  22.108 + * @head: the list to test.
  22.109 + */
  22.110 +static __inline__ int list_empty(struct list_head *head)
  22.111 +{
  22.112 +	return head->next == head;
  22.113 +}
  22.114 +
  22.115 +/**
  22.116 + * list_splice - join two lists
  22.117 + * @list: the new list to add.
  22.118 + * @head: the place to add it in the first list.
  22.119 + */
  22.120 +static __inline__ void list_splice(struct list_head *list, struct list_head *head)
  22.121 +{
  22.122 +	struct list_head *first = list->next;
  22.123 +
  22.124 +	if (first != list) {
  22.125 +		struct list_head *last = list->prev;
  22.126 +		struct list_head *at = head->next;
  22.127 +
  22.128 +		first->prev = head;
  22.129 +		head->next = first;
  22.130 +
  22.131 +		last->next = at;
  22.132 +		at->prev = last;
  22.133 +	}
  22.134 +}
  22.135 +
  22.136 +/**
  22.137 + * list_entry - get the struct for this entry
  22.138 + * @ptr:	the &struct list_head pointer.
  22.139 + * @type:	the type of the struct this is embedded in.
  22.140 + * @member:	the name of the list_struct within the struct.
  22.141 + */
  22.142 +#define list_entry(ptr, type, member) \
  22.143 +	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
  22.144 +
  22.145 +/**
  22.146 + * list_for_each	-	iterate over a list
  22.147 + * @pos:	the &struct list_head to use as a loop counter.
  22.148 + * @head:	the head for your list.
  22.149 + */
  22.150 +#define list_for_each(pos, head) \
  22.151 +	for (pos = (head)->next; pos != (head); pos = pos->next)
  22.152 +        	
  22.153 +/**
  22.154 + * list_for_each_safe	-	iterate over a list safe against removal of list entry
  22.155 + * @pos:	the &struct list_head to use as a loop counter.
  22.156 + * @n:		another &struct list_head to use as temporary storage
  22.157 + * @head:	the head for your list.
  22.158 + */
  22.159 +#define list_for_each_safe(pos, n, head) \
  22.160 +	for (pos = (head)->next, n = pos->next; pos != (head); \
  22.161 +		pos = n, n = pos->next)
  22.162 +
  22.163 +/**
  22.164 + * list_for_each_entry	-	iterate over list of given type
  22.165 + * @pos:	the type * to use as a loop counter.
  22.166 + * @head:	the head for your list.
  22.167 + * @member:	the name of the list_struct within the struct.
  22.168 + */
  22.169 +#define list_for_each_entry(pos, head, member)				\
  22.170 +	for (pos = list_entry((head)->next, typeof(*pos), member);	\
  22.171 +	     &pos->member != (head); 					\
  22.172 +	     pos = list_entry(pos->member.next, typeof(*pos), member))
  22.173 +
  22.174 +/**
  22.175 + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  22.176 + * @pos:	the type * to use as a loop counter.
  22.177 + * @n:		another type * to use as temporary storage
  22.178 + * @head:	the head for your list.
  22.179 + * @member:	the name of the list_struct within the struct.
  22.180 + */
  22.181 +#define list_for_each_entry_safe(pos, n, head, member)			\
  22.182 +	for (pos = list_entry((head)->next, typeof(*pos), member),	\
  22.183 +		n = list_entry(pos->member.next, typeof(*pos), member);	\
  22.184 +	     &pos->member != (head); 					\
  22.185 +	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
  22.186 +#endif /* _LINUX_LIST_H */
  22.187 +
    23.1 --- a/extras/mini-os/include/mm.h	Thu Sep 08 09:18:40 2005 -0600
    23.2 +++ b/extras/mini-os/include/mm.h	Fri Sep 09 10:30:54 2005 -0600
    23.3 @@ -25,6 +25,15 @@
    23.4  #ifndef _MM_H_
    23.5  #define _MM_H_
    23.6  
    23.7 +#ifdef __i386__
    23.8 +#include <xen/arch-x86_32.h>
    23.9 +#endif
   23.10 +
   23.11 +#ifdef __x86_64__
   23.12 +#include <xen/arch-x86_64.h>
   23.13 +#endif
   23.14 +
   23.15 +
   23.16  #ifdef __x86_64__
   23.17  
   23.18  #define L1_PAGETABLE_SHIFT      12
   23.19 @@ -56,6 +65,8 @@
   23.20  
   23.21  #define L1_PAGETABLE_ENTRIES    1024
   23.22  #define L2_PAGETABLE_ENTRIES    1024
   23.23 +
   23.24 +#elif defined(__x86_64__)
   23.25  #endif
   23.26  
   23.27  /* Given a virtual address, get an entry offset into a page table. */
   23.28 @@ -97,13 +108,15 @@
   23.29  
   23.30  extern unsigned long *phys_to_machine_mapping;
   23.31  #define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
   23.32 -#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
   23.33  static __inline__ unsigned long phys_to_machine(unsigned long phys)
   23.34  {
   23.35      unsigned long machine = pfn_to_mfn(phys >> L1_PAGETABLE_SHIFT);
   23.36      machine = (machine << L1_PAGETABLE_SHIFT) | (phys & ~PAGE_MASK);
   23.37      return machine;
   23.38  }
   23.39 +
   23.40 +
   23.41 +#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
   23.42  static __inline__ unsigned long machine_to_phys(unsigned long machine)
   23.43  {
   23.44      unsigned long phys = mfn_to_pfn(machine >> L1_PAGETABLE_SHIFT);
   23.45 @@ -119,16 +132,15 @@ static __inline__ unsigned long machine_
   23.46  
   23.47  #define to_phys(x)                 ((unsigned long)(x)-VIRT_START)
   23.48  #define to_virt(x)                 ((void *)((unsigned long)(x)+VIRT_START))
   23.49 -#define __va to_virt
   23.50 -#define __pa to_phys
   23.51  
   23.52  #define virt_to_pfn(_virt)         (PFN_DOWN(to_phys(_virt)))
   23.53 +#define mach_to_virt(_mach)        (to_virt(machine_to_phys(_mach)))
   23.54 +#define mfn_to_virt(_mfn)          (mach_to_virt(_mfn << PAGE_SHIFT))
   23.55  
   23.56  void init_mm(void);
   23.57  unsigned long alloc_pages(int order);
   23.58  #define alloc_page()    alloc_pages(0);
   23.59  void free_pages(void *pointer, int order);
   23.60 -//int is_mfn_mapped(unsigned long mfn);
   23.61  
   23.62  static __inline__ int get_order(unsigned long size)
   23.63  {
    24.1 --- a/extras/mini-os/include/os.h	Thu Sep 08 09:18:40 2005 -0600
    24.2 +++ b/extras/mini-os/include/os.h	Fri Sep 09 10:30:54 2005 -0600
    24.3 @@ -15,16 +15,17 @@
    24.4  #define unlikely(x)  __builtin_expect((x),0)
    24.5  
    24.6  #define smp_processor_id() 0
    24.7 -#define preempt_disable() ((void)0)
    24.8 -#define preempt_enable() ((void)0)
    24.9  
   24.10 -#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
   24.11  
   24.12  #ifndef __ASSEMBLY__
   24.13  #include <types.h>
   24.14 +#include <hypervisor.h>
   24.15  #endif
   24.16  #include <xen/xen.h>
   24.17  
   24.18 +
   24.19 +#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
   24.20 +
   24.21  #define __KERNEL_CS  FLAT_KERNEL_CS
   24.22  #define __KERNEL_DS  FLAT_KERNEL_DS
   24.23  #define __KERNEL_SS  FLAT_KERNEL_SS
   24.24 @@ -54,8 +55,6 @@
   24.25  /* Everything below this point is not included by assembler (.S) files. */
   24.26  #ifndef __ASSEMBLY__
   24.27  
   24.28 -#define pt_regs xen_regs
   24.29 -
   24.30  void trap_init(void);
   24.31  
   24.32  /* 
   24.33 @@ -69,10 +68,8 @@ void trap_init(void);
   24.34  #define __cli()								\
   24.35  do {									\
   24.36  	vcpu_info_t *_vcpu;						\
   24.37 -	preempt_disable();						\
   24.38  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   24.39  	_vcpu->evtchn_upcall_mask = 1;					\
   24.40 -	preempt_enable_no_resched();					\
   24.41  	barrier();							\
   24.42  } while (0)
   24.43  
   24.44 @@ -80,13 +77,11 @@ do {									\
   24.45  do {									\
   24.46  	vcpu_info_t *_vcpu;						\
   24.47  	barrier();							\
   24.48 -	preempt_disable();						\
   24.49  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   24.50  	_vcpu->evtchn_upcall_mask = 0;					\
   24.51  	barrier(); /* unmask then check (avoid races) */		\
   24.52  	if ( unlikely(_vcpu->evtchn_upcall_pending) )			\
   24.53  		force_evtchn_callback();				\
   24.54 -	preempt_enable();						\
   24.55  } while (0)
   24.56  
   24.57  #define __save_flags(x)							\
   24.58 @@ -100,15 +95,12 @@ do {									\
   24.59  do {									\
   24.60  	vcpu_info_t *_vcpu;						\
   24.61  	barrier();							\
   24.62 -	preempt_disable();						\
   24.63  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   24.64  	if ((_vcpu->evtchn_upcall_mask = (x)) == 0) {			\
   24.65  		barrier(); /* unmask then check (avoid races) */	\
   24.66  		if ( unlikely(_vcpu->evtchn_upcall_pending) )		\
   24.67  			force_evtchn_callback();			\
   24.68 -		preempt_enable();					\
   24.69 -	} else								\
   24.70 -		preempt_enable_no_resched();				\
   24.71 +	}\
   24.72  } while (0)
   24.73  
   24.74  #define safe_halt()		((void)0)
   24.75 @@ -116,11 +108,9 @@ do {									\
   24.76  #define __save_and_cli(x)						\
   24.77  do {									\
   24.78  	vcpu_info_t *_vcpu;						\
   24.79 -	preempt_disable();						\
   24.80  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   24.81  	(x) = _vcpu->evtchn_upcall_mask;				\
   24.82  	_vcpu->evtchn_upcall_mask = 1;					\
   24.83 -	preempt_enable_no_resched();					\
   24.84  	barrier();							\
   24.85  } while (0)
   24.86  
   24.87 @@ -136,6 +126,15 @@ do {									\
   24.88  /* This is a barrier for the compiler only, NOT the processor! */
   24.89  #define barrier() __asm__ __volatile__("": : :"memory")
   24.90  
   24.91 +#if defined(__i386__)
   24.92 +#define mb()    __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
   24.93 +#define rmb()   __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
   24.94 +#elif defined(__x86_64__)
   24.95 +#define mb()    __asm__ __volatile__ ("mfence":::"memory")
   24.96 +#define rmb()   __asm__ __volatile__ ("lfence":::"memory")
   24.97 +#endif
   24.98 +
   24.99 +
  24.100  #define LOCK_PREFIX ""
  24.101  #define LOCK ""
  24.102  #define ADDR (*(volatile long *) addr)
  24.103 @@ -147,39 +146,187 @@ do {									\
  24.104  typedef struct { volatile int counter; } atomic_t;
  24.105  
  24.106  
  24.107 -#define xchg(ptr,v) \
  24.108 -        ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
  24.109 +/************************** i386 *******************************/
  24.110 +#if defined (__i386__)
  24.111 +
  24.112 +#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
  24.113  struct __xchg_dummy { unsigned long a[100]; };
  24.114 -#define __xg(x) ((volatile struct __xchg_dummy *)(x))
  24.115 -static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr,
  24.116 -                                   int size)
  24.117 +#define __xg(x) ((struct __xchg_dummy *)(x))
  24.118 +static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
  24.119  {
  24.120 -    switch (size) {
  24.121 -    case 1:
  24.122 -        __asm__ __volatile__("xchgb %b0,%1"
  24.123 -                             :"=q" (x)
  24.124 -                             :"m" (*__xg(ptr)), "0" (x)
  24.125 -                             :"memory");
  24.126 -        break;
  24.127 -    case 2:
  24.128 -        __asm__ __volatile__("xchgw %w0,%1"
  24.129 -                             :"=r" (x)
  24.130 -                             :"m" (*__xg(ptr)), "0" (x)
  24.131 -                             :"memory");
  24.132 -        break;
  24.133 -    case 4:
  24.134 -        __asm__ __volatile__("xchgl %0,%1"
  24.135 -                             :"=r" (x)
  24.136 -                             :"m" (*__xg(ptr)), "0" (x)
  24.137 -                             :"memory");
  24.138 -        break;
  24.139 -    }
  24.140 -    return x;
  24.141 +	switch (size) {
  24.142 +		case 1:
  24.143 +			__asm__ __volatile__("xchgb %b0,%1"
  24.144 +				:"=q" (x)
  24.145 +				:"m" (*__xg(ptr)), "0" (x)
  24.146 +				:"memory");
  24.147 +			break;
  24.148 +		case 2:
  24.149 +			__asm__ __volatile__("xchgw %w0,%1"
  24.150 +				:"=r" (x)
  24.151 +				:"m" (*__xg(ptr)), "0" (x)
  24.152 +				:"memory");
  24.153 +			break;
  24.154 +		case 4:
  24.155 +			__asm__ __volatile__("xchgl %0,%1"
  24.156 +				:"=r" (x)
  24.157 +				:"m" (*__xg(ptr)), "0" (x)
  24.158 +				:"memory");
  24.159 +			break;
  24.160 +	}
  24.161 +	return x;
  24.162  }
  24.163  
  24.164  /**
  24.165   * test_and_clear_bit - Clear a bit and return its old value
  24.166 - * @nr: Bit to set
  24.167 + * @nr: Bit to clear
  24.168 + * @addr: Address to count from
  24.169 + *
  24.170 + * This operation is atomic and cannot be reordered.
  24.171 + * It can be reorderdered on other architectures other than x86.
  24.172 + * It also implies a memory barrier.
  24.173 + */
  24.174 +static inline int test_and_clear_bit(int nr, volatile unsigned long * addr)
  24.175 +{
  24.176 +	int oldbit;
  24.177 +
  24.178 +	__asm__ __volatile__( LOCK
  24.179 +		"btrl %2,%1\n\tsbbl %0,%0"
  24.180 +		:"=r" (oldbit),"=m" (ADDR)
  24.181 +		:"Ir" (nr) : "memory");
  24.182 +	return oldbit;
  24.183 +}
  24.184 +
  24.185 +static inline int constant_test_bit(int nr, const volatile unsigned long *addr)
  24.186 +{
  24.187 +	return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
  24.188 +}
  24.189 +
  24.190 +static inline int variable_test_bit(int nr, const volatile unsigned long * addr)
  24.191 +{
  24.192 +	int oldbit;
  24.193 +
  24.194 +	__asm__ __volatile__(
  24.195 +		"btl %2,%1\n\tsbbl %0,%0"
  24.196 +		:"=r" (oldbit)
  24.197 +		:"m" (ADDR),"Ir" (nr));
  24.198 +	return oldbit;
  24.199 +}
  24.200 +
  24.201 +#define test_bit(nr,addr) \
  24.202 +(__builtin_constant_p(nr) ? \
  24.203 + constant_test_bit((nr),(addr)) : \
  24.204 + variable_test_bit((nr),(addr)))
  24.205 +
  24.206 +/**
  24.207 + * set_bit - Atomically set a bit in memory
  24.208 + * @nr: the bit to set
  24.209 + * @addr: the address to start counting from
  24.210 + *
  24.211 + * This function is atomic and may not be reordered.  See __set_bit()
  24.212 + * if you do not require the atomic guarantees.
  24.213 + *
  24.214 + * Note: there are no guarantees that this function will not be reordered
  24.215 + * on non x86 architectures, so if you are writting portable code,
  24.216 + * make sure not to rely on its reordering guarantees.
  24.217 + *
  24.218 + * Note that @nr may be almost arbitrarily large; this function is not
  24.219 + * restricted to acting on a single-word quantity.
  24.220 + */
  24.221 +static inline void set_bit(int nr, volatile unsigned long * addr)
  24.222 +{
  24.223 +	__asm__ __volatile__( LOCK
  24.224 +		"btsl %1,%0"
  24.225 +		:"=m" (ADDR)
  24.226 +		:"Ir" (nr));
  24.227 +}
  24.228 +
  24.229 +/**
  24.230 + * clear_bit - Clears a bit in memory
  24.231 + * @nr: Bit to clear
  24.232 + * @addr: Address to start counting from
  24.233 + *
  24.234 + * clear_bit() is atomic and may not be reordered.  However, it does
  24.235 + * not contain a memory barrier, so if it is used for locking purposes,
  24.236 + * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
  24.237 + * in order to ensure changes are visible on other processors.
  24.238 + */
  24.239 +static inline void clear_bit(int nr, volatile unsigned long * addr)
  24.240 +{
  24.241 +	__asm__ __volatile__( LOCK
  24.242 +		"btrl %1,%0"
  24.243 +		:"=m" (ADDR)
  24.244 +		:"Ir" (nr));
  24.245 +}
  24.246 +
  24.247 +/**
  24.248 + * __ffs - find first bit in word.
  24.249 + * @word: The word to search
  24.250 + *
  24.251 + * Undefined if no bit exists, so code should check against 0 first.
  24.252 + */
  24.253 +static inline unsigned long __ffs(unsigned long word)
  24.254 +{
  24.255 +	__asm__("bsfl %1,%0"
  24.256 +		:"=r" (word)
  24.257 +		:"rm" (word));
  24.258 +	return word;
  24.259 +}
  24.260 +
  24.261 +
  24.262 +/*
  24.263 + * These have to be done with inline assembly: that way the bit-setting
  24.264 + * is guaranteed to be atomic. All bit operations return 0 if the bit
  24.265 + * was cleared before the operation and != 0 if it was not.
  24.266 + *
  24.267 + * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  24.268 + */
  24.269 +#define ADDR (*(volatile long *) addr)
  24.270 +
  24.271 +#define rdtscll(val) \
  24.272 +     __asm__ __volatile__("rdtsc" : "=A" (val))
  24.273 +
  24.274 +
  24.275 +
  24.276 +#elif defined(__x86_64__)/* ifdef __i386__ */
  24.277 +/************************** x86_84 *******************************/
  24.278 +
  24.279 +#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
  24.280 +#define __xg(x) ((volatile long *)(x))
  24.281 +static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
  24.282 +{
  24.283 +	switch (size) {
  24.284 +		case 1:
  24.285 +			__asm__ __volatile__("xchgb %b0,%1"
  24.286 +				:"=q" (x)
  24.287 +				:"m" (*__xg(ptr)), "0" (x)
  24.288 +				:"memory");
  24.289 +			break;
  24.290 +		case 2:
  24.291 +			__asm__ __volatile__("xchgw %w0,%1"
  24.292 +				:"=r" (x)
  24.293 +				:"m" (*__xg(ptr)), "0" (x)
  24.294 +				:"memory");
  24.295 +			break;
  24.296 +		case 4:
  24.297 +			__asm__ __volatile__("xchgl %k0,%1"
  24.298 +				:"=r" (x)
  24.299 +				:"m" (*__xg(ptr)), "0" (x)
  24.300 +				:"memory");
  24.301 +			break;
  24.302 +		case 8:
  24.303 +			__asm__ __volatile__("xchgq %0,%1"
  24.304 +				:"=r" (x)
  24.305 +				:"m" (*__xg(ptr)), "0" (x)
  24.306 +				:"memory");
  24.307 +			break;
  24.308 +	}
  24.309 +	return x;
  24.310 +}
  24.311 +
  24.312 +/**
  24.313 + * test_and_clear_bit - Clear a bit and return its old value
  24.314 + * @nr: Bit to clear
  24.315   * @addr: Address to count from
  24.316   *
  24.317   * This operation is atomic and cannot be reordered.  
  24.318 @@ -187,29 +334,29 @@ static __inline__ unsigned long __xchg(u
  24.319   */
  24.320  static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
  24.321  {
  24.322 -        int oldbit;
  24.323 +	int oldbit;
  24.324  
  24.325 -        __asm__ __volatile__( LOCK_PREFIX
  24.326 -                "btrl %2,%1\n\tsbbl %0,%0"
  24.327 -                :"=r" (oldbit),"=m" (ADDR)
  24.328 -                :"Ir" (nr) : "memory");
  24.329 -        return oldbit;
  24.330 +	__asm__ __volatile__( LOCK_PREFIX
  24.331 +		"btrl %2,%1\n\tsbbl %0,%0"
  24.332 +		:"=r" (oldbit),"=m" (ADDR)
  24.333 +		:"dIr" (nr) : "memory");
  24.334 +	return oldbit;
  24.335  }
  24.336  
  24.337  static __inline__ int constant_test_bit(int nr, const volatile void * addr)
  24.338  {
  24.339 -    return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
  24.340 +	return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
  24.341  }
  24.342  
  24.343 -static __inline__ int variable_test_bit(int nr, volatile void * addr)
  24.344 +static __inline__ int variable_test_bit(int nr, volatile const void * addr)
  24.345  {
  24.346 -    int oldbit;
  24.347 -    
  24.348 -    __asm__ __volatile__(
  24.349 -        "btl %2,%1\n\tsbbl %0,%0"
  24.350 -        :"=r" (oldbit)
  24.351 -        :"m" (ADDR),"Ir" (nr));
  24.352 -    return oldbit;
  24.353 +	int oldbit;
  24.354 +
  24.355 +	__asm__ __volatile__(
  24.356 +		"btl %2,%1\n\tsbbl %0,%0"
  24.357 +		:"=r" (oldbit)
  24.358 +		:"m" (ADDR),"dIr" (nr));
  24.359 +	return oldbit;
  24.360  }
  24.361  
  24.362  #define test_bit(nr,addr) \
  24.363 @@ -230,10 +377,10 @@ static __inline__ int variable_test_bit(
  24.364   */
  24.365  static __inline__ void set_bit(int nr, volatile void * addr)
  24.366  {
  24.367 -        __asm__ __volatile__( LOCK_PREFIX
  24.368 -                "btsl %1,%0"
  24.369 -                :"=m" (ADDR)
  24.370 -                :"Ir" (nr));
  24.371 +	__asm__ __volatile__( LOCK_PREFIX
  24.372 +		"btsl %1,%0"
  24.373 +		:"=m" (ADDR)
  24.374 +		:"dIr" (nr) : "memory");
  24.375  }
  24.376  
  24.377  /**
  24.378 @@ -248,41 +395,44 @@ static __inline__ void set_bit(int nr, v
  24.379   */
  24.380  static __inline__ void clear_bit(int nr, volatile void * addr)
  24.381  {
  24.382 -        __asm__ __volatile__( LOCK_PREFIX
  24.383 -                "btrl %1,%0"
  24.384 -                :"=m" (ADDR)
  24.385 -                :"Ir" (nr));
  24.386 +	__asm__ __volatile__( LOCK_PREFIX
  24.387 +		"btrl %1,%0"
  24.388 +		:"=m" (ADDR)
  24.389 +		:"dIr" (nr));
  24.390  }
  24.391  
  24.392  /**
  24.393 - * atomic_inc - increment atomic variable
  24.394 - * @v: pointer of type atomic_t
  24.395 - * 
  24.396 - * Atomically increments @v by 1.  Note that the guaranteed
  24.397 - * useful range of an atomic_t is only 24 bits.
  24.398 - */ 
  24.399 -static __inline__ void atomic_inc(atomic_t *v)
  24.400 -{
  24.401 -        __asm__ __volatile__(
  24.402 -                LOCK "incl %0"
  24.403 -                :"=m" (v->counter)
  24.404 -                :"m" (v->counter));
  24.405 -}
  24.406 -
  24.407 -
  24.408 -#define rdtscll(val) \
  24.409 -     __asm__ __volatile__("rdtsc" : "=A" (val))
  24.410 -
  24.411 + * __ffs - find first bit in word.
  24.412 + * @word: The word to search
  24.413 + *
  24.414 + * Undefined if no bit exists, so code should check against 0 first.
  24.415 + */
  24.416  static __inline__ unsigned long __ffs(unsigned long word)
  24.417  {
  24.418 -        __asm__("bsfl %1,%0"
  24.419 -                :"=r" (word)
  24.420 -                :"rm" (word));
  24.421 -        return word;
  24.422 +	__asm__("bsfq %1,%0"
  24.423 +		:"=r" (word)
  24.424 +		:"rm" (word));
  24.425 +	return word;
  24.426  }
  24.427  
  24.428  #define ADDR (*(volatile long *) addr)
  24.429  
  24.430 +#define rdtscll(val) do { \
  24.431 +     unsigned int __a,__d; \
  24.432 +     asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
  24.433 +     (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \
  24.434 +} while(0)
  24.435 +
  24.436 +
  24.437 +#else /* ifdef __x86_64__ */
  24.438 +#error "Unsupported architecture"
  24.439 +#endif
  24.440 +
  24.441 +
  24.442 +/********************* common i386 and x86_64  ****************************/
  24.443 +
  24.444 +
  24.445 +
  24.446  static __inline__ void synch_set_bit(int nr, volatile void * addr)
  24.447  {
  24.448      __asm__ __volatile__ ( 
  24.449 @@ -306,6 +456,14 @@ static __inline__ int synch_test_and_set
  24.450      return oldbit;
  24.451  }
  24.452  
  24.453 +static __inline__ int synch_test_and_clear_bit(int nr, volatile void * addr)
  24.454 +{
  24.455 +    int oldbit;
  24.456 +    __asm__ __volatile__ (
  24.457 +        "lock btrl %2,%1\n\tsbbl %0,%0"
  24.458 +        : "=r" (oldbit), "=m" (ADDR) : "Ir" (nr) : "memory");
  24.459 +    return oldbit;
  24.460 +}
  24.461  
  24.462  static __inline__ int synch_const_test_bit(int nr, const volatile void * addr)
  24.463  {
  24.464 @@ -326,9 +484,8 @@ static __inline__ int synch_var_test_bit
  24.465  (__builtin_constant_p(nr) ? \
  24.466   synch_const_test_bit((nr),(addr)) : \
  24.467   synch_var_test_bit((nr),(addr)))
  24.468 -#endif /* !__ASSEMBLY__ */
  24.469 +
  24.470 +
  24.471  
  24.472 -#define rdtsc(low,high) \
  24.473 -     __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
  24.474 -
  24.475 +#endif /* not assembly */
  24.476  #endif /* _OS_H_ */
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/extras/mini-os/include/sched.h	Fri Sep 09 10:30:54 2005 -0600
    25.3 @@ -0,0 +1,38 @@
    25.4 +#ifndef __SCHED_H__
    25.5 +#define __SCHED_H__
    25.6 +
    25.7 +#include <list.h>
    25.8 +
    25.9 +struct thread
   25.10 +{
   25.11 +    char *name;
   25.12 +    char *stack;
   25.13 +    unsigned long eps;
   25.14 +    unsigned long eip;
   25.15 +    struct list_head thread_list;
   25.16 +    u32 flags;
   25.17 +};
   25.18 +
   25.19 +
   25.20 +
   25.21 +void init_sched(void);
   25.22 +void run_idle_thread(void);
   25.23 +struct thread* create_thread(char *name, void (*function)(void *), void *data);
   25.24 +void schedule(void);
   25.25 +
   25.26 +static inline struct thread* get_current(void)
   25.27 +{
   25.28 +    struct thread **current;
   25.29 +#ifdef __i386__    
   25.30 +    __asm__("andl %%esp,%0; ":"=r" (current) : "r" (~8191UL));
   25.31 +#endif    
   25.32 +    return *current;
   25.33 +}
   25.34 +          
   25.35 +#define current get_current()
   25.36 +
   25.37 +
   25.38 +void wake(struct thread *thread);
   25.39 +void block(struct thread *thread);
   25.40 +
   25.41 +#endif /* __SCHED_H__ */
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/extras/mini-os/include/semaphore.h	Fri Sep 09 10:30:54 2005 -0600
    26.3 @@ -0,0 +1,46 @@
    26.4 +#ifndef _SEMAPHORE_H_
    26.5 +#define _SEMAPHORE_H_
    26.6 +
    26.7 +#include <wait.h>
    26.8 +
    26.9 +/*
   26.10 + * Implementation of semaphore in Mini-os is simple, because 
   26.11 + * there are no preemptive threads, the atomicity is guaranteed.
   26.12 + */
   26.13 +
   26.14 +struct semaphore
   26.15 +{
   26.16 +	int count;
   26.17 +	struct wait_queue_head wait;
   26.18 +};
   26.19 +
   26.20 +
   26.21 +#define __SEMAPHORE_INITIALIZER(name, n)                            \
   26.22 +{                                                                   \
   26.23 +    .count    = n,                                                  \
   26.24 +    .wait           = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait)    \
   26.25 +}
   26.26 +
   26.27 +#define __MUTEX_INITIALIZER(name) \
   26.28 +    __SEMAPHORE_INITIALIZER(name,1)
   26.29 +                           
   26.30 +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
   26.31 +    struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
   26.32 +    
   26.33 +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
   26.34 +
   26.35 +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
   26.36 +
   26.37 +static void inline down(struct semaphore *sem)
   26.38 +{
   26.39 +    wait_event(sem->wait, sem->count > 0);
   26.40 +    sem->count--;
   26.41 +}
   26.42 +
   26.43 +static void inline up(struct semaphore *sem)
   26.44 +{
   26.45 +    sem->count++;
   26.46 +    wake_up(&sem->wait);
   26.47 +}
   26.48 +
   26.49 +#endif /* _SEMAPHORE_H */
    27.1 --- a/extras/mini-os/include/time.h	Thu Sep 08 09:18:40 2005 -0600
    27.2 +++ b/extras/mini-os/include/time.h	Fri Sep 09 10:30:54 2005 -0600
    27.3 @@ -58,6 +58,6 @@ void     init_time(void);
    27.4  s_time_t get_s_time(void);
    27.5  s_time_t get_v_time(void);
    27.6  void     gettimeofday(struct timeval *tv);
    27.7 -void     block(u32 millisecs);
    27.8 +void     block_domain(u32 millisecs);
    27.9  
   27.10  #endif /* _TIME_H_ */
    28.1 --- a/extras/mini-os/include/traps.h	Thu Sep 08 09:18:40 2005 -0600
    28.2 +++ b/extras/mini-os/include/traps.h	Fri Sep 09 10:30:54 2005 -0600
    28.3 @@ -17,6 +17,7 @@
    28.4  #ifndef _TRAPS_H_
    28.5  #define _TRAPS_H_
    28.6  
    28.7 +#ifdef __i386__
    28.8  struct pt_regs {
    28.9  	long ebx;
   28.10  	long ecx;
   28.11 @@ -34,7 +35,38 @@ struct pt_regs {
   28.12  	long esp;
   28.13  	int  xss;
   28.14  };
   28.15 +#elif __x86_64__
   28.16  
   28.17 +struct pt_regs {
   28.18 +	unsigned long r15;
   28.19 +	unsigned long r14;
   28.20 +	unsigned long r13;
   28.21 +	unsigned long r12;
   28.22 +	unsigned long rbp;
   28.23 +	unsigned long rbx;
   28.24 +/* arguments: non interrupts/non tracing syscalls only save upto here*/
   28.25 + 	unsigned long r11;
   28.26 +	unsigned long r10;	
   28.27 +	unsigned long r9;
   28.28 +	unsigned long r8;
   28.29 +	unsigned long rax;
   28.30 +	unsigned long rcx;
   28.31 +	unsigned long rdx;
   28.32 +	unsigned long rsi;
   28.33 +	unsigned long rdi;
   28.34 +	unsigned long orig_rax;
   28.35 +/* end of arguments */ 	
   28.36 +/* cpu exception frame or undefined */
   28.37 +	unsigned long rip;
   28.38 +	unsigned long cs;
   28.39 +	unsigned long eflags; 
   28.40 +	unsigned long rsp; 
   28.41 +	unsigned long ss;
   28.42 +/* top of stack page */ 
   28.43 +};
   28.44 +
   28.45 +
   28.46 +#endif
   28.47  
   28.48  void dump_regs(struct pt_regs *regs);
   28.49  
    29.1 --- a/extras/mini-os/include/types.h	Thu Sep 08 09:18:40 2005 -0600
    29.2 +++ b/extras/mini-os/include/types.h	Fri Sep 09 10:30:54 2005 -0600
    29.3 @@ -44,11 +44,19 @@ typedef unsigned long       u_long;
    29.4  typedef long long           quad_t;
    29.5  typedef unsigned long long  u_quad_t;
    29.6  typedef unsigned int        uintptr_t;
    29.7 +
    29.8 +typedef struct { unsigned long pte_low; } pte_t;
    29.9  #elif defined(__x86_64__)
   29.10  typedef long                quad_t;
   29.11  typedef unsigned long       u_quad_t;
   29.12  typedef unsigned long       uintptr_t;
   29.13 +
   29.14 +typedef struct { unsigned long pte; } pte_t;
   29.15  #endif
   29.16  
   29.17 +
   29.18 +
   29.19 +
   29.20 +#define INT_MAX         ((int)(~0U>>1))
   29.21  #define UINT_MAX            (~0U)
   29.22  #endif /* _TYPES_H_ */
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/extras/mini-os/include/wait.h	Fri Sep 09 10:30:54 2005 -0600
    30.3 @@ -0,0 +1,91 @@
    30.4 +#ifndef __WAIT_H__
    30.5 +#define __WAIT_H__
    30.6 +
    30.7 +#include <sched.h>
    30.8 +#include <list.h>
    30.9 +#include <lib.h>
   30.10 +#include <os.h>
   30.11 +
   30.12 +struct wait_queue
   30.13 +{
   30.14 +    struct thread *thread;
   30.15 +    struct list_head thread_list;
   30.16 +};
   30.17 +
   30.18 +struct wait_queue_head
   30.19 +{
   30.20 +    /* TODO - lock required? */
   30.21 +    struct list_head thread_list;
   30.22 +};
   30.23 +
   30.24 +#define DECLARE_WAIT_QUEUE_HEAD(name) \
   30.25 +   struct wait_queue_head name =     \
   30.26 +        { .thread_list = { &(name).thread_list, &(name).thread_list} }
   30.27 +
   30.28 +#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                           \
   30.29 +    .thread_list      = { &(name).thread_list, &(name).thread_list } }
   30.30 +
   30.31 +
   30.32 +#define DEFINE_WAIT(name)                               \
   30.33 +struct wait_queue name = {                              \
   30.34 +    .thread       = current,                            \
   30.35 +    .thread_list  = LIST_HEAD_INIT((name).thread_list), \
   30.36 +}
   30.37 +
   30.38 +
   30.39 +
   30.40 +static inline void init_waitqueue_entry(struct wait_queue *q, struct thread *thread)
   30.41 +{
   30.42 +    q->thread = thread;
   30.43 +}
   30.44 +
   30.45 +
   30.46 +static inline void add_wait_queue(struct wait_queue_head *h, struct wait_queue *q)
   30.47 +{
   30.48 +    if (list_empty(&q->thread_list))
   30.49 +        list_add(&q->thread_list, &h->thread_list);   
   30.50 +}
   30.51 +
   30.52 +static inline void remove_wait_queue(struct wait_queue *q)
   30.53 +{
   30.54 +    list_del(&q->thread_list);
   30.55 +}
   30.56 +
   30.57 +static inline void wake_up(struct wait_queue_head *head)
   30.58 +{
   30.59 +    struct list_head *tmp, *next;
   30.60 +    list_for_each_safe(tmp, next, &head->thread_list)
   30.61 +    {
   30.62 +         struct wait_queue *curr;
   30.63 +         curr = list_entry(tmp, struct wait_queue, thread_list);
   30.64 +         wake(curr->thread);
   30.65 +    }
   30.66 +}
   30.67 +
   30.68 +#define wait_event(wq, condition) do{             \
   30.69 +    unsigned long flags;                          \
   30.70 +    if(condition)                                 \
   30.71 +        break;                                    \
   30.72 +    DEFINE_WAIT(__wait);                          \
   30.73 +    for(;;)                                       \
   30.74 +    {                                             \
   30.75 +        /* protect the list */                    \
   30.76 +        local_irq_save(flags);                    \
   30.77 +        add_wait_queue(&wq, &__wait);             \
   30.78 +        block(current);                           \
   30.79 +        local_irq_restore(flags);                 \
   30.80 +        if(condition)                             \
   30.81 +            break;                                \
   30.82 +        schedule();                               \
   30.83 +    }                                             \
   30.84 +    local_irq_save(flags);                        \
   30.85 +    /* need to wake up */                         \
   30.86 +    wake(current);                                \
   30.87 +    remove_wait_queue(&__wait);                   \
   30.88 +    local_irq_restore(flags);                     \
   30.89 +} while(0) 
   30.90 +
   30.91 +
   30.92 +
   30.93 +
   30.94 +#endif /* __WAIT_H__ */
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/extras/mini-os/include/xenbus.h	Fri Sep 09 10:30:54 2005 -0600
    31.3 @@ -0,0 +1,89 @@
    31.4 +/******************************************************************************
    31.5 + * xenbus.h
    31.6 + *
    31.7 + * Talks to Xen Store to figure out what devices we have.
    31.8 + *
    31.9 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
   31.10 + * 
   31.11 + * This file may be distributed separately from the Linux kernel, or
   31.12 + * incorporated into other software packages, subject to the following license:
   31.13 + * 
   31.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   31.15 + * of this source file (the "Software"), to deal in the Software without
   31.16 + * restriction, including without limitation the rights to use, copy, modify,
   31.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   31.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   31.19 + * the following conditions:
   31.20 + * 
   31.21 + * The above copyright notice and this permission notice shall be included in
   31.22 + * all copies or substantial portions of the Software.
   31.23 + * 
   31.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   31.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   31.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   31.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   31.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   31.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   31.30 + * IN THE SOFTWARE.
   31.31 + */
   31.32 +
   31.33 +#ifndef _ASM_XEN_XENBUS_H
   31.34 +#define _ASM_XEN_XENBUS_H
   31.35 +
   31.36 +
   31.37 +/* Caller must hold this lock to call these functions: it's also held
   31.38 + * across watch callbacks. */
   31.39 +// TODO
   31.40 +//extern struct semaphore xenbus_lock;
   31.41 +
   31.42 +char **xenbus_directory(const char *dir, const char *node, unsigned int *num);
   31.43 +void *xenbus_read(const char *dir, const char *node, unsigned int *len);
   31.44 +int xenbus_write(const char *dir, const char *node,
   31.45 +		 const char *string, int createflags);
   31.46 +int xenbus_mkdir(const char *dir, const char *node);
   31.47 +int xenbus_exists(const char *dir, const char *node);
   31.48 +int xenbus_rm(const char *dir, const char *node);
   31.49 +int xenbus_transaction_start(const char *subtree);
   31.50 +int xenbus_transaction_end(int abort);
   31.51 +
   31.52 +/* Single read and scanf: returns -errno or num scanned if > 0. */
   31.53 +int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
   31.54 +	__attribute__((format(scanf, 3, 4)));
   31.55 +
   31.56 +/* Single printf and write: returns -errno or 0. */
   31.57 +int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
   31.58 +	__attribute__((format(printf, 3, 4)));
   31.59 +
   31.60 +/* Generic read function: NULL-terminated triples of name,
   31.61 + * sprintf-style type string, and pointer. Returns 0 or errno.*/
   31.62 +int xenbus_gather(const char *dir, ...);
   31.63 +
   31.64 +/* Register callback to watch this node. */
   31.65 +struct xenbus_watch
   31.66 +{
   31.67 +	struct list_head list;
   31.68 +	char *node;
   31.69 +	void (*callback)(struct xenbus_watch *, const char *node);
   31.70 +};
   31.71 +
   31.72 +int register_xenbus_watch(struct xenbus_watch *watch);
   31.73 +void unregister_xenbus_watch(struct xenbus_watch *watch);
   31.74 +void reregister_xenbus_watches(void);
   31.75 +
   31.76 +/* Called from xen core code. */
   31.77 +void xenbus_suspend(void);
   31.78 +void xenbus_resume(void);
   31.79 +
   31.80 +#define XENBUS_IS_ERR_READ(str) ({			\
   31.81 +	if (!IS_ERR(str) && strlen(str) == 0) {		\
   31.82 +		kfree(str);				\
   31.83 +		str = ERR_PTR(-ERANGE);			\
   31.84 +	}						\
   31.85 +	IS_ERR(str);					\
   31.86 +})
   31.87 +
   31.88 +#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
   31.89 +
   31.90 +int xs_init(void);
   31.91 +
   31.92 +#endif /* _ASM_XEN_XENBUS_H */
    33.1 --- a/extras/mini-os/kernel.c	Thu Sep 08 09:18:40 2005 -0600
    33.2 +++ b/extras/mini-os/kernel.c	Fri Sep 09 10:30:54 2005 -0600
    33.3 @@ -33,6 +33,8 @@
    33.4  #include <time.h>
    33.5  #include <types.h>
    33.6  #include <lib.h>
    33.7 +#include <sched.h>
    33.8 +#include <xenbus.h>
    33.9  
   33.10  /*
   33.11   * Shared page for communicating with the hypervisor.
   33.12 @@ -59,10 +61,12 @@ void failsafe_callback(void);
   33.13  
   33.14  extern char shared_info[PAGE_SIZE];
   33.15  
   33.16 +#define __pte(x) ((pte_t) { (0) } )
   33.17 +
   33.18  static shared_info_t *map_shared_info(unsigned long pa)
   33.19  {
   33.20      if ( HYPERVISOR_update_va_mapping(
   33.21 -        (unsigned long)shared_info, pa | 7, UVMF_INVLPG) )
   33.22 +        (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) )
   33.23      {
   33.24          printk("Failed to map shared_info!!\n");
   33.25          *(int*)0=0;
   33.26 @@ -77,7 +81,6 @@ static shared_info_t *map_shared_info(un
   33.27  void start_kernel(start_info_t *si)
   33.28  {
   33.29      static char hello[] = "Bootstrapping...\n";
   33.30 -    int i;
   33.31      (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello);
   33.32  
   33.33      /* Copy the start_info struct to a globally-accessible area. */
   33.34 @@ -96,7 +99,6 @@ void start_kernel(start_info_t *si)
   33.35          (unsigned long)hypervisor_callback,
   33.36          (unsigned long)failsafe_callback, 0);
   33.37  #endif
   33.38 -
   33.39      trap_init();
   33.40  
   33.41      /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
   33.42 @@ -119,7 +121,6 @@ void start_kernel(start_info_t *si)
   33.43       * If used for porting another OS, start here to figure out your
   33.44       * guest os entry point. Otherwise continue below...
   33.45       */
   33.46 -
   33.47      /* init memory management */
   33.48      init_mm();
   33.49  
   33.50 @@ -127,15 +128,15 @@ void start_kernel(start_info_t *si)
   33.51      init_events();
   33.52      /* init time and timers */
   33.53      init_time();
   33.54 +    
   33.55 +    /* init scheduler */
   33.56 +    init_sched();
   33.57  
   33.58 -    /* do nothing */
   33.59 -    i = 0;
   33.60 -    for ( ; ; ) 
   33.61 -    {      
   33.62 -//        HYPERVISOR_yield();
   33.63 -        block(100);
   33.64 -        i++;
   33.65 -    }
   33.66 +    /* init xenbus */
   33.67 +    xs_init();
   33.68 +    
   33.69 +    /* Everything initialised, start idle thread */
   33.70 +    run_idle_thread();
   33.71  }
   33.72  
   33.73  
    34.1 --- a/extras/mini-os/lib/printf.c	Thu Sep 08 09:18:40 2005 -0600
    34.2 +++ b/extras/mini-os/lib/printf.c	Fri Sep 09 10:30:54 2005 -0600
    34.3 @@ -1,21 +1,19 @@
    34.4 -/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
    34.5 +/* 
    34.6   ****************************************************************************
    34.7   * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
    34.8   ****************************************************************************
    34.9   *
   34.10   *        File: printf.c
   34.11   *      Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
   34.12 - *     Changes: 
   34.13 + *     Changes: Grzegorz Milos (gm281@cam.ac.uk) 
   34.14   *              
   34.15 - *        Date: Aug 2003
   34.16 + *        Date: Aug 2003, Aug 2005
   34.17   * 
   34.18   * Environment: Xen Minimal OS
   34.19   * Description: Library functions for printing
   34.20   *              (freebsd port, mainly sys/subr_prf.c)
   34.21   *
   34.22   ****************************************************************************
   34.23 - * $Id: c-insert.c,v 1.7 2002/11/08 16:04:34 rn Exp $
   34.24 - ****************************************************************************
   34.25   *
   34.26   *-
   34.27   * Copyright (c) 1992, 1993
   34.28 @@ -60,409 +58,748 @@
   34.29  #include <types.h>
   34.30  #include <hypervisor.h>
   34.31  #include <lib.h>
   34.32 +#include <mm.h>
   34.33 +#include <ctype.h>
   34.34  
   34.35 -/****************************************************************************
   34.36 - * RN: printf family of routines
   34.37 - * taken mainly from sys/subr_prf.c
   34.38 - ****************************************************************************/
   34.39 -char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
   34.40 -#define hex2ascii(hex)  (hex2ascii_data[hex])
   34.41 -#define NBBY    8               /* number of bits in a byte */
   34.42 -#define MAXNBUF    (sizeof(quad_t) * NBBY + 1)
   34.43 +/**
   34.44 + * simple_strtoul - convert a string to an unsigned long
   34.45 + * @cp: The start of the string
   34.46 + * @endp: A pointer to the end of the parsed string will be placed here
   34.47 + * @base: The number base to use
   34.48 + */
   34.49 +unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
   34.50 +{
   34.51 +    unsigned long result = 0,value;
   34.52 +
   34.53 +    if (!base) {
   34.54 +        base = 10;
   34.55 +        if (*cp == '0') {
   34.56 +            base = 8;
   34.57 +            cp++;
   34.58 +            if ((*cp == 'x') && isxdigit(cp[1])) {
   34.59 +                cp++;
   34.60 +                base = 16;
   34.61 +            }
   34.62 +        }
   34.63 +    }
   34.64 +    while (isxdigit(*cp) &&
   34.65 +           (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
   34.66 +        result = result*base + value;
   34.67 +        cp++;
   34.68 +    }
   34.69 +    if (endp)
   34.70 +        *endp = (char *)cp;
   34.71 +    return result;
   34.72 +}
   34.73 +
   34.74 +/**
   34.75 + * simple_strtol - convert a string to a signed long
   34.76 + * @cp: The start of the string
   34.77 + * @endp: A pointer to the end of the parsed string will be placed here
   34.78 + * @base: The number base to use
   34.79 + */
   34.80 +long simple_strtol(const char *cp,char **endp,unsigned int base)
   34.81 +{
   34.82 +    if(*cp=='-')
   34.83 +        return -simple_strtoul(cp+1,endp,base);
   34.84 +    return simple_strtoul(cp,endp,base);
   34.85 +}
   34.86  
   34.87 -static int kvprintf(char const *fmt, void *arg, int radix, va_list ap);
   34.88 +/**
   34.89 + * simple_strtoull - convert a string to an unsigned long long
   34.90 + * @cp: The start of the string
   34.91 + * @endp: A pointer to the end of the parsed string will be placed here
   34.92 + * @base: The number base to use
   34.93 + */
   34.94 +unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base)
   34.95 +{
   34.96 +    unsigned long long result = 0,value;
   34.97  
   34.98 +    if (!base) {
   34.99 +        base = 10;
  34.100 +        if (*cp == '0') {
  34.101 +            base = 8;
  34.102 +            cp++;
  34.103 +            if ((*cp == 'x') && isxdigit(cp[1])) {
  34.104 +                cp++;
  34.105 +                base = 16;
  34.106 +            }
  34.107 +        }
  34.108 +    }
  34.109 +    while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
  34.110 +                                                               ? toupper(*cp) : *cp)-'A'+10) < base) {
  34.111 +        result = result*base + value;
  34.112 +        cp++;
  34.113 +    }
  34.114 +    if (endp)
  34.115 +        *endp = (char *)cp;
  34.116 +    return result;
  34.117 +}
  34.118 +
  34.119 +/**
  34.120 + * simple_strtoll - convert a string to a signed long long
  34.121 + * @cp: The start of the string
  34.122 + * @endp: A pointer to the end of the parsed string will be placed here
  34.123 + * @base: The number base to use
  34.124 + */
  34.125 +long long simple_strtoll(const char *cp,char **endp,unsigned int base)
  34.126 +{
  34.127 +    if(*cp=='-')
  34.128 +        return -simple_strtoull(cp+1,endp,base);
  34.129 +    return simple_strtoull(cp,endp,base);
  34.130 +}
  34.131 +
  34.132 +static int skip_atoi(const char **s)
  34.133 +{
  34.134 +    int i=0;
  34.135 +
  34.136 +    while (isdigit(**s))
  34.137 +        i = i*10 + *((*s)++) - '0';
  34.138 +    return i;
  34.139 +}
  34.140  
  34.141 -int
  34.142 -printf(const char *fmt, ...)
  34.143 +#define ZEROPAD 1               /* pad with zero */
  34.144 +#define SIGN    2               /* unsigned/signed long */
  34.145 +#define PLUS    4               /* show plus */
  34.146 +#define SPACE   8               /* space if plus */
  34.147 +#define LEFT    16              /* left justified */
  34.148 +#define SPECIAL 32              /* 0x */
  34.149 +#define LARGE   64              /* use 'ABCDEF' instead of 'abcdef' */
  34.150 +
  34.151 +static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type)
  34.152  {
  34.153 -	va_list ap;
  34.154 -	int retval;
  34.155 -    static char printk_buf[1024];
  34.156 +    char c,sign,tmp[66];
  34.157 +    const char *digits;
  34.158 +    const char small_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
  34.159 +    const char large_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  34.160 +    int i;
  34.161  
  34.162 -	va_start(ap, fmt);
  34.163 -	retval = kvprintf(fmt, printk_buf, 10, ap);
  34.164 -    printk_buf[retval] = '\0';
  34.165 -	va_end(ap);
  34.166 -    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(printk_buf), 
  34.167 -                                printk_buf);
  34.168 -	return retval;
  34.169 +    digits = (type & LARGE) ? large_digits : small_digits;
  34.170 +    if (type & LEFT)
  34.171 +        type &= ~ZEROPAD;
  34.172 +    if (base < 2 || base > 36)
  34.173 +        return buf;
  34.174 +    c = (type & ZEROPAD) ? '0' : ' ';
  34.175 +    sign = 0;
  34.176 +    if (type & SIGN) {
  34.177 +        if (num < 0) {
  34.178 +            sign = '-';
  34.179 +            num = -num;
  34.180 +            size--;
  34.181 +        } else if (type & PLUS) {
  34.182 +            sign = '+';
  34.183 +            size--;
  34.184 +        } else if (type & SPACE) {
  34.185 +            sign = ' ';
  34.186 +            size--;
  34.187 +        }
  34.188 +    }
  34.189 +    if (type & SPECIAL) {
  34.190 +        if (base == 16)
  34.191 +            size -= 2;
  34.192 +        else if (base == 8)
  34.193 +            size--;
  34.194 +    }
  34.195 +    i = 0;
  34.196 +    if (num == 0)
  34.197 +        tmp[i++]='0';
  34.198 +    else 
  34.199 +    {
  34.200 +        /* XXX KAF: force unsigned mod and div. */
  34.201 +        unsigned long long num2=(unsigned long long)num;
  34.202 +        unsigned int base2=(unsigned int)base;
  34.203 +        while (num2 != 0) { tmp[i++] = digits[num2%base2]; num2 /= base2; }
  34.204 +    }
  34.205 +    if (i > precision)
  34.206 +        precision = i;
  34.207 +    size -= precision;
  34.208 +    if (!(type&(ZEROPAD+LEFT))) {
  34.209 +        while(size-->0) {
  34.210 +            if (buf <= end)
  34.211 +                *buf = ' ';
  34.212 +            ++buf;
  34.213 +        }
  34.214 +    }
  34.215 +    if (sign) {
  34.216 +        if (buf <= end)
  34.217 +            *buf = sign;
  34.218 +        ++buf;
  34.219 +    }
  34.220 +    if (type & SPECIAL) {
  34.221 +        if (base==8) {
  34.222 +            if (buf <= end)
  34.223 +                *buf = '0';
  34.224 +            ++buf;
  34.225 +        } else if (base==16) {
  34.226 +            if (buf <= end)
  34.227 +                *buf = '0';
  34.228 +            ++buf;
  34.229 +            if (buf <= end)
  34.230 +                *buf = digits[33];
  34.231 +            ++buf;
  34.232 +        }
  34.233 +    }
  34.234 +    if (!(type & LEFT)) {
  34.235 +        while (size-- > 0) {
  34.236 +            if (buf <= end)
  34.237 +                *buf = c;
  34.238 +            ++buf;
  34.239 +        }
  34.240 +    }
  34.241 +    while (i < precision--) {
  34.242 +        if (buf <= end)
  34.243 +            *buf = '0';
  34.244 +        ++buf;
  34.245 +    }
  34.246 +    while (i-- > 0) {
  34.247 +        if (buf <= end)
  34.248 +            *buf = tmp[i];
  34.249 +        ++buf;
  34.250 +    }
  34.251 +    while (size-- > 0) {
  34.252 +        if (buf <= end)
  34.253 +            *buf = ' ';
  34.254 +        ++buf;
  34.255 +    }
  34.256 +    return buf;
  34.257  }
  34.258  
  34.259 -int
  34.260 -vprintf(const char *fmt, va_list ap)
  34.261 +/**
  34.262 +* vsnprintf - Format a string and place it in a buffer
  34.263 +* @buf: The buffer to place the result into
  34.264 +* @size: The size of the buffer, including the trailing null space
  34.265 +* @fmt: The format string to use
  34.266 +* @args: Arguments for the format string
  34.267 +*
  34.268 +* Call this function if you are already dealing with a va_list.
  34.269 +* You probably want snprintf instead.
  34.270 + */
  34.271 +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
  34.272  {
  34.273 -	int retval;
  34.274 -    static char printk_buf[1024];
  34.275 -	retval = kvprintf(fmt, printk_buf, 10, ap);
  34.276 -    printk_buf[retval] = '\0';
  34.277 -    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(printk_buf),
  34.278 -                                printk_buf);
  34.279 -	return retval;
  34.280 +    int len;
  34.281 +    unsigned long long num;
  34.282 +    int i, base;
  34.283 +    char *str, *end, c;
  34.284 +    const char *s;
  34.285 +
  34.286 +    int flags;          /* flags to number() */
  34.287 +
  34.288 +    int field_width;    /* width of output field */
  34.289 +    int precision;              /* min. # of digits for integers; max
  34.290 +                                   number of chars for from string */
  34.291 +    int qualifier;              /* 'h', 'l', or 'L' for integer fields */
  34.292 +                                /* 'z' support added 23/7/1999 S.H.    */
  34.293 +                                /* 'z' changed to 'Z' --davidm 1/25/99 */
  34.294 +
  34.295 +    str = buf;
  34.296 +    end = buf + size - 1;
  34.297 +
  34.298 +    if (end < buf - 1) {
  34.299 +        end = ((void *) -1);
  34.300 +        size = end - buf + 1;
  34.301 +    }
  34.302 +
  34.303 +    for (; *fmt ; ++fmt) {
  34.304 +        if (*fmt != '%') {
  34.305 +            if (str <= end)
  34.306 +                *str = *fmt;
  34.307 +            ++str;
  34.308 +            continue;
  34.309 +        }
  34.310 +
  34.311 +        /* process flags */
  34.312 +        flags = 0;
  34.313 +    repeat:
  34.314 +        ++fmt;          /* this also skips first '%' */
  34.315 +        switch (*fmt) {
  34.316 +        case '-': flags |= LEFT; goto repeat;
  34.317 +        case '+': flags |= PLUS; goto repeat;
  34.318 +        case ' ': flags |= SPACE; goto repeat;
  34.319 +        case '#': flags |= SPECIAL; goto repeat;
  34.320 +        case '0': flags |= ZEROPAD; goto repeat;
  34.321 +        }
  34.322 +
  34.323 +        /* get field width */
  34.324 +        field_width = -1;
  34.325 +        if (isdigit(*fmt))
  34.326 +            field_width = skip_atoi(&fmt);
  34.327 +        else if (*fmt == '*') {
  34.328 +            ++fmt;
  34.329 +            /* it's the next argument */
  34.330 +            field_width = va_arg(args, int);
  34.331 +            if (field_width < 0) {
  34.332 +                field_width = -field_width;
  34.333 +                flags |= LEFT;
  34.334 +            }
  34.335 +        }
  34.336 +
  34.337 +        /* get the precision */
  34.338 +        precision = -1;
  34.339 +        if (*fmt == '.') {
  34.340 +            ++fmt;
  34.341 +            if (isdigit(*fmt))
  34.342 +                precision = skip_atoi(&fmt);
  34.343 +            else if (*fmt == '*') {
  34.344 +                ++fmt;
  34.345 +                          /* it's the next argument */
  34.346 +                precision = va_arg(args, int);
  34.347 +            }
  34.348 +            if (precision < 0)
  34.349 +                precision = 0;
  34.350 +        }
  34.351 +
  34.352 +        /* get the conversion qualifier */
  34.353 +        qualifier = -1;
  34.354 +        if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='Z') {
  34.355 +            qualifier = *fmt;
  34.356 +            ++fmt;
  34.357 +            if (qualifier == 'l' && *fmt == 'l') {
  34.358 +                qualifier = 'L';
  34.359 +                ++fmt;
  34.360 +            }
  34.361 +        }
  34.362 +        if (*fmt == 'q') {
  34.363 +            qualifier = 'L';
  34.364 +            ++fmt;
  34.365 +        }
  34.366 +
  34.367 +        /* default base */
  34.368 +        base = 10;
  34.369 +
  34.370 +        switch (*fmt) {
  34.371 +        case 'c':
  34.372 +            if (!(flags & LEFT)) {
  34.373 +                while (--field_width > 0) {
  34.374 +                    if (str <= end)
  34.375 +                        *str = ' ';
  34.376 +                    ++str;
  34.377 +                }
  34.378 +            }
  34.379 +            c = (unsigned char) va_arg(args, int);
  34.380 +            if (str <= end)
  34.381 +                *str = c;
  34.382 +            ++str;
  34.383 +            while (--field_width > 0) {
  34.384 +                if (str <= end)
  34.385 +                    *str = ' ';
  34.386 +                ++str;
  34.387 +            }
  34.388 +            continue;
  34.389 +
  34.390 +        case 's':
  34.391 +            s = va_arg(args, char *);
  34.392 +            if (!s)
  34.393 +                s = "<NULL>";
  34.394 +
  34.395 +            len = strnlen(s, precision);
  34.396 +
  34.397 +            if (!(flags & LEFT)) {
  34.398 +                while (len < field_width--) {
  34.399 +                    if (str <= end)
  34.400 +                        *str = ' ';
  34.401 +                    ++str;
  34.402 +                }
  34.403 +            }
  34.404 +            for (i = 0; i < len; ++i) {
  34.405 +                if (str <= end)
  34.406 +                    *str = *s;
  34.407 +                ++str; ++s;
  34.408 +            }
  34.409 +            while (len < field_width--) {
  34.410 +                if (str <= end)
  34.411 +                    *str = ' ';
  34.412 +                ++str;
  34.413 +            }
  34.414 +            continue;
  34.415 +
  34.416 +        case 'p':
  34.417 +            if (field_width == -1) {
  34.418 +                field_width = 2*sizeof(void *);
  34.419 +                flags |= ZEROPAD;
  34.420 +            }
  34.421 +            str = number(str, end,
  34.422 +                         (unsigned long) va_arg(args, void *),
  34.423 +                         16, field_width, precision, flags);
  34.424 +            continue;
  34.425 +
  34.426 +
  34.427 +        case 'n':
  34.428 +            /* FIXME:
  34.429 +             * What does C99 say about the overflow case here? */
  34.430 +            if (qualifier == 'l') {
  34.431 +                long * ip = va_arg(args, long *);
  34.432 +                *ip = (str - buf);
  34.433 +            } else if (qualifier == 'Z') {
  34.434 +                size_t * ip = va_arg(args, size_t *);
  34.435 +                *ip = (str - buf);
  34.436 +            } else {
  34.437 +                int * ip = va_arg(args, int *);
  34.438 +                *ip = (str - buf);
  34.439 +            }
  34.440 +            continue;
  34.441 +
  34.442 +        case '%':
  34.443 +            if (str <= end)
  34.444 +                *str = '%';
  34.445 +            ++str;
  34.446 +            continue;
  34.447 +
  34.448 +                        /* integer number formats - set up the flags and "break" */
  34.449 +        case 'o':
  34.450 +            base = 8;
  34.451 +            break;
  34.452 +
  34.453 +        case 'X':
  34.454 +            flags |= LARGE;
  34.455 +        case 'x':
  34.456 +            base = 16;
  34.457 +            break;
  34.458 +
  34.459 +        case 'd':
  34.460 +        case 'i':
  34.461 +            flags |= SIGN;
  34.462 +        case 'u':
  34.463 +            break;
  34.464 +
  34.465 +        default:
  34.466 +            if (str <= end)
  34.467 +                *str = '%';
  34.468 +            ++str;
  34.469 +            if (*fmt) {
  34.470 +                if (str <= end)
  34.471 +                    *str = *fmt;
  34.472 +                ++str;
  34.473 +            } else {
  34.474 +                --fmt;
  34.475 +            }
  34.476 +            continue;
  34.477 +        }
  34.478 +        if (qualifier == 'L')
  34.479 +            num = va_arg(args, long long);
  34.480 +        else if (qualifier == 'l') {
  34.481 +            num = va_arg(args, unsigned long);
  34.482 +            if (flags & SIGN)
  34.483 +                num = (signed long) num;
  34.484 +        } else if (qualifier == 'Z') {
  34.485 +            num = va_arg(args, size_t);
  34.486 +        } else if (qualifier == 'h') {
  34.487 +            num = (unsigned short) va_arg(args, int);
  34.488 +            if (flags & SIGN)
  34.489 +                num = (signed short) num;
  34.490 +        } else {
  34.491 +            num = va_arg(args, unsigned int);
  34.492 +            if (flags & SIGN)
  34.493 +                num = (signed int) num;
  34.494 +        }
  34.495 +
  34.496 +        str = number(str, end, num, base,
  34.497 +                     field_width, precision, flags);
  34.498 +    }
  34.499 +    if (str <= end)
  34.500 +        *str = '\0';
  34.501 +    else if (size > 0)
  34.502 +        /* don't write out a null byte if the buf size is zero */
  34.503 +        *end = '\0';
  34.504 +    /* the trailing null byte doesn't count towards the total
  34.505 +     * ++str;
  34.506 +     */
  34.507 +    return str-buf;
  34.508  }
  34.509  
  34.510 -int
  34.511 -sprintf(char *buf, const char *cfmt, ...)
  34.512 +/**
  34.513 + * snprintf - Format a string and place it in a buffer
  34.514 + * @buf: The buffer to place the result into
  34.515 + * @size: The size of the buffer, including the trailing null space
  34.516 + * @fmt: The format string to use
  34.517 + * @...: Arguments for the format string
  34.518 + */
  34.519 +int snprintf(char * buf, size_t size, const char *fmt, ...)
  34.520  {
  34.521 -	int retval;
  34.522 -	va_list ap;
  34.523 +    va_list args;
  34.524 +    int i;
  34.525  
  34.526 -	va_start(ap, cfmt);
  34.527 -	retval = kvprintf(cfmt, (void *)buf, 10, ap);
  34.528 -	buf[retval] = '\0';
  34.529 -	va_end(ap);
  34.530 -	return retval;
  34.531 +    va_start(args, fmt);
  34.532 +    i=vsnprintf(buf,size,fmt,args);
  34.533 +    va_end(args);
  34.534 +    return i;
  34.535  }
  34.536  
  34.537 -int
  34.538 -vsprintf(char *buf, const char *cfmt, va_list ap)
  34.539 +/**
  34.540 + * vsprintf - Format a string and place it in a buffer
  34.541 + * @buf: The buffer to place the result into
  34.542 + * @fmt: The format string to use
  34.543 + * @args: Arguments for the format string
  34.544 + *
  34.545 + * Call this function if you are already dealing with a va_list.
  34.546 + * You probably want sprintf instead.
  34.547 + */
  34.548 +int vsprintf(char *buf, const char *fmt, va_list args)
  34.549  {
  34.550 -	int retval;
  34.551 -
  34.552 -	retval = kvprintf(cfmt, (void *)buf, 10, ap);
  34.553 -	buf[retval] = '\0';
  34.554 -	return retval;
  34.555 +    return vsnprintf(buf, 0xFFFFFFFFUL, fmt, args);
  34.556  }
  34.557  
  34.558  
  34.559 -/*
  34.560 - * Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
  34.561 - * order; return an optional length and a pointer to the last character
  34.562 - * written in the buffer (i.e., the first character of the string).
  34.563 - * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
  34.564 +/**
  34.565 + * sprintf - Format a string and place it in a buffer
  34.566 + * @buf: The buffer to place the result into
  34.567 + * @fmt: The format string to use
  34.568 + * @...: Arguments for the format string
  34.569   */
  34.570 -static char *
  34.571 -ksprintn(char *nbuf, u_long ul, int base, int *lenp)
  34.572 +int sprintf(char * buf, const char *fmt, ...)
  34.573  {
  34.574 -	char *p;
  34.575 +    va_list args;
  34.576 +    int i;
  34.577  
  34.578 -	p = nbuf;
  34.579 -	*p = '\0';
  34.580 -	do {
  34.581 -		*++p = hex2ascii(ul % base);
  34.582 -	} while (ul /= base);
  34.583 -	if (lenp)
  34.584 -		*lenp = p - nbuf;
  34.585 -	return (p);
  34.586 +    va_start(args, fmt);
  34.587 +    i=vsprintf(buf,fmt,args);
  34.588 +    va_end(args);
  34.589 +    return i;
  34.590  }
  34.591 -/* ksprintn, but for a quad_t. */
  34.592 -static char *
  34.593 -ksprintqn(char *nbuf, u_quad_t uq, int base, int *lenp)
  34.594 -{
  34.595 -	char *p;
  34.596 +
  34.597  
  34.598 -	p = nbuf;
  34.599 -	*p = '\0';
  34.600 -	do {
  34.601 -		*++p = hex2ascii(uq % base);
  34.602 -	} while (uq /= base);
  34.603 -	if (lenp)
  34.604 -		*lenp = p - nbuf;
  34.605 -	return (p);
  34.606 +void printf(const char *fmt, ...)
  34.607 +{
  34.608 +    static char   buf[1024];
  34.609 +    va_list       args;
  34.610 +    
  34.611 +    va_start(args, fmt);
  34.612 +    (void)vsnprintf(buf, sizeof(buf), fmt, args);
  34.613 +    va_end(args);        
  34.614 +   
  34.615 +    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
  34.616  }
  34.617  
  34.618 -/*
  34.619 - * Scaled down version of printf(3).
  34.620 - *
  34.621 - * Two additional formats:
  34.622 - *
  34.623 - * The format %b is supported to decode error registers.
  34.624 - * Its usage is:
  34.625 - *
  34.626 - *	printf("reg=%b\n", regval, "<base><arg>*");
  34.627 - *
  34.628 - * where <base> is the output base expressed as a control character, e.g.
  34.629 - * \10 gives octal; \20 gives hex.  Each arg is a sequence of characters,
  34.630 - * the first of which gives the bit number to be inspected (origin 1), and
  34.631 - * the next characters (up to a control character, i.e. a character <= 32),
  34.632 - * give the name of the register.  Thus:
  34.633 - *
  34.634 - *	kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
  34.635 - *
  34.636 - * would produce output:
  34.637 - *
  34.638 - *	reg=3<BITTWO,BITONE>
  34.639 - *
  34.640 - * XXX:  %D  -- Hexdump, takes pointer and separator string:
  34.641 - *		("%6D", ptr, ":")   -> XX:XX:XX:XX:XX:XX
  34.642 - *		("%*D", len, ptr, " " -> XX XX XX XX ...
  34.643 +/**
  34.644 + * vsscanf - Unformat a buffer into a list of arguments
  34.645 + * @buf:	input buffer
  34.646 + * @fmt:	format of buffer
  34.647 + * @args:	arguments
  34.648   */
  34.649 +int vsscanf(const char * buf, const char * fmt, va_list args)
  34.650 +{
  34.651 +	const char *str = buf;
  34.652 +	char *next;
  34.653 +	char digit;
  34.654 +	int num = 0;
  34.655 +	int qualifier;
  34.656 +	int base;
  34.657 +	int field_width;
  34.658 +	int is_sign = 0;
  34.659 +
  34.660 +	while(*fmt && *str) {
  34.661 +		/* skip any white space in format */
  34.662 +		/* white space in format matchs any amount of
  34.663 +		 * white space, including none, in the input.
  34.664 +		 */
  34.665 +		if (isspace(*fmt)) {
  34.666 +			while (isspace(*fmt))
  34.667 +				++fmt;
  34.668 +			while (isspace(*str))
  34.669 +				++str;
  34.670 +		}
  34.671 +
  34.672 +		/* anything that is not a conversion must match exactly */
  34.673 +		if (*fmt != '%' && *fmt) {
  34.674 +			if (*fmt++ != *str++)
  34.675 +				break;
  34.676 +			continue;
  34.677 +		}
  34.678  
  34.679 -/* RN: This normally takes a function for output. 
  34.680 - * we always print to a string and the use HYPERCALL for write to console */
  34.681 -static int
  34.682 -kvprintf(char const *fmt, void *arg, int radix, va_list ap)
  34.683 -{
  34.684 -
  34.685 -#define PCHAR(c) {int cc=(c); *d++ = cc; retval++; }
  34.686 +		if (!*fmt)
  34.687 +			break;
  34.688 +		++fmt;
  34.689 +		
  34.690 +		/* skip this conversion.
  34.691 +		 * advance both strings to next white space
  34.692 +		 */
  34.693 +		if (*fmt == '*') {
  34.694 +			while (!isspace(*fmt) && *fmt)
  34.695 +				fmt++;
  34.696 +			while (!isspace(*str) && *str)
  34.697 +				str++;
  34.698 +			continue;
  34.699 +		}
  34.700  
  34.701 -	char nbuf[MAXNBUF];
  34.702 -	char *p, *q, *d;
  34.703 -	u_char *up;
  34.704 -	int ch, n;
  34.705 -	u_long ul;
  34.706 -	u_quad_t uq;
  34.707 -	int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
  34.708 -	int dwidth;
  34.709 -	char padc;
  34.710 -	int retval = 0;
  34.711 +		/* get field width */
  34.712 +		field_width = -1;
  34.713 +		if (isdigit(*fmt))
  34.714 +			field_width = skip_atoi(&fmt);
  34.715  
  34.716 -	ul = 0;
  34.717 -	uq = 0;
  34.718 -    d = (char *) arg;
  34.719 -
  34.720 -	if (fmt == NULL)
  34.721 -		fmt = "(fmt null)\n";
  34.722 -
  34.723 -	if (radix < 2 || radix > 36)
  34.724 -		radix = 10;
  34.725 +		/* get conversion qualifier */
  34.726 +		qualifier = -1;
  34.727 +		if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
  34.728 +		    *fmt == 'Z' || *fmt == 'z') {
  34.729 +			qualifier = *fmt++;
  34.730 +			if (unlikely(qualifier == *fmt)) {
  34.731 +				if (qualifier == 'h') {
  34.732 +					qualifier = 'H';
  34.733 +					fmt++;
  34.734 +				} else if (qualifier == 'l') {
  34.735 +					qualifier = 'L';
  34.736 +					fmt++;
  34.737 +				}
  34.738 +			}
  34.739 +		}
  34.740 +		base = 10;
  34.741 +		is_sign = 0;
  34.742  
  34.743 -	for (;;) {
  34.744 -		padc = ' ';
  34.745 -		width = 0;
  34.746 -		while ((ch = (u_char)*fmt++) != '%') {
  34.747 -			if (ch == '\0') 
  34.748 -				return retval;
  34.749 -			PCHAR(ch);
  34.750 -		}
  34.751 -		qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
  34.752 -		sign = 0; dot = 0; dwidth = 0;
  34.753 -reswitch:	switch (ch = (u_char)*fmt++) {
  34.754 -		case '.':
  34.755 -			dot = 1;
  34.756 -			goto reswitch;
  34.757 -		case '#':
  34.758 -			sharpflag = 1;
  34.759 -			goto reswitch;
  34.760 -		case '+':
  34.761 -			sign = 1;
  34.762 -			goto reswitch;
  34.763 -		case '-':
  34.764 -			ladjust = 1;
  34.765 -			goto reswitch;
  34.766 -		case '%':
  34.767 -			PCHAR(ch);
  34.768 +		if (!*fmt || !*str)
  34.769  			break;
  34.770 -		case '*':
  34.771 -			if (!dot) {
  34.772 -				width = va_arg(ap, int);
  34.773 -				if (width < 0) {
  34.774 -					ladjust = !ladjust;
  34.775 -					width = -width;
  34.776 -				}
  34.777 -			} else {
  34.778 -				dwidth = va_arg(ap, int);
  34.779 -			}
  34.780 -			goto reswitch;
  34.781 -		case '0':
  34.782 -			if (!dot) {
  34.783 -				padc = '0';
  34.784 -				goto reswitch;
  34.785 +
  34.786 +		switch(*fmt++) {
  34.787 +		case 'c':
  34.788 +		{
  34.789 +			char *s = (char *) va_arg(args,char*);
  34.790 +			if (field_width == -1)
  34.791 +				field_width = 1;
  34.792 +			do {
  34.793 +				*s++ = *str++;
  34.794 +			} while (--field_width > 0 && *str);
  34.795 +			num++;
  34.796 +		}
  34.797 +		continue;
  34.798 +		case 's':
  34.799 +		{
  34.800 +			char *s = (char *) va_arg(args, char *);
  34.801 +			if(field_width == -1)
  34.802 +				field_width = INT_MAX;
  34.803 +			/* first, skip leading white space in buffer */
  34.804 +			while (isspace(*str))
  34.805 +				str++;
  34.806 +
  34.807 +			/* now copy until next white space */
  34.808 +			while (*str && !isspace(*str) && field_width--) {
  34.809 +				*s++ = *str++;
  34.810  			}
  34.811 -		case '1': case '2': case '3': case '4':
  34.812 -		case '5': case '6': case '7': case '8': case '9':
  34.813 -				for (n = 0;; ++fmt) {
  34.814 -					n = n * 10 + ch - '0';
  34.815 -					ch = *fmt;
  34.816 -					if (ch < '0' || ch > '9')
  34.817 -						break;
  34.818 -				}
  34.819 -			if (dot)
  34.820 -				dwidth = n;
  34.821 -			else
  34.822 -				width = n;
  34.823 -			goto reswitch;
  34.824 -		case 'b':
  34.825 -			ul = va_arg(ap, int);
  34.826 -			p = va_arg(ap, char *);
  34.827 -			for (q = ksprintn(nbuf, ul, *p++, NULL); *q;)
  34.828 -				PCHAR(*q--);
  34.829 +			*s = '\0';
  34.830 +			num++;
  34.831 +		}
  34.832 +		continue;
  34.833 +		case 'n':
  34.834 +			/* return number of characters read so far */
  34.835 +		{
  34.836 +			int *i = (int *)va_arg(args,int*);
  34.837 +			*i = str - buf;
  34.838 +		}
  34.839 +		continue;
  34.840 +		case 'o':
  34.841 +			base = 8;
  34.842 +			break;
  34.843 +		case 'x':
  34.844 +		case 'X':
  34.845 +			base = 16;
  34.846 +			break;
  34.847 +		case 'i':
  34.848 +                        base = 0;
  34.849 +		case 'd':
  34.850 +			is_sign = 1;
  34.851 +		case 'u':
  34.852 +			break;
  34.853 +		case '%':
  34.854 +			/* looking for '%' in str */
  34.855 +			if (*str++ != '%') 
  34.856 +				return num;
  34.857 +			continue;
  34.858 +		default:
  34.859 +			/* invalid format; stop here */
  34.860 +			return num;
  34.861 +		}
  34.862  
  34.863 -			if (!ul)
  34.864 +		/* have some sort of integer conversion.
  34.865 +		 * first, skip white space in buffer.
  34.866 +		 */
  34.867 +		while (isspace(*str))
  34.868 +			str++;
  34.869 +
  34.870 +		digit = *str;
  34.871 +		if (is_sign && digit == '-')
  34.872 +			digit = *(str + 1);
  34.873 +
  34.874 +		if (!digit
  34.875 +                    || (base == 16 && !isxdigit(digit))
  34.876 +                    || (base == 10 && !isdigit(digit))
  34.877 +                    || (base == 8 && (!isdigit(digit) || digit > '7'))
  34.878 +                    || (base == 0 && !isdigit(digit)))
  34.879  				break;
  34.880  
  34.881 -			for (tmp = 0; *p;) {
  34.882 -				n = *p++;
  34.883 -				if (ul & (1 << (n - 1))) {
  34.884 -					PCHAR(tmp ? ',' : '<');
  34.885 -					for (; (n = *p) > ' '; ++p)
  34.886 -						PCHAR(n);
  34.887 -					tmp = 1;
  34.888 -				} else
  34.889 -					for (; *p > ' '; ++p)
  34.890 -						continue;
  34.891 +		switch(qualifier) {
  34.892 +		case 'H':	/* that's 'hh' in format */
  34.893 +			if (is_sign) {
  34.894 +				signed char *s = (signed char *) va_arg(args,signed char *);
  34.895 +				*s = (signed char) simple_strtol(str,&next,base);
  34.896 +			} else {
  34.897 +				unsigned char *s = (unsigned char *) va_arg(args, unsigned char *);
  34.898 +				*s = (unsigned char) simple_strtoul(str, &next, base);
  34.899  			}
  34.900 -			if (tmp)
  34.901 -				PCHAR('>');
  34.902  			break;
  34.903 -		case 'c':
  34.904 -			PCHAR(va_arg(ap, int));
  34.905 +		case 'h':
  34.906 +			if (is_sign) {
  34.907 +				short *s = (short *) va_arg(args,short *);
  34.908 +				*s = (short) simple_strtol(str,&next,base);
  34.909 +			} else {
  34.910 +				unsigned short *s = (unsigned short *) va_arg(args, unsigned short *);
  34.911 +				*s = (unsigned short) simple_strtoul(str, &next, base);
  34.912 +			}
  34.913  			break;
  34.914 -		case 'D':
  34.915 -			up = va_arg(ap, u_char *);
  34.916 -			p = va_arg(ap, char *);
  34.917 -			if (!width)
  34.918 -				width = 16;
  34.919 -			while(width--) {
  34.920 -				PCHAR(hex2ascii(*up >> 4));
  34.921 -				PCHAR(hex2ascii(*up & 0x0f));
  34.922 -				up++;
  34.923 -				if (width)
  34.924 -					for (q=p;*q;q++)
  34.925 -						PCHAR(*q);
  34.926 +		case 'l':
  34.927 +			if (is_sign) {
  34.928 +				long *l = (long *) va_arg(args,long *);
  34.929 +				*l = simple_strtol(str,&next,base);
  34.930 +			} else {
  34.931 +				unsigned long *l = (unsigned long*) va_arg(args,unsigned long*);
  34.932 +				*l = simple_strtoul(str,&next,base);
  34.933 +			}
  34.934 +			break;
  34.935 +		case 'L':
  34.936 +			if (is_sign) {
  34.937 +				long long *l = (long long*) va_arg(args,long long *);
  34.938 +				*l = simple_strtoll(str,&next,base);
  34.939 +			} else {
  34.940 +				unsigned long long *l = (unsigned long long*) va_arg(args,unsigned long long*);
  34.941 +				*l = simple_strtoull(str,&next,base);
  34.942  			}
  34.943  			break;
  34.944 -		case 'd':
  34.945 -			if (qflag)
  34.946 -				uq = va_arg(ap, quad_t);
  34.947 -			else if (lflag)
  34.948 -				ul = va_arg(ap, long);
  34.949 -			else
  34.950 -				ul = va_arg(ap, int);
  34.951 -			sign = 1;
  34.952 -			base = 10;
  34.953 -			goto number;
  34.954 -		case 'l':
  34.955 -			if (lflag) {
  34.956 -				lflag = 0;
  34.957 -				qflag = 1;
  34.958 -			} else
  34.959 -				lflag = 1;
  34.960 -			goto reswitch;
  34.961 -		case 'o':
  34.962 -			if (qflag)
  34.963 -				uq = va_arg(ap, u_quad_t);
  34.964 -			else if (lflag)
  34.965 -				ul = va_arg(ap, u_long);
  34.966 -			else
  34.967 -				ul = va_arg(ap, u_int);
  34.968 -			base = 8;
  34.969 -			goto nosign;
  34.970 -		case 'p':
  34.971 -			ul = (uintptr_t)va_arg(ap, void *);
  34.972 -			base = 16;
  34.973 -			sharpflag = 0;
  34.974 -            padc  = '0';
  34.975 -            width = sizeof(uintptr_t)*2;
  34.976 -			goto nosign;
  34.977 -		case 'q':
  34.978 -			qflag = 1;
  34.979 -			goto reswitch;
  34.980 -		case 'n':
  34.981 -		case 'r':
  34.982 -			if (qflag)
  34.983 -				uq = va_arg(ap, u_quad_t);
  34.984 -			else if (lflag)
  34.985 -				ul = va_arg(ap, u_long);
  34.986 -			else
  34.987 -				ul = sign ?
  34.988 -				    (u_long)va_arg(ap, int) : va_arg(ap, u_int);
  34.989 -			base = radix;
  34.990 -			goto number;
  34.991 -		case 's':
  34.992 -			p = va_arg(ap, char *);
  34.993 -			if (p == NULL)
  34.994 -				p = "(null)";
  34.995 -			if (!dot)
  34.996 -				n = strlen (p);
  34.997 -			else
  34.998 -				for (n = 0; n < dwidth && p[n]; n++)
  34.999 -					continue;
 34.1000 -
 34.1001 -			width -= n;
 34.1002 -
 34.1003 -			if (!ladjust && width > 0)
 34.1004 -				while (width--)
 34.1005 -					PCHAR(padc);
 34.1006 -			while (n--)
 34.1007 -				PCHAR(*p++);
 34.1008 -			if (ladjust && width > 0)
 34.1009 -				while (width--)
 34.1010 -					PCHAR(padc);
 34.1011 -			break;
 34.1012 -		case 'u':
 34.1013 -			if (qflag)
 34.1014 -				uq = va_arg(ap, u_quad_t);
 34.1015 -			else if (lflag)
 34.1016 -				ul = va_arg(ap, u_long);
 34.1017 -			else
 34.1018 -				ul = va_arg(ap, u_int);
 34.1019 -			base = 10;
 34.1020 -			goto nosign;
 34.1021 -		case 'x':
 34.1022 -		case 'X':
 34.1023 -			if (qflag)
 34.1024 -				uq = va_arg(ap, u_quad_t);
 34.1025 -			else if (lflag)
 34.1026 -				ul = va_arg(ap, u_long);
 34.1027 -			else
 34.1028 -				ul = va_arg(ap, u_int);
 34.1029 -			base = 16;
 34.1030 -			goto nosign;
 34.1031 +		case 'Z':
 34.1032  		case 'z':
 34.1033 -			if (qflag)
 34.1034 -				uq = va_arg(ap, u_quad_t);
 34.1035 -			else if (lflag)
 34.1036 -				ul = va_arg(ap, u_long);
 34.1037 -			else
 34.1038 -				ul = sign ?
 34.1039 -				    (u_long)va_arg(ap, int) : va_arg(ap, u_int);
 34.1040 -			base = 16;
 34.1041 -			goto number;
 34.1042 -nosign:			sign = 0;
 34.1043 -number:			
 34.1044 -			if (qflag) {
 34.1045 -				if (sign && (quad_t)uq < 0) {
 34.1046 -					neg = 1;
 34.1047 -					uq = -(quad_t)uq;
 34.1048 -				}
 34.1049 -				p = ksprintqn(nbuf, uq, base, &tmp);
 34.1050 +		{
 34.1051 +			size_t *s = (size_t*) va_arg(args,size_t*);
 34.1052 +			*s = (size_t) simple_strtoul(str,&next,base);
 34.1053 +		}
 34.1054 +		break;
 34.1055 +		default:
 34.1056 +			if (is_sign) {
 34.1057 +				int *i = (int *) va_arg(args, int*);
 34.1058 +				*i = (int) simple_strtol(str,&next,base);
 34.1059  			} else {
 34.1060 -				if (sign && (long)ul < 0) {
 34.1061 -					neg = 1;
 34.1062 -					ul = -(long)ul;
 34.1063 -				}
 34.1064 -				p = ksprintn(nbuf, ul, base, &tmp);
 34.1065 -			}
 34.1066 -			if (sharpflag && (qflag ? uq != 0 : ul != 0)) {
 34.1067 -				if (base == 8)
 34.1068 -					tmp++;
 34.1069 -				else if (base == 16)
 34.1070 -					tmp += 2;
 34.1071 +				unsigned int *i = (unsigned int*) va_arg(args, unsigned int*);
 34.1072 +				*i = (unsigned int) simple_strtoul(str,&next,base);
 34.1073  			}
 34.1074 -			if (neg)
 34.1075 -				tmp++;
 34.1076 -
 34.1077 -			if (!ladjust && width && (width -= tmp) > 0)
 34.1078 -				while (width--)
 34.1079 -					PCHAR(padc);
 34.1080 -			if (neg)
 34.1081 -				PCHAR('-');
 34.1082 -			if (sharpflag && (qflag ? uq != 0 : ul != 0)) {
 34.1083 -				if (base == 8) {
 34.1084 -					PCHAR('0');
 34.1085 -				} else if (base == 16) {
 34.1086 -					PCHAR('0');
 34.1087 -					PCHAR('x');
 34.1088 -				}
 34.1089 -			}
 34.1090 -
 34.1091 -			while (*p)
 34.1092 -				PCHAR(*p--);
 34.1093 -
 34.1094 -			if (ladjust && width && (width -= tmp) > 0)
 34.1095 -				while (width--)
 34.1096 -					PCHAR(padc);
 34.1097 -
 34.1098 -			break;
 34.1099 -		default:
 34.1100 -			PCHAR('%');
 34.1101 -			if (lflag)
 34.1102 -				PCHAR('l');
 34.1103 -			PCHAR(ch);
 34.1104  			break;
 34.1105  		}
 34.1106 +		num++;
 34.1107 +
 34.1108 +		if (!next)
 34.1109 +			break;
 34.1110 +		str = next;
 34.1111  	}
 34.1112 -#undef PCHAR
 34.1113 +	return num;
 34.1114  }
 34.1115  
 34.1116 +/**
 34.1117 + * sscanf - Unformat a buffer into a list of arguments
 34.1118 + * @buf:	input buffer
 34.1119 + * @fmt:	formatting of buffer
 34.1120 + * @...:	resulting arguments
 34.1121 + */
 34.1122 +int sscanf(const char * buf, const char * fmt, ...)
 34.1123 +{
 34.1124 +	va_list args;
 34.1125 +	int i;
 34.1126 +
 34.1127 +	va_start(args,fmt);
 34.1128 +	i = vsscanf(buf,fmt,args);
 34.1129 +	va_end(args);
 34.1130 +	return i;
 34.1131 +}
 34.1132 +
 34.1133 +
    35.1 --- a/extras/mini-os/lib/string.c	Thu Sep 08 09:18:40 2005 -0600
    35.2 +++ b/extras/mini-os/lib/string.c	Fri Sep 09 10:30:54 2005 -0600
    35.3 @@ -107,6 +107,19 @@ size_t strnlen(const char * s, size_t co
    35.4          return sc - s;
    35.5  }
    35.6  
    35.7 +
    35.8 +char * strcat(char * dest, const char * src)
    35.9 +{
   35.10 +    char *tmp = dest;
   35.11 +    
   35.12 +    while (*dest)
   35.13 +        dest++;
   35.14 +    
   35.15 +    while ((*dest++ = *src++) != '\0');
   35.16 +    
   35.17 +    return tmp;
   35.18 +}
   35.19 +
   35.20  size_t strlen(const char * s)
   35.21  {
   35.22  	const char *sc;
    37.1 --- a/extras/mini-os/mm.c	Thu Sep 08 09:18:40 2005 -0600
    37.2 +++ b/extras/mini-os/mm.c	Fri Sep 09 10:30:54 2005 -0600
    37.3 @@ -198,7 +198,6 @@ static void print_chunks(void *start, in
    37.4  #endif
    37.5  
    37.6  
    37.7 -
    37.8  /*
    37.9   * Initialise allocator, placing addresses [@min,@max] in free pool.
   37.10   * @min and @max are PHYSICAL addresses.
   37.11 @@ -486,16 +485,17 @@ void init_mm(void)
   37.12      phys_to_machine_mapping = (unsigned long *)start_info.mfn_list;
   37.13     
   37.14      /* First page follows page table pages and 3 more pages (store page etc) */
   37.15 -    start_pfn = PFN_UP(__pa(start_info.pt_base)) + start_info.nr_pt_frames + 3;
   37.16 +    start_pfn = PFN_UP(to_phys(start_info.pt_base)) + start_info.nr_pt_frames + 3;
   37.17      max_pfn = start_info.nr_pages;
   37.18  
   37.19      printk("  start_pfn:    %lx\n", start_pfn);
   37.20      printk("  max_pfn:      %lx\n", max_pfn);
   37.21  
   37.22  
   37.23 +#ifdef __i386__
   37.24      build_pagetable(&start_pfn, &max_pfn);
   37.25 -    
   37.26 -#ifdef __i386__
   37.27 +#endif
   37.28 +
   37.29      /*
   37.30       * now we can initialise the page allocator
   37.31       */
   37.32 @@ -503,7 +503,5 @@ void init_mm(void)
   37.33             (u_long)to_virt(PFN_PHYS(start_pfn)), PFN_PHYS(start_pfn), 
   37.34             (u_long)to_virt(PFN_PHYS(max_pfn)), PFN_PHYS(max_pfn));
   37.35      init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn));   
   37.36 -#endif
   37.37 -    
   37.38      printk("MM: done\n");
   37.39  }
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/extras/mini-os/sched.c	Fri Sep 09 10:30:54 2005 -0600
    38.3 @@ -0,0 +1,300 @@
    38.4 +/* 
    38.5 + ****************************************************************************
    38.6 + * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
    38.7 + ****************************************************************************
    38.8 + *
    38.9 + *        File: sched.c
   38.10 + *      Author: Grzegorz Milos
   38.11 + *     Changes: 
   38.12 + *              
   38.13 + *        Date: Aug 2005
   38.14 + * 
   38.15 + * Environment: Xen Minimal OS
   38.16 + * Description: simple scheduler for Mini-Os
   38.17 + *
   38.18 + * The scheduler is non-preemptive (cooperative), and schedules according 
   38.19 + * to Round Robin algorithm.
   38.20 + *
   38.21 + ****************************************************************************
   38.22 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   38.23 + * of this software and associated documentation files (the "Software"), to
   38.24 + * deal in the Software without restriction, including without limitation the
   38.25 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   38.26 + * sell copies of the Software, and to permit persons to whom the Software is
   38.27 + * furnished to do so, subject to the following conditions:
   38.28 + * 
   38.29 + * The above copyright notice and this permission notice shall be included in
   38.30 + * all copies or substantial portions of the Software.
   38.31 + * 
   38.32 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   38.33 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   38.34 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
   38.35 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   38.36 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
   38.37 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
   38.38 + * DEALINGS IN THE SOFTWARE.
   38.39 + */
   38.40 +
   38.41 +#include <os.h>
   38.42 +#include <hypervisor.h>
   38.43 +#include <time.h>
   38.44 +#include <mm.h>
   38.45 +#include <types.h>
   38.46 +#include <lib.h>
   38.47 +#include <xmalloc.h>
   38.48 +#include <list.h>
   38.49 +#include <sched.h>
   38.50 +#include <semaphore.h>
   38.51 +
   38.52 +#ifdef SCHED_DEBUG
   38.53 +#define DEBUG(_f, _a...) \
   38.54 +    printk("MINI_OS(file=sched.c, line=%d) " _f "\n", __LINE__, ## _a)
   38.55 +#else
   38.56 +#define DEBUG(_f, _a...)    ((void)0)
   38.57 +#endif
   38.58 +
   38.59 +
   38.60 +#define RUNNABLE_FLAG   0x00000001
   38.61 +
   38.62 +#define is_runnable(_thread)    (_thread->flags & RUNNABLE_FLAG)
   38.63 +#define set_runnable(_thread)   (_thread->flags |= RUNNABLE_FLAG)
   38.64 +#define clear_runnable(_thread) (_thread->flags &= ~RUNNABLE_FLAG)
   38.65 +
   38.66 +
   38.67 +struct thread *idle_thread;
   38.68 +LIST_HEAD(exited_threads);
   38.69 +
   38.70 +void dump_stack(struct thread *thread)
   38.71 +{
   38.72 +    unsigned long *bottom = (unsigned long *)thread->stack + 2048; 
   38.73 +    unsigned long *pointer = (unsigned long *)thread->eps;
   38.74 +    int count;
   38.75 +    printk("The stack for \"%s\"\n", thread->name);
   38.76 +    for(count = 0; count < 15 && pointer < bottom; count ++)
   38.77 +    {
   38.78 +        printk("[0x%lx] 0x%lx\n", pointer, *pointer);
   38.79 +        pointer++;
   38.80 +    }
   38.81 +    
   38.82 +    if(pointer < bottom) printk("Not the whole stack printed\n");
   38.83 +}
   38.84 +
   38.85 +#ifdef __i386__
   38.86 +#define switch_threads(prev, next) do {                                 \
   38.87 +    unsigned long esi,edi;                                              \
   38.88 +    __asm__ __volatile__("pushfl\n\t"                                   \
   38.89 +                         "pushl %%ebp\n\t"                              \
   38.90 +                         "movl %%esp,%0\n\t"         /* save ESP */     \
   38.91 +                         "movl %4,%%esp\n\t"        /* restore ESP */   \
   38.92 +                         "movl $1f,%1\n\t"          /* save EIP */      \
   38.93 +                         "pushl %5\n\t"             /* restore EIP */   \
   38.94 +                         "ret\n\t"                                      \
   38.95 +                         "1:\t"                                         \
   38.96 +                         "popl %%ebp\n\t"                               \
   38.97 +                         "popfl"                                        \
   38.98 +                         :"=m" (prev->eps),"=m" (prev->eip),            \
   38.99 +                          "=S" (esi),"=D" (edi)             \
  38.100 +                         :"m" (next->eps),"m" (next->eip),              \
  38.101 +                          "2" (prev), "d" (next));                      \
  38.102 +} while (0)
  38.103 +#elif __x86_64__
  38.104 +/* FIXME */
  38.105 +#endif
  38.106 +
  38.107 +void inline print_runqueue(void)
  38.108 +{
  38.109 +    struct list_head *it;
  38.110 +    struct thread *th;
  38.111 +    list_for_each(it, &idle_thread->thread_list)
  38.112 +    {
  38.113 +        th = list_entry(it, struct thread, thread_list);
  38.114 +        printk("   Thread \"%s\", runnable=%d\n", th->name, is_runnable(th));
  38.115 +    }
  38.116 +    printk("\n");
  38.117 +}
  38.118 +
  38.119 +
  38.120 +void schedule(void)
  38.121 +{
  38.122 +    struct thread *prev, *next, *thread;
  38.123 +    struct list_head *iterator;
  38.124 +    unsigned long flags;
  38.125 +    prev = current;
  38.126 +    local_irq_save(flags); 
  38.127 +    list_for_each(iterator, &exited_threads)
  38.128 +    {
  38.129 +        thread = list_entry(iterator, struct thread, thread_list);
  38.130 +        if(thread != prev)
  38.131 +        {
  38.132 +            list_del(&thread->thread_list);
  38.133 +            free_pages(thread->stack, 1);
  38.134 +            xfree(thread);
  38.135 +        }
  38.136 +    }
  38.137 +    next = idle_thread;    
  38.138 +    /* Thread list needs to be protected */
  38.139 +    list_for_each(iterator, &idle_thread->thread_list)
  38.140 +    {
  38.141 +        thread = list_entry(iterator, struct thread, thread_list);
  38.142 +        if(is_runnable(thread)) 
  38.143 +        {
  38.144 +            next = thread;
  38.145 +            /* Put this thread on the end of the list */
  38.146 +            list_del(&thread->thread_list);
  38.147 +            list_add_tail(&thread->thread_list, &idle_thread->thread_list);
  38.148 +            break;
  38.149 +        }
  38.150 +    }
  38.151 +    local_irq_restore(flags);
  38.152 +    /* Interrupting the switch is equivalent to having the next thread
  38.153 +       inturrupted at the return instruction. And therefore at safe point. */
  38.154 +/* The thread switching only works for i386 at the moment */    
  38.155 +#ifdef __i386__    
  38.156 +    if(prev != next) switch_threads(prev, next);
  38.157 +#endif    
  38.158 +}
  38.159 +
  38.160 +
  38.161 +
  38.162 +void exit_thread(struct thread *thread)
  38.163 +{
  38.164 +    unsigned long flags;
  38.165 +    printk("Thread \"%s\" exited.\n", thread->name);
  38.166 +    local_irq_save(flags);
  38.167 +    /* Remove from the thread list */
  38.168 +    list_del(&thread->thread_list);
  38.169 +    clear_runnable(thread);
  38.170 +    /* Put onto exited list */
  38.171 +    list_add(&thread->thread_list, &exited_threads);
  38.172 +    local_irq_restore(flags);
  38.173 +    /* Schedule will free the resources */
  38.174 +    schedule();
  38.175 +}
  38.176 +
  38.177 +
  38.178 +struct thread* create_thread(char *name, void (*function)(void *), void *data)
  38.179 +{
  38.180 +    struct thread *thread;
  38.181 +    unsigned long flags;
  38.182 +    
  38.183 +    thread = xmalloc(struct thread);
  38.184 +    /* Allocate 2 pages for stack, stack will be 2pages aligned */
  38.185 +    thread->stack = (char *)alloc_pages(1);
  38.186 +    thread->name = name;
  38.187 +    printk("Thread \"%s\": pointer: 0x%lx, stack: 0x%lx\n", name, thread, 
  38.188 +            thread->stack);
  38.189 +    
  38.190 +    thread->eps = (unsigned long)thread->stack + 4096 * 2 - 4;
  38.191 +    /* Save pointer to the thread on the stack, used by current macro */
  38.192 +    *((unsigned long *)thread->stack) = (unsigned long)thread;
  38.193 +    *((unsigned long *)thread->eps) = (unsigned long)thread;
  38.194 +    thread->eps -= 4; 
  38.195 +    *((unsigned long *)thread->eps) = (unsigned long)data;
  38.196 +    
  38.197 +    /* No return address */
  38.198 +    thread->eps -= 4;
  38.199 +    *((unsigned long *)thread->eps) = (unsigned long)exit_thread;
  38.200 +    
  38.201 +    thread->eip = (unsigned long)function;
  38.202 +     
  38.203 +    /* Not runable, not exited */ 
  38.204 +    thread->flags = 0;
  38.205 +    set_runnable(thread);
  38.206 +    
  38.207 +    local_irq_save(flags);
  38.208 +    if(idle_thread != NULL)
  38.209 +        list_add_tail(&thread->thread_list, &idle_thread->thread_list); 
  38.210 +    local_irq_restore(flags);
  38.211 +
  38.212 +    return thread;
  38.213 +}
  38.214 +
  38.215 +
  38.216 +void block(struct thread *thread)
  38.217 +{
  38.218 +    clear_runnable(thread);
  38.219 +}
  38.220 +
  38.221 +void wake(struct thread *thread)
  38.222 +{
  38.223 +    set_runnable(thread);
  38.224 +}
  38.225 +
  38.226 +void idle_thread_fn(void *unused)
  38.227 +{
  38.228 +    for(;;)
  38.229 +    {
  38.230 +        schedule();
  38.231 +        printk("Blocking the domain\n"); 
  38.232 +        block_domain(10000);
  38.233 +    }
  38.234 +}
  38.235 +
  38.236 +void run_idle_thread(void)
  38.237 +{
  38.238 +    /* Switch stacks and run the thread */ 
  38.239 +    __asm__ __volatile__("mov %0,%%esp\n\t"
  38.240 +                         "push %1\n\t" 
  38.241 +                         "ret"                                            
  38.242 +                         :"=m" (idle_thread->eps)
  38.243 +                         :"m" (idle_thread->eip));                          
  38.244 +}
  38.245 +
  38.246 +
  38.247 +
  38.248 +DECLARE_MUTEX(mutex);
  38.249 +
  38.250 +void th_f1(void *data)
  38.251 +{
  38.252 +    struct timeval tv1, tv2;
  38.253 +
  38.254 +    for(;;)
  38.255 +    {
  38.256 +        down(&mutex);
  38.257 +        printk("Thread \"%s\" got semaphore, runnable %d\n", current->name, is_runnable(current));
  38.258 +        schedule();
  38.259 +        printk("Thread \"%s\" releases the semaphore\n", current->name);
  38.260 +        up(&mutex);
  38.261 +        
  38.262 +        
  38.263 +        gettimeofday(&tv1);
  38.264 +        for(;;)
  38.265 +        {
  38.266 +            gettimeofday(&tv2);
  38.267 +            if(tv2.tv_sec - tv1.tv_sec > 2) break;
  38.268 +        }
  38.269 +                
  38.270 +        
  38.271 +        schedule(); 
  38.272 +    }
  38.273 +}
  38.274 +
  38.275 +void th_f2(void *data)
  38.276 +{
  38.277 +    for(;;)
  38.278 +    {
  38.279 +        printk("Thread OTHER executing, data 0x%lx\n", data);
  38.280 +        schedule();
  38.281 +    }
  38.282 +}
  38.283 +
  38.284 +
  38.285 +
  38.286 +void init_sched(void)
  38.287 +{
  38.288 +    printk("Initialising scheduler\n");
  38.289 +       
  38.290 +    idle_thread = create_thread("Idle", idle_thread_fn, NULL);
  38.291 +    INIT_LIST_HEAD(&idle_thread->thread_list);
  38.292 +
  38.293 +    
  38.294 +/*    create_thread("1", th_f1, (void *)0x1234);    
  38.295 +    create_thread("2", th_f1, (void *)0x1234);    
  38.296 +    create_thread("3", th_f1, (void *)0x1234);    
  38.297 +    create_thread("4", th_f1, (void *)0x1234);    
  38.298 +    create_thread("5", th_f1, (void *)0x1234);    
  38.299 +    create_thread("6", th_f1, (void *)0x1234);    
  38.300 +    create_thread("second", th_f2, NULL);
  38.301 +*/   
  38.302 +}
  38.303 +
    39.1 --- a/extras/mini-os/time.c	Thu Sep 08 09:18:40 2005 -0600
    39.2 +++ b/extras/mini-os/time.c	Fri Sep 09 10:30:54 2005 -0600
    39.3 @@ -203,7 +203,7 @@ static void print_current_time(void)
    39.4  }
    39.5  
    39.6  
    39.7 -void block(u32 millisecs)
    39.8 +void block_domain(u32 millisecs)
    39.9  {
   39.10      struct timeval tv;
   39.11      gettimeofday(&tv);
   39.12 @@ -232,5 +232,6 @@ static void timer_handler(int ev, struct
   39.13  
   39.14  void init_time(void)
   39.15  {
   39.16 +    printk("Initialising timer interface\n");
   39.17      bind_virq(VIRQ_TIMER, &timer_handler);
   39.18  }
    40.1 --- a/extras/mini-os/traps.c	Thu Sep 08 09:18:40 2005 -0600
    40.2 +++ b/extras/mini-os/traps.c	Fri Sep 09 10:30:54 2005 -0600
    40.3 @@ -33,36 +33,7 @@ extern void do_exit(void);
    40.4  
    40.5  void dump_regs(struct pt_regs *regs)
    40.6  {
    40.7 -    unsigned long esp;
    40.8 -    unsigned short ss;
    40.9 -
   40.10 -#ifdef __x86_64__
   40.11 -    esp = regs->rsp;
   40.12 -    ss  = regs->xss;
   40.13 -#else
   40.14 -    esp = (unsigned long) (&regs->esp);
   40.15 -    ss = __KERNEL_DS;
   40.16 -    if (regs->xcs & 2) {
   40.17 -printk("CS is true, esp is %x\n", regs->esp);
   40.18 -        esp = regs->esp;
   40.19 -        ss = regs->xss & 0xffff;
   40.20 -    }
   40.21 -#endif
   40.22 -    printf("EIP:    %04x:[<%p>]\n",
   40.23 -           0xffff & regs->xcs , regs->eip);
   40.24 -    printf("EFLAGS: %p\n",regs->eflags);
   40.25 -    printf("eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
   40.26 -           regs->eax, regs->ebx, regs->ecx, regs->edx);
   40.27 -    printf("esi: %08lx   edi: %08lx   ebp: %08lx   esp: %08lx\n",
   40.28 -           regs->esi, regs->edi, regs->ebp, esp);
   40.29 -#ifdef __x86_64__
   40.30 -    printf("r8 : %p   r9 : %p   r10: %p   r11: %p\n",
   40.31 -           regs->r8,  regs->r9,  regs->r10, regs->r11);
   40.32 -    printf("r12: %p   r13: %p   r14: %p   r15: %p\n",
   40.33 -           regs->r12, regs->r13, regs->r14, regs->r15);
   40.34 -#endif
   40.35 -    printf("ds: %04x   es: %04x   ss: %04x\n",
   40.36 -           regs->xds & 0xffff, regs->xes & 0xffff, ss);
   40.37 +    printk("FIXME: proper register dump (with the stack dump)\n");
   40.38  }	
   40.39  
   40.40  
   40.41 @@ -105,6 +76,7 @@ void do_page_fault(struct pt_regs *regs,
   40.42      printk("Page fault at linear address %p\n", addr);
   40.43      dump_regs(regs);
   40.44  #ifdef __x86_64__
   40.45 +    /* FIXME: _PAGE_PSE */
   40.46      {
   40.47          unsigned long *tab = (unsigned long *)start_info.pt_base;
   40.48          unsigned long page;
   40.49 @@ -112,23 +84,16 @@ void do_page_fault(struct pt_regs *regs,
   40.50          printk("Pagetable walk from %p:\n", tab);
   40.51          
   40.52          page = tab[l4_table_offset(addr)];
   40.53 -        tab = __va(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   40.54 +        tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   40.55          printk(" L4 = %p (%p)\n", page, tab);
   40.56 -        if ( !(page & AGERESENT) )
   40.57 -            goto out;
   40.58  
   40.59          page = tab[l3_table_offset(addr)];
   40.60 -        tab = __va(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   40.61 +        tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   40.62          printk("  L3 = %p (%p)\n", page, tab);
   40.63 -        if ( !(page & AGERESENT) )
   40.64 -            goto out;
   40.65          
   40.66          page = tab[l2_table_offset(addr)];
   40.67 -        tab = __va(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   40.68 -        printk("   L2 = %p (%p) %s\n", page, tab,
   40.69 -               (page & AGESE) ? "(2MB)" : "");
   40.70 -        if ( !(page & AGERESENT) || (page & AGESE) )
   40.71 -            goto out;
   40.72 +        tab =  to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   40.73 +        printk("   L2 = %p (%p)\n", page, tab);
   40.74          
   40.75          page = tab[l1_table_offset(addr)];
   40.76          printk("    L1 = %p\n", page);
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/extras/mini-os/xenbus/Makefile	Fri Sep 09 10:30:54 2005 -0600
    41.3 @@ -0,0 +1,9 @@
    41.4 +all: xenstore.h xenbus_comms.o xenbus_xs.o xenbus_probe.o
    41.5 +
    41.6 +xenstore.h:
    41.7 +	[ -e xenstored.h ] || ln -sf ../../../tools/xenstore/xenstored.h xenstored.h
    41.8 +
    41.9 +clean:
   41.10 +	#Taken care of by main Makefile
   41.11 +	#rm xenstored.h
   41.12 +	#rm *.o
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/extras/mini-os/xenbus/xenbus_comms.c	Fri Sep 09 10:30:54 2005 -0600
    42.3 @@ -0,0 +1,231 @@
    42.4 +/******************************************************************************
    42.5 + * xenbus_comms.c
    42.6 + *
    42.7 + * Low level code to talks to Xen Store: ringbuffer and event channel.
    42.8 + *
    42.9 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
   42.10 + * 
   42.11 + * This file may be distributed separately from the Linux kernel, or
   42.12 + * incorporated into other software packages, subject to the following license:
   42.13 + * 
   42.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   42.15 + * of this source file (the "Software"), to deal in the Software without
   42.16 + * restriction, including without limitation the rights to use, copy, modify,
   42.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   42.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   42.19 + * the following conditions:
   42.20 + * 
   42.21 + * The above copyright notice and this permission notice shall be included in
   42.22 + * all copies or substantial portions of the Software.
   42.23 + * 
   42.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   42.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   42.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   42.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   42.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   42.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   42.30 + * IN THE SOFTWARE.
   42.31 + */
   42.32 +#include <types.h>
   42.33 +#include <wait.h>
   42.34 +#include <mm.h>
   42.35 +#include <hypervisor.h>
   42.36 +#include <events.h>
   42.37 +#include <os.h>
   42.38 +#include <lib.h>
   42.39 +
   42.40 +
   42.41 +#ifdef XENBUS_COMMS_DEBUG
   42.42 +#define DEBUG(_f, _a...) \
   42.43 +    printk("MINI_OS(file=xenbus_comms.c, line=%d) " _f "\n", __LINE__, ## _a)
   42.44 +#else
   42.45 +#define DEBUG(_f, _a...)    ((void)0)
   42.46 +#endif
   42.47 +
   42.48 +
   42.49 +#define RINGBUF_DATASIZE ((PAGE_SIZE / 2) - sizeof(struct ringbuf_head))
   42.50 +struct ringbuf_head
   42.51 +{
   42.52 +	u32 write; /* Next place to write to */
   42.53 +	u32 read; /* Next place to read from */
   42.54 +	u8 flags;
   42.55 +	char buf[0];
   42.56 +} __attribute__((packed));
   42.57 +
   42.58 +DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
   42.59 +
   42.60 +static inline struct ringbuf_head *outbuf(void)
   42.61 +{
   42.62 +	return mfn_to_virt(start_info.store_mfn);
   42.63 +}
   42.64 +
   42.65 +static inline struct ringbuf_head *inbuf(void)
   42.66 +{
   42.67 +	return (struct ringbuf_head *)((char *)mfn_to_virt(start_info.store_mfn) + PAGE_SIZE/2);
   42.68 +}
   42.69 +
   42.70 +static void wake_waiting(int port, struct pt_regs *regs)
   42.71 +{
   42.72 +	wake_up(&xb_waitq);
   42.73 +}
   42.74 +
   42.75 +static int check_buffer(const struct ringbuf_head *h)
   42.76 +{
   42.77 +	return (h->write < RINGBUF_DATASIZE && h->read < RINGBUF_DATASIZE);
   42.78 +}
   42.79 +
   42.80 +/* We can't fill last byte: would look like empty buffer. */
   42.81 +static void *get_output_chunk(const struct ringbuf_head *h,
   42.82 +			      void *buf, u32 *len)
   42.83 +{
   42.84 +	u32 read_mark;
   42.85 +
   42.86 +	if (h->read == 0)
   42.87 +		read_mark = RINGBUF_DATASIZE - 1;
   42.88 +	else
   42.89 +		read_mark = h->read - 1;
   42.90 +
   42.91 +	/* Here to the end of buffer, unless they haven't read some out. */
   42.92 +	*len = RINGBUF_DATASIZE - h->write;
   42.93 +	if (read_mark >= h->write)
   42.94 +		*len = read_mark - h->write;
   42.95 +	return (void *)((char *)buf + h->write);
   42.96 +}
   42.97 +
   42.98 +static const void *get_input_chunk(const struct ringbuf_head *h,
   42.99 +				   const void *buf, u32 *len)
  42.100 +{
  42.101 +	/* Here to the end of buffer, unless they haven't written some. */
  42.102 +	*len = RINGBUF_DATASIZE - h->read;
  42.103 +	if (h->write >= h->read)
  42.104 +		*len = h->write - h->read;
  42.105 +	return (void *)((char *)buf + h->read);
  42.106 +}
  42.107 +
  42.108 +static void update_output_chunk(struct ringbuf_head *h, u32 len)
  42.109 +{
  42.110 +	h->write += len;
  42.111 +	if (h->write == RINGBUF_DATASIZE)
  42.112 +		h->write = 0;
  42.113 +}
  42.114 +
  42.115 +static void update_input_chunk(struct ringbuf_head *h, u32 len)
  42.116 +{
  42.117 +	h->read += len;
  42.118 +	if (h->read == RINGBUF_DATASIZE)
  42.119 +		h->read = 0;
  42.120 +}
  42.121 +
  42.122 +static int output_avail(struct ringbuf_head *out)
  42.123 +{
  42.124 +	unsigned int avail;
  42.125 +
  42.126 +	get_output_chunk(out, out->buf, &avail);
  42.127 +	return avail != 0;
  42.128 +}
  42.129 +
  42.130 +int xb_write(const void *data, unsigned len)
  42.131 +{
  42.132 +	struct ringbuf_head h;
  42.133 +	struct ringbuf_head *out = outbuf();
  42.134 +
  42.135 +	do {
  42.136 +		void *dst;
  42.137 +		unsigned int avail;
  42.138 +
  42.139 +		wait_event(xb_waitq, output_avail(out));
  42.140 +
  42.141 +		/* Read, then check: not that we don't trust store.
  42.142 +		 * Hell, some of my best friends are daemons.  But,
  42.143 +		 * in this post-911 world... */
  42.144 +		h = *out;
  42.145 +		mb();
  42.146 +		if (!check_buffer(&h)) {
  42.147 +			return -1; /* ETERRORIST! */
  42.148 +		}
  42.149 +
  42.150 +		dst = get_output_chunk(&h, out->buf, &avail);
  42.151 +		if (avail > len)
  42.152 +			avail = len;
  42.153 +		memcpy(dst, data, avail);
  42.154 +		data = (void *)((char *)data + avail);
  42.155 +		len -= avail;
  42.156 +		update_output_chunk(out, avail);
  42.157 +		notify_via_evtchn(start_info.store_evtchn);
  42.158 +	} while (len != 0);
  42.159 +
  42.160 +	return 0;
  42.161 +}
  42.162 +
  42.163 +int xs_input_avail(void)
  42.164 +{
  42.165 +	unsigned int avail;
  42.166 +	struct ringbuf_head *in = inbuf();
  42.167 +
  42.168 +	get_input_chunk(in, in->buf, &avail);
  42.169 +	return avail != 0;
  42.170 +}
  42.171 +
  42.172 +int xb_read(void *data, unsigned len)
  42.173 +{
  42.174 +	struct ringbuf_head h;
  42.175 +	struct ringbuf_head *in = inbuf();
  42.176 +	int was_full;
  42.177 +
  42.178 +	while (len != 0) {
  42.179 +		unsigned int avail;
  42.180 +		const char *src;
  42.181 +
  42.182 +		wait_event(xb_waitq, xs_input_avail());
  42.183 +		h = *in;
  42.184 +		mb();
  42.185 +		if (!check_buffer(&h)) {
  42.186 +			return -1;
  42.187 +		}
  42.188 +
  42.189 +		src = get_input_chunk(&h, in->buf, &avail);
  42.190 +		if (avail > len)
  42.191 +			avail = len;
  42.192 +		was_full = !output_avail(&h);
  42.193 +
  42.194 +		memcpy(data, src, avail);
  42.195 +		data = (void *)((char *)data + avail);
  42.196 +		len -= avail;
  42.197 +		update_input_chunk(in, avail);
  42.198 +		DEBUG("Finished read of %i bytes (%i to go)\n", avail, len);
  42.199 +		/* If it was full, tell them we've taken some. */
  42.200 +		if (was_full)
  42.201 +			notify_via_evtchn(start_info.store_evtchn);
  42.202 +	}
  42.203 +
  42.204 +	/* If we left something, wake watch thread to deal with it. */
  42.205 +	if (xs_input_avail())
  42.206 +		wake_up(&xb_waitq);
  42.207 +
  42.208 +	return 0;
  42.209 +}
  42.210 +
  42.211 +/* Set up interrupt handler off store event channel. */
  42.212 +int xb_init_comms(void)
  42.213 +{
  42.214 +    printk("Init xenbus comms, store event channel %d\n", start_info.store_evtchn);
  42.215 +	if (!start_info.store_evtchn)
  42.216 +		return 0;
  42.217 +    printk("Binding virq\n");
  42.218 +	bind_evtchn(start_info.store_evtchn, &wake_waiting);
  42.219 +
  42.220 +	/* FIXME zero out page -- domain builder should probably do this*/
  42.221 +	memset(mfn_to_virt(start_info.store_mfn), 0, PAGE_SIZE);
  42.222 +    notify_via_evtchn(start_info.store_evtchn);
  42.223 +	return 0;
  42.224 +}
  42.225 +
  42.226 +void xb_suspend_comms(void)
  42.227 +{
  42.228 +
  42.229 +	if (!start_info.store_evtchn)
  42.230 +		return;
  42.231 +
  42.232 +    // TODO
  42.233 +	//unbind_evtchn_from_irqhandler(xen_start_info.store_evtchn, &xb_waitq);
  42.234 +}
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/extras/mini-os/xenbus/xenbus_comms.h	Fri Sep 09 10:30:54 2005 -0600
    43.3 @@ -0,0 +1,40 @@
    43.4 +/*
    43.5 + * Private include for xenbus communications.
    43.6 + * 
    43.7 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
    43.8 + *
    43.9 + * This file may be distributed separately from the Linux kernel, or
   43.10 + * incorporated into other software packages, subject to the following license:
   43.11 + * 
   43.12 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   43.13 + * of this source file (the "Software"), to deal in the Software without
   43.14 + * restriction, including without limitation the rights to use, copy, modify,
   43.15 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   43.16 + * and to permit persons to whom the Software is furnished to do so, subject to
   43.17 + * the following conditions:
   43.18 + * 
   43.19 + * The above copyright notice and this permission notice shall be included in
   43.20 + * all copies or substantial portions of the Software.
   43.21 + * 
   43.22 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   43.23 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   43.24 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   43.25 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   43.26 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   43.27 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   43.28 + * IN THE SOFTWARE.
   43.29 + */
   43.30 +
   43.31 +#ifndef _XENBUS_COMMS_H
   43.32 +#define _XENBUS_COMMS_H
   43.33 +
   43.34 +int xb_init_comms(void);
   43.35 +void xb_suspend_comms(void);
   43.36 +
   43.37 +/* Low level routines. */
   43.38 +int xb_write(const void *data, unsigned len);
   43.39 +int xb_read(void *data, unsigned len);
   43.40 +int xs_input_avail(void);
   43.41 +extern struct wait_queue_head xb_waitq;
   43.42 +
   43.43 +#endif /* _XENBUS_COMMS_H */
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/extras/mini-os/xenbus/xenbus_xs.c	Fri Sep 09 10:30:54 2005 -0600
    44.3 @@ -0,0 +1,554 @@
    44.4 +/******************************************************************************
    44.5 + * xenbus_xs.c
    44.6 + *
    44.7 + * This is the kernel equivalent of the "xs" library.  We don't need everything
    44.8 + * and we use xenbus_comms for communication.
    44.9 + *
   44.10 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
   44.11 + * 
   44.12 + * This file may be distributed separately from the Linux kernel, or
   44.13 + * incorporated into other software packages, subject to the following license:
   44.14 + * 
   44.15 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   44.16 + * of this source file (the "Software"), to deal in the Software without
   44.17 + * restriction, including without limitation the rights to use, copy, modify,
   44.18 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   44.19 + * and to permit persons to whom the Software is furnished to do so, subject to
   44.20 + * the following conditions:
   44.21 + * 
   44.22 + * The above copyright notice and this permission notice shall be included in
   44.23 + * all copies or substantial portions of the Software.
   44.24 + * 
   44.25 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   44.26 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   44.27 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   44.28 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   44.29 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   44.30 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   44.31 + * IN THE SOFTWARE.
   44.32 + */
   44.33 +#include <errno.h>
   44.34 +#include <types.h>
   44.35 +#include <list.h>
   44.36 +#include <lib.h>
   44.37 +#include <err.h>
   44.38 +#include <os.h>
   44.39 +#include <xmalloc.h>
   44.40 +#include <fcntl.h>
   44.41 +#include <xenbus.h>
   44.42 +#include <wait.h>
   44.43 +#include <sched.h>
   44.44 +#include <semaphore.h>
   44.45 +#include "xenstored.h"
   44.46 +#include "xenbus_comms.h"
   44.47 +
   44.48 +#define streq(a, b) (strcmp((a), (b)) == 0)
   44.49 +
   44.50 +static char printf_buffer[4096];
   44.51 +static LIST_HEAD(watches);
   44.52 +//TODO
   44.53 +DECLARE_MUTEX(xenbus_lock);
   44.54 +
   44.55 +static int get_error(const char *errorstring)
   44.56 +{
   44.57 +	unsigned int i;
   44.58 +
   44.59 +	for (i = 0; !streq(errorstring, xsd_errors[i].errstring); i++) {
   44.60 +		if (i == ARRAY_SIZE(xsd_errors) - 1) {
   44.61 +			printk("XENBUS xen store gave: unknown error %s",
   44.62 +			       errorstring);
   44.63 +			return EINVAL;
   44.64 +		}
   44.65 +	}
   44.66 +	return xsd_errors[i].errnum;
   44.67 +}
   44.68 +
   44.69 +static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len)
   44.70 +{
   44.71 +	struct xsd_sockmsg msg;
   44.72 +	void *ret;
   44.73 +	int err;
   44.74 +
   44.75 +	err = xb_read(&msg, sizeof(msg));
   44.76 +	if (err)
   44.77 +		return ERR_PTR(err);
   44.78 +
   44.79 +	ret = xmalloc_array(char, msg.len + 1);
   44.80 +	if (!ret)
   44.81 +		return ERR_PTR(-ENOMEM);
   44.82 +
   44.83 +	err = xb_read(ret, msg.len);
   44.84 +	if (err) {
   44.85 +		xfree(ret);
   44.86 +		return ERR_PTR(err);
   44.87 +	}
   44.88 +	((char*)ret)[msg.len] = '\0';
   44.89 +
   44.90 +	*type = msg.type;
   44.91 +	if (len)
   44.92 +		*len = msg.len;
   44.93 +	return ret;
   44.94 +}
   44.95 +
   44.96 +/* Emergency write. */
   44.97 +void xenbus_debug_write(const char *str, unsigned int count)
   44.98 +{
   44.99 +	struct xsd_sockmsg msg;
  44.100 +
  44.101 +	msg.type = XS_DEBUG;
  44.102 +	msg.len = sizeof("print") + count + 1;
  44.103 +
  44.104 +	xb_write(&msg, sizeof(msg));
  44.105 +	xb_write("print", sizeof("print"));
  44.106 +	xb_write(str, count);
  44.107 +	xb_write("", 1);
  44.108 +}
  44.109 +
  44.110 +/* Send message to xs, get kmalloc'ed reply.  ERR_PTR() on error. */
  44.111 +static void *xs_talkv(enum xsd_sockmsg_type type,
  44.112 +		      const struct kvec *iovec,
  44.113 +		      unsigned int num_vecs,
  44.114 +		      unsigned int *len)
  44.115 +{
  44.116 +	struct xsd_sockmsg msg;
  44.117 +	void *ret = NULL;
  44.118 +	unsigned int i;
  44.119 +	int err;
  44.120 +
  44.121 +	//WARN_ON(down_trylock(&xenbus_lock) == 0);
  44.122 +
  44.123 +	msg.type = type;
  44.124 +	msg.len = 0;
  44.125 +	for (i = 0; i < num_vecs; i++)
  44.126 +		msg.len += iovec[i].iov_len;
  44.127 +
  44.128 +	err = xb_write(&msg, sizeof(msg));
  44.129 +	if (err)
  44.130 +		return ERR_PTR(err);
  44.131 +
  44.132 +	for (i = 0; i < num_vecs; i++) {
  44.133 +		err = xb_write(iovec[i].iov_base, iovec[i].iov_len);;
  44.134 +		if (err)
  44.135 +			return ERR_PTR(err);
  44.136 +	}
  44.137 +
  44.138 +	/* Watches can have fired before reply comes: daemon detects
  44.139 +	 * and re-transmits, so we can ignore this. */
  44.140 +	do {
  44.141 +		xfree(ret);
  44.142 +		ret = read_reply(&msg.type, len);
  44.143 +		if (IS_ERR(ret))
  44.144 +			return ret;
  44.145 +	} while (msg.type == XS_WATCH_EVENT);
  44.146 +
  44.147 +	if (msg.type == XS_ERROR) {
  44.148 +		err = get_error(ret);
  44.149 +		xfree(ret);
  44.150 +		return ERR_PTR(-err);
  44.151 +	}
  44.152 +
  44.153 +	//BUG_ON(msg.type != type);
  44.154 +	return ret;
  44.155 +}
  44.156 +
  44.157 +/* Simplified version of xs_talkv: single message. */
  44.158 +static void *xs_single(enum xsd_sockmsg_type type,
  44.159 +		       const char *string, unsigned int *len)
  44.160 +{
  44.161 +	struct kvec iovec;
  44.162 +
  44.163 +	iovec.iov_base = (void *)string;
  44.164 +	iovec.iov_len = strlen(string) + 1;
  44.165 +	return xs_talkv(type, &iovec, 1, len);
  44.166 +}
  44.167 +
  44.168 +/* Many commands only need an ack, don't care what it says. */
  44.169 +static int xs_error(char *reply)
  44.170 +{
  44.171 +	if (IS_ERR(reply))
  44.172 +		return PTR_ERR(reply);
  44.173 +	xfree(reply);
  44.174 +	return 0;
  44.175 +}
  44.176 +
  44.177 +static unsigned int count_strings(const char *strings, unsigned int len)
  44.178 +{
  44.179 +	unsigned int num;
  44.180 +	const char *p;
  44.181 +
  44.182 +	for (p = strings, num = 0; p < strings + len; p += strlen(p) + 1)
  44.183 +		num++;
  44.184 +
  44.185 +	return num;
  44.186 +}
  44.187 +
  44.188 +/* Return the path to dir with /name appended. */ 
  44.189 +static char *join(const char *dir, const char *name)
  44.190 +{
  44.191 +	static char buffer[4096];
  44.192 +
  44.193 +	//BUG_ON(down_trylock(&xenbus_lock) == 0);
  44.194 +	/* XXX FIXME: might not be correct if name == "" */
  44.195 +	//BUG_ON(strlen(dir) + strlen("/") + strlen(name) + 1 > sizeof(buffer));
  44.196 +
  44.197 +	strcpy(buffer, dir);
  44.198 +	if (!streq(name, "")) {
  44.199 +		strcat(buffer, "/");
  44.200 +		strcat(buffer, name);
  44.201 +	}
  44.202 +	return buffer;
  44.203 +}
  44.204 +
  44.205 +char **xenbus_directory(const char *dir, const char *node, unsigned int *num)
  44.206 +{
  44.207 +	char *strings, *p, **ret;
  44.208 +	unsigned int len;
  44.209 +
  44.210 +	strings = xs_single(XS_DIRECTORY, join(dir, node), &len);
  44.211 +	if (IS_ERR(strings))
  44.212 +		return (char **)strings;
  44.213 +
  44.214 +	/* Count the strings. */
  44.215 +	*num = count_strings(strings, len);
  44.216 +
  44.217 +	/* Transfer to one big alloc for easy freeing. */
  44.218 +	ret = (char **)xmalloc_array(char, *num * sizeof(char *) + len);
  44.219 +	if (!ret) {
  44.220 +		xfree(strings);
  44.221 +		return ERR_PTR(-ENOMEM);
  44.222 +	}
  44.223 +	memcpy(&ret[*num], strings, len);
  44.224 +	xfree(strings);
  44.225 +
  44.226 +	strings = (char *)&ret[*num];
  44.227 +	for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1)
  44.228 +		ret[(*num)++] = p;
  44.229 +	return ret;
  44.230 +}
  44.231 +
  44.232 +/* Check if a path exists. Return 1 if it does. */
  44.233 +int xenbus_exists(const char *dir, const char *node)
  44.234 +{
  44.235 +	char **d;
  44.236 +	int dir_n;
  44.237 +
  44.238 +	d = xenbus_directory(dir, node, &dir_n);
  44.239 +	if (IS_ERR(d))
  44.240 +		return 0;
  44.241 +	xfree(d);
  44.242 +	return 1;
  44.243 +}
  44.244 +
  44.245 +/* Get the value of a single file.
  44.246 + * Returns a kmalloced value: call free() on it after use.
  44.247 + * len indicates length in bytes.
  44.248 + */
  44.249 +void *xenbus_read(const char *dir, const char *node, unsigned int *len)
  44.250 +{
  44.251 +	return xs_single(XS_READ, join(dir, node), len);
  44.252 +}
  44.253 +
  44.254 +/* Write the value of a single file.
  44.255 + * Returns -err on failure.  createflags can be 0, O_CREAT, or O_CREAT|O_EXCL.
  44.256 + */
  44.257 +int xenbus_write(const char *dir, const char *node,
  44.258 +		 const char *string, int createflags)
  44.259 +{
  44.260 +	const char *flags, *path;
  44.261 +	struct kvec iovec[3];
  44.262 +
  44.263 +	path = join(dir, node);
  44.264 +	/* Format: Flags (as string), path, data. */
  44.265 +	if (createflags == 0)
  44.266 +		flags = XS_WRITE_NONE;
  44.267 +	else if (createflags == O_CREAT)
  44.268 +		flags = XS_WRITE_CREATE;
  44.269 +	else if (createflags == (O_CREAT|O_EXCL))
  44.270 +		flags = XS_WRITE_CREATE_EXCL;
  44.271 +	else
  44.272 +		return -EINVAL;
  44.273 +
  44.274 +	iovec[0].iov_base = (void *)path;
  44.275 +	iovec[0].iov_len = strlen(path) + 1;
  44.276 +	iovec[1].iov_base = (void *)flags;
  44.277 +	iovec[1].iov_len = strlen(flags) + 1;
  44.278 +	iovec[2].iov_base = (void *)string;
  44.279 +	iovec[2].iov_len = strlen(string);
  44.280 +
  44.281 +	return xs_error(xs_talkv(XS_WRITE, iovec, ARRAY_SIZE(iovec), NULL));
  44.282 +}
  44.283 +
  44.284 +/* Create a new directory. */
  44.285 +int xenbus_mkdir(const char *dir, const char *node)
  44.286 +{
  44.287 +	return xs_error(xs_single(XS_MKDIR, join(dir, node), NULL));
  44.288 +}
  44.289 +
  44.290 +/* Destroy a file or directory (directories must be empty). */
  44.291 +int xenbus_rm(const char *dir, const char *node)
  44.292 +{
  44.293 +	return xs_error(xs_single(XS_RM, join(dir, node), NULL));
  44.294 +}
  44.295 +
  44.296 +/* Start a transaction: changes by others will not be seen during this
  44.297 + * transaction, and changes will not be visible to others until end.
  44.298 + * Transaction only applies to the given subtree.
  44.299 + * You can only have one transaction at any time.
  44.300 + */
  44.301 +int xenbus_transaction_start(const char *subtree)
  44.302 +{
  44.303 +	return xs_error(xs_single(XS_TRANSACTION_START, subtree, NULL));
  44.304 +}
  44.305 +
  44.306 +/* End a transaction.
  44.307 + * If abandon is true, transaction is discarded instead of committed.
  44.308 + */
  44.309 +int xenbus_transaction_end(int abort)
  44.310 +{
  44.311 +	char abortstr[2];
  44.312 +
  44.313 +	if (abort)
  44.314 +		strcpy(abortstr, "F");
  44.315 +	else
  44.316 +		strcpy(abortstr, "T");
  44.317 +	return xs_error(xs_single(XS_TRANSACTION_END, abortstr, NULL));
  44.318 +}
  44.319 +
  44.320 +/* Single read and scanf: returns -errno or num scanned. */
  44.321 +int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
  44.322 +{
  44.323 +	va_list ap;
  44.324 +	int ret;
  44.325 +	char *val;
  44.326 +
  44.327 +	val = xenbus_read(dir, node, NULL);
  44.328 +	if (IS_ERR(val))
  44.329 +		return PTR_ERR(val);
  44.330 +
  44.331 +	va_start(ap, fmt);
  44.332 +	ret = vsscanf(val, fmt, ap);
  44.333 +	va_end(ap);
  44.334 +	xfree(val);
  44.335 +	/* Distinctive errno. */
  44.336 +	if (ret == 0)
  44.337 +		return -ERANGE;
  44.338 +	return ret;
  44.339 +}
  44.340 +
  44.341 +/* Single printf and write: returns -errno or 0. */
  44.342 +int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
  44.343 +{
  44.344 +	va_list ap;
  44.345 +	int ret;
  44.346 +
  44.347 +	//BUG_ON(down_trylock(&xenbus_lock) == 0);
  44.348 +	va_start(ap, fmt);
  44.349 +	ret = vsnprintf(printf_buffer, sizeof(printf_buffer), fmt, ap);
  44.350 +	va_end(ap);
  44.351 +
  44.352 +	//BUG_ON(ret > sizeof(printf_buffer)-1);
  44.353 +	return xenbus_write(dir, node, printf_buffer, O_CREAT);
  44.354 +}
  44.355 +
  44.356 +	
  44.357 +/* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
  44.358 +int xenbus_gather(const char *dir, ...)
  44.359 +{
  44.360 +	va_list ap;
  44.361 +	const char *name;
  44.362 +	int ret = 0;
  44.363 +
  44.364 +	va_start(ap, dir);
  44.365 +	while (ret == 0 && (name = va_arg(ap, char *)) != NULL) {
  44.366 +		const char *fmt = va_arg(ap, char *);
  44.367 +		void *result = va_arg(ap, void *);
  44.368 +		char *p;
  44.369 +
  44.370 +		p = xenbus_read(dir, name, NULL);
  44.371 +		if (IS_ERR(p)) {
  44.372 +			ret = PTR_ERR(p);
  44.373 +			break;
  44.374 +		}
  44.375 +		if (fmt) {
  44.376 +			if (sscanf(p, fmt, result) == 0)
  44.377 +				ret = -EINVAL;
  44.378 +			xfree(p);
  44.379 +		} else
  44.380 +			*(char **)result = p;
  44.381 +	}
  44.382 +	va_end(ap);
  44.383 +	return ret;
  44.384 +}
  44.385 +
  44.386 +static int xs_watch(const char *path, const char *token)
  44.387 +{
  44.388 +	struct kvec iov[2];
  44.389 +
  44.390 +	iov[0].iov_base = (void *)path;
  44.391 +	iov[0].iov_len = strlen(path) + 1;
  44.392 +	iov[1].iov_base = (void *)token;
  44.393 +	iov[1].iov_len = strlen(token) + 1;
  44.394 +
  44.395 +	return xs_error(xs_talkv(XS_WATCH, iov, ARRAY_SIZE(iov), NULL));
  44.396 +}
  44.397 +
  44.398 +static char *xs_read_watch(char **token)
  44.399 +{
  44.400 +	enum xsd_sockmsg_type type;
  44.401 +	char *ret;
  44.402 +
  44.403 +	ret = read_reply(&type, NULL);
  44.404 +	if (IS_ERR(ret))
  44.405 +		return ret;
  44.406 +
  44.407 +	//BUG_ON(type != XS_WATCH_EVENT);
  44.408 +	*token = ret + strlen(ret) + 1;
  44.409 +	return ret;
  44.410 +}
  44.411 +
  44.412 +static int xs_acknowledge_watch(const char *token)
  44.413 +{
  44.414 +	return xs_error(xs_single(XS_WATCH_ACK, token, NULL));
  44.415 +}
  44.416 +
  44.417 +static int xs_unwatch(const char *path, const char *token)
  44.418 +{
  44.419 +	struct kvec iov[2];
  44.420 +
  44.421 +	iov[0].iov_base = (char *)path;
  44.422 +	iov[0].iov_len = strlen(path) + 1;
  44.423 +	iov[1].iov_base = (char *)token;
  44.424 +	iov[1].iov_len = strlen(token) + 1;
  44.425 +
  44.426 +	return xs_error(xs_talkv(XS_UNWATCH, iov, ARRAY_SIZE(iov), NULL));
  44.427 +}
  44.428 +
  44.429 +/* A little paranoia: we don't just trust token. */
  44.430 +static struct xenbus_watch *find_watch(const char *token)
  44.431 +{
  44.432 +	struct xenbus_watch *i, *cmp;
  44.433 +
  44.434 +	cmp = (void *)simple_strtoul(token, NULL, 16);
  44.435 +
  44.436 +	list_for_each_entry(i, &watches, list)
  44.437 +		if (i == cmp)
  44.438 +			return i;
  44.439 +	return NULL;
  44.440 +}
  44.441 +
  44.442 +/* Register callback to watch this node. */
  44.443 +int register_xenbus_watch(struct xenbus_watch *watch)
  44.444 +{
  44.445 +	/* Pointer in ascii is the token. */
  44.446 +	char token[sizeof(watch) * 2 + 1];
  44.447 +	int err;
  44.448 +
  44.449 +	sprintf(token, "%lX", (long)watch);
  44.450 +	//BUG_ON(find_watch(token));
  44.451 +printk("Registered watch for: %s\n", token);
  44.452 +	err = xs_watch(watch->node, token);
  44.453 +	if (!err)
  44.454 +		list_add(&watch->list, &watches);
  44.455 +	return err;
  44.456 +}
  44.457 +
  44.458 +void unregister_xenbus_watch(struct xenbus_watch *watch)
  44.459 +{
  44.460 +	char token[sizeof(watch) * 2 + 1];
  44.461 +	int err;
  44.462 +
  44.463 +	sprintf(token, "%lX", (long)watch);
  44.464 +	//BUG_ON(!find_watch(token));
  44.465 +
  44.466 +	err = xs_unwatch(watch->node, token);
  44.467 +	list_del(&watch->list);
  44.468 +
  44.469 +	if (err)
  44.470 +		printk("XENBUS Failed to release watch %s: %i\n",
  44.471 +		       watch->node, err);
  44.472 +}
  44.473 +
  44.474 +/* Re-register callbacks to all watches. */
  44.475 +void reregister_xenbus_watches(void)
  44.476 +{
  44.477 +	struct xenbus_watch *watch;
  44.478 +	char token[sizeof(watch) * 2 + 1];
  44.479 +
  44.480 +	list_for_each_entry(watch, &watches, list) {
  44.481 +		sprintf(token, "%lX", (long)watch);
  44.482 +		xs_watch(watch->node, token);
  44.483 +	}
  44.484 +}
  44.485 +
  44.486 +void watch_thread(void *unused)
  44.487 +{
  44.488 +	for (;;) {
  44.489 +		char *token;
  44.490 +		char *node = NULL;
  44.491 +
  44.492 +		wait_event(xb_waitq, xs_input_avail());
  44.493 +
  44.494 +		/* If this is a spurious wakeup caused by someone
  44.495 +		 * doing an op, they'll hold the lock and the buffer
  44.496 +		 * will be empty by the time we get there.		 
  44.497 +		 */
  44.498 +		down(&xenbus_lock);
  44.499 +		if (xs_input_avail())
  44.500 +			node = xs_read_watch(&token);
  44.501 +
  44.502 +		if (node && !IS_ERR(node)) {
  44.503 +			struct xenbus_watch *w;
  44.504 +			int err;
  44.505 +
  44.506 +			err = xs_acknowledge_watch(token);
  44.507 +			if (err)
  44.508 +				printk("XENBUS ack %s fail %i\n", node, err);
  44.509 +			w = find_watch(token);
  44.510 +			//BUG_ON(!w);
  44.511 +			w->callback(w, node);
  44.512 +			xfree(node);
  44.513 +		} else
  44.514 +			printk("XENBUS xs_read_watch: %li\n", PTR_ERR(node));
  44.515 +		up(&xenbus_lock);
  44.516 +	}
  44.517 +}
  44.518 +
  44.519 +
  44.520 +static void ballon_changed(struct xenbus_watch *watch, const char *node)
  44.521 +{
  44.522 +    unsigned long new_target;
  44.523 +    int err;
  44.524 +    err = xenbus_scanf("memory", "target", "%lu", &new_target);
  44.525 +
  44.526 +    if(err != 1)
  44.527 +    {
  44.528 +        printk("Unable to read memory/target\n");
  44.529 +        return;
  44.530 +    }
  44.531 +
  44.532 +    printk("Memory target changed to: %ld bytes, ignoring.\n", new_target);
  44.533 +}
  44.534 +
  44.535 +
  44.536 +static struct xenbus_watch ballon_watch = {
  44.537 +    .node = "memory/target",
  44.538 +    .callback = ballon_changed,
  44.539 +};
  44.540 +
  44.541 +
  44.542 +
  44.543 +int xs_init(void)
  44.544 +{
  44.545 +	int err;
  44.546 +	struct thread *watcher;
  44.547 +    printk("xb_init_comms\n");
  44.548 +	err = xb_init_comms();
  44.549 +	if (err)
  44.550 +		return err;
  44.551 +	
  44.552 +	watcher = create_thread("kxwatch", watch_thread, NULL);
  44.553 +    down(&xenbus_lock);
  44.554 +    register_xenbus_watch(&ballon_watch);
  44.555 +    up(&xenbus_lock);
  44.556 +	return 0;
  44.557 +}
   118.1 --- a/linux-2.4-xen-sparse/mkbuildtree	Thu Sep 08 09:18:40 2005 -0600
   118.2 +++ b/linux-2.4-xen-sparse/mkbuildtree	Fri Sep 09 10:30:54 2005 -0600
   118.3 @@ -102,9 +102,9 @@ for i in `find . -type l`; do rm -f $i; 
   118.4  relative_lndir ${RS}
   118.5  rm -f mkbuildtree
   118.6  
   118.7 -set ${RS}/../linux-2.6-xen-sparse
   118.8 -[ "$1" == "${RS}/../linux-2.6-xen-sparse" ] && { echo "no Linux 2.6 sparse tree at ${RS}/../linux-2.6-xen-sparse"; exit 1; }
   118.9 -LINUX_26="$1"
  118.10 +LINUX_26=${RS}/../linux-2.6-xen-sparse
  118.11 +[ -d $LINUX_26 ] || { echo "no Linux 2.6 sparse tree at ${RS}/../linux-2.6-xen-sparse"; exit 1; }
  118.12 +
  118.13  
  118.14  # Create links to the shared definitions of the Xen interfaces.
  118.15  rm -rf ${AD}/include/asm-xen/xen-public
   125.1 --- a/linux-2.6-xen-sparse/arch/xen/Kconfig	Thu Sep 08 09:18:40 2005 -0600
   125.2 +++ b/linux-2.6-xen-sparse/arch/xen/Kconfig	Fri Sep 09 10:30:54 2005 -0600
   125.3 @@ -70,6 +70,27 @@ config XEN_NETDEV_BACKEND
   125.4  	  network devices to other guests via a high-performance shared-memory
   125.5  	  interface.
   125.6  
   125.7 +config XEN_TPMDEV_FRONTEND
   125.8 +        bool "TPM-device frontend driver"
   125.9 +        default n
  125.10 +        help
  125.11 +          The TPM-device frontend driver.
  125.12 +
  125.13 +config XEN_TPMDEV_BACKEND
  125.14 +        bool "TPM-device backend driver"
  125.15 +        default n
  125.16 +        help
  125.17 +          The TPM-device backend driver
  125.18 +
  125.19 +config XEN_TPMDEV_CLOSE_IF_VTPM_FAILS
  125.20 +        bool "TPM backend closes upon vTPM failure"
  125.21 +        depends on XEN_TPMDEV_BACKEND
  125.22 +        default n
  125.23 +        help
  125.24 +          The TPM backend closes the channel if the vTPM in userspace indicates
  125.25 +          a failure. The corresponding domain's channel will be closed.
  125.26 +          Say Y if you want this feature.
  125.27 +
  125.28  config XEN_BLKDEV_FRONTEND
  125.29  	bool "Block-device frontend driver"
  125.30  	default y
  125.31 @@ -88,15 +109,8 @@ config XEN_NETDEV_FRONTEND
  125.32  	  dedicated device-driver domain, or your master control domain
  125.33  	  (domain 0), then you almost certainly want to say Y here.
  125.34  
  125.35 -config XEN_NETDEV_GRANT_TX
  125.36 -        bool "Grant table substrate for net drivers tx path (DANGEROUS)"
  125.37 -        default n
  125.38 -        help
  125.39 -          This introduces the use of grant tables as a data exhange mechanism
  125.40 -          between the frontend and backend network drivers.
  125.41 -
  125.42 -config XEN_NETDEV_GRANT_RX
  125.43 -        bool "Grant table substrate for net drivers rx path (DANGEROUS)"
  125.44 +config XEN_NETDEV_GRANT
  125.45 +        bool "Grant table substrate for network drivers (DANGEROUS)"
  125.46          default n
  125.47          help
  125.48            This introduces the use of grant tables as a data exhange mechanism
   126.1 --- a/linux-2.6-xen-sparse/arch/xen/Kconfig.drivers	Thu Sep 08 09:18:40 2005 -0600
   126.2 +++ b/linux-2.6-xen-sparse/arch/xen/Kconfig.drivers	Fri Sep 09 10:30:54 2005 -0600
   126.3 @@ -49,6 +49,10 @@ source "drivers/infiniband/Kconfig"
   126.4  endif
   126.5  
   126.6  if !XEN_PHYSDEV_ACCESS
   126.7 +source "drivers/char/tpm/Kconfig.domU"
   126.8 +endif
   126.9 +
  126.10 +if !XEN_PHYSDEV_ACCESS
  126.11  
  126.12  menu "Character devices"
  126.13  
   127.1 --- a/linux-2.6-xen-sparse/arch/xen/Makefile	Thu Sep 08 09:18:40 2005 -0600
   127.2 +++ b/linux-2.6-xen-sparse/arch/xen/Makefile	Fri Sep 09 10:30:54 2005 -0600
   127.3 @@ -65,6 +65,7 @@ vmlinuz: vmlinux
   127.4  
   127.5  XINSTALL_NAME ?= $(KERNELRELEASE)
   127.6  install: vmlinuz
   127.7 +install kernel_install:
   127.8  	mkdir -p $(INSTALL_PATH)/boot
   127.9  	ln -f -s vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX) $(INSTALL_PATH)/boot/vmlinuz-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(XENGUEST)$(INSTALL_SUFFIX)
  127.10  	rm -f $(INSTALL_PATH)/boot/vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
   129.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Thu Sep 08 09:18:40 2005 -0600
   129.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Fri Sep 09 10:30:54 2005 -0600
   129.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
   129.4  CONFIG_XEN_BLKDEV_BACKEND=y
   129.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
   129.6  CONFIG_XEN_NETDEV_BACKEND=y
   129.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
   129.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
   129.9  CONFIG_XEN_BLKDEV_FRONTEND=y
  129.10  CONFIG_XEN_NETDEV_FRONTEND=y
  129.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
  129.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
  129.13 +CONFIG_XEN_NETDEV_GRANT=y
  129.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
  129.15  # CONFIG_XEN_BLKDEV_TAP is not set
  129.16  # CONFIG_XEN_SHADOW_MODE is not set
  129.17 @@ -1122,7 +1123,7 @@ CONFIG_RAMFS=y
  129.18  # CONFIG_BEFS_FS is not set
  129.19  # CONFIG_BFS_FS is not set
  129.20  # CONFIG_EFS_FS is not set
  129.21 -# CONFIG_CRAMFS is not set
  129.22 +CONFIG_CRAMFS=y
  129.23  # CONFIG_VXFS_FS is not set
  129.24  # CONFIG_HPFS_FS is not set
  129.25  # CONFIG_QNX4FS_FS is not set
   130.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Thu Sep 08 09:18:40 2005 -0600
   130.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Fri Sep 09 10:30:54 2005 -0600
   130.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
   130.4  CONFIG_XEN_BLKDEV_BACKEND=y
   130.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
   130.6  CONFIG_XEN_NETDEV_BACKEND=y
   130.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
   130.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
   130.9  CONFIG_XEN_BLKDEV_FRONTEND=y
  130.10  CONFIG_XEN_NETDEV_FRONTEND=y
  130.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
  130.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
  130.13 +CONFIG_XEN_NETDEV_GRANT=y
  130.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
  130.15  # CONFIG_XEN_BLKDEV_TAP is not set
  130.16  # CONFIG_XEN_SHADOW_MODE is not set
  130.17 @@ -195,6 +196,7 @@ CONFIG_BLK_DEV_LOOP=y
  130.18  # CONFIG_BLK_DEV_CRYPTOLOOP is not set
  130.19  # CONFIG_BLK_DEV_NBD is not set
  130.20  # CONFIG_BLK_DEV_SX8 is not set
  130.21 +# CONFIG_BLK_DEV_UB is not set
  130.22  CONFIG_BLK_DEV_RAM=y
  130.23  CONFIG_BLK_DEV_RAM_COUNT=16
  130.24  CONFIG_BLK_DEV_RAM_SIZE=16384
  130.25 @@ -1030,7 +1032,7 @@ CONFIG_RAMFS=y
  130.26  # CONFIG_BEFS_FS is not set
  130.27  # CONFIG_BFS_FS is not set
  130.28  # CONFIG_EFS_FS is not set
  130.29 -# CONFIG_CRAMFS is not set
  130.30 +CONFIG_CRAMFS=y
  130.31  # CONFIG_VXFS_FS is not set
  130.32  # CONFIG_HPFS_FS is not set
  130.33  # CONFIG_QNX4FS_FS is not set
   131.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Thu Sep 08 09:18:40 2005 -0600
   131.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Fri Sep 09 10:30:54 2005 -0600
   131.3 @@ -12,10 +12,11 @@ CONFIG_NO_IDLE_HZ=y
   131.4  #
   131.5  # CONFIG_XEN_PRIVILEGED_GUEST is not set
   131.6  # CONFIG_XEN_PHYSDEV_ACCESS is not set
   131.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
   131.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
   131.9  CONFIG_XEN_BLKDEV_FRONTEND=y
  131.10  CONFIG_XEN_NETDEV_FRONTEND=y
  131.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
  131.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
  131.13 +CONFIG_XEN_NETDEV_GRANT=y
  131.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
  131.15  # CONFIG_XEN_BLKDEV_TAP is not set
  131.16  # CONFIG_XEN_SHADOW_MODE is not set
  131.17 @@ -336,6 +337,7 @@ CONFIG_NETDEVICES=y
  131.18  CONFIG_UNIX98_PTYS=y
  131.19  CONFIG_LEGACY_PTYS=y
  131.20  CONFIG_LEGACY_PTY_COUNT=256
  131.21 +# CONFIG_TCG_TPM is not set
  131.22  
  131.23  #
  131.24  # Character devices
   132.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Thu Sep 08 09:18:40 2005 -0600
   132.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Fri Sep 09 10:30:54 2005 -0600
   132.3 @@ -12,10 +12,11 @@ CONFIG_NO_IDLE_HZ=y
   132.4  #
   132.5  # CONFIG_XEN_PRIVILEGED_GUEST is not set
   132.6  # CONFIG_XEN_PHYSDEV_ACCESS is not set
   132.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
   132.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
   132.9  CONFIG_XEN_BLKDEV_FRONTEND=y
  132.10  CONFIG_XEN_NETDEV_FRONTEND=y
  132.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
  132.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
  132.13 +CONFIG_XEN_NETDEV_GRANT=y
  132.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
  132.15  # CONFIG_XEN_BLKDEV_TAP is not set
  132.16  # CONFIG_XEN_SHADOW_MODE is not set
  132.17 @@ -662,6 +663,7 @@ CONFIG_NETCONSOLE=m
  132.18  CONFIG_INPUT=m
  132.19  CONFIG_UNIX98_PTYS=y
  132.20  # CONFIG_LEGACY_PTYS is not set
  132.21 +# CONFIG_TCG_TPM is not set
  132.22  
  132.23  #
  132.24  # Character devices
   133.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Thu Sep 08 09:18:40 2005 -0600
   133.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Fri Sep 09 10:30:54 2005 -0600
   133.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
   133.4  CONFIG_XEN_BLKDEV_BACKEND=y
   133.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
   133.6  CONFIG_XEN_NETDEV_BACKEND=y
   133.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
   133.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
   133.9  CONFIG_XEN_BLKDEV_FRONTEND=y
  133.10  CONFIG_XEN_NETDEV_FRONTEND=y
  133.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
  133.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
  133.13 +CONFIG_XEN_NETDEV_GRANT=y
  133.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
  133.15  # CONFIG_XEN_BLKDEV_TAP is not set
  133.16  # CONFIG_XEN_SHADOW_MODE is not set
  133.17 @@ -1855,9 +1856,7 @@ CONFIG_HANGCHECK_TIMER=m
  133.18  #
  133.19  # TPM devices
  133.20  #
  133.21 -CONFIG_TCG_TPM=m
  133.22 -CONFIG_TCG_NSC=m
  133.23 -CONFIG_TCG_ATMEL=m
  133.24 +# CONFIG_TCG_TPM is not set
  133.25  
  133.26  #
  133.27  # I2C support
   134.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64	Thu Sep 08 09:18:40 2005 -0600
   134.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64	Fri Sep 09 10:30:54 2005 -0600
   134.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
   134.4  CONFIG_XEN_BLKDEV_BACKEND=y
   134.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
   134.6  CONFIG_XEN_NETDEV_BACKEND=y
   134.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
   134.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
   134.9  CONFIG_XEN_BLKDEV_FRONTEND=y
  134.10  CONFIG_XEN_NETDEV_FRONTEND=y
  134.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
  134.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
  134.13 +CONFIG_XEN_NETDEV_GRANT=y
  134.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
  134.15  # CONFIG_XEN_BLKDEV_TAP is not set
  134.16  # CONFIG_XEN_SHADOW_MODE is not set
  134.17 @@ -2201,7 +2202,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
  134.18  CONFIG_PROC_FS=y
  134.19  CONFIG_PROC_KCORE=y
  134.20  CONFIG_SYSFS=y
  134.21 -# CONFIG_DEVFS_FS is not set
  134.22 +CONFIG_DEVFS_FS=y
  134.23  CONFIG_DEVPTS_FS_XATTR=y
  134.24  CONFIG_DEVPTS_FS_SECURITY=y
  134.25  CONFIG_TMPFS=y
  134.26 @@ -2231,7 +2232,7 @@ CONFIG_JFFS2_FS_NAND=y
  134.27  CONFIG_JFFS2_ZLIB=y
  134.28  CONFIG_JFFS2_RTIME=y
  134.29  # CONFIG_JFFS2_RUBIN is not set
  134.30 -CONFIG_CRAMFS=m
  134.31 +CONFIG_CRAMFS=y
  134.32  CONFIG_VXFS_FS=m
  134.33  # CONFIG_HPFS_FS is not set
  134.34  CONFIG_QNX4FS_FS=m
   135.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/Kconfig	Thu Sep 08 09:18:40 2005 -0600
   135.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/Kconfig	Fri Sep 09 10:30:54 2005 -0600
   135.3 @@ -379,18 +379,18 @@ config SMP
   135.4  	  If you don't know what to do here, say N.
   135.5  
   135.6  config SMP_ALTERNATIVES
   135.7 -        bool "SMP alternatives support (EXPERIMENTAL)"
   135.8 -        depends on SMP && EXPERIMENTAL
   135.9 -        help
  135.10 -          Try to reduce the overhead of running an SMP kernel on a uniprocessor
  135.11 -          host slightly by replacing certain key instruction sequences
  135.12 -          according to whether we currently have more than one CPU available.
  135.13 -          This should provide a noticeable boost to performance when
  135.14 -          running SMP kernels on UP machines, and have negligible impact
  135.15 -          when running on an true SMP host.
  135.16 +	bool "SMP alternatives support (EXPERIMENTAL)"
  135.17 +	depends on SMP && EXPERIMENTAL
  135.18 +	help
  135.19 +	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
  135.20 +	  host slightly by replacing certain key instruction sequences
  135.21 +	  according to whether we currently have more than one CPU available.
  135.22 +	  This should provide a noticeable boost to performance when
  135.23 +	  running SMP kernels on UP machines, and have negligible impact
  135.24 +	  when running on an true SMP host.
  135.25  
  135.26            If unsure, say N.
  135.27 -
  135.28 +	  
  135.29  config NR_CPUS
  135.30  	int "Maximum number of CPUs (2-255)"
  135.31  	range 2 255
  135.32 @@ -807,8 +807,8 @@ choice
  135.33  	  direct access method and falls back to the BIOS if that doesn't
  135.34  	  work. If unsure, go with the default, which is "Any".
  135.35  
  135.36 -config PCI_GOBIOS
  135.37 -	bool "BIOS"
  135.38 +#config PCI_GOBIOS
  135.39 +#	bool "BIOS"
  135.40  
  135.41  config PCI_GOMMCONFIG
  135.42  	bool "MMConfig"
  135.43 @@ -821,10 +821,10 @@ config PCI_GOANY
  135.44  
  135.45  endchoice
  135.46  
  135.47 -config PCI_BIOS
  135.48 -	bool
  135.49 -	depends on !X86_VISWS && PCI && (PCI_GOBIOS || PCI_GOANY)
  135.50 -	default y
  135.51 +#config PCI_BIOS
  135.52 +#	bool
  135.53 +#	depends on !X86_VISWS && PCI && (PCI_GOBIOS || PCI_GOANY)
  135.54 +#	default y
  135.55  
  135.56  config PCI_DIRECT
  135.57  	bool
   137.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile	Thu Sep 08 09:18:40 2005 -0600
   137.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile	Fri Sep 09 10:30:54 2005 -0600
   137.3 @@ -5,6 +5,7 @@
   137.4  XENARCH	:= $(subst ",,$(CONFIG_XENARCH))
   137.5  
   137.6  CFLAGS	+= -Iarch/$(XENARCH)/kernel
   137.7 +AFLAGS	+= -Iarch/$(XENARCH)/kernel
   137.8  
   137.9  extra-y := head.o init_task.o
  137.10  
  137.11 @@ -32,7 +33,7 @@ obj-$(CONFIG_X86_MPPARSE)	+= mpparse.o
  137.12  obj-$(CONFIG_X86_LOCAL_APIC)	+= apic.o
  137.13  c-obj-$(CONFIG_X86_LOCAL_APIC)	+= nmi.o
  137.14  obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o
  137.15 -c-obj-$(CONFIG_X86_REBOOTFIXUPS)+= reboot_fixups.o
  137.16 +c-obj-$(CONFIG_X86_REBOOTFIXUPS)	+= reboot_fixups.o
  137.17  c-obj-$(CONFIG_X86_NUMAQ)	+= numaq.o
  137.18  c-obj-$(CONFIG_X86_SUMMIT_NUMA)	+= summit.o
  137.19  c-obj-$(CONFIG_MODULES)		+= module.o
  137.20 @@ -69,7 +70,7 @@ SYSCFLAGS_vsyscall-int80.so	= $(vsyscall
  137.21  
  137.22  $(obj)/vsyscall-int80.so $(obj)/vsyscall-sysenter.so: \
  137.23  $(obj)/vsyscall-%.so: $(src)/vsyscall.lds \
  137.24 -		      $(obj)/vsyscall-%.o FORCE
  137.25 +		      $(obj)/vsyscall-%.o $(obj)/vsyscall-note.o FORCE
  137.26  	$(call if_changed,syscall)
  137.27  
  137.28  # We also create a special relocatable object that should mirror the symbol
  137.29 @@ -81,20 +82,17 @@ extra-y += vsyscall-syms.o
  137.30  
  137.31  SYSCFLAGS_vsyscall-syms.o = -r
  137.32  $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
  137.33 -			$(obj)/vsyscall-sysenter.o FORCE
  137.34 +			$(obj)/vsyscall-sysenter.o $(obj)/vsyscall-note.o FORCE
  137.35  	$(call if_changed,syscall)
  137.36  
  137.37  c-link	:=
  137.38 -s-link	:= vsyscall-int80.o vsyscall-sysenter.o vsyscall-sigreturn.o vsyscall.lds.o syscall_table.o
  137.39 +s-link	:= vsyscall-int80.o vsyscall-sysenter.o vsyscall-sigreturn.o vsyscall.lds.o vsyscall-note.o
  137.40  
  137.41  $(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-obj-m) $(c-link)) $(patsubst %.o,$(obj)/%.S,$(s-obj-y) $(s-link)):
  137.42  	@ln -fsn $(srctree)/arch/i386/kernel/$(notdir $@) $@
  137.43  
  137.44  $(obj)/vsyscall-int80.S: $(obj)/vsyscall-sigreturn.S
  137.45  
  137.46 -EXTRA_AFLAGS	+= -I$(obj)
  137.47 -$(obj)/entry.o: $(src)/entry.S $(src)/syscall_table.S
  137.48 -
  137.49  obj-y	+= $(c-obj-y) $(s-obj-y)
  137.50  obj-m	+= $(c-obj-m)
  137.51  
   139.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c	Thu Sep 08 09:18:40 2005 -0600
   139.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c	Fri Sep 09 10:30:54 2005 -0600
   139.3 @@ -469,6 +469,18 @@ unsigned int acpi_register_gsi(u32 gsi, 
   139.4  	unsigned int irq;
   139.5  	unsigned int plat_gsi = gsi;
   139.6  
   139.7 +#ifdef CONFIG_PCI
   139.8 +	/*
   139.9 +	 * Make sure all (legacy) PCI IRQs are set as level-triggered.
  139.10 +	 */
  139.11 +	if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
  139.12 +		extern void eisa_set_level_irq(unsigned int irq);
  139.13 +
  139.14 +		if (edge_level == ACPI_LEVEL_SENSITIVE)
  139.15 +				eisa_set_level_irq(gsi);
  139.16 +	}
  139.17 +#endif
  139.18 +
  139.19  #ifdef CONFIG_X86_IO_APIC
  139.20  	if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
  139.21  		plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
  139.22 @@ -610,7 +622,7 @@ static int __init acpi_parse_fadt(unsign
  139.23  	acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
  139.24  #endif
  139.25  
  139.26 -#ifdef CONFIG_X86_PM_TIMER
  139.27 +#if defined(CONFIG_X86_PM_TIMER) && !defined(CONFIG_XEN)
  139.28  	/* detect the location of the ACPI PM Timer */
  139.29  	if (fadt->revision >= FADT2_REVISION_ID) {
  139.30  		/* FADT rev. 2 */
   144.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c	Thu Sep 08 09:18:40 2005 -0600
   144.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c	Fri Sep 09 10:30:54 2005 -0600
   144.3 @@ -147,7 +147,7 @@ static int __init mtrr_init(void)
   144.4  {
   144.5  	struct cpuinfo_x86 *c = &boot_cpu_data;
   144.6  
   144.7 -	if (!(xen_start_info.flags & SIF_PRIVILEGED))
   144.8 +	if (!(xen_start_info->flags & SIF_PRIVILEGED))
   144.9  		return -ENODEV;
  144.10  
  144.11  	if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
   145.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Thu Sep 08 09:18:40 2005 -0600
   145.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Fri Sep 09 10:30:54 2005 -0600
   145.3 @@ -47,6 +47,7 @@
   145.4  #include <asm/segment.h>
   145.5  #include <asm/smp.h>
   145.6  #include <asm/page.h>
   145.7 +#include <asm/desc.h>
   145.8  #include "irq_vectors.h"
   145.9  #include <asm-xen/xen-public/xen.h>
  145.10  
  145.11 @@ -112,7 +113,7 @@ VM_MASK		= 0x00020000
  145.12  				XEN_BLOCK_EVENTS(%esi)
  145.13  #else
  145.14  #define preempt_stop
  145.15 -#define resume_kernel		restore_all
  145.16 +#define resume_kernel		restore_nocheck
  145.17  #endif
  145.18  
  145.19  #define SAVE_ALL \
  145.20 @@ -161,11 +162,9 @@ 4:	movl $0,(%esp);	\
  145.21  	addl $4, %esp;	\
  145.22  1:	iret;		\
  145.23  .section .fixup,"ax";   \
  145.24 -2:	movl $(__USER_DS), %edx; \
  145.25 -	movl %edx, %ds; \
  145.26 -	movl %edx, %es; \
  145.27 -	movl $11,%eax;	\
  145.28 -	call do_exit;	\
  145.29 +2:	pushl $0;	\
  145.30 +	pushl $do_iret_error;	\
  145.31 +	jmp error_code;	\
  145.32  .previous;		\
  145.33  .section __ex_table,"a";\
  145.34  	.align 4;	\
  145.35 @@ -196,7 +195,7 @@ ret_from_intr:
  145.36  	movl EFLAGS(%esp), %eax		# mix EFLAGS and CS
  145.37  	movb CS(%esp), %al
  145.38  	testl $(VM_MASK | 2), %eax
  145.39 -	jz resume_kernel		# returning to kernel or vm86-space
  145.40 +	jz resume_kernel
  145.41  ENTRY(resume_userspace)
  145.42  	XEN_BLOCK_EVENTS(%esi)		# make sure we don't miss an interrupt
  145.43  					# setting need_resched or sigpending
  145.44 @@ -211,7 +210,7 @@ ENTRY(resume_userspace)
  145.45  ENTRY(resume_kernel)
  145.46  	XEN_BLOCK_EVENTS(%esi)
  145.47  	cmpl $0,TI_preempt_count(%ebp)	# non-zero preempt_count ?
  145.48 -	jnz restore_all
  145.49 +	jnz restore_nocheck
  145.50  need_resched:
  145.51  	movl TI_flags(%ebp), %ecx	# need_resched set ?
  145.52  	testb $_TIF_NEED_RESCHED, %cl
  145.53 @@ -252,7 +251,8 @@ 1:	movl (%ebp),%ebp
  145.54  	SAVE_ALL
  145.55  	GET_THREAD_INFO(%ebp)
  145.56  
  145.57 -	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
  145.58 +	/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
  145.59 +	testw $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),TI_flags(%ebp)
  145.60  	jnz syscall_trace_entry
  145.61  	cmpl $(nr_syscalls), %eax
  145.62  	jae syscall_badsys
  145.63 @@ -276,7 +276,8 @@ ENTRY(system_call)
  145.64  	SAVE_ALL
  145.65  	GET_THREAD_INFO(%ebp)
  145.66  					# system call tracing in operation
  145.67 -	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
  145.68 +	/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
  145.69 +	testw $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),TI_flags(%ebp)
  145.70  	jnz syscall_trace_entry
  145.71  	cmpl $(nr_syscalls), %eax
  145.72  	jae syscall_badsys
  145.73 @@ -290,7 +291,20 @@ syscall_exit:
  145.74  	movl TI_flags(%ebp), %ecx
  145.75  	testw $_TIF_ALLWORK_MASK, %cx	# current->work
  145.76  	jne syscall_exit_work
  145.77 +
  145.78  restore_all:
  145.79 +#if 0 /* XEN */
  145.80 +	movl EFLAGS(%esp), %eax		# mix EFLAGS, SS and CS
  145.81 +	# Warning: OLDSS(%esp) contains the wrong/random values if we
  145.82 +	# are returning to the kernel.
  145.83 +	# See comments in process.c:copy_thread() for details.
  145.84 +	movb OLDSS(%esp), %ah
  145.85 +	movb CS(%esp), %al
  145.86 +	andl $(VM_MASK | (4 << 8) | 3), %eax
  145.87 +	cmpl $((4 << 8) | 3), %eax
  145.88 +	je ldt_ss			# returning to user-space with LDT SS
  145.89 +#endif /* XEN */
  145.90 +restore_nocheck:
  145.91  	testl $VM_MASK, EFLAGS(%esp)
  145.92  	jnz resume_vm86
  145.93  	movb EVENT_MASK(%esp), %al
  145.94 @@ -300,7 +314,19 @@ restore_all:
  145.95  	andb $1,%al			# %al == mask & ~saved_mask
  145.96  	jnz restore_all_enable_events	#     != 0 => reenable event delivery
  145.97  	XEN_PUT_VCPU_INFO(%esi)
  145.98 -	RESTORE_ALL
  145.99 +	RESTORE_REGS
 145.100 +	addl $4, %esp
 145.101 +1:	iret
 145.102 +.section .fixup,"ax"
 145.103 +iret_exc:
 145.104 +	pushl $0			# no error code
 145.105 +	pushl $do_iret_error
 145.106 +	jmp error_code
 145.107 +.previous
 145.108 +.section __ex_table,"a"
 145.109 +	.align 4
 145.110 +	.long 1b,iret_exc
 145.111 +.previous
 145.112  
 145.113  resume_vm86:
 145.114  	XEN_UNBLOCK_EVENTS(%esi)
 145.115 @@ -310,6 +336,33 @@ resume_vm86:
 145.116  	int $0x82
 145.117  	ud2
 145.118  
 145.119 +#if 0 /* XEN */
 145.120 +ldt_ss:
 145.121 +	larl OLDSS(%esp), %eax
 145.122 +	jnz restore_nocheck
 145.123 +	testl $0x00400000, %eax		# returning to 32bit stack?
 145.124 +	jnz restore_nocheck		# allright, normal return
 145.125 +	/* If returning to userspace with 16bit stack,
 145.126 +	 * try to fix the higher word of ESP, as the CPU
 145.127 +	 * won't restore it.
 145.128 +	 * This is an "official" bug of all the x86-compatible
 145.129 +	 * CPUs, which we can try to work around to make
 145.130 +	 * dosemu and wine happy. */
 145.131 +	subl $8, %esp		# reserve space for switch16 pointer
 145.132 +	cli
 145.133 +	movl %esp, %eax
 145.134 +	/* Set up the 16bit stack frame with switch32 pointer on top,
 145.135 +	 * and a switch16 pointer on top of the current frame. */
 145.136 +	call setup_x86_bogus_stack
 145.137 +	RESTORE_REGS
 145.138 +	lss 20+4(%esp), %esp	# switch to 16bit stack
 145.139 +1:	iret
 145.140 +.section __ex_table,"a"
 145.141 +	.align 4
 145.142 +	.long 1b,iret_exc
 145.143 +.previous
 145.144 +#endif /* XEN */
 145.145 +
 145.146  	# perform work that needs to be done immediately before resumption
 145.147  	ALIGN
 145.148  work_pending:
 145.149 @@ -385,6 +438,27 @@ syscall_badsys:
 145.150  	jmp resume_userspace
 145.151  
 145.152  #if 0 /* XEN */
 145.153 +#define FIXUP_ESPFIX_STACK \
 145.154 +	movl %esp, %eax; \
 145.155 +	/* switch to 32bit stack using the pointer on top of 16bit stack */ \
 145.156 +	lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
 145.157 +	/* copy data from 16bit stack to 32bit stack */ \
 145.158 +	call fixup_x86_bogus_stack; \
 145.159 +	/* put ESP to the proper location */ \
 145.160 +	movl %eax, %esp;
 145.161 +#define UNWIND_ESPFIX_STACK \
 145.162 +	pushl %eax; \
 145.163 +	movl %ss, %eax; \
 145.164 +	/* see if on 16bit stack */ \
 145.165 +	cmpw $__ESPFIX_SS, %ax; \
 145.166 +	jne 28f; \
 145.167 +	movl $__KERNEL_DS, %edx; \
 145.168 +	movl %edx, %ds; \
 145.169 +	movl %edx, %es; \
 145.170 +	/* switch to 32bit stack */ \
 145.171 +	FIXUP_ESPFIX_STACK \
 145.172 +28:	popl %eax;
 145.173 +
 145.174  /*
 145.175   * Build the entry stubs and pointer table with
 145.176   * some assembler magic.
 145.177 @@ -440,7 +514,9 @@ error_code:
 145.178  	pushl %ecx
 145.179  	pushl %ebx
 145.180  	cld
 145.181 -	movl %es, %ecx
 145.182 +	pushl %es
 145.183 +#	UNWIND_ESPFIX_STACK
 145.184 +	popl %ecx
 145.185  	movl ES(%esp), %edi		# get the function address
 145.186  	movl ORIG_EAX(%esp), %edx	# get the error code
 145.187  	movl %eax, ORIG_EAX(%esp)
 145.188 @@ -625,6 +701,11 @@ debug_stack_correct:
 145.189   * fault happened on the sysenter path.
 145.190   */
 145.191  ENTRY(nmi)
 145.192 +	pushl %eax
 145.193 +	movl %ss, %eax
 145.194 +	cmpw $__ESPFIX_SS, %ax
 145.195 +	popl %eax
 145.196 +	je nmi_16bit_stack
 145.197  	cmpl $sysenter_entry,(%esp)
 145.198  	je nmi_stack_fixup
 145.199  	pushl %eax
 145.200 @@ -644,7 +725,7 @@ nmi_stack_correct:
 145.201  	xorl %edx,%edx		# zero error code
 145.202  	movl %esp,%eax		# pt_regs pointer
 145.203  	call do_nmi
 145.204 -	RESTORE_ALL
 145.205 +	jmp restore_all
 145.206  
 145.207  nmi_stack_fixup:
 145.208  	FIX_STACK(12,nmi_stack_correct, 1)
 145.209 @@ -659,6 +740,29 @@ nmi_debug_stack_check:
 145.210  nmi_debug_stack_fixup:
 145.211  	FIX_STACK(24,nmi_stack_correct, 1)
 145.212  	jmp nmi_stack_correct
 145.213 +
 145.214 +nmi_16bit_stack:
 145.215 +	/* create the pointer to lss back */
 145.216 +	pushl %ss
 145.217 +	pushl %esp
 145.218 +	movzwl %sp, %esp
 145.219 +	addw $4, (%esp)
 145.220 +	/* copy the iret frame of 12 bytes */
 145.221 +	.rept 3
 145.222 +	pushl 16(%esp)
 145.223 +	.endr
 145.224 +	pushl %eax
 145.225 +	SAVE_ALL
 145.226 +	FIXUP_ESPFIX_STACK		# %eax == %esp
 145.227 +	xorl %edx,%edx			# zero error code
 145.228 +	call do_nmi
 145.229 +	RESTORE_REGS
 145.230 +	lss 12+4(%esp), %esp		# back to 16bit stack
 145.231 +1:	iret
 145.232 +.section __ex_table,"a"
 145.233 +	.align 4
 145.234 +	.long 1b,iret_exc
 145.235 +.previous
 145.236  #endif /* XEN */
 145.237  
 145.238  ENTRY(int3)
 145.239 @@ -725,7 +829,9 @@ ENTRY(page_fault)
 145.240  	pushl %ecx
 145.241  	pushl %ebx
 145.242  	cld
 145.243 -	movl %es,%edi
 145.244 +	pushl %es
 145.245 +#	UNWIND_ESPFIX_STACK
 145.246 +	popl %edi
 145.247  	movl ES(%esp), %ecx		/* get the faulting address */
 145.248  	movl ORIG_EAX(%esp), %edx	/* get the error code */
 145.249  	movl %eax, ORIG_EAX(%esp)
   146.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Thu Sep 08 09:18:40 2005 -0600
   146.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Fri Sep 09 10:30:54 2005 -0600
   146.3 @@ -38,17 +38,13 @@
   146.4  #define X86_VENDOR_ID	new_cpu_data+CPUINFO_x86_vendor_id
   146.5  
   146.6  ENTRY(startup_32)
   146.7 -	cld
   146.8 -
   146.9 -	/* Copy the necessary stuff from xen_start_info structure. */
  146.10 -	mov  $xen_start_info_union,%edi
  146.11 -	mov  $512,%ecx
  146.12 -	rep movsl
  146.13 +	movl %esi,xen_start_info
  146.14  
  146.15  #ifdef CONFIG_SMP
  146.16  ENTRY(startup_32_smp)
  146.17 +#endif /* CONFIG_SMP */
  146.18 +
  146.19  	cld
  146.20 -#endif /* CONFIG_SMP */
  146.21  
  146.22  	/* Set up the stack pointer */
  146.23  	lss stack_start,%esp
  146.24 @@ -179,7 +175,7 @@ ENTRY(cpu_gdt_table)
  146.25  	.quad 0x0000000000000000	/* 0xc0 APM CS 16 code (16 bit) */
  146.26  	.quad 0x0000000000000000	/* 0xc8 APM DS    data */
  146.27  
  146.28 -	.quad 0x0000000000000000	/* 0xd0 - unused */
  146.29 +	.quad 0x0000000000000000	/* 0xd0 - ESPFIX 16-bit SS */
  146.30  	.quad 0x0000000000000000	/* 0xd8 - unused */
  146.31  	.quad 0x0000000000000000	/* 0xe0 - unused */
  146.32  	.quad 0x0000000000000000	/* 0xe8 - unused */
   151.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/irq.c	Thu Sep 08 09:18:40 2005 -0600
   151.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/irq.c	Fri Sep 09 10:30:54 2005 -0600
   151.3 @@ -242,12 +242,12 @@ skip:
   151.4  	} else if (i == NR_IRQS) {
   151.5  		seq_printf(p, "NMI: ");
   151.6  		for_each_cpu(j)
   151.7 -			seq_printf(p, "%10u ", nmi_count(j));
   151.8 + 			seq_printf(p, "%10u ", nmi_count(j));
   151.9  		seq_putc(p, '\n');
  151.10  #ifdef CONFIG_X86_LOCAL_APIC
  151.11  		seq_printf(p, "LOC: ");
  151.12  		for_each_cpu(j)
  151.13 -			seq_printf(p, "%10u ", per_cpu(irq_stat, j).apic_timer_irqs);
  151.14 +			seq_printf(p, "%10u ", per_cpu(irq_stat,j).apic_timer_irqs);
  151.15  		seq_putc(p, '\n');
  151.16  #endif
  151.17  		seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
  151.18 @@ -263,6 +263,7 @@ skip:
  151.19  void fixup_irqs(cpumask_t map)
  151.20  {
  151.21  	unsigned int irq;
  151.22 +	static int warned;
  151.23  
  151.24  	for (irq = 0; irq < NR_IRQS; irq++) {
  151.25  		cpumask_t mask;
  151.26 @@ -276,7 +277,7 @@ void fixup_irqs(cpumask_t map)
  151.27  		}
  151.28  		if (irq_desc[irq].handler->set_affinity)
  151.29  			irq_desc[irq].handler->set_affinity(irq, mask);
  151.30 -		else if (irq_desc[irq].action)
  151.31 +		else if (irq_desc[irq].action && !(warned++))
  151.32  			printk("Cannot set affinity for irq %i\n", irq);
  151.33  	}
  151.34  
   155.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Thu Sep 08 09:18:40 2005 -0600
   155.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Fri Sep 09 10:30:54 2005 -0600
   155.3 @@ -115,9 +115,9 @@ dma_supported(struct device *dev, u64 ma
   155.4  	if (swiotlb)
   155.5  		return swiotlb_dma_supported(dev, mask);
   155.6  	/*
   155.7 -         * By default we'll BUG when an infeasible DMA is requested, and
   155.8 -         * request swiotlb=force (see IOMMU_BUG_ON).
   155.9 -         */
  155.10 +	 * By default we'll BUG when an infeasible DMA is requested, and
  155.11 +	 * request swiotlb=force (see IOMMU_BUG_ON).
  155.12 +	 */
  155.13  	return 1;
  155.14  }
  155.15  EXPORT_SYMBOL(dma_supported);
   156.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Thu Sep 08 09:18:40 2005 -0600
   156.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Fri Sep 09 10:30:54 2005 -0600
   156.3 @@ -135,6 +135,10 @@ static inline void play_dead(void)
   156.4   * low exit latency (ie sit in a loop waiting for
   156.5   * somebody to say that they'd like to reschedule)
   156.6   */
   156.7 +#ifdef CONFIG_SMP
   156.8 +extern void smp_suspend(void);
   156.9 +extern void smp_resume(void);
  156.10 +#endif
  156.11  void cpu_idle (void)
  156.12  {
  156.13  	int cpu = _smp_processor_id();
  156.14 @@ -149,6 +153,9 @@ void cpu_idle (void)
  156.15  
  156.16  			if (cpu_is_offline(cpu)) {
  156.17  				local_irq_disable();
  156.18 +#ifdef CONFIG_SMP
  156.19 +				smp_suspend();
  156.20 +#endif
  156.21  #if defined(CONFIG_XEN) && defined(CONFIG_HOTPLUG_CPU)
  156.22  				/* Ack it.  From this point on until
  156.23  				   we get woken up, we're not allowed
  156.24 @@ -159,6 +166,9 @@ void cpu_idle (void)
  156.25  				HYPERVISOR_vcpu_down(cpu);
  156.26  #endif
  156.27  				play_dead();
  156.28 +#ifdef CONFIG_SMP
  156.29 +				smp_resume();
  156.30 +#endif
  156.31  				local_irq_enable();
  156.32  			}
  156.33  
  156.34 @@ -457,7 +467,6 @@ int dump_task_regs(struct task_struct *t
  156.35  	return 1;
  156.36  }
  156.37  
  156.38 -
  156.39  /*
  156.40   *	switch_to(x,yn) should switch tasks from x to y.
  156.41   *
  156.42 @@ -789,10 +798,3 @@ unsigned long arch_align_stack(unsigned 
  156.43  		sp -= get_random_int() % 8192;
  156.44  	return sp & ~0xf;
  156.45  }
  156.46 -
  156.47 -
  156.48 -#ifndef CONFIG_X86_SMP
  156.49 -void _restore_vcpu(void)
  156.50 -{
  156.51 -}
  156.52 -#endif
   157.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Thu Sep 08 09:18:40 2005 -0600
   157.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Sep 09 10:30:54 2005 -0600
   157.3 @@ -55,6 +55,7 @@
   157.4  #include <asm/io.h>
   157.5  #include <asm-xen/hypervisor.h>
   157.6  #include <asm-xen/xen-public/physdev.h>
   157.7 +#include <asm-xen/xen-public/memory.h>
   157.8  #include "setup_arch_pre.h"
   157.9  #include <bios_ebda.h>
  157.10  
  157.11 @@ -288,7 +289,7 @@ static void __init probe_roms(void)
  157.12  	int	      i;
  157.13  
  157.14  	/* Nothing to do if not running in dom0. */
  157.15 -	if (!(xen_start_info.flags & SIF_INITDOMAIN))
  157.16 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
  157.17  		return;
  157.18  
  157.19  	/* video rom */
  157.20 @@ -358,11 +359,12 @@ static void __init probe_roms(void)
  157.21  shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
  157.22  EXPORT_SYMBOL(HYPERVISOR_shared_info);
  157.23  
  157.24 -unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
  157.25 +unsigned long *phys_to_machine_mapping;
  157.26 +unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[16];
  157.27  EXPORT_SYMBOL(phys_to_machine_mapping);
  157.28  
  157.29  /* Raw start-of-day parameters from the hypervisor. */
  157.30 -union xen_start_info_union xen_start_info_union;
  157.31 +start_info_t *xen_start_info;
  157.32  
  157.33  static void __init limit_regions(unsigned long long size)
  157.34  {
  157.35 @@ -702,7 +704,7 @@ static void __init parse_cmdline_early (
  157.36  
  157.37  	if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
  157.38  		max_cmdline = COMMAND_LINE_SIZE;
  157.39 -	memcpy(saved_command_line, xen_start_info.cmd_line, max_cmdline);
  157.40 +	memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
  157.41  	/* Save unparsed command line copy for /proc/cmdline */
  157.42  	saved_command_line[max_cmdline-1] = '\0';
  157.43  
  157.44 @@ -933,8 +935,8 @@ void __init find_max_pfn(void)
  157.45  /* We don't use the fake e820 because we need to respond to user override. */
  157.46  void __init find_max_pfn(void)
  157.47  {
  157.48 -	if ( xen_override_max_pfn < xen_start_info.nr_pages )
  157.49 -		xen_override_max_pfn = xen_start_info.nr_pages;
  157.50 +	if ( xen_override_max_pfn < xen_start_info->nr_pages )
  157.51 +		xen_override_max_pfn = xen_start_info->nr_pages;
  157.52  	max_pfn = xen_override_max_pfn;
  157.53  }
  157.54  #endif /* XEN */
  157.55 @@ -1077,12 +1079,12 @@ static void __init reserve_ebda_region(v
  157.56  void __init setup_bootmem_allocator(void);
  157.57  static unsigned long __init setup_memory(void)
  157.58  {
  157.59 -
  157.60  	/*
  157.61  	 * partially used pages are not usable - thus
  157.62  	 * we are rounding upwards:
  157.63  	 */
  157.64 - 	min_low_pfn = PFN_UP(__pa(xen_start_info.pt_base)) + xen_start_info.nr_pt_frames;
  157.65 + 	min_low_pfn = PFN_UP(__pa(xen_start_info->pt_base)) +
  157.66 +		xen_start_info->nr_pt_frames;
  157.67  
  157.68  	find_max_pfn();
  157.69  
  157.70 @@ -1188,7 +1190,7 @@ void __init setup_bootmem_allocator(void
  157.71  #endif /* !CONFIG_XEN */
  157.72  
  157.73  #ifdef CONFIG_BLK_DEV_INITRD
  157.74 -	if (xen_start_info.mod_start) {
  157.75 +	if (xen_start_info->mod_start) {
  157.76  		if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
  157.77  			/*reserve_bootmem(INITRD_START, INITRD_SIZE);*/
  157.78  			initrd_start = INITRD_START + PAGE_OFFSET;
  157.79 @@ -1205,7 +1207,7 @@ void __init setup_bootmem_allocator(void
  157.80  	}
  157.81  #endif
  157.82  
  157.83 -	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
  157.84 +	phys_to_machine_mapping = (unsigned long *)xen_start_info->mfn_list;
  157.85  }
  157.86  
  157.87  /*
  157.88 @@ -1234,10 +1236,64 @@ static void __init
  157.89  legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
  157.90  {
  157.91  	int i;
  157.92 +#ifdef CONFIG_XEN
  157.93 +	dom0_op_t op;
  157.94 +	struct dom0_memory_map_entry *map;
  157.95 +	unsigned long gapstart, gapsize;
  157.96 +	unsigned long long last;
  157.97 +#endif
  157.98  
  157.99  #ifdef CONFIG_XEN_PRIVILEGED_GUEST
 157.100  	probe_roms();
 157.101  #endif
 157.102 +
 157.103 +#ifdef CONFIG_XEN
 157.104 +	map = alloc_bootmem_low_pages(PAGE_SIZE);
 157.105 +	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
 157.106 +	op.u.physical_memory_map.memory_map = map;
 157.107 +	op.u.physical_memory_map.max_map_entries =
 157.108 +		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 157.109 +	BUG_ON(HYPERVISOR_dom0_op(&op));
 157.110 +
 157.111 +	last = 0x100000000ULL;
 157.112 +	gapstart = 0x10000000;
 157.113 +	gapsize = 0x400000;
 157.114 +
 157.115 +	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
 157.116 +		struct resource *res;
 157.117 +
 157.118 +		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
 157.119 +			gapsize = last - map[i].end;
 157.120 +			gapstart = map[i].end;
 157.121 +		}
 157.122 +		if (map[i].start < last)
 157.123 +			last = map[i].start;
 157.124 +
 157.125 +		if (map[i].end > 0x100000000ULL)
 157.126 +			continue;
 157.127 +		res = alloc_bootmem_low(sizeof(struct resource));
 157.128 +		res->name = map[i].is_ram ? "System RAM" : "reserved";
 157.129 +		res->start = map[i].start;
 157.130 +		res->end = map[i].end - 1;
 157.131 +		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 157.132 +		request_resource(&iomem_resource, res);
 157.133 +	}
 157.134 +
 157.135 +	free_bootmem(__pa(map), PAGE_SIZE);
 157.136 +
 157.137 +	/*
 157.138 +	 * Start allocating dynamic PCI memory a bit into the gap,
 157.139 +	 * aligned up to the nearest megabyte.
 157.140 +	 *
 157.141 +	 * Question: should we try to pad it up a bit (do something
 157.142 +	 * like " + (gapsize >> 3)" in there too?). We now have the
 157.143 +	 * technology.
 157.144 +	 */
 157.145 +	pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
 157.146 +
 157.147 +	printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
 157.148 +		pci_mem_start, gapstart, gapsize);
 157.149 +#else
 157.150  	for (i = 0; i < e820.nr_map; i++) {
 157.151  		struct resource *res;
 157.152  		if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
 157.153 @@ -1263,6 +1319,7 @@ legacy_init_iomem_resources(struct resou
 157.154  			request_resource(res, data_resource);
 157.155  		}
 157.156  	}
 157.157 +#endif
 157.158  }
 157.159  
 157.160  /*
 157.161 @@ -1270,23 +1327,29 @@ legacy_init_iomem_resources(struct resou
 157.162   */
 157.163  static void __init register_memory(void)
 157.164  {
 157.165 +#ifndef CONFIG_XEN
 157.166  	unsigned long gapstart, gapsize;
 157.167  	unsigned long long last;
 157.168 +#endif
 157.169  	int	      i;
 157.170  
 157.171 +	/* Nothing to do if not running in dom0. */
 157.172 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
 157.173 +		return;
 157.174 +
 157.175  	if (efi_enabled)
 157.176  		efi_initialize_iomem_resources(&code_resource, &data_resource);
 157.177  	else
 157.178  		legacy_init_iomem_resources(&code_resource, &data_resource);
 157.179  
 157.180 -	if (xen_start_info.flags & SIF_INITDOMAIN)
 157.181 -		/* EFI systems may still have VGA */
 157.182 -		request_resource(&iomem_resource, &video_ram_resource);
 157.183 +	/* EFI systems may still have VGA */
 157.184 +	request_resource(&iomem_resource, &video_ram_resource);
 157.185  
 157.186  	/* request I/O space for devices used on all i[345]86 PCs */
 157.187  	for (i = 0; i < STANDARD_IO_RESOURCES; i++)
 157.188  		request_resource(&ioport_resource, &standard_io_resources[i]);
 157.189  
 157.190 +#ifndef CONFIG_XEN
 157.191  	/*
 157.192  	 * Search for the bigest gap in the low 32 bits of the e820
 157.193  	 * memory space.
 157.194 @@ -1327,6 +1390,7 @@ static void __init register_memory(void)
 157.195  
 157.196  	printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
 157.197  		pci_mem_start, gapstart, gapsize);
 157.198 +#endif
 157.199  }
 157.200  
 157.201  /* Use inline assembly to define this because the nops are defined 
 157.202 @@ -1456,7 +1520,7 @@ static void set_mca_bus(int x) { }
 157.203   */
 157.204  void __init setup_arch(char **cmdline_p)
 157.205  {
 157.206 -	int i, j;
 157.207 +	int i, j, k, fpp;
 157.208  	physdev_op_t op;
 157.209  	unsigned long max_low_pfn;
 157.210  
 157.211 @@ -1535,8 +1599,8 @@ void __init setup_arch(char **cmdline_p)
 157.212  	init_mm.start_code = (unsigned long) _text;
 157.213  	init_mm.end_code = (unsigned long) _etext;
 157.214  	init_mm.end_data = (unsigned long) _edata;
 157.215 -	init_mm.brk = (PFN_UP(__pa(xen_start_info.pt_base)) +
 157.216 -		       xen_start_info.nr_pt_frames) << PAGE_SHIFT;
 157.217 +	init_mm.brk = (PFN_UP(__pa(xen_start_info->pt_base)) +
 157.218 +		       xen_start_info->nr_pt_frames) << PAGE_SHIFT;
 157.219  
 157.220  	/* XEN: This is nonsense: kernel may not even be contiguous in RAM. */
 157.221  	/*code_resource.start = virt_to_phys(_text);*/
 157.222 @@ -1573,42 +1637,64 @@ void __init setup_arch(char **cmdline_p)
 157.223  #endif
 157.224  
 157.225  	/* Make sure we have a correctly sized P->M table. */
 157.226 -	if (max_pfn != xen_start_info.nr_pages) {
 157.227 +	if (max_pfn != xen_start_info->nr_pages) {
 157.228  		phys_to_machine_mapping = alloc_bootmem_low_pages(
 157.229 -			max_pfn * sizeof(unsigned int));
 157.230 +			max_pfn * sizeof(unsigned long));
 157.231  
 157.232 -		if (max_pfn > xen_start_info.nr_pages) {
 157.233 +		if (max_pfn > xen_start_info->nr_pages) {
 157.234  			/* set to INVALID_P2M_ENTRY */
 157.235  			memset(phys_to_machine_mapping, ~0,
 157.236 -				max_pfn * sizeof(unsigned int));
 157.237 -			memcpy(phys_to_machine_mapping,
 157.238 -				(unsigned int *)xen_start_info.mfn_list,
 157.239 -				xen_start_info.nr_pages * sizeof(unsigned int));
 157.240 -		} else {
 157.241 +				max_pfn * sizeof(unsigned long));
 157.242  			memcpy(phys_to_machine_mapping,
 157.243 -				(unsigned int *)xen_start_info.mfn_list,
 157.244 -				max_pfn * sizeof(unsigned int));
 157.245 -			/* N.B. below relies on sizeof(int) == sizeof(long). */
 157.246 -			if (HYPERVISOR_dom_mem_op(
 157.247 -				MEMOP_decrease_reservation,
 157.248 -				(unsigned long *)xen_start_info.mfn_list + max_pfn,
 157.249 -				xen_start_info.nr_pages - max_pfn, 0) !=
 157.250 -			    (xen_start_info.nr_pages - max_pfn)) BUG();
 157.251 +				(unsigned long *)xen_start_info->mfn_list,
 157.252 +				xen_start_info->nr_pages * sizeof(unsigned long));
 157.253 +		} else {
 157.254 +			struct xen_memory_reservation reservation = {
 157.255 +				.extent_start = (unsigned long *)xen_start_info->mfn_list + max_pfn,
 157.256 +				.nr_extents   = xen_start_info->nr_pages - max_pfn,
 157.257 +				.extent_order = 0,
 157.258 +				.domid        = DOMID_SELF
 157.259 +			};
 157.260 +
 157.261 +			memcpy(phys_to_machine_mapping,
 157.262 +				(unsigned long *)xen_start_info->mfn_list,
 157.263 +				max_pfn * sizeof(unsigned long));
 157.264 +			BUG_ON(HYPERVISOR_memory_op(
 157.265 +				XENMEM_decrease_reservation,
 157.266 +				&reservation) !=
 157.267 +			    (xen_start_info->nr_pages - max_pfn));
 157.268  		}
 157.269  		free_bootmem(
 157.270 -			__pa(xen_start_info.mfn_list), 
 157.271 -			PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
 157.272 -			sizeof(unsigned int))));
 157.273 +			__pa(xen_start_info->mfn_list), 
 157.274 +			PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
 157.275 +			sizeof(unsigned long))));
 157.276  	}
 157.277  
 157.278 -	pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
 157.279 -	for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned int)), j++ )
 157.280 -	{	
 157.281 -	     pfn_to_mfn_frame_list[j] = 
 157.282 -		  virt_to_mfn(&phys_to_machine_mapping[i]);
 157.283 +
 157.284 +	/* 
 157.285 +	 * Initialise the list of the frames that specify the list of 
 157.286 +	 * frames that make up the p2m table. Used by save/restore
 157.287 +	 */
 157.288 +	pfn_to_mfn_frame_list_list = alloc_bootmem_low_pages(PAGE_SIZE);
 157.289 +	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
 157.290 +	  virt_to_mfn(pfn_to_mfn_frame_list_list);
 157.291 +	       
 157.292 +	fpp = PAGE_SIZE/sizeof(unsigned long);
 157.293 +	for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
 157.294 +	{
 157.295 +	    if ( (j % fpp) == 0 )
 157.296 +	    {
 157.297 +	        k++;
 157.298 +		BUG_ON(k>=16);
 157.299 +		pfn_to_mfn_frame_list[k] = alloc_bootmem_low_pages(PAGE_SIZE);
 157.300 +		pfn_to_mfn_frame_list_list[k] = 
 157.301 +		    virt_to_mfn(pfn_to_mfn_frame_list[k]);
 157.302 +		j=0;
 157.303 +	    }
 157.304 +	    pfn_to_mfn_frame_list[k][j] = 
 157.305 +	        virt_to_mfn(&phys_to_machine_mapping[i]);
 157.306  	}
 157.307 -	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
 157.308 -	     virt_to_mfn(pfn_to_mfn_frame_list);
 157.309 +	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
 157.310  
 157.311  	/*
 157.312  	 * NOTE: at this point the bootmem allocator is fully available.
 157.313 @@ -1626,8 +1712,8 @@ void __init setup_arch(char **cmdline_p)
 157.314  	}
 157.315  #endif
 157.316  
 157.317 -
 157.318 -	dmi_scan_machine();
 157.319 +	if (xen_start_info->flags & SIF_INITDOMAIN)
 157.320 +		dmi_scan_machine();
 157.321  
 157.322  #ifdef CONFIG_X86_GENERICARCH
 157.323  	generic_apic_probe(*cmdline_p);
 157.324 @@ -1640,7 +1726,7 @@ void __init setup_arch(char **cmdline_p)
 157.325  	HYPERVISOR_physdev_op(&op);
 157.326  
 157.327  #ifdef CONFIG_ACPI_BOOT
 157.328 -	if (!(xen_start_info.flags & SIF_INITDOMAIN)) {
 157.329 +	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
 157.330  		printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
 157.331  		acpi_disabled = 1;
 157.332  		acpi_ht = 0;
 157.333 @@ -1666,8 +1752,8 @@ void __init setup_arch(char **cmdline_p)
 157.334  
 157.335  	register_memory();
 157.336  
 157.337 -	if (xen_start_info.flags & SIF_INITDOMAIN) {
 157.338 -		if (!(xen_start_info.flags & SIF_PRIVILEGED))
 157.339 +	if (xen_start_info->flags & SIF_INITDOMAIN) {
 157.340 +		if (!(xen_start_info->flags & SIF_PRIVILEGED))
 157.341  			panic("Xen granted us console access "
 157.342  			      "but not privileged status");
 157.343  
   160.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Thu Sep 08 09:18:40 2005 -0600
   160.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Fri Sep 09 10:30:54 2005 -0600
   160.3 @@ -856,9 +856,6 @@ static int __init do_boot_cpu(int apicid
   160.4  	cpu_gdt_descr[cpu].address = __get_free_page(GFP_KERNEL|__GFP_ZERO);
   160.5  	BUG_ON(cpu_gdt_descr[0].size > PAGE_SIZE);
   160.6  	cpu_gdt_descr[cpu].size = cpu_gdt_descr[0].size;
   160.7 -	printk("GDT: copying %d bytes from %lx to %lx\n",
   160.8 -		cpu_gdt_descr[0].size, cpu_gdt_descr[0].address,
   160.9 -		cpu_gdt_descr[cpu].address); 
  160.10  	memcpy((void *)cpu_gdt_descr[cpu].address,
  160.11  	       (void *)cpu_gdt_descr[0].address, cpu_gdt_descr[0].size);
  160.12  
  160.13 @@ -1274,6 +1271,7 @@ static void __init smp_boot_cpus(unsigne
  160.14  			printk(KERN_WARNING "WARNING: %d siblings found for CPU%d, should be %d\n", siblings, cpu, smp_num_siblings);
  160.15  			smp_num_siblings = siblings;
  160.16  		}
  160.17 +
  160.18  		if (c->x86_num_cores > 1) {
  160.19  			for (i = 0; i < NR_CPUS; i++) {
  160.20  				if (!cpu_isset(i, cpu_callout_map))
  160.21 @@ -1601,32 +1599,71 @@ extern void local_teardown_timer_irq(voi
  160.22  
  160.23  void smp_suspend(void)
  160.24  {
  160.25 -	/* XXX todo: take down time and ipi's on all cpus */
  160.26  	local_teardown_timer_irq();
  160.27  	smp_intr_exit();
  160.28  }
  160.29  
  160.30  void smp_resume(void)
  160.31  {
  160.32 -	/* XXX todo: restore time and ipi's on all cpus */
  160.33  	smp_intr_init();
  160.34  	local_setup_timer_irq();
  160.35  }
  160.36  
  160.37 -DECLARE_PER_CPU(int, timer_irq);
  160.38 -
  160.39 -void _restore_vcpu(void)
  160.40 -{
  160.41 -	int cpu = smp_processor_id();
  160.42 -	extern atomic_t vcpus_rebooting;
  160.43 +static atomic_t vcpus_rebooting;
  160.44  
  160.45 -	/* We are the first thing the vcpu runs when it comes back,
  160.46 -	   and we are supposed to restore the IPIs and timer
  160.47 -	   interrupts etc.  When we return, the vcpu's idle loop will
  160.48 -	   start up again. */
  160.49 -	_bind_virq_to_irq(VIRQ_TIMER, cpu, per_cpu(timer_irq, cpu));
  160.50 -	_bind_virq_to_irq(VIRQ_DEBUG, cpu, per_cpu(ldebug_irq, cpu));
  160.51 -	_bind_ipi_to_irq(RESCHEDULE_VECTOR, cpu, per_cpu(resched_irq, cpu) );
  160.52 -	_bind_ipi_to_irq(CALL_FUNCTION_VECTOR, cpu, per_cpu(callfunc_irq, cpu) );
  160.53 +static void restore_vcpu_ready(void)
  160.54 +{
  160.55 +
  160.56  	atomic_dec(&vcpus_rebooting);
  160.57  }
  160.58 +
  160.59 +void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
  160.60 +{
  160.61 +	int r;
  160.62 +	int gdt_pages;
  160.63 +	r = HYPERVISOR_vcpu_pickle(vcpu, ctxt);
  160.64 +	if (r != 0)
  160.65 +		panic("pickling vcpu %d -> %d!\n", vcpu, r);
  160.66 +
  160.67 +	/* Translate from machine to physical addresses where necessary,
  160.68 +	   so that they can be translated to our new machine address space
  160.69 +	   after resume.  libxc is responsible for doing this to vcpu0,
  160.70 +	   but we do it to the others. */
  160.71 +	gdt_pages = (ctxt->gdt_ents + 511) / 512;
  160.72 +	ctxt->ctrlreg[3] = machine_to_phys(ctxt->ctrlreg[3]);
  160.73 +	for (r = 0; r < gdt_pages; r++)
  160.74 +		ctxt->gdt_frames[r] = mfn_to_pfn(ctxt->gdt_frames[r]);
  160.75 +}
  160.76 +
  160.77 +int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
  160.78 +{
  160.79 +	int r;
  160.80 +	int gdt_pages = (ctxt->gdt_ents + 511) / 512;
  160.81 +
  160.82 +	/* This is kind of a hack, and implicitly relies on the fact that
  160.83 +	   the vcpu stops in a place where all of the call clobbered
  160.84 +	   registers are already dead. */
  160.85 +	ctxt->user_regs.esp -= 4;
  160.86 +	((unsigned long *)ctxt->user_regs.esp)[0] = ctxt->user_regs.eip;
  160.87 +	ctxt->user_regs.eip = (unsigned long)restore_vcpu_ready;
  160.88 +
  160.89 +	/* De-canonicalise.  libxc handles this for vcpu 0, but we need
  160.90 +	   to do it for the other vcpus. */
  160.91 +	ctxt->ctrlreg[3] = phys_to_machine(ctxt->ctrlreg[3]);
  160.92 +	for (r = 0; r < gdt_pages; r++)
  160.93 +		ctxt->gdt_frames[r] = pfn_to_mfn(ctxt->gdt_frames[r]);
  160.94 +
  160.95 +	atomic_set(&vcpus_rebooting, 1);
  160.96 +	r = HYPERVISOR_boot_vcpu(vcpu, ctxt);
  160.97 +	if (r != 0) {
  160.98 +		printk(KERN_EMERG "Failed to reboot vcpu %d (%d)\n", vcpu, r);
  160.99 +		return -1;
 160.100 +	}
 160.101 +
 160.102 +	/* Make sure we wait for the new vcpu to come up before trying to do
 160.103 +	   anything with it or starting the next one. */
 160.104 +	while (atomic_read(&vcpus_rebooting))
 160.105 +		barrier();
 160.106 +
 160.107 +	return 0;
 160.108 +}
   161.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Thu Sep 08 09:18:40 2005 -0600
   161.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Fri Sep 09 10:30:54 2005 -0600
   161.3 @@ -51,7 +51,7 @@ static unsigned long iotlb_nslabs;
   161.4   * swiotlb_sync_single_*, to see if the memory was in fact allocated by this
   161.5   * API.
   161.6   */
   161.7 -static dma_addr_t iotlb_bus_start, iotlb_bus_mask;
   161.8 +static dma_addr_t iotlb_bus_start, iotlb_bus_end, iotlb_bus_mask;
   161.9  
  161.10  /* Does the given dma address reside within the swiotlb aperture? */
  161.11  #define in_swiotlb_aperture(a) (!(((a) ^ iotlb_bus_start) & iotlb_bus_mask))
  161.12 @@ -157,6 +157,7 @@ swiotlb_init_with_default_size (size_t d
  161.13  	io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
  161.14  
  161.15  	iotlb_bus_start = virt_to_bus(iotlb_virt_start);
  161.16 +	iotlb_bus_end   = iotlb_bus_start + bytes;
  161.17  	iotlb_bus_mask  = ~(dma_addr_t)(bytes - 1);
  161.18  
  161.19  	printk(KERN_INFO "Software IO TLB enabled: \n"
  161.20 @@ -165,7 +166,7 @@ swiotlb_init_with_default_size (size_t d
  161.21  	       " Kernel range: 0x%016lx - 0x%016lx\n",
  161.22  	       bytes >> 20,
  161.23  	       (unsigned long)iotlb_bus_start,
  161.24 -	       (unsigned long)iotlb_bus_start + bytes,
  161.25 +	       (unsigned long)iotlb_bus_end,
  161.26  	       (unsigned long)iotlb_virt_start,
  161.27  	       (unsigned long)iotlb_virt_start + bytes);
  161.28  }
  161.29 @@ -181,7 +182,7 @@ swiotlb_init(void)
  161.30           * Otherwise, enable for domain 0 if the machine has 'lots of memory',
  161.31           * which we take to mean more than 2GB.
  161.32           */
  161.33 -	if (xen_start_info.flags & SIF_INITDOMAIN) {
  161.34 +	if (xen_start_info->flags & SIF_INITDOMAIN) {
  161.35  		dom0_op_t op;
  161.36  		op.cmd = DOM0_PHYSINFO;
  161.37  		if ((HYPERVISOR_dom0_op(&op) == 0) &&
  161.38 @@ -191,6 +192,8 @@ swiotlb_init(void)
  161.39  
  161.40  	if (swiotlb)
  161.41  		swiotlb_init_with_default_size(64 * (1<<20));
  161.42 +	else
  161.43 +		printk(KERN_INFO "Software IO TLB disabled\n");
  161.44  }
  161.45  
  161.46  static void
  161.47 @@ -424,13 +427,6 @@ swiotlb_map_single(struct device *hwdev,
  161.48  	}
  161.49  
  161.50  	dev_addr = virt_to_bus(map);
  161.51 -
  161.52 -	/*
  161.53 -	 * Ensure that the address returned is DMA'ble
  161.54 -	 */
  161.55 -	if (address_needs_mapping(hwdev, dev_addr))
  161.56 -		panic("map_single: bounce buffer is not DMA'ble");
  161.57 -
  161.58  	return dev_addr;
  161.59  }
  161.60  
  161.61 @@ -632,7 +628,7 @@ swiotlb_dma_mapping_error(dma_addr_t dma
  161.62  int
  161.63  swiotlb_dma_supported (struct device *hwdev, u64 mask)
  161.64  {
  161.65 -	return (mask >= 0xffffffffUL);
  161.66 +	return (mask >= (iotlb_bus_end - 1));
  161.67  }
  161.68  
  161.69  EXPORT_SYMBOL(swiotlb_init);
   162.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Thu Sep 08 09:18:40 2005 -0600
   162.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Fri Sep 09 10:30:54 2005 -0600
   162.3 @@ -445,7 +445,7 @@ int do_settimeofday(struct timespec *tv)
   162.4  	sec = tv->tv_sec;
   162.5  	__normalize_time(&sec, &nsec);
   162.6  
   162.7 -	if ((xen_start_info.flags & SIF_INITDOMAIN) &&
   162.8 +	if ((xen_start_info->flags & SIF_INITDOMAIN) &&
   162.9  	    !independent_wallclock) {
  162.10  		op.cmd = DOM0_SETTIME;
  162.11  		op.u.settime.secs        = sec;
  162.12 @@ -476,7 +476,7 @@ static int set_rtc_mmss(unsigned long no
  162.13  
  162.14  	WARN_ON(irqs_disabled());
  162.15  
  162.16 -	if (!(xen_start_info.flags & SIF_INITDOMAIN))
  162.17 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
  162.18  		return 0;
  162.19  
  162.20  	/* gets recalled with irq locally disabled */
   163.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Thu Sep 08 09:18:40 2005 -0600
   163.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Fri Sep 09 10:30:54 2005 -0600
   163.3 @@ -449,10 +449,10 @@ DO_ERROR(10, SIGSEGV, "invalid TSS", inv
   163.4  DO_ERROR(11, SIGBUS,  "segment not present", segment_not_present)
   163.5  DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
   163.6  DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
   163.7 -DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
   163.8  #ifdef CONFIG_X86_MCE
   163.9  DO_ERROR(18, SIGBUS, "machine check", machine_check)
  163.10  #endif
  163.11 +DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
  163.12  
  163.13  fastcall void do_general_protection(struct pt_regs * regs, long error_code)
  163.14  {
   167.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c	Thu Sep 08 09:18:40 2005 -0600
   167.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c	Fri Sep 09 10:30:54 2005 -0600
   167.3 @@ -588,7 +588,15 @@ vmalloc_fault:
   167.4  		pmd_k = pmd_offset(pud_k, address);
   167.5  		if (!pmd_present(*pmd_k))
   167.6  			goto no_context;
   167.7 +#ifndef CONFIG_XEN
   167.8  		set_pmd(pmd, *pmd_k);
   167.9 +#else
  167.10 +		/*
  167.11 +		 * When running on Xen we must launder *pmd_k through
  167.12 +		 * pmd_val() to ensure that _PAGE_PRESENT is correctly set.
  167.13 +		 */
  167.14 +		set_pmd(pmd, __pmd(pmd_val(*pmd_k)));
  167.15 +#endif
  167.16  
  167.17  		pte_k = pte_offset_kernel(pmd_k, address);
  167.18  		if (!pte_present(*pte_k))
   169.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Sep 08 09:18:40 2005 -0600
   169.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Fri Sep 09 10:30:54 2005 -0600
   169.3 @@ -35,6 +35,7 @@
   169.4  #include <asm/pgtable.h>
   169.5  #include <asm-xen/hypervisor.h>
   169.6  #include <asm-xen/balloon.h>
   169.7 +#include <asm-xen/xen-public/memory.h>
   169.8  #include <linux/module.h>
   169.9  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  169.10  #include <linux/percpu.h>
  169.11 @@ -105,7 +106,7 @@ void xen_l4_entry_update(pgd_t *ptr, pgd
  169.12  void xen_machphys_update(unsigned long mfn, unsigned long pfn)
  169.13  {
  169.14  	mmu_update_t u;
  169.15 -	u.ptr = (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
  169.16 +	u.ptr = ((unsigned long long)mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
  169.17  	u.val = pfn;
  169.18  	BUG_ON(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) < 0);
  169.19  }
  169.20 @@ -320,6 +321,12 @@ void xen_create_contiguous_region(unsign
  169.21  	pmd_t         *pmd;
  169.22  	pte_t         *pte;
  169.23  	unsigned long  mfn, i, flags;
  169.24 +	struct xen_memory_reservation reservation = {
  169.25 +		.extent_start = &mfn,
  169.26 +		.nr_extents   = 1,
  169.27 +		.extent_order = 0,
  169.28 +		.domid        = DOMID_SELF
  169.29 +	};
  169.30  
  169.31  	scrub_pages(vstart, 1 << order);
  169.32  
  169.33 @@ -336,13 +343,15 @@ void xen_create_contiguous_region(unsign
  169.34  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
  169.35  		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
  169.36  			INVALID_P2M_ENTRY;
  169.37 -		BUG_ON(HYPERVISOR_dom_mem_op(
  169.38 -			MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
  169.39 +		BUG_ON(HYPERVISOR_memory_op(
  169.40 +			XENMEM_decrease_reservation, &reservation) != 1);
  169.41  	}
  169.42  
  169.43  	/* 2. Get a new contiguous memory extent. */
  169.44 -	BUG_ON(HYPERVISOR_dom_mem_op(
  169.45 -		MEMOP_increase_reservation, &mfn, 1, order | (32<<8)) != 1);
  169.46 +	reservation.extent_order = order;
  169.47 +	reservation.address_bits = 31; /* aacraid limitation */
  169.48 +	BUG_ON(HYPERVISOR_memory_op(
  169.49 +		XENMEM_increase_reservation, &reservation) != 1);
  169.50  
  169.51  	/* 3. Map the new extent in place of old pages. */
  169.52  	for (i = 0; i < (1<<order); i++) {
  169.53 @@ -367,6 +376,12 @@ void xen_destroy_contiguous_region(unsig
  169.54  	pmd_t         *pmd;
  169.55  	pte_t         *pte;
  169.56  	unsigned long  mfn, i, flags;
  169.57 +	struct xen_memory_reservation reservation = {
  169.58 +		.extent_start = &mfn,
  169.59 +		.nr_extents   = 1,
  169.60 +		.extent_order = 0,
  169.61 +		.domid        = DOMID_SELF
  169.62 +	};
  169.63  
  169.64  	scrub_pages(vstart, 1 << order);
  169.65  
  169.66 @@ -385,14 +400,14 @@ void xen_destroy_contiguous_region(unsig
  169.67  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
  169.68  		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
  169.69  			INVALID_P2M_ENTRY;
  169.70 -		BUG_ON(HYPERVISOR_dom_mem_op(
  169.71 -			MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
  169.72 +		BUG_ON(HYPERVISOR_memory_op(
  169.73 +			XENMEM_decrease_reservation, &reservation) != 1);
  169.74  	}
  169.75  
  169.76  	/* 2. Map new pages in place of old pages. */
  169.77  	for (i = 0; i < (1<<order); i++) {
  169.78 -		BUG_ON(HYPERVISOR_dom_mem_op(
  169.79 -			MEMOP_increase_reservation, &mfn, 1, 0) != 1);
  169.80 +		BUG_ON(HYPERVISOR_memory_op(
  169.81 +			XENMEM_increase_reservation, &reservation) != 1);
  169.82  		BUG_ON(HYPERVISOR_update_va_mapping(
  169.83  			vstart + (i*PAGE_SIZE),
  169.84  			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
   170.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Thu Sep 08 09:18:40 2005 -0600
   170.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Fri Sep 09 10:30:54 2005 -0600
   170.3 @@ -159,7 +159,7 @@ static void __init kernel_physical_mappi
   170.4  	pte_t *pte;
   170.5  	int pgd_idx, pmd_idx, pte_ofs;
   170.6  
   170.7 -	unsigned long max_ram_pfn = xen_start_info.nr_pages;
   170.8 +	unsigned long max_ram_pfn = xen_start_info->nr_pages;
   170.9  	if (max_ram_pfn > max_low_pfn)
  170.10  		max_ram_pfn = max_low_pfn;
  170.11  
  170.12 @@ -219,6 +219,8 @@ static void __init kernel_physical_mappi
  170.13  	}
  170.14  }
  170.15  
  170.16 +#ifndef CONFIG_XEN
  170.17 +
  170.18  static inline int page_kills_ppro(unsigned long pagenr)
  170.19  {
  170.20  	if (pagenr >= 0x70000 && pagenr <= 0x7003F)
  170.21 @@ -266,6 +268,13 @@ static inline int page_is_ram(unsigned l
  170.22  	return 0;
  170.23  }
  170.24  
  170.25 +#else /* CONFIG_XEN */
  170.26 +
  170.27 +#define page_kills_ppro(p)	0
  170.28 +#define page_is_ram(p)		1
  170.29 +
  170.30 +#endif
  170.31 +
  170.32  #ifdef CONFIG_HIGHMEM
  170.33  pte_t *kmap_pte;
  170.34  pgprot_t kmap_prot;
  170.35 @@ -308,7 +317,7 @@ void __init one_highpage_init(struct pag
  170.36  		ClearPageReserved(page);
  170.37  		set_bit(PG_highmem, &page->flags);
  170.38  		set_page_count(page, 1);
  170.39 -		if (pfn < xen_start_info.nr_pages)
  170.40 +		if (pfn < xen_start_info->nr_pages)
  170.41  			__free_page(page);
  170.42  		totalhigh_pages++;
  170.43  	} else
  170.44 @@ -347,7 +356,7 @@ pgd_t *swapper_pg_dir;
  170.45  static void __init pagetable_init (void)
  170.46  {
  170.47  	unsigned long vaddr;
  170.48 -	pgd_t *pgd_base = (pgd_t *)xen_start_info.pt_base;
  170.49 +	pgd_t *pgd_base = (pgd_t *)xen_start_info->pt_base;
  170.50  	int i;
  170.51  
  170.52  	swapper_pg_dir = pgd_base;
  170.53 @@ -526,14 +535,14 @@ void __init paging_init(void)
  170.54  	kmap_init();
  170.55  
  170.56  	/* Switch to the real shared_info page, and clear the dummy page. */
  170.57 -	set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
  170.58 +	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
  170.59  	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
  170.60  	memset(empty_zero_page, 0, sizeof(empty_zero_page));
  170.61  
  170.62  #ifdef CONFIG_XEN_PHYSDEV_ACCESS
  170.63  	/* Setup mapping of lower 1st MB */
  170.64  	for (i = 0; i < NR_FIX_ISAMAPS; i++)
  170.65 -		if (xen_start_info.flags & SIF_PRIVILEGED)
  170.66 +		if (xen_start_info->flags & SIF_PRIVILEGED)
  170.67  			set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
  170.68  		else
  170.69  			__set_fixmap(FIX_ISAMAP_BEGIN - i,
  170.70 @@ -630,7 +639,7 @@ void __init mem_init(void)
  170.71  	/* this will put all low memory onto the freelists */
  170.72  	totalram_pages += free_all_bootmem();
  170.73  	/* XEN: init and count low-mem pages outside initial allocation. */
  170.74 -	for (pfn = xen_start_info.nr_pages; pfn < max_low_pfn; pfn++) {
  170.75 +	for (pfn = xen_start_info->nr_pages; pfn < max_low_pfn; pfn++) {
  170.76  		ClearPageReserved(&mem_map[pfn]);
  170.77  		set_page_count(&mem_map[pfn], 1);
  170.78  		totalram_pages++;
   171.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Thu Sep 08 09:18:40 2005 -0600
   171.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Sep 09 10:30:54 2005 -0600
   171.3 @@ -19,37 +19,125 @@
   171.4  #include <asm/pgtable.h>
   171.5  #include <asm/pgalloc.h>
   171.6  
   171.7 -#ifndef CONFIG_XEN_PHYSDEV_ACCESS
   171.8 +#define ISA_START_ADDRESS	0x0
   171.9 +#define ISA_END_ADDRESS		0x100000
  171.10  
  171.11 -void * __ioremap(unsigned long phys_addr, unsigned long size,
  171.12 -		 unsigned long flags)
  171.13 +#if 0 /* not PAE safe */
  171.14 +/* These hacky macros avoid phys->machine translations. */
  171.15 +#define __direct_pte(x) ((pte_t) { (x) } )
  171.16 +#define __direct_mk_pte(page_nr,pgprot) \
  171.17 +  __direct_pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
  171.18 +#define direct_mk_pte_phys(physpage, pgprot) \
  171.19 +  __direct_mk_pte((physpage) >> PAGE_SHIFT, pgprot)
  171.20 +#endif
  171.21 +
  171.22 +static int direct_remap_area_pte_fn(pte_t *pte, 
  171.23 +				    struct page *pte_page,
  171.24 +				    unsigned long address, 
  171.25 +				    void *data)
  171.26  {
  171.27 -	return NULL;
  171.28 -}
  171.29 +	mmu_update_t **v = (mmu_update_t **)data;
  171.30  
  171.31 -void *ioremap_nocache (unsigned long phys_addr, unsigned long size)
  171.32 -{
  171.33 -	return NULL;
  171.34 +	(*v)->ptr = ((u64)pfn_to_mfn(page_to_pfn(pte_page)) <<
  171.35 +		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
  171.36 +	(*v)++;
  171.37 +
  171.38 +	return 0;
  171.39  }
  171.40  
  171.41 -void iounmap(volatile void __iomem *addr)
  171.42 +int direct_remap_pfn_range(struct mm_struct *mm,
  171.43 +			    unsigned long address, 
  171.44 +			    unsigned long mfn,
  171.45 +			    unsigned long size, 
  171.46 +			    pgprot_t prot,
  171.47 +			    domid_t  domid)
  171.48  {
  171.49 +	int i;
  171.50 +	unsigned long start_address;
  171.51 +#define MAX_DIRECTMAP_MMU_QUEUE 130
  171.52 +	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *v = u, *w = u;
  171.53 +
  171.54 +	start_address = address;
  171.55 +
  171.56 +	flush_cache_all();
  171.57 +
  171.58 +	for (i = 0; i < size; i += PAGE_SIZE) {
  171.59 +		if ((v - u) == MAX_DIRECTMAP_MMU_QUEUE) {
  171.60 +			/* Fill in the PTE pointers. */
  171.61 +			generic_page_range(mm, start_address, 
  171.62 +					   address - start_address,
  171.63 +					   direct_remap_area_pte_fn, &w);
  171.64 +			w = u;
  171.65 +			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
  171.66 +				return -EFAULT;
  171.67 +			v = u;
  171.68 +			start_address = address;
  171.69 +		}
  171.70 +
  171.71 +		/*
  171.72 +		 * Fill in the machine address: PTE ptr is done later by
  171.73 +		 * __direct_remap_area_pages(). 
  171.74 +		 */
  171.75 +		v->val = pte_val_ma(pfn_pte_ma(mfn, prot));
  171.76 +
  171.77 +		mfn++;
  171.78 +		address += PAGE_SIZE; 
  171.79 +		v++;
  171.80 +	}
  171.81 +
  171.82 +	if (v != u) {
  171.83 +		/* get the ptep's filled in */
  171.84 +		generic_page_range(mm, start_address, address - start_address,
  171.85 +				   direct_remap_area_pte_fn, &w);
  171.86 +		if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0))
  171.87 +			return -EFAULT;
  171.88 +	}
  171.89 +
  171.90 +	flush_tlb_all();
  171.91 +
  171.92 +	return 0;
  171.93  }
  171.94  
  171.95 -#ifdef __i386__
  171.96 +EXPORT_SYMBOL(direct_remap_pfn_range);
  171.97 +
  171.98  
  171.99 -void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
 171.100 +/* FIXME: This is horribly broken on PAE */ 
 171.101 +static int lookup_pte_fn(
 171.102 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
 171.103  {
 171.104 -	return NULL;
 171.105 +	unsigned long *ptep = (unsigned long *)data;
 171.106 +	if (ptep)
 171.107 +		*ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
 171.108 +			 PAGE_SHIFT) |
 171.109 +			((unsigned long)pte & ~PAGE_MASK);
 171.110 +	return 0;
 171.111  }
 171.112  
 171.113 -void __init bt_iounmap(void *addr, unsigned long size)
 171.114 +int create_lookup_pte_addr(struct mm_struct *mm, 
 171.115 +			   unsigned long address,
 171.116 +			   unsigned long *ptep)
 171.117  {
 171.118 +	return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
 171.119  }
 171.120  
 171.121 -#endif /* __i386__ */
 171.122 +EXPORT_SYMBOL(create_lookup_pte_addr);
 171.123 +
 171.124 +static int noop_fn(
 171.125 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
 171.126 +{
 171.127 +	return 0;
 171.128 +}
 171.129  
 171.130 -#else
 171.131 +int touch_pte_range(struct mm_struct *mm,
 171.132 +		    unsigned long address,
 171.133 +		    unsigned long size)
 171.134 +{
 171.135 +	return generic_page_range(mm, address, size, noop_fn, NULL);
 171.136 +} 
 171.137 +
 171.138 +EXPORT_SYMBOL(touch_pte_range);
 171.139 +
 171.140 +#ifdef CONFIG_XEN_PHYSDEV_ACCESS
 171.141  
 171.142  /*
 171.143   * Does @address reside within a non-highmem page that is local to this virtual
 171.144 @@ -90,13 +178,12 @@ void __iomem * __ioremap(unsigned long p
 171.145  	if (!size || last_addr < phys_addr)
 171.146  		return NULL;
 171.147  
 171.148 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 171.149  	/*
 171.150  	 * Don't remap the low PCI/ISA area, it's always mapped..
 171.151  	 */
 171.152 -	if (phys_addr >= 0x0 && last_addr < 0x100000)
 171.153 -		return isa_bus_to_virt(phys_addr);
 171.154 -#endif
 171.155 +	if (xen_start_info->flags & SIF_PRIVILEGED &&
 171.156 +	    phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
 171.157 +		return (void __iomem *) isa_bus_to_virt(phys_addr);
 171.158  
 171.159  	/*
 171.160  	 * Don't allow anybody to remap normal RAM that we're using..
 171.161 @@ -134,7 +221,7 @@ void __iomem * __ioremap(unsigned long p
 171.162  #ifdef __x86_64__
 171.163  	flags |= _PAGE_USER;
 171.164  #endif
 171.165 -	if (direct_remap_area_pages(&init_mm, (unsigned long) addr, phys_addr,
 171.166 +	if (direct_remap_pfn_range(&init_mm, (unsigned long) addr, phys_addr>>PAGE_SHIFT,
 171.167  				    size, __pgprot(flags), domid)) {
 171.168  		vunmap((void __force *) addr);
 171.169  		return NULL;
 171.170 @@ -203,24 +290,32 @@ void iounmap(volatile void __iomem *addr
 171.171  {
 171.172  	struct vm_struct *p;
 171.173  	if ((void __force *) addr <= high_memory) 
 171.174 -		return; 
 171.175 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 171.176 +		return;
 171.177 +
 171.178 +	/*
 171.179 +	 * __ioremap special-cases the PCI/ISA range by not instantiating a
 171.180 +	 * vm_area and by simply returning an address into the kernel mapping
 171.181 +	 * of ISA space.   So handle that here.
 171.182 +	 */
 171.183  	if ((unsigned long) addr >= fix_to_virt(FIX_ISAMAP_BEGIN))
 171.184  		return;
 171.185 -#endif
 171.186 -	p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
 171.187 +
 171.188 +	write_lock(&vmlist_lock);
 171.189 +	p = __remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
 171.190  	if (!p) { 
 171.191 -		printk("__iounmap: bad address %p\n", addr);
 171.192 -		return;
 171.193 +		printk("iounmap: bad address %p\n", addr);
 171.194 +		goto out_unlock;
 171.195  	}
 171.196  
 171.197  	if ((p->flags >> 20) && is_local_lowmem(p->phys_addr)) {
 171.198  		/* p->size includes the guard page, but cpa doesn't like that */
 171.199  		change_page_attr(virt_to_page(bus_to_virt(p->phys_addr)),
 171.200  				 (p->size - PAGE_SIZE) >> PAGE_SHIFT,
 171.201 -				 PAGE_KERNEL); 				 
 171.202 +				 PAGE_KERNEL);
 171.203  		global_flush_tlb();
 171.204  	} 
 171.205 +out_unlock:
 171.206 +	write_unlock(&vmlist_lock);
 171.207  	kfree(p); 
 171.208  }
 171.209  
 171.210 @@ -237,13 +332,12 @@ void __init *bt_ioremap(unsigned long ph
 171.211  	if (!size || last_addr < phys_addr)
 171.212  		return NULL;
 171.213  
 171.214 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 171.215  	/*
 171.216  	 * Don't remap the low PCI/ISA area, it's always mapped..
 171.217  	 */
 171.218 -	if (phys_addr >= 0x0 && last_addr < 0x100000)
 171.219 +	if (xen_start_info->flags & SIF_PRIVILEGED &&
 171.220 +	    phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
 171.221  		return isa_bus_to_virt(phys_addr);
 171.222 -#endif
 171.223  
 171.224  	/*
 171.225  	 * Mappings have to be page-aligned
 171.226 @@ -282,10 +376,8 @@ void __init bt_iounmap(void *addr, unsig
 171.227  	virt_addr = (unsigned long)addr;
 171.228  	if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN))
 171.229  		return;
 171.230 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 171.231  	if (virt_addr >= fix_to_virt(FIX_ISAMAP_BEGIN))
 171.232  		return;
 171.233 -#endif
 171.234  	offset = virt_addr & ~PAGE_MASK;
 171.235  	nrpages = PAGE_ALIGN(offset + size - 1) >> PAGE_SHIFT;
 171.236  
 171.237 @@ -299,119 +391,37 @@ void __init bt_iounmap(void *addr, unsig
 171.238  
 171.239  #endif /* __i386__ */
 171.240  
 171.241 -#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
 171.242 -
 171.243 -/* These hacky macros avoid phys->machine translations. */
 171.244 -#define __direct_pte(x) ((pte_t) { (x) } )
 171.245 -#define __direct_mk_pte(page_nr,pgprot) \
 171.246 -  __direct_pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
 171.247 -#define direct_mk_pte_phys(physpage, pgprot) \
 171.248 -  __direct_mk_pte((physpage) >> PAGE_SHIFT, pgprot)
 171.249 -
 171.250 +#else /* CONFIG_XEN_PHYSDEV_ACCESS */
 171.251  
 171.252 -static int direct_remap_area_pte_fn(pte_t *pte, 
 171.253 -				    struct page *pte_page,
 171.254 -				    unsigned long address, 
 171.255 -				    void *data)
 171.256 +void __iomem * __ioremap(unsigned long phys_addr, unsigned long size,
 171.257 +			 unsigned long flags)
 171.258  {
 171.259 -	mmu_update_t **v = (mmu_update_t **)data;
 171.260 +	return NULL;
 171.261 +}
 171.262  
 171.263 -	(*v)->ptr = ((maddr_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
 171.264 -		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
 171.265 -	(*v)++;
 171.266 -
 171.267 -	return 0;
 171.268 +void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
 171.269 +{
 171.270 +	return NULL;
 171.271  }
 171.272  
 171.273 -int direct_remap_area_pages(struct mm_struct *mm,
 171.274 -			    unsigned long address, 
 171.275 -			    unsigned long machine_addr,
 171.276 -			    unsigned long size, 
 171.277 -			    pgprot_t prot,
 171.278 -			    domid_t  domid)
 171.279 +void iounmap(volatile void __iomem *addr)
 171.280  {
 171.281 -	int i;
 171.282 -	unsigned long start_address;
 171.283 -#define MAX_DIRECTMAP_MMU_QUEUE 130
 171.284 -	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *v = u, *w = u;
 171.285 -
 171.286 -	start_address = address;
 171.287 -
 171.288 -	flush_cache_all();
 171.289 -
 171.290 -	for (i = 0; i < size; i += PAGE_SIZE) {
 171.291 -		if ((v - u) == MAX_DIRECTMAP_MMU_QUEUE) {
 171.292 -			/* Fill in the PTE pointers. */
 171.293 -			generic_page_range(mm, start_address, 
 171.294 -					   address - start_address,
 171.295 -					   direct_remap_area_pte_fn, &w);
 171.296 -			w = u;
 171.297 -			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
 171.298 -				return -EFAULT;
 171.299 -			v = u;
 171.300 -			start_address = address;
 171.301 -		}
 171.302 -
 171.303 -		/*
 171.304 -		 * Fill in the machine address: PTE ptr is done later by
 171.305 -		 * __direct_remap_area_pages(). 
 171.306 -		 */
 171.307 -		v->val = pte_val_ma(pfn_pte_ma(machine_addr >> PAGE_SHIFT, prot));
 171.308 -
 171.309 -		machine_addr += PAGE_SIZE;
 171.310 -		address += PAGE_SIZE; 
 171.311 -		v++;
 171.312 -	}
 171.313 -
 171.314 -	if (v != u) {
 171.315 -		/* get the ptep's filled in */
 171.316 -		generic_page_range(mm, start_address, address - start_address,
 171.317 -				   direct_remap_area_pte_fn, &w);
 171.318 -		if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0))
 171.319 -			return -EFAULT;
 171.320 -	}
 171.321 -
 171.322 -	flush_tlb_all();
 171.323 -
 171.324 -	return 0;
 171.325  }
 171.326  
 171.327 -EXPORT_SYMBOL(direct_remap_area_pages);
 171.328 +#ifdef __i386__
 171.329  
 171.330 -static int lookup_pte_fn(
 171.331 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
 171.332 +void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
 171.333  {
 171.334 -	unsigned long *ptep = (unsigned long *)data;
 171.335 -	if (ptep)
 171.336 -		*ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
 171.337 -			 PAGE_SHIFT) |
 171.338 -			((unsigned long)pte & ~PAGE_MASK);
 171.339 -	return 0;
 171.340 +	return NULL;
 171.341  }
 171.342  
 171.343 -int create_lookup_pte_addr(struct mm_struct *mm, 
 171.344 -			   unsigned long address,
 171.345 -			   unsigned long *ptep)
 171.346 +void __init bt_iounmap(void *addr, unsigned long size)
 171.347  {
 171.348 -	return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
 171.349  }
 171.350  
 171.351 -EXPORT_SYMBOL(create_lookup_pte_addr);
 171.352 -
 171.353 -static int noop_fn(
 171.354 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
 171.355 -{
 171.356 -	return 0;
 171.357 -}
 171.358 +#endif /* __i386__ */
 171.359  
 171.360 -int touch_pte_range(struct mm_struct *mm,
 171.361 -		    unsigned long address,
 171.362 -		    unsigned long size)
 171.363 -{
 171.364 -	return generic_page_range(mm, address, size, noop_fn, NULL);
 171.365 -} 
 171.366 -
 171.367 -EXPORT_SYMBOL(touch_pte_range);
 171.368 +#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
 171.369  
 171.370  /*
 171.371   * Local variables:
   173.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile	Thu Sep 08 09:18:40 2005 -0600
   173.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile	Fri Sep 09 10:30:54 2005 -0600
   173.3 @@ -4,7 +4,7 @@ CFLAGS	+= -Iarch/$(XENARCH)/pci
   173.4  
   173.5  c-obj-y				:= i386.o
   173.6  
   173.7 -c-obj-$(CONFIG_PCI_BIOS)		+= pcbios.o
   173.8 +#c-obj-$(CONFIG_PCI_BIOS)		+= pcbios.o
   173.9  c-obj-$(CONFIG_PCI_MMCONFIG)	+= mmconfig.o
  173.10  c-obj-$(CONFIG_PCI_DIRECT)	+= direct.o
  173.11  
   175.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/Makefile	Thu Sep 08 09:18:40 2005 -0600
   175.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/Makefile	Fri Sep 09 10:30:54 2005 -0600
   175.3 @@ -11,7 +11,7 @@ CPPFLAGS_vmlinux.lds += -U$(XENARCH)
   175.4  
   175.5  extra-y += vmlinux.lds
   175.6  
   175.7 -obj-y   := ctrl_if.o evtchn.o fixup.o reboot.o gnttab.o devmem.o
   175.8 +obj-y   := evtchn.o fixup.o reboot.o gnttab.o devmem.o
   175.9  
  175.10  obj-$(CONFIG_PROC_FS) += xen_proc.o
  175.11  obj-$(CONFIG_NET)     += skbuff.o
   176.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c	Thu Sep 08 09:18:40 2005 -0600
   176.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   176.3 @@ -1,569 +0,0 @@
   176.4 -/******************************************************************************
   176.5 - * ctrl_if.c
   176.6 - * 
   176.7 - * Management functions for special interface to the domain controller.
   176.8 - * 
   176.9 - * Copyright (c) 2004, K A Fraser
  176.10 - * 
  176.11 - * This file may be distributed separately from the Linux kernel, or
  176.12 - * incorporated into other software packages, subject to the following license:
  176.13 - * 
  176.14 - * Permission is hereby granted, free of charge, to any person obtaining a copy
  176.15 - * of this source file (the "Software"), to deal in the Software without
  176.16 - * restriction, including without limitation the rights to use, copy, modify,
  176.17 - * merge, publish, distribute, sublicense, and/or sell copies of the Software,
  176.18 - * and to permit persons to whom the Software is furnished to do so, subject to
  176.19 - * the following conditions:
  176.20 - * 
  176.21 - * The above copyright notice and this permission notice shall be included in
  176.22 - * all copies or substantial portions of the Software.
  176.23 - * 
  176.24 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  176.25 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  176.26 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  176.27 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  176.28 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  176.29 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  176.30 - * IN THE SOFTWARE.
  176.31 - */
  176.32 -
  176.33 -#include <linux/config.h>
  176.34 -#include <linux/kernel.h>
  176.35 -#include <linux/sched.h>
  176.36 -#include <linux/slab.h>
  176.37 -#include <linux/string.h>
  176.38 -#include <linux/errno.h>
  176.39 -#include <linux/irq.h>
  176.40 -#include <linux/interrupt.h>
  176.41 -#include <linux/module.h>
  176.42 -#include <asm-xen/ctrl_if.h>
  176.43 -#include <asm-xen/evtchn.h>
  176.44 -
  176.45 -#if 0
  176.46 -#define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
  176.47 -                           __FILE__ , __LINE__ , ## _a )
  176.48 -#else
  176.49 -#define DPRINTK(_f, _a...) ((void)0)
  176.50 -#endif
  176.51 -
  176.52 -/*
  176.53 - * Extra ring macros to sync a consumer index up to the public producer index. 
  176.54 - * Generally UNSAFE, but we use it for recovery and shutdown in some cases.
  176.55 - */
  176.56 -#define RING_DROP_PENDING_REQUESTS(_r)                                  \
  176.57 -    do {                                                                \
  176.58 -        (_r)->req_cons = (_r)->sring->req_prod;                         \
  176.59 -    } while (0)
  176.60 -#define RING_DROP_PENDING_RESPONSES(_r)                                 \
  176.61 -    do {                                                                \
  176.62 -        (_r)->rsp_cons = (_r)->sring->rsp_prod;                         \
  176.63 -    } while (0)
  176.64 -
  176.65 -/*
  176.66 - * Only used by initial domain which must create its own control-interface
  176.67 - * event channel. This value is picked up by the user-space domain controller
  176.68 - * via an ioctl.
  176.69 - */
  176.70 -int initdom_ctrlif_domcontroller_port = -1;
  176.71 -
  176.72 -static int        ctrl_if_evtchn;
  176.73 -static int        ctrl_if_irq;
  176.74 -static spinlock_t ctrl_if_lock;
  176.75 -
  176.76 -static struct irqaction ctrl_if_irq_action;
  176.77 -
  176.78 -static ctrl_front_ring_t ctrl_if_tx_ring;
  176.79 -static ctrl_back_ring_t  ctrl_if_rx_ring;
  176.80 -
  176.81 -/* Incoming message requests. */
  176.82 -    /* Primary message type -> message handler. */
  176.83 -static ctrl_msg_handler_t ctrl_if_rxmsg_handler[256];
  176.84 -    /* Primary message type -> callback in process context? */
  176.85 -static unsigned long ctrl_if_rxmsg_blocking_context[256/sizeof(unsigned long)];
  176.86 -    /* Is it late enough during bootstrap to use schedule_task()? */
  176.87 -static int safe_to_schedule_task;
  176.88 -    /* Queue up messages to be handled in process context. */
  176.89 -static ctrl_msg_t ctrl_if_rxmsg_deferred[CONTROL_RING_SIZE];
  176.90 -static CONTROL_RING_IDX ctrl_if_rxmsg_deferred_prod;
  176.91 -static CONTROL_RING_IDX ctrl_if_rxmsg_deferred_cons;
  176.92 -
  176.93 -/* Incoming message responses: message identifier -> message handler/id. */
  176.94 -static struct {
  176.95 -    ctrl_msg_handler_t fn;
  176.96 -    unsigned long      id;
  176.97 -} ctrl_if_txmsg_id_mapping[CONTROL_RING_SIZE];
  176.98 -
  176.99 -/* For received messages that must be deferred to process context. */
 176.100 -static void __ctrl_if_rxmsg_deferred(void *unused);
 176.101 -static DECLARE_WORK(ctrl_if_rxmsg_deferred_work,
 176.102 -                    __ctrl_if_rxmsg_deferred,
 176.103 -                    NULL);
 176.104 -
 176.105 -/* Deferred callbacks for people waiting for space in the transmit ring. */
 176.106 -static DECLARE_TASK_QUEUE(ctrl_if_tx_tq);
 176.107 -
 176.108 -static DECLARE_WAIT_QUEUE_HEAD(ctrl_if_tx_wait);
 176.109 -static void __ctrl_if_tx_tasklet(unsigned long data);
 176.110 -static DECLARE_TASKLET(ctrl_if_tx_tasklet, __ctrl_if_tx_tasklet, 0);
 176.111 -
 176.112 -static void __ctrl_if_rx_tasklet(unsigned long data);
 176.113 -static DECLARE_TASKLET(ctrl_if_rx_tasklet, __ctrl_if_rx_tasklet, 0);
 176.114 -
 176.115 -#define get_ctrl_if() ((control_if_t *)((char *)HYPERVISOR_shared_info + 2048))
 176.116 -
 176.117 -static void ctrl_if_notify_controller(void)
 176.118 -{
 176.119 -    notify_via_evtchn(ctrl_if_evtchn);
 176.120 -}
 176.121 -
 176.122 -static void ctrl_if_rxmsg_default_handler(ctrl_msg_t *msg, unsigned long id)
 176.123 -{
 176.124 -    msg->length = 0;
 176.125 -    ctrl_if_send_response(msg);
 176.126 -}
 176.127 -
 176.128 -static void __ctrl_if_tx_tasklet(unsigned long data)
 176.129 -{
 176.130 -    ctrl_msg_t *msg;
 176.131 -    int         was_full = RING_FULL(&ctrl_if_tx_ring);
 176.132 -    RING_IDX    i, rp;
 176.133 -
 176.134 -    i  = ctrl_if_tx_ring.rsp_cons;
 176.135 -    rp = ctrl_if_tx_ring.sring->rsp_prod;
 176.136 -    rmb(); /* Ensure we see all requests up to 'rp'. */
 176.137 -
 176.138 -    for ( ; i != rp; i++ )
 176.139 -    {
 176.140 -        msg = RING_GET_RESPONSE(&ctrl_if_tx_ring, i);
 176.141 -        
 176.142 -        DPRINTK("Rx-Rsp %u/%u :: %d/%d\n", i-1,
 176.143 -                ctrl_if_tx_ring.sring->rsp_prod,
 176.144 -                msg->type, msg->subtype);
 176.145 -
 176.146 -        /* Execute the callback handler, if one was specified. */
 176.147 -        if ( msg->id != 0xFF )
 176.148 -        {
 176.149 -            (*ctrl_if_txmsg_id_mapping[msg->id].fn)(
 176.150 -                msg, ctrl_if_txmsg_id_mapping[msg->id].id);
 176.151 -            smp_mb(); /* Execute, /then/ free. */
 176.152 -            ctrl_if_txmsg_id_mapping[msg->id].fn = NULL;
 176.153 -        }
 176.154 -    }
 176.155 -
 176.156 -    /*
 176.157 -     * Step over messages in the ring /after/ finishing reading them. As soon 
 176.158 -     * as the index is updated then the message may get blown away.
 176.159 -     */
 176.160 -    smp_mb();
 176.161 -    ctrl_if_tx_ring.rsp_cons = i;
 176.162 -            
 176.163 -    if ( was_full && !RING_FULL(&ctrl_if_tx_ring) )
 176.164 -    {
 176.165 -        wake_up(&ctrl_if_tx_wait);
 176.166 -        run_task_queue(&ctrl_if_tx_tq);
 176.167 -    }
 176.168 -}
 176.169 -
 176.170 -static void __ctrl_if_rxmsg_deferred(void *unused)
 176.171 -{
 176.172 -    ctrl_msg_t *msg;
 176.173 -    CONTROL_RING_IDX dp;
 176.174 -
 176.175 -    dp = ctrl_if_rxmsg_deferred_prod;
 176.176 -    rmb(); /* Ensure we see all deferred requests up to 'dp'. */
 176.177 -
 176.178 -    while ( ctrl_if_rxmsg_deferred_cons != dp )
 176.179 -    {
 176.180 -        msg = &ctrl_if_rxmsg_deferred[MASK_CONTROL_IDX(
 176.181 -            ctrl_if_rxmsg_deferred_cons++)];
 176.182 -        (*ctrl_if_rxmsg_handler[msg->type])(msg, 0);
 176.183 -    }
 176.184 -}
 176.185 -
 176.186 -static void __ctrl_if_rx_tasklet(unsigned long data)
 176.187 -{
 176.188 -    ctrl_msg_t    msg, *pmsg;
 176.189 -    CONTROL_RING_IDX dp;
 176.190 -    RING_IDX rp, i;
 176.191 -
 176.192 -    i  = ctrl_if_rx_ring.req_cons;
 176.193 -    rp = ctrl_if_rx_ring.sring->req_prod;
 176.194 -    dp = ctrl_if_rxmsg_deferred_prod;
 176.195 -    rmb(); /* Ensure we see all requests up to 'rp'. */
 176.196 - 
 176.197 -    for ( ; i != rp; i++) 
 176.198 -    {
 176.199 -        pmsg = RING_GET_REQUEST(&ctrl_if_rx_ring, i);
 176.200 -        memcpy(&msg, pmsg, offsetof(ctrl_msg_t, msg));
 176.201 -
 176.202 -        DPRINTK("Rx-Req %u/%u :: %d/%d\n", i-1,
 176.203 -                ctrl_if_rx_ring.sring->req_prod,
 176.204 -                msg.type, msg.subtype);
 176.205 -
 176.206 -        if ( msg.length > sizeof(msg.msg) )
 176.207 -            msg.length = sizeof(msg.msg);
 176.208 -        
 176.209 -        if ( msg.length != 0 )
 176.210 -            memcpy(msg.msg, pmsg->msg, msg.length);
 176.211 -
 176.212 -        if ( test_bit(msg.type, 
 176.213 -                      (unsigned long *)&ctrl_if_rxmsg_blocking_context) )
 176.214 -            memcpy(&ctrl_if_rxmsg_deferred[MASK_CONTROL_IDX(dp++)],
 176.215 -                   &msg, offsetof(ctrl_msg_t, msg) + msg.length);
 176.216 -        else
 176.217 -            (*ctrl_if_rxmsg_handler[msg.type])(&msg, 0);
 176.218 -    }
 176.219 -
 176.220 -    ctrl_if_rx_ring.req_cons = i;
 176.221 -
 176.222 -    if ( dp != ctrl_if_rxmsg_deferred_prod )
 176.223 -    {
 176.224 -        wmb();
 176.225 -        ctrl_if_rxmsg_deferred_prod = dp;
 176.226 -        schedule_work(&ctrl_if_rxmsg_deferred_work);
 176.227 -    }
 176.228 -}
 176.229 -
 176.230 -static irqreturn_t ctrl_if_interrupt(int irq, void *dev_id,
 176.231 -                                     struct pt_regs *regs)
 176.232 -{
 176.233 -    if ( RING_HAS_UNCONSUMED_RESPONSES(&ctrl_if_tx_ring) )
 176.234 -        tasklet_schedule(&ctrl_if_tx_tasklet);
 176.235 -
 176.236 -    if ( RING_HAS_UNCONSUMED_REQUESTS(&ctrl_if_rx_ring) )
 176.237 -        tasklet_schedule(&ctrl_if_rx_tasklet);
 176.238 -
 176.239 -    return IRQ_HANDLED;
 176.240 -}
 176.241 -
 176.242 -int
 176.243 -ctrl_if_send_message_noblock(
 176.244 -    ctrl_msg_t *msg, 
 176.245 -    ctrl_msg_handler_t hnd,
 176.246 -    unsigned long id)
 176.247 -{
 176.248 -    unsigned long flags;
 176.249 -    ctrl_msg_t   *dmsg;
 176.250 -    int           i;
 176.251 -
 176.252 -    spin_lock_irqsave(&ctrl_if_lock, flags);
 176.253 -
 176.254 -    if ( RING_FULL(&ctrl_if_tx_ring) )
 176.255 -    {
 176.256 -        spin_unlock_irqrestore(&ctrl_if_lock, flags);
 176.257 -        return -EAGAIN;
 176.258 -    }
 176.259 -
 176.260 -    msg->id = 0xFF;
 176.261 -    if ( hnd != NULL )
 176.262 -    {
 176.263 -        for ( i = 0; ctrl_if_txmsg_id_mapping[i].fn != NULL; i++ )
 176.264 -            continue;
 176.265 -        ctrl_if_txmsg_id_mapping[i].fn = hnd;
 176.266 -        ctrl_if_txmsg_id_mapping[i].id = id;
 176.267 -        msg->id = i;
 176.268 -    }
 176.269 -
 176.270 -    DPRINTK("Tx-Req %u/%u :: %d/%d\n", 
 176.271 -            ctrl_if_tx_ring.req_prod_pvt, 
 176.272 -            ctrl_if_tx_ring.rsp_cons,
 176.273 -            msg->type, msg->subtype);
 176.274 -
 176.275 -    dmsg = RING_GET_REQUEST(&ctrl_if_tx_ring, 
 176.276 -            ctrl_if_tx_ring.req_prod_pvt);
 176.277 -    memcpy(dmsg, msg, sizeof(*msg));
 176.278 -    ctrl_if_tx_ring.req_prod_pvt++;
 176.279 -    RING_PUSH_REQUESTS(&ctrl_if_tx_ring);
 176.280 -
 176.281 -    spin_unlock_irqrestore(&ctrl_if_lock, flags);
 176.282 -
 176.283 -    ctrl_if_notify_controller();
 176.284 -
 176.285 -    return 0;
 176.286 -}
 176.287 -
 176.288 -int
 176.289 -ctrl_if_send_message_block(
 176.290 -    ctrl_msg_t *msg, 
 176.291 -    ctrl_msg_handler_t hnd, 
 176.292 -    unsigned long id,
 176.293 -    long wait_state)
 176.294 -{
 176.295 -    DECLARE_WAITQUEUE(wait, current);
 176.296 -    int rc;
 176.297 -
 176.298 -    /* Fast path. */
 176.299 -    if ( (rc = ctrl_if_send_message_noblock(msg, hnd, id)) != -EAGAIN )
 176.300 -        return rc;
 176.301 -
 176.302 -    add_wait_queue(&ctrl_if_tx_wait, &wait);
 176.303 -
 176.304 -    for ( ; ; )
 176.305 -    {
 176.306 -        set_current_state(wait_state);
 176.307 -
 176.308 -        if ( (rc = ctrl_if_send_message_noblock(msg, hnd, id)) != -EAGAIN )
 176.309 -            break;
 176.310 -
 176.311 -        rc = -ERESTARTSYS;
 176.312 -        if ( signal_pending(current) && (wait_state == TASK_INTERRUPTIBLE) )
 176.313 -            break;
 176.314 -
 176.315 -        schedule();
 176.316 -    }
 176.317 -
 176.318 -    set_current_state(TASK_RUNNING);
 176.319 -    remove_wait_queue(&ctrl_if_tx_wait, &wait);
 176.320 -
 176.321 -    return rc;
 176.322 -}
 176.323 -
 176.324 -/* Allow a reponse-callback handler to find context of a blocked requester.  */
 176.325 -struct rsp_wait {
 176.326 -    ctrl_msg_t         *msg;  /* Buffer for the response message.            */
 176.327 -    struct task_struct *task; /* The task that is blocked on the response.   */
 176.328 -    int                 done; /* Indicate to 'task' that response is rcv'ed. */
 176.329 -};
 176.330 -
 176.331 -static void __ctrl_if_get_response(ctrl_msg_t *msg, unsigned long id)
 176.332 -{
 176.333 -    struct rsp_wait    *wait = (struct rsp_wait *)id;
 176.334 -    struct task_struct *task = wait->task;
 176.335 -
 176.336 -    memcpy(wait->msg, msg, sizeof(*msg));
 176.337 -    wmb();
 176.338 -    wait->done = 1;
 176.339 -
 176.340 -    wake_up_process(task);
 176.341 -}
 176.342 -
 176.343 -int
 176.344 -ctrl_if_send_message_and_get_response(
 176.345 -    ctrl_msg_t *msg, 
 176.346 -    ctrl_msg_t *rmsg,
 176.347 -    long wait_state)
 176.348 -{
 176.349 -    struct rsp_wait wait;
 176.350 -    int rc;
 176.351 -
 176.352 -    wait.msg  = rmsg;
 176.353 -    wait.done = 0;
 176.354 -    wait.task = current;
 176.355 -
 176.356 -    if ( (rc = ctrl_if_send_message_block(msg, __ctrl_if_get_response,
 176.357 -                                          (unsigned long)&wait,
 176.358 -                                          wait_state)) != 0 )
 176.359 -        return rc;
 176.360 -
 176.361 -    for ( ; ; )
 176.362 -    {
 176.363 -        /* NB. Can't easily support TASK_INTERRUPTIBLE here. */
 176.364 -        set_current_state(TASK_UNINTERRUPTIBLE);
 176.365 -        if ( wait.done )
 176.366 -            break;
 176.367 -        schedule();
 176.368 -    }
 176.369 -
 176.370 -    set_current_state(TASK_RUNNING);
 176.371 -    return 0;
 176.372 -}
 176.373 -
 176.374 -int
 176.375 -ctrl_if_enqueue_space_callback(
 176.376 -    struct tq_struct *task)
 176.377 -{
 176.378 -    /* Fast path. */
 176.379 -    if ( !RING_FULL(&ctrl_if_tx_ring) )
 176.380 -        return 0;
 176.381 -
 176.382 -    (void)queue_task(task, &ctrl_if_tx_tq);
 176.383 -
 176.384 -    /*
 176.385 -     * We may race execution of the task queue, so return re-checked status. If
 176.386 -     * the task is not executed despite the ring being non-full then we will
 176.387 -     * certainly return 'not full'.
 176.388 -     */
 176.389 -    smp_mb();
 176.390 -    return RING_FULL(&ctrl_if_tx_ring);
 176.391 -}
 176.392 -
 176.393 -void
 176.394 -ctrl_if_send_response(
 176.395 -    ctrl_msg_t *msg)
 176.396 -{
 176.397 -    unsigned long flags;
 176.398 -    ctrl_msg_t   *dmsg;
 176.399 -
 176.400 -    /*
 176.401 -     * NB. The response may the original request message, modified in-place.
 176.402 -     * In this situation we may have src==dst, so no copying is required.
 176.403 -     */
 176.404 -    spin_lock_irqsave(&ctrl_if_lock, flags);
 176.405 -
 176.406 -    DPRINTK("Tx-Rsp %u :: %d/%d\n", 
 176.407 -            ctrl_if_rx_ring.rsp_prod_pvt, 
 176.408 -            msg->type, msg->subtype);
 176.409 -
 176.410 -    dmsg = RING_GET_RESPONSE(&ctrl_if_rx_ring, 
 176.411 -            ctrl_if_rx_ring.rsp_prod_pvt);
 176.412 -    if ( dmsg != msg )
 176.413 -        memcpy(dmsg, msg, sizeof(*msg));
 176.414 -
 176.415 -    ctrl_if_rx_ring.rsp_prod_pvt++;
 176.416 -    RING_PUSH_RESPONSES(&ctrl_if_rx_ring);
 176.417 -
 176.418 -    spin_unlock_irqrestore(&ctrl_if_lock, flags);
 176.419 -
 176.420 -    ctrl_if_notify_controller();
 176.421 -}
 176.422 -
 176.423 -int
 176.424 -ctrl_if_register_receiver(
 176.425 -    u8 type, 
 176.426 -    ctrl_msg_handler_t hnd, 
 176.427 -    unsigned int flags)
 176.428 -{
 176.429 -    unsigned long _flags;
 176.430 -    int inuse;
 176.431 -
 176.432 -    spin_lock_irqsave(&ctrl_if_lock, _flags);
 176.433 -
 176.434 -    inuse = (ctrl_if_rxmsg_handler[type] != ctrl_if_rxmsg_default_handler);
 176.435 -
 176.436 -    if ( inuse )
 176.437 -    {
 176.438 -        printk(KERN_INFO "Receiver %p already established for control "
 176.439 -               "messages of type %d.\n", ctrl_if_rxmsg_handler[type], type);
 176.440 -    }
 176.441 -    else
 176.442 -    {
 176.443 -        ctrl_if_rxmsg_handler[type] = hnd;
 176.444 -        clear_bit(type, (unsigned long *)&ctrl_if_rxmsg_blocking_context);
 176.445 -        if ( flags == CALLBACK_IN_BLOCKING_CONTEXT )
 176.446 -        {
 176.447 -            set_bit(type, (unsigned long *)&ctrl_if_rxmsg_blocking_context);
 176.448 -            if ( !safe_to_schedule_task )
 176.449 -                BUG();
 176.450 -        }
 176.451 -    }
 176.452 -
 176.453 -    spin_unlock_irqrestore(&ctrl_if_lock, _flags);
 176.454 -
 176.455 -    return !inuse;
 176.456 -}
 176.457 -
 176.458 -void 
 176.459 -ctrl_if_unregister_receiver(
 176.460 -    u8 type,
 176.461 -    ctrl_msg_handler_t hnd)
 176.462 -{
 176.463 -    unsigned long flags;
 176.464 -
 176.465 -    spin_lock_irqsave(&ctrl_if_lock, flags);
 176.466 -
 176.467 -    if ( ctrl_if_rxmsg_handler[type] != hnd )
 176.468 -        printk(KERN_INFO "Receiver %p is not registered for control "
 176.469 -               "messages of type %d.\n", hnd, type);
 176.470 -    else
 176.471 -        ctrl_if_rxmsg_handler[type] = ctrl_if_rxmsg_default_handler;
 176.472 -
 176.473 -    spin_unlock_irqrestore(&ctrl_if_lock, flags);
 176.474 -
 176.475 -    /* Ensure that @hnd will not be executed after this function returns. */
 176.476 -    tasklet_unlock_wait(&ctrl_if_rx_tasklet);
 176.477 -}
 176.478 -
 176.479 -void ctrl_if_suspend(void)
 176.480 -{
 176.481 -    teardown_irq(ctrl_if_irq, &ctrl_if_irq_action);
 176.482 -    unbind_evtchn_from_irq(ctrl_if_evtchn);
 176.483 -}
 176.484 -
 176.485 -void ctrl_if_resume(void)
 176.486 -{
 176.487 -    control_if_t *ctrl_if = get_ctrl_if();
 176.488 -
 176.489 -    if ( xen_start_info.flags & SIF_INITDOMAIN )
 176.490 -    {
 176.491 -        /*
 176.492 -         * The initial domain must create its own domain-controller link.
 176.493 -         * The controller is probably not running at this point, but will
 176.494 -         * pick up its end of the event channel from 
 176.495 -         */
 176.496 -        evtchn_op_t op;
 176.497 -	extern void bind_evtchn_to_cpu(unsigned port, unsigned cpu);
 176.498 -
 176.499 -        op.cmd = EVTCHNOP_bind_interdomain;
 176.500 -        op.u.bind_interdomain.dom1 = DOMID_SELF;
 176.501 -        op.u.bind_interdomain.dom2 = DOMID_SELF;
 176.502 -        op.u.bind_interdomain.port1 = 0;
 176.503 -        op.u.bind_interdomain.port2 = 0;
 176.504 -        if ( HYPERVISOR_event_channel_op(&op) != 0 )
 176.505 -            BUG();
 176.506 -        xen_start_info.domain_controller_evtchn = op.u.bind_interdomain.port1;
 176.507 -        initdom_ctrlif_domcontroller_port   = op.u.bind_interdomain.port2;
 176.508 -	bind_evtchn_to_cpu(op.u.bind_interdomain.port1, 0);
 176.509 -    }
 176.510 -
 176.511 -    /* Sync up with shared indexes. */
 176.512 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
 176.513 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
 176.514 -
 176.515 -    ctrl_if_evtchn = xen_start_info.domain_controller_evtchn;
 176.516 -    ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
 176.517 -
 176.518 -    memset(&ctrl_if_irq_action, 0, sizeof(ctrl_if_irq_action));
 176.519 -    ctrl_if_irq_action.handler = ctrl_if_interrupt;
 176.520 -    ctrl_if_irq_action.name    = "ctrl-if";
 176.521 -    (void)setup_irq(ctrl_if_irq, &ctrl_if_irq_action);
 176.522 -}
 176.523 -
 176.524 -void __init ctrl_if_init(void)
 176.525 -{
 176.526 -    control_if_t *ctrl_if = get_ctrl_if();
 176.527 -    int i;
 176.528 -
 176.529 -    for ( i = 0; i < 256; i++ )
 176.530 -        ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
 176.531 -
 176.532 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
 176.533 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
 176.534 -    
 176.535 -    spin_lock_init(&ctrl_if_lock);
 176.536 -
 176.537 -    ctrl_if_resume();
 176.538 -}
 176.539 -
 176.540 -
 176.541 -/* This is called after it is safe to call schedule_task(). */
 176.542 -static int __init ctrl_if_late_setup(void)
 176.543 -{
 176.544 -    safe_to_schedule_task = 1;
 176.545 -    return 0;
 176.546 -}
 176.547 -__initcall(ctrl_if_late_setup);
 176.548 -
 176.549 -
 176.550 -/*
 176.551 - * !! The following are DANGEROUS FUNCTIONS !!
 176.552 - * Use with care [for example, see xencons_force_flush()].
 176.553 - */
 176.554 -
 176.555 -int ctrl_if_transmitter_empty(void)
 176.556 -{
 176.557 -    return (ctrl_if_tx_ring.sring->req_prod == ctrl_if_tx_ring.rsp_cons);
 176.558 -    
 176.559 -}
 176.560 -
 176.561 -void ctrl_if_discard_responses(void)
 176.562 -{
 176.563 -    RING_DROP_PENDING_RESPONSES(&ctrl_if_tx_ring);
 176.564 -}
 176.565 -
 176.566 -EXPORT_SYMBOL(ctrl_if_send_message_noblock);
 176.567 -EXPORT_SYMBOL(ctrl_if_send_message_block);
 176.568 -EXPORT_SYMBOL(ctrl_if_send_message_and_get_response);
 176.569 -EXPORT_SYMBOL(ctrl_if_enqueue_space_callback);
 176.570 -EXPORT_SYMBOL(ctrl_if_send_response);
 176.571 -EXPORT_SYMBOL(ctrl_if_register_receiver);
 176.572 -EXPORT_SYMBOL(ctrl_if_unregister_receiver);
   178.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Sep 08 09:18:40 2005 -0600
   178.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Fri Sep 09 10:30:54 2005 -0600
   178.3 @@ -40,17 +40,9 @@
   178.4  #include <asm-xen/synch_bitops.h>
   178.5  #include <asm-xen/xen-public/event_channel.h>
   178.6  #include <asm-xen/xen-public/physdev.h>
   178.7 -#include <asm-xen/ctrl_if.h>
   178.8  #include <asm-xen/hypervisor.h>
   178.9  #include <asm-xen/evtchn.h>
  178.10  
  178.11 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  178.12 -EXPORT_SYMBOL(force_evtchn_callback);
  178.13 -EXPORT_SYMBOL(evtchn_do_upcall);
  178.14 -EXPORT_SYMBOL(bind_evtchn_to_irq);
  178.15 -EXPORT_SYMBOL(unbind_evtchn_from_irq);
  178.16 -#endif
  178.17 -
  178.18  /*
  178.19   * This lock protects updates to the following mapping and reference-count
  178.20   * arrays. The lock does not need to be acquired to read the mapping tables.
  178.21 @@ -133,6 +125,7 @@ void force_evtchn_callback(void)
  178.22  {
  178.23      (void)HYPERVISOR_xen_version(0);
  178.24  }
  178.25 +EXPORT_SYMBOL(force_evtchn_callback);
  178.26  
  178.27  /* NB. Interrupts are disabled on entry. */
  178.28  asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
  178.29 @@ -165,6 +158,7 @@ asmlinkage void evtchn_do_upcall(struct 
  178.30          }
  178.31      }
  178.32  }
  178.33 +EXPORT_SYMBOL(evtchn_do_upcall);
  178.34  
  178.35  static int find_unbound_irq(void)
  178.36  {
  178.37 @@ -211,6 +205,7 @@ int bind_virq_to_irq(int virq)
  178.38      
  178.39      return irq;
  178.40  }
  178.41 +EXPORT_SYMBOL(bind_virq_to_irq);
  178.42  
  178.43  void unbind_virq_from_irq(int virq)
  178.44  {
  178.45 @@ -244,74 +239,7 @@ void unbind_virq_from_irq(int virq)
  178.46  
  178.47      spin_unlock(&irq_mapping_update_lock);
  178.48  }
  178.49 -
  178.50 -/* This is only used when a vcpu from an xm save.  The ipi is expected
  178.51 -   to have been bound before we suspended, and so all of the xenolinux
  178.52 -   state is set up; we only need to restore the Xen side of things.
  178.53 -   The irq number has to be the same, but the evtchn number can
  178.54 -   change. */
  178.55 -void _bind_ipi_to_irq(int ipi, int vcpu, int irq)
  178.56 -{
  178.57 -    evtchn_op_t op;
  178.58 -    int evtchn;
  178.59 -
  178.60 -    spin_lock(&irq_mapping_update_lock);
  178.61 -
  178.62 -    op.cmd = EVTCHNOP_bind_ipi;
  178.63 -    if ( HYPERVISOR_event_channel_op(&op) != 0 )
  178.64 -	panic("Failed to bind virtual IPI %d on cpu %d\n", ipi, vcpu);
  178.65 -    evtchn = op.u.bind_ipi.port;
  178.66 -
  178.67 -    printk("<0>IPI %d, old evtchn %d, evtchn %d.\n",
  178.68 -	   ipi, per_cpu(ipi_to_evtchn, vcpu)[ipi],
  178.69 -	   evtchn);
  178.70 -
  178.71 -    evtchn_to_irq[irq_to_evtchn[irq]] = -1;
  178.72 -    irq_to_evtchn[irq] = -1;
  178.73 -
  178.74 -    evtchn_to_irq[evtchn] = irq;
  178.75 -    irq_to_evtchn[irq]    = evtchn;
  178.76 -
  178.77 -    printk("<0>evtchn_to_irq[%d] = %d.\n", evtchn,
  178.78 -	   evtchn_to_irq[evtchn]);
  178.79 -    per_cpu(ipi_to_evtchn, vcpu)[ipi] = evtchn;
  178.80 -
  178.81 -    bind_evtchn_to_cpu(evtchn, vcpu);
  178.82 -
  178.83 -    spin_unlock(&irq_mapping_update_lock);
  178.84 -
  178.85 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_mask);
  178.86 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_pending);
  178.87 -}
  178.88 -
  178.89 -void _bind_virq_to_irq(int virq, int cpu, int irq)
  178.90 -{
  178.91 -    evtchn_op_t op;
  178.92 -    int evtchn;
  178.93 -
  178.94 -    spin_lock(&irq_mapping_update_lock);
  178.95 -
  178.96 -    op.cmd              = EVTCHNOP_bind_virq;
  178.97 -    op.u.bind_virq.virq = virq;
  178.98 -    if ( HYPERVISOR_event_channel_op(&op) != 0 )
  178.99 -            panic("Failed to bind virtual IRQ %d\n", virq);
 178.100 -    evtchn = op.u.bind_virq.port;
 178.101 -
 178.102 -    evtchn_to_irq[irq_to_evtchn[irq]] = -1;
 178.103 -    irq_to_evtchn[irq] = -1;
 178.104 -
 178.105 -    evtchn_to_irq[evtchn] = irq;
 178.106 -    irq_to_evtchn[irq]    = evtchn;
 178.107 -
 178.108 -    per_cpu(virq_to_irq, cpu)[virq] = irq;
 178.109 -
 178.110 -    bind_evtchn_to_cpu(evtchn, cpu);
 178.111 -
 178.112 -    spin_unlock(&irq_mapping_update_lock);
 178.113 -
 178.114 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_mask);
 178.115 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_pending);
 178.116 -}
 178.117 +EXPORT_SYMBOL(unbind_virq_from_irq);
 178.118  
 178.119  int bind_ipi_to_irq(int ipi)
 178.120  {
 178.121 @@ -347,6 +275,7 @@ int bind_ipi_to_irq(int ipi)
 178.122  
 178.123      return irq;
 178.124  }
 178.125 +EXPORT_SYMBOL(bind_ipi_to_irq);
 178.126  
 178.127  void unbind_ipi_from_irq(int ipi)
 178.128  {
 178.129 @@ -374,6 +303,7 @@ void unbind_ipi_from_irq(int ipi)
 178.130  
 178.131      spin_unlock(&irq_mapping_update_lock);
 178.132  }
 178.133 +EXPORT_SYMBOL(unbind_ipi_from_irq);
 178.134  
 178.135  int bind_evtchn_to_irq(unsigned int evtchn)
 178.136  {
 178.137 @@ -394,6 +324,7 @@ int bind_evtchn_to_irq(unsigned int evtc
 178.138      
 178.139      return irq;
 178.140  }
 178.141 +EXPORT_SYMBOL(bind_evtchn_to_irq);
 178.142  
 178.143  void unbind_evtchn_from_irq(unsigned int evtchn)
 178.144  {
 178.145 @@ -409,6 +340,7 @@ void unbind_evtchn_from_irq(unsigned int
 178.146  
 178.147      spin_unlock(&irq_mapping_update_lock);
 178.148  }
 178.149 +EXPORT_SYMBOL(unbind_evtchn_from_irq);
 178.150  
 178.151  int bind_evtchn_to_irqhandler(
 178.152      unsigned int evtchn,
 178.153 @@ -427,6 +359,7 @@ int bind_evtchn_to_irqhandler(
 178.154  
 178.155      return retval;
 178.156  }
 178.157 +EXPORT_SYMBOL(bind_evtchn_to_irqhandler);
 178.158  
 178.159  void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id)
 178.160  {
 178.161 @@ -434,6 +367,7 @@ void unbind_evtchn_from_irqhandler(unsig
 178.162      free_irq(irq, dev_id);
 178.163      unbind_evtchn_from_irq(evtchn);
 178.164  }
 178.165 +EXPORT_SYMBOL(unbind_evtchn_from_irqhandler);
 178.166  
 178.167  #ifdef CONFIG_SMP
 178.168  static void do_nothing_function(void *ign)
 178.169 @@ -797,7 +731,4 @@ void __init init_IRQ(void)
 178.170          irq_desc[pirq_to_irq(i)].depth   = 1;
 178.171          irq_desc[pirq_to_irq(i)].handler = &pirq_type;
 178.172      }
 178.173 -
 178.174 -    /* This needs to be done early, but after the IRQ subsystem is alive. */
 178.175 -    ctrl_if_init();
 178.176  }
   181.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Thu Sep 08 09:18:40 2005 -0600
   181.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Sep 09 10:30:54 2005 -0600
   181.3 @@ -12,10 +12,8 @@
   181.4  #include <asm-xen/evtchn.h>
   181.5  #include <asm-xen/hypervisor.h>
   181.6  #include <asm-xen/xen-public/dom0_ops.h>
   181.7 -#include <asm-xen/linux-public/suspend.h>
   181.8  #include <asm-xen/queues.h>
   181.9  #include <asm-xen/xenbus.h>
  181.10 -#include <asm-xen/ctrl_if.h>
  181.11  #include <linux/cpu.h>
  181.12  #include <linux/kthread.h>
  181.13  
  181.14 @@ -65,69 +63,10 @@ static int shutting_down = SHUTDOWN_INVA
  181.15  #define cpu_up(x) (-EOPNOTSUPP)
  181.16  #endif
  181.17  
  181.18 -static void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
  181.19 -{
  181.20 -    int r;
  181.21 -    int gdt_pages;
  181.22 -    r = HYPERVISOR_vcpu_pickle(vcpu, ctxt);
  181.23 -    if (r != 0)
  181.24 -	panic("pickling vcpu %d -> %d!\n", vcpu, r);
  181.25 -
  181.26 -    /* Translate from machine to physical addresses where necessary,
  181.27 -       so that they can be translated to our new machine address space
  181.28 -       after resume.  libxc is responsible for doing this to vcpu0,
  181.29 -       but we do it to the others. */
  181.30 -    gdt_pages = (ctxt->gdt_ents + 511) / 512;
  181.31 -    ctxt->ctrlreg[3] = machine_to_phys(ctxt->ctrlreg[3]);
  181.32 -    for (r = 0; r < gdt_pages; r++)
  181.33 -	ctxt->gdt_frames[r] = mfn_to_pfn(ctxt->gdt_frames[r]);
  181.34 -}
  181.35 -
  181.36 -void _restore_vcpu(int cpu);
  181.37 -
  181.38 -atomic_t vcpus_rebooting;
  181.39 -
  181.40 -static int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
  181.41 -{
  181.42 -    int r;
  181.43 -    int gdt_pages = (ctxt->gdt_ents + 511) / 512;
  181.44 -
  181.45 -    /* This is kind of a hack, and implicitly relies on the fact that
  181.46 -       the vcpu stops in a place where all of the call clobbered
  181.47 -       registers are already dead. */
  181.48 -    ctxt->user_regs.esp -= 4;
  181.49 -    ((unsigned long *)ctxt->user_regs.esp)[0] = ctxt->user_regs.eip;
  181.50 -    ctxt->user_regs.eip = (unsigned long)_restore_vcpu;
  181.51 -
  181.52 -    /* De-canonicalise.  libxc handles this for vcpu 0, but we need
  181.53 -       to do it for the other vcpus. */
  181.54 -    ctxt->ctrlreg[3] = phys_to_machine(ctxt->ctrlreg[3]);
  181.55 -    for (r = 0; r < gdt_pages; r++)
  181.56 -	ctxt->gdt_frames[r] = pfn_to_mfn(ctxt->gdt_frames[r]);
  181.57 -
  181.58 -    atomic_set(&vcpus_rebooting, 1);
  181.59 -    r = HYPERVISOR_boot_vcpu(vcpu, ctxt);
  181.60 -    if (r != 0) {
  181.61 -	printk(KERN_EMERG "Failed to reboot vcpu %d (%d)\n", vcpu, r);
  181.62 -	return -1;
  181.63 -    }
  181.64 -
  181.65 -    /* Make sure we wait for the new vcpu to come up before trying to do
  181.66 -       anything with it or starting the next one. */
  181.67 -    while (atomic_read(&vcpus_rebooting))
  181.68 -	barrier();
  181.69 -
  181.70 -    return 0;
  181.71 -}
  181.72  
  181.73  static int __do_suspend(void *ignore)
  181.74  {
  181.75 -    int i, j;
  181.76 -    suspend_record_t *suspend_record;
  181.77 -    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
  181.78 -
  181.79 -    /* Hmmm... a cleaner interface to suspend/resume blkdevs would be nice. */
  181.80 -	/* XXX SMH: yes it would :-( */	
  181.81 +    int i, j, k, fpp;
  181.82  
  181.83  #ifdef CONFIG_XEN_USB_FRONTEND
  181.84      extern void usbif_resume();
  181.85 @@ -138,16 +77,25 @@ static int __do_suspend(void *ignore)
  181.86      extern int gnttab_suspend(void);
  181.87      extern int gnttab_resume(void);
  181.88  
  181.89 +    extern void time_suspend(void);
  181.90 +    extern void time_resume(void);
  181.91 +    extern unsigned long max_pfn;
  181.92 +    extern unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[];
  181.93 +
  181.94  #ifdef CONFIG_SMP
  181.95      extern void smp_suspend(void);
  181.96      extern void smp_resume(void);
  181.97 +
  181.98 +    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
  181.99 +    cpumask_t prev_online_cpus, prev_present_cpus;
 181.100 +
 181.101 +    void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt);
 181.102 +    int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt);
 181.103  #endif
 181.104 -    extern void time_suspend(void);
 181.105 -    extern void time_resume(void);
 181.106 -    extern unsigned long max_pfn;
 181.107 -    extern unsigned int *pfn_to_mfn_frame_list;
 181.108  
 181.109 -    cpumask_t prev_online_cpus, prev_present_cpus;
 181.110 +    extern void xencons_suspend(void);
 181.111 +    extern void xencons_resume(void);
 181.112 +
 181.113      int err = 0;
 181.114  
 181.115      BUG_ON(smp_processor_id() != 0);
 181.116 @@ -155,15 +103,14 @@ static int __do_suspend(void *ignore)
 181.117  
 181.118  #if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
 181.119      if (num_online_cpus() > 1) {
 181.120 -	printk(KERN_WARNING "Can't suspend SMP guests without CONFIG_HOTPLUG_CPU\n");
 181.121 +	printk(KERN_WARNING 
 181.122 +               "Can't suspend SMP guests without CONFIG_HOTPLUG_CPU\n");
 181.123  	return -EOPNOTSUPP;
 181.124      }
 181.125  #endif
 181.126  
 181.127 -    suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
 181.128 -    if ( suspend_record == NULL )
 181.129 -        goto out;
 181.130 -
 181.131 +    preempt_disable();
 181.132 +#ifdef CONFIG_SMP
 181.133      /* Take all of the other cpus offline.  We need to be careful not
 181.134         to get preempted between the final test for num_online_cpus()
 181.135         == 1 and disabling interrupts, since otherwise userspace could
 181.136 @@ -175,7 +122,6 @@ static int __do_suspend(void *ignore)
 181.137         since by the time num_online_cpus() == 1, there aren't any
 181.138         other cpus) */
 181.139      cpus_clear(prev_online_cpus);
 181.140 -    preempt_disable();
 181.141      while (num_online_cpus() > 1) {
 181.142  	preempt_enable();
 181.143  	for_each_online_cpu(i) {
 181.144 @@ -190,13 +136,13 @@ static int __do_suspend(void *ignore)
 181.145  	}
 181.146  	preempt_disable();
 181.147      }
 181.148 -
 181.149 -    suspend_record->nr_pfns = max_pfn; /* final number of pfns */
 181.150 +#endif
 181.151  
 181.152      __cli();
 181.153  
 181.154      preempt_enable();
 181.155  
 181.156 +#ifdef CONFIG_SMP
 181.157      cpus_clear(prev_present_cpus);
 181.158      for_each_present_cpu(i) {
 181.159  	if (i == 0)
 181.160 @@ -204,6 +150,7 @@ static int __do_suspend(void *ignore)
 181.161  	save_vcpu_context(i, &suspended_cpu_records[i]);
 181.162  	cpu_set(i, prev_present_cpus);
 181.163      }
 181.164 +#endif
 181.165  
 181.166  #ifdef __i386__
 181.167      mm_pin_all();
 181.168 @@ -218,7 +165,7 @@ static int __do_suspend(void *ignore)
 181.169  
 181.170      xenbus_suspend();
 181.171  
 181.172 -    ctrl_if_suspend();
 181.173 +    xencons_suspend();
 181.174  
 181.175      irq_suspend();
 181.176  
 181.177 @@ -227,37 +174,44 @@ static int __do_suspend(void *ignore)
 181.178      HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
 181.179      clear_fixmap(FIX_SHARED_INFO);
 181.180  
 181.181 -    memcpy(&suspend_record->resume_info, &xen_start_info,
 181.182 -           sizeof(xen_start_info));
 181.183 +    xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
 181.184 +    xen_start_info->console_mfn = mfn_to_pfn(xen_start_info->console_mfn);
 181.185  
 181.186      /* We'll stop somewhere inside this hypercall.  When it returns,
 181.187         we'll start resuming after the restore. */
 181.188 -    HYPERVISOR_suspend(virt_to_mfn(suspend_record));
 181.189 +    HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
 181.190  
 181.191      shutting_down = SHUTDOWN_INVALID; 
 181.192  
 181.193 -    memcpy(&xen_start_info, &suspend_record->resume_info,
 181.194 -           sizeof(xen_start_info));
 181.195 -
 181.196 -    set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
 181.197 +    set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
 181.198  
 181.199      HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
 181.200  
 181.201      memset(empty_zero_page, 0, PAGE_SIZE);
 181.202 -
 181.203 -    for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
 181.204 +	     
 181.205 +    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
 181.206 +		virt_to_mfn(pfn_to_mfn_frame_list_list);
 181.207 +  
 181.208 +    fpp = PAGE_SIZE/sizeof(unsigned long);
 181.209 +    for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
 181.210      {
 181.211 -        pfn_to_mfn_frame_list[j] = 
 181.212 -            virt_to_mfn(&phys_to_machine_mapping[i]);
 181.213 +	if ( (j % fpp) == 0 )
 181.214 +	{
 181.215 +	    k++;
 181.216 +	    pfn_to_mfn_frame_list_list[k] = 
 181.217 +		    virt_to_mfn(pfn_to_mfn_frame_list[k]);
 181.218 +	    j=0;
 181.219 +	}
 181.220 +	pfn_to_mfn_frame_list[k][j] = 
 181.221 +		virt_to_mfn(&phys_to_machine_mapping[i]);
 181.222      }
 181.223 -    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
 181.224 -        virt_to_mfn(pfn_to_mfn_frame_list);
 181.225 +    HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
 181.226  
 181.227      gnttab_resume();
 181.228  
 181.229      irq_resume();
 181.230  
 181.231 -    ctrl_if_resume();
 181.232 +    xencons_resume();
 181.233  
 181.234      xenbus_resume();
 181.235  
 181.236 @@ -269,12 +223,14 @@ static int __do_suspend(void *ignore)
 181.237  
 181.238      usbif_resume();
 181.239  
 181.240 -    for_each_cpu_mask(i, prev_present_cpus) {
 181.241 +#ifdef CONFIG_SMP
 181.242 +    for_each_cpu_mask(i, prev_present_cpus)
 181.243  	restore_vcpu_context(i, &suspended_cpu_records[i]);
 181.244 -    }
 181.245 +#endif
 181.246  
 181.247      __sti();
 181.248  
 181.249 +#ifdef CONFIG_SMP
 181.250   out_reenable_cpus:
 181.251      for_each_cpu_mask(i, prev_online_cpus) {
 181.252  	j = cpu_up(i);
 181.253 @@ -284,10 +240,8 @@ static int __do_suspend(void *ignore)
 181.254  	    err = j;
 181.255  	}
 181.256      }
 181.257 +#endif
 181.258  
 181.259 - out:
 181.260 -    if ( suspend_record != NULL )
 181.261 -        free_page((unsigned long)suspend_record);
 181.262      return err;
 181.263  }
 181.264  
   185.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig	Thu Sep 08 09:18:40 2005 -0600
   185.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig	Fri Sep 09 10:30:54 2005 -0600
   185.3 @@ -21,13 +21,13 @@ config X86_64
   185.4  	  classical 32-bit x86 architecture. For details see
   185.5  	  <http://www.x86-64.org/>.
   185.6  
   185.7 +config 64BIT
   185.8 +	def_bool y
   185.9 +
  185.10  config X86
  185.11  	bool
  185.12  	default y
  185.13  
  185.14 -config 64BIT
  185.15 -	def_bool y
  185.16 -
  185.17  config MMU
  185.18  	bool
  185.19  	default y
  185.20 @@ -89,10 +89,11 @@ choice
  185.21  #	  Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs.
  185.22  
  185.23  config MPSC
  185.24 -       bool "Intel x86-64"
  185.25 +       bool "Intel EM64T"
  185.26         help
  185.27 -	  Optimize for Intel IA32 with 64bit extension CPUs
  185.28 -	  (Prescott/Nocona/Potomac)
  185.29 +	  Optimize for Intel Pentium 4 and Xeon CPUs with Intel
  185.30 +	  Extended Memory 64 Technology(EM64T). For details see
  185.31 +	  <http://www.intel.com/technology/64bitextensions/>.
  185.32  
  185.33  config GENERIC_CPU
  185.34  	bool "Generic-x86-64"
  185.35 @@ -367,7 +368,6 @@ config SECCOMP
  185.36  
  185.37  	  If unsure, say Y. Only embedded should say N here.
  185.38  
  185.39 -
  185.40  endmenu
  185.41  
  185.42  #
   191.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile	Thu Sep 08 09:18:40 2005 -0600
   191.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile	Fri Sep 09 10:30:54 2005 -0600
   191.3 @@ -40,7 +40,7 @@ obj-$(CONFIG_DUMMY_IOMMU)	+= pci-nommu.o
   191.4  i386-obj-$(CONFIG_DUMMY_IOMMU)	+= pci-dma.o
   191.5  i386-obj-$(CONFIG_SWIOTLB)	+= swiotlb.o
   191.6  obj-$(CONFIG_KPROBES)		+= kprobes.o
   191.7 -obj-$(CONFIG_X86_PM_TIMER)	+= pmtimer.o
   191.8 +#obj-$(CONFIG_X86_PM_TIMER)	+= pmtimer.o
   191.9  
  191.10  c-obj-$(CONFIG_MODULES)		+= module.o
  191.11  
   194.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Thu Sep 08 09:18:40 2005 -0600
   194.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Fri Sep 09 10:30:54 2005 -0600
   194.3 @@ -20,6 +20,9 @@
   194.4  #include <asm/e820.h>
   194.5  #include <asm/proto.h>
   194.6  #include <asm/bootsetup.h>
   194.7 +#include <asm-xen/xen-public/memory.h>
   194.8 +
   194.9 +unsigned long pci_mem_start = 0xaeedbabe;
  194.10  
  194.11  /* 
  194.12   * PFN of last memory page.
  194.13 @@ -517,14 +520,13 @@ void __init setup_memory_region(void)
  194.14  }
  194.15  
  194.16  #else  /* CONFIX_XEN */
  194.17 +
  194.18  extern unsigned long xen_override_max_pfn;
  194.19  extern union xen_start_info_union xen_start_info_union;
  194.20 -/*
  194.21 - * Guest physical starts from 0.
  194.22 - */
  194.23 +
  194.24  unsigned long __init e820_end_of_ram(void)
  194.25  {
  194.26 -        unsigned long max_end_pfn = xen_start_info.nr_pages;
  194.27 +        unsigned long max_end_pfn = xen_start_info->nr_pages;
  194.28  
  194.29  	if ( xen_override_max_pfn <  max_end_pfn)
  194.30  		xen_override_max_pfn = max_end_pfn;
  194.31 @@ -532,11 +534,69 @@ unsigned long __init e820_end_of_ram(voi
  194.32          return xen_override_max_pfn;
  194.33  }
  194.34  
  194.35 -
  194.36 -
  194.37  void __init e820_reserve_resources(void) 
  194.38  {
  194.39 -	return;			/* Xen won't have reserved entries */
  194.40 +	dom0_op_t op;
  194.41 +	struct dom0_memory_map_entry *map;
  194.42 +	unsigned long gapstart, gapsize, last;
  194.43 +	int i, found = 0;
  194.44 +
  194.45 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
  194.46 +		return;
  194.47 +
  194.48 +	map = alloc_bootmem_low_pages(PAGE_SIZE);
  194.49 +	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
  194.50 +	op.u.physical_memory_map.memory_map = map;
  194.51 +	op.u.physical_memory_map.max_map_entries =
  194.52 +		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
  194.53 +	BUG_ON(HYPERVISOR_dom0_op(&op));
  194.54 +
  194.55 +	last = 0x100000000ULL;
  194.56 +	gapstart = 0x10000000;
  194.57 +	gapsize = 0x400000;
  194.58 +
  194.59 +	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
  194.60 +		struct resource *res;
  194.61 +
  194.62 +		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
  194.63 +			gapsize = last - map[i].end;
  194.64 +			gapstart = map[i].end;
  194.65 +			found = 1;
  194.66 +		}
  194.67 +		if (map[i].start < last)
  194.68 +			last = map[i].start;
  194.69 +
  194.70 +		if (map[i].end > 0x100000000ULL)
  194.71 +			continue;
  194.72 +		res = alloc_bootmem_low(sizeof(struct resource));
  194.73 +		res->name = map[i].is_ram ? "System RAM" : "reserved";
  194.74 +		res->start = map[i].start;
  194.75 +		res->end = map[i].end - 1;
  194.76 +		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  194.77 +		request_resource(&iomem_resource, res);
  194.78 +	}
  194.79 +
  194.80 +	free_bootmem(__pa(map), PAGE_SIZE);
  194.81 +
  194.82 +	if (!found) {
  194.83 +		HYPERVISOR_memory_op(XENMEM_maximum_ram_page, &gapstart);
  194.84 +		gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
  194.85 +		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
  194.86 +		       KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
  194.87 +	}
  194.88 +
  194.89 +	/*
  194.90 +	 * Start allocating dynamic PCI memory a bit into the gap,
  194.91 +	 * aligned up to the nearest megabyte.
  194.92 +	 *
  194.93 +	 * Question: should we try to pad it up a bit (do something
  194.94 +	 * like " + (gapsize >> 3)" in there too?). We now have the
  194.95 +	 * technology.
  194.96 +	 */
  194.97 +	pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
  194.98 +
  194.99 +	printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
 194.100 +		pci_mem_start, gapstart, gapsize);
 194.101  }
 194.102  
 194.103  #endif
 194.104 @@ -548,8 +608,6 @@ void __init parse_memopt(char *p, char *
 194.105          xen_override_max_pfn = (unsigned long) end_user_pfn;
 194.106  } 
 194.107  
 194.108 -unsigned long pci_mem_start = 0xaeedbabe;
 194.109 -
 194.110  /*
 194.111   * Search for the biggest gap in the low 32 bits of the e820
 194.112   * memory space.  We pass this space to PCI to assign MMIO resources
 194.113 @@ -558,6 +616,7 @@ unsigned long pci_mem_start = 0xaeedbabe
 194.114   */
 194.115  __init void e820_setup_gap(void)
 194.116  {
 194.117 +#ifndef CONFIG_XEN
 194.118  	unsigned long gapstart, gapsize;
 194.119  	unsigned long last;
 194.120  	int i;
 194.121 @@ -606,4 +665,5 @@ unsigned long pci_mem_start = 0xaeedbabe
 194.122  
 194.123  	printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
 194.124  		pci_mem_start, gapstart, gapsize);
 194.125 +#endif
 194.126  }
   199.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S	Thu Sep 08 09:18:40 2005 -0600
   199.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S	Fri Sep 09 10:30:54 2005 -0600
   199.3 @@ -40,16 +40,13 @@
   199.4  	.globl startup_64
   199.5  startup_64:
   199.6  ENTRY(_start)
   199.7 -        cld                
   199.8 -	/* Copy the necessary stuff from xen_start_info structure. */
   199.9 -	movq  $xen_start_info_union,%rdi
  199.10 -	movq  $256,%rcx
  199.11 -	rep movsq
  199.12 +	movq %rsi,xen_start_info(%rip)
  199.13  
  199.14  #ifdef CONFIG_SMP
  199.15 -        ENTRY(startup_64_smp)
  199.16 +ENTRY(startup_64_smp)
  199.17 +#endif /* CONFIG_SMP */
  199.18 +
  199.19  	cld
  199.20 -#endif /* CONFIG_SMP */
  199.21  
  199.22  	movq init_rsp(%rip),%rsp
  199.23  	/* zero EFLAGS after setting rsp */
   200.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head64.c	Thu Sep 08 09:18:40 2005 -0600
   200.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head64.c	Fri Sep 09 10:30:54 2005 -0600
   200.3 @@ -90,8 +90,9 @@ void __init x86_64_start_kernel(char * r
   200.4  {
   200.5  	int i;
   200.6  
   200.7 -        phys_to_machine_mapping = (u32 *)xen_start_info.mfn_list;
   200.8 -        start_pfn = (__pa(xen_start_info.pt_base) >> PAGE_SHIFT) +  xen_start_info.nr_pt_frames;
   200.9 +        phys_to_machine_mapping = (unsigned long *)xen_start_info->mfn_list;
  200.10 +        start_pfn = (__pa(xen_start_info->pt_base) >> PAGE_SHIFT) + 
  200.11 +		xen_start_info->nr_pt_frames;
  200.12  
  200.13  	for (i = 0; i < 256; i++)
  200.14  		set_intr_gate(i, early_idt_handler);
   208.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Thu Sep 08 09:18:40 2005 -0600
   208.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Sep 09 10:30:54 2005 -0600
   208.3 @@ -76,7 +76,8 @@ EXPORT_SYMBOL(HYPERVISOR_shared_info);
   208.4  /* Allows setting of maximum possible memory size  */
   208.5  unsigned long xen_override_max_pfn;
   208.6  
   208.7 -u32 *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
   208.8 +unsigned long *phys_to_machine_mapping;
   208.9 +unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[512];
  208.10  
  208.11  EXPORT_SYMBOL(phys_to_machine_mapping);
  208.12  
  208.13 @@ -84,7 +85,7 @@ DEFINE_PER_CPU(multicall_entry_t, multic
  208.14  DEFINE_PER_CPU(int, nr_multicall_ents);
  208.15  
  208.16  /* Raw start-of-day parameters from the hypervisor. */
  208.17 -union xen_start_info_union xen_start_info_union;
  208.18 +start_info_t *xen_start_info;
  208.19  #endif
  208.20  
  208.21  /*
  208.22 @@ -314,7 +315,7 @@ static __init void parse_cmdline_early (
  208.23  	
  208.24  	if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
  208.25  		max_cmdline = COMMAND_LINE_SIZE;
  208.26 -	memcpy(saved_command_line, xen_start_info.cmd_line, max_cmdline);
  208.27 +	memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
  208.28  	saved_command_line[max_cmdline-1] = '\0';
  208.29  #else
  208.30  	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
  208.31 @@ -687,7 +688,7 @@ void __init setup_arch(char **cmdline_p)
  208.32  #endif
  208.33  #ifdef CONFIG_XEN
  208.34  #ifdef CONFIG_BLK_DEV_INITRD
  208.35 -	if (xen_start_info.mod_start) {
  208.36 +	if (xen_start_info->mod_start) {
  208.37  		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
  208.38  			/*reserve_bootmem_generic(INITRD_START, INITRD_SIZE);*/
  208.39  			initrd_start = INITRD_START + PAGE_OFFSET;
  208.40 @@ -730,29 +731,50 @@ void __init setup_arch(char **cmdline_p)
  208.41  #endif
  208.42  #ifdef CONFIG_XEN
  208.43  	{
  208.44 -		int i, j;
  208.45 +		int i, j, k, fpp;
  208.46  		/* Make sure we have a large enough P->M table. */
  208.47 -		if (end_pfn > xen_start_info.nr_pages) {
  208.48 +		if (end_pfn > xen_start_info->nr_pages) {
  208.49  			phys_to_machine_mapping = alloc_bootmem(
  208.50 -				max_pfn * sizeof(u32));
  208.51 +				end_pfn * sizeof(unsigned long));
  208.52  			memset(phys_to_machine_mapping, ~0,
  208.53 -			       max_pfn * sizeof(u32));
  208.54 +			       end_pfn * sizeof(unsigned long));
  208.55  			memcpy(phys_to_machine_mapping,
  208.56 -			       (u32 *)xen_start_info.mfn_list,
  208.57 -			       xen_start_info.nr_pages * sizeof(u32));
  208.58 +			       (unsigned long *)xen_start_info->mfn_list,
  208.59 +			       xen_start_info->nr_pages * sizeof(unsigned long));
  208.60  			free_bootmem(
  208.61 -				__pa(xen_start_info.mfn_list), 
  208.62 -				PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
  208.63 -						sizeof(u32))));
  208.64 +				__pa(xen_start_info->mfn_list), 
  208.65 +				PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
  208.66 +						sizeof(unsigned long))));
  208.67  		}
  208.68  
  208.69 -		pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE);
  208.70 -
  208.71 -		for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(u32)), j++ )
  208.72 -		{	
  208.73 -			pfn_to_mfn_frame_list[j] = 
  208.74 +		/* 
  208.75 +		 * Initialise the list of the frames that specify the list of 
  208.76 +		 * frames that make up the p2m table. Used by save/restore
  208.77 +		 */
  208.78 +		pfn_to_mfn_frame_list_list = alloc_bootmem(PAGE_SIZE);
  208.79 +		HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
  208.80 +		  virt_to_mfn(pfn_to_mfn_frame_list_list);
  208.81 +	       
  208.82 +		fpp = PAGE_SIZE/sizeof(unsigned long);
  208.83 +		for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
  208.84 +		{
  208.85 +			if ( (j % fpp) == 0 )
  208.86 +			{
  208.87 +				k++;
  208.88 +				BUG_ON(k>=fpp);
  208.89 +				pfn_to_mfn_frame_list[k] = alloc_bootmem(PAGE_SIZE);
  208.90 +				pfn_to_mfn_frame_list_list[k] = 
  208.91 +					virt_to_mfn(pfn_to_mfn_frame_list[k]);
  208.92 +				j=0;
  208.93 +			}
  208.94 +			pfn_to_mfn_frame_list[k][j] = 
  208.95  				virt_to_mfn(&phys_to_machine_mapping[i]);
  208.96  		}
  208.97 +		HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
  208.98 +		
  208.99 +		
 208.100 +
 208.101 +
 208.102  
 208.103  	}
 208.104  #endif
 208.105 @@ -817,8 +839,8 @@ void __init setup_arch(char **cmdline_p)
 208.106  	       op.u.set_iopl.iopl = 1;
 208.107  	       HYPERVISOR_physdev_op(&op);
 208.108  
 208.109 -	       if (xen_start_info.flags & SIF_INITDOMAIN) {
 208.110 -		       if (!(xen_start_info.flags & SIF_PRIVILEGED))
 208.111 +	       if (xen_start_info->flags & SIF_INITDOMAIN) {
 208.112 +		       if (!(xen_start_info->flags & SIF_PRIVILEGED))
 208.113  			       panic("Xen granted us console access "
 208.114  				     "but not privileged status");
 208.115  		       
   212.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c	Thu Sep 08 09:18:40 2005 -0600
   212.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c	Fri Sep 09 10:30:54 2005 -0600
   212.3 @@ -1277,21 +1277,23 @@ extern void local_teardown_timer_irq(voi
   212.4  
   212.5  void smp_suspend(void)
   212.6  {
   212.7 -	/* XXX todo: take down time and ipi's on all cpus */
   212.8  	local_teardown_timer_irq();
   212.9  	smp_intr_exit();
  212.10  }
  212.11  
  212.12  void smp_resume(void)
  212.13  {
  212.14 -	/* XXX todo: restore time and ipi's on all cpus */
  212.15  	smp_intr_init();
  212.16  	local_setup_timer_irq();
  212.17  }
  212.18  
  212.19 -void _restore_vcpu(void)
  212.20 +void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
  212.21  {
  212.22 -	/* XXX need to write this */
  212.23 +}
  212.24 +
  212.25 +int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
  212.26 +{
  212.27 +	return 0;
  212.28  }
  212.29  
  212.30  #endif
   218.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c	Thu Sep 08 09:18:40 2005 -0600
   218.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c	Fri Sep 09 10:30:54 2005 -0600
   218.3 @@ -149,7 +149,7 @@ void dump_pagetable(unsigned long addres
   218.4  	pmd_t *pmd;
   218.5  	pte_t *pte;
   218.6  
   218.7 -        pgd = (pgd_t *)per_cpu(cur_pgd, smp_processor_id());
   218.8 +	pgd = (pgd_t *)per_cpu(cur_pgd, smp_processor_id());
   218.9  	pgd += pgd_index(address);
  218.10  
  218.11  	printk("PGD %lx ", pgd_val(*pgd));
  218.12 @@ -296,9 +296,9 @@ int exception_trace = 1;
  218.13  #define MEM_VERBOSE 1
  218.14  
  218.15  #ifdef MEM_VERBOSE
  218.16 -#define MEM_LOG(_f, _a...)                           \
  218.17 -  printk("fault.c:[%d]-> " _f "\n", \
  218.18 -          __LINE__ , ## _a )
  218.19 +#define MEM_LOG(_f, _a...)			\
  218.20 +	printk("fault.c:[%d]-> " _f "\n",	\
  218.21 +	__LINE__ , ## _a )
  218.22  #else
  218.23  #define MEM_LOG(_f, _a...) ((void)0)
  218.24  #endif
  218.25 @@ -325,7 +325,7 @@ asmlinkage void do_page_fault(struct pt_
  218.26  	siginfo_t info;
  218.27  
  218.28  	if (!user_mode(regs))
  218.29 -                error_code &= ~4; /* means kernel */
  218.30 +		error_code &= ~4; /* means kernel */
  218.31  
  218.32  #ifdef CONFIG_CHECKING
  218.33  	{ 
   219.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Thu Sep 08 09:18:40 2005 -0600
   219.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Fri Sep 09 10:30:54 2005 -0600
   219.3 @@ -62,14 +62,16 @@ static int init_mapping_done;
   219.4   * avaialble in init_memory_mapping().
   219.5   */
   219.6  
   219.7 -#define addr_to_page(addr, page)                                             \
   219.8 -        (addr) &= PHYSICAL_PAGE_MASK;                                   \
   219.9 -        (page) = ((unsigned long *) ((unsigned long)(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) + __START_KERNEL_map)))
  219.10 +#define addr_to_page(addr, page)				\
  219.11 +	(addr) &= PHYSICAL_PAGE_MASK;				\
  219.12 +	(page) = ((unsigned long *) ((unsigned long)		\
  219.13 +	(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) +	\
  219.14 +	__START_KERNEL_map)))
  219.15  
  219.16  static void __make_page_readonly(unsigned long va)
  219.17  {
  219.18 -        unsigned long addr;
  219.19 -        pte_t pte, *ptep;
  219.20 +	unsigned long addr;
  219.21 +	pte_t pte, *ptep;
  219.22  	unsigned long *page = (unsigned long *) init_level4_pgt;
  219.23  
  219.24  	addr = (unsigned long) page[pgd_index(va)];
  219.25 @@ -89,22 +91,22 @@ static void __make_page_readonly(unsigne
  219.26  
  219.27  static void __make_page_writable(unsigned long va)
  219.28  {
  219.29 -        unsigned long addr;
  219.30 -        pte_t pte, *ptep;
  219.31 -        unsigned long *page = (unsigned long *) init_level4_pgt;
  219.32 +	unsigned long addr;
  219.33 +	pte_t pte, *ptep;
  219.34 +	unsigned long *page = (unsigned long *) init_level4_pgt;
  219.35  
  219.36 -        addr = (unsigned long) page[pgd_index(va)];
  219.37 -        addr_to_page(addr, page);
  219.38 +	addr = (unsigned long) page[pgd_index(va)];
  219.39 +	addr_to_page(addr, page);
  219.40  
  219.41 -        addr = page[pud_index(va)];
  219.42 -        addr_to_page(addr, page);
  219.43 -        
  219.44 -        addr = page[pmd_index(va)];
  219.45 -        addr_to_page(addr, page);
  219.46 +	addr = page[pud_index(va)];
  219.47 +	addr_to_page(addr, page);
  219.48 + 
  219.49 +	addr = page[pmd_index(va)];
  219.50 +	addr_to_page(addr, page);
  219.51  
  219.52 -        ptep = (pte_t *) &page[pte_index(va)];
  219.53 +	ptep = (pte_t *) &page[pte_index(va)];
  219.54  	pte.pte = (ptep->pte | _PAGE_RW);
  219.55 -        xen_l1_entry_update(ptep, pte);
  219.56 +	xen_l1_entry_update(ptep, pte);
  219.57  	__flush_tlb_one(addr);
  219.58  }
  219.59  
  219.60 @@ -115,55 +117,55 @@ static void __make_page_writable(unsigne
  219.61  void make_page_readonly(void *va)
  219.62  {
  219.63  	pgd_t* pgd; pud_t *pud; pmd_t* pmd; pte_t pte, *ptep;
  219.64 -        unsigned long addr = (unsigned long) va;
  219.65 +	unsigned long addr = (unsigned long) va;
  219.66  
  219.67 -        if (!init_mapping_done) {
  219.68 -                __make_page_readonly(addr);
  219.69 -                return;
  219.70 -        }
  219.71 -                
  219.72 -        pgd = pgd_offset_k(addr);
  219.73 -        pud = pud_offset(pgd, addr);
  219.74 -        pmd = pmd_offset(pud, addr);
  219.75 -        ptep = pte_offset_kernel(pmd, addr);
  219.76 +	if (!init_mapping_done) {
  219.77 +		__make_page_readonly(addr);
  219.78 +		return;
  219.79 +	}
  219.80 +  
  219.81 +	pgd = pgd_offset_k(addr);
  219.82 +	pud = pud_offset(pgd, addr);
  219.83 +	pmd = pmd_offset(pud, addr);
  219.84 +	ptep = pte_offset_kernel(pmd, addr);
  219.85  	pte.pte = (ptep->pte & ~_PAGE_RW);
  219.86 -        xen_l1_entry_update(ptep, pte);
  219.87 +	xen_l1_entry_update(ptep, pte);
  219.88  	__flush_tlb_one(addr);
  219.89  }
  219.90  
  219.91  void make_page_writable(void *va)
  219.92  {
  219.93 -        pgd_t* pgd; pud_t *pud; pmd_t* pmd; pte_t pte, *ptep;
  219.94 -        unsigned long addr = (unsigned long) va;
  219.95 +	pgd_t* pgd; pud_t *pud; pmd_t* pmd; pte_t pte, *ptep;
  219.96 +	unsigned long addr = (unsigned long) va;
  219.97  
  219.98 -        if (!init_mapping_done) {
  219.99 -                __make_page_writable(addr);
 219.100 -                return;
 219.101 -        }
 219.102 +	if (!init_mapping_done) {
 219.103 +		__make_page_writable(addr);
 219.104 +		return;
 219.105 +	}
 219.106  
 219.107 -        pgd = pgd_offset_k(addr);
 219.108 -        pud = pud_offset(pgd, addr);
 219.109 -        pmd = pmd_offset(pud, addr);
 219.110 -        ptep = pte_offset_kernel(pmd, addr);
 219.111 +	pgd = pgd_offset_k(addr);
 219.112 +	pud = pud_offset(pgd, addr);
 219.113 +	pmd = pmd_offset(pud, addr);
 219.114 +	ptep = pte_offset_kernel(pmd, addr);
 219.115  	pte.pte = (ptep->pte | _PAGE_RW);
 219.116 -        xen_l1_entry_update(ptep, pte);
 219.117 +	xen_l1_entry_update(ptep, pte);
 219.118  	__flush_tlb_one(addr);
 219.119  }
 219.120  
 219.121  void make_pages_readonly(void* va, unsigned nr)
 219.122  {
 219.123 -        while ( nr-- != 0 ) {
 219.124 -                make_page_readonly(va);
 219.125 -                va = (void*)((unsigned long)va + PAGE_SIZE);
 219.126 -        }
 219.127 +	while (nr-- != 0) {
 219.128 +		make_page_readonly(va);
 219.129 +		va = (void*)((unsigned long)va + PAGE_SIZE);
 219.130 +	}
 219.131  }
 219.132  
 219.133  void make_pages_writable(void* va, unsigned nr)
 219.134  {
 219.135 -        while ( nr-- != 0 ) {
 219.136 -                make_page_writable(va);
 219.137 -                va = (void*)((unsigned long)va + PAGE_SIZE);
 219.138 -        }
 219.139 +	while (nr-- != 0) {
 219.140 +		make_page_writable(va);
 219.141 +		va = (void*)((unsigned long)va + PAGE_SIZE);
 219.142 +	}
 219.143  }
 219.144  
 219.145  /*
 219.146 @@ -389,7 +391,7 @@ void __set_fixmap_user (enum fixed_addre
 219.147          set_pte_phys(address, phys, prot, SET_FIXMAP_USER); 
 219.148  }
 219.149  
 219.150 -unsigned long __initdata table_start, table_end, tables_space; 
 219.151 +unsigned long __initdata table_start, tables_space; 
 219.152  
 219.153  unsigned long get_machine_pfn(unsigned long addr)
 219.154  {
 219.155 @@ -400,38 +402,13 @@ unsigned long get_machine_pfn(unsigned l
 219.156          return pte_mfn(*pte);
 219.157  } 
 219.158  
 219.159 -#define ALIGN_TO_4K __attribute__((section(".data.page_aligned")))
 219.160 -#define MAX_LOW_PAGES	0x20
 219.161 -static unsigned long __init_pgt[MAX_LOW_PAGES][512]  ALIGN_TO_4K;
 219.162 -static int __init_pgt_index;
 219.163 -
 219.164 -/*
 219.165 - * We start using from start_pfn
 219.166 - */
 219.167  static __init void *alloc_static_page(unsigned long *phys)
 219.168  {
 219.169 -	int i = __init_pgt_index++;
 219.170 -
 219.171 -	if (__init_pgt_index >= MAX_LOW_PAGES) {
 219.172 -		printk("Need to increase MAX_LOW_PAGES");
 219.173 -		BUG();
 219.174 -	}
 219.175 -		
 219.176 -	*phys = __pa(__init_pgt[i]);
 219.177 -
 219.178 -	return (void *) __init_pgt[i];
 219.179 -} 
 219.180 -
 219.181 -/*
 219.182 - * Get RO page
 219.183 - */
 219.184 -static void __init *alloc_low_page(unsigned long *phys)
 219.185 -{ 
 219.186 -        unsigned long pfn = table_end++;
 219.187 -    
 219.188 -        *phys = (pfn << PAGE_SHIFT);
 219.189 -        memset((void *) ((pfn << PAGE_SHIFT) + __START_KERNEL_map), 0, PAGE_SIZE);
 219.190 -        return (void *)((pfn << PAGE_SHIFT) + __START_KERNEL_map);
 219.191 +	unsigned long va = (start_pfn << PAGE_SHIFT) + __START_KERNEL_map;
 219.192 +	*phys = start_pfn << PAGE_SHIFT;
 219.193 +	start_pfn++;
 219.194 +	memset((void *)va, 0, PAGE_SIZE);
 219.195 +	return (void *)va;
 219.196  } 
 219.197  
 219.198  #define PTE_SIZE PAGE_SIZE
 219.199 @@ -443,30 +420,24 @@ static inline void __set_pte(pte_t *dst,
 219.200  
 219.201  static inline int make_readonly(unsigned long paddr)
 219.202  {
 219.203 -    int readonly = 0;
 219.204 -
 219.205 -    /* Make new page tables read-only. */
 219.206 -    if ((paddr < ((table_start << PAGE_SHIFT) + tables_space)) &&
 219.207 -        (paddr >= (table_start << PAGE_SHIFT)))
 219.208 -        readonly = 1;
 219.209 +	int readonly = 0;
 219.210  
 219.211 -    /* Make old page tables read-only. */
 219.212 -    if ((paddr < ((xen_start_info.pt_base - __START_KERNEL_map) +
 219.213 -                  (xen_start_info.nr_pt_frames << PAGE_SHIFT))) &&
 219.214 -        (paddr >= (xen_start_info.pt_base - __START_KERNEL_map)))
 219.215 -        readonly = 1;
 219.216 +	/* Make old and new page tables read-only. */
 219.217 +	if ((paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
 219.218 +	    && (paddr < ((table_start << PAGE_SHIFT) + tables_space)))
 219.219 +		readonly = 1;
 219.220 +	/*
 219.221 +	 * No need for writable mapping of kernel image. This also ensures that
 219.222 +	 * page and descriptor tables embedded inside don't have writable
 219.223 +	 * mappings. 
 219.224 +	 */
 219.225 +	if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end)))
 219.226 +		readonly = 1;
 219.227  
 219.228 -    /*
 219.229 -     * No need for writable mapping of kernel image. This also ensures that
 219.230 -     * page and descriptor tables embedded inside don't have writable mappings.
 219.231 -     */
 219.232 -    if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end)))
 219.233 -        readonly = 1;
 219.234 -
 219.235 -    return readonly;
 219.236 +	return readonly;
 219.237  }
 219.238  
 219.239 -void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
 219.240 +static void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
 219.241  { 
 219.242          long i, j, k; 
 219.243          unsigned long paddr;
 219.244 @@ -485,7 +456,7 @@ void __init phys_pud_init(pud_t *pud, un
 219.245  			break;
 219.246  		} 
 219.247  
 219.248 -		pmd = alloc_low_page(&pmd_phys);
 219.249 +		pmd = alloc_static_page(&pmd_phys);
 219.250                  make_page_readonly(pmd);
 219.251                  xen_pmd_pin(pmd_phys);
 219.252  		set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
 219.253 @@ -499,19 +470,20 @@ void __init phys_pud_init(pud_t *pud, un
 219.254  					set_pmd(pmd,  __pmd(0)); 
 219.255  				break;
 219.256  			}
 219.257 -                        pte = alloc_low_page(&pte_phys);
 219.258 +                        pte = alloc_static_page(&pte_phys);
 219.259                          pte_save = pte;
 219.260                          for (k = 0; k < PTRS_PER_PTE; pte++, k++, paddr += PTE_SIZE) {
 219.261 +                                if ((paddr >= end) ||
 219.262 +                                    ((paddr >> PAGE_SHIFT) >=
 219.263 +                                     xen_start_info->nr_pages)) { 
 219.264 +                                        __set_pte(pte, __pte(0)); 
 219.265 +                                        continue;
 219.266 +                                }
 219.267                                  if (make_readonly(paddr)) {
 219.268                                          __set_pte(pte, 
 219.269                                                  __pte(paddr | (_KERNPG_TABLE & ~_PAGE_RW)));
 219.270                                          continue;
 219.271                                  }
 219.272 -                                if (paddr >= end) { 
 219.273 -                                        for (; k < PTRS_PER_PTE; k++, pte++)
 219.274 -                                                __set_pte(pte, __pte(0)); 
 219.275 -                                        break;
 219.276 -                                }
 219.277                                  __set_pte(pte, __pte(paddr | _KERNPG_TABLE));
 219.278                          }
 219.279                          pte = pte_save;
 219.280 @@ -525,15 +497,16 @@ void __init phys_pud_init(pud_t *pud, un
 219.281  
 219.282  static void __init find_early_table_space(unsigned long end)
 219.283  {
 219.284 -        unsigned long puds, pmds, ptes; 
 219.285 +	unsigned long puds, pmds, ptes; 
 219.286  
 219.287  	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
 219.288  	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
 219.289 -        ptes = (end + PTE_SIZE - 1) >> PAGE_SHIFT;
 219.290 +	ptes = (end + PTE_SIZE - 1) >> PAGE_SHIFT;
 219.291  
 219.292 -        tables_space = round_up(puds * 8, PAGE_SIZE) + 
 219.293 -	    		  round_up(pmds * 8, PAGE_SIZE) + 
 219.294 -	    		  round_up(ptes * 8, PAGE_SIZE); 
 219.295 +	tables_space =
 219.296 +		round_up(puds * 8, PAGE_SIZE) + 
 219.297 +		round_up(pmds * 8, PAGE_SIZE) + 
 219.298 +		round_up(ptes * 8, PAGE_SIZE); 
 219.299  }
 219.300  
 219.301  void __init xen_init_pt(void)
 219.302 @@ -549,7 +522,7 @@ void __init xen_init_pt(void)
 219.303  	memset((void *)level2_kernel_pgt, 0, PAGE_SIZE);
 219.304  
 219.305  	/* Find the initial pte page that was built for us. */
 219.306 -	page = (unsigned long *)xen_start_info.pt_base;
 219.307 +	page = (unsigned long *)xen_start_info->pt_base;
 219.308  	addr = page[pgd_index(__START_KERNEL_map)];
 219.309  	addr_to_page(addr, page);
 219.310  	addr = page[pud_index(__START_KERNEL_map)];
 219.311 @@ -579,66 +552,59 @@ void __init xen_init_pt(void)
 219.312  		mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
 219.313  }
 219.314  
 219.315 -/*
 219.316 - * Extend kernel mapping to access pages for page tables.  The initial
 219.317 - * mapping done by Xen is minimal (e.g. 8MB) and we need to extend the
 219.318 - * mapping for early initialization.
 219.319 - */
 219.320 -static unsigned long current_size, extended_size;
 219.321 -
 219.322  void __init extend_init_mapping(void) 
 219.323  {
 219.324  	unsigned long va = __START_KERNEL_map;
 219.325  	unsigned long phys, addr, *pte_page;
 219.326 -        pmd_t *pmd;
 219.327 +	pmd_t *pmd;
 219.328  	pte_t *pte, new_pte;
 219.329 -	unsigned long *page = (unsigned long *) init_level4_pgt;
 219.330 -	int i;
 219.331 +	unsigned long *page = (unsigned long *)init_level4_pgt;
 219.332  
 219.333  	addr = page[pgd_index(va)];
 219.334  	addr_to_page(addr, page);
 219.335  	addr = page[pud_index(va)];
 219.336  	addr_to_page(addr, page);
 219.337  
 219.338 -	for (;;) {
 219.339 -		pmd = (pmd_t *)&page[pmd_index(va)];
 219.340 -		if (!pmd_present(*pmd))
 219.341 -			break;
 219.342 -		addr = page[pmd_index(va)];
 219.343 -		addr_to_page(addr, pte_page);
 219.344 -		for (i = 0; i < PTRS_PER_PTE; i++) {
 219.345 -			pte = (pte_t *) &pte_page[pte_index(va)];
 219.346 -			if (!pte_present(*pte))
 219.347 -				break;
 219.348 -			va += PAGE_SIZE;
 219.349 -			current_size += PAGE_SIZE;
 219.350 -		}
 219.351 +	/* Kill mapping of low 1MB. */
 219.352 +	while (va < (unsigned long)&_text) {
 219.353 +		HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
 219.354 +		va += PAGE_SIZE;
 219.355  	}
 219.356  
 219.357 -	while (va < __START_KERNEL_map + current_size + tables_space) {
 219.358 -		pmd = (pmd_t *) &page[pmd_index(va)];
 219.359 -		if (!pmd_none(*pmd))
 219.360 -			continue;
 219.361 -		pte_page = (unsigned long *) alloc_static_page(&phys);
 219.362 -		make_page_readonly(pte_page);
 219.363 -		xen_pte_pin(phys);
 219.364 -		set_pmd(pmd, __pmd(phys | _KERNPG_TABLE | _PAGE_USER));
 219.365 -		for (i = 0; i < PTRS_PER_PTE; i++, va += PAGE_SIZE) {
 219.366 +	/* Ensure init mappings cover kernel text/data and initial tables. */
 219.367 +	while (va < (__START_KERNEL_map
 219.368 +		     + (start_pfn << PAGE_SHIFT)
 219.369 +		     + tables_space)) {
 219.370 +		pmd = (pmd_t *)&page[pmd_index(va)];
 219.371 +		if (pmd_none(*pmd)) {
 219.372 +			pte_page = alloc_static_page(&phys);
 219.373 +			make_page_readonly(pte_page);
 219.374 +			xen_pte_pin(phys);
 219.375 +			set_pmd(pmd, __pmd(phys | _KERNPG_TABLE | _PAGE_USER));
 219.376 +		} else {
 219.377 +			addr = page[pmd_index(va)];
 219.378 +			addr_to_page(addr, pte_page);
 219.379 +		}
 219.380 +		pte = (pte_t *)&pte_page[pte_index(va)];
 219.381 +		if (pte_none(*pte)) {
 219.382  			new_pte = pfn_pte(
 219.383  				(va - __START_KERNEL_map) >> PAGE_SHIFT, 
 219.384  				__pgprot(_KERNPG_TABLE | _PAGE_USER));
 219.385 -			pte = (pte_t *)&pte_page[pte_index(va)];
 219.386  			xen_l1_entry_update(pte, new_pte);
 219.387 -			extended_size += PAGE_SIZE;
 219.388  		}
 219.389 +		va += PAGE_SIZE;
 219.390  	}
 219.391  
 219.392 -	/* Kill mapping of low 1MB. */
 219.393 -	for (va = __START_KERNEL_map; va < (unsigned long)&_text; va += PAGE_SIZE)
 219.394 +	/* Finally, blow away any spurious initial mappings. */
 219.395 +	while (1) {
 219.396 +		pmd = (pmd_t *)&page[pmd_index(va)];
 219.397 +		if (pmd_none(*pmd))
 219.398 +			break;
 219.399  		HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
 219.400 +		va += PAGE_SIZE;
 219.401 +	}
 219.402  }
 219.403  
 219.404 -
 219.405  /* Setup the direct mapping of the physical memory at PAGE_OFFSET.
 219.406     This runs before bootmem is initialized and gets pages directly from the 
 219.407     physical memory. To access them they are temporarily mapped. */
 219.408 @@ -650,34 +616,31 @@ void __init init_memory_mapping(unsigned
 219.409  
 219.410  	find_early_table_space(end);
 219.411  	extend_init_mapping();
 219.412 -	start_pfn = current_size >> PAGE_SHIFT;
 219.413  
 219.414  	table_start = start_pfn;
 219.415 -	table_end = table_start;
 219.416  
 219.417  	start = (unsigned long)__va(start);
 219.418  	end = (unsigned long)__va(end);
 219.419  
 219.420  	for (; start < end; start = next) {
 219.421  		unsigned long pud_phys; 
 219.422 -                pud_t *pud = alloc_low_page(&pud_phys);
 219.423 -                make_page_readonly(pud);
 219.424 -                xen_pud_pin(pud_phys);
 219.425 +		pud_t *pud = alloc_static_page(&pud_phys);
 219.426 +		make_page_readonly(pud);
 219.427 +		xen_pud_pin(pud_phys);
 219.428  		next = start + PGDIR_SIZE;
 219.429  		if (next > end) 
 219.430  			next = end; 
 219.431  		phys_pud_init(pud, __pa(start), __pa(next));
 219.432  		set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
 219.433 -	} 
 219.434 +	}
 219.435  
 219.436 -	printk("kernel direct mapping tables upto %lx @ %lx-%lx\n", end, 
 219.437 -	       table_start<<PAGE_SHIFT, 
 219.438 -	       table_end<<PAGE_SHIFT);
 219.439 +	printk("kernel direct mapping tables upto %lx @ %lx-%lx\n",
 219.440 +	       __pa(end), table_start<<PAGE_SHIFT, start_pfn<<PAGE_SHIFT);
 219.441  
 219.442 -        start_pfn = ((current_size + extended_size) >> PAGE_SHIFT);
 219.443 +	BUG_ON(start_pfn != (table_start + (tables_space >> PAGE_SHIFT)));
 219.444  
 219.445  	__flush_tlb_all();
 219.446 -        init_mapping_done = 1;
 219.447 +	init_mapping_done = 1;
 219.448  }
 219.449  
 219.450  extern struct x8664_pda cpu_pda[NR_CPUS];
 219.451 @@ -708,7 +671,7 @@ void __init paging_init(void)
 219.452  		free_area_init(zones_size);
 219.453  	}
 219.454  
 219.455 -        set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
 219.456 +        set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
 219.457          HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
 219.458  
 219.459          memset(empty_zero_page, 0, sizeof(empty_zero_page));
 219.460 @@ -719,7 +682,7 @@ void __init paging_init(void)
 219.461  		int i;
 219.462          /* Setup mapping of lower 1st MB */
 219.463  		for (i = 0; i < NR_FIX_ISAMAPS; i++)
 219.464 -			if (xen_start_info.flags & SIF_PRIVILEGED)
 219.465 +			if (xen_start_info->flags & SIF_PRIVILEGED)
 219.466  				set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
 219.467  			else
 219.468  				__set_fixmap(FIX_ISAMAP_BEGIN - i,
 219.469 @@ -767,9 +730,6 @@ void __init clear_kernel_mapping(unsigne
 219.470  
 219.471  static inline int page_is_ram (unsigned long pagenr)
 219.472  {
 219.473 -        if (pagenr < start_pfn || pagenr >= end_pfn)
 219.474 -                return 0;
 219.475 -
 219.476          return 1;
 219.477  }
 219.478  
 219.479 @@ -1005,3 +965,13 @@ int in_gate_area_no_task(unsigned long a
 219.480  {
 219.481  	return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
 219.482  }
 219.483 +
 219.484 +/*
 219.485 + * Local variables:
 219.486 + *  c-file-style: "linux"
 219.487 + *  indent-tabs-mode: t
 219.488 + *  c-indent-level: 8
 219.489 + *  c-basic-offset: 8
 219.490 + *  tab-width: 8
 219.491 + * End:
 219.492 + */
   225.1 --- a/linux-2.6-xen-sparse/drivers/char/mem.c	Thu Sep 08 09:18:40 2005 -0600
   225.2 +++ b/linux-2.6-xen-sparse/drivers/char/mem.c	Fri Sep 09 10:30:54 2005 -0600
   225.3 @@ -231,7 +231,7 @@ static ssize_t write_mem(struct file * f
   225.4  }
   225.5  #endif
   225.6  
   225.7 -static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
   225.8 +static int mmap_mem(struct file * file, struct vm_area_struct * vma)
   225.9  {
  225.10  #if defined(__HAVE_PHYS_MEM_ACCESS_PROT)
  225.11  	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
  225.12 @@ -258,7 +258,6 @@ static int mmap_kmem(struct file * file,
  225.13  	return 0;
  225.14  }
  225.15  
  225.16 -#if 0
  225.17  static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
  225.18  {
  225.19          unsigned long long val;
  225.20 @@ -275,7 +274,6 @@ static int mmap_kmem(struct file * file,
  225.21  	vma->vm_pgoff = __pa(val) >> PAGE_SHIFT;
  225.22  	return mmap_mem(file, vma);
  225.23  }
  225.24 -#endif
  225.25  
  225.26  extern long vread(char *buf, char *addr, unsigned long count);
  225.27  extern long vwrite(char *buf, char *addr, unsigned long count);
  225.28 @@ -731,7 +729,7 @@ static struct file_operations mem_fops =
  225.29  	.llseek		= memory_lseek,
  225.30  	.read		= read_mem,
  225.31  	.write		= write_mem,
  225.32 -	.mmap		= mmap_kmem,
  225.33 +	.mmap		= mmap_mem,
  225.34  	.open		= open_mem,
  225.35  };
  225.36  #else
   226.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   226.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig.domU	Fri Sep 09 10:30:54 2005 -0600
   226.3 @@ -0,0 +1,30 @@
   226.4 +#
   226.5 +# TPM device configuration
   226.6 +#
   226.7 +
   226.8 +menu "TPM devices"
   226.9 +
  226.10 +config TCG_TPM
  226.11 +	tristate "TPM Support for XEN"
  226.12 +	depends on ARCH_XEN && !XEN_PHYSDEV_ACCESS
  226.13 +	---help---
  226.14 +	  If you want to make TPM security available in your system,
  226.15 +	  say Yes and it will be accessible from within a user domain.  For
  226.16 +	  more information see <http://www.trustedcomputinggroup.org>.
  226.17 +	  An implementation of the Trusted Software Stack (TSS), the
  226.18 +	  userspace enablement piece of the specification, can be
  226.19 +	  obtained at: <http://sourceforge.net/projects/trousers>.  To
  226.20 +	  compile this driver as a module, choose M here; the module
  226.21 +	  will be called tpm. If unsure, say N.
  226.22 +
  226.23 +config TCG_XEN
  226.24 +	tristate "XEN TPM Interface"
  226.25 +	depends on TCG_TPM && ARCH_XEN && XEN_TPMDEV_FRONTEND
  226.26 +	---help---
  226.27 +	  If you want to make TPM support available to a Xen
  226.28 +	  user domain, say Yes and it will
  226.29 +          be accessible from within Linux. To compile this driver
  226.30 +          as a module, choose M here; the module will be called
  226.31 +          tpm_xen.
  226.32 +
  226.33 +endmenu
   227.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   227.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/Makefile	Fri Sep 09 10:30:54 2005 -0600
   227.3 @@ -0,0 +1,12 @@
   227.4 +#
   227.5 +# Makefile for the kernel tpm device drivers.
   227.6 +#
   227.7 +ifeq ($(CONFIG_XEN_PHYSDEV_ACCESS),y)
   227.8 +obj-$(CONFIG_TCG_TPM) += tpm.o
   227.9 +obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
  227.10 +obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
  227.11 +obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
  227.12 +else
  227.13 +obj-$(CONFIG_TCG_TPM) += tpm_nopci.o
  227.14 +obj-$(CONFIG_TCG_XEN) += tpm_xen.o
  227.15 +endif
   228.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   228.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c	Fri Sep 09 10:30:54 2005 -0600
   228.3 @@ -0,0 +1,627 @@
   228.4 +/*
   228.5 + * Copyright (C) 2004 IBM Corporation
   228.6 + *
   228.7 + * Authors:
   228.8 + * Leendert van Doorn <leendert@watson.ibm.com>
   228.9 + * Dave Safford <safford@watson.ibm.com>
  228.10 + * Reiner Sailer <sailer@watson.ibm.com>
  228.11 + * Kylene Hall <kjhall@us.ibm.com>
  228.12 + *
  228.13 + * Maintained by: <tpmdd_devel@lists.sourceforge.net>
  228.14 + *
  228.15 + * Device driver for TCG/TCPA TPM (trusted platform module).
  228.16 + * Specifications at www.trustedcomputinggroup.org
  228.17 + *
  228.18 + * This program is free software; you can redistribute it and/or
  228.19 + * modify it under the terms of the GNU General Public License as
  228.20 + * published by the Free Software Foundation, version 2 of the
  228.21 + * License.
  228.22 + *
  228.23 + * Note, the TPM chip is not interrupt driven (only polling)
  228.24 + * and can have very long timeouts (minutes!). Hence the unusual
  228.25 + * calls to schedule_timeout.
  228.26 + *
  228.27 + */
  228.28 +
  228.29 +#include <linux/sched.h>
  228.30 +#include <linux/poll.h>
  228.31 +#include <linux/spinlock.h>
  228.32 +#include "tpm.h"
  228.33 +
  228.34 +#define	TPM_MINOR			224	/* officially assigned */
  228.35 +
  228.36 +#define	TPM_BUFSIZE			2048
  228.37 +