|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] build system: stubdom targets now depends on mini-os target
commit 42ddf48a29d2109e6b33fddd6dafd75e0747fd09
Author: Wei Liu <wei.liu2@xxxxxxxxxx>
AuthorDate: Fri Jan 30 15:58:38 2015 +0000
Commit: Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Fri Feb 27 16:04:50 2015 +0000
build system: stubdom targets now depends on mini-os target
Provide mini-os url and revision in Config.mk
Make stubdom targets depend on mini-os-dir target. Make
subtree-force-update{,-all} depend on mini-os-dir-force-update.
Also make mktarball script generate mini-os archive.
Original mini-os directory is renamed to mini-os-intree to help reduce
patch length. That directory will be deleted in a separate patch.
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
Changes in v3:
1. Put mini-os targets in main Makefile.
2. Stubdom clean and distclean don't depend on mini-os-dir.
Changes in v2:
1. Use hash in Config.mk.
---
.gitignore | 6 +-
Config.mk | 6 +
Makefile | 24 +-
extras/mini-os-intree/COPYING | 36 +
extras/mini-os-intree/Config.mk | 99 ++
extras/mini-os-intree/Makefile | 224 +++
extras/mini-os-intree/README | 46 +
extras/mini-os-intree/app.lds | 11 +
extras/mini-os-intree/arch/arm/arm32.S | 294 ++++
extras/mini-os-intree/arch/arm/events.c | 31 +
extras/mini-os-intree/arch/arm/hypercalls32.S | 64 +
extras/mini-os-intree/arch/arm/minios-arm32.lds | 83 ++
extras/mini-os-intree/arch/arm/mm.c | 139 ++
extras/mini-os-intree/arch/arm/panic.c | 98 ++
extras/mini-os-intree/arch/arm/sched.c | 47 +
extras/mini-os-intree/arch/arm/setup.c | 119 ++
extras/mini-os-intree/arch/arm/time.c | 136 ++
extras/mini-os-intree/arch/x86/Makefile | 30 +
extras/mini-os-intree/arch/x86/arch.mk | 22 +
extras/mini-os-intree/arch/x86/events.c | 35 +
extras/mini-os-intree/arch/x86/ioremap.c | 75 +
extras/mini-os-intree/arch/x86/iorw.c | 35 +
extras/mini-os-intree/arch/x86/minios-x86_32.lds | 74 +
extras/mini-os-intree/arch/x86/minios-x86_64.lds | 74 +
extras/mini-os-intree/arch/x86/mm.c | 957 ++++++++++++
extras/mini-os-intree/arch/x86/sched.c | 139 ++
extras/mini-os-intree/arch/x86/setup.c | 168 +++
extras/mini-os-intree/arch/x86/time.c | 238 +++
extras/mini-os-intree/arch/x86/traps.c | 333 +++++
extras/mini-os-intree/arch/x86/x86_32.S | 305 ++++
extras/mini-os-intree/arch/x86/x86_64.S | 383 +++++
extras/mini-os-intree/blkfront.c | 736 ++++++++++
extras/mini-os-intree/config/MiniOS.mk | 10 +
extras/mini-os-intree/config/StdGNU.mk | 47 +
extras/mini-os-intree/config/arm32.mk | 22 +
extras/mini-os-intree/config/arm64.mk | 19 +
extras/mini-os-intree/config/x86_32.mk | 20 +
extras/mini-os-intree/config/x86_64.mk | 33 +
extras/mini-os-intree/console/console.c | 164 ++
extras/mini-os-intree/console/console.h | 2 +
extras/mini-os-intree/console/xenbus.c | 195 +++
extras/mini-os-intree/console/xencons_ring.c | 195 +++
extras/mini-os-intree/daytime.c | 67 +
extras/mini-os-intree/domain_config | 19 +
extras/mini-os-intree/events.c | 269 ++++
extras/mini-os-intree/fbfront.c | 710 +++++++++
extras/mini-os-intree/gntmap.c | 250 ++++
extras/mini-os-intree/gnttab.c | 196 +++
extras/mini-os-intree/hypervisor.c | 132 ++
extras/mini-os-intree/include/arch/cc.h | 87 ++
extras/mini-os-intree/include/arch/perf.h | 15 +
extras/mini-os-intree/include/arch/sys_arch.h | 35 +
extras/mini-os-intree/include/arm/arch_endian.h | 7 +
extras/mini-os-intree/include/arm/arch_limits.h | 9 +
extras/mini-os-intree/include/arm/arch_mm.h | 38 +
extras/mini-os-intree/include/arm/arch_sched.h | 19 +
extras/mini-os-intree/include/arm/arch_spinlock.h | 36 +
.../include/arm/arm32/arch_wordsize.h | 1 +
extras/mini-os-intree/include/arm/gic.h | 1 +
extras/mini-os-intree/include/arm/hypercall-arm.h | 98 ++
extras/mini-os-intree/include/arm/os.h | 216 +++
extras/mini-os-intree/include/arm/traps.h | 20 +
extras/mini-os-intree/include/blkfront.h | 54 +
extras/mini-os-intree/include/byteorder.h | 36 +
extras/mini-os-intree/include/byteswap.h | 39 +
extras/mini-os-intree/include/compiler.h | 10 +
extras/mini-os-intree/include/console.h | 89 ++
extras/mini-os-intree/include/ctype.h | 60 +
extras/mini-os-intree/include/endian.h | 19 +
extras/mini-os-intree/include/err.h | 31 +
extras/mini-os-intree/include/errno-base.h | 39 +
extras/mini-os-intree/include/errno.h | 122 ++
extras/mini-os-intree/include/events.h | 59 +
extras/mini-os-intree/include/fbfront.h | 46 +
extras/mini-os-intree/include/fcntl.h | 99 ++
extras/mini-os-intree/include/gntmap.h | 35 +
extras/mini-os-intree/include/gnttab.h | 17 +
extras/mini-os-intree/include/hypervisor.h | 48 +
extras/mini-os-intree/include/ioremap.h | 33 +
extras/mini-os-intree/include/iorw.h | 16 +
extras/mini-os-intree/include/kernel.h | 9 +
extras/mini-os-intree/include/lib-gpl.h | 59 +
extras/mini-os-intree/include/lib.h | 230 +++
extras/mini-os-intree/include/linux/types.h | 5 +
extras/mini-os-intree/include/lwipopts.h | 23 +
.../mini-os-intree/include/minios-external/README | 24 +
.../include/minios-external/bsd-COPYRIGHT | 126 ++
.../include/minios-external/bsd-queue.3 | 1044 +++++++++++++
.../minios-external/bsd-sys-queue-h-seddery | 72 +
.../include/minios-external/bsd-sys-queue.h | 637 ++++++++
extras/mini-os-intree/include/mm.h | 82 +
extras/mini-os-intree/include/netfront.h | 24 +
extras/mini-os-intree/include/pcifront.h | 29 +
extras/mini-os-intree/include/posix/arpa/inet.h | 7 +
extras/mini-os-intree/include/posix/dirent.h | 24 +
extras/mini-os-intree/include/posix/err.h | 15 +
extras/mini-os-intree/include/posix/fcntl.h | 11 +
extras/mini-os-intree/include/posix/limits.h | 48 +
extras/mini-os-intree/include/posix/net/if.h | 85 ++
extras/mini-os-intree/include/posix/netdb.h | 9 +
extras/mini-os-intree/include/posix/netinet/in.h | 7 +
extras/mini-os-intree/include/posix/netinet/tcp.h | 6 +
extras/mini-os-intree/include/posix/poll.h | 1 +
extras/mini-os-intree/include/posix/pthread.h | 64 +
extras/mini-os-intree/include/posix/signal.h | 10 +
extras/mini-os-intree/include/posix/stdlib.h | 8 +
extras/mini-os-intree/include/posix/strings.h | 12 +
extras/mini-os-intree/include/posix/sys/ioctl.h | 16 +
extras/mini-os-intree/include/posix/sys/mman.h | 22 +
extras/mini-os-intree/include/posix/sys/poll.h | 79 +
extras/mini-os-intree/include/posix/sys/select.h | 7 +
extras/mini-os-intree/include/posix/sys/socket.h | 31 +
extras/mini-os-intree/include/posix/sys/stat.h | 7 +
extras/mini-os-intree/include/posix/syslog.h | 37 +
extras/mini-os-intree/include/posix/termios.h | 87 ++
extras/mini-os-intree/include/posix/time.h | 11 +
extras/mini-os-intree/include/posix/unistd.h | 16 +
extras/mini-os-intree/include/sched.h | 55 +
extras/mini-os-intree/include/semaphore.h | 110 ++
extras/mini-os-intree/include/spinlock.h | 55 +
extras/mini-os-intree/include/sys/lock.h | 52 +
extras/mini-os-intree/include/sys/time.h | 47 +
extras/mini-os-intree/include/time.h | 63 +
extras/mini-os-intree/include/tpm_tis.h | 61 +
extras/mini-os-intree/include/tpmback.h | 104 ++
extras/mini-os-intree/include/tpmfront.h | 97 ++
extras/mini-os-intree/include/types.h | 74 +
extras/mini-os-intree/include/wait.h | 105 ++
extras/mini-os-intree/include/waittypes.h | 32 +
extras/mini-os-intree/include/x86/arch_endian.h | 7 +
extras/mini-os-intree/include/x86/arch_limits.h | 20 +
extras/mini-os-intree/include/x86/arch_mm.h | 233 +++
extras/mini-os-intree/include/x86/arch_sched.h | 25 +
extras/mini-os-intree/include/x86/arch_spinlock.h | 94 ++
extras/mini-os-intree/include/x86/os.h | 572 ++++++++
extras/mini-os-intree/include/x86/traps.h | 78 +
.../include/x86/x86_32/arch_wordsize.h | 1 +
.../include/x86/x86_32/hypercall-x86_32.h | 337 +++++
.../include/x86/x86_64/arch_wordsize.h | 2 +
.../include/x86/x86_64/hypercall-x86_64.h | 344 +++++
extras/mini-os-intree/include/xen/COPYING | 38 +
extras/mini-os-intree/include/xen/arch-arm.h | 432 ++++++
.../mini-os-intree/include/xen/arch-arm/hvm/save.h | 39 +
extras/mini-os-intree/include/xen/arch-x86/cpuid.h | 90 ++
.../mini-os-intree/include/xen/arch-x86/hvm/save.h | 630 ++++++++
.../mini-os-intree/include/xen/arch-x86/xen-mca.h | 440 ++++++
.../include/xen/arch-x86/xen-x86_32.h | 171 +++
.../include/xen/arch-x86/xen-x86_64.h | 202 +++
extras/mini-os-intree/include/xen/arch-x86/xen.h | 303 ++++
extras/mini-os-intree/include/xen/arch-x86_32.h | 27 +
extras/mini-os-intree/include/xen/arch-x86_64.h | 43 +
extras/mini-os-intree/include/xen/callback.h | 121 ++
extras/mini-os-intree/include/xen/dom0_ops.h | 120 ++
extras/mini-os-intree/include/xen/domctl.h | 1154 +++++++++++++++
extras/mini-os-intree/include/xen/elfnote.h | 271 ++++
extras/mini-os-intree/include/xen/event_channel.h | 385 +++++
extras/mini-os-intree/include/xen/features.h | 114 ++
extras/mini-os-intree/include/xen/gcov.h | 115 ++
extras/mini-os-intree/include/xen/grant_table.h | 682 +++++++++
extras/mini-os-intree/include/xen/hvm/e820.h | 34 +
.../include/xen/hvm/hvm_info_table.h | 72 +
extras/mini-os-intree/include/xen/hvm/hvm_op.h | 402 +++++
.../include/xen/hvm/hvm_xs_strings.h | 80 +
extras/mini-os-intree/include/xen/hvm/ioreq.h | 129 ++
extras/mini-os-intree/include/xen/hvm/params.h | 199 +++
extras/mini-os-intree/include/xen/hvm/pvdrivers.h | 49 +
extras/mini-os-intree/include/xen/hvm/save.h | 111 ++
extras/mini-os-intree/include/xen/io/blkif.h | 640 ++++++++
extras/mini-os-intree/include/xen/io/console.h | 51 +
extras/mini-os-intree/include/xen/io/fbif.h | 176 +++
extras/mini-os-intree/include/xen/io/fsif.h | 192 +++
extras/mini-os-intree/include/xen/io/kbdif.h | 132 ++
extras/mini-os-intree/include/xen/io/libxenvchan.h | 97 ++
extras/mini-os-intree/include/xen/io/netif.h | 305 ++++
extras/mini-os-intree/include/xen/io/pciif.h | 125 ++
extras/mini-os-intree/include/xen/io/protocols.h | 40 +
extras/mini-os-intree/include/xen/io/ring.h | 312 ++++
extras/mini-os-intree/include/xen/io/tpmif.h | 143 ++
extras/mini-os-intree/include/xen/io/usbif.h | 150 ++
extras/mini-os-intree/include/xen/io/vscsiif.h | 260 ++++
extras/mini-os-intree/include/xen/io/xenbus.h | 80 +
extras/mini-os-intree/include/xen/io/xs_wire.h | 149 ++
extras/mini-os-intree/include/xen/kexec.h | 249 ++++
extras/mini-os-intree/include/xen/mem_event.h | 134 ++
extras/mini-os-intree/include/xen/memory.h | 587 ++++++++
extras/mini-os-intree/include/xen/nmi.h | 85 ++
extras/mini-os-intree/include/xen/physdev.h | 380 +++++
extras/mini-os-intree/include/xen/platform.h | 606 ++++++++
extras/mini-os-intree/include/xen/sched.h | 175 +++
extras/mini-os-intree/include/xen/sysctl.h | 719 +++++++++
extras/mini-os-intree/include/xen/tmem.h | 152 ++
extras/mini-os-intree/include/xen/trace.h | 331 +++++
extras/mini-os-intree/include/xen/vcpu.h | 240 +++
extras/mini-os-intree/include/xen/version.h | 96 ++
extras/mini-os-intree/include/xen/xen-compat.h | 44 +
extras/mini-os-intree/include/xen/xen.h | 899 ++++++++++++
extras/mini-os-intree/include/xen/xencomm.h | 41 +
extras/mini-os-intree/include/xen/xenoprof.h | 152 ++
extras/mini-os-intree/include/xen/xsm/flask_op.h | 201 +++
extras/mini-os-intree/include/xenbus.h | 120 ++
extras/mini-os-intree/include/xmalloc.h | 44 +
extras/mini-os-intree/kernel.c | 198 +++
extras/mini-os-intree/lib/ctype.c | 29 +
extras/mini-os-intree/lib/math.c | 426 ++++++
extras/mini-os-intree/lib/printf.c | 786 ++++++++++
extras/mini-os-intree/lib/stack_chk_fail.c | 8 +
extras/mini-os-intree/lib/string.c | 228 +++
extras/mini-os-intree/lib/sys.c | 1550 ++++++++++++++++++++
extras/mini-os-intree/lib/xmalloc.c | 319 ++++
extras/mini-os-intree/lib/xs.c | 194 +++
extras/mini-os-intree/lock.c | 112 ++
extras/mini-os-intree/lwip-arch.c | 293 ++++
extras/mini-os-intree/lwip-net.c | 386 +++++
extras/mini-os-intree/main.c | 193 +++
extras/mini-os-intree/minios.mk | 76 +
extras/mini-os-intree/mm.c | 441 ++++++
extras/mini-os-intree/netfront.c | 675 +++++++++
extras/mini-os-intree/pcifront.c | 616 ++++++++
extras/mini-os-intree/sched.c | 304 ++++
extras/mini-os-intree/test.c | 577 ++++++++
extras/mini-os-intree/tpm_tis.c | 1523 +++++++++++++++++++
extras/mini-os-intree/tpmback.c | 1136 ++++++++++++++
extras/mini-os-intree/tpmfront.c | 631 ++++++++
extras/mini-os-intree/xenbus/xenbus.c | 870 +++++++++++
extras/mini-os/COPYING | 36 -
extras/mini-os/Config.mk | 99 --
extras/mini-os/Makefile | 224 ---
extras/mini-os/README | 46 -
extras/mini-os/app.lds | 11 -
extras/mini-os/arch/arm/arm32.S | 294 ----
extras/mini-os/arch/arm/events.c | 31 -
extras/mini-os/arch/arm/hypercalls32.S | 64 -
extras/mini-os/arch/arm/minios-arm32.lds | 83 --
extras/mini-os/arch/arm/mm.c | 139 --
extras/mini-os/arch/arm/panic.c | 98 --
extras/mini-os/arch/arm/sched.c | 47 -
extras/mini-os/arch/arm/setup.c | 119 --
extras/mini-os/arch/arm/time.c | 136 --
extras/mini-os/arch/x86/Makefile | 30 -
extras/mini-os/arch/x86/arch.mk | 22 -
extras/mini-os/arch/x86/events.c | 35 -
extras/mini-os/arch/x86/ioremap.c | 75 -
extras/mini-os/arch/x86/iorw.c | 35 -
extras/mini-os/arch/x86/minios-x86_32.lds | 74 -
extras/mini-os/arch/x86/minios-x86_64.lds | 74 -
extras/mini-os/arch/x86/mm.c | 957 ------------
extras/mini-os/arch/x86/sched.c | 139 --
extras/mini-os/arch/x86/setup.c | 168 ---
extras/mini-os/arch/x86/time.c | 238 ---
extras/mini-os/arch/x86/traps.c | 333 -----
extras/mini-os/arch/x86/x86_32.S | 305 ----
extras/mini-os/arch/x86/x86_64.S | 383 -----
extras/mini-os/blkfront.c | 736 ----------
extras/mini-os/config/MiniOS.mk | 10 -
extras/mini-os/config/StdGNU.mk | 47 -
extras/mini-os/config/arm32.mk | 22 -
extras/mini-os/config/arm64.mk | 19 -
extras/mini-os/config/x86_32.mk | 20 -
extras/mini-os/config/x86_64.mk | 33 -
extras/mini-os/console/console.c | 164 --
extras/mini-os/console/console.h | 2 -
extras/mini-os/console/xenbus.c | 195 ---
extras/mini-os/console/xencons_ring.c | 195 ---
extras/mini-os/daytime.c | 67 -
extras/mini-os/domain_config | 19 -
extras/mini-os/events.c | 269 ----
extras/mini-os/fbfront.c | 710 ---------
extras/mini-os/gntmap.c | 250 ----
extras/mini-os/gnttab.c | 196 ---
extras/mini-os/hypervisor.c | 132 --
extras/mini-os/include/arch/cc.h | 87 --
extras/mini-os/include/arch/perf.h | 15 -
extras/mini-os/include/arch/sys_arch.h | 35 -
extras/mini-os/include/arm/arch_endian.h | 7 -
extras/mini-os/include/arm/arch_limits.h | 9 -
extras/mini-os/include/arm/arch_mm.h | 38 -
extras/mini-os/include/arm/arch_sched.h | 19 -
extras/mini-os/include/arm/arch_spinlock.h | 36 -
extras/mini-os/include/arm/arm32/arch_wordsize.h | 1 -
extras/mini-os/include/arm/gic.h | 1 -
extras/mini-os/include/arm/hypercall-arm.h | 98 --
extras/mini-os/include/arm/os.h | 216 ---
extras/mini-os/include/arm/traps.h | 20 -
extras/mini-os/include/blkfront.h | 54 -
extras/mini-os/include/byteorder.h | 36 -
extras/mini-os/include/byteswap.h | 39 -
extras/mini-os/include/compiler.h | 10 -
extras/mini-os/include/console.h | 89 --
extras/mini-os/include/ctype.h | 60 -
extras/mini-os/include/endian.h | 19 -
extras/mini-os/include/err.h | 31 -
extras/mini-os/include/errno-base.h | 39 -
extras/mini-os/include/errno.h | 122 --
extras/mini-os/include/events.h | 59 -
extras/mini-os/include/fbfront.h | 46 -
extras/mini-os/include/fcntl.h | 99 --
extras/mini-os/include/gntmap.h | 35 -
extras/mini-os/include/gnttab.h | 17 -
extras/mini-os/include/hypervisor.h | 48 -
extras/mini-os/include/ioremap.h | 33 -
extras/mini-os/include/iorw.h | 16 -
extras/mini-os/include/kernel.h | 9 -
extras/mini-os/include/lib-gpl.h | 59 -
extras/mini-os/include/lib.h | 230 ---
extras/mini-os/include/linux/types.h | 5 -
extras/mini-os/include/lwipopts.h | 23 -
extras/mini-os/include/minios-external/README | 24 -
.../mini-os/include/minios-external/bsd-COPYRIGHT | 126 --
extras/mini-os/include/minios-external/bsd-queue.3 | 1044 -------------
.../minios-external/bsd-sys-queue-h-seddery | 72 -
.../include/minios-external/bsd-sys-queue.h | 637 --------
extras/mini-os/include/mm.h | 82 -
extras/mini-os/include/netfront.h | 24 -
extras/mini-os/include/pcifront.h | 29 -
extras/mini-os/include/posix/arpa/inet.h | 7 -
extras/mini-os/include/posix/dirent.h | 24 -
extras/mini-os/include/posix/err.h | 15 -
extras/mini-os/include/posix/fcntl.h | 11 -
extras/mini-os/include/posix/limits.h | 48 -
extras/mini-os/include/posix/net/if.h | 85 --
extras/mini-os/include/posix/netdb.h | 9 -
extras/mini-os/include/posix/netinet/in.h | 7 -
extras/mini-os/include/posix/netinet/tcp.h | 6 -
extras/mini-os/include/posix/poll.h | 1 -
extras/mini-os/include/posix/pthread.h | 64 -
extras/mini-os/include/posix/signal.h | 10 -
extras/mini-os/include/posix/stdlib.h | 8 -
extras/mini-os/include/posix/strings.h | 12 -
extras/mini-os/include/posix/sys/ioctl.h | 16 -
extras/mini-os/include/posix/sys/mman.h | 22 -
extras/mini-os/include/posix/sys/poll.h | 79 -
extras/mini-os/include/posix/sys/select.h | 7 -
extras/mini-os/include/posix/sys/socket.h | 31 -
extras/mini-os/include/posix/sys/stat.h | 7 -
extras/mini-os/include/posix/syslog.h | 37 -
extras/mini-os/include/posix/termios.h | 87 --
extras/mini-os/include/posix/time.h | 11 -
extras/mini-os/include/posix/unistd.h | 16 -
extras/mini-os/include/sched.h | 55 -
extras/mini-os/include/semaphore.h | 110 --
extras/mini-os/include/spinlock.h | 55 -
extras/mini-os/include/sys/lock.h | 52 -
extras/mini-os/include/sys/time.h | 47 -
extras/mini-os/include/time.h | 63 -
extras/mini-os/include/tpm_tis.h | 61 -
extras/mini-os/include/tpmback.h | 104 --
extras/mini-os/include/tpmfront.h | 97 --
extras/mini-os/include/types.h | 74 -
extras/mini-os/include/wait.h | 105 --
extras/mini-os/include/waittypes.h | 32 -
extras/mini-os/include/x86/arch_endian.h | 7 -
extras/mini-os/include/x86/arch_limits.h | 20 -
extras/mini-os/include/x86/arch_mm.h | 233 ---
extras/mini-os/include/x86/arch_sched.h | 25 -
extras/mini-os/include/x86/arch_spinlock.h | 94 --
extras/mini-os/include/x86/os.h | 572 --------
extras/mini-os/include/x86/traps.h | 78 -
extras/mini-os/include/x86/x86_32/arch_wordsize.h | 1 -
.../mini-os/include/x86/x86_32/hypercall-x86_32.h | 337 -----
extras/mini-os/include/x86/x86_64/arch_wordsize.h | 2 -
.../mini-os/include/x86/x86_64/hypercall-x86_64.h | 344 -----
extras/mini-os/include/xen/COPYING | 38 -
extras/mini-os/include/xen/arch-arm.h | 432 ------
extras/mini-os/include/xen/arch-arm/hvm/save.h | 39 -
extras/mini-os/include/xen/arch-x86/cpuid.h | 90 --
extras/mini-os/include/xen/arch-x86/hvm/save.h | 630 --------
extras/mini-os/include/xen/arch-x86/xen-mca.h | 440 ------
extras/mini-os/include/xen/arch-x86/xen-x86_32.h | 171 ---
extras/mini-os/include/xen/arch-x86/xen-x86_64.h | 202 ---
extras/mini-os/include/xen/arch-x86/xen.h | 303 ----
extras/mini-os/include/xen/arch-x86_32.h | 27 -
extras/mini-os/include/xen/arch-x86_64.h | 43 -
extras/mini-os/include/xen/callback.h | 121 --
extras/mini-os/include/xen/dom0_ops.h | 120 --
extras/mini-os/include/xen/domctl.h | 1154 ---------------
extras/mini-os/include/xen/elfnote.h | 271 ----
extras/mini-os/include/xen/event_channel.h | 385 -----
extras/mini-os/include/xen/features.h | 114 --
extras/mini-os/include/xen/gcov.h | 115 --
extras/mini-os/include/xen/grant_table.h | 682 ---------
extras/mini-os/include/xen/hvm/e820.h | 34 -
extras/mini-os/include/xen/hvm/hvm_info_table.h | 72 -
extras/mini-os/include/xen/hvm/hvm_op.h | 402 -----
extras/mini-os/include/xen/hvm/hvm_xs_strings.h | 80 -
extras/mini-os/include/xen/hvm/ioreq.h | 129 --
extras/mini-os/include/xen/hvm/params.h | 199 ---
extras/mini-os/include/xen/hvm/pvdrivers.h | 49 -
extras/mini-os/include/xen/hvm/save.h | 111 --
extras/mini-os/include/xen/io/blkif.h | 640 --------
extras/mini-os/include/xen/io/console.h | 51 -
extras/mini-os/include/xen/io/fbif.h | 176 ---
extras/mini-os/include/xen/io/fsif.h | 192 ---
extras/mini-os/include/xen/io/kbdif.h | 132 --
extras/mini-os/include/xen/io/libxenvchan.h | 97 --
extras/mini-os/include/xen/io/netif.h | 305 ----
extras/mini-os/include/xen/io/pciif.h | 125 --
extras/mini-os/include/xen/io/protocols.h | 40 -
extras/mini-os/include/xen/io/ring.h | 312 ----
extras/mini-os/include/xen/io/tpmif.h | 143 --
extras/mini-os/include/xen/io/usbif.h | 150 --
extras/mini-os/include/xen/io/vscsiif.h | 260 ----
extras/mini-os/include/xen/io/xenbus.h | 80 -
extras/mini-os/include/xen/io/xs_wire.h | 149 --
extras/mini-os/include/xen/kexec.h | 249 ----
extras/mini-os/include/xen/mem_event.h | 134 --
extras/mini-os/include/xen/memory.h | 587 --------
extras/mini-os/include/xen/nmi.h | 85 --
extras/mini-os/include/xen/physdev.h | 380 -----
extras/mini-os/include/xen/platform.h | 606 --------
extras/mini-os/include/xen/sched.h | 175 ---
extras/mini-os/include/xen/sysctl.h | 719 ---------
extras/mini-os/include/xen/tmem.h | 152 --
extras/mini-os/include/xen/trace.h | 331 -----
extras/mini-os/include/xen/vcpu.h | 240 ---
extras/mini-os/include/xen/version.h | 96 --
extras/mini-os/include/xen/xen-compat.h | 44 -
extras/mini-os/include/xen/xen.h | 899 ------------
extras/mini-os/include/xen/xencomm.h | 41 -
extras/mini-os/include/xen/xenoprof.h | 152 --
extras/mini-os/include/xen/xsm/flask_op.h | 201 ---
extras/mini-os/include/xenbus.h | 120 --
extras/mini-os/include/xmalloc.h | 44 -
extras/mini-os/kernel.c | 198 ---
extras/mini-os/lib/ctype.c | 29 -
extras/mini-os/lib/math.c | 426 ------
extras/mini-os/lib/printf.c | 786 ----------
extras/mini-os/lib/stack_chk_fail.c | 8 -
extras/mini-os/lib/string.c | 228 ---
extras/mini-os/lib/sys.c | 1550 --------------------
extras/mini-os/lib/xmalloc.c | 319 ----
extras/mini-os/lib/xs.c | 194 ---
extras/mini-os/lock.c | 112 --
extras/mini-os/lwip-arch.c | 293 ----
extras/mini-os/lwip-net.c | 386 -----
extras/mini-os/main.c | 193 ---
extras/mini-os/minios.mk | 76 -
extras/mini-os/mm.c | 441 ------
extras/mini-os/netfront.c | 675 ---------
extras/mini-os/pcifront.c | 616 --------
extras/mini-os/sched.c | 304 ----
extras/mini-os/test.c | 577 --------
extras/mini-os/tpm_tis.c | 1523 -------------------
extras/mini-os/tpmback.c | 1136 --------------
extras/mini-os/tpmfront.c | 631 --------
extras/mini-os/xenbus/xenbus.c | 870 -----------
stubdom/Makefile | 4 +
tools/misc/mktarball | 4 +-
447 files changed, 40533 insertions(+), 40507 deletions(-)
diff --git a/.gitignore b/.gitignore
index cdbdca7..4979018 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,10 +46,8 @@ docs/man1/
docs/man5/
docs/pdf/
docs/txt/
-extras/mini-os/include/mini-os
-extras/mini-os/include/x86/mini-os
-extras/mini-os/include/list.h
-extras/mini-os/mini-os*
+extras/mini-os
+extras/mini-os-remote
install/*
stubdom/autom4te.cache/
stubdom/binutils-*
diff --git a/Config.mk b/Config.mk
index d12ad91..109f1f1 100644
--- a/Config.mk
+++ b/Config.mk
@@ -245,14 +245,20 @@ OVMF_UPSTREAM_URL ?=
http://xenbits.xen.org/git-http/ovmf.git
QEMU_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/qemu-upstream-unstable.git
QEMU_TRADITIONAL_URL ?= http://xenbits.xen.org/git-http/qemu-xen-unstable.git
SEABIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/seabios.git
+MINIOS_UPSTREAM_URL ?= http://xenbits.xen.org/git-http/mini-os.git
else
OVMF_UPSTREAM_URL ?= git://xenbits.xen.org/ovmf.git
QEMU_UPSTREAM_URL ?= git://xenbits.xen.org/qemu-upstream-unstable.git
QEMU_TRADITIONAL_URL ?= git://xenbits.xen.org/qemu-xen-unstable.git
SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
+MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git
endif
OVMF_UPSTREAM_REVISION ?= 447d264115c476142f884af0be287622cd244423
QEMU_UPSTREAM_REVISION ?= master
+MINIOS_UPSTREAM_REVISION ?= 55f7cd7427ef3e7fe3563a3da46d8664a2ed0d6d
+# Thu Jan 29 19:10:04 2015 +0000
+# Mini-OS: standalone build
+
SEABIOS_UPSTREAM_REVISION ?= rel-1.7.5
# Thu May 22 16:59:16 2014 -0400
# python3 fixes for vgabios and csm builds.
diff --git a/Makefile b/Makefile
index ad6f917..e8a75ff 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,22 @@ TARGS_DISTCLEAN=$(patsubst %, distclean-%, $(SUBSYSTEMS))
export XEN_ROOT=$(CURDIR)
include Config.mk
+.PHONY: mini-os-dir
+mini-os-dir:
+ GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh \
+ $(MINIOS_UPSTREAM_URL) \
+ $(MINIOS_UPSTREAM_REVISION) \
+ $(XEN_ROOT)/extras/mini-os
+
+.PHONY: mini-os-dir-force-update
+mini-os-dir-force-update: mini-os-dir
+ set -ex; \
+ if [ "$(MINIOS_UPSTREAM_REVISION)" ]; then \
+ cd extras/mini-os-remote; \
+ $(GIT) fetch origin; \
+ $(GIT) reset --hard $(MINIOS_UPSTREAM_REVISION); \
+ fi
+
SUBARCH := $(subst x86_32,i386,$(XEN_TARGET_ARCH))
export XEN_TARGET_ARCH SUBARCH
export DESTDIR
@@ -37,7 +53,7 @@ build-tools:
$(MAKE) -C tools build
.PHONY: build-stubdom
-build-stubdom:
+build-stubdom: mini-os-dir
$(MAKE) -C stubdom build
ifeq (x86_64,$(XEN_TARGET_ARCH))
XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
@@ -84,7 +100,7 @@ install-tools:
$(MAKE) -C tools install
.PHONY: install-stubdom
-install-stubdom: install-tools
+install-stubdom: install-tools mini-os-dir
$(MAKE) -C stubdom install
ifeq (x86_64,$(XEN_TARGET_ARCH))
XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
@@ -125,11 +141,11 @@ rpmball: dist
bash ./tools/misc/mkrpm $(XEN_ROOT) $$($(MAKE) -C xen xenversion
--no-print-directory)
.PHONY: subtree-force-update
-subtree-force-update:
+subtree-force-update: mini-os-dir-force-update
$(MAKE) -C tools subtree-force-update
.PHONY: subtree-force-update-all
-subtree-force-update-all:
+subtree-force-update-all: mini-os-dir-force-update
$(MAKE) -C tools subtree-force-update-all
# Make a source tarball, including qemu sub-trees.
diff --git a/extras/mini-os-intree/COPYING b/extras/mini-os-intree/COPYING
new file mode 100644
index 0000000..1d9df6c
--- /dev/null
+++ b/extras/mini-os-intree/COPYING
@@ -0,0 +1,36 @@
+Certain files in this directory are licensed by the GNU
+General Public License version 2 (GPLv2). By default these
+files are not built and linked into MiniOs. Enabling them
+will cause the whole work to become covered by the GPLv2.
+
+The current set of GPLv2 features are:
+CONFIG_TPMFRONT
+CONFIG_TPMBACK
+CONFIG_TPM_TIS
+
+Do not use these if you do not want your MiniOS build to become
+GPL licensed!
+
+Copyright (c) 2009 Citrix Systems, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
diff --git a/extras/mini-os-intree/Config.mk b/extras/mini-os-intree/Config.mk
new file mode 100644
index 0000000..e5d8ade
--- /dev/null
+++ b/extras/mini-os-intree/Config.mk
@@ -0,0 +1,99 @@
+#
+# Compare $(1) and $(2) and replace $(2) with $(1) if they differ
+#
+# Typically $(1) is a newly generated file and $(2) is the target file
+# being regenerated. This prevents changing the timestamp of $(2) only
+# due to being auto regenereated with the same contents.
+define move-if-changed
+ if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi
+endef
+
+# cc-option: Check if compiler supports first option, else fall back to second.
+#
+# This is complicated by the fact that unrecognised -Wno-* options:
+# (a) are ignored unless the compilation emits a warning; and
+# (b) even then produce a warning rather than an error
+# To handle this we do a test compile, passing the option-under-test, on a code
+# fragment that will always produce a warning (integer assigned to pointer).
+# We then grep for the option-under-test in the compiler's output, the presence
+# of which would indicate an "unrecognized command-line option" warning/error.
+#
+# Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
+cc-option = $(shell if test -z "`echo 'void*p=1;' | \
+ $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) -`"; \
+ then echo "$(2)"; else echo "$(3)"; fi ;)
+
+# Compatibility with Xen's stubdom build environment. If we are building
+# stubdom, some XEN_ variables are set, set MINIOS_ variables accordingly.
+#
+ifneq ($(XEN_ROOT),)
+MINI-OS_ROOT=$(XEN_ROOT)/extras/mini-os
+else
+MINI-OS_ROOT=$(TOPLEVEL_DIR)
+endif
+export MINI-OS_ROOT
+
+ifneq ($(XEN_TARGET_ARCH),)
+MINIOS_TARGET_ARCH = $(XEN_TARGET_ARCH)
+else
+MINIOS_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \
+ -e s/i86pc/x86_32/ -e s/amd64/x86_64/ \
+ -e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \
+ -e s/aarch64/arm64/)
+
+MINIOS_TARGET_ARCH ?= $(MINIOS_COMPILE_ARCH)
+endif
+
+libc = $(stubdom)
+
+XEN_INTERFACE_VERSION := 0x00030205
+export XEN_INTERFACE_VERSION
+
+# Try to find out the architecture family TARGET_ARCH_FAM.
+# First check whether x86_... is contained (for x86_32, x86_32y, x86_64).
+# If not x86 then use $(MINIOS_TARGET_ARCH)
+ifeq ($(findstring x86_,$(MINIOS_TARGET_ARCH)),x86_)
+TARGET_ARCH_FAM = x86
+else
+TARGET_ARCH_FAM = $(MINIOS_TARGET_ARCH)
+endif
+
+# The architecture family directory below mini-os.
+TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM)
+
+# Export these variables for possible use in architecture dependent makefiles.
+export TARGET_ARCH_DIR
+export TARGET_ARCH_FAM
+
+# This is used for architecture specific links.
+# This can be overwritten from arch specific rules.
+ARCH_LINKS =
+
+# The path pointing to the architecture specific header files.
+ARCH_INC := $(TARGET_ARCH_FAM)
+
+# For possible special header directories.
+# This can be overwritten from arch specific rules.
+EXTRA_INC = $(ARCH_INC)
+
+# Include the architecture family's special makerules.
+# This must be before include minios.mk!
+include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk
+
+extra_incl := $(foreach dir,$(EXTRA_INC),-isystem
$(MINI-OS_ROOT)/include/$(dir))
+
+DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/include
+DEF_CPPFLAGS += -D__MINIOS__
+
+ifeq ($(libc),y)
+DEF_CPPFLAGS += -DHAVE_LIBC
+DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/include/posix
+DEF_CPPFLAGS += -isystem $(XEN_ROOT)/tools/xenstore/include
+endif
+
+ifneq ($(LWIPDIR),)
+lwip=y
+DEF_CPPFLAGS += -DHAVE_LWIP
+DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include
+DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include/ipv4
+endif
diff --git a/extras/mini-os-intree/Makefile b/extras/mini-os-intree/Makefile
new file mode 100644
index 0000000..f16520e
--- /dev/null
+++ b/extras/mini-os-intree/Makefile
@@ -0,0 +1,224 @@
+# Common Makefile for mini-os.
+#
+# Every architecture directory below mini-os/arch has to have a
+# Makefile and a arch.mk.
+#
+
+OBJ_DIR=$(CURDIR)
+TOPLEVEL_DIR=$(CURDIR)
+
+ifeq ($(MINIOS_CONFIG),)
+include Config.mk
+else
+EXTRA_DEPS += $(MINIOS_CONFIG)
+include $(MINIOS_CONFIG)
+endif
+
+include $(MINI-OS_ROOT)/config/MiniOS.mk
+
+# Configuration defaults
+CONFIG_START_NETWORK ?= y
+CONFIG_SPARSE_BSS ?= y
+CONFIG_QEMU_XS_ARGS ?= n
+CONFIG_TEST ?= n
+CONFIG_PCIFRONT ?= n
+CONFIG_BLKFRONT ?= y
+CONFIG_TPMFRONT ?= n
+CONFIG_TPM_TIS ?= n
+CONFIG_TPMBACK ?= n
+CONFIG_NETFRONT ?= y
+CONFIG_FBFRONT ?= y
+CONFIG_KBDFRONT ?= y
+CONFIG_CONSFRONT ?= y
+CONFIG_XENBUS ?= y
+CONFIG_XC ?=y
+CONFIG_LWIP ?= $(lwip)
+
+# Export config items as compiler directives
+flags-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK
+flags-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS
+flags-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS
+flags-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT
+flags-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT
+flags-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT
+flags-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS
+flags-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK
+flags-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT
+flags-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT
+flags-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT
+flags-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT
+flags-$(CONFIG_XENBUS) += -DCONFIG_XENBUS
+
+DEF_CFLAGS += $(flags-y)
+
+# Symlinks and headers that must be created before building the C files
+GENERATED_HEADERS := include/list.h $(ARCH_LINKS) include/mini-os
include/$(TARGET_ARCH_FAM)/mini-os
+
+EXTRA_DEPS += $(GENERATED_HEADERS)
+
+# Include common mini-os makerules.
+include minios.mk
+
+# Set tester flags
+# CFLAGS += -DBLKTEST_WRITE
+
+# Define some default flags for linking.
+LDLIBS :=
+APP_LDLIBS :=
+LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME)
+LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds
+
+# Prefix for global API names. All other symbols are localised before
+# linking with EXTRA_OBJS.
+GLOBAL_PREFIX := xenos_
+EXTRA_OBJS =
+
+TARGET := mini-os
+
+# Subdirectories common to mini-os
+SUBDIRS := lib xenbus console
+
+src-$(CONFIG_BLKFRONT) += blkfront.c
+src-$(CONFIG_TPMFRONT) += tpmfront.c
+src-$(CONFIG_TPM_TIS) += tpm_tis.c
+src-$(CONFIG_TPMBACK) += tpmback.c
+src-y += daytime.c
+src-y += events.c
+src-$(CONFIG_FBFRONT) += fbfront.c
+src-y += gntmap.c
+src-y += gnttab.c
+src-y += hypervisor.c
+src-y += kernel.c
+src-y += lock.c
+src-y += main.c
+src-y += mm.c
+src-$(CONFIG_NETFRONT) += netfront.c
+src-$(CONFIG_PCIFRONT) += pcifront.c
+src-y += sched.c
+src-$(CONFIG_TEST) += test.c
+
+src-y += lib/ctype.c
+src-y += lib/math.c
+src-y += lib/printf.c
+src-y += lib/stack_chk_fail.c
+src-y += lib/string.c
+src-y += lib/sys.c
+src-y += lib/xmalloc.c
+src-$(CONFIG_XENBUS) += lib/xs.c
+
+src-$(CONFIG_XENBUS) += xenbus/xenbus.c
+
+src-y += console/console.c
+src-y += console/xencons_ring.c
+src-$(CONFIG_CONSFRONT) += console/xenbus.c
+
+# The common mini-os objects to build.
+APP_OBJS :=
+OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(src-y))
+
+.PHONY: default
+default: $(OBJ_DIR)/$(TARGET)
+
+# Create special architecture specific links. The function arch_links
+# has to be defined in arch.mk (see include above).
+ifneq ($(ARCH_LINKS),)
+$(ARCH_LINKS):
+ $(arch_links)
+endif
+
+include/list.h: include/minios-external/bsd-sys-queue-h-seddery
include/minios-external/bsd-sys-queue.h
+ perl $^ --prefix=minios >$@.new
+ $(call move-if-changed,$@.new,$@)
+
+# Used by stubdom's Makefile
+.PHONY: links
+links: $(GENERATED_HEADERS)
+
+include/mini-os:
+ ln -sf . $@
+
+include/$(TARGET_ARCH_FAM)/mini-os:
+ ln -sf . $@
+
+.PHONY: arch_lib
+arch_lib:
+ $(MAKE) --directory=$(TARGET_ARCH_DIR)
OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) || exit 1;
+
+ifeq ($(CONFIG_LWIP),y)
+# lwIP library
+LWC := $(shell find $(LWIPDIR)/src -type f -name '*.c')
+LWC := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC))
+LWO := $(patsubst %.c,%.o,$(LWC))
+LWO += $(OBJ_DIR)/lwip-arch.o
+ifeq ($(CONFIG_NETFRONT),y)
+LWO += $(OBJ_DIR)/lwip-net.o
+endif
+
+$(OBJ_DIR)/lwip.a: $(LWO)
+ $(RM) $@
+ $(AR) cqs $@ $^
+
+OBJS += $(OBJ_DIR)/lwip.a
+endif
+
+OBJS := $(filter-out $(OBJ_DIR)/lwip%.o $(LWO), $(OBJS))
+
+ifeq ($(libc),y)
+ifeq ($(CONFIG_XC),y)
+APP_LDLIBS += -L$(XEN_ROOT)/stubdom/libxc-$(XEN_TARGET_ARCH) -whole-archive
-lxenguest -lxenctrl -no-whole-archive
+endif
+APP_LDLIBS += -lpci
+APP_LDLIBS += -lz
+APP_LDLIBS += -lm
+LDLIBS += -lc
+endif
+
+ifneq ($(APP_OBJS)-$(lwip),-y)
+OBJS := $(filter-out $(OBJ_DIR)/daytime.o, $(OBJS))
+endif
+
+$(OBJ_DIR)/$(TARGET)_app.o: $(APP_OBJS) app.lds
+ $(LD) -r -d $(LDFLAGS) -\( $^ -\) $(APP_LDLIBS) --undefined main -o $@
+
+ifneq ($(APP_OBJS),)
+APP_O=$(OBJ_DIR)/$(TARGET)_app.o
+endif
+
+$(OBJ_DIR)/$(TARGET): $(OBJS) $(APP_O) arch_lib
+ $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(APP_O) $(OBJS) $(LDARCHLIB) $(LDLIBS)
-o $@.o
+ $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
+ $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
+ gzip -f -9 -c $@ >$@.gz
+
+.PHONY: clean arch_clean
+
+arch_clean:
+ $(MAKE) --directory=$(TARGET_ARCH_DIR)
OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) clean || exit 1;
+
+clean: arch_clean
+ for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \
+ rm -f $$dir/*.o; \
+ done
+ rm -f include/list.h
+ rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core $(OBJ_DIR)/$(TARGET).elf
$(OBJ_DIR)/$(TARGET).raw $(OBJ_DIR)/$(TARGET) $(OBJ_DIR)/$(TARGET).gz
+ find . $(OBJ_DIR) -type l | xargs rm -f
+ $(RM) $(OBJ_DIR)/lwip.a $(LWO)
+ rm -f tags TAGS
+
+
+define all_sources
+ ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
+endef
+
+.PHONY: cscope
+cscope:
+ $(all_sources) > cscope.files
+ cscope -k -b -q
+
+.PHONY: tags
+tags:
+ $(all_sources) | xargs ctags
+
+.PHONY: TAGS
+TAGS:
+ $(all_sources) | xargs etags
diff --git a/extras/mini-os-intree/README b/extras/mini-os-intree/README
new file mode 100644
index 0000000..7960314
--- /dev/null
+++ b/extras/mini-os-intree/README
@@ -0,0 +1,46 @@
+ Minimal OS
+ ----------
+
+This shows some of the stuff that any guest OS will have to set up.
+
+This includes:
+
+ * installing a virtual exception table
+ * handling virtual exceptions
+ * handling asynchronous events
+ * enabling/disabling async events
+ * parsing start_info struct at start-of-day
+ * registering virtual interrupt handlers (for timer interrupts)
+ * a simple page and memory allocator
+ * minimal libc support
+ * minimal Copy-on-Write support
+ * network, block, framebuffer support
+ * transparent access to FileSystem exports (see tools/fs-back)
+
+- to build it just type make.
+
+- to build it with TCP/IP support, download LWIP 1.3.2 source code and type
+
+ make LWIPDIR=/path/to/lwip/source
+
+- to build it with much better libc support, see the stubdom/ directory
+
+- to start it do the following in domain0
+ # xl create -c domain_config
+
+This starts the kernel and prints out a bunch of stuff and then once every
+second the system time.
+
+If you have setup a disk in the config file (e.g.
+disk = [ 'file:/tmp/foo,hda,r' ] ), it will loop reading it. If that disk is
+writable (e.g. disk = [ 'file:/tmp/foo,hda,w' ] ), it will write data patterns
+and re-read them.
+
+If you have setup a network in the config file (e.g. vif = [''] ), it will
+print incoming packets.
+
+If you have setup a VFB in the config file (e.g. vfb = ['type=sdl'] ), it will
+show a mouse with which you can draw color squares.
+
+If you have compiled it with TCP/IP support, it will run a daytime server on
+TCP port 13.
diff --git a/extras/mini-os-intree/app.lds b/extras/mini-os-intree/app.lds
new file mode 100644
index 0000000..4a48cc8
--- /dev/null
+++ b/extras/mini-os-intree/app.lds
@@ -0,0 +1,11 @@
+SECTIONS
+{
+ .app.bss : {
+ __app_bss_start = . ;
+ *(.bss .bss.*)
+ *(COMMON)
+ *(.lbss .lbss.*)
+ *(LARGE_COMMON)
+ __app_bss_end = . ;
+ }
+}
diff --git a/extras/mini-os-intree/arch/arm/arm32.S
b/extras/mini-os-intree/arch/arm/arm32.S
new file mode 100644
index 0000000..a08a170
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/arm32.S
@@ -0,0 +1,294 @@
+@ Offset of the kernel within the RAM. This is a Linux/zImage convention which
we
+@ rely on for now.
+#define ZIMAGE_KERNEL_OFFSET 0x8000
+
+.section .text
+
+.globl _start
+_start:
+ @ zImage header
+.rept 8
+ mov r0, r0
+.endr
+ b reset
+ .word 0x016f2818 @ Magic numbers to help the loader
+ .word 0 @ zImage start address (0 = relocatable)
+ .word _edata - _start @ zImage end address (excludes bss section)
+ @ end of zImage header
+
+@ Called at boot time. Sets up MMU, exception vectors and stack, and then
calls C arch_init() function.
+@ => r2 -> DTB
+@ <= never returns
+@ Note: this boot code needs to be within the first (1MB -
ZIMAGE_KERNEL_OFFSET) of _start.
+reset:
+ @ Problem: the C code wants to be at a known address (_start), but Xen
might
+ @ load us anywhere. We initialise the MMU (mapping virtual to physical
@ addresses)
+ @ so everything ends up where the code expects it to be.
+ @
+ @ We calculate the offet between where the linker thought _start would
be and where
+ @ it actually is and initialise the page tables to have that offset for
every page.
+ @
+ @ When we turn on the MMU, we're still executing at the old address. We
don't want
+ @ the code to disappear from under us. So we have to do the mapping in
stages:
+ @
+ @ 1. set up a mapping to our current page from both its current and
desired addresses
+ @ 2. enable the MMU
+ @ 3. jump to the new address
+ @ 4. remap all the other pages with the calculated offset
+
+ adr r1, _start @ r1 = physical address of _start
+ ldr r3, =_start @ r3 = (desired) virtual address of
_start
+ sub r9, r1, r3 @ r9 = (physical - virtual) offset
+
+ ldr r7, =_page_dir @ r7 = (desired) virtual addr of
translation table
+ add r1, r7, r9 @ r1 = physical addr of translation
table
+
+ @ Tell the system where our page table is located.
+ @ This is the 16 KB top-level translation table, in which
+ @ each word maps one 1MB virtual section to a physical section.
+ @ Note: We leave TTBCR as 0, meaning that only TTBR0 is used and
+ @ we use the short-descriptor format (32-bit physical addresses).
+ orr r0, r1, #0b0001011 @ Sharable, Inner/Outer Write-Back
Write-Allocate Cacheable
+ mcr p15, 0, r0, c2, c0, 0 @ set TTBR0
+
+ @ Set access permission for domains.
+ @ Domains are deprecated, but we have to configure them anyway.
+ @ We mark every page as being domain 0 and set domain 0 to "client mode"
+ @ (client mode = use access flags in page table).
+ mov r0, #1 @ 1 = client
+ mcr p15, 0, r0, c3, c0, 0 @ DACR
+
+ @ Template (flags) for a 1 MB page-table entry.
+ @ TEX[2:0] C B = 001 1 1 (outer and inner write-back, write-allocate)
+ ldr r8, =(0x2 + /* Section entry */ \
+ 0xc + /* C B */ \
+ (3 << 10) + /* Read/write */ \
+ (1 << 12) + /* TEX */ \
+ (1 << 16) + /* Sharable */ \
+ (1<<19)) /* Non-secure */
+ @ r8 = template page table entry
+
+ @ Add an entry for the current physical section, at the old and new
+ @ addresses. It's OK if they're the same.
+ mov r0, pc, lsr#20
+ mov r0, r0, lsl#20 @ r0 = physical address of this code's
section start
+ orr r3, r0, r8 @ r3 = table entry for this section
+ ldr r4, =_start @ r4 = desired virtual address of this
section
+ str r3, [r1, r4, lsr#18] @ map desired virtual section to this
code
+ str r3, [r1, r0, lsr#18] @ map current section to this code too
+
+ @ Invalidate TLB
+ dsb @ Caching is off, but must still
prevent reordering
+ mcr p15, 0, r1, c8, c7, 0 @ TLBIALL
+
+ @ Enable MMU / SCTLR
+ mrc p15, 0, r1, c1, c0, 0 @ SCTLR
+ orr r1, r1, #3 << 11 @ enable icache, branch prediction
+ orr r1, r1, #4 + 1 @ enable dcache, MMU
+ mcr p15, 0, r1, c1, c0, 0 @ SCTLR
+ isb
+
+ ldr r1, =stage2 @ Virtual address of stage2
+ bx r1
+
+@ Called once the MMU is enabled. The boot code and the page table are mapped,
+@ but nothing else is yet.
+@
+@ => r2 -> dtb (physical)
+@ r7 = virtual address of page table
+@ r8 = section entry template (flags)
+@ r9 = desired physical - virtual offset
+@ pc -> somewhere in newly-mapped virtual code section
+stage2:
+ @ Invalidate TLB
+ mcr p15, 0, r1, c8, c7, 0 @ TLBIALL
+ isb
+
+ @ The new mapping has now taken effect:
+ @ r7 -> page_dir
+
+ @ Fill in the whole top-level translation table (at page_dir).
+ @ Populate the whole pagedir with 1MB section descriptors.
+
+ mov r1, r7 @ r1 -> first section entry
+ add r3, r1, #4*4*1024 @ limit (4 GB address space, 4 byte
entries)
+ orr r0, r8, r9 @ r0 = entry mapping section zero to
start of physical RAM
+1:
+ str r0, [r1],#4 @ write the section entry
+ add r0, r0, #1 << 20 @ next physical page (wraps)
+ cmp r1, r3
+ bne 1b
+
+ @ Invalidate TLB
+ dsb
+ mcr p15, 0, r1, c8, c7, 0 @ TLBIALL
+ isb
+
+ @ Set VBAR -> exception_vector_table
+ @ SCTLR.V = 0
+ adr r0, exception_vector_table
+ mcr p15, 0, r0, c12, c0, 0
+
+ @ Enable hardware floating point:
+ @ 1. Access to CP10 and CP11 must be enabled in the Coprocessor Access
+ @ Control Register (CP15.CACR):
+ mrc p15, 0, r1, c1, c0, 2 @ CACR
+ orr r1, r1, #(3 << 20) + (3 << 22) @ full access for CP10 & CP11
+ mcr p15, 0, r1, c1, c0, 2
+ @ 2. The EN bit in the FPEXC register must be set:
+ vmrs r0, FPEXC
+ orr r0, r0, #1<<30 @ EN (enable)
+ vmsr FPEXC, r0
+
+ @ Initialise 16 KB stack
+ ldr sp, =_boot_stack_end
+
+ sub r0, r2, r9 @ r0 -> device tree (virtual address)
+ mov r1, r9 @ r1 = physical_address_offset
+
+ b arch_init
+
+.pushsection .bss
+@ Note: calling arch_init zeroes out this region.
+.align 12
+.globl shared_info_page
+shared_info_page:
+ .fill (1024), 4, 0x0
+
+.align 3
+.globl irqstack
+.globl irqstack_end
+irqstack:
+ .fill (1024), 4, 0x0
+irqstack_end:
+
+fault_dump:
+ .fill 18, 4, 0x0 @ On fault, we save the registers +
CPSR + handler address
+
+.popsection
+
+fault:
+ cpsid aif @ Disable interrupts
+
+ ldr r13, =fault_dump
+ stmia r13, {r0-r12} @ Dump the non-banked registers
directly (well, unless from FIQ mode)
+ str r14, [r13, #15 << 2] @ Our r14 is the faulting r15
+ mov r0, r13
+
+ @ Save the caller's CPSR (our SPSR) too.
+ mrs r1, SPSR
+ str r1, [r13, #16 << 2]
+
+ @ Switch to the mode we came from to get r13 and r14.
+ @ If coming from user mode, use System mode instead so we're still
+ @ privileged.
+ and r1, r1, #0x1f @ r1 = SPSR mode
+ cmp r1, #0x10 @ If from User mode
+ moveq r1, #0x1f @ Then use System mode instead
+
+ mrs r3, CPSR @ r3 = our CPSR
+ bic r2, r3, #0x1f
+ orr r2, r2, r1
+ msr CPSR, r2 @ Change to mode r1
+
+ @ Save old mode's r13, r14
+ str r13, [r0, #13 << 2]
+ str r14, [r0, #14 << 2]
+
+ msr CPSR, r3 @ Back to fault mode
+
+ ldr r1, [r0, #17 << 2]
+ sub r1, r1, #12 @ Fix to point at start of handler
+ str r1, [r0, #17 << 2]
+
+ @ Call C code to format the register dump.
+ @ Clobbers the stack, but we're not going to return anyway.
+ ldr sp, =_boot_stack_end
+ bl dump_registers
+ b do_exit
+
+@ We want to store a unique value to identify this handler, without corrupting
+@ any of the registers. So, we store r15 (which will point just after the
branch).
+@ Later, we subtract 12 so the user gets pointed at the start of the exception
+@ handler.
+#define FAULT(name) \
+.globl fault_##name; \
+fault_##name: \
+ ldr r13, =fault_dump; \
+ str r15, [r13, #17 << 2]; \
+ b fault
+
+FAULT(reset)
+FAULT(undefined_instruction)
+FAULT(svc)
+FAULT(prefetch_call)
+FAULT(prefetch_abort)
+FAULT(data_abort)
+
+@ exception base address
+.align 5
+.globl exception_vector_table
+@ Note: remember to call CLREX if returning from an exception:
+@ "The architecture enables the local monitor to treat any exclusive store as
+@ matching a previous LDREX address. For this reason, use of the CLREX
+@ instruction to clear an existing tag is required on context switches."
+@ -- ARM Cortex-A Series Programmerâ??s Guide (Version: 4.0)
+exception_vector_table:
+ b fault_reset
+ b fault_undefined_instruction
+ b fault_svc
+ b fault_prefetch_call
+ b fault_prefetch_abort
+ b fault_data_abort
+ b irq_handler @ IRQ
+ .word 0xe7f000f0 @ abort on FIQ
+
+@ Call fault_undefined_instruction in "Undefined mode"
+bug:
+ .word 0xe7f000f0 @ und/udf - a "Permanently Undefined"
instruction
+
+irq_handler:
+ ldr sp, =irqstack_end
+ push {r0 - r12, r14}
+
+ ldr r0, IRQ_handler
+ cmp r0, #0
+ beq bug
+ blx r0 @ call handler
+
+ @ Return from IRQ
+ pop {r0 - r12, r14}
+ clrex
+ subs pc, lr, #4
+
+.globl IRQ_handler
+IRQ_handler:
+ .long 0x0
+
+
+.globl __arch_switch_threads
+@ => r0 = &prev->sp
+@ r1 = &next->sp
+@ <= returns to next thread's saved return address
+__arch_switch_threads:
+ push {r4-r11} @ Store callee-saved registers to old thread's
stack
+ stmia r0, {sp, lr} @ Store current sp and ip to prev's struct
thread
+
+ ldmia r1, {sp, lr} @ Load new sp, ip from next's struct thread
+ pop {r4-r11} @ Load callee-saved registers from new thread's
stack
+
+ bx lr
+
+@ This is called if you try to divide by zero. For now, we make a supervisor
call,
+@ which will make us halt.
+.globl raise
+raise:
+ svc 0
+
+.globl arm_start_thread
+arm_start_thread:
+ pop {r0, r1}
+ @ r0 = user data
+ @ r1 -> thread's main function
+ ldr lr, =exit_thread
+ bx r1
diff --git a/extras/mini-os-intree/arch/arm/events.c
b/extras/mini-os-intree/arch/arm/events.c
new file mode 100644
index 0000000..441010d
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/events.c
@@ -0,0 +1,31 @@
+#include <mini-os/os.h>
+#include <mini-os/events.h>
+#include <mini-os/hypervisor.h>
+#include <mini-os/console.h>
+
+static void virq_debug(evtchn_port_t port, struct pt_regs *regs, void *params)
+{
+ printk("Received a virq_debug event\n");
+}
+
+evtchn_port_t debug_port = -1;
+void arch_init_events(void)
+{
+ debug_port = bind_virq(VIRQ_DEBUG, (evtchn_handler_t)virq_debug, 0);
+ if(debug_port == -1)
+ BUG();
+ unmask_evtchn(debug_port);
+}
+
+void arch_unbind_ports(void)
+{
+ if(debug_port != -1)
+ {
+ mask_evtchn(debug_port);
+ unbind_evtchn(debug_port);
+ }
+}
+
+void arch_fini_events(void)
+{
+}
diff --git a/extras/mini-os-intree/arch/arm/hypercalls32.S
b/extras/mini-os-intree/arch/arm/hypercalls32.S
new file mode 100644
index 0000000..af8e175
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/hypercalls32.S
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * hypercall.S
+ *
+ * Xen hypercall wrappers
+ *
+ * Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>, Citrix, 2012
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation; or, when distributed
+ * separately from the Linux kernel or incorporated into other
+ * software packages, subject to the following license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <xen/xen.h>
+
+#define __HVC(imm16) .long ((0xE1400070 | (((imm16) & 0xFFF0) << 4) | ((imm16)
& 0x000F)) & 0xFFFFFFFF)
+
+#define XEN_IMM 0xEA1
+
+#define HYPERCALL_SIMPLE(hypercall) \
+.globl HYPERVISOR_##hypercall; \
+.align 4,0x90; \
+HYPERVISOR_##hypercall: \
+ mov r12, #__HYPERVISOR_##hypercall; \
+ __HVC(XEN_IMM); \
+ mov pc, lr;
+
+#define _hypercall0 HYPERCALL_SIMPLE
+#define _hypercall1 HYPERCALL_SIMPLE
+#define _hypercall2 HYPERCALL_SIMPLE
+#define _hypercall3 HYPERCALL_SIMPLE
+#define _hypercall4 HYPERCALL_SIMPLE
+
+_hypercall2(sched_op);
+_hypercall2(memory_op);
+_hypercall2(event_channel_op);
+_hypercall2(xen_version);
+_hypercall3(console_io);
+_hypercall1(physdev_op);
+_hypercall3(grant_table_op);
+_hypercall3(vcpu_op);
+_hypercall1(sysctl);
+_hypercall1(domctl);
+_hypercall2(hvm_op);
+_hypercall1(xsm_op);
diff --git a/extras/mini-os-intree/arch/arm/minios-arm32.lds
b/extras/mini-os-intree/arch/arm/minios-arm32.lds
new file mode 100755
index 0000000..9627162
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/minios-arm32.lds
@@ -0,0 +1,83 @@
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+ /* Note: we currently assume that Xen will load the kernel image
+ * at start-of-RAM + 0x8000. We use this initial 32 KB for the stack
+ * and translation tables.
+ */
+ _boot_stack = 0x400000; /* 16 KB boot stack */
+ _boot_stack_end = 0x404000;
+ _page_dir = 0x404000; /* 16 KB translation table */
+ . = 0x408000;
+ _text = .; /* Text and read-only data */
+ .text : {
+ *(.text)
+ *(.gnu.warning)
+ } = 0x9090
+
+ _etext = .; /* End of text section */
+
+ .rodata : { *(.rodata) *(.rodata.*) }
+ . = ALIGN(4096);
+ _erodata = .;
+
+ /* newlib initialization functions */
+ . = ALIGN(32 / 8);
+ PROVIDE (__preinit_array_start = .);
+ .preinit_array : { *(.preinit_array) }
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ .init_array : { *(.init_array) }
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ .fini_array : { *(.fini_array) }
+ PROVIDE (__fini_array_end = .);
+
+ .ctors : {
+ __CTOR_LIST__ = .;
+ *(.ctors)
+ CONSTRUCTORS
+ LONG(0)
+ __CTOR_END__ = .;
+ }
+
+ .dtors : {
+ __DTOR_LIST__ = .;
+ *(.dtors)
+ LONG(0)
+ __DTOR_END__ = .;
+ }
+
+ .data : { /* Data */
+ *(.data)
+ }
+
+ /* Note: linker will insert any extra sections here, just before .bss */
+
+ .bss : {
+ _edata = .; /* End of data included in image */
+ /* Nothing after here is included in the zImage's size */
+
+ __bss_start = .;
+ *(.bss)
+ *(.app.bss)
+ }
+ _end = . ;
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.text.exit)
+ *(.data.exit)
+ *(.exitcall.exit)
+ }
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+}
diff --git a/extras/mini-os-intree/arch/arm/mm.c
b/extras/mini-os-intree/arch/arm/mm.c
new file mode 100644
index 0000000..efecc51
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/mm.c
@@ -0,0 +1,139 @@
+#include <mini-os/console.h>
+#include <xen/memory.h>
+#include <arch_mm.h>
+#include <mini-os/hypervisor.h>
+#include <libfdt.h>
+#include <lib.h>
+
+uint32_t physical_address_offset;
+
+unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
+{
+ // FIXME
+ BUG();
+}
+
+void arch_init_mm(unsigned long *start_pfn_p, unsigned long *max_pfn_p)
+{
+ int memory;
+ int prop_len = 0;
+ const uint64_t *regs;
+
+ printk(" _text: %p(VA)\n", &_text);
+ printk(" _etext: %p(VA)\n", &_etext);
+ printk(" _erodata: %p(VA)\n", &_erodata);
+ printk(" _edata: %p(VA)\n", &_edata);
+ printk(" stack start: %p(VA)\n", _boot_stack);
+ printk(" _end: %p(VA)\n", &_end);
+
+ if (fdt_num_mem_rsv(device_tree) != 0)
+ printk("WARNING: reserved memory not supported!\n");
+
+ memory = fdt_node_offset_by_prop_value(device_tree, -1, "device_type",
"memory", sizeof("memory"));
+ if (memory < 0) {
+ printk("No memory found in FDT!\n");
+ BUG();
+ }
+
+ /* Xen will always provide us at least one bank of memory.
+ * Mini-OS will use the first bank for the time-being. */
+ regs = fdt_getprop(device_tree, memory, "reg", &prop_len);
+
+ /* The property must contain at least the start address
+ * and size, each of which is 8-bytes. */
+ if (regs == NULL || prop_len < 16) {
+ printk("Bad 'reg' property: %p %d\n", regs, prop_len);
+ BUG();
+ }
+
+ unsigned int end = (unsigned int) &_end;
+ paddr_t mem_base = fdt64_to_cpu(regs[0]);
+ uint64_t mem_size = fdt64_to_cpu(regs[1]);
+ printk("Found memory at 0x%llx (len 0x%llx)\n",
+ (unsigned long long) mem_base, (unsigned long long) mem_size);
+
+ BUG_ON(to_virt(mem_base) > (void *) &_text); /* Our image isn't
in our RAM! */
+ *start_pfn_p = PFN_UP(to_phys(end));
+ uint64_t heap_len = mem_size - (PFN_PHYS(*start_pfn_p) - mem_base);
+ *max_pfn_p = *start_pfn_p + PFN_DOWN(heap_len);
+
+ printk("Using pages %lu to %lu as free space for heap.\n", *start_pfn_p,
*max_pfn_p);
+
+ /* The device tree is probably in memory that we're about to hand over to
the page
+ * allocator, so move it to the end and reserve that space.
+ */
+ uint32_t fdt_size = fdt_totalsize(device_tree);
+ void *new_device_tree = to_virt(((*max_pfn_p << PAGE_SHIFT) - fdt_size) &
PAGE_MASK);
+ if (new_device_tree != device_tree) {
+ memmove(new_device_tree, device_tree, fdt_size);
+ }
+ device_tree = new_device_tree;
+ *max_pfn_p = to_phys(new_device_tree) >> PAGE_SHIFT;
+}
+
+void arch_init_p2m(unsigned long max_pfn)
+{
+}
+
+void arch_init_demand_mapping_area(unsigned long cur_pfn)
+{
+}
+
+/* Get Xen's suggested physical page assignments for the grant table. */
+static paddr_t get_gnttab_base(void)
+{
+ int hypervisor;
+ int len = 0;
+ const uint64_t *regs;
+ paddr_t gnttab_base;
+
+ hypervisor = fdt_node_offset_by_compatible(device_tree, -1, "xen,xen");
+ BUG_ON(hypervisor < 0);
+
+ regs = fdt_getprop(device_tree, hypervisor, "reg", &len);
+ /* The property contains the address and size, 8-bytes each. */
+ if (regs == NULL || len < 16) {
+ printk("Bad 'reg' property: %p %d\n", regs, len);
+ BUG();
+ }
+
+ gnttab_base = fdt64_to_cpu(regs[0]);
+
+ printk("FDT suggests grant table base %llx\n", (unsigned long long)
gnttab_base);
+
+ return gnttab_base;
+}
+
+grant_entry_t *arch_init_gnttab(int nr_grant_frames)
+{
+ struct xen_add_to_physmap xatp;
+ struct gnttab_setup_table setup;
+ xen_pfn_t frames[nr_grant_frames];
+ paddr_t gnttab_table;
+ int i, rc;
+
+ gnttab_table = get_gnttab_base();
+
+ for (i = 0; i < nr_grant_frames; i++)
+ {
+ xatp.domid = DOMID_SELF;
+ xatp.size = 0; /* Seems to be unused */
+ xatp.space = XENMAPSPACE_grant_table;
+ xatp.idx = i;
+ xatp.gpfn = (gnttab_table >> PAGE_SHIFT) + i;
+ rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp);
+ BUG_ON(rc != 0);
+ }
+
+ setup.dom = DOMID_SELF;
+ setup.nr_frames = nr_grant_frames;
+ set_xen_guest_handle(setup.frame_list, frames);
+ HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
+ if (setup.status != 0)
+ {
+ printk("GNTTABOP_setup_table failed; status = %d\n", setup.status);
+ BUG();
+ }
+
+ return to_virt(gnttab_table);
+}
diff --git a/extras/mini-os-intree/arch/arm/panic.c
b/extras/mini-os-intree/arch/arm/panic.c
new file mode 100644
index 0000000..0ac49ad
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/panic.c
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * panic.c
+ *
+ * Displays a register dump and stack trace for debugging.
+ *
+ * Copyright (c) 2014, Thomas Leonard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <mini-os/os.h>
+#include <mini-os/console.h>
+#include <arch_mm.h>
+
+extern int irqstack[];
+extern int irqstack_end[];
+
+typedef void handler(void);
+
+extern handler fault_reset;
+extern handler fault_undefined_instruction;
+extern handler fault_svc;
+extern handler fault_prefetch_call;
+extern handler fault_prefetch_abort;
+extern handler fault_data_abort;
+
+void dump_registers(int *saved_registers) {
+ static int in_dump = 0;
+ int *sp, *stack_top, *x;
+ char *fault_name;
+ void *fault_handler;
+ int i;
+
+ if (in_dump)
+ {
+ printk("Crash while in dump_registers! Not generating a second
report.\n");
+ return;
+ }
+
+ in_dump = 1;
+
+ fault_handler = (handler *) saved_registers[17];
+ if (fault_handler == fault_reset)
+ fault_name = "reset";
+ else if (fault_handler == fault_undefined_instruction)
+ fault_name = "undefined_instruction";
+ else if (fault_handler == fault_svc)
+ fault_name = "svc";
+ else if (fault_handler == fault_prefetch_call)
+ fault_name = "prefetch_call";
+ else if (fault_handler == fault_prefetch_abort)
+ fault_name = "prefetch_abort";
+ else if (fault_handler == fault_data_abort)
+ fault_name = "data_abort";
+ else
+ fault_name = "unknown fault type!";
+
+ printk("Fault handler at %p called (%s)\n", fault_handler, fault_name);
+
+ for (i = 0; i < 16; i++) {
+ printk("r%d = %x\n", i, saved_registers[i]);
+ }
+ printk("CPSR = %x\n", saved_registers[16]);
+
+ printk("Stack dump (innermost last)\n");
+ sp = (int *) saved_registers[13];
+
+ if (sp >= _boot_stack && sp <= _boot_stack_end)
+ stack_top = _boot_stack_end; /* The boot stack */
+ else if (sp >= irqstack && sp <= irqstack_end)
+ stack_top = irqstack_end; /* The IRQ stack */
+ else
+ stack_top = (int *) ((((unsigned long) sp) | (__STACK_SIZE-1)) + 1);
/* A normal thread stack */
+
+ for (x = stack_top - 1; x >= sp; x--)
+ {
+ printk(" [%8p] %8x\n", x, *x);
+ }
+ printk("End of stack\n");
+
+ in_dump = 0;
+}
diff --git a/extras/mini-os-intree/arch/arm/sched.c
b/extras/mini-os-intree/arch/arm/sched.c
new file mode 100644
index 0000000..8091566
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/sched.c
@@ -0,0 +1,47 @@
+#include <mini-os/sched.h>
+#include <mini-os/xmalloc.h>
+#include <mini-os/console.h>
+
+void arm_start_thread(void);
+
+/* The AAPCS requires the callee (e.g. __arch_switch_threads) to preserve
r4-r11. */
+#define CALLEE_SAVED_REGISTERS 8
+
+/* Architecture specific setup of thread creation */
+struct thread* arch_create_thread(char *name, void (*function)(void *),
+ void *data)
+{
+ struct thread *thread;
+
+ thread = xmalloc(struct thread);
+ /* We can't use lazy allocation here since the trap handler runs on the
stack */
+ thread->stack = (char *)alloc_pages(STACK_SIZE_PAGE_ORDER);
+ thread->name = name;
+ printk("Thread \"%s\": pointer: 0x%p, stack: 0x%p\n", name, thread,
+ thread->stack);
+
+ /* Save pointer to the thread on the stack, used by current macro */
+ *((unsigned long *)thread->stack) = (unsigned long)thread;
+
+ /* Push the details to pass to arm_start_thread onto the stack. */
+ int *sp = (int *) (thread->stack + STACK_SIZE);
+ *(--sp) = (int) function;
+ *(--sp) = (int) data;
+
+ /* We leave room for the 8 callee-saved registers which we will
+ * try to restore on thread switch, even though they're not needed
+ * for the initial switch. */
+ thread->sp = (unsigned long) sp - 4 * CALLEE_SAVED_REGISTERS;
+
+ thread->ip = (unsigned long) arm_start_thread;
+
+ return thread;
+}
+
+void run_idle_thread(void)
+{
+ __asm__ __volatile__ ("mov sp, %0; bx %1"::
+ "r"(idle_thread->sp + 4 * CALLEE_SAVED_REGISTERS),
+ "r"(idle_thread->ip));
+ /* Never arrive here! */
+}
diff --git a/extras/mini-os-intree/arch/arm/setup.c
b/extras/mini-os-intree/arch/arm/setup.c
new file mode 100644
index 0000000..06afe46
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/setup.c
@@ -0,0 +1,119 @@
+#include <mini-os/os.h>
+#include <mini-os/kernel.h>
+#include <mini-os/gic.h>
+#include <mini-os/console.h>
+#include <xen/xen.h>
+#include <xen/memory.h>
+#include <xen/hvm/params.h>
+#include <arch_mm.h>
+#include <libfdt.h>
+
+/*
+ * This structure contains start-of-day info, such as pagetable base pointer,
+ * address of the shared_info structure, and things like that.
+ * On x86, the hypervisor passes it to us. On ARM, we fill it in ourselves.
+ */
+union start_info_union start_info_union;
+
+/*
+ * Shared page for communicating with the hypervisor.
+ * Events flags go here, for example.
+ */
+shared_info_t *HYPERVISOR_shared_info;
+
+extern char shared_info_page[PAGE_SIZE];
+
+void *device_tree;
+
+static int hvm_get_parameter(int idx, uint64_t *value)
+{
+ struct xen_hvm_param xhv;
+ int ret;
+
+ xhv.domid = DOMID_SELF;
+ xhv.index = idx;
+ ret = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
+ if (ret < 0) {
+ BUG();
+ }
+ *value = xhv.value;
+ return ret;
+}
+
+static void get_console(void)
+{
+ uint64_t v = -1;
+
+ hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v);
+ start_info.console.domU.evtchn = v;
+
+ hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &v);
+ start_info.console.domU.mfn = v;
+
+ printk("Console is on port %d\n", start_info.console.domU.evtchn);
+ printk("Console ring is at mfn %lx\n", (unsigned long)
start_info.console.domU.mfn);
+}
+
+void get_xenbus(void)
+{
+ uint64_t value;
+
+ if (hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &value))
+ BUG();
+
+ start_info.store_evtchn = (int)value;
+
+ if(hvm_get_parameter(HVM_PARAM_STORE_PFN, &value))
+ BUG();
+ start_info.store_mfn = (unsigned long)value;
+}
+
+/*
+ * INITIAL C ENTRY POINT.
+ */
+void arch_init(void *dtb_pointer, uint32_t physical_offset)
+{
+ struct xen_add_to_physmap xatp;
+ int r;
+
+ memset(&__bss_start, 0, &_end - &__bss_start);
+
+ physical_address_offset = physical_offset;
+
+ xprintk("Virtual -> physical offset = %x\n", physical_address_offset);
+
+ xprintk("Checking DTB at %p...\n", dtb_pointer);
+
+ if ((r = fdt_check_header(dtb_pointer))) {
+ xprintk("Invalid DTB from Xen: %s\n", fdt_strerror(r));
+ BUG();
+ }
+ device_tree = dtb_pointer;
+
+ /* Map shared_info page */
+ xatp.domid = DOMID_SELF;
+ xatp.idx = 0;
+ xatp.space = XENMAPSPACE_shared_info;
+ xatp.gpfn = virt_to_pfn(shared_info_page);
+ if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp) != 0)
+ BUG();
+ HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;
+
+ /* Fill in start_info */
+ get_console();
+ get_xenbus();
+
+ gic_init();
+
+ start_kernel();
+}
+
+void
+arch_fini(void)
+{
+}
+
+void
+arch_do_exit(void)
+{
+}
diff --git a/extras/mini-os-intree/arch/arm/time.c
b/extras/mini-os-intree/arch/arm/time.c
new file mode 100644
index 0000000..a088981
--- /dev/null
+++ b/extras/mini-os-intree/arch/arm/time.c
@@ -0,0 +1,136 @@
+#include <mini-os/os.h>
+#include <mini-os/hypervisor.h>
+#include <mini-os/events.h>
+#include <mini-os/traps.h>
+#include <mini-os/types.h>
+#include <mini-os/time.h>
+#include <mini-os/lib.h>
+
+//#define VTIMER_DEBUG
+#ifdef VTIMER_DEBUG
+#define DEBUG(_f, _a...) \
+ printk("MINI_OS(file=vtimer.c, line=%d) " _f , __LINE__, ## _a)
+#else
+#define DEBUG(_f, _a...) ((void)0)
+#endif
+
+/************************************************************************
+ * Time functions
+ *************************************************************************/
+
+static uint64_t cntvct_at_init;
+static uint32_t counter_freq;
+
+/* Compute with 96 bit intermediate result: (a*b)/c */
+uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
+{
+ union {
+ uint64_t ll;
+ struct {
+ uint32_t low, high;
+ } l;
+ } u, res;
+ uint64_t rl, rh;
+
+ u.ll = a;
+ rl = (uint64_t)u.l.low * (uint64_t)b;
+ rh = (uint64_t)u.l.high * (uint64_t)b;
+ rh += (rl >> 32);
+ res.l.high = rh / c;
+ res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
+ return res.ll;
+}
+
+static inline s_time_t ticks_to_ns(uint64_t ticks)
+{
+ return muldiv64(ticks, SECONDS(1), counter_freq);
+}
+
+static inline uint64_t ns_to_ticks(s_time_t ns)
+{
+ return muldiv64(ns, counter_freq, SECONDS(1));
+}
+
+/* Wall-clock time is not currently available on ARM, so this is always zero
for now:
+ * http://wiki.xenproject.org/wiki/Xen_ARM_TODO#Expose_Wallclock_time_to_guests
+ */
+static struct timespec shadow_ts;
+
+static inline uint64_t read_virtual_count(void)
+{
+ uint32_t c_lo, c_hi;
+ __asm__ __volatile__("mrrc p15, 1, %0, %1, c14":"=r"(c_lo), "=r"(c_hi));
+ return (((uint64_t) c_hi) << 32) + c_lo;
+}
+
+/* monotonic_clock(): returns # of nanoseconds passed since time_init()
+ * Note: This function is required to return accurate
+ * time even in the absence of multiple timer ticks.
+ */
+uint64_t monotonic_clock(void)
+{
+ return ticks_to_ns(read_virtual_count() - cntvct_at_init);
+}
+
+int gettimeofday(struct timeval *tv, void *tz)
+{
+ uint64_t nsec = monotonic_clock();
+ nsec += shadow_ts.tv_nsec;
+
+ tv->tv_sec = shadow_ts.tv_sec;
+ tv->tv_sec += NSEC_TO_SEC(nsec);
+ tv->tv_usec = NSEC_TO_USEC(nsec % 1000000000UL);
+
+ return 0;
+}
+
+/* Set the timer and mask. */
+void write_timer_ctl(uint32_t value) {
+ __asm__ __volatile__(
+ "mcr p15, 0, %0, c14, c3, 1\n"
+ "isb"::"r"(value));
+}
+
+void set_vtimer_compare(uint64_t value) {
+ DEBUG("New CompareValue : %llx\n", value);
+
+ __asm__ __volatile__("mcrr p15, 3, %0, %H0, c14"
+ ::"r"(value));
+
+ /* Enable timer and unmask the output signal */
+ write_timer_ctl(1);
+}
+
+void unset_vtimer_compare(void) {
+ /* Disable timer and mask the output signal */
+ write_timer_ctl(2);
+}
+
+void block_domain(s_time_t until)
+{
+ uint64_t until_count = ns_to_ticks(until) + cntvct_at_init;
+ ASSERT(irqs_disabled());
+ if (read_virtual_count() < until_count)
+ {
+ set_vtimer_compare(until_count);
+ __asm__ __volatile__("wfi");
+ unset_vtimer_compare();
+
+ /* Give the IRQ handler a chance to handle whatever woke us up. */
+ local_irq_enable();
+ local_irq_disable();
+ }
+}
+
+void init_time(void)
+{
+ printk("Initialising timer interface\n");
+
+ __asm__ __volatile__("mrc p15, 0, %0, c14, c0, 0":"=r"(counter_freq));
+ cntvct_at_init = read_virtual_count();
+ printk("Virtual Count register is %llx, freq = %d Hz\n", cntvct_at_init,
counter_freq);
+}
+
+void fini_time(void)
+{
+}
diff --git a/extras/mini-os-intree/arch/x86/Makefile
b/extras/mini-os-intree/arch/x86/Makefile
new file mode 100644
index 0000000..9f04a93
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/Makefile
@@ -0,0 +1,30 @@
+#
+# x86 architecture specific makefiles.
+# It's is used for x86_32, x86_32y and x86_64
+#
+
+TOPLEVEL_DIR = $(CURDIR)/../..
+include ../../Config.mk
+
+# include arch.mk has to be before mini-os.mk!
+
+include arch.mk
+include ../../minios.mk
+
+# Sources here are all *.c *.S without $(MINIOS_TARGET_ARCH).S
+# This is handled in $(HEAD_ARCH_OBJ)
+ARCH_SRCS := $(wildcard *.c)
+
+# The objects built from the sources.
+ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS))
+
+all: $(OBJ_DIR)/$(ARCH_LIB)
+
+# $(HEAD_ARCH_OBJ) is only build here, needed on linking
+# in ../../Makefile.
+$(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
+ $(AR) rv $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS)
+
+clean:
+ rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ)
+
diff --git a/extras/mini-os-intree/arch/x86/arch.mk
b/extras/mini-os-intree/arch/x86/arch.mk
new file mode 100644
index 0000000..81e8118
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/arch.mk
@@ -0,0 +1,22 @@
+#
+# Architecture special makerules for x86 family
+# (including x86_32, x86_32y and x86_64).
+#
+
+ifeq ($(MINIOS_TARGET_ARCH),x86_32)
+ARCH_CFLAGS := -m32 -march=i686
+ARCH_LDFLAGS := -m elf_i386
+ARCH_ASFLAGS := -m32
+EXTRA_INC += $(TARGET_ARCH_FAM)/$(MINIOS_TARGET_ARCH)
+EXTRA_SRC += arch/$(EXTRA_INC)
+endif
+
+ifeq ($(MINIOS_TARGET_ARCH),x86_64)
+ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks
+ARCH_CFLAGS += -fno-asynchronous-unwind-tables
+ARCH_ASFLAGS := -m64
+ARCH_LDFLAGS := -m elf_x86_64
+EXTRA_INC += $(TARGET_ARCH_FAM)/$(MINIOS_TARGET_ARCH)
+EXTRA_SRC += arch/$(EXTRA_INC)
+endif
+
diff --git a/extras/mini-os-intree/arch/x86/events.c
b/extras/mini-os-intree/arch/x86/events.c
new file mode 100644
index 0000000..5198cf3
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/events.c
@@ -0,0 +1,35 @@
+#include <mini-os/os.h>
+#include <mini-os/mm.h>
+#include <mini-os/events.h>
+
+#if defined(__x86_64__)
+char irqstack[2 * STACK_SIZE];
+
+static struct pda
+{
+ int irqcount; /* offset 0 (used in x86_64.S) */
+ char *irqstackptr; /* 8 */
+} cpu0_pda;
+#endif
+
+void arch_init_events(void)
+{
+#if defined(__x86_64__)
+ asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
+ wrmsrl(0xc0000101, &cpu0_pda); /* 0xc0000101 is MSR_GS_BASE */
+ cpu0_pda.irqcount = -1;
+ cpu0_pda.irqstackptr = (void*) (((unsigned long)irqstack + 2 * STACK_SIZE)
+ & ~(STACK_SIZE - 1));
+#endif
+}
+
+void arch_unbind_ports(void)
+{
+}
+
+void arch_fini_events(void)
+{
+#if defined(__x86_64__)
+ wrmsrl(0xc0000101, NULL); /* 0xc0000101 is MSR_GS_BASE */
+#endif
+}
diff --git a/extras/mini-os-intree/arch/x86/ioremap.c
b/extras/mini-os-intree/arch/x86/ioremap.c
new file mode 100644
index 0000000..4384b1c
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/ioremap.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2009, Netronome Systems, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include <mini-os/types.h>
+#include <mini-os/lib.h>
+#include <mini-os/xmalloc.h>
+#include <mini-os/mm.h>
+#include <mini-os/ioremap.h>
+
+/* Map a physical address range into virtual address space with provided
+ * flags. Return a virtual address range it is mapped to. */
+static void *__do_ioremap(unsigned long phys_addr, unsigned long size,
+ unsigned long prot)
+{
+ unsigned long va;
+ unsigned long mfns, mfn;
+ unsigned long num_pages, offset;
+
+ /* allow non page aligned addresses but for mapping we need to align them
*/
+ offset = (phys_addr & ~PAGE_MASK);
+ num_pages = (offset + size + PAGE_SIZE - 1) / PAGE_SIZE;
+ phys_addr &= PAGE_MASK;
+ mfns = mfn = phys_addr >> PAGE_SHIFT;
+
+ va = (unsigned long)map_frames_ex(&mfns, num_pages, 0, 1, 1,
+ DOMID_IO, NULL, prot);
+ return (void *)(va + offset);
+}
+
+void *ioremap(unsigned long phys_addr, unsigned long size)
+{
+ return __do_ioremap(phys_addr, size, IO_PROT);
+}
+
+void *ioremap_nocache(unsigned long phys_addr, unsigned long size)
+{
+ return __do_ioremap(phys_addr, size, IO_PROT_NOCACHE);
+}
+
+/* Un-map the io-remapped region. Currently no list of existing mappings is
+ * maintained, so the caller has to supply the size */
+void iounmap(void *virt_addr, unsigned long size)
+{
+ unsigned long num_pages;
+ unsigned long va = (unsigned long)virt_addr;
+
+ /* work out number of frames to unmap */
+ num_pages = ((va & ~PAGE_MASK) + size + PAGE_SIZE - 1) / PAGE_SIZE;
+
+ unmap_frames(va & PAGE_MASK, num_pages);
+}
+
+
+
+/* -*- Mode:C; c-basic-offset:4; tab-width:4 indent-tabs-mode:nil -*- */
diff --git a/extras/mini-os-intree/arch/x86/iorw.c
b/extras/mini-os-intree/arch/x86/iorw.c
new file mode 100644
index 0000000..3080769
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/iorw.c
@@ -0,0 +1,35 @@
+#include <mini-os/iorw.h>
+
+void iowrite8(volatile void* addr, uint8_t val)
+{
+ *((volatile uint8_t*)addr) = val;
+}
+void iowrite16(volatile void* addr, uint16_t val)
+{
+ *((volatile uint16_t*)addr) = val;
+}
+void iowrite32(volatile void* addr, uint32_t val)
+{
+ *((volatile uint32_t*)addr) = val;
+}
+void iowrite64(volatile void* addr, uint64_t val)
+{
+ *((volatile uint64_t*)addr) = val;
+}
+
+uint8_t ioread8(volatile void* addr)
+{
+ return *((volatile uint8_t*) addr);
+}
+uint16_t ioread16(volatile void* addr)
+{
+ return *((volatile uint16_t*) addr);
+}
+uint32_t ioread32(volatile void* addr)
+{
+ return *((volatile uint32_t*) addr);
+}
+uint64_t ioread64(volatile void* addr)
+{
+ return *((volatile uint64_t*) addr);
+}
diff --git a/extras/mini-os-intree/arch/x86/minios-x86_32.lds
b/extras/mini-os-intree/arch/x86/minios-x86_32.lds
new file mode 100644
index 0000000..f5cabb6
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/minios-x86_32.lds
@@ -0,0 +1,74 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x0;
+ _text = .; /* Text and read-only data */
+ .text : {
+ *(.text)
+ *(.gnu.warning)
+ } = 0x9090
+
+ _etext = .; /* End of text section */
+
+ .rodata : { *(.rodata) *(.rodata.*) }
+ . = ALIGN(4096);
+ _erodata = .;
+
+ /* newlib initialization functions */
+ . = ALIGN(32 / 8);
+ PROVIDE (__preinit_array_start = .);
+ .preinit_array : { *(.preinit_array) }
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ .init_array : { *(.init_array) }
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ .fini_array : { *(.fini_array) }
+ PROVIDE (__fini_array_end = .);
+
+ .ctors : {
+ __CTOR_LIST__ = .;
+ *(.ctors)
+ CONSTRUCTORS
+ LONG(0)
+ __CTOR_END__ = .;
+ }
+
+ .dtors : {
+ __DTOR_LIST__ = .;
+ *(.dtors)
+ LONG(0)
+ __DTOR_END__ = .;
+ }
+
+ .data : { /* Data */
+ *(.data)
+ }
+
+ _edata = .; /* End of data section */
+
+ __bss_start = .; /* BSS */
+ .bss : {
+ *(.bss)
+ *(.app.bss)
+ }
+ _end = . ;
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.text.exit)
+ *(.data.exit)
+ *(.exitcall.exit)
+ }
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+}
diff --git a/extras/mini-os-intree/arch/x86/minios-x86_64.lds
b/extras/mini-os-intree/arch/x86/minios-x86_64.lds
new file mode 100644
index 0000000..3da0a9f
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/minios-x86_64.lds
@@ -0,0 +1,74 @@
+OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
+OUTPUT_ARCH(i386:x86-64)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x0;
+ _text = .; /* Text and read-only data */
+ .text : {
+ *(.text)
+ *(.gnu.warning)
+ } = 0x9090
+
+ _etext = .; /* End of text section */
+
+ .rodata : { *(.rodata) *(.rodata.*) }
+ . = ALIGN(4096);
+ _erodata = .;
+
+ /* newlib initialization functions */
+ . = ALIGN(64 / 8);
+ PROVIDE (__preinit_array_start = .);
+ .preinit_array : { *(.preinit_array) }
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ .init_array : { *(.init_array) }
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ .fini_array : { *(.fini_array) }
+ PROVIDE (__fini_array_end = .);
+
+ .ctors : {
+ __CTOR_LIST__ = .;
+ *(.ctors)
+ CONSTRUCTORS
+ QUAD(0)
+ __CTOR_END__ = .;
+ }
+
+ .dtors : {
+ __DTOR_LIST__ = .;
+ *(.dtors)
+ QUAD(0)
+ __DTOR_END__ = .;
+ }
+
+ .data : { /* Data */
+ *(.data)
+ }
+
+ _edata = .; /* End of data section */
+
+ __bss_start = .; /* BSS */
+ .bss : {
+ *(.bss)
+ *(.app.bss)
+ }
+ _end = . ;
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.text.exit)
+ *(.data.exit)
+ *(.exitcall.exit)
+ }
+
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+}
diff --git a/extras/mini-os-intree/arch/x86/mm.c
b/extras/mini-os-intree/arch/x86/mm.c
new file mode 100644
index 0000000..9c6d1b8
--- /dev/null
+++ b/extras/mini-os-intree/arch/x86/mm.c
@@ -0,0 +1,957 @@
+/*
+ ****************************************************************************
+ * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
+ * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
+ ****************************************************************************
+ *
+ * File: mm.c
+ * Author: Rolf Neugebauer (neugebar@xxxxxxxxxxxxx)
+ * Changes: Grzegorz Milos
+ *
+ * Date: Aug 2003, chages Aug 2005
+ *
+ * Environment: Xen Minimal OS
+ * Description: memory management related functions
+ * contains buddy page allocator from Xen.
+ *
+ ****************************************************************************
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <mini-os/os.h>
+#include <mini-os/hypervisor.h>
+#include <mini-os/mm.h>
+#include <mini-os/types.h>
+#include <mini-os/lib.h>
+#include <mini-os/xmalloc.h>
+#include <xen/memory.h>
+
+#ifdef MM_DEBUG
+#define DEBUG(_f, _a...) \
+ printk("MINI_OS(file=mm.c, line=%d) " _f "\n", __LINE__, ## _a)
+#else
+#define DEBUG(_f, _a...) ((void)0)
+#endif
+
+unsigned long *phys_to_machine_mapping;
+unsigned long mfn_zero;
+extern char stack[];
+extern void page_walk(unsigned long va);
+
+/*
+ * Make pt_pfn a new 'level' page table frame and hook it into the page
+ * table at offset in previous level MFN (pref_l_mfn). pt_pfn is a guest
+ * PFN.
+ */
+static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,
+ unsigned long offset, unsigned long level)
+{
+ pgentry_t *tab = (pgentry_t *)start_info.pt_base;
+ unsigned long pt_page = (unsigned long)pfn_to_virt(*pt_pfn);
+ pgentry_t prot_e, prot_t;
+ mmu_update_t mmu_updates[1];
+ int rc;
+
+ prot_e = prot_t = 0;
+ DEBUG("Allocating new L%d pt frame for pfn=%lx, "
+ "prev_l_mfn=%lx, offset=%lx",
+ level, *pt_pfn, prev_l_mfn, offset);
+
+ /* We need to clear the page, otherwise we might fail to map it
+ as a page table page */
+ memset((void*) pt_page, 0, PAGE_SIZE);
+
+ switch ( level )
+ {
+ case L1_FRAME:
+ prot_e = L1_PROT;
+ prot_t = L2_PROT;
+ break;
+ case L2_FRAME:
+ prot_e = L2_PROT;
+ prot_t = L3_PROT;
+ break;
+#if defined(__x86_64__)
+ case L3_FRAME:
+ prot_e = L3_PROT;
+ prot_t = L4_PROT;
+ break;
+#endif
+ default:
+ printk("new_pt_frame() called with invalid level number %d\n", level);
+ do_exit();
+ break;
+ }
+
+ /* Make PFN a page table page */
+#if defined(__x86_64__)
+ tab = pte_to_virt(tab[l4_table_offset(pt_page)]);
+#endif
+ tab = pte_to_virt(tab[l3_table_offset(pt_page)]);
+
+ mmu_updates[0].ptr = (tab[l2_table_offset(pt_page)] & PAGE_MASK) +
+ sizeof(pgentry_t) * l1_table_offset(pt_page);
+ mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT |
+ (prot_e & ~_PAGE_RW);
+
+ if ( (rc = HYPERVISOR_mmu_update(mmu_updates, 1, NULL, DOMID_SELF)) < 0 )
+ {
+ printk("ERROR: PTE for new page table page could not be updated\n");
+ printk(" mmu_update failed with rc=%d\n", rc);
+ do_exit();
+ }
+
+ /* Hook the new page table page into the hierarchy */
+ mmu_updates[0].ptr =
+ ((pgentry_t)prev_l_mfn << PAGE_SHIFT) + sizeof(pgentry_t) * offset;
+ mmu_updates[0].val = (pgentry_t)pfn_to_mfn(*pt_pfn) << PAGE_SHIFT | prot_t;
+
+ if ( (rc = HYPERVISOR_mmu_update(mmu_updates, 1, NULL, DOMID_SELF)) < 0 )
+ {
+ printk("ERROR: mmu_update failed with rc=%d\n", rc);
+ do_exit();
+ }
+
+ *pt_pfn += 1;
+}
+
+/*
+ * Checks if a pagetable frame is needed at 'level' to map a given
+ * address. Note, this function is specific to the initial page table
+ * building.
+ */
+static int need_pt_frame(unsigned long va, int level)
+{
+ unsigned long hyp_virt_start = HYPERVISOR_VIRT_START;
+#if defined(__x86_64__)
+ unsigned long hyp_virt_end = HYPERVISOR_VIRT_END;
+#else
+ unsigned long hyp_virt_end = 0xffffffff;
+#endif
+
+ /* In general frames will _not_ be needed if they were already
+ allocated to map the hypervisor into our VA space */
+#if defined(__x86_64__)
+ if ( level == L3_FRAME )
+ {
+ if ( l4_table_offset(va) >=
+ l4_table_offset(hyp_virt_start) &&
+ l4_table_offset(va) <=
+ l4_table_offset(hyp_virt_end))
+ return 0;
+ return 1;
+ }
+ else
+#endif
+
+ if ( level == L2_FRAME )
+ {
+#if defined(__x86_64__)
+ if ( l4_table_offset(va) >=
+ l4_table_offset(hyp_virt_start) &&
+ l4_table_offset(va) <=
+ l4_table_offset(hyp_virt_end))
+#endif
+ if ( l3_table_offset(va) >=
+ l3_table_offset(hyp_virt_start) &&
+ l3_table_offset(va) <=
+ l3_table_offset(hyp_virt_end))
+ return 0;
+
+ return 1;
+ }
+ else
+ /* Always need l1 frames */
+ if ( level == L1_FRAME )
+ return 1;
+
+ printk("ERROR: Unknown frame level %d, hypervisor %llx,%llx\n",
+ level, hyp_virt_start, hyp_virt_end);
+ return -1;
+}
+
+/*
+ * Build the initial pagetable.
+ */
+static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn)
+{
+ unsigned long start_address, end_address;
+ unsigned long pfn_to_map, pt_pfn = *start_pfn;
+ static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES + 1];
+ pgentry_t *tab = (pgentry_t *)start_info.pt_base, page;
+ unsigned long pt_mfn = pfn_to_mfn(virt_to_pfn(start_info.pt_base));
+ unsigned long offset;
+ int count = 0;
+ int rc;
+
+ pfn_to_map =
+ (start_info.nr_pt_frames - NOT_L1_FRAMES) * L1_PAGETABLE_ENTRIES;
+
+ if ( *max_pfn >= virt_to_pfn(HYPERVISOR_VIRT_START) )
+ {
+ printk("WARNING: Mini-OS trying to use Xen virtual space. "
+ "Truncating memory from %dMB to ",
+ ((unsigned long)pfn_to_virt(*max_pfn) -
+ (unsigned long)&_text)>>20);
+ *max_pfn = virt_to_pfn(HYPERVISOR_VIRT_START - PAGE_SIZE);
+ printk("%dMB\n",
+ ((unsigned long)pfn_to_virt(*max_pfn) -
+ (unsigned long)&_text)>>20);
+ }
+
+ start_address = (unsigned long)pfn_to_virt(pfn_to_map);
+ end_address = (unsigned long)pfn_to_virt(*max_pfn);
+
+ /* We worked out the virtual memory range to map, now mapping loop */
+ printk("Mapping memory range 0x%lx - 0x%lx\n", start_address, end_address);
+
+ while ( start_address < end_address )
+ {
+ tab = (pgentry_t *)start_info.pt_base;
+ pt_mfn = pfn_to_mfn(virt_to_pfn(start_info.pt_base));
+
+#if defined(__x86_64__)
+ offset = l4_table_offset(start_address);
+ /* Need new L3 pt frame */
+ if ( !(start_address & L3_MASK) )
+ if ( need_pt_frame(start_address, L3_FRAME) )
+ new_pt_frame(&pt_pfn, pt_mfn, offset, L3_FRAME);
+
+ page = tab[offset];
+ pt_mfn = pte_to_mfn(page);
+ tab = to_virt(mfn_to_pfn(pt_mfn) << PAGE_SHIFT);
+#endif
+ offset = l3_table_offset(start_address);
+ /* Need new L2 pt frame */
+ if ( !(start_address & L2_MASK) )
+ if ( need_pt_frame(start_address, L2_FRAME) )
+ new_pt_frame(&pt_pfn, pt_mfn, offset, L2_FRAME);
+
+ page = tab[offset];
+ pt_mfn = pte_to_mfn(page);
+ tab = to_virt(mfn_to_pfn(pt_mfn) << PAGE_SHIFT);
+ offset = l2_table_offset(start_address);
+ /* Need new L1 pt frame */
+ if ( !(start_address & L1_MASK) )
+ if ( need_pt_frame(start_address, L1_FRAME) )
+ new_pt_frame(&pt_pfn, pt_mfn, offset, L1_FRAME);
+
+ page = tab[offset];
+ pt_mfn = pte_to_mfn(page);
+ offset = l1_table_offset(start_address);
+
+ mmu_updates[count].ptr =
+ ((pgentry_t)pt_mfn << PAGE_SHIFT) + sizeof(pgentry_t) * offset;
+ mmu_updates[count].val =
+ (pgentry_t)pfn_to_mfn(pfn_to_map++) << PAGE_SHIFT | L1_PROT;
+ count++;
+ if ( count == L1_PAGETABLE_ENTRIES || pfn_to_map == *max_pfn )
+ {
+ rc = HYPERVISOR_mmu_update(mmu_updates, count, NULL, DOMID_SELF);
+ if ( rc < 0 )
+ {
+ printk("ERROR: build_pagetable(): PTE could not be updated\n");
+ printk(" mmu_update failed with rc=%d\n", rc);
+ do_exit();
+ }
+ count = 0;
+ }
+ start_address += PAGE_SIZE;
+ }
+
+ *start_pfn = pt_pfn;
+}
+
+/*
+ * Mark portion of the address space read only.
+ */
+extern struct shared_info shared_info;
+static void set_readonly(void *text, void *etext)
+{
+ unsigned long start_address =
+ ((unsigned long) text + PAGE_SIZE - 1) & PAGE_MASK;
+ unsigned long end_address = (unsigned long) etext;
+ static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES + 1];
+ pgentry_t *tab = (pgentry_t *)start_info.pt_base, page;
+ unsigned long mfn = pfn_to_mfn(virt_to_pfn(start_info.pt_base));
+ unsigned long offset;
+ int count = 0;
+ int rc;
+
+ printk("setting %p-%p readonly\n", text, etext);
+
+ while ( start_address + PAGE_SIZE <= end_address )
+ {
+ tab = (pgentry_t *)start_info.pt_base;
+ mfn = pfn_to_mfn(virt_to_pfn(start_info.pt_base));
+
+#if defined(__x86_64__)
+ offset = l4_table_offset(start_address);
+ page = tab[offset];
+ mfn = pte_to_mfn(page);
+ tab = to_virt(mfn_to_pfn(mfn) << PAGE_SHIFT);
+#endif
+ offset = l3_table_offset(start_address);
+ page = tab[offset];
+ mfn = pte_to_mfn(page);
+ tab = to_virt(mfn_to_pfn(mfn) << PAGE_SHIFT);
+ offset = l2_table_offset(start_address);
+ page = tab[offset];
+ mfn = pte_to_mfn(page);
+ tab = to_virt(mfn_to_pfn(mfn) << PAGE_SHIFT);
+
+ offset = l1_table_offset(start_address);
+
+ if ( start_address != (unsigned long)&shared_info )
+ {
+ mmu_updates[count].ptr =
+ ((pgentry_t)mfn << PAGE_SHIFT) + sizeof(pgentry_t) * offset;
+ mmu_updates[count].val = tab[offset] & ~_PAGE_RW;
+ count++;
+ }
+ else
+ printk("skipped %p\n", start_address);
+
+ start_address += PAGE_SIZE;
+
+ if ( count == L1_PAGETABLE_ENTRIES ||
+ start_address + PAGE_SIZE > end_address )
+ {
+ rc = HYPERVISOR_mmu_update(mmu_updates, count, NULL, DOMID_SELF);
+ if ( rc < 0 )
+ {
+ printk("ERROR: set_readonly(): PTE could not be updated\n");
+ do_exit();
+ }
+ count = 0;
+ }
+ }
+
+ {
+ mmuext_op_t op = {
+ .cmd = MMUEXT_TLB_FLUSH_ALL,
+ };
+ int count;
+ HYPERVISOR_mmuext_op(&op, 1, &count, DOMID_SELF);
+ }
+}
+
+/*
+ * A useful mem testing function. Write the address to every address in the
+ * range provided and read back the value. If verbose, print page walk to
+ * some VA
+ *
+ * If we get MEM_TEST_MAX_ERRORS we might as well stop
+ */
+#define MEM_TEST_MAX_ERRORS 10
+int mem_test(unsigned long *start_va, unsigned long *end_va, int verbose)
+{
+ unsigned long mask = 0x10000;
+ unsigned long *pointer;
+ int error_count = 0;
+
+ /* write values and print page walks */
+ if ( verbose && (((unsigned long)start_va) & 0xfffff) )
+ {
+ printk("MemTest Start: 0x%lx\n", start_va);
+ page_walk((unsigned long)start_va);
+ }
+ for ( pointer = start_va; pointer < end_va; pointer++ )
+ {
+ if ( verbose && !(((unsigned long)pointer) & 0xfffff) )
+ {
+ printk("Writing to %lx\n", pointer);
+ page_walk((unsigned long)pointer);
+ }
+ *pointer = (unsigned long)pointer & ~mask;
+ }
+ if ( verbose && (((unsigned long)end_va) & 0xfffff) )
+ {
+ printk("MemTest End: %lx\n", end_va-1);
+ page_walk((unsigned long)end_va-1);
+ }
+
+ /* verify values */
+ for ( pointer = start_va; pointer < end_va; pointer++ )
+ {
+ if ( ((unsigned long)pointer & ~mask) != *pointer )
+ {
+ printk("Read error at 0x%lx. Read: 0x%lx, should read 0x%lx\n",
+ (unsigned long)pointer, *pointer,
+ ((unsigned long)pointer & ~mask));
+ error_count++;
+ if ( error_count >= MEM_TEST_MAX_ERRORS )
+ {
+ printk("mem_test: too many errors\n");
+ return -1;
+ }
+ }
+ }
+ return 0;
+}
+
+
+/*
+ * get the PTE for virtual address va if it exists. Otherwise NULL.
+ */
+static pgentry_t *get_pgt(unsigned long va)
+{
+ unsigned long mfn;
+ pgentry_t *tab;
+ unsigned offset;
+
+ tab = (pgentry_t *)start_info.pt_base;
+ mfn = virt_to_mfn(start_info.pt_base);
+
+#if defined(__x86_64__)
+ offset = l4_table_offset(va);
+ if ( !(tab[offset] & _PAGE_PRESENT) )
+ return NULL;
+ mfn = pte_to_mfn(tab[offset]);
+ tab = mfn_to_virt(mfn);
+#endif
+ offset = l3_table_offset(va);
+ if ( !(tab[offset] & _PAGE_PRESENT) )
+ return NULL;
+ mfn = pte_to_mfn(tab[offset]);
+ tab = mfn_to_virt(mfn);
+ offset = l2_table_offset(va);
+ if ( !(tab[offset] & _PAGE_PRESENT) )
+ return NULL;
+ mfn = pte_to_mfn(tab[offset]);
+ tab = mfn_to_virt(mfn);
+ offset = l1_table_offset(va);
+ return &tab[offset];
+}
+
+
+/*
+ * return a valid PTE for a given virtual address. If PTE does not exist,
+ * allocate page-table pages.
+ */
+pgentry_t *need_pgt(unsigned long va)
+{
+ unsigned long pt_mfn;
+ pgentry_t *tab;
+ unsigned long pt_pfn;
+ unsigned offset;
+
+ tab = (pgentry_t *)start_info.pt_base;
+ pt_mfn = virt_to_mfn(start_info.pt_base);
+
+#if defined(__x86_64__)
+ offset = l4_table_offset(va);
+ if ( !(tab[offset] & _PAGE_PRESENT) )
+ {
+ pt_pfn = virt_to_pfn(alloc_page());
+ new_pt_frame(&pt_pfn, pt_mfn, offset, L3_FRAME);
+ }
+ ASSERT(tab[offset] & _PAGE_PRESENT);
+ pt_mfn = pte_to_mfn(tab[offset]);
+ tab = mfn_to_virt(pt_mfn);
+#endif
+ offset = l3_table_offset(va);
+ if ( !(tab[offset] & _PAGE_PRESENT) )
+ {
+ pt_pfn = virt_to_pfn(alloc_page());
+ new_pt_frame(&pt_pfn, pt_mfn, offset, L2_FRAME);
+ }
+ ASSERT(tab[offset] & _PAGE_PRESENT);
+ pt_mfn = pte_to_mfn(tab[offset]);
+ tab = mfn_to_virt(pt_mfn);
+ offset = l2_table_offset(va);
+ if ( !(tab[offset] & _PAGE_PRESENT) )
+ {
+ pt_pfn = virt_to_pfn(alloc_page());
+ new_pt_frame(&pt_pfn, pt_mfn, offset, L1_FRAME);
+ }
+ ASSERT(tab[offset] & _PAGE_PRESENT);
+ pt_mfn = pte_to_mfn(tab[offset]);
+ tab = mfn_to_virt(pt_mfn);
+
+ offset = l1_table_offset(va);
+ return &tab[offset];
+}
+
+/*
+ * Reserve an area of virtual address space for mappings and Heap
+ */
+static unsigned long demand_map_area_start;
+#ifdef __x86_64__
+#define DEMAND_MAP_PAGES ((128ULL << 30) / PAGE_SIZE)
+#else
+#define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE)
+#endif
+
+#ifndef HAVE_LIBC
+#define HEAP_PAGES 0
+#else
+unsigned long heap, brk, heap_mapped, heap_end;
+#ifdef __x86_64__
+#define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE)
+#else
+#define HEAP_PAGES ((1ULL << 30) / PAGE_SIZE)
+#endif
+#endif
_______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |