ia64/xen-unstable

changeset 6722: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:
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/docs/misc/vtpm.txt	Fri Sep 09 10:30:54 2005 -0600
     4.3 @@ -0,0 +1,122 @@
     4.4 +Copyright: IBM Corporation (C), Intel Corporation
     4.5 +17 August 2005
     4.6 +Authors: Stefan Berger <stefanb@us.ibm.com> (IBM), 
     4.7 +         Employees of Intel Corp
     4.8 +
     4.9 +This document gives a short introduction to the virtual TPM support
    4.10 +in XEN and goes as far as connecting a user domain to a virtual TPM
    4.11 +instance and doing a short test to verify success. It is assumed
    4.12 +that the user is fairly familiar with compiling and installing XEN
    4.13 +and Linux on a machine. 
    4.14 + 
    4.15 +Production Prerequisites: An x86-based machine machine with an ATMEL or
    4.16 +National Semiconductor (NSC) TPM on the motherboard.
    4.17 +Development Prerequisites: An emulator for TESTING ONLY is provided
    4.18 +
    4.19 +
    4.20 +Compiling XEN tree:
    4.21 +-------------------
    4.22 +
    4.23 +Compile the XEN tree as usual.
    4.24 +
    4.25 +make uninstall; make mrproper; make install 
    4.26 +
    4.27 +After compiling the tree, verify that in the linux-2.6.XX-xen0/.config 
    4.28 +file at least the following entries are set as below (they should be set
    4.29 +by default):
    4.30 +
    4.31 +CONFIG_XEN_TPMDEV_BACKEND=y
    4.32 +CONFIG_XEN_TPMDEV_GRANT=y
    4.33 +
    4.34 +CONFIG_TCG_TPM=m
    4.35 +CONFIG_TCG_NSC=m
    4.36 +CONFIG_TCG_ATMEL=m
    4.37 +
    4.38 +
    4.39 +Verify that in the linux-2.6.XX-xenU/.config file at least the 
    4.40 +Following entries are set as below (they should be set by default):
    4.41 +
    4.42 +CONFIG_XEN_TPMDEV_FRONTEND=y
    4.43 +CONFIG_XEN_TPMDEV_GRANT=y
    4.44 +
    4.45 +CONFIG_TCG_TPM=y
    4.46 +CONFIG_TCG_XEN=y
    4.47 +
    4.48 +
    4.49 +Reboot the machine with the created XEN-0 kernel.
    4.50 +
    4.51 +Note: If you do not want any TPM-related code compiled into your
    4.52 +kernel or built as module then comment all the above lines like
    4.53 +this example:
    4.54 +# CONFIG_TCG_TPM is not set
    4.55 +
    4.56 +
    4.57 +Modifying VM Configuration files:
    4.58 +---------------------------------
    4.59 +
    4.60 +VM configuration files need to be adapted to make a TPM instance
    4.61 +available to a user domain. The following VM configuration file is
    4.62 +an example of how a user domain can be configured to have a TPM
    4.63 +available. It works similar to making a network interface
    4.64 +available to a domain.
    4.65 +
    4.66 +kernel = "/boot/vmlinuz-2.6.12-xenU"
    4.67 +ramdisk = "/xen/initrd_domU/U1_ramdisk.img"
    4.68 +memory = 32
    4.69 +name = "TPMUserDomain0"
    4.70 +vtpm = ['instance=1,backend=0']
    4.71 +root = "/dev/ram0 cosole=tty ro"
    4.72 +vif = ['backend=0']
    4.73 +
    4.74 +In the above configuration file the line 'vtpm = ...' provides
    4.75 +information about the domain where the virtual TPM is running and
    4.76 +where the TPM backend has been compiled into - this has to be 
    4.77 +domain 0  at the moment - and which TPM instance the user domain
    4.78 +is supposed to talk to. Note that each running VM must use a 
    4.79 +different instance and that using instance 0 is NOT allowed.
    4.80 +
    4.81 +Note: If you do not want TPM functionality for your user domain simply
    4.82 +leave out the 'vtpm' line in the configuration file.
    4.83 +
    4.84 +
    4.85 +Running the TPM:
    4.86 +----------------
    4.87 +
    4.88 +To run the vTPM, dev device /dev/vtpm must be available.
    4.89 +Verify that 'ls -l /dev/vtpm' shows the following output:
    4.90 +
    4.91 +crw-------  1 root root 10, 225 Aug 11 06:58 /dev/vtpm
    4.92 +
    4.93 +If it is not available, run the following command as 'root'.
    4.94 +mknod /dev/vtpm c 10 225
    4.95 +
    4.96 +Make sure that the vTPM is running in domain 0. To do this run the
    4.97 +following
    4.98 +
    4.99 +/usr/bin/vtpm_managerd
   4.100 +
   4.101 +Start a user domain using the 'xm create' command. Once you are in the
   4.102 +shell of the user domain, you should be able to do the following:
   4.103 +
   4.104 +> cd /sys/devices/vtpm
   4.105 +> ls
   4.106 +cancel  caps   pcrs    pubek
   4.107 +> cat pcrs
   4.108 +PCR-00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.109 +PCR-01: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.110 +PCR-02: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.111 +PCR-03: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.112 +PCR-04: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.113 +PCR-05: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.114 +PCR-06: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.115 +PCR-07: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.116 +PCR-08: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   4.117 +[...]
   4.118 +
   4.119 +At this point the user domain has been sucessfully connected to its
   4.120 +virtual TPM instance.
   4.121 +
   4.122 +For further information please read the documentation in 
   4.123 +tools/vtpm_manager/README and tools/vtpm/README
   4.124 +
   4.125 +Stefan Berger and Employees of the Intel Corp
     5.1 --- a/extras/mini-os/Makefile	Thu Sep 08 09:18:40 2005 -0600
     5.2 +++ b/extras/mini-os/Makefile	Fri Sep 09 10:30:54 2005 -0600
     5.3 @@ -31,16 +31,18 @@ TARGET := mini-os
     5.4  OBJS := $(TARGET_ARCH).o
     5.5  OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
     5.6  OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
     5.7 -
     5.8 +OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
     5.9 +										   
    5.10  HDRS := $(wildcard include/*.h)
    5.11  HDRS += $(wildcard include/xen/*.h)
    5.12  
    5.13  default: $(TARGET)
    5.14  
    5.15 -xen-public:
    5.16 +links:
    5.17  	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
    5.18 -
    5.19 -$(TARGET): xen-public $(OBJS)
    5.20 +	[ -e xenbus/xenstored.h ] || ln -sf ../../../tools/xenstore/xenstored.h xenbus/xenstored.h
    5.21 +	
    5.22 +$(TARGET): links $(OBJS)
    5.23  	$(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o $@.elf
    5.24  	gzip -f -9 -c $@.elf >$@.gz
    5.25  
    5.26 @@ -55,3 +57,4 @@ clean:
    5.27  %.o: %.S $(HDRS) Makefile
    5.28  	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
    5.29  
    5.30 +
     6.1 --- a/extras/mini-os/README	Thu Sep 08 09:18:40 2005 -0600
     6.2 +++ b/extras/mini-os/README	Fri Sep 09 10:30:54 2005 -0600
     6.3 @@ -23,13 +23,8 @@ Stuff it doesn't show:
     6.4  
     6.5  - to build it just type make.
     6.6  
     6.7 -- copy image.final somewhere where dom0 can access it
     6.8 +- to start it do the following in domain0 (assuming xend is running)
     6.9 +  # xm create domain_config
    6.10  
    6.11 -- in dom0
    6.12 -  # xi_create 16000 test
    6.13 -    <domid>
    6.14 -  # xi_build <domid> image.final 0
    6.15 -  # xi_start <domid>
    6.16 -
    6.17 -this prints out a bunch of stuff and then every 1000 timer interrupts the
    6.18 -system time.
    6.19 +this starts the kernel and prints out a bunch of stuff and then every
    6.20 +1000 timer interrupts the system time.
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/extras/mini-os/domain_config	Fri Sep 09 10:30:54 2005 -0600
     7.3 @@ -0,0 +1,17 @@
     7.4 +#  -*- mode: python; -*-
     7.5 +#============================================================================
     7.6 +# Python configuration setup for 'xm create'.
     7.7 +# This script sets the parameters used when a domain is created using 'xm create'.
     7.8 +# You use a separate script for each domain you want to create, or 
     7.9 +# you can set the parameters for the domain on the xm command line.
    7.10 +#============================================================================
    7.11 +
    7.12 +#----------------------------------------------------------------------------
    7.13 +# Kernel image file.
    7.14 +kernel = "mini-os.elf"
    7.15 +
    7.16 +# Initial memory allocation (in megabytes) for the new domain.
    7.17 +memory = 32
    7.18 +
    7.19 +# A name for your domain. All domains must have different names.
    7.20 +name = "Mini-OS"
     8.1 --- a/extras/mini-os/events.c	Thu Sep 08 09:18:40 2005 -0600
     8.2 +++ b/extras/mini-os/events.c	Fri Sep 09 10:30:54 2005 -0600
     8.3 @@ -17,13 +17,13 @@
     8.4   */
     8.5  
     8.6  #include <os.h>
     8.7 +#include <mm.h>
     8.8  #include <hypervisor.h>
     8.9  #include <events.h>
    8.10  #include <lib.h>
    8.11  
    8.12 -#include <xen/event_channel.h>
    8.13  static ev_action_t ev_actions[NR_EVS];
    8.14 -void default_handler(u32 port, struct pt_regs *regs);
    8.15 +void default_handler(int port, struct pt_regs *regs);
    8.16  
    8.17  
    8.18  /*
    8.19 @@ -32,7 +32,6 @@ void default_handler(u32 port, struct pt
    8.20  int do_event(u32 port, struct pt_regs *regs)
    8.21  {
    8.22      ev_action_t  *action;
    8.23 -
    8.24      if (port >= NR_EVS) {
    8.25          printk("Port number too large: %d\n", port);
    8.26          return 0;
    8.27 @@ -57,11 +56,23 @@ int do_event(u32 port, struct pt_regs *r
    8.28  
    8.29  }
    8.30  
    8.31 +void bind_evtchn( u32 port, void (*handler)(int, struct pt_regs *) )
    8.32 +{
    8.33 + 	if(ev_actions[port].handler)
    8.34 +        printk("WARN: Handler for port %d already registered, replacing\n",
    8.35 +				port);
    8.36 +
    8.37 +	ev_actions[port].handler = handler;
    8.38 +	ev_actions[port].status &= ~EVS_DISABLED;	  
    8.39 + 
    8.40 +	/* Finally unmask the port */
    8.41 +	unmask_evtchn(port);
    8.42 +}
    8.43 +
    8.44  int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) )
    8.45  {
    8.46  	evtchn_op_t op;
    8.47  	int ret = 0;
    8.48 -	u32 port;
    8.49  
    8.50  	/* Try to bind the virq to a port */
    8.51  	op.cmd = EVTCHNOP_bind_virq;
    8.52 @@ -73,22 +84,13 @@ int bind_virq( u32 virq, void (*handler)
    8.53  		printk("Failed to bind virtual IRQ %d\n", virq);
    8.54  		goto out;
    8.55      }
    8.56 -
    8.57 -    port = op.u.bind_virq.port;
    8.58 -	
    8.59 -	if(ev_actions[port].handler)
    8.60 -        printk("WARN: Handler for port %d already registered, replacing\n",
    8.61 -				port);
    8.62 -
    8.63 -	ev_actions[port].handler = handler;
    8.64 -	ev_actions[port].status &= ~EVS_DISABLED;
    8.65 -	
    8.66 -	/* Finally unmask the port */
    8.67 -	unmask_evtchn(port);
    8.68 +    bind_evtchn(op.u.bind_virq.port, handler);	
    8.69  out:
    8.70  	return ret;
    8.71  }
    8.72  
    8.73 +
    8.74 +
    8.75  /*
    8.76   * Initially all events are without a handler and disabled
    8.77   */
    8.78 @@ -100,10 +102,10 @@ void init_events(void)
    8.79      for ( i = 0; i < NR_EVS; i++ )
    8.80      {
    8.81          ev_actions[i].status  = EVS_DISABLED;
    8.82 -        ev_actions[i].handler = NULL;
    8.83 +        ev_actions[i].handler = default_handler;
    8.84      }
    8.85  }
    8.86  
    8.87 -void default_handler(u32 port, struct pt_regs *regs) {
    8.88 +void default_handler(int port, struct pt_regs *regs) {
    8.89      printk("[Port %d] - event received\n", port);
    8.90  }
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/extras/mini-os/include/ctype.h	Fri Sep 09 10:30:54 2005 -0600
     9.3 @@ -0,0 +1,79 @@
     9.4 +#ifndef _CTYPE_H
     9.5 +#define _CTYPE_H
     9.6 +
     9.7 +/*
     9.8 + * NOTE! This ctype does not handle EOF like the standard C
     9.9 + * library is required to.
    9.10 + */
    9.11 +
    9.12 +#define _U	0x01	/* upper */
    9.13 +#define _L	0x02	/* lower */
    9.14 +#define _D	0x04	/* digit */
    9.15 +#define _C	0x08	/* cntrl */
    9.16 +#define _P	0x10	/* punct */
    9.17 +#define _S	0x20	/* white space (space/lf/tab) */
    9.18 +#define _X	0x40	/* hex digit */
    9.19 +#define _SP	0x80	/* hard space (0x20) */
    9.20 +
    9.21 +
    9.22 +unsigned char _ctype[] = {
    9.23 +_C,_C,_C,_C,_C,_C,_C,_C,                        /* 0-7 */
    9.24 +_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,         /* 8-15 */
    9.25 +_C,_C,_C,_C,_C,_C,_C,_C,                        /* 16-23 */
    9.26 +_C,_C,_C,_C,_C,_C,_C,_C,                        /* 24-31 */
    9.27 +_S|_SP,_P,_P,_P,_P,_P,_P,_P,                    /* 32-39 */
    9.28 +_P,_P,_P,_P,_P,_P,_P,_P,                        /* 40-47 */
    9.29 +_D,_D,_D,_D,_D,_D,_D,_D,                        /* 48-55 */
    9.30 +_D,_D,_P,_P,_P,_P,_P,_P,                        /* 56-63 */
    9.31 +_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U,      /* 64-71 */
    9.32 +_U,_U,_U,_U,_U,_U,_U,_U,                        /* 72-79 */
    9.33 +_U,_U,_U,_U,_U,_U,_U,_U,                        /* 80-87 */
    9.34 +_U,_U,_U,_P,_P,_P,_P,_P,                        /* 88-95 */
    9.35 +_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,      /* 96-103 */
    9.36 +_L,_L,_L,_L,_L,_L,_L,_L,                        /* 104-111 */
    9.37 +_L,_L,_L,_L,_L,_L,_L,_L,                        /* 112-119 */
    9.38 +_L,_L,_L,_P,_P,_P,_P,_C,                        /* 120-127 */
    9.39 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,                /* 128-143 */
    9.40 +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,                /* 144-159 */
    9.41 +_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
    9.42 +_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
    9.43 +_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
    9.44 +_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
    9.45 +_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
    9.46 +_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
    9.47 +
    9.48 +#define __ismask(x) (_ctype[(int)(unsigned char)(x)])
    9.49 +
    9.50 +#define isalnum(c)	((__ismask(c)&(_U|_L|_D)) != 0)
    9.51 +#define isalpha(c)	((__ismask(c)&(_U|_L)) != 0)
    9.52 +#define iscntrl(c)	((__ismask(c)&(_C)) != 0)
    9.53 +#define isdigit(c)	((__ismask(c)&(_D)) != 0)
    9.54 +#define isgraph(c)	((__ismask(c)&(_P|_U|_L|_D)) != 0)
    9.55 +#define islower(c)	((__ismask(c)&(_L)) != 0)
    9.56 +#define isprint(c)	((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
    9.57 +#define ispunct(c)	((__ismask(c)&(_P)) != 0)
    9.58 +#define isspace(c)	((__ismask(c)&(_S)) != 0)
    9.59 +#define isupper(c)	((__ismask(c)&(_U)) != 0)
    9.60 +#define isxdigit(c)	((__ismask(c)&(_D|_X)) != 0)
    9.61 +
    9.62 +#define isascii(c) (((unsigned char)(c))<=0x7f)
    9.63 +#define toascii(c) (((unsigned char)(c))&0x7f)
    9.64 +
    9.65 +static inline unsigned char __tolower(unsigned char c)
    9.66 +{
    9.67 +	if (isupper(c))
    9.68 +		c -= 'A'-'a';
    9.69 +	return c;
    9.70 +}
    9.71 +
    9.72 +static inline unsigned char __toupper(unsigned char c)
    9.73 +{
    9.74 +	if (islower(c))
    9.75 +		c -= 'a'-'A';
    9.76 +	return c;
    9.77 +}
    9.78 +
    9.79 +#define tolower(c) __tolower(c)
    9.80 +#define toupper(c) __toupper(c)
    9.81 +
    9.82 +#endif
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/extras/mini-os/include/err.h	Fri Sep 09 10:30:54 2005 -0600
    10.3 @@ -0,0 +1,31 @@
    10.4 +#ifndef _ERR_H
    10.5 +#define _ERR_H
    10.6 +
    10.7 +#include <errno.h>
    10.8 +
    10.9 +/*
   10.10 + * Kernel pointers have redundant information, so we can use a
   10.11 + * scheme where we can return either an error code or a dentry
   10.12 + * pointer with the same return value.
   10.13 + *
   10.14 + * This should be a per-architecture thing, to allow different
   10.15 + * error and pointer decisions.
   10.16 + */
   10.17 +#define IS_ERR_VALUE(x) ((x) > (unsigned long)-1000L)
   10.18 +
   10.19 +static inline void *ERR_PTR(long error)
   10.20 +{
   10.21 +	return (void *) error;
   10.22 +}
   10.23 +
   10.24 +static inline long PTR_ERR(const void *ptr)
   10.25 +{
   10.26 +	return (long) ptr;
   10.27 +}
   10.28 +
   10.29 +static inline long IS_ERR(const void *ptr)
   10.30 +{
   10.31 +	return IS_ERR_VALUE((unsigned long)ptr);
   10.32 +}
   10.33 +
   10.34 +#endif /* _LINUX_ERR_H */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/extras/mini-os/include/errno-base.h	Fri Sep 09 10:30:54 2005 -0600
    11.3 @@ -0,0 +1,39 @@
    11.4 +#ifndef _ERRNO_BASE_H
    11.5 +#define _ERRNO_BASE_H
    11.6 +
    11.7 +#define	EPERM		 1	/* Operation not permitted */
    11.8 +#define	ENOENT		 2	/* No such file or directory */
    11.9 +#define	ESRCH		 3	/* No such process */
   11.10 +#define	EINTR		 4	/* Interrupted system call */
   11.11 +#define	EIO		 5	/* I/O error */
   11.12 +#define	ENXIO		 6	/* No such device or address */
   11.13 +#define	E2BIG		 7	/* Argument list too long */
   11.14 +#define	ENOEXEC		 8	/* Exec format error */
   11.15 +#define	EBADF		 9	/* Bad file number */
   11.16 +#define	ECHILD		10	/* No child processes */
   11.17 +#define	EAGAIN		11	/* Try again */
   11.18 +#define	ENOMEM		12	/* Out of memory */
   11.19 +#define	EACCES		13	/* Permission denied */
   11.20 +#define	EFAULT		14	/* Bad address */
   11.21 +#define	ENOTBLK		15	/* Block device required */
   11.22 +#define	EBUSY		16	/* Device or resource busy */
   11.23 +#define	EEXIST		17	/* File exists */
   11.24 +#define	EXDEV		18	/* Cross-device link */
   11.25 +#define	ENODEV		19	/* No such device */
   11.26 +#define	ENOTDIR		20	/* Not a directory */
   11.27 +#define	EISDIR		21	/* Is a directory */
   11.28 +#define	EINVAL		22	/* Invalid argument */
   11.29 +#define	ENFILE		23	/* File table overflow */
   11.30 +#define	EMFILE		24	/* Too many open files */
   11.31 +#define	ENOTTY		25	/* Not a typewriter */
   11.32 +#define	ETXTBSY		26	/* Text file busy */
   11.33 +#define	EFBIG		27	/* File too large */
   11.34 +#define	ENOSPC		28	/* No space left on device */
   11.35 +#define	ESPIPE		29	/* Illegal seek */
   11.36 +#define	EROFS		30	/* Read-only file system */
   11.37 +#define	EMLINK		31	/* Too many links */
   11.38 +#define	EPIPE		32	/* Broken pipe */
   11.39 +#define	EDOM		33	/* Math argument out of domain of func */
   11.40 +#define	ERANGE		34	/* Math result not representable */
   11.41 +
   11.42 +#endif
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/extras/mini-os/include/errno.h	Fri Sep 09 10:30:54 2005 -0600
    12.3 @@ -0,0 +1,109 @@
    12.4 +#ifndef _ERRNO_H
    12.5 +#define _ERRNO_H
    12.6 +
    12.7 +#include <errno-base.h>
    12.8 +
    12.9 +#define	EDEADLK		35	/* Resource deadlock would occur */
   12.10 +#define	ENAMETOOLONG	36	/* File name too long */
   12.11 +#define	ENOLCK		37	/* No record locks available */
   12.12 +#define	ENOSYS		38	/* Function not implemented */
   12.13 +#define	ENOTEMPTY	39	/* Directory not empty */
   12.14 +#define	ELOOP		40	/* Too many symbolic links encountered */
   12.15 +#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
   12.16 +#define	ENOMSG		42	/* No message of desired type */
   12.17 +#define	EIDRM		43	/* Identifier removed */
   12.18 +#define	ECHRNG		44	/* Channel number out of range */
   12.19 +#define	EL2NSYNC	45	/* Level 2 not synchronized */
   12.20 +#define	EL3HLT		46	/* Level 3 halted */
   12.21 +#define	EL3RST		47	/* Level 3 reset */
   12.22 +#define	ELNRNG		48	/* Link number out of range */
   12.23 +#define	EUNATCH		49	/* Protocol driver not attached */
   12.24 +#define	ENOCSI		50	/* No CSI structure available */
   12.25 +#define	EL2HLT		51	/* Level 2 halted */
   12.26 +#define	EBADE		52	/* Invalid exchange */
   12.27 +#define	EBADR		53	/* Invalid request descriptor */
   12.28 +#define	EXFULL		54	/* Exchange full */
   12.29 +#define	ENOANO		55	/* No anode */
   12.30 +#define	EBADRQC		56	/* Invalid request code */
   12.31 +#define	EBADSLT		57	/* Invalid slot */
   12.32 +
   12.33 +#define	EDEADLOCK	EDEADLK
   12.34 +
   12.35 +#define	EBFONT		59	/* Bad font file format */
   12.36 +#define	ENOSTR		60	/* Device not a stream */
   12.37 +#define	ENODATA		61	/* No data available */
   12.38 +#define	ETIME		62	/* Timer expired */
   12.39 +#define	ENOSR		63	/* Out of streams resources */
   12.40 +#define	ENONET		64	/* Machine is not on the network */
   12.41 +#define	ENOPKG		65	/* Package not installed */
   12.42 +#define	EREMOTE		66	/* Object is remote */
   12.43 +#define	ENOLINK		67	/* Link has been severed */
   12.44 +#define	EADV		68	/* Advertise error */
   12.45 +#define	ESRMNT		69	/* Srmount error */
   12.46 +#define	ECOMM		70	/* Communication error on send */
   12.47 +#define	EPROTO		71	/* Protocol error */
   12.48 +#define	EMULTIHOP	72	/* Multihop attempted */
   12.49 +#define	EDOTDOT		73	/* RFS specific error */
   12.50 +#define	EBADMSG		74	/* Not a data message */
   12.51 +#define	EOVERFLOW	75	/* Value too large for defined data type */
   12.52 +#define	ENOTUNIQ	76	/* Name not unique on network */
   12.53 +#define	EBADFD		77	/* File descriptor in bad state */
   12.54 +#define	EREMCHG		78	/* Remote address changed */
   12.55 +#define	ELIBACC		79	/* Can not access a needed shared library */
   12.56 +#define	ELIBBAD		80	/* Accessing a corrupted shared library */
   12.57 +#define	ELIBSCN		81	/* .lib section in a.out corrupted */
   12.58 +#define	ELIBMAX		82	/* Attempting to link in too many shared libraries */
   12.59 +#define	ELIBEXEC	83	/* Cannot exec a shared library directly */
   12.60 +#define	EILSEQ		84	/* Illegal byte sequence */
   12.61 +#define	ERESTART	85	/* Interrupted system call should be restarted */
   12.62 +#define	ESTRPIPE	86	/* Streams pipe error */
   12.63 +#define	EUSERS		87	/* Too many users */
   12.64 +#define	ENOTSOCK	88	/* Socket operation on non-socket */
   12.65 +#define	EDESTADDRREQ	89	/* Destination address required */
   12.66 +#define	EMSGSIZE	90	/* Message too long */
   12.67 +#define	EPROTOTYPE	91	/* Protocol wrong type for socket */
   12.68 +#define	ENOPROTOOPT	92	/* Protocol not available */
   12.69 +#define	EPROTONOSUPPORT	93	/* Protocol not supported */
   12.70 +#define	ESOCKTNOSUPPORT	94	/* Socket type not supported */
   12.71 +#define	EOPNOTSUPP	95	/* Operation not supported on transport endpoint */
   12.72 +#define	EPFNOSUPPORT	96	/* Protocol family not supported */
   12.73 +#define	EAFNOSUPPORT	97	/* Address family not supported by protocol */
   12.74 +#define	EADDRINUSE	98	/* Address already in use */
   12.75 +#define	EADDRNOTAVAIL	99	/* Cannot assign requested address */
   12.76 +#define	ENETDOWN	100	/* Network is down */
   12.77 +#define	ENETUNREACH	101	/* Network is unreachable */
   12.78 +#define	ENETRESET	102	/* Network dropped connection because of reset */
   12.79 +#define	ECONNABORTED	103	/* Software caused connection abort */
   12.80 +#define	ECONNRESET	104	/* Connection reset by peer */
   12.81 +#define	ENOBUFS		105	/* No buffer space available */
   12.82 +#define	EISCONN		106	/* Transport endpoint is already connected */
   12.83 +#define	ENOTCONN	107	/* Transport endpoint is not connected */
   12.84 +#define	ESHUTDOWN	108	/* Cannot send after transport endpoint shutdown */
   12.85 +#define	ETOOMANYREFS	109	/* Too many references: cannot splice */
   12.86 +#define	ETIMEDOUT	110	/* Connection timed out */
   12.87 +#define	ECONNREFUSED	111	/* Connection refused */
   12.88 +#define	EHOSTDOWN	112	/* Host is down */
   12.89 +#define	EHOSTUNREACH	113	/* No route to host */
   12.90 +#define	EALREADY	114	/* Operation already in progress */
   12.91 +#define	EINPROGRESS	115	/* Operation now in progress */
   12.92 +#define	ESTALE		116	/* Stale NFS file handle */
   12.93 +#define	EUCLEAN		117	/* Structure needs cleaning */
   12.94 +#define	ENOTNAM		118	/* Not a XENIX named type file */
   12.95 +#define	ENAVAIL		119	/* No XENIX semaphores available */
   12.96 +#define	EISNAM		120	/* Is a named type file */
   12.97 +#define	EREMOTEIO	121	/* Remote I/O error */
   12.98 +#define	EDQUOT		122	/* Quota exceeded */
   12.99 +
  12.100 +#define	ENOMEDIUM	123	/* No medium found */
  12.101 +#define	EMEDIUMTYPE	124	/* Wrong medium type */
  12.102 +#define	ECANCELED	125	/* Operation Canceled */
  12.103 +#define	ENOKEY		126	/* Required key not available */
  12.104 +#define	EKEYEXPIRED	127	/* Key has expired */
  12.105 +#define	EKEYREVOKED	128	/* Key has been revoked */
  12.106 +#define	EKEYREJECTED	129	/* Key was rejected by service */
  12.107 +
  12.108 +/* for robust mutexes */
  12.109 +#define	EOWNERDEAD	130	/* Owner died */
  12.110 +#define	ENOTRECOVERABLE	131	/* State not recoverable */
  12.111 +
  12.112 +#endif
    13.1 --- a/extras/mini-os/include/events.h	Thu Sep 08 09:18:40 2005 -0600
    13.2 +++ b/extras/mini-os/include/events.h	Fri Sep 09 10:30:54 2005 -0600
    13.3 @@ -20,6 +20,7 @@
    13.4  #define _EVENTS_H_
    13.5  
    13.6  #include<traps.h>
    13.7 +#include <xen/event_channel.h>
    13.8  
    13.9  #define NR_EVS 1024
   13.10  
   13.11 @@ -39,6 +40,16 @@ typedef struct _ev_action_t {
   13.12  /* prototypes */
   13.13  int do_event(u32 port, struct pt_regs *regs);
   13.14  int bind_virq( u32 virq, void (*handler)(int, struct pt_regs *) );
   13.15 +void bind_evtchn( u32 virq, void (*handler)(int, struct pt_regs *) );
   13.16  void init_events(void);
   13.17  
   13.18 +static inline int notify_via_evtchn(int port)
   13.19 +{
   13.20 +    evtchn_op_t op;
   13.21 +    op.cmd = EVTCHNOP_send;
   13.22 +    op.u.send.local_port = port;
   13.23 +    return HYPERVISOR_event_channel_op(&op);
   13.24 +}
   13.25 +
   13.26 +
   13.27  #endif /* _EVENTS_H_ */
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/extras/mini-os/include/fcntl.h	Fri Sep 09 10:30:54 2005 -0600
    14.3 @@ -0,0 +1,89 @@
    14.4 +#ifndef _I386_FCNTL_H
    14.5 +#define _I386_FCNTL_H
    14.6 +
    14.7 +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
    14.8 +   located on an ext2 file system */
    14.9 +#define O_ACCMODE	   0003
   14.10 +#define O_RDONLY	     00
   14.11 +#define O_WRONLY	     01
   14.12 +#define O_RDWR		     02
   14.13 +#define O_CREAT		   0100	/* not fcntl */
   14.14 +#define O_EXCL		   0200	/* not fcntl */
   14.15 +#define O_NOCTTY	   0400	/* not fcntl */
   14.16 +#define O_TRUNC		  01000	/* not fcntl */
   14.17 +#define O_APPEND	  02000
   14.18 +#define O_NONBLOCK	  04000
   14.19 +#define O_NDELAY	O_NONBLOCK
   14.20 +#define O_SYNC		 010000
   14.21 +#define FASYNC		 020000	/* fcntl, for BSD compatibility */
   14.22 +#define O_DIRECT	 040000	/* direct disk access hint */
   14.23 +#define O_LARGEFILE	0100000
   14.24 +#define O_DIRECTORY	0200000	/* must be a directory */
   14.25 +#define O_NOFOLLOW	0400000 /* don't follow links */
   14.26 +#define O_NOATIME	01000000
   14.27 +
   14.28 +#define F_DUPFD		0	/* dup */
   14.29 +#define F_GETFD		1	/* get close_on_exec */
   14.30 +#define F_SETFD		2	/* set/clear close_on_exec */
   14.31 +#define F_GETFL		3	/* get file->f_flags */
   14.32 +#define F_SETFL		4	/* set file->f_flags */
   14.33 +#define F_GETLK		5
   14.34 +#define F_SETLK		6
   14.35 +#define F_SETLKW	7
   14.36 +
   14.37 +#define F_SETOWN	8	/*  for sockets. */
   14.38 +#define F_GETOWN	9	/*  for sockets. */
   14.39 +#define F_SETSIG	10	/*  for sockets. */
   14.40 +#define F_GETSIG	11	/*  for sockets. */
   14.41 +
   14.42 +#define F_GETLK64	12	/*  using 'struct flock64' */
   14.43 +#define F_SETLK64	13
   14.44 +#define F_SETLKW64	14
   14.45 +
   14.46 +/* for F_[GET|SET]FL */
   14.47 +#define FD_CLOEXEC	1	/* actually anything with low bit set goes */
   14.48 +
   14.49 +/* for posix fcntl() and lockf() */
   14.50 +#define F_RDLCK		0
   14.51 +#define F_WRLCK		1
   14.52 +#define F_UNLCK		2
   14.53 +
   14.54 +/* for old implementation of bsd flock () */
   14.55 +#define F_EXLCK		4	/* or 3 */
   14.56 +#define F_SHLCK		8	/* or 4 */
   14.57 +
   14.58 +/* for leases */
   14.59 +#define F_INPROGRESS	16
   14.60 +
   14.61 +/* operations for bsd flock(), also used by the kernel implementation */
   14.62 +#define LOCK_SH		1	/* shared lock */
   14.63 +#define LOCK_EX		2	/* exclusive lock */
   14.64 +#define LOCK_NB		4	/* or'd with one of the above to prevent
   14.65 +				   blocking */
   14.66 +#define LOCK_UN		8	/* remove lock */
   14.67 +
   14.68 +#define LOCK_MAND	32	/* This is a mandatory flock */
   14.69 +#define LOCK_READ	64	/* ... Which allows concurrent read operations */
   14.70 +#define LOCK_WRITE	128	/* ... Which allows concurrent write operations */
   14.71 +#define LOCK_RW		192	/* ... Which allows concurrent read & write ops */
   14.72 +
   14.73 +/*
   14.74 +struct flock {
   14.75 +	short l_type;
   14.76 +	short l_whence;
   14.77 +	off_t l_start;
   14.78 +	off_t l_len;
   14.79 +	pid_t l_pid;
   14.80 +};
   14.81 +
   14.82 +struct flock64 {
   14.83 +	short  l_type;
   14.84 +	short  l_whence;
   14.85 +	loff_t l_start;
   14.86 +	loff_t l_len;
   14.87 +	pid_t  l_pid;
   14.88 +};
   14.89 +
   14.90 +#define F_LINUX_SPECIFIC_BASE	1024
   14.91 +*/
   14.92 +#endif
    15.1 --- a/extras/mini-os/include/hypervisor.h	Thu Sep 08 09:18:40 2005 -0600
    15.2 +++ b/extras/mini-os/include/hypervisor.h	Fri Sep 09 10:30:54 2005 -0600
    15.3 @@ -13,7 +13,6 @@
    15.4  #define _HYPERVISOR_H_
    15.5  
    15.6  #include <types.h>
    15.7 -
    15.8  #include <xen/xen.h>
    15.9  #include <xen/io/domain_controller.h>
   15.10  
   15.11 @@ -40,48 +39,26 @@ void clear_evtchn(u32 port);
   15.12  /*
   15.13   * Assembler stubs for hyper-calls.
   15.14   */
   15.15 -
   15.16 -#ifdef __i386__
   15.17 -#define _a1 "b"
   15.18 -#define _a2 "c"
   15.19 -#define _a3 "d"
   15.20 -#define _a4 "S"
   15.21 -#else
   15.22 -#define _a1 "D"
   15.23 -#define _a2 "S"
   15.24 -#define _a3 "d"
   15.25 -#define _a4 "b"
   15.26 -#endif
   15.27 -
   15.28 -static __inline__ int HYPERVISOR_event_channel_op(
   15.29 -    void *op)
   15.30 +#if defined(__i386__)
   15.31 +static inline int
   15.32 +HYPERVISOR_set_trap_table(
   15.33 +    trap_info_t *table)
   15.34  {
   15.35      int ret;
   15.36      unsigned long ignore;
   15.37 +
   15.38      __asm__ __volatile__ (
   15.39          TRAP_INSTR
   15.40          : "=a" (ret), "=b" (ignore)
   15.41 -	: "0" (__HYPERVISOR_event_channel_op), "1" (op)
   15.42 +	: "0" (__HYPERVISOR_set_trap_table), "1" (table)
   15.43  	: "memory" );
   15.44  
   15.45      return ret;
   15.46  }
   15.47  
   15.48 -static __inline__ int HYPERVISOR_set_trap_table(trap_info_t *table)
   15.49 -{
   15.50 -    int ret;
   15.51 -    __asm__ __volatile__ (
   15.52 -        TRAP_INSTR
   15.53 -        : "=a" (ret) : "0" (__HYPERVISOR_set_trap_table),
   15.54 -        _a1 (table) : "memory" );
   15.55 -
   15.56 -    return ret;
   15.57 -}
   15.58 -
   15.59 -static __inline__ int HYPERVISOR_mmu_update(mmu_update_t *req, 
   15.60 -                                            int count, 
   15.61 -                                            int *success_count, 
   15.62 -                                            domid_t domid)
   15.63 +static inline int
   15.64 +HYPERVISOR_mmu_update(
   15.65 +    mmu_update_t *req, int count, int *success_count, domid_t domid)
   15.66  {
   15.67      int ret;
   15.68      unsigned long ign1, ign2, ign3, ign4;
   15.69 @@ -89,18 +66,16 @@ static __inline__ int HYPERVISOR_mmu_upd
   15.70      __asm__ __volatile__ (
   15.71          TRAP_INSTR
   15.72          : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   15.73 -        : "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
   15.74 -          "3" (success_count), "4" (domid)
   15.75 -        : "memory" );
   15.76 +	: "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
   15.77 +        "3" (success_count), "4" (domid)
   15.78 +	: "memory" );
   15.79  
   15.80      return ret;
   15.81  }
   15.82  
   15.83 -
   15.84 -static __inline__ int HYPERVISOR_mmuext_op(struct mmuext_op *op, 
   15.85 -                                           int count, 
   15.86 -                                           int *success_count, 
   15.87 -                                           domid_t domid)
   15.88 +static inline int
   15.89 +HYPERVISOR_mmuext_op(
   15.90 +    struct mmuext_op *op, int count, int *success_count, domid_t domid)
   15.91  {
   15.92      int ret;
   15.93      unsigned long ign1, ign2, ign3, ign4;
   15.94 @@ -108,70 +83,65 @@ static __inline__ int HYPERVISOR_mmuext_
   15.95      __asm__ __volatile__ (
   15.96          TRAP_INSTR
   15.97          : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   15.98 -        : "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
   15.99 -          "3" (success_count), "4" (domid)
  15.100 -        : "memory" );
  15.101 +	: "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
  15.102 +        "3" (success_count), "4" (domid)
  15.103 +	: "memory" );
  15.104  
  15.105      return ret;
  15.106  }
  15.107  
  15.108 -
  15.109 -
  15.110 -static __inline__ int HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
  15.111 +static inline int
  15.112 +HYPERVISOR_set_gdt(
  15.113 +    unsigned long *frame_list, int entries)
  15.114  {
  15.115      int ret;
  15.116 +    unsigned long ign1, ign2;
  15.117 +
  15.118      __asm__ __volatile__ (
  15.119          TRAP_INSTR
  15.120 -        : "=a" (ret) : "0" (__HYPERVISOR_set_gdt), 
  15.121 -        _a1 (frame_list), _a2 (entries) : "memory" );
  15.122 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.123 +	: "0" (__HYPERVISOR_set_gdt), "1" (frame_list), "2" (entries)
  15.124 +	: "memory" );
  15.125  
  15.126  
  15.127      return ret;
  15.128  }
  15.129  
  15.130 -static __inline__ int HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp)
  15.131 +static inline int
  15.132 +HYPERVISOR_stack_switch(
  15.133 +    unsigned long ss, unsigned long esp)
  15.134  {
  15.135      int ret;
  15.136 +    unsigned long ign1, ign2;
  15.137 +
  15.138      __asm__ __volatile__ (
  15.139          TRAP_INSTR
  15.140 -        : "=a" (ret) : "0" (__HYPERVISOR_stack_switch),
  15.141 -        _a1 (ss), _a2 (esp) : "memory" );
  15.142 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.143 +	: "0" (__HYPERVISOR_stack_switch), "1" (ss), "2" (esp)
  15.144 +	: "memory" );
  15.145  
  15.146      return ret;
  15.147  }
  15.148  
  15.149 -#ifdef __i386__
  15.150 -static __inline__ int HYPERVISOR_set_callbacks(
  15.151 +static inline int
  15.152 +HYPERVISOR_set_callbacks(
  15.153      unsigned long event_selector, unsigned long event_address,
  15.154      unsigned long failsafe_selector, unsigned long failsafe_address)
  15.155  {
  15.156      int ret;
  15.157 +    unsigned long ign1, ign2, ign3, ign4;
  15.158 +
  15.159      __asm__ __volatile__ (
  15.160          TRAP_INSTR
  15.161 -        : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
  15.162 -        _a1 (event_selector), _a2 (event_address), 
  15.163 -        _a3 (failsafe_selector), _a4 (failsafe_address) : "memory" );
  15.164 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
  15.165 +	: "0" (__HYPERVISOR_set_callbacks), "1" (event_selector),
  15.166 +	  "2" (event_address), "3" (failsafe_selector), "4" (failsafe_address)
  15.167 +	: "memory" );
  15.168  
  15.169      return ret;
  15.170  }
  15.171 -#else
  15.172 -static __inline__ int HYPERVISOR_set_callbacks(
  15.173 -    unsigned long event_address,
  15.174 -    unsigned long failsafe_address,
  15.175 -    unsigned long syscall_address)
  15.176 -{
  15.177 -    int ret;
  15.178 -    __asm__ __volatile__ (
  15.179 -        TRAP_INSTR
  15.180 -        : "=a" (ret) : "0" (__HYPERVISOR_set_callbacks),
  15.181 -        _a1 (event_address), _a2 (failsafe_address), 
  15.182 -        _a3 (syscall_address) : "memory" );
  15.183  
  15.184 -    return ret;
  15.185 -}
  15.186 -#endif
  15.187 -
  15.188 -static __inline__ int
  15.189 +static inline int
  15.190  HYPERVISOR_fpu_taskswitch(
  15.191      int set)
  15.192  {
  15.193 @@ -187,67 +157,106 @@ HYPERVISOR_fpu_taskswitch(
  15.194      return ret;
  15.195  }
  15.196  
  15.197 -static __inline__ int HYPERVISOR_yield(void)
  15.198 +static inline int
  15.199 +HYPERVISOR_yield(
  15.200 +    void)
  15.201  {
  15.202      int ret;
  15.203 +    unsigned long ign;
  15.204 +
  15.205      __asm__ __volatile__ (
  15.206          TRAP_INSTR
  15.207 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  15.208 -        _a1 (SCHEDOP_yield) : "memory" );
  15.209 -
  15.210 -    return ret;
  15.211 -}
  15.212 -
  15.213 -static __inline__ int HYPERVISOR_block(void)
  15.214 -{
  15.215 -    int ret;
  15.216 -    __asm__ __volatile__ (
  15.217 -        TRAP_INSTR
  15.218 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  15.219 -        _a1 (SCHEDOP_block) : "memory" );
  15.220 +        : "=a" (ret), "=b" (ign)
  15.221 +	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_yield)
  15.222 +	: "memory", "ecx" );
  15.223  
  15.224      return ret;
  15.225  }
  15.226  
  15.227 -static __inline__ int HYPERVISOR_shutdown(void)
  15.228 +static inline int
  15.229 +HYPERVISOR_block(
  15.230 +    void)
  15.231  {
  15.232      int ret;
  15.233 +    unsigned long ign1;
  15.234      __asm__ __volatile__ (
  15.235          TRAP_INSTR
  15.236 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  15.237 -        _a1 (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
  15.238 -        : "memory" );
  15.239 +        : "=a" (ret), "=b" (ign1)
  15.240 +	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_block)
  15.241 +	: "memory", "ecx" );
  15.242  
  15.243      return ret;
  15.244  }
  15.245  
  15.246 -static __inline__ int HYPERVISOR_reboot(void)
  15.247 +static inline int
  15.248 +HYPERVISOR_shutdown(
  15.249 +    void)
  15.250  {
  15.251      int ret;
  15.252 +    unsigned long ign1;
  15.253      __asm__ __volatile__ (
  15.254          TRAP_INSTR
  15.255 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  15.256 -        _a1 (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
  15.257 -        : "memory" );
  15.258 +        : "=a" (ret), "=b" (ign1)
  15.259 +	: "0" (__HYPERVISOR_sched_op),
  15.260 +	  "1" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
  15.261 +        : "memory", "ecx" );
  15.262  
  15.263      return ret;
  15.264  }
  15.265  
  15.266 -static __inline__ int HYPERVISOR_suspend(unsigned long srec)
  15.267 +static inline int
  15.268 +HYPERVISOR_reboot(
  15.269 +    void)
  15.270  {
  15.271      int ret;
  15.272 -    /* NB. On suspend, control software expects a suspend record in %esi. */
  15.273 +    unsigned long ign1;
  15.274      __asm__ __volatile__ (
  15.275          TRAP_INSTR
  15.276 -        : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
  15.277 -        _a1 (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
  15.278 -        "S" (srec) : "memory" );
  15.279 +        : "=a" (ret), "=b" (ign1)
  15.280 +	: "0" (__HYPERVISOR_sched_op),
  15.281 +	  "1" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
  15.282 +        : "memory", "ecx" );
  15.283  
  15.284      return ret;
  15.285  }
  15.286  
  15.287 -#ifdef __i386__
  15.288 -static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
  15.289 +static inline int
  15.290 +HYPERVISOR_suspend(
  15.291 +    unsigned long srec)
  15.292 +{
  15.293 +    int ret;
  15.294 +    unsigned long ign1, ign2;
  15.295 +
  15.296 +    /* NB. On suspend, control software expects a suspend record in %esi. */
  15.297 +    __asm__ __volatile__ (
  15.298 +        TRAP_INSTR
  15.299 +        : "=a" (ret), "=b" (ign1), "=S" (ign2)
  15.300 +	: "0" (__HYPERVISOR_sched_op),
  15.301 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
  15.302 +        "S" (srec) : "memory", "ecx");
  15.303 +
  15.304 +    return ret;
  15.305 +}
  15.306 +
  15.307 +static inline int
  15.308 +HYPERVISOR_crash(
  15.309 +    void)
  15.310 +{
  15.311 +    int ret;
  15.312 +    unsigned long ign1;
  15.313 +    __asm__ __volatile__ (
  15.314 +        TRAP_INSTR
  15.315 +        : "=a" (ret), "=b" (ign1)
  15.316 +	: "0" (__HYPERVISOR_sched_op),
  15.317 +	  "1" (SCHEDOP_shutdown | (SHUTDOWN_crash << SCHEDOP_reasonshift))
  15.318 +        : "memory", "ecx" );
  15.319 +
  15.320 +    return ret;
  15.321 +}
  15.322 +
  15.323 +static inline long
  15.324 +HYPERVISOR_set_timer_op(
  15.325 +    u64 timeout)
  15.326  {
  15.327      int ret;
  15.328      unsigned long timeout_hi = (unsigned long)(timeout>>32);
  15.329 @@ -262,8 +271,516 @@ static __inline__ long HYPERVISOR_set_ti
  15.330  
  15.331      return ret;
  15.332  }
  15.333 +
  15.334 +#if 0
  15.335 +static inline int
  15.336 +HYPERVISOR_dom0_op(
  15.337 +    dom0_op_t *dom0_op)
  15.338 +{
  15.339 +    int ret;
  15.340 +    unsigned long ign1;
  15.341 +
  15.342 +    dom0_op->interface_version = DOM0_INTERFACE_VERSION;
  15.343 +    __asm__ __volatile__ (
  15.344 +        TRAP_INSTR
  15.345 +        : "=a" (ret), "=b" (ign1)
  15.346 +	: "0" (__HYPERVISOR_dom0_op), "1" (dom0_op)
  15.347 +	: "memory");
  15.348 +
  15.349 +    return ret;
  15.350 +}
  15.351 +#endif
  15.352 +
  15.353 +static inline int
  15.354 +HYPERVISOR_set_debugreg(
  15.355 +    int reg, unsigned long value)
  15.356 +{
  15.357 +    int ret;
  15.358 +    unsigned long ign1, ign2;
  15.359 +    __asm__ __volatile__ (
  15.360 +        TRAP_INSTR
  15.361 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.362 +	: "0" (__HYPERVISOR_set_debugreg), "1" (reg), "2" (value)
  15.363 +	: "memory" );
  15.364 +
  15.365 +    return ret;
  15.366 +}
  15.367 +
  15.368 +static inline unsigned long
  15.369 +HYPERVISOR_get_debugreg(
  15.370 +    int reg)
  15.371 +{
  15.372 +    unsigned long ret;
  15.373 +    unsigned long ign;
  15.374 +    __asm__ __volatile__ (
  15.375 +        TRAP_INSTR
  15.376 +        : "=a" (ret), "=b" (ign)
  15.377 +	: "0" (__HYPERVISOR_get_debugreg), "1" (reg)
  15.378 +	: "memory" );
  15.379 +
  15.380 +    return ret;
  15.381 +}
  15.382 +
  15.383 +static inline int
  15.384 +HYPERVISOR_update_descriptor(
  15.385 +    u64 ma, u64 desc)
  15.386 +{
  15.387 +    int ret;
  15.388 +    unsigned long ign1, ign2, ign3, ign4;
  15.389 +
  15.390 +    __asm__ __volatile__ (
  15.391 +        TRAP_INSTR
  15.392 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
  15.393 +	: "0" (__HYPERVISOR_update_descriptor),
  15.394 +	  "1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
  15.395 +	  "3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
  15.396 +	: "memory" );
  15.397 +
  15.398 +    return ret;
  15.399 +}
  15.400 +
  15.401 +static inline int
  15.402 +HYPERVISOR_dom_mem_op(
  15.403 +    unsigned int op, unsigned long *extent_list,
  15.404 +    unsigned long nr_extents, unsigned int extent_order)
  15.405 +{
  15.406 +    int ret;
  15.407 +    unsigned long ign1, ign2, ign3, ign4, ign5;
  15.408 +
  15.409 +    __asm__ __volatile__ (
  15.410 +        TRAP_INSTR
  15.411 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4),
  15.412 +	  "=D" (ign5)
  15.413 +	: "0" (__HYPERVISOR_dom_mem_op), "1" (op), "2" (extent_list),
  15.414 +	  "3" (nr_extents), "4" (extent_order), "5" (DOMID_SELF)
  15.415 +        : "memory" );
  15.416 +
  15.417 +    return ret;
  15.418 +}
  15.419 +
  15.420 +static inline int
  15.421 +HYPERVISOR_multicall(
  15.422 +    void *call_list, int nr_calls)
  15.423 +{
  15.424 +    int ret;
  15.425 +    unsigned long ign1, ign2;
  15.426 +
  15.427 +    __asm__ __volatile__ (
  15.428 +        TRAP_INSTR
  15.429 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.430 +	: "0" (__HYPERVISOR_multicall), "1" (call_list), "2" (nr_calls)
  15.431 +	: "memory" );
  15.432 +
  15.433 +    return ret;
  15.434 +}
  15.435 +
  15.436 +static inline int
  15.437 +HYPERVISOR_update_va_mapping(
  15.438 +    unsigned long va, pte_t new_val, unsigned long flags)
  15.439 +{
  15.440 +    int ret;
  15.441 +    unsigned long ign1, ign2, ign3, ign4;
  15.442 +
  15.443 +    __asm__ __volatile__ (
  15.444 +        TRAP_INSTR
  15.445 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
  15.446 +	: "0" (__HYPERVISOR_update_va_mapping), 
  15.447 +          "1" (va), "2" ((new_val).pte_low),
  15.448 +#ifdef CONFIG_X86_PAE
  15.449 +	  "3" ((new_val).pte_high),
  15.450  #else
  15.451 -static __inline__ long HYPERVISOR_set_timer_op( u64 timeout )
  15.452 +	  "3" (0),
  15.453 +#endif
  15.454 +	  "4" (flags)
  15.455 +	: "memory" );
  15.456 +
  15.457 +    return ret;
  15.458 +}
  15.459 +
  15.460 +static inline int
  15.461 +HYPERVISOR_event_channel_op(
  15.462 +    void *op)
  15.463 +{
  15.464 +    int ret;
  15.465 +    unsigned long ignore;
  15.466 +    __asm__ __volatile__ (
  15.467 +        TRAP_INSTR
  15.468 +        : "=a" (ret), "=b" (ignore)
  15.469 +	: "0" (__HYPERVISOR_event_channel_op), "1" (op)
  15.470 +	: "memory" );
  15.471 +
  15.472 +    return ret;
  15.473 +}
  15.474 +
  15.475 +static inline int
  15.476 +HYPERVISOR_xen_version(
  15.477 +    int cmd)
  15.478 +{
  15.479 +    int ret;
  15.480 +    unsigned long ignore;
  15.481 +
  15.482 +    __asm__ __volatile__ (
  15.483 +        TRAP_INSTR
  15.484 +        : "=a" (ret), "=b" (ignore)
  15.485 +	: "0" (__HYPERVISOR_xen_version), "1" (cmd)
  15.486 +	: "memory" );
  15.487 +
  15.488 +    return ret;
  15.489 +}
  15.490 +
  15.491 +static inline int
  15.492 +HYPERVISOR_console_io(
  15.493 +    int cmd, int count, char *str)
  15.494 +{
  15.495 +    int ret;
  15.496 +    unsigned long ign1, ign2, ign3;
  15.497 +    __asm__ __volatile__ (
  15.498 +        TRAP_INSTR
  15.499 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
  15.500 +	: "0" (__HYPERVISOR_console_io), "1" (cmd), "2" (count), "3" (str)
  15.501 +	: "memory" );
  15.502 +
  15.503 +    return ret;
  15.504 +}
  15.505 +
  15.506 +static inline int
  15.507 +HYPERVISOR_physdev_op(
  15.508 +    void *physdev_op)
  15.509 +{
  15.510 +    int ret;
  15.511 +    unsigned long ign;
  15.512 +
  15.513 +    __asm__ __volatile__ (
  15.514 +        TRAP_INSTR
  15.515 +        : "=a" (ret), "=b" (ign)
  15.516 +	: "0" (__HYPERVISOR_physdev_op), "1" (physdev_op)
  15.517 +	: "memory" );
  15.518 +
  15.519 +    return ret;
  15.520 +}
  15.521 +
  15.522 +static inline int
  15.523 +HYPERVISOR_grant_table_op(
  15.524 +    unsigned int cmd, void *uop, unsigned int count)
  15.525 +{
  15.526 +    int ret;
  15.527 +    unsigned long ign1, ign2, ign3;
  15.528 +
  15.529 +    __asm__ __volatile__ (
  15.530 +        TRAP_INSTR
  15.531 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
  15.532 +	: "0" (__HYPERVISOR_grant_table_op), "1" (cmd), "2" (uop), "3" (count)
  15.533 +	: "memory" );
  15.534 +
  15.535 +    return ret;
  15.536 +}
  15.537 +
  15.538 +static inline int
  15.539 +HYPERVISOR_update_va_mapping_otherdomain(
  15.540 +    unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
  15.541 +{
  15.542 +    int ret;
  15.543 +    unsigned long ign1, ign2, ign3, ign4, ign5;
  15.544 +
  15.545 +    __asm__ __volatile__ (
  15.546 +        TRAP_INSTR
  15.547 +        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3),
  15.548 +	  "=S" (ign4), "=D" (ign5)
  15.549 +	: "0" (__HYPERVISOR_update_va_mapping_otherdomain),
  15.550 +          "1" (va), "2" ((new_val).pte_low),
  15.551 +#ifdef CONFIG_X86_PAE
  15.552 +	  "3" ((new_val).pte_high),
  15.553 +#else
  15.554 +	  "3" (0),
  15.555 +#endif
  15.556 +	  "4" (flags), "5" (domid) :
  15.557 +        "memory" );
  15.558 +    
  15.559 +    return ret;
  15.560 +}
  15.561 +
  15.562 +static inline int
  15.563 +HYPERVISOR_vm_assist(
  15.564 +    unsigned int cmd, unsigned int type)
  15.565 +{
  15.566 +    int ret;
  15.567 +    unsigned long ign1, ign2;
  15.568 +
  15.569 +    __asm__ __volatile__ (
  15.570 +        TRAP_INSTR
  15.571 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.572 +	: "0" (__HYPERVISOR_vm_assist), "1" (cmd), "2" (type)
  15.573 +	: "memory" );
  15.574 +
  15.575 +    return ret;
  15.576 +}
  15.577 +
  15.578 +static inline int
  15.579 +HYPERVISOR_boot_vcpu(
  15.580 +    unsigned long vcpu, vcpu_guest_context_t *ctxt)
  15.581 +{
  15.582 +    int ret;
  15.583 +    unsigned long ign1, ign2;
  15.584 +
  15.585 +    __asm__ __volatile__ (
  15.586 +        TRAP_INSTR
  15.587 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.588 +	: "0" (__HYPERVISOR_boot_vcpu), "1" (vcpu), "2" (ctxt)
  15.589 +	: "memory");
  15.590 +
  15.591 +    return ret;
  15.592 +}
  15.593 +
  15.594 +static inline int
  15.595 +HYPERVISOR_vcpu_down(
  15.596 +    int vcpu)
  15.597 +{
  15.598 +    int ret;
  15.599 +    unsigned long ign1;
  15.600 +    /* Yes, I really do want to clobber edx here: when we resume a
  15.601 +       vcpu after unpickling a multi-processor domain, it returns
  15.602 +       here, but clobbers all of the call clobbered registers. */
  15.603 +    __asm__ __volatile__ (
  15.604 +        TRAP_INSTR
  15.605 +        : "=a" (ret), "=b" (ign1)
  15.606 +	: "0" (__HYPERVISOR_sched_op),
  15.607 +	  "1" (SCHEDOP_vcpu_down | (vcpu << SCHEDOP_vcpushift))
  15.608 +        : "memory", "ecx", "edx" );
  15.609 +
  15.610 +    return ret;
  15.611 +}
  15.612 +
  15.613 +static inline int
  15.614 +HYPERVISOR_vcpu_up(
  15.615 +    int vcpu)
  15.616 +{
  15.617 +    int ret;
  15.618 +    unsigned long ign1;
  15.619 +    __asm__ __volatile__ (
  15.620 +        TRAP_INSTR
  15.621 +        : "=a" (ret), "=b" (ign1)
  15.622 +	: "0" (__HYPERVISOR_sched_op),
  15.623 +	  "1" (SCHEDOP_vcpu_up | (vcpu << SCHEDOP_vcpushift))
  15.624 +        : "memory", "ecx" );
  15.625 +
  15.626 +    return ret;
  15.627 +}
  15.628 +
  15.629 +static inline int
  15.630 +HYPERVISOR_vcpu_pickle(
  15.631 +    int vcpu, vcpu_guest_context_t *ctxt)
  15.632 +{
  15.633 +    int ret;
  15.634 +    unsigned long ign1, ign2;
  15.635 +    __asm__ __volatile__ (
  15.636 +        TRAP_INSTR
  15.637 +        : "=a" (ret), "=b" (ign1), "=c" (ign2)
  15.638 +	: "0" (__HYPERVISOR_sched_op),
  15.639 +	  "1" (SCHEDOP_vcpu_pickle | (vcpu << SCHEDOP_vcpushift)),
  15.640 +	  "2" (ctxt)
  15.641 +        : "memory" );
  15.642 +
  15.643 +    return ret;
  15.644 +}
  15.645 +#elif defined(__x86_64__)
  15.646 +
  15.647 +#define __syscall_clobber "r11","rcx","memory"
  15.648 +
  15.649 +/*
  15.650 + * Assembler stubs for hyper-calls.
  15.651 + */
  15.652 +static inline int
  15.653 +HYPERVISOR_set_trap_table(
  15.654 +    trap_info_t *table)
  15.655 +{
  15.656 +    int ret;
  15.657 +
  15.658 +    __asm__ __volatile__ (
  15.659 +        TRAP_INSTR
  15.660 +        : "=a" (ret)
  15.661 +	: "0" ((unsigned long)__HYPERVISOR_set_trap_table), "D" (table)
  15.662 +	: __syscall_clobber );
  15.663 +
  15.664 +    return ret;
  15.665 +}
  15.666 +
  15.667 +static inline int
  15.668 +HYPERVISOR_mmu_update(
  15.669 +    mmu_update_t *req, int count, int *success_count, domid_t domid)
  15.670 +{
  15.671 +    int ret;
  15.672 +
  15.673 +    __asm__ __volatile__ (
  15.674 +        "movq %5, %%r10;" TRAP_INSTR
  15.675 +        : "=a" (ret)
  15.676 +	: "0" ((unsigned long)__HYPERVISOR_mmu_update), "D" (req), "S" ((long)count),
  15.677 +	  "d" (success_count), "g" ((unsigned long)domid)
  15.678 +	: __syscall_clobber, "r10" );
  15.679 +
  15.680 +    return ret;
  15.681 +}
  15.682 +
  15.683 +static inline int
  15.684 +HYPERVISOR_mmuext_op(
  15.685 +    struct mmuext_op *op, int count, int *success_count, domid_t domid)
  15.686 +{
  15.687 +    int ret;
  15.688 +
  15.689 +    __asm__ __volatile__ (
  15.690 +        "movq %5, %%r10;" TRAP_INSTR
  15.691 +        : "=a" (ret)
  15.692 +        : "0" (__HYPERVISOR_mmuext_op), "D" (op), "S" ((long)count), 
  15.693 +          "d" (success_count), "g" ((unsigned long)domid)
  15.694 +        : __syscall_clobber, "r10" );
  15.695 +
  15.696 +    return ret;
  15.697 +}
  15.698 +
  15.699 +static inline int
  15.700 +HYPERVISOR_set_gdt(
  15.701 +    unsigned long *frame_list, int entries)
  15.702 +{
  15.703 +    int ret;
  15.704 +
  15.705 +    __asm__ __volatile__ (
  15.706 +        TRAP_INSTR
  15.707 +        : "=a" (ret)
  15.708 +	: "0" ((unsigned long)__HYPERVISOR_set_gdt), "D" (frame_list), "S" ((long)entries)
  15.709 +	: __syscall_clobber );
  15.710 +
  15.711 +
  15.712 +    return ret;
  15.713 +}
  15.714 +static inline int
  15.715 +HYPERVISOR_stack_switch(
  15.716 +    unsigned long ss, unsigned long esp)
  15.717 +{
  15.718 +    int ret;
  15.719 +
  15.720 +    __asm__ __volatile__ (
  15.721 +        TRAP_INSTR
  15.722 +        : "=a" (ret)
  15.723 +	: "0" ((unsigned long)__HYPERVISOR_stack_switch), "D" (ss), "S" (esp)
  15.724 +	: __syscall_clobber );
  15.725 +
  15.726 +    return ret;
  15.727 +}
  15.728 +
  15.729 +static inline int
  15.730 +HYPERVISOR_set_callbacks(
  15.731 +    unsigned long event_address, unsigned long failsafe_address, 
  15.732 +    unsigned long syscall_address)
  15.733 +{
  15.734 +    int ret;
  15.735 +
  15.736 +    __asm__ __volatile__ (
  15.737 +        TRAP_INSTR
  15.738 +        : "=a" (ret)
  15.739 +	: "0" ((unsigned long)__HYPERVISOR_set_callbacks), "D" (event_address),
  15.740 +	  "S" (failsafe_address), "d" (syscall_address)
  15.741 +	: __syscall_clobber );
  15.742 +
  15.743 +    return ret;
  15.744 +}
  15.745 +
  15.746 +static inline int
  15.747 +HYPERVISOR_fpu_taskswitch(
  15.748 +    int set)
  15.749 +{
  15.750 +    int ret;
  15.751 +    __asm__ __volatile__ (
  15.752 +        TRAP_INSTR
  15.753 +        : "=a" (ret) : "0" ((unsigned long)__HYPERVISOR_fpu_taskswitch),
  15.754 +          "D" ((unsigned long) set) : __syscall_clobber );
  15.755 +
  15.756 +    return ret;
  15.757 +}
  15.758 +
  15.759 +static inline int
  15.760 +HYPERVISOR_yield(
  15.761 +    void)
  15.762 +{
  15.763 +    int ret;
  15.764 +
  15.765 +    __asm__ __volatile__ (
  15.766 +        TRAP_INSTR
  15.767 +        : "=a" (ret)
  15.768 +	: "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_yield)
  15.769 +	: __syscall_clobber );
  15.770 +
  15.771 +    return ret;
  15.772 +}
  15.773 +
  15.774 +static inline int
  15.775 +HYPERVISOR_block(
  15.776 +    void)
  15.777 +{
  15.778 +    int ret;
  15.779 +    __asm__ __volatile__ (
  15.780 +        TRAP_INSTR
  15.781 +        : "=a" (ret)
  15.782 +	: "0" ((unsigned long)__HYPERVISOR_sched_op), "D" ((unsigned long)SCHEDOP_block)
  15.783 +	: __syscall_clobber );
  15.784 +
  15.785 +    return ret;
  15.786 +}
  15.787 +
  15.788 +static inline int
  15.789 +HYPERVISOR_shutdown(
  15.790 +    void)
  15.791 +{
  15.792 +    int ret;
  15.793 +    __asm__ __volatile__ (
  15.794 +        TRAP_INSTR
  15.795 +        : "=a" (ret)
  15.796 +	: "0" ((unsigned long)__HYPERVISOR_sched_op),
  15.797 +	  "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift)))
  15.798 +	: __syscall_clobber );
  15.799 +
  15.800 +    return ret;
  15.801 +}
  15.802 +
  15.803 +static inline int
  15.804 +HYPERVISOR_reboot(
  15.805 +    void)
  15.806 +{
  15.807 +    int ret;
  15.808 +
  15.809 +    __asm__ __volatile__ (
  15.810 +        TRAP_INSTR
  15.811 +        : "=a" (ret)
  15.812 +	: "0" ((unsigned long)__HYPERVISOR_sched_op),
  15.813 +	  "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift)))
  15.814 +	: __syscall_clobber );
  15.815 +
  15.816 +    return ret;
  15.817 +}
  15.818 +
  15.819 +static inline int
  15.820 +HYPERVISOR_suspend(
  15.821 +    unsigned long srec)
  15.822 +{
  15.823 +    int ret;
  15.824 +
  15.825 +    /* NB. On suspend, control software expects a suspend record in %esi. */
  15.826 +    __asm__ __volatile__ (
  15.827 +        TRAP_INSTR
  15.828 +        : "=a" (ret)
  15.829 +	: "0" ((unsigned long)__HYPERVISOR_sched_op),
  15.830 +        "D" ((unsigned long)(SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift))), 
  15.831 +        "S" (srec)
  15.832 +	: __syscall_clobber );
  15.833 +
  15.834 +    return ret;
  15.835 +}
  15.836 +
  15.837 +/*
  15.838 + * We can have the timeout value in a single argument for the hypercall, but
  15.839 + * that will break the common code. 
  15.840 + */
  15.841 +static inline long
  15.842 +HYPERVISOR_set_timer_op(
  15.843 +    u64 timeout)
  15.844  {
  15.845      int ret;
  15.846  
  15.847 @@ -329,7 +846,7 @@ static __inline__ int HYPERVISOR_dom_mem
  15.848      int ret;
  15.849      __asm__ __volatile__ (
  15.850          TRAP_INSTR
  15.851 -        : "=a" (ret) : "0" (__HYPERVISOR_dom_mem_op),
  15.852 +        : "=a" (ret) : "0" (__HYPERVISOR_memory_op),
  15.853          _a1 (dom_mem_op) : "memory" );
  15.854  
  15.855      return ret;
    16.1 --- a/extras/mini-os/include/lib.h	Thu Sep 08 09:18:40 2005 -0600
    16.2 +++ b/extras/mini-os/include/lib.h	Fri Sep 09 10:30:54 2005 -0600
    16.3 @@ -60,10 +60,22 @@
    16.4  /* printing */
    16.5  #define printk  printf
    16.6  #define kprintf printf
    16.7 -int printf(const char *fmt, ...);
    16.8 -int vprintf(const char *fmt, va_list ap);
    16.9 -int sprintf(char *buf, const char *cfmt, ...);
   16.10 -int vsprintf(char *buf, const char *cfmt, va_list ap);
   16.11 +#define _p(_x) ((void *)(unsigned long)(_x))
   16.12 +void printf(const char *fmt, ...);
   16.13 +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
   16.14 +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
   16.15 +int snprintf(char * buf, size_t size, const char *fmt, ...);
   16.16 +int scnprintf(char * buf, size_t size, const char *fmt, ...);
   16.17 +int vsprintf(char *buf, const char *fmt, va_list args);
   16.18 +int sprintf(char * buf, const char *fmt, ...);
   16.19 +int vsscanf(const char * buf, const char * fmt, va_list args);
   16.20 +int sscanf(const char * buf, const char * fmt, ...);
   16.21 +
   16.22 +long simple_strtol(const char *cp,char **endp,unsigned int base);
   16.23 +unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
   16.24 +long long simple_strtoll(const char *cp,char **endp,unsigned int base);
   16.25 +unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base);
   16.26 +
   16.27  
   16.28  /* string and memory manipulation */
   16.29  int    memcmp(const void *cs, const void *ct, size_t count);
   16.30 @@ -77,6 +89,16 @@ size_t strnlen(const char *s, size_t cou
   16.31  size_t strlen(const char *s);
   16.32  char  *strchr(const char *s, int c);
   16.33  char  *strstr(const char *s1, const char *s2);
   16.34 +char * strcat(char * dest, const char * src);
   16.35 +
   16.36 +
   16.37 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
   16.38 +
   16.39 +struct kvec {
   16.40 +    void *iov_base;
   16.41 +    size_t iov_len;
   16.42 +};
   16.43 +
   16.44  
   16.45  
   16.46  #endif /* _LIB_H_ */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/extras/mini-os/include/list.h	Fri Sep 09 10:30:54 2005 -0600
    17.3 @@ -0,0 +1,184 @@
    17.4 +#ifndef _LINUX_LIST_H
    17.5 +#define _LINUX_LIST_H
    17.6 +
    17.7 +/*
    17.8 + * Simple doubly linked list implementation.
    17.9 + *
   17.10 + * Some of the internal functions ("__xxx") are useful when
   17.11 + * manipulating whole lists rather than single entries, as
   17.12 + * sometimes we already know the next/prev entries and we can
   17.13 + * generate better code by using them directly rather than
   17.14 + * using the generic single-entry routines.
   17.15 + */
   17.16 +
   17.17 +struct list_head {
   17.18 +	struct list_head *next, *prev;
   17.19 +};
   17.20 +
   17.21 +#define LIST_HEAD_INIT(name) { &(name), &(name) }
   17.22 +
   17.23 +#define LIST_HEAD(name) \
   17.24 +	struct list_head name = LIST_HEAD_INIT(name)
   17.25 +
   17.26 +#define INIT_LIST_HEAD(ptr) do { \
   17.27 +	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
   17.28 +} while (0)
   17.29 +
   17.30 +/*
   17.31 + * Insert a new entry between two known consecutive entries. 
   17.32 + *
   17.33 + * This is only for internal list manipulation where we know
   17.34 + * the prev/next entries already!
   17.35 + */
   17.36 +static __inline__ void __list_add(struct list_head * new,
   17.37 +	struct list_head * prev,
   17.38 +	struct list_head * next)
   17.39 +{
   17.40 +	next->prev = new;
   17.41 +	new->next = next;
   17.42 +	new->prev = prev;
   17.43 +	prev->next = new;
   17.44 +}
   17.45 +
   17.46 +/**
   17.47 + * list_add - add a new entry
   17.48 + * @new: new entry to be added
   17.49 + * @head: list head to add it after
   17.50 + *
   17.51 + * Insert a new entry after the specified head.
   17.52 + * This is good for implementing stacks.
   17.53 + */
   17.54 +static __inline__ void list_add(struct list_head *new, struct list_head *head)
   17.55 +{
   17.56 +	__list_add(new, head, head->next);
   17.57 +}
   17.58 +
   17.59 +/**
   17.60 + * list_add_tail - add a new entry
   17.61 + * @new: new entry to be added
   17.62 + * @head: list head to add it before
   17.63 + *
   17.64 + * Insert a new entry before the specified head.
   17.65 + * This is useful for implementing queues.
   17.66 + */
   17.67 +static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
   17.68 +{
   17.69 +	__list_add(new, head->prev, head);
   17.70 +}
   17.71 +
   17.72 +/*
   17.73 + * Delete a list entry by making the prev/next entries
   17.74 + * point to each other.
   17.75 + *
   17.76 + * This is only for internal list manipulation where we know
   17.77 + * the prev/next entries already!
   17.78 + */
   17.79 +static __inline__ void __list_del(struct list_head * prev,
   17.80 +				  struct list_head * next)
   17.81 +{
   17.82 +	next->prev = prev;
   17.83 +	prev->next = next;
   17.84 +}
   17.85 +
   17.86 +/**
   17.87 + * list_del - deletes entry from list.
   17.88 + * @entry: the element to delete from the list.
   17.89 + * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
   17.90 + */
   17.91 +static __inline__ void list_del(struct list_head *entry)
   17.92 +{
   17.93 +	__list_del(entry->prev, entry->next);
   17.94 +}
   17.95 +
   17.96 +/**
   17.97 + * list_del_init - deletes entry from list and reinitialize it.
   17.98 + * @entry: the element to delete from the list.
   17.99 + */
  17.100 +static __inline__ void list_del_init(struct list_head *entry)
  17.101 +{
  17.102 +	__list_del(entry->prev, entry->next);
  17.103 +	INIT_LIST_HEAD(entry); 
  17.104 +}
  17.105 +
  17.106 +/**
  17.107 + * list_empty - tests whether a list is empty
  17.108 + * @head: the list to test.
  17.109 + */
  17.110 +static __inline__ int list_empty(struct list_head *head)
  17.111 +{
  17.112 +	return head->next == head;
  17.113 +}
  17.114 +
  17.115 +/**
  17.116 + * list_splice - join two lists
  17.117 + * @list: the new list to add.
  17.118 + * @head: the place to add it in the first list.
  17.119 + */
  17.120 +static __inline__ void list_splice(struct list_head *list, struct list_head *head)
  17.121 +{
  17.122 +	struct list_head *first = list->next;
  17.123 +
  17.124 +	if (first != list) {
  17.125 +		struct list_head *last = list->prev;
  17.126 +		struct list_head *at = head->next;
  17.127 +
  17.128 +		first->prev = head;
  17.129 +		head->next = first;
  17.130 +
  17.131 +		last->next = at;
  17.132 +		at->prev = last;
  17.133 +	}
  17.134 +}
  17.135 +
  17.136 +/**
  17.137 + * list_entry - get the struct for this entry
  17.138 + * @ptr:	the &struct list_head pointer.
  17.139 + * @type:	the type of the struct this is embedded in.
  17.140 + * @member:	the name of the list_struct within the struct.
  17.141 + */
  17.142 +#define list_entry(ptr, type, member) \
  17.143 +	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
  17.144 +
  17.145 +/**
  17.146 + * list_for_each	-	iterate over a list
  17.147 + * @pos:	the &struct list_head to use as a loop counter.
  17.148 + * @head:	the head for your list.
  17.149 + */
  17.150 +#define list_for_each(pos, head) \
  17.151 +	for (pos = (head)->next; pos != (head); pos = pos->next)
  17.152 +        	
  17.153 +/**
  17.154 + * list_for_each_safe	-	iterate over a list safe against removal of list entry
  17.155 + * @pos:	the &struct list_head to use as a loop counter.
  17.156 + * @n:		another &struct list_head to use as temporary storage
  17.157 + * @head:	the head for your list.
  17.158 + */
  17.159 +#define list_for_each_safe(pos, n, head) \
  17.160 +	for (pos = (head)->next, n = pos->next; pos != (head); \
  17.161 +		pos = n, n = pos->next)
  17.162 +
  17.163 +/**
  17.164 + * list_for_each_entry	-	iterate over list of given type
  17.165 + * @pos:	the type * to use as a loop counter.
  17.166 + * @head:	the head for your list.
  17.167 + * @member:	the name of the list_struct within the struct.
  17.168 + */
  17.169 +#define list_for_each_entry(pos, head, member)				\
  17.170 +	for (pos = list_entry((head)->next, typeof(*pos), member);	\
  17.171 +	     &pos->member != (head); 					\
  17.172 +	     pos = list_entry(pos->member.next, typeof(*pos), member))
  17.173 +
  17.174 +/**
  17.175 + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  17.176 + * @pos:	the type * to use as a loop counter.
  17.177 + * @n:		another type * to use as temporary storage
  17.178 + * @head:	the head for your list.
  17.179 + * @member:	the name of the list_struct within the struct.
  17.180 + */
  17.181 +#define list_for_each_entry_safe(pos, n, head, member)			\
  17.182 +	for (pos = list_entry((head)->next, typeof(*pos), member),	\
  17.183 +		n = list_entry(pos->member.next, typeof(*pos), member);	\
  17.184 +	     &pos->member != (head); 					\
  17.185 +	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
  17.186 +#endif /* _LINUX_LIST_H */
  17.187 +
    18.1 --- a/extras/mini-os/include/mm.h	Thu Sep 08 09:18:40 2005 -0600
    18.2 +++ b/extras/mini-os/include/mm.h	Fri Sep 09 10:30:54 2005 -0600
    18.3 @@ -25,6 +25,15 @@
    18.4  #ifndef _MM_H_
    18.5  #define _MM_H_
    18.6  
    18.7 +#ifdef __i386__
    18.8 +#include <xen/arch-x86_32.h>
    18.9 +#endif
   18.10 +
   18.11 +#ifdef __x86_64__
   18.12 +#include <xen/arch-x86_64.h>
   18.13 +#endif
   18.14 +
   18.15 +
   18.16  #ifdef __x86_64__
   18.17  
   18.18  #define L1_PAGETABLE_SHIFT      12
   18.19 @@ -56,6 +65,8 @@
   18.20  
   18.21  #define L1_PAGETABLE_ENTRIES    1024
   18.22  #define L2_PAGETABLE_ENTRIES    1024
   18.23 +
   18.24 +#elif defined(__x86_64__)
   18.25  #endif
   18.26  
   18.27  /* Given a virtual address, get an entry offset into a page table. */
   18.28 @@ -97,13 +108,15 @@
   18.29  
   18.30  extern unsigned long *phys_to_machine_mapping;
   18.31  #define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
   18.32 -#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
   18.33  static __inline__ unsigned long phys_to_machine(unsigned long phys)
   18.34  {
   18.35      unsigned long machine = pfn_to_mfn(phys >> L1_PAGETABLE_SHIFT);
   18.36      machine = (machine << L1_PAGETABLE_SHIFT) | (phys & ~PAGE_MASK);
   18.37      return machine;
   18.38  }
   18.39 +
   18.40 +
   18.41 +#define mfn_to_pfn(_mfn) (machine_to_phys_mapping[(_mfn)])
   18.42  static __inline__ unsigned long machine_to_phys(unsigned long machine)
   18.43  {
   18.44      unsigned long phys = mfn_to_pfn(machine >> L1_PAGETABLE_SHIFT);
   18.45 @@ -119,16 +132,15 @@ static __inline__ unsigned long machine_
   18.46  
   18.47  #define to_phys(x)                 ((unsigned long)(x)-VIRT_START)
   18.48  #define to_virt(x)                 ((void *)((unsigned long)(x)+VIRT_START))
   18.49 -#define __va to_virt
   18.50 -#define __pa to_phys
   18.51  
   18.52  #define virt_to_pfn(_virt)         (PFN_DOWN(to_phys(_virt)))
   18.53 +#define mach_to_virt(_mach)        (to_virt(machine_to_phys(_mach)))
   18.54 +#define mfn_to_virt(_mfn)          (mach_to_virt(_mfn << PAGE_SHIFT))
   18.55  
   18.56  void init_mm(void);
   18.57  unsigned long alloc_pages(int order);
   18.58  #define alloc_page()    alloc_pages(0);
   18.59  void free_pages(void *pointer, int order);
   18.60 -//int is_mfn_mapped(unsigned long mfn);
   18.61  
   18.62  static __inline__ int get_order(unsigned long size)
   18.63  {
    19.1 --- a/extras/mini-os/include/os.h	Thu Sep 08 09:18:40 2005 -0600
    19.2 +++ b/extras/mini-os/include/os.h	Fri Sep 09 10:30:54 2005 -0600
    19.3 @@ -15,16 +15,17 @@
    19.4  #define unlikely(x)  __builtin_expect((x),0)
    19.5  
    19.6  #define smp_processor_id() 0
    19.7 -#define preempt_disable() ((void)0)
    19.8 -#define preempt_enable() ((void)0)
    19.9  
   19.10 -#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
   19.11  
   19.12  #ifndef __ASSEMBLY__
   19.13  #include <types.h>
   19.14 +#include <hypervisor.h>
   19.15  #endif
   19.16  #include <xen/xen.h>
   19.17  
   19.18 +
   19.19 +#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
   19.20 +
   19.21  #define __KERNEL_CS  FLAT_KERNEL_CS
   19.22  #define __KERNEL_DS  FLAT_KERNEL_DS
   19.23  #define __KERNEL_SS  FLAT_KERNEL_SS
   19.24 @@ -54,8 +55,6 @@
   19.25  /* Everything below this point is not included by assembler (.S) files. */
   19.26  #ifndef __ASSEMBLY__
   19.27  
   19.28 -#define pt_regs xen_regs
   19.29 -
   19.30  void trap_init(void);
   19.31  
   19.32  /* 
   19.33 @@ -69,10 +68,8 @@ void trap_init(void);
   19.34  #define __cli()								\
   19.35  do {									\
   19.36  	vcpu_info_t *_vcpu;						\
   19.37 -	preempt_disable();						\
   19.38  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   19.39  	_vcpu->evtchn_upcall_mask = 1;					\
   19.40 -	preempt_enable_no_resched();					\
   19.41  	barrier();							\
   19.42  } while (0)
   19.43  
   19.44 @@ -80,13 +77,11 @@ do {									\
   19.45  do {									\
   19.46  	vcpu_info_t *_vcpu;						\
   19.47  	barrier();							\
   19.48 -	preempt_disable();						\
   19.49  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   19.50  	_vcpu->evtchn_upcall_mask = 0;					\
   19.51  	barrier(); /* unmask then check (avoid races) */		\
   19.52  	if ( unlikely(_vcpu->evtchn_upcall_pending) )			\
   19.53  		force_evtchn_callback();				\
   19.54 -	preempt_enable();						\
   19.55  } while (0)
   19.56  
   19.57  #define __save_flags(x)							\
   19.58 @@ -100,15 +95,12 @@ do {									\
   19.59  do {									\
   19.60  	vcpu_info_t *_vcpu;						\
   19.61  	barrier();							\
   19.62 -	preempt_disable();						\
   19.63  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   19.64  	if ((_vcpu->evtchn_upcall_mask = (x)) == 0) {			\
   19.65  		barrier(); /* unmask then check (avoid races) */	\
   19.66  		if ( unlikely(_vcpu->evtchn_upcall_pending) )		\
   19.67  			force_evtchn_callback();			\
   19.68 -		preempt_enable();					\
   19.69 -	} else								\
   19.70 -		preempt_enable_no_resched();				\
   19.71 +	}\
   19.72  } while (0)
   19.73  
   19.74  #define safe_halt()		((void)0)
   19.75 @@ -116,11 +108,9 @@ do {									\
   19.76  #define __save_and_cli(x)						\
   19.77  do {									\
   19.78  	vcpu_info_t *_vcpu;						\
   19.79 -	preempt_disable();						\
   19.80  	_vcpu = &HYPERVISOR_shared_info->vcpu_data[smp_processor_id()];	\
   19.81  	(x) = _vcpu->evtchn_upcall_mask;				\
   19.82  	_vcpu->evtchn_upcall_mask = 1;					\
   19.83 -	preempt_enable_no_resched();					\
   19.84  	barrier();							\
   19.85  } while (0)
   19.86  
   19.87 @@ -136,6 +126,15 @@ do {									\
   19.88  /* This is a barrier for the compiler only, NOT the processor! */
   19.89  #define barrier() __asm__ __volatile__("": : :"memory")
   19.90  
   19.91 +#if defined(__i386__)
   19.92 +#define mb()    __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
   19.93 +#define rmb()   __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
   19.94 +#elif defined(__x86_64__)
   19.95 +#define mb()    __asm__ __volatile__ ("mfence":::"memory")
   19.96 +#define rmb()   __asm__ __volatile__ ("lfence":::"memory")
   19.97 +#endif
   19.98 +
   19.99 +
  19.100  #define LOCK_PREFIX ""
  19.101  #define LOCK ""
  19.102  #define ADDR (*(volatile long *) addr)
  19.103 @@ -147,39 +146,187 @@ do {									\
  19.104  typedef struct { volatile int counter; } atomic_t;
  19.105  
  19.106  
  19.107 -#define xchg(ptr,v) \
  19.108 -        ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
  19.109 +/************************** i386 *******************************/
  19.110 +#if defined (__i386__)
  19.111 +
  19.112 +#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
  19.113  struct __xchg_dummy { unsigned long a[100]; };
  19.114 -#define __xg(x) ((volatile struct __xchg_dummy *)(x))
  19.115 -static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr,
  19.116 -                                   int size)
  19.117 +#define __xg(x) ((struct __xchg_dummy *)(x))
  19.118 +static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
  19.119  {
  19.120 -    switch (size) {
  19.121 -    case 1:
  19.122 -        __asm__ __volatile__("xchgb %b0,%1"
  19.123 -                             :"=q" (x)
  19.124 -                             :"m" (*__xg(ptr)), "0" (x)
  19.125 -                             :"memory");
  19.126 -        break;
  19.127 -    case 2:
  19.128 -        __asm__ __volatile__("xchgw %w0,%1"
  19.129 -                             :"=r" (x)
  19.130 -                             :"m" (*__xg(ptr)), "0" (x)
  19.131 -                             :"memory");
  19.132 -        break;
  19.133 -    case 4:
  19.134 -        __asm__ __volatile__("xchgl %0,%1"
  19.135 -                             :"=r" (x)
  19.136 -                             :"m" (*__xg(ptr)), "0" (x)
  19.137 -                             :"memory");
  19.138 -        break;
  19.139 -    }
  19.140 -    return x;
  19.141 +	switch (size) {
  19.142 +		case 1:
  19.143 +			__asm__ __volatile__("xchgb %b0,%1"
  19.144 +				:"=q" (x)
  19.145 +				:"m" (*__xg(ptr)), "0" (x)
  19.146 +				:"memory");
  19.147 +			break;
  19.148 +		case 2:
  19.149 +			__asm__ __volatile__("xchgw %w0,%1"
  19.150 +				:"=r" (x)
  19.151 +				:"m" (*__xg(ptr)), "0" (x)
  19.152 +				:"memory");
  19.153 +			break;
  19.154 +		case 4:
  19.155 +			__asm__ __volatile__("xchgl %0,%1"
  19.156 +				:"=r" (x)
  19.157 +				:"m" (*__xg(ptr)), "0" (x)
  19.158 +				:"memory");
  19.159 +			break;
  19.160 +	}
  19.161 +	return x;
  19.162  }
  19.163  
  19.164  /**
  19.165   * test_and_clear_bit - Clear a bit and return its old value
  19.166 - * @nr: Bit to set
  19.167 + * @nr: Bit to clear
  19.168 + * @addr: Address to count from
  19.169 + *
  19.170 + * This operation is atomic and cannot be reordered.
  19.171 + * It can be reorderdered on other architectures other than x86.
  19.172 + * It also implies a memory barrier.
  19.173 + */
  19.174 +static inline int test_and_clear_bit(int nr, volatile unsigned long * addr)
  19.175 +{
  19.176 +	int oldbit;
  19.177 +
  19.178 +	__asm__ __volatile__( LOCK
  19.179 +		"btrl %2,%1\n\tsbbl %0,%0"
  19.180 +		:"=r" (oldbit),"=m" (ADDR)
  19.181 +		:"Ir" (nr) : "memory");
  19.182 +	return oldbit;
  19.183 +}
  19.184 +
  19.185 +static inline int constant_test_bit(int nr, const volatile unsigned long *addr)
  19.186 +{
  19.187 +	return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
  19.188 +}
  19.189 +
  19.190 +static inline int variable_test_bit(int nr, const volatile unsigned long * addr)
  19.191 +{
  19.192 +	int oldbit;
  19.193 +
  19.194 +	__asm__ __volatile__(
  19.195 +		"btl %2,%1\n\tsbbl %0,%0"
  19.196 +		:"=r" (oldbit)
  19.197 +		:"m" (ADDR),"Ir" (nr));
  19.198 +	return oldbit;
  19.199 +}
  19.200 +
  19.201 +#define test_bit(nr,addr) \
  19.202 +(__builtin_constant_p(nr) ? \
  19.203 + constant_test_bit((nr),(addr)) : \
  19.204 + variable_test_bit((nr),(addr)))
  19.205 +
  19.206 +/**
  19.207 + * set_bit - Atomically set a bit in memory
  19.208 + * @nr: the bit to set
  19.209 + * @addr: the address to start counting from
  19.210 + *
  19.211 + * This function is atomic and may not be reordered.  See __set_bit()
  19.212 + * if you do not require the atomic guarantees.
  19.213 + *
  19.214 + * Note: there are no guarantees that this function will not be reordered
  19.215 + * on non x86 architectures, so if you are writting portable code,
  19.216 + * make sure not to rely on its reordering guarantees.
  19.217 + *
  19.218 + * Note that @nr may be almost arbitrarily large; this function is not
  19.219 + * restricted to acting on a single-word quantity.
  19.220 + */
  19.221 +static inline void set_bit(int nr, volatile unsigned long * addr)
  19.222 +{
  19.223 +	__asm__ __volatile__( LOCK
  19.224 +		"btsl %1,%0"
  19.225 +		:"=m" (ADDR)
  19.226 +		:"Ir" (nr));
  19.227 +}
  19.228 +
  19.229 +/**
  19.230 + * clear_bit - Clears a bit in memory
  19.231 + * @nr: Bit to clear
  19.232 + * @addr: Address to start counting from
  19.233 + *
  19.234 + * clear_bit() is atomic and may not be reordered.  However, it does
  19.235 + * not contain a memory barrier, so if it is used for locking purposes,
  19.236 + * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
  19.237 + * in order to ensure changes are visible on other processors.
  19.238 + */
  19.239 +static inline void clear_bit(int nr, volatile unsigned long * addr)
  19.240 +{
  19.241 +	__asm__ __volatile__( LOCK
  19.242 +		"btrl %1,%0"
  19.243 +		:"=m" (ADDR)
  19.244 +		:"Ir" (nr));
  19.245 +}
  19.246 +
  19.247 +/**
  19.248 + * __ffs - find first bit in word.
  19.249 + * @word: The word to search
  19.250 + *
  19.251 + * Undefined if no bit exists, so code should check against 0 first.
  19.252 + */
  19.253 +static inline unsigned long __ffs(unsigned long word)
  19.254 +{
  19.255 +	__asm__("bsfl %1,%0"
  19.256 +		:"=r" (word)
  19.257 +		:"rm" (word));
  19.258 +	return word;
  19.259 +}
  19.260 +
  19.261 +
  19.262 +/*
  19.263 + * These have to be done with inline assembly: that way the bit-setting
  19.264 + * is guaranteed to be atomic. All bit operations return 0 if the bit
  19.265 + * was cleared before the operation and != 0 if it was not.
  19.266 + *
  19.267 + * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  19.268 + */
  19.269 +#define ADDR (*(volatile long *) addr)
  19.270 +
  19.271 +#define rdtscll(val) \
  19.272 +     __asm__ __volatile__("rdtsc" : "=A" (val))
  19.273 +
  19.274 +
  19.275 +
  19.276 +#elif defined(__x86_64__)/* ifdef __i386__ */
  19.277 +/************************** x86_84 *******************************/
  19.278 +
  19.279 +#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
  19.280 +#define __xg(x) ((volatile long *)(x))
  19.281 +static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
  19.282 +{
  19.283 +	switch (size) {
  19.284 +		case 1:
  19.285 +			__asm__ __volatile__("xchgb %b0,%1"
  19.286 +				:"=q" (x)
  19.287 +				:"m" (*__xg(ptr)), "0" (x)
  19.288 +				:"memory");
  19.289 +			break;
  19.290 +		case 2:
  19.291 +			__asm__ __volatile__("xchgw %w0,%1"
  19.292 +				:"=r" (x)
  19.293 +				:"m" (*__xg(ptr)), "0" (x)
  19.294 +				:"memory");
  19.295 +			break;
  19.296 +		case 4:
  19.297 +			__asm__ __volatile__("xchgl %k0,%1"
  19.298 +				:"=r" (x)
  19.299 +				:"m" (*__xg(ptr)), "0" (x)
  19.300 +				:"memory");
  19.301 +			break;
  19.302 +		case 8:
  19.303 +			__asm__ __volatile__("xchgq %0,%1"
  19.304 +				:"=r" (x)
  19.305 +				:"m" (*__xg(ptr)), "0" (x)
  19.306 +				:"memory");
  19.307 +			break;
  19.308 +	}
  19.309 +	return x;
  19.310 +}
  19.311 +
  19.312 +/**
  19.313 + * test_and_clear_bit - Clear a bit and return its old value
  19.314 + * @nr: Bit to clear
  19.315   * @addr: Address to count from
  19.316   *
  19.317   * This operation is atomic and cannot be reordered.  
  19.318 @@ -187,29 +334,29 @@ static __inline__ unsigned long __xchg(u
  19.319   */
  19.320  static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
  19.321  {
  19.322 -        int oldbit;
  19.323 +	int oldbit;
  19.324  
  19.325 -        __asm__ __volatile__( LOCK_PREFIX
  19.326 -                "btrl %2,%1\n\tsbbl %0,%0"
  19.327 -                :"=r" (oldbit),"=m" (ADDR)
  19.328 -                :"Ir" (nr) : "memory");
  19.329 -        return oldbit;
  19.330 +	__asm__ __volatile__( LOCK_PREFIX
  19.331 +		"btrl %2,%1\n\tsbbl %0,%0"
  19.332 +		:"=r" (oldbit),"=m" (ADDR)
  19.333 +		:"dIr" (nr) : "memory");
  19.334 +	return oldbit;
  19.335  }
  19.336  
  19.337  static __inline__ int constant_test_bit(int nr, const volatile void * addr)
  19.338  {
  19.339 -    return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
  19.340 +	return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
  19.341  }
  19.342  
  19.343 -static __inline__ int variable_test_bit(int nr, volatile void * addr)
  19.344 +static __inline__ int variable_test_bit(int nr, volatile const void * addr)
  19.345  {
  19.346 -    int oldbit;
  19.347 -    
  19.348 -    __asm__ __volatile__(
  19.349 -        "btl %2,%1\n\tsbbl %0,%0"
  19.350 -        :"=r" (oldbit)
  19.351 -        :"m" (ADDR),"Ir" (nr));
  19.352 -    return oldbit;
  19.353 +	int oldbit;
  19.354 +
  19.355 +	__asm__ __volatile__(
  19.356 +		"btl %2,%1\n\tsbbl %0,%0"
  19.357 +		:"=r" (oldbit)
  19.358 +		:"m" (ADDR),"dIr" (nr));
  19.359 +	return oldbit;
  19.360  }
  19.361  
  19.362  #define test_bit(nr,addr) \
  19.363 @@ -230,10 +377,10 @@ static __inline__ int variable_test_bit(
  19.364   */
  19.365  static __inline__ void set_bit(int nr, volatile void * addr)
  19.366  {
  19.367 -        __asm__ __volatile__( LOCK_PREFIX
  19.368 -                "btsl %1,%0"
  19.369 -                :"=m" (ADDR)
  19.370 -                :"Ir" (nr));
  19.371 +	__asm__ __volatile__( LOCK_PREFIX
  19.372 +		"btsl %1,%0"
  19.373 +		:"=m" (ADDR)
  19.374 +		:"dIr" (nr) : "memory");
  19.375  }
  19.376  
  19.377  /**
  19.378 @@ -248,41 +395,44 @@ static __inline__ void set_bit(int nr, v
  19.379   */
  19.380  static __inline__ void clear_bit(int nr, volatile void * addr)
  19.381  {
  19.382 -        __asm__ __volatile__( LOCK_PREFIX
  19.383 -                "btrl %1,%0"
  19.384 -                :"=m" (ADDR)
  19.385 -                :"Ir" (nr));
  19.386 +	__asm__ __volatile__( LOCK_PREFIX
  19.387 +		"btrl %1,%0"
  19.388 +		:"=m" (ADDR)
  19.389 +		:"dIr" (nr));
  19.390  }
  19.391  
  19.392  /**
  19.393 - * atomic_inc - increment atomic variable
  19.394 - * @v: pointer of type atomic_t
  19.395 - * 
  19.396 - * Atomically increments @v by 1.  Note that the guaranteed
  19.397 - * useful range of an atomic_t is only 24 bits.
  19.398 - */ 
  19.399 -static __inline__ void atomic_inc(atomic_t *v)
  19.400 -{
  19.401 -        __asm__ __volatile__(
  19.402 -                LOCK "incl %0"
  19.403 -                :"=m" (v->counter)
  19.404 -                :"m" (v->counter));
  19.405 -}
  19.406 -
  19.407 -
  19.408 -#define rdtscll(val) \
  19.409 -     __asm__ __volatile__("rdtsc" : "=A" (val))
  19.410 -
  19.411 + * __ffs - find first bit in word.
  19.412 + * @word: The word to search
  19.413 + *
  19.414 + * Undefined if no bit exists, so code should check against 0 first.
  19.415 + */
  19.416  static __inline__ unsigned long __ffs(unsigned long word)
  19.417  {
  19.418 -        __asm__("bsfl %1,%0"
  19.419 -                :"=r" (word)
  19.420 -                :"rm" (word));
  19.421 -        return word;
  19.422 +	__asm__("bsfq %1,%0"
  19.423 +		:"=r" (word)
  19.424 +		:"rm" (word));
  19.425 +	return word;
  19.426  }
  19.427  
  19.428  #define ADDR (*(volatile long *) addr)
  19.429  
  19.430 +#define rdtscll(val) do { \
  19.431 +     unsigned int __a,__d; \
  19.432 +     asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
  19.433 +     (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \
  19.434 +} while(0)
  19.435 +
  19.436 +
  19.437 +#else /* ifdef __x86_64__ */
  19.438 +#error "Unsupported architecture"
  19.439 +#endif
  19.440 +
  19.441 +
  19.442 +/********************* common i386 and x86_64  ****************************/
  19.443 +
  19.444 +
  19.445 +
  19.446  static __inline__ void synch_set_bit(int nr, volatile void * addr)
  19.447  {
  19.448      __asm__ __volatile__ ( 
  19.449 @@ -306,6 +456,14 @@ static __inline__ int synch_test_and_set
  19.450      return oldbit;
  19.451  }
  19.452  
  19.453 +static __inline__ int synch_test_and_clear_bit(int nr, volatile void * addr)
  19.454 +{
  19.455 +    int oldbit;
  19.456 +    __asm__ __volatile__ (
  19.457 +        "lock btrl %2,%1\n\tsbbl %0,%0"
  19.458 +        : "=r" (oldbit), "=m" (ADDR) : "Ir" (nr) : "memory");
  19.459 +    return oldbit;
  19.460 +}
  19.461  
  19.462  static __inline__ int synch_const_test_bit(int nr, const volatile void * addr)
  19.463  {
  19.464 @@ -326,9 +484,8 @@ static __inline__ int synch_var_test_bit
  19.465  (__builtin_constant_p(nr) ? \
  19.466   synch_const_test_bit((nr),(addr)) : \
  19.467   synch_var_test_bit((nr),(addr)))
  19.468 -#endif /* !__ASSEMBLY__ */
  19.469  
  19.470 -#define rdtsc(low,high) \
  19.471 -     __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
  19.472  
  19.473 +
  19.474 +#endif /* not assembly */
  19.475  #endif /* _OS_H_ */
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/extras/mini-os/include/sched.h	Fri Sep 09 10:30:54 2005 -0600
    20.3 @@ -0,0 +1,38 @@
    20.4 +#ifndef __SCHED_H__
    20.5 +#define __SCHED_H__
    20.6 +
    20.7 +#include <list.h>
    20.8 +
    20.9 +struct thread
   20.10 +{
   20.11 +    char *name;
   20.12 +    char *stack;
   20.13 +    unsigned long eps;
   20.14 +    unsigned long eip;
   20.15 +    struct list_head thread_list;
   20.16 +    u32 flags;
   20.17 +};
   20.18 +
   20.19 +
   20.20 +
   20.21 +void init_sched(void);
   20.22 +void run_idle_thread(void);
   20.23 +struct thread* create_thread(char *name, void (*function)(void *), void *data);
   20.24 +void schedule(void);
   20.25 +
   20.26 +static inline struct thread* get_current(void)
   20.27 +{
   20.28 +    struct thread **current;
   20.29 +#ifdef __i386__    
   20.30 +    __asm__("andl %%esp,%0; ":"=r" (current) : "r" (~8191UL));
   20.31 +#endif    
   20.32 +    return *current;
   20.33 +}
   20.34 +          
   20.35 +#define current get_current()
   20.36 +
   20.37 +
   20.38 +void wake(struct thread *thread);
   20.39 +void block(struct thread *thread);
   20.40 +
   20.41 +#endif /* __SCHED_H__ */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/extras/mini-os/include/semaphore.h	Fri Sep 09 10:30:54 2005 -0600
    21.3 @@ -0,0 +1,46 @@
    21.4 +#ifndef _SEMAPHORE_H_
    21.5 +#define _SEMAPHORE_H_
    21.6 +
    21.7 +#include <wait.h>
    21.8 +
    21.9 +/*
   21.10 + * Implementation of semaphore in Mini-os is simple, because 
   21.11 + * there are no preemptive threads, the atomicity is guaranteed.
   21.12 + */
   21.13 +
   21.14 +struct semaphore
   21.15 +{
   21.16 +	int count;
   21.17 +	struct wait_queue_head wait;
   21.18 +};
   21.19 +
   21.20 +
   21.21 +#define __SEMAPHORE_INITIALIZER(name, n)                            \
   21.22 +{                                                                   \
   21.23 +    .count    = n,                                                  \
   21.24 +    .wait           = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait)    \
   21.25 +}
   21.26 +
   21.27 +#define __MUTEX_INITIALIZER(name) \
   21.28 +    __SEMAPHORE_INITIALIZER(name,1)
   21.29 +                           
   21.30 +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
   21.31 +    struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
   21.32 +    
   21.33 +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
   21.34 +
   21.35 +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
   21.36 +
   21.37 +static void inline down(struct semaphore *sem)
   21.38 +{
   21.39 +    wait_event(sem->wait, sem->count > 0);
   21.40 +    sem->count--;
   21.41 +}
   21.42 +
   21.43 +static void inline up(struct semaphore *sem)
   21.44 +{
   21.45 +    sem->count++;
   21.46 +    wake_up(&sem->wait);
   21.47 +}
   21.48 +
   21.49 +#endif /* _SEMAPHORE_H */
    22.1 --- a/extras/mini-os/include/time.h	Thu Sep 08 09:18:40 2005 -0600
    22.2 +++ b/extras/mini-os/include/time.h	Fri Sep 09 10:30:54 2005 -0600
    22.3 @@ -58,6 +58,6 @@ void     init_time(void);
    22.4  s_time_t get_s_time(void);
    22.5  s_time_t get_v_time(void);
    22.6  void     gettimeofday(struct timeval *tv);
    22.7 -void     block(u32 millisecs);
    22.8 +void     block_domain(u32 millisecs);
    22.9  
   22.10  #endif /* _TIME_H_ */
    23.1 --- a/extras/mini-os/include/traps.h	Thu Sep 08 09:18:40 2005 -0600
    23.2 +++ b/extras/mini-os/include/traps.h	Fri Sep 09 10:30:54 2005 -0600
    23.3 @@ -17,6 +17,7 @@
    23.4  #ifndef _TRAPS_H_
    23.5  #define _TRAPS_H_
    23.6  
    23.7 +#ifdef __i386__
    23.8  struct pt_regs {
    23.9  	long ebx;
   23.10  	long ecx;
   23.11 @@ -34,7 +35,38 @@ struct pt_regs {
   23.12  	long esp;
   23.13  	int  xss;
   23.14  };
   23.15 +#elif __x86_64__
   23.16  
   23.17 +struct pt_regs {
   23.18 +	unsigned long r15;
   23.19 +	unsigned long r14;
   23.20 +	unsigned long r13;
   23.21 +	unsigned long r12;
   23.22 +	unsigned long rbp;
   23.23 +	unsigned long rbx;
   23.24 +/* arguments: non interrupts/non tracing syscalls only save upto here*/
   23.25 + 	unsigned long r11;
   23.26 +	unsigned long r10;	
   23.27 +	unsigned long r9;
   23.28 +	unsigned long r8;
   23.29 +	unsigned long rax;
   23.30 +	unsigned long rcx;
   23.31 +	unsigned long rdx;
   23.32 +	unsigned long rsi;
   23.33 +	unsigned long rdi;
   23.34 +	unsigned long orig_rax;
   23.35 +/* end of arguments */ 	
   23.36 +/* cpu exception frame or undefined */
   23.37 +	unsigned long rip;
   23.38 +	unsigned long cs;
   23.39 +	unsigned long eflags; 
   23.40 +	unsigned long rsp; 
   23.41 +	unsigned long ss;
   23.42 +/* top of stack page */ 
   23.43 +};
   23.44 +
   23.45 +
   23.46 +#endif
   23.47  
   23.48  void dump_regs(struct pt_regs *regs);
   23.49  
    24.1 --- a/extras/mini-os/include/types.h	Thu Sep 08 09:18:40 2005 -0600
    24.2 +++ b/extras/mini-os/include/types.h	Fri Sep 09 10:30:54 2005 -0600
    24.3 @@ -44,11 +44,19 @@ typedef unsigned long       u_long;
    24.4  typedef long long           quad_t;
    24.5  typedef unsigned long long  u_quad_t;
    24.6  typedef unsigned int        uintptr_t;
    24.7 +
    24.8 +typedef struct { unsigned long pte_low; } pte_t;
    24.9  #elif defined(__x86_64__)
   24.10  typedef long                quad_t;
   24.11  typedef unsigned long       u_quad_t;
   24.12  typedef unsigned long       uintptr_t;
   24.13 +
   24.14 +typedef struct { unsigned long pte; } pte_t;
   24.15  #endif
   24.16  
   24.17 +
   24.18 +
   24.19 +
   24.20 +#define INT_MAX         ((int)(~0U>>1))
   24.21  #define UINT_MAX            (~0U)
   24.22  #endif /* _TYPES_H_ */
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/extras/mini-os/include/wait.h	Fri Sep 09 10:30:54 2005 -0600
    25.3 @@ -0,0 +1,91 @@
    25.4 +#ifndef __WAIT_H__
    25.5 +#define __WAIT_H__
    25.6 +
    25.7 +#include <sched.h>
    25.8 +#include <list.h>
    25.9 +#include <lib.h>
   25.10 +#include <os.h>
   25.11 +
   25.12 +struct wait_queue
   25.13 +{
   25.14 +    struct thread *thread;
   25.15 +    struct list_head thread_list;
   25.16 +};
   25.17 +
   25.18 +struct wait_queue_head
   25.19 +{
   25.20 +    /* TODO - lock required? */
   25.21 +    struct list_head thread_list;
   25.22 +};
   25.23 +
   25.24 +#define DECLARE_WAIT_QUEUE_HEAD(name) \
   25.25 +   struct wait_queue_head name =     \
   25.26 +        { .thread_list = { &(name).thread_list, &(name).thread_list} }
   25.27 +
   25.28 +#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                           \
   25.29 +    .thread_list      = { &(name).thread_list, &(name).thread_list } }
   25.30 +
   25.31 +
   25.32 +#define DEFINE_WAIT(name)                               \
   25.33 +struct wait_queue name = {                              \
   25.34 +    .thread       = current,                            \
   25.35 +    .thread_list  = LIST_HEAD_INIT((name).thread_list), \
   25.36 +}
   25.37 +
   25.38 +
   25.39 +
   25.40 +static inline void init_waitqueue_entry(struct wait_queue *q, struct thread *thread)
   25.41 +{
   25.42 +    q->thread = thread;
   25.43 +}
   25.44 +
   25.45 +
   25.46 +static inline void add_wait_queue(struct wait_queue_head *h, struct wait_queue *q)
   25.47 +{
   25.48 +    if (list_empty(&q->thread_list))
   25.49 +        list_add(&q->thread_list, &h->thread_list);   
   25.50 +}
   25.51 +
   25.52 +static inline void remove_wait_queue(struct wait_queue *q)
   25.53 +{
   25.54 +    list_del(&q->thread_list);
   25.55 +}
   25.56 +
   25.57 +static inline void wake_up(struct wait_queue_head *head)
   25.58 +{
   25.59 +    struct list_head *tmp, *next;
   25.60 +    list_for_each_safe(tmp, next, &head->thread_list)
   25.61 +    {
   25.62 +         struct wait_queue *curr;
   25.63 +         curr = list_entry(tmp, struct wait_queue, thread_list);
   25.64 +         wake(curr->thread);
   25.65 +    }
   25.66 +}
   25.67 +
   25.68 +#define wait_event(wq, condition) do{             \
   25.69 +    unsigned long flags;                          \
   25.70 +    if(condition)                                 \
   25.71 +        break;                                    \
   25.72 +    DEFINE_WAIT(__wait);                          \
   25.73 +    for(;;)                                       \
   25.74 +    {                                             \
   25.75 +        /* protect the list */                    \
   25.76 +        local_irq_save(flags);                    \
   25.77 +        add_wait_queue(&wq, &__wait);             \
   25.78 +        block(current);                           \
   25.79 +        local_irq_restore(flags);                 \
   25.80 +        if(condition)                             \
   25.81 +            break;                                \
   25.82 +        schedule();                               \
   25.83 +    }                                             \
   25.84 +    local_irq_save(flags);                        \
   25.85 +    /* need to wake up */                         \
   25.86 +    wake(current);                                \
   25.87 +    remove_wait_queue(&__wait);                   \
   25.88 +    local_irq_restore(flags);                     \
   25.89 +} while(0) 
   25.90 +
   25.91 +
   25.92 +
   25.93 +
   25.94 +#endif /* __WAIT_H__ */
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/extras/mini-os/include/xenbus.h	Fri Sep 09 10:30:54 2005 -0600
    26.3 @@ -0,0 +1,89 @@
    26.4 +/******************************************************************************
    26.5 + * xenbus.h
    26.6 + *
    26.7 + * Talks to Xen Store to figure out what devices we have.
    26.8 + *
    26.9 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
   26.10 + * 
   26.11 + * This file may be distributed separately from the Linux kernel, or
   26.12 + * incorporated into other software packages, subject to the following license:
   26.13 + * 
   26.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   26.15 + * of this source file (the "Software"), to deal in the Software without
   26.16 + * restriction, including without limitation the rights to use, copy, modify,
   26.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   26.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   26.19 + * the following conditions:
   26.20 + * 
   26.21 + * The above copyright notice and this permission notice shall be included in
   26.22 + * all copies or substantial portions of the Software.
   26.23 + * 
   26.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   26.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   26.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   26.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   26.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   26.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   26.30 + * IN THE SOFTWARE.
   26.31 + */
   26.32 +
   26.33 +#ifndef _ASM_XEN_XENBUS_H
   26.34 +#define _ASM_XEN_XENBUS_H
   26.35 +
   26.36 +
   26.37 +/* Caller must hold this lock to call these functions: it's also held
   26.38 + * across watch callbacks. */
   26.39 +// TODO
   26.40 +//extern struct semaphore xenbus_lock;
   26.41 +
   26.42 +char **xenbus_directory(const char *dir, const char *node, unsigned int *num);
   26.43 +void *xenbus_read(const char *dir, const char *node, unsigned int *len);
   26.44 +int xenbus_write(const char *dir, const char *node,
   26.45 +		 const char *string, int createflags);
   26.46 +int xenbus_mkdir(const char *dir, const char *node);
   26.47 +int xenbus_exists(const char *dir, const char *node);
   26.48 +int xenbus_rm(const char *dir, const char *node);
   26.49 +int xenbus_transaction_start(const char *subtree);
   26.50 +int xenbus_transaction_end(int abort);
   26.51 +
   26.52 +/* Single read and scanf: returns -errno or num scanned if > 0. */
   26.53 +int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
   26.54 +	__attribute__((format(scanf, 3, 4)));
   26.55 +
   26.56 +/* Single printf and write: returns -errno or 0. */
   26.57 +int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
   26.58 +	__attribute__((format(printf, 3, 4)));
   26.59 +
   26.60 +/* Generic read function: NULL-terminated triples of name,
   26.61 + * sprintf-style type string, and pointer. Returns 0 or errno.*/
   26.62 +int xenbus_gather(const char *dir, ...);
   26.63 +
   26.64 +/* Register callback to watch this node. */
   26.65 +struct xenbus_watch
   26.66 +{
   26.67 +	struct list_head list;
   26.68 +	char *node;
   26.69 +	void (*callback)(struct xenbus_watch *, const char *node);
   26.70 +};
   26.71 +
   26.72 +int register_xenbus_watch(struct xenbus_watch *watch);
   26.73 +void unregister_xenbus_watch(struct xenbus_watch *watch);
   26.74 +void reregister_xenbus_watches(void);
   26.75 +
   26.76 +/* Called from xen core code. */
   26.77 +void xenbus_suspend(void);
   26.78 +void xenbus_resume(void);
   26.79 +
   26.80 +#define XENBUS_IS_ERR_READ(str) ({			\
   26.81 +	if (!IS_ERR(str) && strlen(str) == 0) {		\
   26.82 +		kfree(str);				\
   26.83 +		str = ERR_PTR(-ERANGE);			\
   26.84 +	}						\
   26.85 +	IS_ERR(str);					\
   26.86 +})
   26.87 +
   26.88 +#define XENBUS_EXIST_ERR(err) ((err) == -ENOENT || (err) == -ERANGE)
   26.89 +
   26.90 +int xs_init(void);
   26.91 +
   26.92 +#endif /* _ASM_XEN_XENBUS_H */
    27.1 --- a/extras/mini-os/kernel.c	Thu Sep 08 09:18:40 2005 -0600
    27.2 +++ b/extras/mini-os/kernel.c	Fri Sep 09 10:30:54 2005 -0600
    27.3 @@ -33,6 +33,8 @@
    27.4  #include <time.h>
    27.5  #include <types.h>
    27.6  #include <lib.h>
    27.7 +#include <sched.h>
    27.8 +#include <xenbus.h>
    27.9  
   27.10  /*
   27.11   * Shared page for communicating with the hypervisor.
   27.12 @@ -59,10 +61,12 @@ void failsafe_callback(void);
   27.13  
   27.14  extern char shared_info[PAGE_SIZE];
   27.15  
   27.16 +#define __pte(x) ((pte_t) { (0) } )
   27.17 +
   27.18  static shared_info_t *map_shared_info(unsigned long pa)
   27.19  {
   27.20      if ( HYPERVISOR_update_va_mapping(
   27.21 -        (unsigned long)shared_info, pa | 7, UVMF_INVLPG) )
   27.22 +        (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG) )
   27.23      {
   27.24          printk("Failed to map shared_info!!\n");
   27.25          *(int*)0=0;
   27.26 @@ -77,7 +81,6 @@ static shared_info_t *map_shared_info(un
   27.27  void start_kernel(start_info_t *si)
   27.28  {
   27.29      static char hello[] = "Bootstrapping...\n";
   27.30 -    int i;
   27.31      (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(hello), hello);
   27.32  
   27.33      /* Copy the start_info struct to a globally-accessible area. */
   27.34 @@ -96,7 +99,6 @@ void start_kernel(start_info_t *si)
   27.35          (unsigned long)hypervisor_callback,
   27.36          (unsigned long)failsafe_callback, 0);
   27.37  #endif
   27.38 -
   27.39      trap_init();
   27.40  
   27.41      /* ENABLE EVENT DELIVERY. This is disabled at start of day. */
   27.42 @@ -119,7 +121,6 @@ void start_kernel(start_info_t *si)
   27.43       * If used for porting another OS, start here to figure out your
   27.44       * guest os entry point. Otherwise continue below...
   27.45       */
   27.46 -
   27.47      /* init memory management */
   27.48      init_mm();
   27.49  
   27.50 @@ -127,15 +128,15 @@ void start_kernel(start_info_t *si)
   27.51      init_events();
   27.52      /* init time and timers */
   27.53      init_time();
   27.54 +    
   27.55 +    /* init scheduler */
   27.56 +    init_sched();
   27.57  
   27.58 -    /* do nothing */
   27.59 -    i = 0;
   27.60 -    for ( ; ; ) 
   27.61 -    {      
   27.62 -//        HYPERVISOR_yield();
   27.63 -        block(100);
   27.64 -        i++;
   27.65 -    }
   27.66 +    /* init xenbus */
   27.67 +    xs_init();
   27.68 +    
   27.69 +    /* Everything initialised, start idle thread */
   27.70 +    run_idle_thread();
   27.71  }
   27.72  
   27.73  
    28.1 --- a/extras/mini-os/lib/printf.c	Thu Sep 08 09:18:40 2005 -0600
    28.2 +++ b/extras/mini-os/lib/printf.c	Fri Sep 09 10:30:54 2005 -0600
    28.3 @@ -1,21 +1,19 @@
    28.4 -/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
    28.5 +/* 
    28.6   ****************************************************************************
    28.7   * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
    28.8   ****************************************************************************
    28.9   *
   28.10   *        File: printf.c
   28.11   *      Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk)
   28.12 - *     Changes: 
   28.13 + *     Changes: Grzegorz Milos (gm281@cam.ac.uk) 
   28.14   *              
   28.15 - *        Date: Aug 2003
   28.16 + *        Date: Aug 2003, Aug 2005
   28.17   * 
   28.18   * Environment: Xen Minimal OS
   28.19   * Description: Library functions for printing
   28.20   *              (freebsd port, mainly sys/subr_prf.c)
   28.21   *
   28.22   ****************************************************************************
   28.23 - * $Id: c-insert.c,v 1.7 2002/11/08 16:04:34 rn Exp $
   28.24 - ****************************************************************************
   28.25   *
   28.26   *-
   28.27   * Copyright (c) 1992, 1993
   28.28 @@ -60,409 +58,748 @@
   28.29  #include <types.h>
   28.30  #include <hypervisor.h>
   28.31  #include <lib.h>
   28.32 -
   28.33 -/****************************************************************************
   28.34 - * RN: printf family of routines
   28.35 - * taken mainly from sys/subr_prf.c
   28.36 - ****************************************************************************/
   28.37 -char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
   28.38 -#define hex2ascii(hex)  (hex2ascii_data[hex])
   28.39 -#define NBBY    8               /* number of bits in a byte */
   28.40 -#define MAXNBUF    (sizeof(quad_t) * NBBY + 1)
   28.41 -
   28.42 -static int kvprintf(char const *fmt, void *arg, int radix, va_list ap);
   28.43 -
   28.44 +#include <mm.h>
   28.45 +#include <ctype.h>
   28.46  
   28.47 -int
   28.48 -printf(const char *fmt, ...)
   28.49 +/**
   28.50 + * simple_strtoul - convert a string to an unsigned long
   28.51 + * @cp: The start of the string
   28.52 + * @endp: A pointer to the end of the parsed string will be placed here
   28.53 + * @base: The number base to use
   28.54 + */
   28.55 +unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
   28.56  {
   28.57 -	va_list ap;
   28.58 -	int retval;
   28.59 -    static char printk_buf[1024];
   28.60 +    unsigned long result = 0,value;
   28.61  
   28.62 -	va_start(ap, fmt);
   28.63 -	retval = kvprintf(fmt, printk_buf, 10, ap);
   28.64 -    printk_buf[retval] = '\0';
   28.65 -	va_end(ap);
   28.66 -    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(printk_buf), 
   28.67 -                                printk_buf);
   28.68 -	return retval;
   28.69 +    if (!base) {
   28.70 +        base = 10;
   28.71 +        if (*cp == '0') {
   28.72 +            base = 8;
   28.73 +            cp++;
   28.74 +            if ((*cp == 'x') && isxdigit(cp[1])) {
   28.75 +                cp++;
   28.76 +                base = 16;
   28.77 +            }
   28.78 +        }
   28.79 +    }
   28.80 +    while (isxdigit(*cp) &&
   28.81 +           (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
   28.82 +        result = result*base + value;
   28.83 +        cp++;
   28.84 +    }
   28.85 +    if (endp)
   28.86 +        *endp = (char *)cp;
   28.87 +    return result;
   28.88  }
   28.89  
   28.90 -int
   28.91 -vprintf(const char *fmt, va_list ap)
   28.92 +/**
   28.93 + * simple_strtol - convert a string to a signed long
   28.94 + * @cp: The start of the string
   28.95 + * @endp: A pointer to the end of the parsed string will be placed here
   28.96 + * @base: The number base to use
   28.97 + */
   28.98 +long simple_strtol(const char *cp,char **endp,unsigned int base)
   28.99  {
  28.100 -	int retval;
  28.101 -    static char printk_buf[1024];
  28.102 -	retval = kvprintf(fmt, printk_buf, 10, ap);
  28.103 -    printk_buf[retval] = '\0';
  28.104 -    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(printk_buf),
  28.105 -                                printk_buf);
  28.106 -	return retval;
  28.107 +    if(*cp=='-')
  28.108 +        return -simple_strtoul(cp+1,endp,base);
  28.109 +    return simple_strtoul(cp,endp,base);
  28.110  }
  28.111  
  28.112 -int
  28.113 -sprintf(char *buf, const char *cfmt, ...)
  28.114 +/**
  28.115 + * simple_strtoull - convert a string to an unsigned long long
  28.116 + * @cp: The start of the string
  28.117 + * @endp: A pointer to the end of the parsed string will be placed here
  28.118 + * @base: The number base to use
  28.119 + */
  28.120 +unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base)
  28.121  {
  28.122 -	int retval;
  28.123 -	va_list ap;
  28.124 +    unsigned long long result = 0,value;
  28.125  
  28.126 -	va_start(ap, cfmt);
  28.127 -	retval = kvprintf(cfmt, (void *)buf, 10, ap);
  28.128 -	buf[retval] = '\0';
  28.129 -	va_end(ap);
  28.130 -	return retval;
  28.131 +    if (!base) {
  28.132 +        base = 10;
  28.133 +        if (*cp == '0') {
  28.134 +            base = 8;
  28.135 +            cp++;
  28.136 +            if ((*cp == 'x') && isxdigit(cp[1])) {
  28.137 +                cp++;
  28.138 +                base = 16;
  28.139 +            }
  28.140 +        }
  28.141 +    }
  28.142 +    while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
  28.143 +                                                               ? toupper(*cp) : *cp)-'A'+10) < base) {
  28.144 +        result = result*base + value;
  28.145 +        cp++;
  28.146 +    }
  28.147 +    if (endp)
  28.148 +        *endp = (char *)cp;
  28.149 +    return result;
  28.150  }
  28.151  
  28.152 -int
  28.153 -vsprintf(char *buf, const char *cfmt, va_list ap)
  28.154 +/**
  28.155 + * simple_strtoll - convert a string to a signed long long
  28.156 + * @cp: The start of the string
  28.157 + * @endp: A pointer to the end of the parsed string will be placed here
  28.158 + * @base: The number base to use
  28.159 + */
  28.160 +long long simple_strtoll(const char *cp,char **endp,unsigned int base)
  28.161  {
  28.162 -	int retval;
  28.163 +    if(*cp=='-')
  28.164 +        return -simple_strtoull(cp+1,endp,base);
  28.165 +    return simple_strtoull(cp,endp,base);
  28.166 +}
  28.167  
  28.168 -	retval = kvprintf(cfmt, (void *)buf, 10, ap);
  28.169 -	buf[retval] = '\0';
  28.170 -	return retval;
  28.171 +static int skip_atoi(const char **s)
  28.172 +{
  28.173 +    int i=0;
  28.174 +
  28.175 +    while (isdigit(**s))
  28.176 +        i = i*10 + *((*s)++) - '0';
  28.177 +    return i;
  28.178 +}
  28.179 +
  28.180 +#define ZEROPAD 1               /* pad with zero */
  28.181 +#define SIGN    2               /* unsigned/signed long */
  28.182 +#define PLUS    4               /* show plus */
  28.183 +#define SPACE   8               /* space if plus */
  28.184 +#define LEFT    16              /* left justified */
  28.185 +#define SPECIAL 32              /* 0x */
  28.186 +#define LARGE   64              /* use 'ABCDEF' instead of 'abcdef' */
  28.187 +
  28.188 +static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type)
  28.189 +{
  28.190 +    char c,sign,tmp[66];
  28.191 +    const char *digits;
  28.192 +    const char small_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
  28.193 +    const char large_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  28.194 +    int i;
  28.195 +
  28.196 +    digits = (type & LARGE) ? large_digits : small_digits;
  28.197 +    if (type & LEFT)
  28.198 +        type &= ~ZEROPAD;
  28.199 +    if (base < 2 || base > 36)
  28.200 +        return buf;
  28.201 +    c = (type & ZEROPAD) ? '0' : ' ';
  28.202 +    sign = 0;
  28.203 +    if (type & SIGN) {
  28.204 +        if (num < 0) {
  28.205 +            sign = '-';
  28.206 +            num = -num;
  28.207 +            size--;
  28.208 +        } else if (type & PLUS) {
  28.209 +            sign = '+';
  28.210 +            size--;
  28.211 +        } else if (type & SPACE) {
  28.212 +            sign = ' ';
  28.213 +            size--;
  28.214 +        }
  28.215 +    }
  28.216 +    if (type & SPECIAL) {
  28.217 +        if (base == 16)
  28.218 +            size -= 2;
  28.219 +        else if (base == 8)
  28.220 +            size--;
  28.221 +    }
  28.222 +    i = 0;
  28.223 +    if (num == 0)
  28.224 +        tmp[i++]='0';
  28.225 +    else 
  28.226 +    {
  28.227 +        /* XXX KAF: force unsigned mod and div. */
  28.228 +        unsigned long long num2=(unsigned long long)num;
  28.229 +        unsigned int base2=(unsigned int)base;
  28.230 +        while (num2 != 0) { tmp[i++] = digits[num2%base2]; num2 /= base2; }
  28.231 +    }
  28.232 +    if (i > precision)
  28.233 +        precision = i;
  28.234 +    size -= precision;
  28.235 +    if (!(type&(ZEROPAD+LEFT))) {
  28.236 +        while(size-->0) {
  28.237 +            if (buf <= end)
  28.238 +                *buf = ' ';
  28.239 +            ++buf;
  28.240 +        }
  28.241 +    }
  28.242 +    if (sign) {
  28.243 +        if (buf <= end)
  28.244 +            *buf = sign;
  28.245 +        ++buf;
  28.246 +    }
  28.247 +    if (type & SPECIAL) {
  28.248 +        if (base==8) {
  28.249 +            if (buf <= end)
  28.250 +                *buf = '0';
  28.251 +            ++buf;
  28.252 +        } else if (base==16) {
  28.253 +            if (buf <= end)
  28.254 +                *buf = '0';
  28.255 +            ++buf;
  28.256 +            if (buf <= end)
  28.257 +                *buf = digits[33];
  28.258 +            ++buf;
  28.259 +        }
  28.260 +    }
  28.261 +    if (!(type & LEFT)) {
  28.262 +        while (size-- > 0) {
  28.263 +            if (buf <= end)
  28.264 +                *buf = c;
  28.265 +            ++buf;
  28.266 +        }
  28.267 +    }
  28.268 +    while (i < precision--) {
  28.269 +        if (buf <= end)
  28.270 +            *buf = '0';
  28.271 +        ++buf;
  28.272 +    }
  28.273 +    while (i-- > 0) {
  28.274 +        if (buf <= end)
  28.275 +            *buf = tmp[i];
  28.276 +        ++buf;
  28.277 +    }
  28.278 +    while (size-- > 0) {
  28.279 +        if (buf <= end)
  28.280 +            *buf = ' ';
  28.281 +        ++buf;
  28.282 +    }
  28.283 +    return buf;
  28.284 +}
  28.285 +
  28.286 +/**
  28.287 +* vsnprintf - Format a string and place it in a buffer
  28.288 +* @buf: The buffer to place the result into
  28.289 +* @size: The size of the buffer, including the trailing null space
  28.290 +* @fmt: The format string to use
  28.291 +* @args: Arguments for the format string
  28.292 +*
  28.293 +* Call this function if you are already dealing with a va_list.
  28.294 +* You probably want snprintf instead.
  28.295 + */
  28.296 +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
  28.297 +{
  28.298 +    int len;
  28.299 +    unsigned long long num;
  28.300 +    int i, base;
  28.301 +    char *str, *end, c;
  28.302 +    const char *s;
  28.303 +
  28.304 +    int flags;          /* flags to number() */
  28.305 +
  28.306 +    int field_width;    /* width of output field */
  28.307 +    int precision;              /* min. # of digits for integers; max
  28.308 +                                   number of chars for from string */
  28.309 +    int qualifier;              /* 'h', 'l', or 'L' for integer fields */
  28.310 +                                /* 'z' support added 23/7/1999 S.H.    */
  28.311 +                                /* 'z' changed to 'Z' --davidm 1/25/99 */
  28.312 +
  28.313 +    str = buf;
  28.314 +    end = buf + size - 1;
  28.315 +
  28.316 +    if (end < buf - 1) {
  28.317 +        end = ((void *) -1);
  28.318 +        size = end - buf + 1;
  28.319 +    }
  28.320 +
  28.321 +    for (; *fmt ; ++fmt) {
  28.322 +        if (*fmt != '%') {
  28.323 +            if (str <= end)
  28.324 +                *str = *fmt;
  28.325 +            ++str;
  28.326 +            continue;
  28.327 +        }
  28.328 +
  28.329 +        /* process flags */
  28.330 +        flags = 0;
  28.331 +    repeat:
  28.332 +        ++fmt;          /* this also skips first '%' */
  28.333 +        switch (*fmt) {
  28.334 +        case '-': flags |= LEFT; goto repeat;
  28.335 +        case '+': flags |= PLUS; goto repeat;
  28.336 +        case ' ': flags |= SPACE; goto repeat;
  28.337 +        case '#': flags |= SPECIAL; goto repeat;
  28.338 +        case '0': flags |= ZEROPAD; goto repeat;
  28.339 +        }
  28.340 +
  28.341 +        /* get field width */
  28.342 +        field_width = -1;
  28.343 +        if (isdigit(*fmt))
  28.344 +            field_width = skip_atoi(&fmt);
  28.345 +        else if (*fmt == '*') {
  28.346 +            ++fmt;
  28.347 +            /* it's the next argument */
  28.348 +            field_width = va_arg(args, int);
  28.349 +            if (field_width < 0) {
  28.350 +                field_width = -field_width;
  28.351 +                flags |= LEFT;
  28.352 +            }
  28.353 +        }
  28.354 +
  28.355 +        /* get the precision */
  28.356 +        precision = -1;
  28.357 +        if (*fmt == '.') {
  28.358 +            ++fmt;
  28.359 +            if (isdigit(*fmt))
  28.360 +                precision = skip_atoi(&fmt);
  28.361 +            else if (*fmt == '*') {
  28.362 +                ++fmt;
  28.363 +                          /* it's the next argument */
  28.364 +                precision = va_arg(args, int);
  28.365 +            }
  28.366 +            if (precision < 0)
  28.367 +                precision = 0;
  28.368 +        }
  28.369 +
  28.370 +        /* get the conversion qualifier */
  28.371 +        qualifier = -1;
  28.372 +        if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='Z') {
  28.373 +            qualifier = *fmt;
  28.374 +            ++fmt;
  28.375 +            if (qualifier == 'l' && *fmt == 'l') {
  28.376 +                qualifier = 'L';
  28.377 +                ++fmt;
  28.378 +            }
  28.379 +        }
  28.380 +        if (*fmt == 'q') {
  28.381 +            qualifier = 'L';
  28.382 +            ++fmt;
  28.383 +        }
  28.384 +
  28.385 +        /* default base */
  28.386 +        base = 10;
  28.387 +
  28.388 +        switch (*fmt) {
  28.389 +        case 'c':
  28.390 +            if (!(flags & LEFT)) {
  28.391 +                while (--field_width > 0) {
  28.392 +                    if (str <= end)
  28.393 +                        *str = ' ';
  28.394 +                    ++str;
  28.395 +                }
  28.396 +            }
  28.397 +            c = (unsigned char) va_arg(args, int);
  28.398 +            if (str <= end)
  28.399 +                *str = c;
  28.400 +            ++str;
  28.401 +            while (--field_width > 0) {
  28.402 +                if (str <= end)
  28.403 +                    *str = ' ';
  28.404 +                ++str;
  28.405 +            }
  28.406 +            continue;
  28.407 +
  28.408 +        case 's':
  28.409 +            s = va_arg(args, char *);
  28.410 +            if (!s)
  28.411 +                s = "<NULL>";
  28.412 +
  28.413 +            len = strnlen(s, precision);
  28.414 +
  28.415 +            if (!(flags & LEFT)) {
  28.416 +                while (len < field_width--) {
  28.417 +                    if (str <= end)
  28.418 +                        *str = ' ';
  28.419 +                    ++str;
  28.420 +                }
  28.421 +            }
  28.422 +            for (i = 0; i < len; ++i) {
  28.423 +                if (str <= end)
  28.424 +                    *str = *s;
  28.425 +                ++str; ++s;
  28.426 +            }
  28.427 +            while (len < field_width--) {
  28.428 +                if (str <= end)
  28.429 +                    *str = ' ';
  28.430 +                ++str;
  28.431 +            }
  28.432 +            continue;
  28.433 +
  28.434 +        case 'p':
  28.435 +            if (field_width == -1) {
  28.436 +                field_width = 2*sizeof(void *);
  28.437 +                flags |= ZEROPAD;
  28.438 +            }
  28.439 +            str = number(str, end,
  28.440 +                         (unsigned long) va_arg(args, void *),
  28.441 +                         16, field_width, precision, flags);
  28.442 +            continue;
  28.443 +
  28.444 +
  28.445 +        case 'n':
  28.446 +            /* FIXME:
  28.447 +             * What does C99 say about the overflow case here? */
  28.448 +            if (qualifier == 'l') {
  28.449 +                long * ip = va_arg(args, long *);
  28.450 +                *ip = (str - buf);
  28.451 +            } else if (qualifier == 'Z') {
  28.452 +                size_t * ip = va_arg(args, size_t *);
  28.453 +                *ip = (str - buf);
  28.454 +            } else {
  28.455 +                int * ip = va_arg(args, int *);
  28.456 +                *ip = (str - buf);
  28.457 +            }
  28.458 +            continue;
  28.459 +
  28.460 +        case '%':
  28.461 +            if (str <= end)
  28.462 +                *str = '%';
  28.463 +            ++str;
  28.464 +            continue;
  28.465 +
  28.466 +                        /* integer number formats - set up the flags and "break" */
  28.467 +        case 'o':
  28.468 +            base = 8;
  28.469 +            break;
  28.470 +
  28.471 +        case 'X':
  28.472 +            flags |= LARGE;
  28.473 +        case 'x':
  28.474 +            base = 16;
  28.475 +            break;
  28.476 +
  28.477 +        case 'd':
  28.478 +        case 'i':
  28.479 +            flags |= SIGN;
  28.480 +        case 'u':
  28.481 +            break;
  28.482 +
  28.483 +        default:
  28.484 +            if (str <= end)
  28.485 +                *str = '%';
  28.486 +            ++str;
  28.487 +            if (*fmt) {
  28.488 +                if (str <= end)
  28.489 +                    *str = *fmt;
  28.490 +                ++str;
  28.491 +            } else {
  28.492 +                --fmt;
  28.493 +            }
  28.494 +            continue;
  28.495 +        }
  28.496 +        if (qualifier == 'L')
  28.497 +            num = va_arg(args, long long);
  28.498 +        else if (qualifier == 'l') {
  28.499 +            num = va_arg(args, unsigned long);
  28.500 +            if (flags & SIGN)
  28.501 +                num = (signed long) num;
  28.502 +        } else if (qualifier == 'Z') {
  28.503 +            num = va_arg(args, size_t);
  28.504 +        } else if (qualifier == 'h') {
  28.505 +            num = (unsigned short) va_arg(args, int);
  28.506 +            if (flags & SIGN)
  28.507 +                num = (signed short) num;
  28.508 +        } else {
  28.509 +            num = va_arg(args, unsigned int);
  28.510 +            if (flags & SIGN)
  28.511 +                num = (signed int) num;
  28.512 +        }
  28.513 +
  28.514 +        str = number(str, end, num, base,
  28.515 +                     field_width, precision, flags);
  28.516 +    }
  28.517 +    if (str <= end)
  28.518 +        *str = '\0';
  28.519 +    else if (size > 0)
  28.520 +        /* don't write out a null byte if the buf size is zero */
  28.521 +        *end = '\0';
  28.522 +    /* the trailing null byte doesn't count towards the total
  28.523 +     * ++str;
  28.524 +     */
  28.525 +    return str-buf;
  28.526 +}
  28.527 +
  28.528 +/**
  28.529 + * snprintf - Format a string and place it in a buffer
  28.530 + * @buf: The buffer to place the result into
  28.531 + * @size: The size of the buffer, including the trailing null space
  28.532 + * @fmt: The format string to use
  28.533 + * @...: Arguments for the format string
  28.534 + */
  28.535 +int snprintf(char * buf, size_t size, const char *fmt, ...)
  28.536 +{
  28.537 +    va_list args;
  28.538 +    int i;
  28.539 +
  28.540 +    va_start(args, fmt);
  28.541 +    i=vsnprintf(buf,size,fmt,args);
  28.542 +    va_end(args);
  28.543 +    return i;
  28.544 +}
  28.545 +
  28.546 +/**
  28.547 + * vsprintf - Format a string and place it in a buffer
  28.548 + * @buf: The buffer to place the result into
  28.549 + * @fmt: The format string to use
  28.550 + * @args: Arguments for the format string
  28.551 + *
  28.552 + * Call this function if you are already dealing with a va_list.
  28.553 + * You probably want sprintf instead.
  28.554 + */
  28.555 +int vsprintf(char *buf, const char *fmt, va_list args)
  28.556 +{
  28.557 +    return vsnprintf(buf, 0xFFFFFFFFUL, fmt, args);
  28.558  }
  28.559  
  28.560  
  28.561 -/*
  28.562 - * Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
  28.563 - * order; return an optional length and a pointer to the last character
  28.564 - * written in the buffer (i.e., the first character of the string).
  28.565 - * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
  28.566 +/**
  28.567 + * sprintf - Format a string and place it in a buffer
  28.568 + * @buf: The buffer to place the result into
  28.569 + * @fmt: The format string to use
  28.570 + * @...: Arguments for the format string
  28.571   */
  28.572 -static char *
  28.573 -ksprintn(char *nbuf, u_long ul, int base, int *lenp)
  28.574 +int sprintf(char * buf, const char *fmt, ...)
  28.575  {
  28.576 -	char *p;
  28.577 +    va_list args;
  28.578 +    int i;
  28.579  
  28.580 -	p = nbuf;
  28.581 -	*p = '\0';
  28.582 -	do {
  28.583 -		*++p = hex2ascii(ul % base);
  28.584 -	} while (ul /= base);
  28.585 -	if (lenp)
  28.586 -		*lenp = p - nbuf;
  28.587 -	return (p);
  28.588 -}
  28.589 -/* ksprintn, but for a quad_t. */
  28.590 -static char *
  28.591 -ksprintqn(char *nbuf, u_quad_t uq, int base, int *lenp)
  28.592 -{
  28.593 -	char *p;
  28.594 -
  28.595 -	p = nbuf;
  28.596 -	*p = '\0';
  28.597 -	do {
  28.598 -		*++p = hex2ascii(uq % base);
  28.599 -	} while (uq /= base);
  28.600 -	if (lenp)
  28.601 -		*lenp = p - nbuf;
  28.602 -	return (p);
  28.603 +    va_start(args, fmt);
  28.604 +    i=vsprintf(buf,fmt,args);
  28.605 +    va_end(args);
  28.606 +    return i;
  28.607  }
  28.608  
  28.609 -/*
  28.610 - * Scaled down version of printf(3).
  28.611 - *
  28.612 - * Two additional formats:
  28.613 - *
  28.614 - * The format %b is supported to decode error registers.
  28.615 - * Its usage is:
  28.616 - *
  28.617 - *	printf("reg=%b\n", regval, "<base><arg>*");
  28.618 - *
  28.619 - * where <base> is the output base expressed as a control character, e.g.
  28.620 - * \10 gives octal; \20 gives hex.  Each arg is a sequence of characters,
  28.621 - * the first of which gives the bit number to be inspected (origin 1), and
  28.622 - * the next characters (up to a control character, i.e. a character <= 32),
  28.623 - * give the name of the register.  Thus:
  28.624 - *
  28.625 - *	kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
  28.626 - *
  28.627 - * would produce output:
  28.628 - *
  28.629 - *	reg=3<BITTWO,BITONE>
  28.630 - *
  28.631 - * XXX:  %D  -- Hexdump, takes pointer and separator string:
  28.632 - *		("%6D", ptr, ":")   -> XX:XX:XX:XX:XX:XX
  28.633 - *		("%*D", len, ptr, " " -> XX XX XX XX ...
  28.634 - */
  28.635 -
  28.636 -/* RN: This normally takes a function for output. 
  28.637 - * we always print to a string and the use HYPERCALL for write to console */
  28.638 -static int
  28.639 -kvprintf(char const *fmt, void *arg, int radix, va_list ap)
  28.640 -{
  28.641 -
  28.642 -#define PCHAR(c) {int cc=(c); *d++ = cc; retval++; }
  28.643 -
  28.644 -	char nbuf[MAXNBUF];
  28.645 -	char *p, *q, *d;
  28.646 -	u_char *up;
  28.647 -	int ch, n;
  28.648 -	u_long ul;
  28.649 -	u_quad_t uq;
  28.650 -	int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
  28.651 -	int dwidth;
  28.652 -	char padc;
  28.653 -	int retval = 0;
  28.654 -
  28.655 -	ul = 0;
  28.656 -	uq = 0;
  28.657 -    d = (char *) arg;
  28.658 -
  28.659 -	if (fmt == NULL)
  28.660 -		fmt = "(fmt null)\n";
  28.661 -
  28.662 -	if (radix < 2 || radix > 36)
  28.663 -		radix = 10;
  28.664  
  28.665 -	for (;;) {
  28.666 -		padc = ' ';
  28.667 -		width = 0;
  28.668 -		while ((ch = (u_char)*fmt++) != '%') {
  28.669 -			if (ch == '\0') 
  28.670 -				return retval;
  28.671 -			PCHAR(ch);
  28.672 +void printf(const char *fmt, ...)
  28.673 +{
  28.674 +    static char   buf[1024];
  28.675 +    va_list       args;
  28.676 +    
  28.677 +    va_start(args, fmt);
  28.678 +    (void)vsnprintf(buf, sizeof(buf), fmt, args);
  28.679 +    va_end(args);        
  28.680 +   
  28.681 +    (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
  28.682 +}
  28.683 +
  28.684 +/**
  28.685 + * vsscanf - Unformat a buffer into a list of arguments
  28.686 + * @buf:	input buffer
  28.687 + * @fmt:	format of buffer
  28.688 + * @args:	arguments
  28.689 + */
  28.690 +int vsscanf(const char * buf, const char * fmt, va_list args)
  28.691 +{
  28.692 +	const char *str = buf;
  28.693 +	char *next;
  28.694 +	char digit;
  28.695 +	int num = 0;
  28.696 +	int qualifier;
  28.697 +	int base;
  28.698 +	int field_width;
  28.699 +	int is_sign = 0;
  28.700 +
  28.701 +	while(*fmt && *str) {
  28.702 +		/* skip any white space in format */
  28.703 +		/* white space in format matchs any amount of
  28.704 +		 * white space, including none, in the input.
  28.705 +		 */
  28.706 +		if (isspace(*fmt)) {
  28.707 +			while (isspace(*fmt))
  28.708 +				++fmt;
  28.709 +			while (isspace(*str))
  28.710 +				++str;
  28.711  		}
  28.712 -		qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
  28.713 -		sign = 0; dot = 0; dwidth = 0;
  28.714 -reswitch:	switch (ch = (u_char)*fmt++) {
  28.715 -		case '.':
  28.716 -			dot = 1;
  28.717 -			goto reswitch;
  28.718 -		case '#':
  28.719 -			sharpflag = 1;
  28.720 -			goto reswitch;
  28.721 -		case '+':
  28.722 -			sign = 1;
  28.723 -			goto reswitch;
  28.724 -		case '-':
  28.725 -			ladjust = 1;
  28.726 -			goto reswitch;
  28.727 -		case '%':
  28.728 -			PCHAR(ch);
  28.729 +
  28.730 +		/* anything that is not a conversion must match exactly */
  28.731 +		if (*fmt != '%' && *fmt) {
  28.732 +			if (*fmt++ != *str++)
  28.733 +				break;
  28.734 +			continue;
  28.735 +		}
  28.736 +
  28.737 +		if (!*fmt)
  28.738  			break;
  28.739 -		case '*':
  28.740 -			if (!dot) {
  28.741 -				width = va_arg(ap, int);
  28.742 -				if (width < 0) {
  28.743 -					ladjust = !ladjust;
  28.744 -					width = -width;
  28.745 +		++fmt;
  28.746 +		
  28.747 +		/* skip this conversion.
  28.748 +		 * advance both strings to next white space
  28.749 +		 */
  28.750 +		if (*fmt == '*') {
  28.751 +			while (!isspace(*fmt) && *fmt)
  28.752 +				fmt++;
  28.753 +			while (!isspace(*str) && *str)
  28.754 +				str++;
  28.755 +			continue;
  28.756 +		}
  28.757 +
  28.758 +		/* get field width */
  28.759 +		field_width = -1;
  28.760 +		if (isdigit(*fmt))
  28.761 +			field_width = skip_atoi(&fmt);
  28.762 +
  28.763 +		/* get conversion qualifier */
  28.764 +		qualifier = -1;
  28.765 +		if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
  28.766 +		    *fmt == 'Z' || *fmt == 'z') {
  28.767 +			qualifier = *fmt++;
  28.768 +			if (unlikely(qualifier == *fmt)) {
  28.769 +				if (qualifier == 'h') {
  28.770 +					qualifier = 'H';
  28.771 +					fmt++;
  28.772 +				} else if (qualifier == 'l') {
  28.773 +					qualifier = 'L';
  28.774 +					fmt++;
  28.775  				}
  28.776 -			} else {
  28.777 -				dwidth = va_arg(ap, int);
  28.778 -			}
  28.779 -			goto reswitch;
  28.780 -		case '0':
  28.781 -			if (!dot) {
  28.782 -				padc = '0';
  28.783 -				goto reswitch;
  28.784  			}
  28.785 -		case '1': case '2': case '3': case '4':
  28.786 -		case '5': case '6': case '7': case '8': case '9':
  28.787 -				for (n = 0;; ++fmt) {
  28.788 -					n = n * 10 + ch - '0';
  28.789 -					ch = *fmt;
  28.790 -					if (ch < '0' || ch > '9')
  28.791 -						break;
  28.792 -				}
  28.793 -			if (dot)
  28.794 -				dwidth = n;
  28.795 -			else
  28.796 -				width = n;
  28.797 -			goto reswitch;
  28.798 -		case 'b':
  28.799 -			ul = va_arg(ap, int);
  28.800 -			p = va_arg(ap, char *);
  28.801 -			for (q = ksprintn(nbuf, ul, *p++, NULL); *q;)
  28.802 -				PCHAR(*q--);
  28.803 +		}
  28.804 +		base = 10;
  28.805 +		is_sign = 0;
  28.806  
  28.807 -			if (!ul)
  28.808 +		if (!*fmt || !*str)
  28.809 +			break;
  28.810 +
  28.811 +		switch(*fmt++) {
  28.812 +		case 'c':
  28.813 +		{
  28.814 +			char *s = (char *) va_arg(args,char*);
  28.815 +			if (field_width == -1)
  28.816 +				field_width = 1;
  28.817 +			do {
  28.818 +				*s++ = *str++;
  28.819 +			} while (--field_width > 0 && *str);
  28.820 +			num++;
  28.821 +		}
  28.822 +		continue;
  28.823 +		case 's':
  28.824 +		{
  28.825 +			char *s = (char *) va_arg(args, char *);
  28.826 +			if(field_width == -1)
  28.827 +				field_width = INT_MAX;
  28.828 +			/* first, skip leading white space in buffer */
  28.829 +			while (isspace(*str))
  28.830 +				str++;
  28.831 +
  28.832 +			/* now copy until next white space */
  28.833 +			while (*str && !isspace(*str) && field_width--) {
  28.834 +				*s++ = *str++;
  28.835 +			}
  28.836 +			*s = '\0';
  28.837 +			num++;
  28.838 +		}
  28.839 +		continue;
  28.840 +		case 'n':
  28.841 +			/* return number of characters read so far */
  28.842 +		{
  28.843 +			int *i = (int *)va_arg(args,int*);
  28.844 +			*i = str - buf;
  28.845 +		}
  28.846 +		continue;
  28.847 +		case 'o':
  28.848 +			base = 8;
  28.849 +			break;
  28.850 +		case 'x':
  28.851 +		case 'X':
  28.852 +			base = 16;
  28.853 +			break;
  28.854 +		case 'i':
  28.855 +                        base = 0;
  28.856 +		case 'd':
  28.857 +			is_sign = 1;
  28.858 +		case 'u':
  28.859 +			break;
  28.860 +		case '%':
  28.861 +			/* looking for '%' in str */
  28.862 +			if (*str++ != '%') 
  28.863 +				return num;
  28.864 +			continue;
  28.865 +		default:
  28.866 +			/* invalid format; stop here */
  28.867 +			return num;
  28.868 +		}
  28.869 +
  28.870 +		/* have some sort of integer conversion.
  28.871 +		 * first, skip white space in buffer.
  28.872 +		 */
  28.873 +		while (isspace(*str))
  28.874 +			str++;
  28.875 +
  28.876 +		digit = *str;
  28.877 +		if (is_sign && digit == '-')
  28.878 +			digit = *(str + 1);
  28.879 +
  28.880 +		if (!digit
  28.881 +                    || (base == 16 && !isxdigit(digit))
  28.882 +                    || (base == 10 && !isdigit(digit))
  28.883 +                    || (base == 8 && (!isdigit(digit) || digit > '7'))
  28.884 +                    || (base == 0 && !isdigit(digit)))
  28.885  				break;
  28.886  
  28.887 -			for (tmp = 0; *p;) {
  28.888 -				n = *p++;
  28.889 -				if (ul & (1 << (n - 1))) {
  28.890 -					PCHAR(tmp ? ',' : '<');
  28.891 -					for (; (n = *p) > ' '; ++p)
  28.892 -						PCHAR(n);
  28.893 -					tmp = 1;
  28.894 -				} else
  28.895 -					for (; *p > ' '; ++p)
  28.896 -						continue;
  28.897 -			}
  28.898 -			if (tmp)
  28.899 -				PCHAR('>');
  28.900 -			break;
  28.901 -		case 'c':
  28.902 -			PCHAR(va_arg(ap, int));
  28.903 -			break;
  28.904 -		case 'D':
  28.905 -			up = va_arg(ap, u_char *);
  28.906 -			p = va_arg(ap, char *);
  28.907 -			if (!width)
  28.908 -				width = 16;
  28.909 -			while(width--) {
  28.910 -				PCHAR(hex2ascii(*up >> 4));
  28.911 -				PCHAR(hex2ascii(*up & 0x0f));
  28.912 -				up++;
  28.913 -				if (width)
  28.914 -					for (q=p;*q;q++)
  28.915 -						PCHAR(*q);
  28.916 +		switch(qualifier) {
  28.917 +		case 'H':	/* that's 'hh' in format */
  28.918 +			if (is_sign) {
  28.919 +				signed char *s = (signed char *) va_arg(args,signed char *);
  28.920 +				*s = (signed char) simple_strtol(str,&next,base);
  28.921 +			} else {
  28.922 +				unsigned char *s = (unsigned char *) va_arg(args, unsigned char *);
  28.923 +				*s = (unsigned char) simple_strtoul(str, &next, base);
  28.924  			}
  28.925  			break;
  28.926 -		case 'd':
  28.927 -			if (qflag)
  28.928 -				uq = va_arg(ap, quad_t);
  28.929 -			else if (lflag)
  28.930 -				ul = va_arg(ap, long);
  28.931 -			else
  28.932 -				ul = va_arg(ap, int);
  28.933 -			sign = 1;
  28.934 -			base = 10;
  28.935 -			goto number;
  28.936 -		case 'l':
  28.937 -			if (lflag) {
  28.938 -				lflag = 0;
  28.939 -				qflag = 1;
  28.940 -			} else
  28.941 -				lflag = 1;
  28.942 -			goto reswitch;
  28.943 -		case 'o':
  28.944 -			if (qflag)
  28.945 -				uq = va_arg(ap, u_quad_t);
  28.946 -			else if (lflag)
  28.947 -				ul = va_arg(ap, u_long);
  28.948 -			else
  28.949 -				ul = va_arg(ap, u_int);
  28.950 -			base = 8;
  28.951 -			goto nosign;
  28.952 -		case 'p':
  28.953 -			ul = (uintptr_t)va_arg(ap, void *);
  28.954 -			base = 16;
  28.955 -			sharpflag = 0;
  28.956 -            padc  = '0';
  28.957 -            width = sizeof(uintptr_t)*2;
  28.958 -			goto nosign;
  28.959 -		case 'q':
  28.960 -			qflag = 1;
  28.961 -			goto reswitch;
  28.962 -		case 'n':
  28.963 -		case 'r':
  28.964 -			if (qflag)
  28.965 -				uq = va_arg(ap, u_quad_t);
  28.966 -			else if (lflag)
  28.967 -				ul = va_arg(ap, u_long);
  28.968 -			else
  28.969 -				ul = sign ?
  28.970 -				    (u_long)va_arg(ap, int) : va_arg(ap, u_int);
  28.971 -			base = radix;
  28.972 -			goto number;
  28.973 -		case 's':
  28.974 -			p = va_arg(ap, char *);
  28.975 -			if (p == NULL)
  28.976 -				p = "(null)";
  28.977 -			if (!dot)
  28.978 -				n = strlen (p);
  28.979 -			else
  28.980 -				for (n = 0; n < dwidth && p[n]; n++)
  28.981 -					continue;
  28.982 -
  28.983 -			width -= n;
  28.984 -
  28.985 -			if (!ladjust && width > 0)
  28.986 -				while (width--)
  28.987 -					PCHAR(padc);
  28.988 -			while (n--)
  28.989 -				PCHAR(*p++);
  28.990 -			if (ladjust && width > 0)
  28.991 -				while (width--)
  28.992 -					PCHAR(padc);
  28.993 +		case 'h':
  28.994 +			if (is_sign) {
  28.995 +				short *s = (short *) va_arg(args,short *);
  28.996 +				*s = (short) simple_strtol(str,&next,base);
  28.997 +			} else {
  28.998 +				unsigned short *s = (unsigned short *) va_arg(args, unsigned short *);
  28.999 +				*s = (unsigned short) simple_strtoul(str, &next, base);
 28.1000 +			}
 28.1001  			break;
 28.1002 -		case 'u':
 28.1003 -			if (qflag)
 28.1004 -				uq = va_arg(ap, u_quad_t);
 28.1005 -			else if (lflag)
 28.1006 -				ul = va_arg(ap, u_long);
 28.1007 -			else
 28.1008 -				ul = va_arg(ap, u_int);
 28.1009 -			base = 10;
 28.1010 -			goto nosign;
 28.1011 -		case 'x':
 28.1012 -		case 'X':
 28.1013 -			if (qflag)
 28.1014 -				uq = va_arg(ap, u_quad_t);
 28.1015 -			else if (lflag)
 28.1016 -				ul = va_arg(ap, u_long);
 28.1017 -			else
 28.1018 -				ul = va_arg(ap, u_int);
 28.1019 -			base = 16;
 28.1020 -			goto nosign;
 28.1021 -		case 'z':
 28.1022 -			if (qflag)
 28.1023 -				uq = va_arg(ap, u_quad_t);
 28.1024 -			else if (lflag)
 28.1025 -				ul = va_arg(ap, u_long);
 28.1026 -			else
 28.1027 -				ul = sign ?
 28.1028 -				    (u_long)va_arg(ap, int) : va_arg(ap, u_int);
 28.1029 -			base = 16;
 28.1030 -			goto number;
 28.1031 -nosign:			sign = 0;
 28.1032 -number:			
 28.1033 -			if (qflag) {
 28.1034 -				if (sign && (quad_t)uq < 0) {
 28.1035 -					neg = 1;
 28.1036 -					uq = -(quad_t)uq;
 28.1037 -				}
 28.1038 -				p = ksprintqn(nbuf, uq, base, &tmp);
 28.1039 +		case 'l':
 28.1040 +			if (is_sign) {
 28.1041 +				long *l = (long *) va_arg(args,long *);
 28.1042 +				*l = simple_strtol(str,&next,base);
 28.1043  			} else {
 28.1044 -				if (sign && (long)ul < 0) {
 28.1045 -					neg = 1;
 28.1046 -					ul = -(long)ul;
 28.1047 -				}
 28.1048 -				p = ksprintn(nbuf, ul, base, &tmp);
 28.1049 -			}
 28.1050 -			if (sharpflag && (qflag ? uq != 0 : ul != 0)) {
 28.1051 -				if (base == 8)
 28.1052 -					tmp++;
 28.1053 -				else if (base == 16)
 28.1054 -					tmp += 2;
 28.1055 +				unsigned long *l = (unsigned long*) va_arg(args,unsigned long*);
 28.1056 +				*l = simple_strtoul(str,&next,base);
 28.1057  			}
 28.1058 -			if (neg)
 28.1059 -				tmp++;
 28.1060 -
 28.1061 -			if (!ladjust && width && (width -= tmp) > 0)
 28.1062 -				while (width--)
 28.1063 -					PCHAR(padc);
 28.1064 -			if (neg)
 28.1065 -				PCHAR('-');
 28.1066 -			if (sharpflag && (qflag ? uq != 0 : ul != 0)) {
 28.1067 -				if (base == 8) {
 28.1068 -					PCHAR('0');
 28.1069 -				} else if (base == 16) {
 28.1070 -					PCHAR('0');
 28.1071 -					PCHAR('x');
 28.1072 -				}
 28.1073 +			break;
 28.1074 +		case 'L':
 28.1075 +			if (is_sign) {
 28.1076 +				long long *l = (long long*) va_arg(args,long long *);
 28.1077 +				*l = simple_strtoll(str,&next,base);
 28.1078 +			} else {
 28.1079 +				unsigned long long *l = (unsigned long long*) va_arg(args,unsigned long long*);
 28.1080 +				*l = simple_strtoull(str,&next,base);
 28.1081  			}
 28.1082 -
 28.1083 -			while (*p)
 28.1084 -				PCHAR(*p--);
 28.1085 -
 28.1086 -			if (ladjust && width && (width -= tmp) > 0)
 28.1087 -				while (width--)
 28.1088 -					PCHAR(padc);
 28.1089 -
 28.1090  			break;
 28.1091 +		case 'Z':
 28.1092 +		case 'z':
 28.1093 +		{
 28.1094 +			size_t *s = (size_t*) va_arg(args,size_t*);
 28.1095 +			*s = (size_t) simple_strtoul(str,&next,base);
 28.1096 +		}
 28.1097 +		break;
 28.1098  		default:
 28.1099 -			PCHAR('%');
 28.1100 -			if (lflag)
 28.1101 -				PCHAR('l');
 28.1102 -			PCHAR(ch);
 28.1103 +			if (is_sign) {
 28.1104 +				int *i = (int *) va_arg(args, int*);
 28.1105 +				*i = (int) simple_strtol(str,&next,base);
 28.1106 +			} else {
 28.1107 +				unsigned int *i = (unsigned int*) va_arg(args, unsigned int*);
 28.1108 +				*i = (unsigned int) simple_strtoul(str,&next,base);
 28.1109 +			}
 28.1110  			break;
 28.1111  		}
 28.1112 +		num++;
 28.1113 +
 28.1114 +		if (!next)
 28.1115 +			break;
 28.1116 +		str = next;
 28.1117  	}
 28.1118 -#undef PCHAR
 28.1119 +	return num;
 28.1120  }
 28.1121  
 28.1122 +/**
 28.1123 + * sscanf - Unformat a buffer into a list of arguments
 28.1124 + * @buf:	input buffer
 28.1125 + * @fmt:	formatting of buffer
 28.1126 + * @...:	resulting arguments
 28.1127 + */
 28.1128 +int sscanf(const char * buf, const char * fmt, ...)
 28.1129 +{
 28.1130 +	va_list args;
 28.1131 +	int i;
 28.1132 +
 28.1133 +	va_start(args,fmt);
 28.1134 +	i = vsscanf(buf,fmt,args);
 28.1135 +	va_end(args);
 28.1136 +	return i;
 28.1137 +}
 28.1138 +
 28.1139 +
    29.1 --- a/extras/mini-os/lib/string.c	Thu Sep 08 09:18:40 2005 -0600
    29.2 +++ b/extras/mini-os/lib/string.c	Fri Sep 09 10:30:54 2005 -0600
    29.3 @@ -107,6 +107,19 @@ size_t strnlen(const char * s, size_t co
    29.4          return sc - s;
    29.5  }
    29.6  
    29.7 +
    29.8 +char * strcat(char * dest, const char * src)
    29.9 +{
   29.10 +    char *tmp = dest;
   29.11 +    
   29.12 +    while (*dest)
   29.13 +        dest++;
   29.14 +    
   29.15 +    while ((*dest++ = *src++) != '\0');
   29.16 +    
   29.17 +    return tmp;
   29.18 +}
   29.19 +
   29.20  size_t strlen(const char * s)
   29.21  {
   29.22  	const char *sc;
    30.1 --- a/extras/mini-os/mm.c	Thu Sep 08 09:18:40 2005 -0600
    30.2 +++ b/extras/mini-os/mm.c	Fri Sep 09 10:30:54 2005 -0600
    30.3 @@ -198,7 +198,6 @@ static void print_chunks(void *start, in
    30.4  #endif
    30.5  
    30.6  
    30.7 -
    30.8  /*
    30.9   * Initialise allocator, placing addresses [@min,@max] in free pool.
   30.10   * @min and @max are PHYSICAL addresses.
   30.11 @@ -486,16 +485,17 @@ void init_mm(void)
   30.12      phys_to_machine_mapping = (unsigned long *)start_info.mfn_list;
   30.13     
   30.14      /* First page follows page table pages and 3 more pages (store page etc) */
   30.15 -    start_pfn = PFN_UP(__pa(start_info.pt_base)) + start_info.nr_pt_frames + 3;
   30.16 +    start_pfn = PFN_UP(to_phys(start_info.pt_base)) + start_info.nr_pt_frames + 3;
   30.17      max_pfn = start_info.nr_pages;
   30.18  
   30.19      printk("  start_pfn:    %lx\n", start_pfn);
   30.20      printk("  max_pfn:      %lx\n", max_pfn);
   30.21  
   30.22  
   30.23 +#ifdef __i386__
   30.24      build_pagetable(&start_pfn, &max_pfn);
   30.25 -    
   30.26 -#ifdef __i386__
   30.27 +#endif
   30.28 +
   30.29      /*
   30.30       * now we can initialise the page allocator
   30.31       */
   30.32 @@ -503,7 +503,5 @@ void init_mm(void)
   30.33             (u_long)to_virt(PFN_PHYS(start_pfn)), PFN_PHYS(start_pfn), 
   30.34             (u_long)to_virt(PFN_PHYS(max_pfn)), PFN_PHYS(max_pfn));
   30.35      init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn));   
   30.36 -#endif
   30.37 -    
   30.38      printk("MM: done\n");
   30.39  }
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/extras/mini-os/sched.c	Fri Sep 09 10:30:54 2005 -0600
    31.3 @@ -0,0 +1,300 @@
    31.4 +/* 
    31.5 + ****************************************************************************
    31.6 + * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
    31.7 + ****************************************************************************
    31.8 + *
    31.9 + *        File: sched.c
   31.10 + *      Author: Grzegorz Milos
   31.11 + *     Changes: 
   31.12 + *              
   31.13 + *        Date: Aug 2005
   31.14 + * 
   31.15 + * Environment: Xen Minimal OS
   31.16 + * Description: simple scheduler for Mini-Os
   31.17 + *
   31.18 + * The scheduler is non-preemptive (cooperative), and schedules according 
   31.19 + * to Round Robin algorithm.
   31.20 + *
   31.21 + ****************************************************************************
   31.22 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   31.23 + * of this software and associated documentation files (the "Software"), to
   31.24 + * deal in the Software without restriction, including without limitation the
   31.25 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   31.26 + * sell copies of the Software, and to permit persons to whom the Software is
   31.27 + * furnished to do so, subject to the following conditions:
   31.28 + * 
   31.29 + * The above copyright notice and this permission notice shall be included in
   31.30 + * all copies or substantial portions of the Software.
   31.31 + * 
   31.32 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   31.33 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   31.34 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
   31.35 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   31.36 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
   31.37 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
   31.38 + * DEALINGS IN THE SOFTWARE.
   31.39 + */
   31.40 +
   31.41 +#include <os.h>
   31.42 +#include <hypervisor.h>
   31.43 +#include <time.h>
   31.44 +#include <mm.h>
   31.45 +#include <types.h>
   31.46 +#include <lib.h>
   31.47 +#include <xmalloc.h>
   31.48 +#include <list.h>
   31.49 +#include <sched.h>
   31.50 +#include <semaphore.h>
   31.51 +
   31.52 +#ifdef SCHED_DEBUG
   31.53 +#define DEBUG(_f, _a...) \
   31.54 +    printk("MINI_OS(file=sched.c, line=%d) " _f "\n", __LINE__, ## _a)
   31.55 +#else
   31.56 +#define DEBUG(_f, _a...)    ((void)0)
   31.57 +#endif
   31.58 +
   31.59 +
   31.60 +#define RUNNABLE_FLAG   0x00000001
   31.61 +
   31.62 +#define is_runnable(_thread)    (_thread->flags & RUNNABLE_FLAG)
   31.63 +#define set_runnable(_thread)   (_thread->flags |= RUNNABLE_FLAG)
   31.64 +#define clear_runnable(_thread) (_thread->flags &= ~RUNNABLE_FLAG)
   31.65 +
   31.66 +
   31.67 +struct thread *idle_thread;
   31.68 +LIST_HEAD(exited_threads);
   31.69 +
   31.70 +void dump_stack(struct thread *thread)
   31.71 +{
   31.72 +    unsigned long *bottom = (unsigned long *)thread->stack + 2048; 
   31.73 +    unsigned long *pointer = (unsigned long *)thread->eps;
   31.74 +    int count;
   31.75 +    printk("The stack for \"%s\"\n", thread->name);
   31.76 +    for(count = 0; count < 15 && pointer < bottom; count ++)
   31.77 +    {
   31.78 +        printk("[0x%lx] 0x%lx\n", pointer, *pointer);
   31.79 +        pointer++;
   31.80 +    }
   31.81 +    
   31.82 +    if(pointer < bottom) printk("Not the whole stack printed\n");
   31.83 +}
   31.84 +
   31.85 +#ifdef __i386__
   31.86 +#define switch_threads(prev, next) do {                                 \
   31.87 +    unsigned long esi,edi;                                              \
   31.88 +    __asm__ __volatile__("pushfl\n\t"                                   \
   31.89 +                         "pushl %%ebp\n\t"                              \
   31.90 +                         "movl %%esp,%0\n\t"         /* save ESP */     \
   31.91 +                         "movl %4,%%esp\n\t"        /* restore ESP */   \
   31.92 +                         "movl $1f,%1\n\t"          /* save EIP */      \
   31.93 +                         "pushl %5\n\t"             /* restore EIP */   \
   31.94 +                         "ret\n\t"                                      \
   31.95 +                         "1:\t"                                         \
   31.96 +                         "popl %%ebp\n\t"                               \
   31.97 +                         "popfl"                                        \
   31.98 +                         :"=m" (prev->eps),"=m" (prev->eip),            \
   31.99 +                          "=S" (esi),"=D" (edi)             \
  31.100 +                         :"m" (next->eps),"m" (next->eip),              \
  31.101 +                          "2" (prev), "d" (next));                      \
  31.102 +} while (0)
  31.103 +#elif __x86_64__
  31.104 +/* FIXME */
  31.105 +#endif
  31.106 +
  31.107 +void inline print_runqueue(void)
  31.108 +{
  31.109 +    struct list_head *it;
  31.110 +    struct thread *th;
  31.111 +    list_for_each(it, &idle_thread->thread_list)
  31.112 +    {
  31.113 +        th = list_entry(it, struct thread, thread_list);
  31.114 +        printk("   Thread \"%s\", runnable=%d\n", th->name, is_runnable(th));
  31.115 +    }
  31.116 +    printk("\n");
  31.117 +}
  31.118 +
  31.119 +
  31.120 +void schedule(void)
  31.121 +{
  31.122 +    struct thread *prev, *next, *thread;
  31.123 +    struct list_head *iterator;
  31.124 +    unsigned long flags;
  31.125 +    prev = current;
  31.126 +    local_irq_save(flags); 
  31.127 +    list_for_each(iterator, &exited_threads)
  31.128 +    {
  31.129 +        thread = list_entry(iterator, struct thread, thread_list);
  31.130 +        if(thread != prev)
  31.131 +        {
  31.132 +            list_del(&thread->thread_list);
  31.133 +            free_pages(thread->stack, 1);
  31.134 +            xfree(thread);
  31.135 +        }
  31.136 +    }
  31.137 +    next = idle_thread;    
  31.138 +    /* Thread list needs to be protected */
  31.139 +    list_for_each(iterator, &idle_thread->thread_list)
  31.140 +    {
  31.141 +        thread = list_entry(iterator, struct thread, thread_list);
  31.142 +        if(is_runnable(thread)) 
  31.143 +        {
  31.144 +            next = thread;
  31.145 +            /* Put this thread on the end of the list */
  31.146 +            list_del(&thread->thread_list);
  31.147 +            list_add_tail(&thread->thread_list, &idle_thread->thread_list);
  31.148 +            break;
  31.149 +        }
  31.150 +    }
  31.151 +    local_irq_restore(flags);
  31.152 +    /* Interrupting the switch is equivalent to having the next thread
  31.153 +       inturrupted at the return instruction. And therefore at safe point. */
  31.154 +/* The thread switching only works for i386 at the moment */    
  31.155 +#ifdef __i386__    
  31.156 +    if(prev != next) switch_threads(prev, next);
  31.157 +#endif    
  31.158 +}
  31.159 +
  31.160 +
  31.161 +
  31.162 +void exit_thread(struct thread *thread)
  31.163 +{
  31.164 +    unsigned long flags;
  31.165 +    printk("Thread \"%s\" exited.\n", thread->name);
  31.166 +    local_irq_save(flags);
  31.167 +    /* Remove from the thread list */
  31.168 +    list_del(&thread->thread_list);
  31.169 +    clear_runnable(thread);
  31.170 +    /* Put onto exited list */
  31.171 +    list_add(&thread->thread_list, &exited_threads);
  31.172 +    local_irq_restore(flags);
  31.173 +    /* Schedule will free the resources */
  31.174 +    schedule();
  31.175 +}
  31.176 +
  31.177 +
  31.178 +struct thread* create_thread(char *name, void (*function)(void *), void *data)
  31.179 +{
  31.180 +    struct thread *thread;
  31.181 +    unsigned long flags;
  31.182 +    
  31.183 +    thread = xmalloc(struct thread);
  31.184 +    /* Allocate 2 pages for stack, stack will be 2pages aligned */
  31.185 +    thread->stack = (char *)alloc_pages(1);
  31.186 +    thread->name = name;
  31.187 +    printk("Thread \"%s\": pointer: 0x%lx, stack: 0x%lx\n", name, thread, 
  31.188 +            thread->stack);
  31.189 +    
  31.190 +    thread->eps = (unsigned long)thread->stack + 4096 * 2 - 4;
  31.191 +    /* Save pointer to the thread on the stack, used by current macro */
  31.192 +    *((unsigned long *)thread->stack) = (unsigned long)thread;
  31.193 +    *((unsigned long *)thread->eps) = (unsigned long)thread;
  31.194 +    thread->eps -= 4; 
  31.195 +    *((unsigned long *)thread->eps) = (unsigned long)data;
  31.196 +    
  31.197 +    /* No return address */
  31.198 +    thread->eps -= 4;
  31.199 +    *((unsigned long *)thread->eps) = (unsigned long)exit_thread;
  31.200 +    
  31.201 +    thread->eip = (unsigned long)function;
  31.202 +     
  31.203 +    /* Not runable, not exited */ 
  31.204 +    thread->flags = 0;
  31.205 +    set_runnable(thread);
  31.206 +    
  31.207 +    local_irq_save(flags);
  31.208 +    if(idle_thread != NULL)
  31.209 +        list_add_tail(&thread->thread_list, &idle_thread->thread_list); 
  31.210 +    local_irq_restore(flags);
  31.211 +
  31.212 +    return thread;
  31.213 +}
  31.214 +
  31.215 +
  31.216 +void block(struct thread *thread)
  31.217 +{
  31.218 +    clear_runnable(thread);
  31.219 +}
  31.220 +
  31.221 +void wake(struct thread *thread)
  31.222 +{
  31.223 +    set_runnable(thread);
  31.224 +}
  31.225 +
  31.226 +void idle_thread_fn(void *unused)
  31.227 +{
  31.228 +    for(;;)
  31.229 +    {
  31.230 +        schedule();
  31.231 +        printk("Blocking the domain\n"); 
  31.232 +        block_domain(10000);
  31.233 +    }
  31.234 +}
  31.235 +
  31.236 +void run_idle_thread(void)
  31.237 +{
  31.238 +    /* Switch stacks and run the thread */ 
  31.239 +    __asm__ __volatile__("mov %0,%%esp\n\t"
  31.240 +                         "push %1\n\t" 
  31.241 +                         "ret"                                            
  31.242 +                         :"=m" (idle_thread->eps)
  31.243 +                         :"m" (idle_thread->eip));                          
  31.244 +}
  31.245 +
  31.246 +
  31.247 +
  31.248 +DECLARE_MUTEX(mutex);
  31.249 +
  31.250 +void th_f1(void *data)
  31.251 +{
  31.252 +    struct timeval tv1, tv2;
  31.253 +
  31.254 +    for(;;)
  31.255 +    {
  31.256 +        down(&mutex);
  31.257 +        printk("Thread \"%s\" got semaphore, runnable %d\n", current->name, is_runnable(current));
  31.258 +        schedule();
  31.259 +        printk("Thread \"%s\" releases the semaphore\n", current->name);
  31.260 +        up(&mutex);
  31.261 +        
  31.262 +        
  31.263 +        gettimeofday(&tv1);
  31.264 +        for(;;)
  31.265 +        {
  31.266 +            gettimeofday(&tv2);
  31.267 +            if(tv2.tv_sec - tv1.tv_sec > 2) break;
  31.268 +        }
  31.269 +                
  31.270 +        
  31.271 +        schedule(); 
  31.272 +    }
  31.273 +}
  31.274 +
  31.275 +void th_f2(void *data)
  31.276 +{
  31.277 +    for(;;)
  31.278 +    {
  31.279 +        printk("Thread OTHER executing, data 0x%lx\n", data);
  31.280 +        schedule();
  31.281 +    }
  31.282 +}
  31.283 +
  31.284 +
  31.285 +
  31.286 +void init_sched(void)
  31.287 +{
  31.288 +    printk("Initialising scheduler\n");
  31.289 +       
  31.290 +    idle_thread = create_thread("Idle", idle_thread_fn, NULL);
  31.291 +    INIT_LIST_HEAD(&idle_thread->thread_list);
  31.292 +
  31.293 +    
  31.294 +/*    create_thread("1", th_f1, (void *)0x1234);    
  31.295 +    create_thread("2", th_f1, (void *)0x1234);    
  31.296 +    create_thread("3", th_f1, (void *)0x1234);    
  31.297 +    create_thread("4", th_f1, (void *)0x1234);    
  31.298 +    create_thread("5", th_f1, (void *)0x1234);    
  31.299 +    create_thread("6", th_f1, (void *)0x1234);    
  31.300 +    create_thread("second", th_f2, NULL);
  31.301 +*/   
  31.302 +}
  31.303 +
    32.1 --- a/extras/mini-os/time.c	Thu Sep 08 09:18:40 2005 -0600
    32.2 +++ b/extras/mini-os/time.c	Fri Sep 09 10:30:54 2005 -0600
    32.3 @@ -203,7 +203,7 @@ static void print_current_time(void)
    32.4  }
    32.5  
    32.6  
    32.7 -void block(u32 millisecs)
    32.8 +void block_domain(u32 millisecs)
    32.9  {
   32.10      struct timeval tv;
   32.11      gettimeofday(&tv);
   32.12 @@ -232,5 +232,6 @@ static void timer_handler(int ev, struct
   32.13  
   32.14  void init_time(void)
   32.15  {
   32.16 +    printk("Initialising timer interface\n");
   32.17      bind_virq(VIRQ_TIMER, &timer_handler);
   32.18  }
    33.1 --- a/extras/mini-os/traps.c	Thu Sep 08 09:18:40 2005 -0600
    33.2 +++ b/extras/mini-os/traps.c	Fri Sep 09 10:30:54 2005 -0600
    33.3 @@ -33,36 +33,7 @@ extern void do_exit(void);
    33.4  
    33.5  void dump_regs(struct pt_regs *regs)
    33.6  {
    33.7 -    unsigned long esp;
    33.8 -    unsigned short ss;
    33.9 -
   33.10 -#ifdef __x86_64__
   33.11 -    esp = regs->rsp;
   33.12 -    ss  = regs->xss;
   33.13 -#else
   33.14 -    esp = (unsigned long) (&regs->esp);
   33.15 -    ss = __KERNEL_DS;
   33.16 -    if (regs->xcs & 2) {
   33.17 -printk("CS is true, esp is %x\n", regs->esp);
   33.18 -        esp = regs->esp;
   33.19 -        ss = regs->xss & 0xffff;
   33.20 -    }
   33.21 -#endif
   33.22 -    printf("EIP:    %04x:[<%p>]\n",
   33.23 -           0xffff & regs->xcs , regs->eip);
   33.24 -    printf("EFLAGS: %p\n",regs->eflags);
   33.25 -    printf("eax: %08lx   ebx: %08lx   ecx: %08lx   edx: %08lx\n",
   33.26 -           regs->eax, regs->ebx, regs->ecx, regs->edx);
   33.27 -    printf("esi: %08lx   edi: %08lx   ebp: %08lx   esp: %08lx\n",
   33.28 -           regs->esi, regs->edi, regs->ebp, esp);
   33.29 -#ifdef __x86_64__
   33.30 -    printf("r8 : %p   r9 : %p   r10: %p   r11: %p\n",
   33.31 -           regs->r8,  regs->r9,  regs->r10, regs->r11);
   33.32 -    printf("r12: %p   r13: %p   r14: %p   r15: %p\n",
   33.33 -           regs->r12, regs->r13, regs->r14, regs->r15);
   33.34 -#endif
   33.35 -    printf("ds: %04x   es: %04x   ss: %04x\n",
   33.36 -           regs->xds & 0xffff, regs->xes & 0xffff, ss);
   33.37 +    printk("FIXME: proper register dump (with the stack dump)\n");
   33.38  }	
   33.39  
   33.40  
   33.41 @@ -105,6 +76,7 @@ void do_page_fault(struct pt_regs *regs,
   33.42      printk("Page fault at linear address %p\n", addr);
   33.43      dump_regs(regs);
   33.44  #ifdef __x86_64__
   33.45 +    /* FIXME: _PAGE_PSE */
   33.46      {
   33.47          unsigned long *tab = (unsigned long *)start_info.pt_base;
   33.48          unsigned long page;
   33.49 @@ -112,23 +84,16 @@ void do_page_fault(struct pt_regs *regs,
   33.50          printk("Pagetable walk from %p:\n", tab);
   33.51          
   33.52          page = tab[l4_table_offset(addr)];
   33.53 -        tab = __va(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   33.54 +        tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   33.55          printk(" L4 = %p (%p)\n", page, tab);
   33.56 -        if ( !(page & AGERESENT) )
   33.57 -            goto out;
   33.58  
   33.59          page = tab[l3_table_offset(addr)];
   33.60 -        tab = __va(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   33.61 +        tab = to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   33.62          printk("  L3 = %p (%p)\n", page, tab);
   33.63 -        if ( !(page & AGERESENT) )
   33.64 -            goto out;
   33.65          
   33.66          page = tab[l2_table_offset(addr)];
   33.67 -        tab = __va(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   33.68 -        printk("   L2 = %p (%p) %s\n", page, tab,
   33.69 -               (page & AGESE) ? "(2MB)" : "");
   33.70 -        if ( !(page & AGERESENT) || (page & AGESE) )
   33.71 -            goto out;
   33.72 +        tab =  to_virt(mfn_to_pfn(pte_to_mfn(page)) << PAGE_SHIFT);
   33.73 +        printk("   L2 = %p (%p)\n", page, tab);
   33.74          
   33.75          page = tab[l1_table_offset(addr)];
   33.76          printk("    L1 = %p\n", page);
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/extras/mini-os/xenbus/Makefile	Fri Sep 09 10:30:54 2005 -0600
    34.3 @@ -0,0 +1,9 @@
    34.4 +all: xenstore.h xenbus_comms.o xenbus_xs.o xenbus_probe.o
    34.5 +
    34.6 +xenstore.h:
    34.7 +	[ -e xenstored.h ] || ln -sf ../../../tools/xenstore/xenstored.h xenstored.h
    34.8 +
    34.9 +clean:
   34.10 +	#Taken care of by main Makefile
   34.11 +	#rm xenstored.h
   34.12 +	#rm *.o
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/extras/mini-os/xenbus/xenbus_comms.c	Fri Sep 09 10:30:54 2005 -0600
    35.3 @@ -0,0 +1,231 @@
    35.4 +/******************************************************************************
    35.5 + * xenbus_comms.c
    35.6 + *
    35.7 + * Low level code to talks to Xen Store: ringbuffer and event channel.
    35.8 + *
    35.9 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
   35.10 + * 
   35.11 + * This file may be distributed separately from the Linux kernel, or
   35.12 + * incorporated into other software packages, subject to the following license:
   35.13 + * 
   35.14 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   35.15 + * of this source file (the "Software"), to deal in the Software without
   35.16 + * restriction, including without limitation the rights to use, copy, modify,
   35.17 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   35.18 + * and to permit persons to whom the Software is furnished to do so, subject to
   35.19 + * the following conditions:
   35.20 + * 
   35.21 + * The above copyright notice and this permission notice shall be included in
   35.22 + * all copies or substantial portions of the Software.
   35.23 + * 
   35.24 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   35.25 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   35.26 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   35.27 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   35.28 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   35.29 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   35.30 + * IN THE SOFTWARE.
   35.31 + */
   35.32 +#include <types.h>
   35.33 +#include <wait.h>
   35.34 +#include <mm.h>
   35.35 +#include <hypervisor.h>
   35.36 +#include <events.h>
   35.37 +#include <os.h>
   35.38 +#include <lib.h>
   35.39 +
   35.40 +
   35.41 +#ifdef XENBUS_COMMS_DEBUG
   35.42 +#define DEBUG(_f, _a...) \
   35.43 +    printk("MINI_OS(file=xenbus_comms.c, line=%d) " _f "\n", __LINE__, ## _a)
   35.44 +#else
   35.45 +#define DEBUG(_f, _a...)    ((void)0)
   35.46 +#endif
   35.47 +
   35.48 +
   35.49 +#define RINGBUF_DATASIZE ((PAGE_SIZE / 2) - sizeof(struct ringbuf_head))
   35.50 +struct ringbuf_head
   35.51 +{
   35.52 +	u32 write; /* Next place to write to */
   35.53 +	u32 read; /* Next place to read from */
   35.54 +	u8 flags;
   35.55 +	char buf[0];
   35.56 +} __attribute__((packed));
   35.57 +
   35.58 +DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
   35.59 +
   35.60 +static inline struct ringbuf_head *outbuf(void)
   35.61 +{
   35.62 +	return mfn_to_virt(start_info.store_mfn);
   35.63 +}
   35.64 +
   35.65 +static inline struct ringbuf_head *inbuf(void)
   35.66 +{
   35.67 +	return (struct ringbuf_head *)((char *)mfn_to_virt(start_info.store_mfn) + PAGE_SIZE/2);
   35.68 +}
   35.69 +
   35.70 +static void wake_waiting(int port, struct pt_regs *regs)
   35.71 +{
   35.72 +	wake_up(&xb_waitq);
   35.73 +}
   35.74 +
   35.75 +static int check_buffer(const struct ringbuf_head *h)
   35.76 +{
   35.77 +	return (h->write < RINGBUF_DATASIZE && h->read < RINGBUF_DATASIZE);
   35.78 +}
   35.79 +
   35.80 +/* We can't fill last byte: would look like empty buffer. */
   35.81 +static void *get_output_chunk(const struct ringbuf_head *h,
   35.82 +			      void *buf, u32 *len)
   35.83 +{
   35.84 +	u32 read_mark;
   35.85 +
   35.86 +	if (h->read == 0)
   35.87 +		read_mark = RINGBUF_DATASIZE - 1;
   35.88 +	else
   35.89 +		read_mark = h->read - 1;
   35.90 +
   35.91 +	/* Here to the end of buffer, unless they haven't read some out. */
   35.92 +	*len = RINGBUF_DATASIZE - h->write;
   35.93 +	if (read_mark >= h->write)
   35.94 +		*len = read_mark - h->write;
   35.95 +	return (void *)((char *)buf + h->write);
   35.96 +}
   35.97 +
   35.98 +static const void *get_input_chunk(const struct ringbuf_head *h,
   35.99 +				   const void *buf, u32 *len)
  35.100 +{
  35.101 +	/* Here to the end of buffer, unless they haven't written some. */
  35.102 +	*len = RINGBUF_DATASIZE - h->read;
  35.103 +	if (h->write >= h->read)
  35.104 +		*len = h->write - h->read;
  35.105 +	return (void *)((char *)buf + h->read);
  35.106 +}
  35.107 +
  35.108 +static void update_output_chunk(struct ringbuf_head *h, u32 len)
  35.109 +{
  35.110 +	h->write += len;
  35.111 +	if (h->write == RINGBUF_DATASIZE)
  35.112 +		h->write = 0;
  35.113 +}
  35.114 +
  35.115 +static void update_input_chunk(struct ringbuf_head *h, u32 len)
  35.116 +{
  35.117 +	h->read += len;
  35.118 +	if (h->read == RINGBUF_DATASIZE)
  35.119 +		h->read = 0;
  35.120 +}
  35.121 +
  35.122 +static int output_avail(struct ringbuf_head *out)
  35.123 +{
  35.124 +	unsigned int avail;
  35.125 +
  35.126 +	get_output_chunk(out, out->buf, &avail);
  35.127 +	return avail != 0;
  35.128 +}
  35.129 +
  35.130 +int xb_write(const void *data, unsigned len)
  35.131 +{
  35.132 +	struct ringbuf_head h;
  35.133 +	struct ringbuf_head *out = outbuf();
  35.134 +
  35.135 +	do {
  35.136 +		void *dst;
  35.137 +		unsigned int avail;
  35.138 +
  35.139 +		wait_event(xb_waitq, output_avail(out));
  35.140 +
  35.141 +		/* Read, then check: not that we don't trust store.
  35.142 +		 * Hell, some of my best friends are daemons.  But,
  35.143 +		 * in this post-911 world... */
  35.144 +		h = *out;
  35.145 +		mb();
  35.146 +		if (!check_buffer(&h)) {
  35.147 +			return -1; /* ETERRORIST! */
  35.148 +		}
  35.149 +
  35.150 +		dst = get_output_chunk(&h, out->buf, &avail);
  35.151 +		if (avail > len)
  35.152 +			avail = len;
  35.153 +		memcpy(dst, data, avail);
  35.154 +		data = (void *)((char *)data + avail);
  35.155 +		len -= avail;
  35.156 +		update_output_chunk(out, avail);
  35.157 +		notify_via_evtchn(start_info.store_evtchn);
  35.158 +	} while (len != 0);
  35.159 +
  35.160 +	return 0;
  35.161 +}
  35.162 +
  35.163 +int xs_input_avail(void)
  35.164 +{
  35.165 +	unsigned int avail;
  35.166 +	struct ringbuf_head *in = inbuf();
  35.167 +
  35.168 +	get_input_chunk(in, in->buf, &avail);
  35.169 +	return avail != 0;
  35.170 +}
  35.171 +
  35.172 +int xb_read(void *data, unsigned len)
  35.173 +{
  35.174 +	struct ringbuf_head h;
  35.175 +	struct ringbuf_head *in = inbuf();
  35.176 +	int was_full;
  35.177 +
  35.178 +	while (len != 0) {
  35.179 +		unsigned int avail;
  35.180 +		const char *src;
  35.181 +
  35.182 +		wait_event(xb_waitq, xs_input_avail());
  35.183 +		h = *in;
  35.184 +		mb();
  35.185 +		if (!check_buffer(&h)) {
  35.186 +			return -1;
  35.187 +		}
  35.188 +
  35.189 +		src = get_input_chunk(&h, in->buf, &avail);
  35.190 +		if (avail > len)
  35.191 +			avail = len;
  35.192 +		was_full = !output_avail(&h);
  35.193 +
  35.194 +		memcpy(data, src, avail);
  35.195 +		data = (void *)((char *)data + avail);
  35.196 +		len -= avail;
  35.197 +		update_input_chunk(in, avail);
  35.198 +		DEBUG("Finished read of %i bytes (%i to go)\n", avail, len);
  35.199 +		/* If it was full, tell them we've taken some. */
  35.200 +		if (was_full)
  35.201 +			notify_via_evtchn(start_info.store_evtchn);
  35.202 +	}
  35.203 +
  35.204 +	/* If we left something, wake watch thread to deal with it. */
  35.205 +	if (xs_input_avail())
  35.206 +		wake_up(&xb_waitq);
  35.207 +
  35.208 +	return 0;
  35.209 +}
  35.210 +
  35.211 +/* Set up interrupt handler off store event channel. */
  35.212 +int xb_init_comms(void)
  35.213 +{
  35.214 +    printk("Init xenbus comms, store event channel %d\n", start_info.store_evtchn);
  35.215 +	if (!start_info.store_evtchn)
  35.216 +		return 0;
  35.217 +    printk("Binding virq\n");
  35.218 +	bind_evtchn(start_info.store_evtchn, &wake_waiting);
  35.219 +
  35.220 +	/* FIXME zero out page -- domain builder should probably do this*/
  35.221 +	memset(mfn_to_virt(start_info.store_mfn), 0, PAGE_SIZE);
  35.222 +    notify_via_evtchn(start_info.store_evtchn);
  35.223 +	return 0;
  35.224 +}
  35.225 +
  35.226 +void xb_suspend_comms(void)
  35.227 +{
  35.228 +
  35.229 +	if (!start_info.store_evtchn)
  35.230 +		return;
  35.231 +
  35.232 +    // TODO
  35.233 +	//unbind_evtchn_from_irqhandler(xen_start_info.store_evtchn, &xb_waitq);
  35.234 +}
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/extras/mini-os/xenbus/xenbus_comms.h	Fri Sep 09 10:30:54 2005 -0600
    36.3 @@ -0,0 +1,40 @@
    36.4 +/*
    36.5 + * Private include for xenbus communications.
    36.6 + * 
    36.7 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
    36.8 + *
    36.9 + * This file may be distributed separately from the Linux kernel, or
   36.10 + * incorporated into other software packages, subject to the following license:
   36.11 + * 
   36.12 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   36.13 + * of this source file (the "Software"), to deal in the Software without
   36.14 + * restriction, including without limitation the rights to use, copy, modify,
   36.15 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   36.16 + * and to permit persons to whom the Software is furnished to do so, subject to
   36.17 + * the following conditions:
   36.18 + * 
   36.19 + * The above copyright notice and this permission notice shall be included in
   36.20 + * all copies or substantial portions of the Software.
   36.21 + * 
   36.22 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   36.23 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   36.24 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   36.25 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   36.26 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   36.27 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   36.28 + * IN THE SOFTWARE.
   36.29 + */
   36.30 +
   36.31 +#ifndef _XENBUS_COMMS_H
   36.32 +#define _XENBUS_COMMS_H
   36.33 +
   36.34 +int xb_init_comms(void);
   36.35 +void xb_suspend_comms(void);
   36.36 +
   36.37 +/* Low level routines. */
   36.38 +int xb_write(const void *data, unsigned len);
   36.39 +int xb_read(void *data, unsigned len);
   36.40 +int xs_input_avail(void);
   36.41 +extern struct wait_queue_head xb_waitq;
   36.42 +
   36.43 +#endif /* _XENBUS_COMMS_H */
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/extras/mini-os/xenbus/xenbus_xs.c	Fri Sep 09 10:30:54 2005 -0600
    37.3 @@ -0,0 +1,554 @@
    37.4 +/******************************************************************************
    37.5 + * xenbus_xs.c
    37.6 + *
    37.7 + * This is the kernel equivalent of the "xs" library.  We don't need everything
    37.8 + * and we use xenbus_comms for communication.
    37.9 + *
   37.10 + * Copyright (C) 2005 Rusty Russell, IBM Corporation
   37.11 + * 
   37.12 + * This file may be distributed separately from the Linux kernel, or
   37.13 + * incorporated into other software packages, subject to the following license:
   37.14 + * 
   37.15 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   37.16 + * of this source file (the "Software"), to deal in the Software without
   37.17 + * restriction, including without limitation the rights to use, copy, modify,
   37.18 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   37.19 + * and to permit persons to whom the Software is furnished to do so, subject to
   37.20 + * the following conditions:
   37.21 + * 
   37.22 + * The above copyright notice and this permission notice shall be included in
   37.23 + * all copies or substantial portions of the Software.
   37.24 + * 
   37.25 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   37.26 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   37.27 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   37.28 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   37.29 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   37.30 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   37.31 + * IN THE SOFTWARE.
   37.32 + */
   37.33 +#include <errno.h>
   37.34 +#include <types.h>
   37.35 +#include <list.h>
   37.36 +#include <lib.h>
   37.37 +#include <err.h>
   37.38 +#include <os.h>
   37.39 +#include <xmalloc.h>
   37.40 +#include <fcntl.h>
   37.41 +#include <xenbus.h>
   37.42 +#include <wait.h>
   37.43 +#include <sched.h>
   37.44 +#include <semaphore.h>
   37.45 +#include "xenstored.h"
   37.46 +#include "xenbus_comms.h"
   37.47 +
   37.48 +#define streq(a, b) (strcmp((a), (b)) == 0)
   37.49 +
   37.50 +static char printf_buffer[4096];
   37.51 +static LIST_HEAD(watches);
   37.52 +//TODO
   37.53 +DECLARE_MUTEX(xenbus_lock);
   37.54 +
   37.55 +static int get_error(const char *errorstring)
   37.56 +{
   37.57 +	unsigned int i;
   37.58 +
   37.59 +	for (i = 0; !streq(errorstring, xsd_errors[i].errstring); i++) {
   37.60 +		if (i == ARRAY_SIZE(xsd_errors) - 1) {
   37.61 +			printk("XENBUS xen store gave: unknown error %s",
   37.62 +			       errorstring);
   37.63 +			return EINVAL;
   37.64 +		}
   37.65 +	}
   37.66 +	return xsd_errors[i].errnum;
   37.67 +}
   37.68 +
   37.69 +static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len)
   37.70 +{
   37.71 +	struct xsd_sockmsg msg;
   37.72 +	void *ret;
   37.73 +	int err;
   37.74 +
   37.75 +	err = xb_read(&msg, sizeof(msg));
   37.76 +	if (err)
   37.77 +		return ERR_PTR(err);
   37.78 +
   37.79 +	ret = xmalloc_array(char, msg.len + 1);
   37.80 +	if (!ret)
   37.81 +		return ERR_PTR(-ENOMEM);
   37.82 +
   37.83 +	err = xb_read(ret, msg.len);
   37.84 +	if (err) {
   37.85 +		xfree(ret);
   37.86 +		return ERR_PTR(err);
   37.87 +	}
   37.88 +	((char*)ret)[msg.len] = '\0';
   37.89 +
   37.90 +	*type = msg.type;
   37.91 +	if (len)
   37.92 +		*len = msg.len;
   37.93 +	return ret;
   37.94 +}
   37.95 +
   37.96 +/* Emergency write. */
   37.97 +void xenbus_debug_write(const char *str, unsigned int count)
   37.98 +{
   37.99 +	struct xsd_sockmsg msg;
  37.100 +
  37.101 +	msg.type = XS_DEBUG;
  37.102 +	msg.len = sizeof("print") + count + 1;
  37.103 +
  37.104 +	xb_write(&msg, sizeof(msg));
  37.105 +	xb_write("print", sizeof("print"));
  37.106 +	xb_write(str, count);
  37.107 +	xb_write("", 1);
  37.108 +}
  37.109 +
  37.110 +/* Send message to xs, get kmalloc'ed reply.  ERR_PTR() on error. */
  37.111 +static void *xs_talkv(enum xsd_sockmsg_type type,
  37.112 +		      const struct kvec *iovec,
  37.113 +		      unsigned int num_vecs,
  37.114 +		      unsigned int *len)
  37.115 +{
  37.116 +	struct xsd_sockmsg msg;
  37.117 +	void *ret = NULL;
  37.118 +	unsigned int i;
  37.119 +	int err;
  37.120 +
  37.121 +	//WARN_ON(down_trylock(&xenbus_lock) == 0);
  37.122 +
  37.123 +	msg.type = type;
  37.124 +	msg.len = 0;
  37.125 +	for (i = 0; i < num_vecs; i++)
  37.126 +		msg.len += iovec[i].iov_len;
  37.127 +
  37.128 +	err = xb_write(&msg, sizeof(msg));
  37.129 +	if (err)
  37.130 +		return ERR_PTR(err);
  37.131 +
  37.132 +	for (i = 0; i < num_vecs; i++) {
  37.133 +		err = xb_write(iovec[i].iov_base, iovec[i].iov_len);;
  37.134 +		if (err)
  37.135 +			return ERR_PTR(err);
  37.136 +	}
  37.137 +
  37.138 +	/* Watches can have fired before reply comes: daemon detects
  37.139 +	 * and re-transmits, so we can ignore this. */
  37.140 +	do {
  37.141 +		xfree(ret);
  37.142 +		ret = read_reply(&msg.type, len);
  37.143 +		if (IS_ERR(ret))
  37.144 +			return ret;
  37.145 +	} while (msg.type == XS_WATCH_EVENT);
  37.146 +
  37.147 +	if (msg.type == XS_ERROR) {
  37.148 +		err = get_error(ret);
  37.149 +		xfree(ret);
  37.150 +		return ERR_PTR(-err);
  37.151 +	}
  37.152 +
  37.153 +	//BUG_ON(msg.type != type);
  37.154 +	return ret;
  37.155 +}
  37.156 +
  37.157 +/* Simplified version of xs_talkv: single message. */
  37.158 +static void *xs_single(enum xsd_sockmsg_type type,
  37.159 +		       const char *string, unsigned int *len)
  37.160 +{
  37.161 +	struct kvec iovec;
  37.162 +
  37.163 +	iovec.iov_base = (void *)string;
  37.164 +	iovec.iov_len = strlen(string) + 1;
  37.165 +	return xs_talkv(type, &iovec, 1, len);
  37.166 +}
  37.167 +
  37.168 +/* Many commands only need an ack, don't care what it says. */
  37.169 +static int xs_error(char *reply)
  37.170 +{
  37.171 +	if (IS_ERR(reply))
  37.172 +		return PTR_ERR(reply);
  37.173 +	xfree(reply);
  37.174 +	return 0;
  37.175 +}
  37.176 +
  37.177 +static unsigned int count_strings(const char *strings, unsigned int len)
  37.178 +{
  37.179 +	unsigned int num;
  37.180 +	const char *p;
  37.181 +
  37.182 +	for (p = strings, num = 0; p < strings + len; p += strlen(p) + 1)
  37.183 +		num++;
  37.184 +
  37.185 +	return num;
  37.186 +}
  37.187 +
  37.188 +/* Return the path to dir with /name appended. */ 
  37.189 +static char *join(const char *dir, const char *name)
  37.190 +{
  37.191 +	static char buffer[4096];
  37.192 +
  37.193 +	//BUG_ON(down_trylock(&xenbus_lock) == 0);
  37.194 +	/* XXX FIXME: might not be correct if name == "" */
  37.195 +	//BUG_ON(strlen(dir) + strlen("/") + strlen(name) + 1 > sizeof(buffer));
  37.196 +
  37.197 +	strcpy(buffer, dir);
  37.198 +	if (!streq(name, "")) {
  37.199 +		strcat(buffer, "/");
  37.200 +		strcat(buffer, name);
  37.201 +	}
  37.202 +	return buffer;
  37.203 +}
  37.204 +
  37.205 +char **xenbus_directory(const char *dir, const char *node, unsigned int *num)
  37.206 +{
  37.207 +	char *strings, *p, **ret;
  37.208 +	unsigned int len;
  37.209 +
  37.210 +	strings = xs_single(XS_DIRECTORY, join(dir, node), &len);
  37.211 +	if (IS_ERR(strings))
  37.212 +		return (char **)strings;
  37.213 +
  37.214 +	/* Count the strings. */
  37.215 +	*num = count_strings(strings, len);
  37.216 +
  37.217 +	/* Transfer to one big alloc for easy freeing. */
  37.218 +	ret = (char **)xmalloc_array(char, *num * sizeof(char *) + len);
  37.219 +	if (!ret) {
  37.220 +		xfree(strings);
  37.221 +		return ERR_PTR(-ENOMEM);
  37.222 +	}
  37.223 +	memcpy(&ret[*num], strings, len);
  37.224 +	xfree(strings);
  37.225 +
  37.226 +	strings = (char *)&ret[*num];
  37.227 +	for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1)
  37.228 +		ret[(*num)++] = p;
  37.229 +	return ret;
  37.230 +}
  37.231 +
  37.232 +/* Check if a path exists. Return 1 if it does. */
  37.233 +int xenbus_exists(const char *dir, const char *node)
  37.234 +{
  37.235 +	char **d;
  37.236 +	int dir_n;
  37.237 +
  37.238 +	d = xenbus_directory(dir, node, &dir_n);
  37.239 +	if (IS_ERR(d))
  37.240 +		return 0;
  37.241 +	xfree(d);
  37.242 +	return 1;
  37.243 +}
  37.244 +
  37.245 +/* Get the value of a single file.
  37.246 + * Returns a kmalloced value: call free() on it after use.
  37.247 + * len indicates length in bytes.
  37.248 + */
  37.249 +void *xenbus_read(const char *dir, const char *node, unsigned int *len)
  37.250 +{
  37.251 +	return xs_single(XS_READ, join(dir, node), len);
  37.252 +}
  37.253 +
  37.254 +/* Write the value of a single file.
  37.255 + * Returns -err on failure.  createflags can be 0, O_CREAT, or O_CREAT|O_EXCL.
  37.256 + */
  37.257 +int xenbus_write(const char *dir, const char *node,
  37.258 +		 const char *string, int createflags)
  37.259 +{
  37.260 +	const char *flags, *path;
  37.261 +	struct kvec iovec[3];
  37.262 +
  37.263 +	path = join(dir, node);
  37.264 +	/* Format: Flags (as string), path, data. */
  37.265 +	if (createflags == 0)
  37.266 +		flags = XS_WRITE_NONE;
  37.267 +	else if (createflags == O_CREAT)
  37.268 +		flags = XS_WRITE_CREATE;
  37.269 +	else if (createflags == (O_CREAT|O_EXCL))
  37.270 +		flags = XS_WRITE_CREATE_EXCL;
  37.271 +	else
  37.272 +		return -EINVAL;
  37.273 +
  37.274 +	iovec[0].iov_base = (void *)path;
  37.275 +	iovec[0].iov_len = strlen(path) + 1;
  37.276 +	iovec[1].iov_base = (void *)flags;
  37.277 +	iovec[1].iov_len = strlen(flags) + 1;
  37.278 +	iovec[2].iov_base = (void *)string;
  37.279 +	iovec[2].iov_len = strlen(string);
  37.280 +
  37.281 +	return xs_error(xs_talkv(XS_WRITE, iovec, ARRAY_SIZE(iovec), NULL));
  37.282 +}
  37.283 +
  37.284 +/* Create a new directory. */
  37.285 +int xenbus_mkdir(const char *dir, const char *node)
  37.286 +{
  37.287 +	return xs_error(xs_single(XS_MKDIR, join(dir, node), NULL));
  37.288 +}
  37.289 +
  37.290 +/* Destroy a file or directory (directories must be empty). */
  37.291 +int xenbus_rm(const char *dir, const char *node)
  37.292 +{
  37.293 +	return xs_error(xs_single(XS_RM, join(dir, node), NULL));
  37.294 +}
  37.295 +
  37.296 +/* Start a transaction: changes by others will not be seen during this
  37.297 + * transaction, and changes will not be visible to others until end.
  37.298 + * Transaction only applies to the given subtree.
  37.299 + * You can only have one transaction at any time.
  37.300 + */
  37.301 +int xenbus_transaction_start(const char *subtree)
  37.302 +{
  37.303 +	return xs_error(xs_single(XS_TRANSACTION_START, subtree, NULL));
  37.304 +}
  37.305 +
  37.306 +/* End a transaction.
  37.307 + * If abandon is true, transaction is discarded instead of committed.
  37.308 + */
  37.309 +int xenbus_transaction_end(int abort)
  37.310 +{
  37.311 +	char abortstr[2];
  37.312 +
  37.313 +	if (abort)
  37.314 +		strcpy(abortstr, "F");
  37.315 +	else
  37.316 +		strcpy(abortstr, "T");
  37.317 +	return xs_error(xs_single(XS_TRANSACTION_END, abortstr, NULL));
  37.318 +}
  37.319 +
  37.320 +/* Single read and scanf: returns -errno or num scanned. */
  37.321 +int xenbus_scanf(const char *dir, const char *node, const char *fmt, ...)
  37.322 +{
  37.323 +	va_list ap;
  37.324 +	int ret;
  37.325 +	char *val;
  37.326 +
  37.327 +	val = xenbus_read(dir, node, NULL);
  37.328 +	if (IS_ERR(val))
  37.329 +		return PTR_ERR(val);
  37.330 +
  37.331 +	va_start(ap, fmt);
  37.332 +	ret = vsscanf(val, fmt, ap);
  37.333 +	va_end(ap);
  37.334 +	xfree(val);
  37.335 +	/* Distinctive errno. */
  37.336 +	if (ret == 0)
  37.337 +		return -ERANGE;
  37.338 +	return ret;
  37.339 +}
  37.340 +
  37.341 +/* Single printf and write: returns -errno or 0. */
  37.342 +int xenbus_printf(const char *dir, const char *node, const char *fmt, ...)
  37.343 +{
  37.344 +	va_list ap;
  37.345 +	int ret;
  37.346 +
  37.347 +	//BUG_ON(down_trylock(&xenbus_lock) == 0);
  37.348 +	va_start(ap, fmt);
  37.349 +	ret = vsnprintf(printf_buffer, sizeof(printf_buffer), fmt, ap);
  37.350 +	va_end(ap);
  37.351 +
  37.352 +	//BUG_ON(ret > sizeof(printf_buffer)-1);
  37.353 +	return xenbus_write(dir, node, printf_buffer, O_CREAT);
  37.354 +}
  37.355 +
  37.356 +	
  37.357 +/* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
  37.358 +int xenbus_gather(const char *dir, ...)
  37.359 +{
  37.360 +	va_list ap;
  37.361 +	const char *name;
  37.362 +	int ret = 0;
  37.363 +
  37.364 +	va_start(ap, dir);
  37.365 +	while (ret == 0 && (name = va_arg(ap, char *)) != NULL) {
  37.366 +		const char *fmt = va_arg(ap, char *);
  37.367 +		void *result = va_arg(ap, void *);
  37.368 +		char *p;
  37.369 +
  37.370 +		p = xenbus_read(dir, name, NULL);
  37.371 +		if (IS_ERR(p)) {
  37.372 +			ret = PTR_ERR(p);
  37.373 +			break;
  37.374 +		}
  37.375 +		if (fmt) {
  37.376 +			if (sscanf(p, fmt, result) == 0)
  37.377 +				ret = -EINVAL;
  37.378 +			xfree(p);
  37.379 +		} else
  37.380 +			*(char **)result = p;
  37.381 +	}
  37.382 +	va_end(ap);
  37.383 +	return ret;
  37.384 +}
  37.385 +
  37.386 +static int xs_watch(const char *path, const char *token)
  37.387 +{
  37.388 +	struct kvec iov[2];
  37.389 +
  37.390 +	iov[0].iov_base = (void *)path;
  37.391 +	iov[0].iov_len = strlen(path) + 1;
  37.392 +	iov[1].iov_base = (void *)token;
  37.393 +	iov[1].iov_len = strlen(token) + 1;
  37.394 +
  37.395 +	return xs_error(xs_talkv(XS_WATCH, iov, ARRAY_SIZE(iov), NULL));
  37.396 +}
  37.397 +
  37.398 +static char *xs_read_watch(char **token)
  37.399 +{
  37.400 +	enum xsd_sockmsg_type type;
  37.401 +	char *ret;
  37.402 +
  37.403 +	ret = read_reply(&type, NULL);
  37.404 +	if (IS_ERR(ret))
  37.405 +		return ret;
  37.406 +
  37.407 +	//BUG_ON(type != XS_WATCH_EVENT);
  37.408 +	*token = ret + strlen(ret) + 1;
  37.409 +	return ret;
  37.410 +}
  37.411 +
  37.412 +static int xs_acknowledge_watch(const char *token)
  37.413 +{
  37.414 +	return xs_error(xs_single(XS_WATCH_ACK, token, NULL));
  37.415 +}
  37.416 +
  37.417 +static int xs_unwatch(const char *path, const char *token)
  37.418 +{
  37.419 +	struct kvec iov[2];
  37.420 +
  37.421 +	iov[0].iov_base = (char *)path;
  37.422 +	iov[0].iov_len = strlen(path) + 1;
  37.423 +	iov[1].iov_base = (char *)token;
  37.424 +	iov[1].iov_len = strlen(token) + 1;
  37.425 +
  37.426 +	return xs_error(xs_talkv(XS_UNWATCH, iov, ARRAY_SIZE(iov), NULL));
  37.427 +}
  37.428 +
  37.429 +/* A little paranoia: we don't just trust token. */
  37.430 +static struct xenbus_watch *find_watch(const char *token)
  37.431 +{
  37.432 +	struct xenbus_watch *i, *cmp;
  37.433 +
  37.434 +	cmp = (void *)simple_strtoul(token, NULL, 16);
  37.435 +
  37.436 +	list_for_each_entry(i, &watches, list)
  37.437 +		if (i == cmp)
  37.438 +			return i;
  37.439 +	return NULL;
  37.440 +}
  37.441 +
  37.442 +/* Register callback to watch this node. */
  37.443 +int register_xenbus_watch(struct xenbus_watch *watch)
  37.444 +{
  37.445 +	/* Pointer in ascii is the token. */
  37.446 +	char token[sizeof(watch) * 2 + 1];
  37.447 +	int err;
  37.448 +
  37.449 +	sprintf(token, "%lX", (long)watch);
  37.450 +	//BUG_ON(find_watch(token));
  37.451 +printk("Registered watch for: %s\n", token);
  37.452 +	err = xs_watch(watch->node, token);
  37.453 +	if (!err)
  37.454 +		list_add(&watch->list, &watches);
  37.455 +	return err;
  37.456 +}
  37.457 +
  37.458 +void unregister_xenbus_watch(struct xenbus_watch *watch)
  37.459 +{
  37.460 +	char token[sizeof(watch) * 2 + 1];
  37.461 +	int err;
  37.462 +
  37.463 +	sprintf(token, "%lX", (long)watch);
  37.464 +	//BUG_ON(!find_watch(token));
  37.465 +
  37.466 +	err = xs_unwatch(watch->node, token);
  37.467 +	list_del(&watch->list);
  37.468 +
  37.469 +	if (err)
  37.470 +		printk("XENBUS Failed to release watch %s: %i\n",
  37.471 +		       watch->node, err);
  37.472 +}
  37.473 +
  37.474 +/* Re-register callbacks to all watches. */
  37.475 +void reregister_xenbus_watches(void)
  37.476 +{
  37.477 +	struct xenbus_watch *watch;
  37.478 +	char token[sizeof(watch) * 2 + 1];
  37.479 +
  37.480 +	list_for_each_entry(watch, &watches, list) {
  37.481 +		sprintf(token, "%lX", (long)watch);
  37.482 +		xs_watch(watch->node, token);
  37.483 +	}
  37.484 +}
  37.485 +
  37.486 +void watch_thread(void *unused)
  37.487 +{
  37.488 +	for (;;) {
  37.489 +		char *token;
  37.490 +		char *node = NULL;
  37.491 +
  37.492 +		wait_event(xb_waitq, xs_input_avail());
  37.493 +
  37.494 +		/* If this is a spurious wakeup caused by someone
  37.495 +		 * doing an op, they'll hold the lock and the buffer
  37.496 +		 * will be empty by the time we get there.		 
  37.497 +		 */
  37.498 +		down(&xenbus_lock);
  37.499 +		if (xs_input_avail())
  37.500 +			node = xs_read_watch(&token);
  37.501 +
  37.502 +		if (node && !IS_ERR(node)) {
  37.503 +			struct xenbus_watch *w;
  37.504 +			int err;
  37.505 +
  37.506 +			err = xs_acknowledge_watch(token);
  37.507 +			if (err)
  37.508 +				printk("XENBUS ack %s fail %i\n", node, err);
  37.509 +			w = find_watch(token);
  37.510 +			//BUG_ON(!w);
  37.511 +			w->callback(w, node);
  37.512 +			xfree(node);
  37.513 +		} else
  37.514 +			printk("XENBUS xs_read_watch: %li\n", PTR_ERR(node));
  37.515 +		up(&xenbus_lock);
  37.516 +	}
  37.517 +}
  37.518 +
  37.519 +
  37.520 +static void ballon_changed(struct xenbus_watch *watch, const char *node)
  37.521 +{
  37.522 +    unsigned long new_target;
  37.523 +    int err;
  37.524 +    err = xenbus_scanf("memory", "target", "%lu", &new_target);
  37.525 +
  37.526 +    if(err != 1)
  37.527 +    {
  37.528 +        printk("Unable to read memory/target\n");
  37.529 +        return;
  37.530 +    }
  37.531 +
  37.532 +    printk("Memory target changed to: %ld bytes, ignoring.\n", new_target);
  37.533 +}
  37.534 +
  37.535 +
  37.536 +static struct xenbus_watch ballon_watch = {
  37.537 +    .node = "memory/target",
  37.538 +    .callback = ballon_changed,
  37.539 +};
  37.540 +
  37.541 +
  37.542 +
  37.543 +int xs_init(void)
  37.544 +{
  37.545 +	int err;
  37.546 +	struct thread *watcher;
  37.547 +    printk("xb_init_comms\n");
  37.548 +	err = xb_init_comms();
  37.549 +	if (err)
  37.550 +		return err;
  37.551 +	
  37.552 +	watcher = create_thread("kxwatch", watch_thread, NULL);
  37.553 +    down(&xenbus_lock);
  37.554 +    register_xenbus_watch(&ballon_watch);
  37.555 +    up(&xenbus_lock);
  37.556 +	return 0;
  37.557 +}
    38.1 --- a/linux-2.4-xen-sparse/mkbuildtree	Thu Sep 08 09:18:40 2005 -0600
    38.2 +++ b/linux-2.4-xen-sparse/mkbuildtree	Fri Sep 09 10:30:54 2005 -0600
    38.3 @@ -102,9 +102,9 @@ for i in `find . -type l`; do rm -f $i; 
    38.4  relative_lndir ${RS}
    38.5  rm -f mkbuildtree
    38.6  
    38.7 -set ${RS}/../linux-2.6-xen-sparse
    38.8 -[ "$1" == "${RS}/../linux-2.6-xen-sparse" ] && { echo "no Linux 2.6 sparse tree at ${RS}/../linux-2.6-xen-sparse"; exit 1; }
    38.9 -LINUX_26="$1"
   38.10 +LINUX_26=${RS}/../linux-2.6-xen-sparse
   38.11 +[ -d $LINUX_26 ] || { echo "no Linux 2.6 sparse tree at ${RS}/../linux-2.6-xen-sparse"; exit 1; }
   38.12 +
   38.13  
   38.14  # Create links to the shared definitions of the Xen interfaces.
   38.15  rm -rf ${AD}/include/asm-xen/xen-public
    39.1 --- a/linux-2.6-xen-sparse/arch/xen/Kconfig	Thu Sep 08 09:18:40 2005 -0600
    39.2 +++ b/linux-2.6-xen-sparse/arch/xen/Kconfig	Fri Sep 09 10:30:54 2005 -0600
    39.3 @@ -70,6 +70,27 @@ config XEN_NETDEV_BACKEND
    39.4  	  network devices to other guests via a high-performance shared-memory
    39.5  	  interface.
    39.6  
    39.7 +config XEN_TPMDEV_FRONTEND
    39.8 +        bool "TPM-device frontend driver"
    39.9 +        default n
   39.10 +        help
   39.11 +          The TPM-device frontend driver.
   39.12 +
   39.13 +config XEN_TPMDEV_BACKEND
   39.14 +        bool "TPM-device backend driver"
   39.15 +        default n
   39.16 +        help
   39.17 +          The TPM-device backend driver
   39.18 +
   39.19 +config XEN_TPMDEV_CLOSE_IF_VTPM_FAILS
   39.20 +        bool "TPM backend closes upon vTPM failure"
   39.21 +        depends on XEN_TPMDEV_BACKEND
   39.22 +        default n
   39.23 +        help
   39.24 +          The TPM backend closes the channel if the vTPM in userspace indicates
   39.25 +          a failure. The corresponding domain's channel will be closed.
   39.26 +          Say Y if you want this feature.
   39.27 +
   39.28  config XEN_BLKDEV_FRONTEND
   39.29  	bool "Block-device frontend driver"
   39.30  	default y
   39.31 @@ -88,15 +109,8 @@ config XEN_NETDEV_FRONTEND
   39.32  	  dedicated device-driver domain, or your master control domain
   39.33  	  (domain 0), then you almost certainly want to say Y here.
   39.34  
   39.35 -config XEN_NETDEV_GRANT_TX
   39.36 -        bool "Grant table substrate for net drivers tx path (DANGEROUS)"
   39.37 -        default n
   39.38 -        help
   39.39 -          This introduces the use of grant tables as a data exhange mechanism
   39.40 -          between the frontend and backend network drivers.
   39.41 -
   39.42 -config XEN_NETDEV_GRANT_RX
   39.43 -        bool "Grant table substrate for net drivers rx path (DANGEROUS)"
   39.44 +config XEN_NETDEV_GRANT
   39.45 +        bool "Grant table substrate for network drivers (DANGEROUS)"
   39.46          default n
   39.47          help
   39.48            This introduces the use of grant tables as a data exhange mechanism
    40.1 --- a/linux-2.6-xen-sparse/arch/xen/Kconfig.drivers	Thu Sep 08 09:18:40 2005 -0600
    40.2 +++ b/linux-2.6-xen-sparse/arch/xen/Kconfig.drivers	Fri Sep 09 10:30:54 2005 -0600
    40.3 @@ -49,6 +49,10 @@ source "drivers/infiniband/Kconfig"
    40.4  endif
    40.5  
    40.6  if !XEN_PHYSDEV_ACCESS
    40.7 +source "drivers/char/tpm/Kconfig.domU"
    40.8 +endif
    40.9 +
   40.10 +if !XEN_PHYSDEV_ACCESS
   40.11  
   40.12  menu "Character devices"
   40.13  
    41.1 --- a/linux-2.6-xen-sparse/arch/xen/Makefile	Thu Sep 08 09:18:40 2005 -0600
    41.2 +++ b/linux-2.6-xen-sparse/arch/xen/Makefile	Fri Sep 09 10:30:54 2005 -0600
    41.3 @@ -65,6 +65,7 @@ vmlinuz: vmlinux
    41.4  
    41.5  XINSTALL_NAME ?= $(KERNELRELEASE)
    41.6  install: vmlinuz
    41.7 +install kernel_install:
    41.8  	mkdir -p $(INSTALL_PATH)/boot
    41.9  	ln -f -s vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX) $(INSTALL_PATH)/boot/vmlinuz-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(XENGUEST)$(INSTALL_SUFFIX)
   41.10  	rm -f $(INSTALL_PATH)/boot/vmlinuz-$(XINSTALL_NAME)$(INSTALL_SUFFIX)
    42.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Thu Sep 08 09:18:40 2005 -0600
    42.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Fri Sep 09 10:30:54 2005 -0600
    42.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
    42.4  CONFIG_XEN_BLKDEV_BACKEND=y
    42.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
    42.6  CONFIG_XEN_NETDEV_BACKEND=y
    42.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
    42.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
    42.9  CONFIG_XEN_BLKDEV_FRONTEND=y
   42.10  CONFIG_XEN_NETDEV_FRONTEND=y
   42.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
   42.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
   42.13 +CONFIG_XEN_NETDEV_GRANT=y
   42.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
   42.15  # CONFIG_XEN_BLKDEV_TAP is not set
   42.16  # CONFIG_XEN_SHADOW_MODE is not set
   42.17 @@ -1122,7 +1123,7 @@ CONFIG_RAMFS=y
   42.18  # CONFIG_BEFS_FS is not set
   42.19  # CONFIG_BFS_FS is not set
   42.20  # CONFIG_EFS_FS is not set
   42.21 -# CONFIG_CRAMFS is not set
   42.22 +CONFIG_CRAMFS=y
   42.23  # CONFIG_VXFS_FS is not set
   42.24  # CONFIG_HPFS_FS is not set
   42.25  # CONFIG_QNX4FS_FS is not set
    43.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Thu Sep 08 09:18:40 2005 -0600
    43.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Fri Sep 09 10:30:54 2005 -0600
    43.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
    43.4  CONFIG_XEN_BLKDEV_BACKEND=y
    43.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
    43.6  CONFIG_XEN_NETDEV_BACKEND=y
    43.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
    43.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
    43.9  CONFIG_XEN_BLKDEV_FRONTEND=y
   43.10  CONFIG_XEN_NETDEV_FRONTEND=y
   43.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
   43.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
   43.13 +CONFIG_XEN_NETDEV_GRANT=y
   43.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
   43.15  # CONFIG_XEN_BLKDEV_TAP is not set
   43.16  # CONFIG_XEN_SHADOW_MODE is not set
   43.17 @@ -195,6 +196,7 @@ CONFIG_BLK_DEV_LOOP=y
   43.18  # CONFIG_BLK_DEV_CRYPTOLOOP is not set
   43.19  # CONFIG_BLK_DEV_NBD is not set
   43.20  # CONFIG_BLK_DEV_SX8 is not set
   43.21 +# CONFIG_BLK_DEV_UB is not set
   43.22  CONFIG_BLK_DEV_RAM=y
   43.23  CONFIG_BLK_DEV_RAM_COUNT=16
   43.24  CONFIG_BLK_DEV_RAM_SIZE=16384
   43.25 @@ -1030,7 +1032,7 @@ CONFIG_RAMFS=y
   43.26  # CONFIG_BEFS_FS is not set
   43.27  # CONFIG_BFS_FS is not set
   43.28  # CONFIG_EFS_FS is not set
   43.29 -# CONFIG_CRAMFS is not set
   43.30 +CONFIG_CRAMFS=y
   43.31  # CONFIG_VXFS_FS is not set
   43.32  # CONFIG_HPFS_FS is not set
   43.33  # CONFIG_QNX4FS_FS is not set
    44.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Thu Sep 08 09:18:40 2005 -0600
    44.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Fri Sep 09 10:30:54 2005 -0600
    44.3 @@ -12,10 +12,11 @@ CONFIG_NO_IDLE_HZ=y
    44.4  #
    44.5  # CONFIG_XEN_PRIVILEGED_GUEST is not set
    44.6  # CONFIG_XEN_PHYSDEV_ACCESS is not set
    44.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
    44.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
    44.9  CONFIG_XEN_BLKDEV_FRONTEND=y
   44.10  CONFIG_XEN_NETDEV_FRONTEND=y
   44.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
   44.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
   44.13 +CONFIG_XEN_NETDEV_GRANT=y
   44.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
   44.15  # CONFIG_XEN_BLKDEV_TAP is not set
   44.16  # CONFIG_XEN_SHADOW_MODE is not set
   44.17 @@ -336,6 +337,7 @@ CONFIG_NETDEVICES=y
   44.18  CONFIG_UNIX98_PTYS=y
   44.19  CONFIG_LEGACY_PTYS=y
   44.20  CONFIG_LEGACY_PTY_COUNT=256
   44.21 +# CONFIG_TCG_TPM is not set
   44.22  
   44.23  #
   44.24  # Character devices
    45.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Thu Sep 08 09:18:40 2005 -0600
    45.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Fri Sep 09 10:30:54 2005 -0600
    45.3 @@ -12,10 +12,11 @@ CONFIG_NO_IDLE_HZ=y
    45.4  #
    45.5  # CONFIG_XEN_PRIVILEGED_GUEST is not set
    45.6  # CONFIG_XEN_PHYSDEV_ACCESS is not set
    45.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
    45.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
    45.9  CONFIG_XEN_BLKDEV_FRONTEND=y
   45.10  CONFIG_XEN_NETDEV_FRONTEND=y
   45.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
   45.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
   45.13 +CONFIG_XEN_NETDEV_GRANT=y
   45.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
   45.15  # CONFIG_XEN_BLKDEV_TAP is not set
   45.16  # CONFIG_XEN_SHADOW_MODE is not set
   45.17 @@ -662,6 +663,7 @@ CONFIG_NETCONSOLE=m
   45.18  CONFIG_INPUT=m
   45.19  CONFIG_UNIX98_PTYS=y
   45.20  # CONFIG_LEGACY_PTYS is not set
   45.21 +# CONFIG_TCG_TPM is not set
   45.22  
   45.23  #
   45.24  # Character devices
    46.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Thu Sep 08 09:18:40 2005 -0600
    46.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Fri Sep 09 10:30:54 2005 -0600
    46.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
    46.4  CONFIG_XEN_BLKDEV_BACKEND=y
    46.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
    46.6  CONFIG_XEN_NETDEV_BACKEND=y
    46.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
    46.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
    46.9  CONFIG_XEN_BLKDEV_FRONTEND=y
   46.10  CONFIG_XEN_NETDEV_FRONTEND=y
   46.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
   46.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
   46.13 +CONFIG_XEN_NETDEV_GRANT=y
   46.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
   46.15  # CONFIG_XEN_BLKDEV_TAP is not set
   46.16  # CONFIG_XEN_SHADOW_MODE is not set
   46.17 @@ -1855,9 +1856,7 @@ CONFIG_HANGCHECK_TIMER=m
   46.18  #
   46.19  # TPM devices
   46.20  #
   46.21 -CONFIG_TCG_TPM=m
   46.22 -CONFIG_TCG_NSC=m
   46.23 -CONFIG_TCG_ATMEL=m
   46.24 +# CONFIG_TCG_TPM is not set
   46.25  
   46.26  #
   46.27  # I2C support
    47.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64	Thu Sep 08 09:18:40 2005 -0600
    47.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64	Fri Sep 09 10:30:54 2005 -0600
    47.3 @@ -15,10 +15,11 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
    47.4  CONFIG_XEN_BLKDEV_BACKEND=y
    47.5  # CONFIG_XEN_BLKDEV_TAP_BE is not set
    47.6  CONFIG_XEN_NETDEV_BACKEND=y
    47.7 +# CONFIG_XEN_TPMDEV_FRONTEND is not set
    47.8 +# CONFIG_XEN_TPMDEV_BACKEND is not set
    47.9  CONFIG_XEN_BLKDEV_FRONTEND=y
   47.10  CONFIG_XEN_NETDEV_FRONTEND=y
   47.11 -CONFIG_XEN_NETDEV_GRANT_TX=y
   47.12 -CONFIG_XEN_NETDEV_GRANT_RX=y
   47.13 +CONFIG_XEN_NETDEV_GRANT=y
   47.14  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
   47.15  # CONFIG_XEN_BLKDEV_TAP is not set
   47.16  # CONFIG_XEN_SHADOW_MODE is not set
   47.17 @@ -2201,7 +2202,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
   47.18  CONFIG_PROC_FS=y
   47.19  CONFIG_PROC_KCORE=y
   47.20  CONFIG_SYSFS=y
   47.21 -# CONFIG_DEVFS_FS is not set
   47.22 +CONFIG_DEVFS_FS=y
   47.23  CONFIG_DEVPTS_FS_XATTR=y
   47.24  CONFIG_DEVPTS_FS_SECURITY=y
   47.25  CONFIG_TMPFS=y
   47.26 @@ -2231,7 +2232,7 @@ CONFIG_JFFS2_FS_NAND=y
   47.27  CONFIG_JFFS2_ZLIB=y
   47.28  CONFIG_JFFS2_RTIME=y
   47.29  # CONFIG_JFFS2_RUBIN is not set
   47.30 -CONFIG_CRAMFS=m
   47.31 +CONFIG_CRAMFS=y
   47.32  CONFIG_VXFS_FS=m
   47.33  # CONFIG_HPFS_FS is not set
   47.34  CONFIG_QNX4FS_FS=m
    48.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/Kconfig	Thu Sep 08 09:18:40 2005 -0600
    48.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/Kconfig	Fri Sep 09 10:30:54 2005 -0600
    48.3 @@ -379,18 +379,18 @@ config SMP
    48.4  	  If you don't know what to do here, say N.
    48.5  
    48.6  config SMP_ALTERNATIVES
    48.7 -        bool "SMP alternatives support (EXPERIMENTAL)"
    48.8 -        depends on SMP && EXPERIMENTAL
    48.9 -        help
   48.10 -          Try to reduce the overhead of running an SMP kernel on a uniprocessor
   48.11 -          host slightly by replacing certain key instruction sequences
   48.12 -          according to whether we currently have more than one CPU available.
   48.13 -          This should provide a noticeable boost to performance when
   48.14 -          running SMP kernels on UP machines, and have negligible impact
   48.15 -          when running on an true SMP host.
   48.16 +	bool "SMP alternatives support (EXPERIMENTAL)"
   48.17 +	depends on SMP && EXPERIMENTAL
   48.18 +	help
   48.19 +	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   48.20 +	  host slightly by replacing certain key instruction sequences
   48.21 +	  according to whether we currently have more than one CPU available.
   48.22 +	  This should provide a noticeable boost to performance when
   48.23 +	  running SMP kernels on UP machines, and have negligible impact
   48.24 +	  when running on an true SMP host.
   48.25  
   48.26            If unsure, say N.
   48.27 -
   48.28 +	  
   48.29  config NR_CPUS
   48.30  	int "Maximum number of CPUs (2-255)"
   48.31  	range 2 255
   48.32 @@ -807,8 +807,8 @@ choice
   48.33  	  direct access method and falls back to the BIOS if that doesn't
   48.34  	  work. If unsure, go with the default, which is "Any".
   48.35  
   48.36 -config PCI_GOBIOS
   48.37 -	bool "BIOS"
   48.38 +#config PCI_GOBIOS
   48.39 +#	bool "BIOS"
   48.40  
   48.41  config PCI_GOMMCONFIG
   48.42  	bool "MMConfig"
   48.43 @@ -821,10 +821,10 @@ config PCI_GOANY
   48.44  
   48.45  endchoice
   48.46  
   48.47 -config PCI_BIOS
   48.48 -	bool
   48.49 -	depends on !X86_VISWS && PCI && (PCI_GOBIOS || PCI_GOANY)
   48.50 -	default y
   48.51 +#config PCI_BIOS
   48.52 +#	bool
   48.53 +#	depends on !X86_VISWS && PCI && (PCI_GOBIOS || PCI_GOANY)
   48.54 +#	default y
   48.55  
   48.56  config PCI_DIRECT
   48.57  	bool
    49.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile	Thu Sep 08 09:18:40 2005 -0600
    49.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile	Fri Sep 09 10:30:54 2005 -0600
    49.3 @@ -5,6 +5,7 @@
    49.4  XENARCH	:= $(subst ",,$(CONFIG_XENARCH))
    49.5  
    49.6  CFLAGS	+= -Iarch/$(XENARCH)/kernel
    49.7 +AFLAGS	+= -Iarch/$(XENARCH)/kernel
    49.8  
    49.9  extra-y := head.o init_task.o
   49.10  
   49.11 @@ -32,7 +33,7 @@ obj-$(CONFIG_X86_MPPARSE)	+= mpparse.o
   49.12  obj-$(CONFIG_X86_LOCAL_APIC)	+= apic.o
   49.13  c-obj-$(CONFIG_X86_LOCAL_APIC)	+= nmi.o
   49.14  obj-$(CONFIG_X86_IO_APIC)	+= io_apic.o
   49.15 -c-obj-$(CONFIG_X86_REBOOTFIXUPS)+= reboot_fixups.o
   49.16 +c-obj-$(CONFIG_X86_REBOOTFIXUPS)	+= reboot_fixups.o
   49.17  c-obj-$(CONFIG_X86_NUMAQ)	+= numaq.o
   49.18  c-obj-$(CONFIG_X86_SUMMIT_NUMA)	+= summit.o
   49.19  c-obj-$(CONFIG_MODULES)		+= module.o
   49.20 @@ -69,7 +70,7 @@ SYSCFLAGS_vsyscall-int80.so	= $(vsyscall
   49.21  
   49.22  $(obj)/vsyscall-int80.so $(obj)/vsyscall-sysenter.so: \
   49.23  $(obj)/vsyscall-%.so: $(src)/vsyscall.lds \
   49.24 -		      $(obj)/vsyscall-%.o FORCE
   49.25 +		      $(obj)/vsyscall-%.o $(obj)/vsyscall-note.o FORCE
   49.26  	$(call if_changed,syscall)
   49.27  
   49.28  # We also create a special relocatable object that should mirror the symbol
   49.29 @@ -81,20 +82,17 @@ extra-y += vsyscall-syms.o
   49.30  
   49.31  SYSCFLAGS_vsyscall-syms.o = -r
   49.32  $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
   49.33 -			$(obj)/vsyscall-sysenter.o FORCE
   49.34 +			$(obj)/vsyscall-sysenter.o $(obj)/vsyscall-note.o FORCE
   49.35  	$(call if_changed,syscall)
   49.36  
   49.37  c-link	:=
   49.38 -s-link	:= vsyscall-int80.o vsyscall-sysenter.o vsyscall-sigreturn.o vsyscall.lds.o syscall_table.o
   49.39 +s-link	:= vsyscall-int80.o vsyscall-sysenter.o vsyscall-sigreturn.o vsyscall.lds.o vsyscall-note.o
   49.40  
   49.41  $(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-obj-m) $(c-link)) $(patsubst %.o,$(obj)/%.S,$(s-obj-y) $(s-link)):
   49.42  	@ln -fsn $(srctree)/arch/i386/kernel/$(notdir $@) $@
   49.43  
   49.44  $(obj)/vsyscall-int80.S: $(obj)/vsyscall-sigreturn.S
   49.45  
   49.46 -EXTRA_AFLAGS	+= -I$(obj)
   49.47 -$(obj)/entry.o: $(src)/entry.S $(src)/syscall_table.S
   49.48 -
   49.49  obj-y	+= $(c-obj-y) $(s-obj-y)
   49.50  obj-m	+= $(c-obj-m)
   49.51  
    50.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c	Thu Sep 08 09:18:40 2005 -0600
    50.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/acpi/boot.c	Fri Sep 09 10:30:54 2005 -0600
    50.3 @@ -469,6 +469,18 @@ unsigned int acpi_register_gsi(u32 gsi, 
    50.4  	unsigned int irq;
    50.5  	unsigned int plat_gsi = gsi;
    50.6  
    50.7 +#ifdef CONFIG_PCI
    50.8 +	/*
    50.9 +	 * Make sure all (legacy) PCI IRQs are set as level-triggered.
   50.10 +	 */
   50.11 +	if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
   50.12 +		extern void eisa_set_level_irq(unsigned int irq);
   50.13 +
   50.14 +		if (edge_level == ACPI_LEVEL_SENSITIVE)
   50.15 +				eisa_set_level_irq(gsi);
   50.16 +	}
   50.17 +#endif
   50.18 +
   50.19  #ifdef CONFIG_X86_IO_APIC
   50.20  	if (acpi_irq_model == ACPI_IRQ_MODEL_IOAPIC) {
   50.21  		plat_gsi = mp_register_gsi(gsi, edge_level, active_high_low);
   50.22 @@ -610,7 +622,7 @@ static int __init acpi_parse_fadt(unsign
   50.23  	acpi_fadt.force_apic_physical_destination_mode = fadt->force_apic_physical_destination_mode;
   50.24  #endif
   50.25  
   50.26 -#ifdef CONFIG_X86_PM_TIMER
   50.27 +#if defined(CONFIG_X86_PM_TIMER) && !defined(CONFIG_XEN)
   50.28  	/* detect the location of the ACPI PM Timer */
   50.29  	if (fadt->revision >= FADT2_REVISION_ID) {
   50.30  		/* FADT rev. 2 */
    51.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c	Thu Sep 08 09:18:40 2005 -0600
    51.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/mtrr/main.c	Fri Sep 09 10:30:54 2005 -0600
    51.3 @@ -147,7 +147,7 @@ static int __init mtrr_init(void)
    51.4  {
    51.5  	struct cpuinfo_x86 *c = &boot_cpu_data;
    51.6  
    51.7 -	if (!(xen_start_info.flags & SIF_PRIVILEGED))
    51.8 +	if (!(xen_start_info->flags & SIF_PRIVILEGED))
    51.9  		return -ENODEV;
   51.10  
   51.11  	if ((!cpu_has(c, X86_FEATURE_MTRR)) &&
    52.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Thu Sep 08 09:18:40 2005 -0600
    52.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Fri Sep 09 10:30:54 2005 -0600
    52.3 @@ -47,6 +47,7 @@
    52.4  #include <asm/segment.h>
    52.5  #include <asm/smp.h>
    52.6  #include <asm/page.h>
    52.7 +#include <asm/desc.h>
    52.8  #include "irq_vectors.h"
    52.9  #include <asm-xen/xen-public/xen.h>
   52.10  
   52.11 @@ -112,7 +113,7 @@ VM_MASK		= 0x00020000
   52.12  				XEN_BLOCK_EVENTS(%esi)
   52.13  #else
   52.14  #define preempt_stop
   52.15 -#define resume_kernel		restore_all
   52.16 +#define resume_kernel		restore_nocheck
   52.17  #endif
   52.18  
   52.19  #define SAVE_ALL \
   52.20 @@ -161,11 +162,9 @@ 4:	movl $0,(%esp);	\
   52.21  	addl $4, %esp;	\
   52.22  1:	iret;		\
   52.23  .section .fixup,"ax";   \
   52.24 -2:	movl $(__USER_DS), %edx; \
   52.25 -	movl %edx, %ds; \
   52.26 -	movl %edx, %es; \
   52.27 -	movl $11,%eax;	\
   52.28 -	call do_exit;	\
   52.29 +2:	pushl $0;	\
   52.30 +	pushl $do_iret_error;	\
   52.31 +	jmp error_code;	\
   52.32  .previous;		\
   52.33  .section __ex_table,"a";\
   52.34  	.align 4;	\
   52.35 @@ -196,7 +195,7 @@ ret_from_intr:
   52.36  	movl EFLAGS(%esp), %eax		# mix EFLAGS and CS
   52.37  	movb CS(%esp), %al
   52.38  	testl $(VM_MASK | 2), %eax
   52.39 -	jz resume_kernel		# returning to kernel or vm86-space
   52.40 +	jz resume_kernel
   52.41  ENTRY(resume_userspace)
   52.42  	XEN_BLOCK_EVENTS(%esi)		# make sure we don't miss an interrupt
   52.43  					# setting need_resched or sigpending
   52.44 @@ -211,7 +210,7 @@ ENTRY(resume_userspace)
   52.45  ENTRY(resume_kernel)
   52.46  	XEN_BLOCK_EVENTS(%esi)
   52.47  	cmpl $0,TI_preempt_count(%ebp)	# non-zero preempt_count ?
   52.48 -	jnz restore_all
   52.49 +	jnz restore_nocheck
   52.50  need_resched:
   52.51  	movl TI_flags(%ebp), %ecx	# need_resched set ?
   52.52  	testb $_TIF_NEED_RESCHED, %cl
   52.53 @@ -252,7 +251,8 @@ 1:	movl (%ebp),%ebp
   52.54  	SAVE_ALL
   52.55  	GET_THREAD_INFO(%ebp)
   52.56  
   52.57 -	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
   52.58 +	/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
   52.59 +	testw $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),TI_flags(%ebp)
   52.60  	jnz syscall_trace_entry
   52.61  	cmpl $(nr_syscalls), %eax
   52.62  	jae syscall_badsys
   52.63 @@ -276,7 +276,8 @@ ENTRY(system_call)
   52.64  	SAVE_ALL
   52.65  	GET_THREAD_INFO(%ebp)
   52.66  					# system call tracing in operation
   52.67 -	testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
   52.68 +	/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
   52.69 +	testw $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),TI_flags(%ebp)
   52.70  	jnz syscall_trace_entry
   52.71  	cmpl $(nr_syscalls), %eax
   52.72  	jae syscall_badsys
   52.73 @@ -290,7 +291,20 @@ syscall_exit:
   52.74  	movl TI_flags(%ebp), %ecx
   52.75  	testw $_TIF_ALLWORK_MASK, %cx	# current->work
   52.76  	jne syscall_exit_work
   52.77 +
   52.78  restore_all:
   52.79 +#if 0 /* XEN */
   52.80 +	movl EFLAGS(%esp), %eax		# mix EFLAGS, SS and CS
   52.81 +	# Warning: OLDSS(%esp) contains the wrong/random values if we
   52.82 +	# are returning to the kernel.
   52.83 +	# See comments in process.c:copy_thread() for details.
   52.84 +	movb OLDSS(%esp), %ah
   52.85 +	movb CS(%esp), %al
   52.86 +	andl $(VM_MASK | (4 << 8) | 3), %eax
   52.87 +	cmpl $((4 << 8) | 3), %eax
   52.88 +	je ldt_ss			# returning to user-space with LDT SS
   52.89 +#endif /* XEN */
   52.90 +restore_nocheck:
   52.91  	testl $VM_MASK, EFLAGS(%esp)
   52.92  	jnz resume_vm86
   52.93  	movb EVENT_MASK(%esp), %al
   52.94 @@ -300,7 +314,19 @@ restore_all:
   52.95  	andb $1,%al			# %al == mask & ~saved_mask
   52.96  	jnz restore_all_enable_events	#     != 0 => reenable event delivery
   52.97  	XEN_PUT_VCPU_INFO(%esi)
   52.98 -	RESTORE_ALL
   52.99 +	RESTORE_REGS
  52.100 +	addl $4, %esp
  52.101 +1:	iret
  52.102 +.section .fixup,"ax"
  52.103 +iret_exc:
  52.104 +	pushl $0			# no error code
  52.105 +	pushl $do_iret_error
  52.106 +	jmp error_code
  52.107 +.previous
  52.108 +.section __ex_table,"a"
  52.109 +	.align 4
  52.110 +	.long 1b,iret_exc
  52.111 +.previous
  52.112  
  52.113  resume_vm86:
  52.114  	XEN_UNBLOCK_EVENTS(%esi)
  52.115 @@ -310,6 +336,33 @@ resume_vm86:
  52.116  	int $0x82
  52.117  	ud2
  52.118  
  52.119 +#if 0 /* XEN */
  52.120 +ldt_ss:
  52.121 +	larl OLDSS(%esp), %eax
  52.122 +	jnz restore_nocheck
  52.123 +	testl $0x00400000, %eax		# returning to 32bit stack?
  52.124 +	jnz restore_nocheck		# allright, normal return
  52.125 +	/* If returning to userspace with 16bit stack,
  52.126 +	 * try to fix the higher word of ESP, as the CPU
  52.127 +	 * won't restore it.
  52.128 +	 * This is an "official" bug of all the x86-compatible
  52.129 +	 * CPUs, which we can try to work around to make
  52.130 +	 * dosemu and wine happy. */
  52.131 +	subl $8, %esp		# reserve space for switch16 pointer
  52.132 +	cli
  52.133 +	movl %esp, %eax
  52.134 +	/* Set up the 16bit stack frame with switch32 pointer on top,
  52.135 +	 * and a switch16 pointer on top of the current frame. */
  52.136 +	call setup_x86_bogus_stack
  52.137 +	RESTORE_REGS
  52.138 +	lss 20+4(%esp), %esp	# switch to 16bit stack
  52.139 +1:	iret
  52.140 +.section __ex_table,"a"
  52.141 +	.align 4
  52.142 +	.long 1b,iret_exc
  52.143 +.previous
  52.144 +#endif /* XEN */
  52.145 +
  52.146  	# perform work that needs to be done immediately before resumption
  52.147  	ALIGN
  52.148  work_pending:
  52.149 @@ -385,6 +438,27 @@ syscall_badsys:
  52.150  	jmp resume_userspace
  52.151  
  52.152  #if 0 /* XEN */
  52.153 +#define FIXUP_ESPFIX_STACK \
  52.154 +	movl %esp, %eax; \
  52.155 +	/* switch to 32bit stack using the pointer on top of 16bit stack */ \
  52.156 +	lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \
  52.157 +	/* copy data from 16bit stack to 32bit stack */ \
  52.158 +	call fixup_x86_bogus_stack; \
  52.159 +	/* put ESP to the proper location */ \
  52.160 +	movl %eax, %esp;
  52.161 +#define UNWIND_ESPFIX_STACK \
  52.162 +	pushl %eax; \
  52.163 +	movl %ss, %eax; \
  52.164 +	/* see if on 16bit stack */ \
  52.165 +	cmpw $__ESPFIX_SS, %ax; \
  52.166 +	jne 28f; \
  52.167 +	movl $__KERNEL_DS, %edx; \
  52.168 +	movl %edx, %ds; \
  52.169 +	movl %edx, %es; \
  52.170 +	/* switch to 32bit stack */ \
  52.171 +	FIXUP_ESPFIX_STACK \
  52.172 +28:	popl %eax;
  52.173 +
  52.174  /*
  52.175   * Build the entry stubs and pointer table with
  52.176   * some assembler magic.
  52.177 @@ -440,7 +514,9 @@ error_code:
  52.178  	pushl %ecx
  52.179  	pushl %ebx
  52.180  	cld
  52.181 -	movl %es, %ecx
  52.182 +	pushl %es
  52.183 +#	UNWIND_ESPFIX_STACK
  52.184 +	popl %ecx
  52.185  	movl ES(%esp), %edi		# get the function address
  52.186  	movl ORIG_EAX(%esp), %edx	# get the error code
  52.187  	movl %eax, ORIG_EAX(%esp)
  52.188 @@ -625,6 +701,11 @@ debug_stack_correct:
  52.189   * fault happened on the sysenter path.
  52.190   */
  52.191  ENTRY(nmi)
  52.192 +	pushl %eax
  52.193 +	movl %ss, %eax
  52.194 +	cmpw $__ESPFIX_SS, %ax
  52.195 +	popl %eax
  52.196 +	je nmi_16bit_stack
  52.197  	cmpl $sysenter_entry,(%esp)
  52.198  	je nmi_stack_fixup
  52.199  	pushl %eax
  52.200 @@ -644,7 +725,7 @@ nmi_stack_correct:
  52.201  	xorl %edx,%edx		# zero error code
  52.202  	movl %esp,%eax		# pt_regs pointer
  52.203  	call do_nmi
  52.204 -	RESTORE_ALL
  52.205 +	jmp restore_all
  52.206  
  52.207  nmi_stack_fixup:
  52.208  	FIX_STACK(12,nmi_stack_correct, 1)
  52.209 @@ -659,6 +740,29 @@ nmi_debug_stack_check:
  52.210  nmi_debug_stack_fixup:
  52.211  	FIX_STACK(24,nmi_stack_correct, 1)
  52.212  	jmp nmi_stack_correct
  52.213 +
  52.214 +nmi_16bit_stack:
  52.215 +	/* create the pointer to lss back */
  52.216 +	pushl %ss
  52.217 +	pushl %esp
  52.218 +	movzwl %sp, %esp
  52.219 +	addw $4, (%esp)
  52.220 +	/* copy the iret frame of 12 bytes */
  52.221 +	.rept 3
  52.222 +	pushl 16(%esp)
  52.223 +	.endr
  52.224 +	pushl %eax
  52.225 +	SAVE_ALL
  52.226 +	FIXUP_ESPFIX_STACK		# %eax == %esp
  52.227 +	xorl %edx,%edx			# zero error code
  52.228 +	call do_nmi
  52.229 +	RESTORE_REGS
  52.230 +	lss 12+4(%esp), %esp		# back to 16bit stack
  52.231 +1:	iret
  52.232 +.section __ex_table,"a"
  52.233 +	.align 4
  52.234 +	.long 1b,iret_exc
  52.235 +.previous
  52.236  #endif /* XEN */
  52.237  
  52.238  ENTRY(int3)
  52.239 @@ -725,7 +829,9 @@ ENTRY(page_fault)
  52.240  	pushl %ecx
  52.241  	pushl %ebx
  52.242  	cld
  52.243 -	movl %es,%edi
  52.244 +	pushl %es
  52.245 +#	UNWIND_ESPFIX_STACK
  52.246 +	popl %edi
  52.247  	movl ES(%esp), %ecx		/* get the faulting address */
  52.248  	movl ORIG_EAX(%esp), %edx	/* get the error code */
  52.249  	movl %eax, ORIG_EAX(%esp)
    53.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Thu Sep 08 09:18:40 2005 -0600
    53.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Fri Sep 09 10:30:54 2005 -0600
    53.3 @@ -38,17 +38,13 @@
    53.4  #define X86_VENDOR_ID	new_cpu_data+CPUINFO_x86_vendor_id
    53.5  
    53.6  ENTRY(startup_32)
    53.7 -	cld
    53.8 -
    53.9 -	/* Copy the necessary stuff from xen_start_info structure. */
   53.10 -	mov  $xen_start_info_union,%edi
   53.11 -	mov  $512,%ecx
   53.12 -	rep movsl
   53.13 +	movl %esi,xen_start_info
   53.14  
   53.15  #ifdef CONFIG_SMP
   53.16  ENTRY(startup_32_smp)
   53.17 +#endif /* CONFIG_SMP */
   53.18 +
   53.19  	cld
   53.20 -#endif /* CONFIG_SMP */
   53.21  
   53.22  	/* Set up the stack pointer */
   53.23  	lss stack_start,%esp
   53.24 @@ -179,7 +175,7 @@ ENTRY(cpu_gdt_table)
   53.25  	.quad 0x0000000000000000	/* 0xc0 APM CS 16 code (16 bit) */
   53.26  	.quad 0x0000000000000000	/* 0xc8 APM DS    data */
   53.27  
   53.28 -	.quad 0x0000000000000000	/* 0xd0 - unused */
   53.29 +	.quad 0x0000000000000000	/* 0xd0 - ESPFIX 16-bit SS */
   53.30  	.quad 0x0000000000000000	/* 0xd8 - unused */
   53.31  	.quad 0x0000000000000000	/* 0xe0 - unused */
   53.32  	.quad 0x0000000000000000	/* 0xe8 - unused */
    54.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/irq.c	Thu Sep 08 09:18:40 2005 -0600
    54.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/irq.c	Fri Sep 09 10:30:54 2005 -0600
    54.3 @@ -242,12 +242,12 @@ skip:
    54.4  	} else if (i == NR_IRQS) {
    54.5  		seq_printf(p, "NMI: ");
    54.6  		for_each_cpu(j)
    54.7 -			seq_printf(p, "%10u ", nmi_count(j));
    54.8 + 			seq_printf(p, "%10u ", nmi_count(j));
    54.9  		seq_putc(p, '\n');
   54.10  #ifdef CONFIG_X86_LOCAL_APIC
   54.11  		seq_printf(p, "LOC: ");
   54.12  		for_each_cpu(j)
   54.13 -			seq_printf(p, "%10u ", per_cpu(irq_stat, j).apic_timer_irqs);
   54.14 +			seq_printf(p, "%10u ", per_cpu(irq_stat,j).apic_timer_irqs);
   54.15  		seq_putc(p, '\n');
   54.16  #endif
   54.17  		seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
   54.18 @@ -263,6 +263,7 @@ skip:
   54.19  void fixup_irqs(cpumask_t map)
   54.20  {
   54.21  	unsigned int irq;
   54.22 +	static int warned;
   54.23  
   54.24  	for (irq = 0; irq < NR_IRQS; irq++) {
   54.25  		cpumask_t mask;
   54.26 @@ -276,7 +277,7 @@ void fixup_irqs(cpumask_t map)
   54.27  		}
   54.28  		if (irq_desc[irq].handler->set_affinity)
   54.29  			irq_desc[irq].handler->set_affinity(irq, mask);
   54.30 -		else if (irq_desc[irq].action)
   54.31 +		else if (irq_desc[irq].action && !(warned++))
   54.32  			printk("Cannot set affinity for irq %i\n", irq);
   54.33  	}
   54.34  
    55.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Thu Sep 08 09:18:40 2005 -0600
    55.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Fri Sep 09 10:30:54 2005 -0600
    55.3 @@ -115,9 +115,9 @@ dma_supported(struct device *dev, u64 ma
    55.4  	if (swiotlb)
    55.5  		return swiotlb_dma_supported(dev, mask);
    55.6  	/*
    55.7 -         * By default we'll BUG when an infeasible DMA is requested, and
    55.8 -         * request swiotlb=force (see IOMMU_BUG_ON).
    55.9 -         */
   55.10 +	 * By default we'll BUG when an infeasible DMA is requested, and
   55.11 +	 * request swiotlb=force (see IOMMU_BUG_ON).
   55.12 +	 */
   55.13  	return 1;
   55.14  }
   55.15  EXPORT_SYMBOL(dma_supported);
    56.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Thu Sep 08 09:18:40 2005 -0600
    56.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Fri Sep 09 10:30:54 2005 -0600
    56.3 @@ -135,6 +135,10 @@ static inline void play_dead(void)
    56.4   * low exit latency (ie sit in a loop waiting for
    56.5   * somebody to say that they'd like to reschedule)
    56.6   */
    56.7 +#ifdef CONFIG_SMP
    56.8 +extern void smp_suspend(void);
    56.9 +extern void smp_resume(void);
   56.10 +#endif
   56.11  void cpu_idle (void)
   56.12  {
   56.13  	int cpu = _smp_processor_id();
   56.14 @@ -149,6 +153,9 @@ void cpu_idle (void)
   56.15  
   56.16  			if (cpu_is_offline(cpu)) {
   56.17  				local_irq_disable();
   56.18 +#ifdef CONFIG_SMP
   56.19 +				smp_suspend();
   56.20 +#endif
   56.21  #if defined(CONFIG_XEN) && defined(CONFIG_HOTPLUG_CPU)
   56.22  				/* Ack it.  From this point on until
   56.23  				   we get woken up, we're not allowed
   56.24 @@ -159,6 +166,9 @@ void cpu_idle (void)
   56.25  				HYPERVISOR_vcpu_down(cpu);
   56.26  #endif
   56.27  				play_dead();
   56.28 +#ifdef CONFIG_SMP
   56.29 +				smp_resume();
   56.30 +#endif
   56.31  				local_irq_enable();
   56.32  			}
   56.33  
   56.34 @@ -457,7 +467,6 @@ int dump_task_regs(struct task_struct *t
   56.35  	return 1;
   56.36  }
   56.37  
   56.38 -
   56.39  /*
   56.40   *	switch_to(x,yn) should switch tasks from x to y.
   56.41   *
   56.42 @@ -789,10 +798,3 @@ unsigned long arch_align_stack(unsigned 
   56.43  		sp -= get_random_int() % 8192;
   56.44  	return sp & ~0xf;
   56.45  }
   56.46 -
   56.47 -
   56.48 -#ifndef CONFIG_X86_SMP
   56.49 -void _restore_vcpu(void)
   56.50 -{
   56.51 -}
   56.52 -#endif
    57.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Thu Sep 08 09:18:40 2005 -0600
    57.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Sep 09 10:30:54 2005 -0600
    57.3 @@ -55,6 +55,7 @@
    57.4  #include <asm/io.h>
    57.5  #include <asm-xen/hypervisor.h>
    57.6  #include <asm-xen/xen-public/physdev.h>
    57.7 +#include <asm-xen/xen-public/memory.h>
    57.8  #include "setup_arch_pre.h"
    57.9  #include <bios_ebda.h>
   57.10  
   57.11 @@ -288,7 +289,7 @@ static void __init probe_roms(void)
   57.12  	int	      i;
   57.13  
   57.14  	/* Nothing to do if not running in dom0. */
   57.15 -	if (!(xen_start_info.flags & SIF_INITDOMAIN))
   57.16 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
   57.17  		return;
   57.18  
   57.19  	/* video rom */
   57.20 @@ -358,11 +359,12 @@ static void __init probe_roms(void)
   57.21  shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
   57.22  EXPORT_SYMBOL(HYPERVISOR_shared_info);
   57.23  
   57.24 -unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
   57.25 +unsigned long *phys_to_machine_mapping;
   57.26 +unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[16];
   57.27  EXPORT_SYMBOL(phys_to_machine_mapping);
   57.28  
   57.29  /* Raw start-of-day parameters from the hypervisor. */
   57.30 -union xen_start_info_union xen_start_info_union;
   57.31 +start_info_t *xen_start_info;
   57.32  
   57.33  static void __init limit_regions(unsigned long long size)
   57.34  {
   57.35 @@ -702,7 +704,7 @@ static void __init parse_cmdline_early (
   57.36  
   57.37  	if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
   57.38  		max_cmdline = COMMAND_LINE_SIZE;
   57.39 -	memcpy(saved_command_line, xen_start_info.cmd_line, max_cmdline);
   57.40 +	memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
   57.41  	/* Save unparsed command line copy for /proc/cmdline */
   57.42  	saved_command_line[max_cmdline-1] = '\0';
   57.43  
   57.44 @@ -933,8 +935,8 @@ void __init find_max_pfn(void)
   57.45  /* We don't use the fake e820 because we need to respond to user override. */
   57.46  void __init find_max_pfn(void)
   57.47  {
   57.48 -	if ( xen_override_max_pfn < xen_start_info.nr_pages )
   57.49 -		xen_override_max_pfn = xen_start_info.nr_pages;
   57.50 +	if ( xen_override_max_pfn < xen_start_info->nr_pages )
   57.51 +		xen_override_max_pfn = xen_start_info->nr_pages;
   57.52  	max_pfn = xen_override_max_pfn;
   57.53  }
   57.54  #endif /* XEN */
   57.55 @@ -1077,12 +1079,12 @@ static void __init reserve_ebda_region(v
   57.56  void __init setup_bootmem_allocator(void);
   57.57  static unsigned long __init setup_memory(void)
   57.58  {
   57.59 -
   57.60  	/*
   57.61  	 * partially used pages are not usable - thus
   57.62  	 * we are rounding upwards:
   57.63  	 */
   57.64 - 	min_low_pfn = PFN_UP(__pa(xen_start_info.pt_base)) + xen_start_info.nr_pt_frames;
   57.65 + 	min_low_pfn = PFN_UP(__pa(xen_start_info->pt_base)) +
   57.66 +		xen_start_info->nr_pt_frames;
   57.67  
   57.68  	find_max_pfn();
   57.69  
   57.70 @@ -1188,7 +1190,7 @@ void __init setup_bootmem_allocator(void
   57.71  #endif /* !CONFIG_XEN */
   57.72  
   57.73  #ifdef CONFIG_BLK_DEV_INITRD
   57.74 -	if (xen_start_info.mod_start) {
   57.75 +	if (xen_start_info->mod_start) {
   57.76  		if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
   57.77  			/*reserve_bootmem(INITRD_START, INITRD_SIZE);*/
   57.78  			initrd_start = INITRD_START + PAGE_OFFSET;
   57.79 @@ -1205,7 +1207,7 @@ void __init setup_bootmem_allocator(void
   57.80  	}
   57.81  #endif
   57.82  
   57.83 -	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
   57.84 +	phys_to_machine_mapping = (unsigned long *)xen_start_info->mfn_list;
   57.85  }
   57.86  
   57.87  /*
   57.88 @@ -1234,10 +1236,64 @@ static void __init
   57.89  legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
   57.90  {
   57.91  	int i;
   57.92 +#ifdef CONFIG_XEN
   57.93 +	dom0_op_t op;
   57.94 +	struct dom0_memory_map_entry *map;
   57.95 +	unsigned long gapstart, gapsize;
   57.96 +	unsigned long long last;
   57.97 +#endif
   57.98  
   57.99  #ifdef CONFIG_XEN_PRIVILEGED_GUEST
  57.100  	probe_roms();
  57.101  #endif
  57.102 +
  57.103 +#ifdef CONFIG_XEN
  57.104 +	map = alloc_bootmem_low_pages(PAGE_SIZE);
  57.105 +	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
  57.106 +	op.u.physical_memory_map.memory_map = map;
  57.107 +	op.u.physical_memory_map.max_map_entries =
  57.108 +		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
  57.109 +	BUG_ON(HYPERVISOR_dom0_op(&op));
  57.110 +
  57.111 +	last = 0x100000000ULL;
  57.112 +	gapstart = 0x10000000;
  57.113 +	gapsize = 0x400000;
  57.114 +
  57.115 +	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
  57.116 +		struct resource *res;
  57.117 +
  57.118 +		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
  57.119 +			gapsize = last - map[i].end;
  57.120 +			gapstart = map[i].end;
  57.121 +		}
  57.122 +		if (map[i].start < last)
  57.123 +			last = map[i].start;
  57.124 +
  57.125 +		if (map[i].end > 0x100000000ULL)
  57.126 +			continue;
  57.127 +		res = alloc_bootmem_low(sizeof(struct resource));
  57.128 +		res->name = map[i].is_ram ? "System RAM" : "reserved";
  57.129 +		res->start = map[i].start;
  57.130 +		res->end = map[i].end - 1;
  57.131 +		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  57.132 +		request_resource(&iomem_resource, res);
  57.133 +	}
  57.134 +
  57.135 +	free_bootmem(__pa(map), PAGE_SIZE);
  57.136 +
  57.137 +	/*
  57.138 +	 * Start allocating dynamic PCI memory a bit into the gap,
  57.139 +	 * aligned up to the nearest megabyte.
  57.140 +	 *
  57.141 +	 * Question: should we try to pad it up a bit (do something
  57.142 +	 * like " + (gapsize >> 3)" in there too?). We now have the
  57.143 +	 * technology.
  57.144 +	 */
  57.145 +	pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
  57.146 +
  57.147 +	printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
  57.148 +		pci_mem_start, gapstart, gapsize);
  57.149 +#else
  57.150  	for (i = 0; i < e820.nr_map; i++) {
  57.151  		struct resource *res;
  57.152  		if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
  57.153 @@ -1263,6 +1319,7 @@ legacy_init_iomem_resources(struct resou
  57.154  			request_resource(res, data_resource);
  57.155  		}
  57.156  	}
  57.157 +#endif
  57.158  }
  57.159  
  57.160  /*
  57.161 @@ -1270,23 +1327,29 @@ legacy_init_iomem_resources(struct resou
  57.162   */
  57.163  static void __init register_memory(void)
  57.164  {
  57.165 +#ifndef CONFIG_XEN
  57.166  	unsigned long gapstart, gapsize;
  57.167  	unsigned long long last;
  57.168 +#endif
  57.169  	int	      i;
  57.170  
  57.171 +	/* Nothing to do if not running in dom0. */
  57.172 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
  57.173 +		return;
  57.174 +
  57.175  	if (efi_enabled)
  57.176  		efi_initialize_iomem_resources(&code_resource, &data_resource);
  57.177  	else
  57.178  		legacy_init_iomem_resources(&code_resource, &data_resource);
  57.179  
  57.180 -	if (xen_start_info.flags & SIF_INITDOMAIN)
  57.181 -		/* EFI systems may still have VGA */
  57.182 -		request_resource(&iomem_resource, &video_ram_resource);
  57.183 +	/* EFI systems may still have VGA */
  57.184 +	request_resource(&iomem_resource, &video_ram_resource);
  57.185  
  57.186  	/* request I/O space for devices used on all i[345]86 PCs */
  57.187  	for (i = 0; i < STANDARD_IO_RESOURCES; i++)
  57.188  		request_resource(&ioport_resource, &standard_io_resources[i]);
  57.189  
  57.190 +#ifndef CONFIG_XEN
  57.191  	/*
  57.192  	 * Search for the bigest gap in the low 32 bits of the e820
  57.193  	 * memory space.
  57.194 @@ -1327,6 +1390,7 @@ static void __init register_memory(void)
  57.195  
  57.196  	printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
  57.197  		pci_mem_start, gapstart, gapsize);
  57.198 +#endif
  57.199  }
  57.200  
  57.201  /* Use inline assembly to define this because the nops are defined 
  57.202 @@ -1456,7 +1520,7 @@ static void set_mca_bus(int x) { }
  57.203   */
  57.204  void __init setup_arch(char **cmdline_p)
  57.205  {
  57.206 -	int i, j;
  57.207 +	int i, j, k, fpp;
  57.208  	physdev_op_t op;
  57.209  	unsigned long max_low_pfn;
  57.210  
  57.211 @@ -1535,8 +1599,8 @@ void __init setup_arch(char **cmdline_p)
  57.212  	init_mm.start_code = (unsigned long) _text;
  57.213  	init_mm.end_code = (unsigned long) _etext;
  57.214  	init_mm.end_data = (unsigned long) _edata;
  57.215 -	init_mm.brk = (PFN_UP(__pa(xen_start_info.pt_base)) +
  57.216 -		       xen_start_info.nr_pt_frames) << PAGE_SHIFT;
  57.217 +	init_mm.brk = (PFN_UP(__pa(xen_start_info->pt_base)) +
  57.218 +		       xen_start_info->nr_pt_frames) << PAGE_SHIFT;
  57.219  
  57.220  	/* XEN: This is nonsense: kernel may not even be contiguous in RAM. */
  57.221  	/*code_resource.start = virt_to_phys(_text);*/
  57.222 @@ -1573,42 +1637,64 @@ void __init setup_arch(char **cmdline_p)
  57.223  #endif
  57.224  
  57.225  	/* Make sure we have a correctly sized P->M table. */
  57.226 -	if (max_pfn != xen_start_info.nr_pages) {
  57.227 +	if (max_pfn != xen_start_info->nr_pages) {
  57.228  		phys_to_machine_mapping = alloc_bootmem_low_pages(
  57.229 -			max_pfn * sizeof(unsigned int));
  57.230 +			max_pfn * sizeof(unsigned long));
  57.231  
  57.232 -		if (max_pfn > xen_start_info.nr_pages) {
  57.233 +		if (max_pfn > xen_start_info->nr_pages) {
  57.234  			/* set to INVALID_P2M_ENTRY */
  57.235  			memset(phys_to_machine_mapping, ~0,
  57.236 -				max_pfn * sizeof(unsigned int));
  57.237 -			memcpy(phys_to_machine_mapping,
  57.238 -				(unsigned int *)xen_start_info.mfn_list,
  57.239 -				xen_start_info.nr_pages * sizeof(unsigned int));
  57.240 -		} else {
  57.241 +				max_pfn * sizeof(unsigned long));
  57.242  			memcpy(phys_to_machine_mapping,
  57.243 -				(unsigned int *)xen_start_info.mfn_list,
  57.244 -				max_pfn * sizeof(unsigned int));
  57.245 -			/* N.B. below relies on sizeof(int) == sizeof(long). */
  57.246 -			if (HYPERVISOR_dom_mem_op(
  57.247 -				MEMOP_decrease_reservation,
  57.248 -				(unsigned long *)xen_start_info.mfn_list + max_pfn,
  57.249 -				xen_start_info.nr_pages - max_pfn, 0) !=
  57.250 -			    (xen_start_info.nr_pages - max_pfn)) BUG();
  57.251 +				(unsigned long *)xen_start_info->mfn_list,
  57.252 +				xen_start_info->nr_pages * sizeof(unsigned long));
  57.253 +		} else {
  57.254 +			struct xen_memory_reservation reservation = {
  57.255 +				.extent_start = (unsigned long *)xen_start_info->mfn_list + max_pfn,
  57.256 +				.nr_extents   = xen_start_info->nr_pages - max_pfn,
  57.257 +				.extent_order = 0,
  57.258 +				.domid        = DOMID_SELF
  57.259 +			};
  57.260 +
  57.261 +			memcpy(phys_to_machine_mapping,
  57.262 +				(unsigned long *)xen_start_info->mfn_list,
  57.263 +				max_pfn * sizeof(unsigned long));
  57.264 +			BUG_ON(HYPERVISOR_memory_op(
  57.265 +				XENMEM_decrease_reservation,
  57.266 +				&reservation) !=
  57.267 +			    (xen_start_info->nr_pages - max_pfn));
  57.268  		}
  57.269  		free_bootmem(
  57.270 -			__pa(xen_start_info.mfn_list), 
  57.271 -			PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
  57.272 -			sizeof(unsigned int))));
  57.273 +			__pa(xen_start_info->mfn_list), 
  57.274 +			PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
  57.275 +			sizeof(unsigned long))));
  57.276  	}
  57.277  
  57.278 -	pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
  57.279 -	for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned int)), j++ )
  57.280 -	{	
  57.281 -	     pfn_to_mfn_frame_list[j] = 
  57.282 -		  virt_to_mfn(&phys_to_machine_mapping[i]);
  57.283 +
  57.284 +	/* 
  57.285 +	 * Initialise the list of the frames that specify the list of 
  57.286 +	 * frames that make up the p2m table. Used by save/restore
  57.287 +	 */
  57.288 +	pfn_to_mfn_frame_list_list = alloc_bootmem_low_pages(PAGE_SIZE);
  57.289 +	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
  57.290 +	  virt_to_mfn(pfn_to_mfn_frame_list_list);
  57.291 +	       
  57.292 +	fpp = PAGE_SIZE/sizeof(unsigned long);
  57.293 +	for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
  57.294 +	{
  57.295 +	    if ( (j % fpp) == 0 )
  57.296 +	    {
  57.297 +	        k++;
  57.298 +		BUG_ON(k>=16);
  57.299 +		pfn_to_mfn_frame_list[k] = alloc_bootmem_low_pages(PAGE_SIZE);
  57.300 +		pfn_to_mfn_frame_list_list[k] = 
  57.301 +		    virt_to_mfn(pfn_to_mfn_frame_list[k]);
  57.302 +		j=0;
  57.303 +	    }
  57.304 +	    pfn_to_mfn_frame_list[k][j] = 
  57.305 +	        virt_to_mfn(&phys_to_machine_mapping[i]);
  57.306  	}
  57.307 -	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
  57.308 -	     virt_to_mfn(pfn_to_mfn_frame_list);
  57.309 +	HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
  57.310  
  57.311  	/*
  57.312  	 * NOTE: at this point the bootmem allocator is fully available.
  57.313 @@ -1626,8 +1712,8 @@ void __init setup_arch(char **cmdline_p)
  57.314  	}
  57.315  #endif
  57.316  
  57.317 -
  57.318 -	dmi_scan_machine();
  57.319 +	if (xen_start_info->flags & SIF_INITDOMAIN)
  57.320 +		dmi_scan_machine();
  57.321  
  57.322  #ifdef CONFIG_X86_GENERICARCH
  57.323  	generic_apic_probe(*cmdline_p);
  57.324 @@ -1640,7 +1726,7 @@ void __init setup_arch(char **cmdline_p)
  57.325  	HYPERVISOR_physdev_op(&op);
  57.326  
  57.327  #ifdef CONFIG_ACPI_BOOT
  57.328 -	if (!(xen_start_info.flags & SIF_INITDOMAIN)) {
  57.329 +	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
  57.330  		printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
  57.331  		acpi_disabled = 1;
  57.332  		acpi_ht = 0;
  57.333 @@ -1666,8 +1752,8 @@ void __init setup_arch(char **cmdline_p)
  57.334  
  57.335  	register_memory();
  57.336  
  57.337 -	if (xen_start_info.flags & SIF_INITDOMAIN) {
  57.338 -		if (!(xen_start_info.flags & SIF_PRIVILEGED))
  57.339 +	if (xen_start_info->flags & SIF_INITDOMAIN) {
  57.340 +		if (!(xen_start_info->flags & SIF_PRIVILEGED))
  57.341  			panic("Xen granted us console access "
  57.342  			      "but not privileged status");
  57.343  
    58.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Thu Sep 08 09:18:40 2005 -0600
    58.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/smpboot.c	Fri Sep 09 10:30:54 2005 -0600
    58.3 @@ -856,9 +856,6 @@ static int __init do_boot_cpu(int apicid
    58.4  	cpu_gdt_descr[cpu].address = __get_free_page(GFP_KERNEL|__GFP_ZERO);
    58.5  	BUG_ON(cpu_gdt_descr[0].size > PAGE_SIZE);
    58.6  	cpu_gdt_descr[cpu].size = cpu_gdt_descr[0].size;
    58.7 -	printk("GDT: copying %d bytes from %lx to %lx\n",
    58.8 -		cpu_gdt_descr[0].size, cpu_gdt_descr[0].address,
    58.9 -		cpu_gdt_descr[cpu].address); 
   58.10  	memcpy((void *)cpu_gdt_descr[cpu].address,
   58.11  	       (void *)cpu_gdt_descr[0].address, cpu_gdt_descr[0].size);
   58.12  
   58.13 @@ -1274,6 +1271,7 @@ static void __init smp_boot_cpus(unsigne
   58.14  			printk(KERN_WARNING "WARNING: %d siblings found for CPU%d, should be %d\n", siblings, cpu, smp_num_siblings);
   58.15  			smp_num_siblings = siblings;
   58.16  		}
   58.17 +
   58.18  		if (c->x86_num_cores > 1) {
   58.19  			for (i = 0; i < NR_CPUS; i++) {
   58.20  				if (!cpu_isset(i, cpu_callout_map))
   58.21 @@ -1601,32 +1599,71 @@ extern void local_teardown_timer_irq(voi
   58.22  
   58.23  void smp_suspend(void)
   58.24  {
   58.25 -	/* XXX todo: take down time and ipi's on all cpus */
   58.26  	local_teardown_timer_irq();
   58.27  	smp_intr_exit();
   58.28  }
   58.29  
   58.30  void smp_resume(void)
   58.31  {
   58.32 -	/* XXX todo: restore time and ipi's on all cpus */
   58.33  	smp_intr_init();
   58.34  	local_setup_timer_irq();
   58.35  }
   58.36  
   58.37 -DECLARE_PER_CPU(int, timer_irq);
   58.38 -
   58.39 -void _restore_vcpu(void)
   58.40 -{
   58.41 -	int cpu = smp_processor_id();
   58.42 -	extern atomic_t vcpus_rebooting;
   58.43 +static atomic_t vcpus_rebooting;
   58.44  
   58.45 -	/* We are the first thing the vcpu runs when it comes back,
   58.46 -	   and we are supposed to restore the IPIs and timer
   58.47 -	   interrupts etc.  When we return, the vcpu's idle loop will
   58.48 -	   start up again. */
   58.49 -	_bind_virq_to_irq(VIRQ_TIMER, cpu, per_cpu(timer_irq, cpu));
   58.50 -	_bind_virq_to_irq(VIRQ_DEBUG, cpu, per_cpu(ldebug_irq, cpu));
   58.51 -	_bind_ipi_to_irq(RESCHEDULE_VECTOR, cpu, per_cpu(resched_irq, cpu) );
   58.52 -	_bind_ipi_to_irq(CALL_FUNCTION_VECTOR, cpu, per_cpu(callfunc_irq, cpu) );
   58.53 +static void restore_vcpu_ready(void)
   58.54 +{
   58.55 +
   58.56  	atomic_dec(&vcpus_rebooting);
   58.57  }
   58.58 +
   58.59 +void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
   58.60 +{
   58.61 +	int r;
   58.62 +	int gdt_pages;
   58.63 +	r = HYPERVISOR_vcpu_pickle(vcpu, ctxt);
   58.64 +	if (r != 0)
   58.65 +		panic("pickling vcpu %d -> %d!\n", vcpu, r);
   58.66 +
   58.67 +	/* Translate from machine to physical addresses where necessary,
   58.68 +	   so that they can be translated to our new machine address space
   58.69 +	   after resume.  libxc is responsible for doing this to vcpu0,
   58.70 +	   but we do it to the others. */
   58.71 +	gdt_pages = (ctxt->gdt_ents + 511) / 512;
   58.72 +	ctxt->ctrlreg[3] = machine_to_phys(ctxt->ctrlreg[3]);
   58.73 +	for (r = 0; r < gdt_pages; r++)
   58.74 +		ctxt->gdt_frames[r] = mfn_to_pfn(ctxt->gdt_frames[r]);
   58.75 +}
   58.76 +
   58.77 +int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
   58.78 +{
   58.79 +	int r;
   58.80 +	int gdt_pages = (ctxt->gdt_ents + 511) / 512;
   58.81 +
   58.82 +	/* This is kind of a hack, and implicitly relies on the fact that
   58.83 +	   the vcpu stops in a place where all of the call clobbered
   58.84 +	   registers are already dead. */
   58.85 +	ctxt->user_regs.esp -= 4;
   58.86 +	((unsigned long *)ctxt->user_regs.esp)[0] = ctxt->user_regs.eip;
   58.87 +	ctxt->user_regs.eip = (unsigned long)restore_vcpu_ready;
   58.88 +
   58.89 +	/* De-canonicalise.  libxc handles this for vcpu 0, but we need
   58.90 +	   to do it for the other vcpus. */
   58.91 +	ctxt->ctrlreg[3] = phys_to_machine(ctxt->ctrlreg[3]);
   58.92 +	for (r = 0; r < gdt_pages; r++)
   58.93 +		ctxt->gdt_frames[r] = pfn_to_mfn(ctxt->gdt_frames[r]);
   58.94 +
   58.95 +	atomic_set(&vcpus_rebooting, 1);
   58.96 +	r = HYPERVISOR_boot_vcpu(vcpu, ctxt);
   58.97 +	if (r != 0) {
   58.98 +		printk(KERN_EMERG "Failed to reboot vcpu %d (%d)\n", vcpu, r);
   58.99 +		return -1;
  58.100 +	}
  58.101 +
  58.102 +	/* Make sure we wait for the new vcpu to come up before trying to do
  58.103 +	   anything with it or starting the next one. */
  58.104 +	while (atomic_read(&vcpus_rebooting))
  58.105 +		barrier();
  58.106 +
  58.107 +	return 0;
  58.108 +}
    59.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Thu Sep 08 09:18:40 2005 -0600
    59.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/swiotlb.c	Fri Sep 09 10:30:54 2005 -0600
    59.3 @@ -51,7 +51,7 @@ static unsigned long iotlb_nslabs;
    59.4   * swiotlb_sync_single_*, to see if the memory was in fact allocated by this
    59.5   * API.
    59.6   */
    59.7 -static dma_addr_t iotlb_bus_start, iotlb_bus_mask;
    59.8 +static dma_addr_t iotlb_bus_start, iotlb_bus_end, iotlb_bus_mask;
    59.9  
   59.10  /* Does the given dma address reside within the swiotlb aperture? */
   59.11  #define in_swiotlb_aperture(a) (!(((a) ^ iotlb_bus_start) & iotlb_bus_mask))
   59.12 @@ -157,6 +157,7 @@ swiotlb_init_with_default_size (size_t d
   59.13  	io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
   59.14  
   59.15  	iotlb_bus_start = virt_to_bus(iotlb_virt_start);
   59.16 +	iotlb_bus_end   = iotlb_bus_start + bytes;
   59.17  	iotlb_bus_mask  = ~(dma_addr_t)(bytes - 1);
   59.18  
   59.19  	printk(KERN_INFO "Software IO TLB enabled: \n"
   59.20 @@ -165,7 +166,7 @@ swiotlb_init_with_default_size (size_t d
   59.21  	       " Kernel range: 0x%016lx - 0x%016lx\n",
   59.22  	       bytes >> 20,
   59.23  	       (unsigned long)iotlb_bus_start,
   59.24 -	       (unsigned long)iotlb_bus_start + bytes,
   59.25 +	       (unsigned long)iotlb_bus_end,
   59.26  	       (unsigned long)iotlb_virt_start,
   59.27  	       (unsigned long)iotlb_virt_start + bytes);
   59.28  }
   59.29 @@ -181,7 +182,7 @@ swiotlb_init(void)
   59.30           * Otherwise, enable for domain 0 if the machine has 'lots of memory',
   59.31           * which we take to mean more than 2GB.
   59.32           */
   59.33 -	if (xen_start_info.flags & SIF_INITDOMAIN) {
   59.34 +	if (xen_start_info->flags & SIF_INITDOMAIN) {
   59.35  		dom0_op_t op;
   59.36  		op.cmd = DOM0_PHYSINFO;
   59.37  		if ((HYPERVISOR_dom0_op(&op) == 0) &&
   59.38 @@ -191,6 +192,8 @@ swiotlb_init(void)
   59.39  
   59.40  	if (swiotlb)
   59.41  		swiotlb_init_with_default_size(64 * (1<<20));
   59.42 +	else
   59.43 +		printk(KERN_INFO "Software IO TLB disabled\n");
   59.44  }
   59.45  
   59.46  static void
   59.47 @@ -424,13 +427,6 @@ swiotlb_map_single(struct device *hwdev,
   59.48  	}
   59.49  
   59.50  	dev_addr = virt_to_bus(map);
   59.51 -
   59.52 -	/*
   59.53 -	 * Ensure that the address returned is DMA'ble
   59.54 -	 */
   59.55 -	if (address_needs_mapping(hwdev, dev_addr))
   59.56 -		panic("map_single: bounce buffer is not DMA'ble");
   59.57 -
   59.58  	return dev_addr;
   59.59  }
   59.60  
   59.61 @@ -632,7 +628,7 @@ swiotlb_dma_mapping_error(dma_addr_t dma
   59.62  int
   59.63  swiotlb_dma_supported (struct device *hwdev, u64 mask)
   59.64  {
   59.65 -	return (mask >= 0xffffffffUL);
   59.66 +	return (mask >= (iotlb_bus_end - 1));
   59.67  }
   59.68  
   59.69  EXPORT_SYMBOL(swiotlb_init);
    60.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Thu Sep 08 09:18:40 2005 -0600
    60.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/time.c	Fri Sep 09 10:30:54 2005 -0600
    60.3 @@ -445,7 +445,7 @@ int do_settimeofday(struct timespec *tv)
    60.4  	sec = tv->tv_sec;
    60.5  	__normalize_time(&sec, &nsec);
    60.6  
    60.7 -	if ((xen_start_info.flags & SIF_INITDOMAIN) &&
    60.8 +	if ((xen_start_info->flags & SIF_INITDOMAIN) &&
    60.9  	    !independent_wallclock) {
   60.10  		op.cmd = DOM0_SETTIME;
   60.11  		op.u.settime.secs        = sec;
   60.12 @@ -476,7 +476,7 @@ static int set_rtc_mmss(unsigned long no
   60.13  
   60.14  	WARN_ON(irqs_disabled());
   60.15  
   60.16 -	if (!(xen_start_info.flags & SIF_INITDOMAIN))
   60.17 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
   60.18  		return 0;
   60.19  
   60.20  	/* gets recalled with irq locally disabled */
    61.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Thu Sep 08 09:18:40 2005 -0600
    61.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Fri Sep 09 10:30:54 2005 -0600
    61.3 @@ -449,10 +449,10 @@ DO_ERROR(10, SIGSEGV, "invalid TSS", inv
    61.4  DO_ERROR(11, SIGBUS,  "segment not present", segment_not_present)
    61.5  DO_ERROR(12, SIGBUS,  "stack segment", stack_segment)
    61.6  DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
    61.7 -DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
    61.8  #ifdef CONFIG_X86_MCE
    61.9  DO_ERROR(18, SIGBUS, "machine check", machine_check)
   61.10  #endif
   61.11 +DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
   61.12  
   61.13  fastcall void do_general_protection(struct pt_regs * regs, long error_code)
   61.14  {
    62.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c	Thu Sep 08 09:18:40 2005 -0600
    62.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/fault.c	Fri Sep 09 10:30:54 2005 -0600
    62.3 @@ -588,7 +588,15 @@ vmalloc_fault:
    62.4  		pmd_k = pmd_offset(pud_k, address);
    62.5  		if (!pmd_present(*pmd_k))
    62.6  			goto no_context;
    62.7 +#ifndef CONFIG_XEN
    62.8  		set_pmd(pmd, *pmd_k);
    62.9 +#else
   62.10 +		/*
   62.11 +		 * When running on Xen we must launder *pmd_k through
   62.12 +		 * pmd_val() to ensure that _PAGE_PRESENT is correctly set.
   62.13 +		 */
   62.14 +		set_pmd(pmd, __pmd(pmd_val(*pmd_k)));
   62.15 +#endif
   62.16  
   62.17  		pte_k = pte_offset_kernel(pmd_k, address);
   62.18  		if (!pte_present(*pte_k))
    63.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Sep 08 09:18:40 2005 -0600
    63.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c	Fri Sep 09 10:30:54 2005 -0600
    63.3 @@ -35,6 +35,7 @@
    63.4  #include <asm/pgtable.h>
    63.5  #include <asm-xen/hypervisor.h>
    63.6  #include <asm-xen/balloon.h>
    63.7 +#include <asm-xen/xen-public/memory.h>
    63.8  #include <linux/module.h>
    63.9  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   63.10  #include <linux/percpu.h>
   63.11 @@ -105,7 +106,7 @@ void xen_l4_entry_update(pgd_t *ptr, pgd
   63.12  void xen_machphys_update(unsigned long mfn, unsigned long pfn)
   63.13  {
   63.14  	mmu_update_t u;
   63.15 -	u.ptr = (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
   63.16 +	u.ptr = ((unsigned long long)mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
   63.17  	u.val = pfn;
   63.18  	BUG_ON(HYPERVISOR_mmu_update(&u, 1, NULL, DOMID_SELF) < 0);
   63.19  }
   63.20 @@ -320,6 +321,12 @@ void xen_create_contiguous_region(unsign
   63.21  	pmd_t         *pmd;
   63.22  	pte_t         *pte;
   63.23  	unsigned long  mfn, i, flags;
   63.24 +	struct xen_memory_reservation reservation = {
   63.25 +		.extent_start = &mfn,
   63.26 +		.nr_extents   = 1,
   63.27 +		.extent_order = 0,
   63.28 +		.domid        = DOMID_SELF
   63.29 +	};
   63.30  
   63.31  	scrub_pages(vstart, 1 << order);
   63.32  
   63.33 @@ -336,13 +343,15 @@ void xen_create_contiguous_region(unsign
   63.34  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
   63.35  		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
   63.36  			INVALID_P2M_ENTRY;
   63.37 -		BUG_ON(HYPERVISOR_dom_mem_op(
   63.38 -			MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
   63.39 +		BUG_ON(HYPERVISOR_memory_op(
   63.40 +			XENMEM_decrease_reservation, &reservation) != 1);
   63.41  	}
   63.42  
   63.43  	/* 2. Get a new contiguous memory extent. */
   63.44 -	BUG_ON(HYPERVISOR_dom_mem_op(
   63.45 -		MEMOP_increase_reservation, &mfn, 1, order | (32<<8)) != 1);
   63.46 +	reservation.extent_order = order;
   63.47 +	reservation.address_bits = 31; /* aacraid limitation */
   63.48 +	BUG_ON(HYPERVISOR_memory_op(
   63.49 +		XENMEM_increase_reservation, &reservation) != 1);
   63.50  
   63.51  	/* 3. Map the new extent in place of old pages. */
   63.52  	for (i = 0; i < (1<<order); i++) {
   63.53 @@ -367,6 +376,12 @@ void xen_destroy_contiguous_region(unsig
   63.54  	pmd_t         *pmd;
   63.55  	pte_t         *pte;
   63.56  	unsigned long  mfn, i, flags;
   63.57 +	struct xen_memory_reservation reservation = {
   63.58 +		.extent_start = &mfn,
   63.59 +		.nr_extents   = 1,
   63.60 +		.extent_order = 0,
   63.61 +		.domid        = DOMID_SELF
   63.62 +	};
   63.63  
   63.64  	scrub_pages(vstart, 1 << order);
   63.65  
   63.66 @@ -385,14 +400,14 @@ void xen_destroy_contiguous_region(unsig
   63.67  			vstart + (i*PAGE_SIZE), __pte_ma(0), 0));
   63.68  		phys_to_machine_mapping[(__pa(vstart)>>PAGE_SHIFT)+i] =
   63.69  			INVALID_P2M_ENTRY;
   63.70 -		BUG_ON(HYPERVISOR_dom_mem_op(
   63.71 -			MEMOP_decrease_reservation, &mfn, 1, 0) != 1);
   63.72 +		BUG_ON(HYPERVISOR_memory_op(
   63.73 +			XENMEM_decrease_reservation, &reservation) != 1);
   63.74  	}
   63.75  
   63.76  	/* 2. Map new pages in place of old pages. */
   63.77  	for (i = 0; i < (1<<order); i++) {
   63.78 -		BUG_ON(HYPERVISOR_dom_mem_op(
   63.79 -			MEMOP_increase_reservation, &mfn, 1, 0) != 1);
   63.80 +		BUG_ON(HYPERVISOR_memory_op(
   63.81 +			XENMEM_increase_reservation, &reservation) != 1);
   63.82  		BUG_ON(HYPERVISOR_update_va_mapping(
   63.83  			vstart + (i*PAGE_SIZE),
   63.84  			pfn_pte_ma(mfn, PAGE_KERNEL), 0));
    64.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Thu Sep 08 09:18:40 2005 -0600
    64.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Fri Sep 09 10:30:54 2005 -0600
    64.3 @@ -159,7 +159,7 @@ static void __init kernel_physical_mappi
    64.4  	pte_t *pte;
    64.5  	int pgd_idx, pmd_idx, pte_ofs;
    64.6  
    64.7 -	unsigned long max_ram_pfn = xen_start_info.nr_pages;
    64.8 +	unsigned long max_ram_pfn = xen_start_info->nr_pages;
    64.9  	if (max_ram_pfn > max_low_pfn)
   64.10  		max_ram_pfn = max_low_pfn;
   64.11  
   64.12 @@ -219,6 +219,8 @@ static void __init kernel_physical_mappi
   64.13  	}
   64.14  }
   64.15  
   64.16 +#ifndef CONFIG_XEN
   64.17 +
   64.18  static inline int page_kills_ppro(unsigned long pagenr)
   64.19  {
   64.20  	if (pagenr >= 0x70000 && pagenr <= 0x7003F)
   64.21 @@ -266,6 +268,13 @@ static inline int page_is_ram(unsigned l
   64.22  	return 0;
   64.23  }
   64.24  
   64.25 +#else /* CONFIG_XEN */
   64.26 +
   64.27 +#define page_kills_ppro(p)	0
   64.28 +#define page_is_ram(p)		1
   64.29 +
   64.30 +#endif
   64.31 +
   64.32  #ifdef CONFIG_HIGHMEM
   64.33  pte_t *kmap_pte;
   64.34  pgprot_t kmap_prot;
   64.35 @@ -308,7 +317,7 @@ void __init one_highpage_init(struct pag
   64.36  		ClearPageReserved(page);
   64.37  		set_bit(PG_highmem, &page->flags);
   64.38  		set_page_count(page, 1);
   64.39 -		if (pfn < xen_start_info.nr_pages)
   64.40 +		if (pfn < xen_start_info->nr_pages)
   64.41  			__free_page(page);
   64.42  		totalhigh_pages++;
   64.43  	} else
   64.44 @@ -347,7 +356,7 @@ pgd_t *swapper_pg_dir;
   64.45  static void __init pagetable_init (void)
   64.46  {
   64.47  	unsigned long vaddr;
   64.48 -	pgd_t *pgd_base = (pgd_t *)xen_start_info.pt_base;
   64.49 +	pgd_t *pgd_base = (pgd_t *)xen_start_info->pt_base;
   64.50  	int i;
   64.51  
   64.52  	swapper_pg_dir = pgd_base;
   64.53 @@ -526,14 +535,14 @@ void __init paging_init(void)
   64.54  	kmap_init();
   64.55  
   64.56  	/* Switch to the real shared_info page, and clear the dummy page. */
   64.57 -	set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
   64.58 +	set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
   64.59  	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   64.60  	memset(empty_zero_page, 0, sizeof(empty_zero_page));
   64.61  
   64.62  #ifdef CONFIG_XEN_PHYSDEV_ACCESS
   64.63  	/* Setup mapping of lower 1st MB */
   64.64  	for (i = 0; i < NR_FIX_ISAMAPS; i++)
   64.65 -		if (xen_start_info.flags & SIF_PRIVILEGED)
   64.66 +		if (xen_start_info->flags & SIF_PRIVILEGED)
   64.67  			set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
   64.68  		else
   64.69  			__set_fixmap(FIX_ISAMAP_BEGIN - i,
   64.70 @@ -630,7 +639,7 @@ void __init mem_init(void)
   64.71  	/* this will put all low memory onto the freelists */
   64.72  	totalram_pages += free_all_bootmem();
   64.73  	/* XEN: init and count low-mem pages outside initial allocation. */
   64.74 -	for (pfn = xen_start_info.nr_pages; pfn < max_low_pfn; pfn++) {
   64.75 +	for (pfn = xen_start_info->nr_pages; pfn < max_low_pfn; pfn++) {
   64.76  		ClearPageReserved(&mem_map[pfn]);
   64.77  		set_page_count(&mem_map[pfn], 1);
   64.78  		totalram_pages++;
    65.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Thu Sep 08 09:18:40 2005 -0600
    65.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/ioremap.c	Fri Sep 09 10:30:54 2005 -0600
    65.3 @@ -19,37 +19,125 @@
    65.4  #include <asm/pgtable.h>
    65.5  #include <asm/pgalloc.h>
    65.6  
    65.7 -#ifndef CONFIG_XEN_PHYSDEV_ACCESS
    65.8 +#define ISA_START_ADDRESS	0x0
    65.9 +#define ISA_END_ADDRESS		0x100000
   65.10  
   65.11 -void * __ioremap(unsigned long phys_addr, unsigned long size,
   65.12 -		 unsigned long flags)
   65.13 +#if 0 /* not PAE safe */
   65.14 +/* These hacky macros avoid phys->machine translations. */
   65.15 +#define __direct_pte(x) ((pte_t) { (x) } )
   65.16 +#define __direct_mk_pte(page_nr,pgprot) \
   65.17 +  __direct_pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
   65.18 +#define direct_mk_pte_phys(physpage, pgprot) \
   65.19 +  __direct_mk_pte((physpage) >> PAGE_SHIFT, pgprot)
   65.20 +#endif
   65.21 +
   65.22 +static int direct_remap_area_pte_fn(pte_t *pte, 
   65.23 +				    struct page *pte_page,
   65.24 +				    unsigned long address, 
   65.25 +				    void *data)
   65.26  {
   65.27 -	return NULL;
   65.28 -}
   65.29 +	mmu_update_t **v = (mmu_update_t **)data;
   65.30  
   65.31 -void *ioremap_nocache (unsigned long phys_addr, unsigned long size)
   65.32 -{
   65.33 -	return NULL;
   65.34 +	(*v)->ptr = ((u64)pfn_to_mfn(page_to_pfn(pte_page)) <<
   65.35 +		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
   65.36 +	(*v)++;
   65.37 +
   65.38 +	return 0;
   65.39  }
   65.40  
   65.41 -void iounmap(volatile void __iomem *addr)
   65.42 +int direct_remap_pfn_range(struct mm_struct *mm,
   65.43 +			    unsigned long address, 
   65.44 +			    unsigned long mfn,
   65.45 +			    unsigned long size, 
   65.46 +			    pgprot_t prot,
   65.47 +			    domid_t  domid)
   65.48  {
   65.49 +	int i;
   65.50 +	unsigned long start_address;
   65.51 +#define MAX_DIRECTMAP_MMU_QUEUE 130
   65.52 +	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *v = u, *w = u;
   65.53 +
   65.54 +	start_address = address;
   65.55 +
   65.56 +	flush_cache_all();
   65.57 +
   65.58 +	for (i = 0; i < size; i += PAGE_SIZE) {
   65.59 +		if ((v - u) == MAX_DIRECTMAP_MMU_QUEUE) {
   65.60 +			/* Fill in the PTE pointers. */
   65.61 +			generic_page_range(mm, start_address, 
   65.62 +					   address - start_address,
   65.63 +					   direct_remap_area_pte_fn, &w);
   65.64 +			w = u;
   65.65 +			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
   65.66 +				return -EFAULT;
   65.67 +			v = u;
   65.68 +			start_address = address;
   65.69 +		}
   65.70 +
   65.71 +		/*
   65.72 +		 * Fill in the machine address: PTE ptr is done later by
   65.73 +		 * __direct_remap_area_pages(). 
   65.74 +		 */
   65.75 +		v->val = pte_val_ma(pfn_pte_ma(mfn, prot));
   65.76 +
   65.77 +		mfn++;
   65.78 +		address += PAGE_SIZE; 
   65.79 +		v++;
   65.80 +	}
   65.81 +
   65.82 +	if (v != u) {
   65.83 +		/* get the ptep's filled in */
   65.84 +		generic_page_range(mm, start_address, address - start_address,
   65.85 +				   direct_remap_area_pte_fn, &w);
   65.86 +		if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0))
   65.87 +			return -EFAULT;
   65.88 +	}
   65.89 +
   65.90 +	flush_tlb_all();
   65.91 +
   65.92 +	return 0;
   65.93  }
   65.94  
   65.95 -#ifdef __i386__
   65.96 +EXPORT_SYMBOL(direct_remap_pfn_range);
   65.97  
   65.98 -void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
   65.99 +
  65.100 +/* FIXME: This is horribly broken on PAE */ 
  65.101 +static int lookup_pte_fn(
  65.102 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
  65.103  {
  65.104 -	return NULL;
  65.105 +	unsigned long *ptep = (unsigned long *)data;
  65.106 +	if (ptep)
  65.107 +		*ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
  65.108 +			 PAGE_SHIFT) |
  65.109 +			((unsigned long)pte & ~PAGE_MASK);
  65.110 +	return 0;
  65.111  }
  65.112  
  65.113 -void __init bt_iounmap(void *addr, unsigned long size)
  65.114 +int create_lookup_pte_addr(struct mm_struct *mm, 
  65.115 +			   unsigned long address,
  65.116 +			   unsigned long *ptep)
  65.117  {
  65.118 +	return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
  65.119  }
  65.120  
  65.121 -#endif /* __i386__ */
  65.122 +EXPORT_SYMBOL(create_lookup_pte_addr);
  65.123  
  65.124 -#else
  65.125 +static int noop_fn(
  65.126 +	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
  65.127 +{
  65.128 +	return 0;
  65.129 +}
  65.130 +
  65.131 +int touch_pte_range(struct mm_struct *mm,
  65.132 +		    unsigned long address,
  65.133 +		    unsigned long size)
  65.134 +{
  65.135 +	return generic_page_range(mm, address, size, noop_fn, NULL);
  65.136 +} 
  65.137 +
  65.138 +EXPORT_SYMBOL(touch_pte_range);
  65.139 +
  65.140 +#ifdef CONFIG_XEN_PHYSDEV_ACCESS
  65.141  
  65.142  /*
  65.143   * Does @address reside within a non-highmem page that is local to this virtual
  65.144 @@ -90,13 +178,12 @@ void __iomem * __ioremap(unsigned long p
  65.145  	if (!size || last_addr < phys_addr)
  65.146  		return NULL;
  65.147  
  65.148 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
  65.149  	/*
  65.150  	 * Don't remap the low PCI/ISA area, it's always mapped..
  65.151  	 */
  65.152 -	if (phys_addr >= 0x0 && last_addr < 0x100000)
  65.153 -		return isa_bus_to_virt(phys_addr);
  65.154 -#endif
  65.155 +	if (xen_start_info->flags & SIF_PRIVILEGED &&
  65.156 +	    phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
  65.157 +		return (void __iomem *) isa_bus_to_virt(phys_addr);
  65.158  
  65.159  	/*
  65.160  	 * Don't allow anybody to remap normal RAM that we're using..
  65.161 @@ -134,7 +221,7 @@ void __iomem * __ioremap(unsigned long p
  65.162  #ifdef __x86_64__
  65.163  	flags |= _PAGE_USER;
  65.164  #endif
  65.165 -	if (direct_remap_area_pages(&init_mm, (unsigned long) addr, phys_addr,
  65.166 +	if (direct_remap_pfn_range(&init_mm, (unsigned long) addr, phys_addr>>PAGE_SHIFT,
  65.167  				    size, __pgprot(flags), domid)) {
  65.168  		vunmap((void __force *) addr);
  65.169  		return NULL;
  65.170 @@ -203,24 +290,32 @@ void iounmap(volatile void __iomem *addr
  65.171  {
  65.172  	struct vm_struct *p;
  65.173  	if ((void __force *) addr <= high_memory) 
  65.174 -		return; 
  65.175 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
  65.176 +		return;
  65.177 +
  65.178 +	/*
  65.179 +	 * __ioremap special-cases the PCI/ISA range by not instantiating a
  65.180 +	 * vm_area and by simply returning an address into the kernel mapping
  65.181 +	 * of ISA space.   So handle that here.
  65.182 +	 */
  65.183  	if ((unsigned long) addr >= fix_to_virt(FIX_ISAMAP_BEGIN))
  65.184  		return;
  65.185 -#endif
  65.186 -	p = remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
  65.187 +
  65.188 +	write_lock(&vmlist_lock);
  65.189 +	p = __remove_vm_area((void *) (PAGE_MASK & (unsigned long __force) addr));
  65.190  	if (!p) { 
  65.191 -		printk("__iounmap: bad address %p\n", addr);
  65.192 -		return;
  65.193 +		printk("iounmap: bad address %p\n", addr);
  65.194 +		goto out_unlock;
  65.195  	}
  65.196  
  65.197  	if ((p->flags >> 20) && is_local_lowmem(p->phys_addr)) {
  65.198  		/* p->size includes the guard page, but cpa doesn't like that */
  65.199  		change_page_attr(virt_to_page(bus_to_virt(p->phys_addr)),
  65.200  				 (p->size - PAGE_SIZE) >> PAGE_SHIFT,
  65.201 -				 PAGE_KERNEL); 				 
  65.202 +				 PAGE_KERNEL);
  65.203  		global_flush_tlb();
  65.204  	} 
  65.205 +out_unlock:
  65.206 +	write_unlock(&vmlist_lock);
  65.207  	kfree(p); 
  65.208  }
  65.209  
  65.210 @@ -237,13 +332,12 @@ void __init *bt_ioremap(unsigned long ph
  65.211  	if (!size || last_addr < phys_addr)
  65.212  		return NULL;
  65.213  
  65.214 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
  65.215  	/*
  65.216  	 * Don't remap the low PCI/ISA area, it's always mapped..
  65.217  	 */
  65.218 -	if (phys_addr >= 0x0 && last_addr < 0x100000)
  65.219 +	if (xen_start_info->flags & SIF_PRIVILEGED &&
  65.220 +	    phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
  65.221  		return isa_bus_to_virt(phys_addr);
  65.222 -#endif
  65.223  
  65.224  	/*
  65.225  	 * Mappings have to be page-aligned
  65.226 @@ -282,10 +376,8 @@ void __init bt_iounmap(void *addr, unsig
  65.227  	virt_addr = (unsigned long)addr;
  65.228  	if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN))
  65.229  		return;
  65.230 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
  65.231  	if (virt_addr >= fix_to_virt(FIX_ISAMAP_BEGIN))
  65.232  		return;
  65.233 -#endif
  65.234  	offset = virt_addr & ~PAGE_MASK;
  65.235  	nrpages = PAGE_ALIGN(offset + size - 1) >> PAGE_SHIFT;
  65.236  
  65.237 @@ -299,119 +391,37 @@ void __init bt_iounmap(void *addr, unsig
  65.238  
  65.239  #endif /* __i386__ */
  65.240  
  65.241 -#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
  65.242 -
  65.243 -/* These hacky macros avoid phys->machine translations. */
  65.244 -#define __direct_pte(x) ((pte_t) { (x) } )
  65.245 -#define __direct_mk_pte(page_nr,pgprot) \
  65.246 -  __direct_pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
  65.247 -#define direct_mk_pte_phys(physpage, pgprot) \
  65.248 -  __direct_mk_pte((physpage) >> PAGE_SHIFT, pgprot)
  65.249 -
  65.250 +#else /* CONFIG_XEN_PHYSDEV_ACCESS */
  65.251  
  65.252 -static int direct_remap_area_pte_fn(pte_t *pte, 
  65.253 -				    struct page *pte_page,
  65.254 -				    unsigned long address, 
  65.255 -				    void *data)
  65.256 +void __iomem * __ioremap(unsigned long phys_addr, unsigned long size,
  65.257 +			 unsigned long flags)
  65.258  {
  65.259 -	mmu_update_t **v = (mmu_update_t **)data;
  65.260 -
  65.261 -	(*v)->ptr = ((maddr_t)pfn_to_mfn(page_to_pfn(pte_page)) <<
  65.262 -		     PAGE_SHIFT) | ((unsigned long)pte & ~PAGE_MASK);
  65.263 -	(*v)++;
  65.264 -
  65.265 -	return 0;
  65.266 +	return NULL;
  65.267  }
  65.268  
  65.269 -int direct_remap_area_pages(struct mm_struct *mm,
  65.270 -			    unsigned long address, 
  65.271 -			    unsigned long machine_addr,
  65.272 -			    unsigned long size, 
  65.273 -			    pgprot_t prot,
  65.274 -			    domid_t  domid)
  65.275 +void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
  65.276  {
  65.277 -	int i;
  65.278 -	unsigned long start_address;
  65.279 -#define MAX_DIRECTMAP_MMU_QUEUE 130
  65.280 -	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *v = u, *w = u;
  65.281 -
  65.282 -	start_address = address;
  65.283 -
  65.284 -	flush_cache_all();
  65.285 -
  65.286 -	for (i = 0; i < size; i += PAGE_SIZE) {
  65.287 -		if ((v - u) == MAX_DIRECTMAP_MMU_QUEUE) {
  65.288 -			/* Fill in the PTE pointers. */
  65.289 -			generic_page_range(mm, start_address, 
  65.290 -					   address - start_address,
  65.291 -					   direct_remap_area_pte_fn, &w);
  65.292 -			w = u;
  65.293 -			if (HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)
  65.294 -				return -EFAULT;
  65.295 -			v = u;
  65.296 -			start_address = address;
  65.297 -		}
  65.298 -
  65.299 -		/*
  65.300 -		 * Fill in the machine address: PTE ptr is done later by
  65.301 -		 * __direct_remap_area_pages(). 
  65.302 -		 */
  65.303 -		v->val = pte_val_ma(pfn_pte_ma(machine_addr >> PAGE_SHIFT, prot));
  65.304 -
  65.305 -		machine_addr += PAGE_SIZE;
  65.306 -		address += PAGE_SIZE; 
  65.307 -		v++;
  65.308 -	}
  65.309 -
  65.310 -	if (v != u) {
  65.311 -		/* get the ptep's filled in */
  65.312 -		generic_page_range(mm, start_address, address - start_address,
  65.313 -				   direct_remap_area_pte_fn, &w);
  65.314 -		if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0))
  65.315 -			return -EFAULT;
  65.316 -	}
  65.317 -
  65.318 -	flush_tlb_all();
  65.319 -
  65.320 -	return 0;
  65.321 +	return NULL;
  65.322  }
  65.323  
  65.324 -EXPORT_SYMBOL(direct_remap_area_pages);
  65.325 -
  65.326 -static int lookup_pte_fn(
  65.327 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
  65.328 +void iounmap(volatile void __iomem *addr)
  65.329  {
  65.330 -	unsigned long *ptep = (unsigned long *)data;
  65.331 -	if (ptep)
  65.332 -		*ptep = (pfn_to_mfn(page_to_pfn(pte_page)) <<
  65.333 -			 PAGE_SHIFT) |
  65.334 -			((unsigned long)pte & ~PAGE_MASK);
  65.335 -	return 0;
  65.336  }
  65.337  
  65.338 -int create_lookup_pte_addr(struct mm_struct *mm, 
  65.339 -			   unsigned long address,
  65.340 -			   unsigned long *ptep)
  65.341 +#ifdef __i386__
  65.342 +
  65.343 +void __init *bt_ioremap(unsigned long phys_addr, unsigned long size)
  65.344  {
  65.345 -	return generic_page_range(mm, address, PAGE_SIZE, lookup_pte_fn, ptep);
  65.346 +	return NULL;
  65.347  }
  65.348  
  65.349 -EXPORT_SYMBOL(create_lookup_pte_addr);
  65.350 -
  65.351 -static int noop_fn(
  65.352 -	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
  65.353 +void __init bt_iounmap(void *addr, unsigned long size)
  65.354  {
  65.355 -	return 0;
  65.356  }
  65.357  
  65.358 -int touch_pte_range(struct mm_struct *mm,
  65.359 -		    unsigned long address,
  65.360 -		    unsigned long size)
  65.361 -{
  65.362 -	return generic_page_range(mm, address, size, noop_fn, NULL);
  65.363 -} 
  65.364 +#endif /* __i386__ */
  65.365  
  65.366 -EXPORT_SYMBOL(touch_pte_range);
  65.367 +#endif /* CONFIG_XEN_PHYSDEV_ACCESS */
  65.368  
  65.369  /*
  65.370   * Local variables:
    66.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile	Thu Sep 08 09:18:40 2005 -0600
    66.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile	Fri Sep 09 10:30:54 2005 -0600
    66.3 @@ -4,7 +4,7 @@ CFLAGS	+= -Iarch/$(XENARCH)/pci
    66.4  
    66.5  c-obj-y				:= i386.o
    66.6  
    66.7 -c-obj-$(CONFIG_PCI_BIOS)		+= pcbios.o
    66.8 +#c-obj-$(CONFIG_PCI_BIOS)		+= pcbios.o
    66.9  c-obj-$(CONFIG_PCI_MMCONFIG)	+= mmconfig.o
   66.10  c-obj-$(CONFIG_PCI_DIRECT)	+= direct.o
   66.11  
    67.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/Makefile	Thu Sep 08 09:18:40 2005 -0600
    67.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/Makefile	Fri Sep 09 10:30:54 2005 -0600
    67.3 @@ -11,7 +11,7 @@ CPPFLAGS_vmlinux.lds += -U$(XENARCH)
    67.4  
    67.5  extra-y += vmlinux.lds
    67.6  
    67.7 -obj-y   := ctrl_if.o evtchn.o fixup.o reboot.o gnttab.o devmem.o
    67.8 +obj-y   := evtchn.o fixup.o reboot.o gnttab.o devmem.o
    67.9  
   67.10  obj-$(CONFIG_PROC_FS) += xen_proc.o
   67.11  obj-$(CONFIG_NET)     += skbuff.o
    68.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/ctrl_if.c	Thu Sep 08 09:18:40 2005 -0600
    68.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.3 @@ -1,569 +0,0 @@
    68.4 -/******************************************************************************
    68.5 - * ctrl_if.c
    68.6 - * 
    68.7 - * Management functions for special interface to the domain controller.
    68.8 - * 
    68.9 - * Copyright (c) 2004, K A Fraser
   68.10 - * 
   68.11 - * This file may be distributed separately from the Linux kernel, or
   68.12 - * incorporated into other software packages, subject to the following license:
   68.13 - * 
   68.14 - * Permission is hereby granted, free of charge, to any person obtaining a copy
   68.15 - * of this source file (the "Software"), to deal in the Software without
   68.16 - * restriction, including without limitation the rights to use, copy, modify,
   68.17 - * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   68.18 - * and to permit persons to whom the Software is furnished to do so, subject to
   68.19 - * the following conditions:
   68.20 - * 
   68.21 - * The above copyright notice and this permission notice shall be included in
   68.22 - * all copies or substantial portions of the Software.
   68.23 - * 
   68.24 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   68.25 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   68.26 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   68.27 - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   68.28 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   68.29 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   68.30 - * IN THE SOFTWARE.
   68.31 - */
   68.32 -
   68.33 -#include <linux/config.h>
   68.34 -#include <linux/kernel.h>
   68.35 -#include <linux/sched.h>
   68.36 -#include <linux/slab.h>
   68.37 -#include <linux/string.h>
   68.38 -#include <linux/errno.h>
   68.39 -#include <linux/irq.h>
   68.40 -#include <linux/interrupt.h>
   68.41 -#include <linux/module.h>
   68.42 -#include <asm-xen/ctrl_if.h>
   68.43 -#include <asm-xen/evtchn.h>
   68.44 -
   68.45 -#if 0
   68.46 -#define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
   68.47 -                           __FILE__ , __LINE__ , ## _a )
   68.48 -#else
   68.49 -#define DPRINTK(_f, _a...) ((void)0)
   68.50 -#endif
   68.51 -
   68.52 -/*
   68.53 - * Extra ring macros to sync a consumer index up to the public producer index. 
   68.54 - * Generally UNSAFE, but we use it for recovery and shutdown in some cases.
   68.55 - */
   68.56 -#define RING_DROP_PENDING_REQUESTS(_r)                                  \
   68.57 -    do {                                                                \
   68.58 -        (_r)->req_cons = (_r)->sring->req_prod;                         \
   68.59 -    } while (0)
   68.60 -#define RING_DROP_PENDING_RESPONSES(_r)                                 \
   68.61 -    do {                                                                \
   68.62 -        (_r)->rsp_cons = (_r)->sring->rsp_prod;                         \
   68.63 -    } while (0)
   68.64 -
   68.65 -/*
   68.66 - * Only used by initial domain which must create its own control-interface
   68.67 - * event channel. This value is picked up by the user-space domain controller
   68.68 - * via an ioctl.
   68.69 - */
   68.70 -int initdom_ctrlif_domcontroller_port = -1;
   68.71 -
   68.72 -static int        ctrl_if_evtchn;
   68.73 -static int        ctrl_if_irq;
   68.74 -static spinlock_t ctrl_if_lock;
   68.75 -
   68.76 -static struct irqaction ctrl_if_irq_action;
   68.77 -
   68.78 -static ctrl_front_ring_t ctrl_if_tx_ring;
   68.79 -static ctrl_back_ring_t  ctrl_if_rx_ring;
   68.80 -
   68.81 -/* Incoming message requests. */
   68.82 -    /* Primary message type -> message handler. */
   68.83 -static ctrl_msg_handler_t ctrl_if_rxmsg_handler[256];
   68.84 -    /* Primary message type -> callback in process context? */
   68.85 -static unsigned long ctrl_if_rxmsg_blocking_context[256/sizeof(unsigned long)];
   68.86 -    /* Is it late enough during bootstrap to use schedule_task()? */
   68.87 -static int safe_to_schedule_task;
   68.88 -    /* Queue up messages to be handled in process context. */
   68.89 -static ctrl_msg_t ctrl_if_rxmsg_deferred[CONTROL_RING_SIZE];
   68.90 -static CONTROL_RING_IDX ctrl_if_rxmsg_deferred_prod;
   68.91 -static CONTROL_RING_IDX ctrl_if_rxmsg_deferred_cons;
   68.92 -
   68.93 -/* Incoming message responses: message identifier -> message handler/id. */
   68.94 -static struct {
   68.95 -    ctrl_msg_handler_t fn;
   68.96 -    unsigned long      id;
   68.97 -} ctrl_if_txmsg_id_mapping[CONTROL_RING_SIZE];
   68.98 -
   68.99 -/* For received messages that must be deferred to process context. */
  68.100 -static void __ctrl_if_rxmsg_deferred(void *unused);
  68.101 -static DECLARE_WORK(ctrl_if_rxmsg_deferred_work,
  68.102 -                    __ctrl_if_rxmsg_deferred,
  68.103 -                    NULL);
  68.104 -
  68.105 -/* Deferred callbacks for people waiting for space in the transmit ring. */
  68.106 -static DECLARE_TASK_QUEUE(ctrl_if_tx_tq);
  68.107 -
  68.108 -static DECLARE_WAIT_QUEUE_HEAD(ctrl_if_tx_wait);
  68.109 -static void __ctrl_if_tx_tasklet(unsigned long data);
  68.110 -static DECLARE_TASKLET(ctrl_if_tx_tasklet, __ctrl_if_tx_tasklet, 0);
  68.111 -
  68.112 -static void __ctrl_if_rx_tasklet(unsigned long data);
  68.113 -static DECLARE_TASKLET(ctrl_if_rx_tasklet, __ctrl_if_rx_tasklet, 0);
  68.114 -
  68.115 -#define get_ctrl_if() ((control_if_t *)((char *)HYPERVISOR_shared_info + 2048))
  68.116 -
  68.117 -static void ctrl_if_notify_controller(void)
  68.118 -{
  68.119 -    notify_via_evtchn(ctrl_if_evtchn);
  68.120 -}
  68.121 -
  68.122 -static void ctrl_if_rxmsg_default_handler(ctrl_msg_t *msg, unsigned long id)
  68.123 -{
  68.124 -    msg->length = 0;
  68.125 -    ctrl_if_send_response(msg);
  68.126 -}
  68.127 -
  68.128 -static void __ctrl_if_tx_tasklet(unsigned long data)
  68.129 -{
  68.130 -    ctrl_msg_t *msg;
  68.131 -    int         was_full = RING_FULL(&ctrl_if_tx_ring);
  68.132 -    RING_IDX    i, rp;
  68.133 -
  68.134 -    i  = ctrl_if_tx_ring.rsp_cons;
  68.135 -    rp = ctrl_if_tx_ring.sring->rsp_prod;
  68.136 -    rmb(); /* Ensure we see all requests up to 'rp'. */
  68.137 -
  68.138 -    for ( ; i != rp; i++ )
  68.139 -    {
  68.140 -        msg = RING_GET_RESPONSE(&ctrl_if_tx_ring, i);
  68.141 -        
  68.142 -        DPRINTK("Rx-Rsp %u/%u :: %d/%d\n", i-1,
  68.143 -                ctrl_if_tx_ring.sring->rsp_prod,
  68.144 -                msg->type, msg->subtype);
  68.145 -
  68.146 -        /* Execute the callback handler, if one was specified. */
  68.147 -        if ( msg->id != 0xFF )
  68.148 -        {
  68.149 -            (*ctrl_if_txmsg_id_mapping[msg->id].fn)(
  68.150 -                msg, ctrl_if_txmsg_id_mapping[msg->id].id);
  68.151 -            smp_mb(); /* Execute, /then/ free. */
  68.152 -            ctrl_if_txmsg_id_mapping[msg->id].fn = NULL;
  68.153 -        }
  68.154 -    }
  68.155 -
  68.156 -    /*
  68.157 -     * Step over messages in the ring /after/ finishing reading them. As soon 
  68.158 -     * as the index is updated then the message may get blown away.
  68.159 -     */
  68.160 -    smp_mb();
  68.161 -    ctrl_if_tx_ring.rsp_cons = i;
  68.162 -            
  68.163 -    if ( was_full && !RING_FULL(&ctrl_if_tx_ring) )
  68.164 -    {
  68.165 -        wake_up(&ctrl_if_tx_wait);
  68.166 -        run_task_queue(&ctrl_if_tx_tq);
  68.167 -    }
  68.168 -}
  68.169 -
  68.170 -static void __ctrl_if_rxmsg_deferred(void *unused)
  68.171 -{
  68.172 -    ctrl_msg_t *msg;
  68.173 -    CONTROL_RING_IDX dp;
  68.174 -
  68.175 -    dp = ctrl_if_rxmsg_deferred_prod;
  68.176 -    rmb(); /* Ensure we see all deferred requests up to 'dp'. */
  68.177 -
  68.178 -    while ( ctrl_if_rxmsg_deferred_cons != dp )
  68.179 -    {
  68.180 -        msg = &ctrl_if_rxmsg_deferred[MASK_CONTROL_IDX(
  68.181 -            ctrl_if_rxmsg_deferred_cons++)];
  68.182 -        (*ctrl_if_rxmsg_handler[msg->type])(msg, 0);
  68.183 -    }
  68.184 -}
  68.185 -
  68.186 -static void __ctrl_if_rx_tasklet(unsigned long data)
  68.187 -{
  68.188 -    ctrl_msg_t    msg, *pmsg;
  68.189 -    CONTROL_RING_IDX dp;
  68.190 -    RING_IDX rp, i;
  68.191 -
  68.192 -    i  = ctrl_if_rx_ring.req_cons;
  68.193 -    rp = ctrl_if_rx_ring.sring->req_prod;
  68.194 -    dp = ctrl_if_rxmsg_deferred_prod;
  68.195 -    rmb(); /* Ensure we see all requests up to 'rp'. */
  68.196 - 
  68.197 -    for ( ; i != rp; i++) 
  68.198 -    {
  68.199 -        pmsg = RING_GET_REQUEST(&ctrl_if_rx_ring, i);
  68.200 -        memcpy(&msg, pmsg, offsetof(ctrl_msg_t, msg));
  68.201 -
  68.202 -        DPRINTK("Rx-Req %u/%u :: %d/%d\n", i-1,
  68.203 -                ctrl_if_rx_ring.sring->req_prod,
  68.204 -                msg.type, msg.subtype);
  68.205 -
  68.206 -        if ( msg.length > sizeof(msg.msg) )
  68.207 -            msg.length = sizeof(msg.msg);
  68.208 -        
  68.209 -        if ( msg.length != 0 )
  68.210 -            memcpy(msg.msg, pmsg->msg, msg.length);
  68.211 -
  68.212 -        if ( test_bit(msg.type, 
  68.213 -                      (unsigned long *)&ctrl_if_rxmsg_blocking_context) )
  68.214 -            memcpy(&ctrl_if_rxmsg_deferred[MASK_CONTROL_IDX(dp++)],
  68.215 -                   &msg, offsetof(ctrl_msg_t, msg) + msg.length);
  68.216 -        else
  68.217 -            (*ctrl_if_rxmsg_handler[msg.type])(&msg, 0);
  68.218 -    }
  68.219 -
  68.220 -    ctrl_if_rx_ring.req_cons = i;
  68.221 -
  68.222 -    if ( dp != ctrl_if_rxmsg_deferred_prod )
  68.223 -    {
  68.224 -        wmb();
  68.225 -        ctrl_if_rxmsg_deferred_prod = dp;
  68.226 -        schedule_work(&ctrl_if_rxmsg_deferred_work);
  68.227 -    }
  68.228 -}
  68.229 -
  68.230 -static irqreturn_t ctrl_if_interrupt(int irq, void *dev_id,
  68.231 -                                     struct pt_regs *regs)
  68.232 -{
  68.233 -    if ( RING_HAS_UNCONSUMED_RESPONSES(&ctrl_if_tx_ring) )
  68.234 -        tasklet_schedule(&ctrl_if_tx_tasklet);
  68.235 -
  68.236 -    if ( RING_HAS_UNCONSUMED_REQUESTS(&ctrl_if_rx_ring) )
  68.237 -        tasklet_schedule(&ctrl_if_rx_tasklet);
  68.238 -
  68.239 -    return IRQ_HANDLED;
  68.240 -}
  68.241 -
  68.242 -int
  68.243 -ctrl_if_send_message_noblock(
  68.244 -    ctrl_msg_t *msg, 
  68.245 -    ctrl_msg_handler_t hnd,
  68.246 -    unsigned long id)
  68.247 -{
  68.248 -    unsigned long flags;
  68.249 -    ctrl_msg_t   *dmsg;
  68.250 -    int           i;
  68.251 -
  68.252 -    spin_lock_irqsave(&ctrl_if_lock, flags);
  68.253 -
  68.254 -    if ( RING_FULL(&ctrl_if_tx_ring) )
  68.255 -    {
  68.256 -        spin_unlock_irqrestore(&ctrl_if_lock, flags);
  68.257 -        return -EAGAIN;
  68.258 -    }
  68.259 -
  68.260 -    msg->id = 0xFF;
  68.261 -    if ( hnd != NULL )
  68.262 -    {
  68.263 -        for ( i = 0; ctrl_if_txmsg_id_mapping[i].fn != NULL; i++ )
  68.264 -            continue;
  68.265 -        ctrl_if_txmsg_id_mapping[i].fn = hnd;
  68.266 -        ctrl_if_txmsg_id_mapping[i].id = id;
  68.267 -        msg->id = i;
  68.268 -    }
  68.269 -
  68.270 -    DPRINTK("Tx-Req %u/%u :: %d/%d\n", 
  68.271 -            ctrl_if_tx_ring.req_prod_pvt, 
  68.272 -            ctrl_if_tx_ring.rsp_cons,
  68.273 -            msg->type, msg->subtype);
  68.274 -
  68.275 -    dmsg = RING_GET_REQUEST(&ctrl_if_tx_ring, 
  68.276 -            ctrl_if_tx_ring.req_prod_pvt);
  68.277 -    memcpy(dmsg, msg, sizeof(*msg));
  68.278 -    ctrl_if_tx_ring.req_prod_pvt++;
  68.279 -    RING_PUSH_REQUESTS(&ctrl_if_tx_ring);
  68.280 -
  68.281 -    spin_unlock_irqrestore(&ctrl_if_lock, flags);
  68.282 -
  68.283 -    ctrl_if_notify_controller();
  68.284 -
  68.285 -    return 0;
  68.286 -}
  68.287 -
  68.288 -int
  68.289 -ctrl_if_send_message_block(
  68.290 -    ctrl_msg_t *msg, 
  68.291 -    ctrl_msg_handler_t hnd, 
  68.292 -    unsigned long id,
  68.293 -    long wait_state)
  68.294 -{
  68.295 -    DECLARE_WAITQUEUE(wait, current);
  68.296 -    int rc;
  68.297 -
  68.298 -    /* Fast path. */
  68.299 -    if ( (rc = ctrl_if_send_message_noblock(msg, hnd, id)) != -EAGAIN )
  68.300 -        return rc;
  68.301 -
  68.302 -    add_wait_queue(&ctrl_if_tx_wait, &wait);
  68.303 -
  68.304 -    for ( ; ; )
  68.305 -    {
  68.306 -        set_current_state(wait_state);
  68.307 -
  68.308 -        if ( (rc = ctrl_if_send_message_noblock(msg, hnd, id)) != -EAGAIN )
  68.309 -            break;
  68.310 -
  68.311 -        rc = -ERESTARTSYS;
  68.312 -        if ( signal_pending(current) && (wait_state == TASK_INTERRUPTIBLE) )
  68.313 -            break;
  68.314 -
  68.315 -        schedule();
  68.316 -    }
  68.317 -
  68.318 -    set_current_state(TASK_RUNNING);
  68.319 -    remove_wait_queue(&ctrl_if_tx_wait, &wait);
  68.320 -
  68.321 -    return rc;
  68.322 -}
  68.323 -
  68.324 -/* Allow a reponse-callback handler to find context of a blocked requester.  */
  68.325 -struct rsp_wait {
  68.326 -    ctrl_msg_t         *msg;  /* Buffer for the response message.            */
  68.327 -    struct task_struct *task; /* The task that is blocked on the response.   */
  68.328 -    int                 done; /* Indicate to 'task' that response is rcv'ed. */
  68.329 -};
  68.330 -
  68.331 -static void __ctrl_if_get_response(ctrl_msg_t *msg, unsigned long id)
  68.332 -{
  68.333 -    struct rsp_wait    *wait = (struct rsp_wait *)id;
  68.334 -    struct task_struct *task = wait->task;
  68.335 -
  68.336 -    memcpy(wait->msg, msg, sizeof(*msg));
  68.337 -    wmb();
  68.338 -    wait->done = 1;
  68.339 -
  68.340 -    wake_up_process(task);
  68.341 -}
  68.342 -
  68.343 -int
  68.344 -ctrl_if_send_message_and_get_response(
  68.345 -    ctrl_msg_t *msg, 
  68.346 -    ctrl_msg_t *rmsg,
  68.347 -    long wait_state)
  68.348 -{
  68.349 -    struct rsp_wait wait;
  68.350 -    int rc;
  68.351 -
  68.352 -    wait.msg  = rmsg;
  68.353 -    wait.done = 0;
  68.354 -    wait.task = current;
  68.355 -
  68.356 -    if ( (rc = ctrl_if_send_message_block(msg, __ctrl_if_get_response,
  68.357 -                                          (unsigned long)&wait,
  68.358 -                                          wait_state)) != 0 )
  68.359 -        return rc;
  68.360 -
  68.361 -    for ( ; ; )
  68.362 -    {
  68.363 -        /* NB. Can't easily support TASK_INTERRUPTIBLE here. */
  68.364 -        set_current_state(TASK_UNINTERRUPTIBLE);
  68.365 -        if ( wait.done )
  68.366 -            break;
  68.367 -        schedule();
  68.368 -    }
  68.369 -
  68.370 -    set_current_state(TASK_RUNNING);
  68.371 -    return 0;
  68.372 -}
  68.373 -
  68.374 -int
  68.375 -ctrl_if_enqueue_space_callback(
  68.376 -    struct tq_struct *task)
  68.377 -{
  68.378 -    /* Fast path. */
  68.379 -    if ( !RING_FULL(&ctrl_if_tx_ring) )
  68.380 -        return 0;
  68.381 -
  68.382 -    (void)queue_task(task, &ctrl_if_tx_tq);
  68.383 -
  68.384 -    /*
  68.385 -     * We may race execution of the task queue, so return re-checked status. If
  68.386 -     * the task is not executed despite the ring being non-full then we will
  68.387 -     * certainly return 'not full'.
  68.388 -     */
  68.389 -    smp_mb();
  68.390 -    return RING_FULL(&ctrl_if_tx_ring);
  68.391 -}
  68.392 -
  68.393 -void
  68.394 -ctrl_if_send_response(
  68.395 -    ctrl_msg_t *msg)
  68.396 -{
  68.397 -    unsigned long flags;
  68.398 -    ctrl_msg_t   *dmsg;
  68.399 -
  68.400 -    /*
  68.401 -     * NB. The response may the original request message, modified in-place.
  68.402 -     * In this situation we may have src==dst, so no copying is required.
  68.403 -     */
  68.404 -    spin_lock_irqsave(&ctrl_if_lock, flags);
  68.405 -
  68.406 -    DPRINTK("Tx-Rsp %u :: %d/%d\n", 
  68.407 -            ctrl_if_rx_ring.rsp_prod_pvt, 
  68.408 -            msg->type, msg->subtype);
  68.409 -
  68.410 -    dmsg = RING_GET_RESPONSE(&ctrl_if_rx_ring, 
  68.411 -            ctrl_if_rx_ring.rsp_prod_pvt);
  68.412 -    if ( dmsg != msg )
  68.413 -        memcpy(dmsg, msg, sizeof(*msg));
  68.414 -
  68.415 -    ctrl_if_rx_ring.rsp_prod_pvt++;
  68.416 -    RING_PUSH_RESPONSES(&ctrl_if_rx_ring);
  68.417 -
  68.418 -    spin_unlock_irqrestore(&ctrl_if_lock, flags);
  68.419 -
  68.420 -    ctrl_if_notify_controller();
  68.421 -}
  68.422 -
  68.423 -int
  68.424 -ctrl_if_register_receiver(
  68.425 -    u8 type, 
  68.426 -    ctrl_msg_handler_t hnd, 
  68.427 -    unsigned int flags)
  68.428 -{
  68.429 -    unsigned long _flags;
  68.430 -    int inuse;
  68.431 -
  68.432 -    spin_lock_irqsave(&ctrl_if_lock, _flags);
  68.433 -
  68.434 -    inuse = (ctrl_if_rxmsg_handler[type] != ctrl_if_rxmsg_default_handler);
  68.435 -
  68.436 -    if ( inuse )
  68.437 -    {
  68.438 -        printk(KERN_INFO "Receiver %p already established for control "
  68.439 -               "messages of type %d.\n", ctrl_if_rxmsg_handler[type], type);
  68.440 -    }
  68.441 -    else
  68.442 -    {
  68.443 -        ctrl_if_rxmsg_handler[type] = hnd;
  68.444 -        clear_bit(type, (unsigned long *)&ctrl_if_rxmsg_blocking_context);
  68.445 -        if ( flags == CALLBACK_IN_BLOCKING_CONTEXT )
  68.446 -        {
  68.447 -            set_bit(type, (unsigned long *)&ctrl_if_rxmsg_blocking_context);
  68.448 -            if ( !safe_to_schedule_task )
  68.449 -                BUG();
  68.450 -        }
  68.451 -    }
  68.452 -
  68.453 -    spin_unlock_irqrestore(&ctrl_if_lock, _flags);
  68.454 -
  68.455 -    return !inuse;
  68.456 -}
  68.457 -
  68.458 -void 
  68.459 -ctrl_if_unregister_receiver(
  68.460 -    u8 type,
  68.461 -    ctrl_msg_handler_t hnd)
  68.462 -{
  68.463 -    unsigned long flags;
  68.464 -
  68.465 -    spin_lock_irqsave(&ctrl_if_lock, flags);
  68.466 -
  68.467 -    if ( ctrl_if_rxmsg_handler[type] != hnd )
  68.468 -        printk(KERN_INFO "Receiver %p is not registered for control "
  68.469 -               "messages of type %d.\n", hnd, type);
  68.470 -    else
  68.471 -        ctrl_if_rxmsg_handler[type] = ctrl_if_rxmsg_default_handler;
  68.472 -
  68.473 -    spin_unlock_irqrestore(&ctrl_if_lock, flags);
  68.474 -
  68.475 -    /* Ensure that @hnd will not be executed after this function returns. */
  68.476 -    tasklet_unlock_wait(&ctrl_if_rx_tasklet);
  68.477 -}
  68.478 -
  68.479 -void ctrl_if_suspend(void)
  68.480 -{
  68.481 -    teardown_irq(ctrl_if_irq, &ctrl_if_irq_action);
  68.482 -    unbind_evtchn_from_irq(ctrl_if_evtchn);
  68.483 -}
  68.484 -
  68.485 -void ctrl_if_resume(void)
  68.486 -{
  68.487 -    control_if_t *ctrl_if = get_ctrl_if();
  68.488 -
  68.489 -    if ( xen_start_info.flags & SIF_INITDOMAIN )
  68.490 -    {
  68.491 -        /*
  68.492 -         * The initial domain must create its own domain-controller link.
  68.493 -         * The controller is probably not running at this point, but will
  68.494 -         * pick up its end of the event channel from 
  68.495 -         */
  68.496 -        evtchn_op_t op;
  68.497 -	extern void bind_evtchn_to_cpu(unsigned port, unsigned cpu);
  68.498 -
  68.499 -        op.cmd = EVTCHNOP_bind_interdomain;
  68.500 -        op.u.bind_interdomain.dom1 = DOMID_SELF;
  68.501 -        op.u.bind_interdomain.dom2 = DOMID_SELF;
  68.502 -        op.u.bind_interdomain.port1 = 0;
  68.503 -        op.u.bind_interdomain.port2 = 0;
  68.504 -        if ( HYPERVISOR_event_channel_op(&op) != 0 )
  68.505 -            BUG();
  68.506 -        xen_start_info.domain_controller_evtchn = op.u.bind_interdomain.port1;
  68.507 -        initdom_ctrlif_domcontroller_port   = op.u.bind_interdomain.port2;
  68.508 -	bind_evtchn_to_cpu(op.u.bind_interdomain.port1, 0);
  68.509 -    }
  68.510 -
  68.511 -    /* Sync up with shared indexes. */
  68.512 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
  68.513 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
  68.514 -
  68.515 -    ctrl_if_evtchn = xen_start_info.domain_controller_evtchn;
  68.516 -    ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
  68.517 -
  68.518 -    memset(&ctrl_if_irq_action, 0, sizeof(ctrl_if_irq_action));
  68.519 -    ctrl_if_irq_action.handler = ctrl_if_interrupt;
  68.520 -    ctrl_if_irq_action.name    = "ctrl-if";
  68.521 -    (void)setup_irq(ctrl_if_irq, &ctrl_if_irq_action);
  68.522 -}
  68.523 -
  68.524 -void __init ctrl_if_init(void)
  68.525 -{
  68.526 -    control_if_t *ctrl_if = get_ctrl_if();
  68.527 -    int i;
  68.528 -
  68.529 -    for ( i = 0; i < 256; i++ )
  68.530 -        ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
  68.531 -
  68.532 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
  68.533 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
  68.534 -    
  68.535 -    spin_lock_init(&ctrl_if_lock);
  68.536 -
  68.537 -    ctrl_if_resume();
  68.538 -}
  68.539 -
  68.540 -
  68.541 -/* This is called after it is safe to call schedule_task(). */
  68.542 -static int __init ctrl_if_late_setup(void)
  68.543 -{
  68.544 -    safe_to_schedule_task = 1;
  68.545 -    return 0;
  68.546 -}
  68.547 -__initcall(ctrl_if_late_setup);
  68.548 -
  68.549 -
  68.550 -/*
  68.551 - * !! The following are DANGEROUS FUNCTIONS !!
  68.552 - * Use with care [for example, see xencons_force_flush()].
  68.553 - */
  68.554 -
  68.555 -int ctrl_if_transmitter_empty(void)
  68.556 -{
  68.557 -    return (ctrl_if_tx_ring.sring->req_prod == ctrl_if_tx_ring.rsp_cons);
  68.558 -    
  68.559 -}
  68.560 -
  68.561 -void ctrl_if_discard_responses(void)
  68.562 -{
  68.563 -    RING_DROP_PENDING_RESPONSES(&ctrl_if_tx_ring);
  68.564 -}
  68.565 -
  68.566 -EXPORT_SYMBOL(ctrl_if_send_message_noblock);
  68.567 -EXPORT_SYMBOL(ctrl_if_send_message_block);
  68.568 -EXPORT_SYMBOL(ctrl_if_send_message_and_get_response);
  68.569 -EXPORT_SYMBOL(ctrl_if_enqueue_space_callback);
  68.570 -EXPORT_SYMBOL(ctrl_if_send_response);
  68.571 -EXPORT_SYMBOL(ctrl_if_register_receiver);
  68.572 -EXPORT_SYMBOL(ctrl_if_unregister_receiver);
    69.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Thu Sep 08 09:18:40 2005 -0600
    69.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c	Fri Sep 09 10:30:54 2005 -0600
    69.3 @@ -40,17 +40,9 @@
    69.4  #include <asm-xen/synch_bitops.h>
    69.5  #include <asm-xen/xen-public/event_channel.h>
    69.6  #include <asm-xen/xen-public/physdev.h>
    69.7 -#include <asm-xen/ctrl_if.h>
    69.8  #include <asm-xen/hypervisor.h>
    69.9  #include <asm-xen/evtchn.h>
   69.10  
   69.11 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   69.12 -EXPORT_SYMBOL(force_evtchn_callback);
   69.13 -EXPORT_SYMBOL(evtchn_do_upcall);
   69.14 -EXPORT_SYMBOL(bind_evtchn_to_irq);
   69.15 -EXPORT_SYMBOL(unbind_evtchn_from_irq);
   69.16 -#endif
   69.17 -
   69.18  /*
   69.19   * This lock protects updates to the following mapping and reference-count
   69.20   * arrays. The lock does not need to be acquired to read the mapping tables.
   69.21 @@ -133,6 +125,7 @@ void force_evtchn_callback(void)
   69.22  {
   69.23      (void)HYPERVISOR_xen_version(0);
   69.24  }
   69.25 +EXPORT_SYMBOL(force_evtchn_callback);
   69.26  
   69.27  /* NB. Interrupts are disabled on entry. */
   69.28  asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
   69.29 @@ -165,6 +158,7 @@ asmlinkage void evtchn_do_upcall(struct 
   69.30          }
   69.31      }
   69.32  }
   69.33 +EXPORT_SYMBOL(evtchn_do_upcall);
   69.34  
   69.35  static int find_unbound_irq(void)
   69.36  {
   69.37 @@ -211,6 +205,7 @@ int bind_virq_to_irq(int virq)
   69.38      
   69.39      return irq;
   69.40  }
   69.41 +EXPORT_SYMBOL(bind_virq_to_irq);
   69.42  
   69.43  void unbind_virq_from_irq(int virq)
   69.44  {
   69.45 @@ -244,74 +239,7 @@ void unbind_virq_from_irq(int virq)
   69.46  
   69.47      spin_unlock(&irq_mapping_update_lock);
   69.48  }
   69.49 -
   69.50 -/* This is only used when a vcpu from an xm save.  The ipi is expected
   69.51 -   to have been bound before we suspended, and so all of the xenolinux
   69.52 -   state is set up; we only need to restore the Xen side of things.
   69.53 -   The irq number has to be the same, but the evtchn number can
   69.54 -   change. */
   69.55 -void _bind_ipi_to_irq(int ipi, int vcpu, int irq)
   69.56 -{
   69.57 -    evtchn_op_t op;
   69.58 -    int evtchn;
   69.59 -
   69.60 -    spin_lock(&irq_mapping_update_lock);
   69.61 -
   69.62 -    op.cmd = EVTCHNOP_bind_ipi;
   69.63 -    if ( HYPERVISOR_event_channel_op(&op) != 0 )
   69.64 -	panic("Failed to bind virtual IPI %d on cpu %d\n", ipi, vcpu);
   69.65 -    evtchn = op.u.bind_ipi.port;
   69.66 -
   69.67 -    printk("<0>IPI %d, old evtchn %d, evtchn %d.\n",
   69.68 -	   ipi, per_cpu(ipi_to_evtchn, vcpu)[ipi],
   69.69 -	   evtchn);
   69.70 -
   69.71 -    evtchn_to_irq[irq_to_evtchn[irq]] = -1;
   69.72 -    irq_to_evtchn[irq] = -1;
   69.73 -
   69.74 -    evtchn_to_irq[evtchn] = irq;
   69.75 -    irq_to_evtchn[irq]    = evtchn;
   69.76 -
   69.77 -    printk("<0>evtchn_to_irq[%d] = %d.\n", evtchn,
   69.78 -	   evtchn_to_irq[evtchn]);
   69.79 -    per_cpu(ipi_to_evtchn, vcpu)[ipi] = evtchn;
   69.80 -
   69.81 -    bind_evtchn_to_cpu(evtchn, vcpu);
   69.82 -
   69.83 -    spin_unlock(&irq_mapping_update_lock);
   69.84 -
   69.85 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_mask);
   69.86 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_pending);
   69.87 -}
   69.88 -
   69.89 -void _bind_virq_to_irq(int virq, int cpu, int irq)
   69.90 -{
   69.91 -    evtchn_op_t op;
   69.92 -    int evtchn;
   69.93 -
   69.94 -    spin_lock(&irq_mapping_update_lock);
   69.95 -
   69.96 -    op.cmd              = EVTCHNOP_bind_virq;
   69.97 -    op.u.bind_virq.virq = virq;
   69.98 -    if ( HYPERVISOR_event_channel_op(&op) != 0 )
   69.99 -            panic("Failed to bind virtual IRQ %d\n", virq);
  69.100 -    evtchn = op.u.bind_virq.port;
  69.101 -
  69.102 -    evtchn_to_irq[irq_to_evtchn[irq]] = -1;
  69.103 -    irq_to_evtchn[irq] = -1;
  69.104 -
  69.105 -    evtchn_to_irq[evtchn] = irq;
  69.106 -    irq_to_evtchn[irq]    = evtchn;
  69.107 -
  69.108 -    per_cpu(virq_to_irq, cpu)[virq] = irq;
  69.109 -
  69.110 -    bind_evtchn_to_cpu(evtchn, cpu);
  69.111 -
  69.112 -    spin_unlock(&irq_mapping_update_lock);
  69.113 -
  69.114 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_mask);
  69.115 -    clear_bit(evtchn, (unsigned long *)HYPERVISOR_shared_info->evtchn_pending);
  69.116 -}
  69.117 +EXPORT_SYMBOL(unbind_virq_from_irq);
  69.118  
  69.119  int bind_ipi_to_irq(int ipi)
  69.120  {
  69.121 @@ -347,6 +275,7 @@ int bind_ipi_to_irq(int ipi)
  69.122  
  69.123      return irq;
  69.124  }
  69.125 +EXPORT_SYMBOL(bind_ipi_to_irq);
  69.126  
  69.127  void unbind_ipi_from_irq(int ipi)
  69.128  {
  69.129 @@ -374,6 +303,7 @@ void unbind_ipi_from_irq(int ipi)
  69.130  
  69.131      spin_unlock(&irq_mapping_update_lock);
  69.132  }
  69.133 +EXPORT_SYMBOL(unbind_ipi_from_irq);
  69.134  
  69.135  int bind_evtchn_to_irq(unsigned int evtchn)
  69.136  {
  69.137 @@ -394,6 +324,7 @@ int bind_evtchn_to_irq(unsigned int evtc
  69.138      
  69.139      return irq;
  69.140  }
  69.141 +EXPORT_SYMBOL(bind_evtchn_to_irq);
  69.142  
  69.143  void unbind_evtchn_from_irq(unsigned int evtchn)
  69.144  {
  69.145 @@ -409,6 +340,7 @@ void unbind_evtchn_from_irq(unsigned int
  69.146  
  69.147      spin_unlock(&irq_mapping_update_lock);
  69.148  }
  69.149 +EXPORT_SYMBOL(unbind_evtchn_from_irq);
  69.150  
  69.151  int bind_evtchn_to_irqhandler(
  69.152      unsigned int evtchn,
  69.153 @@ -427,6 +359,7 @@ int bind_evtchn_to_irqhandler(
  69.154  
  69.155      return retval;
  69.156  }
  69.157 +EXPORT_SYMBOL(bind_evtchn_to_irqhandler);
  69.158  
  69.159  void unbind_evtchn_from_irqhandler(unsigned int evtchn, void *dev_id)
  69.160  {
  69.161 @@ -434,6 +367,7 @@ void unbind_evtchn_from_irqhandler(unsig
  69.162      free_irq(irq, dev_id);
  69.163      unbind_evtchn_from_irq(evtchn);
  69.164  }
  69.165 +EXPORT_SYMBOL(unbind_evtchn_from_irqhandler);
  69.166  
  69.167  #ifdef CONFIG_SMP
  69.168  static void do_nothing_function(void *ign)
  69.169 @@ -797,7 +731,4 @@ void __init init_IRQ(void)
  69.170          irq_desc[pirq_to_irq(i)].depth   = 1;
  69.171          irq_desc[pirq_to_irq(i)].handler = &pirq_type;
  69.172      }
  69.173 -
  69.174 -    /* This needs to be done early, but after the IRQ subsystem is alive. */
  69.175 -    ctrl_if_init();
  69.176  }
    70.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Thu Sep 08 09:18:40 2005 -0600
    70.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Fri Sep 09 10:30:54 2005 -0600
    70.3 @@ -12,10 +12,8 @@
    70.4  #include <asm-xen/evtchn.h>
    70.5  #include <asm-xen/hypervisor.h>
    70.6  #include <asm-xen/xen-public/dom0_ops.h>
    70.7 -#include <asm-xen/linux-public/suspend.h>
    70.8  #include <asm-xen/queues.h>
    70.9  #include <asm-xen/xenbus.h>
   70.10 -#include <asm-xen/ctrl_if.h>
   70.11  #include <linux/cpu.h>
   70.12  #include <linux/kthread.h>
   70.13  
   70.14 @@ -65,69 +63,10 @@ static int shutting_down = SHUTDOWN_INVA
   70.15  #define cpu_up(x) (-EOPNOTSUPP)
   70.16  #endif
   70.17  
   70.18 -static void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
   70.19 -{
   70.20 -    int r;
   70.21 -    int gdt_pages;
   70.22 -    r = HYPERVISOR_vcpu_pickle(vcpu, ctxt);
   70.23 -    if (r != 0)
   70.24 -	panic("pickling vcpu %d -> %d!\n", vcpu, r);
   70.25 -
   70.26 -    /* Translate from machine to physical addresses where necessary,
   70.27 -       so that they can be translated to our new machine address space
   70.28 -       after resume.  libxc is responsible for doing this to vcpu0,
   70.29 -       but we do it to the others. */
   70.30 -    gdt_pages = (ctxt->gdt_ents + 511) / 512;
   70.31 -    ctxt->ctrlreg[3] = machine_to_phys(ctxt->ctrlreg[3]);
   70.32 -    for (r = 0; r < gdt_pages; r++)
   70.33 -	ctxt->gdt_frames[r] = mfn_to_pfn(ctxt->gdt_frames[r]);
   70.34 -}
   70.35 -
   70.36 -void _restore_vcpu(int cpu);
   70.37 -
   70.38 -atomic_t vcpus_rebooting;
   70.39 -
   70.40 -static int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
   70.41 -{
   70.42 -    int r;
   70.43 -    int gdt_pages = (ctxt->gdt_ents + 511) / 512;
   70.44 -
   70.45 -    /* This is kind of a hack, and implicitly relies on the fact that
   70.46 -       the vcpu stops in a place where all of the call clobbered
   70.47 -       registers are already dead. */
   70.48 -    ctxt->user_regs.esp -= 4;
   70.49 -    ((unsigned long *)ctxt->user_regs.esp)[0] = ctxt->user_regs.eip;
   70.50 -    ctxt->user_regs.eip = (unsigned long)_restore_vcpu;
   70.51 -
   70.52 -    /* De-canonicalise.  libxc handles this for vcpu 0, but we need
   70.53 -       to do it for the other vcpus. */
   70.54 -    ctxt->ctrlreg[3] = phys_to_machine(ctxt->ctrlreg[3]);
   70.55 -    for (r = 0; r < gdt_pages; r++)
   70.56 -	ctxt->gdt_frames[r] = pfn_to_mfn(ctxt->gdt_frames[r]);
   70.57 -
   70.58 -    atomic_set(&vcpus_rebooting, 1);
   70.59 -    r = HYPERVISOR_boot_vcpu(vcpu, ctxt);
   70.60 -    if (r != 0) {
   70.61 -	printk(KERN_EMERG "Failed to reboot vcpu %d (%d)\n", vcpu, r);
   70.62 -	return -1;
   70.63 -    }
   70.64 -
   70.65 -    /* Make sure we wait for the new vcpu to come up before trying to do
   70.66 -       anything with it or starting the next one. */
   70.67 -    while (atomic_read(&vcpus_rebooting))
   70.68 -	barrier();
   70.69 -
   70.70 -    return 0;
   70.71 -}
   70.72  
   70.73  static int __do_suspend(void *ignore)
   70.74  {
   70.75 -    int i, j;
   70.76 -    suspend_record_t *suspend_record;
   70.77 -    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
   70.78 -
   70.79 -    /* Hmmm... a cleaner interface to suspend/resume blkdevs would be nice. */
   70.80 -	/* XXX SMH: yes it would :-( */	
   70.81 +    int i, j, k, fpp;
   70.82  
   70.83  #ifdef CONFIG_XEN_USB_FRONTEND
   70.84      extern void usbif_resume();
   70.85 @@ -138,16 +77,25 @@ static int __do_suspend(void *ignore)
   70.86      extern int gnttab_suspend(void);
   70.87      extern int gnttab_resume(void);
   70.88  
   70.89 +    extern void time_suspend(void);
   70.90 +    extern void time_resume(void);
   70.91 +    extern unsigned long max_pfn;
   70.92 +    extern unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[];
   70.93 +
   70.94  #ifdef CONFIG_SMP
   70.95      extern void smp_suspend(void);
   70.96      extern void smp_resume(void);
   70.97 +
   70.98 +    static vcpu_guest_context_t suspended_cpu_records[NR_CPUS];
   70.99 +    cpumask_t prev_online_cpus, prev_present_cpus;
  70.100 +
  70.101 +    void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt);
  70.102 +    int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt);
  70.103  #endif
  70.104 -    extern void time_suspend(void);
  70.105 -    extern void time_resume(void);
  70.106 -    extern unsigned long max_pfn;
  70.107 -    extern unsigned int *pfn_to_mfn_frame_list;
  70.108  
  70.109 -    cpumask_t prev_online_cpus, prev_present_cpus;
  70.110 +    extern void xencons_suspend(void);
  70.111 +    extern void xencons_resume(void);
  70.112 +
  70.113      int err = 0;
  70.114  
  70.115      BUG_ON(smp_processor_id() != 0);
  70.116 @@ -155,15 +103,14 @@ static int __do_suspend(void *ignore)
  70.117  
  70.118  #if defined(CONFIG_SMP) && !defined(CONFIG_HOTPLUG_CPU)
  70.119      if (num_online_cpus() > 1) {
  70.120 -	printk(KERN_WARNING "Can't suspend SMP guests without CONFIG_HOTPLUG_CPU\n");
  70.121 +	printk(KERN_WARNING 
  70.122 +               "Can't suspend SMP guests without CONFIG_HOTPLUG_CPU\n");
  70.123  	return -EOPNOTSUPP;
  70.124      }
  70.125  #endif
  70.126  
  70.127 -    suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
  70.128 -    if ( suspend_record == NULL )
  70.129 -        goto out;
  70.130 -
  70.131 +    preempt_disable();
  70.132 +#ifdef CONFIG_SMP
  70.133      /* Take all of the other cpus offline.  We need to be careful not
  70.134         to get preempted between the final test for num_online_cpus()
  70.135         == 1 and disabling interrupts, since otherwise userspace could
  70.136 @@ -175,7 +122,6 @@ static int __do_suspend(void *ignore)
  70.137         since by the time num_online_cpus() == 1, there aren't any
  70.138         other cpus) */
  70.139      cpus_clear(prev_online_cpus);
  70.140 -    preempt_disable();
  70.141      while (num_online_cpus() > 1) {
  70.142  	preempt_enable();
  70.143  	for_each_online_cpu(i) {
  70.144 @@ -190,13 +136,13 @@ static int __do_suspend(void *ignore)
  70.145  	}
  70.146  	preempt_disable();
  70.147      }
  70.148 -
  70.149 -    suspend_record->nr_pfns = max_pfn; /* final number of pfns */
  70.150 +#endif
  70.151  
  70.152      __cli();
  70.153  
  70.154      preempt_enable();
  70.155  
  70.156 +#ifdef CONFIG_SMP
  70.157      cpus_clear(prev_present_cpus);
  70.158      for_each_present_cpu(i) {
  70.159  	if (i == 0)
  70.160 @@ -204,6 +150,7 @@ static int __do_suspend(void *ignore)
  70.161  	save_vcpu_context(i, &suspended_cpu_records[i]);
  70.162  	cpu_set(i, prev_present_cpus);
  70.163      }
  70.164 +#endif
  70.165  
  70.166  #ifdef __i386__
  70.167      mm_pin_all();
  70.168 @@ -218,7 +165,7 @@ static int __do_suspend(void *ignore)
  70.169  
  70.170      xenbus_suspend();
  70.171  
  70.172 -    ctrl_if_suspend();
  70.173 +    xencons_suspend();
  70.174  
  70.175      irq_suspend();
  70.176  
  70.177 @@ -227,37 +174,44 @@ static int __do_suspend(void *ignore)
  70.178      HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
  70.179      clear_fixmap(FIX_SHARED_INFO);
  70.180  
  70.181 -    memcpy(&suspend_record->resume_info, &xen_start_info,
  70.182 -           sizeof(xen_start_info));
  70.183 +    xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
  70.184 +    xen_start_info->console_mfn = mfn_to_pfn(xen_start_info->console_mfn);
  70.185  
  70.186      /* We'll stop somewhere inside this hypercall.  When it returns,
  70.187         we'll start resuming after the restore. */
  70.188 -    HYPERVISOR_suspend(virt_to_mfn(suspend_record));
  70.189 +    HYPERVISOR_suspend(virt_to_mfn(xen_start_info));
  70.190  
  70.191      shutting_down = SHUTDOWN_INVALID; 
  70.192  
  70.193 -    memcpy(&xen_start_info, &suspend_record->resume_info,
  70.194 -           sizeof(xen_start_info));
  70.195 -
  70.196 -    set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
  70.197 +    set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
  70.198  
  70.199      HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
  70.200  
  70.201      memset(empty_zero_page, 0, PAGE_SIZE);
  70.202 -
  70.203 -    for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
  70.204 +	     
  70.205 +    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
  70.206 +		virt_to_mfn(pfn_to_mfn_frame_list_list);
  70.207 +  
  70.208 +    fpp = PAGE_SIZE/sizeof(unsigned long);
  70.209 +    for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
  70.210      {
  70.211 -        pfn_to_mfn_frame_list[j] = 
  70.212 -            virt_to_mfn(&phys_to_machine_mapping[i]);
  70.213 +	if ( (j % fpp) == 0 )
  70.214 +	{
  70.215 +	    k++;
  70.216 +	    pfn_to_mfn_frame_list_list[k] = 
  70.217 +		    virt_to_mfn(pfn_to_mfn_frame_list[k]);
  70.218 +	    j=0;
  70.219 +	}
  70.220 +	pfn_to_mfn_frame_list[k][j] = 
  70.221 +		virt_to_mfn(&phys_to_machine_mapping[i]);
  70.222      }
  70.223 -    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
  70.224 -        virt_to_mfn(pfn_to_mfn_frame_list);
  70.225 +    HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
  70.226  
  70.227      gnttab_resume();
  70.228  
  70.229      irq_resume();
  70.230  
  70.231 -    ctrl_if_resume();
  70.232 +    xencons_resume();
  70.233  
  70.234      xenbus_resume();
  70.235  
  70.236 @@ -269,12 +223,14 @@ static int __do_suspend(void *ignore)
  70.237  
  70.238      usbif_resume();
  70.239  
  70.240 -    for_each_cpu_mask(i, prev_present_cpus) {
  70.241 +#ifdef CONFIG_SMP
  70.242 +    for_each_cpu_mask(i, prev_present_cpus)
  70.243  	restore_vcpu_context(i, &suspended_cpu_records[i]);
  70.244 -    }
  70.245 +#endif
  70.246  
  70.247      __sti();
  70.248  
  70.249 +#ifdef CONFIG_SMP
  70.250   out_reenable_cpus:
  70.251      for_each_cpu_mask(i, prev_online_cpus) {
  70.252  	j = cpu_up(i);
  70.253 @@ -284,10 +240,8 @@ static int __do_suspend(void *ignore)
  70.254  	    err = j;
  70.255  	}
  70.256      }
  70.257 +#endif
  70.258  
  70.259 - out:
  70.260 -    if ( suspend_record != NULL )
  70.261 -        free_page((unsigned long)suspend_record);
  70.262      return err;
  70.263  }
  70.264  
    71.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig	Thu Sep 08 09:18:40 2005 -0600
    71.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/Kconfig	Fri Sep 09 10:30:54 2005 -0600
    71.3 @@ -21,13 +21,13 @@ config X86_64
    71.4  	  classical 32-bit x86 architecture. For details see
    71.5  	  <http://www.x86-64.org/>.
    71.6  
    71.7 +config 64BIT
    71.8 +	def_bool y
    71.9 +
   71.10  config X86
   71.11  	bool
   71.12  	default y
   71.13  
   71.14 -config 64BIT
   71.15 -	def_bool y
   71.16 -
   71.17  config MMU
   71.18  	bool
   71.19  	default y
   71.20 @@ -89,10 +89,11 @@ choice
   71.21  #	  Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs.
   71.22  
   71.23  config MPSC
   71.24 -       bool "Intel x86-64"
   71.25 +       bool "Intel EM64T"
   71.26         help
   71.27 -	  Optimize for Intel IA32 with 64bit extension CPUs
   71.28 -	  (Prescott/Nocona/Potomac)
   71.29 +	  Optimize for Intel Pentium 4 and Xeon CPUs with Intel
   71.30 +	  Extended Memory 64 Technology(EM64T). For details see
   71.31 +	  <http://www.intel.com/technology/64bitextensions/>.
   71.32  
   71.33  config GENERIC_CPU
   71.34  	bool "Generic-x86-64"
   71.35 @@ -367,7 +368,6 @@ config SECCOMP
   71.36  
   71.37  	  If unsure, say Y. Only embedded should say N here.
   71.38  
   71.39 -
   71.40  endmenu
   71.41  
   71.42  #
    72.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile	Thu Sep 08 09:18:40 2005 -0600
    72.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/Makefile	Fri Sep 09 10:30:54 2005 -0600
    72.3 @@ -40,7 +40,7 @@ obj-$(CONFIG_DUMMY_IOMMU)	+= pci-nommu.o
    72.4  i386-obj-$(CONFIG_DUMMY_IOMMU)	+= pci-dma.o
    72.5  i386-obj-$(CONFIG_SWIOTLB)	+= swiotlb.o
    72.6  obj-$(CONFIG_KPROBES)		+= kprobes.o
    72.7 -obj-$(CONFIG_X86_PM_TIMER)	+= pmtimer.o
    72.8 +#obj-$(CONFIG_X86_PM_TIMER)	+= pmtimer.o
    72.9  
   72.10  c-obj-$(CONFIG_MODULES)		+= module.o
   72.11  
    73.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Thu Sep 08 09:18:40 2005 -0600
    73.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Fri Sep 09 10:30:54 2005 -0600
    73.3 @@ -20,6 +20,9 @@
    73.4  #include <asm/e820.h>
    73.5  #include <asm/proto.h>
    73.6  #include <asm/bootsetup.h>
    73.7 +#include <asm-xen/xen-public/memory.h>
    73.8 +
    73.9 +unsigned long pci_mem_start = 0xaeedbabe;
   73.10  
   73.11  /* 
   73.12   * PFN of last memory page.
   73.13 @@ -517,14 +520,13 @@ void __init setup_memory_region(void)
   73.14  }
   73.15  
   73.16  #else  /* CONFIX_XEN */
   73.17 +
   73.18  extern unsigned long xen_override_max_pfn;
   73.19  extern union xen_start_info_union xen_start_info_union;
   73.20 -/*
   73.21 - * Guest physical starts from 0.
   73.22 - */
   73.23 +
   73.24  unsigned long __init e820_end_of_ram(void)
   73.25  {
   73.26 -        unsigned long max_end_pfn = xen_start_info.nr_pages;
   73.27 +        unsigned long max_end_pfn = xen_start_info->nr_pages;
   73.28  
   73.29  	if ( xen_override_max_pfn <  max_end_pfn)
   73.30  		xen_override_max_pfn = max_end_pfn;
   73.31 @@ -532,11 +534,69 @@ unsigned long __init e820_end_of_ram(voi
   73.32          return xen_override_max_pfn;
   73.33  }
   73.34  
   73.35 -
   73.36 -
   73.37  void __init e820_reserve_resources(void) 
   73.38  {
   73.39 -	return;			/* Xen won't have reserved entries */
   73.40 +	dom0_op_t op;
   73.41 +	struct dom0_memory_map_entry *map;
   73.42 +	unsigned long gapstart, gapsize, last;
   73.43 +	int i, found = 0;
   73.44 +
   73.45 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
   73.46 +		return;
   73.47 +
   73.48 +	map = alloc_bootmem_low_pages(PAGE_SIZE);
   73.49 +	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
   73.50 +	op.u.physical_memory_map.memory_map = map;
   73.51 +	op.u.physical_memory_map.max_map_entries =
   73.52 +		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
   73.53 +	BUG_ON(HYPERVISOR_dom0_op(&op));
   73.54 +
   73.55 +	last = 0x100000000ULL;
   73.56 +	gapstart = 0x10000000;
   73.57 +	gapsize = 0x400000;
   73.58 +
   73.59 +	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
   73.60 +		struct resource *res;
   73.61 +
   73.62 +		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
   73.63 +			gapsize = last - map[i].end;
   73.64 +			gapstart = map[i].end;
   73.65 +			found = 1;
   73.66 +		}
   73.67 +		if (map[i].start < last)
   73.68 +			last = map[i].start;
   73.69 +
   73.70 +		if (map[i].end > 0x100000000ULL)
   73.71 +			continue;
   73.72 +		res = alloc_bootmem_low(sizeof(struct resource));
   73.73 +		res->name = map[i].is_ram ? "System RAM" : "reserved";
   73.74 +		res->start = map[i].start;
   73.75 +		res->end = map[i].end - 1;
   73.76 +		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
   73.77 +		request_resource(&iomem_resource, res);
   73.78 +	}
   73.79 +
   73.80 +	free_bootmem(__pa(map), PAGE_SIZE);
   73.81 +
   73.82 +	if (!found) {
   73.83 +		HYPERVISOR_memory_op(XENMEM_maximum_ram_page, &gapstart);
   73.84 +		gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
   73.85 +		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
   73.86 +		       KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
   73.87 +	}
   73.88 +
   73.89 +	/*
   73.90 +	 * Start allocating dynamic PCI memory a bit into the gap,
   73.91 +	 * aligned up to the nearest megabyte.
   73.92 +	 *
   73.93 +	 * Question: should we try to pad it up a bit (do something
   73.94 +	 * like " + (gapsize >> 3)" in there too?). We now have the
   73.95 +	 * technology.
   73.96 +	 */
   73.97 +	pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
   73.98 +
   73.99 +	printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
  73.100 +		pci_mem_start, gapstart, gapsize);
  73.101  }
  73.102  
  73.103  #endif
  73.104 @@ -548,8 +608,6 @@ void __init parse_memopt(char *p, char *
  73.105          xen_override_max_pfn = (unsigned long) end_user_pfn;
  73.106  } 
  73.107  
  73.108 -unsigned long pci_mem_start = 0xaeedbabe;
  73.109 -
  73.110  /*
  73.111   * Search for the biggest gap in the low 32 bits of the e820
  73.112   * memory space.  We pass this space to PCI to assign MMIO resources
  73.113 @@ -558,6 +616,7 @@ unsigned long pci_mem_start = 0xaeedbabe
  73.114   */
  73.115  __init void e820_setup_gap(void)
  73.116  {
  73.117 +#ifndef CONFIG_XEN
  73.118  	unsigned long gapstart, gapsize;
  73.119  	unsigned long last;
  73.120  	int i;
  73.121 @@ -606,4 +665,5 @@ unsigned long pci_mem_start = 0xaeedbabe
  73.122  
  73.123  	printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
  73.124  		pci_mem_start, gapstart, gapsize);
  73.125 +#endif
  73.126  }
    74.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S	Thu Sep 08 09:18:40 2005 -0600
    74.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head.S	Fri Sep 09 10:30:54 2005 -0600
    74.3 @@ -40,16 +40,13 @@
    74.4  	.globl startup_64
    74.5  startup_64:
    74.6  ENTRY(_start)
    74.7 -        cld                
    74.8 -	/* Copy the necessary stuff from xen_start_info structure. */
    74.9 -	movq  $xen_start_info_union,%rdi
   74.10 -	movq  $256,%rcx
   74.11 -	rep movsq
   74.12 +	movq %rsi,xen_start_info(%rip)
   74.13  
   74.14  #ifdef CONFIG_SMP
   74.15 -        ENTRY(startup_64_smp)
   74.16 +ENTRY(startup_64_smp)
   74.17 +#endif /* CONFIG_SMP */
   74.18 +
   74.19  	cld
   74.20 -#endif /* CONFIG_SMP */
   74.21  
   74.22  	movq init_rsp(%rip),%rsp
   74.23  	/* zero EFLAGS after setting rsp */
    75.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head64.c	Thu Sep 08 09:18:40 2005 -0600
    75.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/head64.c	Fri Sep 09 10:30:54 2005 -0600
    75.3 @@ -90,8 +90,9 @@ void __init x86_64_start_kernel(char * r
    75.4  {
    75.5  	int i;
    75.6  
    75.7 -        phys_to_machine_mapping = (u32 *)xen_start_info.mfn_list;
    75.8 -        start_pfn = (__pa(xen_start_info.pt_base) >> PAGE_SHIFT) +  xen_start_info.nr_pt_frames;
    75.9 +        phys_to_machine_mapping = (unsigned long *)xen_start_info->mfn_list;
   75.10 +        start_pfn = (__pa(xen_start_info->pt_base) >> PAGE_SHIFT) + 
   75.11 +		xen_start_info->nr_pt_frames;
   75.12  
   75.13  	for (i = 0; i < 256; i++)
   75.14  		set_intr_gate(i, early_idt_handler);
    76.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Thu Sep 08 09:18:40 2005 -0600
    76.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Sep 09 10:30:54 2005 -0600
    76.3 @@ -76,7 +76,8 @@ EXPORT_SYMBOL(HYPERVISOR_shared_info);
    76.4  /* Allows setting of maximum possible memory size  */
    76.5  unsigned long xen_override_max_pfn;
    76.6  
    76.7 -u32 *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
    76.8 +unsigned long *phys_to_machine_mapping;
    76.9 +unsigned long *pfn_to_mfn_frame_list_list, *pfn_to_mfn_frame_list[512];
   76.10  
   76.11  EXPORT_SYMBOL(phys_to_machine_mapping);
   76.12  
   76.13 @@ -84,7 +85,7 @@ DEFINE_PER_CPU(multicall_entry_t, multic
   76.14  DEFINE_PER_CPU(int, nr_multicall_ents);
   76.15  
   76.16  /* Raw start-of-day parameters from the hypervisor. */
   76.17 -union xen_start_info_union xen_start_info_union;
   76.18 +start_info_t *xen_start_info;
   76.19  #endif
   76.20  
   76.21  /*
   76.22 @@ -314,7 +315,7 @@ static __init void parse_cmdline_early (
   76.23  	
   76.24  	if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
   76.25  		max_cmdline = COMMAND_LINE_SIZE;
   76.26 -	memcpy(saved_command_line, xen_start_info.cmd_line, max_cmdline);
   76.27 +	memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
   76.28  	saved_command_line[max_cmdline-1] = '\0';
   76.29  #else
   76.30  	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
   76.31 @@ -687,7 +688,7 @@ void __init setup_arch(char **cmdline_p)
   76.32  #endif
   76.33  #ifdef CONFIG_XEN
   76.34  #ifdef CONFIG_BLK_DEV_INITRD
   76.35 -	if (xen_start_info.mod_start) {
   76.36 +	if (xen_start_info->mod_start) {
   76.37  		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
   76.38  			/*reserve_bootmem_generic(INITRD_START, INITRD_SIZE);*/
   76.39  			initrd_start = INITRD_START + PAGE_OFFSET;
   76.40 @@ -730,29 +731,50 @@ void __init setup_arch(char **cmdline_p)
   76.41  #endif
   76.42  #ifdef CONFIG_XEN
   76.43  	{
   76.44 -		int i, j;
   76.45 +		int i, j, k, fpp;
   76.46  		/* Make sure we have a large enough P->M table. */
   76.47 -		if (end_pfn > xen_start_info.nr_pages) {
   76.48 +		if (end_pfn > xen_start_info->nr_pages) {
   76.49  			phys_to_machine_mapping = alloc_bootmem(
   76.50 -				max_pfn * sizeof(u32));
   76.51 +				end_pfn * sizeof(unsigned long));
   76.52  			memset(phys_to_machine_mapping, ~0,
   76.53 -			       max_pfn * sizeof(u32));
   76.54 +			       end_pfn * sizeof(unsigned long));
   76.55  			memcpy(phys_to_machine_mapping,
   76.56 -			       (u32 *)xen_start_info.mfn_list,
   76.57 -			       xen_start_info.nr_pages * sizeof(u32));
   76.58 +			       (unsigned long *)xen_start_info->mfn_list,
   76.59 +			       xen_start_info->nr_pages * sizeof(unsigned long));
   76.60  			free_bootmem(
   76.61 -				__pa(xen_start_info.mfn_list), 
   76.62 -				PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
   76.63 -						sizeof(u32))));
   76.64 +				__pa(xen_start_info->mfn_list), 
   76.65 +				PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
   76.66 +						sizeof(unsigned long))));
   76.67  		}
   76.68  
   76.69 -		pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE);
   76.70 -
   76.71 -		for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(u32)), j++ )
   76.72 -		{	
   76.73 -			pfn_to_mfn_frame_list[j] = 
   76.74 +		/* 
   76.75 +		 * Initialise the list of the frames that specify the list of 
   76.76 +		 * frames that make up the p2m table. Used by save/restore
   76.77 +		 */
   76.78 +		pfn_to_mfn_frame_list_list = alloc_bootmem(PAGE_SIZE);
   76.79 +		HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
   76.80 +		  virt_to_mfn(pfn_to_mfn_frame_list_list);
   76.81 +	       
   76.82 +		fpp = PAGE_SIZE/sizeof(unsigned long);
   76.83 +		for ( i=0, j=0, k=-1; i< max_pfn; i+=fpp, j++ )
   76.84 +		{
   76.85 +			if ( (j % fpp) == 0 )
   76.86 +			{
   76.87 +				k++;
   76.88 +				BUG_ON(k>=fpp);
   76.89 +				pfn_to_mfn_frame_list[k] = alloc_bootmem(PAGE_SIZE);
   76.90 +				pfn_to_mfn_frame_list_list[k] = 
   76.91 +					virt_to_mfn(pfn_to_mfn_frame_list[k]);
   76.92 +				j=0;
   76.93 +			}
   76.94 +			pfn_to_mfn_frame_list[k][j] = 
   76.95  				virt_to_mfn(&phys_to_machine_mapping[i]);
   76.96  		}
   76.97 +		HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
   76.98 +		
   76.99 +		
  76.100 +
  76.101 +
  76.102  
  76.103  	}
  76.104  #endif
  76.105 @@ -817,8 +839,8 @@ void __init setup_arch(char **cmdline_p)
  76.106  	       op.u.set_iopl.iopl = 1;
  76.107  	       HYPERVISOR_physdev_op(&op);
  76.108  
  76.109 -	       if (xen_start_info.flags & SIF_INITDOMAIN) {
  76.110 -		       if (!(xen_start_info.flags & SIF_PRIVILEGED))
  76.111 +	       if (xen_start_info->flags & SIF_INITDOMAIN) {
  76.112 +		       if (!(xen_start_info->flags & SIF_PRIVILEGED))
  76.113  			       panic("Xen granted us console access "
  76.114  				     "but not privileged status");
  76.115  		       
    77.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c	Thu Sep 08 09:18:40 2005 -0600
    77.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/smpboot.c	Fri Sep 09 10:30:54 2005 -0600
    77.3 @@ -1277,21 +1277,23 @@ extern void local_teardown_timer_irq(voi
    77.4  
    77.5  void smp_suspend(void)
    77.6  {
    77.7 -	/* XXX todo: take down time and ipi's on all cpus */
    77.8  	local_teardown_timer_irq();
    77.9  	smp_intr_exit();
   77.10  }
   77.11  
   77.12  void smp_resume(void)
   77.13  {
   77.14 -	/* XXX todo: restore time and ipi's on all cpus */
   77.15  	smp_intr_init();
   77.16  	local_setup_timer_irq();
   77.17  }
   77.18  
   77.19 -void _restore_vcpu(void)
   77.20 +void save_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
   77.21  {
   77.22 -	/* XXX need to write this */
   77.23 +}
   77.24 +
   77.25 +int restore_vcpu_context(int vcpu, vcpu_guest_context_t *ctxt)
   77.26 +{
   77.27 +	return 0;
   77.28  }
   77.29  
   77.30  #endif
    78.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c	Thu Sep 08 09:18:40 2005 -0600
    78.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/fault.c	Fri Sep 09 10:30:54 2005 -0600
    78.3 @@ -149,7 +149,7 @@ void dump_pagetable(unsigned long addres
    78.4  	pmd_t *pmd;
    78.5  	pte_t *pte;
    78.6  
    78.7 -        pgd = (pgd_t *)per_cpu(cur_pgd, smp_processor_id());
    78.8 +	pgd = (pgd_t *)per_cpu(cur_pgd, smp_processor_id());
    78.9  	pgd += pgd_index(address);
   78.10  
   78.11  	printk("PGD %lx ", pgd_val(*pgd));
   78.12 @@ -296,9 +296,9 @@ int exception_trace = 1;
   78.13  #define MEM_VERBOSE 1
   78.14  
   78.15  #ifdef MEM_VERBOSE
   78.16 -#define MEM_LOG(_f, _a...)                           \
   78.17 -  printk("fault.c:[%d]-> " _f "\n", \
   78.18 -          __LINE__ , ## _a )
   78.19 +#define MEM_LOG(_f, _a...)			\
   78.20 +	printk("fault.c:[%d]-> " _f "\n",	\
   78.21 +	__LINE__ , ## _a )
   78.22  #else
   78.23  #define MEM_LOG(_f, _a...) ((void)0)
   78.24  #endif
   78.25 @@ -325,7 +325,7 @@ asmlinkage void do_page_fault(struct pt_
   78.26  	siginfo_t info;
   78.27  
   78.28  	if (!user_mode(regs))
   78.29 -                error_code &= ~4; /* means kernel */
   78.30 +		error_code &= ~4; /* means kernel */
   78.31  
   78.32  #ifdef CONFIG_CHECKING
   78.33  	{ 
    79.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Thu Sep 08 09:18:40 2005 -0600
    79.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Fri Sep 09 10:30:54 2005 -0600
    79.3 @@ -62,14 +62,16 @@ static int init_mapping_done;
    79.4   * avaialble in init_memory_mapping().
    79.5   */
    79.6  
    79.7 -#define addr_to_page(addr, page)                                             \
    79.8 -        (addr) &= PHYSICAL_PAGE_MASK;                                   \
    79.9 -        (page) = ((unsigned long *) ((unsigned long)(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) + __START_KERNEL_map)))
   79.10 +#define addr_to_page(addr, page)				\
   79.11 +	(addr) &= PHYSICAL_PAGE_MASK;				\
   79.12 +	(page) = ((unsigned long *) ((unsigned long)		\
   79.13 +	(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) +	\
   79.14 +	__START_KERNEL_map)))
   79.15  
   79.16  static void __make_page_readonly(unsigned long va)
   79.17  {
   79.18 -        unsigned long addr;
   79.19 -        pte_t pte, *ptep;
   79.20 +	unsigned long addr;
   79.21 +	pte_t pte, *ptep;
   79.22  	unsigned long *page = (unsigned long *) init_level4_pgt;
   79.23  
   79.24  	addr = (unsigned long) page[pgd_index(va)];
   79.25 @@ -89,22 +91,22 @@ static void __make_page_readonly(unsigne
   79.26  
   79.27  static void __make_page_writable(unsigned long va)
   79.28  {
   79.29 -        unsigned long addr;
   79.30 -        pte_t pte, *ptep;
   79.31 -        unsigned long *page = (unsigned long *) init_level4_pgt;
   79.32 -
   79.33 -        addr = (unsigned long) page[pgd_index(va)];
   79.34 -        addr_to_page(addr, page);
   79.35 +	unsigned long addr;
   79.36 +	pte_t pte, *ptep;
   79.37 +	unsigned long *page = (unsigned long *) init_level4_pgt;
   79.38  
   79.39 -        addr = page[pud_index(va)];
   79.40 -        addr_to_page(addr, page);
   79.41 -        
   79.42 -        addr = page[pmd_index(va)];
   79.43 -        addr_to_page(addr, page);
   79.44 +	addr = (unsigned long) page[pgd_index(va)];
   79.45 +	addr_to_page(addr, page);
   79.46  
   79.47 -        ptep = (pte_t *) &page[pte_index(va)];
   79.48 +	addr = page[pud_index(va)];
   79.49 +	addr_to_page(addr, page);
   79.50 + 
   79.51 +	addr = page[pmd_index(va)];
   79.52 +	addr_to_page(addr, page);
   79.53 +
   79.54 +	ptep = (pte_t *) &page[pte_index(va)];
   79.55  	pte.pte = (ptep->pte | _PAGE_RW);
   79.56 -        xen_l1_entry_update(ptep, pte);
   79.57 +	xen_l1_entry_update(ptep, pte);
   79.58  	__flush_tlb_one(addr);
   79.59  }
   79.60  
   79.61 @@ -115,55 +117,55 @@ static void __make_page_writable(unsigne
   79.62  void make_page_readonly(void *va)
   79.63  {
   79.64  	pgd_t* pgd; pud_t *pud; pmd_t* pmd; pte_t pte, *ptep;
   79.65 -        unsigned long addr = (unsigned long) va;
   79.66 +	unsigned long addr = (unsigned long) va;
   79.67  
   79.68 -        if (!init_mapping_done) {
   79.69 -                __make_page_readonly(addr);
   79.70 -                return;
   79.71 -        }
   79.72 -                
   79.73 -        pgd = pgd_offset_k(addr);
   79.74 -        pud = pud_offset(pgd, addr);
   79.75 -        pmd = pmd_offset(pud, addr);
   79.76 -        ptep = pte_offset_kernel(pmd, addr);
   79.77 +	if (!init_mapping_done) {
   79.78 +		__make_page_readonly(addr);
   79.79 +		return;
   79.80 +	}
   79.81 +  
   79.82 +	pgd = pgd_offset_k(addr);
   79.83 +	pud = pud_offset(pgd, addr);
   79.84 +	pmd = pmd_offset(pud, addr);
   79.85 +	ptep = pte_offset_kernel(pmd, addr);
   79.86  	pte.pte = (ptep->pte & ~_PAGE_RW);
   79.87 -        xen_l1_entry_update(ptep, pte);
   79.88 +	xen_l1_entry_update(ptep, pte);
   79.89  	__flush_tlb_one(addr);
   79.90  }
   79.91  
   79.92  void make_page_writable(void *va)
   79.93  {
   79.94 -        pgd_t* pgd; pud_t *pud; pmd_t* pmd; pte_t pte, *ptep;
   79.95 -        unsigned long addr = (unsigned long) va;
   79.96 +	pgd_t* pgd; pud_t *pud; pmd_t* pmd; pte_t pte, *ptep;
   79.97 +	unsigned long addr = (unsigned long) va;
   79.98  
   79.99 -        if (!init_mapping_done) {
  79.100 -                __make_page_writable(addr);
  79.101 -                return;
  79.102 -        }
  79.103 +	if (!init_mapping_done) {
  79.104 +		__make_page_writable(addr);
  79.105 +		return;
  79.106 +	}
  79.107  
  79.108 -        pgd = pgd_offset_k(addr);
  79.109 -        pud = pud_offset(pgd, addr);
  79.110 -        pmd = pmd_offset(pud, addr);
  79.111 -        ptep = pte_offset_kernel(pmd, addr);
  79.112 +	pgd = pgd_offset_k(addr);
  79.113 +	pud = pud_offset(pgd, addr);
  79.114 +	pmd = pmd_offset(pud, addr);
  79.115 +	ptep = pte_offset_kernel(pmd, addr);
  79.116  	pte.pte = (ptep->pte | _PAGE_RW);
  79.117 -        xen_l1_entry_update(ptep, pte);
  79.118 +	xen_l1_entry_update(ptep, pte);
  79.119  	__flush_tlb_one(addr);
  79.120  }
  79.121  
  79.122  void make_pages_readonly(void* va, unsigned nr)
  79.123  {
  79.124 -        while ( nr-- != 0 ) {
  79.125 -                make_page_readonly(va);
  79.126 -                va = (void*)((unsigned long)va + PAGE_SIZE);
  79.127 -        }
  79.128 +	while (nr-- != 0) {
  79.129 +		make_page_readonly(va);
  79.130 +		va = (void*)((unsigned long)va + PAGE_SIZE);
  79.131 +	}
  79.132  }
  79.133  
  79.134  void make_pages_writable(void* va, unsigned nr)
  79.135  {
  79.136 -        while ( nr-- != 0 ) {
  79.137 -                make_page_writable(va);
  79.138 -                va = (void*)((unsigned long)va + PAGE_SIZE);
  79.139 -        }
  79.140 +	while (nr-- != 0) {
  79.141 +		make_page_writable(va);
  79.142 +		va = (void*)((unsigned long)va + PAGE_SIZE);
  79.143 +	}
  79.144  }
  79.145  
  79.146  /*
  79.147 @@ -389,7 +391,7 @@ void __set_fixmap_user (enum fixed_addre
  79.148          set_pte_phys(address, phys, prot, SET_FIXMAP_USER); 
  79.149  }
  79.150  
  79.151 -unsigned long __initdata table_start, table_end, tables_space; 
  79.152 +unsigned long __initdata table_start, tables_space; 
  79.153  
  79.154  unsigned long get_machine_pfn(unsigned long addr)
  79.155  {
  79.156 @@ -400,38 +402,13 @@ unsigned long get_machine_pfn(unsigned l
  79.157          return pte_mfn(*pte);
  79.158  } 
  79.159  
  79.160 -#define ALIGN_TO_4K __attribute__((section(".data.page_aligned")))
  79.161 -#define MAX_LOW_PAGES	0x20
  79.162 -static unsigned long __init_pgt[MAX_LOW_PAGES][512]  ALIGN_TO_4K;
  79.163 -static int __init_pgt_index;
  79.164 -
  79.165 -/*
  79.166 - * We start using from start_pfn
  79.167 - */
  79.168  static __init void *alloc_static_page(unsigned long *phys)
  79.169  {
  79.170 -	int i = __init_pgt_index++;
  79.171 -
  79.172 -	if (__init_pgt_index >= MAX_LOW_PAGES) {
  79.173 -		printk("Need to increase MAX_LOW_PAGES");
  79.174 -		BUG();
  79.175 -	}
  79.176 -		
  79.177 -	*phys = __pa(__init_pgt[i]);
  79.178 -
  79.179 -	return (void *) __init_pgt[i];
  79.180 -} 
  79.181 -
  79.182 -/*
  79.183 - * Get RO page
  79.184 - */
  79.185 -static void __init *alloc_low_page(unsigned long *phys)
  79.186 -{ 
  79.187 -        unsigned long pfn = table_end++;
  79.188 -    
  79.189 -        *phys = (pfn << PAGE_SHIFT);
  79.190 -        memset((void *) ((pfn << PAGE_SHIFT) + __START_KERNEL_map), 0, PAGE_SIZE);
  79.191 -        return (void *)((pfn << PAGE_SHIFT) + __START_KERNEL_map);
  79.192 +	unsigned long va = (start_pfn << PAGE_SHIFT) + __START_KERNEL_map;
  79.193 +	*phys = start_pfn << PAGE_SHIFT;
  79.194 +	start_pfn++;
  79.195 +	memset((void *)va, 0, PAGE_SIZE);
  79.196 +	return (void *)va;
  79.197  } 
  79.198  
  79.199  #define PTE_SIZE PAGE_SIZE
  79.200 @@ -443,30 +420,24 @@ static inline void __set_pte(pte_t *dst,
  79.201  
  79.202  static inline int make_readonly(unsigned long paddr)
  79.203  {
  79.204 -    int readonly = 0;
  79.205 -
  79.206 -    /* Make new page tables read-only. */
  79.207 -    if ((paddr < ((table_start << PAGE_SHIFT) + tables_space)) &&
  79.208 -        (paddr >= (table_start << PAGE_SHIFT)))
  79.209 -        readonly = 1;
  79.210 +	int readonly = 0;
  79.211  
  79.212 -    /* Make old page tables read-only. */
  79.213 -    if ((paddr < ((xen_start_info.pt_base - __START_KERNEL_map) +
  79.214 -                  (xen_start_info.nr_pt_frames << PAGE_SHIFT))) &&
  79.215 -        (paddr >= (xen_start_info.pt_base - __START_KERNEL_map)))
  79.216 -        readonly = 1;
  79.217 +	/* Make old and new page tables read-only. */
  79.218 +	if ((paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
  79.219 +	    && (paddr < ((table_start << PAGE_SHIFT) + tables_space)))
  79.220 +		readonly = 1;
  79.221 +	/*
  79.222 +	 * No need for writable mapping of kernel image. This also ensures that
  79.223 +	 * page and descriptor tables embedded inside don't have writable
  79.224 +	 * mappings. 
  79.225 +	 */
  79.226 +	if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end)))
  79.227 +		readonly = 1;
  79.228  
  79.229 -    /*
  79.230 -     * No need for writable mapping of kernel image. This also ensures that
  79.231 -     * page and descriptor tables embedded inside don't have writable mappings.
  79.232 -     */
  79.233 -    if ((paddr >= __pa_symbol(&_text)) && (paddr < __pa_symbol(&_end)))
  79.234 -        readonly = 1;
  79.235 -
  79.236 -    return readonly;
  79.237 +	return readonly;
  79.238  }
  79.239  
  79.240 -void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
  79.241 +static void __init phys_pud_init(pud_t *pud, unsigned long address, unsigned long end)
  79.242  { 
  79.243          long i, j, k; 
  79.244          unsigned long paddr;
  79.245 @@ -485,7 +456,7 @@ void __init phys_pud_init(pud_t *pud, un
  79.246  			break;
  79.247  		} 
  79.248  
  79.249 -		pmd = alloc_low_page(&pmd_phys);
  79.250 +		pmd = alloc_static_page(&pmd_phys);
  79.251                  make_page_readonly(pmd);
  79.252                  xen_pmd_pin(pmd_phys);
  79.253  		set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
  79.254 @@ -499,19 +470,20 @@ void __init phys_pud_init(pud_t *pud, un
  79.255  					set_pmd(pmd,  __pmd(0)); 
  79.256  				break;
  79.257  			}
  79.258 -                        pte = alloc_low_page(&pte_phys);
  79.259 +                        pte = alloc_static_page(&pte_phys);
  79.260                          pte_save = pte;
  79.261                          for (k = 0; k < PTRS_PER_PTE; pte++, k++, paddr += PTE_SIZE) {
  79.262 +                                if ((paddr >= end) ||
  79.263 +                                    ((paddr >> PAGE_SHIFT) >=
  79.264 +                                     xen_start_info->nr_pages)) { 
  79.265 +                                        __set_pte(pte, __pte(0)); 
  79.266 +                                        continue;
  79.267 +                                }
  79.268                                  if (make_readonly(paddr)) {
  79.269                                          __set_pte(pte, 
  79.270                                                  __pte(paddr | (_KERNPG_TABLE & ~_PAGE_RW)));
  79.271                                          continue;
  79.272                                  }
  79.273 -                                if (paddr >= end) { 
  79.274 -                                        for (; k < PTRS_PER_PTE; k++, pte++)
  79.275 -                                                __set_pte(pte, __pte(0)); 
  79.276 -                                        break;
  79.277 -                                }
  79.278                                  __set_pte(pte, __pte(paddr | _KERNPG_TABLE));
  79.279                          }
  79.280                          pte = pte_save;
  79.281 @@ -525,15 +497,16 @@ void __init phys_pud_init(pud_t *pud, un
  79.282  
  79.283  static void __init find_early_table_space(unsigned long end)
  79.284  {
  79.285 -        unsigned long puds, pmds, ptes; 
  79.286 +	unsigned long puds, pmds, ptes; 
  79.287  
  79.288  	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
  79.289  	pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
  79.290 -        ptes = (end + PTE_SIZE - 1) >> PAGE_SHIFT;
  79.291 +	ptes = (end + PTE_SIZE - 1) >> PAGE_SHIFT;
  79.292  
  79.293 -        tables_space = round_up(puds * 8, PAGE_SIZE) + 
  79.294 -	    		  round_up(pmds * 8, PAGE_SIZE) + 
  79.295 -	    		  round_up(ptes * 8, PAGE_SIZE); 
  79.296 +	tables_space =
  79.297 +		round_up(puds * 8, PAGE_SIZE) + 
  79.298 +		round_up(pmds * 8, PAGE_SIZE) + 
  79.299 +		round_up(ptes * 8, PAGE_SIZE); 
  79.300  }
  79.301  
  79.302  void __init xen_init_pt(void)
  79.303 @@ -549,7 +522,7 @@ void __init xen_init_pt(void)
  79.304  	memset((void *)level2_kernel_pgt, 0, PAGE_SIZE);
  79.305  
  79.306  	/* Find the initial pte page that was built for us. */
  79.307 -	page = (unsigned long *)xen_start_info.pt_base;
  79.308 +	page = (unsigned long *)xen_start_info->pt_base;
  79.309  	addr = page[pgd_index(__START_KERNEL_map)];
  79.310  	addr_to_page(addr, page);
  79.311  	addr = page[pud_index(__START_KERNEL_map)];
  79.312 @@ -579,66 +552,59 @@ void __init xen_init_pt(void)
  79.313  		mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
  79.314  }
  79.315  
  79.316 -/*
  79.317 - * Extend kernel mapping to access pages for page tables.  The initial
  79.318 - * mapping done by Xen is minimal (e.g. 8MB) and we need to extend the
  79.319 - * mapping for early initialization.
  79.320 - */
  79.321 -static unsigned long current_size, extended_size;
  79.322 -
  79.323  void __init extend_init_mapping(void) 
  79.324  {
  79.325  	unsigned long va = __START_KERNEL_map;
  79.326  	unsigned long phys, addr, *pte_page;
  79.327 -        pmd_t *pmd;
  79.328 +	pmd_t *pmd;
  79.329  	pte_t *pte, new_pte;
  79.330 -	unsigned long *page = (unsigned long *) init_level4_pgt;
  79.331 -	int i;
  79.332 +	unsigned long *page = (unsigned long *)init_level4_pgt;
  79.333  
  79.334  	addr = page[pgd_index(va)];
  79.335  	addr_to_page(addr, page);
  79.336  	addr = page[pud_index(va)];
  79.337  	addr_to_page(addr, page);
  79.338  
  79.339 -	for (;;) {
  79.340 -		pmd = (pmd_t *)&page[pmd_index(va)];
  79.341 -		if (!pmd_present(*pmd))
  79.342 -			break;
  79.343 -		addr = page[pmd_index(va)];
  79.344 -		addr_to_page(addr, pte_page);
  79.345 -		for (i = 0; i < PTRS_PER_PTE; i++) {
  79.346 -			pte = (pte_t *) &pte_page[pte_index(va)];
  79.347 -			if (!pte_present(*pte))
  79.348 -				break;
  79.349 -			va += PAGE_SIZE;
  79.350 -			current_size += PAGE_SIZE;
  79.351 -		}
  79.352 +	/* Kill mapping of low 1MB. */
  79.353 +	while (va < (unsigned long)&_text) {
  79.354 +		HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
  79.355 +		va += PAGE_SIZE;
  79.356  	}
  79.357  
  79.358 -	while (va < __START_KERNEL_map + current_size + tables_space) {
  79.359 -		pmd = (pmd_t *) &page[pmd_index(va)];
  79.360 -		if (!pmd_none(*pmd))
  79.361 -			continue;
  79.362 -		pte_page = (unsigned long *) alloc_static_page(&phys);
  79.363 -		make_page_readonly(pte_page);
  79.364 -		xen_pte_pin(phys);
  79.365 -		set_pmd(pmd, __pmd(phys | _KERNPG_TABLE | _PAGE_USER));
  79.366 -		for (i = 0; i < PTRS_PER_PTE; i++, va += PAGE_SIZE) {
  79.367 +	/* Ensure init mappings cover kernel text/data and initial tables. */
  79.368 +	while (va < (__START_KERNEL_map
  79.369 +		     + (start_pfn << PAGE_SHIFT)
  79.370 +		     + tables_space)) {
  79.371 +		pmd = (pmd_t *)&page[pmd_index(va)];
  79.372 +		if (pmd_none(*pmd)) {
  79.373 +			pte_page = alloc_static_page(&phys);
  79.374 +			make_page_readonly(pte_page);
  79.375 +			xen_pte_pin(phys);
  79.376 +			set_pmd(pmd, __pmd(phys | _KERNPG_TABLE | _PAGE_USER));
  79.377 +		} else {
  79.378 +			addr = page[pmd_index(va)];
  79.379 +			addr_to_page(addr, pte_page);
  79.380 +		}
  79.381 +		pte = (pte_t *)&pte_page[pte_index(va)];
  79.382 +		if (pte_none(*pte)) {
  79.383  			new_pte = pfn_pte(
  79.384  				(va - __START_KERNEL_map) >> PAGE_SHIFT, 
  79.385  				__pgprot(_KERNPG_TABLE | _PAGE_USER));
  79.386 -			pte = (pte_t *)&pte_page[pte_index(va)];
  79.387  			xen_l1_entry_update(pte, new_pte);
  79.388 -			extended_size += PAGE_SIZE;
  79.389  		}
  79.390 +		va += PAGE_SIZE;
  79.391  	}
  79.392  
  79.393 -	/* Kill mapping of low 1MB. */
  79.394 -	for (va = __START_KERNEL_map; va < (unsigned long)&_text; va += PAGE_SIZE)
  79.395 +	/* Finally, blow away any spurious initial mappings. */
  79.396 +	while (1) {
  79.397 +		pmd = (pmd_t *)&page[pmd_index(va)];
  79.398 +		if (pmd_none(*pmd))
  79.399 +			break;
  79.400  		HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
  79.401 +		va += PAGE_SIZE;
  79.402 +	}
  79.403  }
  79.404  
  79.405 -
  79.406  /* Setup the direct mapping of the physical memory at PAGE_OFFSET.
  79.407     This runs before bootmem is initialized and gets pages directly from the 
  79.408     physical memory. To access them they are temporarily mapped. */
  79.409 @@ -650,34 +616,31 @@ void __init init_memory_mapping(unsigned
  79.410  
  79.411  	find_early_table_space(end);
  79.412  	extend_init_mapping();
  79.413 -	start_pfn = current_size >> PAGE_SHIFT;
  79.414  
  79.415  	table_start = start_pfn;
  79.416 -	table_end = table_start;
  79.417  
  79.418  	start = (unsigned long)__va(start);
  79.419  	end = (unsigned long)__va(end);
  79.420  
  79.421  	for (; start < end; start = next) {
  79.422  		unsigned long pud_phys; 
  79.423 -                pud_t *pud = alloc_low_page(&pud_phys);
  79.424 -                make_page_readonly(pud);
  79.425 -                xen_pud_pin(pud_phys);
  79.426 +		pud_t *pud = alloc_static_page(&pud_phys);
  79.427 +		make_page_readonly(pud);
  79.428 +		xen_pud_pin(pud_phys);
  79.429  		next = start + PGDIR_SIZE;
  79.430  		if (next > end) 
  79.431  			next = end; 
  79.432  		phys_pud_init(pud, __pa(start), __pa(next));
  79.433  		set_pgd(pgd_offset_k(start), mk_kernel_pgd(pud_phys));
  79.434 -	} 
  79.435 +	}
  79.436  
  79.437 -	printk("kernel direct mapping tables upto %lx @ %lx-%lx\n", end, 
  79.438 -	       table_start<<PAGE_SHIFT, 
  79.439 -	       table_end<<PAGE_SHIFT);
  79.440 +	printk("kernel direct mapping tables upto %lx @ %lx-%lx\n",
  79.441 +	       __pa(end), table_start<<PAGE_SHIFT, start_pfn<<PAGE_SHIFT);
  79.442  
  79.443 -        start_pfn = ((current_size + extended_size) >> PAGE_SHIFT);
  79.444 +	BUG_ON(start_pfn != (table_start + (tables_space >> PAGE_SHIFT)));
  79.445  
  79.446  	__flush_tlb_all();
  79.447 -        init_mapping_done = 1;
  79.448 +	init_mapping_done = 1;
  79.449  }
  79.450  
  79.451  extern struct x8664_pda cpu_pda[NR_CPUS];
  79.452 @@ -708,7 +671,7 @@ void __init paging_init(void)
  79.453  		free_area_init(zones_size);
  79.454  	}
  79.455  
  79.456 -        set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
  79.457 +        set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
  79.458          HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
  79.459  
  79.460          memset(empty_zero_page, 0, sizeof(empty_zero_page));
  79.461 @@ -719,7 +682,7 @@ void __init paging_init(void)
  79.462  		int i;
  79.463          /* Setup mapping of lower 1st MB */
  79.464  		for (i = 0; i < NR_FIX_ISAMAPS; i++)
  79.465 -			if (xen_start_info.flags & SIF_PRIVILEGED)
  79.466 +			if (xen_start_info->flags & SIF_PRIVILEGED)
  79.467  				set_fixmap(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
  79.468  			else
  79.469  				__set_fixmap(FIX_ISAMAP_BEGIN - i,
  79.470 @@ -767,9 +730,6 @@ void __init clear_kernel_mapping(unsigne
  79.471  
  79.472  static inline int page_is_ram (unsigned long pagenr)
  79.473  {
  79.474 -        if (pagenr < start_pfn || pagenr >= end_pfn)
  79.475 -                return 0;
  79.476 -
  79.477          return 1;
  79.478  }
  79.479  
  79.480 @@ -1005,3 +965,13 @@ int in_gate_area_no_task(unsigned long a
  79.481  {
  79.482  	return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
  79.483  }
  79.484 +
  79.485 +/*
  79.486 + * Local variables:
  79.487 + *  c-file-style: "linux"
  79.488 + *  indent-tabs-mode: t
  79.489 + *  c-indent-level: 8
  79.490 + *  c-basic-offset: 8
  79.491 + *  tab-width: 8
  79.492 + * End:
  79.493 + */
    80.1 --- a/linux-2.6-xen-sparse/drivers/char/mem.c	Thu Sep 08 09:18:40 2005 -0600
    80.2 +++ b/linux-2.6-xen-sparse/drivers/char/mem.c	Fri Sep 09 10:30:54 2005 -0600
    80.3 @@ -231,7 +231,7 @@ static ssize_t write_mem(struct file * f
    80.4  }
    80.5  #endif
    80.6  
    80.7 -static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
    80.8 +static int mmap_mem(struct file * file, struct vm_area_struct * vma)
    80.9  {
   80.10  #if defined(__HAVE_PHYS_MEM_ACCESS_PROT)
   80.11  	unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
   80.12 @@ -258,7 +258,6 @@ static int mmap_kmem(struct file * file,
   80.13  	return 0;
   80.14  }
   80.15  
   80.16 -#if 0
   80.17  static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
   80.18  {
   80.19          unsigned long long val;
   80.20 @@ -275,7 +274,6 @@ static int mmap_kmem(struct file * file,
   80.21  	vma->vm_pgoff = __pa(val) >> PAGE_SHIFT;
   80.22  	return mmap_mem(file, vma);
   80.23  }
   80.24 -#endif
   80.25  
   80.26  extern long vread(char *buf, char *addr, unsigned long count);
   80.27  extern long vwrite(char *buf, char *addr, unsigned long count);
   80.28 @@ -731,7 +729,7 @@ static struct file_operations mem_fops =
   80.29  	.llseek		= memory_lseek,
   80.30  	.read		= read_mem,
   80.31  	.write		= write_mem,
   80.32 -	.mmap		= mmap_kmem,
   80.33 +	.mmap		= mmap_mem,
   80.34  	.open		= open_mem,
   80.35  };
   80.36  #else
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/Kconfig.domU	Fri Sep 09 10:30:54 2005 -0600
    81.3 @@ -0,0 +1,30 @@
    81.4 +#
    81.5 +# TPM device configuration
    81.6 +#
    81.7 +
    81.8 +menu "TPM devices"
    81.9 +
   81.10 +config TCG_TPM
   81.11 +	tristate "TPM Support for XEN"
   81.12 +	depends on ARCH_XEN && !XEN_PHYSDEV_ACCESS
   81.13 +	---help---
   81.14 +	  If you want to make TPM security available in your system,
   81.15 +	  say Yes and it will be accessible from within a user domain.  For
   81.16 +	  more information see <http://www.trustedcomputinggroup.org>.
   81.17 +	  An implementation of the Trusted Software Stack (TSS), the
   81.18 +	  userspace enablement piece of the specification, can be
   81.19 +	  obtained at: <http://sourceforge.net/projects/trousers>.  To
   81.20 +	  compile this driver as a module, choose M here; the module
   81.21 +	  will be called tpm. If unsure, say N.
   81.22 +
   81.23 +config TCG_XEN
   81.24 +	tristate "XEN TPM Interface"
   81.25 +	depends on TCG_TPM && ARCH_XEN && XEN_TPMDEV_FRONTEND
   81.26 +	---help---
   81.27 +	  If you want to make TPM support available to a Xen
   81.28 +	  user domain, say Yes and it will
   81.29 +          be accessible from within Linux. To compile this driver
   81.30 +          as a module, choose M here; the module will be called
   81.31 +          tpm_xen.
   81.32 +
   81.33 +endmenu
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/Makefile	Fri Sep 09 10:30:54 2005 -0600
    82.3 @@ -0,0 +1,12 @@
    82.4 +#
    82.5 +# Makefile for the kernel tpm device drivers.
    82.6 +#
    82.7 +ifeq ($(CONFIG_XEN_PHYSDEV_ACCESS),y)
    82.8 +obj-$(CONFIG_TCG_TPM) += tpm.o
    82.9 +obj-$(CONFIG_TCG_NSC) += tpm_nsc.o
   82.10 +obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o
   82.11 +obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
   82.12 +else
   82.13 +obj-$(CONFIG_TCG_TPM) += tpm_nopci.o
   82.14 +obj-$(CONFIG_TCG_XEN) += tpm_xen.o
   82.15 +endif
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c	Fri Sep 09 10:30:54 2005 -0600
    83.3 @@ -0,0 +1,627 @@
    83.4 +/*
    83.5 + * Copyright (C) 2004 IBM Corporation
    83.6 + *
    83.7 + * Authors:
    83.8 + * Leendert van Doorn <leendert@watson.ibm.com>
    83.9 + * Dave Safford <safford@watson.ibm.com>
   83.10 + * Reiner Sailer <sailer@watson.ibm.com>
   83.11 + * Kylene Hall <kjhall@us.ibm.com>
   83.12 + *
   83.13 + * Maintained by: <tpmdd_devel@lists.sourceforge.net>
   83.14 + *
   83.15 + * Device driver for TCG/TCPA TPM (trusted platform module).
   83.16 + * Specifications at www.trustedcomputinggroup.org
   83.17 + *
   83.18 + * This program is free software; you can redistribute it and/or
   83.19 + * modify it under the terms of the GNU General Public License as
   83.20 + * published by the Free Software Foundation, version 2 of the
   83.21 + * License.
   83.22 + *
   83.23 + * Note, the TPM chip is not interrupt driven (only polling)
   83.24 + * and can have very long timeouts (minutes!). Hence the unusual
   83.25 + * calls to schedule_timeout.
   83.26 + *
   83.27 + */
   83.28 +
   83.29 +#include <linux/sched.h>
   83.30 +#include <linux/poll.h>
   83.31 +#include <linux/spinlock.h>
   83.32 +#include "tpm.h"
   83.33 +
   83.34 +#define	TPM_MINOR			224	/* officially assigned */
   83.35 +
   83.36 +#define	TPM_BUFSIZE			2048
   83.37 +
   83.38 +static LIST_HEAD(tpm_chip_list);
   83.39 +static DEFINE_SPINLOCK(driver_lock);
   83.40 +static int dev_mask[32];
   83.41 +
   83.42 +static void user_reader_timeout(unsigned long ptr)
   83.43 +{
   83.44 +	struct tpm_chip *chip = (struct tpm_chip *) ptr;
   83.45 +
   83.46 +	down(&chip->buffer_mutex);
   83.47 +	atomic_set(&chip->data_pending, 0);
   83.48 +	memset(chip->data_buffer, 0, TPM_BUFSIZE);
   83.49 +	up(&chip->buffer_mutex);
   83.50 +}
   83.51 +
   83.52 +void tpm_time_expired(unsigned long ptr)
   83.53 +{
   83.54 +	int *exp = (int *) ptr;
   83.55 +	*exp = 1;
   83.56 +}
   83.57 +
   83.58 +EXPORT_SYMBOL_GPL(tpm_time_expired);
   83.59 +
   83.60 +/*
   83.61 + * Internal kernel interface to transmit TPM commands
   83.62 + */
   83.63 +static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
   83.64 +			    size_t bufsiz)
   83.65 +{
   83.66 +	ssize_t len;
   83.67 +	u32 count;
   83.68 +	__be32 *native_size;
   83.69 +
   83.70 +	native_size = (__force __be32 *) (buf + 2);
   83.71 +	count = be32_to_cpu(*native_size);
   83.72 +
   83.73 +	if (count == 0)
   83.74 +		return -ENODATA;
   83.75 +	if (count > bufsiz) {
   83.76 +		dev_err(&chip->pci_dev->dev,
   83.77 +			"invalid count value %x %zx \n", count, bufsiz);