debuggers.hg

changeset 15:5c0bf00e371d

REFRESH to UNSTABLE Aug 21 2008 changeset:18356 (tag 3.3.0-branched). NO debugger changes other than kdb_cmds.c and time.c build breaks. A diff (-r) with unstable-18356 will create debugger only patch
author Mukesh Rathor
date Tue Sep 02 16:34:53 2008 -0700 (2008-09-02)
parents aedb8b90840f
children 790c2f0eaf7c
files .hgignore Config.mk Makefile README buildconfigs/mk.linux-2.6-tip-latest buildconfigs/select-repository buildconfigs/src.git-clone config/StdGNU.mk docs/ChangeLog docs/Docs.mk docs/Makefile docs/misc/kexec_and_kdump.txt docs/misc/vtd.txt docs/src/user.tex docs/xen-api/Makefile docs/xen-api/coversheet.tex docs/xen-api/revision-history.tex docs/xen-api/xenapi-coversheet.tex docs/xen-api/xenapi-datamodel-graph.dot docs/xen-api/xenapi-datamodel.tex extras/mini-os/Config.mk extras/mini-os/Makefile extras/mini-os/arch/ia64/Makefile extras/mini-os/arch/ia64/common.c extras/mini-os/arch/ia64/minios-ia64.lds extras/mini-os/arch/ia64/mm.c extras/mini-os/arch/ia64/sched.c extras/mini-os/arch/ia64/time.c extras/mini-os/arch/x86/Makefile extras/mini-os/arch/x86/minios-x86_32.lds extras/mini-os/arch/x86/minios-x86_64.lds extras/mini-os/arch/x86/mm.c extras/mini-os/arch/x86/setup.c extras/mini-os/arch/x86/time.c extras/mini-os/arch/x86/traps.c extras/mini-os/arch/x86/x86_32.S extras/mini-os/blkfront.c extras/mini-os/console/console.c extras/mini-os/console/xencons_ring.c extras/mini-os/events.c extras/mini-os/fbfront.c extras/mini-os/fs-front.c extras/mini-os/gntmap.c extras/mini-os/gnttab.c extras/mini-os/hypervisor.c extras/mini-os/include/arch/cc.h extras/mini-os/include/arch/sys_arch.h extras/mini-os/include/blkfront.h extras/mini-os/include/byteswap.h extras/mini-os/include/console.h extras/mini-os/include/ctype.h extras/mini-os/include/err.h extras/mini-os/include/errno.h extras/mini-os/include/events.h extras/mini-os/include/fbfront.h extras/mini-os/include/fcntl.h extras/mini-os/include/fs.h extras/mini-os/include/gntmap.h extras/mini-os/include/gnttab.h extras/mini-os/include/hypervisor.h extras/mini-os/include/ia64/arch_spinlock.h extras/mini-os/include/ia64/atomic.h extras/mini-os/include/ia64/efi.h extras/mini-os/include/ia64/endian.h extras/mini-os/include/ia64/hypercall-ia64.h extras/mini-os/include/ia64/os.h extras/mini-os/include/ia64/traps.h extras/mini-os/include/kernel.h extras/mini-os/include/lib.h extras/mini-os/include/linux/types.h extras/mini-os/include/list.h extras/mini-os/include/lwipopts.h extras/mini-os/include/mm.h extras/mini-os/include/netfront.h extras/mini-os/include/pcifront.h extras/mini-os/include/posix/fcntl.h extras/mini-os/include/posix/limits.h extras/mini-os/include/posix/pthread.h extras/mini-os/include/posix/sys/mman.h extras/mini-os/include/posix/sys/select.h extras/mini-os/include/posix/sys/stat.h extras/mini-os/include/posix/unistd.h extras/mini-os/include/sched.h extras/mini-os/include/semaphore.h extras/mini-os/include/spinlock.h extras/mini-os/include/sys/lock.h extras/mini-os/include/time.h extras/mini-os/include/types.h extras/mini-os/include/wait.h extras/mini-os/include/waittypes.h extras/mini-os/include/x86/arch_mm.h extras/mini-os/include/x86/arch_sched.h extras/mini-os/include/x86/arch_spinlock.h extras/mini-os/include/x86/os.h extras/mini-os/include/x86/traps.h extras/mini-os/include/x86/x86_32/hypercall-x86_32.h extras/mini-os/include/x86/x86_64/hypercall-x86_64.h extras/mini-os/include/xenbus.h extras/mini-os/include/xmalloc.h extras/mini-os/kernel.c extras/mini-os/lib/ctype.c extras/mini-os/lib/printf.c extras/mini-os/lib/sys.c extras/mini-os/lib/xmalloc.c extras/mini-os/lock.c extras/mini-os/lwip-net.c extras/mini-os/main-caml.c extras/mini-os/main.c extras/mini-os/minios.mk extras/mini-os/mm.c extras/mini-os/netfront.c extras/mini-os/pcifront.c extras/mini-os/sched.c extras/mini-os/xenbus/xenbus.c stubdom/Makefile stubdom/README stubdom/binutils.patch stubdom/c/Makefile stubdom/c/main.c stubdom/caml/Makefile stubdom/caml/main-caml.c stubdom/gcc.patch stubdom/grub.patches/00cvs stubdom/grub.patches/10graphics.diff stubdom/grub.patches/20print_func.diff stubdom/grub.patches/30savedefault.diff stubdom/grub.patches/40ext3_256byte_inode.diff stubdom/grub.patches/99minios stubdom/grub/Makefile stubdom/grub/boot-x86_32.S stubdom/grub/boot-x86_64.S stubdom/grub/config.h stubdom/grub/kexec.c stubdom/grub/mini-os.c stubdom/grub/mini-os.h stubdom/grub/osdep.h stubdom/libpci.config.h stubdom/libpci.config.mak stubdom/lwip.patch-cvs stubdom/newlib.patch stubdom/pciutils.patch stubdom/stubdom-dm tools/Makefile tools/blktap/Makefile tools/blktap/drivers/Makefile tools/blktap/drivers/blktapctrl.c tools/blktap/drivers/blktapctrl.h tools/blktap/drivers/blktapctrl_linux.c tools/blktap/drivers/block-aio.c tools/blktap/drivers/block-qcow.c tools/blktap/drivers/block-qcow2.c tools/blktap/drivers/block-ram.c tools/blktap/drivers/block-sync.c tools/blktap/drivers/check_gcrypt tools/blktap/drivers/img2qcow.c tools/blktap/drivers/qcow-create.c tools/blktap/drivers/qcow2raw.c tools/blktap/drivers/tapdisk.c tools/blktap/lib/Makefile tools/blktap/lib/blktaplib.h tools/blktap/lib/xenbus.c tools/console/Makefile tools/console/daemon/io.c tools/cross-install tools/debugger/xenitp/xenitp.c tools/examples/Makefile tools/examples/README tools/examples/blktap tools/examples/block tools/examples/network-bridge tools/examples/vscsi tools/examples/vtpm-common.sh tools/examples/xen-backend.agent tools/examples/xen-backend.rules tools/examples/xend-config-xenapi.sxp tools/examples/xend-config.sxp tools/examples/xm-config-xenapi.xml tools/examples/xmexample.hvm tools/examples/xmexample.hvm-dm tools/examples/xmexample.hvm-stubdom tools/examples/xmexample.pv-grub tools/examples/xmexample.vti tools/examples/xmexample1 tools/examples/xmexample2 tools/examples/xmexample3 tools/firmware/extboot/Makefile tools/firmware/hvmloader/Makefile tools/firmware/hvmloader/acpi/acpi2_0.h tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/acpi/dsdt.asl tools/firmware/hvmloader/acpi/dsdt.c tools/firmware/hvmloader/config.h tools/firmware/hvmloader/hvmloader.c tools/firmware/hvmloader/mp_tables.c tools/firmware/hvmloader/smbios.c tools/firmware/hvmloader/smp.c tools/firmware/hvmloader/util.c tools/firmware/hvmloader/util.h tools/firmware/rombios/32bit/32bitbios.c tools/firmware/rombios/32bit/Makefile tools/firmware/rombios/32bit/tcgbios/Makefile tools/firmware/rombios/32bit/tcgbios/tcgbios.c tools/firmware/rombios/32bit/tcgbios/tcgbios.h tools/firmware/rombios/32bit/tcgbios/tpm_drivers.c tools/firmware/rombios/32bit/util.c tools/firmware/rombios/32bit/util.h tools/firmware/rombios/32bitgateway.c tools/firmware/rombios/32bitprotos.h tools/firmware/rombios/Makefile tools/firmware/rombios/rombios.c tools/firmware/vgabios/ChangeLog tools/firmware/vgabios/Makefile tools/firmware/vgabios/README tools/firmware/vgabios/TODO tools/firmware/vgabios/biossums.c tools/firmware/vgabios/clext.c tools/firmware/vgabios/vbe.c tools/firmware/vgabios/vbe.h tools/firmware/vgabios/vbe_display_api.txt tools/firmware/vgabios/vbetables-gen.c tools/firmware/vgabios/vbetables.h tools/firmware/vgabios/vgabios.c tools/firmware/vgabios/vgatables.h tools/flask/libflask/flask_op.c tools/flask/libflask/include/flask.h tools/fs-back/fs-backend.c tools/fs-back/fs-backend.h tools/fs-back/fs-ops.c tools/fs-back/fs-xenbus.c tools/include/xen-sys/MiniOS/privcmd.h tools/include/xen-sys/NetBSD/privcmd.h tools/ioemu/Makefile.target tools/ioemu/audio/audio.c tools/ioemu/audio/audio.h tools/ioemu/audio/audio_int.h tools/ioemu/audio/audio_template.h tools/ioemu/audio/sys-queue.h tools/ioemu/block-vbd.c tools/ioemu/cocoa.m tools/ioemu/hw/cirrus_vga.c tools/ioemu/hw/e1000.c tools/ioemu/hw/pass-through.c tools/ioemu/hw/pass-through.h tools/ioemu/hw/pc.c tools/ioemu/hw/pci.c tools/ioemu/hw/pci_emulation.c tools/ioemu/hw/pci_emulation.h tools/ioemu/hw/piix4acpi.c tools/ioemu/hw/pl110.c tools/ioemu/hw/pt-msi.c tools/ioemu/hw/pt-msi.h tools/ioemu/hw/serial.c tools/ioemu/hw/tcx.c tools/ioemu/hw/usb-msd.c tools/ioemu/hw/usb.h tools/ioemu/hw/vga.c tools/ioemu/hw/vga_int.h tools/ioemu/hw/xen_console.c tools/ioemu/hw/xen_platform.c tools/ioemu/hw/xenfb.c tools/ioemu/hw/xenfb.h tools/ioemu/monitor.c tools/ioemu/sdl.c tools/ioemu/target-i386-dm/exec-dm.c tools/ioemu/target-i386-dm/helper2.c tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c tools/ioemu/xenfbfront.c tools/ioemu/xenstore.c tools/libaio/src/Makefile tools/libfsimage/ext2fs/fsys_ext2fs.c tools/libfsimage/fat/fsys_fat.c tools/libfsimage/iso9660/fsys_iso9660.c tools/libfsimage/reiserfs/fsys_reiserfs.c tools/libfsimage/ufs/fsys_ufs.c tools/libfsimage/zfs/fsys_zfs.c tools/libxc/Makefile tools/libxc/ia64/dom_fw_acpi.c tools/libxc/ia64/xc_ia64_hvm_build.c tools/libxc/ia64/xc_ia64_linux_restore.c tools/libxc/ia64/xc_ia64_linux_save.c tools/libxc/ia64/xc_ia64_save_restore.h tools/libxc/xc_core.c tools/libxc/xc_core_ia64.c tools/libxc/xc_core_ia64.h tools/libxc/xc_cpuid_x86.c tools/libxc/xc_dom.h tools/libxc/xc_dom_boot.c tools/libxc/xc_dom_core.c tools/libxc/xc_dom_x86.c tools/libxc/xc_domain.c tools/libxc/xc_domain_restore.c tools/libxc/xc_domain_save.c tools/libxc/xc_hvm_build.c tools/libxc/xc_linux.c tools/libxc/xc_minios.c tools/libxc/xc_misc.c tools/libxc/xc_netbsd.c tools/libxc/xc_pagetab.c tools/libxc/xc_physdev.c tools/libxc/xc_pm.c tools/libxc/xc_private.c tools/libxc/xc_private.h tools/libxc/xc_ptrace.c tools/libxc/xc_ptrace_core.c tools/libxc/xc_resume.c tools/libxc/xc_solaris.c tools/libxc/xenctrl.h tools/libxc/xg_private.c tools/libxc/xg_private.h tools/libxc/xg_save_restore.h tools/misc/Makefile tools/misc/nsplitd/nsplitd.c tools/misc/xend tools/misc/xenperf.c tools/pygrub/src/pygrub tools/python/get-path tools/python/install-wrap tools/python/xen/lowlevel/acm/acm.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/lowlevel/xs/xs.c tools/python/xen/util/acmpolicy.py tools/python/xen/util/blkif.py tools/python/xen/util/oshelp.py tools/python/xen/util/pci.py tools/python/xen/util/utils.py tools/python/xen/util/vscsi_util.py tools/python/xen/util/xsconstants.py tools/python/xen/util/xsm/acm/acm.py tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendConstants.py tools/python/xen/xend/XendDPCI.py tools/python/xen/xend/XendDevices.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/XendOptions.py tools/python/xen/xend/XendPIF.py tools/python/xen/xend/XendPPCI.py tools/python/xen/xend/XendXSPolicyAdmin.py tools/python/xen/xend/balloon.py tools/python/xen/xend/image.py tools/python/xen/xend/osdep.py tools/python/xen/xend/server/DevController.py tools/python/xen/xend/server/SrvDomain.py tools/python/xen/xend/server/XMLRPCServer.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/pciif.py tools/python/xen/xend/server/relocate.py tools/python/xen/xend/server/vscsiif.py tools/python/xen/xend/xenstore/xswatch.py tools/python/xen/xm/console.py tools/python/xen/xm/create.dtd tools/python/xen/xm/create.py tools/python/xen/xm/main.py tools/python/xen/xm/migrate.py tools/python/xen/xm/shutdown.py tools/python/xen/xm/xenapi_create.py tools/tests/test_x86_emulator.c tools/vnet/vnet-module/varp_util.h tools/vnet/vnet-module/vnet.c tools/vtpm_manager/migration/vtpm_migratord_handler.c tools/xcutils/xc_save.c tools/xenballoon/xenballoon-monitor tools/xenballoon/xenballoon.conf tools/xenballoon/xenballoond tools/xenballoon/xenballoond.README tools/xenballoon/xenballoond.init tools/xenmon/Makefile tools/xenmon/xenbaked.c tools/xenstat/libxenstat/Makefile tools/xenstat/libxenstat/src/xenstat.c tools/xenstat/libxenstat/src/xenstat_linux.c tools/xenstat/xentop/xentop.c tools/xenstore/hashtable.c tools/xenstore/list.h tools/xenstore/talloc.c tools/xenstore/tdb.c tools/xenstore/xenstore_client.c tools/xenstore/xenstored_core.c tools/xentrace/formats tools/xentrace/xenctx.c tools/xentrace/xentrace.c tools/xentrace/xentrace_format tools/xm-test/lib/XmTestLib/block_utils.py tools/xm-test/tests/security-acm/10_security-acm_pol_update.py unmodified_drivers/linux-2.6/README unmodified_drivers/linux-2.6/platform-pci/evtchn.c unmodified_drivers/linux-2.6/platform-pci/machine_reboot.c unmodified_drivers/linux-2.6/platform-pci/panic-handler.c xen/Makefile xen/arch/ia64/Rules.mk xen/arch/ia64/asm-offsets.c xen/arch/ia64/linux-xen/Makefile xen/arch/ia64/linux-xen/README.origin xen/arch/ia64/linux-xen/acpi.c xen/arch/ia64/linux-xen/acpi_numa.c xen/arch/ia64/linux-xen/efi.c xen/arch/ia64/linux-xen/entry.S xen/arch/ia64/linux-xen/iosapic.c xen/arch/ia64/linux-xen/mca_asm.S xen/arch/ia64/linux-xen/mm_contig.c xen/arch/ia64/linux-xen/mm_numa.c xen/arch/ia64/linux-xen/sal.c xen/arch/ia64/linux-xen/setup.c xen/arch/ia64/linux-xen/smpboot.c xen/arch/ia64/linux/Makefile xen/arch/ia64/linux/README.origin xen/arch/ia64/linux/ia64_ksyms.c xen/arch/ia64/linux/numa.c xen/arch/ia64/vmx/optvfault.S xen/arch/ia64/vmx/vmmu.c xen/arch/ia64/vmx/vmx_entry.S xen/arch/ia64/vmx/vmx_hypercall.c xen/arch/ia64/vmx/vmx_init.c xen/arch/ia64/vmx/vmx_ivt.S xen/arch/ia64/vmx/vmx_minstate.h xen/arch/ia64/vmx/vmx_phy_mode.c xen/arch/ia64/vmx/vmx_vcpu.c xen/arch/ia64/vmx/vtlb.c xen/arch/ia64/xen/Makefile xen/arch/ia64/xen/acpi.c xen/arch/ia64/xen/dom0_ops.c xen/arch/ia64/xen/dom_fw_common.c xen/arch/ia64/xen/dom_fw_dom0.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/faults.c xen/arch/ia64/xen/fw_emul.c xen/arch/ia64/xen/hypercall.c xen/arch/ia64/xen/irq.c xen/arch/ia64/xen/ivt.S xen/arch/ia64/xen/machine_kexec.c xen/arch/ia64/xen/mm.c xen/arch/ia64/xen/mm_init.c xen/arch/ia64/xen/pcdp.c xen/arch/ia64/xen/regionreg.c xen/arch/ia64/xen/relocate_kernel.S xen/arch/ia64/xen/vcpu.c xen/arch/ia64/xen/vhpt.c xen/arch/ia64/xen/xenasm.S xen/arch/ia64/xen/xenmem.c xen/arch/ia64/xen/xensetup.c xen/arch/x86/Makefile xen/arch/x86/acpi/boot.c xen/arch/x86/acpi/cpu_idle.c xen/arch/x86/acpi/cpufreq/Makefile xen/arch/x86/acpi/cpufreq/cpufreq.c xen/arch/x86/acpi/cpufreq/cpufreq_ondemand.c xen/arch/x86/acpi/cpufreq/powernow.c xen/arch/x86/acpi/cpufreq/utility.c xen/arch/x86/acpi/pmstat.c xen/arch/x86/acpi/power.c xen/arch/x86/cpu/amd.c xen/arch/x86/cpu/intel.c xen/arch/x86/cpu/mcheck/Makefile xen/arch/x86/cpu/mcheck/amd_f10.c xen/arch/x86/cpu/mcheck/amd_k8.c xen/arch/x86/cpu/mcheck/amd_nonfatal.c xen/arch/x86/cpu/mcheck/k7.c xen/arch/x86/cpu/mcheck/mce.c xen/arch/x86/cpu/mcheck/mce.h xen/arch/x86/cpu/mcheck/non-fatal.c xen/arch/x86/cpu/mcheck/x86_mca.h xen/arch/x86/crash.c xen/arch/x86/domain.c xen/arch/x86/domain_build.c xen/arch/x86/domctl.c xen/arch/x86/hpet.c xen/arch/x86/hvm/emulate.c xen/arch/x86/hvm/hpet.c xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/i8254.c xen/arch/x86/hvm/io.c xen/arch/x86/hvm/mtrr.c xen/arch/x86/hvm/pmtimer.c xen/arch/x86/hvm/rtc.c xen/arch/x86/hvm/stdvga.c xen/arch/x86/hvm/svm/emulate.c xen/arch/x86/hvm/svm/intr.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vioapic.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmsi.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/hvm/vmx/vpmu_core2.c xen/arch/x86/hvm/vpic.c xen/arch/x86/hvm/vpt.c xen/arch/x86/i8259.c xen/arch/x86/io_apic.c xen/arch/x86/ioport_emulate.c xen/arch/x86/irq.c xen/arch/x86/machine_kexec.c xen/arch/x86/mm.c xen/arch/x86/mm/hap/p2m-ept.c xen/arch/x86/mm/p2m.c xen/arch/x86/mm/shadow/common.c xen/arch/x86/mm/shadow/multi.c xen/arch/x86/mm/shadow/multi.h xen/arch/x86/mm/shadow/private.h xen/arch/x86/mm/shadow/types.h xen/arch/x86/msi.c xen/arch/x86/nmi.c xen/arch/x86/numa.c xen/arch/x86/oprofile/nmi_int.c xen/arch/x86/physdev.c xen/arch/x86/platform_hypercall.c xen/arch/x86/setup.c xen/arch/x86/shutdown.c xen/arch/x86/smpboot.c xen/arch/x86/tboot.c xen/arch/x86/time.c xen/arch/x86/trace.c xen/arch/x86/traps.c xen/arch/x86/x86_32/asm-offsets.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/asm-offsets.c xen/arch/x86/x86_64/compat/entry.S xen/arch/x86/x86_64/compat/mm.c xen/arch/x86/x86_64/compat/traps.c xen/arch/x86/x86_64/cpu_idle.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/mm.c xen/arch/x86/x86_64/physdev.c xen/arch/x86/x86_64/traps.c xen/arch/x86/x86_emulate/x86_emulate.c xen/arch/x86/x86_emulate/x86_emulate.h xen/common/compat/domain.c xen/common/compat/grant_table.c xen/common/compat/memory.c xen/common/domain.c xen/common/domctl.c xen/common/event_channel.c xen/common/grant_table.c xen/common/hvm/save.c xen/common/kexec.c xen/common/keyhandler.c xen/common/libelf/libelf-private.h xen/common/memory.c xen/common/page_alloc.c xen/common/sched_sedf.c xen/common/schedule.c xen/common/shutdown.c xen/common/stop_machine.c xen/common/timer.c xen/common/version.c xen/drivers/acpi/Makefile xen/drivers/acpi/numa.c xen/drivers/acpi/osl.c xen/drivers/acpi/reboot.c xen/drivers/acpi/tables.c xen/drivers/acpi/tables/Makefile xen/drivers/acpi/tables/tbfadt.c xen/drivers/acpi/tables/tbinstal.c xen/drivers/acpi/tables/tbutils.c xen/drivers/acpi/tables/tbxface.c xen/drivers/acpi/tables/tbxfroot.c xen/drivers/acpi/utglobal.c xen/drivers/acpi/utilities/Makefile xen/drivers/acpi/utilities/utglobal.c xen/drivers/acpi/utilities/utmisc.c xen/drivers/char/console.c xen/drivers/char/serial.c xen/drivers/passthrough/Makefile xen/drivers/passthrough/amd/Makefile xen/drivers/passthrough/amd/iommu_acpi.c xen/drivers/passthrough/amd/iommu_detect.c xen/drivers/passthrough/amd/iommu_init.c xen/drivers/passthrough/amd/iommu_intr.c xen/drivers/passthrough/amd/iommu_map.c xen/drivers/passthrough/amd/pci_amd_iommu.c xen/drivers/passthrough/io.c xen/drivers/passthrough/iommu.c xen/drivers/passthrough/pci.c xen/drivers/passthrough/vtd/dmar.c xen/drivers/passthrough/vtd/dmar.h xen/drivers/passthrough/vtd/extern.h xen/drivers/passthrough/vtd/intremap.c xen/drivers/passthrough/vtd/iommu.c xen/drivers/passthrough/vtd/iommu.h xen/drivers/passthrough/vtd/qinval.c xen/drivers/passthrough/vtd/utils.c xen/drivers/passthrough/vtd/vtd.h xen/drivers/passthrough/vtd/x86/vtd.c xen/include/Makefile xen/include/acpi/acnamesp.h xen/include/acpi/actables.h xen/include/acpi/cpufreq/cpufreq.h xen/include/acpi/cpufreq/processor_perf.h xen/include/acpi/platform/aclinux.h xen/include/asm-ia64/bug.h xen/include/asm-ia64/config.h xen/include/asm-ia64/linux-null/asm-generic/pci-dma-compat.h xen/include/asm-ia64/linux-null/asm/cyclone.h xen/include/asm-ia64/linux-null/asm/scatterlist.h xen/include/asm-ia64/linux-null/asm/xen/hypervisor.h xen/include/asm-ia64/linux-null/linux/node.h xen/include/asm-ia64/linux-null/linux/platform.h xen/include/asm-ia64/linux-null/linux/pm.h xen/include/asm-ia64/linux-xen/asm/README.origin xen/include/asm-ia64/linux-xen/asm/acpi.h xen/include/asm-ia64/linux-xen/asm/mca_asm.h xen/include/asm-ia64/linux-xen/asm/numa.h xen/include/asm-ia64/linux-xen/asm/pal.h xen/include/asm-ia64/linux-xen/asm/pci.h xen/include/asm-ia64/linux-xen/asm/percpu.h xen/include/asm-ia64/linux-xen/asm/sal.h xen/include/asm-ia64/linux-xen/asm/system.h xen/include/asm-ia64/linux-xen/linux/efi.h xen/include/asm-ia64/linux/README.origin xen/include/asm-ia64/linux/asm/README.origin xen/include/asm-ia64/linux/asm/sal.h xen/include/asm-ia64/linux/numa.h xen/include/asm-ia64/mm.h xen/include/asm-ia64/mmu_context.h xen/include/asm-ia64/regionreg.h xen/include/asm-ia64/vhpt.h xen/include/asm-ia64/vmmu.h xen/include/asm-ia64/vmx_pal_vsa.h xen/include/asm-ia64/vmx_phy_mode.h xen/include/asm-ia64/vmx_vcpu.h xen/include/asm-ia64/xenpage.h xen/include/asm-ia64/xenprocessor.h xen/include/asm-ia64/xensystem.h xen/include/asm-x86/amd-iommu.h xen/include/asm-x86/config.h xen/include/asm-x86/domain.h xen/include/asm-x86/guest_access.h xen/include/asm-x86/hpet.h xen/include/asm-x86/hvm/domain.h xen/include/asm-x86/hvm/guest_access.h xen/include/asm-x86/hvm/hvm.h xen/include/asm-x86/hvm/support.h xen/include/asm-x86/hvm/svm/amd-iommu-defs.h xen/include/asm-x86/hvm/svm/amd-iommu-proto.h xen/include/asm-x86/hvm/svm/emulate.h xen/include/asm-x86/hvm/trace.h xen/include/asm-x86/hvm/vcpu.h xen/include/asm-x86/hvm/vioapic.h xen/include/asm-x86/hvm/vmx/vmcs.h xen/include/asm-x86/hvm/vmx/vmx.h xen/include/asm-x86/hvm/vpic.h xen/include/asm-x86/hvm/vpt.h xen/include/asm-x86/io_apic.h xen/include/asm-x86/mm.h xen/include/asm-x86/msi.h xen/include/asm-x86/msr-index.h xen/include/asm-x86/mtrr.h xen/include/asm-x86/p2m.h xen/include/asm-x86/percpu.h xen/include/asm-x86/perfc_defn.h xen/include/asm-x86/softirq.h xen/include/asm-x86/spinlock.h xen/include/asm-x86/tboot.h xen/include/asm-x86/time.h xen/include/asm-x86/traps.h xen/include/asm-x86/uaccess.h xen/include/asm-x86/x86_32/uaccess.h xen/include/asm-x86/x86_64/uaccess.h xen/include/public/arch-ia64.h xen/include/public/arch-x86/xen-mca.h xen/include/public/arch-x86/xen.h xen/include/public/domctl.h xen/include/public/hvm/hvm_op.h xen/include/public/hvm/params.h xen/include/public/io/fsif.h xen/include/public/io/pciif.h xen/include/public/kexec.h xen/include/public/memory.h xen/include/public/physdev.h xen/include/public/sysctl.h xen/include/public/trace.h xen/include/public/xen-compat.h xen/include/public/xen.h xen/include/public/xsm/flask_op.h xen/include/xen/acpi.h xen/include/xen/compat.h xen/include/xen/compiler.h xen/include/xen/domain.h xen/include/xen/elfcore.h xen/include/xen/event.h xen/include/xen/hvm/iommu.h xen/include/xen/iommu.h xen/include/xen/irq.h xen/include/xen/mm.h xen/include/xen/pci.h xen/include/xen/sched.h xen/include/xen/serial.h xen/include/xen/shutdown.h xen/include/xen/spinlock.h xen/include/xen/time.h xen/include/xen/timer.h xen/include/xen/xencomm.h xen/include/xsm/xsm.h xen/kdb/kdb_cmds.c xen/tools/get-fields.sh xen/xsm/dummy.c xen/xsm/flask/avc.c xen/xsm/flask/flask_op.c xen/xsm/flask/hooks.c xen/xsm/flask/include/avc.h
line diff
     1.1 --- a/.hgignore	Fri Aug 29 15:47:21 2008 -0700
     1.2 +++ b/.hgignore	Tue Sep 02 16:34:53 2008 -0700
     1.3 @@ -1,6 +1,7 @@
     1.4  .*\.a$
     1.5  .*\.cmi$
     1.6  .*\.cmo$
     1.7 +.*\.cmx$
     1.8  .*\.d$
     1.9  .*\.o$
    1.10  .*\.opic$
    1.11 @@ -20,8 +21,7 @@
    1.12  ^[^/]*\.bz2$
    1.13  ^\.config$
    1.14  ^\.pc
    1.15 -^TAGS$
    1.16 -^tags$
    1.17 +(^|/)(tags|TAGS)$
    1.18  ^build-.*$
    1.19  ^dist/.*$
    1.20  ^docs/.*\.aux$
    1.21 @@ -59,8 +59,12 @@
    1.22  ^docs/xen-api/vm_lifecycle.eps$
    1.23  ^docs/xen-api/xenapi-datamodel-graph.eps$
    1.24  ^docs/xen-api/xenapi.out$
    1.25 -^extras/mini-os/h/hypervisor-ifs$
    1.26 -^extras/mini-os/h/xen-public$
    1.27 +^extras/mini-os/arch/ia64/gen_off.s$
    1.28 +^extras/mini-os/include/mini-os$
    1.29 +^extras/mini-os/include/ia64/mini-os$
    1.30 +^extras/mini-os/include/ia64/offsets.h$
    1.31 +^extras/mini-os/include/x86/mini-os$
    1.32 +^extras/mini-os/include/xen$
    1.33  ^extras/mini-os/mini-os.*$
    1.34  ^install/.*$
    1.35  ^linux-[^/]*-paravirt/.*$
    1.36 @@ -86,13 +90,16 @@
    1.37  ^stubdom/gcc-.*$
    1.38  ^stubdom/include$
    1.39  ^stubdom/ioemu$
    1.40 -^stubdom/libxc$
    1.41 +^stubdom/libxc-.*$
    1.42  ^stubdom/lwip-.*$
    1.43 -^stubdom/mini-os$
    1.44 +^stubdom/mini-os-.*$
    1.45 +^stubdom/mk-headers-.*$
    1.46  ^stubdom/newlib-.*$
    1.47  ^stubdom/pciutils-.*$
    1.48  ^stubdom/zlib-.*$
    1.49 -^tools/.*/TAGS$
    1.50 +^stubdom/grub-.*$
    1.51 +^stubdom/lwip/
    1.52 +^stubdom/ioemu/
    1.53  ^tools/.*/build/lib.*/.*\.py$
    1.54  ^tools/blktap/Makefile\.smh$
    1.55  ^tools/blktap/drivers/blktapctrl$
    1.56 @@ -134,10 +141,10 @@
    1.57  ^tools/firmware/rombios/_rombios[^/]*_\.c$
    1.58  ^tools/firmware/rombios/rombios[^/]*\.s$
    1.59  ^tools/firmware/rombios/32bit/32bitbios_flat\.h$
    1.60 -^tools/firmware/vmxassist/gen$
    1.61 -^tools/firmware/vmxassist/offsets\.h$
    1.62 -^tools/firmware/vmxassist/vmxassist$
    1.63 +^tools/firmware/vgabios/vbetables-gen$
    1.64 +^tools/firmware/vgabios/vbetables\.h$
    1.65  ^tools/flask/loadpolicy/flask-loadpolicy$
    1.66 +^tools/fs-back/fs-backend$
    1.67  ^tools/include/xen/.*$
    1.68  ^tools/include/xen-foreign/.*\.(c|h|size)$
    1.69  ^tools/include/xen-foreign/checker$
    1.70 @@ -247,10 +254,11 @@
    1.71  ^tools/xm-test/lib/XmTestLib/config.py$
    1.72  ^tools/xm-test/lib/XmTestReport/xmtest.py$
    1.73  ^tools/xm-test/tests/.*\.test$
    1.74 +^tools/ioemu-remote
    1.75 +^tools/ioemu-dir$
    1.76  ^xen/\.banner.*$
    1.77  ^xen/BLOG$
    1.78  ^xen/System.map$
    1.79 -^xen/TAGS$
    1.80  ^xen/arch/x86/asm-offsets\.s$
    1.81  ^xen/arch/x86/boot/mkelf32$
    1.82  ^xen/arch/x86/xen\.lds$
    1.83 @@ -268,7 +276,6 @@
    1.84  ^xen/include/xen/acm_policy\.h$
    1.85  ^xen/include/xen/banner\.h$
    1.86  ^xen/include/xen/compile\.h$
    1.87 -^xen/tags$
    1.88  ^xen/tools/figlet/figlet$
    1.89  ^xen/tools/symbols$
    1.90  ^xen/xen$
     2.1 --- a/Config.mk	Fri Aug 29 15:47:21 2008 -0700
     2.2 +++ b/Config.mk	Tue Sep 02 16:34:53 2008 -0700
     2.3 @@ -19,6 +19,8 @@ HOSTCFLAGS += -fno-strict-aliasing
     2.4  
     2.5  DISTDIR     ?= $(XEN_ROOT)/dist
     2.6  DESTDIR     ?= /
     2.7 +DOCDIR      ?= /usr/share/doc/xen
     2.8 +MANDIR      ?= /usr/share/man
     2.9  
    2.10  # Allow phony attribute to be listed as dependency rather than fake target
    2.11  .PHONY: .phony
    2.12 @@ -85,6 +87,18 @@ XSM_ENABLE ?= n
    2.13  FLASK_ENABLE ?= n
    2.14  ACM_SECURITY ?= n
    2.15  
    2.16 +QEMU_REMOTE=http://xenbits.xensource.com/git-http/qemu-xen-unstable.git
    2.17 +
    2.18 +# Specify which qemu-dm to use. This may be `ioemu' to use the old
    2.19 +# Mercurial in-tree version, or a local directory, or a git URL.
    2.20 +# CONFIG_QEMU   ?= ioemu
    2.21 +# CONFIG_QEMU   ?= ../qemu-xen.git
    2.22 +ifeq ($(XEN_TARGET_ARCH),ia64)
    2.23 +CONFIG_QEMU   ?= ioemu
    2.24 +else
    2.25 +CONFIG_QEMU   ?= $(QEMU_REMOTE)
    2.26 +endif
    2.27 +
    2.28  # Optional components
    2.29  XENSTAT_XENTOP     ?= y
    2.30  VTPM_TOOLS         ?= n
     3.1 --- a/Makefile	Fri Aug 29 15:47:21 2008 -0700
     3.2 +++ b/Makefile	Tue Sep 02 16:34:53 2008 -0700
     3.3 @@ -15,12 +15,16 @@ include buildconfigs/Rules.mk
     3.4  
     3.5  # build and install everything into the standard system directories
     3.6  .PHONY: install
     3.7 -install: install-xen install-kernels install-tools install-docs
     3.8 +install: install-xen install-kernels install-tools install-stubdom install-docs
     3.9  
    3.10  .PHONY: build
    3.11  build: kernels
    3.12  	$(MAKE) -C xen build
    3.13  	$(MAKE) -C tools build
    3.14 +	$(MAKE) -C stubdom build
    3.15 +ifeq (x86_64,$(XEN_TARGET_ARCH))
    3.16 +	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
    3.17 +endif
    3.18  	$(MAKE) -C docs build
    3.19  
    3.20  # The test target is for unit tests that can run without an installation.  Of
    3.21 @@ -33,7 +37,7 @@ test:
    3.22  # build and install everything into local dist directory
    3.23  .PHONY: dist
    3.24  dist: DESTDIR=$(DISTDIR)/install
    3.25 -dist: dist-xen dist-kernels dist-tools dist-docs
    3.26 +dist: dist-xen dist-kernels dist-tools dist-stubdom dist-docs
    3.27  	$(INSTALL_DIR) $(DISTDIR)/check
    3.28  	$(INSTALL_DATA) ./COPYING $(DISTDIR)
    3.29  	$(INSTALL_DATA) ./README $(DISTDIR)
    3.30 @@ -44,10 +48,11 @@ dist-%: install-%
    3.31  	@: # do nothing
    3.32  
    3.33  # Legacy dist targets
    3.34 -.PHONY: xen tools kernels docs
    3.35 +.PHONY: xen tools stubdom kernels docs
    3.36  xen: dist-xen
    3.37  tools: dist-tools
    3.38  kernels: dist-kernels
    3.39 +stubdom: dist-stubdom
    3.40  docs: dist-docs
    3.41  
    3.42  .PHONY: prep-kernels
    3.43 @@ -66,6 +71,13 @@ install-tools:
    3.44  install-kernels:
    3.45  	for i in $(XKERNELS) ; do $(MAKE) $$i-install || exit 1; done
    3.46  
    3.47 +.PHONY: install-stubdom
    3.48 +install-stubdom:
    3.49 +	$(MAKE) -C stubdom install
    3.50 +ifeq (x86_64,$(XEN_TARGET_ARCH))
    3.51 +	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
    3.52 +endif
    3.53 +
    3.54  .PHONY: install-docs
    3.55  install-docs:
    3.56  	sh ./docs/check_pkgs && $(MAKE) -C docs install || true
    3.57 @@ -102,6 +114,10 @@ world:
    3.58  clean::
    3.59  	$(MAKE) -C xen clean
    3.60  	$(MAKE) -C tools clean
    3.61 +	$(MAKE) -C stubdom crossclean
    3.62 +ifeq (x86_64,$(XEN_TARGET_ARCH))
    3.63 +	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom crossclean
    3.64 +endif
    3.65  	$(MAKE) -C docs clean
    3.66  
    3.67  # clean, but blow away kernel build tree plus tarballs
    3.68 @@ -109,6 +125,10 @@ clean::
    3.69  distclean:
    3.70  	$(MAKE) -C xen distclean
    3.71  	$(MAKE) -C tools distclean
    3.72 +	$(MAKE) -C stubdom distclean
    3.73 +ifeq (x86_64,$(XEN_TARGET_ARCH))
    3.74 +	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom distclean
    3.75 +endif
    3.76  	$(MAKE) -C docs distclean
    3.77  	rm -rf dist patches/tmp
    3.78  	for i in $(ALLKERNELS) ; do $(MAKE) $$i-delete ; done
    3.79 @@ -132,6 +152,7 @@ help:
    3.80  	@echo '  install-xen      - build and install the Xen hypervisor'
    3.81  	@echo '  install-tools    - build and install the control tools'
    3.82  	@echo '  install-kernels  - build and install guest kernels'
    3.83 +	@echo '  install-stubdom  - build and install the stubdomain images'
    3.84  	@echo '  install-docs     - build and install user documentation'
    3.85  	@echo ''
    3.86  	@echo 'Building targets:'
    3.87 @@ -140,6 +161,7 @@ help:
    3.88  	@echo '                     trees then make dist'
    3.89  	@echo '  xen              - build and install Xen hypervisor'
    3.90  	@echo '  tools            - build and install tools'
    3.91 +	@echo '  stubdom          - build and install the stubdomain images'
    3.92  	@echo '  kernels          - build and install guest kernels'
    3.93  	@echo '  kbuild           - synonym for make kernels'
    3.94  	@echo '  docs             - build and install user documentation'
    3.95 @@ -214,7 +236,7 @@ linux26:
    3.96  # tboot targets
    3.97  #
    3.98  
    3.99 -TBOOT_TARFILE = tboot-20071128.tar.gz
   3.100 +TBOOT_TARFILE = tboot-20080613.tar.gz
   3.101  TBOOT_BASE_URL = http://downloads.sourceforge.net/tboot
   3.102  
   3.103  .PHONY: build-tboot
     4.1 --- a/README	Fri Aug 29 15:47:21 2008 -0700
     4.2 +++ b/README	Tue Sep 02 16:34:53 2008 -0700
     4.3 @@ -224,6 +224,6 @@ tarballs of the source.  Instructions in
     4.4  to modify grub.conf to use tboot to launch Xen.
     4.5  
     4.6  There are optional targets as part of Xen's top-level makefile that will
     4.7 -downlaod and build tboot: install-tboot, build-tboot, dist-tboot, clean-tboot.
     4.8 +download and build tboot: install-tboot, build-tboot, dist-tboot, clean-tboot.
     4.9  These will download the latest tar file from the SourceForge site using wget,
    4.10  then build/install/dist according to Xen's settings.
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/buildconfigs/mk.linux-2.6-tip-latest	Tue Sep 02 16:34:53 2008 -0700
     5.3 @@ -0,0 +1,14 @@
     5.4 +XEN_LINUX_SOURCE ?= git-clone
     5.5 +LINUX_VER ?= 2.6-x86-latest
     5.6 +
     5.7 +IMAGE_TARGET ?= bzImage vmlinux
     5.8 +
     5.9 +XEN_LINUX_CONFIG_UPDATE := buildconfigs/enable-xen-config
    5.10 +
    5.11 +XEN_LINUX_GIT_URL ?= git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-tip.git
    5.12 +XEN_LINUX_GIT_REMOTENAME ?= x86
    5.13 +XEN_LINUX_GIT_REMOTEBRANCH ?= auto-latest
    5.14 +
    5.15 +EXTRAVERSION ?=
    5.16 +
    5.17 +include buildconfigs/mk.linux-2.6-common
     6.1 --- a/buildconfigs/select-repository	Fri Aug 29 15:47:21 2008 -0700
     6.2 +++ b/buildconfigs/select-repository	Tue Sep 02 16:34:53 2008 -0700
     6.3 @@ -32,31 +32,38 @@ if [ X"${LINUX_SRC_PATH}" != X ] ; then
     6.4      IFS="$IFS_saved"
     6.5  fi
     6.6  
     6.7 -XEN=$(hg -R ${XEN_ROOT} path default)
     6.8 -if [ $? -ne 0 ] || [ X"$XEN" = "X" ] ; then
     6.9 -    echo "$ME: Unable to determine Xen repository parent." 1>&2
    6.10 -    exit 1;
    6.11 +if [ -d ${XEN_ROOT}/.hgxxx ] ; then
    6.12 +    XEN=$(hg -R ${XEN_ROOT} path default)
    6.13 +    if [ $? -ne 0 ] || [ X"$XEN" = "X" ] ; then
    6.14 +	echo "$ME: Unable to determine Xen repository parent." 1>&2
    6.15 +	exit 1;
    6.16 +    fi
    6.17 +
    6.18 +    BASE=$(dirname ${XEN})
    6.19 +    if [ $? -ne 0 ] || [ X"$BASE" = "X" ] ; then
    6.20 +	echo "$ME: Unable to determine Xen repository base." 1>&2
    6.21 +	exit 1;
    6.22 +    fi
    6.23 +    if [ -d "$XEN" ] && [ ! -d "$BASE/$REPO" ] ; then
    6.24 +	echo "$ME: No such dir: $BASE/$REPO" 1>&2
    6.25 +	exit 1
    6.26 +    fi
    6.27 +
    6.28 +    echo "$ME: Found ${BASE}/${REPO}" 1>&2
    6.29 +
    6.30 +    # If ${BASE}/${REPO} is a local directory then prepend file:// so that
    6.31 +    # the test in src.hg-clone will fail and we will clone instead of
    6.32 +    # linking this repository. We only want to link repositories which
    6.33 +    # were found via LINUX_SRC_PATH.
    6.34 +    if [ -d "${BASE}/${REPO}" ] ; then
    6.35 +	echo "file://${BASE}/${REPO}"
    6.36 +    else
    6.37 +	echo ${BASE}/${REPO}
    6.38 +    fi
    6.39 +else
    6.40 +    echo "Unable to determine path to Linux source tree." 1>&2
    6.41 +    echo "Falling back to linux-2.6.18-xen Mercurial repository." 1>&2
    6.42 +    echo http://xenbits.xensource.com/linux-2.6.18-xen.hg
    6.43  fi
    6.44  
    6.45 -BASE=$(dirname ${XEN})
    6.46 -if [ $? -ne 0 ] || [ X"$BASE" = "X" ] ; then
    6.47 -    echo "$ME: Unable to determine Xen repository base." 1>&2
    6.48 -    exit 1;
    6.49 -fi
    6.50 -if [ -d "$XEN" ] && [ ! -d "$BASE/$REPO" ] ; then
    6.51 -    echo "$ME: No such dir: $BASE/$REPO" 1>&2
    6.52 -    exit 1
    6.53 -fi
    6.54 -
    6.55 -echo "$ME: Found ${BASE}/${REPO}" 1>&2
    6.56 -
    6.57 -# If ${BASE}/${REPO} is a local directory then prepend file:// so that
    6.58 -# the test in src.hg-clone will fail and we will clone instead of
    6.59 -# linking this repository. We only want to link repositories which
    6.60 -# were found via LINUX_SRC_PATH.
    6.61 -if [ -d "${BASE}/${REPO}" ] ; then
    6.62 -    echo "file://${BASE}/${REPO}"
    6.63 -else
    6.64 -    echo ${BASE}/${REPO}
    6.65 -fi
    6.66  exit 0
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/buildconfigs/src.git-clone	Tue Sep 02 16:34:53 2008 -0700
     7.3 @@ -0,0 +1,60 @@
     7.4 +# Mercurial
     7.5 +GIT ?= git
     7.6 +
     7.7 +LINUX_SRCDIR ?= linux-$(LINUX_VER).git
     7.8 +
     7.9 +# The URL of the remote GIT repository
    7.10 +ifeq ($(XEN_LINUX_GIT_URL),)
    7.11 +.ERROR: XEN_LINUX_GIT_URL not specified
    7.12 +endif
    7.13 +
    7.14 +# The name to use for the remote repository
    7.15 +XEN_LINUX_GIT_REMOTENAME ?= origin
    7.16 +
    7.17 +# The branch in the remote repository
    7.18 +ifeq ($(XEN_LINUX_GIT_REMOTEBRANCH),)
    7.19 +.ERROR: XEN_LINUX_GIT_REMOTEBRANCH not specified
    7.20 +endif
    7.21 +
    7.22 +XEN_LINUX_GIT_LOCALBRANCH ?= master
    7.23 +
    7.24 +# Set XEN_LINUX_GITREV to update to a particlar revision.
    7.25 +XEN_LINUX_GITREV  ?= 
    7.26 +
    7.27 +$(LINUX_SRCDIR)/.valid-src: $(__XEN_LINUX_UPDATE)
    7.28 +	@set -e ; if [ -d $(LINUX_SRCDIR) ] && [ ! -d $(GIT_DIR) ] ; then \
    7.29 +	    echo "$(LINUX_SRCDIR) exists but is not a git repository." 1>&2 ; \
    7.30 +	    false ; \
    7.31 +	fi
    7.32 +
    7.33 +	@set -e ; if [ ! -e $(LINUX_SRCDIR)/.git ] ; then \
    7.34 +	    mkdir $(LINUX_SRCDIR) ; \
    7.35 +	    cd $(LINUX_SRCDIR) ; \
    7.36 +	    $(GIT) init-db ; \
    7.37 +	fi
    7.38 +
    7.39 +	@set -e ; cd $(LINUX_SRCDIR) ; \
    7.40 +	if ! $(GIT) remote | grep -q $(XEN_LINUX_GIT_REMOTENAME) ; then \
    7.41 +	    echo "Adding remote git repository \`$(XEN_LINUX_GIT_URL)' as \`$(XEN_LINUX_GIT_REMOTENAME)'" ; \
    7.42 +	    $(GIT) remote add $(XEN_LINUX_GIT_REMOTENAME) $(XEN_LINUX_GIT_URL) ; \
    7.43 +	fi
    7.44 +
    7.45 +	@echo "Updating remote \`$(XEN_LINUX_GIT_REMOTENAME)'"
    7.46 +	@cd $(LINUX_SRCDIR) && $(GIT) fetch $(XEN_LINUX_GIT_REMOTENAME)
    7.47 +
    7.48 +	@set -e ; cd $(LINUX_SRCDIR) ; \
    7.49 +	if ! $(GIT) branch -l | grep -q $(XEN_LINUX_GIT_LOCALBRANCH) ; then \
    7.50 +	    $(GIT) branch --track $(XEN_LINUX_GIT_LOCALBRANCH) \
    7.51 +	        $(XEN_LINUX_GIT_REMOTENAME)/$(XEN_LINUX_GIT_REMOTEBRANCH) ; \
    7.52 +	    $(GIT) checkout ; \
    7.53 +	fi
    7.54 +
    7.55 +	@ set -e ; cd $(LINUX_SRCDIR) ; \
    7.56 +	if [ -n "$(XEN_LINUX_GITREV)" ] ; then \
    7.57 +	    echo "Updating $(LINUX_SRCDIR) to revision \'$(XEN_LINUX_GITREV)'." ; \
    7.58 +	    $(GIT) reset --hard $(XEN_LINUX_GITREV) ; \
    7.59 +	else \
    7.60 +	    $(GIT) reset --hard $(XEN_LINUX_GIT_REMOTENAME)/$(XEN_LINUX_GIT_REMOTEBRANCH) ; \
    7.61 +	fi
    7.62 +
    7.63 +	touch $@
     8.1 --- a/config/StdGNU.mk	Fri Aug 29 15:47:21 2008 -0700
     8.2 +++ b/config/StdGNU.mk	Tue Sep 02 16:34:53 2008 -0700
     8.3 @@ -13,6 +13,9 @@ SIZEUTIL   = $(CROSS_COMPILE)size
     8.4  MSGFMT     = msgfmt
     8.5  MSGMERGE   = msgmerge
     8.6  
     8.7 +# Allow git to be wrappered in the environment
     8.8 +GIT        ?= git
     8.9 +
    8.10  INSTALL      = install
    8.11  INSTALL_DIR  = $(INSTALL) -d -m0755 -p
    8.12  INSTALL_DATA = $(INSTALL) -m0644 -p
     9.1 --- a/docs/ChangeLog	Fri Aug 29 15:47:21 2008 -0700
     9.2 +++ b/docs/ChangeLog	Tue Sep 02 16:34:53 2008 -0700
     9.3 @@ -16,6 +16,18 @@ http://lists.xensource.com/archives/html
     9.4  Xen 3.3 release
     9.5  ---------------
     9.6  
     9.7 +17974: PHYSDEVOP_manage_pci_add/PHYSDEVOP_manage_pci_remove
     9.8 +http://xenbits.xensource.com/xen-unstable.hg?rev/183ca809e1d7
     9.9 +
    9.10 +17903: Add greater than 16 xvd device availability
    9.11 +http://xenbits.xensource.com/xen-unstable.hg?rev/0728459b3c8d
    9.12 +
    9.13 +The tools can now attach a disk of the form:
    9.14 +(1<<28) | (device<<8) | partition
    9.15 +to support many more xvd disks and up to 256 partitions.
    9.16 +The linux guest frontend has been expanded to support
    9.17 +this new construct, while legacy guests should just ignore it.
    9.18 +	
    9.19  17538: Add XENPF_set_processor_pminfo
    9.20  http://xenbits.xensource.com/xen-unstable.hg?rev/5bb9093eb0e9
    9.21  
    10.1 --- a/docs/Docs.mk	Fri Aug 29 15:47:21 2008 -0700
    10.2 +++ b/docs/Docs.mk	Tue Sep 02 16:34:53 2008 -0700
    10.3 @@ -7,7 +7,3 @@ DOXYGEN		:= doxygen
    10.4  POD2MAN		:= pod2man
    10.5  DOT		:= dot
    10.6  NEATO		:= neato
    10.7 -
    10.8 -pkgdocdir	:= /usr/share/doc/xen
    10.9 -mandir		:= /usr/share/man
   10.10 -
    11.1 --- a/docs/Makefile	Fri Aug 29 15:47:21 2008 -0700
    11.2 +++ b/docs/Makefile	Tue Sep 02 16:34:53 2008 -0700
    11.3 @@ -80,13 +80,13 @@ distclean: clean
    11.4  
    11.5  .PHONY: install
    11.6  install: all
    11.7 -	rm -rf $(DESTDIR)$(pkgdocdir)
    11.8 -	$(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)
    11.9 +	rm -rf $(DESTDIR)$(DOCDIR)
   11.10 +	$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
   11.11  
   11.12  	$(MAKE) -C xen-api install
   11.13  
   11.14 -	cp -dR ps $(DESTDIR)$(pkgdocdir)
   11.15 -	cp -dR pdf $(DESTDIR)$(pkgdocdir)
   11.16 +	cp -dR ps $(DESTDIR)$(DOCDIR)
   11.17 +	cp -dR pdf $(DESTDIR)$(DOCDIR)
   11.18  
   11.19  ifeq ($(XEN_GDBSX_CONFIG),y)
   11.20          cp $(XEN_ROOT)/tools/debugger/gdbsx/README \
   11.21 @@ -95,10 +95,10 @@ endif
   11.22  ifeq ($(XEN_KDB_CONFIG),y)
   11.23          cp $(XEN_ROOT)/xen/kdb/README $(DESTDIR)$(pkgdocdir)/README.kdb
   11.24  endif
   11.25 -	$(INSTALL_DIR) $(DESTDIR)$(mandir)
   11.26 -	cp -dR man1 $(DESTDIR)$(mandir)
   11.27 -	cp -dR man5 $(DESTDIR)$(mandir)
   11.28 -	[ ! -d html ] || cp -dR html $(DESTDIR)$(pkgdocdir)
   11.29 +	$(INSTALL_DIR) $(DESTDIR)$(MANDIR)
   11.30 +	cp -dR man1 $(DESTDIR)$(MANDIR)
   11.31 +	cp -dR man5 $(DESTDIR)$(MANDIR)
   11.32 +	[ ! -d html ] || cp -dR html $(DESTDIR)$(DOCDIR)
   11.33  
   11.34  pdf/%.pdf: ps/%.ps
   11.35  	$(INSTALL_DIR) $(@D)
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/docs/misc/kexec_and_kdump.txt	Tue Sep 02 16:34:53 2008 -0700
    12.3 @@ -0,0 +1,213 @@
    12.4 +
    12.5 +=======================
    12.6 +Kexec and Kdump for Xen
    12.7 +=======================
    12.8 +
    12.9 +This is a breif guide to using Kexec and Kdump in conjunction with Xen.
   12.10 +This functionaly works at the level of the hypervisor and dom0 kernel.
   12.11 +And will thus affect all guests running on a machine.
   12.12 +
   12.13 +At this stage it does not work in conjunction with domU kernels.
   12.14 +
   12.15 +This document should be read in conjunction with
   12.16 +Documentation/kdump/kdump.txt from the Linux kernel source.
   12.17 +Some of the information in this document has been
   12.18 +sourced from that document.
   12.19 +
   12.20 +
   12.21 +Kexec
   12.22 +=====
   12.23 +
   12.24 +It is possible to kexec from Xen or Linux to either Xen or Linux.
   12.25 +
   12.26 +Pattern        | Before Kexec       | After Kexec
   12.27 +---------------+--------------------+--------------------
   12.28 +Xen -> Xen     | first hypervisor & | second hypervisor &
   12.29 +               | dom0 kernel        | dom0 kernel
   12.30 +---------------+--------------------+--------------------
   12.31 +Xen   -> Linux | first hypervisor & | second kernel
   12.32 +               | dom0 kernel        |
   12.33 +---------------+--------------------+--------------------
   12.34 +Linux -> Xen   | first kernel       | second hypervisor &
   12.35 +               |                    | dom0 kernel
   12.36 +---------------+--------------------+--------------------
   12.37 +Linux -> Linux | first kernel       | second kernel
   12.38 +
   12.39 +If you are kexecing to Xen then you will also need to preapare the second
   12.40 +hypervisor and dom0 kernel that will run after kexec. These may be the same
   12.41 +as the first hypervisor and dom0 kernel that are used before kexec if you
   12.42 +are kexecing from Xen to Xen.
   12.43 +
   12.44 +If you are kexecing to Linux then you will need to prepare the second Linux
   12.45 +kernel that will run after kexec. In the case that you are kexecing from
   12.46 +Linux, it may be the same as the first kernel image that that runs before
   12.47 +kexec.
   12.48 +
   12.49 +Regardless of which kexec pattern you wish to run, you will
   12.50 +need to have kexec-tools installed. This provides the kexec command.
   12.51 +
   12.52 +1. Load
   12.53 +-------
   12.54 +
   12.55 +Before kexecing the second kernel or hypervisor & dom0 kernel
   12.56 +need to be loaded into the running hypervisor or kernel using
   12.57 +the kexec command.
   12.58 +
   12.59 +  a. To kexec to Xen (Xen->Xen or Linux->Xen)
   12.60 +
   12.61 +  kexec -l --append="XEN_ARGS -- DOM0_ARGS" \
   12.62 +	--vmm="XEN_IMAGE" "DOM0_IMAGE" KEXEC_ARGS
   12.63 +
   12.64 +  where:
   12.65 +    XEN_ARGS: command line arguments to the xen hypervisor
   12.66 +              On x86 the no-real-mode argument should be included
   12.67 +    DOM0_ARGS: command line arguments to the dom0 kernel
   12.68 +    XEN_IMAGE: xen hypervisor image
   12.69 +    DOM0_IMAGE: dom0 kernel image
   12.70 +    KEXEC_ARGS: additional kexec-tools command line arguments
   12.71 +
   12.72 +  e.g. kexec -l --append "no-real-mode" --vmm="/boot/xen.gz" /boot/vmlinuz.gz
   12.73 +
   12.74 +  OR
   12.75 +
   12.76 +  b. To kexec to Linux (Xen->Linux or Linux->Linux)
   12.77 +
   12.78 +  kexec -l LINUX_IMAGE --append "$LINUX_ARGS" KEXEC_ARGS
   12.79 +
   12.80 +  where:
   12.81 +    LINUX_IMAGE: the second linux kernel image
   12.82 +    LINUX_ARGS: command line arguments to the second linux kernel
   12.83 +    KEXEC_ARGS: additional kexec-tools command line arguments
   12.84 +
   12.85 +  e.g. kexec -l /boot/second-vmlinuz.gz
   12.86 +
   12.87 +2. Execute
   12.88 +----------
   12.89 +
   12.90 +Once the second kernel is loaded, it can be executed at any time.
   12.91 +If you don't see the second kernel booting within a second or so,
   12.92 +you are in trouble :(
   12.93 +
   12.94 +   kexec -e
   12.95 +
   12.96 +Kdump
   12.97 +=====
   12.98 +
   12.99 +It is possible to kdump from Xen or Linux to a Linux crash kernel.
  12.100 +It is not possible to use xen as a crash kernel.
  12.101 +
  12.102 +Pattern        | Before Kexec       | After Kexec
  12.103 +---------------+--------------------+--------------------
  12.104 +Xen -> Linux   | first hypervisor & | crash kernel
  12.105 +               | dom0 kernel        |
  12.106 +---------------+--------------------+--------------------
  12.107 +Linux -> Linux | first kernel       | crash kernel
  12.108 +
  12.109 +Regardless of if you are kdumping from Xen or Linux you will need to
  12.110 +prepare a linux crash kernel.  You will also need to have kexec-tools
  12.111 +installed. This provides the kexec command.
  12.112 +
  12.113 +0. Set-Up The Crash Kernel Region
  12.114 +---------------------------------
  12.115 +
  12.116 +In order to use kdump an area of memory has to be reserved at boot time.
  12.117 +This is the area of memory that the crash kernel will use, thus allowing it
  12.118 +to run without disrupting the memory used by the first kernel. This area is
  12.119 +called the crash kernel region and is reserved using the crashkernel
  12.120 +command line parameter to the Xen hypervisor. It has two forms:
  12.121 +
  12.122 +  i) crashkernel=size
  12.123 +
  12.124 +     This is the simplest and recommended way to reserve the crash kernel
  12.125 +     region. Just specify how large the region should be and the hypervisor
  12.126 +     will find a good location for it. A good size to start with is 128Mb
  12.127 +
  12.128 +     e.g.
  12.129 +
  12.130 +     crashkernel=128M
  12.131 +
  12.132 +  ii) crashkernel=size@base
  12.133 +
  12.134 +      In this form the base address is provided in addition to
  12.135 +      the size. Use this if auto-placement doesn't work for some reason.
  12.136 +      It is strongly recommended that the base address be aligned
  12.137 +      to 64Mb, else memory below the alignment point will not
  12.138 +      be usable.
  12.139 +
  12.140 +      e.g. crashkernel=128M@256M
  12.141 +
  12.142 +   Regardless of which of the two forms of the crashkernel command line you
  12.143 +   use, the crash kernel region should appear in /proc/iomem on x86 or
  12.144 +   /proc/iomem_machine on ia64. If it doesn't then either the crashkernel
  12.145 +   parameter is missing, or for some reason the region couldn't be placed -
  12.146 +   for instance because it is too large.
  12.147 +
  12.148 +   # cat /proc/iomem
  12.149 +   ...
  12.150 +   00100000-07feffff : System RAM
  12.151 +     00100000-00bfffff : Hypervisor code and data
  12.152 +     0533f000-0733efff : Crash kernel
  12.153 +   ...
  12.154 +
  12.155 +
  12.156 +1. Load
  12.157 +-------
  12.158 +
  12.159 +Once you are running in a kexec-enabled hypervisor and dom0,
  12.160 +you can prepare to kdump by loading the crash kernel into the
  12.161 +running kernel.
  12.162 +
  12.163 +  kexec -p CRASH_KERNEL_IMAGE --append "$CRASH_KERNEL_ARGS" KEXEC_ARGS
  12.164 +
  12.165 +  where:
  12.166 +    CRASH_KERNEL_IMAGE: the crash kernel image
  12.167 +    CRASH_KERNEL_ARGS: command line arguments to the crash kernel
  12.168 +		       init 1 is strongly recommended
  12.169 +		       irqpoll is strongly recommended
  12.170 +		       maxcpus=1 is required if the crash kernel is SMP
  12.171 +		       reset_devices is strongly recommended
  12.172 +    KEXEC_ARGS: additional kexec-tools command line arguments
  12.173 +                On x86 --args-linux should be supplied if an uncompressed
  12.174 +		vmlinux image is used as the crash kernel
  12.175 +
  12.176 +  e.g. kexec -p /boot/crash-vmlinuz \
  12.177 +        --append "init 1 irqpoll maxcpus=1 reset_devices" --args-linux
  12.178 +
  12.179 +On x86 systems the crash kernel may be either
  12.180 +- A uncompressed vmlinux image if the kernel is not relocatable
  12.181 +- A compressed bzImage or vmlinuz image if the kernel is relocatable
  12.182 +- Relocatability is crontroled by the CONFIG_RELOCATABLE kernel
  12.183 +  compile configuration parameter. This option may not be available
  12.184 +  depending on the kernel version
  12.185 +On ia64
  12.186 +  Either a vmlinuz or vmlinux.gz image may be used
  12.187 +
  12.188 +
  12.189 +2. Execute
  12.190 +----------
  12.191 +
  12.192 +Once the second kernel is loaded, the crash kernel will be executed if the
  12.193 +hypervisor panics. It will also be executed if dom0 panics or if dom0
  12.194 +oopses and /proc/sys/kernel/panic_on_oops is set to a non-zero value
  12.195 +
  12.196 +echo 1 > /proc/sys/kernel/panic_on_oops
  12.197 +
  12.198 +Kdump may also be triggered (for testing)
  12.199 +
  12.200 +  a. From Domain 0
  12.201 +
  12.202 +  echo c > /proc/sysrq-trigger
  12.203 +
  12.204 +  b. From Xen
  12.205 +
  12.206 +     Enter the xen console
  12.207 +
  12.208 +     ctrl^a ctrl^a  (may be bound to a different key, this is the default)
  12.209 +
  12.210 +     Select C for "trigger a crashdump"
  12.211 +
  12.212 +     C
  12.213 +
  12.214 +If you don't see the crash kernel booting within a second or so,
  12.215 +you are in trouble :(
  12.216 +
    13.1 --- a/docs/misc/vtd.txt	Fri Aug 29 15:47:21 2008 -0700
    13.2 +++ b/docs/misc/vtd.txt	Tue Sep 02 16:34:53 2008 -0700
    13.3 @@ -2,7 +2,7 @@ Title   : How to do PCI Passthrough with
    13.4  Authors : Allen Kay    <allen.m.kay@intel.com>
    13.5            Weidong Han  <weidong.han@intel.com>
    13.6  Created : October-24-2007
    13.7 -Updated : May-07-2008
    13.8 +Updated : August-06-2008
    13.9  
   13.10  How to turn on VT-d in Xen
   13.11  --------------------------
   13.12 @@ -21,7 +21,7 @@ 11) "hide" pci device from dom0 as follo
   13.13  
   13.14  title Xen-Fedora Core (2.6.18-xen)
   13.15          root (hd0,0)
   13.16 -        kernel /boot/xen.gz com1=115200,8n1 console=com1
   13.17 +        kernel /boot/xen.gz com1=115200,8n1 console=com1 iommu=1
   13.18          module /boot/vmlinuz-2.6.18.8-xen root=LABEL=/ ro xencons=ttyS console=tty0 console=ttyS0, pciback.hide=(01:00.0)(03:00.0)
   13.19          module /boot/initrd-2.6.18-xen.img
   13.20  
   13.21 @@ -32,6 +32,11 @@ 15) start hvm guest and use "lspci" to s
   13.22      "ifconfig" to see if IP address has been assigned to NIC devices.
   13.23  
   13.24  
   13.25 +Enable MSI/MSI-x for assigned devices
   13.26 +-------------------------------------
   13.27 +Add "msi=1" option in kernel line of host grub.
   13.28 +
   13.29 +
   13.30  Caveat on Conventional PCI Device Passthrough
   13.31  ---------------------------------------------
   13.32  
    14.1 --- a/docs/src/user.tex	Fri Aug 29 15:47:21 2008 -0700
    14.2 +++ b/docs/src/user.tex	Tue Sep 02 16:34:53 2008 -0700
    14.3 @@ -4204,11 +4204,9 @@ writing to the VGA console after domain 
    14.4    enabled by the BIOS.
    14.5  \item [ apic=bigsmp,default,es7000,summit ] Specify NUMA platform.
    14.6    This can usually be probed automatically.
    14.7 -\item [ dma\_bits=xxx ] Specify width of DMA
    14.8 -  addresses in bits. Default is 30 bits (addresses up to 1GB are DMAable).
    14.9 -\item [ dma\_emergency\_pool=xxx ] Specify lower bound on size of DMA
   14.10 -  pool below which ordinary allocations will fail rather than fall
   14.11 -  back to allocating from the DMA pool.
   14.12 +\item [ dma\_bits=xxx ] Specify width of DMA addresses in bits. This
   14.13 +  is used in NUMA systems to prevent this special DMA memory from
   14.14 +  being exhausted in one node when remote nodes have available memory.
   14.15  \end{description}
   14.16  
   14.17  In addition, the following options may be specified on the Xen command
    15.1 --- a/docs/xen-api/Makefile	Fri Aug 29 15:47:21 2008 -0700
    15.2 +++ b/docs/xen-api/Makefile	Tue Sep 02 16:34:53 2008 -0700
    15.3 @@ -16,11 +16,11 @@ all: build
    15.4  build: xenapi.pdf xenapi.ps
    15.5  
    15.6  install:
    15.7 -	$(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)/ps
    15.8 -	$(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)/pdf
    15.9 +	$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)/ps
   15.10 +	$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)/pdf
   15.11  
   15.12 -	[ -e xenapi.ps ] && cp xenapi.ps $(DESTDIR)$(pkgdocdir)/ps || true
   15.13 -	[ -e xenapi.pdf ] && cp xenapi.pdf $(DESTDIR)$(pkgdocdir)/pdf || true
   15.14 +	[ -e xenapi.ps ] && cp xenapi.ps $(DESTDIR)$(DOCDIR)/ps || true
   15.15 +	[ -e xenapi.pdf ] && cp xenapi.pdf $(DESTDIR)$(DOCDIR)/pdf || true
   15.16  
   15.17  xenapi.dvi: $(TEX) $(EPS) $(EPSDOT)
   15.18  	$(LATEX) xenapi.tex
    16.1 --- a/docs/xen-api/coversheet.tex	Fri Aug 29 15:47:21 2008 -0700
    16.2 +++ b/docs/xen-api/coversheet.tex	Tue Sep 02 16:34:53 2008 -0700
    16.3 @@ -50,7 +50,7 @@ Gareth Bestor, IBM & Jon Ludlam, XenSour
    16.4  Hollis Blanchard, IBM & Alastair Tse, XenSource \\
    16.5  Mike Day, IBM & Daniel Veillard, Red Hat \\
    16.6  Jim Fehlig, Novell & Tom Wilkie, University of Cambridge \\
    16.7 -Jon Harrop, XenSource & \\
    16.8 +Jon Harrop, XenSource & Yosuke Iwamatsu, NEC \\
    16.9  \end{tabular}
   16.10  \end{large}
   16.11  
   16.12 @@ -60,4 +60,4 @@ Jon Harrop, XenSource & \\
   16.13  \legalnotice{}
   16.14  
   16.15  \newpage
   16.16 -\pagestyle{fancy}
   16.17 \ No newline at end of file
   16.18 +\pagestyle{fancy}
    17.1 --- a/docs/xen-api/revision-history.tex	Fri Aug 29 15:47:21 2008 -0700
    17.2 +++ b/docs/xen-api/revision-history.tex	Tue Sep 02 16:34:53 2008 -0700
    17.3 @@ -47,5 +47,14 @@
    17.4      \end{flushleft}
    17.5     \end{minipage}\\
    17.6    \hline
    17.7 +  1.0.6 & 24th Jul. 08 & Y. Iwamatsu &
    17.8 +   \begin{minipage}[t]{7cm}
    17.9 +    \begin{flushleft}
   17.10 +     Added definitions of new classes DPCI and PPCI. Updated the table
   17.11 +     and the diagram representing relationships between classes.
   17.12 +     Added host.PPCIs and VM.DPCIs fields.
   17.13 +    \end{flushleft}
   17.14 +   \end{minipage}\\
   17.15 +  \hline
   17.16   \end{tabular}
   17.17  \end{center}
    18.1 --- a/docs/xen-api/xenapi-coversheet.tex	Fri Aug 29 15:47:21 2008 -0700
    18.2 +++ b/docs/xen-api/xenapi-coversheet.tex	Tue Sep 02 16:34:53 2008 -0700
    18.3 @@ -17,12 +17,12 @@
    18.4  \newcommand{\coversheetlogo}{xen.eps}
    18.5  
    18.6  %% Document date
    18.7 -\newcommand{\datestring}{11th February 2008}
    18.8 +\newcommand{\datestring}{24th July 2008}
    18.9  
   18.10  \newcommand{\releasestatement}{Stable Release}
   18.11  
   18.12  %% Document revision
   18.13 -\newcommand{\revstring}{API Revision 1.0.5}
   18.14 +\newcommand{\revstring}{API Revision 1.0.6}
   18.15  
   18.16  %% Document authors
   18.17  \newcommand{\docauthors}{
    19.1 --- a/docs/xen-api/xenapi-datamodel-graph.dot	Fri Aug 29 15:47:21 2008 -0700
    19.2 +++ b/docs/xen-api/xenapi-datamodel-graph.dot	Tue Sep 02 16:34:53 2008 -0700
    19.3 @@ -14,7 +14,7 @@ fontname="Verdana";
    19.4  
    19.5  node [ shape=box ]; session VM host network VIF PIF SR VDI VBD PBD user XSPolicy ACMPolicy;
    19.6  node [shape=ellipse]; PIF_metrics VIF_metrics VM_metrics VBD_metrics PBD_metrics VM_guest_metrics host_metrics;
    19.7 -node [shape=box]; host_cpu console
    19.8 +node [shape=box]; DPCI PPCI host_cpu console
    19.9  session -> host [ arrowhead="none" ]
   19.10  session -> user [ arrowhead="none" ]
   19.11  VM -> VM_metrics [ arrowhead="none" ]
   19.12 @@ -22,7 +22,7 @@ VM -> VM_guest_metrics [ arrowhead="none
   19.13  VM -> console [ arrowhead="crow" ]
   19.14  host -> PBD [ arrowhead="crow", arrowtail="none" ]
   19.15  host -> host_metrics [ arrowhead="none" ]
   19.16 -host -> host_cpu [ arrowhead="none" ]
   19.17 +host -> host_cpu [ arrowhead="crow", arrowtail="none" ]
   19.18  VIF -> VM [ arrowhead="none", arrowtail="crow" ]
   19.19  VIF -> network [ arrowhead="none", arrowtail="crow" ]
   19.20  VIF -> VIF_metrics [ arrowhead="none" ]
   19.21 @@ -38,4 +38,7 @@ VTPM -> VM [ arrowhead="none", arrowtail
   19.22  VBD -> VBD_metrics [ arrowhead="none" ]
   19.23  XSPolicy -> host [ arrowhead="none" ]
   19.24  XSPolicy -> ACMPolicy [ arrowhead="none" ]
   19.25 +DPCI -> VM [ arrowhead="none", arrowtail="crow" ]
   19.26 +DPCI -> PPCI [ arrowhead="none" ]
   19.27 +PPCI -> host [ arrowhead="none", arrowtail="crow" ]
   19.28  }
    20.1 --- a/docs/xen-api/xenapi-datamodel.tex	Fri Aug 29 15:47:21 2008 -0700
    20.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Tue Sep 02 16:34:53 2008 -0700
    20.3 @@ -44,6 +44,8 @@ Name & Description \\
    20.4  {\tt crashdump} & A VM crashdump \\
    20.5  {\tt VTPM} & A virtual TPM device \\
    20.6  {\tt console} & A console \\
    20.7 +{\tt DPCI} & A pass-through PCI device \\
    20.8 +{\tt PPCI} & A physical PCI device \\
    20.9  {\tt user} & A user of the system \\
   20.10  {\tt debug} & A basic class for testing \\
   20.11  {\tt XSPolicy} & A class for handling Xen Security Policies \\
   20.12 @@ -70,6 +72,8 @@ PIF.network & network.PIFs & one-to-many
   20.13  SR.VDIs & VDI.SR & many-to-one\\
   20.14  VTPM.VM & VM.VTPMs & one-to-many\\
   20.15  console.VM & VM.consoles & one-to-many\\
   20.16 +DPCI.VM & VM.DPCIs & one-to-many\\
   20.17 +PPCI.host & host.PPCIs & one-to-many\\
   20.18  host.resident\_VMs & VM.resident\_on & many-to-one\\
   20.19  host.host\_CPUs & host\_cpu.host & many-to-one\\
   20.20  \hline
   20.21 @@ -1402,6 +1406,7 @@ Quals & Field & Type & Description \\
   20.22  $\mathit{RO}_\mathit{run}$ &  {\tt VBDs} & (VBD ref) Set & virtual block devices \\
   20.23  $\mathit{RO}_\mathit{run}$ &  {\tt crash\_dumps} & (crashdump ref) Set & crash dumps associated with this VM \\
   20.24  $\mathit{RO}_\mathit{run}$ &  {\tt VTPMs} & (VTPM ref) Set & virtual TPMs \\
   20.25 +$\mathit{RO}_\mathit{run}$ &  {\tt DPCIs} & (DPCI ref) Set & pass-through PCI devices \\
   20.26  $\mathit{RW}$ &  {\tt PV/bootloader} & string & name of or path to bootloader \\
   20.27  $\mathit{RW}$ &  {\tt PV/kernel} & string & path to the kernel \\
   20.28  $\mathit{RW}$ &  {\tt PV/ramdisk} & string & path to the initrd \\
   20.29 @@ -3413,6 +3418,38 @@ value of the field
   20.30  \vspace{0.3cm}
   20.31  \vspace{0.3cm}
   20.32  \vspace{0.3cm}
   20.33 +\subsubsection{RPC name:~get\_DPCIs}
   20.34 +
   20.35 +{\bf Overview:} 
   20.36 +Get the DPCIs field of the given VM.
   20.37 +
   20.38 + \noindent {\bf Signature:} 
   20.39 +\begin{verbatim} ((DPCI ref) Set) get_DPCIs (session_id s, VM ref self)\end{verbatim}
   20.40 +
   20.41 +
   20.42 +\noindent{\bf Arguments:}
   20.43 +
   20.44 + 
   20.45 +\vspace{0.3cm}
   20.46 +\begin{tabular}{|c|c|p{7cm}|}
   20.47 + \hline
   20.48 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   20.49 +{\tt VM ref } & self & reference to the object \\ \hline 
   20.50 +
   20.51 +\end{tabular}
   20.52 +
   20.53 +\vspace{0.3cm}
   20.54 +
   20.55 + \noindent {\bf Return Type:} 
   20.56 +{\tt 
   20.57 +(DPCI ref) Set
   20.58 +}
   20.59 +
   20.60 +
   20.61 +value of the field
   20.62 +\vspace{0.3cm}
   20.63 +\vspace{0.3cm}
   20.64 +\vspace{0.3cm}
   20.65  \subsubsection{RPC name:~get\_PV\_bootloader}
   20.66  
   20.67  {\bf Overview:} 
   20.68 @@ -5480,6 +5517,7 @@ Quals & Field & Type & Description \\
   20.69  $\mathit{RW}$ &  {\tt suspend\_image\_sr} & SR ref & The SR in which VDIs for suspend images are created \\
   20.70  $\mathit{RW}$ &  {\tt crash\_dump\_sr} & SR ref & The SR in which VDIs for crash dumps are created \\
   20.71  $\mathit{RO}_\mathit{run}$ &  {\tt PBDs} & (PBD ref) Set & physical blockdevices \\
   20.72 +$\mathit{RO}_\mathit{run}$ &  {\tt PPCIs} & (PPCI ref) Set & physical PCI devices \\
   20.73  $\mathit{RO}_\mathit{run}$ &  {\tt host\_CPUs} & (host\_cpu ref) Set & The physical CPUs on this host \\
   20.74  $\mathit{RO}_\mathit{run}$ &  {\tt metrics} & host\_metrics ref & metrics associated with this host \\
   20.75  \hline
   20.76 @@ -6774,6 +6812,38 @@ value of the field
   20.77  \vspace{0.3cm}
   20.78  \vspace{0.3cm}
   20.79  \vspace{0.3cm}
   20.80 +\subsubsection{RPC name:~get\_PPCIs}
   20.81 +
   20.82 +{\bf Overview:} 
   20.83 +Get the PPCIs field of the given host.
   20.84 +
   20.85 + \noindent {\bf Signature:} 
   20.86 +\begin{verbatim} ((PPCI ref) Set) get_PPCIs (session_id s, host ref self)\end{verbatim}
   20.87 +
   20.88 +
   20.89 +\noindent{\bf Arguments:}
   20.90 +
   20.91 + 
   20.92 +\vspace{0.3cm}
   20.93 +\begin{tabular}{|c|c|p{7cm}|}
   20.94 + \hline
   20.95 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   20.96 +{\tt host ref } & self & reference to the object \\ \hline 
   20.97 +
   20.98 +\end{tabular}
   20.99 +
  20.100 +\vspace{0.3cm}
  20.101 +
  20.102 + \noindent {\bf Return Type:} 
  20.103 +{\tt 
  20.104 +(PPCI ref) Set
  20.105 +}
  20.106 +
  20.107 +
  20.108 +value of the field
  20.109 +\vspace{0.3cm}
  20.110 +\vspace{0.3cm}
  20.111 +\vspace{0.3cm}
  20.112  \subsubsection{RPC name:~get\_host\_CPUs}
  20.113  
  20.114  {\bf Overview:} 
  20.115 @@ -14464,6 +14534,1195 @@ all fields from the object
  20.116  
  20.117  \vspace{1cm}
  20.118  \newpage
  20.119 +\section{Class: DPCI}
  20.120 +\subsection{Fields for class: DPCI}
  20.121 +\begin{longtable}{|lllp{0.38\textwidth}|}
  20.122 +\hline
  20.123 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf DPCI} \\
  20.124 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A
  20.125 +pass-through PCI device.}} \\
  20.126 +\hline
  20.127 +Quals & Field & Type & Description \\
  20.128 +\hline
  20.129 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
  20.130 +$\mathit{RO}_\mathit{inst}$ &  {\tt VM} & VM ref & the virtual machine \\
  20.131 +$\mathit{RO}_\mathit{inst}$ &  {\tt PPCI} & PPCI ref & the physical PCI device \\
  20.132 +$\mathit{RO}_\mathit{inst}$ &  {\tt hotplug\_slot} & int & the slot number to which this PCI device is inserted \\
  20.133 +$\mathit{RO}_\mathit{run}$ &  {\tt virtual\_domain} & int & the virtual domain number \\
  20.134 +$\mathit{RO}_\mathit{run}$ &  {\tt virtual\_bus} & int & the virtual bus number \\
  20.135 +$\mathit{RO}_\mathit{run}$ &  {\tt virtual\_slot} & int & the virtual slot number \\
  20.136 +$\mathit{RO}_\mathit{run}$ &  {\tt virtual\_func} & int & the virtual func number \\
  20.137 +$\mathit{RO}_\mathit{run}$ &  {\tt virtual\_name} & string & the virtual PCI name \\
  20.138 +\hline
  20.139 +\end{longtable}
  20.140 +\subsection{RPCs associated with class: DPCI}
  20.141 +\subsubsection{RPC name:~get\_all}
  20.142 +
  20.143 +{\bf Overview:} 
  20.144 +Return a list of all the DPCIs known to the system.
  20.145 +
  20.146 + \noindent {\bf Signature:} 
  20.147 +\begin{verbatim} ((DPCI ref) Set) get_all (session_id s)\end{verbatim}
  20.148 +
  20.149 +
  20.150 +\vspace{0.3cm}
  20.151 +
  20.152 + \noindent {\bf Return Type:} 
  20.153 +{\tt 
  20.154 +(DPCI ref) Set
  20.155 +}
  20.156 +
  20.157 +
  20.158 +references to all objects
  20.159 +\vspace{0.3cm}
  20.160 +\vspace{0.3cm}
  20.161 +\vspace{0.3cm}
  20.162 +\subsubsection{RPC name:~get\_uuid}
  20.163 +
  20.164 +{\bf Overview:} 
  20.165 +Get the uuid field of the given DPCI.
  20.166 +
  20.167 + \noindent {\bf Signature:} 
  20.168 +\begin{verbatim} string get_uuid (session_id s, DPCI ref self)\end{verbatim}
  20.169 +
  20.170 +
  20.171 +\noindent{\bf Arguments:}
  20.172 +
  20.173 + 
  20.174 +\vspace{0.3cm}
  20.175 +\begin{tabular}{|c|c|p{7cm}|}
  20.176 + \hline
  20.177 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.178 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.179 +
  20.180 +\end{tabular}
  20.181 +
  20.182 +\vspace{0.3cm}
  20.183 +
  20.184 + \noindent {\bf Return Type:} 
  20.185 +{\tt 
  20.186 +string
  20.187 +}
  20.188 +
  20.189 +
  20.190 +value of the field
  20.191 +\vspace{0.3cm}
  20.192 +\vspace{0.3cm}
  20.193 +\vspace{0.3cm}
  20.194 +\subsubsection{RPC name:~get\_VM}
  20.195 +
  20.196 +{\bf Overview:} 
  20.197 +Get the VM field of the given DPCI.
  20.198 +
  20.199 + \noindent {\bf Signature:} 
  20.200 +\begin{verbatim} (VM ref) get_VM (session_id s, DPCI ref self)\end{verbatim}
  20.201 +
  20.202 +
  20.203 +\noindent{\bf Arguments:}
  20.204 +
  20.205 + 
  20.206 +\vspace{0.3cm}
  20.207 +\begin{tabular}{|c|c|p{7cm}|}
  20.208 + \hline
  20.209 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.210 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.211 +
  20.212 +\end{tabular}
  20.213 +
  20.214 +\vspace{0.3cm}
  20.215 +
  20.216 + \noindent {\bf Return Type:} 
  20.217 +{\tt 
  20.218 +VM ref
  20.219 +}
  20.220 +
  20.221 +
  20.222 +value of the field
  20.223 +\vspace{0.3cm}
  20.224 +\vspace{0.3cm}
  20.225 +\vspace{0.3cm}
  20.226 +\subsubsection{RPC name:~get\_PPCI}
  20.227 +
  20.228 +{\bf Overview:} 
  20.229 +Get the PPCI field of the given DPCI.
  20.230 +
  20.231 + \noindent {\bf Signature:} 
  20.232 +\begin{verbatim} (PPCI ref) get_PPCI (session_id s, DPCI ref self)\end{verbatim}
  20.233 +
  20.234 +
  20.235 +\noindent{\bf Arguments:}
  20.236 +
  20.237 + 
  20.238 +\vspace{0.3cm}
  20.239 +\begin{tabular}{|c|c|p{7cm}|}
  20.240 + \hline
  20.241 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.242 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.243 +
  20.244 +\end{tabular}
  20.245 +
  20.246 +\vspace{0.3cm}
  20.247 +
  20.248 + \noindent {\bf Return Type:} 
  20.249 +{\tt 
  20.250 +PPCI ref
  20.251 +}
  20.252 +
  20.253 +
  20.254 +value of the field
  20.255 +\vspace{0.3cm}
  20.256 +\vspace{0.3cm}
  20.257 +\vspace{0.3cm}
  20.258 +\subsubsection{RPC name:~get\_hotplug\_slot}
  20.259 +
  20.260 +{\bf Overview:} 
  20.261 +Get the hotplug\_slot field of the given DPCI.
  20.262 +
  20.263 + \noindent {\bf Signature:} 
  20.264 +\begin{verbatim} int get_hotplug_slot (session_id s, DPCI ref self)\end{verbatim}
  20.265 +
  20.266 +
  20.267 +\noindent{\bf Arguments:}
  20.268 +
  20.269 + 
  20.270 +\vspace{0.3cm}
  20.271 +\begin{tabular}{|c|c|p{7cm}|}
  20.272 + \hline
  20.273 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.274 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.275 +
  20.276 +\end{tabular}
  20.277 +
  20.278 +\vspace{0.3cm}
  20.279 +
  20.280 + \noindent {\bf Return Type:} 
  20.281 +{\tt 
  20.282 +int
  20.283 +}
  20.284 +
  20.285 +
  20.286 +value of the field
  20.287 +\vspace{0.3cm}
  20.288 +\vspace{0.3cm}
  20.289 +\vspace{0.3cm}
  20.290 +\subsubsection{RPC name:~get\_virtual\_domain}
  20.291 +
  20.292 +{\bf Overview:} 
  20.293 +Get the virtual\_domain field of the given DPCI.
  20.294 +
  20.295 + \noindent {\bf Signature:} 
  20.296 +\begin{verbatim} int get_virtual_domain (session_id s, DPCI ref self)\end{verbatim}
  20.297 +
  20.298 +
  20.299 +\noindent{\bf Arguments:}
  20.300 +
  20.301 + 
  20.302 +\vspace{0.3cm}
  20.303 +\begin{tabular}{|c|c|p{7cm}|}
  20.304 + \hline
  20.305 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.306 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.307 +
  20.308 +\end{tabular}
  20.309 +
  20.310 +\vspace{0.3cm}
  20.311 +
  20.312 + \noindent {\bf Return Type:} 
  20.313 +{\tt 
  20.314 +int
  20.315 +}
  20.316 +
  20.317 +
  20.318 +value of the field
  20.319 +\vspace{0.3cm}
  20.320 +\vspace{0.3cm}
  20.321 +\vspace{0.3cm}
  20.322 +\subsubsection{RPC name:~get\_virtual\_bus}
  20.323 +
  20.324 +{\bf Overview:} 
  20.325 +Get the virtual\_bus field of the given DPCI.
  20.326 +
  20.327 + \noindent {\bf Signature:} 
  20.328 +\begin{verbatim} int get_virtual_bus (session_id s, DPCI ref self)\end{verbatim}
  20.329 +
  20.330 +
  20.331 +\noindent{\bf Arguments:}
  20.332 +
  20.333 + 
  20.334 +\vspace{0.3cm}
  20.335 +\begin{tabular}{|c|c|p{7cm}|}
  20.336 + \hline
  20.337 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.338 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.339 +
  20.340 +\end{tabular}
  20.341 +
  20.342 +\vspace{0.3cm}
  20.343 +
  20.344 + \noindent {\bf Return Type:} 
  20.345 +{\tt 
  20.346 +int
  20.347 +}
  20.348 +
  20.349 +
  20.350 +value of the field
  20.351 +\vspace{0.3cm}
  20.352 +\vspace{0.3cm}
  20.353 +\vspace{0.3cm}
  20.354 +\subsubsection{RPC name:~get\_virtual\_slot}
  20.355 +
  20.356 +{\bf Overview:} 
  20.357 +Get the virtual\_slot field of the given DPCI.
  20.358 +
  20.359 + \noindent {\bf Signature:} 
  20.360 +\begin{verbatim} int get_virtual_slot (session_id s, DPCI ref self)\end{verbatim}
  20.361 +
  20.362 +
  20.363 +\noindent{\bf Arguments:}
  20.364 +
  20.365 + 
  20.366 +\vspace{0.3cm}
  20.367 +\begin{tabular}{|c|c|p{7cm}|}
  20.368 + \hline
  20.369 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.370 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.371 +
  20.372 +\end{tabular}
  20.373 +
  20.374 +\vspace{0.3cm}
  20.375 +
  20.376 + \noindent {\bf Return Type:} 
  20.377 +{\tt 
  20.378 +int
  20.379 +}
  20.380 +
  20.381 +
  20.382 +value of the field
  20.383 +\vspace{0.3cm}
  20.384 +\vspace{0.3cm}
  20.385 +\vspace{0.3cm}
  20.386 +\subsubsection{RPC name:~get\_virtual\_func}
  20.387 +
  20.388 +{\bf Overview:} 
  20.389 +Get the virtual\_func field of the given DPCI.
  20.390 +
  20.391 + \noindent {\bf Signature:} 
  20.392 +\begin{verbatim} int get_virtual_func (session_id s, DPCI ref self)\end{verbatim}
  20.393 +
  20.394 +
  20.395 +\noindent{\bf Arguments:}
  20.396 +
  20.397 + 
  20.398 +\vspace{0.3cm}
  20.399 +\begin{tabular}{|c|c|p{7cm}|}
  20.400 + \hline
  20.401 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.402 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.403 +
  20.404 +\end{tabular}
  20.405 +
  20.406 +\vspace{0.3cm}
  20.407 +
  20.408 + \noindent {\bf Return Type:} 
  20.409 +{\tt 
  20.410 +int
  20.411 +}
  20.412 +
  20.413 +
  20.414 +value of the field
  20.415 +\vspace{0.3cm}
  20.416 +\vspace{0.3cm}
  20.417 +\vspace{0.3cm}
  20.418 +\subsubsection{RPC name:~get\_virtual\_name}
  20.419 +
  20.420 +{\bf Overview:} 
  20.421 +Get the virtual\_name field of the given DPCI.
  20.422 +
  20.423 + \noindent {\bf Signature:} 
  20.424 +\begin{verbatim} string get_virtual_name (session_id s, DPCI ref self)\end{verbatim}
  20.425 +
  20.426 +
  20.427 +\noindent{\bf Arguments:}
  20.428 +
  20.429 + 
  20.430 +\vspace{0.3cm}
  20.431 +\begin{tabular}{|c|c|p{7cm}|}
  20.432 + \hline
  20.433 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.434 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.435 +
  20.436 +\end{tabular}
  20.437 +
  20.438 +\vspace{0.3cm}
  20.439 +
  20.440 + \noindent {\bf Return Type:} 
  20.441 +{\tt 
  20.442 +string
  20.443 +}
  20.444 +
  20.445 +
  20.446 +value of the field
  20.447 +\vspace{0.3cm}
  20.448 +\vspace{0.3cm}
  20.449 +\vspace{0.3cm}
  20.450 +\subsubsection{RPC name:~create}
  20.451 +
  20.452 +{\bf Overview:} 
  20.453 +Create a new DPCI instance, and return its handle.
  20.454 +
  20.455 + \noindent {\bf Signature:} 
  20.456 +\begin{verbatim} (DPCI ref) create (session_id s, DPCI record args)\end{verbatim}
  20.457 +
  20.458 +
  20.459 +\noindent{\bf Arguments:}
  20.460 +
  20.461 + 
  20.462 +\vspace{0.3cm}
  20.463 +\begin{tabular}{|c|c|p{7cm}|}
  20.464 + \hline
  20.465 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.466 +{\tt DPCI record } & args & All constructor arguments \\ \hline 
  20.467 +
  20.468 +\end{tabular}
  20.469 +
  20.470 +\vspace{0.3cm}
  20.471 +
  20.472 + \noindent {\bf Return Type:} 
  20.473 +{\tt 
  20.474 +DPCI ref
  20.475 +}
  20.476 +
  20.477 +
  20.478 +reference to the newly created object
  20.479 +\vspace{0.3cm}
  20.480 +\vspace{0.3cm}
  20.481 +\vspace{0.3cm}
  20.482 +\subsubsection{RPC name:~destroy}
  20.483 +
  20.484 +{\bf Overview:} 
  20.485 +Destroy the specified DPCI instance.
  20.486 +
  20.487 + \noindent {\bf Signature:} 
  20.488 +\begin{verbatim} void destroy (session_id s, DPCI ref self)\end{verbatim}
  20.489 +
  20.490 +
  20.491 +\noindent{\bf Arguments:}
  20.492 +
  20.493 + 
  20.494 +\vspace{0.3cm}
  20.495 +\begin{tabular}{|c|c|p{7cm}|}
  20.496 + \hline
  20.497 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.498 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.499 +
  20.500 +\end{tabular}
  20.501 +
  20.502 +\vspace{0.3cm}
  20.503 +
  20.504 + \noindent {\bf Return Type:} 
  20.505 +{\tt 
  20.506 +void
  20.507 +}
  20.508 +
  20.509 +
  20.510 +\vspace{0.3cm}
  20.511 +\vspace{0.3cm}
  20.512 +\vspace{0.3cm}
  20.513 +\subsubsection{RPC name:~get\_by\_uuid}
  20.514 +
  20.515 +{\bf Overview:} 
  20.516 +Get a reference to the DPCI instance with the specified UUID.
  20.517 +
  20.518 + \noindent {\bf Signature:} 
  20.519 +\begin{verbatim} (DPCI ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
  20.520 +
  20.521 +
  20.522 +\noindent{\bf Arguments:}
  20.523 +
  20.524 + 
  20.525 +\vspace{0.3cm}
  20.526 +\begin{tabular}{|c|c|p{7cm}|}
  20.527 + \hline
  20.528 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.529 +{\tt string } & uuid & UUID of object to return \\ \hline 
  20.530 +
  20.531 +\end{tabular}
  20.532 +
  20.533 +\vspace{0.3cm}
  20.534 +
  20.535 + \noindent {\bf Return Type:} 
  20.536 +{\tt 
  20.537 +DPCI ref
  20.538 +}
  20.539 +
  20.540 +
  20.541 +reference to the object
  20.542 +\vspace{0.3cm}
  20.543 +\vspace{0.3cm}
  20.544 +\vspace{0.3cm}
  20.545 +\subsubsection{RPC name:~get\_record}
  20.546 +
  20.547 +{\bf Overview:} 
  20.548 +Get a record containing the current state of the given DPCI.
  20.549 +
  20.550 + \noindent {\bf Signature:} 
  20.551 +\begin{verbatim} (DPCI record) get_record (session_id s, DPCI ref self)\end{verbatim}
  20.552 +
  20.553 +
  20.554 +\noindent{\bf Arguments:}
  20.555 +
  20.556 + 
  20.557 +\vspace{0.3cm}
  20.558 +\begin{tabular}{|c|c|p{7cm}|}
  20.559 + \hline
  20.560 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.561 +{\tt DPCI ref } & self & reference to the object \\ \hline 
  20.562 +
  20.563 +\end{tabular}
  20.564 +
  20.565 +\vspace{0.3cm}
  20.566 +
  20.567 + \noindent {\bf Return Type:} 
  20.568 +{\tt 
  20.569 +DPCI record
  20.570 +}
  20.571 +
  20.572 +
  20.573 +all fields from the object
  20.574 +\vspace{0.3cm}
  20.575 +\vspace{0.3cm}
  20.576 +\vspace{0.3cm}
  20.577 +
  20.578 +\vspace{1cm}
  20.579 +\newpage
  20.580 +\section{Class: PPCI}
  20.581 +\subsection{Fields for class: PPCI}
  20.582 +\begin{longtable}{|lllp{0.38\textwidth}|}
  20.583 +\hline
  20.584 +\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf PPCI} \\
  20.585 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A
  20.586 +physical PCI device.}} \\
  20.587 +\hline
  20.588 +Quals & Field & Type & Description \\
  20.589 +\hline
  20.590 +$\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
  20.591 +$\mathit{RO}_\mathit{run}$ &  {\tt host} & host ref &  the physical machine to which this PPCI is connected \\
  20.592 +$\mathit{RO}_\mathit{run}$ &  {\tt domain} & int & the domain number \\
  20.593 +$\mathit{RO}_\mathit{run}$ &  {\tt bus} & int & the bus number \\
  20.594 +$\mathit{RO}_\mathit{run}$ &  {\tt slot} & int & the slot number \\
  20.595 +$\mathit{RO}_\mathit{run}$ &  {\tt func} & int & the func number \\
  20.596 +$\mathit{RO}_\mathit{run}$ &  {\tt name} & string & the PCI name \\
  20.597 +$\mathit{RO}_\mathit{run}$ &  {\tt vendor\_id} & int & the vendor ID \\
  20.598 +$\mathit{RO}_\mathit{run}$ &  {\tt vendor\_name} & string & the vendor name \\
  20.599 +$\mathit{RO}_\mathit{run}$ &  {\tt device\_id} & int & the device ID \\
  20.600 +$\mathit{RO}_\mathit{run}$ &  {\tt device\_name} & string & the device name \\
  20.601 +$\mathit{RO}_\mathit{run}$ &  {\tt revision\_id} & int & the revision ID \\
  20.602 +$\mathit{RO}_\mathit{run}$ &  {\tt class\_code} & int & the class code \\
  20.603 +$\mathit{RO}_\mathit{run}$ &  {\tt class\_name} & string & the class name \\
  20.604 +$\mathit{RO}_\mathit{run}$ &  {\tt subsystem\_vendor\_id} & int & the subsystem vendor ID \\
  20.605 +$\mathit{RO}_\mathit{run}$ &  {\tt subsystem\_vendor\_name} & string & the subsystem vendor name \\
  20.606 +$\mathit{RO}_\mathit{run}$ &  {\tt subsystem\_id} & int & the subsystem ID \\
  20.607 +$\mathit{RO}_\mathit{run}$ &  {\tt subsystem\_name} & string & the subsystem name \\
  20.608 +$\mathit{RO}_\mathit{run}$ &  {\tt driver} & string & the driver name \\
  20.609 +\hline
  20.610 +\end{longtable}
  20.611 +\subsection{RPCs associated with class: PPCI}
  20.612 +\subsubsection{RPC name:~get\_all}
  20.613 +
  20.614 +{\bf Overview:} 
  20.615 +Return a list of all the PPCIs known to the system.
  20.616 +
  20.617 + \noindent {\bf Signature:} 
  20.618 +\begin{verbatim} ((PPCI ref) Set) get_all (session_id s)\end{verbatim}
  20.619 +
  20.620 +
  20.621 +\vspace{0.3cm}
  20.622 +
  20.623 + \noindent {\bf Return Type:} 
  20.624 +{\tt 
  20.625 +(PPCI ref) Set
  20.626 +}
  20.627 +
  20.628 +
  20.629 +references to all objects
  20.630 +\vspace{0.3cm}
  20.631 +\vspace{0.3cm}
  20.632 +\vspace{0.3cm}
  20.633 +\subsubsection{RPC name:~get\_uuid}
  20.634 +
  20.635 +{\bf Overview:} 
  20.636 +Get the uuid field of the given PPCI.
  20.637 +
  20.638 + \noindent {\bf Signature:} 
  20.639 +\begin{verbatim} string get_uuid (session_id s, PPCI ref self)\end{verbatim}
  20.640 +
  20.641 +
  20.642 +\noindent{\bf Arguments:}
  20.643 +
  20.644 + 
  20.645 +\vspace{0.3cm}
  20.646 +\begin{tabular}{|c|c|p{7cm}|}
  20.647 + \hline
  20.648 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.649 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.650 +
  20.651 +\end{tabular}
  20.652 +
  20.653 +\vspace{0.3cm}
  20.654 +
  20.655 + \noindent {\bf Return Type:} 
  20.656 +{\tt 
  20.657 +string
  20.658 +}
  20.659 +
  20.660 +
  20.661 +value of the field
  20.662 +\vspace{0.3cm}
  20.663 +\vspace{0.3cm}
  20.664 +\vspace{0.3cm}
  20.665 +\subsubsection{RPC name:~get\_host}
  20.666 +
  20.667 +{\bf Overview:} 
  20.668 +Get the host field of the given PPCI.
  20.669 +
  20.670 + \noindent {\bf Signature:} 
  20.671 +\begin{verbatim} (host ref) get_host (session_id s, PPCI ref self)\end{verbatim}
  20.672 +
  20.673 +
  20.674 +\noindent{\bf Arguments:}
  20.675 +
  20.676 + 
  20.677 +\vspace{0.3cm}
  20.678 +\begin{tabular}{|c|c|p{7cm}|}
  20.679 + \hline
  20.680 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.681 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.682 +
  20.683 +\end{tabular}
  20.684 +
  20.685 +\vspace{0.3cm}
  20.686 +
  20.687 + \noindent {\bf Return Type:} 
  20.688 +{\tt 
  20.689 +host ref
  20.690 +}
  20.691 +
  20.692 +
  20.693 +value of the field
  20.694 +\vspace{0.3cm}
  20.695 +\vspace{0.3cm}
  20.696 +\vspace{0.3cm}
  20.697 +\subsubsection{RPC name:~get\_domain}
  20.698 +
  20.699 +{\bf Overview:} 
  20.700 +Get the domain field of the given PPCI.
  20.701 +
  20.702 + \noindent {\bf Signature:} 
  20.703 +\begin{verbatim} int get_domain (session_id s, PPCI ref self)\end{verbatim}
  20.704 +
  20.705 +
  20.706 +\noindent{\bf Arguments:}
  20.707 +
  20.708 + 
  20.709 +\vspace{0.3cm}
  20.710 +\begin{tabular}{|c|c|p{7cm}|}
  20.711 + \hline
  20.712 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.713 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.714 +
  20.715 +\end{tabular}
  20.716 +
  20.717 +\vspace{0.3cm}
  20.718 +
  20.719 + \noindent {\bf Return Type:} 
  20.720 +{\tt 
  20.721 +int
  20.722 +}
  20.723 +
  20.724 +
  20.725 +value of the field
  20.726 +\vspace{0.3cm}
  20.727 +\vspace{0.3cm}
  20.728 +\vspace{0.3cm}
  20.729 +\subsubsection{RPC name:~get\_bus}
  20.730 +
  20.731 +{\bf Overview:} 
  20.732 +Get the bus field of the given PPCI.
  20.733 +
  20.734 + \noindent {\bf Signature:} 
  20.735 +\begin{verbatim} int get_bus (session_id s, PPCI ref self)\end{verbatim}
  20.736 +
  20.737 +
  20.738 +\noindent{\bf Arguments:}
  20.739 +
  20.740 + 
  20.741 +\vspace{0.3cm}
  20.742 +\begin{tabular}{|c|c|p{7cm}|}
  20.743 + \hline
  20.744 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.745 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.746 +
  20.747 +\end{tabular}
  20.748 +
  20.749 +\vspace{0.3cm}
  20.750 +
  20.751 + \noindent {\bf Return Type:} 
  20.752 +{\tt 
  20.753 +int
  20.754 +}
  20.755 +
  20.756 +
  20.757 +value of the field
  20.758 +\vspace{0.3cm}
  20.759 +\vspace{0.3cm}
  20.760 +\vspace{0.3cm}
  20.761 +\subsubsection{RPC name:~get\_slot}
  20.762 +
  20.763 +{\bf Overview:} 
  20.764 +Get the slot field of the given PPCI.
  20.765 +
  20.766 + \noindent {\bf Signature:} 
  20.767 +\begin{verbatim} int get_slot (session_id s, PPCI ref self)\end{verbatim}
  20.768 +
  20.769 +
  20.770 +\noindent{\bf Arguments:}
  20.771 +
  20.772 + 
  20.773 +\vspace{0.3cm}
  20.774 +\begin{tabular}{|c|c|p{7cm}|}
  20.775 + \hline
  20.776 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.777 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.778 +
  20.779 +\end{tabular}
  20.780 +
  20.781 +\vspace{0.3cm}
  20.782 +
  20.783 + \noindent {\bf Return Type:} 
  20.784 +{\tt 
  20.785 +int
  20.786 +}
  20.787 +
  20.788 +
  20.789 +value of the field
  20.790 +\vspace{0.3cm}
  20.791 +\vspace{0.3cm}
  20.792 +\vspace{0.3cm}
  20.793 +\subsubsection{RPC name:~get\_func}
  20.794 +
  20.795 +{\bf Overview:} 
  20.796 +Get the func field of the given PPCI.
  20.797 +
  20.798 + \noindent {\bf Signature:} 
  20.799 +\begin{verbatim} int get_func (session_id s, PPCI ref self)\end{verbatim}
  20.800 +
  20.801 +
  20.802 +\noindent{\bf Arguments:}
  20.803 +
  20.804 + 
  20.805 +\vspace{0.3cm}
  20.806 +\begin{tabular}{|c|c|p{7cm}|}
  20.807 + \hline
  20.808 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.809 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.810 +
  20.811 +\end{tabular}
  20.812 +
  20.813 +\vspace{0.3cm}
  20.814 +
  20.815 + \noindent {\bf Return Type:} 
  20.816 +{\tt 
  20.817 +int
  20.818 +}
  20.819 +
  20.820 +
  20.821 +value of the field
  20.822 +\vspace{0.3cm}
  20.823 +\vspace{0.3cm}
  20.824 +\vspace{0.3cm}
  20.825 +\subsubsection{RPC name:~get\_name}
  20.826 +
  20.827 +{\bf Overview:} 
  20.828 +Get the name field of the given PPCI.
  20.829 +
  20.830 + \noindent {\bf Signature:} 
  20.831 +\begin{verbatim} string get_name (session_id s, PPCI ref self)\end{verbatim}
  20.832 +
  20.833 +
  20.834 +\noindent{\bf Arguments:}
  20.835 +
  20.836 + 
  20.837 +\vspace{0.3cm}
  20.838 +\begin{tabular}{|c|c|p{7cm}|}
  20.839 + \hline
  20.840 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.841 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.842 +
  20.843 +\end{tabular}
  20.844 +
  20.845 +\vspace{0.3cm}
  20.846 +
  20.847 + \noindent {\bf Return Type:} 
  20.848 +{\tt 
  20.849 +string
  20.850 +}
  20.851 +
  20.852 +
  20.853 +value of the field
  20.854 +\vspace{0.3cm}
  20.855 +\vspace{0.3cm}
  20.856 +\vspace{0.3cm}
  20.857 +\subsubsection{RPC name:~get\_vendor\_id}
  20.858 +
  20.859 +{\bf Overview:} 
  20.860 +Get the vendor\_id field of the given PPCI.
  20.861 +
  20.862 + \noindent {\bf Signature:} 
  20.863 +\begin{verbatim} int get_vendor_id (session_id s, PPCI ref self)\end{verbatim}
  20.864 +
  20.865 +
  20.866 +\noindent{\bf Arguments:}
  20.867 +
  20.868 + 
  20.869 +\vspace{0.3cm}
  20.870 +\begin{tabular}{|c|c|p{7cm}|}
  20.871 + \hline
  20.872 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.873 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.874 +
  20.875 +\end{tabular}
  20.876 +
  20.877 +\vspace{0.3cm}
  20.878 +
  20.879 + \noindent {\bf Return Type:} 
  20.880 +{\tt 
  20.881 +int
  20.882 +}
  20.883 +
  20.884 +
  20.885 +value of the field
  20.886 +\vspace{0.3cm}
  20.887 +\vspace{0.3cm}
  20.888 +\vspace{0.3cm}
  20.889 +\subsubsection{RPC name:~get\_vendor\_name}
  20.890 +
  20.891 +{\bf Overview:} 
  20.892 +Get the vendor\_name field of the given PPCI.
  20.893 +
  20.894 + \noindent {\bf Signature:} 
  20.895 +\begin{verbatim} string get_vendor_name (session_id s, PPCI ref self)\end{verbatim}
  20.896 +
  20.897 +
  20.898 +\noindent{\bf Arguments:}
  20.899 +
  20.900 + 
  20.901 +\vspace{0.3cm}
  20.902 +\begin{tabular}{|c|c|p{7cm}|}
  20.903 + \hline
  20.904 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.905 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.906 +
  20.907 +\end{tabular}
  20.908 +
  20.909 +\vspace{0.3cm}
  20.910 +
  20.911 + \noindent {\bf Return Type:} 
  20.912 +{\tt 
  20.913 +string
  20.914 +}
  20.915 +
  20.916 +
  20.917 +value of the field
  20.918 +\vspace{0.3cm}
  20.919 +\vspace{0.3cm}
  20.920 +\vspace{0.3cm}
  20.921 +\subsubsection{RPC name:~get\_device\_id}
  20.922 +
  20.923 +{\bf Overview:} 
  20.924 +Get the device\_id field of the given PPCI.
  20.925 +
  20.926 + \noindent {\bf Signature:} 
  20.927 +\begin{verbatim} int get_device_id (session_id s, PPCI ref self)\end{verbatim}
  20.928 +
  20.929 +
  20.930 +\noindent{\bf Arguments:}
  20.931 +
  20.932 + 
  20.933 +\vspace{0.3cm}
  20.934 +\begin{tabular}{|c|c|p{7cm}|}
  20.935 + \hline
  20.936 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.937 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.938 +
  20.939 +\end{tabular}
  20.940 +
  20.941 +\vspace{0.3cm}
  20.942 +
  20.943 + \noindent {\bf Return Type:} 
  20.944 +{\tt 
  20.945 +int
  20.946 +}
  20.947 +
  20.948 +
  20.949 +value of the field
  20.950 +\vspace{0.3cm}
  20.951 +\vspace{0.3cm}
  20.952 +\vspace{0.3cm}
  20.953 +\subsubsection{RPC name:~get\_device\_name}
  20.954 +
  20.955 +{\bf Overview:} 
  20.956 +Get the device\_name field of the given PPCI.
  20.957 +
  20.958 + \noindent {\bf Signature:} 
  20.959 +\begin{verbatim} string get_device_name (session_id s, PPCI ref self)\end{verbatim}
  20.960 +
  20.961 +
  20.962 +\noindent{\bf Arguments:}
  20.963 +
  20.964 + 
  20.965 +\vspace{0.3cm}
  20.966 +\begin{tabular}{|c|c|p{7cm}|}
  20.967 + \hline
  20.968 +{\bf type} & {\bf name} & {\bf description} \\ \hline
  20.969 +{\tt PPCI ref } & self & reference to the object \\ \hline 
  20.970 +
  20.971 +\end{tabular}
  20.972 +
  20.973 +\vspace{0.3cm}
  20.974 +
  20.975 + \noindent {\bf Return Type:} 
  20.976 +{\tt 
  20.977 +string
  20.978 +}
  20.979 +
  20.980 +
  20.981 +value of the field
  20.982 +\vspace{0.3cm}
  20.983 +\vspace{0.3cm}
  20.984 +\vspace{0.3cm}
  20.985 +\subsubsection{RPC name:~get\_revision\_id}
  20.986 +
  20.987 +{\bf Overview:} 
  20.988 +Get the revision\_id field of the given PPCI.
  20.989 +
  20.990 + \noindent {\bf Signature:} 
  20.991 +\begin{verbatim} int get_revision_id (session_id s, PPCI ref self)\end{verbatim}
  20.992 +
  20.993 +
  20.994 +\noindent{\bf Arguments:}
  20.995 +
  20.996 + 
  20.997 +\vspace{0.3cm}
  20.998 +\begin{tabular}{|c|c|p{7cm}|}
  20.999 + \hline
 20.1000 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1001 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1002 +
 20.1003 +\end{tabular}
 20.1004 +
 20.1005 +\vspace{0.3cm}
 20.1006 +
 20.1007 + \noindent {\bf Return Type:} 
 20.1008 +{\tt 
 20.1009 +int
 20.1010 +}
 20.1011 +
 20.1012 +
 20.1013 +value of the field
 20.1014 +\vspace{0.3cm}
 20.1015 +\vspace{0.3cm}
 20.1016 +\vspace{0.3cm}
 20.1017 +\subsubsection{RPC name:~get\_class\_code}
 20.1018 +
 20.1019 +{\bf Overview:} 
 20.1020 +Get the class\_code field of the given PPCI.
 20.1021 +
 20.1022 + \noindent {\bf Signature:} 
 20.1023 +\begin{verbatim} int get_class_code (session_id s, PPCI ref self)\end{verbatim}
 20.1024 +
 20.1025 +
 20.1026 +\noindent{\bf Arguments:}
 20.1027 +
 20.1028 + 
 20.1029 +\vspace{0.3cm}
 20.1030 +\begin{tabular}{|c|c|p{7cm}|}
 20.1031 + \hline
 20.1032 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1033 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1034 +
 20.1035 +\end{tabular}
 20.1036 +
 20.1037 +\vspace{0.3cm}
 20.1038 +
 20.1039 + \noindent {\bf Return Type:} 
 20.1040 +{\tt 
 20.1041 +int
 20.1042 +}
 20.1043 +
 20.1044 +
 20.1045 +value of the field
 20.1046 +\vspace{0.3cm}
 20.1047 +\vspace{0.3cm}
 20.1048 +\vspace{0.3cm}
 20.1049 +\subsubsection{RPC name:~get\_class\_name}
 20.1050 +
 20.1051 +{\bf Overview:} 
 20.1052 +Get the class\_name field of the given PPCI.
 20.1053 +
 20.1054 + \noindent {\bf Signature:} 
 20.1055 +\begin{verbatim} string get_class_name (session_id s, PPCI ref self)\end{verbatim}
 20.1056 +
 20.1057 +
 20.1058 +\noindent{\bf Arguments:}
 20.1059 +
 20.1060 + 
 20.1061 +\vspace{0.3cm}
 20.1062 +\begin{tabular}{|c|c|p{7cm}|}
 20.1063 + \hline
 20.1064 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1065 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1066 +
 20.1067 +\end{tabular}
 20.1068 +
 20.1069 +\vspace{0.3cm}
 20.1070 +
 20.1071 + \noindent {\bf Return Type:} 
 20.1072 +{\tt 
 20.1073 +string
 20.1074 +}
 20.1075 +
 20.1076 +
 20.1077 +value of the field
 20.1078 +\vspace{0.3cm}
 20.1079 +\vspace{0.3cm}
 20.1080 +\vspace{0.3cm}
 20.1081 +\subsubsection{RPC name:~get\_subsystem\_vendor\_id}
 20.1082 +
 20.1083 +{\bf Overview:} 
 20.1084 +Get the subsystem\_vendor\_id field of the given PPCI.
 20.1085 +
 20.1086 + \noindent {\bf Signature:} 
 20.1087 +\begin{verbatim} int get_subsystem_vendor_id (session_id s, PPCI ref self)\end{verbatim}
 20.1088 +
 20.1089 +
 20.1090 +\noindent{\bf Arguments:}
 20.1091 +
 20.1092 + 
 20.1093 +\vspace{0.3cm}
 20.1094 +\begin{tabular}{|c|c|p{7cm}|}
 20.1095 + \hline
 20.1096 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1097 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1098 +
 20.1099 +\end{tabular}
 20.1100 +
 20.1101 +\vspace{0.3cm}
 20.1102 +
 20.1103 + \noindent {\bf Return Type:} 
 20.1104 +{\tt 
 20.1105 +int
 20.1106 +}
 20.1107 +
 20.1108 +
 20.1109 +value of the field
 20.1110 +\vspace{0.3cm}
 20.1111 +\vspace{0.3cm}
 20.1112 +\vspace{0.3cm}
 20.1113 +\subsubsection{RPC name:~get\_subsystem\_vendor\_name}
 20.1114 +
 20.1115 +{\bf Overview:} 
 20.1116 +Get the subsystem\_vendor\_name field of the given PPCI.
 20.1117 +
 20.1118 + \noindent {\bf Signature:} 
 20.1119 +\begin{verbatim} string get_subsystem_vendor_name (session_id s, PPCI ref self)\end{verbatim}
 20.1120 +
 20.1121 +
 20.1122 +\noindent{\bf Arguments:}
 20.1123 +
 20.1124 + 
 20.1125 +\vspace{0.3cm}
 20.1126 +\begin{tabular}{|c|c|p{7cm}|}
 20.1127 + \hline
 20.1128 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1129 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1130 +
 20.1131 +\end{tabular}
 20.1132 +
 20.1133 +\vspace{0.3cm}
 20.1134 +
 20.1135 + \noindent {\bf Return Type:} 
 20.1136 +{\tt 
 20.1137 +string
 20.1138 +}
 20.1139 +
 20.1140 +
 20.1141 +value of the field
 20.1142 +\vspace{0.3cm}
 20.1143 +\vspace{0.3cm}
 20.1144 +\vspace{0.3cm}
 20.1145 +\subsubsection{RPC name:~get\_subsystem\_id}
 20.1146 +
 20.1147 +{\bf Overview:} 
 20.1148 +Get the subsystem\_id field of the given PPCI.
 20.1149 +
 20.1150 + \noindent {\bf Signature:} 
 20.1151 +\begin{verbatim} int get_subsystem_id (session_id s, PPCI ref self)\end{verbatim}
 20.1152 +
 20.1153 +
 20.1154 +\noindent{\bf Arguments:}
 20.1155 +
 20.1156 + 
 20.1157 +\vspace{0.3cm}
 20.1158 +\begin{tabular}{|c|c|p{7cm}|}
 20.1159 + \hline
 20.1160 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1161 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1162 +
 20.1163 +\end{tabular}
 20.1164 +
 20.1165 +\vspace{0.3cm}
 20.1166 +
 20.1167 + \noindent {\bf Return Type:} 
 20.1168 +{\tt 
 20.1169 +int
 20.1170 +}
 20.1171 +
 20.1172 +
 20.1173 +value of the field
 20.1174 +\vspace{0.3cm}
 20.1175 +\vspace{0.3cm}
 20.1176 +\vspace{0.3cm}
 20.1177 +\subsubsection{RPC name:~get\_subsystem\_name}
 20.1178 +
 20.1179 +{\bf Overview:} 
 20.1180 +Get the subsystem\_name field of the given PPCI.
 20.1181 +
 20.1182 + \noindent {\bf Signature:} 
 20.1183 +\begin{verbatim} string get_subsystem_name (session_id s, PPCI ref self)\end{verbatim}
 20.1184 +
 20.1185 +
 20.1186 +\noindent{\bf Arguments:}
 20.1187 +
 20.1188 + 
 20.1189 +\vspace{0.3cm}
 20.1190 +\begin{tabular}{|c|c|p{7cm}|}
 20.1191 + \hline
 20.1192 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1193 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1194 +
 20.1195 +\end{tabular}
 20.1196 +
 20.1197 +\vspace{0.3cm}
 20.1198 +
 20.1199 + \noindent {\bf Return Type:} 
 20.1200 +{\tt 
 20.1201 +string
 20.1202 +}
 20.1203 +
 20.1204 +
 20.1205 +value of the field
 20.1206 +\vspace{0.3cm}
 20.1207 +\vspace{0.3cm}
 20.1208 +\vspace{0.3cm}
 20.1209 +\subsubsection{RPC name:~get\_driver}
 20.1210 +
 20.1211 +{\bf Overview:} 
 20.1212 +Get the driver field of the given PPCI.
 20.1213 +
 20.1214 + \noindent {\bf Signature:} 
 20.1215 +\begin{verbatim} string get_driver (session_id s, PPCI ref self)\end{verbatim}
 20.1216 +
 20.1217 +
 20.1218 +\noindent{\bf Arguments:}
 20.1219 +
 20.1220 + 
 20.1221 +\vspace{0.3cm}
 20.1222 +\begin{tabular}{|c|c|p{7cm}|}
 20.1223 + \hline
 20.1224 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1225 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1226 +
 20.1227 +\end{tabular}
 20.1228 +
 20.1229 +\vspace{0.3cm}
 20.1230 +
 20.1231 + \noindent {\bf Return Type:} 
 20.1232 +{\tt 
 20.1233 +string
 20.1234 +}
 20.1235 +
 20.1236 +
 20.1237 +value of the field
 20.1238 +\vspace{0.3cm}
 20.1239 +\vspace{0.3cm}
 20.1240 +\vspace{0.3cm}
 20.1241 +\subsubsection{RPC name:~get\_by\_uuid}
 20.1242 +
 20.1243 +{\bf Overview:} 
 20.1244 +Get a reference to the PPCI instance with the specified UUID.
 20.1245 +
 20.1246 + \noindent {\bf Signature:} 
 20.1247 +\begin{verbatim} (PPCI ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
 20.1248 +
 20.1249 +
 20.1250 +\noindent{\bf Arguments:}
 20.1251 +
 20.1252 + 
 20.1253 +\vspace{0.3cm}
 20.1254 +\begin{tabular}{|c|c|p{7cm}|}
 20.1255 + \hline
 20.1256 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1257 +{\tt string } & uuid & UUID of object to return \\ \hline 
 20.1258 +
 20.1259 +\end{tabular}
 20.1260 +
 20.1261 +\vspace{0.3cm}
 20.1262 +
 20.1263 + \noindent {\bf Return Type:} 
 20.1264 +{\tt 
 20.1265 +PPCI ref
 20.1266 +}
 20.1267 +
 20.1268 +
 20.1269 +reference to the object
 20.1270 +\vspace{0.3cm}
 20.1271 +\vspace{0.3cm}
 20.1272 +\vspace{0.3cm}
 20.1273 +\subsubsection{RPC name:~get\_record}
 20.1274 +
 20.1275 +{\bf Overview:} 
 20.1276 +Get a record containing the current state of the given PPCI.
 20.1277 +
 20.1278 + \noindent {\bf Signature:} 
 20.1279 +\begin{verbatim} (PPCI record) get_record (session_id s, PPCI ref self)\end{verbatim}
 20.1280 +
 20.1281 +
 20.1282 +\noindent{\bf Arguments:}
 20.1283 +
 20.1284 + 
 20.1285 +\vspace{0.3cm}
 20.1286 +\begin{tabular}{|c|c|p{7cm}|}
 20.1287 + \hline
 20.1288 +{\bf type} & {\bf name} & {\bf description} \\ \hline
 20.1289 +{\tt PPCI ref } & self & reference to the object \\ \hline 
 20.1290 +
 20.1291 +\end{tabular}
 20.1292 +
 20.1293 +\vspace{0.3cm}
 20.1294 +
 20.1295 + \noindent {\bf Return Type:} 
 20.1296 +{\tt 
 20.1297 +PPCI record
 20.1298 +}
 20.1299 +
 20.1300 +
 20.1301 +all fields from the object
 20.1302 +\vspace{0.3cm}
 20.1303 +\vspace{0.3cm}
 20.1304 +\vspace{0.3cm}
 20.1305 +
 20.1306 +\vspace{1cm}
 20.1307 +\newpage
 20.1308  \section{Class: user}
 20.1309  \subsection{Fields for class: user}
 20.1310  \begin{longtable}{|lllp{0.38\textwidth}|}
    21.1 --- a/extras/mini-os/Config.mk	Fri Aug 29 15:47:21 2008 -0700
    21.2 +++ b/extras/mini-os/Config.mk	Tue Sep 02 16:34:53 2008 -0700
    21.3 @@ -38,31 +38,20 @@ EXTRA_INC = $(ARCH_INC)
    21.4  # This must be before include minios.mk!
    21.5  include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk
    21.6  
    21.7 -extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir))
    21.8 -
    21.9 -DEF_CPPFLAGS += -I$(MINI-OS_ROOT)/include
   21.10 +extra_incl := $(foreach dir,$(EXTRA_INC),-isystem $(CURDIR)/$(MINI-OS_ROOT)/include/$(dir))
   21.11  
   21.12 -ifeq ($(stubdom),y)
   21.13 -DEF_CPPFLAGS += -DCONFIG_STUBDOM
   21.14 -endif
   21.15 +DEF_CPPFLAGS += -isystem $(CURDIR)/$(MINI-OS_ROOT)/include
   21.16 +DEF_CPPFLAGS += -D__MINIOS__
   21.17  
   21.18  ifeq ($(libc),y)
   21.19  DEF_CPPFLAGS += -DHAVE_LIBC
   21.20 -DEF_CPPFLAGS += -I$(MINI-OS_ROOT)/include/posix
   21.21 -DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore
   21.22 +DEF_CPPFLAGS += -isystem $(CURDIR)/$(MINI-OS_ROOT)/include/posix
   21.23 +DEF_CPPFLAGS += -isystem $(CURDIR)/$(XEN_ROOT)/tools/xenstore
   21.24  endif
   21.25  
   21.26  ifneq ($(LWIPDIR),)
   21.27  lwip=y
   21.28  DEF_CPPFLAGS += -DHAVE_LWIP
   21.29 -DEF_CPPFLAGS += -I$(LWIPDIR)/src/include
   21.30 -DEF_CPPFLAGS += -I$(LWIPDIR)/src/include/ipv4
   21.31 +DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include
   21.32 +DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include/ipv4
   21.33  endif
   21.34 -
   21.35 -ifneq ($(QEMUDIR),)
   21.36 -qemu=y
   21.37 -endif
   21.38 -
   21.39 -ifneq ($(CAMLDIR),)
   21.40 -caml=y
   21.41 -endif
    22.1 --- a/extras/mini-os/Makefile	Fri Aug 29 15:47:21 2008 -0700
    22.2 +++ b/extras/mini-os/Makefile	Tue Sep 02 16:34:53 2008 -0700
    22.3 @@ -6,6 +6,7 @@
    22.4  
    22.5  export XEN_ROOT = ../..
    22.6  include $(XEN_ROOT)/Config.mk
    22.7 +OBJ_DIR ?= $(CURDIR)
    22.8  
    22.9  ifneq ($(stubdom),y)
   22.10  include Config.mk
   22.11 @@ -20,7 +21,7 @@ include minios.mk
   22.12  # Define some default flags for linking.
   22.13  LDLIBS := 
   22.14  APP_LDLIBS := 
   22.15 -LDARCHLIB := -L$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
   22.16 +LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
   22.17  LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
   22.18  
   22.19  # Prefix for global API names. All other symbols are localised before
   22.20 @@ -35,14 +36,14 @@ SUBDIRS := lib xenbus console
   22.21  
   22.22  # The common mini-os objects to build.
   22.23  APP_OBJS :=
   22.24 -OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
   22.25 -OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
   22.26 -OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
   22.27 -OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
   22.28 +OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard *.c))
   22.29 +OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard lib/*.c))
   22.30 +OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard xenbus/*.c))
   22.31 +OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard console/*.c))
   22.32  
   22.33  
   22.34  .PHONY: default
   22.35 -default: $(TARGET)
   22.36 +default: $(OBJ_DIR)/$(TARGET)
   22.37  
   22.38  # Create special architecture specific links. The function arch_links
   22.39  # has to be defined in arch.mk (see include above).
   22.40 @@ -54,63 +55,46 @@ endif
   22.41  .PHONY: links
   22.42  links:	$(ARCH_LINKS)
   22.43  	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
   22.44 +	[ -e include/mini-os ] || ln -sf . include/mini-os
   22.45 +	[ -e include/$(TARGET_ARCH_FAM)/mini-os ] || ln -sf . include/$(TARGET_ARCH_FAM)/mini-os
   22.46  
   22.47  .PHONY: arch_lib
   22.48  arch_lib:
   22.49 -	$(MAKE) --directory=$(TARGET_ARCH_DIR) || exit 1;
   22.50 +	$(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) || exit 1;
   22.51  
   22.52  ifeq ($(lwip),y)
   22.53  # lwIP library
   22.54  LWC	:= $(shell find $(LWIPDIR)/ -type f -name '*.c')
   22.55  LWC	:= $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
   22.56 -LWC	+= lwip-arch.c lwip-net.c
   22.57  LWO	:= $(patsubst %.c,%.o,$(LWC))
   22.58 +LWO	+= $(addprefix $(OBJ_DIR)/,lwip-arch.o lwip-net.o)
   22.59  
   22.60 -lwip.a: $(LWO)
   22.61 +$(OBJ_DIR)/lwip.a: $(LWO)
   22.62  	$(RM) $@
   22.63  	$(AR) cqs $@ $^
   22.64  
   22.65 -OBJS += lwip.a
   22.66 +OBJS += $(OBJ_DIR)/lwip.a
   22.67  endif
   22.68  
   22.69 -OBJS := $(filter-out lwip%.o $(LWO), $(OBJS))
   22.70 -
   22.71 -ifeq ($(caml),y)
   22.72 -CAMLLIB = $(shell ocamlc -where)
   22.73 -APP_OBJS += main-caml.o
   22.74 -APP_OBJS += $(CAMLDIR)/caml.o
   22.75 -APP_OBJS += $(CAMLLIB)/libasmrun.a
   22.76 -CFLAGS += -I$(CAMLLIB)
   22.77 -APP_LDLIBS += -lm
   22.78 -endif
   22.79 -OBJS := $(filter-out main-caml.o, $(OBJS))
   22.80 -
   22.81 -ifeq ($(qemu),y)
   22.82 -APP_OBJS += $(QEMUDIR)/i386-dm-stubdom/qemu.a $(QEMUDIR)/i386-dm-stubdom/libqemu.a
   22.83 -CFLAGS += -DCONFIG_QEMU
   22.84 -endif
   22.85 -
   22.86 -ifneq ($(CDIR),)
   22.87 -APP_OBJS += $(CDIR)/main.a
   22.88 -APP_LDLIBS += 
   22.89 -endif
   22.90 +OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS))
   22.91  
   22.92  ifeq ($(libc),y)
   22.93 -LDLIBS += -L$(XEN_ROOT)/stubdom/libxc -lxenctrl -lxenguest
   22.94 +APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive -lxenguest -lxenctrl -no-whole-archive
   22.95  APP_LDLIBS += -lpci
   22.96  APP_LDLIBS += -lz
   22.97 +APP_LDLIBS += -lm
   22.98  LDLIBS += -lc
   22.99  endif
  22.100  
  22.101 -ifneq ($(caml)-$(qemu)-$(CDIR)-$(lwip),---y)
  22.102 -OBJS := $(filter-out daytime.o, $(OBJS))
  22.103 +ifneq ($(APP_OBJS)-$(lwip),-y)
  22.104 +OBJS := $(filter-out $(OBJ_DIR)/daytime.o, $(OBJS))
  22.105  endif
  22.106  
  22.107 -app.o: $(APP_OBJS) app.lds
  22.108 -	$(LD) -r -d $(LDFLAGS) $^ $(APP_LDLIBS) --undefined main -o $@
  22.109 +$(OBJ_DIR)/$(TARGET)_app.o: $(APP_OBJS) app.lds
  22.110 +	$(LD) -r -d $(LDFLAGS) -\( $^ -\) $(APP_LDLIBS) --undefined main -o $@
  22.111  
  22.112 -$(TARGET): links $(OBJS) app.o arch_lib
  22.113 -	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) app.o $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
  22.114 +$(OBJ_DIR)/$(TARGET): links $(OBJS) $(OBJ_DIR)/$(TARGET)_app.o arch_lib
  22.115 +	$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJ_DIR)/$(TARGET)_app.o $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
  22.116  	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
  22.117  	$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
  22.118  	gzip -f -9 -c $@ >$@.gz
  22.119 @@ -118,15 +102,15 @@ app.o: $(APP_OBJS) app.lds
  22.120  .PHONY: clean arch_clean
  22.121  
  22.122  arch_clean:
  22.123 -	$(MAKE) --directory=$(TARGET_ARCH_DIR) clean || exit 1;
  22.124 +	$(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) clean || exit 1;
  22.125  
  22.126  clean:	arch_clean
  22.127 -	for dir in $(SUBDIRS); do \
  22.128 +	for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \
  22.129  		rm -f $$dir/*.o; \
  22.130  	done
  22.131 -	rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
  22.132 -	find . -type l | xargs rm -f
  22.133 -	$(RM) lwip.a $(LWO)
  22.134 +	rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core $(OBJ_DIR)/$(TARGET).elf $(OBJ_DIR)/$(TARGET).raw $(OBJ_DIR)/$(TARGET) $(OBJ_DIR)/$(TARGET).gz
  22.135 +	find . $(OBJ_DIR) -type l | xargs rm -f
  22.136 +	$(RM) $(OBJ_DIR)/lwip.a $(LWO)
  22.137  	rm -f tags TAGS
  22.138  
  22.139  
    23.1 --- a/extras/mini-os/arch/ia64/Makefile	Fri Aug 29 15:47:21 2008 -0700
    23.2 +++ b/extras/mini-os/arch/ia64/Makefile	Tue Sep 02 16:34:53 2008 -0700
    23.3 @@ -40,12 +40,13 @@ ARCH_OBJS += __umoddi3.o
    23.4  ARCH_OBJS += __udivdi3.o
    23.5  ARCH_OBJS += __udivsi3.o
    23.6  ARCH_OBJS += __divdi3.o
    23.7 +ARCH_OBJS := $(addprefix $(OBJ_DIR)/,$(ARCH_OBJS))
    23.8  
    23.9  GEN_OFF_SRC := gen_off.c
   23.10  GEN_OFF_ASM := gen_off.s
   23.11  GEN_OFF_H   := $(MINI-OS_ROOT)/include/$(ARCH_INC)/offsets.h
   23.12  
   23.13 -all: $(ARCH_LIB)
   23.14 +all: $(OBJ_DIR)/$(ARCH_LIB)
   23.15  
   23.16  $(GEN_OFF_ASM): $(GEN_OFF_SRC)
   23.17  	$(CC) -S -o $@ $(CPPFLAGS) $<
   23.18 @@ -53,10 +54,10 @@ all: $(ARCH_LIB)
   23.19  $(GEN_OFF_H): $(GEN_OFF_ASM)
   23.20  	sed -ne "/^->/ {s/->/#define /; p}" < $< > $@
   23.21  
   23.22 -$(ARCH_LIB): $(GEN_OFF_H) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
   23.23 +$(OBJ_DIR)/$(ARCH_LIB): $(GEN_OFF_H) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
   23.24  	$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
   23.25  
   23.26  clean:
   23.27 -	rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
   23.28 +	rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
   23.29  	rm -f $(GEN_OFF_ASM)
   23.30  	rm -f $(GEN_OFF_H)
    24.1 --- a/extras/mini-os/arch/ia64/common.c	Fri Aug 29 15:47:21 2008 -0700
    24.2 +++ b/extras/mini-os/arch/ia64/common.c	Tue Sep 02 16:34:53 2008 -0700
    24.3 @@ -236,6 +236,12 @@ arch_init(start_info_t *si)
    24.4  }
    24.5  
    24.6  void
    24.7 +arch_fini(void)
    24.8 +{
    24.9 +	/* TODO */
   24.10 +}
   24.11 +
   24.12 +void
   24.13  arch_print_info(void)
   24.14  {
   24.15  	int major, minor;
    25.1 --- a/extras/mini-os/arch/ia64/minios-ia64.lds	Fri Aug 29 15:47:21 2008 -0700
    25.2 +++ b/extras/mini-os/arch/ia64/minios-ia64.lds	Tue Sep 02 16:34:53 2008 -0700
    25.3 @@ -52,6 +52,23 @@ SECTIONS
    25.4    .fini_array     : { *(.fini_array) }
    25.5    PROVIDE (__fini_array_end = .);
    25.6  
    25.7 +  .ctors : {
    25.8 +        __CTOR_LIST__ = .;
    25.9 +        QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
   25.10 +        *(.ctors)
   25.11 +	CONSTRUCTORS
   25.12 +        QUAD(0)
   25.13 +        __CTOR_END__ = .;
   25.14 +        }
   25.15 +
   25.16 +  .dtors : {
   25.17 +        __DTOR_LIST__ = .;
   25.18 +        QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
   25.19 +        *(.dtors)
   25.20 +        QUAD(0)
   25.21 +        __DTOR_END__ = .;
   25.22 +        }
   25.23 +
   25.24    .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20)))
   25.25    { *(.IA_64.unwind_info) }
   25.26  
    26.1 --- a/extras/mini-os/arch/ia64/mm.c	Fri Aug 29 15:47:21 2008 -0700
    26.2 +++ b/extras/mini-os/arch/ia64/mm.c	Tue Sep 02 16:34:53 2008 -0700
    26.3 @@ -130,7 +130,20 @@ arch_init_demand_mapping_area(unsigned l
    26.4  	max_pfn = max_pfn;
    26.5  }
    26.6  
    26.7 +unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
    26.8 +{
    26.9 +        return 0;
   26.10 +}
   26.11 +
   26.12  /* Helper function used in gnttab.c. */
   26.13 +void do_map_frames(unsigned long addr,
   26.14 +        unsigned long *f, unsigned long n, unsigned long stride,
   26.15 +	unsigned long increment, domid_t id, int may_fail, unsigned long prot)
   26.16 +{
   26.17 +	/* TODO */
   26.18 +	ASSERT(0);
   26.19 +}
   26.20 +
   26.21  void*
   26.22  map_frames_ex(unsigned long* frames, unsigned long n, unsigned long stride,
   26.23  	unsigned long increment, unsigned long alignment, domid_t id,
    27.1 --- a/extras/mini-os/arch/ia64/sched.c	Fri Aug 29 15:47:21 2008 -0700
    27.2 +++ b/extras/mini-os/arch/ia64/sched.c	Tue Sep 02 16:34:53 2008 -0700
    27.3 @@ -34,6 +34,11 @@
    27.4  /* The function is implemented in fw.S */
    27.5  extern void thread_starter(void);
    27.6  
    27.7 +void stack_walk(void)
    27.8 +{
    27.9 +    /* TODO */
   27.10 +}
   27.11 +
   27.12  struct thread*
   27.13  arch_create_thread(char *name, void (*function)(void *), void *data)
   27.14  {
    28.1 --- a/extras/mini-os/arch/ia64/time.c	Fri Aug 29 15:47:21 2008 -0700
    28.2 +++ b/extras/mini-os/arch/ia64/time.c	Tue Sep 02 16:34:53 2008 -0700
    28.3 @@ -280,3 +280,9 @@ init_time(void)
    28.4  	ia64_set_itm(new);
    28.5  	ia64_srlz_d();
    28.6  }
    28.7 +
    28.8 +void
    28.9 +fini_time(void)
   28.10 +{
   28.11 +	/* TODO */
   28.12 +}
    29.1 --- a/extras/mini-os/arch/x86/Makefile	Fri Aug 29 15:47:21 2008 -0700
    29.2 +++ b/extras/mini-os/arch/x86/Makefile	Tue Sep 02 16:34:53 2008 -0700
    29.3 @@ -17,15 +17,15 @@ include ../../minios.mk
    29.4  ARCH_SRCS := $(wildcard *.c)
    29.5  
    29.6  # The objects built from the sources.
    29.7 -ARCH_OBJS := $(patsubst %.c,%.o,$(ARCH_SRCS))
    29.8 +ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS))
    29.9  
   29.10 -all: $(ARCH_LIB)
   29.11 +all: $(OBJ_DIR)/$(ARCH_LIB)
   29.12  
   29.13  # $(HEAD_ARCH_OBJ) is only build here, needed on linking
   29.14  # in ../../Makefile.
   29.15 -$(ARCH_LIB): $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
   29.16 -	$(AR) rv $(ARCH_LIB) $(ARCH_OBJS)
   29.17 +$(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
   29.18 +	$(AR) rv $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS)
   29.19  
   29.20  clean:
   29.21 -	rm -f $(ARCH_LIB) $(ARCH_OBJS) $(HEAD_ARCH_OBJ)
   29.22 +	rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
   29.23  
    30.1 --- a/extras/mini-os/arch/x86/minios-x86_32.lds	Fri Aug 29 15:47:21 2008 -0700
    30.2 +++ b/extras/mini-os/arch/x86/minios-x86_32.lds	Tue Sep 02 16:34:53 2008 -0700
    30.3 @@ -28,9 +28,25 @@ SECTIONS
    30.4    .fini_array     : { *(.fini_array) }
    30.5    PROVIDE (__fini_array_end = .);
    30.6  
    30.7 +  .ctors : {
    30.8 +        __CTOR_LIST__ = .;
    30.9 +        LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
   30.10 +        *(.ctors)
   30.11 +	CONSTRUCTORS
   30.12 +        LONG(0)
   30.13 +        __CTOR_END__ = .;
   30.14 +        }
   30.15 +
   30.16 +  .dtors : {
   30.17 +        __DTOR_LIST__ = .;
   30.18 +        LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
   30.19 +        *(.dtors)
   30.20 +        LONG(0)
   30.21 +        __DTOR_END__ = .;
   30.22 +        }
   30.23 +
   30.24    .data : {			/* Data */
   30.25  	*(.data)
   30.26 -	CONSTRUCTORS
   30.27  	}
   30.28  
   30.29    _edata = .;			/* End of data section */
    31.1 --- a/extras/mini-os/arch/x86/minios-x86_64.lds	Fri Aug 29 15:47:21 2008 -0700
    31.2 +++ b/extras/mini-os/arch/x86/minios-x86_64.lds	Tue Sep 02 16:34:53 2008 -0700
    31.3 @@ -28,9 +28,25 @@ SECTIONS
    31.4    .fini_array     : { *(.fini_array) }
    31.5    PROVIDE (__fini_array_end = .);
    31.6  
    31.7 +  .ctors : {
    31.8 +        __CTOR_LIST__ = .;
    31.9 +        QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
   31.10 +        *(.ctors)
   31.11 +	CONSTRUCTORS
   31.12 +        QUAD(0)
   31.13 +        __CTOR_END__ = .;
   31.14 +        }
   31.15 +
   31.16 +  .dtors : {
   31.17 +        __DTOR_LIST__ = .;
   31.18 +        QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2)
   31.19 +        *(.dtors)
   31.20 +        QUAD(0)
   31.21 +        __DTOR_END__ = .;
   31.22 +        }
   31.23 +
   31.24    .data : {			/* Data */
   31.25  	*(.data)
   31.26 -	CONSTRUCTORS
   31.27  	}
   31.28  
   31.29    _edata = .;			/* End of data section */
    32.1 --- a/extras/mini-os/arch/x86/mm.c	Fri Aug 29 15:47:21 2008 -0700
    32.2 +++ b/extras/mini-os/arch/x86/mm.c	Tue Sep 02 16:34:53 2008 -0700
    32.3 @@ -59,36 +59,32 @@ void new_pt_frame(unsigned long *pt_pfn,
    32.4  {   
    32.5      pgentry_t *tab = (pgentry_t *)start_info.pt_base;
    32.6      unsigned long pt_page = (unsigned long)pfn_to_virt(*pt_pfn); 
    32.7 -    unsigned long prot_e, prot_t, pincmd;
    32.8 +    pgentry_t prot_e, prot_t;
    32.9      mmu_update_t mmu_updates[1];
   32.10 -    struct mmuext_op pin_request;
   32.11      
   32.12 -    prot_e = prot_t = pincmd = 0;
   32.13 +    prot_e = prot_t = 0;
   32.14      DEBUG("Allocating new L%d pt frame for pt_pfn=%lx, "
   32.15             "prev_l_mfn=%lx, offset=%lx", 
   32.16             level, *pt_pfn, prev_l_mfn, offset);
   32.17  
   32.18      /* We need to clear the page, otherwise we might fail to map it
   32.19         as a page table page */
   32.20 -    memset((unsigned long*)pfn_to_virt(*pt_pfn), 0, PAGE_SIZE);  
   32.21 +    memset((void*) pt_page, 0, PAGE_SIZE);  
   32.22   
   32.23      switch ( level )
   32.24      {
   32.25      case L1_FRAME:
   32.26           prot_e = L1_PROT;
   32.27           prot_t = L2_PROT;
   32.28 -         pincmd = MMUEXT_PIN_L1_TABLE;
   32.29           break;
   32.30      case L2_FRAME:
   32.31           prot_e = L2_PROT;
   32.32           prot_t = L3_PROT;
   32.33 -         pincmd = MMUEXT_PIN_L2_TABLE;
   32.34           break;
   32.35  #if defined(__x86_64__)
   32.36      case L3_FRAME:
   32.37           prot_e = L3_PROT;
   32.38           prot_t = L4_PROT;
   32.39 -         pincmd = MMUEXT_PIN_L3_TABLE;
   32.40           break;
   32.41  #endif
   32.42      default:
   32.43 @@ -103,7 +99,7 @@ void new_pt_frame(unsigned long *pt_pfn,
   32.44  #endif
   32.45      tab = pte_to_virt(tab[l3_table_offset(pt_page)]);
   32.46  
   32.47 -    mmu_updates[0].ptr = ((pgentry_t)tab[l2_table_offset(pt_page)] & PAGE_MASK) + 
   32.48 +    mmu_updates[0].ptr = (tab[l2_table_offset(pt_page)] & PAGE_MASK) + 
   32.49                           sizeof(pgentry_t) * l1_table_offset(pt_page);
   32.50      mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT | 
   32.51                           (prot_e & ~_PAGE_RW);
   32.52 @@ -113,15 +109,6 @@ void new_pt_frame(unsigned long *pt_pfn,
   32.53           do_exit();
   32.54      }
   32.55                          
   32.56 -    /* Pin the page to provide correct protection */
   32.57 -    pin_request.cmd = pincmd;
   32.58 -    pin_request.arg1.mfn = pfn_to_mfn(*pt_pfn);
   32.59 -    if(HYPERVISOR_mmuext_op(&pin_request, 1, NULL, DOMID_SELF) < 0)
   32.60 -    {
   32.61 -        printk("ERROR: pinning failed\n");
   32.62 -        do_exit();
   32.63 -    }
   32.64 -
   32.65      /* Now fill the new page table page with entries.
   32.66         Update the page directory as well. */
   32.67      mmu_updates[0].ptr = ((pgentry_t)prev_l_mfn << PAGE_SHIFT) + sizeof(pgentry_t) * offset;
   32.68 @@ -385,7 +372,7 @@ static pgentry_t *get_pgt(unsigned long 
   32.69      return &tab[offset];
   32.70  }
   32.71  
   32.72 -static pgentry_t *need_pgt(unsigned long addr)
   32.73 +pgentry_t *need_pgt(unsigned long addr)
   32.74  {
   32.75      unsigned long mfn;
   32.76      pgentry_t *tab;
   32.77 @@ -487,7 +474,7 @@ void do_map_frames(unsigned long addr,
   32.78                  if (!pgt || !(addr & L1_MASK))
   32.79                      pgt = need_pgt(addr);
   32.80  		mmu_updates[i].ptr = virt_to_mach(pgt);
   32.81 -		mmu_updates[i].val = ((f[(done + i) * stride] + (done + i) * increment) << PAGE_SHIFT) | prot;
   32.82 +		mmu_updates[i].val = ((pgentry_t)(f[(done + i) * stride] + (done + i) * increment) << PAGE_SHIFT) | prot;
   32.83  	    }
   32.84  
   32.85  	    rc = HYPERVISOR_mmu_update(mmu_updates, todo, NULL, id);
   32.86 @@ -505,9 +492,7 @@ void do_map_frames(unsigned long addr,
   32.87      }
   32.88  }
   32.89  
   32.90 -void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
   32.91 -	unsigned long increment, unsigned long alignment, domid_t id,
   32.92 -	int may_fail, unsigned long prot)
   32.93 +unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
   32.94  {
   32.95      unsigned long x;
   32.96      unsigned long y = 0;
   32.97 @@ -530,29 +515,35 @@ void *map_frames_ex(unsigned long *f, un
   32.98      }
   32.99      if (y != n) {
  32.100          printk("Failed to find %ld frames!\n", n);
  32.101 +        return 0;
  32.102 +    }
  32.103 +    return demand_map_area_start + x * PAGE_SIZE;
  32.104 +}
  32.105 +
  32.106 +void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
  32.107 +	unsigned long increment, unsigned long alignment, domid_t id,
  32.108 +	int may_fail, unsigned long prot)
  32.109 +{
  32.110 +    unsigned long addr = allocate_ondemand(n, alignment);
  32.111 +
  32.112 +    if (!addr)
  32.113          return NULL;
  32.114 -    }
  32.115  
  32.116      /* Found it at x.  Map it in. */
  32.117 -    do_map_frames(demand_map_area_start + x * PAGE_SIZE, f, n, stride, increment, id, may_fail, prot);
  32.118 +    do_map_frames(addr, f, n, stride, increment, id, may_fail, prot);
  32.119  
  32.120 -    return (void *)(unsigned long)(demand_map_area_start + x * PAGE_SIZE);
  32.121 +    return (void *)addr;
  32.122  }
  32.123  
  32.124  static void clear_bootstrap(void)
  32.125  {
  32.126 -    xen_pfn_t mfns[] = { virt_to_mfn(&shared_info) };
  32.127 -    int n = sizeof(mfns)/sizeof(*mfns);
  32.128      pte_t nullpte = { };
  32.129  
  32.130      /* Use first page as the CoW zero page */
  32.131      memset(&_text, 0, PAGE_SIZE);
  32.132 -    mfn_zero = pfn_to_mfn((unsigned long) &_text);
  32.133 -    if (HYPERVISOR_update_va_mapping((unsigned long) &_text, nullpte, UVMF_INVLPG))
  32.134 -	printk("Unable to unmap first page\n");
  32.135 -
  32.136 -    if (free_physical_pages(mfns, n) != n)
  32.137 -	printk("Unable to free bootstrap pages\n");
  32.138 +    mfn_zero = virt_to_mfn((unsigned long) &_text);
  32.139 +    if (HYPERVISOR_update_va_mapping(0, nullpte, UVMF_INVLPG))
  32.140 +	printk("Unable to unmap NULL page\n");
  32.141  }
  32.142  
  32.143  void arch_init_p2m(unsigned long max_pfn)
  32.144 @@ -567,7 +558,7 @@ void arch_init_p2m(unsigned long max_pfn
  32.145  #define L2_P2M_MASK     (L2_P2M_ENTRIES - 1)    
  32.146  #define L3_P2M_MASK     (L3_P2M_ENTRIES - 1)    
  32.147      
  32.148 -    unsigned long *l1_list, *l2_list, *l3_list;
  32.149 +    unsigned long *l1_list = NULL, *l2_list = NULL, *l3_list;
  32.150      unsigned long pfn;
  32.151      
  32.152      l3_list = (unsigned long *)alloc_page(); 
    33.1 --- a/extras/mini-os/arch/x86/setup.c	Fri Aug 29 15:47:21 2008 -0700
    33.2 +++ b/extras/mini-os/arch/x86/setup.c	Tue Sep 02 16:34:53 2008 -0700
    33.3 @@ -100,6 +100,16 @@ arch_init(start_info_t *si)
    33.4  }
    33.5  
    33.6  void
    33.7 +arch_fini(void)
    33.8 +{
    33.9 +#ifdef __i386__
   33.10 +	HYPERVISOR_set_callbacks(0, 0, 0, 0);
   33.11 +#else
   33.12 +	HYPERVISOR_set_callbacks(0, 0, 0);
   33.13 +#endif
   33.14 +}
   33.15 +
   33.16 +void
   33.17  arch_print_info(void)
   33.18  {
   33.19  	printk("  stack:      %p-%p\n", stack, stack + sizeof(stack));
    34.1 --- a/extras/mini-os/arch/x86/time.c	Fri Aug 29 15:47:21 2008 -0700
    34.2 +++ b/extras/mini-os/arch/x86/time.c	Tue Sep 02 16:34:53 2008 -0700
    34.3 @@ -222,10 +222,17 @@ static void timer_handler(evtchn_port_t 
    34.4  
    34.5  
    34.6  
    34.7 +static evtchn_port_t port;
    34.8  void init_time(void)
    34.9  {
   34.10 -    evtchn_port_t port;
   34.11      printk("Initialising timer interface\n");
   34.12      port = bind_virq(VIRQ_TIMER, &timer_handler, NULL);
   34.13      unmask_evtchn(port);
   34.14  }
   34.15 +
   34.16 +void fini_time(void)
   34.17 +{
   34.18 +    /* Clear any pending timer */
   34.19 +    HYPERVISOR_set_timer_op(0);
   34.20 +    unbind_evtchn(port);
   34.21 +}
    35.1 --- a/extras/mini-os/arch/x86/traps.c	Fri Aug 29 15:47:21 2008 -0700
    35.2 +++ b/extras/mini-os/arch/x86/traps.c	Tue Sep 02 16:34:53 2008 -0700
    35.3 @@ -112,7 +112,7 @@ void page_walk(unsigned long virt_addres
    35.4          printk("   L2 = %"PRIpte" (%p)  [offset = %lx]\n", page, tab, l2_table_offset(addr));
    35.5          
    35.6          page = tab[l1_table_offset(addr)];
    35.7 -        printk("    L1 = %"PRIpte" (%p)  [offset = %lx]\n", page, tab, l1_table_offset(addr));
    35.8 +        printk("    L1 = %"PRIpte" [offset = %lx]\n", page, l1_table_offset(addr));
    35.9  
   35.10  }
   35.11  
   35.12 @@ -155,6 +155,40 @@ static int handle_cow(unsigned long addr
   35.13  	return 0;
   35.14  }
   35.15  
   35.16 +static void do_stack_walk(unsigned long frame_base)
   35.17 +{
   35.18 +    unsigned long *frame = (void*) frame_base;
   35.19 +    printk("base is %#lx ", frame_base);
   35.20 +    printk("caller is %#lx\n", frame[1]);
   35.21 +    if (frame[0])
   35.22 +	do_stack_walk(frame[0]);
   35.23 +}
   35.24 +
   35.25 +void stack_walk(void)
   35.26 +{
   35.27 +    unsigned long bp;
   35.28 +#ifdef __x86_64__
   35.29 +    asm("movq %%rbp, %0":"=r"(bp));
   35.30 +#else
   35.31 +    asm("movl %%ebp, %0":"=r"(bp));
   35.32 +#endif
   35.33 +    do_stack_walk(bp);
   35.34 +}
   35.35 +
   35.36 +static void dump_mem(unsigned long addr)
   35.37 +{
   35.38 +    unsigned long i;
   35.39 +    if (addr < PAGE_SIZE)
   35.40 +	return;
   35.41 +
   35.42 +    for (i = ((addr)-16 ) & ~15; i < (((addr)+48 ) & ~15); i++)
   35.43 +    {
   35.44 +	if (!(i%16))
   35.45 +	    printk("\n%lx:", i);
   35.46 +	printk(" %02x", *(unsigned char *)i);
   35.47 +    }
   35.48 +    printk("\n");
   35.49 +}
   35.50  #define read_cr2() \
   35.51          (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)
   35.52  
   35.53 @@ -163,6 +197,7 @@ static int handling_pg_fault = 0;
   35.54  void do_page_fault(struct pt_regs *regs, unsigned long error_code)
   35.55  {
   35.56      unsigned long addr = read_cr2();
   35.57 +    struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
   35.58  
   35.59      if ((error_code & TRAP_PF_WRITE) && handle_cow(addr))
   35.60  	return;
   35.61 @@ -170,37 +205,61 @@ void do_page_fault(struct pt_regs *regs,
   35.62      /* If we are already handling a page fault, and got another one
   35.63         that means we faulted in pagetable walk. Continuing here would cause
   35.64         a recursive fault */       
   35.65 -    if(handling_pg_fault) 
   35.66 +    if(handling_pg_fault == 1) 
   35.67      {
   35.68          printk("Page fault in pagetable walk (access to invalid memory?).\n"); 
   35.69 -        do_exit();
   35.70 +        HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
   35.71      }
   35.72 -    handling_pg_fault = 1;
   35.73 +    handling_pg_fault++;
   35.74 +    barrier();
   35.75  
   35.76  #if defined(__x86_64__)
   35.77 -    printk("Page fault at linear address %p, rip %p, code %lx\n",
   35.78 -           addr, regs->rip, error_code);
   35.79 +    printk("Page fault at linear address %p, rip %p, regs %p, sp %p, our_sp %p, code %lx\n",
   35.80 +           addr, regs->rip, regs, regs->rsp, &addr, error_code);
   35.81  #else
   35.82 -    printk("Page fault at linear address %p, eip %p, code %lx\n",
   35.83 -           addr, regs->eip, error_code);
   35.84 +    printk("Page fault at linear address %p, eip %p, regs %p, sp %p, our_sp %p, code %lx\n",
   35.85 +           addr, regs->eip, regs, regs->esp, &addr, error_code);
   35.86  #endif
   35.87  
   35.88      dump_regs(regs);
   35.89 +#if defined(__x86_64__)
   35.90 +    do_stack_walk(regs->rbp);
   35.91 +    dump_mem(regs->rsp);
   35.92 +    dump_mem(regs->rbp);
   35.93 +    dump_mem(regs->rip);
   35.94 +#else
   35.95 +    do_stack_walk(regs->ebp);
   35.96 +    dump_mem(regs->esp);
   35.97 +    dump_mem(regs->ebp);
   35.98 +    dump_mem(regs->eip);
   35.99 +#endif
  35.100      page_walk(addr);
  35.101 -    do_exit();
  35.102 +    HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
  35.103      /* We should never get here ... but still */
  35.104 -    handling_pg_fault = 0;
  35.105 +    handling_pg_fault--;
  35.106  }
  35.107  
  35.108  void do_general_protection(struct pt_regs *regs, long error_code)
  35.109  {
  35.110 +    struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
  35.111  #ifdef __i386__
  35.112      printk("GPF eip: %p, error_code=%lx\n", regs->eip, error_code);
  35.113  #else    
  35.114      printk("GPF rip: %p, error_code=%lx\n", regs->rip, error_code);
  35.115  #endif
  35.116      dump_regs(regs);
  35.117 -    do_exit();
  35.118 +#if defined(__x86_64__)
  35.119 +    do_stack_walk(regs->rbp);
  35.120 +    dump_mem(regs->rsp);
  35.121 +    dump_mem(regs->rbp);
  35.122 +    dump_mem(regs->rip);
  35.123 +#else
  35.124 +    do_stack_walk(regs->ebp);
  35.125 +    dump_mem(regs->esp);
  35.126 +    dump_mem(regs->ebp);
  35.127 +    dump_mem(regs->eip);
  35.128 +#endif
  35.129 +    HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown);
  35.130  }
  35.131  
  35.132  
  35.133 @@ -268,3 +327,7 @@ void trap_init(void)
  35.134      HYPERVISOR_set_trap_table(trap_table);    
  35.135  }
  35.136  
  35.137 +void trap_fini(void)
  35.138 +{
  35.139 +    HYPERVISOR_set_trap_table(NULL);
  35.140 +}
    36.1 --- a/extras/mini-os/arch/x86/x86_32.S	Fri Aug 29 15:47:21 2008 -0700
    36.2 +++ b/extras/mini-os/arch/x86/x86_32.S	Tue Sep 02 16:34:53 2008 -0700
    36.3 @@ -8,7 +8,7 @@
    36.4  	.ascii	",VIRT_BASE=0x0" /* &_text from minios_x86_32.lds */
    36.5  	.ascii	",ELF_PADDR_OFFSET=0x0"
    36.6  	.ascii	",HYPERCALL_PAGE=0x2"
    36.7 -	.ascii	",PAE=yes"
    36.8 +	.ascii	",PAE=yes[extended-cr3]"
    36.9  	.ascii	",LOADER=generic"
   36.10  	.byte	0
   36.11  .text
    37.1 --- a/extras/mini-os/blkfront.c	Fri Aug 29 15:47:21 2008 -0700
    37.2 +++ b/extras/mini-os/blkfront.c	Tue Sep 02 16:34:53 2008 -0700
    37.3 @@ -63,7 +63,8 @@ void blkfront_handler(evtchn_port_t port
    37.4      struct blkfront_dev *dev = data;
    37.5      int fd = dev->fd;
    37.6  
    37.7 -    files[fd].read = 1;
    37.8 +    if (fd != -1)
    37.9 +        files[fd].read = 1;
   37.10  #endif
   37.11      wake_up(&blkfront_queue);
   37.12  }
   37.13 @@ -83,7 +84,7 @@ static void free_blkfront(struct blkfron
   37.14      free(dev);
   37.15  }
   37.16  
   37.17 -struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info)
   37.18 +struct blkfront_dev *init_blkfront(char *_nodename, struct blkfront_info *info)
   37.19  {
   37.20      xenbus_transaction_t xbt;
   37.21      char* err;
   37.22 @@ -92,12 +93,10 @@ struct blkfront_dev *init_blkfront(char 
   37.23      int retry=0;
   37.24      char* msg;
   37.25      char* c;
   37.26 +    char* nodename = _nodename ? _nodename : "device/vbd/768";
   37.27  
   37.28      struct blkfront_dev *dev;
   37.29  
   37.30 -    if (!nodename)
   37.31 -        nodename = "device/vbd/768";
   37.32 -
   37.33      char path[strlen(nodename) + 1 + 10 + 1];
   37.34  
   37.35      printk("******************* BLKFRONT for %s **********\n\n\n", nodename);
   37.36 @@ -105,6 +104,9 @@ struct blkfront_dev *init_blkfront(char 
   37.37      dev = malloc(sizeof(*dev));
   37.38      memset(dev, 0, sizeof(*dev));
   37.39      dev->nodename = strdup(nodename);
   37.40 +#ifdef HAVE_LIBC
   37.41 +    dev->fd = -1;
   37.42 +#endif
   37.43  
   37.44      snprintf(path, sizeof(path), "%s/backend-id", nodename);
   37.45      dev->dom = xenbus_read_integer(path); 
   37.46 @@ -121,7 +123,6 @@ struct blkfront_dev *init_blkfront(char 
   37.47  
   37.48      dev->events = NULL;
   37.49  
   37.50 -    // FIXME: proper frees on failures
   37.51  again:
   37.52      err = xenbus_transaction_start(&xbt);
   37.53      if (err) {
   37.54 @@ -238,8 +239,16 @@ void shutdown_blkfront(struct blkfront_d
   37.55      err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
   37.56      xenbus_wait_for_value(path, "6", &dev->events);
   37.57  
   37.58 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
   37.59 +    xenbus_wait_for_value(path, "2", &dev->events);
   37.60 +
   37.61      xenbus_unwatch_path(XBT_NIL, path);
   37.62  
   37.63 +    snprintf(path, sizeof(path), "%s/ring-ref", nodename);
   37.64 +    xenbus_rm(XBT_NIL, path);
   37.65 +    snprintf(path, sizeof(path), "%s/event-channel", nodename);
   37.66 +    xenbus_rm(XBT_NIL, path);
   37.67 +
   37.68      free_blkfront(dev);
   37.69  }
   37.70  
   37.71 @@ -323,14 +332,34 @@ void blkfront_aio(struct blkfront_aiocb 
   37.72      if(notify) notify_remote_via_evtchn(dev->evtchn);
   37.73  }
   37.74  
   37.75 -void blkfront_aio_write(struct blkfront_aiocb *aiocbp)
   37.76 +static void blkfront_aio_cb(struct blkfront_aiocb *aiocbp, int ret)
   37.77  {
   37.78 -    blkfront_aio(aiocbp, 1);
   37.79 +    aiocbp->data = (void*) 1;
   37.80  }
   37.81  
   37.82 -void blkfront_aio_read(struct blkfront_aiocb *aiocbp)
   37.83 +void blkfront_io(struct blkfront_aiocb *aiocbp, int write)
   37.84  {
   37.85 -    blkfront_aio(aiocbp, 0);
   37.86 +    unsigned long flags;
   37.87 +    DEFINE_WAIT(w);
   37.88 +
   37.89 +    ASSERT(!aiocbp->aio_cb);
   37.90 +    aiocbp->aio_cb = blkfront_aio_cb;
   37.91 +    blkfront_aio(aiocbp, write);
   37.92 +    aiocbp->data = NULL;
   37.93 +
   37.94 +    local_irq_save(flags);
   37.95 +    while (1) {
   37.96 +	blkfront_aio_poll(aiocbp->aio_dev);
   37.97 +	if (aiocbp->data)
   37.98 +	    break;
   37.99 +
  37.100 +	add_waiter(w, blkfront_queue);
  37.101 +	local_irq_restore(flags);
  37.102 +	schedule();
  37.103 +	local_irq_save(flags);
  37.104 +    }
  37.105 +    remove_waiter(w);
  37.106 +    local_irq_restore(flags);
  37.107  }
  37.108  
  37.109  static void blkfront_push_operation(struct blkfront_dev *dev, uint8_t op, uint64_t id)
  37.110 @@ -363,6 +392,7 @@ void blkfront_aio_push_operation(struct 
  37.111  void blkfront_sync(struct blkfront_dev *dev)
  37.112  {
  37.113      unsigned long flags;
  37.114 +    DEFINE_WAIT(w);
  37.115  
  37.116      if (dev->info.mode == O_RDWR) {
  37.117          if (dev->info.barrier == 1)
  37.118 @@ -374,7 +404,6 @@ void blkfront_sync(struct blkfront_dev *
  37.119  
  37.120      /* Note: This won't finish if another thread enqueues requests.  */
  37.121      local_irq_save(flags);
  37.122 -    DEFINE_WAIT(w);
  37.123      while (1) {
  37.124  	blkfront_aio_poll(dev);
  37.125  	if (RING_FREE_REQUESTS(&dev->ring) == RING_SIZE(&dev->ring))
  37.126 @@ -394,25 +423,31 @@ int blkfront_aio_poll(struct blkfront_de
  37.127      RING_IDX rp, cons;
  37.128      struct blkif_response *rsp;
  37.129      int more;
  37.130 +    int nr_consumed;
  37.131  
  37.132  moretodo:
  37.133  #ifdef HAVE_LIBC
  37.134 -    files[dev->fd].read = 0;
  37.135 -    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
  37.136 +    if (dev->fd != -1) {
  37.137 +        files[dev->fd].read = 0;
  37.138 +        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
  37.139 +    }
  37.140  #endif
  37.141  
  37.142      rp = dev->ring.sring->rsp_prod;
  37.143      rmb(); /* Ensure we see queued responses up to 'rp'. */
  37.144      cons = dev->ring.rsp_cons;
  37.145  
  37.146 -    int nr_consumed = 0;
  37.147 +    nr_consumed = 0;
  37.148      while ((cons != rp))
  37.149      {
  37.150 +        struct blkfront_aiocb *aiocbp;
  37.151 +        int status;
  37.152 +
  37.153  	rsp = RING_GET_RESPONSE(&dev->ring, cons);
  37.154  	nr_consumed++;
  37.155  
  37.156 -        struct blkfront_aiocb *aiocbp = (void*) (uintptr_t) rsp->id;
  37.157 -        int status = rsp->status;
  37.158 +        aiocbp = (void*) (uintptr_t) rsp->id;
  37.159 +        status = rsp->status;
  37.160  
  37.161          if (status != BLKIF_RSP_OKAY)
  37.162              printk("block error %d for op %d\n", status, rsp->operation);
    38.1 --- a/extras/mini-os/console/console.c	Fri Aug 29 15:47:21 2008 -0700
    38.2 +++ b/extras/mini-os/console/console.c	Tue Sep 02 16:34:53 2008 -0700
    38.3 @@ -49,17 +49,13 @@
    38.4     of standard dom0 handled console */
    38.5  #define USE_XEN_CONSOLE
    38.6  
    38.7 -/* Low level functions defined in xencons_ring.c */
    38.8 -extern int xencons_ring_init(void);
    38.9 -extern int xencons_ring_send(const char *data, unsigned len);
   38.10 -extern int xencons_ring_send_no_notify(const char *data, unsigned len);
   38.11 -
   38.12  
   38.13  /* If console not initialised the printk will be sent to xen serial line 
   38.14     NOTE: you need to enable verbose in xen/Rules.mk for it to work. */
   38.15  static int console_initialised = 0;
   38.16  
   38.17  
   38.18 +#ifndef HAVE_LIBC
   38.19  void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
   38.20  {
   38.21      if(len > 0)
   38.22 @@ -77,6 +73,7 @@ void xencons_tx(void)
   38.23  {
   38.24      /* Do nothing, handled by _rx */
   38.25  }
   38.26 +#endif
   38.27  
   38.28  
   38.29  void console_print(char *data, int length)
   38.30 @@ -153,3 +150,8 @@ void init_console(void)
   38.31      /* This is also required to notify the daemon */
   38.32      printk("done.\n");
   38.33  }
   38.34 +
   38.35 +void fini_console(void)
   38.36 +{
   38.37 +    /* Destruct the console and get the parameters of the restarted one */
   38.38 +}
    39.1 --- a/extras/mini-os/console/xencons_ring.c	Fri Aug 29 15:47:21 2008 -0700
    39.2 +++ b/extras/mini-os/console/xencons_ring.c	Tue Sep 02 16:34:53 2008 -0700
    39.3 @@ -8,6 +8,7 @@
    39.4  #include <xenbus.h>
    39.5  #include <xen/io/console.h>
    39.6  
    39.7 +DECLARE_WAIT_QUEUE_HEAD(console_queue);
    39.8  
    39.9  static inline struct xencons_interface *xencons_interface(void)
   39.10  {
   39.11 @@ -52,6 +53,9 @@ int xencons_ring_send(const char *data, 
   39.12  
   39.13  static void handle_input(evtchn_port_t port, struct pt_regs *regs, void *ign)
   39.14  {
   39.15 +#ifdef HAVE_LIBC
   39.16 +        wake_up(&console_queue);
   39.17 +#else
   39.18  	struct xencons_interface *intf = xencons_interface();
   39.19  	XENCONS_RING_IDX cons, prod;
   39.20  
   39.21 @@ -71,8 +75,48 @@ static void handle_input(evtchn_port_t p
   39.22  	notify_daemon();
   39.23  
   39.24  	xencons_tx();
   39.25 +#endif
   39.26  }
   39.27  
   39.28 +#ifdef HAVE_LIBC
   39.29 +int xencons_ring_avail(void)
   39.30 +{
   39.31 +	struct xencons_interface *intf = xencons_interface();
   39.32 +	XENCONS_RING_IDX cons, prod;
   39.33 +
   39.34 +	cons = intf->in_cons;
   39.35 +	prod = intf->in_prod;
   39.36 +	mb();
   39.37 +	BUG_ON((prod - cons) > sizeof(intf->in));
   39.38 +
   39.39 +        return prod - cons;
   39.40 +}
   39.41 +
   39.42 +int xencons_ring_recv(char *data, unsigned len)
   39.43 +{
   39.44 +	struct xencons_interface *intf = xencons_interface();
   39.45 +	XENCONS_RING_IDX cons, prod;
   39.46 +        unsigned filled = 0;
   39.47 +
   39.48 +	cons = intf->in_cons;
   39.49 +	prod = intf->in_prod;
   39.50 +	mb();
   39.51 +	BUG_ON((prod - cons) > sizeof(intf->in));
   39.52 +
   39.53 +        while (filled < len && cons + filled != prod) {
   39.54 +                data[filled] = *(intf->in + MASK_XENCONS_IDX(cons + filled, intf->in));
   39.55 +                filled++;
   39.56 +	}
   39.57 +
   39.58 +	mb();
   39.59 +        intf->in_cons = cons + filled;
   39.60 +
   39.61 +	notify_daemon();
   39.62 +
   39.63 +        return filled;
   39.64 +}
   39.65 +#endif
   39.66 +
   39.67  int xencons_ring_init(void)
   39.68  {
   39.69  	int err;
    40.1 --- a/extras/mini-os/events.c	Fri Aug 29 15:47:21 2008 -0700
    40.2 +++ b/extras/mini-os/events.c	Tue Sep 02 16:34:53 2008 -0700
    40.3 @@ -39,19 +39,29 @@ static unsigned long bound_ports[NR_EVS/
    40.4  void unbind_all_ports(void)
    40.5  {
    40.6      int i;
    40.7 +    int cpu = 0;
    40.8 +    shared_info_t *s = HYPERVISOR_shared_info;
    40.9 +    vcpu_info_t   *vcpu_info = &s->vcpu_info[cpu];
   40.10  
   40.11      for (i = 0; i < NR_EVS; i++)
   40.12      {
   40.13 +        if (i == start_info.console.domU.evtchn ||
   40.14 +            i == start_info.store_evtchn)
   40.15 +            continue;
   40.16          if (test_and_clear_bit(i, bound_ports))
   40.17          {
   40.18              struct evtchn_close close;
   40.19 +            printk("port %d still bound!\n", i);
   40.20              mask_evtchn(i);
   40.21              close.port = i;
   40.22              HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
   40.23 +            clear_evtchn(i);
   40.24          }
   40.25      }
   40.26 +    vcpu_info->evtchn_upcall_pending = 0;
   40.27 +    vcpu_info->evtchn_pending_sel = 0;
   40.28  }
   40.29 -  
   40.30 +
   40.31  /*
   40.32   * Demux events to different handlers.
   40.33   */
   40.34 @@ -86,17 +96,27 @@ evtchn_port_t bind_evtchn(evtchn_port_t 
   40.35  	ev_actions[port].data = data;
   40.36  	wmb();
   40.37  	ev_actions[port].handler = handler;
   40.38 +	set_bit(port, bound_ports);
   40.39  
   40.40  	return port;
   40.41  }
   40.42  
   40.43  void unbind_evtchn(evtchn_port_t port )
   40.44  {
   40.45 +	struct evtchn_close close;
   40.46 +
   40.47  	if (ev_actions[port].handler == default_handler)
   40.48  		printk("WARN: No handler for port %d when unbinding\n", port);
   40.49 +	mask_evtchn(port);
   40.50 +	clear_evtchn(port);
   40.51 +
   40.52  	ev_actions[port].handler = default_handler;
   40.53  	wmb();
   40.54  	ev_actions[port].data = NULL;
   40.55 +	clear_bit(port, bound_ports);
   40.56 +
   40.57 +	close.port = port;
   40.58 +	HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
   40.59  }
   40.60  
   40.61  evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data)
   40.62 @@ -112,11 +132,27 @@ evtchn_port_t bind_virq(uint32_t virq, e
   40.63  		printk("Failed to bind virtual IRQ %d\n", virq);
   40.64  		return -1;
   40.65      }
   40.66 -    set_bit(op.port,bound_ports);
   40.67      bind_evtchn(op.port, handler, data);
   40.68  	return op.port;
   40.69  }
   40.70  
   40.71 +evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data)
   40.72 +{
   40.73 +	evtchn_bind_pirq_t op;
   40.74 +
   40.75 +	/* Try to bind the pirq to a port */
   40.76 +	op.pirq = pirq;
   40.77 +	op.flags = will_share ? BIND_PIRQ__WILL_SHARE : 0;
   40.78 +
   40.79 +	if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op) != 0 )
   40.80 +	{
   40.81 +		printk("Failed to bind physical IRQ %d\n", pirq);
   40.82 +		return -1;
   40.83 +	}
   40.84 +	bind_evtchn(op.port, handler, data);
   40.85 +	return op.port;
   40.86 +}
   40.87 +
   40.88  #if defined(__x86_64__)
   40.89  char irqstack[2 * STACK_SIZE];
   40.90  
   40.91 @@ -147,6 +183,15 @@ void init_events(void)
   40.92      }
   40.93  }
   40.94  
   40.95 +void fini_events(void)
   40.96 +{
   40.97 +    /* Dealloc all events */
   40.98 +    unbind_all_ports();
   40.99 +#if defined(__x86_64__)
  40.100 +    wrmsrl(0xc0000101, NULL); /* 0xc0000101 is MSR_GS_BASE */
  40.101 +#endif
  40.102 +}
  40.103 +
  40.104  void default_handler(evtchn_port_t port, struct pt_regs *regs, void *ignore)
  40.105  {
  40.106      printk("[Port %d] - event received\n", port);
  40.107 @@ -162,10 +207,11 @@ void default_handler(evtchn_port_t port,
  40.108  int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler,
  40.109  						 void *data, evtchn_port_t *port)
  40.110  {
  40.111 +    int err;
  40.112      evtchn_alloc_unbound_t op;
  40.113      op.dom = DOMID_SELF;
  40.114      op.remote_dom = pal;
  40.115 -    int err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
  40.116 +    err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op);
  40.117      if (err)
  40.118  		return err;
  40.119      *port = bind_evtchn(op.port, handler, data);
  40.120 @@ -179,14 +225,15 @@ int evtchn_bind_interdomain(domid_t pal,
  40.121  			    evtchn_handler_t handler, void *data,
  40.122  			    evtchn_port_t *local_port)
  40.123  {
  40.124 +    int err;
  40.125 +    evtchn_port_t port;
  40.126      evtchn_bind_interdomain_t op;
  40.127      op.remote_dom = pal;
  40.128      op.remote_port = remote_port;
  40.129 -    int err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
  40.130 +    err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op);
  40.131      if (err)
  40.132  		return err;
  40.133 -    set_bit(op.local_port,bound_ports);
  40.134 -    evtchn_port_t port = op.local_port;
  40.135 +    port = op.local_port;
  40.136      *local_port = bind_evtchn(port, handler, data);
  40.137      return err;
  40.138  }
    41.1 --- a/extras/mini-os/fbfront.c	Fri Aug 29 15:47:21 2008 -0700
    41.2 +++ b/extras/mini-os/fbfront.c	Tue Sep 02 16:34:53 2008 -0700
    41.3 @@ -44,7 +44,8 @@ void kbdfront_handler(evtchn_port_t port
    41.4      struct kbdfront_dev *dev = data;
    41.5      int fd = dev->fd;
    41.6  
    41.7 -    files[fd].read = 1;
    41.8 +    if (fd != -1)
    41.9 +        files[fd].read = 1;
   41.10  #endif
   41.11      wake_up(&kbdfront_queue);
   41.12  }
   41.13 @@ -63,7 +64,7 @@ static void free_kbdfront(struct kbdfron
   41.14      free(dev);
   41.15  }
   41.16  
   41.17 -struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer)
   41.18 +struct kbdfront_dev *init_kbdfront(char *_nodename, int abs_pointer)
   41.19  {
   41.20      xenbus_transaction_t xbt;
   41.21      char* err;
   41.22 @@ -71,18 +72,18 @@ struct kbdfront_dev *init_kbdfront(char 
   41.23      struct xenkbd_page *s;
   41.24      int retry=0;
   41.25      char* msg;
   41.26 -
   41.27 +    char* nodename = _nodename ? _nodename : "device/vkbd/0";
   41.28      struct kbdfront_dev *dev;
   41.29  
   41.30 -    if (!nodename)
   41.31 -        nodename = "device/vkbd/0";
   41.32 -
   41.33      char path[strlen(nodename) + 1 + 10 + 1];
   41.34  
   41.35      printk("******************* KBDFRONT for %s **********\n\n\n", nodename);
   41.36  
   41.37      dev = malloc(sizeof(*dev));
   41.38      dev->nodename = strdup(nodename);
   41.39 +#ifdef HAVE_LIBC
   41.40 +    dev->fd = -1;
   41.41 +#endif
   41.42  
   41.43      snprintf(path, sizeof(path), "%s/backend-id", nodename);
   41.44      dev->dom = xenbus_read_integer(path); 
   41.45 @@ -96,7 +97,6 @@ struct kbdfront_dev *init_kbdfront(char 
   41.46      s->in_cons = s->in_prod = 0;
   41.47      s->out_cons = s->out_prod = 0;
   41.48  
   41.49 -    // FIXME: proper frees on failures
   41.50  again:
   41.51      err = xenbus_transaction_start(&xbt);
   41.52      if (err) {
   41.53 @@ -179,8 +179,10 @@ int kbdfront_receive(struct kbdfront_dev
   41.54      int i;
   41.55  
   41.56  #ifdef HAVE_LIBC
   41.57 -    files[dev->fd].read = 0;
   41.58 -    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
   41.59 +    if (dev->fd != -1) {
   41.60 +        files[dev->fd].read = 0;
   41.61 +        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
   41.62 +    }
   41.63  #endif
   41.64  
   41.65      prod = page->in_prod;
   41.66 @@ -198,7 +200,7 @@ int kbdfront_receive(struct kbdfront_dev
   41.67      notify_remote_via_evtchn(dev->evtchn);
   41.68  
   41.69  #ifdef HAVE_LIBC
   41.70 -    if (cons != prod)
   41.71 +    if (cons != prod && dev->fd != -1)
   41.72          /* still some events to read */
   41.73          files[dev->fd].read = 1;
   41.74  #endif
   41.75 @@ -223,8 +225,19 @@ void shutdown_kbdfront(struct kbdfront_d
   41.76      err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
   41.77      xenbus_wait_for_value(path, "6", &dev->events);
   41.78  
   41.79 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
   41.80 +    // does not work yet.
   41.81 +    //xenbus_wait_for_value(path, "2", &dev->events);
   41.82 +
   41.83      xenbus_unwatch_path(XBT_NIL, path);
   41.84  
   41.85 +    snprintf(path, sizeof(path), "%s/page-ref", nodename);
   41.86 +    xenbus_rm(XBT_NIL, path);
   41.87 +    snprintf(path, sizeof(path), "%s/event-channel", nodename);
   41.88 +    xenbus_rm(XBT_NIL, path);
   41.89 +    snprintf(path, sizeof(path), "%s/request-abs-pointer", nodename);
   41.90 +    xenbus_rm(XBT_NIL, path);
   41.91 +
   41.92      free_kbdfront(dev);
   41.93  }
   41.94  
   41.95 @@ -279,7 +292,8 @@ void fbfront_handler(evtchn_port_t port,
   41.96      struct fbfront_dev *dev = data;
   41.97      int fd = dev->fd;
   41.98  
   41.99 -    files[fd].read = 1;
  41.100 +    if (fd != -1)
  41.101 +        files[fd].read = 1;
  41.102  #endif
  41.103      wake_up(&fbfront_queue);
  41.104  }
  41.105 @@ -305,8 +319,10 @@ int fbfront_receive(struct fbfront_dev *
  41.106      int i;
  41.107  
  41.108  #ifdef HAVE_LIBC
  41.109 -    files[dev->fd].read = 0;
  41.110 -    mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
  41.111 +    if (dev->fd != -1) {
  41.112 +        files[dev->fd].read = 0;
  41.113 +        mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
  41.114 +    }
  41.115  #endif
  41.116  
  41.117      prod = page->in_prod;
  41.118 @@ -324,7 +340,7 @@ int fbfront_receive(struct fbfront_dev *
  41.119      notify_remote_via_evtchn(dev->evtchn);
  41.120  
  41.121  #ifdef HAVE_LIBC
  41.122 -    if (cons != prod)
  41.123 +    if (cons != prod && dev->fd != -1)
  41.124          /* still some events to read */
  41.125          files[dev->fd].read = 1;
  41.126  #endif
  41.127 @@ -332,7 +348,7 @@ int fbfront_receive(struct fbfront_dev *
  41.128      return i;
  41.129  }
  41.130  
  41.131 -struct fbfront_dev *init_fbfront(char *nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n)
  41.132 +struct fbfront_dev *init_fbfront(char *_nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n)
  41.133  {
  41.134      xenbus_transaction_t xbt;
  41.135      char* err;
  41.136 @@ -342,9 +358,9 @@ struct fbfront_dev *init_fbfront(char *n
  41.137      char* msg;
  41.138      int i, j;
  41.139      struct fbfront_dev *dev;
  41.140 -
  41.141 -    if (!nodename)
  41.142 -        nodename = "device/vfb/0";
  41.143 +    int max_pd;
  41.144 +    unsigned long mapped;
  41.145 +    char* nodename = _nodename ? _nodename : "device/vfb/0";
  41.146  
  41.147      char path[strlen(nodename) + 1 + 10 + 1];
  41.148  
  41.149 @@ -352,6 +368,9 @@ struct fbfront_dev *init_fbfront(char *n
  41.150  
  41.151      dev = malloc(sizeof(*dev));
  41.152      dev->nodename = strdup(nodename);
  41.153 +#ifdef HAVE_LIBC
  41.154 +    dev->fd = -1;
  41.155 +#endif
  41.156  
  41.157      snprintf(path, sizeof(path), "%s/backend-id", nodename);
  41.158      dev->dom = xenbus_read_integer(path); 
  41.159 @@ -370,8 +389,8 @@ struct fbfront_dev *init_fbfront(char *n
  41.160      dev->offset = 0;
  41.161      dev->events = NULL;
  41.162  
  41.163 -    const int max_pd = sizeof(s->pd) / sizeof(s->pd[0]);
  41.164 -    unsigned long mapped = 0;
  41.165 +    max_pd = sizeof(s->pd) / sizeof(s->pd[0]);
  41.166 +    mapped = 0;
  41.167  
  41.168      for (i = 0; mapped < n && i < max_pd; i++) {
  41.169          unsigned long *pd = (unsigned long *) alloc_page();
  41.170 @@ -385,7 +404,6 @@ struct fbfront_dev *init_fbfront(char *n
  41.171          s->pd[i] = 0;
  41.172  
  41.173  
  41.174 -    // FIXME: proper frees on failures
  41.175  again:
  41.176      err = xenbus_transaction_start(&xbt);
  41.177      if (err) {
  41.178 @@ -547,8 +565,21 @@ void shutdown_fbfront(struct fbfront_dev
  41.179      err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
  41.180      xenbus_wait_for_value(path, "6", &dev->events);
  41.181  
  41.182 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
  41.183 +    // does not work yet
  41.184 +    //xenbus_wait_for_value(path, "2", &dev->events);
  41.185 +
  41.186      xenbus_unwatch_path(XBT_NIL, path);
  41.187  
  41.188 +    snprintf(path, sizeof(path), "%s/page-ref", nodename);
  41.189 +    xenbus_rm(XBT_NIL, path);
  41.190 +    snprintf(path, sizeof(path), "%s/event-channel", nodename);
  41.191 +    xenbus_rm(XBT_NIL, path);
  41.192 +    snprintf(path, sizeof(path), "%s/protocol", nodename);
  41.193 +    xenbus_rm(XBT_NIL, path);
  41.194 +    snprintf(path, sizeof(path), "%s/feature-update", nodename);
  41.195 +    xenbus_rm(XBT_NIL, path);
  41.196 +
  41.197      unbind_evtchn(dev->evtchn);
  41.198  
  41.199      free_fbfront(dev);
    42.1 --- a/extras/mini-os/fs-front.c	Fri Aug 29 15:47:21 2008 -0700
    42.2 +++ b/extras/mini-os/fs-front.c	Tue Sep 02 16:34:53 2008 -0700
    42.3 @@ -3,7 +3,7 @@
    42.4   * 
    42.5   * Frontend driver for FS split device driver.
    42.6   *
    42.7 - * Copyright (c) 2007, Grzegorz Milos, Sun Microsystems, Inc.
    42.8 + * Copyright (c) 2007, Grzegorz Milos, <gm281@cam.ac.uk>.
    42.9   * 
   42.10   * Permission is hereby granted, free of charge, to any person obtaining a copy
   42.11   * of this software and associated documentation files (the "Software"), to
   42.12 @@ -50,6 +50,8 @@
   42.13  
   42.14  struct fs_request;
   42.15  struct fs_import *fs_import;
   42.16 +void *alloc_buffer_page(struct fs_request *req, domid_t domid, grant_ref_t *gref);
   42.17 +void free_buffer_page(struct fs_request *req);
   42.18  
   42.19  /******************************************************************************/
   42.20  /*                      RING REQUEST/RESPONSES HANDLING                       */
   42.21 @@ -57,13 +59,21 @@ struct fs_import *fs_import;
   42.22  
   42.23  struct fs_request
   42.24  {
   42.25 -    void *page;
   42.26 -    grant_ref_t gref;
   42.27 +    void *private1;                        /* Specific to request type */
   42.28 +    void *private2;
   42.29      struct thread *thread;                 /* Thread blocked on this request */
   42.30      struct fsif_response shadow_rsp;       /* Response copy writen by the 
   42.31                                                interrupt handler */  
   42.32  };
   42.33  
   42.34 +struct fs_rw_gnts
   42.35 +{
   42.36 +    /* TODO 16 bit? */
   42.37 +    int count;
   42.38 +    grant_ref_t grefs[FSIF_NR_READ_GNTS];  
   42.39 +    void *pages[FSIF_NR_READ_GNTS];  
   42.40 +};
   42.41 +
   42.42  /* Ring operations:
   42.43   * FSIF ring is used differently to Linux-like split devices. This stems from 
   42.44   * the fact that no I/O request queue is present. The use of some of the macros
   42.45 @@ -136,8 +146,8 @@ static inline void add_id_to_freelist(un
   42.46  again:    
   42.47      old_id = freelist[0];
   42.48      /* Note: temporal inconsistency, since freelist[0] can be changed by someone
   42.49 -     * else, but we are a sole owner of freelist[id], it's OK. */
   42.50 -    freelist[id] = old_id;
   42.51 +     * else, but we are a sole owner of freelist[id + 1], it's OK. */
   42.52 +    freelist[id + 1] = old_id;
   42.53      new_id = id;
   42.54      if(cmpxchg(&freelist[0], old_id, new_id) != old_id)
   42.55      {
   42.56 @@ -154,7 +164,7 @@ static inline unsigned short get_id_from
   42.57  
   42.58  again:    
   42.59      old_id = freelist[0];
   42.60 -    new_id = freelist[old_id];
   42.61 +    new_id = freelist[old_id + 1];
   42.62      if(cmpxchg(&freelist[0], old_id, new_id) != old_id)
   42.63      {
   42.64          printk("Cmpxchg on freelist remove failed.\n");
   42.65 @@ -177,25 +187,29 @@ int fs_open(struct fs_import *import, ch
   42.66  {
   42.67      struct fs_request *fsr;
   42.68      unsigned short priv_req_id;
   42.69 +    grant_ref_t gref;
   42.70 +    void *buffer;
   42.71      RING_IDX back_req_id; 
   42.72      struct fsif_request *req;
   42.73      int fd;
   42.74  
   42.75      /* Prepare request for the backend */
   42.76      back_req_id = reserve_fsif_request(import);
   42.77 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
   42.78 +    DEBUG("Backend request id=%d\n", back_req_id);
   42.79  
   42.80      /* Prepare our private request structure */
   42.81      priv_req_id = get_id_from_freelist(import->freelist);
   42.82      DEBUG("Request id for fs_open call is: %d\n", priv_req_id);
   42.83      fsr = &import->requests[priv_req_id];
   42.84 +    buffer = alloc_buffer_page(fsr, import->dom_id, &gref);
   42.85 +    DEBUG("gref id=%d\n", gref);
   42.86      fsr->thread = current;
   42.87 -    sprintf(fsr->page, "%s", file);
   42.88 +    sprintf(buffer, "%s", file);
   42.89  
   42.90      req = RING_GET_REQUEST(&import->ring, back_req_id);
   42.91      req->type = REQ_FILE_OPEN;
   42.92      req->id = priv_req_id;
   42.93 -    req->u.fopen.gref = fsr->gref;
   42.94 +    req->u.fopen.gref = gref;
   42.95  
   42.96      /* Set blocked flag before commiting the request, thus avoiding missed
   42.97       * response race */
   42.98 @@ -206,6 +220,7 @@ int fs_open(struct fs_import *import, ch
   42.99      /* Read the response */
  42.100      fd = (int)fsr->shadow_rsp.ret_val;
  42.101      DEBUG("The following FD returned: %d\n", fd);
  42.102 +    free_buffer_page(fsr);
  42.103      add_id_to_freelist(priv_req_id, import->freelist);
  42.104  
  42.105      return fd;
  42.106 @@ -221,7 +236,7 @@ int fs_close(struct fs_import *import, i
  42.107  
  42.108      /* Prepare request for the backend */
  42.109      back_req_id = reserve_fsif_request(import);
  42.110 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.111 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.112  
  42.113      /* Prepare our private request structure */
  42.114      priv_req_id = get_id_from_freelist(import->freelist);
  42.115 @@ -253,31 +268,44 @@ ssize_t fs_read(struct fs_import *import
  42.116  {
  42.117      struct fs_request *fsr;
  42.118      unsigned short priv_req_id;
  42.119 +    struct fs_rw_gnts gnts;
  42.120      RING_IDX back_req_id; 
  42.121      struct fsif_request *req;
  42.122      ssize_t ret;
  42.123 +    int i;
  42.124  
  42.125 -    BUG_ON(len > PAGE_SIZE);
  42.126 +    BUG_ON(len > PAGE_SIZE * FSIF_NR_READ_GNTS);
  42.127  
  42.128      /* Prepare request for the backend */
  42.129      back_req_id = reserve_fsif_request(import);
  42.130 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.131 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.132  
  42.133      /* Prepare our private request structure */
  42.134      priv_req_id = get_id_from_freelist(import->freelist);
  42.135      DEBUG("Request id for fs_read call is: %d\n", priv_req_id);
  42.136      fsr = &import->requests[priv_req_id];
  42.137 -    fsr->thread = current;
  42.138 -    memset(fsr->page, 0, PAGE_SIZE);
  42.139  
  42.140      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.141      req->type = REQ_FILE_READ;
  42.142      req->id = priv_req_id;
  42.143      req->u.fread.fd = fd;
  42.144 -    req->u.fread.gref = fsr->gref;
  42.145      req->u.fread.len = len;
  42.146      req->u.fread.offset = offset;
  42.147  
  42.148 +
  42.149 +    ASSERT(len > 0);
  42.150 +    gnts.count = ((len - 1) / PAGE_SIZE) + 1; 
  42.151 +    for(i=0; i<gnts.count; i++)
  42.152 +    {
  42.153 +        gnts.pages[i] = (void *)alloc_page(); 
  42.154 +        gnts.grefs[i] = gnttab_grant_access(import->dom_id, 
  42.155 +                                            virt_to_mfn(gnts.pages[i]), 
  42.156 +                                            0); 
  42.157 +        memset(gnts.pages[i], 0, PAGE_SIZE);
  42.158 +        req->u.fread.grefs[i] = gnts.grefs[i];
  42.159 +    }
  42.160 +    fsr->thread = current;
  42.161 +
  42.162      /* Set blocked flag before commiting the request, thus avoiding missed
  42.163       * response race */
  42.164      block(current);
  42.165 @@ -288,7 +316,19 @@ ssize_t fs_read(struct fs_import *import
  42.166      ret = (ssize_t)fsr->shadow_rsp.ret_val;
  42.167      DEBUG("The following ret value returned %d\n", ret);
  42.168      if(ret > 0)
  42.169 -        memcpy(buf, fsr->page, ret);
  42.170 +    {
  42.171 +        ssize_t to_copy = ret, current_copy;
  42.172 +        for(i=0; i<gnts.count; i++)
  42.173 +        {
  42.174 +            gnttab_end_access(gnts.grefs[i]);
  42.175 +            current_copy = to_copy > PAGE_SIZE ? PAGE_SIZE : to_copy;
  42.176 +            if(current_copy > 0)
  42.177 +                memcpy(buf, gnts.pages[i], current_copy); 
  42.178 +            to_copy -= current_copy; 
  42.179 +            buf = (char*) buf + current_copy;
  42.180 +            free_page(gnts.pages[i]);
  42.181 +        }
  42.182 +    }
  42.183      add_id_to_freelist(priv_req_id, import->freelist);
  42.184  
  42.185      return ret;
  42.186 @@ -299,33 +339,51 @@ ssize_t fs_write(struct fs_import *impor
  42.187  {
  42.188      struct fs_request *fsr;
  42.189      unsigned short priv_req_id;
  42.190 +    struct fs_rw_gnts gnts;
  42.191      RING_IDX back_req_id; 
  42.192      struct fsif_request *req;
  42.193 -    ssize_t ret;
  42.194 +    ssize_t ret, to_copy;
  42.195 +    int i;
  42.196  
  42.197 -    BUG_ON(len > PAGE_SIZE);
  42.198 +    BUG_ON(len > PAGE_SIZE * FSIF_NR_WRITE_GNTS);
  42.199  
  42.200      /* Prepare request for the backend */
  42.201      back_req_id = reserve_fsif_request(import);
  42.202 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.203 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.204  
  42.205      /* Prepare our private request structure */
  42.206      priv_req_id = get_id_from_freelist(import->freelist);
  42.207      DEBUG("Request id for fs_read call is: %d\n", priv_req_id);
  42.208      fsr = &import->requests[priv_req_id];
  42.209 -    fsr->thread = current;
  42.210 -    memcpy(fsr->page, buf, len);
  42.211 -    BUG_ON(len > PAGE_SIZE);
  42.212 -    memset((char *)fsr->page + len, 0, PAGE_SIZE - len); 
  42.213  
  42.214      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.215      req->type = REQ_FILE_WRITE;
  42.216      req->id = priv_req_id;
  42.217      req->u.fwrite.fd = fd;
  42.218 -    req->u.fwrite.gref = fsr->gref;
  42.219      req->u.fwrite.len = len;
  42.220      req->u.fwrite.offset = offset;
  42.221  
  42.222 +    ASSERT(len > 0);
  42.223 +    gnts.count = ((len - 1) / PAGE_SIZE) + 1; 
  42.224 +    to_copy = len;
  42.225 +    for(i=0; i<gnts.count; i++)
  42.226 +    {
  42.227 +        int current_copy = (to_copy > PAGE_SIZE ? PAGE_SIZE : to_copy);
  42.228 +        gnts.pages[i] = (void *)alloc_page(); 
  42.229 +        gnts.grefs[i] = gnttab_grant_access(import->dom_id, 
  42.230 +                                            virt_to_mfn(gnts.pages[i]), 
  42.231 +                                            0); 
  42.232 +        memcpy(gnts.pages[i], buf, current_copy);
  42.233 +        if(current_copy < PAGE_SIZE)
  42.234 +            memset((char *)gnts.pages[i] + current_copy, 
  42.235 +                    0, 
  42.236 +                    PAGE_SIZE - current_copy); 
  42.237 +        req->u.fwrite.grefs[i] = gnts.grefs[i];
  42.238 +        to_copy -= current_copy; 
  42.239 +        buf = (char*) buf + current_copy;
  42.240 +    }
  42.241 +    fsr->thread = current;
  42.242 +
  42.243      /* Set blocked flag before commiting the request, thus avoiding missed
  42.244       * response race */
  42.245      block(current);
  42.246 @@ -335,6 +393,11 @@ ssize_t fs_write(struct fs_import *impor
  42.247      /* Read the response */
  42.248      ret = (ssize_t)fsr->shadow_rsp.ret_val;
  42.249      DEBUG("The following ret value returned %d\n", ret);
  42.250 +    for(i=0; i<gnts.count; i++)
  42.251 +    {
  42.252 +        gnttab_end_access(gnts.grefs[i]);
  42.253 +        free_page(gnts.pages[i]);
  42.254 +    }
  42.255      add_id_to_freelist(priv_req_id, import->freelist);
  42.256  
  42.257      return ret;
  42.258 @@ -352,20 +415,18 @@ int fs_stat(struct fs_import *import,
  42.259  
  42.260      /* Prepare request for the backend */
  42.261      back_req_id = reserve_fsif_request(import);
  42.262 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.263 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.264  
  42.265      /* Prepare our private request structure */
  42.266      priv_req_id = get_id_from_freelist(import->freelist);
  42.267      DEBUG("Request id for fs_stat call is: %d\n", priv_req_id);
  42.268      fsr = &import->requests[priv_req_id];
  42.269      fsr->thread = current;
  42.270 -    memset(fsr->page, 0, PAGE_SIZE);
  42.271  
  42.272      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.273      req->type = REQ_STAT;
  42.274      req->id = priv_req_id;
  42.275      req->u.fstat.fd   = fd;
  42.276 -    req->u.fstat.gref = fsr->gref;
  42.277  
  42.278      /* Set blocked flag before commiting the request, thus avoiding missed
  42.279       * response race */
  42.280 @@ -376,7 +437,9 @@ int fs_stat(struct fs_import *import,
  42.281      /* Read the response */
  42.282      ret = (int)fsr->shadow_rsp.ret_val;
  42.283      DEBUG("Following ret from fstat: %d\n", ret);
  42.284 -    memcpy(stat, fsr->page, sizeof(struct fsif_stat_response));
  42.285 +    memcpy(stat, 
  42.286 +           &fsr->shadow_rsp.fstat, 
  42.287 +           sizeof(struct fsif_stat_response));
  42.288      add_id_to_freelist(priv_req_id, import->freelist);
  42.289  
  42.290      return ret;
  42.291 @@ -394,7 +457,7 @@ int fs_truncate(struct fs_import *import
  42.292  
  42.293      /* Prepare request for the backend */
  42.294      back_req_id = reserve_fsif_request(import);
  42.295 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.296 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.297  
  42.298      /* Prepare our private request structure */
  42.299      priv_req_id = get_id_from_freelist(import->freelist);
  42.300 @@ -426,25 +489,29 @@ int fs_remove(struct fs_import *import, 
  42.301  {
  42.302      struct fs_request *fsr;
  42.303      unsigned short priv_req_id;
  42.304 +    grant_ref_t gref;
  42.305 +    void *buffer;
  42.306      RING_IDX back_req_id; 
  42.307      struct fsif_request *req;
  42.308      int ret;
  42.309  
  42.310      /* Prepare request for the backend */
  42.311      back_req_id = reserve_fsif_request(import);
  42.312 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.313 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.314  
  42.315      /* Prepare our private request structure */
  42.316      priv_req_id = get_id_from_freelist(import->freelist);
  42.317      DEBUG("Request id for fs_open call is: %d\n", priv_req_id);
  42.318      fsr = &import->requests[priv_req_id];
  42.319 +    buffer = alloc_buffer_page(fsr, import->dom_id, &gref);
  42.320 +    DEBUG("gref=%d\n", gref);
  42.321      fsr->thread = current;
  42.322 -    sprintf(fsr->page, "%s", file);
  42.323 +    sprintf(buffer, "%s", file);
  42.324  
  42.325      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.326      req->type = REQ_REMOVE;
  42.327      req->id = priv_req_id;
  42.328 -    req->u.fremove.gref = fsr->gref;
  42.329 +    req->u.fremove.gref = gref;
  42.330  
  42.331      /* Set blocked flag before commiting the request, thus avoiding missed
  42.332       * response race */
  42.333 @@ -455,6 +522,7 @@ int fs_remove(struct fs_import *import, 
  42.334      /* Read the response */
  42.335      ret = (int)fsr->shadow_rsp.ret_val;
  42.336      DEBUG("The following ret: %d\n", ret);
  42.337 +    free_buffer_page(fsr);
  42.338      add_id_to_freelist(priv_req_id, import->freelist);
  42.339  
  42.340      return ret;
  42.341 @@ -467,6 +535,8 @@ int fs_rename(struct fs_import *import,
  42.342  {
  42.343      struct fs_request *fsr;
  42.344      unsigned short priv_req_id;
  42.345 +    grant_ref_t gref;
  42.346 +    void *buffer;
  42.347      RING_IDX back_req_id; 
  42.348      struct fsif_request *req;
  42.349      int ret;
  42.350 @@ -475,20 +545,22 @@ int fs_rename(struct fs_import *import,
  42.351  
  42.352      /* Prepare request for the backend */
  42.353      back_req_id = reserve_fsif_request(import);
  42.354 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.355 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.356  
  42.357      /* Prepare our private request structure */
  42.358      priv_req_id = get_id_from_freelist(import->freelist);
  42.359      DEBUG("Request id for fs_open call is: %d\n", priv_req_id);
  42.360      fsr = &import->requests[priv_req_id];
  42.361 +    buffer = alloc_buffer_page(fsr, import->dom_id, &gref);
  42.362 +    DEBUG("gref=%d\n", gref);
  42.363      fsr->thread = current;
  42.364 -    sprintf(fsr->page, "%s%s%c%s%s", 
  42.365 +    sprintf(buffer, "%s%s%c%s%s", 
  42.366              old_header, old_file_name, '\0', new_header, new_file_name);
  42.367  
  42.368      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.369      req->type = REQ_RENAME;
  42.370      req->id = priv_req_id;
  42.371 -    req->u.frename.gref = fsr->gref;
  42.372 +    req->u.frename.gref = gref;
  42.373      req->u.frename.old_name_offset = strlen(old_header);
  42.374      req->u.frename.new_name_offset = strlen(old_header) +
  42.375                                       strlen(old_file_name) +
  42.376 @@ -505,6 +577,7 @@ int fs_rename(struct fs_import *import,
  42.377      /* Read the response */
  42.378      ret = (int)fsr->shadow_rsp.ret_val;
  42.379      DEBUG("The following ret: %d\n", ret);
  42.380 +    free_buffer_page(fsr);
  42.381      add_id_to_freelist(priv_req_id, import->freelist);
  42.382  
  42.383      return ret;
  42.384 @@ -515,25 +588,29 @@ int fs_create(struct fs_import *import, 
  42.385  {
  42.386      struct fs_request *fsr;
  42.387      unsigned short priv_req_id;
  42.388 +    grant_ref_t gref;
  42.389 +    void *buffer;
  42.390      RING_IDX back_req_id; 
  42.391      struct fsif_request *req;
  42.392      int ret;
  42.393  
  42.394      /* Prepare request for the backend */
  42.395      back_req_id = reserve_fsif_request(import);
  42.396 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.397 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.398  
  42.399      /* Prepare our private request structure */
  42.400      priv_req_id = get_id_from_freelist(import->freelist);
  42.401      DEBUG("Request id for fs_create call is: %d\n", priv_req_id);
  42.402      fsr = &import->requests[priv_req_id];
  42.403 +    buffer = alloc_buffer_page(fsr, import->dom_id, &gref);
  42.404 +    DEBUG("gref=%d\n", gref);
  42.405      fsr->thread = current;
  42.406 -    sprintf(fsr->page, "%s", name);
  42.407 +    sprintf(buffer, "%s", name);
  42.408  
  42.409      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.410      req->type = REQ_CREATE;
  42.411      req->id = priv_req_id;
  42.412 -    req->u.fcreate.gref = fsr->gref;
  42.413 +    req->u.fcreate.gref = gref;
  42.414      req->u.fcreate.directory = directory;
  42.415      req->u.fcreate.mode = mode;
  42.416  
  42.417 @@ -546,6 +623,7 @@ int fs_create(struct fs_import *import, 
  42.418      /* Read the response */
  42.419      ret = (int)fsr->shadow_rsp.ret_val;
  42.420      DEBUG("The following ret: %d\n", ret);
  42.421 +    free_buffer_page(fsr);
  42.422      add_id_to_freelist(priv_req_id, import->freelist);
  42.423  
  42.424      return ret;
  42.425 @@ -556,6 +634,8 @@ char** fs_list(struct fs_import *import,
  42.426  {
  42.427      struct fs_request *fsr;
  42.428      unsigned short priv_req_id;
  42.429 +    grant_ref_t gref;
  42.430 +    void *buffer;
  42.431      RING_IDX back_req_id; 
  42.432      struct fsif_request *req;
  42.433      char **files, *current_file;
  42.434 @@ -566,19 +646,21 @@ char** fs_list(struct fs_import *import,
  42.435  
  42.436      /* Prepare request for the backend */
  42.437      back_req_id = reserve_fsif_request(import);
  42.438 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.439 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.440  
  42.441      /* Prepare our private request structure */
  42.442      priv_req_id = get_id_from_freelist(import->freelist);
  42.443      DEBUG("Request id for fs_list call is: %d\n", priv_req_id);
  42.444      fsr = &import->requests[priv_req_id];
  42.445 +    buffer = alloc_buffer_page(fsr, import->dom_id, &gref);
  42.446 +    DEBUG("gref=%d\n", gref);
  42.447      fsr->thread = current;
  42.448 -    sprintf(fsr->page, "%s", name);
  42.449 +    sprintf(buffer, "%s", name);
  42.450  
  42.451      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.452      req->type = REQ_DIR_LIST;
  42.453      req->id = priv_req_id;
  42.454 -    req->u.flist.gref = fsr->gref;
  42.455 +    req->u.flist.gref = gref;
  42.456      req->u.flist.offset = offset;
  42.457  
  42.458      /* Set blocked flag before commiting the request, thus avoiding missed
  42.459 @@ -592,7 +674,7 @@ char** fs_list(struct fs_import *import,
  42.460      files = NULL;
  42.461      if(*nr_files <= 0) goto exit;
  42.462      files = malloc(sizeof(char*) * (*nr_files));
  42.463 -    current_file = fsr->page;
  42.464 +    current_file = buffer; 
  42.465      for(i=0; i<*nr_files; i++)
  42.466      {
  42.467          files[i] = strdup(current_file); 
  42.468 @@ -600,6 +682,7 @@ char** fs_list(struct fs_import *import,
  42.469      }
  42.470      if(has_more != NULL)
  42.471          *has_more = fsr->shadow_rsp.ret_val & HAS_MORE_FLAG;
  42.472 +    free_buffer_page(fsr);
  42.473      add_id_to_freelist(priv_req_id, import->freelist);
  42.474  exit:
  42.475      return files;
  42.476 @@ -615,7 +698,7 @@ int fs_chmod(struct fs_import *import, i
  42.477  
  42.478      /* Prepare request for the backend */
  42.479      back_req_id = reserve_fsif_request(import);
  42.480 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.481 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.482  
  42.483      /* Prepare our private request structure */
  42.484      priv_req_id = get_id_from_freelist(import->freelist);
  42.485 @@ -647,25 +730,29 @@ int64_t fs_space(struct fs_import *impor
  42.486  {
  42.487      struct fs_request *fsr;
  42.488      unsigned short priv_req_id;
  42.489 +    grant_ref_t gref;
  42.490 +    void *buffer;
  42.491      RING_IDX back_req_id; 
  42.492      struct fsif_request *req;
  42.493      int64_t ret;
  42.494  
  42.495      /* Prepare request for the backend */
  42.496      back_req_id = reserve_fsif_request(import);
  42.497 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.498 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.499  
  42.500      /* Prepare our private request structure */
  42.501      priv_req_id = get_id_from_freelist(import->freelist);
  42.502      DEBUG("Request id for fs_space is: %d\n", priv_req_id);
  42.503      fsr = &import->requests[priv_req_id];
  42.504 +    buffer = alloc_buffer_page(fsr, import->dom_id, &gref);
  42.505 +    DEBUG("gref=%d\n", gref);
  42.506      fsr->thread = current;
  42.507 -    sprintf(fsr->page, "%s", location);
  42.508 +    sprintf(buffer, "%s", location);
  42.509  
  42.510      req = RING_GET_REQUEST(&import->ring, back_req_id);
  42.511      req->type = REQ_FS_SPACE;
  42.512      req->id = priv_req_id;
  42.513 -    req->u.fspace.gref = fsr->gref;
  42.514 +    req->u.fspace.gref = gref;
  42.515  
  42.516      /* Set blocked flag before commiting the request, thus avoiding missed
  42.517       * response race */
  42.518 @@ -676,6 +763,7 @@ int64_t fs_space(struct fs_import *impor
  42.519      /* Read the response */
  42.520      ret = (int64_t)fsr->shadow_rsp.ret_val;
  42.521      DEBUG("The following returned: %lld\n", ret);
  42.522 +    free_buffer_page(fsr);
  42.523      add_id_to_freelist(priv_req_id, import->freelist);
  42.524  
  42.525      return ret;
  42.526 @@ -691,7 +779,7 @@ int fs_sync(struct fs_import *import, in
  42.527  
  42.528      /* Prepare request for the backend */
  42.529      back_req_id = reserve_fsif_request(import);
  42.530 -    DEBUG("Backend request id=%d, gref=%d\n", back_req_id, fsr->gref);
  42.531 +    DEBUG("Backend request id=%d\n", back_req_id);
  42.532  
  42.533      /* Prepare our private request structure */
  42.534      priv_req_id = get_id_from_freelist(import->freelist);
  42.535 @@ -723,6 +811,23 @@ int fs_sync(struct fs_import *import, in
  42.536  /*                       END OF INDIVIDUAL FILE OPERATIONS                    */
  42.537  /******************************************************************************/
  42.538  
  42.539 +void *alloc_buffer_page(struct fs_request *req, domid_t domid, grant_ref_t *gref)
  42.540 +{
  42.541 +    void *page;
  42.542 +
  42.543 +    page = (void *)alloc_page(); 
  42.544 +    *gref = gnttab_grant_access(domid, virt_to_mfn(page), 0); 
  42.545 +    req->private1 = page;
  42.546 +    req->private2 = (void *)(uintptr_t)(*gref);
  42.547 +
  42.548 +    return page;
  42.549 +}
  42.550 +
  42.551 +void free_buffer_page(struct fs_request *req)
  42.552 +{
  42.553 +    gnttab_end_access((grant_ref_t)(uintptr_t)req->private2);
  42.554 +    free_page(req->private1);
  42.555 +}
  42.556  
  42.557  static void fsfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
  42.558  {
  42.559 @@ -737,7 +842,7 @@ static void fsfront_handler(evtchn_port_
  42.560  
  42.561      DEBUG("Event from import [%d:%d].\n", import->dom_id, import->export_id);
  42.562  moretodo:   
  42.563 -    rp = import->ring.sring->req_prod;
  42.564 +    rp = import->ring.sring->rsp_prod;
  42.565      rmb(); /* Ensure we see queued responses up to 'rp'. */
  42.566      cons = import->ring.rsp_cons;
  42.567      while (cons != rp)
  42.568 @@ -747,7 +852,7 @@ moretodo:
  42.569  
  42.570          rsp = RING_GET_RESPONSE(&import->ring, cons); 
  42.571          DEBUG("Response at idx=%d to request id=%d, ret_val=%lx\n", 
  42.572 -            import->ring.rsp_cons, rsp->id, rsp->ret_val);
  42.573 +            cons, rsp->id, rsp->ret_val);
  42.574          req = &import->requests[rsp->id];
  42.575          memcpy(&req->shadow_rsp, rsp, sizeof(struct fsif_response));
  42.576          DEBUG("Waking up: %s\n", req->thread->name);
  42.577 @@ -785,18 +890,10 @@ static void alloc_request_table(struct f
  42.578      printk("Allocating request array for import %d, nr_entries = %d.\n",
  42.579              import->import_id, import->nr_entries);
  42.580      requests = xmalloc_array(struct fs_request, import->nr_entries);
  42.581 -    import->freelist = xmalloc_array(unsigned short, import->nr_entries);
  42.582 -    memset(import->freelist, 0, sizeof(unsigned short) * import->nr_entries);
  42.583 +    import->freelist = xmalloc_array(unsigned short, import->nr_entries + 1);
  42.584 +    memset(import->freelist, 0, sizeof(unsigned short) * (import->nr_entries + 1));
  42.585      for(i=0; i<import->nr_entries; i++)
  42.586 -    {
  42.587 -	/* TODO: that's a lot of memory */
  42.588 -        requests[i].page = (void *)alloc_page(); 
  42.589 -        requests[i].gref = gnttab_grant_access(import->dom_id, 
  42.590 -                                               virt_to_mfn(requests[i].page),
  42.591 -                                               0);
  42.592 -        //printk("   ===>> Page=%lx, gref=%d, mfn=%lx\n", requests[i].page, requests[i].gref, virt_to_mfn(requests[i].page));
  42.593          add_id_to_freelist(i, import->freelist);
  42.594 -    }
  42.595      import->requests = requests;
  42.596  }
  42.597  
  42.598 @@ -809,22 +906,27 @@ static void alloc_request_table(struct f
  42.599  void test_fs_import(void *data)
  42.600  {
  42.601      struct fs_import *import = (struct fs_import *)data; 
  42.602 -    int ret, fd, i;
  42.603 +    int ret, fd, i, repeat_count;
  42.604      int32_t nr_files;
  42.605      char buffer[1024];
  42.606      ssize_t offset;
  42.607      char **files;
  42.608      long ret64;
  42.609 -   
  42.610 +    struct fsif_stat_response stat;
  42.611 +    
  42.612 +    repeat_count = 10; 
  42.613      /* Sleep for 1s and then try to open a file */
  42.614      msleep(1000);
  42.615 +again:
  42.616      ret = fs_create(import, "mini-os-created-directory", 1, 0777);
  42.617      printk("Directory create: %d\n", ret);
  42.618  
  42.619 -    ret = fs_create(import, "mini-os-created-directory/mini-os-created-file", 0, 0666);
  42.620 +    sprintf(buffer, "mini-os-created-directory/mini-os-created-file-%d", 
  42.621 +            repeat_count);
  42.622 +    ret = fs_create(import, buffer, 0, 0666);
  42.623      printk("File create: %d\n", ret);
  42.624  
  42.625 -    fd = fs_open(import, "mini-os-created-directory/mini-os-created-file");
  42.626 +    fd = fs_open(import, buffer);
  42.627      printk("File descriptor: %d\n", fd);
  42.628      if(fd < 0) return;
  42.629  
  42.630 @@ -838,7 +940,16 @@ void test_fs_import(void *data)
  42.631              return;
  42.632          offset += ret;
  42.633      }
  42.634 -
  42.635 +    ret = fs_stat(import, fd, &stat);
  42.636 +    printk("Ret after stat: %d\n", ret);
  42.637 +    printk(" st_mode=%o\n", stat.stat_mode);
  42.638 +    printk(" st_uid =%d\n", stat.stat_uid);
  42.639 +    printk(" st_gid =%d\n", stat.stat_gid);
  42.640 +    printk(" st_size=%ld\n", stat.stat_size);
  42.641 +    printk(" st_atime=%ld\n", stat.stat_atime);
  42.642 +    printk(" st_mtime=%ld\n", stat.stat_mtime);
  42.643 +    printk(" st_ctime=%ld\n", stat.stat_ctime);
  42.644 + 
  42.645      ret = fs_close(import, fd);
  42.646      printk("Closed fd: %d, ret=%d\n", fd, ret);
  42.647     
  42.648 @@ -849,6 +960,9 @@ void test_fs_import(void *data)
  42.649  
  42.650      ret64 = fs_space(import, "/");
  42.651      printk("Free space: %lld (=%lld Mb)\n", ret64, (ret64 >> 20));
  42.652 +    repeat_count--;
  42.653 +    if(repeat_count > 0)
  42.654 +        goto again;
  42.655      
  42.656  }
  42.657  
  42.658 @@ -915,20 +1029,21 @@ static int init_fs_import(struct fs_impo
  42.659      xenbus_transaction_t xbt;
  42.660      char nodename[1024], r_nodename[1024], token[128], *message = NULL;
  42.661      struct fsif_sring *sring;
  42.662 -    int retry = 0;
  42.663 +    int i, retry = 0;
  42.664      domid_t self_id;
  42.665      xenbus_event_queue events = NULL;
  42.666  
  42.667      printk("Initialising FS fortend to backend dom %d\n", import->dom_id);
  42.668      /* Allocate page for the shared ring */
  42.669 -    sring = (struct fsif_sring*) alloc_page();
  42.670 -    memset(sring, 0, PAGE_SIZE);
  42.671 +    sring = (struct fsif_sring*) alloc_pages(FSIF_RING_SIZE_ORDER);
  42.672 +    memset(sring, 0, PAGE_SIZE * FSIF_RING_SIZE_PAGES);
  42.673  
  42.674      /* Init the shared ring */
  42.675      SHARED_RING_INIT(sring);
  42.676 +    ASSERT(FSIF_NR_READ_GNTS == FSIF_NR_WRITE_GNTS);
  42.677  
  42.678      /* Init private frontend ring */
  42.679 -    FRONT_RING_INIT(&import->ring, sring, PAGE_SIZE);
  42.680 +    FRONT_RING_INIT(&import->ring, sring, PAGE_SIZE * FSIF_RING_SIZE_PAGES);
  42.681      import->nr_entries = import->ring.nr_ents;
  42.682  
  42.683      /* Allocate table of requests */
  42.684 @@ -936,7 +1051,11 @@ static int init_fs_import(struct fs_impo
  42.685      init_SEMAPHORE(&import->reqs_sem, import->nr_entries);
  42.686  
  42.687      /* Grant access to the shared ring */
  42.688 -    import->gnt_ref = gnttab_grant_access(import->dom_id, virt_to_mfn(sring), 0);
  42.689 +    for(i=0; i<FSIF_RING_SIZE_PAGES; i++) 
  42.690 +        import->gnt_refs[i] = 
  42.691 +            gnttab_grant_access(import->dom_id, 
  42.692 +                                virt_to_mfn((char *)sring + i * PAGE_SIZE), 
  42.693 +                                0);
  42.694     
  42.695      /* Allocate event channel */ 
  42.696      BUG_ON(evtchn_alloc_unbound(import->dom_id, 
  42.697 @@ -960,13 +1079,27 @@ again:
  42.698      
  42.699      err = xenbus_printf(xbt, 
  42.700                          nodename, 
  42.701 -                        "ring-ref",
  42.702 +                        "ring-size",
  42.703                          "%u",
  42.704 -                        import->gnt_ref);
  42.705 +                        FSIF_RING_SIZE_PAGES);
  42.706      if (err) {
  42.707 -        message = "writing ring-ref";
  42.708 +        message = "writing ring-size";
  42.709          goto abort_transaction;
  42.710      }
  42.711 +    
  42.712 +    for(i=0; i<FSIF_RING_SIZE_PAGES; i++)
  42.713 +    {
  42.714 +        sprintf(r_nodename, "ring-ref-%d", i);
  42.715 +        err = xenbus_printf(xbt, 
  42.716 +                            nodename, 
  42.717 +                            r_nodename,
  42.718 +                            "%u",
  42.719 +                            import->gnt_refs[i]);
  42.720 +        if (err) {
  42.721 +            message = "writing ring-refs";
  42.722 +            goto abort_transaction;
  42.723 +        }
  42.724 +    }
  42.725  
  42.726      err = xenbus_printf(xbt, 
  42.727                          nodename,
  42.728 @@ -1037,7 +1170,7 @@ done:
  42.729      return 1;
  42.730  }
  42.731  
  42.732 -static void add_export(struct list_head *exports, unsigned int domid)
  42.733 +static void add_export(struct minios_list_head *exports, unsigned int domid)
  42.734  {
  42.735      char node[1024], **exports_list = NULL, *ret_msg;
  42.736      int j = 0;
  42.737 @@ -1059,8 +1192,8 @@ static void add_export(struct list_head 
  42.738              import->dom_id = domid;
  42.739              import->export_id = export_id;
  42.740              import->import_id = import_id++;
  42.741 -            INIT_LIST_HEAD(&import->list);
  42.742 -            list_add(&import->list, exports);
  42.743 +            MINIOS_INIT_LIST_HEAD(&import->list);
  42.744 +            minios_list_add(&import->list, exports);
  42.745          }
  42.746          free(exports_list[j]);
  42.747          j++;
  42.748 @@ -1072,14 +1205,14 @@ static void add_export(struct list_head 
  42.749  }
  42.750  
  42.751  #if 0
  42.752 -static struct list_head* probe_exports(void)
  42.753 +static struct minios_list_head* probe_exports(void)
  42.754  {
  42.755 -    struct list_head *exports;
  42.756 +    struct minios_list_head *exports;
  42.757      char **node_list = NULL, *msg = NULL;
  42.758      int i = 0;
  42.759  
  42.760 -    exports = xmalloc(struct list_head);
  42.761 -    INIT_LIST_HEAD(exports);
  42.762 +    exports = xmalloc(struct minios_list_head);
  42.763 +    MINIOS_INIT_LIST_HEAD(exports);
  42.764      
  42.765      msg = xenbus_ls(XBT_NIL, "/local/domain", &node_list);
  42.766      if(msg)
  42.767 @@ -1104,19 +1237,19 @@ exit:
  42.768  }
  42.769  #endif
  42.770  
  42.771 -LIST_HEAD(exports);
  42.772 +MINIOS_LIST_HEAD(exports);
  42.773  
  42.774  void init_fs_frontend(void)
  42.775  {
  42.776 -    struct list_head *entry;
  42.777 +    struct minios_list_head *entry;
  42.778      struct fs_import *import = NULL;
  42.779      printk("Initing FS fronend(s).\n");
  42.780  
  42.781      //exports = probe_exports();
  42.782      add_export(&exports, 0);
  42.783 -    list_for_each(entry, &exports)
  42.784 +    minios_list_for_each(entry, &exports)
  42.785      {
  42.786 -        import = list_entry(entry, struct fs_import, list);
  42.787 +        import = minios_list_entry(entry, struct fs_import, list);
  42.788          printk("FS export [dom=%d, id=%d] found\n", 
  42.789                  import->dom_id, import->export_id);
  42.790          init_fs_import(import);
  42.791 @@ -1127,3 +1260,5 @@ void init_fs_frontend(void)
  42.792      if (!fs_import)
  42.793  	printk("No FS import\n");
  42.794  }
  42.795 +
  42.796 +/* TODO: shutdown */
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/extras/mini-os/gntmap.c	Tue Sep 02 16:34:53 2008 -0700
    43.3 @@ -0,0 +1,252 @@
    43.4 +/*
    43.5 + * Manages grant mappings from other domains.
    43.6 + *
    43.7 + * Diego Ongaro <diego.ongaro@citrix.com>, July 2008
    43.8 + *
    43.9 + * Files of type FTYPE_GNTMAP contain a gntmap, which is an array of
   43.10 + * (host address, grant handle) pairs. Grant handles come from a hypervisor map
   43.11 + * operation and are needed for the corresponding unmap.
   43.12 + *
   43.13 + * This is a rather naive implementation in terms of performance. If we start
   43.14 + * using it frequently, there's definitely some low-hanging fruit here.
   43.15 + *
   43.16 + *
   43.17 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   43.18 + * of this software and associated documentation files (the "Software"), to
   43.19 + * deal in the Software without restriction, including without limitation the
   43.20 + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
   43.21 + * sell copies of the Software, and to permit persons to whom the Software is
   43.22 + * furnished to do so, subject to the following conditions:
   43.23 + *
   43.24 + * The above copyright notice and this permission notice shall be included in
   43.25 + * all copies or substantial portions of the Software.
   43.26 + *
   43.27 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
   43.28 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
   43.29 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
   43.30 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
   43.31 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
   43.32 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
   43.33 + * DEALINGS IN THE SOFTWARE.
   43.34 + */
   43.35 +
   43.36 +#include <os.h>
   43.37 +#include <xmalloc.h>
   43.38 +#include <errno.h>
   43.39 +#include <xen/grant_table.h>
   43.40 +#include <inttypes.h>
   43.41 +#include "gntmap.h"
   43.42 +
   43.43 +#define DEFAULT_MAX_GRANTS 128
   43.44 +
   43.45 +struct gntmap_entry {
   43.46 +    unsigned long host_addr;
   43.47 +    grant_handle_t handle;
   43.48 +};
   43.49 +
   43.50 +static inline int
   43.51 +gntmap_entry_used(struct gntmap_entry *entry)
   43.52 +{
   43.53 +    return entry->host_addr != 0;
   43.54 +}
   43.55 +
   43.56 +static struct gntmap_entry*
   43.57 +gntmap_find_free_entry(struct gntmap *map)
   43.58 +{
   43.59 +    int i;
   43.60 +
   43.61 +    for (i = 0; i < map->nentries; i++) {
   43.62 +        if (!gntmap_entry_used(&map->entries[i]))
   43.63 +            return &map->entries[i];
   43.64 +    }
   43.65 +
   43.66 +#ifdef GNTMAP_DEBUG
   43.67 +    printk("gntmap_find_free_entry(map=%p): all %d entries full\n",
   43.68 +           map, map->nentries);
   43.69 +#endif
   43.70 +    return NULL;
   43.71 +}
   43.72 +
   43.73 +static struct gntmap_entry*
   43.74 +gntmap_find_entry(struct gntmap *map, unsigned long addr)
   43.75 +{
   43.76 +    int i;
   43.77 +
   43.78 +    for (i = 0; i < map->nentries; i++) {
   43.79 +        if (map->entries[i].host_addr == addr)
   43.80 +            return &map->entries[i];
   43.81 +    }
   43.82 +    return NULL;
   43.83 +}
   43.84 +
   43.85 +int
   43.86 +gntmap_set_max_grants(struct gntmap *map, int count)
   43.87 +{
   43.88 +#ifdef GNTMAP_DEBUG
   43.89 +    printk("gntmap_set_max_grants(map=%p, count=%d)\n", map, count);
   43.90 +#endif
   43.91 +
   43.92 +    if (map->nentries != 0)
   43.93 +        return -EBUSY;
   43.94 +
   43.95 +    map->entries = xmalloc_array(struct gntmap_entry, count);
   43.96 +    if (map->entries == NULL)
   43.97 +        return -ENOMEM;
   43.98 +
   43.99 +    memset(map->entries, 0, sizeof(struct gntmap_entry) * count);
  43.100 +    map->nentries = count;
  43.101 +    return 0;
  43.102 +}
  43.103 +
  43.104 +static int
  43.105 +_gntmap_map_grant_ref(struct gntmap_entry *entry, 
  43.106 +                      unsigned long host_addr,
  43.107 +                      uint32_t domid,
  43.108 +                      uint32_t ref,
  43.109 +                      int writable)
  43.110 +{
  43.111 +    struct gnttab_map_grant_ref op;
  43.112 +    int rc;
  43.113 +
  43.114 +    op.ref = (grant_ref_t) ref;
  43.115 +    op.dom = (domid_t) domid;
  43.116 +    op.host_addr = (uint64_t) host_addr;
  43.117 +    op.flags = GNTMAP_host_map;
  43.118 +    if (!writable)
  43.119 +        op.flags |= GNTMAP_readonly;
  43.120 +
  43.121 +    rc = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
  43.122 +    if (rc != 0 || op.status != GNTST_okay) {
  43.123 +        printk("GNTTABOP_map_grant_ref failed: "
  43.124 +               "returned %d, status %" PRId16 "\n",
  43.125 +               rc, op.status);
  43.126 +        return rc != 0 ? rc : op.status;
  43.127 +    }
  43.128 +
  43.129 +    entry->host_addr = host_addr;
  43.130 +    entry->handle = op.handle;
  43.131 +    return 0;
  43.132 +}
  43.133 +
  43.134 +static int
  43.135 +_gntmap_unmap_grant_ref(struct gntmap_entry *entry)
  43.136 +{
  43.137 +    struct gnttab_unmap_grant_ref op;
  43.138 +    int rc;
  43.139 +
  43.140 +    op.host_addr    = (uint64_t) entry->host_addr;
  43.141 +    op.dev_bus_addr = 0;
  43.142 +    op.handle       = entry->handle;
  43.143 +
  43.144 +    rc = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
  43.145 +    if (rc != 0 || op.status != GNTST_okay) {
  43.146 +        printk("GNTTABOP_unmap_grant_ref failed: "
  43.147 +               "returned %d, status %" PRId16 "\n",
  43.148 +               rc, op.status);
  43.149 +        return rc != 0 ? rc : op.status;
  43.150 +    }
  43.151 +
  43.152 +    entry->host_addr = 0;
  43.153 +    return 0;
  43.154 +}
  43.155 +
  43.156 +int
  43.157 +gntmap_munmap(struct gntmap *map, unsigned long start_address, int count)
  43.158 +{
  43.159 +    int i, rc;
  43.160 +    struct gntmap_entry *ent;
  43.161 +
  43.162 +#ifdef GNTMAP_DEBUG
  43.163 +    printk("gntmap_munmap(map=%p, start_address=%lx, count=%d)\n",
  43.164 +           map, start_address, count);
  43.165 +#endif
  43.166 +
  43.167 +    for (i = 0; i < count; i++) {
  43.168 +        ent = gntmap_find_entry(map, start_address + PAGE_SIZE * i);
  43.169 +        if (ent == NULL) {
  43.170 +            printk("gntmap: tried to munmap unknown page\n");
  43.171 +            return -EINVAL;
  43.172 +        }
  43.173 +
  43.174 +        rc = _gntmap_unmap_grant_ref(ent);
  43.175 +        if (rc != 0)
  43.176 +            return rc;
  43.177 +    }
  43.178 +
  43.179 +    return 0;
  43.180 +}
  43.181 +
  43.182 +void*
  43.183 +gntmap_map_grant_refs(struct gntmap *map, 
  43.184 +                      uint32_t count,
  43.185 +                      uint32_t *domids,
  43.186 +                      int domids_stride,
  43.187 +                      uint32_t *refs,
  43.188 +                      int writable)
  43.189 +{
  43.190 +    unsigned long addr;
  43.191 +    struct gntmap_entry *ent;
  43.192 +    int i;
  43.193 +
  43.194 +#ifdef GNTMAP_DEBUG
  43.195 +    printk("gntmap_map_grant_refs(map=%p, count=%" PRIu32 ", "
  43.196 +           "domids=%p [%" PRIu32 "...], domids_stride=%d, "
  43.197 +           "refs=%p [%" PRIu32 "...], writable=%d)\n",
  43.198 +           map, count,
  43.199 +           domids, domids == NULL ? 0 : domids[0], domids_stride,
  43.200 +           refs, refs == NULL ? 0 : refs[0], writable);
  43.201 +#endif
  43.202 +
  43.203 +    (void) gntmap_set_max_grants(map, DEFAULT_MAX_GRANTS);
  43.204 +
  43.205 +    addr = allocate_ondemand((unsigned long) count, 1);
  43.206 +    if (addr == 0)
  43.207 +        return NULL;
  43.208 +
  43.209 +    for (i = 0; i < count; i++) {
  43.210 +        ent = gntmap_find_free_entry(map);
  43.211 +        if (ent == NULL ||
  43.212 +            _gntmap_map_grant_ref(ent,
  43.213 +                                  addr + PAGE_SIZE * i,
  43.214 +                                  domids[i * domids_stride],
  43.215 +                                  refs[i],
  43.216 +                                  writable) != 0) {
  43.217 +
  43.218 +            (void) gntmap_munmap(map, addr, i);
  43.219 +            return NULL;
  43.220 +        }
  43.221 +    }
  43.222 +
  43.223 +    return (void*) addr;
  43.224 +}
  43.225 +
  43.226 +void
  43.227 +gntmap_init(struct gntmap *map)
  43.228 +{
  43.229 +#ifdef GNTMAP_DEBUG
  43.230 +    printk("gntmap_init(map=%p)\n", map);
  43.231 +#endif
  43.232 +    map->nentries = 0;
  43.233 +    map->entries = NULL;
  43.234 +}
  43.235 +
  43.236 +void
  43.237 +gntmap_fini(struct gntmap *map)
  43.238 +{
  43.239 +    struct gntmap_entry *ent;
  43.240 +    int i;
  43.241 +
  43.242 +#ifdef GNTMAP_DEBUG
  43.243 +    printk("gntmap_fini(map=%p)\n", map);
  43.244 +#endif
  43.245 +
  43.246 +    for (i = 0; i < map->nentries; i++) {
  43.247 +        ent = &map->entries[i];
  43.248 +        if (gntmap_entry_used(ent))
  43.249 +            (void) _gntmap_unmap_grant_ref(ent);
  43.250 +    }
  43.251 +
  43.252 +    xfree(map->entries);
  43.253 +    map->entries = NULL;
  43.254 +    map->nentries = 0;
  43.255 +}
    44.1 --- a/extras/mini-os/gnttab.c	Fri Aug 29 15:47:21 2008 -0700
    44.2 +++ b/extras/mini-os/gnttab.c	Tue Sep 02 16:34:53 2008 -0700
    44.3 @@ -35,7 +35,7 @@ static grant_ref_t gnttab_list[NR_GRANT_
    44.4  #ifdef GNT_DEBUG
    44.5  static char inuse[NR_GRANT_ENTRIES];
    44.6  #endif
    44.7 -static __DECLARE_SEMAPHORE_GENERIC(gnttab_sem, NR_GRANT_ENTRIES);
    44.8 +static __DECLARE_SEMAPHORE_GENERIC(gnttab_sem, 0);
    44.9  
   44.10  static void
   44.11  put_free_entry(grant_ref_t ref)
   44.12 @@ -60,6 +60,7 @@ get_free_entry(void)
   44.13      down(&gnttab_sem);
   44.14      local_irq_save(flags);
   44.15      ref = gnttab_list[0];
   44.16 +    BUG_ON(ref < NR_RESERVED_ENTRIES || ref >= NR_GRANT_ENTRIES);
   44.17      gnttab_list[0] = gnttab_list[ref];
   44.18  #ifdef GNT_DEBUG
   44.19      BUG_ON(inuse[ref]);
   44.20 @@ -193,3 +194,14 @@ init_gnttab(void)
   44.21      gnttab_table = map_frames(frames, NR_GRANT_FRAMES);
   44.22      printk("gnttab_table mapped at %p.\n", gnttab_table);
   44.23  }
   44.24 +
   44.25 +void
   44.26 +fini_gnttab(void)
   44.27 +{
   44.28 +    struct gnttab_setup_table setup;
   44.29 +
   44.30 +    setup.dom = DOMID_SELF;
   44.31 +    setup.nr_frames = 0;
   44.32 +
   44.33 +    HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
   44.34 +}
    45.1 --- a/extras/mini-os/hypervisor.c	Fri Aug 29 15:47:21 2008 -0700
    45.2 +++ b/extras/mini-os/hypervisor.c	Tue Sep 02 16:34:53 2008 -0700
    45.3 @@ -55,12 +55,12 @@ void do_hypervisor_callback(struct pt_re
    45.4      while ( l1 != 0 )
    45.5      {
    45.6          l1i = __ffs(l1);
    45.7 -        l1 &= ~(1 << l1i);
    45.8 +        l1 &= ~(1UL << l1i);
    45.9          
   45.10          while ( (l2 = active_evtchns(cpu, s, l1i)) != 0 )
   45.11          {
   45.12              l2i = __ffs(l2);
   45.13 -            l2 &= ~(1 << l2i);
   45.14 +            l2 &= ~(1UL << l2i);
   45.15  
   45.16              port = (l1i * (sizeof(unsigned long) * 8)) + l2i;
   45.17  			do_event(port, regs);
   45.18 @@ -72,9 +72,10 @@ void do_hypervisor_callback(struct pt_re
   45.19  
   45.20  void force_evtchn_callback(void)
   45.21  {
   45.22 +    int save;
   45.23      vcpu_info_t *vcpu;
   45.24      vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()];
   45.25 -    int save = vcpu->evtchn_upcall_mask;
   45.26 +    save = vcpu->evtchn_upcall_mask;
   45.27  
   45.28      while (vcpu->evtchn_upcall_pending) {
   45.29          vcpu->evtchn_upcall_mask = 1;
    46.1 --- a/extras/mini-os/include/arch/cc.h	Fri Aug 29 15:47:21 2008 -0700
    46.2 +++ b/extras/mini-os/include/arch/cc.h	Tue Sep 02 16:34:53 2008 -0700
    46.3 @@ -10,8 +10,8 @@
    46.4  #define __LWIP_ARCH_CC_H__
    46.5  
    46.6  /*   Typedefs for the types used by lwip - */
    46.7 -#include <os.h>
    46.8 -#include <types.h>
    46.9 +#include <mini-os/os.h>
   46.10 +#include <mini-os/types.h>
   46.11  #include <time.h>
   46.12  typedef  u8  u8_t;
   46.13  typedef  s8  s8_t;
   46.14 @@ -46,7 +46,7 @@ extern void lwip_die(char *fmt, ...);
   46.15  
   46.16  /*   If the compiler does not provide memset() this file must include a */
   46.17  /*   definition of it, or include a file which defines it. */
   46.18 -#include <lib.h>
   46.19 +#include <mini-os/lib.h>
   46.20  
   46.21  /*   This file must either include a system-local <errno.h> which defines */
   46.22  /*   the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO */
    47.1 --- a/extras/mini-os/include/arch/sys_arch.h	Fri Aug 29 15:47:21 2008 -0700
    47.2 +++ b/extras/mini-os/include/arch/sys_arch.h	Tue Sep 02 16:34:53 2008 -0700
    47.3 @@ -9,9 +9,9 @@
    47.4  #ifndef __LWIP_ARCH_SYS_ARCH_H__
    47.5  #define __LWIP_ARCH_SYS_ARCH_H__
    47.6  
    47.7 -#include <os.h>
    47.8 -#include <xmalloc.h>
    47.9 -#include <semaphore.h>
   47.10 +#include <mini-os/os.h>
   47.11 +#include <mini-os/xmalloc.h>
   47.12 +#include <mini-os/semaphore.h>
   47.13  
   47.14  typedef struct semaphore *sys_sem_t;
   47.15  #define SYS_SEM_NULL ((sys_sem_t) NULL)
    48.1 --- a/extras/mini-os/include/blkfront.h	Fri Aug 29 15:47:21 2008 -0700
    48.2 +++ b/extras/mini-os/include/blkfront.h	Tue Sep 02 16:34:53 2008 -0700
    48.3 @@ -1,6 +1,6 @@
    48.4 -#include <wait.h>
    48.5 +#include <mini-os/wait.h>
    48.6  #include <xen/io/blkif.h>
    48.7 -#include <types.h>
    48.8 +#include <mini-os/types.h>
    48.9  struct blkfront_dev;
   48.10  struct blkfront_aiocb
   48.11  {
   48.12 @@ -29,8 +29,11 @@ struct blkfront_dev *init_blkfront(char 
   48.13  int blkfront_open(struct blkfront_dev *dev);
   48.14  #endif
   48.15  void blkfront_aio(struct blkfront_aiocb *aiocbp, int write);
   48.16 -void blkfront_aio_read(struct blkfront_aiocb *aiocbp);
   48.17 -void blkfront_aio_write(struct blkfront_aiocb *aiocbp);
   48.18 +#define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0)
   48.19 +#define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1)
   48.20 +void blkfront_io(struct blkfront_aiocb *aiocbp, int write);
   48.21 +#define blkfront_read(aiocbp) blkfront_io(aiocbp, 0)
   48.22 +#define blkfront_write(aiocbp) blkfront_io(aiocbp, 1)
   48.23  void blkfront_aio_push_operation(struct blkfront_aiocb *aiocbp, uint8_t op);
   48.24  int blkfront_aio_poll(struct blkfront_dev *dev);
   48.25  void blkfront_sync(struct blkfront_dev *dev);
    49.1 --- a/extras/mini-os/include/byteswap.h	Fri Aug 29 15:47:21 2008 -0700
    49.2 +++ b/extras/mini-os/include/byteswap.h	Tue Sep 02 16:34:53 2008 -0700
    49.3 @@ -2,21 +2,32 @@
    49.4  #define _BYTESWAP_H_
    49.5  
    49.6  /* Unfortunately not provided by newlib.  */
    49.7 -#define bswap_16(x) \
    49.8 -    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8))
    49.9  
   49.10 -#define bswap_32(x) \
   49.11 -    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
   49.12 -     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
   49.13 +#include <mini-os/types.h>
   49.14 +static inline uint16_t bswap_16(uint16_t x)
   49.15 +{
   49.16 +    return
   49.17 +    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8));
   49.18 +}
   49.19  
   49.20 -#define bswap_64(x) \
   49.21 -    ((((x) & 0xff00000000000000ULL) >> 56) | \
   49.22 -     (((x) & 0x00ff000000000000ULL) >> 40) | \
   49.23 -     (((x) & 0x0000ff0000000000ULL) >> 24) | \
   49.24 -     (((x) & 0x000000ff00000000ULL) >>  8) | \
   49.25 -     (((x) & 0x00000000ff000000ULL) <<  8) | \
   49.26 -     (((x) & 0x0000000000ff0000ULL) << 24) | \
   49.27 -     (((x) & 0x000000000000ff00ULL) << 40) | \
   49.28 -     (((x) & 0x00000000000000ffULL) << 56))
   49.29 +static inline uint32_t bswap_32(uint32_t x)
   49.30 +{
   49.31 +    return
   49.32 +    ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) |
   49.33 +     (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24));
   49.34 +}
   49.35 +
   49.36 +static inline uint64_t bswap_64(uint64_t x)
   49.37 +{
   49.38 +    return
   49.39 +    ((((x) & 0xff00000000000000ULL) >> 56) |
   49.40 +     (((x) & 0x00ff000000000000ULL) >> 40) |
   49.41 +     (((x) & 0x0000ff0000000000ULL) >> 24) |
   49.42 +     (((x) & 0x000000ff00000000ULL) >>  8) |
   49.43 +     (((x) & 0x00000000ff000000ULL) <<  8) |
   49.44 +     (((x) & 0x0000000000ff0000ULL) << 24) |
   49.45 +     (((x) & 0x000000000000ff00ULL) << 40) |
   49.46 +     (((x) & 0x00000000000000ffULL) << 56));
   49.47 +}
   49.48  
   49.49  #endif /* _BYTESWAP_H */
    50.1 --- a/extras/mini-os/include/console.h	Fri Aug 29 15:47:21 2008 -0700
    50.2 +++ b/extras/mini-os/include/console.h	Tue Sep 02 16:34:53 2008 -0700
    50.3 @@ -36,8 +36,8 @@
    50.4  #ifndef _LIB_CONSOLE_H_
    50.5  #define _LIB_CONSOLE_H_
    50.6  
    50.7 -#include<os.h>
    50.8 -#include<traps.h>
    50.9 +#include<mini-os/os.h>
   50.10 +#include<mini-os/traps.h>
   50.11  #include<stdarg.h>
   50.12  
   50.13  void print(int direct, const char *fmt, va_list args);
   50.14 @@ -51,5 +51,15 @@ void xencons_tx(void);
   50.15  
   50.16  void init_console(void);
   50.17  void console_print(char *data, int length);
   50.18 +void fini_console(void);
   50.19 +
   50.20 +/* Low level functions defined in xencons_ring.c */
   50.21 +extern struct wait_queue_head console_queue;
   50.22 +int xencons_ring_init(void);
   50.23 +int xencons_ring_send(const char *data, unsigned len);
   50.24 +int xencons_ring_send_no_notify(const char *data, unsigned len);
   50.25 +int xencons_ring_avail(void);
   50.26 +int xencons_ring_recv(char *data, unsigned len);
   50.27 +
   50.28  
   50.29  #endif /* _LIB_CONSOLE_H_ */
    51.1 --- a/extras/mini-os/include/ctype.h	Fri Aug 29 15:47:21 2008 -0700
    51.2 +++ b/extras/mini-os/include/ctype.h	Tue Sep 02 16:34:53 2008 -0700
    51.3 @@ -1,6 +1,9 @@
    51.4  #ifndef _CTYPE_H
    51.5  #define _CTYPE_H
    51.6  
    51.7 +#ifdef HAVE_LIBC
    51.8 +#include_next <ctype.h>
    51.9 +#else
   51.10  /*
   51.11   * NOTE! This ctype does not handle EOF like the standard C
   51.12   * library is required to.
   51.13 @@ -53,3 +56,5 @@ static inline unsigned char __toupper(un
   51.14  #define toupper(c) __toupper(c)
   51.15  
   51.16  #endif
   51.17 +
   51.18 +#endif
    52.1 --- a/extras/mini-os/include/err.h	Fri Aug 29 15:47:21 2008 -0700
    52.2 +++ b/extras/mini-os/include/err.h	Tue Sep 02 16:34:53 2008 -0700
    52.3 @@ -1,7 +1,7 @@
    52.4  #ifndef _ERR_H
    52.5  #define _ERR_H
    52.6  
    52.7 -#include <errno.h>
    52.8 +#include <mini-os/errno.h>
    52.9  
   52.10  /*
   52.11   * Kernel pointers have redundant information, so we can use a
    53.1 --- a/extras/mini-os/include/errno.h	Fri Aug 29 15:47:21 2008 -0700
    53.2 +++ b/extras/mini-os/include/errno.h	Tue Sep 02 16:34:53 2008 -0700
    53.3 @@ -1,7 +1,9 @@
    53.4  #ifndef _ERRNO_H
    53.5  #define _ERRNO_H
    53.6  
    53.7 -#include <errno-base.h>
    53.8 +#include <mini-os/errno-base.h>
    53.9 +
   53.10 +typedef int error_t;
   53.11  
   53.12  #define	EDEADLK		35	/* Resource deadlock would occur */
   53.13  #define	ENAMETOOLONG	36	/* File name too long */
   53.14 @@ -107,8 +109,11 @@
   53.15  #define	EOWNERDEAD	130	/* Owner died */
   53.16  #define	ENOTRECOVERABLE	131	/* State not recoverable */
   53.17  
   53.18 +
   53.19 +#define EFTYPE          132     /* Inappropriate file type or format */
   53.20 +
   53.21  #ifdef HAVE_LIBC
   53.22 -#include <sched.h>
   53.23 +#include <mini-os/sched.h>
   53.24  extern int errno;
   53.25  #define ERRNO
   53.26  #define errno (get_current()->reent._errno)
    54.1 --- a/extras/mini-os/include/events.h	Fri Aug 29 15:47:21 2008 -0700
    54.2 +++ b/extras/mini-os/include/events.h	Tue Sep 02 16:34:53 2008 -0700
    54.3 @@ -19,7 +19,7 @@
    54.4  #ifndef _EVENTS_H_
    54.5  #define _EVENTS_H_
    54.6  
    54.7 -#include<traps.h>
    54.8 +#include<mini-os/traps.h>
    54.9  #include<xen/event_channel.h>
   54.10  
   54.11  typedef void (*evtchn_handler_t)(evtchn_port_t, struct pt_regs *, void *);
   54.12 @@ -27,6 +27,7 @@ typedef void (*evtchn_handler_t)(evtchn_
   54.13  /* prototypes */
   54.14  int do_event(evtchn_port_t port, struct pt_regs *regs);
   54.15  evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data);
   54.16 +evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data);
   54.17  evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler,
   54.18  						  void *data);
   54.19  void unbind_evtchn(evtchn_port_t port);
   54.20 @@ -45,5 +46,6 @@ static inline int notify_remote_via_evtc
   54.21      return HYPERVISOR_event_channel_op(EVTCHNOP_send, &op);
   54.22  }
   54.23  
   54.24 +void fini_events(void);
   54.25  
   54.26  #endif /* _EVENTS_H_ */
    55.1 --- a/extras/mini-os/include/fbfront.h	Fri Aug 29 15:47:21 2008 -0700
    55.2 +++ b/extras/mini-os/include/fbfront.h	Tue Sep 02 16:34:53 2008 -0700
    55.3 @@ -1,6 +1,6 @@
    55.4  #include <xen/io/kbdif.h>
    55.5  #include <xen/io/fbif.h>
    55.6 -#include <wait.h>
    55.7 +#include <mini-os/wait.h>
    55.8  
    55.9  /* from <linux/input.h> */
   55.10  #ifndef BTN_LEFT
    56.1 --- a/extras/mini-os/include/fcntl.h	Fri Aug 29 15:47:21 2008 -0700
    56.2 +++ b/extras/mini-os/include/fcntl.h	Tue Sep 02 16:34:53 2008 -0700
    56.3 @@ -91,8 +91,9 @@ struct flock64 {
    56.4  #define F_LINUX_SPECIFIC_BASE	1024
    56.5  */
    56.6  
    56.7 -int open(const char *path, int flags, ...);
    56.8 -int fcntl(int fd, int cmd, ...);
    56.9  #endif
   56.10  
   56.11 +int open(const char *path, int flags, ...) asm("open64");
   56.12 +int fcntl(int fd, int cmd, ...);
   56.13 +
   56.14  #endif
    57.1 --- a/extras/mini-os/include/fs.h	Fri Aug 29 15:47:21 2008 -0700
    57.2 +++ b/extras/mini-os/include/fs.h	Tue Sep 02 16:34:53 2008 -0700
    57.3 @@ -2,19 +2,22 @@
    57.4  #define __FS_H__
    57.5  
    57.6  #include <xen/io/fsif.h>
    57.7 -#include <semaphore.h>
    57.8 -#include <types.h>
    57.9 +#include <mini-os/semaphore.h>
   57.10 +#include <mini-os/types.h>
   57.11 +
   57.12 +#define FSIF_RING_SIZE_ORDER   1
   57.13 +#define FSIF_RING_SIZE_PAGES   (1<<FSIF_RING_SIZE_ORDER)
   57.14  
   57.15  struct fs_import 
   57.16  {
   57.17      domid_t dom_id;                 /* dom id of the exporting domain       */ 
   57.18      u16 export_id;                  /* export id (exporting dom specific)   */
   57.19      u16 import_id;                  /* import id (specific to this domain)  */ 
   57.20 -    struct list_head list;          /* list of all imports                  */
   57.21 +    struct minios_list_head list;   /* list of all imports                  */
   57.22      unsigned int nr_entries;        /* Number of entries in rings & request
   57.23                                         array                                */
   57.24      struct fsif_front_ring ring;    /* frontend ring (contains shared ring) */
   57.25 -    int gnt_ref;                    /* grant reference to the shared ring   */
   57.26 +    u32 gnt_refs[FSIF_RING_SIZE_PAGES];  /* grant references to the shared ring  */
   57.27      evtchn_port_t local_port;       /* local event channel port             */
   57.28      char *backend;                  /* XenBus location of the backend       */
   57.29      struct fs_request *requests;    /* Table of requests                    */
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/extras/mini-os/include/gntmap.h	Tue Sep 02 16:34:53 2008 -0700
    58.3 @@ -0,0 +1,35 @@
    58.4 +#ifndef __GNTMAP_H__
    58.5 +#define __GNTMAP_H__
    58.6 +
    58.7 +#include <os.h>
    58.8 +
    58.9 +/*
   58.10 + * Please consider struct gntmap opaque. If instead you choose to disregard
   58.11 + * this message, I insist that you keep an eye out for raptors.
   58.12 + */
   58.13 +struct gntmap {
   58.14 +    int nentries;
   58.15 +    struct gntmap_entry *entries;
   58.16 +};
   58.17 +
   58.18 +int
   58.19 +gntmap_set_max_grants(struct gntmap *map, int count);
   58.20 +
   58.21 +int
   58.22 +gntmap_munmap(struct gntmap *map, unsigned long start_address, int count);
   58.23 +
   58.24 +void*
   58.25 +gntmap_map_grant_refs(struct gntmap *map, 
   58.26 +                      uint32_t count,
   58.27 +                      uint32_t *domids,
   58.28 +                      int domids_stride,
   58.29 +                      uint32_t *refs,
   58.30 +                      int writable);
   58.31 +
   58.32 +void
   58.33 +gntmap_init(struct gntmap *map);
   58.34 +
   58.35 +void
   58.36 +gntmap_fini(struct gntmap *map);
   58.37 +
   58.38 +#endif /* !__GNTMAP_H__ */
    59.1 --- a/extras/mini-os/include/gnttab.h	Fri Aug 29 15:47:21 2008 -0700
    59.2 +++ b/extras/mini-os/include/gnttab.h	Tue Sep 02 16:34:53 2008 -0700
    59.3 @@ -11,5 +11,6 @@ grant_ref_t gnttab_grant_transfer(domid_
    59.4  unsigned long gnttab_end_transfer(grant_ref_t gref);
    59.5  int gnttab_end_access(grant_ref_t ref);
    59.6  const char *gnttabop_error(int16_t status);
    59.7 +void fini_gnttab(void);
    59.8  
    59.9  #endif /* !__GNTTAB_H__ */
    60.1 --- a/extras/mini-os/include/hypervisor.h	Fri Aug 29 15:47:21 2008 -0700
    60.2 +++ b/extras/mini-os/include/hypervisor.h	Tue Sep 02 16:34:53 2008 -0700
    60.3 @@ -13,7 +13,7 @@
    60.4  #ifndef _HYPERVISOR_H_
    60.5  #define _HYPERVISOR_H_
    60.6  
    60.7 -#include <types.h>
    60.8 +#include <mini-os/types.h>
    60.9  #include <xen/xen.h>
   60.10  #if defined(__i386__)
   60.11  #include <hypercall-x86_32.h>
   60.12 @@ -24,7 +24,7 @@
   60.13  #else
   60.14  #error "Unsupported architecture"
   60.15  #endif
   60.16 -#include <traps.h>
   60.17 +#include <mini-os/traps.h>
   60.18  
   60.19  /*
   60.20   * a placeholder for the start of day information passed up from the hypervisor
    61.1 --- a/extras/mini-os/include/ia64/arch_spinlock.h	Fri Aug 29 15:47:21 2008 -0700
    61.2 +++ b/extras/mini-os/include/ia64/arch_spinlock.h	Tue Sep 02 16:34:53 2008 -0700
    61.3 @@ -27,7 +27,7 @@
    61.4  
    61.5  #include "atomic.h"
    61.6  
    61.7 -#define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
    61.8 +#define ARCH_SPIN_LOCK_UNLOCKED { 0 }
    61.9  
   61.10  #define SPIN_LOCK_UNUSED	0
   61.11  #define SPIN_LOCK_USED		1
    62.1 --- a/extras/mini-os/include/ia64/atomic.h	Fri Aug 29 15:47:21 2008 -0700
    62.2 +++ b/extras/mini-os/include/ia64/atomic.h	Tue Sep 02 16:34:53 2008 -0700
    62.3 @@ -38,7 +38,7 @@
    62.4  
    62.5  #if !defined(__ASSEMBLY__)
    62.6  
    62.7 -#include <types.h>
    62.8 +#include <mini-os/types.h>
    62.9  
   62.10  
   62.11  /*
    63.1 --- a/extras/mini-os/include/ia64/efi.h	Fri Aug 29 15:47:21 2008 -0700
    63.2 +++ b/extras/mini-os/include/ia64/efi.h	Tue Sep 02 16:34:53 2008 -0700
    63.3 @@ -32,7 +32,7 @@
    63.4  #ifndef _EFI_H_
    63.5  #define _EFI_H_
    63.6  
    63.7 -#include "types.h"
    63.8 +#include <mini-os/types.h>
    63.9  
   63.10  
   63.11  #define EFIWARN(a)                      (a)
   63.12 @@ -323,7 +323,7 @@ typedef efi_status_t (*efi_get_next_high
   63.13   * EFI Runtime Serivces Table
   63.14   */
   63.15  
   63.16 -#define EFI_RUNTIME_SERVICES_SIGNATURE  0x56524553544e5552
   63.17 +#define EFI_RUNTIME_SERVICES_SIGNATURE  0x5652453544e5552ULL
   63.18  #define EFI_RUNTIME_SERVICES_REVISION ((EFI_SPECIFICATION_MAJOR_REVISION<<16) \
   63.19  					| (EFI_SPECIFICATION_MINOR_REVISION))
   63.20  
    64.1 --- a/extras/mini-os/include/ia64/endian.h	Fri Aug 29 15:47:21 2008 -0700
    64.2 +++ b/extras/mini-os/include/ia64/endian.h	Tue Sep 02 16:34:53 2008 -0700
    64.3 @@ -26,7 +26,7 @@
    64.4  #if !defined(_ENDIAN_H_)
    64.5  #define _ENDIAN_H_
    64.6  
    64.7 -#include "types.h"
    64.8 +#include <mini-os/types.h>
    64.9  
   64.10  
   64.11  #if !defined(__ASSEMBLY__)
    65.1 --- a/extras/mini-os/include/ia64/hypercall-ia64.h	Fri Aug 29 15:47:21 2008 -0700
    65.2 +++ b/extras/mini-os/include/ia64/hypercall-ia64.h	Tue Sep 02 16:34:53 2008 -0700
    65.3 @@ -34,8 +34,8 @@
    65.4  #ifndef __HYPERCALL_H__
    65.5  #define __HYPERCALL_H__
    65.6  
    65.7 -#include "lib.h"	/* memcpy() */
    65.8 -#include "errno.h"	/* ENOSYS() */
    65.9 +#include <mini-os/lib.h>	/* memcpy() */
   65.10 +#include <mini-os/errno.h>	/* ENOSYS() */
   65.11  #include <xen/event_channel.h>
   65.12  #include <xen/sched.h>
   65.13  #include <xen/version.h>
    66.1 --- a/extras/mini-os/include/ia64/os.h	Fri Aug 29 15:47:21 2008 -0700
    66.2 +++ b/extras/mini-os/include/ia64/os.h	Tue Sep 02 16:34:53 2008 -0700
    66.3 @@ -27,14 +27,15 @@
    66.4  
    66.5  #if !defined(__ASSEMBLY__)
    66.6  
    66.7 -#include "types.h"
    66.8 +#include <mini-os/types.h>
    66.9  #include "endian.h"
   66.10  #include "ia64_cpu.h"
   66.11  #include "atomic.h"
   66.12  #include "efi.h"
   66.13  #include "sal.h"
   66.14  #include "pal.h"
   66.15 -#include "hypervisor.h"
   66.16 +#include <mini-os/hypervisor.h>
   66.17 +#include <mini-os/kernel.h>
   66.18  
   66.19  
   66.20  typedef uint64_t paddr_t;		/* Physical address. */
   66.21 @@ -46,9 +47,9 @@ typedef uint64_t caddr_t;		/* rr7/kernel
   66.22  #include "mm.h"
   66.23  
   66.24  
   66.25 -void do_exit(void) __attribute__((noreturn));
   66.26  void arch_init(start_info_t *si);	/* in common.c */
   66.27  void arch_print_info(void);		/* in common.c */
   66.28 +void arch_fini(void);
   66.29  
   66.30  
   66.31  /* Size of xen_ia64_boot_param.command_line */
    67.1 --- a/extras/mini-os/include/ia64/traps.h	Fri Aug 29 15:47:21 2008 -0700
    67.2 +++ b/extras/mini-os/include/ia64/traps.h	Tue Sep 02 16:34:53 2008 -0700
    67.3 @@ -38,11 +38,17 @@ inline static void trap_init(void)
    67.4  {
    67.5  	//printk("trap_init() until now not needed!\n");
    67.6  }
    67.7 +inline static void trap_fini(void)
    67.8 +{
    67.9 +	//printk("trap_fini() until now not needed!\n");
   67.10 +}
   67.11  
   67.12  
   67.13  #endif /* !defined(__ASSEMBLY__) */
   67.14  
   67.15  #include "ia64_cpu.h"
   67.16  
   67.17 +void stack_walk(void);
   67.18 +
   67.19  #endif /* !defined(_TRAPS_H_) */
   67.20  
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/extras/mini-os/include/kernel.h	Tue Sep 02 16:34:53 2008 -0700
    68.3 @@ -0,0 +1,7 @@
    68.4 +#ifndef _KERNEL_H_
    68.5 +#define _KERNEL_H_
    68.6 +
    68.7 +extern void do_exit(void) __attribute__((noreturn));
    68.8 +extern void stop_kernel(void);
    68.9 +
   68.10 +#endif /* _KERNEL_H_ */
    69.1 --- a/extras/mini-os/include/lib.h	Fri Aug 29 15:47:21 2008 -0700
    69.2 +++ b/extras/mini-os/include/lib.h	Tue Sep 02 16:34:53 2008 -0700
    69.3 @@ -59,6 +59,7 @@
    69.4  #include <stddef.h>
    69.5  #include <xen/xen.h>
    69.6  #include <xen/event_channel.h>
    69.7 +#include "gntmap.h"
    69.8  
    69.9  #ifdef HAVE_LIBC
   69.10  #include <stdio.h>
   69.11 @@ -99,13 +100,13 @@ char  *strstr(const char *s1, const char
   69.12  char * strcat(char * dest, const char * src);
   69.13  char  *strdup(const char *s);
   69.14  #endif
   69.15 -#include <console.h>
   69.16 +#include <mini-os/console.h>
   69.17  
   69.18  #define RAND_MIX 2654435769U
   69.19  
   69.20  int rand(void);
   69.21  
   69.22 -#include <xenbus.h>
   69.23 +#include <mini-os/xenbus.h>
   69.24  
   69.25  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
   69.26  
   69.27 @@ -136,7 +137,9 @@ enum fd_type {
   69.28      FTYPE_CONSOLE,
   69.29      FTYPE_FILE,
   69.30      FTYPE_XENBUS,
   69.31 +    FTYPE_XC,
   69.32      FTYPE_EVTCHN,
   69.33 +    FTYPE_GNTMAP,
   69.34      FTYPE_SOCKET,
   69.35      FTYPE_TAP,
   69.36      FTYPE_BLK,
   69.37 @@ -167,6 +170,7 @@ extern struct file {
   69.38                  int bound;
   69.39              } ports[MAX_EVTCHN_PORTS];
   69.40  	} evtchn;
   69.41 +	struct gntmap gntmap;
   69.42  	struct {
   69.43  	    struct netfront_dev *dev;
   69.44  	} tap;
    70.1 --- a/extras/mini-os/include/linux/types.h	Fri Aug 29 15:47:21 2008 -0700
    70.2 +++ b/extras/mini-os/include/linux/types.h	Tue Sep 02 16:34:53 2008 -0700
    70.3 @@ -1,5 +1,5 @@
    70.4  #ifndef _LINUX_TYPES_H_
    70.5  #define _LINUX_TYPES_H_
    70.6 -#include <types.h>
    70.7 +#include <mini-os/types.h>
    70.8  typedef u64 __u64;
    70.9  #endif /* _LINUX_TYPES_H_ */
    71.1 --- a/extras/mini-os/include/list.h	Fri Aug 29 15:47:21 2008 -0700
    71.2 +++ b/extras/mini-os/include/list.h	Tue Sep 02 16:34:53 2008 -0700
    71.3 @@ -11,28 +11,34 @@
    71.4   * using the generic single-entry routines.
    71.5   */
    71.6  
    71.7 -struct list_head {
    71.8 -	struct list_head *next, *prev;
    71.9 +struct minios_list_head {
   71.10 +	struct minios_list_head *next, *prev;
   71.11  };
   71.12  
   71.13 -#define LIST_HEAD_INIT(name) { &(name), &(name) }
   71.14 +#define MINIOS_LIST_HEAD_INIT(name) { &(name), &(name) }
   71.15  
   71.16 -#define LIST_HEAD(name) \
   71.17 -	struct list_head name = LIST_HEAD_INIT(name)
   71.18 +#define MINIOS_LIST_HEAD(name) \
   71.19 +	struct minios_list_head name = MINIOS_LIST_HEAD_INIT(name)
   71.20  
   71.21 -#define INIT_LIST_HEAD(ptr) do { \
   71.22 +#define MINIOS_INIT_LIST_HEAD(ptr) do { \
   71.23  	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
   71.24  } while (0)
   71.25  
   71.26 +#define minios_list_top(head, type, member)					  \
   71.27 +({ 									  \
   71.28 +	struct minios_list_head *_head = (head);				  \
   71.29 +	minios_list_empty(_head) ? NULL : minios_list_entry(_head->next, type, member); \
   71.30 +})
   71.31 +
   71.32  /*
   71.33   * Insert a new entry between two known consecutive entries. 
   71.34   *
   71.35   * This is only for internal list manipulation where we know
   71.36   * the prev/next entries already!
   71.37   */
   71.38 -static __inline__ void __list_add(struct list_head * new,
   71.39 -	struct list_head * prev,
   71.40 -	struct list_head * next)
   71.41 +static __inline__ void __minios_list_add(struct minios_list_head * new,
   71.42 +	struct minios_list_head * prev,
   71.43 +	struct minios_list_head * next)
   71.44  {
   71.45  	next->prev = new;
   71.46  	new->next = next;
   71.47 @@ -41,29 +47,29 @@ static __inline__ void __list_add(struct
   71.48  }
   71.49  
   71.50  /**
   71.51 - * list_add - add a new entry
   71.52 + * minios_list_add - add a new entry
   71.53   * @new: new entry to be added
   71.54   * @head: list head to add it after
   71.55   *
   71.56   * Insert a new entry after the specified head.
   71.57   * This is good for implementing stacks.
   71.58   */
   71.59 -static __inline__ void list_add(struct list_head *new, struct list_head *head)
   71.60 +static __inline__ void minios_list_add(struct minios_list_head *new, struct minios_list_head *head)
   71.61  {
   71.62 -	__list_add(new, head, head->next);
   71.63 +	__minios_list_add(new, head, head->next);
   71.64  }
   71.65  
   71.66  /**
   71.67 - * list_add_tail - add a new entry
   71.68 + * minios_list_add_tail - add a new entry
   71.69   * @new: new entry to be added
   71.70   * @head: list head to add it before
   71.71   *
   71.72   * Insert a new entry before the specified head.
   71.73   * This is useful for implementing queues.
   71.74   */
   71.75 -static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
   71.76 +static __inline__ void minios_list_add_tail(struct minios_list_head *new, struct minios_list_head *head)
   71.77  {
   71.78 -	__list_add(new, head->prev, head);
   71.79 +	__minios_list_add(new, head->prev, head);
   71.80  }
   71.81  
   71.82  /*
   71.83 @@ -73,54 +79,54 @@ static __inline__ void list_add_tail(str
   71.84   * This is only for internal list manipulation where we know
   71.85   * the prev/next entries already!
   71.86   */
   71.87 -static __inline__ void __list_del(struct list_head * prev,
   71.88 -				  struct list_head * next)
   71.89 +static __inline__ void __minios_list_del(struct minios_list_head * prev,
   71.90 +				  struct minios_list_head * next)
   71.91  {
   71.92  	next->prev = prev;
   71.93  	prev->next = next;
   71.94  }
   71.95  
   71.96  /**
   71.97 - * list_del - deletes entry from list.
   71.98 + * minios_list_del - deletes entry from list.
   71.99   * @entry: the element to delete from the list.
  71.100 - * Note: list_empty on entry does not return true after this, the entry is in an undefined state.
  71.101 + * Note: minios_list_empty on entry does not return true after this, the entry is in an undefined state.
  71.102   */
  71.103 -static __inline__ void list_del(struct list_head *entry)
  71.104 +static __inline__ void minios_list_del(struct minios_list_head *entry)
  71.105  {
  71.106 -	__list_del(entry->prev, entry->next);
  71.107 +	__minios_list_del(entry->prev, entry->next);
  71.108  }
  71.109  
  71.110  /**
  71.111 - * list_del_init - deletes entry from list and reinitialize it.
  71.112 + * minios_list_del_init - deletes entry from list and reinitialize it.
  71.113   * @entry: the element to delete from the list.
  71.114   */
  71.115 -static __inline__ void list_del_init(struct list_head *entry)
  71.116 +static __inline__ void minios_list_del_init(struct minios_list_head *entry)
  71.117  {
  71.118 -	__list_del(entry->prev, entry->next);
  71.119 -	INIT_LIST_HEAD(entry); 
  71.120 +	__minios_list_del(entry->prev, entry->next);
  71.121 +	MINIOS_INIT_LIST_HEAD(entry); 
  71.122  }
  71.123  
  71.124  /**
  71.125 - * list_empty - tests whether a list is empty
  71.126 + * minios_list_empty - tests whether a list is empty
  71.127   * @head: the list to test.
  71.128   */
  71.129 -static __inline__ int list_empty(struct list_head *head)
  71.130 +static __inline__ int minios_list_empty(struct minios_list_head *head)
  71.131  {
  71.132  	return head->next == head;
  71.133  }
  71.134  
  71.135  /**
  71.136 - * list_splice - join two lists
  71.137 + * minios_list_splice - join two lists
  71.138   * @list: the new list to add.
  71.139   * @head: the place to add it in the first list.
  71.140   */
  71.141 -static __inline__ void list_splice(struct list_head *list, struct list_head *head)
  71.142 +static __inline__ void minios_list_splice(struct minios_list_head *list, struct minios_list_head *head)
  71.143  {
  71.144 -	struct list_head *first = list->next;
  71.145 +	struct minios_list_head *first = list->next;
  71.146  
  71.147  	if (first != list) {
  71.148 -		struct list_head *last = list->prev;
  71.149 -		struct list_head *at = head->next;
  71.150 +		struct minios_list_head *last = list->prev;
  71.151 +		struct minios_list_head *at = head->next;
  71.152  
  71.153  		first->prev = head;
  71.154  		head->next = first;
  71.155 @@ -131,54 +137,54 @@ static __inline__ void list_splice(struc
  71.156  }
  71.157  
  71.158  /**
  71.159 - * list_entry - get the struct for this entry
  71.160 - * @ptr:	the &struct list_head pointer.
  71.161 + * minios_list_entry - get the struct for this entry
  71.162 + * @ptr:	the &struct minios_list_head pointer.
  71.163   * @type:	the type of the struct this is embedded in.
  71.164 - * @member:	the name of the list_struct within the struct.
  71.165 + * @member:	the name of the minios_list_struct within the struct.
  71.166   */
  71.167 -#define list_entry(ptr, type, member) \
  71.168 +#define minios_list_entry(ptr, type, member) \
  71.169  	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
  71.170  
  71.171  /**
  71.172 - * list_for_each	-	iterate over a list
  71.173 - * @pos:	the &struct list_head to use as a loop counter.
  71.174 + * minios_list_for_each	-	iterate over a list
  71.175 + * @pos:	the &struct minios_list_head to use as a loop counter.
  71.176   * @head:	the head for your list.
  71.177   */
  71.178 -#define list_for_each(pos, head) \
  71.179 +#define minios_list_for_each(pos, head) \
  71.180  	for (pos = (head)->next; pos != (head); pos = pos->next)
  71.181          	
  71.182  /**
  71.183 - * list_for_each_safe	-	iterate over a list safe against removal of list entry
  71.184 - * @pos:	the &struct list_head to use as a loop counter.
  71.185 - * @n:		another &struct list_head to use as temporary storage
  71.186 + * minios_list_for_each_safe	-	iterate over a list safe against removal of list entry
  71.187 + * @pos:	the &struct minios_list_head to use as a loop counter.
  71.188 + * @n:		another &struct minios_list_head to use as temporary storage
  71.189   * @head:	the head for your list.
  71.190   */
  71.191 -#define list_for_each_safe(pos, n, head) \
  71.192 +#define minios_list_for_each_safe(pos, n, head) \
  71.193  	for (pos = (head)->next, n = pos->next; pos != (head); \
  71.194  		pos = n, n = pos->next)
  71.195  
  71.196  /**
  71.197 - * list_for_each_entry	-	iterate over list of given type
  71.198 + * minios_list_for_each_entry	-	iterate over list of given type
  71.199   * @pos:	the type * to use as a loop counter.
  71.200   * @head:	the head for your list.
  71.201 - * @member:	the name of the list_struct within the struct.
  71.202 + * @member:	the name of the minios_list_struct within the struct.
  71.203   */
  71.204 -#define list_for_each_entry(pos, head, member)				\
  71.205 -	for (pos = list_entry((head)->next, typeof(*pos), member);	\
  71.206 +#define minios_list_for_each_entry(pos, head, member)				\
  71.207 +	for (pos = minios_list_entry((head)->next, typeof(*pos), member);	\
  71.208  	     &pos->member != (head); 					\
  71.209 -	     pos = list_entry(pos->member.next, typeof(*pos), member))
  71.210 +	     pos = minios_list_entry(pos->member.next, typeof(*pos), member))
  71.211  
  71.212  /**
  71.213 - * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  71.214 + * minios_list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  71.215   * @pos:	the type * to use as a loop counter.
  71.216   * @n:		another type * to use as temporary storage
  71.217   * @head:	the head for your list.
  71.218 - * @member:	the name of the list_struct within the struct.
  71.219 + * @member:	the name of the minios_list_struct within the struct.
  71.220   */
  71.221 -#define list_for_each_entry_safe(pos, n, head, member)			\
  71.222 -	for (pos = list_entry((head)->next, typeof(*pos), member),	\
  71.223 -		n = list_entry(pos->member.next, typeof(*pos), member);	\
  71.224 +#define minios_list_for_each_entry_safe(pos, n, head, member)			\
  71.225 +	for (pos = minios_list_entry((head)->next, typeof(*pos), member),	\
  71.226 +		n = minios_list_entry(pos->member.next, typeof(*pos), member);	\
  71.227  	     &pos->member != (head); 					\
  71.228 -	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
  71.229 +	     pos = n, n = minios_list_entry(n->member.next, typeof(*n), member))
  71.230  #endif /* _LINUX_LIST_H */
  71.231  
    72.1 --- a/extras/mini-os/include/lwipopts.h	Fri Aug 29 15:47:21 2008 -0700
    72.2 +++ b/extras/mini-os/include/lwipopts.h	Tue Sep 02 16:34:53 2008 -0700
    72.3 @@ -15,6 +15,7 @@
    72.4  #define LWIP_DHCP 1
    72.5  #define LWIP_COMPAT_SOCKETS 0
    72.6  #define LWIP_IGMP 1
    72.7 +#define LWIP_USE_HEAP_FROM_INTERRUPT 1
    72.8  #define MEMP_NUM_SYS_TIMEOUT 10
    72.9  #define TCP_SND_BUF 3000
   72.10  #define TCP_MSS 1500
    73.1 --- a/extras/mini-os/include/mm.h	Fri Aug 29 15:47:21 2008 -0700
    73.2 +++ b/extras/mini-os/include/mm.h	Tue Sep 02 16:34:53 2008 -0700
    73.3 @@ -35,10 +35,10 @@
    73.4  #error "Unsupported architecture"
    73.5  #endif
    73.6  
    73.7 -#include <lib.h>
    73.8 +#include <mini-os/lib.h>
    73.9  
   73.10 -#include <arch_limits.h>
   73.11 -#include <arch_mm.h>
   73.12 +#include <mini-os/arch_limits.h>
   73.13 +#include <mini-os/arch_mm.h>
   73.14  
   73.15  #define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER
   73.16  #define STACK_SIZE __STACK_SIZE
   73.17 @@ -63,14 +63,19 @@ void arch_init_demand_mapping_area(unsig
   73.18  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
   73.19  void arch_init_p2m(unsigned long max_pfn_p);
   73.20  
   73.21 +unsigned long allocate_ondemand(unsigned long n, unsigned long alignment);
   73.22  /* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */
   73.23  void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
   73.24  	unsigned long increment, unsigned long alignment, domid_t id,
   73.25  	int may_fail, unsigned long prot);
   73.26 +void do_map_frames(unsigned long addr,
   73.27 +        unsigned long *f, unsigned long n, unsigned long stride,
   73.28 +	unsigned long increment, domid_t id, int may_fail, unsigned long prot);
   73.29  #ifdef HAVE_LIBC
   73.30  extern unsigned long heap, brk, heap_mapped, heap_end;
   73.31  #endif
   73.32  
   73.33  int free_physical_pages(xen_pfn_t *mfns, int n);
   73.34 +void fini_mm(void);
   73.35  
   73.36  #endif /* _MM_H_ */
    74.1 --- a/extras/mini-os/include/netfront.h	Fri Aug 29 15:47:21 2008 -0700
    74.2 +++ b/extras/mini-os/include/netfront.h	Tue Sep 02 16:34:53 2008 -0700
    74.3 @@ -1,4 +1,4 @@
    74.4 -#include <wait.h>
    74.5 +#include <mini-os/wait.h>
    74.6  #ifdef HAVE_LWIP
    74.7  #include <lwip/netif.h>
    74.8  #endif
    74.9 @@ -18,6 +18,7 @@ extern struct wait_queue_head netfront_q
   74.10   * N.B. _must_ be called from a thread; it's not safe to call this from 
   74.11   * app_main(). */
   74.12  void start_networking(void);
   74.13 +void stop_networking(void);
   74.14  
   74.15  void networking_set_addr(struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw);
   74.16  #endif
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/extras/mini-os/include/pcifront.h	Tue Sep 02 16:34:53 2008 -0700
    75.3 @@ -0,0 +1,28 @@
    75.4 +#include <mini-os/types.h>
    75.5 +#include <xen/io/pciif.h>
    75.6 +struct pcifront_dev;
    75.7 +struct pcifront_dev *init_pcifront(char *nodename);
    75.8 +void pcifront_op(struct pcifront_dev *dev, struct xen_pci_op *op);
    75.9 +void pcifront_scan(struct pcifront_dev *dev, void (*fun)(unsigned int domain, unsigned int bus, unsigned slot, unsigned int fun));
   75.10 +int pcifront_conf_read(struct pcifront_dev *dev,
   75.11 +                       unsigned int dom,
   75.12 +                       unsigned int bus, unsigned int slot, unsigned long fun,
   75.13 +                       unsigned int off, unsigned int size, unsigned int *val);
   75.14 +int pcifront_conf_write(struct pcifront_dev *dev,
   75.15 +                        unsigned int dom,
   75.16 +                        unsigned int bus, unsigned int slot, unsigned long fun,
   75.17 +                        unsigned int off, unsigned int size, unsigned int val);
   75.18 +int pcifront_enable_msi(struct pcifront_dev *dev,
   75.19 +                        unsigned int dom,
   75.20 +                        unsigned int bus, unsigned int slot, unsigned long fun);
   75.21 +int pcifront_disable_msi(struct pcifront_dev *dev,
   75.22 +                         unsigned int dom,
   75.23 +                         unsigned int bus, unsigned int slot, unsigned long fun);
   75.24 +int pcifront_enable_msix(struct pcifront_dev *dev,
   75.25 +                         unsigned int dom,
   75.26 +                         unsigned int bus, unsigned int slot, unsigned long fun,
   75.27 +                         struct xen_msix_entry *entries, int n);
   75.28 +int pcifront_disable_msix(struct pcifront_dev *dev,
   75.29 +                          unsigned int dom,
   75.30 +                          unsigned int bus, unsigned int slot, unsigned long fun);
   75.31 +void shutdown_pcifront(struct pcifront_dev *dev);
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/extras/mini-os/include/posix/fcntl.h	Tue Sep 02 16:34:53 2008 -0700
    76.3 @@ -0,0 +1,11 @@
    76.4 +#ifndef _POSIX_FCNTL_H
    76.5 +#define _POSIX_FCNTL_H
    76.6 +
    76.7 +#include_next <fcntl.h>
    76.8 +
    76.9 +#define F_ULOCK 0
   76.10 +#define F_LOCK  1
   76.11 +#define F_TLOCK 2
   76.12 +#define F_TEST  3
   76.13 +
   76.14 +#endif /* _POSIX_FCNTL_H */
    77.1 --- a/extras/mini-os/include/posix/limits.h	Fri Aug 29 15:47:21 2008 -0700
    77.2 +++ b/extras/mini-os/include/posix/limits.h	Tue Sep 02 16:34:53 2008 -0700
    77.3 @@ -1,9 +1,46 @@
    77.4  #ifndef _POSIX_LIMITS_H
    77.5  #define _POSIX_LIMITS_H
    77.6  
    77.7 -#include_next <limits.h>
    77.8 -#include <arch_limits.h>
    77.9 +#include <mini-os/arch_limits.h>
   77.10 +
   77.11 +#define CHAR_BIT        8
   77.12 +
   77.13 +#define SCHAR_MAX       0x7f
   77.14 +#define SCHAR_MIN       (-SCHAR_MAX-1)
   77.15 +#define UCHAR_MAX       0xff
   77.16 +
   77.17 +#ifdef __CHAR_UNSIGNED__
   77.18 +# define CHAR_MIN       0
   77.19 +# define CHAR_MAX       UCHAR_MAX
   77.20 +#else
   77.21 +# define CHAR_MIN       SCHAR_MIN
   77.22 +# define CHAR_MAX       SCHAR_MAX
   77.23 +#endif
   77.24 +
   77.25 +#define INT_MAX         0x7fffffff
   77.26 +#define INT_MIN         (-INT_MAX-1)
   77.27 +#define UINT_MAX        0xffffffff
   77.28 +
   77.29 +#define SHRT_MAX        0x7fff
   77.30 +
   77.31 +#if defined(__x86_64__) || defined(__ia64__)
   77.32 +# define LONG_MAX       0x7fffffffffffffffL
   77.33 +# define ULONG_MAX      0xffffffffffffffffUL
   77.34 +#else
   77.35 +# define LONG_MAX       0x7fffffffL
   77.36 +# define ULONG_MAX      0xffffffffUL
   77.37 +#endif
   77.38 +#define LONG_MIN        (-LONG_MAX-1L)
   77.39 +
   77.40 +#define LLONG_MAX       0x7fffffffffffffffLL
   77.41 +#define LLONG_MIN       (-LLONG_MAX-1LL)
   77.42 +#define ULLONG_MAX      0xffffffffffffffffULL
   77.43 +
   77.44 +#define LONG_LONG_MIN   LLONG_MIN
   77.45 +#define LONG_LONG_MAX   LLONG_MAX
   77.46 +#define ULONG_LONG_MAX  ULLONG_MAX
   77.47  
   77.48  #define PATH_MAX __PAGE_SIZE
   77.49 +#define PAGE_SIZE __PAGE_SIZE
   77.50  
   77.51  #endif /* _POSIX_LIMITS_H */
    78.1 --- a/extras/mini-os/include/posix/pthread.h	Fri Aug 29 15:47:21 2008 -0700
    78.2 +++ b/extras/mini-os/include/posix/pthread.h	Tue Sep 02 16:34:53 2008 -0700
    78.3 @@ -1,18 +1,56 @@
    78.4  #ifndef _POSIX_PTHREAD_H
    78.5  #define _POSIX_PTHREAD_H
    78.6  
    78.7 +#include <stdlib.h>
    78.8 +
    78.9  /* Let's be single-threaded for now.  */
   78.10  
   78.11 -typedef void *pthread_key_t;
   78.12 -typedef struct {} pthread_mutex_t, pthread_once_t;
   78.13 +typedef struct {
   78.14 +    void *ptr;
   78.15 +} *pthread_key_t;
   78.16 +static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*))
   78.17 +{
   78.18 +    *key = malloc(sizeof(**key));
   78.19 +    (*key)->ptr = NULL;
   78.20 +    return 0;
   78.21 +}
   78.22 +static inline int pthread_setspecific(pthread_key_t key, const void *pointer)
   78.23 +{
   78.24 +    key->ptr = (void*) pointer;
   78.25 +    return 0;
   78.26 +}
   78.27 +static inline void *pthread_getspecific(pthread_key_t key)
   78.28 +{
   78.29 +    return key->ptr;
   78.30 +}
   78.31 +static inline int pthread_key_delete(pthread_key_t key)
   78.32 +{
   78.33 +    free(key);
   78.34 +    return 0;
   78.35 +}
   78.36 +
   78.37 +
   78.38 +
   78.39 +typedef struct {} pthread_mutex_t;
   78.40  #define PTHREAD_MUTEX_INITIALIZER {}
   78.41 -#define PTHREAD_ONCE_INIT {}
   78.42  static inline int pthread_mutex_lock(pthread_mutex_t *mutex) { return 0; }
   78.43  static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) { return 0; }
   78.44 -static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*)) { *key = NULL; return 0; }
   78.45 -static inline int pthread_setspecific(pthread_key_t *key, const void *pointer) { *key = (void*) pointer; return 0; }
   78.46 -static inline void *pthread_getspecific(pthread_key_t *key) { return *key; }
   78.47 -static inline int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) { init_routine(); return 0; }
   78.48 +
   78.49 +
   78.50 +
   78.51 +typedef struct {
   78.52 +    int done;
   78.53 +} pthread_once_t;
   78.54 +#define PTHREAD_ONCE_INIT { 0 }
   78.55 +
   78.56 +static inline int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
   78.57 +{
   78.58 +    if (!once_control->done) {
   78.59 +        once_control->done = 1;
   78.60 +        init_routine();
   78.61 +    }
   78.62 +    return 0;
   78.63 +}
   78.64  
   78.65  #define __thread
   78.66  
    79.1 --- a/extras/mini-os/include/posix/sys/mman.h	Fri Aug 29 15:47:21 2008 -0700
    79.2 +++ b/extras/mini-os/include/posix/sys/mman.h	Tue Sep 02 16:34:53 2008 -0700
    79.3 @@ -9,9 +9,12 @@
    79.4  #define MAP_PRIVATE	0x02
    79.5  #define MAP_ANON	0x20
    79.6  
    79.7 +/* Pages are always resident anyway */
    79.8 +#define MAP_LOCKED	0x0
    79.9 +
   79.10  #define MAP_FAILED	((void*)0)
   79.11  
   79.12 -void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
   79.13 +void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) asm("mmap64");
   79.14  int munmap(void *start, size_t length);
   79.15  #define munlock(addr, len) ((void)addr, (void)len, 0)
   79.16  #define mlock(addr, len) ((void)addr, (void)len, 0)
    80.1 --- a/extras/mini-os/include/posix/sys/select.h	Fri Aug 29 15:47:21 2008 -0700
    80.2 +++ b/extras/mini-os/include/posix/sys/select.h	Tue Sep 02 16:34:53 2008 -0700
    80.3 @@ -2,6 +2,7 @@
    80.4  #define _POSIX_SELECT_H
    80.5  
    80.6  #include <sys/time.h>
    80.7 +#include <lwip/sockets.h>
    80.8  int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
    80.9  
   80.10  #endif /* _POSIX_SELECT_H */
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/extras/mini-os/include/posix/sys/stat.h	Tue Sep 02 16:34:53 2008 -0700
    81.3 @@ -0,0 +1,7 @@
    81.4 +#ifndef _POSIX_SYS_STAT_H
    81.5 +#define _POSIX_SYS_STAT_H
    81.6 +
    81.7 +#include_next <sys/stat.h>
    81.8 +int fstat(int fd, struct stat *buf) asm("fstat64");
    81.9 +
   81.10 +#endif /* _POSIX_SYS_STAT_H */
    82.1 --- a/extras/mini-os/include/posix/unistd.h	Fri Aug 29 15:47:21 2008 -0700
    82.2 +++ b/extras/mini-os/include/posix/unistd.h	Tue Sep 02 16:34:53 2008 -0700
    82.3 @@ -2,11 +2,8 @@
    82.4  #define _POSIX_UNISTD_H
    82.5  
    82.6  #include_next <unistd.h>
    82.7 -#include <sys/select.h>
    82.8 -#include <arch_limits.h>
    82.9  
   82.10 -#define getpagesize() __PAGE_SIZE
   82.11 -
   82.12 +size_t getpagesize(void);
   82.13  int ftruncate(int fd, off_t length);
   82.14  
   82.15  #endif /* _POSIX_UNISTD_H */
    83.1 --- a/extras/mini-os/include/sched.h	Fri Aug 29 15:47:21 2008 -0700
    83.2 +++ b/extras/mini-os/include/sched.h	Tue Sep 02 16:34:53 2008 -0700
    83.3 @@ -1,9 +1,12 @@
    83.4  #ifndef __SCHED_H__
    83.5  #define __SCHED_H__
    83.6  
    83.7 -#include <list.h>
    83.8 -#include <time.h>
    83.9 -#include <arch_sched.h>
   83.10 +#include <mini-os/list.h>
   83.11 +#include <mini-os/time.h>
   83.12 +#include <mini-os/arch_sched.h>
   83.13 +#ifdef HAVE_LIBC
   83.14 +#include <sys/reent.h>
   83.15 +#endif
   83.16  
   83.17  struct thread
   83.18  {
   83.19 @@ -16,7 +19,7 @@ struct thread
   83.20  #else /* !defined(__ia64__) */
   83.21      thread_regs_t regs;
   83.22  #endif /* !defined(__ia64__) */
   83.23 -    struct list_head thread_list;
   83.24 +    struct minios_list_head thread_list;
   83.25      u32 flags;
   83.26      s_time_t wakeup_time;
   83.27  #ifdef HAVE_LIBC
    84.1 --- a/extras/mini-os/include/semaphore.h	Fri Aug 29 15:47:21 2008 -0700
    84.2 +++ b/extras/mini-os/include/semaphore.h	Tue Sep 02 16:34:53 2008 -0700
    84.3 @@ -1,8 +1,8 @@
    84.4  #ifndef _SEMAPHORE_H_
    84.5  #define _SEMAPHORE_H_
    84.6  
    84.7 -#include <wait.h>
    84.8 -#include <spinlock.h>
    84.9 +#include <mini-os/wait.h>
   84.10 +#include <mini-os/spinlock.h>
   84.11  
   84.12  /*
   84.13   * Implementation of semaphore in Mini-os is simple, because 
   84.14 @@ -21,7 +21,7 @@ struct semaphore
   84.15  struct rw_semaphore {
   84.16  	signed long		count;
   84.17  	spinlock_t		wait_lock;
   84.18 -	struct list_head	wait_list;
   84.19 +	struct minios_list_head	wait_list;
   84.20  	int			debug;
   84.21  };
   84.22  
    85.1 --- a/extras/mini-os/include/spinlock.h	Fri Aug 29 15:47:21 2008 -0700
    85.2 +++ b/extras/mini-os/include/spinlock.h	Tue Sep 02 16:34:53 2008 -0700
    85.3 @@ -1,7 +1,7 @@
    85.4  #ifndef __ASM_SPINLOCK_H
    85.5  #define __ASM_SPINLOCK_H
    85.6  
    85.7 -#include <lib.h>
    85.8 +#include <mini-os/lib.h>
    85.9  
   85.10  /*
   85.11   * Your basic SMP spinlocks, allowing only a single CPU anywhere
   85.12 @@ -12,7 +12,7 @@ typedef struct {
   85.13  } spinlock_t;
   85.14  
   85.15  
   85.16 -#include "arch_spinlock.h"
   85.17 +#include <mini-os/arch_spinlock.h>
   85.18  
   85.19  
   85.20  #define SPINLOCK_MAGIC	0xdead4ead
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/extras/mini-os/include/sys/lock.h	Tue Sep 02 16:34:53 2008 -0700
    86.3 @@ -0,0 +1,52 @@
    86.4 +#ifndef _MINIOS_SYS_LOCK_H_
    86.5 +#define _MINIOS_SYS_LOCK_H_
    86.6 +
    86.7 +#ifdef HAVE_LIBC
    86.8 +
    86.9 +/* Due to inclusion loop, we can not include sched.h, so have to hide things */
   86.10 +
   86.11 +#include <mini-os/waittypes.h>
   86.12 +
   86.13 +
   86.14 +typedef struct {
   86.15 +        int busy;
   86.16 +        struct wait_queue_head wait;
   86.17 +} _LOCK_T;
   86.18 +
   86.19 +#define __LOCK_INIT(class,lock) \
   86.20 +    class _LOCK_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER(lock.wait) }
   86.21 +int ___lock_init(_LOCK_T *lock);
   86.22 +int ___lock_acquire(_LOCK_T *lock);
   86.23 +int ___lock_try_acquire(_LOCK_T *lock);
   86.24 +int ___lock_release(_LOCK_T *lock);
   86.25 +int ___lock_close(_LOCK_T *lock);
   86.26 +#define __lock_init(__lock) ___lock_init(&__lock)
   86.27 +#define __lock_acquire(__lock) ___lock_acquire(&__lock)
   86.28 +#define __lock_release(__lock) ___lock_release(&__lock)
   86.29 +#define __lock_try_acquire(__lock) ___lock_try_acquire(&__lock)
   86.30 +#define __lock_close(__lock) 0
   86.31 +
   86.32 +
   86.33 +typedef struct {
   86.34 +    struct thread *owner;
   86.35 +    int count;
   86.36 +    struct wait_queue_head wait;
   86.37 +} _LOCK_RECURSIVE_T;
   86.38 +
   86.39 +#define __LOCK_INIT_RECURSIVE(class, lock) \
   86.40 +    class _LOCK_RECURSIVE_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER((lock).wait) }
   86.41 +
   86.42 +int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock);
   86.43 +int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock);
   86.44 +int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock);
   86.45 +int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock);
   86.46 +int ___lock_close_recursive(_LOCK_RECURSIVE_T *lock);
   86.47 +#define __lock_init_recursive(__lock) ___lock_init_recursive(&__lock)
   86.48 +#define __lock_acquire_recursive(__lock) ___lock_acquire_recursive(&__lock)
   86.49 +#define __lock_release_recursive(__lock) ___lock_release_recursive(&__lock)
   86.50 +#define __lock_try_acquire_recursive(__lock) ___lock_try_acquire_recursive(&__lock)
   86.51 +#define __lock_close_recursive(__lock) 0
   86.52 +
   86.53 +#endif
   86.54 +
   86.55 +#endif /* _MINIOS_SYS_LOCK_H_ */
    87.1 --- a/extras/mini-os/include/time.h	Fri Aug 29 15:47:21 2008 -0700
    87.2 +++ b/extras/mini-os/include/time.h	Tue Sep 02 16:34:53 2008 -0700
    87.3 @@ -19,7 +19,7 @@
    87.4  
    87.5  #ifndef _MINIOS_TIME_H_
    87.6  #define _MINIOS_TIME_H_
    87.7 -#include <types.h>
    87.8 +#include <mini-os/types.h>
    87.9  
   87.10  /*
   87.11   * System Time
   87.12 @@ -54,6 +54,7 @@ typedef long suseconds_t;
   87.13  
   87.14  /* prototypes */
   87.15  void     init_time(void);
   87.16 +void     fini_time(void);
   87.17  s_time_t get_s_time(void);
   87.18  s_time_t get_v_time(void);
   87.19  u64      monotonic_clock(void);
    88.1 --- a/extras/mini-os/include/types.h	Fri Aug 29 15:47:21 2008 -0700
    88.2 +++ b/extras/mini-os/include/types.h	Tue Sep 02 16:34:53 2008 -0700
    88.3 @@ -36,9 +36,11 @@ typedef unsigned long       u64;
    88.4  #endif
    88.5  
    88.6  /* FreeBSD compat types */
    88.7 +#ifndef HAVE_LIBC
    88.8  typedef unsigned char       u_char;
    88.9  typedef unsigned int        u_int;
   88.10  typedef unsigned long       u_long;
   88.11 +#endif
   88.12  #ifdef __i386__
   88.13  typedef long long           quad_t;
   88.14  typedef unsigned long long  u_quad_t;
   88.15 @@ -79,11 +81,13 @@ typedef s32 int32_t;
   88.16  typedef u64 uint64_t, uintmax_t;
   88.17  typedef s64 int64_t, intmax_t;
   88.18  typedef u64 off_t;
   88.19 +#endif
   88.20 +
   88.21 +typedef intptr_t            ptrdiff_t;
   88.22  
   88.23  
   88.24 -#define INT_MAX         ((int)(~0U>>1))
   88.25 -#define UINT_MAX            (~0U)
   88.26 -
   88.27 +#ifndef HAVE_LIBC
   88.28  typedef long ssize_t;
   88.29  #endif
   88.30 +
   88.31  #endif /* _TYPES_H_ */
    89.1 --- a/extras/mini-os/include/wait.h	Fri Aug 29 15:47:21 2008 -0700
    89.2 +++ b/extras/mini-os/include/wait.h	Tue Sep 02 16:34:53 2008 -0700
    89.3 @@ -1,70 +1,49 @@
    89.4  #ifndef __WAIT_H__
    89.5  #define __WAIT_H__
    89.6  
    89.7 -#include <sched.h>
    89.8 -#include <list.h>
    89.9 -#include <lib.h>
   89.10 -#include <os.h>
   89.11 -
   89.12 -struct wait_queue
   89.13 -{
   89.14 -    struct thread *thread;
   89.15 -    struct list_head thread_list;
   89.16 -};
   89.17 -
   89.18 -struct wait_queue_head
   89.19 -{
   89.20 -    /* TODO - lock required? */
   89.21 -    struct list_head thread_list;
   89.22 -};
   89.23 -
   89.24 -#define DECLARE_WAIT_QUEUE_HEAD(name) \
   89.25 -   struct wait_queue_head name =     \
   89.26 -        { .thread_list = { &(name).thread_list, &(name).thread_list} }
   89.27 -
   89.28 -#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                           \
   89.29 -    .thread_list      = { &(name).thread_list, &(name).thread_list } }
   89.30 -
   89.31 +#include <mini-os/sched.h>
   89.32 +#include <mini-os/os.h>
   89.33 +#include <mini-os/waittypes.h>
   89.34  
   89.35  #define DEFINE_WAIT(name)                               \
   89.36  struct wait_queue name = {                              \
   89.37      .thread       = current,                            \
   89.38 -    .thread_list  = LIST_HEAD_INIT((name).thread_list), \
   89.39 +    .thread_list  = MINIOS_LIST_HEAD_INIT((name).thread_list), \
   89.40  }
   89.41  
   89.42  
   89.43  static inline void init_waitqueue_head(struct wait_queue_head *h)
   89.44  {
   89.45 -  INIT_LIST_HEAD(&h->thread_list);
   89.46 +  MINIOS_INIT_LIST_HEAD(&h->thread_list);
   89.47  }
   89.48  
   89.49  static inline void init_waitqueue_entry(struct wait_queue *q, struct thread *thread)
   89.50  {
   89.51      q->thread = thread;
   89.52 -    INIT_LIST_HEAD(&q->thread_list);
   89.53 +    MINIOS_INIT_LIST_HEAD(&q->thread_list);
   89.54  }
   89.55  
   89.56  
   89.57  static inline void add_wait_queue(struct wait_queue_head *h, struct wait_queue *q)
   89.58  {
   89.59 -    if (list_empty(&q->thread_list))
   89.60 -        list_add(&q->thread_list, &h->thread_list);   
   89.61 +    if (minios_list_empty(&q->thread_list))
   89.62 +        minios_list_add(&q->thread_list, &h->thread_list);   
   89.63  }
   89.64  
   89.65  static inline void remove_wait_queue(struct wait_queue *q)
   89.66  {
   89.67 -    list_del(&q->thread_list);
   89.68 +    minios_list_del(&q->thread_list);
   89.69  }
   89.70  
   89.71  static inline void wake_up(struct wait_queue_head *head)
   89.72  {
   89.73      unsigned long flags;
   89.74 -    struct list_head *tmp, *next;
   89.75 +    struct minios_list_head *tmp, *next;
   89.76      local_irq_save(flags);
   89.77 -    list_for_each_safe(tmp, next, &head->thread_list)
   89.78 +    minios_list_for_each_safe(tmp, next, &head->thread_list)
   89.79      {
   89.80           struct wait_queue *curr;
   89.81 -         curr = list_entry(tmp, struct wait_queue, thread_list);
   89.82 +         curr = minios_list_entry(tmp, struct wait_queue, thread_list);
   89.83           wake(curr->thread);
   89.84      }
   89.85      local_irq_restore(flags);
   89.86 @@ -87,9 +66,9 @@ static inline void wake_up(struct wait_q
   89.87  
   89.88  #define wait_event_deadline(wq, condition, deadline) do {       \
   89.89      unsigned long flags;                                        \
   89.90 +    DEFINE_WAIT(__wait);                                        \
   89.91      if(condition)                                               \
   89.92          break;                                                  \
   89.93 -    DEFINE_WAIT(__wait);                                        \
   89.94      for(;;)                                                     \
   89.95      {                                                           \
   89.96          /* protect the list */                                  \
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/extras/mini-os/include/waittypes.h	Tue Sep 02 16:34:53 2008 -0700
    90.3 @@ -0,0 +1,26 @@
    90.4 +#ifndef __WAITTYPE_H__
    90.5 +#define __WAITTYPE_H__
    90.6 +
    90.7 +#include <mini-os/list.h>
    90.8 +
    90.9 +struct thread;
   90.10 +struct wait_queue
   90.11 +{
   90.12 +    struct thread *thread;
   90.13 +    struct minios_list_head thread_list;
   90.14 +};
   90.15 +
   90.16 +struct wait_queue_head
   90.17 +{
   90.18 +    /* TODO - lock required? */
   90.19 +    struct minios_list_head thread_list;
   90.20 +};
   90.21 +
   90.22 +#define DECLARE_WAIT_QUEUE_HEAD(name) \
   90.23 +   struct wait_queue_head name =     \
   90.24 +        { .thread_list = { &(name).thread_list, &(name).thread_list} }
   90.25 +
   90.26 +#define __WAIT_QUEUE_HEAD_INITIALIZER(name) {                           \
   90.27 +    .thread_list      = { &(name).thread_list, &(name).thread_list } }
   90.28 +
   90.29 +#endif
    91.1 --- a/extras/mini-os/include/x86/arch_mm.h	Fri Aug 29 15:47:21 2008 -0700
    91.2 +++ b/extras/mini-os/include/x86/arch_mm.h	Tue Sep 02 16:34:53 2008 -0700
    91.3 @@ -109,16 +109,16 @@ typedef unsigned long pgentry_t;
    91.4    (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
    91.5  #endif
    91.6  
    91.7 -#define _PAGE_PRESENT  0x001UL
    91.8 -#define _PAGE_RW       0x002UL
    91.9 -#define _PAGE_USER     0x004UL
   91.10 -#define _PAGE_PWT      0x008UL
   91.11 -#define _PAGE_PCD      0x010UL
   91.12 -#define _PAGE_ACCESSED 0x020UL
   91.13 -#define _PAGE_DIRTY    0x040UL
   91.14 -#define _PAGE_PAT      0x080UL
   91.15 -#define _PAGE_PSE      0x080UL
   91.16 -#define _PAGE_GLOBAL   0x100UL
   91.17 +#define _PAGE_PRESENT  0x001ULL
   91.18 +#define _PAGE_RW       0x002ULL
   91.19 +#define _PAGE_USER     0x004ULL
   91.20 +#define _PAGE_PWT      0x008ULL
   91.21 +#define _PAGE_PCD      0x010ULL
   91.22 +#define _PAGE_ACCESSED 0x020ULL
   91.23 +#define _PAGE_DIRTY    0x040ULL
   91.24 +#define _PAGE_PAT      0x080ULL
   91.25 +#define _PAGE_PSE      0x080ULL
   91.26 +#define _PAGE_GLOBAL   0x100ULL
   91.27  
   91.28  #if defined(__i386__)
   91.29  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
   91.30 @@ -140,7 +140,7 @@ typedef unsigned long pgentry_t;
   91.31  
   91.32  #define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> L1_PAGETABLE_SHIFT)
   91.33  #define PFN_DOWN(x)	((x) >> L1_PAGETABLE_SHIFT)
   91.34 -#define PFN_PHYS(x)	((x) << L1_PAGETABLE_SHIFT)
   91.35 +#define PFN_PHYS(x)	((uint64_t)(x) << L1_PAGETABLE_SHIFT)
   91.36  #define PHYS_PFN(x)	((x) >> L1_PAGETABLE_SHIFT)
   91.37  
   91.38  /* to align the pointer to the (next) page boundary */
   91.39 @@ -219,11 +219,8 @@ static __inline__ paddr_t machine_to_phy
   91.40  
   91.41  #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, L1_PROT)
   91.42  #define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, L1_PROT_RO)
   91.43 -#ifndef __ASSEMBLY__
   91.44 -void do_map_frames(unsigned long addr,
   91.45 -        unsigned long *f, unsigned long n, unsigned long stride,
   91.46 -	unsigned long increment, domid_t id, int may_fail, unsigned long prot);
   91.47 -#endif
   91.48  #define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, 0, L1_PROT_RO)
   91.49  
   91.50 +pgentry_t *need_pgt(unsigned long addr);
   91.51 +
   91.52  #endif /* _ARCH_MM_H_ */
    92.1 --- a/extras/mini-os/include/x86/arch_sched.h	Fri Aug 29 15:47:21 2008 -0700
    92.2 +++ b/extras/mini-os/include/x86/arch_sched.h	Tue Sep 02 16:34:53 2008 -0700
    92.3 @@ -2,7 +2,7 @@
    92.4  #ifndef __ARCH_SCHED_H__
    92.5  #define __ARCH_SCHED_H__
    92.6  
    92.7 -#include <arch_limits.h>
    92.8 +#include "arch_limits.h"
    92.9  
   92.10  static inline struct thread* get_current(void)
   92.11  {
    93.1 --- a/extras/mini-os/include/x86/arch_spinlock.h	Fri Aug 29 15:47:21 2008 -0700
    93.2 +++ b/extras/mini-os/include/x86/arch_spinlock.h	Tue Sep 02 16:34:53 2008 -0700
    93.3 @@ -3,11 +3,11 @@
    93.4  #ifndef __ARCH_ASM_SPINLOCK_H
    93.5  #define __ARCH_ASM_SPINLOCK_H
    93.6  
    93.7 -#include <lib.h>
    93.8 +#include <mini-os/lib.h>
    93.9  #include "os.h"
   93.10  
   93.11  
   93.12 -#define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 1 }
   93.13 +#define ARCH_SPIN_LOCK_UNLOCKED { 1 }
   93.14  
   93.15  /*
   93.16   * Simple spin lock operations.  There are two variants, one clears IRQ's
    94.1 --- a/extras/mini-os/include/x86/os.h	Fri Aug 29 15:47:21 2008 -0700
    94.2 +++ b/extras/mini-os/include/x86/os.h	Tue Sep 02 16:34:53 2008 -0700
    94.3 @@ -16,12 +16,12 @@
    94.4  
    94.5  
    94.6  #ifndef __ASSEMBLY__
    94.7 -#include <types.h>
    94.8 -#include <hypervisor.h>
    94.9 +#include <mini-os/types.h>
   94.10 +#include <mini-os/hypervisor.h>
   94.11 +#include <mini-os/kernel.h>
   94.12  
   94.13  #define USED    __attribute__ ((used))
   94.14  
   94.15 -extern void do_exit(void) __attribute__((noreturn));
   94.16  #define BUG do_exit
   94.17  
   94.18  #endif
   94.19 @@ -61,9 +61,11 @@ extern void do_exit(void) __attribute__(
   94.20  extern shared_info_t *HYPERVISOR_shared_info;
   94.21  
   94.22  void trap_init(void);
   94.23 +void trap_fini(void);
   94.24  
   94.25  void arch_init(start_info_t *si);
   94.26  void arch_print_info(void);
   94.27 +void arch_fini(void);
   94.28  
   94.29  
   94.30  
    95.1 --- a/extras/mini-os/include/x86/traps.h	Fri Aug 29 15:47:21 2008 -0700
    95.2 +++ b/extras/mini-os/include/x86/traps.h	Tue Sep 02 16:34:53 2008 -0700
    95.3 @@ -69,6 +69,7 @@ struct pt_regs {
    95.4  #endif
    95.5  
    95.6  void dump_regs(struct pt_regs *regs);
    95.7 +void stack_walk(void);
    95.8  
    95.9  #define TRAP_PF_PROT   0x1
   95.10  #define TRAP_PF_WRITE  0x2
    96.1 --- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Fri Aug 29 15:47:21 2008 -0700
    96.2 +++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h	Tue Sep 02 16:34:53 2008 -0700
    96.3 @@ -33,7 +33,7 @@
    96.4  #include <xen/xen.h>
    96.5  #include <xen/sched.h>
    96.6  #include <xen/nmi.h>
    96.7 -#include <mm.h>
    96.8 +#include <mini-os/mm.h>
    96.9  
   96.10  #define __STR(x) #x
   96.11  #define STR(x) __STR(x)
    97.1 --- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Fri Aug 29 15:47:21 2008 -0700
    97.2 +++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h	Tue Sep 02 16:34:53 2008 -0700
    97.3 @@ -36,7 +36,7 @@
    97.4  
    97.5  #include <xen/xen.h>
    97.6  #include <xen/sched.h>
    97.7 -#include <mm.h>
    97.8 +#include <mini-os/mm.h>
    97.9  
   97.10  #define __STR(x) #x
   97.11  #define STR(x) __STR(x)
    98.1 --- a/extras/mini-os/include/xenbus.h	Fri Aug 29 15:47:21 2008 -0700
    98.2 +++ b/extras/mini-os/include/xenbus.h	Tue Sep 02 16:34:53 2008 -0700
    98.3 @@ -90,4 +90,7 @@ char* xenbus_printf(xenbus_transaction_t
    98.4                                    char* node, char* path,
    98.5                                    char* fmt, ...);
    98.6  
    98.7 +/* Reset the XenBus system. */
    98.8 +void fini_xenbus(void);
    98.9 +
   98.10  #endif /* XENBUS_H__ */
    99.1 --- a/extras/mini-os/include/xmalloc.h	Fri Aug 29 15:47:21 2008 -0700
    99.2 +++ b/extras/mini-os/include/xmalloc.h	Tue Sep 02 16:34:53 2008 -0700
    99.3 @@ -11,6 +11,8 @@
    99.4  
    99.5  #else
    99.6  
    99.7 +#include <limits.h>
    99.8 +
    99.9  #define DEFAULT_ALIGN (sizeof(unsigned long))
   99.10  #define malloc(size) _xmalloc(size, DEFAULT_ALIGN)
   99.11  #define free(ptr) xfree(ptr)
   100.1 --- a/extras/mini-os/kernel.c	Fri Aug 29 15:47:21 2008 -0700
   100.2 +++ b/extras/mini-os/kernel.c	Tue Sep 02 16:34:53 2008 -0700
   100.3 @@ -40,12 +40,14 @@
   100.4  #include <netfront.h>
   100.5  #include <blkfront.h>
   100.6  #include <fbfront.h>
   100.7 +#include <pcifront.h>
   100.8  #include <fs.h>
   100.9  #include <xmalloc.h>
  100.10  #include <fcntl.h>
  100.11  #include <xen/features.h>
  100.12  #include <xen/version.h>
  100.13  
  100.14 +static struct netfront_dev *net_dev;
  100.15  
  100.16  u8 xen_features[XENFEAT_NR_SUBMAPS * 32];
  100.17  
  100.18 @@ -87,7 +89,7 @@ static void periodic_thread(void *p)
  100.19  
  100.20  static void netfront_thread(void *p)
  100.21  {
  100.22 -    init_netfront(NULL, NULL, NULL, NULL);
  100.23 +    net_dev = init_netfront(NULL, NULL, NULL, NULL);
  100.24  }
  100.25  
  100.26  static struct blkfront_dev *blk_dev;
  100.27 @@ -347,9 +349,9 @@ static void refresh_cursor(int new_x, in
  100.28      fbfront_update(fb_dev, new_x, new_y, 9, 9);
  100.29  }
  100.30  
  100.31 +static struct kbdfront_dev *kbd_dev;
  100.32  static void kbdfront_thread(void *p)
  100.33  {
  100.34 -    struct kbdfront_dev *kbd_dev;
  100.35      DEFINE_WAIT(w);
  100.36      int x = WIDTH / 2, y = HEIGHT / 2, z = 0;
  100.37  
  100.38 @@ -430,6 +432,29 @@ static void kbdfront_thread(void *p)
  100.39      }
  100.40  }
  100.41  
  100.42 +static struct pcifront_dev *pci_dev;
  100.43 +
  100.44 +static void pcifront_thread(void *p)
  100.45 +{
  100.46 +    void print(unsigned int domain, unsigned int bus, unsigned int slot, unsigned int fun)
  100.47 +    {
  100.48 +        unsigned int vendor, device, rev, class;
  100.49 +
  100.50 +        pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x00, 2, &vendor);
  100.51 +        pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x02, 2, &device);
  100.52 +        pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x08, 1, &rev);
  100.53 +        pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x0a, 2, &class);
  100.54 +
  100.55 +        printk("%04x:%02x:%02x.%02x %04x: %04x:%04x (rev %02x)\n", domain, bus, slot, fun, class, vendor, device, rev);
  100.56 +    }
  100.57 +
  100.58 +    pci_dev = init_pcifront(NULL);
  100.59 +    if (!pci_dev)
  100.60 +        return;
  100.61 +    printk("PCI devices:\n");
  100.62 +    pcifront_scan(pci_dev, print);
  100.63 +}
  100.64 +
  100.65  static void fs_thread(void *p)
  100.66  {
  100.67      init_fs_frontend();
  100.68 @@ -445,6 +470,7 @@ static void fs_thread(void *p)
  100.69      create_thread("blkfront", blkfront_thread, si);
  100.70      create_thread("fbfront", fbfront_thread, si);
  100.71      create_thread("kbdfront", kbdfront_thread, si);
  100.72 +    create_thread("pcifront", pcifront_thread, si);
  100.73      create_thread("fs-frontend", fs_thread, si);
  100.74      return 0;
  100.75  }
  100.76 @@ -509,6 +535,52 @@ void start_kernel(start_info_t *si)
  100.77      run_idle_thread();
  100.78  }
  100.79  
  100.80 +void stop_kernel(void)
  100.81 +{
  100.82 +    if (net_dev)
  100.83 +        shutdown_netfront(net_dev);
  100.84 +
  100.85 +    if (blk_dev)
  100.86 +        shutdown_blkfront(blk_dev);
  100.87 +
  100.88 +    if (fb_dev)
  100.89 +        shutdown_fbfront(fb_dev);
  100.90 +
  100.91 +    if (kbd_dev)
  100.92 +        shutdown_kbdfront(kbd_dev);
  100.93 +
  100.94 +    if (pci_dev)
  100.95 +        shutdown_pcifront(pci_dev);
  100.96 +
  100.97 +    /* TODO: fs import */
  100.98 +
  100.99 +    local_irq_disable();
 100.100 +
 100.101 +    /* Reset grant tables */
 100.102 +    fini_gnttab();
 100.103 +
 100.104 +    /* Reset the console driver. */
 100.105 +    fini_console();
 100.106 +    /* TODO: record new ring mfn & event in start_info */
 100.107 +
 100.108 +    /* Reset XenBus */
 100.109 +    fini_xenbus();
 100.110 +
 100.111 +    /* Reset timers */
 100.112 +    fini_time();
 100.113 +
 100.114 +    /* Reset memory management. */
 100.115 +    fini_mm();
 100.116 +
 100.117 +    /* Reset events. */
 100.118 +    fini_events();
 100.119 +
 100.120 +    /* Reset traps */
 100.121 +    trap_fini();
 100.122 +
 100.123 +    /* Reset arch details */
 100.124 +    arch_fini();
 100.125 +}
 100.126  
 100.127  /*
 100.128   * do_exit: This is called whenever an IRET fails in entry.S.
 100.129 @@ -520,6 +592,7 @@ void start_kernel(start_info_t *si)
 100.130  void do_exit(void)
 100.131  {
 100.132      printk("Do_exit called!\n");
 100.133 +    stack_walk();
 100.134      for( ;; )
 100.135      {
 100.136          struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_crash };
   101.1 --- a/extras/mini-os/lib/ctype.c	Fri Aug 29 15:47:21 2008 -0700
   101.2 +++ b/extras/mini-os/lib/ctype.c	Tue Sep 02 16:34:53 2008 -0700
   101.3 @@ -1,3 +1,4 @@
   101.4 +#ifndef HAVE_LIBC
   101.5  #include <ctype.h>
   101.6  
   101.7  unsigned char _ctype[] = {
   101.8 @@ -25,3 +26,4 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        
   101.9  _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
  101.10  _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
  101.11  _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
  101.12 +#endif
   102.1 --- a/extras/mini-os/lib/printf.c	Fri Aug 29 15:47:21 2008 -0700
   102.2 +++ b/extras/mini-os/lib/printf.c	Tue Sep 02 16:34:53 2008 -0700
   102.3 @@ -62,6 +62,7 @@
   102.4  #include <lib.h>
   102.5  #include <mm.h>
   102.6  #include <ctype.h>
   102.7 +#include <limits.h>
   102.8  
   102.9  /**
  102.10   * simple_strtoul - convert a string to an unsigned long
   103.1 --- a/extras/mini-os/lib/sys.c	Fri Aug 29 15:47:21 2008 -0700
   103.2 +++ b/extras/mini-os/lib/sys.c	Tue Sep 02 16:34:53 2008 -0700
   103.3 @@ -43,7 +43,9 @@
   103.4  #include <stdlib.h>
   103.5  #include <math.h>
   103.6  
   103.7 +#ifdef HAVE_LWIP
   103.8  #include <lwip/sockets.h>
   103.9 +#endif
  103.10  #include <fs.h>
  103.11  
  103.12  #define debug(fmt, ...) \
  103.13 @@ -81,6 +83,8 @@
  103.14  
  103.15  #define NOFILE 32
  103.16  extern int xc_evtchn_close(int fd);
  103.17 +extern int xc_interface_close(int fd);
  103.18 +extern int xc_gnttab_close(int fd);
  103.19  
  103.20  pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
  103.21  struct file files[NOFILE] = {
  103.22 @@ -200,9 +204,6 @@ int open(const char *pathname, int flags
  103.23      files[fd].file.offset = 0;
  103.24      return fd;
  103.25  }
  103.26 -#if defined(__x86_64__) || defined(__ia64__)
  103.27 -__typeof__(open) open64 __attribute__((__alias__("open")));
  103.28 -#endif
  103.29  
  103.30  int isatty(int fd)
  103.31  {
  103.32 @@ -212,12 +213,23 @@ int isatty(int fd)
  103.33  int read(int fd, void *buf, size_t nbytes)
  103.34  {
  103.35      switch (files[fd].type) {
  103.36 -	case FTYPE_CONSOLE:
  103.37 -	    return 0;
  103.38 +	case FTYPE_CONSOLE: {
  103.39 +	    int ret;
  103.40 +            DEFINE_WAIT(w);
  103.41 +            while(1) {
  103.42 +                add_waiter(w, console_queue);
  103.43 +                ret = xencons_ring_recv(buf, nbytes);
  103.44 +                if (ret)
  103.45 +                    break;
  103.46 +                schedule();
  103.47 +            }
  103.48 +            remove_waiter(w);
  103.49 +            return ret;
  103.50 +        }
  103.51  	case FTYPE_FILE: {
  103.52  	    ssize_t ret;
  103.53 -	    if (nbytes > PAGE_SIZE)
  103.54 -		nbytes = PAGE_SIZE;
  103.55 +	    if (nbytes > PAGE_SIZE * FSIF_NR_READ_GNTS)
  103.56 +		nbytes = PAGE_SIZE * FSIF_NR_READ_GNTS;
  103.57  	    ret = fs_read(fs_import, files[fd].file.fd, buf, nbytes, files[fd].file.offset);
  103.58  	    if (ret > 0) {
  103.59  		files[fd].file.offset += ret;
  103.60 @@ -228,8 +240,10 @@ int read(int fd, void *buf, size_t nbyte
  103.61  	    }
  103.62  	    return 0;
  103.63  	}
  103.64 +#ifdef HAVE_LWIP
  103.65  	case FTYPE_SOCKET:
  103.66  	    return lwip_read(files[fd].socket.fd, buf, nbytes);
  103.67 +#endif
  103.68  	case FTYPE_TAP: {
  103.69  	    ssize_t ret;
  103.70  	    ret = netfront_receive(files[fd].tap.dev, buf, nbytes);
  103.71 @@ -259,10 +273,7 @@ int read(int fd, void *buf, size_t nbyte
  103.72  	    }
  103.73  	    return ret * sizeof(union xenfb_in_event);
  103.74          }
  103.75 -	case FTYPE_NONE:
  103.76 -	case FTYPE_XENBUS:
  103.77 -	case FTYPE_EVTCHN:
  103.78 -	case FTYPE_BLK:
  103.79 +	default:
  103.80  	    break;
  103.81      }
  103.82      printk("read(%d): Bad descriptor\n", fd);
  103.83 @@ -278,8 +289,8 @@ int write(int fd, const void *buf, size_
  103.84  	    return nbytes;
  103.85  	case FTYPE_FILE: {
  103.86  	    ssize_t ret;
  103.87 -	    if (nbytes > PAGE_SIZE)
  103.88 -		nbytes = PAGE_SIZE;
  103.89 +	    if (nbytes > PAGE_SIZE * FSIF_NR_WRITE_GNTS)
  103.90 +		nbytes = PAGE_SIZE * FSIF_NR_WRITE_GNTS;
  103.91  	    ret = fs_write(fs_import, files[fd].file.fd, (void *) buf, nbytes, files[fd].file.offset);
  103.92  	    if (ret > 0) {
  103.93  		files[fd].file.offset += ret;
  103.94 @@ -290,17 +301,14 @@ int write(int fd, const void *buf, size_
  103.95  	    }
  103.96  	    return 0;
  103.97  	}
  103.98 +#ifdef HAVE_LWIP
  103.99  	case FTYPE_SOCKET:
 103.100  	    return lwip_write(files[fd].socket.fd, (void*) buf, nbytes);
 103.101 +#endif
 103.102  	case FTYPE_TAP:
 103.103  	    netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes);
 103.104  	    return nbytes;
 103.105 -	case FTYPE_NONE:
 103.106 -	case FTYPE_XENBUS:
 103.107 -	case FTYPE_EVTCHN:
 103.108 -	case FTYPE_BLK:
 103.109 -	case FTYPE_KBD:
 103.110 -	case FTYPE_FB:
 103.111 +	default:
 103.112  	    break;
 103.113      }
 103.114      printk("write(%d): Bad descriptor\n", fd);
 103.115 @@ -336,9 +344,6 @@ off_t lseek(int fd, off_t offset, int wh
 103.116      }
 103.117      return files[fd].file.offset;
 103.118  }
 103.119 -#if defined(__x86_64__) || defined(__ia64__)
 103.120 -__typeof__(lseek) lseek64 __attribute__((__alias__("lseek")));
 103.121 -#endif
 103.122  
 103.123  int fsync(int fd) {
 103.124      switch (files[fd].type) {
 103.125 @@ -351,15 +356,7 @@ int fsync(int fd) {
 103.126  	    }
 103.127  	    return 0;
 103.128  	}
 103.129 -	case FTYPE_NONE:
 103.130 -	case FTYPE_CONSOLE:
 103.131 -	case FTYPE_SOCKET:
 103.132 -	case FTYPE_XENBUS:
 103.133 -	case FTYPE_EVTCHN:
 103.134 -	case FTYPE_TAP:
 103.135 -	case FTYPE_BLK:
 103.136 -	case FTYPE_KBD:
 103.137 -	case FTYPE_FB:
 103.138 +	default:
 103.139  	    break;
 103.140      }
 103.141      printk("fsync(%d): Bad descriptor\n", fd);
 103.142 @@ -371,7 +368,7 @@ int close(int fd)
 103.143  {
 103.144      printk("close(%d)\n", fd);
 103.145      switch (files[fd].type) {
 103.146 -	case FTYPE_CONSOLE:
 103.147 +        default:
 103.148  	    files[fd].type = FTYPE_NONE;
 103.149  	    return 0;
 103.150  	case FTYPE_FILE: {
 103.151 @@ -386,14 +383,22 @@ int close(int fd)
 103.152  	case FTYPE_XENBUS:
 103.153              xs_daemon_close((void*)(intptr_t) fd);
 103.154              return 0;
 103.155 +#ifdef HAVE_LWIP
 103.156  	case FTYPE_SOCKET: {
 103.157  	    int res = lwip_close(files[fd].socket.fd);
 103.158  	    files[fd].type = FTYPE_NONE;
 103.159  	    return res;
 103.160  	}
 103.161 +#endif
 103.162 +	case FTYPE_XC:
 103.163 +	    xc_interface_close(fd);
 103.164 +	    return 0;
 103.165  	case FTYPE_EVTCHN:
 103.166              xc_evtchn_close(fd);
 103.167              return 0;
 103.168 +	case FTYPE_GNTMAP:
 103.169 +	    xc_gnttab_close(fd);
 103.170 +	    return 0;
 103.171  	case FTYPE_TAP:
 103.172  	    shutdown_netfront(files[fd].tap.dev);
 103.173  	    files[fd].type = FTYPE_NONE;
 103.174 @@ -495,13 +500,7 @@ int fstat(int fd, struct stat *buf)
 103.175  	    stat_from_fs(buf, &stat);
 103.176  	    return 0;
 103.177  	}
 103.178 -	case FTYPE_NONE:
 103.179 -	case FTYPE_XENBUS:
 103.180 -	case FTYPE_EVTCHN:
 103.181 -	case FTYPE_TAP:
 103.182 -	case FTYPE_BLK:
 103.183 -	case FTYPE_KBD:
 103.184 -	case FTYPE_FB:
 103.185 +	default:
 103.186  	    break;
 103.187      }
 103.188  
 103.189 @@ -522,15 +521,7 @@ int ftruncate(int fd, off_t length)
 103.190  	    }
 103.191  	    return 0;
 103.192  	}
 103.193 -	case FTYPE_NONE:
 103.194 -	case FTYPE_CONSOLE:
 103.195 -	case FTYPE_SOCKET:
 103.196 -	case FTYPE_XENBUS:
 103.197 -	case FTYPE_EVTCHN:
 103.198 -	case FTYPE_TAP:
 103.199 -	case FTYPE_BLK:
 103.200 -	case FTYPE_KBD:
 103.201 -	case FTYPE_FB:
 103.202 +	default:
 103.203  	    break;
 103.204      }
 103.205  
 103.206 @@ -570,6 +561,7 @@ int fcntl(int fd, int cmd, ...)
 103.207      va_end(ap);
 103.208  
 103.209      switch (cmd) {
 103.210 +#ifdef HAVE_LWIP
 103.211  	case F_SETFL:
 103.212  	    if (files[fd].type == FTYPE_SOCKET && !(arg & ~O_NONBLOCK)) {
 103.213  		/* Only flag supported: non-blocking mode */
 103.214 @@ -577,6 +569,7 @@ int fcntl(int fd, int cmd, ...)
 103.215  		return lwip_ioctl(files[fd].socket.fd, FIONBIO, &nblock);
 103.216  	    }
 103.217  	    /* Fallthrough */
 103.218 +#endif
 103.219  	default:
 103.220  	    printk("fcntl(%d, %d, %lx/%lo)\n", fd, cmd, arg, arg);
 103.221  	    errno = ENOSYS;
 103.222 @@ -636,9 +629,10 @@ static const char file_types[] = {
 103.223      [FTYPE_NONE]	= 'N',
 103.224      [FTYPE_CONSOLE]	= 'C',
 103.225      [FTYPE_FILE]	= 'F',
 103.226 -    [FTYPE_XENBUS]	= 'X',
 103.227 +    [FTYPE_XENBUS]	= 'S',
 103.228 +    [FTYPE_XC]		= 'X',
 103.229      [FTYPE_EVTCHN]	= 'E',
 103.230 -    [FTYPE_SOCKET]	= 'S',
 103.231 +    [FTYPE_SOCKET]	= 's',
 103.232      [FTYPE_TAP]		= 'T',
 103.233      [FTYPE_BLK]		= 'B',
 103.234      [FTYPE_KBD]		= 'K',
 103.235 @@ -680,18 +674,22 @@ static void dump_set(int nfds, fd_set *r
 103.236  /* Just poll without blocking */
 103.237  static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
 103.238  {
 103.239 -    int i, n = 0, sock_n, sock_nfds = 0;
 103.240 +    int i, n = 0;
 103.241 +#ifdef HAVE_LWIP
 103.242 +    int sock_n, sock_nfds = 0;
 103.243      fd_set sock_readfds, sock_writefds, sock_exceptfds;
 103.244      struct timeval timeout = { .tv_sec = 0, .tv_usec = 0};
 103.245 +#endif
 103.246  
 103.247  #ifdef LIBC_VERBOSE
 103.248      static int nb;
 103.249      static int nbread[NOFILE], nbwrite[NOFILE], nbexcept[NOFILE];
 103.250 -    static s64_t lastshown;
 103.251 +    static s_time_t lastshown;
 103.252  
 103.253      nb++;
 103.254  #endif
 103.255  
 103.256 +#ifdef HAVE_LWIP
 103.257      /* first poll network */
 103.258      FD_ZERO(&sock_readfds);
 103.259      FD_ZERO(&sock_writefds);
 103.260 @@ -718,11 +716,12 @@ static int select_poll(int nfds, fd_set 
 103.261      sock_n = lwip_select(sock_nfds, &sock_readfds, &sock_writefds, &sock_exceptfds, &timeout);
 103.262      dump_set(nfds, &sock_readfds, &sock_writefds, &sock_exceptfds, &timeout);
 103.263      DEBUG("\n");
 103.264 +#endif
 103.265  
 103.266      /* Then see others as well. */
 103.267      for (i = 0; i < nfds; i++) {
 103.268  	switch(files[i].type) {
 103.269 -	case FTYPE_NONE:
 103.270 +	default:
 103.271  	    if (FD_ISSET(i, readfds) || FD_ISSET(i, writefds) || FD_ISSET(i, exceptfds))
 103.272  		printk("bogus fd %d in select\n", i);
 103.273  	    /* Fallthrough.  */
 103.274 @@ -732,7 +731,12 @@ static int select_poll(int nfds, fd_set 
 103.275  	    FD_CLR(i, exceptfds);
 103.276  	    break;
 103.277  	case FTYPE_CONSOLE:
 103.278 -	    FD_CLR(i, readfds);
 103.279 +	    if (FD_ISSET(i, readfds)) {
 103.280 +                if (xencons_ring_avail())
 103.281 +		    n++;
 103.282 +		else
 103.283 +		    FD_CLR(i, readfds);
 103.284 +            }
 103.285  	    if (FD_ISSET(i, writefds))
 103.286                  n++;
 103.287  	    FD_CLR(i, exceptfds);
 103.288 @@ -761,6 +765,7 @@ static int select_poll(int nfds, fd_set 
 103.289  	    FD_CLR(i, writefds);
 103.290  	    FD_CLR(i, exceptfds);
 103.291  	    break;
 103.292 +#ifdef HAVE_LWIP
 103.293  	case FTYPE_SOCKET:
 103.294  	    if (FD_ISSET(i, readfds)) {
 103.295  	        /* Optimize no-network-packet case.  */
 103.296 @@ -782,6 +787,7 @@ static int select_poll(int nfds, fd_set 
 103.297  		    FD_CLR(i, exceptfds);
 103.298              }
 103.299  	    break;
 103.300 +#endif
 103.301  	}
 103.302  #ifdef LIBC_VERBOSE
 103.303  	if (FD_ISSET(i, readfds))
 103.304 @@ -834,6 +840,7 @@ int select(int nfds, fd_set *readfds, fd
 103.305      DEFINE_WAIT(w3);
 103.306      DEFINE_WAIT(w4);
 103.307      DEFINE_WAIT(w5);
 103.308 +    DEFINE_WAIT(w6);
 103.309  
 103.310      assert(thread == main_thread);
 103.311  
 103.312 @@ -855,6 +862,7 @@ int select(int nfds, fd_set *readfds, fd
 103.313      add_waiter(w3, blkfront_queue);
 103.314      add_waiter(w4, xenbus_watch_queue);
 103.315      add_waiter(w5, kbdfront_queue);
 103.316 +    add_waiter(w6, console_queue);
 103.317  
 103.318      if (readfds)
 103.319          myread = *readfds;
 103.320 @@ -941,9 +949,11 @@ out:
 103.321      remove_waiter(w3);
 103.322      remove_waiter(w4);
 103.323      remove_waiter(w5);
 103.324 +    remove_waiter(w6);
 103.325      return ret;
 103.326  }
 103.327  
 103.328 +#ifdef HAVE_LWIP
 103.329  int socket(int domain, int type, int protocol)
 103.330  {
 103.331      int fd, res;
 103.332 @@ -995,6 +1005,7 @@ LWIP_STUB(ssize_t, recvfrom, (int s, voi
 103.333  LWIP_STUB(ssize_t, send, (int s, void *buf, size_t len, int flags), (s, buf, len, flags))
 103.334  LWIP_STUB(ssize_t, sendto, (int s, void *buf, size_t len, int flags, struct sockaddr *to, socklen_t tolen), (s, buf, len, flags, to, tolen))
 103.335  LWIP_STUB(int, getsockname, (int s, struct sockaddr *name, socklen_t *namelen), (s, name, namelen))
 103.336 +#endif
 103.337  
 103.338  int nanosleep(const struct timespec *req, struct timespec *rem)
 103.339  {
 103.340 @@ -1081,20 +1092,28 @@ int clock_gettime(clockid_t clk_id, stru
 103.341      return 0;
 103.342  }
 103.343  
 103.344 +size_t getpagesize(void)
 103.345 +{
 103.346 +    return PAGE_SIZE;
 103.347 +}
 103.348 +
 103.349  void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
 103.350  {
 103.351 +    unsigned long n = (length + PAGE_SIZE - 1) / PAGE_SIZE;
 103.352 +
 103.353      ASSERT(!start);
 103.354 -    length = (length + PAGE_SIZE - 1) & PAGE_MASK;
 103.355      ASSERT(prot == (PROT_READ|PROT_WRITE));
 103.356 -    ASSERT(flags == (MAP_SHARED|MAP_ANON) || flags == (MAP_PRIVATE|MAP_ANON));
 103.357 -    ASSERT(fd == -1);
 103.358 +    ASSERT((fd == -1 && (flags == (MAP_SHARED|MAP_ANON) || flags == (MAP_PRIVATE|MAP_ANON)))
 103.359 +        || (fd != -1 && flags == MAP_SHARED));
 103.360      ASSERT(offset == 0);
 103.361  
 103.362 -    return map_zero(length / PAGE_SIZE, 1);
 103.363 +    if (fd == -1)
 103.364 +        return map_zero(n, 1);
 103.365 +    else if (files[fd].type == FTYPE_XC) {
 103.366 +        unsigned long zero = 0;
 103.367 +        return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0);
 103.368 +    } else ASSERT(0);
 103.369  }
 103.370 -#if defined(__x86_64__) || defined(__ia64__)
 103.371 -__typeof__(mmap) mmap64 __attribute__((__alias__("mmap")));
 103.372 -#endif
 103.373  
 103.374  int munmap(void *start, size_t length)
 103.375  {
 103.376 @@ -1110,7 +1129,7 @@ int munmap(void *start, size_t length)
 103.377  	call[i].args[0] = (unsigned long) &data[i];
 103.378  	call[i].args[1] = 0;
 103.379  	call[i].args[2] = 0;
 103.380 -	call[i].args[3] = UVMF_INVLPG | UVMF_ALL;
 103.381 +	call[i].args[3] = UVMF_INVLPG;
 103.382      }
 103.383  
 103.384      ret = HYPERVISOR_multicall(call, n);
 103.385 @@ -1166,6 +1185,7 @@ void sparse(unsigned long data, size_t s
 103.386  /* Not supported by FS yet.  */
 103.387  unsupported_function_crash(link);
 103.388  unsupported_function(int, readlink, -1);
 103.389 +unsupported_function_crash(umask);
 103.390  
 103.391  /* We could support that.  */
 103.392  unsupported_function_log(int, chdir, -1);
 103.393 @@ -1188,6 +1208,18 @@ unsupported_function(int, __sigsetjmp, 0
 103.394  unsupported_function(int, sigaltstack, -1);
 103.395  unsupported_function_crash(kill);
 103.396  
 103.397 +/* Unsupported */
 103.398 +unsupported_function_crash(pipe);
 103.399 +unsupported_function_crash(fork);
 103.400 +unsupported_function_crash(execv);
 103.401 +unsupported_function_crash(execve);
 103.402 +unsupported_function_crash(waitpid);
 103.403 +unsupported_function_crash(wait);
 103.404 +unsupported_function_crash(lockf);
 103.405 +unsupported_function_crash(sysconf);
 103.406 +unsupported_function(int, tcsetattr, -1);
 103.407 +unsupported_function(int, tcgetattr, 0);
 103.408 +
 103.409  /* Linuxish abi for the Caml runtime, don't support */
 103.410  unsupported_function_log(struct dirent *, readdir64, NULL);
 103.411  unsupported_function_log(int, getrusage, -1);
   104.1 --- a/extras/mini-os/lib/xmalloc.c	Fri Aug 29 15:47:21 2008 -0700
   104.2 +++ b/extras/mini-os/lib/xmalloc.c	Tue Sep 02 16:34:53 2008 -0700
   104.3 @@ -44,14 +44,14 @@
   104.4  #include <xmalloc.h>
   104.5  
   104.6  #ifndef HAVE_LIBC
   104.7 -static LIST_HEAD(freelist);
   104.8 +static MINIOS_LIST_HEAD(freelist);
   104.9  /* static spinlock_t freelist_lock = SPIN_LOCK_UNLOCKED; */
  104.10  
  104.11  struct xmalloc_hdr
  104.12  {
  104.13      /* Total including this hdr, unused padding and second hdr. */
  104.14      size_t size;
  104.15 -    struct list_head freelist;
  104.16 +    struct minios_list_head freelist;
  104.17  } __cacheline_aligned;
  104.18  
  104.19  /* Unused padding data between the two hdrs. */
  104.20 @@ -82,7 +82,7 @@ static void maybe_split(struct xmalloc_h
  104.21          extra = (struct xmalloc_hdr *)((unsigned long)hdr + size);
  104.22          extra->size = leftover;
  104.23          /* spin_lock_irqsave(&freelist_lock, flags); */
  104.24 -        list_add(&extra->freelist, &freelist);
  104.25 +        minios_list_add(&extra->freelist, &freelist);
  104.26          /* spin_unlock_irqrestore(&freelist_lock, flags); */
  104.27      }
  104.28      else
  104.29 @@ -127,7 +127,7 @@ static void *xmalloc_whole_pages(size_t 
  104.30      if ( hdr == NULL )
  104.31          return NULL;
  104.32  
  104.33 -    hdr->size = (1 << (pageorder + PAGE_SHIFT));
  104.34 +    hdr->size = (1UL << (pageorder + PAGE_SHIFT));
  104.35      /* Debugging aid. */
  104.36      hdr->freelist.next = hdr->freelist.prev = NULL;
  104.37  
  104.38 @@ -139,7 +139,7 @@ static void *xmalloc_whole_pages(size_t 
  104.39  
  104.40  void *_xmalloc(size_t size, size_t align)
  104.41  {
  104.42 -    struct xmalloc_hdr *i, *hdr = NULL;
  104.43 +    struct xmalloc_hdr *i, *tmp, *hdr = NULL;
  104.44      uintptr_t data_begin;
  104.45      size_t hdr_size;
  104.46      /* unsigned long flags; */
  104.47 @@ -155,14 +155,14 @@ void *_xmalloc(size_t size, size_t align
  104.48  
  104.49      /* Search free list. */
  104.50      /* spin_lock_irqsave(&freelist_lock, flags); */
  104.51 -    list_for_each_entry( i, &freelist, freelist )
  104.52 +    minios_list_for_each_entry_safe( i, tmp, &freelist, freelist )
  104.53      {
  104.54          data_begin = align_up((uintptr_t)i + hdr_size, align);
  104.55  
  104.56          if ( data_begin + size > (uintptr_t)i + i->size )
  104.57              continue;
  104.58  
  104.59 -        list_del(&i->freelist);
  104.60 +        minios_list_del(&i->freelist);
  104.61          /* spin_unlock_irqrestore(&freelist_lock, flags); */
  104.62  
  104.63          uintptr_t size_before = (data_begin - hdr_size) - (uintptr_t)i;
  104.64 @@ -173,7 +173,7 @@ void *_xmalloc(size_t size, size_t align
  104.65              new_i->size = i->size - size_before;
  104.66              i->size = size_before;
  104.67              /* spin_lock_irqsave(&freelist_lock, flags); */
  104.68 -            list_add(&i->freelist, &freelist);
  104.69 +            minios_list_add(&i->freelist, &freelist);
  104.70              /* spin_unlock_irqrestore(&freelist_lock, flags); */
  104.71              i = new_i;
  104.72          }
  104.73 @@ -231,7 +231,7 @@ void xfree(const void *p)
  104.74  
  104.75      /* Merge with other free block, or put in list. */
  104.76      /* spin_lock_irqsave(&freelist_lock, flags); */
  104.77 -    list_for_each_entry_safe( i, tmp, &freelist, freelist )
  104.78 +    minios_list_for_each_entry_safe( i, tmp, &freelist, freelist )
  104.79      {
  104.80          unsigned long _i   = (unsigned long)i;
  104.81          unsigned long _hdr = (unsigned long)hdr;
  104.82 @@ -243,7 +243,7 @@ void xfree(const void *p)
  104.83          /* We follow this block?  Swallow it. */
  104.84          if ( (_i + i->size) == _hdr )
  104.85          {
  104.86 -            list_del(&i->freelist);
  104.87 +            minios_list_del(&i->freelist);
  104.88              i->size += hdr->size;
  104.89              hdr = i;
  104.90          }
  104.91 @@ -251,7 +251,7 @@ void xfree(const void *p)
  104.92          /* We precede this block? Swallow it. */
  104.93          if ( (_hdr + hdr->size) == _i )
  104.94          {
  104.95 -            list_del(&i->freelist);
  104.96 +            minios_list_del(&i->freelist);
  104.97              hdr->size += i->size;
  104.98          }
  104.99      }
 104.100 @@ -268,7 +268,7 @@ void xfree(const void *p)
 104.101      }
 104.102      else
 104.103      {
 104.104 -        list_add(&hdr->freelist, &freelist);
 104.105 +        minios_list_add(&hdr->freelist, &freelist);
 104.106      }
 104.107  
 104.108      /* spin_unlock_irqrestore(&freelist_lock, flags); */
   105.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.2 +++ b/extras/mini-os/lock.c	Tue Sep 02 16:34:53 2008 -0700
   105.3 @@ -0,0 +1,111 @@
   105.4 +/*
   105.5 + * locks for newlib
   105.6 + *
   105.7 + * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, July 20008
   105.8 + */
   105.9 +
  105.10 +#ifdef HAVE_LIBC
  105.11 +
  105.12 +#include <sys/lock.h>
  105.13 +#include <sched.h>
  105.14 +#include <wait.h>
  105.15 +
  105.16 +int ___lock_init(_LOCK_T *lock)
  105.17 +{
  105.18 +    lock->busy = 0;
  105.19 +    init_waitqueue_head(&lock->wait);
  105.20 +    return 0;
  105.21 +}
  105.22 +
  105.23 +int ___lock_acquire(_LOCK_T *lock)
  105.24 +{
  105.25 +    unsigned long flags;
  105.26 +    while(1) {
  105.27 +        wait_event(lock->wait, !lock->busy);
  105.28 +        local_irq_save(flags);
  105.29 +        if (!lock->busy)
  105.30 +            break;
  105.31 +        local_irq_restore(flags);
  105.32 +    }
  105.33 +    lock->busy = 1;
  105.34 +    local_irq_restore(flags);
  105.35 +    return 0;
  105.36 +}
  105.37 +
  105.38 +int ___lock_try_acquire(_LOCK_T *lock)
  105.39 +{
  105.40 +    unsigned long flags;
  105.41 +    int ret = -1;
  105.42 +    local_irq_save(flags);
  105.43 +    if (!lock->busy) {
  105.44 +        lock->busy = 1;
  105.45 +        ret = 0;
  105.46 +    }
  105.47 +    local_irq_restore(flags);
  105.48 +    return ret;
  105.49 +}
  105.50 +
  105.51 +int ___lock_release(_LOCK_T *lock)
  105.52 +{
  105.53 +    unsigned long flags;
  105.54 +    local_irq_save(flags);
  105.55 +    lock->busy = 0;
  105.56 +    wake_up(&lock->wait);
  105.57 +    local_irq_restore(flags);
  105.58 +    return 0;
  105.59 +}
  105.60 +
  105.61 +
  105.62 +int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock)
  105.63 +{
  105.64 +    lock->owner = NULL;
  105.65 +    init_waitqueue_head(&lock->wait);
  105.66 +    return 0;
  105.67 +}
  105.68 +
  105.69 +int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock)
  105.70 +{
  105.71 +    unsigned long flags;
  105.72 +    if (lock->owner != get_current()) {
  105.73 +        while (1) {
  105.74 +            wait_event(lock->wait, lock->owner == NULL);
  105.75 +            local_irq_save(flags);
  105.76 +            if (lock->owner == NULL)
  105.77 +                break;
  105.78 +            local_irq_restore(flags);
  105.79 +        }
  105.80 +        lock->owner = get_current();
  105.81 +        local_irq_restore(flags);
  105.82 +    }
  105.83 +    lock->count++;
  105.84 +    return 0;
  105.85 +}
  105.86 +
  105.87 +int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock)
  105.88 +{
  105.89 +    unsigned long flags;
  105.90 +    int ret = -1;
  105.91 +    local_irq_save(flags);
  105.92 +    if (!lock->owner) {
  105.93 +        ret = 0;
  105.94 +        lock->owner = get_current();
  105.95 +        lock->count++;
  105.96 +    }
  105.97 +    local_irq_restore(flags);
  105.98 +    return ret;
  105.99 +}
 105.100 +
 105.101 +int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock)
 105.102 +{
 105.103 +    unsigned long flags;
 105.104 +    BUG_ON(lock->owner != get_current());
 105.105 +    if (--lock->count)
 105.106 +        return 0;
 105.107 +    local_irq_save(flags);
 105.108 +    lock->owner = NULL;
 105.109 +    wake_up(&lock->wait);
 105.110 +    local_irq_restore(flags);
 105.111 +    return 0;
 105.112 +}
 105.113 +
 105.114 +#endif
   106.1 --- a/extras/mini-os/lwip-net.c	Fri Aug 29 15:47:21 2008 -0700
   106.2 +++ b/extras/mini-os/lwip-net.c	Tue Sep 02 16:34:53 2008 -0700
   106.3 @@ -93,6 +93,9 @@ static err_t netfront_output(struct neti
   106.4  static err_t
   106.5  low_level_output(struct netif *netif, struct pbuf *p)
   106.6  {
   106.7 +  if (!dev)
   106.8 +    return ERR_OK;
   106.9 +
  106.10  #ifdef ETH_PAD_SIZE
  106.11    pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
  106.12  #endif
  106.13 @@ -342,7 +345,7 @@ void start_networking(void)
  106.14    struct ip_addr ipaddr = { htonl(IF_IPADDR) };
  106.15    struct ip_addr netmask = { htonl(IF_NETMASK) };
  106.16    struct ip_addr gw = { 0 };
  106.17 -  char *ip;
  106.18 +  char *ip = NULL;
  106.19  
  106.20    tprintk("Waiting for network.\n");
  106.21  
  106.22 @@ -376,3 +379,10 @@ void start_networking(void)
  106.23  
  106.24    tprintk("Network is ready.\n");
  106.25  }
  106.26 +
  106.27 +/* Shut down the network */
  106.28 +void stop_networking(void)
  106.29 +{
  106.30 +  if (dev)
  106.31 +    shutdown_netfront(dev);
  106.32 +}
   107.1 --- a/extras/mini-os/main-caml.c	Fri Aug 29 15:47:21 2008 -0700
   107.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.3 @@ -1,42 +0,0 @@
   107.4 -/*
   107.5 - * Caml bootstrap
   107.6 - *
   107.7 - * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008
   107.8 - */
   107.9 -
  107.10 -#include <stdio.h>
  107.11 -#include <errno.h>
  107.12 -
  107.13 -#include <caml/mlvalues.h>
  107.14 -#include <caml/callback.h>
  107.15 -#include <unistd.h>
  107.16 -
  107.17 -/* Ugly binary compatibility with Linux */
  107.18 -FILE *_stderr asm("stderr");
  107.19 -int *__errno_location;
  107.20 -/* Will probably break everything, probably need to fetch from glibc */
  107.21 -void *__ctype_b_loc;
  107.22 -
  107.23 -int main(int argc, char *argv[], char *envp[])
  107.24 -{
  107.25 -    value *val;
  107.26 -
  107.27 -    /* Get current thread's value */
  107.28 -    _stderr = stderr;
  107.29 -    __errno_location = &errno;
  107.30 -
  107.31 -    printf("starting caml\n");
  107.32 -
  107.33 -    /* Wait before things might hang up */
  107.34 -    sleep(1);
  107.35 -
  107.36 -    caml_startup(argv);
  107.37 -    val = caml_named_value("main");
  107.38 -    if (!val) {
  107.39 -        printf("Couldn't find Caml main");
  107.40 -        return 1;
  107.41 -    }
  107.42 -    caml_callback(*val, Val_int(0));
  107.43 -    printf("callback returned\n");
  107.44 -    return 0;
  107.45 -}
   108.1 --- a/extras/mini-os/main.c	Fri Aug 29 15:47:21 2008 -0700
   108.2 +++ b/extras/mini-os/main.c	Tue Sep 02 16:34:53 2008 -0700
   108.3 @@ -19,8 +19,8 @@
   108.4  extern int main(int argc, char *argv[], char *envp[]);
   108.5  extern void __libc_init_array(void);
   108.6  extern void __libc_fini_array(void);
   108.7 -
   108.8 -struct thread *main_thread;
   108.9 +extern unsigned long __CTOR_LIST__[];
  108.10 +extern unsigned long __DTOR_LIST__[];
  108.11  
  108.12  #if 0
  108.13  #include <stdio.h>
  108.14 @@ -42,24 +42,31 @@ void _fini(void)
  108.15  extern char __app_bss_start, __app_bss_end;
  108.16  static void call_main(void *p)
  108.17  {
  108.18 -    char *args, /**path,*/ *msg, *c;
  108.19 +    char *c;
  108.20  #ifdef CONFIG_QEMU
  108.21 -    char *domargs;
  108.22 +    char *domargs, *msg;
  108.23  #endif
  108.24      int argc;
  108.25      char **argv;
  108.26      char *envp[] = { NULL };
  108.27 +#ifdef CONFIG_QEMU
  108.28      char *vm;
  108.29 +    char path[128];
  108.30 +    int domid;
  108.31 +#endif
  108.32      int i;
  108.33 -    char path[128];
  108.34  
  108.35      /* Let other parts initialize (including console output) before maybe
  108.36       * crashing. */
  108.37      //sleep(1);
  108.38  
  108.39 +#ifndef CONFIG_GRUB
  108.40      sparse((unsigned long) &__app_bss_start, &__app_bss_end - &__app_bss_start);
  108.41 +#ifdef HAVE_LWIP
  108.42      start_networking();
  108.43 +#endif
  108.44      init_fs_frontend();
  108.45 +#endif
  108.46  
  108.47  #ifdef CONFIG_QEMU
  108.48      if (!fs_import) {
  108.49 @@ -68,7 +75,6 @@ static void call_main(void *p)
  108.50      }
  108.51  
  108.52      /* Fetch argc, argv from XenStore */
  108.53 -    int domid;
  108.54      domid = xenbus_read_integer("target");
  108.55      if (domid == -1) {
  108.56          printk("Couldn't read target\n");
  108.57 @@ -93,22 +99,6 @@ static void call_main(void *p)
  108.58      }
  108.59  #endif
  108.60  
  108.61 -    msg = xenbus_read(XBT_NIL, "vm", &vm);
  108.62 -    if (msg) {
  108.63 -        printk("Couldn't read vm path\n");
  108.64 -        do_exit();
  108.65 -    }
  108.66 -
  108.67 -    printk("my vm is at %s\n", vm);
  108.68 -    snprintf(path, sizeof(path), "%s/image/cmdline", vm);
  108.69 -    free(vm);
  108.70 -    msg = xenbus_read(XBT_NIL, path, &args);
  108.71 -
  108.72 -    if (msg) {
  108.73 -        printk("Couldn't get my args: %s\n", msg);
  108.74 -        args = strdup("");
  108.75 -    }
  108.76 -
  108.77      argc = 1;
  108.78  
  108.79  #define PARSE_ARGS(ARGS,START,END) \
  108.80 @@ -125,7 +115,7 @@ static void call_main(void *p)
  108.81  	} \
  108.82      }
  108.83  
  108.84 -    PARSE_ARGS(args, argc++, );
  108.85 +    PARSE_ARGS((char*)start_info.cmd_line, argc++, );
  108.86  #ifdef CONFIG_QEMU
  108.87      PARSE_ARGS(domargs, argc++, );
  108.88  #endif
  108.89 @@ -134,7 +124,7 @@ static void call_main(void *p)
  108.90      argv[0] = "main";
  108.91      argc = 1;
  108.92  
  108.93 -    PARSE_ARGS(args, argv[argc++] = c, *c++ = 0)
  108.94 +    PARSE_ARGS((char*)start_info.cmd_line, argv[argc++] = c, *c++ = 0)
  108.95  #ifdef CONFIG_QEMU
  108.96      PARSE_ARGS(domargs, argv[argc++] = c, *c++ = 0)
  108.97  #endif
  108.98 @@ -147,6 +137,8 @@ static void call_main(void *p)
  108.99  
 108.100      __libc_init_array();
 108.101      environ = envp;
 108.102 +    for (i = 1; i <= __CTOR_LIST__[0]; i++)
 108.103 +        ((void((*)(void)))__CTOR_LIST__[i]) ();
 108.104      tzset();
 108.105  
 108.106      exit(main(argc, argv, envp));
 108.107 @@ -154,10 +146,17 @@ static void call_main(void *p)
 108.108  
 108.109  void _exit(int ret)
 108.110  {
 108.111 +    int i;
 108.112 +
 108.113 +    for (i = 1; i <= __DTOR_LIST__[0]; i++)
 108.114 +        ((void((*)(void)))__DTOR_LIST__[i]) ();
 108.115      close_all_files();
 108.116      __libc_fini_array();
 108.117      printk("main returned %d\n", ret);
 108.118 -    unbind_all_ports();
 108.119 +#ifdef HAVE_LWIP
 108.120 +    stop_networking();
 108.121 +#endif
 108.122 +    stop_kernel();
 108.123      if (!ret) {
 108.124  	/* No problem, just shutdown.  */
 108.125          struct sched_shutdown sched_shutdown = { .reason = SHUTDOWN_poweroff };
   109.1 --- a/extras/mini-os/minios.mk	Fri Aug 29 15:47:21 2008 -0700
   109.2 +++ b/extras/mini-os/minios.mk	Tue Sep 02 16:34:53 2008 -0700
   109.3 @@ -6,13 +6,14 @@ debug = y
   109.4  
   109.5  # Define some default flags.
   109.6  # NB. '-Wcast-qual' is nasty, so I omitted it.
   109.7 -DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
   109.8 +DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls
   109.9  DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
  109.10 +DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline)
  109.11  DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
  109.12  DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
  109.13  
  109.14 -DEF_ASFLAGS = -D__ASSEMBLY__
  109.15 -DEF_LDFLAGS =
  109.16 +DEF_ASFLAGS += -D__ASSEMBLY__
  109.17 +DEF_LDFLAGS +=
  109.18  
  109.19  ifeq ($(debug),y)
  109.20  DEF_CFLAGS += -g
  109.21 @@ -20,6 +21,7 @@ DEF_CFLAGS += -g
  109.22  #DEF_CFLAGS += -DFS_DEBUG
  109.23  #DEF_CFLAGS += -DLIBC_DEBUG
  109.24  DEF_CFLAGS += -DGNT_DEBUG
  109.25 +DEF_CFLAGS += -DGNTMAP_DEBUG
  109.26  else
  109.27  DEF_CFLAGS += -O3
  109.28  endif
  109.29 @@ -57,13 +59,13 @@ ARCH_LIB := lib$(ARCH_LIB_NAME).a
  109.30  # This object contains the entrypoint for startup from Xen.
  109.31  # $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory.
  109.32  HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o
  109.33 -HEAD_OBJ := $(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
  109.34 +HEAD_OBJ := $(OBJ_DIR)/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ)
  109.35  
  109.36  
  109.37 -%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS)
  109.38 +$(OBJ_DIR)/%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS)
  109.39  	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  109.40  
  109.41 -%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS)
  109.42 +$(OBJ_DIR)/%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS)
  109.43  	$(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
  109.44  
  109.45  
   110.1 --- a/extras/mini-os/mm.c	Fri Aug 29 15:47:21 2008 -0700
   110.2 +++ b/extras/mini-os/mm.c	Tue Sep 02 16:34:53 2008 -0700
   110.3 @@ -58,7 +58,7 @@ static unsigned long *alloc_bitmap;
   110.4  #define PAGES_PER_MAPWORD (sizeof(unsigned long) * 8)
   110.5  
   110.6  #define allocated_in_map(_pn) \
   110.7 -(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1<<((_pn)&(PAGES_PER_MAPWORD-1))))
   110.8 +(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1UL<<((_pn)&(PAGES_PER_MAPWORD-1))))
   110.9  
  110.10  /*
  110.11   * Hint regarding bitwise arithmetic in map_{alloc,free}:
  110.12 @@ -80,13 +80,13 @@ static void map_alloc(unsigned long firs
  110.13  
  110.14      if ( curr_idx == end_idx )
  110.15      {
  110.16 -        alloc_bitmap[curr_idx] |= ((1<<end_off)-1) & -(1<<start_off);
  110.17 +        alloc_bitmap[curr_idx] |= ((1UL<<end_off)-1) & -(1UL<<start_off);
  110.18      }
  110.19      else 
  110.20      {
  110.21 -        alloc_bitmap[curr_idx] |= -(1<<start_off);
  110.22 -        while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0L;
  110.23 -        alloc_bitmap[curr_idx] |= (1<<end_off)-1;
  110.24 +        alloc_bitmap[curr_idx] |= -(1UL<<start_off);
  110.25 +        while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0UL;
  110.26 +        alloc_bitmap[curr_idx] |= (1UL<<end_off)-1;
  110.27      }
  110.28  }
  110.29  
  110.30 @@ -102,13 +102,13 @@ static void map_free(unsigned long first
  110.31  
  110.32      if ( curr_idx == end_idx )
  110.33      {
  110.34 -        alloc_bitmap[curr_idx] &= -(1<<end_off) | ((1<<start_off)-1);
  110.35 +        alloc_bitmap[curr_idx] &= -(1UL<<end_off) | ((1UL<<start_off)-1);
  110.36      }
  110.37      else 
  110.38      {
  110.39 -        alloc_bitmap[curr_idx] &= (1<<start_off)-1;
  110.40 +        alloc_bitmap[curr_idx] &= (1UL<<start_off)-1;
  110.41          while ( ++curr_idx != end_idx ) alloc_bitmap[curr_idx] = 0;
  110.42 -        alloc_bitmap[curr_idx] &= -(1<<end_off);
  110.43 +        alloc_bitmap[curr_idx] &= -(1UL<<end_off);
  110.44      }
  110.45  }
  110.46  
  110.47 @@ -178,7 +178,7 @@ USED static void print_chunks(void *star
  110.48          head = free_head[order];
  110.49          while(!FREELIST_EMPTY(head))
  110.50          {
  110.51 -            for(count = 0; count < 1<< head->level; count++)
  110.52 +            for(count = 0; count < 1UL<< head->level; count++)
  110.53              {
  110.54                  if(count + virt_to_pfn(head) - pfn_start < 1000)
  110.55                      chunks[count + virt_to_pfn(head) - pfn_start] = current;
  110.56 @@ -235,13 +235,13 @@ static void init_page_allocator(unsigned
  110.57           * Next chunk is limited by alignment of min, but also
  110.58           * must not be bigger than remaining range.
  110.59           */
  110.60 -        for ( i = PAGE_SHIFT; (1<<(i+1)) <= range; i++ )
  110.61 -            if ( min & (1<<i) ) break;
  110.62 +        for ( i = PAGE_SHIFT; (1UL<<(i+1)) <= range; i++ )
  110.63 +            if ( min & (1UL<<i) ) break;
  110.64  
  110.65  
  110.66          ch = (chunk_head_t *)min;
  110.67 -        min   += (1<<i);
  110.68 -        range -= (1<<i);
  110.69 +        min   += (1UL<<i);
  110.70 +        range -= (1UL<<i);
  110.71          ct = (chunk_tail_t *)min-1;
  110.72          i -= PAGE_SHIFT;
  110.73          ch->level       = i;
  110.74 @@ -280,8 +280,8 @@ unsigned long alloc_pages(int order)
  110.75      {
  110.76          /* Split into two equal parts. */
  110.77          i--;
  110.78 -        spare_ch = (chunk_head_t *)((char *)alloc_ch + (1<<(i+PAGE_SHIFT)));
  110.79 -        spare_ct = (chunk_tail_t *)((char *)spare_ch + (1<<(i+PAGE_SHIFT)))-1;
  110.80 +        spare_ch = (chunk_head_t *)((char *)alloc_ch + (1UL<<(i+PAGE_SHIFT)));
  110.81 +        spare_ct = (chunk_tail_t *)((char *)spare_ch + (1UL<<(i+PAGE_SHIFT)))-1;
  110.82  
  110.83          /* Create new header for spare chunk. */
  110.84          spare_ch->level = i;
  110.85 @@ -294,7 +294,7 @@ unsigned long alloc_pages(int order)
  110.86          free_head[i] = spare_ch;
  110.87      }
  110.88      
  110.89 -    map_alloc(PHYS_PFN(to_phys(alloc_ch)), 1<<order);
  110.90 +    map_alloc(PHYS_PFN(to_phys(alloc_ch)), 1UL<<order);
  110.91  
  110.92      return((unsigned long)alloc_ch);
  110.93  
  110.94 @@ -312,16 +312,16 @@ void free_pages(void *pointer, int order
  110.95      unsigned long mask;
  110.96      
  110.97      /* First free the chunk */
  110.98 -    map_free(virt_to_pfn(pointer), 1 << order);
  110.99 +    map_free(virt_to_pfn(pointer), 1UL << order);
 110.100      
 110.101      /* Create free chunk */
 110.102      freed_ch = (chunk_head_t *)pointer;
 110.103 -    freed_ct = (chunk_tail_t *)((char *)pointer + (1<<(order + PAGE_SHIFT)))-1;
 110.104 +    freed_ct = (chunk_tail_t *)((char *)pointer + (1UL<<(order + PAGE_SHIFT)))-1;
 110.105      
 110.106      /* Now, possibly we can conseal chunks together */
 110.107      while(order < FREELIST_SIZE)
 110.108      {
 110.109 -        mask = 1 << (order + PAGE_SHIFT);
 110.110 +        mask = 1UL << (order + PAGE_SHIFT);
 110.111          if((unsigned long)freed_ch & mask) 
 110.112          {
 110.113              to_merge_ch = (chunk_head_t *)((char *)freed_ch - mask);
 110.114 @@ -361,6 +361,7 @@ void free_pages(void *pointer, int order
 110.115     
 110.116  }
 110.117  
 110.118 +#ifndef __ia64__
 110.119  int free_physical_pages(xen_pfn_t *mfns, int n)
 110.120  {
 110.121      struct xen_memory_reservation reservation;
 110.122 @@ -371,6 +372,7 @@ int free_physical_pages(xen_pfn_t *mfns,
 110.123      reservation.domid = DOMID_SELF;
 110.124      return HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 110.125  }
 110.126 +#endif
 110.127  
 110.128  #ifdef HAVE_LIBC
 110.129  void *sbrk(ptrdiff_t increment)
 110.130 @@ -419,6 +421,10 @@ void init_mm(void)
 110.131      arch_init_demand_mapping_area(max_pfn);
 110.132  }
 110.133  
 110.134 +void fini_mm(void)
 110.135 +{
 110.136 +}
 110.137 +
 110.138  void sanity_check(void)
 110.139  {
 110.140      int x;
   111.1 --- a/extras/mini-os/netfront.c	Fri Aug 29 15:47:21 2008 -0700
   111.2 +++ b/extras/mini-os/netfront.c	Tue Sep 02 16:34:53 2008 -0700
   111.3 @@ -38,7 +38,7 @@ struct net_buffer {
   111.4  struct netfront_dev {
   111.5      domid_t dom;
   111.6  
   111.7 -    unsigned short tx_freelist[NET_TX_RING_SIZE];
   111.8 +    unsigned short tx_freelist[NET_TX_RING_SIZE + 1];
   111.9      struct semaphore tx_sem;
  111.10  
  111.11      struct net_buffer rx_buffers[NET_RX_RING_SIZE];
  111.12 @@ -70,14 +70,14 @@ void init_rx_buffers(struct netfront_dev
  111.13  
  111.14  static inline void add_id_to_freelist(unsigned int id,unsigned short* freelist)
  111.15  {
  111.16 -    freelist[id] = freelist[0];
  111.17 +    freelist[id + 1] = freelist[0];
  111.18      freelist[0]  = id;
  111.19  }
  111.20  
  111.21  static inline unsigned short get_id_from_freelist(unsigned short* freelist)
  111.22  {
  111.23      unsigned int id = freelist[0];
  111.24 -    freelist[0] = freelist[id];
  111.25 +    freelist[0] = freelist[id + 1];
  111.26      return id;
  111.27  }
  111.28  
  111.29 @@ -95,8 +95,9 @@ static inline int xennet_rxidx(RING_IDX 
  111.30  
  111.31  void network_rx(struct netfront_dev *dev)
  111.32  {
  111.33 -    RING_IDX rp,cons;
  111.34 +    RING_IDX rp,cons,req_prod;
  111.35      struct netif_rx_response *rx;
  111.36 +    int nr_consumed, some, more, i, notify;
  111.37  
  111.38  
  111.39  moretodo:
  111.40 @@ -104,12 +105,13 @@ moretodo:
  111.41      rmb(); /* Ensure we see queued responses up to 'rp'. */
  111.42      cons = dev->rx.rsp_cons;
  111.43  
  111.44 -    int nr_consumed=0;
  111.45 -    int some = 0;
  111.46 +    nr_consumed = 0;
  111.47 +    some = 0;
  111.48      while ((cons != rp) && !some)
  111.49      {
  111.50          struct net_buffer* buf;
  111.51          unsigned char* page;
  111.52 +        int id;
  111.53  
  111.54          rx = RING_GET_RESPONSE(&dev->rx, cons);
  111.55  
  111.56 @@ -122,7 +124,7 @@ moretodo:
  111.57  
  111.58          if (rx->status == NETIF_RSP_NULL) continue;
  111.59  
  111.60 -        int id = rx->id;
  111.61 +        id = rx->id;
  111.62          BUG_ON(id >= NET_TX_RING_SIZE);
  111.63  
  111.64          buf = &dev->rx_buffers[id];
  111.65 @@ -151,19 +153,15 @@ moretodo:
  111.66      }
  111.67      dev->rx.rsp_cons=cons;
  111.68  
  111.69 -    int more;
  111.70      RING_FINAL_CHECK_FOR_RESPONSES(&dev->rx,more);
  111.71      if(more && !some) goto moretodo;
  111.72  
  111.73 -    RING_IDX req_prod = dev->rx.req_prod_pvt;
  111.74 -
  111.75 -    int i;
  111.76 -    netif_rx_request_t *req;
  111.77 +    req_prod = dev->rx.req_prod_pvt;
  111.78  
  111.79      for(i=0; i<nr_consumed; i++)
  111.80      {
  111.81          int id = xennet_rxidx(req_prod + i);
  111.82 -        req = RING_GET_REQUEST(&dev->rx, req_prod + i);
  111.83 +        netif_rx_request_t *req = RING_GET_REQUEST(&dev->rx, req_prod + i);
  111.84          struct net_buffer* buf = &dev->rx_buffers[id];
  111.85          void* page = buf->page;
  111.86  
  111.87 @@ -178,7 +176,6 @@ moretodo:
  111.88  
  111.89      dev->rx.req_prod_pvt = req_prod + i;
  111.90      
  111.91 -    int notify;
  111.92      RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&dev->rx, notify);
  111.93      if (notify)
  111.94          notify_remote_via_evtchn(dev->evtchn);
  111.95 @@ -199,6 +196,7 @@ void network_tx_buf_gc(struct netfront_d
  111.96          for (cons = dev->tx.rsp_cons; cons != prod; cons++) 
  111.97          {
  111.98              struct netif_tx_response *txrsp;
  111.99 +            struct net_buffer *buf;
 111.100  
 111.101              txrsp = RING_GET_RESPONSE(&dev->tx, cons);
 111.102              if (txrsp->status == NETIF_RSP_NULL)
 111.103 @@ -209,7 +207,7 @@ void network_tx_buf_gc(struct netfront_d
 111.104  
 111.105              id  = txrsp->id;
 111.106              BUG_ON(id >= NET_TX_RING_SIZE);
 111.107 -            struct net_buffer* buf = &dev->tx_buffers[id];
 111.108 +            buf = &dev->tx_buffers[id];
 111.109              gnttab_end_access(buf->gref);
 111.110              buf->gref=GRANT_INVALID_REF;
 111.111  
 111.112 @@ -259,7 +257,8 @@ void netfront_select_handler(evtchn_port
 111.113      network_tx_buf_gc(dev);
 111.114      local_irq_restore(flags);
 111.115  
 111.116 -    files[fd].read = 1;
 111.117 +    if (fd != -1)
 111.118 +        files[fd].read = 1;
 111.119      wake_up(&netfront_queue);
 111.120  }
 111.121  #endif
 111.122 @@ -297,7 +296,7 @@ static void free_netfront(struct netfron
 111.123      free(dev);
 111.124  }
 111.125  
 111.126 -struct netfront_dev *init_netfront(char *nodename, void (*thenetif_rx)(unsigned char* data, int len), unsigned char rawmac[6], char **ip)
 111.127 +struct netfront_dev *init_netfront(char *_nodename, void (*thenetif_rx)(unsigned char* data, int len), unsigned char rawmac[6], char **ip)
 111.128  {
 111.129      xenbus_transaction_t xbt;
 111.130      char* err;
 111.131 @@ -307,12 +306,10 @@ struct netfront_dev *init_netfront(char 
 111.132      int retry=0;
 111.133      int i;
 111.134      char* msg;
 111.135 +    char* nodename = _nodename ? _nodename : "device/vif/0";
 111.136  
 111.137      struct netfront_dev *dev;
 111.138  
 111.139 -    if (!nodename)
 111.140 -	nodename = "device/vif/0";
 111.141 -
 111.142      char path[strlen(nodename) + 1 + 10 + 1];
 111.143  
 111.144      if (!thenetif_rx)
 111.145 @@ -323,6 +320,9 @@ struct netfront_dev *init_netfront(char 
 111.146      dev = malloc(sizeof(*dev));
 111.147      memset(dev, 0, sizeof(*dev));
 111.148      dev->nodename = strdup(nodename);
 111.149 +#ifdef HAVE_LIBC
 111.150 +    dev->fd = -1;
 111.151 +#endif
 111.152  
 111.153      printk("net TX ring size %d\n", NET_TX_RING_SIZE);
 111.154      printk("net RX ring size %d\n", NET_RX_RING_SIZE);
 111.155 @@ -493,14 +493,27 @@ void shutdown_netfront(struct netfront_d
 111.156      printk("close network: backend at %s\n",dev->backend);
 111.157  
 111.158      snprintf(path, sizeof(path), "%s/state", dev->backend);
 111.159 +
 111.160      err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
 111.161      xenbus_wait_for_value(path, "5", &dev->events);
 111.162  
 111.163      err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
 111.164      xenbus_wait_for_value(path, "6", &dev->events);
 111.165  
 111.166 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
 111.167 +    xenbus_wait_for_value(path, "2", &dev->events);
 111.168 +
 111.169      xenbus_unwatch_path(XBT_NIL, path);
 111.170  
 111.171 +    snprintf(path, sizeof(path), "%s/tx-ring-ref", nodename);
 111.172 +    xenbus_rm(XBT_NIL, path);
 111.173 +    snprintf(path, sizeof(path), "%s/rx-ring-ref", nodename);
 111.174 +    xenbus_rm(XBT_NIL, path);
 111.175 +    snprintf(path, sizeof(path), "%s/event-channel", nodename);
 111.176 +    xenbus_rm(XBT_NIL, path);
 111.177 +    snprintf(path, sizeof(path), "%s/request-rx-copy", nodename);
 111.178 +    xenbus_rm(XBT_NIL, path);
 111.179 +
 111.180      free_netfront(dev);
 111.181  }
 111.182  
 111.183 @@ -597,7 +610,7 @@ ssize_t netfront_receive(struct netfront
 111.184  
 111.185      local_irq_save(flags);
 111.186      network_rx(dev);
 111.187 -    if (!dev->rlen)
 111.188 +    if (!dev->rlen && fd != -1)
 111.189  	/* No data for us, make select stop returning */
 111.190  	files[fd].read = 0;
 111.191      /* Before re-enabling the interrupts, in case a packet just arrived in the
   112.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.2 +++ b/extras/mini-os/pcifront.c	Tue Sep 02 16:34:53 2008 -0700
   112.3 @@ -0,0 +1,371 @@
   112.4 +/* Minimal PCI driver for Mini-OS. 
   112.5 + * Copyright (c) 2007-2008 Samuel Thibault.
   112.6 + * Based on blkfront.c.
   112.7 + */
   112.8 +
   112.9 +#include <os.h>
  112.10 +#include <xenbus.h>
  112.11 +#include <events.h>
  112.12 +#include <errno.h>
  112.13 +#include <gnttab.h>
  112.14 +#include <xmalloc.h>
  112.15 +#include <wait.h>
  112.16 +#include <pcifront.h>
  112.17 +
  112.18 +#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
  112.19 +
  112.20 +DECLARE_WAIT_QUEUE_HEAD(pcifront_queue);
  112.21 +
  112.22 +struct pcifront_dev {
  112.23 +    domid_t dom;
  112.24 +
  112.25 +    struct xen_pci_sharedinfo *info;
  112.26 +    grant_ref_t info_ref;
  112.27 +    evtchn_port_t evtchn;
  112.28 +
  112.29 +    char *nodename;
  112.30 +    char *backend;
  112.31 +
  112.32 +    xenbus_event_queue events;
  112.33 +};
  112.34 +
  112.35 +void pcifront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
  112.36 +{
  112.37 +    wake_up(&pcifront_queue);
  112.38 +}
  112.39 +
  112.40 +static void free_pcifront(struct pcifront_dev *dev)
  112.41 +{
  112.42 +    mask_evtchn(dev->evtchn);
  112.43 +
  112.44 +    free(dev->backend);
  112.45 +
  112.46 +    gnttab_end_access(dev->info_ref);
  112.47 +    free_page(dev->info);
  112.48 +
  112.49 +    unbind_evtchn(dev->evtchn);
  112.50 +
  112.51 +    free(dev->nodename);
  112.52 +    free(dev);
  112.53 +}
  112.54 +
  112.55 +struct pcifront_dev *init_pcifront(char *_nodename)
  112.56 +{
  112.57 +    xenbus_transaction_t xbt;
  112.58 +    char* err;
  112.59 +    char* message=NULL;
  112.60 +    int retry=0;
  112.61 +    char* msg;
  112.62 +    char* nodename = _nodename ? _nodename : "device/pci/0";
  112.63 +    int dom;
  112.64 +
  112.65 +    struct pcifront_dev *dev;
  112.66 +
  112.67 +    char path[strlen(nodename) + 1 + 10 + 1];
  112.68 +
  112.69 +    printk("******************* PCIFRONT for %s **********\n\n\n", nodename);
  112.70 +
  112.71 +    snprintf(path, sizeof(path), "%s/backend-id", nodename);
  112.72 +    dom = xenbus_read_integer(path); 
  112.73 +    if (dom == -1) {
  112.74 +        printk("no backend\n");
  112.75 +        return NULL;
  112.76 +    }
  112.77 +
  112.78 +    dev = malloc(sizeof(*dev));
  112.79 +    memset(dev, 0, sizeof(*dev));
  112.80 +    dev->nodename = strdup(nodename);
  112.81 +    dev->dom = dom;
  112.82 +
  112.83 +    evtchn_alloc_unbound(dev->dom, pcifront_handler, dev, &dev->evtchn);
  112.84 +
  112.85 +    dev->info = (struct xen_pci_sharedinfo*) alloc_page();
  112.86 +    memset(dev->info,0,PAGE_SIZE);
  112.87 +
  112.88 +    dev->info_ref = gnttab_grant_access(dev->dom,virt_to_mfn(dev->info),0);
  112.89 +
  112.90 +    dev->events = NULL;
  112.91 +
  112.92 +again:
  112.93 +    err = xenbus_transaction_start(&xbt);
  112.94 +    if (err) {
  112.95 +        printk("starting transaction\n");
  112.96 +    }
  112.97 +
  112.98 +    err = xenbus_printf(xbt, nodename, "pci-op-ref","%u",
  112.99 +                dev->info_ref);
 112.100 +    if (err) {
 112.101 +        message = "writing pci-op-ref";
 112.102 +        goto abort_transaction;
 112.103 +    }
 112.104 +    err = xenbus_printf(xbt, nodename,
 112.105 +                "event-channel", "%u", dev->evtchn);
 112.106 +    if (err) {
 112.107 +        message = "writing event-channel";
 112.108 +        goto abort_transaction;
 112.109 +    }
 112.110 +    err = xenbus_printf(xbt, nodename,
 112.111 +                "magic", XEN_PCI_MAGIC);
 112.112 +    if (err) {
 112.113 +        message = "writing magic";
 112.114 +        goto abort_transaction;
 112.115 +    }
 112.116 +
 112.117 +    err = xenbus_printf(xbt, nodename, "state", "%u",
 112.118 +            3); /* initialised */
 112.119 +
 112.120 +
 112.121 +    err = xenbus_transaction_end(xbt, 0, &retry);
 112.122 +    if (retry) {
 112.123 +            goto again;
 112.124 +        printk("completing transaction\n");
 112.125 +    }
 112.126 +
 112.127 +    goto done;
 112.128 +
 112.129 +abort_transaction:
 112.130 +    xenbus_transaction_end(xbt, 1, &retry);
 112.131 +    goto error;
 112.132 +
 112.133 +done:
 112.134 +
 112.135 +    snprintf(path, sizeof(path), "%s/backend", nodename);
 112.136 +    msg = xenbus_read(XBT_NIL, path, &dev->backend);
 112.137 +    if (msg) {
 112.138 +        printk("Error %s when reading the backend path %s\n", msg, path);
 112.139 +        goto error;
 112.140 +    }
 112.141 +
 112.142 +    printk("backend at %s\n", dev->backend);
 112.143 +
 112.144 +    {
 112.145 +        char path[strlen(dev->backend) + 1 + 5 + 1];
 112.146 +        snprintf(path, sizeof(path), "%s/state", dev->backend);
 112.147 +
 112.148 +        xenbus_watch_path_token(XBT_NIL, path, path, &dev->events);
 112.149 +
 112.150 +        xenbus_wait_for_value(path, "4", &dev->events);
 112.151 +
 112.152 +        xenbus_printf(xbt, nodename, "state", "%u", 4); /* connected */
 112.153 +    }
 112.154 +    unmask_evtchn(dev->evtchn);
 112.155 +
 112.156 +    printk("**************************\n");
 112.157 +
 112.158 +    return dev;
 112.159 +
 112.160 +error:
 112.161 +    free_pcifront(dev);
 112.162 +    return NULL;
 112.163 +}
 112.164 +
 112.165 +void pcifront_scan(struct pcifront_dev *dev, void (*func)(unsigned int domain, unsigned int bus, unsigned slot, unsigned int fun))
 112.166 +{
 112.167 +    char path[strlen(dev->backend) + 1 + 5 + 10 + 1];
 112.168 +    int i, n;
 112.169 +    char *s, *msg;
 112.170 +    unsigned int domain, bus, slot, fun;
 112.171 +
 112.172 +    snprintf(path, sizeof(path), "%s/num_devs", dev->backend);
 112.173 +    n = xenbus_read_integer(path);
 112.174 +
 112.175 +    for (i = 0; i < n; i++) {
 112.176 +        snprintf(path, sizeof(path), "%s/vdev-%d", dev->backend, i);
 112.177 +        msg = xenbus_read(XBT_NIL, path, &s);
 112.178 +        if (msg) {
 112.179 +            printk("Error %s when reading the PCI root name at %s\n", path);
 112.180 +            continue;
 112.181 +        }
 112.182 +
 112.183 +        if (sscanf(s, "%x:%x:%x.%x", &domain, &bus, &slot, &fun) != 4) {
 112.184 +            printk("\"%s\" does not look like a PCI device address\n", s);
 112.185 +            free(s);
 112.186 +            continue;
 112.187 +        }
 112.188 +        free(s);
 112.189 +
 112.190 +        func(domain, bus, slot, fun);
 112.191 +    }
 112.192 +}
 112.193 +
 112.194 +void shutdown_pcifront(struct pcifront_dev *dev)
 112.195 +{
 112.196 +    char* err;
 112.197 +    char *nodename = dev->nodename;
 112.198 +
 112.199 +    char path[strlen(dev->backend) + 1 + 5 + 1];
 112.200 +
 112.201 +    printk("close pci: backend at %s\n",dev->backend);
 112.202 +
 112.203 +    snprintf(path, sizeof(path), "%s/state", dev->backend);
 112.204 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */
 112.205 +    xenbus_wait_for_value(path, "5", &dev->events);
 112.206 +
 112.207 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
 112.208 +    xenbus_wait_for_value(path, "6", &dev->events);
 112.209 +
 112.210 +    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
 112.211 +    xenbus_wait_for_value(path, "2", &dev->events);
 112.212 +
 112.213 +    xenbus_unwatch_path(XBT_NIL, path);
 112.214 +
 112.215 +    snprintf(path, sizeof(path), "%s/info-ref", nodename);
 112.216 +    xenbus_rm(XBT_NIL, path);
 112.217 +    snprintf(path, sizeof(path), "%s/event-channel", nodename);
 112.218 +    xenbus_rm(XBT_NIL, path);
 112.219 +
 112.220 +    free_pcifront(dev);
 112.221 +}
 112.222 +
 112.223 +
 112.224 +void pcifront_op(struct pcifront_dev *dev, struct xen_pci_op *op)
 112.225 +{
 112.226 +    dev->info->op = *op;
 112.227 +    /* Make sure info is written before the flag */
 112.228 +    wmb();
 112.229 +    set_bit(_XEN_PCIF_active, (void*) &dev->info->flags);
 112.230 +    notify_remote_via_evtchn(dev->evtchn);
 112.231 +
 112.232 +    wait_event(pcifront_queue, !test_bit(_XEN_PCIF_active, (void*) &dev->info->flags));
 112.233 +
 112.234 +    /* Make sure flag is read before info */
 112.235 +    rmb();
 112.236 +    *op = dev->info->op;
 112.237 +}
 112.238 +
 112.239 +int pcifront_conf_read(struct pcifront_dev *dev,
 112.240 +                       unsigned int dom,
 112.241 +                       unsigned int bus, unsigned int slot, unsigned long fun,
 112.242 +                       unsigned int off, unsigned int size, unsigned int *val)
 112.243 +{
 112.244 +    struct xen_pci_op op;
 112.245 +
 112.246 +    memset(&op, 0, sizeof(op));
 112.247 +
 112.248 +    op.cmd = XEN_PCI_OP_conf_read;
 112.249 +    op.domain = dom;
 112.250 +    op.bus = bus;
 112.251 +    op.devfn = PCI_DEVFN(slot, fun);
 112.252 +    op.offset = off;
 112.253 +    op.size = size;
 112.254 +
 112.255 +    pcifront_op(dev, &op);
 112.256 +
 112.257 +    if (op.err)
 112.258 +        return op.err;
 112.259 +
 112.260 +    *val = op.value;
 112.261 +
 112.262 +    return 0;
 112.263 +}
 112.264 +
 112.265 +int pcifront_conf_write(struct pcifront_dev *dev,
 112.266 +                        unsigned int dom,
 112.267 +                        unsigned int bus, unsigned int slot, unsigned long fun,
 112.268 +                        unsigned int off, unsigned int size, unsigned int val)
 112.269 +{
 112.270 +    struct xen_pci_op op;
 112.271 +
 112.272 +    memset(&op, 0, sizeof(op));
 112.273 +
 112.274 +    op.cmd = XEN_PCI_OP_conf_write;
 112.275 +    op.domain = dom;
 112.276 +    op.bus = bus;
 112.277 +    op.devfn = PCI_DEVFN(slot, fun);
 112.278 +    op.offset = off;
 112.279 +    op.size = size;
 112.280 +
 112.281 +    op.value = val;
 112.282 +
 112.283 +    pcifront_op(dev, &op);
 112.284 +
 112.285 +    return op.err;
 112.286 +}
 112.287 +
 112.288 +int pcifront_enable_msi(struct pcifront_dev *dev,
 112.289 +                        unsigned int dom,
 112.290 +                        unsigned int bus, unsigned int slot, unsigned long fun)
 112.291 +{
 112.292 +    struct xen_pci_op op;
 112.293 +
 112.294 +    memset(&op, 0, sizeof(op));
 112.295 +
 112.296 +    op.cmd = XEN_PCI_OP_enable_msi;
 112.297 +    op.domain = dom;
 112.298 +    op.bus = bus;
 112.299 +    op.devfn = PCI_DEVFN(slot, fun);
 112.300 +
 112.301 +    pcifront_op(dev, &op);
 112.302 +    
 112.303 +    if (op.err)
 112.304 +        return op.err;
 112.305 +    else
 112.306 +        return op.value;
 112.307 +}
 112.308 +
 112.309 +int pcifront_disable_msi(struct pcifront_dev *dev,
 112.310 +                         unsigned int dom,
 112.311 +                         unsigned int bus, unsigned int slot, unsigned long fun)
 112.312 +{
 112.313 +    struct xen_pci_op op;
 112.314 +
 112.315 +    memset(&op, 0, sizeof(op));
 112.316 +
 112.317 +    op.cmd = XEN_PCI_OP_disable_msi;
 112.318 +    op.domain = dom;
 112.319 +    op.bus = bus;
 112.320 +    op.devfn = PCI_DEVFN(slot, fun);
 112.321 +
 112.322 +    pcifront_op(dev, &op);
 112.323 +    
 112.324 +    return op.err;
 112.325 +}
 112.326 +
 112.327 +int pcifront_enable_msix(struct pcifront_dev *dev,
 112.328 +                         unsigned int dom,
 112.329 +                         unsigned int bus, unsigned int slot, unsigned long fun,
 112.330 +                         struct xen_msix_entry *entries, int n)
 112.331 +{
 112.332 +    struct xen_pci_op op;
 112.333 +
 112.334 +    if (n > SH_INFO_MAX_VEC)
 112.335 +        return XEN_PCI_ERR_op_failed;
 112.336 +
 112.337 +    memset(&op, 0, sizeof(op));
 112.338 +
 112.339 +    op.cmd = XEN_PCI_OP_enable_msix;
 112.340 +    op.domain = dom;
 112.341 +    op.bus = bus;
 112.342 +    op.devfn = PCI_DEVFN(slot, fun);
 112.343 +    op.value = n;
 112.344 +
 112.345 +    memcpy(op.msix_entries, entries, n * sizeof(*entries));
 112.346 +
 112.347 +    pcifront_op(dev, &op);
 112.348 +    
 112.349 +    if (op.err)
 112.350 +        return op.err;
 112.351 +
 112.352 +    memcpy(entries, op.msix_entries, n * sizeof(*entries));
 112.353 +
 112.354 +    return 0;
 112.355 +}
 112.356 +
 112.357 +
 112.358 +int pcifront_disable_msix(struct pcifront_dev *dev,
 112.359 +                          unsigned int dom,
 112.360 +                          unsigned int bus, unsigned int slot, unsigned long fun)
 112.361 +{
 112.362 +    struct xen_pci_op op;
 112.363 +
 112.364 +    memset(&op, 0, sizeof(op));
 112.365 +
 112.366 +    op.cmd = XEN_PCI_OP_disable_msix;
 112.367 +    op.domain = dom;
 112.368 +    op.bus = bus;
 112.369 +    op.devfn = PCI_DEVFN(slot, fun);
 112.370 +
 112.371 +    pcifront_op(dev, &op);
 112.372 +    
 112.373 +    return op.err;
 112.374 +}
   113.1 --- a/extras/mini-os/sched.c	Fri Aug 29 15:47:21 2008 -0700
   113.2 +++ b/extras/mini-os/sched.c	Tue Sep 02 16:34:53 2008 -0700
   113.3 @@ -55,16 +55,18 @@
   113.4  #endif
   113.5  
   113.6  struct thread *idle_thread = NULL;
   113.7 -LIST_HEAD(exited_threads);
   113.8 +MINIOS_LIST_HEAD(exited_threads);
   113.9  static int threads_started;
  113.10  
  113.11 +struct thread *main_thread;
  113.12 +
  113.13  void inline print_runqueue(void)
  113.14  {
  113.15 -    struct list_head *it;
  113.16 +    struct minios_list_head *it;
  113.17      struct thread *th;
  113.18 -    list_for_each(it, &idle_thread->thread_list)
  113.19 +    minios_list_for_each(it, &idle_thread->thread_list)
  113.20      {
  113.21 -        th = list_entry(it, struct thread, thread_list);
  113.22 +        th = minios_list_entry(it, struct thread, thread_list);
  113.23          printk("   Thread \"%s\", runnable=%d\n", th->name, is_runnable(th));
  113.24      }
  113.25      printk("\n");
  113.26 @@ -73,7 +75,7 @@ void inline print_runqueue(void)
  113.27  void schedule(void)
  113.28  {
  113.29      struct thread *prev, *next, *thread;
  113.30 -    struct list_head *iterator;
  113.31 +    struct minios_list_head *iterator, *next_iterator;
  113.32      unsigned long flags;
  113.33  
  113.34      prev = current;
  113.35 @@ -95,9 +97,9 @@ void schedule(void)
  113.36          s_time_t now = NOW();
  113.37          s_time_t min_wakeup_time = now + SECONDS(10);
  113.38          next = NULL;   
  113.39 -        list_for_each(iterator, &idle_thread->thread_list)
  113.40 +        minios_list_for_each_safe(iterator, next_iterator, &idle_thread->thread_list)
  113.41          {
  113.42 -            thread = list_entry(iterator, struct thread, thread_list);
  113.43 +            thread = minios_list_entry(iterator, struct thread, thread_list);
  113.44              if (!is_runnable(thread) && thread->wakeup_time != 0LL)
  113.45              {
  113.46                  if (thread->wakeup_time <= now)
  113.47 @@ -109,8 +111,8 @@ void schedule(void)
  113.48              {
  113.49                  next = thread;
  113.50                  /* Put this thread on the end of the list */
  113.51 -                list_del(&thread->thread_list);
  113.52 -                list_add_tail(&thread->thread_list, &idle_thread->thread_list);
  113.53 +                minios_list_del(&thread->thread_list);
  113.54 +                minios_list_add_tail(&thread->thread_list, &idle_thread->thread_list);
  113.55                  break;
  113.56              }
  113.57          }
  113.58 @@ -126,12 +128,12 @@ void schedule(void)
  113.59         inturrupted at the return instruction. And therefore at safe point. */
  113.60      if(prev != next) switch_threads(prev, next);
  113.61  
  113.62 -    list_for_each(iterator, &exited_threads)
  113.63 +    minios_list_for_each_safe(iterator, next_iterator, &exited_threads)
  113.64      {
  113.65 -        thread = list_entry(iterator, struct thread, thread_list);
  113.66 +        thread = minios_list_entry(iterator, struct thread, thread_list);
  113.67          if(thread != prev)
  113.68          {
  113.69 -            list_del(&thread->thread_list);
  113.70 +            minios_list_del(&thread->thread_list);
  113.71              free_pages(thread->stack, STACK_SIZE_PAGE_ORDER);
  113.72              xfree(thread);
  113.73          }
  113.74 @@ -153,7 +155,7 @@ struct thread* create_thread(char *name,
  113.75      set_runnable(thread);
  113.76      local_irq_save(flags);
  113.77      if(idle_thread != NULL) {
  113.78 -        list_add_tail(&thread->thread_list, &idle_thread->thread_list); 
  113.79 +        minios_list_add_tail(&thread->thread_list, &idle_thread->thread_list); 
  113.80      } else if(function != idle_thread_fn)
  113.81      {
  113.82          printk("BUG: Not allowed to create thread before initialising scheduler.\n");
  113.83 @@ -206,10 +208,10 @@ void exit_thread(void)
  113.84      printk("Thread \"%s\" exited.\n", thread->name);
  113.85      local_irq_save(flags);
  113.86      /* Remove from the thread list */
  113.87 -    list_del(&thread->thread_list);
  113.88 +    minios_list_del(&thread->thread_list);
  113.89      clear_runnable(thread);
  113.90      /* Put onto exited list */
  113.91 -    list_add(&thread->thread_list, &exited_threads);
  113.92 +    minios_list_add(&thread->thread_list, &exited_threads);
  113.93      local_irq_restore(flags);
  113.94      /* Schedule will free the resources */
  113.95      while(1)
  113.96 @@ -294,6 +296,6 @@ void init_sched(void)
  113.97      _REENT_INIT_PTR((&callback_reent))
  113.98  #endif
  113.99      idle_thread = create_thread("Idle", idle_thread_fn, NULL);
 113.100 -    INIT_LIST_HEAD(&idle_thread->thread_list);
 113.101 +    MINIOS_INIT_LIST_HEAD(&idle_thread->thread_list);
 113.102  }
 113.103  
   114.1 --- a/extras/mini-os/xenbus/xenbus.c	Fri Aug 29 15:47:21 2008 -0700
   114.2 +++ b/extras/mini-os/xenbus/xenbus.c	Tue Sep 02 16:34:53 2008 -0700
   114.3 @@ -78,9 +78,9 @@ static void memcpy_from_ring(const void 
   114.4  char **xenbus_wait_for_watch_return(xenbus_event_queue *queue)
   114.5  {
   114.6      struct xenbus_event *event;
   114.7 +    DEFINE_WAIT(w);
   114.8      if (!queue)
   114.9          queue = &xenbus_events;
  114.10 -    DEFINE_WAIT(w);
  114.11      while (!(event = *queue)) {
  114.12          add_waiter(w, xenbus_watch_queue);
  114.13          schedule();
  114.14 @@ -124,7 +124,7 @@ char* xenbus_wait_for_value(const char* 
  114.15  static void xenbus_thread_func(void *ign)
  114.16  {
  114.17      struct xsd_sockmsg msg;
  114.18 -    unsigned prod = 0;
  114.19 +    unsigned prod = xenstore_buf->rsp_prod;
  114.20  
  114.21      for (;;) 
  114.22      {
  114.23 @@ -174,9 +174,14 @@ static void xenbus_thread_func(void *ign
  114.24                          break;
  114.25                      }
  114.26  
  114.27 -		event->next = *events;
  114.28 -		*events = event;
  114.29 -                wake_up(&xenbus_watch_queue);
  114.30 +                if (events) {
  114.31 +                    event->next = *events;
  114.32 +                    *events = event;
  114.33 +                    wake_up(&xenbus_watch_queue);
  114.34 +                } else {
  114.35 +                    printk("unexpected watch token %s\n", event->token);
  114.36 +                    free(event);
  114.37 +                }
  114.38              }
  114.39  
  114.40              else
  114.41 @@ -265,6 +270,10 @@ void init_xenbus(void)
  114.42      DEBUG("xenbus on irq %d\n", err);
  114.43  }
  114.44  
  114.45 +void fini_xenbus(void)
  114.46 +{
  114.47 +}
  114.48 +
  114.49  /* Send data to xenbus.  This can block.  All of the requests are seen
  114.50     by xenbus as if sent atomically.  The header is added
  114.51     automatically, using type %type, req_id %req_id, and trans_id
  114.52 @@ -373,6 +382,7 @@ xenbus_msg_reply(int type,
  114.53  
  114.54  static char *errmsg(struct xsd_sockmsg *rep)
  114.55  {
  114.56 +    char *res;
  114.57      if (!rep) {
  114.58  	char msg[] = "No reply";
  114.59  	size_t len = strlen(msg) + 1;
  114.60 @@ -380,7 +390,7 @@ static char *errmsg(struct xsd_sockmsg *
  114.61      }
  114.62      if (rep->type != XS_ERROR)
  114.63  	return NULL;
  114.64 -    char *res = malloc(rep->len + 1);
  114.65 +    res = malloc(rep->len + 1);
  114.66      memcpy(res, rep + 1, rep->len);
  114.67      res[rep->len] = 0;
  114.68      free(rep);
  114.69 @@ -410,10 +420,10 @@ char *xenbus_ls(xenbus_transaction_t xbt
  114.70      struct xsd_sockmsg *reply, *repmsg;
  114.71      struct write_req req[] = { { pre, strlen(pre)+1 } };
  114.72      int nr_elems, x, i;
  114.73 -    char **res;
  114.74 +    char **res, *msg;
  114.75  
  114.76      repmsg = xenbus_msg_reply(XS_DIRECTORY, xbt, req, ARRAY_SIZE(req));
  114.77 -    char *msg = errmsg(repmsg);
  114.78 +    msg = errmsg(repmsg);
  114.79      if (msg) {
  114.80  	*contents = NULL;
  114.81  	return msg;
  114.82 @@ -438,9 +448,9 @@ char *xenbus_read(xenbus_transaction_t x
  114.83  {
  114.84      struct write_req req[] = { {path, strlen(path) + 1} };
  114.85      struct xsd_sockmsg *rep;
  114.86 -    char *res;
  114.87 +    char *res, *msg;
  114.88      rep = xenbus_msg_reply(XS_READ, xbt, req, ARRAY_SIZE(req));
  114.89 -    char *msg = errmsg(rep);
  114.90 +    msg = errmsg(rep);
  114.91      if (msg) {
  114.92  	*value = NULL;
  114.93  	return msg;
  114.94 @@ -460,8 +470,9 @@ char *xenbus_write(xenbus_transaction_t 
  114.95  	{value, strlen(value)},
  114.96      };
  114.97      struct xsd_sockmsg *rep;
  114.98 +    char *msg;
  114.99      rep = xenbus_msg_reply(XS_WRITE, xbt, req, ARRAY_SIZE(req));
 114.100 -    char *msg = errmsg(rep);
 114.101 +    msg = errmsg(rep);
 114.102      if (msg) return msg;
 114.103      free(rep);
 114.104      return NULL;
 114.105 @@ -478,6 +489,8 @@ char* xenbus_watch_path_token( xenbus_tr
 114.106  
 114.107      struct watch *watch = malloc(sizeof(*watch));
 114.108  
 114.109 +    char *msg;
 114.110 +
 114.111      if (!events)
 114.112          events = &xenbus_events;
 114.113  
 114.114 @@ -488,7 +501,7 @@ char* xenbus_watch_path_token( xenbus_tr
 114.115  
 114.116      rep = xenbus_msg_reply(XS_WATCH, xbt, req, ARRAY_SIZE(req));
 114.117  
 114.118 -    char *msg = errmsg(rep);
 114.119 +    msg = errmsg(rep);
 114.120      if (msg) return msg;
 114.121      free(rep);
 114.122  
 114.123 @@ -506,9 +519,11 @@ char* xenbus_unwatch_path_token( xenbus_
 114.124  
 114.125      struct watch *watch, **prev;
 114.126  
 114.127 +    char *msg;
 114.128 +
 114.129      rep = xenbus_msg_reply(XS_UNWATCH, xbt, req, ARRAY_SIZE(req));
 114.130  
 114.131 -    char *msg = errmsg(rep);
 114.132 +    msg = errmsg(rep);
 114.133      if (msg) return msg;
 114.134      free(rep);
 114.135  
 114.136 @@ -527,8 +542,9 @@ char *xenbus_rm(xenbus_transaction_t xbt
 114.137  {
 114.138      struct write_req req[] = { {path, strlen(path) + 1} };
 114.139      struct xsd_sockmsg *rep;
 114.140 +    char *msg;
 114.141      rep = xenbus_msg_reply(XS_RM, xbt, req, ARRAY_SIZE(req));
 114.142 -    char *msg = errmsg(rep);
 114.143 +    msg = errmsg(rep);
 114.144      if (msg)
 114.145  	return msg;
 114.146      free(rep);
 114.147 @@ -539,9 +555,9 @@ char *xenbus_get_perms(xenbus_transactio
 114.148  {
 114.149      struct write_req req[] = { {path, strlen(path) + 1} };
 114.150      struct xsd_sockmsg *rep;
 114.151 -    char *res;
 114.152 +    char *res, *msg;
 114.153      rep = xenbus_msg_reply(XS_GET_PERMS, xbt, req, ARRAY_SIZE(req));
 114.154 -    char *msg = errmsg(rep);
 114.155 +    msg = errmsg(rep);
 114.156      if (msg) {
 114.157  	*value = NULL;
 114.158  	return msg;
 114.159 @@ -558,14 +574,16 @@ char *xenbus_get_perms(xenbus_transactio
 114.160  char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm)
 114.161  {
 114.162      char value[PERM_MAX_SIZE];
 114.163 -    snprintf(value, PERM_MAX_SIZE, "%c%hu", perm, dom);
 114.164      struct write_req req[] = { 
 114.165  	{path, strlen(path) + 1},
 114.166 -	{value, strlen(value) + 1},
 114.167 +	{value, 0},
 114.168      };
 114.169      struct xsd_sockmsg *rep;
 114.170 +    char *msg;
 114.171 +    snprintf(value, PERM_MAX_SIZE, "%c%hu", perm, dom);
 114.172 +    req[1].len = strlen(value) + 1;
 114.173      rep = xenbus_msg_reply(XS_SET_PERMS, xbt, req, ARRAY_SIZE(req));
 114.174 -    char *msg = errmsg(rep);
 114.175 +    msg = errmsg(rep);
 114.176      if (msg)
 114.177  	return msg;
 114.178      free(rep);
 114.179 @@ -650,11 +668,11 @@ char* xenbus_printf(xenbus_transaction_t
 114.180  
 114.181  static void do_ls_test(const char *pre)
 114.182  {
 114.183 -    char **dirs;
 114.184 +    char **dirs, *msg;
 114.185      int x;
 114.186  
 114.187      DEBUG("ls %s...\n", pre);
 114.188 -    char *msg = xenbus_ls(XBT_NIL, pre, &dirs);
 114.189 +    msg = xenbus_ls(XBT_NIL, pre, &dirs);
 114.190      if (msg) {
 114.191  	DEBUG("Error in xenbus ls: %s\n", msg);
 114.192  	free(msg);
 114.193 @@ -670,9 +688,9 @@ static void do_ls_test(const char *pre)
 114.194  
 114.195  static void do_read_test(const char *path)
 114.196  {
 114.197 -    char *res;
 114.198 +    char *res, *msg;
 114.199      DEBUG("Read %s...\n", path);
 114.200 -    char *msg = xenbus_read(XBT_NIL, path, &res);
 114.201 +    msg = xenbus_read(XBT_NIL, path, &res);
 114.202      if (msg) {
 114.203  	DEBUG("Error in xenbus read: %s\n", msg);
 114.204  	free(msg);
 114.205 @@ -684,8 +702,9 @@ static void do_read_test(const char *pat
 114.206  
 114.207  static void do_write_test(const char *path, const char *val)
 114.208  {
 114.209 +    char *msg;
 114.210      DEBUG("Write %s to %s...\n", val, path);
 114.211 -    char *msg = xenbus_write(XBT_NIL, path, val);
 114.212 +    msg = xenbus_write(XBT_NIL, path, val);
 114.213      if (msg) {
 114.214  	DEBUG("Result %s\n", msg);
 114.215  	free(msg);
 114.216 @@ -696,8 +715,9 @@ static void do_write_test(const char *pa
 114.217  
 114.218  static void do_rm_test(const char *path)
 114.219  {
 114.220 +    char *msg;
 114.221      DEBUG("rm %s...\n", path);
 114.222 -    char *msg = xenbus_rm(XBT_NIL, path);
 114.223 +    msg = xenbus_rm(XBT_NIL, path);
 114.224      if (msg) {
 114.225  	DEBUG("Result %s\n", msg);
 114.226  	free(msg);
   115.1 --- a/stubdom/Makefile	Fri Aug 29 15:47:21 2008 -0700
   115.2 +++ b/stubdom/Makefile	Tue Sep 02 16:34:53 2008 -0700
   115.3 @@ -1,18 +1,25 @@
   115.4  XEN_ROOT = ..
   115.5 +MINI_OS = $(XEN_ROOT)/extras/mini-os
   115.6  
   115.7  export XEN_OS=MiniOS
   115.8  
   115.9 -include $(XEN_ROOT)/Config.mk
  115.10  export stubdom=y
  115.11  export debug=y
  115.12 +include $(XEN_ROOT)/Config.mk
  115.13  
  115.14 -IOEMU_OPTIONS=--disable-vnc-tls 
  115.15 -BINUTILS_VERSION=2.18
  115.16 -GCC_VERSION=4.2.2
  115.17 +override CONFIG_QEMU=ioemu
  115.18 +
  115.19 +IOEMU_OPTIONS=--disable-sdl --disable-opengl --disable-gfx-check --disable-vnc-tls --disable-brlapi --disable-kqemu
  115.20 +ZLIB_URL?=http://www.zlib.net
  115.21  ZLIB_VERSION=1.2.3
  115.22 +LIBPCI_URL?=http://www.kernel.org/pub/software/utils/pciutils
  115.23  LIBPCI_VERSION=2.2.9
  115.24 -NEWLIB_DATE=2008-01-01
  115.25 -LWIP_DATE=2008-02-08
  115.26 +NEWLIB_URL?=ftp://sources.redhat.com/pub/newlib
  115.27 +NEWLIB_VERSION=1.16.0
  115.28 +LWIP_URL?=http://download.savannah.gnu.org/releases/lwip
  115.29 +LWIP_VERSION=1.3.0
  115.30 +GRUB_URL?=http://alpha.gnu.org/gnu/grub
  115.31 +GRUB_VERSION=0.97
  115.32  
  115.33  WGET=wget -c
  115.34  
  115.35 @@ -23,9 +30,13 @@ endif
  115.36  
  115.37  ifeq ($(GNU_TARGET_ARCH), i686)
  115.38  TARGET_CFLAGS=
  115.39 +NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
  115.40 +STUBDOM_SUPPORTED=1
  115.41  endif
  115.42  ifeq ($(GNU_TARGET_ARCH), x86_64)
  115.43  TARGET_CFLAGS=-mno-red-zone
  115.44 +NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
  115.45 +STUBDOM_SUPPORTED=1
  115.46  endif
  115.47  ifeq ($(GNU_TARGET_ARCH), ia64)
  115.48  TARGET_CFLAGS=-mconstant-gp
  115.49 @@ -33,88 +44,76 @@ endif
  115.50  
  115.51  CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
  115.52  CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
  115.53 -export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf-
  115.54 -export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
  115.55 +
  115.56 +# Disable PIE/SSP if GCC supports them. They can break us.
  115.57 +TARGET_CFLAGS += $(CFLAGS)
  115.58 +TARGET_CPPFLAGS += $(CPPFLAGS)
  115.59 +TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
  115.60 +TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
  115.61 +TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
  115.62 +
  115.63 +# Do not use host headers and libs
  115.64 +GCC_INSTALL = $(shell gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
  115.65 +TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
  115.66 +TARGET_CPPFLAGS += -nostdinc
  115.67 +TARGET_CPPFLAGS += -isystem $(CURDIR)/$(MINI_OS)/include/posix
  115.68 +TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
  115.69 +TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
  115.70 +TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/src/include
  115.71 +TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/src/include/ipv4
  115.72 +TARGET_CPPFLAGS += -I$(CURDIR)/include
  115.73 +
  115.74 +TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
  115.75 +
  115.76 +TARGETS=ioemu c caml grub
  115.77  
  115.78  .PHONY: all
  115.79 -all: qemu-stubdom
  115.80 -
  115.81 -################
  115.82 -# Cross-binutils
  115.83 -################
  115.84 -
  115.85 -binutils-$(BINUTILS_VERSION).tar.bz2:
  115.86 -	$(WGET) http://ftp.gnu.org/gnu/binutils/$@
  115.87 -binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
  115.88 -	tar xjf $@.tar.bz2
  115.89 -	( cd binutils-$(BINUTILS_VERSION) && patch -p1 < ../binutils.patch )
  115.90 -	touch $@
  115.91 -
  115.92 -BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar
  115.93 -.PHONY: cross-binutils
  115.94 -cross-binutils: $(BINUTILS_STAMPFILE)
  115.95 -$(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION)
  115.96 -	mkdir -p binutils-build
  115.97 -	( cd binutils-build && \
  115.98 -	  ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \
  115.99 -	  $(MAKE) && \
 115.100 -	  $(MAKE) check && \
 115.101 -	  $(MAKE) install )
 115.102 -
 115.103 -###########
 115.104 -# Cross-gcc
 115.105 -###########
 115.106 -
 115.107 -gcc-$(GCC_VERSION).tar.bz2:
 115.108 -	$(WGET) http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2
 115.109 -gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
 115.110 -	tar xjf gcc-$(GCC_VERSION).tar.bz2
 115.111 -	( cd gcc-$(GCC_VERSION) && patch -p1 < ../gcc.patch )
 115.112 -	touch $@
 115.113 -	
 115.114 -GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION)
 115.115 -.PHONY: cross-gcc
 115.116 -cross-gcc: $(GCC_STAMPFILE)
 115.117 -$(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE)
 115.118 -	mkdir -p gcc-build
 115.119 -	( cd gcc-build && \
 115.120 -	  ../gcc-$(GCC_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-languages=c --disable-libssp --with-gnu-as --with-gnu-ld && \
 115.121 -	  $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \
 115.122 -	  $(MAKE) install )
 115.123 +all: build
 115.124 +ifeq ($(STUBDOM_SUPPORTED),1)
 115.125 +build: ioemu-stubdom c-stubdom pv-grub
 115.126 +else
 115.127 +build:
 115.128 +endif
 115.129  
 115.130  ##############
 115.131  # Cross-newlib
 115.132  ##############
 115.133  
 115.134 -newlib-cvs:
 115.135 -	cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib
 115.136 -	mv src newlib-cvs
 115.137 -	( cd newlib-cvs && patch -p0 < ../newlib.patch)
 115.138 +newlib-$(NEWLIB_VERSION).tar.gz:
 115.139 +	$(WGET) $(NEWLIB_URL)/$@
 115.140 +
 115.141 +newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
 115.142 +	tar xzf $<
 115.143 +	patch -d $@ -p0 < newlib.patch
 115.144 +	touch $@
 115.145  
 115.146  NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
 115.147  .PHONY: cross-newlib
 115.148  cross-newlib: $(NEWLIB_STAMPFILE)
 115.149 -$(NEWLIB_STAMPFILE): newlib-cvs $(GCC_STAMPFILE)
 115.150 -	mkdir -p newlib-build
 115.151 -	( cd newlib-build && \
 115.152 -	  CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
 115.153 +$(NEWLIB_STAMPFILE): mk-headers-$(XEN_TARGET_ARCH) newlib-$(NEWLIB_VERSION)
 115.154 +	mkdir -p newlib-$(XEN_TARGET_ARCH)
 115.155 +	( cd newlib-$(XEN_TARGET_ARCH) && \
 115.156 +	  CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \
 115.157  	  $(MAKE) && \
 115.158 -	  $(MAKE) install )
 115.159 +	  DESTDIR= $(MAKE) install )
 115.160  
 115.161  ############
 115.162  # Cross-zlib
 115.163  ############
 115.164  
 115.165  zlib-$(ZLIB_VERSION).tar.gz:
 115.166 -	$(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
 115.167 +	$(WGET) $(ZLIB_URL)/$@
 115.168 +
 115.169 +zlib-$(XEN_TARGET_ARCH): zlib-$(ZLIB_VERSION).tar.gz 
 115.170 +	tar xzf $<
 115.171 +	mv zlib-$(ZLIB_VERSION) $@
 115.172  
 115.173  ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
 115.174  .PHONY: cross-zlib
 115.175  cross-zlib: $(ZLIB_STAMPFILE)
 115.176 -$(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
 115.177 -	tar xzf $<
 115.178 -	( cd zlib-$(ZLIB_VERSION) && \
 115.179 -	  CFLAGS="$(TARGET_CFLAGS)" CC=$(GNU_TARGET_ARCH)-xen-elf-gcc ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
 115.180 +$(ZLIB_STAMPFILE): zlib-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
 115.181 +	( cd $< && \
 115.182 +	  CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
 115.183  	  $(MAKE) libz.a && \
 115.184  	  $(MAKE) install )
 115.185  
 115.186 @@ -123,30 +122,40 @@ cross-zlib: $(ZLIB_STAMPFILE)
 115.187  ##############
 115.188  
 115.189  pciutils-$(LIBPCI_VERSION).tar.bz2:
 115.190 -	$(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
 115.191 +	$(WGET) $(LIBPCI_URL)/$@
 115.192 +
 115.193 +pciutils-$(XEN_TARGET_ARCH): pciutils-$(LIBPCI_VERSION).tar.bz2
 115.194 +	tar xjf $<
 115.195 +	mv pciutils-$(LIBPCI_VERSION) $@
 115.196 +	patch -d $@ -p1 < pciutils.patch
 115.197 +	touch $@
 115.198  
 115.199  LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
 115.200  .PHONY: cross-libpci
 115.201  cross-libpci: $(LIBPCI_STAMPFILE)
 115.202 -$(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
 115.203 -	tar xjf $<
 115.204 -	( cd pciutils-$(LIBPCI_VERSION) && \
 115.205 +$(LIBPCI_STAMPFILE): pciutils-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
 115.206 +	( cd $< && \
 115.207  	  cp ../libpci.config.h lib/config.h && \
 115.208  	  echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
 115.209  	  cp ../libpci.config.mak lib/config.mk && \
 115.210 -	  $(MAKE) CC="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" lib/libpci.a && \
 115.211 +	  $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
 115.212  	  $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
 115.213  	  $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
 115.214 -	  $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
 115.215 +	  $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
 115.216  	)
 115.217  
 115.218  ######
 115.219  # lwIP
 115.220  ######
 115.221  
 115.222 -lwip-cvs:
 115.223 -	cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) lwip
 115.224 -	mv lwip lwip-cvs
 115.225 +lwip-$(LWIP_VERSION).tar.gz:
 115.226 +	$(WGET) $(LWIP_URL)/$@
 115.227 +
 115.228 +lwip-$(XEN_TARGET_ARCH): lwip-$(LWIP_VERSION).tar.gz
 115.229 +	tar xzf $<
 115.230 +	mv lwip $@
 115.231 +	patch -d $@ -p0 < lwip.patch-cvs
 115.232 +	touch $@
 115.233  
 115.234  #######
 115.235  # Links
 115.236 @@ -155,83 +164,162 @@ lwip-cvs:
 115.237  .PHONY: $(CROSS_ROOT)
 115.238  $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
 115.239  
 115.240 -.PHONY: mk-symlinks
 115.241 -mk-symlinks:
 115.242 -	[ -h include ] || ln -sf ../tools/include .
 115.243 -	mkdir -p libxc
 115.244 -	[ -h libxc/Makefile ] || ( cd libxc && \
 115.245 -	  ln -sf ../../tools/libxc/*.h . && \
 115.246 -	  ln -sf ../../tools/libxc/*.c . && \
 115.247 -	  ln -sf ../../tools/libxc/Makefile . )
 115.248 -	mkdir -p libxc/$(XEN_TARGET_ARCH)
 115.249 -	[ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
 115.250 -	  ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
 115.251 -	  ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
 115.252 -	  ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
 115.253 +mk-headers-$(XEN_TARGET_ARCH):
 115.254 +	mkdir -p include/xen && \
 115.255 +          ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
 115.256 +          ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \
 115.257 +          ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
 115.258 +	  mkdir -p include/xen-foreign && \
 115.259 +	  ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
 115.260 +	  $(MAKE) -C include/xen-foreign/ && \
 115.261 +	  ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
 115.262 +	mkdir -p libxc-$(XEN_TARGET_ARCH)
 115.263 +	[ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \
 115.264 +	  ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
 115.265 +	  ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
 115.266 +	  ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
 115.267 +	mkdir -p libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH)
 115.268 +	[ -h libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) ] || ( cd libxc-$(XEN_TARGET_ARCH)/$(XEN_TARGET_ARCH) && \
 115.269 +	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
 115.270 +	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
 115.271 +	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
 115.272  	mkdir -p ioemu
 115.273 +ifeq ($(CONFIG_QEMU),ioemu)
 115.274  	[ -h ioemu/Makefile ] || ( cd ioemu && \
 115.275 -	  ln -sf ../../tools/ioemu/* . && \
 115.276 -	  ([ ! -h config-host.h ] || rm -f config-host.h) && \
 115.277 -	  ([ ! -h config-host.mak ] || rm -f config-host.mak) )
 115.278 -	[ -h mini-os ] || ln -sf ../extras/mini-os .
 115.279 +	  ln -sf ../$(XEN_ROOT)/tools/ioemu/* .)
 115.280 +else
 115.281 +	[ -h ioemu/Makefile ] || ( cd ioemu && \
 115.282 +	  ln -sf $(CONFIG_QEMU)/* . && \
 115.283 +          rm -fr i386-dm && \
 115.284 +          rm -fr i386-stubdom && \
 115.285 +          mkdir i386-dm && \
 115.286 +          mkdir i386-stubdom && \
 115.287 +	  ln -sf $(CONFIG_QEMU)/i386-dm/* i386-dm/ && \
 115.288 +	  ln -sf $(CONFIG_QEMU)/i386-stubdom/* i386-stubdom/ )
 115.289 +endif
 115.290 +	[ ! -h ioemu/config-host.h ] || rm -f ioemu/config-host.h
 115.291 +	[ ! -h ioemu/config-host.mak ] || rm -f ioemu/config-host.mak
 115.292 +	$(MAKE) -C $(MINI_OS) links
 115.293 +	touch mk-headers-$(XEN_TARGET_ARCH)
 115.294 +
 115.295 +TARGETS_MINIOS=$(addprefix mini-os-$(XEN_TARGET_ARCH)-,$(TARGETS))
 115.296 +$(TARGETS_MINIOS): mini-os-%:
 115.297 +	[ -d $@ ] || \
 115.298 +	for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
 115.299 +                mkdir -p $@/$$i ; \
 115.300 +	done
 115.301  
 115.302  #######
 115.303  # libxc
 115.304  #######
 115.305  
 115.306  .PHONY: libxc
 115.307 -libxc: cross-zlib mk-symlinks
 115.308 -	$(MAKE) -C $@
 115.309 +libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
 115.310 +libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a:: cross-zlib
 115.311 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc-$(XEN_TARGET_ARCH)
 115.312  
 115.313  #######
 115.314  # ioemu
 115.315  #######
 115.316  
 115.317  .PHONY: ioemu
 115.318 -ioemu: cross-zlib cross-libpci mk-symlinks libxc
 115.319 +ioemu: cross-zlib cross-libpci libxc
 115.320 +ifeq ($(CONFIG_QEMU),ioemu)
 115.321  	[ -f ioemu/config-host.mak ] || \
 115.322 -	  ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
 115.323 -	$(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs
 115.324 +	  ( cd ioemu ; \
 115.325 +          XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
 115.326 +	CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) TOOLS=
 115.327 +else
 115.328 +	[ -f ioemu/config-host.mak ] || \
 115.329 +	  ( cd ioemu ; \
 115.330 +          CONFIG_STUBDOM=yes XEN_ROOT=$(abspath $(XEN_ROOT)) XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh ./xen-setup --cc=$(CC) --disable-gcc-check $(IOEMU_OPTIONS))
 115.331 +	CPPFLAGS= TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) TOOLS= CONFIG_STUBDOM=yes
 115.332 +endif
 115.333  
 115.334  ######
 115.335  # caml
 115.336  ######
 115.337  
 115.338  .PHONY: caml
 115.339 -caml:
 115.340 -	$(MAKE) -C $@
 115.341 +caml: $(CROSS_ROOT)
 115.342 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
 115.343  
 115.344  ###
 115.345  # C
 115.346  ###
 115.347  
 115.348  .PHONY: c
 115.349 -c:
 115.350 -	$(MAKE) -C $@
 115.351 +c: $(CROSS_ROOT)
 115.352 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
 115.353 +
 115.354 +######
 115.355 +# Grub
 115.356 +######
 115.357 +
 115.358 +grub-$(GRUB_VERSION).tar.gz:
 115.359 +	$(WGET) $(GRUB_URL)/$@
 115.360 +
 115.361 +grub-upstream: grub-$(GRUB_VERSION).tar.gz
 115.362 +	tar xzf $<
 115.363 +	mv grub-$(GRUB_VERSION) $@
 115.364 +	for i in grub.patches/* ; do \
 115.365 +		patch -d $@ -p1 < $$i ; \
 115.366 +	done
 115.367 +
 115.368 +.PHONY: grub
 115.369 +grub: grub-upstream $(CROSS_ROOT)
 115.370 +	mkdir -p grub-$(XEN_TARGET_ARCH)
 115.371 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
 115.372  
 115.373  ########
 115.374  # minios
 115.375  ########
 115.376  
 115.377 -.PHONY: qemu-stubdom
 115.378 -qemu-stubdom: mk-symlinks lwip-cvs libxc ioemu
 115.379 -	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs QEMUDIR=$(CURDIR)/ioemu
 115.380 +.PHONY: ioemu-stubdom
 115.381 +ifeq ($(CONFIG_QEMU),ioemu)
 115.382 +ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a
 115.383 +else
 115.384 +ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
 115.385 +endif
 115.386 +ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
 115.387 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
 115.388  
 115.389 +CAMLLIB = $(shell ocamlc -where)
 115.390  .PHONY: caml-stubdom
 115.391 -caml-stubdom: mk-symlinks lwip-cvs libxc cross-libpci caml
 115.392 -	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs CAMLDIR=$(CURDIR)/caml
 115.393 +caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc caml
 115.394 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
 115.395  
 115.396  .PHONY: c-stubdom
 115.397 -c-stubdom: mk-symlinks lwip-cvs libxc cross-libpci c
 115.398 -	$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs CDIR=$(CURDIR)/c
 115.399 +c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
 115.400 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
 115.401 +
 115.402 +.PHONY: pv-grub
 115.403 +pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
 115.404 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 115.405  
 115.406  #########
 115.407  # install
 115.408  #########
 115.409  
 115.410 -install: mini-os/mini-os.gz
 115.411 +ifeq ($(STUBDOM_SUPPORTED),1)
 115.412 +install: install-readme install-ioemu install-grub
 115.413 +else
 115.414 +install:
 115.415 +endif
 115.416 +
 115.417 +install-readme:
 115.418 +	$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
 115.419 +	$(INSTALL_DATA) README $(DESTDIR)$(DOCDIR)/README.stubdom
 115.420 +
 115.421 +install-ioemu: ioemu-stubdom
 115.422 +	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
 115.423  	$(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
 115.424 -	$(INSTALL_PROG) mini-os/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
 115.425 +	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
 115.426 +	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
 115.427 +
 115.428 +install-grub: pv-grub
 115.429 +	$(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
 115.430 +	$(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub-$(XEN_TARGET_ARCH).gz"
 115.431  
 115.432  #######
 115.433  # clean
 115.434 @@ -240,32 +328,40 @@ install: mini-os/mini-os.gz
 115.435  # Only clean the libxc/ioemu/mini-os part
 115.436  .PHONY: clean
 115.437  clean:
 115.438 -	-$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs clean
 115.439 +	rm -fr mini-os-$(XEN_TARGET_ARCH)-ioemu
 115.440 +	rm -fr mini-os-$(XEN_TARGET_ARCH)-c
 115.441 +	rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
 115.442 +	rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
 115.443  	$(MAKE) -C caml clean
 115.444 -	rm -fr libxc ioemu mini-os include
 115.445 +	$(MAKE) -C c clean
 115.446 +	rm -fr grub-$(XEN_TARGET_ARCH)
 115.447 +	[ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
 115.448 +	[ ! -d ioemu ] || $(MAKE) -C ioemu clean
 115.449  
 115.450  # clean the cross-compilation result
 115.451  .PHONY: crossclean
 115.452  crossclean: clean
 115.453  	rm -fr $(CROSS_ROOT)
 115.454 -	rm -fr binutils-build gcc-build newlib-build
 115.455 -	rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
 115.456 +	rm -fr newlib-$(XEN_TARGET_ARCH)
 115.457 +	rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
 115.458 +	rm -fr libxc-$(XEN_TARGET_ARCH) ioemu
 115.459 +	rm -f mk-headers-$(XEN_TARGET_ARCH)
 115.460  
 115.461  # clean patched sources
 115.462  .PHONY: patchclean
 115.463  patchclean: crossclean
 115.464 -	rm -fr binutils-$(BINUTILS_VERSION)
 115.465 -	rm -fr gcc-$(GCC_VERSION)
 115.466 -	rm -fr newlib-cvs
 115.467 -	rm -fr lwip-cvs
 115.468 +	rm -fr newlib-$(NEWLIB_VERSION)
 115.469 +	rm -fr lwip-$(XEN_TARGET_ARCH)
 115.470 +	rm -fr grub-upstream
 115.471  
 115.472  # clean downloads
 115.473  .PHONY: downloadclean
 115.474  downloadclean: patchclean
 115.475 -	rm -f binutils-$(BINUTILS_VERSION).tar.bz2
 115.476 -	rm -f gcc-$(GCC_VERSION).tar.bz2
 115.477 +	rm -f newlib-$(NEWLIB_VERSION).tar.gz
 115.478  	rm -f zlib-$(ZLIB_VERSION).tar.gz
 115.479  	rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
 115.480 +	rm -f grub-$(GRUB_VERSION).tar.gz
 115.481 +	rm -f lwip-$(LWIP_VERSION).tar.gz
 115.482  
 115.483  .PHONY: distclean
 115.484  distclean: downloadclean
   116.1 --- a/stubdom/README	Fri Aug 29 15:47:21 2008 -0700
   116.2 +++ b/stubdom/README	Tue Sep 02 16:34:53 2008 -0700
   116.3 @@ -1,17 +1,22 @@
   116.4 -To compile
   116.5 -==========
   116.6 +                                IOEMU stubdom
   116.7 +                                =============
   116.8  
   116.9 -Just run make -j 4, that will download / patch / compile
  116.10 -Then make install to install the result.
  116.11 -
  116.12 -Also, run make and make install in $XEN_ROOT/tools/fs-back
  116.13 +  This boosts HVM performance by putting ioemu in its own lightweight domain.
  116.14  
  116.15  General Configuration
  116.16  =====================
  116.17  
  116.18 +Due to a race between the creation of the IOEMU stubdomain itself and allocation
  116.19 +of video memory for the HVM domain, you need to avoid the need for ballooning,
  116.20 +by using the hypervisor dom0_mem= option for instance.
  116.21 +
  116.22 +
  116.23 +There is a sample configuration set in xmexample.hvm-stubdom and
  116.24 +xmexample.hvm-dm
  116.25 +
  116.26  In your HVM config "hvmconfig",
  116.27  
  116.28 -- use /usr/lib/xen/bin/stubdom-dm as dm script
  116.29 +- use /usr/lib/xen/bin/stubdom-dm as dm script:
  116.30  
  116.31  device_model = '/usr/lib/xen/bin/stubdom-dm'
  116.32  
  116.33 @@ -19,11 +24,13 @@ device_model = '/usr/lib/xen/bin/stubdom
  116.34  
  116.35  #disk = [  'file:/tmp/install.iso,hdc:cdrom,r', 'phy:/dev/sda6,hda,w', 'file:/tmp/test,hdb,r' ]
  116.36  
  116.37 +- disable anything related to dom0, like pty serial assignments
  116.38 +
  116.39  
  116.40  Create /etc/xen/stubdom-hvmconfig (where "hvmconfig" is the name of your HVM
  116.41  guest) with
  116.42  
  116.43 -kernel = "/usr/lib/xen/boot/stubdom.gz"
  116.44 +kernel = "/usr/lib/xen/boot/ioemu-stubdom.gz"
  116.45  vif = [ '', 'ip=10.0.1.1,mac=aa:00:00:12:23:34']
  116.46  disk = [  'file:/tmp/install.iso,hdc:cdrom,r', 'phy:/dev/sda6,hda,w', 'file:/tmp/test,hdb,r' ]
  116.47  
  116.48 @@ -40,34 +47,36 @@ There are three posibilities
  116.49  
  116.50  * Using SDL
  116.51  
  116.52 -In hvmconfig, disable vnc:
  116.53 +  - In hvmconfig, disable vnc and sdl:
  116.54  
  116.55  vnc = 0
  116.56 +sdl = 0
  116.57  
  116.58 -In stubdom-hvmconfig, set a vfb:
  116.59 +  - In stubdom-hvmconfig, set an sdl vfb:
  116.60  
  116.61  vfb = [ 'type=sdl' ]
  116.62  
  116.63  * Using a VNC server in the stub domain
  116.64  
  116.65 -In hvmconfig, set vnclisten to "172.30.206.1" for instance.  Do not use a host
  116.66 -name as Mini-OS does not have a name resolver.  Do not use 127.0.0.1 since then
  116.67 -you will not be able to connect to it.
  116.68 +  - In hvmconfig, set vnclisten to "172.30.206.1" for instance.  Do not use a
  116.69 +host name as Mini-OS does not have a name resolver.  Do not use 127.0.0.1 since
  116.70 +then you will not be able to connect to it.
  116.71  
  116.72  vnc = 1
  116.73  vnclisten = "172.30.206.1"
  116.74  
  116.75 -In stubdom-hvmconfig, fill the reserved vif with the same IP, for instance:
  116.76 +  - In stubdom-hvmconfig, fill the reserved vif with the same IP, for instance:
  116.77  
  116.78  vif = [ 'ip=172.30.206.1', 'ip=10.0.1.1,mac=aa:00:00:12:23:34']
  116.79  
  116.80  * Using a VNC server in dom0
  116.81  
  116.82 -In hvmconfig, disable vnc:
  116.83 +  - In hvmconfig, disable vnc and sdl:
  116.84  
  116.85  vnc = 0
  116.86 +sdl = 0
  116.87  
  116.88 -In stubdom-hvmconfig, set a vfb:
  116.89 +  - In stubdom-hvmconfig, set a vnc vfb:
  116.90  
  116.91  vfb = [ 'type=vnc' ]
  116.92  
  116.93 @@ -76,10 +85,50 @@ and any other parameter as wished.
  116.94  To run
  116.95  ======
  116.96  
  116.97 -mkdir -p /exports/usr/share/qemu
  116.98 -ln -s /usr/share/qemu/keymaps /exports/usr/share/qemu
  116.99 +mkdir -p /exports/usr/share/xen/qemu
 116.100 +ln -s /usr/share/xen/qemu/keymaps /exports/usr/share/xen/qemu
 116.101  mkdir -p /exports/var/lib
 116.102  ln -s /var/lib/xen /exports/var/lib
 116.103  /usr/sbin/fs-backend &
 116.104  
 116.105  xm create hvmconfig
 116.106 +
 116.107 +
 116.108 +
 116.109 +                                   PV-GRUB
 116.110 +                                   =======
 116.111 +
 116.112 +  This replaces pygrub to boot domU images safely: it runs the regular grub
 116.113 +inside the created domain itself and uses regular domU facilities to read the
 116.114 +disk / fetch files from network etc. ; it eventually loads the PV kernel and
 116.115 +chain-boots it.
 116.116 +  
 116.117 +Configuration
 116.118 +=============
 116.119 +
 116.120 +In your PV config,
 116.121 +
 116.122 +- use /usr/lib/xen/boot/pv-grub.gz as kernel:
 116.123 +
 116.124 +kernel = "/usr/lib/xen/boot/pv-grub.gz"
 116.125 +
 116.126 +- set the path to menu.lst, as seen from the domU, in extra:
 116.127 +
 116.128 +extra = "(hd0,0)/boot/grub/menu.lst"
 116.129 +
 116.130 +you can also use a tftp path (dhcp will be automatically performed):
 116.131 +
 116.132 +extra = "(nd)/somepath/menu.lst"
 116.133 +
 116.134 +or you can set it in option 150 of your dhcp server and leave extra empty
 116.135 +
 116.136 +Limitations
 116.137 +===========
 116.138 +
 116.139 +- You can not boot a 64bit kernel with a 32bit-compiled PV-GRUB and vice-versa.
 116.140 +To cross-compile a 32bit PV-GRUB,
 116.141 +
 116.142 +export XEN_TARGET_ARCH=x86_32
 116.143 +
 116.144 +- bootsplash is supported, but the ioemu backend does not yet support restart
 116.145 +for use by the booted kernel.
   117.1 --- a/stubdom/binutils.patch	Fri Aug 29 15:47:21 2008 -0700
   117.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.3 @@ -1,14 +0,0 @@
   117.4 -It looks like binutils has troubles with makeinfo and the doc generation.
   117.5 -We don't need it anyway
   117.6 -
   117.7 ---- binutils-2.18/bfd/Makefile.inorig	2008-01-16 16:17:43.004484000 +0000
   117.8 -+++ binutils-2.18/bfd/Makefile.in	2008-01-16 16:17:50.505526000 +0000
   117.9 -@@ -271,7 +271,7 @@
  117.10 - INCDIR = $(srcdir)/../include
  117.11 - CSEARCH = -I. -I$(srcdir) -I$(INCDIR)
  117.12 - MKDEP = gcc -MM
  117.13 --SUBDIRS = doc po
  117.14 -+SUBDIRS = po
  117.15 - bfddocdir = doc
  117.16 - bfdlib_LTLIBRARIES = libbfd.la
  117.17 - AM_CFLAGS = $(WARN_CFLAGS)
   118.1 --- a/stubdom/c/Makefile	Fri Aug 29 15:47:21 2008 -0700
   118.2 +++ b/stubdom/c/Makefile	Tue Sep 02 16:34:53 2008 -0700
   118.3 @@ -2,7 +2,9 @@ XEN_ROOT = ../..
   118.4  
   118.5  include $(XEN_ROOT)/Config.mk
   118.6  
   118.7 -main.a: main.o
   118.8 +all: main.a
   118.9 +
  118.10 +main.a: main.o 
  118.11  	$(AR) cr $@ $^
  118.12  
  118.13  clean:
   119.1 --- a/stubdom/c/main.c	Fri Aug 29 15:47:21 2008 -0700
   119.2 +++ b/stubdom/c/main.c	Tue Sep 02 16:34:53 2008 -0700
   119.3 @@ -1,4 +1,6 @@
   119.4  #include <stdio.h>
   119.5 +#include <unistd.h>
   119.6 +
   119.7  int main(void) {
   119.8          sleep(2);
   119.9          printf("Hello, world!\n");
   120.1 --- a/stubdom/caml/Makefile	Fri Aug 29 15:47:21 2008 -0700
   120.2 +++ b/stubdom/caml/Makefile	Tue Sep 02 16:34:53 2008 -0700
   120.3 @@ -2,12 +2,17 @@ XEN_ROOT = ../..
   120.4  
   120.5  include $(XEN_ROOT)/Config.mk
   120.6  
   120.7 +CAMLLIB = $(shell ocamlc -where)
   120.8 +DEF_CPPFLAGS += -I$(CAMLLIB)
   120.9 +
  120.10  OCAMLFIND=ocamlfind
  120.11  OCAMLOPT=ocamlopt
  120.12  
  120.13  OBJS := hello.cmx
  120.14  LIBS := 
  120.15  
  120.16 +all: main-caml.o caml.o
  120.17 +
  120.18  %.cmx: %.ml
  120.19  	$(OCAMLFIND) $(OCAMLOPT) -c $< -o $@
  120.20  
  120.21 @@ -15,4 +20,4 @@ caml.o: $(OBJS)
  120.22  	$(OCAMLFIND) $(OCAMLOPT) $(LIBS) $^ -output-obj -o $@
  120.23  
  120.24  clean:
  120.25 -	rm -f *.o *.cmx *.cmi
  120.26 +	rm -f *.a *.o *.cmx *.cmi
   121.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   121.2 +++ b/stubdom/caml/main-caml.c	Tue Sep 02 16:34:53 2008 -0700
   121.3 @@ -0,0 +1,42 @@
   121.4 +/*
   121.5 + * Caml bootstrap
   121.6 + *
   121.7 + * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, January 2008
   121.8 + */
   121.9 +
  121.10 +#include <stdio.h>
  121.11 +#include <errno.h>
  121.12 +
  121.13 +#include <caml/mlvalues.h>
  121.14 +#include <caml/callback.h>
  121.15 +#include <unistd.h>
  121.16 +
  121.17 +/* Ugly binary compatibility with Linux */
  121.18 +FILE *_stderr asm("stderr");
  121.19 +int *__errno_location;
  121.20 +/* Will probably break everything, probably need to fetch from glibc */
  121.21 +void *__ctype_b_loc;
  121.22 +
  121.23 +int main(int argc, char *argv[], char *envp[])
  121.24 +{
  121.25 +    value *val;
  121.26 +
  121.27 +    /* Get current thread's value */
  121.28 +    _stderr = stderr;
  121.29 +    __errno_location = &errno;
  121.30 +
  121.31 +    printf("starting caml\n");
  121.32 +
  121.33 +    /* Wait before things might hang up */
  121.34 +    sleep(1);
  121.35 +
  121.36 +    caml_startup(argv);
  121.37 +    val = caml_named_value("main");
  121.38 +    if (!val) {
  121.39 +        printf("Couldn't find Caml main");
  121.40 +        return 1;
  121.41 +    }
  121.42 +    caml_callback(*val, Val_int(0));
  121.43 +    printf("callback returned\n");
  121.44 +    return 0;
  121.45 +}
   122.1 --- a/stubdom/gcc.patch	Fri Aug 29 15:47:21 2008 -0700
   122.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   122.3 @@ -1,31 +0,0 @@
   122.4 -Backported from later versions
   122.5 -
   122.6 ---- gcc-4.2.2/gcc/config.gcc       2007-11-22 16:27:45.000000000 +0000
   122.7 -+++ gcc-4.2.2/gcc/config.gcc       2007-11-22 16:23:00.000000000 +0000
   122.8 -@@ -1033,6 +1033,11 @@
   122.9 - 	tmake_file="i386/t-i386elf t-svr4"
  122.10 - 	use_fixproto=yes
  122.11 - 	;;
  122.12 -+x86_64-*-elf*)
  122.13 -+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h i386/x86-64.h"
  122.14 -+	tmake_file="i386/t-i386elf t-svr4"
  122.15 -+	use_fixproto=yes
  122.16 -+	;;
  122.17 - i[34567]86-sequent-ptx4* | i[34567]86-sequent-sysv4*)
  122.18 - 	if test x$gas = xyes
  122.19 - 	then
  122.20 -
  122.21 -We don't have a libc yet at this stage. Unused anyway
  122.22 -
  122.23 ---- gcc-4.2.2/gcc/unwind-generic.h.orig 2008-01-11 18:54:40.000000000 +0100
  122.24 -+++ gcc-4.2.2/gcc/unwind-generic.h      2008-01-11 18:54:31.000000000 +0100
  122.25 -@@ -203,7 +203,6 @@
  122.26 -    compatible with the standard ABI for IA-64, we inline these.  */
  122.27 - 
  122.28 - #ifdef __ia64__
  122.29 --#include <stdlib.h>
  122.30 - 
  122.31 - static inline _Unwind_Ptr
  122.32 - _Unwind_GetDataRelBase (struct _Unwind_Context *_C)
  122.33 -Backported from later versions
  122.34 -
   123.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   123.2 +++ b/stubdom/grub.patches/00cvs	Tue Sep 02 16:34:53 2008 -0700
   123.3 @@ -0,0 +1,1382 @@
   123.4 +diff -uprN grub-0.97/acinclude.m4 grub/acinclude.m4
   123.5 +--- grub-0.97/acinclude.m4	2004-04-27 21:48:06.000000000 +0100
   123.6 ++++ grub/acinclude.m4	2007-11-05 01:29:46.000000000 +0000
   123.7 +@@ -57,7 +57,7 @@ else
   123.8 + fi
   123.9 + grub_cv_prog_objcopy_absolute=yes
  123.10 + for link_addr in 2000 8000 7C00; do
  123.11 +-  if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
  123.12 ++  if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
  123.13 +   else
  123.14 +     AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
  123.15 +   fi
  123.16 +diff -uprN grub-0.97/ChangeLog grub/ChangeLog
  123.17 +--- grub-0.97/ChangeLog	2005-05-08 03:47:02.000000000 +0100
  123.18 ++++ grub/ChangeLog	2008-05-20 12:04:18.000000000 +0100
  123.19 +@@ -1,3 +1,127 @@
  123.20 ++2008-05-20  Robert Millan  <rmh@aybabtu.com>
  123.21 ++
  123.22 ++	* netboot/cs89x0.c: Fix license violation.
  123.23 ++	* netboot/cs89x0.h: Likewise.
  123.24 ++
  123.25 ++2008-04-10  Pavel Roskin  <proski@gnu.org>
  123.26 ++
  123.27 ++	* configure.ac: Always use "_cv_" in cache variables for
  123.28 ++	compatibility with Autoconf 2.62.
  123.29 ++
  123.30 ++2008-03-28  Robert Millan  <rmh@aybabtu.com>
  123.31 ++
  123.32 ++	Surpass 1 TiB disk addressing limit.  Note: there are no plans to handle
  123.33 ++	the 2 TiB disk limit in GRUB Legacy, since that would need considerable
  123.34 ++	rework.  If you have >2TiB disks, use GRUB 2 instead.
  123.35 ++
  123.36 ++	* grub/asmstub.c (biosdisk): Add unsigned qualifier to `sector'.
  123.37 ++	* stage2/bios.c (biosdisk): Likewise.
  123.38 ++	* stage2/disk_io.c (rawread, devread, rawwrite, devwrite): Likewise.
  123.39 ++	* stage2/shared.h (rawread, devread, rawwrite, devwrite): Likewise.
  123.40 ++	* lib/device.c (get_drive_geometry): Replace BLKGETSIZE with
  123.41 ++	BLKGETSIZE64.
  123.42 ++
  123.43 ++2007-10-29  Pavel Roskin  <proski@gnu.org>
  123.44 ++
  123.45 ++	* configure.ac: Test if '--build-id=none' is supported by the
  123.46 ++	linker and add it to LDFLAGS if possible.  Build ID causes
  123.47 ++	objcopy to generate huge binary files.
  123.48 ++	* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): Use LDFLAGS when
  123.49 ++	linking, so that build ID doesn't break the test.
  123.50 ++	* stage1/Makefile.am: Preserve LDFLAGS, use stage1_exec_LDFLAGS.
  123.51 ++
  123.52 ++2007-02-22  Pavel Roskin  <proski@gnu.org>
  123.53 ++
  123.54 ++	* stage2/iso9660.h: Remove unnecessary packed attributes.
  123.55 ++
  123.56 ++2007-02-22  Robert Millan  <rmh@aybabtu.com>
  123.57 ++
  123.58 ++	* util/mkbimage: Update my email address, and remove my name from
  123.59 ++	some places where unnecessary credit is given.
  123.60 ++
  123.61 ++2006-09-10  Pavel Roskin  <proski@gnu.org>
  123.62 ++
  123.63 ++	* netboot/natsemi.c: Fix compile error with gcc 4.1.1.  Cast
  123.64 ++	cannot make a variable volatile - it should be declared as such.
  123.65 ++	* netboot/sis900.c: Likewise.
  123.66 ++
  123.67 ++2006-09-08  Pavel Roskin  <proski@gnu.org>
  123.68 ++
  123.69 ++	* netboot/etherboot.h: Remove incorrect extern declarations of
  123.70 ++	the variables later declared static.  Move BOOTP_DATA_ADDR ...
  123.71 ++	* netboot/main.c: ... here.  Eliminate end_of_rfc1533 - it's
  123.72 ++	write-only.
  123.73 ++
  123.74 ++2006-06-24  Yoshinori K. Okuji  <okuji@enbug.org>
  123.75 ++
  123.76 ++	* docs/grub.texi: Changed the license term to the GNU Free
  123.77 ++	Documentation License 1.2.
  123.78 ++
  123.79 ++	* docs/multiboot.texi: Reformatted to show the license term
  123.80 ++	and the version number explicitly.
  123.81 ++	
  123.82 ++	* docs/fdl.texi: New file.
  123.83 ++	
  123.84 ++	* docs/Makefile.am (grub_TEXINFOS): Added fdl.texi.
  123.85 ++
  123.86 ++2006-06-24  Robert Millan  <robertmh@gnu.org>
  123.87 ++
  123.88 ++	* lib/device.c (write_to_partition): /dev/ataraid/ and /dev/rd/
  123.89 ++	partitions have a "p" prefix.  Add it.
  123.90 ++
  123.91 ++2006-06-24  Robert Millan  <robertmh@gnu.org>
  123.92 ++
  123.93 ++	* lib/device.c (get_i2o_disk_name): New function.
  123.94 ++	(init_device_map) [__linux__]: Add support for I2O devices.
  123.95 ++
  123.96 ++2006-05-02  Pavel Roskin  <proski@gnu.org>
  123.97 ++
  123.98 ++	* stage2/stage2.c (run_menu): Fix "savedefault" to save only top
  123.99 ++	level menu positions.  Remember current position when calling a
 123.100 ++	submenu.  Don't recalculate it when booting from a submenu.
 123.101 ++
 123.102 ++	* grub/main.c (main): Make sure the boot drive number doesn't
 123.103 ++	exceed 255.
 123.104 ++
 123.105 ++2006-05-02  Vesa Jaaskelainen  <chaac@nic.fi>
 123.106 ++
 123.107 ++	* stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2
 123.108 ++	to GRUB Legacy.  Problem reported by Gerardo Richarte.
 123.109 ++
 123.110 ++2006-04-23  Robert Millan  <robertmh@gnu.org>
 123.111 ++
 123.112 ++	* grub/asmstub.c (get_diskinfo): Optimize sysctl routine.
 123.113 ++
 123.114 ++2006-04-20  Robert Millan  <robertmh@gnu.org>
 123.115 ++
 123.116 ++	Fixes for kernel of FreeBSD:
 123.117 ++	* grub/asmstub.c (get_diskinfo): Toggle "kern.geom.debugflags" sysctl
 123.118 ++	before opening a device for writing.
 123.119 ++	* util/grub-install.in: Devices don't have this "r" prefix anymore.
 123.120 ++
 123.121 ++2006-04-16  Yoshinori K. Okuji  <okuji@enbug.org>
 123.122 ++
 123.123 ++	* docs/multiboot.texi: Correct the offset of address
 123.124 ++	fields. Reported by Jeroen Dekkers.
 123.125 ++
 123.126 ++2006-03-21  Yoshinori K. Okuji  <okuji@enbug.org>
 123.127 ++
 123.128 ++	* stage2/builtins.c (setup_func): Specify the size of DEVICE to
 123.129 ++	grub_strncat instead of a strange number 256. Reported by Vitaly
 123.130 ++	Fertman <vitaly@namesys.com>.
 123.131 ++
 123.132 ++2005-09-29  Yoshinori K. Okuji  <okuji@enbug.org>
 123.133 ++
 123.134 ++	* docs/multiboot.texi: Fix a bug in the byte order of
 123.135 ++	boot_device. I hope this won't affect any OS image.
 123.136 ++	Increased the version number to 0.6.94.
 123.137 ++
 123.138 ++2005-09-28  Yoshinori K. Okuji  <okuji@enbug.org>
 123.139 ++
 123.140 ++	* stage2/boot.c (load_image): Even if an OS image is an ELF
 123.141 ++	object, use the a.out kludge if MULTIBOOT_AOUT_KLUDGE is
 123.142 ++	specified.
 123.143 ++
 123.144 + 2005-05-08  Yoshinori K. Okuji  <okuji@enbug.org>
 123.145 + 
 123.146 + 	* configure.ac (AC_INIT): Upgraded to 0.97.
 123.147 +diff -uprN grub-0.97/configure grub/configure
 123.148 +--- grub-0.97/configure	2005-05-08 03:48:12.000000000 +0100
 123.149 ++++ grub/configure	2007-11-05 01:29:46.000000000 +0000
 123.150 +@@ -3694,6 +3694,64 @@ if test "x$undef_flag" = xyes; then
 123.151 +   CPPFLAGS="$CPPFLAGS -Wundef"
 123.152 + fi
 123.153 + 
 123.154 ++# Check if build ID can be disabled in the linker
 123.155 ++echo "$as_me:$LINENO: checking whether linker accepts \`--build-id=none'" >&5
 123.156 ++echo $ECHO_N "checking whether linker accepts \`--build-id=none'... $ECHO_C" >&6
 123.157 ++save_LDFLAGS="$LDFLAGS"
 123.158 ++LDFLAGS="$LDFLAGS -Wl,--build-id=none"
 123.159 ++cat >conftest.$ac_ext <<_ACEOF
 123.160 ++/* confdefs.h.  */
 123.161 ++_ACEOF
 123.162 ++cat confdefs.h >>conftest.$ac_ext
 123.163 ++cat >>conftest.$ac_ext <<_ACEOF
 123.164 ++/* end confdefs.h.  */
 123.165 ++
 123.166 ++int
 123.167 ++main ()
 123.168 ++{
 123.169 ++
 123.170 ++  ;
 123.171 ++  return 0;
 123.172 ++}
 123.173 ++_ACEOF
 123.174 ++rm -f conftest.$ac_objext conftest$ac_exeext
 123.175 ++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
 123.176 ++  (eval $ac_link) 2>conftest.er1
 123.177 ++  ac_status=$?
 123.178 ++  grep -v '^ *+' conftest.er1 >conftest.err
 123.179 ++  rm -f conftest.er1
 123.180 ++  cat conftest.err >&5
 123.181 ++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 123.182 ++  (exit $ac_status); } &&
 123.183 ++	 { ac_try='test -z "$ac_c_werror_flag"
 123.184 ++			 || test ! -s conftest.err'
 123.185 ++  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 123.186 ++  (eval $ac_try) 2>&5
 123.187 ++  ac_status=$?
 123.188 ++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 123.189 ++  (exit $ac_status); }; } &&
 123.190 ++	 { ac_try='test -s conftest$ac_exeext'
 123.191 ++  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 123.192 ++  (eval $ac_try) 2>&5
 123.193 ++  ac_status=$?
 123.194 ++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
 123.195 ++  (exit $ac_status); }; }; then
 123.196 ++  build_id_flag=yes
 123.197 ++else
 123.198 ++  echo "$as_me: failed program was:" >&5
 123.199 ++sed 's/^/| /' conftest.$ac_ext >&5
 123.200 ++
 123.201 ++build_id_flag=no
 123.202 ++fi
 123.203 ++rm -f conftest.err conftest.$ac_objext \
 123.204 ++      conftest$ac_exeext conftest.$ac_ext
 123.205 ++echo "$as_me:$LINENO: result: $build_id_flag" >&5
 123.206 ++echo "${ECHO_T}$build_id_flag" >&6
 123.207 ++LDFLAGS="$save_LDFLAGS"
 123.208 ++if test "x$build_id_flag" = xyes; then
 123.209 ++  LDFLAGS="$LDFLAGS -Wl,--build-id=none"
 123.210 ++fi
 123.211 ++
 123.212 + if test "x$with_binutils" != x; then
 123.213 +   # Extract the first word of "objcopy", so it can be a program name with args.
 123.214 + set dummy objcopy; ac_word=$2
 123.215 +@@ -3892,7 +3950,7 @@ echo "$as_me: error: ${CC-cc} cannot com
 123.216 + fi
 123.217 + grub_cv_prog_objcopy_absolute=yes
 123.218 + for link_addr in 2000 8000 7C00; do
 123.219 +-  if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'
 123.220 ++  if { ac_try='${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'
 123.221 +   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
 123.222 +   (eval $ac_try) 2>&5
 123.223 +   ac_status=$?
 123.224 +diff -uprN grub-0.97/configure.ac grub/configure.ac
 123.225 +--- grub-0.97/configure.ac	2005-05-08 03:36:03.000000000 +0100
 123.226 ++++ grub/configure.ac	2008-04-10 23:26:50.000000000 +0100
 123.227 +@@ -86,13 +86,13 @@ if test "x$ac_cv_prog_gcc" = xyes; then
 123.228 +     fi
 123.229 +     STAGE1_CFLAGS="-O2"
 123.230 +     GRUB_CFLAGS="-O2"
 123.231 +-    AC_CACHE_CHECK([whether optimization for size works], size_flag, [
 123.232 ++    AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [
 123.233 +       saved_CFLAGS=$CFLAGS
 123.234 +       CFLAGS="-Os -g"
 123.235 +-      AC_TRY_COMPILE(, , size_flag=yes, size_flag=no)
 123.236 ++      AC_TRY_COMPILE(, , grub_cv_cc_Os=yes, grub_cv_cc_Os=no)
 123.237 +       CFLAGS=$saved_CFLAGS
 123.238 +     ])
 123.239 +-    if test "x$size_flag" = xyes; then
 123.240 ++    if test "x$grub_cv_cc_Os" = xyes; then
 123.241 +       STAGE2_CFLAGS="-Os"
 123.242 +     else
 123.243 +       STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops"
 123.244 +@@ -100,16 +100,16 @@ if test "x$ac_cv_prog_gcc" = xyes; then
 123.245 +     # OpenBSD has a GCC extension for protecting applications from
 123.246 +     # stack smashing attacks, but GRUB doesn't want this feature.
 123.247 +     AC_CACHE_CHECK([whether gcc has -fno-stack-protector],
 123.248 +-		   no_stack_protector_flag, [
 123.249 ++		   grub_cv_cc_no_stack_protector, [
 123.250 +       saved_CFLAGS=$CFLAGS
 123.251 +       CFLAGS="-fno-stack-protector"
 123.252 +       AC_TRY_COMPILE(,
 123.253 + 		     ,
 123.254 +-		     no_stack_protector_flag=yes,
 123.255 +-		     no_stack_protector_flag=no)
 123.256 ++		     grub_cv_cc_no_stack_protector=yes,
 123.257 ++		     grub_cv_cc_no_stack_protector=no)
 123.258 +       CFLAGS=$saved_CFLAGS
 123.259 +     ])
 123.260 +-    if test "x$no_stack_protector_flag" = xyes; then
 123.261 ++    if test "x$grub_cv_cc_no_stack_protector" = xyes; then
 123.262 +       STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector"
 123.263 +     fi
 123.264 +   fi
 123.265 +@@ -123,33 +123,44 @@ AC_SUBST(GRUB_CFLAGS)
 123.266 + CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow"
 123.267 + CPPFLAGS="$CPPFLAGS -Wpointer-arith"
 123.268 + 
 123.269 +-AC_CACHE_CHECK([whether -Wundef works], undef_flag, [
 123.270 ++AC_CACHE_CHECK([whether -Wundef works], grub_cv_cc_Wundef, [
 123.271 +   saved_CPPFLAGS="$CPPFLAGS"
 123.272 +   CPPFLAGS="-Wundef"
 123.273 +-  AC_TRY_COMPILE(, , undef_flag=yes, undef_flag=no)
 123.274 ++  AC_TRY_COMPILE(, , grub_cv_cc_Wundef=yes, grub_cv_cc_Wundef=no)
 123.275 +   CPPFLAGS="$saved_CPPFLAGS"
 123.276 + ])
 123.277 + 
 123.278 + # The options `-falign-*' are supported by gcc 3.0 or later.
 123.279 + # Probably it is sufficient to only check for -falign-loops.
 123.280 +-AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [
 123.281 ++AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
 123.282 +   saved_CPPFLAGS="$CPPFLAGS"
 123.283 +   CPPFLAGS="-falign-loops=1"
 123.284 +-  AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no])
 123.285 ++  AC_TRY_COMPILE(, , [grub_cv_cc_falign_loop=yes], [grub_cv_cc_falign_loop=no])
 123.286 +   CPPFLAGS="$saved_CPPFLAGS"
 123.287 + ])
 123.288 + 
 123.289 + # Force no alignment to save space.
 123.290 +-if test "x$falign_loop_flag" = xyes; then
 123.291 ++if test "x$grub_cv_cc_falign_loop" = xyes; then
 123.292 +   CPPFLAGS="$CPPFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
 123.293 + else
 123.294 +   CPPFLAGS="$CPPFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
 123.295 + fi
 123.296 + 
 123.297 +-if test "x$undef_flag" = xyes; then
 123.298 ++if test "x$grub_cv_cc_Wundef" = xyes; then
 123.299 +   CPPFLAGS="$CPPFLAGS -Wundef"
 123.300 + fi
 123.301 + 
 123.302 ++# Check if build ID can be disabled in the linker
 123.303 ++AC_MSG_CHECKING([whether linker accepts `--build-id=none'])
 123.304 ++save_LDFLAGS="$LDFLAGS"
 123.305 ++LDFLAGS="$LDFLAGS -Wl,--build-id=none"
 123.306 ++AC_TRY_LINK(, , build_id_flag=yes, build_id_flag=no)
 123.307 ++AC_MSG_RESULT([$build_id_flag])
 123.308 ++LDFLAGS="$save_LDFLAGS"
 123.309 ++if test "x$build_id_flag" = xyes; then
 123.310 ++  LDFLAGS="$LDFLAGS -Wl,--build-id=none"
 123.311 ++fi
 123.312 ++
 123.313 + if test "x$with_binutils" != x; then
 123.314 + dnl  AC_PATH_TOOL(OBJCOPY, objcopy, , "$with_binutils:$PATH")
 123.315 +   AC_PATH_PROG(OBJCOPY, objcopy, , "$with_binutils:$PATH")
 123.316 +diff -uprN grub-0.97/docs/grub.8 grub/docs/grub.8
 123.317 +--- grub-0.97/docs/grub.8	2005-05-08 03:48:56.000000000 +0100
 123.318 ++++ grub/docs/grub.8	2006-06-24 15:40:02.000000000 +0100
 123.319 +@@ -1,5 +1,5 @@
 123.320 + .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.23.
 123.321 +-.TH GRUB "8" "May 2005" "grub (GNU GRUB 0.97)" FSF
 123.322 ++.TH GRUB "8" "June 2006" "grub (GNU GRUB 0.97)" FSF
 123.323 + .SH NAME
 123.324 + grub \- the grub shell
 123.325 + .SH SYNOPSIS
 123.326 +diff -uprN grub-0.97/docs/grub-install.8 grub/docs/grub-install.8
 123.327 +--- grub-0.97/docs/grub-install.8	2005-05-08 03:48:56.000000000 +0100
 123.328 ++++ grub/docs/grub-install.8	2006-06-24 15:40:02.000000000 +0100
 123.329 +@@ -1,5 +1,5 @@
 123.330 + .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.23.
 123.331 +-.TH GRUB-INSTALL "8" "May 2005" "grub-install (GNU GRUB 0.97)" FSF
 123.332 ++.TH GRUB-INSTALL "8" "June 2006" "grub-install (GNU GRUB 0.97)" FSF
 123.333 + .SH NAME
 123.334 + grub-install \- install GRUB on your drive
 123.335 + .SH SYNOPSIS
 123.336 +diff -uprN grub-0.97/docs/grub-md5-crypt.8 grub/docs/grub-md5-crypt.8
 123.337 +--- grub-0.97/docs/grub-md5-crypt.8	2005-05-08 03:48:56.000000000 +0100
 123.338 ++++ grub/docs/grub-md5-crypt.8	2006-06-24 15:40:02.000000000 +0100
 123.339 +@@ -1,5 +1,5 @@
 123.340 + .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.23.
 123.341 +-.TH GRUB-MD5-CRYPT "8" "May 2005" "grub-md5-crypt (GNU GRUB )" FSF
 123.342 ++.TH GRUB-MD5-CRYPT "8" "June 2006" "grub-md5-crypt (GNU GRUB )" FSF
 123.343 + .SH NAME
 123.344 + grub-md5-crypt \- Encrypt a password in MD5 format
 123.345 + .SH SYNOPSIS
 123.346 +diff -uprN grub-0.97/docs/grub-terminfo.8 grub/docs/grub-terminfo.8
 123.347 +--- grub-0.97/docs/grub-terminfo.8	2005-05-08 03:48:56.000000000 +0100
 123.348 ++++ grub/docs/grub-terminfo.8	2006-06-24 15:40:02.000000000 +0100
 123.349 +@@ -1,5 +1,5 @@
 123.350 + .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.23.
 123.351 +-.TH GRUB-TERMINFO "8" "May 2005" "grub-terminfo (GNU GRUB 0.97)" FSF
 123.352 ++.TH GRUB-TERMINFO "8" "June 2006" "grub-terminfo (GNU GRUB 0.97)" FSF
 123.353 + .SH NAME
 123.354 + grub-terminfo \- Generate a terminfo command from a terminfo name
 123.355 + .SH SYNOPSIS
 123.356 +diff -uprN grub-0.97/docs/grub.texi grub/docs/grub.texi
 123.357 +--- grub-0.97/docs/grub.texi	2005-05-08 03:59:59.000000000 +0100
 123.358 ++++ grub/docs/grub.texi	2006-06-24 15:40:02.000000000 +0100
 123.359 +@@ -2,22 +2,41 @@
 123.360 + @c -*-texinfo-*-
 123.361 + @c %**start of header
 123.362 + @setfilename grub.info
 123.363 +-@settitle GRUB Manual
 123.364 +-@c %**end of header
 123.365 +-
 123.366 + @include version.texi
 123.367 +-
 123.368 ++@settitle GNU GRUB Manual @value{VERSION}
 123.369 + @c Unify all our little indices for now.
 123.370 + @syncodeindex fn cp
 123.371 + @syncodeindex vr cp
 123.372 + @syncodeindex ky cp
 123.373 + @syncodeindex pg cp
 123.374 + @syncodeindex tp cp
 123.375 ++@c %**end of header
 123.376 + 
 123.377 + @footnotestyle separate
 123.378 + @paragraphindent 3
 123.379 + @finalout
 123.380 + 
 123.381 ++@copying
 123.382 ++This manual is for GNU GRUB (version @value{VERSION},
 123.383 ++@value{UPDATED}).
 123.384 ++
 123.385 ++Copyright @copyright{} 1999,2000,2001,2002,2004,2006 Free Software Foundation, Inc.
 123.386 ++
 123.387 ++@quotation
 123.388 ++Permission is granted to copy, distribute and/or modify this document
 123.389 ++under the terms of the GNU Free Documentation License, Version 1.2 or
 123.390 ++any later version published by the Free Software Foundation; with no
 123.391 ++Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
 123.392 ++and with the Back-Cover Texts as in (a) below.  A copy of the
 123.393 ++license is included in the section entitled ``GNU Free Documentation
 123.394 ++License.''
 123.395 ++
 123.396 ++(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
 123.397 ++this GNU Manual, like GNU software.  Copies published by the Free
 123.398 ++Software Foundation raise funds for GNU development.''
 123.399 ++@end quotation
 123.400 ++@end copying
 123.401 ++
 123.402 + @dircategory Kernel
 123.403 + @direntry
 123.404 + * GRUB: (grub).                 The GRand Unified Bootloader
 123.405 +@@ -34,53 +53,16 @@
 123.406 + 
 123.407 + @setchapternewpage odd
 123.408 + 
 123.409 +-@ifinfo
 123.410 +-Copyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc.
 123.411 +-
 123.412 +-Permission is granted to make and distribute verbatim copies of
 123.413 +-this manual provided the copyright notice and this permission notice
 123.414 +-are preserved on all copies.
 123.415 +-
 123.416 +-@ignore
 123.417 +-Permission is granted to process this file through TeX and print the
 123.418 +-results, provided the printed document carries a copying permission
 123.419 +-notice identical to this one except for the removal of this paragraph
 123.420 +-(this paragraph not being relevant to the printed manual).
 123.421 +-
 123.422 +-@end ignore
 123.423 +-
 123.424 +-Permission is granted to copy and distribute modified versions of this
 123.425 +-manual under the conditions for verbatim copying, provided also that
 123.426 +-the entire resulting derived work is distributed under the terms of a
 123.427 +-permission notice identical to this one.
 123.428 +-
 123.429 +-Permission is granted to copy and distribute translations of this manual
 123.430 +-into another language, under the above conditions for modified versions.
 123.431 +-@end ifinfo
 123.432 +-
 123.433 + @titlepage
 123.434 + @sp 10
 123.435 +-@title the GRUB manual
 123.436 ++@title the GNU GRUB manual
 123.437 + @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}.
 123.438 + @author Gordon Matzigkeit
 123.439 + @author Yoshinori K. Okuji
 123.440 + @c The following two commands start the copyright page.
 123.441 + @page
 123.442 + @vskip 0pt plus 1filll
 123.443 +-Copyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc.
 123.444 +-
 123.445 +-Permission is granted to make and distribute verbatim copies of
 123.446 +-this manual provided the copyright notice and this permission notice
 123.447 +-are preserved on all copies.
 123.448 +-Permission is granted to copy and distribute modified versions of this
 123.449 +-manual under the conditions for verbatim copying, provided that the entire
 123.450 +-resulting derived work is distributed under the terms of a permission
 123.451 +-notice identical to this one.
 123.452 +-
 123.453 +-Permission is granted to copy and distribute translations of this manual
 123.454 +-into another language, under the above conditions for modified versions,
 123.455 +-except that this permission notice may be stated in a translation approved
 123.456 +-by Free Software Foundation.
 123.457 ++@insertcopying
 123.458 + @end titlepage
 123.459 + 
 123.460 + @c Output the table of contents at the beginning.
 123.461 +@@ -91,12 +73,14 @@ by Free Software Foundation.
 123.462 + 
 123.463 + @ifnottex
 123.464 + @node Top
 123.465 +-@top GRUB manual
 123.466 ++@top GNU GRUB manual
 123.467 + 
 123.468 + This is the documentation of GNU GRUB, the GRand Unified Bootloader,
 123.469 + a flexible and powerful boot loader program for @sc{pc}s.
 123.470 + 
 123.471 + This edition documents version @value{VERSION}.
 123.472 ++
 123.473 ++@insertcopying
 123.474 + @end ifnottex
 123.475 + 
 123.476 + @menu
 123.477 +@@ -124,6 +108,7 @@ This edition documents version @value{VE
 123.478 + * Reporting bugs::              Where you should send a bug report
 123.479 + * Future::                      Some future plans on GRUB
 123.480 + * Internals::                   Hacking GRUB
 123.481 ++* Copying This Manual::         Copying This Manual
 123.482 + * Index::
 123.483 + @end menu
 123.484 + 
 123.485 +@@ -3965,6 +3950,16 @@ homepage}.
 123.486 + @include internals.texi
 123.487 + 
 123.488 + 
 123.489 ++@node Copying This Manual
 123.490 ++@appendix Copying This Manual
 123.491 ++
 123.492 ++@menu
 123.493 ++* GNU Free Documentation License::  License for copying this manual.
 123.494 ++@end menu
 123.495 ++
 123.496 ++@include fdl.texi
 123.497 ++
 123.498 ++
 123.499 + @node Index
 123.500 + @unnumbered Index
 123.501 + 
 123.502 +diff -uprN grub-0.97/docs/Makefile.am grub/docs/Makefile.am
 123.503 +--- grub-0.97/docs/Makefile.am	2003-07-09 12:45:35.000000000 +0100
 123.504 ++++ grub/docs/Makefile.am	2006-06-24 15:40:02.000000000 +0100
 123.505 +@@ -1,5 +1,5 @@
 123.506 + info_TEXINFOS = grub.texi multiboot.texi
 123.507 +-grub_TEXINFOS = internals.texi
 123.508 ++grub_TEXINFOS = internals.texi fdl.texi
 123.509 + EXAMPLES = boot.S kernel.c multiboot.h
 123.510 + multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi
 123.511 + man_MANS = grub.8 mbchk.1 grub-install.8 grub-md5-crypt.8 grub-terminfo.8
 123.512 +diff -uprN grub-0.97/docs/Makefile.in grub/docs/Makefile.in
 123.513 +--- grub-0.97/docs/Makefile.in	2005-05-08 03:42:34.000000000 +0100
 123.514 ++++ grub/docs/Makefile.in	2006-06-24 15:40:02.000000000 +0100
 123.515 +@@ -202,7 +202,7 @@ sharedstatedir = @sharedstatedir@
 123.516 + sysconfdir = @sysconfdir@
 123.517 + target_alias = @target_alias@
 123.518 + info_TEXINFOS = grub.texi multiboot.texi
 123.519 +-grub_TEXINFOS = internals.texi
 123.520 ++grub_TEXINFOS = internals.texi fdl.texi
 123.521 + EXAMPLES = boot.S kernel.c multiboot.h
 123.522 + multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi
 123.523 + man_MANS = grub.8 mbchk.1 grub-install.8 grub-md5-crypt.8 grub-terminfo.8
 123.524 +diff -uprN grub-0.97/docs/mbchk.1 grub/docs/mbchk.1
 123.525 +--- grub-0.97/docs/mbchk.1	2005-05-08 03:48:56.000000000 +0100
 123.526 ++++ grub/docs/mbchk.1	2006-06-24 15:40:02.000000000 +0100
 123.527 +@@ -1,5 +1,5 @@
 123.528 + .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.23.
 123.529 +-.TH MBCHK "1" "May 2005" "mbchk (GNU GRUB 0.97)" FSF
 123.530 ++.TH MBCHK "1" "June 2006" "mbchk (GNU GRUB 0.97)" FSF
 123.531 + .SH NAME
 123.532 + mbchk \- check the format of a Multiboot kernel
 123.533 + .SH SYNOPSIS
 123.534 +diff -uprN grub-0.97/docs/multiboot.texi grub/docs/multiboot.texi
 123.535 +--- grub-0.97/docs/multiboot.texi	2003-07-09 12:45:36.000000000 +0100
 123.536 ++++ grub/docs/multiboot.texi	2006-06-24 15:40:02.000000000 +0100
 123.537 +@@ -1,32 +1,28 @@
 123.538 + \input texinfo @c -*-texinfo-*-
 123.539 +-@c -*-texinfo-*-
 123.540 + @c %**start of header
 123.541 + @setfilename multiboot.info
 123.542 +-@settitle Multiboot Specification
 123.543 +-@c %**end of header
 123.544 +-
 123.545 ++@set VERSION 0.6.95
 123.546 ++@settitle Multiboot Specification version @value{VERSION}
 123.547 + @c Unify all our little indices for now.
 123.548 + @syncodeindex fn cp
 123.549 + @syncodeindex vr cp
 123.550 + @syncodeindex ky cp
 123.551 + @syncodeindex pg cp
 123.552 + @syncodeindex tp cp
 123.553 ++@c %**end of header
 123.554 + 
 123.555 + @footnotestyle separate
 123.556 + @paragraphindent 3
 123.557 + @finalout
 123.558 + 
 123.559 ++@copying
 123.560 ++Copyright @copyright{} 1995,96 Bryan Ford <baford@@cs.utah.edu>
 123.561 + 
 123.562 +-@dircategory Kernel
 123.563 +-@direntry
 123.564 +-* Multiboot Specification: (multiboot).		Multiboot Specification.
 123.565 +-@end direntry
 123.566 ++Copyright @copyright{} 1995,96 Erich Stefan Boleyn <erich@@uruk.org>
 123.567 + 
 123.568 +-@ifinfo
 123.569 +-Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
 123.570 +-Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
 123.571 +-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 123.572 ++Copyright @copyright{} 1999,2000,2001,2002,2005,2006 Free Software Foundation, Inc.
 123.573 + 
 123.574 ++@quotation
 123.575 + Permission is granted to make and distribute verbatim copies of
 123.576 + this manual provided the copyright notice and this permission notice
 123.577 + are preserved on all copies.
 123.578 +@@ -36,7 +32,6 @@ Permission is granted to process this fi
 123.579 + results, provided the printed document carries a copying permission
 123.580 + notice identical to this one except for the removal of this paragraph
 123.581 + (this paragraph not being relevant to the printed manual).
 123.582 +-
 123.583 + @end ignore
 123.584 + 
 123.585 + Permission is granted to copy and distribute modified versions of this
 123.586 +@@ -45,31 +40,23 @@ the entire resulting derived work is dis
 123.587 + permission notice identical to this one.
 123.588 + 
 123.589 + Permission is granted to copy and distribute translations of this manual
 123.590 +-into another language, under the above conditions for modified versions.
 123.591 +-@end ifinfo
 123.592 ++into another language, under the above conditions for modified
 123.593 ++versions.
 123.594 ++@end quotation
 123.595 ++@end copying
 123.596 ++
 123.597 ++@dircategory Kernel
 123.598 ++@direntry
 123.599 ++* Multiboot Specification: (multiboot).		Multiboot Specification.
 123.600 ++@end direntry
 123.601 + 
 123.602 + @titlepage
 123.603 + @sp 10
 123.604 +-@title The Multiboot Specification
 123.605 ++@title The Multiboot Specification version @value{VERSION}
 123.606 + @author Yoshinori K. Okuji, Bryan Ford, Erich Stefan Boleyn, Kunihiro Ishiguro
 123.607 + @page
 123.608 +-
 123.609 + @vskip 0pt plus 1filll
 123.610 +-Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu>
 123.611 +-Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org>
 123.612 +-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 123.613 +-
 123.614 +-Permission is granted to make and distribute verbatim copies of
 123.615 +-this manual provided the copyright notice and this permission notice
 123.616 +-are preserved on all copies.
 123.617 +-
 123.618 +-Permission is granted to copy and distribute modified versions of this
 123.619 +-manual under the conditions for verbatim copying, provided also that
 123.620 +-the entire resulting derived work is distributed under the terms of a
 123.621 +-permission notice identical to this one.
 123.622 +-
 123.623 +-Permission is granted to copy and distribute translations of this manual
 123.624 +-into another language, under the above conditions for modified versions.
 123.625 ++@insertcopying
 123.626 + @end titlepage
 123.627 + 
 123.628 + @finalout
 123.629 +@@ -80,7 +67,9 @@ into another language, under the above c
 123.630 + @top Multiboot Specification
 123.631 + 
 123.632 + This file documents Multiboot Specification, the proposal for the boot
 123.633 +-sequence standard. This edition documents version 0.6.93.
 123.634 ++sequence standard. This edition documents version @value{VERSION}.
 123.635 ++
 123.636 ++@insertcopying
 123.637 + @end ifnottex
 123.638 + 
 123.639 + @menu
 123.640 +@@ -426,7 +415,7 @@ mode table (@pxref{Boot information form
 123.641 + kernel.
 123.642 + 
 123.643 + If bit 16 in the @samp{flags} word is set, then the fields at offsets
 123.644 +-8-24 in the Multiboot header are valid, and the boot loader should use
 123.645 ++12-28 in the Multiboot header are valid, and the boot loader should use
 123.646 + them instead of the fields in the actual executable header to calculate
 123.647 + where to load the OS image. This information does not need to be
 123.648 + provided if the kernel image is in @sc{elf} format, but it @emph{must}
 123.649 +@@ -677,7 +666,7 @@ follows:
 123.650 + @example
 123.651 + @group
 123.652 + +-------+-------+-------+-------+
 123.653 +-| drive | part1 | part2 | part3 |
 123.654 ++| part3 | part2 | part1 | drive |
 123.655 + +-------+-------+-------+-------+
 123.656 + @end group
 123.657 + @end example
 123.658 +@@ -1197,6 +1186,17 @@ Rewritten, using more strict words.
 123.659 + @item
 123.660 + The maintainer changes to the GNU GRUB maintainer team
 123.661 + @email{bug-grub@@gnu.org}, from Bryan Ford and Erich Stefan Boleyn.
 123.662 ++
 123.663 ++@item
 123.664 ++The byte order of the @samp{boot_device} in Multiboot information is
 123.665 ++reversed. This was a mistake.
 123.666 ++
 123.667 ++@item
 123.668 ++The offset of the address fields were wrong.
 123.669 ++
 123.670 ++@item
 123.671 ++The format is adapted to a newer Texinfo, and the version number is
 123.672 ++specified more explicitly in the title.
 123.673 + @end itemize
 123.674 + 
 123.675 + @item 0.6
 123.676 +diff -uprN grub-0.97/grub/asmstub.c grub/grub/asmstub.c
 123.677 +--- grub-0.97/grub/asmstub.c	2005-02-16 20:45:14.000000000 +0000
 123.678 ++++ grub/grub/asmstub.c	2008-03-28 13:22:28.000000000 +0000
 123.679 +@@ -55,6 +55,10 @@ int grub_stage2 (void);
 123.680 + # endif /* ! BLKFLSBUF */
 123.681 + #endif /* __linux__ */
 123.682 + 
 123.683 ++#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
 123.684 ++# include <sys/sysctl.h>
 123.685 ++#endif
 123.686 ++
 123.687 + /* We want to prevent any circularararity in our stubs, as well as
 123.688 +    libc name clashes. */
 123.689 + #define WITHOUT_LIBC_STUBS 1
 123.690 +@@ -777,7 +781,39 @@ get_diskinfo (int drive, struct geometry
 123.691 + 
 123.692 +       /* Open read/write, or read-only if that failed. */
 123.693 +       if (! read_only)
 123.694 +-	disks[drive].flags = open (devname, O_RDWR);
 123.695 ++	{
 123.696 ++/* By default, kernel of FreeBSD does not allow overwriting MBR */
 123.697 ++#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
 123.698 ++#define GEOM_SYSCTL	"kern.geom.debugflags"
 123.699 ++	  int old_flags, flags;
 123.700 ++	  size_t sizeof_int = sizeof (int);
 123.701 ++
 123.702 ++	  if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0)
 123.703 ++	    grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
 123.704 ++
 123.705 ++	  if ((old_flags & 0x10) == 0)
 123.706 ++	    {
 123.707 ++	      /* "allow foot shooting", see geom(4) */
 123.708 ++	      flags = old_flags | 0x10;
 123.709 ++
 123.710 ++	      if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0)
 123.711 ++		{
 123.712 ++		  flags = old_flags;
 123.713 ++		  grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
 123.714 ++		}
 123.715 ++	    }
 123.716 ++	  else
 123.717 ++	    flags = old_flags;
 123.718 ++#endif
 123.719 ++	  disks[drive].flags = open (devname, O_RDWR);
 123.720 ++#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
 123.721 ++	  if (flags != old_flags)
 123.722 ++	    {
 123.723 ++	      if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0)
 123.724 ++	        grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno));
 123.725 ++	    }
 123.726 ++#endif
 123.727 ++	}
 123.728 + 
 123.729 +       if (disks[drive].flags == -1)
 123.730 + 	{
 123.731 +@@ -926,7 +962,7 @@ hex_dump (void *buf, size_t size)
 123.732 + 
 123.733 + int
 123.734 + biosdisk (int subfunc, int drive, struct geometry *geometry,
 123.735 +-	  int sector, int nsec, int segment)
 123.736 ++	  unsigned int sector, int nsec, int segment)
 123.737 + {
 123.738 +   char *buf;
 123.739 +   int fd = geometry->flags;
 123.740 +diff -uprN grub-0.97/grub/main.c grub/grub/main.c
 123.741 +--- grub-0.97/grub/main.c	2003-07-09 12:45:36.000000000 +0100
 123.742 ++++ grub/grub/main.c	2006-05-05 22:43:46.000000000 +0100
 123.743 +@@ -32,6 +32,7 @@ int grub_stage2 (void);
 123.744 + #define WITHOUT_LIBC_STUBS 1
 123.745 + #include <shared.h>
 123.746 + #include <term.h>
 123.747 ++#include <device.h>
 123.748 + 
 123.749 + char *program_name = 0;
 123.750 + int use_config_file = 1;
 123.751 +@@ -192,6 +193,12 @@ main (int argc, char **argv)
 123.752 + 	      perror ("strtoul");
 123.753 + 	      exit (1);
 123.754 + 	    }
 123.755 ++	  if (boot_drive >= NUM_DISKS)
 123.756 ++	    {
 123.757 ++	      fprintf (stderr, "boot_drive should be from 0 to %d\n",
 123.758 ++		       NUM_DISKS - 1);
 123.759 ++	      exit (1);
 123.760 ++	    }
 123.761 + 	  break;
 123.762 + 
 123.763 + 	case OPT_NO_CONFIG_FILE:
 123.764 +diff -uprN grub-0.97/lib/device.c grub/lib/device.c
 123.765 +--- grub-0.97/lib/device.c	2005-03-28 00:14:25.000000000 +0100
 123.766 ++++ grub/lib/device.c	2008-03-28 13:22:28.000000000 +0000
 123.767 +@@ -69,9 +69,9 @@ struct hd_geometry
 123.768 + # ifndef CDROM_GET_CAPABILITY
 123.769 + #  define CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
 123.770 + # endif /* ! CDROM_GET_CAPABILITY */
 123.771 +-# ifndef BLKGETSIZE
 123.772 +-#  define BLKGETSIZE	_IO(0x12,96)	/* return device size */
 123.773 +-# endif /* ! BLKGETSIZE */
 123.774 ++# ifndef BLKGETSIZE64
 123.775 ++#  define BLKGETSIZE64	_IOR(0x12,114,size_t)	/* return device size */
 123.776 ++# endif /* ! BLKGETSIZE64 */
 123.777 + #endif /* __linux__ */
 123.778 + 
 123.779 + /* Use __FreeBSD_kernel__ instead of __FreeBSD__ for compatibility with
 123.780 +@@ -152,19 +152,19 @@ get_drive_geometry (struct geometry *geo
 123.781 +   /* Linux */
 123.782 +   {
 123.783 +     struct hd_geometry hdg;
 123.784 +-    unsigned long nr;
 123.785 ++    unsigned long long nr;
 123.786 +     
 123.787 +     if (ioctl (fd, HDIO_GETGEO, &hdg))
 123.788 +       goto fail;
 123.789 + 
 123.790 +-    if (ioctl (fd, BLKGETSIZE, &nr))
 123.791 ++    if (ioctl (fd, BLKGETSIZE64, &nr))
 123.792 +       goto fail;
 123.793 +     
 123.794 +     /* Got the geometry, so save it. */
 123.795 +     geom->cylinders = hdg.cylinders;
 123.796 +     geom->heads = hdg.heads;
 123.797 +     geom->sectors = hdg.sectors;
 123.798 +-    geom->total_sectors = nr;
 123.799 ++    geom->total_sectors = nr / 512;
 123.800 +     
 123.801 +     goto success;
 123.802 +   }
 123.803 +@@ -407,6 +407,12 @@ get_ataraid_disk_name (char *name, int u
 123.804 + {
 123.805 +   sprintf (name, "/dev/ataraid/d%c", unit + '0');
 123.806 + }
 123.807 ++
 123.808 ++static void
 123.809 ++get_i2o_disk_name (char *name, char unit)
 123.810 ++{
 123.811 ++  sprintf (name, "/dev/i2o/hd%c", unit);
 123.812 ++}
 123.813 + #endif
 123.814 + 
 123.815 + /* Check if DEVICE can be read. If an error occurs, return zero,
 123.816 +@@ -801,6 +807,29 @@ init_device_map (char ***map, const char
 123.817 + 	  }
 123.818 +       }
 123.819 +   }
 123.820 ++    
 123.821 ++  /* This is for I2O - we have /dev/i2o/hd<logical drive><partition> */
 123.822 ++  {
 123.823 ++    int unit;
 123.824 ++
 123.825 ++    for (unit = 'a'; unit < 'f'; unit++)
 123.826 ++      {
 123.827 ++        char name[24];
 123.828 ++    
 123.829 ++        get_i2o_disk_name (name, unit);
 123.830 ++        if (check_device (name))
 123.831 ++          {
 123.832 ++              (*map)[num_hd + 0x80] = strdup (name);
 123.833 ++                  assert ((*map)[num_hd + 0x80]);
 123.834 ++                  
 123.835 ++	    /* If the device map file is opened, write the map.  */
 123.836 ++               if (fp)
 123.837 ++                     fprintf (fp, "(hd%d)\t%s\n", num_hd, name);
 123.838 ++                     
 123.839 ++	    num_hd++;
 123.840 ++          }
 123.841 ++      }
 123.842 ++  }
 123.843 + #endif /* __linux__ */
 123.844 +   
 123.845 +   /* OK, close the device map file if opened.  */
 123.846 +@@ -861,6 +890,12 @@ write_to_partition (char **map, int driv
 123.847 +       if (strcmp (dev + strlen(dev) - 5, "/disc") == 0)
 123.848 + 	strcpy (dev + strlen(dev) - 5, "/part");
 123.849 +     }
 123.850 ++  else
 123.851 ++    {
 123.852 ++      if ((strncmp (dev, "/dev/ataraid/", 13) == 0) ||
 123.853 ++         (strncmp (dev, "/dev/rd/", 8) == 0))
 123.854 ++        strcpy (dev + strlen(dev), "p");
 123.855 ++    }
 123.856 +   sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1);
 123.857 +   
 123.858 +   /* Open the partition.  */
 123.859 +diff -uprN grub-0.97/netboot/3c509.c grub/netboot/3c509.c
 123.860 +--- grub-0.97/netboot/3c509.c	2003-07-09 12:45:37.000000000 +0100
 123.861 ++++ grub/netboot/3c509.c	2002-01-02 21:56:40.000000000 +0000
 123.862 +@@ -18,7 +18,7 @@ Author: Martin Renters.
 123.863 + 
 123.864 + 3c509 support added by Serge Babkin (babkin@hq.icb.chel.su)
 123.865 + 
 123.866 +-$Id: 3c509.c,v 1.4 2002/01/02 21:56:40 okuji Exp $
 123.867 ++$Id: 3c509.c 609 2002-01-02 21:56:40Z okuji $
 123.868 + 
 123.869 + ***************************************************************************/
 123.870 + 
 123.871 +diff -uprN grub-0.97/netboot/cs89x0.c grub/netboot/cs89x0.c
 123.872 +--- grub-0.97/netboot/cs89x0.c	2003-07-09 12:45:37.000000000 +0100
 123.873 ++++ grub/netboot/cs89x0.c	2008-05-20 12:04:18.000000000 +0100
 123.874 +@@ -1,3 +1,21 @@
 123.875 ++/**
 123.876 ++   Per an email message from Russ Nelson <nelson@crynwr.com> on
 123.877 ++   18 March 2008 this file is now licensed under GPL Version 2.
 123.878 ++
 123.879 ++   From: Russ Nelson <nelson@crynwr.com>
 123.880 ++   Date: Tue, 18 Mar 2008 12:42:00 -0400
 123.881 ++   Subject: Re: [Etherboot-developers] cs89x0 driver in etherboot
 123.882 ++   -- quote from email
 123.883 ++   As copyright holder, if I say it doesn't conflict with the GPL,
 123.884 ++   then it doesn't conflict with the GPL.
 123.885 ++
 123.886 ++   However, there's no point in causing people's brains to overheat,
 123.887 ++   so yes, I grant permission for the code to be relicensed under the
 123.888 ++   GPLv2.  Please make sure that this change in licensing makes its
 123.889 ++   way upstream.  -russ
 123.890 ++   -- quote from email
 123.891 ++**/
 123.892 ++
 123.893 + /* cs89x0.c: A Crystal Semiconductor CS89[02]0 driver for etherboot. */
 123.894 + /*
 123.895 +   Permission is granted to distribute the enclosed cs89x0.[ch] driver
 123.896 +diff -uprN grub-0.97/netboot/cs89x0.h grub/netboot/cs89x0.h
 123.897 +--- grub-0.97/netboot/cs89x0.h	2003-07-09 12:45:37.000000000 +0100
 123.898 ++++ grub/netboot/cs89x0.h	2008-05-20 12:04:18.000000000 +0100
 123.899 +@@ -1,3 +1,21 @@
 123.900 ++/**
 123.901 ++   Per an email message from Russ Nelson <nelson@crynwr.com> on
 123.902 ++   18 March 2008 this file is now licensed under GPL Version 2.
 123.903 ++
 123.904 ++   From: Russ Nelson <nelson@crynwr.com>
 123.905 ++   Date: Tue, 18 Mar 2008 12:42:00 -0400
 123.906 ++   Subject: Re: [Etherboot-developers] cs89x0 driver in etherboot
 123.907 ++   -- quote from email
 123.908 ++   As copyright holder, if I say it doesn't conflict with the GPL,
 123.909 ++   then it doesn't conflict with the GPL.
 123.910 ++
 123.911 ++   However, there's no point in causing people's brains to overheat,
 123.912 ++   so yes, I grant permission for the code to be relicensed under the
 123.913 ++   GPLv2.  Please make sure that this change in licensing makes its
 123.914 ++   way upstream.  -russ
 123.915 ++   -- quote from email
 123.916 ++**/
 123.917 ++
 123.918 + /*  Copyright, 1988-1992, Russell Nelson, Crynwr Software
 123.919 + 
 123.920 +    This program is free software; you can redistribute it and/or modify
 123.921 +diff -uprN grub-0.97/netboot/etherboot.h grub/netboot/etherboot.h
 123.922 +--- grub-0.97/netboot/etherboot.h	2003-07-09 12:45:37.000000000 +0100
 123.923 ++++ grub/netboot/etherboot.h	2006-09-08 13:56:22.000000000 +0100
 123.924 +@@ -531,9 +531,6 @@ extern int ip_abort;
 123.925 + extern int network_ready;
 123.926 + extern struct rom_info rom;
 123.927 + extern struct arptable_t arptable[MAX_ARP];
 123.928 +-extern struct bootpd_t bootp_data;
 123.929 +-#define	BOOTP_DATA_ADDR	(&bootp_data)
 123.930 +-extern unsigned char *end_of_rfc1533;
 123.931 + 
 123.932 + /* config.c */
 123.933 + extern struct nic nic;
 123.934 +diff -uprN grub-0.97/netboot/main.c grub/netboot/main.c
 123.935 +--- grub-0.97/netboot/main.c	2004-05-20 23:19:33.000000000 +0100
 123.936 ++++ grub/netboot/main.c	2006-09-08 13:56:22.000000000 +0100
 123.937 +@@ -56,7 +56,8 @@ static int vendorext_isvalid;
 123.938 + static unsigned long netmask;
 123.939 + static struct bootpd_t bootp_data;
 123.940 + static unsigned long xid;
 123.941 +-static unsigned char *end_of_rfc1533 = NULL;
 123.942 ++
 123.943 ++#define	BOOTP_DATA_ADDR	(&bootp_data)
 123.944 + 
 123.945 + #ifndef	NO_DHCP_SUPPORT
 123.946 + #endif /* NO_DHCP_SUPPORT */
 123.947 +@@ -967,7 +968,6 @@ decode_rfc1533 (unsigned char *p, int bl
 123.948 +   
 123.949 +   if (block == 0)
 123.950 +     {
 123.951 +-      end_of_rfc1533 = NULL;
 123.952 +       vendorext_isvalid = 0;
 123.953 +       
 123.954 +       if (grub_memcmp (p, rfc1533_cookie, 4))
 123.955 +@@ -1021,7 +1021,7 @@ decode_rfc1533 (unsigned char *p, int bl
 123.956 + 	}
 123.957 +       else if (c == RFC1533_END)
 123.958 + 	{
 123.959 +-	  end_of_rfc1533 = endp = p;
 123.960 ++	  endp = p;
 123.961 + 	  continue;
 123.962 + 	}
 123.963 +       else if (c == RFC1533_NETMASK)
 123.964 +diff -uprN grub-0.97/netboot/natsemi.c grub/netboot/natsemi.c
 123.965 +--- grub-0.97/netboot/natsemi.c	2003-07-09 12:45:38.000000000 +0100
 123.966 ++++ grub/netboot/natsemi.c	2006-09-10 08:26:10.000000000 +0100
 123.967 +@@ -608,7 +608,7 @@ natsemi_transmit(struct nic  *nic,
 123.968 + 		 const char  *p)     /* Packet */
 123.969 + {
 123.970 +     u32 status, to, nstype;
 123.971 +-    u32 tx_status;
 123.972 ++    volatile u32 tx_status;
 123.973 +     
 123.974 +     /* Stop the transmitter */
 123.975 +     outl(TxOff, ioaddr + ChipCmd);
 123.976 +@@ -647,7 +647,7 @@ natsemi_transmit(struct nic  *nic,
 123.977 + 
 123.978 +     to = currticks() + TX_TIMEOUT;
 123.979 + 
 123.980 +-    while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to))
 123.981 ++    while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to))