├── .gitignore ├── .gitmodules ├── .travis.yml ├── AUTHORS ├── LICENSE ├── README.md ├── app-tools ├── Makefile ├── cc.in ├── cookfs.in ├── recipe.s.in ├── rumprun ├── rumprun-bake.conf ├── rumprun-bake.in ├── rumpstop ├── specs-bake.in ├── specs-compile_or_ferment.in ├── specs-stub.in └── toolchain.cmake.in ├── build-rr.sh ├── doc └── config.md ├── gdbscripts ├── bmk_dmesg └── bmk_thr.subr ├── global.mk ├── include ├── bmk-core │ ├── amd64 │ │ └── asm.h │ ├── arm │ │ └── asm.h │ ├── core.h │ ├── errno.h │ ├── i386 │ │ └── asm.h │ ├── jsmn.h │ ├── mainthread.h │ ├── memalloc.h │ ├── null.h │ ├── pgalloc.h │ ├── platform.h │ ├── printf.h │ ├── queue.h │ ├── sched.h │ ├── string.h │ └── types.h ├── bmk-rumpuser │ ├── core_types.h │ └── rumpuser.h └── rumprun-base │ ├── config.h │ ├── makelwp.h │ ├── parseargs.h │ └── rumprun.h ├── lib ├── Makefile.inc ├── README.txt ├── libbmk_core │ ├── Makefile │ ├── arch │ │ ├── earm │ │ │ ├── Makefile.inc │ │ │ ├── __aeabi_read_tp.S │ │ │ ├── cpu_sched.c │ │ │ └── cpu_sched_switch.S │ │ ├── i386 │ │ │ ├── Makefile.inc │ │ │ └── cpu_sched_switch.S │ │ ├── x86 │ │ │ ├── Makefile.inc │ │ │ └── cpu_sched.c │ │ └── x86_64 │ │ │ ├── Makefile.inc │ │ │ └── cpu_sched_switch.S │ ├── bmk_string.c │ ├── init.c │ ├── jsmn.c │ ├── memalloc.c │ ├── pgalloc.c │ ├── sched.c │ ├── strtoul.c │ └── subr_prf.c ├── libbmk_rumpuser │ ├── Makefile │ ├── rumpuser_base.c │ ├── rumpuser_clock.c │ ├── rumpuser_cons.c │ ├── rumpuser_mem.c │ ├── rumpuser_stubs.c │ └── rumpuser_synch.c ├── libcompiler_rt │ └── Makefile ├── librumpkern_bmktc │ ├── Makefile │ ├── bmktc_user.c │ ├── bmktc_user.h │ └── rump_bmktc.c ├── librumpkern_mman │ ├── Makefile │ ├── mman_component.c │ └── sys_mman.c ├── librumprun_base │ ├── Makefile │ ├── __errno.c │ ├── _lwp.c │ ├── config.c │ ├── daemon.c │ ├── libc_stubs.c │ ├── main.c │ ├── malloc.c │ ├── netbsd_initfini.c │ ├── parseargs.c │ ├── platefs.c │ ├── platefs.h │ ├── pthread │ │ └── pthread_makelwp_rumprun.c │ ├── rumprun-private.h │ ├── rumprun.c │ ├── signals.c │ ├── syscall_misc.c │ ├── syscall_mman.c │ └── sysproxy.c ├── librumprun_tester │ ├── Makefile │ ├── rumprun_tester.c │ └── tester.h ├── librumprunfs_base │ ├── Makefile │ └── rootfs │ │ └── etc │ │ ├── group │ │ ├── hosts │ │ ├── master.passwd │ │ ├── nsswitch.conf │ │ ├── protocols │ │ ├── pwd.db │ │ ├── resolv.conf │ │ ├── services │ │ └── spwd.db └── libunwind │ └── Makefile ├── platform ├── Makefile.inc ├── hw │ ├── Makefile │ ├── arch │ │ ├── amd64 │ │ │ ├── Makefile.inc │ │ │ ├── intr.S │ │ │ ├── kern.ldscript │ │ │ ├── locore.S │ │ │ ├── machdep.c │ │ │ ├── makepagetable.awk │ │ │ └── pagetable.S │ │ ├── arm │ │ │ └── integrator │ │ │ │ ├── Makefile.inc │ │ │ │ ├── boardreg.h │ │ │ │ ├── kern.ldscript │ │ │ │ ├── locore.S │ │ │ │ ├── machdep.c │ │ │ │ └── serialcons.c │ │ ├── i386 │ │ │ ├── Makefile.inc │ │ │ ├── kern.ldscript │ │ │ ├── locore.S │ │ │ └── machdep.c │ │ └── x86 │ │ │ ├── boot.c │ │ │ ├── clock.c │ │ │ ├── cons.c │ │ │ ├── cpu_subr.c │ │ │ ├── hypervisor.c │ │ │ ├── serialcons.c │ │ │ ├── vgacons.c │ │ │ └── x86_subr.c │ ├── clock_subr.c │ ├── include │ │ ├── arch │ │ │ ├── earm │ │ │ │ ├── inline.h │ │ │ │ ├── md.h │ │ │ │ └── pcpu.h │ │ │ ├── i386 │ │ │ │ ├── md.h │ │ │ │ └── pcpu.h │ │ │ ├── x86 │ │ │ │ ├── cons.h │ │ │ │ ├── hypervisor.h │ │ │ │ ├── inline.h │ │ │ │ ├── reg.h │ │ │ │ └── var.h │ │ │ └── x86_64 │ │ │ │ ├── md.h │ │ │ │ └── pcpu.h │ │ └── hw │ │ │ ├── clock_subr.h │ │ │ ├── kernel.h │ │ │ ├── multiboot.h │ │ │ └── types.h │ ├── intr.c │ ├── kernel.c │ ├── multiboot.c │ ├── pci │ │ ├── Makefile │ │ ├── Makefile.pcihyperdefs │ │ ├── rumpcomp_userfeatures_pci.h │ │ ├── rumpdma.c │ │ └── rumppci.c │ ├── platform.conf │ ├── tests │ │ └── checksum │ │ │ └── test.sh │ └── undefs.c ├── makepseudolinkstubs.sh └── xen │ ├── Makefile │ ├── init.c │ ├── librumpnet_xenif │ ├── Makefile │ ├── if_virt.c │ ├── if_virt.h │ ├── if_virt_user.h │ ├── xenif_component.c │ └── xenif_user.c │ ├── librumpxen_xendev │ ├── Makefile │ ├── busdev.c │ ├── busdev_user.c │ ├── busdev_user.h │ ├── evtdev.c │ ├── privcmd.c │ ├── rumpxen_xendev.h │ ├── xendev_component.c │ ├── xenio.h │ └── xenio3.h │ ├── pci │ ├── Makefile │ ├── Makefile.pcihyperdefs │ ├── rumpcomp_userfeatures_pci.h │ ├── rumphyper_dma.c │ └── rumphyper_pci.c │ ├── platform.conf │ ├── rumphyper_bio.c │ └── xen │ ├── Config.mk │ ├── Makefile │ ├── arch │ └── x86 │ │ ├── Makefile │ │ ├── arch.mk │ │ ├── gdt_32.c │ │ ├── ioremap.c │ │ ├── minios-x86_32.lds │ │ ├── minios-x86_64.lds │ │ ├── mm.c │ │ ├── sched.c │ │ ├── setup.c │ │ ├── time.c │ │ ├── traps.c │ │ ├── x86_32.S │ │ └── x86_64.S │ ├── blkfront.c │ ├── console │ ├── console.c │ ├── console.h │ ├── xenbus.c │ └── xencons_ring.c │ ├── events.c │ ├── gntmap.c │ ├── gnttab.c │ ├── hypervisor.c │ ├── include │ └── mini-os │ │ ├── blkfront.h │ │ ├── console.h │ │ ├── events.h │ │ ├── fbfront.h │ │ ├── gntmap.h │ │ ├── gnttab.h │ │ ├── hypervisor.h │ │ ├── ioremap.h │ │ ├── kernel.h │ │ ├── lib.h │ │ ├── mm.h │ │ ├── netfront.h │ │ ├── os.h │ │ ├── pcifront.h │ │ ├── queue.h │ │ ├── semaphore.h │ │ ├── spinlock.h │ │ ├── time.h │ │ ├── types.h │ │ ├── wait.h │ │ ├── waittypes.h │ │ ├── x86 │ │ ├── limits.h │ │ ├── mm.h │ │ ├── os.h │ │ ├── pcpu.h │ │ ├── spinlock.h │ │ ├── traps.h │ │ ├── x86_32 │ │ │ └── hypercall-x86_32.h │ │ └── x86_64 │ │ │ └── hypercall-x86_64.h │ │ └── xenbus.h │ ├── kernel.c │ ├── minios.mk │ ├── mm.c │ ├── netfront.c │ ├── pcifront.c │ └── xenbus │ └── xenbus.c └── tests ├── Makefile ├── Makefile.inc ├── basic ├── Makefile ├── ctor_test.c ├── misc_test.c ├── pthread_test.c └── tls_test.c ├── buildtests.sh ├── cmake ├── CMakeLists.txt ├── config.h.in └── test.c ├── configure ├── .gitignore ├── Makefile.am ├── Makefile.in ├── aclocal.m4 ├── build-aux │ ├── compile │ ├── config.guess │ ├── config.sub │ ├── depcomp │ ├── install-sh │ ├── ltmain.sh │ └── missing ├── config.h.in ├── configure ├── configure.ac ├── m4 │ ├── libtool.m4 │ ├── ltoptions.m4 │ ├── ltsugar.m4 │ ├── ltversion.m4 │ └── lt~obsolete.m4 └── test.c ├── crypto ├── Makefile ├── README └── md5.c ├── hello ├── Makefile ├── hello.c └── hellopp.cc ├── nolibc ├── Makefile ├── main.c └── nolibc.h └── runtests.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.o 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "buildrump.sh"] 2 | path = buildrump.sh 3 | url = https://github.com/rumpkernel/buildrump.sh 4 | [submodule "src-netbsd"] 5 | path = src-netbsd 6 | url = https://github.com/rumpkernel/src-netbsd 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | language: c 4 | cache: ccache 5 | compiler: 6 | - gcc 7 | 8 | before_script: 9 | - sudo apt-get update -y 10 | - sudo apt-get install qemu-kvm libxen-dev -y 11 | - sudo apt-get install --only-upgrade binutils gcc -y 12 | 13 | env: 14 | - PLATFORM=hw MACHINE=x86_64 TESTS=qemu EXTRAFLAGS= 15 | - PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686' 16 | - PLATFORM=xen MACHINE=x86_64 TESTS=none EXTRAFLAGS= 17 | - PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none EXTRAFLAGS='-- -F ACLFLAGS=-m32' 18 | - PLATFORM=hw MACHINE=x86_64 TESTS=qemu EXTRAFLAGS= CXX='false' 19 | - PLATFORM=hw MACHINE=x86_64 TESTS=none KERNONLY=-k EXTRAFLAGS= 20 | - PLATFORM=xen MACHINE=x86_64 TESTS=none KERNONLY=-k EXTRAFLAGS= 21 | 22 | script: 23 | - git submodule update --init 24 | - ./build-rr.sh -o myobj -j16 -qq ${KERNONLY} ${PLATFORM} ${EXTRAFLAGS} 25 | - . ./myobj/config 26 | - ./tests/buildtests.sh ${KERNONLY} 27 | - ./tests/runtests.sh ${TESTS} 28 | 29 | notifications: 30 | irc: 31 | channels: 32 | - "chat.freenode.net#rumpkernel-builds" 33 | template: 34 | - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}' 35 | skip_join: true 36 | use_notice: true 37 | email: 38 | recipients: 39 | - rumpkernel-builds@freelists.org 40 | on_success: always 41 | on_failure: always 42 | 43 | # touch me to force a travis rebuild 44 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The following people have contributed to this repository: 2 | 3 | Antti Kantee 4 | Martin Lucina 5 | Wei Liu 6 | Justin Cormack 7 | Timmons C. Player 8 | Sotiris Salloumis 9 | Stefan Grundmann 10 | Sebastian Wicki 11 | Dan Skorupski 12 | Matt Gray 13 | Ian Eyberg 14 | Francesco Lattanzio 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The rumprun software stack is provided under a 2-clause BSD license 2 | which is given at the end of this file. 3 | 4 | NetBSD source code (src-netbsd) is required for successful execution. 5 | NetBSD is licensed under a BSD style license, but third party code 6 | imported into the NetBSD tree's "external" section may have a differing 7 | license. For example, source code licensed under CDDL is found in 8 | src/external/cddl. Almost all of the produced rump kernel component 9 | binaries fall under a BSD license, but when pertinent, verify the license 10 | of a component by examining its source code. We do not intentionally 11 | include code which is available exclusively under GPL to avoid debate 12 | on the licensing terms of the entire rumprun stack. 13 | 14 | 15 | Copyright (c) Authors. All rights reserved. 16 | 17 | Redistribution and use in source and binary forms, with or without 18 | modification, are permitted provided that the following conditions 19 | are met: 20 | 1. Redistributions of source code must retain the above copyright 21 | notice, this list of conditions and the following disclaimer. 22 | 2. Redistributions in binary form must reproduce the above copyright 23 | notice, this list of conditions and the following disclaimer in the 24 | documentation and/or other materials provided with the distribution. 25 | 26 | THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 27 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 30 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | SUCH DAMAGE. 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Rumprun [![Build Status](https://travis-ci.org/rumpkernel/rumprun.svg?branch=master)](https://travis-ci.org/rumpkernel/rumprun) 2 | ======= 3 | 4 | This repository uses [rump kernels](http://rumpkernel.org) to provide 5 | the Rumprun [unikernel](https://en.wikipedia.org/wiki/Unikernel). 6 | Rumprun works on not only on hypervisors such as KVM and Xen, but also on 7 | bare metal. Rumprun can be used with or without a POSIX'y interface. 8 | The former allows existing, unmodified POSIX applications to run 9 | out-of-the-box, while the latter allows building highly customized 10 | solutions with minimal footprints. 11 | 12 | The Rumprun unikernel supports applications written in, for example 13 | but not limited to: _C_, _C++_, _Erlang_, _Go_, _Java_, _Javascript (node.js)_, 14 | _Python_, _Ruby_ and _Rust_. 15 | 16 | You will find ready-made software packages for Rumprun from the 17 | [rumprun-packages repository](http://repo.rumpkernel.org/rumprun-packages). 18 | Some examples of software available from there includes _LevelDB_, 19 | _Memcached_, _nanomsg_, _Nginx_ and _Redis_. See the packages repository 20 | for further details. 21 | 22 | See the [wiki](http://wiki.rumpkernel.org/Repo:-rumprun) for more 23 | information and instructions. You may also want to watch video 24 | tutorials in the 25 | [Rumprun unikernel video series](http://wiki.rumpkernel.org/Tutorial%3A-Rumprun-unikernel-video-series). 26 | 27 | Note: some of our tools will throw a warning about them 28 | being experimental. It does not mean that they 29 | are not expected to produce a working result, just that the usage 30 | is not necessarily final. The wiki 31 | [explains](http://wiki.rumpkernel.org/Repo%3A-rumprun#experimental-nature) 32 | further. 33 | 34 | hw 35 | -- 36 | 37 | The hardware (``hw'') platform is meant for embedded systems 38 | and the cloud. It works on raw hardware, but also supports 39 | _virtio_ drivers and KVM. For a demonstration, see this [youtube 40 | video](https://www.youtube.com/watch?v=EyeRplLMx4c) where the hw platform 41 | is booted on a laptop and plays audio using the PCI hdaudio drivers. 42 | The supported CPU architectures are x86_32, x86_64 and ARM. 43 | 44 | Xen 45 | --- 46 | 47 | The Xen platform is optimized for running on top of the Xen hypervisor 48 | as a paravirtualized guest, and provides support for virtualization 49 | functions not available on the _hw_ platform. The Xen platform will 50 | work both against the `xl` tools and the Amazon EC2 cloud. 51 | The supported CPU architectures are x86_32 and x86_64. 52 | -------------------------------------------------------------------------------- /app-tools/recipe.s.in: -------------------------------------------------------------------------------- 1 | .section ".note.rumprun.bakerecipe", "a" 2 | .p2align 2 3 | .long 1f - 0f 4 | .long 3f - 2f 5 | .long 0x00000101 6 | 0: .asciz "rumpkernel.org" 7 | 1: .p2align 2 8 | 2: .asciz "rumprun_tuple: !TOOLTUPLE!" 9 | .asciz "rumprun_tooldir: !DESTDIR!" 10 | .asciz "rumprun_backingcc: !LIBEXEC_CC!" 11 | /* XXX: cc frontend cflags should not be here */ 12 | .asciz "rumprun_cflags: !CFLAGS!" 13 | 3: .p2align 2 14 | -------------------------------------------------------------------------------- /app-tools/rumpstop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | die () 4 | { 5 | echo ">> ERROR:" 1>&2 6 | echo ">> $@" 1>&2 7 | exit 1 8 | } 9 | 10 | unset sudo 11 | if [ "$1" = '-S' ]; then 12 | shift 13 | [ $(id -u) -ne 0 ] && sudo=sudo 14 | fi 15 | 16 | [ $# -eq 1 ] || die usage: rumpstop guest_spec 17 | 18 | stack=${1%%:*} 19 | guest=${1#*:} 20 | 21 | case "${stack}" in 22 | qemu) 23 | kill ${guest} 24 | ;; 25 | xen) 26 | ${sudo} xl destroy ${guest} 27 | ;; 28 | *) 29 | die invalid stack spec \"${stack}\" 30 | ;; 31 | esac 32 | 33 | exit $? 34 | -------------------------------------------------------------------------------- /app-tools/specs-bake.in: -------------------------------------------------------------------------------- 1 | *startfile: 2 | !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/rumprun-!PLATFORM!/rumprun.o 3 | 4 | *endfile: 5 | 6 | 7 | *lib: 8 | !LDFLAGS_BAKE! -L!DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/rumprun-!PLATFORM! \ 9 | --whole-archive -lrump --no-whole-archive \ 10 | --start-group -lrumprun_base -lpthread -lc --end-group 11 | 12 | *link: 13 | %{m64:-m elf_x86_64;mx32:-m elf32_x86_64;m32:-m elf_i386} -T !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/!PLATFORM!.ldscript %:replace-outfile(-lstdc++ -lc++) %{rdynamic:} 14 | 15 | %rename link_libgcc old_link_libgcc 16 | 17 | %rename libgcc old_libgcc 18 | -------------------------------------------------------------------------------- /app-tools/specs-compile_or_ferment.in: -------------------------------------------------------------------------------- 1 | %rename cpp_options old_cpp_options 2 | 3 | *cpp_options: 4 | -nostdinc -isystem !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/include %{,c++:%{!std=*:-std=c++11}} %{,c++:-isystem !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/include/c++} %(old_cpp_options) !CPPFLAGS! -D__RUMPRUN__ 5 | 6 | %rename cc1_options old_cc1_options 7 | 8 | *cc1_options: 9 | %(old_cc1_options) !CFLAGS! -fno-stack-protector -fno-builtin-sin -fno-builtin-sinf -fno-builtin-cos -fno-builtin-cosf 10 | 11 | *cc1plus: 12 | %{!std=*:-std=c++11} 13 | 14 | *startfile: 15 | 16 | 17 | *endfile: 18 | 19 | 20 | *lib: 21 | -L!DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib 22 | 23 | *link: 24 | %{m64:-m elf_x86_64;mx32:-m elf32_x86_64;m32:-m elf_i386} %:remove-outfile(-lstdc++) %{rdynamic:} 25 | 26 | %rename link_libgcc old_link_libgcc 27 | 28 | %rename libgcc old_libgcc 29 | -------------------------------------------------------------------------------- /app-tools/specs-stub.in: -------------------------------------------------------------------------------- 1 | *startfile: 2 | 3 | 4 | *endfile: 5 | 6 | 7 | *lib: 8 | -L!DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib \ 9 | --start-group -lpthread -lc --end-group \ 10 | !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!/lib/pseudolinkstubs.o 11 | 12 | *link: 13 | %{m64:-m elf_x86_64;mx32:-m elf32_x86_64;m32:-m elf_i386} %:replace-outfile(-lstdc++ -lc++) %{rdynamic:} 14 | 15 | %rename link_libgcc old_link_libgcc 16 | 17 | %rename libgcc old_libgcc 18 | -------------------------------------------------------------------------------- /app-tools/toolchain.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # CMake toolchain file for cross-compiling to !TOOLTUPLE! 3 | # 4 | # When building software with CMake, specify as -DCMAKE_TOOLCHAIN_FILE=... 5 | # 6 | 7 | set(CMAKE_SYSTEM_NAME Generic) 8 | 9 | set(CMAKE_C_COMPILER !TOOLS_CC!) 10 | set(CMAKE_CXX_COMPILER !TOOLS_CXX!) 11 | 12 | set(CMAKE_FIND_ROOT_PATH !DESTDIR!/rumprun-!MACHINE_GNU_ARCH!) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 15 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 17 | -------------------------------------------------------------------------------- /gdbscripts/bmk_dmesg: -------------------------------------------------------------------------------- 1 | set pagination off 2 | target remote:1234 3 | printf "%s", bmk_dmesg 4 | detach 5 | quit 6 | -------------------------------------------------------------------------------- /gdbscripts/bmk_thr.subr: -------------------------------------------------------------------------------- 1 | define bmk_thr_pr 2 | set $thr = (struct bmk_thread *)$arg0 3 | printf "n: %-10s\tsp: 0x%016x\tf: 0x%08x\tw: %ld\n", $thr->bt_name, \ 4 | $thr->bt_tcb.btcb_sp, $thr->bt_flags, $thr->bt_wakeup_time 5 | end 6 | 7 | define bmk_thr_apply_name 8 | set $thr = threadq->tqh_first 9 | while ($thr) 10 | if (strncmp($thr->bt_name, $arg0, strlen($arg0)) == 0) 11 | $arg1 $thr 12 | end 13 | set $thr = $thr->bt_threadq.tqe_next 14 | end 15 | end 16 | 17 | define bmk_thr_apply 18 | set $thr = threadq->tqh_first 19 | while ($thr) 20 | $arg0 $thr 21 | set $thr = $thr->bt_threadq.tqe_next 22 | end 23 | end 24 | 25 | define bmk_thr_pr_all 26 | bmk_thr_apply bmk_thr_pr 27 | end 28 | -------------------------------------------------------------------------------- /global.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(RUMPRUN_MKCONF),) 2 | $(error RUMPRUN_MKCONF missing) 3 | endif 4 | include ${RUMPRUN_MKCONF} 5 | ifeq (${RRDEST},) 6 | $(error invalid RUMPRUN_MKCONF) 7 | endif 8 | 9 | DBG?= -O2 -g 10 | CFLAGS+= -std=gnu99 ${DBG} 11 | CFLAGS+= -fno-stack-protector -ffreestanding 12 | CXXFLAGS+= -fno-stack-protector -ffreestanding 13 | 14 | CFLAGS+= -Wall -Wimplicit -Wmissing-prototypes -Wstrict-prototypes 15 | ifndef NOGCCERROR 16 | CFLAGS+= -Werror 17 | endif 18 | 19 | LDFLAGS.x86_64.hw= -z max-page-size=0x1000 20 | 21 | ifeq (${BUILDRR},true) 22 | INSTALLDIR= ${RROBJ}/dest.stage 23 | else 24 | INSTALLDIR= ${RRDEST} 25 | endif 26 | 27 | cc-option = $(shell if [ -z "`echo 'int p=1;' | $(CC) $(1) -S -o /dev/null -x c - 2>&1`" ]; \ 28 | then echo y; else echo n; fi) 29 | -------------------------------------------------------------------------------- /include/bmk-core/amd64/asm.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_AMD64_ASM_H_ 27 | #define _BMK_CORE_AMD64_ASM_H_ 28 | 29 | #define ENTRY(x) .text; .globl x; .type x,@function; x: 30 | #define END(x) .size x, . - x 31 | 32 | #endif /* _BMK_CORE_AMD64_ASM_H_ */ 33 | -------------------------------------------------------------------------------- /include/bmk-core/arm/asm.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_ARM_ASM_H_ 27 | #define _BMK_CORE_ARM_ASM_H_ 28 | 29 | #define ENTRY(x) .text; .globl x; .type x,%function; x: 30 | #define END(x) .size x, . - x 31 | 32 | #endif /* _BMK_CORE_ARM_ASM_H_ */ 33 | -------------------------------------------------------------------------------- /include/bmk-core/core.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_CORE_H_ 27 | #define _BMK_CORE_CORE_H_ 28 | 29 | #include 30 | 31 | #include 32 | 33 | int bmk_core_init(unsigned long); 34 | 35 | #define bmk_assert(x) \ 36 | do { \ 37 | if (__builtin_expect(!(x), 0)) { \ 38 | bmk_platform_halt("assert \"" #x "\" FAILED\n"); \ 39 | } \ 40 | } while (0) 41 | 42 | /* 43 | * Compile-time assert. 44 | * 45 | * We use it only if cpp supports __COUNTER__ (everything from 46 | * the past several years does). 47 | * 48 | * And hooray for cpp macro expansion. 49 | */ 50 | #ifdef __COUNTER__ 51 | #define __bmk_ctassert_c(x,c) typedef char __ct##c[(x) ? 1 : -1] \ 52 | __attribute__((unused)) 53 | #define __bmk_ctassert(x,c) __bmk_ctassert_c(x,c) 54 | #define bmk_ctassert(x) __bmk_ctassert(x,__COUNTER__) 55 | #else 56 | #define bmk_ctassert(x) 57 | #endif 58 | 59 | extern unsigned long bmk_stackpageorder, bmk_stacksize; 60 | 61 | void *bmk_mainstackbase; 62 | unsigned long bmk_mainstacksize; 63 | 64 | #define bmk_round_page(_p_) \ 65 | (((_p_) + (BMK_PCPU_PAGE_SIZE-1)) & ~(BMK_PCPU_PAGE_SIZE-1)) 66 | #define bmk_trunc_page(_p_) \ 67 | ((_p_) & ~(BMK_PCPU_PAGE_SIZE-1)) 68 | 69 | #endif /* _BMK_CORE_CORE_H_ */ 70 | -------------------------------------------------------------------------------- /include/bmk-core/errno.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_ERRNO_H_ 27 | #define _BMK_CORE_ERRNO_H_ 28 | 29 | /* 30 | * errno values. 31 | * these "accidentally" match NetBSD ones for convenience reasons. 32 | * 33 | * NOTE: we don't slurp in the whole errno table for a reason. 34 | * Please be critical when adding new values! Prefer to remove them! 35 | */ 36 | 37 | #define BMK_ENOENT 2 38 | #define BMK_EIO 5 39 | #define BMK_ENXIO 6 40 | #define BMK_E2BIG 7 41 | #define BMK_EBADF 9 42 | #define BMK_ENOMEM 12 43 | #define BMK_EBUSY 16 44 | #define BMK_EINVAL 22 45 | #define BMK_EROFS 30 46 | #define BMK_ETIMEDOUT 60 47 | #define BMK_ENOSYS 78 48 | 49 | #define BMK_EGENERIC BMK_EINVAL 50 | 51 | #endif /* _BMK_CORE_ERRNO_H_ */ 52 | -------------------------------------------------------------------------------- /include/bmk-core/i386/asm.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_I386_ASM_H_ 27 | #define _BMK_CORE_I386_ASM_H_ 28 | 29 | #define ENTRY(x) .text; .globl x; .type x,@function; x: 30 | #define END(x) .size x, . - x 31 | 32 | #endif /* _BMK_CORE_I386_ASM_H_ */ 33 | -------------------------------------------------------------------------------- /include/bmk-core/mainthread.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_MAINTHREAD_H_ 27 | #define _BMK_CORE_MAINTHREAD_H_ 28 | 29 | void bmk_mainthread(void *); 30 | 31 | #endif /* _BMK_CORE_MAINTHREAD_H_ */ 32 | -------------------------------------------------------------------------------- /include/bmk-core/null.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: null.h,v 1.9 2010/07/06 11:56:20 kleink Exp $ */ 2 | 3 | /* 4 | * Written by Klaus Klein , December 22, 1999. 5 | * Public domain. 6 | */ 7 | 8 | #ifndef _BMK_CORE_NULL_H_ 9 | #define _BMK_CORE_NULL_H_ 10 | #ifndef NULL 11 | #if !defined(__GNUG__) || __GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 90) 12 | #if !defined(__cplusplus) 13 | #define NULL ((void *)0) 14 | #else 15 | #define NULL 0 16 | #endif /* !__cplusplus */ 17 | #else 18 | #define NULL __null 19 | #endif 20 | #endif 21 | #endif /* _BMK_CORE_NULL_H_ */ 22 | -------------------------------------------------------------------------------- /include/bmk-core/pgalloc.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_PGALLOC_H_ 27 | #define _BMK_CORE_PGALLOC_H_ 28 | 29 | void bmk_pgalloc_loadmem(unsigned long, unsigned long); 30 | 31 | void * bmk_pgalloc(int); 32 | void * bmk_pgalloc_align(int, unsigned long); 33 | void bmk_pgfree(void *, int); 34 | 35 | void bmk_pgalloc_dumpstats(void); 36 | 37 | #define bmk_pgalloc_one() bmk_pgalloc(0) 38 | #define bmk_pgfree_one(p) bmk_pgfree(p, 0) 39 | 40 | #endif /* _BMK_CORE_PGALLOC_H_ */ 41 | -------------------------------------------------------------------------------- /include/bmk-core/platform.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_PLATFORM_H_ 27 | #define _BMK_CORE_PLATFORM_H_ 28 | 29 | #include 30 | 31 | extern unsigned long bmk_memsize; 32 | 33 | void bmk_platform_halt(const char *) __attribute__((noreturn)); 34 | 35 | void bmk_platform_cpu_block(bmk_time_t); 36 | 37 | bmk_time_t bmk_platform_cpu_clock_monotonic(void); 38 | bmk_time_t bmk_platform_cpu_clock_epochoffset(void); 39 | 40 | unsigned long bmk_platform_splhigh(void); 41 | void bmk_platform_splx(unsigned long); 42 | 43 | #endif /* _BMK_CORE_PLATFORM_H_ */ 44 | -------------------------------------------------------------------------------- /include/bmk-core/printf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_PRINTF_H_ 27 | #define _BMK_CORE_PRINTF_H_ 28 | 29 | void bmk_printf_init(void (*)(int), void (*)(void)); 30 | void bmk_printf(const char *, ...) 31 | __attribute__((__format__(__printf__,1,2))); 32 | int bmk_snprintf(char *, unsigned long, const char *, ...) 33 | __attribute__((__format__(__printf__,3,4))); 34 | 35 | /* definition of va_list might cause collisions, so hide it by default */ 36 | #ifdef _BMK_PRINTF_VA 37 | typedef __builtin_va_list va_list; 38 | #define va_start(ap, last) __builtin_va_start((ap), (last)) 39 | #define va_arg __builtin_va_arg 40 | #define va_end(ap) __builtin_va_end(ap) 41 | 42 | void bmk_vprintf(const char *, va_list) 43 | __attribute__((__format__(__printf__,1,0))); 44 | int bmk_vsnprintf(char *, unsigned long, const char *, va_list) 45 | __attribute__((__format__(__printf__,3,0))); 46 | #endif /* _BMK_PRINTF_VA */ 47 | 48 | #endif /* _BMK_CORE_PRINTF_H_ */ 49 | -------------------------------------------------------------------------------- /include/bmk-core/string.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_STRING_H_ 27 | #define _BMK_CORE_STRING_H_ 28 | 29 | void *bmk_memcpy(void *, const void *, unsigned long); 30 | void *bmk_memset(void *, int, unsigned long); 31 | void *bmk_memchr(const void *, int, unsigned long); 32 | void *bmk_memrchr(const void *, int, unsigned long); 33 | 34 | unsigned long bmk_strlen(const char *); 35 | char *bmk_strcpy(char *, const char *); 36 | char *bmk_strncpy(char *, const char *, unsigned long); 37 | int bmk_strcmp(const char *, const char *); 38 | int bmk_strncmp(const char *, const char *, unsigned long); 39 | unsigned long bmk_strtoul(const char *, char **, int); 40 | 41 | #endif /* _BMK_CORE_STRING_H_ */ 42 | -------------------------------------------------------------------------------- /include/bmk-core/types.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_CORE_TYPES_H_ 27 | #define _BMK_CORE_TYPES_H_ 28 | 29 | typedef __INT64_TYPE__ int64_t; 30 | typedef __UINT64_TYPE__ uint64_t; 31 | typedef __INT32_TYPE__ int32_t; 32 | typedef __UINT32_TYPE__ uint32_t; 33 | typedef __INT16_TYPE__ int16_t; 34 | typedef __UINT16_TYPE__ uint16_t; 35 | typedef __INT8_TYPE__ int8_t; 36 | typedef __UINT8_TYPE__ uint8_t; 37 | typedef __INTPTR_TYPE__ intptr_t; 38 | typedef __UINTPTR_TYPE__ uintptr_t; 39 | 40 | typedef __INT64_TYPE__ bmk_time_t; 41 | 42 | #endif /* _BMK_CORE_TYPES_H_ */ 43 | -------------------------------------------------------------------------------- /include/bmk-rumpuser/core_types.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | /* 27 | * Unfortunately, the rumpuser interface uses a small number 28 | * of constructs not defined by the compiler. To avoid pulling 29 | * in a can of worms, we define just those constructs here. 30 | */ 31 | 32 | #ifdef _LP64 33 | typedef long int64_t; 34 | typedef unsigned long uint64_t; 35 | #else 36 | typedef long long int64_t; 37 | typedef unsigned long long uint64_t; 38 | #endif /* _LP64 */ 39 | 40 | typedef int pid_t; 41 | typedef unsigned long size_t; 42 | 43 | #ifdef __GNUC__ 44 | #ifndef __dead 45 | #define __dead __attribute__((__noreturn__)) 46 | #endif 47 | #ifndef __printflike 48 | #define __printflike(a,b) __attribute__((__format__ (__printf__,a,b))) 49 | #endif 50 | #else /* __GNUC__ */ 51 | #define __dead 52 | #define __printflike(a,b) 53 | #endif /* __GNUC__ */ 54 | -------------------------------------------------------------------------------- /include/bmk-rumpuser/rumpuser.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: rumpuser_int.h,v 1.8 2013/04/30 12:39:20 pooka Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Antti Kantee. All Rights Reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | int rumprun_platform_rumpuser_init(void); 29 | 30 | #define LIBRUMPUSER 31 | #include 32 | 33 | extern struct rumpuser_hyperup rumpuser__hyp; 34 | 35 | static inline void 36 | rumpkern_unsched(int *nlocks, void *interlock) 37 | { 38 | 39 | rumpuser__hyp.hyp_backend_unschedule(0, nlocks, interlock); 40 | } 41 | 42 | static inline void 43 | rumpkern_sched(int nlocks, void *interlock) 44 | { 45 | 46 | rumpuser__hyp.hyp_backend_schedule(nlocks, interlock); 47 | } 48 | -------------------------------------------------------------------------------- /include/rumprun-base/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Martin Lucina. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMKCOMMON_RUMPRUN_CONFIG_H_ 27 | #define _BMKCOMMON_RUMPRUN_CONFIG_H_ 28 | 29 | #include 30 | 31 | /* yeah, simple */ 32 | #define RUMPRUN_DEFAULTUSERSTACK ((32*(sizeof(void *)/4)*4096)/1024) 33 | 34 | void rumprun_config(char *); 35 | 36 | #define RUMPRUN_EXEC_BACKGROUND 0x01 37 | #define RUMPRUN_EXEC_PIPE 0x02 38 | #define RUMPRUN_EXEC_CMDLINE 0x04 39 | struct rumprun_exec { 40 | int rre_flags; 41 | 42 | TAILQ_ENTRY(rumprun_exec) rre_entries; 43 | 44 | int rre_argc; 45 | char *rre_argv[]; 46 | }; 47 | 48 | TAILQ_HEAD(rumprun_execs, rumprun_exec); 49 | extern struct rumprun_execs rumprun_execs; 50 | 51 | #endif /* _BMKCOMMON_RUMPRUN_CONFIG_H_ */ 52 | -------------------------------------------------------------------------------- /include/rumprun-base/makelwp.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_BASE_RUMPRUN_MAKELWP_H_ 27 | #define _BMK_BASE_RUMPRUN_MAKELWP_H_ 28 | 29 | int rumprun_makelwp(void (*)(void *), void *, 30 | void *, void *, size_t, unsigned long, lwpid_t *); 31 | 32 | #endif /* _BMK_BASE_RUMPRUN_MAKELWP_H_ */ 33 | -------------------------------------------------------------------------------- /include/rumprun-base/parseargs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Citrix. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _RUMPRUN_BASE_PARSEARGS_H_ 27 | #define _RUMPRUN_BASE_PARSEARGS_H_ 28 | 29 | void rumprun_parseargs(char *, int *, char **); 30 | 31 | #endif /* _RUMPRUN_BASE_PARSEARGS_H_ */ 32 | -------------------------------------------------------------------------------- /include/rumprun-base/rumprun.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _RUMPRUN_BASE_RUMPRUN_H_ 27 | #define _RUMPRUN_BASE_RUMPRUN_H_ 28 | 29 | typedef int mainlike_fn(int, char *[]); 30 | mainlike_fn main; 31 | 32 | void rumprun_boot(char *); 33 | 34 | void * rumprun(int, mainlike_fn, int, char *[]); 35 | int rumprun_wait(void *); 36 | void * rumprun_get_finished(void); 37 | 38 | void rumprun_reboot(void) __attribute__((noreturn)); 39 | 40 | /* XXX: this prototype shouldn't be here (if it should exist at all) */ 41 | void rumprun_daemon(void); 42 | 43 | extern int rumprun_cold; 44 | 45 | #endif /* _RUMPRUN_BASE_RUMPRUN_H_ */ 46 | -------------------------------------------------------------------------------- /lib/Makefile.inc: -------------------------------------------------------------------------------- 1 | CFLAGS+= -Wall -Wextra -Wno-unused-parameter 2 | CFLAGS+= -Wmissing-prototypes -Wstrict-prototypes 3 | CFLAGS+= -fno-stack-protector 4 | 5 | CPPFLAGS+= -I${BMKHEADERS} 6 | -------------------------------------------------------------------------------- /lib/README.txt: -------------------------------------------------------------------------------- 1 | Libraries hosted in this directory: 2 | 3 | bmk_core: 4 | "kernel" routines, these are self-contained and especially 5 | may *NOT* use libc interfaces 6 | 7 | bmk_rumpuser: 8 | common bits for the rump kernel hypercall implementation, 9 | runs on top of bmk. 10 | 11 | rumprun_base: 12 | "userspace" routines, implement some libc interfaces, etc. 13 | 14 | rumpkern_bmktc: 15 | bmk hypercall timecounter driver for the NetBSD kernel 16 | 17 | unwind: 18 | reachover library for NetBSD's stack unwind support (for C++) 19 | 20 | compiler_rt: 21 | reachover library for NetBSD's compiler runtime support (the 22 | bits are usually in libc, so this library is necessary only in 23 | "kernonly" mode) 24 | -------------------------------------------------------------------------------- /lib/libbmk_core/Makefile: -------------------------------------------------------------------------------- 1 | LIB= bmk_core 2 | LIBISPRIVATE= # defined 3 | 4 | SRCS= init.c bmk_string.c jsmn.c memalloc.c pgalloc.c sched.c 5 | SRCS+= subr_prf.c strtoul.c 6 | 7 | # kernel-level source code 8 | CFLAGS+= -fno-stack-protector 9 | 10 | CPPFLAGS+= -I${.CURDIR}/../../include 11 | 12 | .include "${.CURDIR}/arch/${MACHINE_ARCH}/Makefile.inc" 13 | 14 | .include 15 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/earm/Makefile.inc: -------------------------------------------------------------------------------- 1 | MYDIR:= ${.PARSEDIR} 2 | .PATH: ${MYDIR} 3 | 4 | SRCS+= cpu_sched_switch.S __aeabi_read_tp.S 5 | SRCS+= cpu_sched.c 6 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/earm/__aeabi_read_tp.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | /* Should use cp15 */ 29 | 30 | ENTRY(__aeabi_read_tp) 31 | ldr r0, =bmk_cpu_arm_curtcb 32 | ldr r0, [r0] 33 | bx lr 34 | END(__aeabi_read_tp) 35 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/earm/cpu_sched_switch.S: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | ENTRY(bmk_cpu_sched_bouncer) 29 | pop {r1, r0} /* pop function and argument */ 30 | mov lr, pc 31 | bx r1 32 | bl bmk_sched_exit 33 | END(bmk_cpu_sched_bouncer) 34 | 35 | /* 36 | * r0 = previous thread 37 | * r1 = new thread 38 | */ 39 | ENTRY(bmk_cpu_sched_switch) 40 | push {r4-r12,r14} /* save non-scratch regs except sp+pc */ 41 | str sp, [r0, #0] /* save sp */ 42 | ldr sp, [r1, #0] /* restore sp */ 43 | adr r2, 1f /* save pc */ 44 | str r2, [r0, #4] 45 | ldr pc, [r1, #4] /* restore pc */ 46 | 47 | 1: 48 | pop {r4-r12,r14} /* restore registers */ 49 | bx lr 50 | END(bmk_cpu_sched_switch) 51 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/i386/Makefile.inc: -------------------------------------------------------------------------------- 1 | MYDIR:= ${.PARSEDIR} 2 | .PATH: ${MYDIR} 3 | 4 | SRCS+= cpu_sched_switch.S 5 | 6 | .include "${MYDIR}/../x86/Makefile.inc" 7 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/i386/cpu_sched_switch.S: -------------------------------------------------------------------------------- 1 | /*- 2 | **************************************************************************** 3 | * (C) 2005 - Grzegorz Milos - Intel Research Cambridge 4 | **************************************************************************** 5 | * 6 | * File: sched.c 7 | * Author: Grzegorz Milos 8 | * Changes: Robert Kaiser 9 | * 10 | * Date: Aug 2005 11 | * 12 | * Environment: Xen Minimal OS 13 | * Description: simple scheduler for Mini-Os 14 | * 15 | * The scheduler is non-preemptive (cooperative), and schedules according 16 | * to Round Robin algorithm. 17 | * 18 | **************************************************************************** 19 | * Permission is hereby granted, free of charge, to any person obtaining a copy 20 | * of this software and associated documentation files (the "Software"), to 21 | * deal in the Software without restriction, including without limitation the 22 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 23 | * sell copies of the Software, and to permit persons to whom the Software is 24 | * furnished to do so, subject to the following conditions: 25 | * 26 | * The above copyright notice and this permission notice shall be included in 27 | * all copies or substantial portions of the Software. 28 | * 29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 34 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 35 | * DEALINGS IN THE SOFTWARE. 36 | */ 37 | 38 | #include 39 | 40 | ENTRY(bmk_cpu_sched_bouncer) 41 | popl %eax 42 | popl %ebx 43 | pushl $0 44 | xorl %ebp,%ebp 45 | pushl %eax 46 | call *%ebx 47 | call bmk_sched_exit 48 | END(bmk_cpu_sched_bouncer) 49 | 50 | ENTRY(bmk_cpu_sched_switch) 51 | movl 4(%esp), %ecx /* prev */ 52 | movl 8(%esp), %edx /* next */ 53 | 54 | pushl %ebp 55 | pushl %ebx 56 | pushl %esi 57 | pushl %edi 58 | movl %esp, (%ecx) /* save ESP */ 59 | movl (%edx), %esp /* restore ESP */ 60 | movl $1f, 4(%ecx) /* save EIP */ 61 | pushl 4(%edx) /* restore EIP */ 62 | ret 63 | 1: 64 | popl %edi 65 | popl %esi 66 | popl %ebx 67 | popl %ebp 68 | ret 69 | END(bmk_cpu_sched_switch) 70 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/x86/Makefile.inc: -------------------------------------------------------------------------------- 1 | X86DIR:=${.PARSEDIR} 2 | .PATH: ${X86DIR} 3 | 4 | SRCS+= cpu_sched.c 5 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/x86_64/Makefile.inc: -------------------------------------------------------------------------------- 1 | MYDIR:= ${.PARSEDIR} 2 | .PATH: ${MYDIR} 3 | 4 | SRCS+= cpu_sched_switch.S 5 | 6 | .include "${MYDIR}/../x86/Makefile.inc" 7 | -------------------------------------------------------------------------------- /lib/libbmk_core/arch/x86_64/cpu_sched_switch.S: -------------------------------------------------------------------------------- 1 | /*- 2 | **************************************************************************** 3 | * (C) 2005 - Grzegorz Milos - Intel Research Cambridge 4 | **************************************************************************** 5 | * 6 | * File: sched.c 7 | * Author: Grzegorz Milos 8 | * Changes: Robert Kaiser 9 | * 10 | * Date: Aug 2005 11 | * 12 | * Environment: Xen Minimal OS 13 | * Description: simple scheduler for Mini-Os 14 | * 15 | * The scheduler is non-preemptive (cooperative), and schedules according 16 | * to Round Robin algorithm. 17 | * 18 | **************************************************************************** 19 | * Permission is hereby granted, free of charge, to any person obtaining a copy 20 | * of this software and associated documentation files (the "Software"), to 21 | * deal in the Software without restriction, including without limitation the 22 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 23 | * sell copies of the Software, and to permit persons to whom the Software is 24 | * furnished to do so, subject to the following conditions: 25 | * 26 | * The above copyright notice and this permission notice shall be included in 27 | * all copies or substantial portions of the Software. 28 | * 29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 34 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 35 | * DEALINGS IN THE SOFTWARE. 36 | */ 37 | 38 | #include 39 | 40 | ENTRY(bmk_cpu_sched_bouncer) 41 | popq %rdi 42 | popq %rbx 43 | pushq $0 /* correct stack alignment for SSE */ 44 | pushq $0 45 | xorq %rbp,%rbp 46 | call *%rbx 47 | call bmk_sched_exit 48 | END(bmk_cpu_sched_bouncer) 49 | 50 | ENTRY(bmk_cpu_sched_switch) 51 | pushq %rbp 52 | pushq %rbx 53 | pushq %r12 54 | pushq %r13 55 | pushq %r14 56 | pushq %r15 57 | movq %rsp, (%rdi) /* save ESP */ 58 | movq (%rsi), %rsp /* restore ESP */ 59 | movq $1f, 8(%rdi) /* save EIP */ 60 | pushq 8(%rsi) /* restore EIP */ 61 | ret 62 | 1: 63 | popq %r15 64 | popq %r14 65 | popq %r13 66 | popq %r12 67 | popq %rbx 68 | popq %rbp 69 | ret 70 | END(bmk_cpu_sched_switch) 71 | -------------------------------------------------------------------------------- /lib/libbmk_core/init.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | unsigned long bmk_stackpageorder; 32 | unsigned long bmk_stacksize; 33 | 34 | unsigned long bmk_memsize; 35 | 36 | int 37 | bmk_core_init(unsigned long stackpageorder) 38 | { 39 | 40 | bmk_stackpageorder = stackpageorder; 41 | bmk_stacksize = (1< 18 | -------------------------------------------------------------------------------- /lib/libbmk_rumpuser/rumpuser_cons.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #define _BMK_PRINTF_VA 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | void 34 | rumpuser_putchar(int c) 35 | { 36 | 37 | bmk_printf("%c", c); 38 | } 39 | 40 | void 41 | rumpuser_dprintf(const char *fmt, ...) 42 | { 43 | va_list ap; 44 | 45 | va_start(ap, fmt); 46 | bmk_vprintf(fmt, ap); 47 | va_end(ap); 48 | } 49 | -------------------------------------------------------------------------------- /lib/libbmk_rumpuser/rumpuser_stubs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | /* 27 | * Stub implementations for various rump kernel hypercalls that 28 | * are not supported on these platforms. This file should go away 29 | * with the next revision of the rump kernel hypercall interface. 30 | */ 31 | 32 | #include 33 | 34 | int rumpuser_stub_nothing(void); 35 | int rumpuser_stub_nothing(void) {return 0;} 36 | #define NOTHING(name) \ 37 | int name(void) __attribute__((alias("rumpuser_stub_nothing"))); 38 | 39 | int rumpuser_stub_enosys(void); 40 | int rumpuser_stub_enosys(void) {return BMK_ENOSYS;} 41 | #define NOSYS(name) \ 42 | int name(void) __attribute__((alias("rumpuser_stub_enosys"))); 43 | 44 | NOTHING(rumpuser_dl_bootstrap); 45 | 46 | NOSYS(rumpuser_anonmmap); 47 | NOSYS(rumpuser_unmap); 48 | 49 | NOSYS(rumpuser_kill); 50 | 51 | NOSYS(rumpuser_daemonize_begin); 52 | NOSYS(rumpuser_daemonize_done); 53 | 54 | NOSYS(rumpuser_iovread); 55 | NOSYS(rumpuser_iovwrite); 56 | -------------------------------------------------------------------------------- /lib/libcompiler_rt/Makefile: -------------------------------------------------------------------------------- 1 | LIB= compiler_rt 2 | LIBISPRIVATE= # defined 3 | 4 | .include 5 | 6 | CPPFLAGS+=-D_STANDALONE 7 | 8 | .include "${RUMPSRC}/sys/lib/libkern/Makefile.compiler-rt" 9 | .include 10 | -------------------------------------------------------------------------------- /lib/librumpkern_bmktc/Makefile: -------------------------------------------------------------------------------- 1 | .include 2 | 3 | LIB= rumpkern_bmktc 4 | 5 | SRCS+= rump_bmktc.c 6 | 7 | RUMPTOP= ${TOPRUMP} 8 | 9 | RUMPCOMP_USER_SRCS= bmktc_user.c 10 | RUMPCOMP_USER_CPPFLAGS+=-I${.CURDIR}/../../include 11 | 12 | .undef RUMPKERN_ONLY 13 | 14 | .include "${RUMPTOP}/Makefile.rump" 15 | .include 16 | .include 17 | -------------------------------------------------------------------------------- /lib/librumpkern_bmktc/bmktc_user.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include "bmktc_user.h" 29 | 30 | unsigned int 31 | rumpcomp_bmktc_gettime(void) 32 | { 33 | 34 | return (unsigned int)bmk_platform_cpu_clock_monotonic(); 35 | } 36 | -------------------------------------------------------------------------------- /lib/librumpkern_bmktc/bmktc_user.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | unsigned int rumpcomp_bmktc_gettime(void); 27 | -------------------------------------------------------------------------------- /lib/librumpkern_bmktc/rump_bmktc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Martin Lucina. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "bmktc_user.h" 34 | 35 | MODULE(MODULE_CLASS_MISC, bmktc, NULL); 36 | 37 | static u_int 38 | bmktc_get(struct timecounter *tc) 39 | { 40 | 41 | return rumpcomp_bmktc_gettime(); 42 | } 43 | 44 | static struct timecounter bmktc = { 45 | .tc_get_timecount = bmktc_get, 46 | .tc_poll_pps = NULL, 47 | .tc_counter_mask = ~0, 48 | .tc_frequency = 1000000000ULL, 49 | .tc_name = "bmktc", 50 | .tc_quality = 100, 51 | }; 52 | 53 | static int 54 | bmktc_modcmd(modcmd_t cmd, void *arg) 55 | { 56 | 57 | switch (cmd) { 58 | case MODULE_CMD_INIT: 59 | tc_init(&bmktc); 60 | break; 61 | 62 | case MODULE_CMD_FINI: 63 | tc_detach(&bmktc); 64 | break; 65 | 66 | default: 67 | return ENOTTY; 68 | } 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /lib/librumpkern_mman/Makefile: -------------------------------------------------------------------------------- 1 | .include 2 | 3 | LIB= rumpkern_mman 4 | 5 | SRCS+= sys_mman.c mman_component.c 6 | 7 | RUMPTOP= ${TOPRUMP} 8 | 9 | CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern 10 | 11 | .include "${RUMPTOP}/Makefile.rump" 12 | .include 13 | .include 14 | -------------------------------------------------------------------------------- /lib/librumpkern_mman/mman_component.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2016 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include "rump_private.h" 30 | 31 | extern sy_call_t sys_mmap; 32 | extern sy_call_t sys_munmap; 33 | extern sy_call_t sys___msync13; 34 | extern sy_call_t sys_mincore; 35 | extern sy_call_t sys_madvise; 36 | extern sy_call_t sys_mprotect; 37 | extern sy_call_t sys_mlock; 38 | extern sy_call_t sys_mlockall; 39 | extern sy_call_t sys_munlock; 40 | extern sy_call_t sys_munlockall; 41 | 42 | #define ENTRY(name) { SYS_##name, sys_##name }, 43 | static const struct rump_onesyscall mysys[] = { 44 | ENTRY(mmap) 45 | ENTRY(munmap) 46 | ENTRY(__msync13) 47 | ENTRY(mincore) 48 | ENTRY(mprotect) 49 | ENTRY(mlock) 50 | ENTRY(mlockall) 51 | ENTRY(munlock) 52 | ENTRY(munlockall) 53 | }; 54 | #undef ENTRY 55 | 56 | RUMP_COMPONENT(RUMP_COMPONENT_SYSCALL) 57 | { 58 | 59 | rump_syscall_boot_establish(mysys, __arraycount(mysys)); 60 | } 61 | -------------------------------------------------------------------------------- /lib/librumprun_base/Makefile: -------------------------------------------------------------------------------- 1 | LIB= rumprun_base 2 | 3 | SRCS= main.c rumprun.c 4 | SRCS+= parseargs.c config.c 5 | SRCS+= malloc.c netbsd_initfini.c signals.c 6 | SRCS+= syscall_mman.c syscall_misc.c 7 | SRCS+= __errno.c _lwp.c libc_stubs.c 8 | SRCS+= daemon.c 9 | SRCS+= sysproxy.c 10 | 11 | # doesn't really belong here, but at the moment we don't have 12 | # a rumpkernel-only "userspace" lib 13 | SRCS+= platefs.c 14 | 15 | INCS= platefs.h 16 | INCSDIR= /usr/include/rumprun 17 | 18 | WARNS= 5 19 | 20 | CPPFLAGS+= -I${.CURDIR}/../../include 21 | CPPFLAGS+= -D_KERNTYPES 22 | 23 | .include 24 | -------------------------------------------------------------------------------- /lib/librumprun_base/__errno.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #undef __errno 28 | 29 | #include 30 | 31 | int * 32 | __errno(void) 33 | { 34 | 35 | return bmk_sched_geterrno(); 36 | } 37 | -------------------------------------------------------------------------------- /lib/librumprun_base/daemon.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: daemon.c,v 1.10 2012/06/25 22:32:43 abs Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1990, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the University nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | /* 33 | * NetBSD libc daemon, modified to use rumprun_daemon() instead of fork() 34 | */ 35 | 36 | #define daemon _daemon 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include 44 | 45 | __weak_alias(daemon,_daemon) 46 | 47 | int 48 | daemon(int nochdir, int noclose) 49 | { 50 | int fd; 51 | 52 | if (setsid() == -1) 53 | return (-1); 54 | 55 | if (!nochdir) 56 | (void)chdir("/"); 57 | 58 | if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { 59 | (void)dup2(fd, STDIN_FILENO); 60 | (void)dup2(fd, STDOUT_FILENO); 61 | (void)dup2(fd, STDERR_FILENO); 62 | if (fd > STDERR_FILENO) 63 | (void)close(fd); 64 | } 65 | 66 | rumprun_daemon(); 67 | 68 | return (0); 69 | } 70 | -------------------------------------------------------------------------------- /lib/librumprun_base/malloc.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | int 34 | posix_memalign(void **rv, size_t align, size_t nbytes) 35 | { 36 | void *v; 37 | int error = BMK_ENOMEM; 38 | 39 | if ((v = bmk_memalloc(nbytes, align, BMK_MEMWHO_USER)) != NULL) { 40 | *rv = v; 41 | error = 0; 42 | } 43 | 44 | return error; 45 | } 46 | 47 | void * 48 | malloc(size_t size) 49 | { 50 | 51 | return bmk_memalloc(size, 8, BMK_MEMWHO_USER); 52 | } 53 | 54 | void * 55 | calloc(size_t n, size_t size) 56 | { 57 | 58 | return bmk_memcalloc(n, size, BMK_MEMWHO_USER); 59 | } 60 | 61 | void * 62 | realloc(void *cp, size_t nbytes) 63 | { 64 | 65 | return bmk_memrealloc_user(cp, nbytes); 66 | } 67 | 68 | void 69 | free(void *cp) 70 | { 71 | 72 | bmk_memfree(cp, BMK_MEMWHO_USER); 73 | } 74 | -------------------------------------------------------------------------------- /lib/librumprun_base/parseargs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Citrix. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | void 29 | rumprun_parseargs(char *p, int *nargs, char **outarray) 30 | { 31 | char *out = 0; 32 | int quote = -1; /* -1 means outside arg, 0 or '"' or '\'' inside */ 33 | 34 | *nargs = 0; 35 | 36 | for (;;) { 37 | int ac = *p++; 38 | int rc = ac; 39 | if (ac == '\\') 40 | rc = *p++; 41 | if (!rc || ac==' ' || ac=='\n' || ac=='\t') { 42 | /* any kind of delimiter */ 43 | if (!rc || quote==0) { 44 | /* ending an argument */ 45 | if (out) 46 | *out++ = 0; 47 | quote = -1; 48 | } 49 | if (!rc) 50 | /* definitely quit then */ 51 | break; 52 | if (quote<0) 53 | /* not in an argument now */ 54 | continue; 55 | } 56 | if (quote<0) { 57 | /* starting an argument */ 58 | if (outarray) 59 | outarray[*nargs] = out = p-1; 60 | (*nargs)++; 61 | quote = 0; 62 | } 63 | if (quote > 0 && ac == quote) { 64 | quote = 0; 65 | continue; 66 | } 67 | if (ac == '\'' || ac == '"') { 68 | quote = ac; 69 | continue; 70 | } 71 | if (out) 72 | *out++ = rc; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/librumprun_base/platefs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2016 Antti Kantee 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 15 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | void 39 | rumprun_platefs(const char **dirs, size_t ndirs, 40 | struct rumprun_extfile *refs, size_t nrefs) 41 | { 42 | unsigned i; 43 | int fd; 44 | 45 | for (i = 0; i < ndirs; i++) { 46 | if (rump_sys_mkdir(dirs[i], 0777) == -1) { 47 | if (*bmk_sched_geterrno() != RUMP_EEXIST) 48 | bmk_platform_halt("platefs: mkdir"); 49 | } 50 | } 51 | 52 | 53 | for (i = 0; i < nrefs; i++) { 54 | if ((fd = rump_sys_open(refs[i].ref_fname, 55 | RUMP_O_CREAT | RUMP_O_RDWR | RUMP_O_EXCL, 0777)) == -1) 56 | bmk_platform_halt("platefs: open"); 57 | if (rump_sys_fcntl(fd, RUMPFS_FCNTL_EXTSTORAGE_ADD, 58 | &refs[i].ref_es) == -1) 59 | bmk_platform_halt("platefs: fcntl"); 60 | rump_sys_close(fd); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/librumprun_base/platefs.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2016 Antti Kantee 3 | * All Rights Reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 15 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | * SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _RUMPRUN_GENFS_H_ 28 | #define _RUMPRUN_GENFS_H_ 29 | 30 | #include 31 | 32 | struct rumprun_extfile { 33 | const char *ref_fname; 34 | struct rumpfs_extstorage ref_es; 35 | }; 36 | 37 | void rumprun_platefs(const char **, size_t, 38 | struct rumprun_extfile *, size_t); 39 | 40 | #endif /* _RUMPRUN_GENFS_H_ */ 41 | -------------------------------------------------------------------------------- /lib/librumprun_base/pthread/pthread_makelwp_rumprun.c: -------------------------------------------------------------------------------- 1 | #include "pthread_makelwp.h" 2 | 3 | #include 4 | 5 | int 6 | pthread__makelwp(void (*start)(void *), void *arg, void *private, 7 | void *stack_base, size_t stack_size, unsigned long flags, lwpid_t *lid) 8 | { 9 | 10 | return rumprun_makelwp(start, arg, private, 11 | stack_base, stack_size, flags, lid); 12 | } 13 | -------------------------------------------------------------------------------- /lib/librumprun_base/rumprun-private.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _RUMPRUN_BASE_RUMPRUN_PRIVATE_H_ 27 | #define _RUMPRUN_BASE_RUMPRUN_PRIVATE_H_ 28 | 29 | void _netbsd_userlevel_init(void); 30 | void _netbsd_userlevel_fini(void); 31 | 32 | void rumprun_lwp_init(void); 33 | 34 | #endif /* _RUMPRUN_BASE_RUMPRUN_PRIVATE_H_ */ 35 | -------------------------------------------------------------------------------- /lib/librumprun_tester/Makefile: -------------------------------------------------------------------------------- 1 | LIB= rumprun_tester 2 | INCS= tester.h 3 | INCSDIR= /usr/include/rumprun 4 | 5 | SRCS= rumprun_tester.c 6 | 7 | .include 8 | -------------------------------------------------------------------------------- /lib/librumprun_tester/tester.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef _BMK_BASE_RUMPRUN_TEST_H_ 27 | #define _BMK_BASE_RUMPRUN_TEST_H_ 28 | 29 | #include 30 | 31 | __BEGIN_DECLS 32 | int rumprun_test(int, char **); 33 | __END_DECLS 34 | 35 | #endif /* _BMK_BASE_RUMPRUN_TEST_H_ */ 36 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/Makefile: -------------------------------------------------------------------------------- 1 | # XXX: this Makefile is built with rumpmake 2 | 3 | include ${RUMPRUN_MKCONF} 4 | include ${BUILDRUMP_TOOLFLAGS} 5 | 6 | obj: 7 | mkdir -p ${MAKEOBJDIR} 8 | 9 | includes: 10 | 11 | dependall: 12 | ( cd ${.CURDIR} && \ 13 | RUMPRUN_COOKFS_CC="${CC}" \ 14 | RUMPRUN_COOKFS_OBJCOPY="${OBJCOPY}" \ 15 | RUMPRUN_COOKFS_SIZE="${SIZE}" \ 16 | RUMPRUN_COOKFS_INCDIR="${RROBJ}/dest.stage/include" \ 17 | ${RROBJ}/app-tools/${TOOLTUPLE}-cookfs -s 1 \ 18 | ${MAKEOBJDIR}/librumprunfs_base.a rootfs ) 19 | 20 | install: 21 | mkdir -p ${DESTDIR}/share/rumprun/rumprunfs_base 22 | ( cd ${.CURDIR}/rootfs ; tar -cf - . ) \ 23 | | ( cd ${DESTDIR}/share/rumprun/rumprunfs_base ; tar -xf - ) 24 | install -m 444 ${MAKEOBJDIR}/librumprunfs_base.a ${LIBDIR} 25 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/group: -------------------------------------------------------------------------------- 1 | daemon:x:1: 2 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/hosts: -------------------------------------------------------------------------------- 1 | 127.0.0.1 localhost localhost. 2 | :1 localhost localhost. 3 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/master.passwd: -------------------------------------------------------------------------------- 1 | root:*:0:0::0:0:Charlie &:/:/thereisnoshell 2 | daemon:*:1:1::0:0:The devil himself:/:/thereisnoshell 3 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/nsswitch.conf: -------------------------------------------------------------------------------- 1 | # $NetBSD: nsswitch.conf,v 1.6 2009/10/25 00:17:06 tsarna Exp $ 2 | # 3 | # nsswitch.conf(5) - 4 | # name service switch configuration file 5 | # 6 | 7 | 8 | # These are the defaults in libc 9 | # 10 | group: compat 11 | group_compat: nis 12 | hosts: files dns 13 | netgroup: files [notfound=return] nis 14 | networks: files 15 | passwd: compat 16 | passwd_compat: nis 17 | shells: files 18 | 19 | 20 | # List of supported sources for each database 21 | # 22 | # group: compat, dns, files, nis 23 | # group_compat: dns, nis 24 | # hosts: dns, files, nis, mdnsd, multicast_dns 25 | # netgroup: files, nis 26 | # networks: dns, files, nis 27 | # passwd: compat, dns, files, nis 28 | # passwd_compat: dns, nis 29 | # shells: dns, files, nis 30 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/pwd.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rumpkernel/rumprun/b04d42225a12a6fae57a78a9c1cf23642e46cd00/lib/librumprunfs_base/rootfs/etc/pwd.db -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/resolv.conf: -------------------------------------------------------------------------------- 1 | # Edit resolver info below. 2 | # 3 | # NOTE: the Rumprun DHCP client does not currently generate 4 | # this file, so if you want DNS to work, you even in DHCP scenarios 5 | # you *MUST* include the nameserver here. 6 | # (yes, the DHCP client should be fixed, but that's another story) 7 | 8 | # nameserver 1.2.3.4 9 | -------------------------------------------------------------------------------- /lib/librumprunfs_base/rootfs/etc/spwd.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rumpkernel/rumprun/b04d42225a12a6fae57a78a9c1cf23642e46cd00/lib/librumprunfs_base/rootfs/etc/spwd.db -------------------------------------------------------------------------------- /lib/libunwind/Makefile: -------------------------------------------------------------------------------- 1 | .include 2 | 3 | RUMPTOP= ${TOPRUMP} 4 | 5 | LIB= unwind 6 | INCSDIR=/usr/include 7 | 8 | CPPFLAGS+= -isystem ${DESTDIR}/usr/include/c++ 9 | 10 | LIBC_MACHINE_CPU?= ${MACHINE_CPU} 11 | .include "${RUMPTOP}/../lib/libunwind/Makefile.inc" 12 | 13 | .include 14 | -------------------------------------------------------------------------------- /platform/hw/Makefile: -------------------------------------------------------------------------------- 1 | include ../../global.mk 2 | include ${BUILDRUMP_TOOLFLAGS} 3 | 4 | default: all 5 | 6 | # Check if we're building for a supported target. 7 | supported= false 8 | # assume we're doing "make clean" 9 | MACHINE?= i386 10 | ifeq (${MACHINE},i386) 11 | HW_MACHINE_ARCH=i386 12 | supported:= true 13 | endif 14 | ifeq (${MACHINE},amd64) 15 | supported:= true 16 | endif 17 | ifeq (${MACHINE},evbarm) 18 | supported:= true 19 | ARCHDIR= arm/integrator 20 | endif 21 | ifneq (${supported},true) 22 | $(error only supported target is x86, you have ${MACHINE}) 23 | endif 24 | 25 | ARCHDIR?= ${MACHINE} 26 | HW_MACHINE_ARCH?= ${MACHINE_GNU_ARCH} 27 | 28 | LDSCRIPT:= $(abspath arch/${ARCHDIR}/kern.ldscript) 29 | SRCS+= intr.c clock_subr.c kernel.c multiboot.c undefs.c 30 | 31 | include ../Makefile.inc 32 | include arch/${ARCHDIR}/Makefile.inc 33 | 34 | # Disable PIE, but need to check if compiler supports it 35 | LDFLAGS-$(call cc-option,-no-pie) += -no-pie 36 | LDFLAGS += $(LDFLAGS-y) 37 | 38 | OBJS:= $(patsubst %.c,${RROBJ}/platform/%.o,${SRCS}) \ 39 | $(patsubst %.S,${RROBJ}/platform/%.o,${ASMS}) 40 | 41 | .PHONY: clean cleandir all 42 | 43 | all: links archdirs ${MAINOBJ} ${TARGETS} 44 | 45 | ${RROBJ}/include/hw/machine: 46 | @mkdir -p ${RROBJ}/include/hw 47 | @ln -sf $(shell pwd)/include/arch/${HW_MACHINE_ARCH} $@ 48 | 49 | ${RROBJ}/include/bmk-pcpu: 50 | @ln -sf ${RROBJ}/include/hw/machine $@ 51 | 52 | links: ${RROBJ}/include/hw/machine ${RROBJ}/include/bmk-pcpu 53 | 54 | ${RROBJ}/platform/%.o: %.c 55 | ${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@ 56 | 57 | ${RROBJ}/platform/%.o: %.S 58 | ${CC} -D_LOCORE ${CPPFLAGS} ${CFLAGS} -c $< -o $@ 59 | 60 | ${MAINOBJ}: ${OBJS} platformlibs 61 | ${CC} -nostdlib ${CFLAGS} ${LDFLAGS} -Wl,-r ${OBJS} -o $@ \ 62 | -L${RROBJLIB}/libbmk_core -L${RROBJLIB}/libbmk_rumpuser \ 63 | -Wl,--whole-archive -lbmk_rumpuser -lbmk_core -Wl,--no-whole-archive 64 | ${OBJCOPY} -w -G bmk_* -G rumpuser_* -G jsmn_* \ 65 | -G rumprun_platform_rumpuser_init -G _start $@ 66 | 67 | clean: commonclean 68 | rm -f ${OBJS_BMK} include/hw/machine buildtest ${MAINOBJ} 69 | 70 | cleandir: clean 71 | -------------------------------------------------------------------------------- /platform/hw/arch/amd64/Makefile.inc: -------------------------------------------------------------------------------- 1 | ASMS= arch/amd64/locore.S arch/amd64/intr.S 2 | SRCS+= arch/amd64/machdep.c 3 | 4 | SRCS+= arch/x86/boot.c 5 | SRCS+= arch/x86/cons.c arch/x86/vgacons.c arch/x86/serialcons.c 6 | SRCS+= arch/x86/cpu_subr.c 7 | SRCS+= arch/x86/x86_subr.c 8 | SRCS+= arch/x86/clock.c 9 | SRCS+= arch/x86/hypervisor.c 10 | 11 | CFLAGS+= -mno-sse -mno-mmx 12 | 13 | # squash all interrupts to a single level to 14 | # avoid having to figure out routing 15 | CFLAGS+= -DBMK_SCREW_INTERRUPT_ROUTING 16 | 17 | .PHONY: archdirs 18 | archdirs: 19 | mkdir -p ${RROBJ}/platform/arch/amd64 20 | mkdir -p ${RROBJ}/platform/arch/x86 21 | -------------------------------------------------------------------------------- /platform/hw/arch/amd64/kern.ldscript: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 2 | OUTPUT_ARCH(i386:x86-64) 3 | ENTRY(_start) 4 | 5 | SECTIONS 6 | { 7 | . = 0x100000; 8 | _begin = . ; 9 | 10 | .bootstrap : 11 | { 12 | *(.bootstrap) 13 | } 14 | 15 | . = ALIGN(0x1000); 16 | 17 | .text : 18 | AT (ADDR(.text)) 19 | { 20 | *(.text) 21 | *(.text.*) 22 | *(.stub) 23 | *(.note*) 24 | } 25 | _etext = . ; 26 | 27 | .rodata : 28 | AT (LOADADDR(.text) + (ADDR(.rodata) - ADDR(.text))) 29 | { 30 | *(.rodata) 31 | *(.rodata.*) 32 | } 33 | 34 | .initfini : 35 | AT (LOADADDR(.text) + (ADDR(.initfini) - ADDR(.text))) 36 | { 37 | __init_array_start = . ; 38 | *(SORT_BY_INIT_PRIORITY(.init_array.*)) 39 | *(SORT_BY_INIT_PRIORITY(.ctors*)) 40 | *(.init_array) 41 | __init_array_end = . ; 42 | __fini_array_start = . ; 43 | *(SORT_BY_INIT_PRIORITY(.fini_array.*)) 44 | *(SORT_BY_INIT_PRIORITY(.dtors*)) 45 | *(.fini_array) 46 | __fini_array_end = . ; 47 | } 48 | 49 | . = ALIGN(0x1000); 50 | 51 | _data_start = .; 52 | .data : 53 | AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text))) 54 | { 55 | *(.data) 56 | *(.data.*) 57 | } 58 | .tdata : { 59 | _tdata_start = . ; 60 | *(.tdata) 61 | _tdata_end = . ; 62 | } 63 | _edata = . ; 64 | .tbss : { 65 | _tbss_start = . ; 66 | *(.tbss) 67 | _tbss_end = . ; 68 | } 69 | 70 | __bss_start = . ; 71 | .bss : 72 | AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text))) 73 | { 74 | *(.bss) 75 | *(.bss.*) 76 | *(COMMON) 77 | } 78 | .lbss : 79 | AT (LOADADDR(.text) + (ADDR(.lbss) - ADDR(.text))) 80 | { 81 | *(.lbss) 82 | *(.lbss.*) 83 | *(LARGE_COMMON) 84 | } 85 | _ebss = . ; 86 | _end = . ; 87 | } 88 | -------------------------------------------------------------------------------- /platform/hw/arch/amd64/makepagetable.awk: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env awk -f 2 | 3 | # build page tables. easier doing it like this than in assembly. 4 | # we might actually want the page tables to reflect reality some 5 | # day (e.g. mapping text r/o), but for now we don't care. 6 | 7 | BEGIN { 8 | MAXGIGS=512 9 | MINGIGS=4 10 | 11 | if (mapgigs == 0) 12 | mapgigs = MINGIGS 13 | if (mapgigs < MINGIGS) { 14 | printf("currently need min 4G for mmio space, you want %d\n", \ 15 | MINGIGS, mapgigs) | "cat 1>&2"; 16 | exit(1); 17 | } 18 | if (mapgigs > MAXGIGS) { 19 | printf("up to %dG supported, you have %d\n", \ 20 | MAXGIGS, mapgigs) | "cat 1>&2"; 21 | exit(1); 22 | } 23 | 24 | PG_VALID = 0x001 25 | PG_RW = 0x002 26 | PG_PS = 0x080 27 | PG_GLOBAL= 0x100 28 | PG_FORALL= PG_VALID + PG_RW; 29 | 30 | TWOMEGS = 0x200000 31 | 32 | printf("/* AUTOMATICALLY GENERATED BY makepagetables.awk */\n\n"); 33 | 34 | # first level, only used for lowest 2MB, with 0 unmapped 35 | printf(".align 0x1000\ncpu_pt0:\n"); 36 | printf("\t.quad 0x0\n"); 37 | addr = 0x1000 38 | for (i = 0; i < 0x1ff; i++) { 39 | printf("\t.quad 0x%x + 0x%x\n", addr, PG_FORALL); 40 | addr += 0x1000 41 | } 42 | 43 | # second level, page directories, need full one per gig 44 | for (i = 0; i < mapgigs; i++) { 45 | printf("\n.align 0x1000\ncpu_pd%d:\n", i); 46 | addr = i*512*TWOMEGS 47 | if (i == 0) { 48 | printf("\t.quad cpu_pt0 + 0%x\n", PG_FORALL); 49 | j = 1 50 | addr += TWOMEGS 51 | } else { 52 | j = 0 53 | } 54 | for (; j < 0x200; j++) { 55 | printf("\t.quad 0x%016x + 0x%x + 0x%x\n", \ 56 | addr, PG_FORALL, PG_PS); 57 | addr += TWOMEGS 58 | } 59 | } 60 | 61 | # third level, page directory pointer tables, need only one for now 62 | printf("\n.align 0x1000\ncpu_pdpt:\n"); 63 | for (i = 0; i < mapgigs; i++) { 64 | printf("\t.quad cpu_pd%d + 0x%x\n", i, PG_FORALL); 65 | } 66 | if (mapgigs != MAXGIGS) { 67 | printf("\t.fill 0x%x, 0x8, 0x0\n", MAXGIGS-mapgigs); 68 | } 69 | 70 | # and finally, lessons in hate from page map level 42 71 | printf("\n.align 0x1000\ncpu_pml4:\n"); 72 | printf("\t.quad cpu_pdpt + 0x%x\n", PG_FORALL); 73 | printf("\t.fill 0x1ff, 0x8, 0x0\n"); 74 | } 75 | -------------------------------------------------------------------------------- /platform/hw/arch/arm/integrator/Makefile.inc: -------------------------------------------------------------------------------- 1 | ASMS= arch/arm/integrator/locore.S 2 | 3 | SRCS+= arch/arm/integrator/machdep.c 4 | SRCS+= arch/arm/integrator/serialcons.c 5 | 6 | CPPFLAGS+= -Iarch/arm 7 | 8 | .PHONY: archdirs 9 | archdirs: 10 | mkdir -p ${RROBJ}/platform/arch/arm/integrator 11 | -------------------------------------------------------------------------------- /platform/hw/arch/arm/integrator/boardreg.h: -------------------------------------------------------------------------------- 1 | #define UART0 0x16000000 /* uart address */ 2 | 3 | #define UARTDR 0x0000 /* data register */ 4 | #define UARTFR 0x0018 /* flag register */ 5 | 6 | #define UARTFR_TXFE 0x80 /* fifo empty */ 7 | 8 | 9 | #define TMR1 0x13000100 /* timer base address */ 10 | #define TMR2 0x13000200 /* timer base address */ 11 | 12 | #define TMR1_LOAD TMR1 + 0x00 /* load value to decrement */ 13 | #define TMR1_VALUE TMR1 + 0x04 /* current value */ 14 | #define TMR1_CTRL TMR1 + 0x08 /* control register */ 15 | #define TMR1_CLRINT TMR1 + 0x0c /* clear interrupt by writing here */ 16 | 17 | #define TMR2_LOAD TMR2 + 0x00 /* load value to decrement */ 18 | #define TMR2_VALUE TMR2 + 0x04 /* current value */ 19 | #define TMR2_CTRL TMR2 + 0x08 /* control register */ 20 | #define TMR2_CLRINT TMR2 + 0x0c /* clear interrupt by writing here */ 21 | 22 | #define TMR_CTRL_EN 0x80 /* timer enabled */ 23 | #define TMR_CTRL_PER 0x40 /* periodic (loop to value) */ 24 | #define TMR_CTRL_IE 0x20 /* interrupt enable */ 25 | #define TMR_CTRL_D256 0x08 /* divide clock by 256 */ 26 | #define TMR_CTRL_D16 0x04 /* divide clock by 16 */ 27 | #define TMR_CTRL_32 0x02 /* 16/32bit timer */ 28 | 29 | 30 | #define INTR_BASE 0x14000000 /* irq control base */ 31 | 32 | #define INTR_STATUS INTR_BASE + 0x0 /* current status */ 33 | #define INTR_ENABLE INTR_BASE + 0x8 /* enable irqs */ 34 | #define INTR_CLEAR INTR_BASE + 0xc /* clear irqs */ 35 | 36 | #define CM_SDRAM 0x10000020 /* sdram control register */ 37 | -------------------------------------------------------------------------------- /platform/hw/arch/arm/integrator/kern.ldscript: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(arm) 2 | ENTRY(_start) 3 | SECTIONS 4 | { 5 | . = 1m; 6 | _begin = . ; 7 | .text : 8 | AT (ADDR(.text) & 0x0fffffff) 9 | { 10 | *(.start) 11 | *(.text) 12 | *(.text.*) 13 | *(.stub) 14 | *(.note*) 15 | } 16 | _etext = . ; 17 | 18 | .rodata : 19 | AT (LOADADDR(.text) + (ADDR(.rodata) - ADDR(.text))) 20 | { 21 | *(.rodata) 22 | *(.rodata.*) 23 | } 24 | 25 | .initfini : 26 | AT (LOADADDR(.text) + (ADDR(.initfini) - ADDR(.text))) 27 | { 28 | __init_array_start = . ; 29 | *(SORT_BY_INIT_PRIORITY(.init_array.*)) 30 | *(SORT_BY_INIT_PRIORITY(.ctors*)) 31 | *(.init_array) 32 | __init_array_end = . ; 33 | __fini_array_start = . ; 34 | *(SORT_BY_INIT_PRIORITY(.fini_array.*)) 35 | *(SORT_BY_INIT_PRIORITY(.dtors*)) 36 | *(.fini_array) 37 | __fini_array_end = . ; 38 | } 39 | 40 | _data_start = .; 41 | .data : 42 | AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text))) 43 | { 44 | *(.data) 45 | } 46 | _edata = . ; 47 | 48 | .tdata : 49 | AT (LOADADDR(.text) + (ADDR(.tdata) - ADDR(.text))) 50 | { 51 | _tdata_start = . ; 52 | *(.tdata) 53 | _tdata_end = . ; 54 | } 55 | 56 | .tbss : 57 | AT (LOADADDR(.text) + (ADDR(.tbss) - ADDR(.text))) 58 | { 59 | _tbss_start = . ; 60 | *(.tbss) 61 | _tbss_end = . ; 62 | } 63 | 64 | __bss_start = . ; 65 | .bss : 66 | AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text))) 67 | { 68 | *(.bss) 69 | *(.bss.*) 70 | *(COMMON) 71 | *(.bootstack) 72 | } 73 | _end = . ; 74 | PROVIDE (end = .) ; 75 | } 76 | -------------------------------------------------------------------------------- /platform/hw/arch/arm/integrator/serialcons.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | /* 32 | * Since this is serial, unlike in a framebuffer console, 33 | * we can just write a character and that's it. NetBSD seems to use 34 | * a scheme where it waits for the FIFO to be empty before writing to 35 | * it, and also after writing to it. Not sure why you need to wait 36 | * after writing. Therefore, we just wait before writing. 37 | */ 38 | void 39 | cons_putc(int c) 40 | { 41 | volatile uint8_t *const uartdr = (uint8_t *)(UART0 + UARTDR); 42 | volatile uint16_t *const uartfr = (uint16_t *)(UART0 + UARTFR); 43 | int timo; 44 | unsigned char cw = c; 45 | 46 | timo = 150000; /* magic value from NetBSD */ 47 | while (!(*uartfr & UARTFR_TXFE) && --timo) 48 | continue; 49 | 50 | *uartdr = cw; 51 | } 52 | 53 | void 54 | cons_puts(const char *s) 55 | { 56 | int c; 57 | 58 | while ((c = *s++) != 0) 59 | cons_putc(c); 60 | } 61 | -------------------------------------------------------------------------------- /platform/hw/arch/i386/Makefile.inc: -------------------------------------------------------------------------------- 1 | ASMS= arch/i386/locore.S 2 | 3 | SRCS+= arch/i386/machdep.c 4 | 5 | SRCS+= arch/x86/boot.c 6 | SRCS+= arch/x86/cons.c arch/x86/vgacons.c arch/x86/serialcons.c 7 | SRCS+= arch/x86/cpu_subr.c 8 | SRCS+= arch/x86/x86_subr.c 9 | SRCS+= arch/x86/clock.c 10 | SRCS+= arch/x86/hypervisor.c 11 | 12 | CFLAGS+= -mno-sse -mno-mmx -march=i686 13 | 14 | .PHONY: archdirs 15 | archdirs: 16 | mkdir -p ${RROBJ}/platform/arch/i386 17 | mkdir -p ${RROBJ}/platform/arch/x86 18 | -------------------------------------------------------------------------------- /platform/hw/arch/i386/kern.ldscript: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 2 | OUTPUT_ARCH(i386) 3 | ENTRY(_start) 4 | SECTIONS 5 | { 6 | . = 1m; 7 | _begin = . ; 8 | .text : 9 | AT (ADDR(.text) & 0x0fffffff) 10 | { 11 | *(.multiboot) 12 | *(.text) 13 | *(.text.*) 14 | *(.stub) 15 | *(.note*) 16 | } 17 | _etext = . ; 18 | 19 | .rodata : 20 | AT (LOADADDR(.text) + (ADDR(.rodata) - ADDR(.text))) 21 | { 22 | *(.rodata) 23 | *(.rodata.*) 24 | } 25 | 26 | .initfini : 27 | AT (LOADADDR(.text) + (ADDR(.initfini) - ADDR(.text))) 28 | { 29 | __init_array_start = . ; 30 | *(SORT_BY_INIT_PRIORITY(.init_array.*)) 31 | *(SORT_BY_INIT_PRIORITY(.ctors*)) 32 | *(.init_array) 33 | __init_array_end = . ; 34 | __fini_array_start = . ; 35 | *(SORT_BY_INIT_PRIORITY(.fini_array.*)) 36 | *(SORT_BY_INIT_PRIORITY(.dtors*)) 37 | *(.fini_array) 38 | __fini_array_end = . ; 39 | } 40 | 41 | _data_start = .; 42 | .data : 43 | AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text))) 44 | { 45 | *(.data) 46 | } 47 | _edata = . ; 48 | 49 | .tdata : 50 | AT (LOADADDR(.text) + (ADDR(.tdata) - ADDR(.text))) 51 | { 52 | _tdata_start = . ; 53 | *(.tdata) 54 | _tdata_end = . ; 55 | } 56 | 57 | .tbss : 58 | AT (LOADADDR(.text) + (ADDR(.tbss) - ADDR(.text))) 59 | { 60 | _tbss_start = . ; 61 | *(.tbss) 62 | _tbss_end = . ; 63 | } 64 | 65 | __bss_start = . ; 66 | .bss : 67 | AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text))) 68 | { 69 | *(.bss) 70 | *(.bss.*) 71 | *(COMMON) 72 | *(.bootstack) 73 | } 74 | .lbss : 75 | AT (LOADADDR(.text) + (ADDR(.lbss) - ADDR(.text))) 76 | { 77 | *(.lbss) 78 | *(.lbss.*) 79 | *(LARGE_COMMON) 80 | } 81 | _end = . ; 82 | PROVIDE (end = .) ; 83 | } 84 | -------------------------------------------------------------------------------- /platform/hw/arch/x86/boot.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | void 36 | x86_boot(struct multiboot_info *mbi) 37 | { 38 | 39 | cons_init(); 40 | bmk_printf("rump kernel bare metal bootstrap\n\n"); 41 | 42 | cpu_init(); 43 | bmk_sched_init(); 44 | multiboot(mbi); 45 | 46 | spl0(); 47 | 48 | bmk_sched_startmain(bmk_mainthread, multiboot_cmdline); 49 | } 50 | -------------------------------------------------------------------------------- /platform/hw/arch/x86/cons.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Martin Lucina. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | static void (*vcons_putc)(int) = vgacons_putc; 35 | 36 | /* 37 | * Filled in by locore from BIOS data area. 38 | */ 39 | uint16_t bios_com1_base, bios_crtc_base; 40 | 41 | void 42 | cons_init(void) 43 | { 44 | int prefer_serial = 0; 45 | int hypervisor; 46 | 47 | hypervisor = hypervisor_detect(); 48 | 49 | /* 50 | * If running under Xen use the serial console. 51 | */ 52 | if (hypervisor == HYPERVISOR_XEN) 53 | prefer_serial = 1; 54 | 55 | /* 56 | * If the BIOS says no CRTC is present use the serial console if 57 | * available. 58 | */ 59 | if (bios_crtc_base == 0) 60 | prefer_serial = 1; 61 | 62 | if (prefer_serial && bios_com1_base != 0) { 63 | cons_puts("Using serial console."); 64 | serialcons_init(bios_com1_base, 115200); 65 | vcons_putc = serialcons_putc; 66 | } 67 | bmk_printf_init(vcons_putc, NULL); 68 | } 69 | 70 | void 71 | cons_putc(int c) 72 | { 73 | 74 | vcons_putc(c); 75 | } 76 | 77 | void 78 | cons_puts(const char *s) 79 | { 80 | int c; 81 | 82 | while ((c = *s++) != 0) 83 | vcons_putc(c); 84 | } 85 | -------------------------------------------------------------------------------- /platform/hw/arch/x86/cpu_subr.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014, 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | void x86_isr_9(void); 30 | void x86_isr_10(void); 31 | void x86_isr_11(void); 32 | void x86_isr_14(void); 33 | void x86_isr_15(void); 34 | 35 | uint8_t pic1mask, pic2mask; 36 | 37 | int 38 | cpu_intr_init(int intr) 39 | { 40 | 41 | if (intr > 15) 42 | return BMK_EGENERIC; 43 | 44 | #define FILLGATE(n) case n: x86_fillgate(32+n, x86_isr_##n, 0); break 45 | switch (intr) { 46 | FILLGATE(9); 47 | FILLGATE(10); 48 | FILLGATE(11); 49 | FILLGATE(14); 50 | FILLGATE(15); 51 | default: 52 | return BMK_EGENERIC; 53 | } 54 | #undef FILLGATE 55 | 56 | /* unmask interrupt in PIC */ 57 | if (intr < 8) { 58 | pic1mask &= ~(1< 27 | #include 28 | 29 | #include 30 | 31 | int hypervisor_detect(void) 32 | { 33 | uint32_t eax, ebx, ecx, edx; 34 | 35 | /* 36 | * First check for generic "hypervisor present" bit. 37 | */ 38 | x86_cpuid(0x0, &eax, &ebx, &ecx, &edx); 39 | if (eax >= 0x1) { 40 | x86_cpuid(0x1, &eax, &ebx, &ecx, &edx); 41 | if (!(ecx & (1 << 31))) 42 | return 0; 43 | } 44 | else 45 | return 0; 46 | 47 | /* 48 | * CPUID leaf at 0x40000000 returns hypervisor vendor signature. 49 | * Source: https://lkml.org/lkml/2008/10/1/246 50 | */ 51 | x86_cpuid(0x40000000, &eax, &ebx, &ecx, &edx); 52 | if (!(eax >= 0x40000000)) 53 | return 0; 54 | /* Xen: "XenVMMXenVMM" */ 55 | if (ebx == 0x566e6558 && ecx == 0x65584d4d && edx == 0x4d4d566e) 56 | return HYPERVISOR_XEN; 57 | /* VMware: "VMwareVMware" */ 58 | else if (ebx == 0x61774d56 && ecx == 0x4d566572 && edx == 0x65726177) 59 | return HYPERVISOR_VMWARE; 60 | /* Hyper-V: "Microsoft Hv" */ 61 | else if (ebx == 0x7263694d && ecx == 0x666f736f && edx == 0x76482074) 62 | return HYPERVISOR_HYPERV; 63 | /* KVM: "KVMKVMKVM\0\0\0" */ 64 | else if (ebx == 0x4b4d564b && ecx == 0x564b4d56 && edx == 0x0000004d) 65 | return HYPERVISOR_KVM; 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /platform/hw/arch/x86/serialcons.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Martin Lucina. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | static uint16_t combase = 0; 32 | 33 | void 34 | serialcons_init(uint16_t combase_init, int speed) 35 | { 36 | uint16_t divisor = 115200 / speed; 37 | 38 | combase = combase_init; 39 | outb(combase + COM_IER, 0x00); 40 | outb(combase + COM_LCTL, 0x80); 41 | outb(combase + COM_DLBL, divisor & 0xff); 42 | outb(combase + COM_DLBH, divisor >> 8); 43 | outb(combase + COM_LCTL, 0x03); 44 | outb(combase + COM_FIFO, 0xc7); 45 | } 46 | 47 | void 48 | serialcons_putc(int c) 49 | { 50 | 51 | if (!combase) 52 | return; 53 | if (c == '\n') 54 | serialcons_putc('\r'); 55 | 56 | /* 57 | * Write a single character at a time, while the output FIFO has space. 58 | */ 59 | while ((inb(combase + COM_LSR) & 0x20) == 0) 60 | ; 61 | outb(combase + COM_DATA, c); 62 | } 63 | -------------------------------------------------------------------------------- /platform/hw/arch/x86/vgacons.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #define CONS_MAGENTA 0x500 32 | static volatile uint16_t *cons_buf = (volatile uint16_t *)CONS_ADDRESS; 33 | 34 | static void 35 | cons_putat(int c, int x, int y) 36 | { 37 | 38 | cons_buf[x + y*CONS_WIDTH] = CONS_MAGENTA|c; 39 | } 40 | 41 | /* display a character in the next available slot */ 42 | void 43 | vgacons_putc(int c) 44 | { 45 | static int cons_x; 46 | static int cons_y; 47 | int x; 48 | int doclear = 0; 49 | 50 | if (c == '\n') { 51 | cons_x = 0; 52 | cons_y++; 53 | doclear = 1; 54 | } else if (c == '\r') { 55 | cons_x = 0; 56 | } else if (c == '\t') { 57 | cons_x = (cons_x+8) & ~7; 58 | } else { 59 | cons_putat(c, cons_x++, cons_y); 60 | } 61 | if (cons_x == CONS_WIDTH) { 62 | cons_x = 0; 63 | cons_y++; 64 | doclear = 1; 65 | } 66 | if (cons_y == CONS_HEIGHT) { 67 | cons_y--; 68 | /* scroll screen up one line */ 69 | for (x = 0; x < (CONS_HEIGHT-1)*CONS_WIDTH; x++) 70 | cons_buf[x] = cons_buf[x+CONS_WIDTH]; 71 | } 72 | if (doclear) { 73 | for (x = 0; x < CONS_WIDTH; x++) 74 | cons_putat(' ', x, cons_y); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /platform/hw/include/arch/earm/inline.h: -------------------------------------------------------------------------------- 1 | static inline uint8_t 2 | inb(unsigned long address) 3 | { 4 | 5 | return *(volatile uint8_t *)address; 6 | } 7 | 8 | static inline uint32_t 9 | inl(unsigned long address) 10 | { 11 | 12 | return *(volatile uint32_t *)address; 13 | } 14 | 15 | static inline void 16 | outb(unsigned long address, uint8_t value) 17 | { 18 | 19 | *(volatile uint8_t *)address = value; 20 | } 21 | 22 | static inline void 23 | outl(unsigned long address, uint32_t value) 24 | { 25 | 26 | *(volatile uint32_t *)address = value; 27 | } 28 | -------------------------------------------------------------------------------- /platform/hw/include/arch/earm/md.h: -------------------------------------------------------------------------------- 1 | #ifndef _BMK_ARCH_ARM_MD_H_ 2 | #define _BMK_ARCH_ARM_MD_H_ 3 | 4 | #include 5 | 6 | #define ENTRY(x) .text; .globl x; .type x,%function; x: 7 | #define END(x) .size x, . - x 8 | 9 | #define BMK_THREAD_STACK_PAGE_ORDER 1 10 | #define BMK_THREAD_STACKSIZE ((1< 14 | 15 | void splhigh(void); 16 | void spl0(void); 17 | 18 | static inline void 19 | hlt(void) 20 | { 21 | 22 | /* dumdidumdum */ 23 | } 24 | 25 | void arm_boot(void); 26 | void arm_interrupt(unsigned long *); 27 | void arm_undefined(unsigned long *); 28 | #endif 29 | 30 | #endif /* _BMK..._H_ */ 31 | -------------------------------------------------------------------------------- /platform/hw/include/arch/earm/pcpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _BMK_PCPU_PCPU_H_ 2 | #define _BMK_PCPU_PCPU_H_ 3 | 4 | #define BMK_PCPU_PAGE_SHIFT 12UL 5 | #define BMK_PCPU_PAGE_SIZE (1< 5 | 6 | #include 7 | 8 | #define BMK_THREAD_STACK_PAGE_ORDER 1 9 | #define BMK_THREAD_STACKSIZE ((1< 12 | #include 13 | 14 | #ifndef _LOCORE 15 | struct region_descriptor; 16 | void cpu_lidt(struct region_descriptor *); 17 | void cpu_lgdt(struct region_descriptor *); 18 | 19 | #include 20 | 21 | #include 22 | 23 | struct multiboot_info; 24 | void cpu_boot(struct multiboot_info *); 25 | #endif /* !_LOCORE */ 26 | 27 | #endif /* _BMK..._H_ */ 28 | -------------------------------------------------------------------------------- /platform/hw/include/arch/i386/pcpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _BMK_PCPU_PCPU_H_ 2 | #define _BMK_PCPU_PCPU_H_ 3 | 4 | #define BMK_PCPU_PAGE_SHIFT 12UL 5 | #define BMK_PCPU_PAGE_SIZE (1< 5 | 6 | #include 7 | 8 | #define BMK_THREAD_STACK_PAGE_ORDER 3 9 | #define BMK_THREAD_STACKSIZE ((1< 13 | #include 14 | 15 | #ifndef _LOCORE 16 | #include 17 | 18 | struct region_descriptor; 19 | void amd64_lidt(struct region_descriptor *); 20 | void amd64_ltr(unsigned long); 21 | 22 | #include 23 | 24 | void cpu_boot(void *); 25 | #endif /* !_LOCORE */ 26 | 27 | #endif /* _BMK..._H_ */ 28 | -------------------------------------------------------------------------------- /platform/hw/include/arch/x86_64/pcpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _BMK_PCPU_PCPU_H_ 2 | #define _BMK_PCPU_PCPU_H_ 3 | 4 | #define BMK_PCPU_PAGE_SHIFT 12UL 5 | #define BMK_PCPU_PAGE_SIZE (1<> 4) & 0x0f) * 10 + (bcd & 0x0f); 54 | } 55 | 56 | #endif /* _BMK_CLOCK_SUBR_H_ */ 57 | -------------------------------------------------------------------------------- /platform/hw/include/hw/kernel.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef _LOCORE 4 | 5 | #include 6 | 7 | struct multiboot_info; 8 | void multiboot(struct multiboot_info *); 9 | 10 | void cons_init(void); 11 | void cons_putc(int); 12 | void cons_puts(const char *); 13 | 14 | void cpu_init(void); 15 | void cpu_block(bmk_time_t); 16 | int cpu_intr_init(int); 17 | void cpu_intr_ack(unsigned); 18 | 19 | bmk_time_t cpu_clock_now(void); 20 | bmk_time_t cpu_clock_epochoffset(void); 21 | 22 | void isr(int); 23 | void intr_init(void); 24 | void bmk_isr_rumpkernel(int (*)(void *), void *, int, int); 25 | 26 | #define BMK_INTR_ROUTED 0x01 27 | 28 | #define BMK_MULTIBOOT_CMDLINE_SIZE 4096 29 | extern char multiboot_cmdline[]; 30 | 31 | #endif /* _LOCORE */ 32 | 33 | #include 34 | 35 | #define BMK_MAXINTR 32 36 | 37 | #define HZ 100 38 | -------------------------------------------------------------------------------- /platform/hw/include/hw/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _BMK_TYPES_H_ 2 | #define _BMK_TYPES_H_ 3 | 4 | #include 5 | 6 | #ifndef NULL 7 | #define NULL (void *)0 8 | #endif 9 | 10 | #ifndef __dead 11 | #define __dead __attribute__((__noreturn__)) 12 | #endif 13 | 14 | #endif /* _BMK_TYPES_H_ */ 15 | -------------------------------------------------------------------------------- /platform/hw/kernel.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | int spldepth = 1; 32 | 33 | /* 34 | * splhigh()/spl0() internally track depth 35 | */ 36 | unsigned long 37 | bmk_platform_splhigh(void) 38 | { 39 | 40 | splhigh(); 41 | return 0; 42 | } 43 | 44 | void 45 | bmk_platform_splx(unsigned long x) 46 | { 47 | 48 | spl0(); 49 | } 50 | 51 | void __attribute__((noreturn)) 52 | bmk_platform_halt(const char *panicstring) 53 | { 54 | 55 | if (panicstring) 56 | bmk_printf("PANIC: %s\n", panicstring); 57 | bmk_printf("halted\n"); 58 | for (;;) 59 | hlt(); 60 | } 61 | -------------------------------------------------------------------------------- /platform/hw/pci/Makefile: -------------------------------------------------------------------------------- 1 | RUMPTOP= ${TOPRUMP} 2 | 3 | .include "${RUMPRUN_MKCONF}" 4 | .include "${BUILDRUMP_TOOLFLAGS}" 5 | 6 | RUMPCOMP_MAKEFILEINC_rumpdev_pci:= ${.PARSEDIR}/Makefile.pcihyperdefs 7 | .export RUMPCOMP_MAKEFILEINC_rumpdev_pci 8 | 9 | RUMPRUN_OBJDIR=${RROBJ} 10 | RUMPRUN_TOOL_CFLAGS=${BUILDRUMP_TOOL_CFLAGS} 11 | 12 | .export RUMPRUN_OBJDIR 13 | .export RUMPRUN_TOOL_CFLAGS 14 | 15 | .include "${RUMPTOP}/dev/Makefile.rumpdevcomp" 16 | 17 | .for pcidev in ${RUMPPCIDEVS} 18 | SUBDIR+= ${RUMPTOP}/dev/lib/lib${pcidev} 19 | .endfor 20 | 21 | .include 22 | -------------------------------------------------------------------------------- /platform/hw/pci/Makefile.pcihyperdefs: -------------------------------------------------------------------------------- 1 | # make defs for hypercalls for PCI component 2 | 3 | RUMPRUN_PCIDIR:= ${.PARSEDIR} 4 | .PATH: ${RUMPRUN_PCIDIR} 5 | 6 | .ifndef RUMPRUN_OBJDIR 7 | .error ${.PARSEDIR} invoked improperly 8 | .endif 9 | 10 | RUMPCOMP_USER_SRCS= rumppci.c rumpdma.c 11 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_PCIDIR} 12 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_PCIDIR}/../include 13 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_PCIDIR}/../../../include 14 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_OBJDIR}/include 15 | RUMPCOMP_USER_CFLAGS+= ${RUMPRUN_TOOL_CFLAGS} 16 | 17 | CPPFLAGS+= -I${RUMPRUN_PCIDIR} 18 | -------------------------------------------------------------------------------- /platform/hw/pci/rumpcomp_userfeatures_pci.h: -------------------------------------------------------------------------------- 1 | #define RUMPCOMP_USERFEATURE_PCI_IOSPACE 2 | #define RUMPCOMP_USERFEATURE_PCI_DMAFREE 3 | -------------------------------------------------------------------------------- /platform/hw/platform.conf: -------------------------------------------------------------------------------- 1 | PLATFORM_PCI_P='[ "${MACHINE}" = "amd64" -o "${MACHINE}" = "i386" ]' 2 | -------------------------------------------------------------------------------- /platform/hw/tests/checksum/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ^ bash for job control 3 | 4 | if ! type qemu-system-i386 >/dev/null 2>&1; then 5 | echo ERROR: qemu-system-i386 required but not found 6 | exit 1 7 | fi 8 | 9 | dd if=/dev/urandom of=disk.img count=1 2>/dev/null 10 | echo 'PLEASE WRITE ON THIS IMAGE' | dd of=disk.img conv=notrunc 2>/dev/null 11 | 12 | sum=$(md5sum disk.img | awk '{print $1}') 13 | qemu-system-i386 -net none -drive if=virtio,file=disk.img -display none \ 14 | -no-kvm -kernel test-app & 15 | 16 | rv=1 17 | 18 | # poll for results 19 | for x in $(seq 10) ; do 20 | echo 'polling ...' 21 | res=$(sed q disk.img) 22 | if [ "${res}" = "OK" ]; then 23 | emusum=$(sed -n '2{p;q;}' disk.img) 24 | echo res ok 25 | echo sum1: ${sum} 26 | echo sum2: ${emusum} 27 | if [ "${sum}" = "${emusum}" ]; then 28 | rv=0 29 | fi 30 | break 31 | elif [ "${res}" = "ERROR" ]; then 32 | emesg=$(sed -n '2{p;q;}' disk.img) 33 | echo GOT ERROR: ${emesg} 34 | rv=1 35 | break 36 | fi 37 | sleep 1 38 | done 39 | 40 | # cleanup 41 | kill %1 42 | rm disk.img 43 | exit ${rv} 44 | -------------------------------------------------------------------------------- /platform/hw/undefs.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2014 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /* 30 | * Stubs for unused rump kernel hypercalls 31 | */ 32 | 33 | #define NOTHING(name) \ 34 | int name(void); int name(void) \ 35 | {bmk_printf("unimplemented: " #name "\n"); for (;;);} 36 | 37 | #define REALNOTHING(name, rv) \ 38 | int name(void); int name(void) {return rv;} 39 | 40 | NOTHING(rumpuser_open) 41 | NOTHING(rumpuser_close) 42 | NOTHING(rumpuser_bio) 43 | 44 | REALNOTHING(rumpuser_getfileinfo, BMK_ENOSYS) 45 | 46 | REALNOTHING(rumprun_platform_rumpuser_init, 0); 47 | -------------------------------------------------------------------------------- /platform/makepseudolinkstubs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | makealias () 4 | { 5 | 6 | printf "\n" >> ${OUTPUT} 7 | printf "__weak_alias(%s,_stubnosys);\n" $1 >> ${OUTPUT} 8 | printf "__weak_alias(_%s,_stubnosys);\n" $1 >> ${OUTPUT} 9 | printf "__strong_alias(_sys_%s,_stubnosys);\n" $1 >> ${OUTPUT} 10 | } 11 | 12 | [ $# -eq 4 ] || { echo invalid usage; exit 1;} 13 | 14 | NM=$1 15 | RUMPSRC=$2 16 | BASELIB=$3 17 | OUTPUT=$4 18 | 19 | rm -f ${OUTPUT} 20 | printf '/* AUTOMATICALLY GENERATED */\n\n' >> ${OUTPUT} 21 | printf '#include \n\n' >> ${OUTPUT} 22 | printf 'extern int main(int, char**);\n' >> ${OUTPUT} 23 | printf 'int _want_main(void); int _want_main(void) {return main(0, 0);}\n' \ 24 | >> ${OUTPUT} 25 | printf 'int _stubnosys(void); int _stubnosys(void) {return -1;}\n' \ 26 | >> ${OUTPUT} 27 | 28 | # special cases 29 | printf "__strong_alias(rump_syscall,_stubnosys);\n" >> ${OUTPUT} 30 | printf "__strong_alias(_start,_stubnosys);\n\n" >> ${OUTPUT} 31 | 32 | # symbols not convered by libc 33 | ${NM} -o -g --defined-only ${BASELIB} | awk ' 34 | $(NF-1) == "T" { 35 | printf("__strong_alias(%s,_stubnosys);\n", $NF); 36 | next 37 | } 38 | $(NF-1) == "W" { 39 | printf("__weak_alias(%s,_stubnosys);\n", $NF); 40 | next 41 | } 42 | $(NF-1) ~ "(D|C)" { 43 | printf("int %s;\n", $NF); 44 | next 45 | } 46 | { 47 | printf("error, symbol type %s not handled\n", $(NF-1)) | "cat 1>&2"; 48 | exit(1) 49 | } 50 | ' >> ${OUTPUT} || exit 1 51 | 52 | # system calls 53 | awk '{print $3}' < ${RUMPSRC}/sys/rump/rump.sysmap | while read syscall; do 54 | makealias ${syscall} 55 | done 56 | 57 | exit 0 58 | -------------------------------------------------------------------------------- /platform/xen/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: default 3 | 4 | include ../../global.mk 5 | include ${BUILDRUMP_TOOLFLAGS} 6 | 7 | # 8 | # Rumprun-xen Makefile. 9 | # Abandon all hope, ye who enter here: 10 | # This is in flux while cleanup and separation from the Mini-OS 11 | # Makefile is being worked out. 12 | # 13 | OBJ_DIR ?= $(CURDIR)/obj 14 | 15 | LDSCRIPT:= $(abspath $(OBJ_DIR)/xen/minios.lds) 16 | 17 | INSTALLTGTS= librumpxen_xendev_install librumpnet_xenif_install 18 | 19 | include ../Makefile.inc 20 | 21 | .PHONY: default 22 | default: prepare links mini-os ${MAINOBJ} ${TARGETS} 23 | 24 | CPPFLAGS+= -isystem xen/include 25 | CPPFLAGS+= -no-integrated-cpp 26 | 27 | # Disable PIE, but need to check if compiler supports it 28 | LDFLAGS-$(call cc-option,-no-pie) += -no-pie 29 | LDFLAGS += $(LDFLAGS-y) 30 | 31 | CFLAGS += -fno-builtin 32 | 33 | rump-src-y += rumphyper_bio.c 34 | rump-src-y += init.c 35 | 36 | # Rump kernel middleware objects to build. 37 | RUMP_OBJS= $(OBJ_DIR)/xen/minios.o $(patsubst %.c,$(OBJ_DIR)/%.o,$(rump-src-y)) 38 | 39 | $(OBJ_DIR)/%.o: %.c $(HDRS) $(EXTRA_DEPS) 40 | $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ 41 | 42 | .PHONY: prepare 43 | prepare: 44 | mkdir -p $(OBJ_DIR)/lib 45 | 46 | .PHONY: mini-os 47 | mini-os: 48 | $(MAKE) -C xen OBJ_DIR=$(OBJ_DIR)/xen 49 | 50 | links: 51 | $(MAKE) -C xen links 52 | 53 | $(eval $(call BUILDLIB_target,librumpxen_xendev,.)) 54 | $(eval $(call BUILDLIB_target,librumpnet_xenif,.)) 55 | 56 | xenlibs: ${RROBJLIB}/librumpxen_xendev/librumpxen_xendev.a ${RROBJLIB}/librumpnet_xenif/librumpnet_xenif.a 57 | 58 | $(MAINOBJ): $(RUMP_OBJS) platformlibs xenlibs 59 | $(CC) -Wl,-r $(CFLAGS) $(LDFLAGS) $(RUMP_OBJS) -nostdlib -o $@ \ 60 | -L${RROBJLIB}/libbmk_core -L${RROBJLIB}/libbmk_rumpuser \ 61 | -Wl,--whole-archive -lbmk_rumpuser -lbmk_core -Wl,--no-whole-archive 62 | 63 | .PHONY: clean arch_clean 64 | 65 | clean: commonclean 66 | $(MAKE) -C xen OBJ_DIR=$(OBJ_DIR)/xen clean 67 | rm -f $(OBJ_DIR)/*.o $(OBJ_DIR)/lib/*.o buildtest $(MAINOBJ) 68 | 69 | cleandir: clean 70 | -------------------------------------------------------------------------------- /platform/xen/init.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2015 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include /* XXX */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | static char * 39 | get_xenstorecfg(void) 40 | { 41 | xenbus_transaction_t txn; 42 | char *cfg; 43 | int retry; 44 | 45 | if (xenbus_transaction_start(&txn)) 46 | return NULL; 47 | xenbus_read(txn, "rumprun/cfg", &cfg); 48 | /* XXX: unclear what the "retry" param is supposed to signify */ 49 | xenbus_transaction_end(txn, 0, &retry); 50 | 51 | return cfg; 52 | } 53 | 54 | int 55 | app_main(start_info_t *si) 56 | { 57 | char *cmdline; 58 | 59 | /* 60 | * So, what we currently do is: 61 | * 1) try to fetch the config from xenstore. if available, use that 62 | * 2) else, just pass the command line to bmk_mainthread 63 | * 64 | * Not sure if we eventually need to pass both, but we can change 65 | * it later. 66 | */ 67 | 68 | if ((cmdline = get_xenstorecfg()) == NULL) 69 | cmdline = (char *)si->cmd_line; 70 | 71 | bmk_mainthread(cmdline); 72 | /* NOTREACHED */ 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /platform/xen/librumpnet_xenif/Makefile: -------------------------------------------------------------------------------- 1 | .include 2 | 3 | LIB= rumpnet_xenif 4 | 5 | SRCS= if_virt.c 6 | SRCS+= xenif_component.c 7 | 8 | RUMPTOP= ${TOPRUMP} 9 | 10 | IFBASE= -DVIRTIF_BASE=xenif 11 | 12 | CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern -I${RUMPTOP}/librump/rumpnet 13 | CPPFLAGS+= -I${.CURDIR} 14 | CPPFLAGS+= ${IFBASE} 15 | 16 | RUMPCOMP_USER_SRCS= xenif_user.c 17 | RUMPCOMP_USER_CPPFLAGS+= -I${.CURDIR}/.. 18 | RUMPCOMP_USER_CPPFLAGS+= -I${.CURDIR}/../xen/include 19 | RUMPCOMP_USER_CPPFLAGS+= -I${.CURDIR}/../../../include 20 | RUMPCOMP_USER_CPPFLAGS+= ${IFBASE} 21 | 22 | # XXX 23 | .undef RUMPKERN_ONLY 24 | 25 | .include "${RUMPTOP}/Makefile.rump" 26 | .include 27 | .include 28 | -------------------------------------------------------------------------------- /platform/xen/librumpnet_xenif/if_virt.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: if_virt.h,v 1.2 2013/07/04 11:58:11 pooka Exp $ */ 2 | 3 | /* 4 | * NOTE! This file is supposed to work on !NetBSD platforms. 5 | */ 6 | 7 | #ifndef VIRTIF_BASE 8 | #error Define VIRTIF_BASE 9 | #endif 10 | 11 | #define VIF_STRING(x) #x 12 | #define VIF_STRINGIFY(x) VIF_STRING(x) 13 | #define VIF_CONCAT(x,y) x##y 14 | #define VIF_CONCAT3(x,y,z) x##y##z 15 | #define VIF_BASENAME(x,y) VIF_CONCAT(x,y) 16 | #define VIF_BASENAME3(x,y,z) VIF_CONCAT3(x,y,z) 17 | 18 | #define VIF_CLONER VIF_BASENAME(VIRTIF_BASE,_cloner) 19 | #define VIF_NAME VIF_STRINGIFY(VIRTIF_BASE) 20 | 21 | #define VIFHYPER_CREATE VIF_BASENAME3(rumpcomp_,VIRTIF_BASE,_create) 22 | #define VIFHYPER_DYING VIF_BASENAME3(rumpcomp_,VIRTIF_BASE,_dying) 23 | #define VIFHYPER_DESTROY VIF_BASENAME3(rumpcomp_,VIRTIF_BASE,_destroy) 24 | #define VIFHYPER_SEND VIF_BASENAME3(rumpcomp_,VIRTIF_BASE,_send) 25 | 26 | struct virtif_sc; 27 | void rump_virtif_pktdeliver(struct virtif_sc *, struct iovec *, size_t); 28 | -------------------------------------------------------------------------------- /platform/xen/librumpnet_xenif/if_virt_user.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: rumpcomp_user.h,v 1.4 2013/07/04 11:46:51 pooka Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2013 Antti Kantee. All Rights Reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 16 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | 28 | struct virtif_user; 29 | 30 | int VIFHYPER_CREATE(int, struct virtif_sc *, uint8_t *, 31 | struct virtif_user **); 32 | void VIFHYPER_DYING(struct virtif_user *); 33 | void VIFHYPER_DESTROY(struct virtif_user *); 34 | 35 | void VIFHYPER_SEND(struct virtif_user *, struct iovec *, size_t); 36 | -------------------------------------------------------------------------------- /platform/xen/librumpnet_xenif/xenif_component.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: component.c,v 1.4 2013/07/04 11:46:51 pooka Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2009 Antti Kantee. All Rights Reserved. 5 | * 6 | * Development of this software was supported by The Nokia Foundation 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 18 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | __KERNEL_RCSID(0, "$NetBSD: component.c,v 1.4 2013/07/04 11:46:51 pooka Exp $"); 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | #include "rump_private.h" 40 | #include "rump_net_private.h" 41 | #include "if_virt.h" 42 | 43 | RUMP_COMPONENT(RUMP_COMPONENT_NET_IF) 44 | { 45 | extern struct if_clone VIF_CLONER; /* XXX */ 46 | 47 | if_clone_attach(&VIF_CLONER); 48 | } 49 | -------------------------------------------------------------------------------- /platform/xen/librumpxen_xendev/Makefile: -------------------------------------------------------------------------------- 1 | .include 2 | 3 | LIB= rumpxen_xendev 4 | 5 | SRCS= xendev_component.c 6 | SRCS+= busdev.c 7 | # XXX: issue #73 8 | #SRCS+= evtdev.c 9 | #SRCS+= privcmd.c 10 | 11 | RUMPTOP= ${TOPRUMP} 12 | 13 | CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern -I${RUMPTOP}/librump 14 | CPPFLAGS+= -I${RUMPTOP}/librump/rumpvfs 15 | CPPFLAGS+= -I${.CURDIR}/../xen/include 16 | CPPFLAGS+= -I${.CURDIR} 17 | 18 | RUMPCOMP_USER_SRCS= busdev_user.c 19 | RUMPCOMP_USER_CPPFLAGS+= -I${.CURDIR}/.. 20 | RUMPCOMP_USER_CPPFLAGS+= -I${.CURDIR}/../xen/include 21 | RUMPCOMP_USER_CPPFLAGS+= -I${.CURDIR}/../../../include 22 | 23 | .ifdef RUMP_DEV_XEN_DEBUG 24 | CPPFLAGS+= -DRUMP_DEV_XEN_DEBUG=1 25 | RUMPCOMP_USER_CPPFLAGS+= -DRUMP_DEV_XEN_DEBUG=1 26 | .endif 27 | 28 | # XXX 29 | .undef RUMPKERN_ONLY 30 | 31 | .include "${RUMPTOP}/Makefile.rump" 32 | .include 33 | .include 34 | -------------------------------------------------------------------------------- /platform/xen/librumpxen_xendev/busdev_user.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | struct rumpxenbus_data_dev; 5 | struct rumpxenbus_data_user; 6 | 7 | #define BUFFER_SIZE (XENSTORE_PAYLOAD_MAX+sizeof(struct xsd_sockmsg)) 8 | 9 | struct rumpxenbus_data_common { 10 | /* Partially written request(s). */ 11 | unsigned int wbuf_used; 12 | union { 13 | struct xsd_sockmsg msg; 14 | unsigned char buffer[BUFFER_SIZE]; 15 | } wbuf; 16 | 17 | _Bool queued_enomem; 18 | 19 | struct rumpxenbus_data_user *du; 20 | }; 21 | 22 | /* void __NORETURN__ WTROUBLE(const char *details_without_newline); 23 | * assumes: struct rumpxenbus_data_common *dc; 24 | * int err; 25 | * end: */ 26 | #define WTROUBLE(s) do{ rumpxenbus_write_trouble((dc),s); err = EINVAL; goto end; }while(0) 27 | 28 | void 29 | rumpxenbus_write_trouble(struct rumpxenbus_data_common *dc, const char *what); 30 | 31 | int 32 | rumpxenbus_process_request(struct rumpxenbus_data_common *dc); 33 | 34 | struct xsd_sockmsg* 35 | rumpxenbus_next_event_msg(struct rumpxenbus_data_common *dc, 36 | _Bool block, 37 | void (**mfree_r)(void*)); 38 | 39 | void rumpxenbus_block_before(struct rumpxenbus_data_common *dc); 40 | void rumpxenbus_block_after(struct rumpxenbus_data_common *dc); 41 | 42 | void rumpxenbus_dev_xb_wakeup(struct rumpxenbus_data_common *dc); 43 | void rumpxenbus_dev_restart_wakeup(struct rumpxenbus_data_common *dc); 44 | 45 | void 46 | rumpxenbus_dev_user_shutdown(struct rumpxenbus_data_common *dc); 47 | int 48 | rumpxenbus_dev_user_open(struct rumpxenbus_data_common *dc); 49 | 50 | /* nicked from NetBSD sys/dev/pci/cxgb/cxgb_adapter.h */ 51 | #ifndef container_of 52 | #define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field))) 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /platform/xen/pci/Makefile: -------------------------------------------------------------------------------- 1 | RUMPTOP= ${TOPRUMP} 2 | 3 | .include "${RUMPRUN_MKCONF}" 4 | .include "${BUILDRUMP_TOOLFLAGS}" 5 | 6 | RUMPCOMP_MAKEFILEINC_rumpdev_pci:= ${.PARSEDIR}/Makefile.pcihyperdefs 7 | .export RUMPCOMP_MAKEFILEINC_rumpdev_pci 8 | 9 | RUMPRUN_OBJDIR=${RROBJ} 10 | RUMPRUN_TOOL_CFLAGS=${BUILDRUMP_TOOL_CFLAGS} 11 | 12 | .export RUMPRUN_OBJDIR 13 | .export RUMPRUN_TOOL_CFLAGS 14 | 15 | .include "${RUMPTOP}/dev/Makefile.rumpdevcomp" 16 | 17 | .for pcidev in ${RUMPPCIDEVS} 18 | SUBDIR+= ${RUMPTOP}/dev/lib/lib${pcidev} 19 | .endfor 20 | 21 | .include 22 | -------------------------------------------------------------------------------- /platform/xen/pci/Makefile.pcihyperdefs: -------------------------------------------------------------------------------- 1 | # make defs for hypercalls for PCI component 2 | 3 | RUMPRUN_PCIDIR:= ${.PARSEDIR} 4 | .PATH: ${RUMPRUN_PCIDIR} 5 | 6 | .ifndef RUMPRUN_OBJDIR 7 | .error ${.PARSEDIR} invoked improperly 8 | .endif 9 | 10 | RUMPCOMP_USER_SRCS= rumphyper_pci.c rumphyper_dma.c 11 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_PCIDIR}/../xen/include 12 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_PCIDIR} 13 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_PCIDIR}/../../../include 14 | RUMPCOMP_USER_CPPFLAGS+=-I${RUMPRUN_OBJDIR}/include 15 | RUMPCOMP_USER_CFLAGS+= ${RUMPRUN_TOOL_CFLAGS} 16 | 17 | CPPFLAGS+= -I${RUMPRUN_PCIDIR} 18 | -------------------------------------------------------------------------------- /platform/xen/pci/rumpcomp_userfeatures_pci.h: -------------------------------------------------------------------------------- 1 | /* empty */ 2 | -------------------------------------------------------------------------------- /platform/xen/pci/rumphyper_dma.c: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2013 Antti Kantee. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 14 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 | * SUCH DAMAGE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include "pci_user.h" 37 | 38 | int 39 | rumpcomp_pci_dmalloc(size_t size, size_t align, 40 | unsigned long *pap, unsigned long *vap) 41 | { 42 | unsigned long va; 43 | int i; 44 | 45 | for (i = 0; size >> (i + PAGE_SHIFT); i++) 46 | continue; 47 | 48 | va = minios_alloc_contig_pages(i, 0); /* XXX: MD interface */ 49 | *vap = (uintptr_t)va; 50 | *pap = virt_to_mach(va); 51 | 52 | return 0; 53 | } 54 | 55 | int 56 | rumpcomp_pci_dmamem_map(struct rumpcomp_pci_dmaseg *dss, size_t nseg, 57 | size_t totlen, void **vap) 58 | { 59 | 60 | if (nseg > 1) { 61 | return BMK_EIO; 62 | } 63 | *vap = (void *)dss[0].ds_vacookie; 64 | 65 | return 0; 66 | } 67 | 68 | unsigned long 69 | rumpcomp_pci_virt_to_mach(void *virt) 70 | { 71 | 72 | return virt_to_mach(virt); 73 | } 74 | -------------------------------------------------------------------------------- /platform/xen/platform.conf: -------------------------------------------------------------------------------- 1 | PLATFORM_MKCONF="CPPFLAGS+=-DMAXPHYS=32768" 2 | PLATFORM_PCI_P=true 3 | -------------------------------------------------------------------------------- /platform/xen/xen/Config.mk: -------------------------------------------------------------------------------- 1 | # Useful config stuff 2 | 3 | ifeq ($(RUMPRUN_MKCONF),) 4 | $(error RUMPRUN_MKCONF missing) 5 | endif 6 | include ${RUMPRUN_MKCONF} 7 | 8 | # from Xen/Config.mk 9 | XEN_COMPILE_ARCH ?= $(patsubst amd64,x86_64,$(patsubst i386,x86_32,${MACHINE})) 10 | XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) 11 | 12 | XEN_INTERFACE_VERSION := 0x00030205 13 | export XEN_INTERFACE_VERSION 14 | 15 | OBJ_DIR ?= $(MINI-OS_ROOT)/obj 16 | 17 | # Try to find out the architecture family TARGET_ARCH_FAM. 18 | # First check whether x86_... is contained (for x86_32, x86_32y, x86_64). 19 | # If not x86 then use $(XEN_TARGET_ARCH) -> for ia64, ... 20 | ifeq ($(findstring x86_,$(XEN_TARGET_ARCH)),x86_) 21 | TARGET_ARCH_FAM = x86 22 | else 23 | TARGET_ARCH_FAM = $(XEN_TARGET_ARCH) 24 | endif 25 | 26 | # The architecture family directory below mini-os. 27 | TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM) 28 | 29 | # Export these variables for possible use in architecture dependent makefiles. 30 | export TARGET_ARCH_DIR 31 | export TARGET_ARCH_FAM 32 | 33 | # This is used for architecture specific links. 34 | # This can be overwritten from arch specific rules. 35 | ARCH_LINKS = 36 | 37 | # The path pointing to the architecture specific header files. 38 | ARCH_INC := $(TARGET_ARCH_FAM) 39 | 40 | # For possible special header directories. 41 | # This can be overwritten from arch specific rules. 42 | EXTRA_INC = $(ARCH_INC) 43 | 44 | # Include the architecture family's special makerules. 45 | # This must be before include minios.mk! 46 | include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk 47 | 48 | extra_incl := $(foreach dir,$(EXTRA_INC),-isystem $(MINI-OS_ROOT)/include/$(dir)) 49 | 50 | DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/include 51 | -------------------------------------------------------------------------------- /platform/xen/xen/arch/x86/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # x86 architecture specific makefiles. 3 | # It's is used for x86_32, x86_32y and x86_64 4 | # 5 | 6 | MINI-OS_ROOT=../.. 7 | export MINI-OS_ROOT 8 | 9 | include $(MINI-OS_ROOT)/Config.mk 10 | 11 | # include arch.mk has to be before mini-os.mk! 12 | 13 | include arch.mk 14 | include $(MINI-OS_ROOT)/minios.mk 15 | 16 | # TODO: Import rump CPPFLAGS / include directories from top-level Makefile 17 | CFLAGS+= -I $(MINI-OS_ROOT)/../../../include -nostdinc 18 | CFLAGS+= ${BUILDRUMP_TOOL_CFLAGS} 19 | 20 | # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S 21 | # This is handled in $(HEAD_ARCH_OBJ) 22 | ARCH_SRCS := $(wildcard *.c) 23 | 24 | # The objects built from the sources. 25 | ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS)) 26 | 27 | all: $(OBJ_DIR)/$(ARCH_LIB) 28 | 29 | # $(HEAD_ARCH_OBJ) is only build here, needed on linking 30 | # in ../../Makefile. 31 | $(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 32 | $(AR) rv $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) 33 | 34 | clean: 35 | rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 36 | 37 | -------------------------------------------------------------------------------- /platform/xen/xen/arch/x86/arch.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Architecture special makerules for x86 family 3 | # (including x86_32, x86_32y and x86_64). 4 | # 5 | 6 | ifeq ($(XEN_TARGET_ARCH),x86_32) 7 | ARCH_CFLAGS := -m32 -march=i686 8 | ARCH_CFLAGS += -fno-stack-protector 9 | ARCH_LDFLAGS := -m elf_i386 10 | ARCH_ASFLAGS := -m32 11 | EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH) 12 | EXTRA_SRC += xen/arch/$(EXTRA_INC) 13 | endif 14 | 15 | ifeq ($(XEN_TARGET_ARCH),x86_64) 16 | ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks 17 | ARCH_CFLAGS += -fno-asynchronous-unwind-tables 18 | ARCH_CFLAGS += -fno-stack-protector 19 | ARCH_ASFLAGS := -m64 20 | ARCH_LDFLAGS := -m elf_x86_64 21 | EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH) 22 | EXTRA_SRC += xen/arch/$(EXTRA_INC) 23 | endif 24 | 25 | -------------------------------------------------------------------------------- /platform/xen/xen/arch/x86/minios-x86_32.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 2 | OUTPUT_ARCH(i386) 3 | ENTRY(_start) 4 | SECTIONS 5 | { 6 | . = 0x0; 7 | _text = .; /* Text and read-only data */ 8 | .text : { 9 | *(.text) 10 | *(.text.*) 11 | *(.gnu.warning) 12 | } = 0x9090 13 | 14 | _etext = .; /* End of text section */ 15 | 16 | .rodata : { 17 | *(.rodata) 18 | *(.rodata.*) 19 | 20 | /* Constructors/destructors */ 21 | . = ALIGN(32 / 8); 22 | __init_array_start = . ; 23 | *(SORT_BY_INIT_PRIORITY(.init_array.*)) 24 | *(SORT_BY_INIT_PRIORITY(.ctors*)) 25 | *(.init_array) 26 | __init_array_end = . ; 27 | __fini_array_start = . ; 28 | *(SORT_BY_INIT_PRIORITY(.fini_array.*)) 29 | *(SORT_BY_INIT_PRIORITY(.dtors*)) 30 | *(.fini_array) 31 | __fini_array_end = . ; 32 | } 33 | 34 | . = ALIGN(4096); 35 | _erodata = .; 36 | 37 | .data : { /* Data */ 38 | *(.data) 39 | } 40 | 41 | _edata = .; /* End of data section */ 42 | 43 | .tdata : { 44 | _tdata_start = . ; 45 | *(.tdata) 46 | _tdata_end = . ; 47 | } 48 | 49 | .tbss : { 50 | _tbss_start = . ; 51 | *(.tbss) 52 | _tbss_end = . ; 53 | } 54 | 55 | __bss_start = .; /* BSS */ 56 | .bss : { 57 | *(.bss) 58 | *(.bss.*) 59 | } 60 | _end = . ; 61 | 62 | /* Sections to be discarded */ 63 | /DISCARD/ : { 64 | *(.data.exit) 65 | *(.exitcall.exit) 66 | } 67 | 68 | /* Stabs debugging sections. */ 69 | .stab 0 : { *(.stab) } 70 | .stabstr 0 : { *(.stabstr) } 71 | .stab.excl 0 : { *(.stab.excl) } 72 | .stab.exclstr 0 : { *(.stab.exclstr) } 73 | .stab.index 0 : { *(.stab.index) } 74 | .stab.indexstr 0 : { *(.stab.indexstr) } 75 | .comment 0 : { *(.comment) } 76 | } 77 | -------------------------------------------------------------------------------- /platform/xen/xen/arch/x86/minios-x86_64.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 2 | OUTPUT_ARCH(i386:x86-64) 3 | ENTRY(_start) 4 | SECTIONS 5 | { 6 | . = 0x0; 7 | _text = .; /* Text and read-only data */ 8 | .text : { 9 | *(.text) 10 | *(.text.*) 11 | *(.gnu.warning) 12 | } = 0x9090 13 | 14 | _etext = .; /* End of text section */ 15 | 16 | .rodata : { 17 | *(.rodata) 18 | *(.rodata.*) 19 | 20 | /* Constructors/destructors */ 21 | . = ALIGN(64 / 8); 22 | __init_array_start = . ; 23 | *(SORT_BY_INIT_PRIORITY(.init_array.*)) 24 | *(SORT_BY_INIT_PRIORITY(.ctors*)) 25 | *(.init_array) 26 | __init_array_end = . ; 27 | __fini_array_start = . ; 28 | *(SORT_BY_INIT_PRIORITY(.fini_array.*)) 29 | *(SORT_BY_INIT_PRIORITY(.dtors*)) 30 | *(.fini_array) 31 | __fini_array_end = . ; 32 | } 33 | 34 | . = ALIGN(4096); 35 | _erodata = .; 36 | 37 | .data : { /* Data */ 38 | *(.data) 39 | } 40 | 41 | _edata = .; /* End of data section */ 42 | 43 | .tdata : { 44 | _tdata_start = . ; 45 | *(.tdata) 46 | _tdata_end = . ; 47 | } 48 | 49 | .tbss : { 50 | _tbss_start = . ; 51 | *(.tbss) 52 | _tbss_end = . ; 53 | } 54 | 55 | __bss_start = .; /* BSS */ 56 | .bss : { 57 | *(.bss) 58 | *(.bss.*) 59 | } 60 | _end = . ; 61 | 62 | /* Sections to be discarded */ 63 | /DISCARD/ : { 64 | *(.data.exit) 65 | *(.exitcall.exit) 66 | } 67 | 68 | /* Stabs debugging sections. */ 69 | .stab 0 : { *(.stab) } 70 | .stabstr 0 : { *(.stabstr) } 71 | .stab.excl 0 : { *(.stab.excl) } 72 | .stab.exclstr 0 : { *(.stab.exclstr) } 73 | .stab.index 0 : { *(.stab.index) } 74 | .stab.indexstr 0 : { *(.stab.indexstr) } 75 | .comment 0 : { *(.comment) } 76 | } 77 | -------------------------------------------------------------------------------- /platform/xen/xen/console/console.h: -------------------------------------------------------------------------------- 1 | 2 | void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data); 3 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/blkfront.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_BLKFRONT_H_ 2 | #define _MINIOS_BLKFRONT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | struct blkfront_dev; 8 | struct blkfront_aiocb 9 | { 10 | struct blkfront_dev *aio_dev; 11 | uint8_t *aio_buf; 12 | size_t aio_nbytes; 13 | int64_t aio_offset; 14 | size_t total_bytes; 15 | uint8_t is_write; 16 | void *data; 17 | 18 | grant_ref_t gref[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 19 | int n; 20 | 21 | void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret); 22 | }; 23 | 24 | enum blkfront_mode { BLKFRONT_RDONLY, BLKFRONT_RDWR }; 25 | struct blkfront_info 26 | { 27 | uint64_t sectors; 28 | unsigned sector_size; 29 | int mode; 30 | enum blkfront_mode info; 31 | int barrier; 32 | int flush; 33 | }; 34 | struct blkfront_dev *blkfront_init(char *nodename, struct blkfront_info *info); 35 | void blkfront_aio(struct blkfront_aiocb *aiocbp, int write); 36 | #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0) 37 | #define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1) 38 | void blkfront_io(struct blkfront_aiocb *aiocbp, int write); 39 | #define blkfront_read(aiocbp) blkfront_io(aiocbp, 0) 40 | #define blkfront_write(aiocbp) blkfront_io(aiocbp, 1) 41 | void blkfront_aio_push_operation(struct blkfront_aiocb *aiocbp, uint8_t op); 42 | int blkfront_aio_poll(struct blkfront_dev *dev); 43 | void blkfront_sync(struct blkfront_dev *dev); 44 | void blkfront_shutdown(struct blkfront_dev *dev); 45 | 46 | extern struct wait_queue_head blkfront_queue; 47 | 48 | #endif /* _MINIOS_BLKFRONT_H_ */ 49 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/events.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | * (C) 2005 - Grzegorz Milos - Intel Reseach Cambridge 5 | **************************************************************************** 6 | * 7 | * File: events.h 8 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 9 | * Changes: Grzegorz Milos (gm281@cam.ac.uk) 10 | * 11 | * Date: Jul 2003, changes Jun 2005 12 | * 13 | * Environment: Xen Minimal OS 14 | * Description: Deals with events on the event channels 15 | * 16 | **************************************************************************** 17 | */ 18 | 19 | #ifndef _MINIOS_EVENTS_H_ 20 | #define _MINIOS_EVENTS_H_ 21 | 22 | #include 23 | 24 | struct pt_regs; 25 | typedef void (*evtchn_handler_t)(evtchn_port_t, struct pt_regs *, void *); 26 | 27 | /* prototypes */ 28 | int do_event(evtchn_port_t port, struct pt_regs *regs); 29 | evtchn_port_t minios_bind_virq(uint32_t virq, evtchn_handler_t handler, void *data); 30 | evtchn_port_t minios_bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data); 31 | evtchn_port_t minios_bind_evtchn(evtchn_port_t port, evtchn_handler_t handler, 32 | void *data); 33 | void minios_unbind_evtchn(evtchn_port_t port); 34 | void init_events(void); 35 | int minios_evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler, 36 | void *data, evtchn_port_t *port); 37 | int minios_evtchn_bind_interdomain(domid_t pal, evtchn_port_t remote_port, 38 | evtchn_handler_t handler, void *data, 39 | evtchn_port_t *local_port); 40 | void unbind_all_ports(void); 41 | 42 | int minios_notify_remote_via_evtchn(evtchn_port_t port); 43 | 44 | int minios_event_channel_op(int cmd, void *op); 45 | 46 | void fini_events(void); 47 | 48 | extern struct wait_queue_head minios_events_waitq; 49 | void minios_evtdev_handler(evtchn_port_t port, struct pt_regs * regs, 50 | void *data); 51 | void minios_events_register_rump_callback(void (*cb)(u_int)); 52 | #endif /* _MINIOS_EVENTS_H_ */ 53 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/fbfront.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_FBFRONT_H_ 2 | #define _MINIOS_FBFRONT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* from */ 10 | #ifndef BTN_LEFT 11 | #define BTN_LEFT 0x110 12 | #endif 13 | #ifndef BTN_RIGHT 14 | #define BTN_RIGHT 0x111 15 | #endif 16 | #ifndef BTN_MIDDLE 17 | #define BTN_MIDDLE 0x112 18 | #endif 19 | #ifndef KEY_Q 20 | #define KEY_Q 16 21 | #endif 22 | #ifndef KEY_MAX 23 | #define KEY_MAX 0x1ff 24 | #endif 25 | 26 | 27 | struct kbdfront_dev; 28 | struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer); 29 | 30 | int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n); 31 | extern struct wait_queue_head kbdfront_queue; 32 | 33 | void shutdown_kbdfront(struct kbdfront_dev *dev); 34 | 35 | 36 | struct fbfront_dev *init_fbfront(char *nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n); 37 | 38 | int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n); 39 | extern struct wait_queue_head fbfront_queue; 40 | void fbfront_update(struct fbfront_dev *dev, int x, int y, int width, int height); 41 | void fbfront_resize(struct fbfront_dev *dev, int width, int height, int stride, int depth, int offset); 42 | 43 | void shutdown_fbfront(struct fbfront_dev *dev); 44 | 45 | #endif /* _MINIOS_FBFRONT_H_ */ 46 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/gntmap.h: -------------------------------------------------------------------------------- 1 | #ifndef __MINIOS_GNTMAP_H__ 2 | #define __MINIOS_GNTMAP_H__ 3 | 4 | #include 5 | 6 | /* 7 | * Please consider struct gntmap opaque. If instead you choose to disregard 8 | * this message, I insist that you keep an eye out for raptors. 9 | */ 10 | struct gntmap { 11 | int nentries; 12 | struct gntmap_entry *entries; 13 | }; 14 | 15 | int 16 | gntmap_set_max_grants(struct gntmap *map, int count); 17 | 18 | int 19 | gntmap_munmap(struct gntmap *map, unsigned long start_address, int count); 20 | 21 | void* 22 | gntmap_map_grant_refs(struct gntmap *map, 23 | uint32_t count, 24 | uint32_t *domids, 25 | int domids_stride, 26 | uint32_t *refs, 27 | int writable); 28 | 29 | void 30 | gntmap_init(struct gntmap *map); 31 | 32 | void 33 | gntmap_fini(struct gntmap *map); 34 | 35 | #endif /* !__MINIOS_GNTMAP_H__ */ 36 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/gnttab.h: -------------------------------------------------------------------------------- 1 | #ifndef __MINIOS_GNTTAB_H__ 2 | #define __MINIOS_GNTTAB_H__ 3 | 4 | #include 5 | 6 | void init_gnttab(void); 7 | grant_ref_t gnttab_alloc_and_grant(void **map); 8 | grant_ref_t gnttab_grant_access(domid_t domid, unsigned long frame, 9 | int readonly); 10 | grant_ref_t gnttab_grant_transfer(domid_t domid, unsigned long pfn); 11 | unsigned long gnttab_end_transfer(grant_ref_t gref); 12 | int gnttab_end_access(grant_ref_t ref); 13 | const char *gnttabop_error(int16_t status); 14 | void fini_gnttab(void); 15 | 16 | #endif /* !__MINIOS_GNTTAB_H__ */ 17 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/hypervisor.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * hypervisor.h 3 | * 4 | * Hypervisor handling. 5 | * 6 | * 7 | * Copyright (c) 2002, K A Fraser 8 | * Copyright (c) 2005, Grzegorz Milos 9 | * Updates: Aravindh Puthiyaparambil 10 | * Updates: Dietmar Hahn for ia64 11 | */ 12 | 13 | #ifndef _MINIOS_HYPERVISOR_H_ 14 | #define _MINIOS_HYPERVISOR_H_ 15 | 16 | #include 17 | #include 18 | #if defined(__i386__) 19 | #include 20 | #elif defined(__x86_64__) 21 | #include 22 | #else 23 | #error "Unsupported architecture" 24 | #endif 25 | #include 26 | 27 | /* 28 | * a placeholder for the start of day information passed up from the hypervisor 29 | */ 30 | union start_info_union 31 | { 32 | start_info_t start_info; 33 | char padding[512]; 34 | }; 35 | extern union start_info_union _minios_start_info_union; 36 | #define start_info (_minios_start_info_union.start_info) 37 | 38 | /* hypervisor.c */ 39 | void minios_force_evtchn_callback(void); 40 | void minios_do_hypervisor_callback(struct pt_regs *regs); 41 | void minios_mask_evtchn(uint32_t port); 42 | void minios_unmask_evtchn(uint32_t port); 43 | void minios_clear_evtchn(uint32_t port); 44 | int minios_hypercall(unsigned op, unsigned long a0, 45 | unsigned long a1, unsigned long a2, 46 | unsigned long a3, unsigned long a4); 47 | 48 | extern int _minios_in_hypervisor_callback; 49 | 50 | #endif /* __MINIOS_HYPERVISOR_H__ */ 51 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/ioremap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 Netronome Systems, Inc. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | 24 | #ifndef _MINIOS_IOREMAP_H_ 25 | #define _MINIOS_IOREMAP_H_ 26 | 27 | void *minios_ioremap(unsigned long phys_addr, unsigned long size); 28 | void *minios_ioremap_nocache(unsigned long phys_addr, unsigned long size); 29 | void minios_iounmap(void *virt_addr, unsigned long size); 30 | 31 | #endif /* _MINIOS_IOREMAP_H_ */ 32 | 33 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 indent-tabs-mode:nil -*- */ 34 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_KERNEL_H_ 2 | #define _MINIOS_KERNEL_H_ 3 | 4 | extern int app_main(start_info_t *); 5 | 6 | extern void minios_do_exit(void) __attribute__((noreturn)); 7 | extern void minios_stop_kernel(void); 8 | 9 | /* Values should mirror SHUTDOWN_* in xen/sched.h */ 10 | #define MINIOS_HALT_POWEROFF 0 11 | #define MINIOS_HALT_CRASH 3 12 | extern void minios_do_halt(int reason) __attribute__((noreturn)); 13 | 14 | #endif /* _MINIOS_KERNEL_H_ */ 15 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/netfront.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_NETFRONT_H_ 2 | #define _MINIOS_NETFRONT_H_ 3 | 4 | #include 5 | struct netfront_dev; 6 | struct netfront_dev *netfront_init(char *nodename, void (*netif_rx)(struct netfront_dev *, unsigned char *data, int len), unsigned char rawmac[6], char **ip, void *priv); 7 | void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len); 8 | void netfront_shutdown(struct netfront_dev *dev); 9 | 10 | void *netfront_get_private(struct netfront_dev *); 11 | 12 | extern struct wait_queue_head netfront_queue; 13 | 14 | #endif /* _MINIOS_NETFRONT_H_ */ 15 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/os.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_OS_H_ 2 | #define _MINIOS_OS_H_ 3 | 4 | #define smp_processor_id() 0 5 | #define unlikely(x) __builtin_expect((x),0) 6 | #define likely(x) __builtin_expect((x),1) 7 | 8 | #include 9 | 10 | #ifndef __RUMP_KERNEL__ 11 | 12 | #if __GNUC__ == 2 && __GNUC_MINOR__ < 96 13 | #define __builtin_expect(x, expected_value) (x) 14 | #endif 15 | 16 | #ifndef __ASSEMBLY__ 17 | #include 18 | #include 19 | #endif 20 | 21 | #define USED __attribute__ ((used)) 22 | 23 | #define BUG minios_do_exit 24 | 25 | #include 26 | 27 | #endif /* !__RUMP_KERNEL__ */ 28 | 29 | #endif /* _MINIOS_OS_H_ */ 30 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/pcifront.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_PCIFRONT_H_ 2 | #define _MINIOS_PCIFRONT_H_ 3 | 4 | #include 5 | #include 6 | struct pcifront_dev; 7 | void pcifront_watches(void *opaque); 8 | struct pcifront_dev *init_pcifront(char *nodename); 9 | void pcifront_op(struct pcifront_dev *dev, struct xen_pci_op *op); 10 | void pcifront_scan(struct pcifront_dev *dev, void (*fun)(unsigned int domain, unsigned int bus, unsigned slot, unsigned int fun)); 11 | int pcifront_conf_read(struct pcifront_dev *dev, 12 | unsigned int dom, 13 | unsigned int bus, unsigned int slot, unsigned long fun, 14 | unsigned int off, unsigned int size, unsigned int *val); 15 | int pcifront_conf_write(struct pcifront_dev *dev, 16 | unsigned int dom, 17 | unsigned int bus, unsigned int slot, unsigned long fun, 18 | unsigned int off, unsigned int size, unsigned int val); 19 | int pcifront_enable_msi(struct pcifront_dev *dev, 20 | unsigned int dom, 21 | unsigned int bus, unsigned int slot, unsigned long fun); 22 | int pcifront_disable_msi(struct pcifront_dev *dev, 23 | unsigned int dom, 24 | unsigned int bus, unsigned int slot, unsigned long fun); 25 | int pcifront_enable_msix(struct pcifront_dev *dev, 26 | unsigned int dom, 27 | unsigned int bus, unsigned int slot, unsigned long fun, 28 | struct xen_msix_entry *entries, int n); 29 | int pcifront_disable_msix(struct pcifront_dev *dev, 30 | unsigned int dom, 31 | unsigned int bus, unsigned int slot, unsigned long fun); 32 | void shutdown_pcifront(struct pcifront_dev *dev); 33 | 34 | #endif /* _MINIOS_PCIFRONT_H_ */ 35 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/spinlock.h: -------------------------------------------------------------------------------- 1 | #ifndef __MINIOS_ASM_SPINLOCK_H 2 | #define __MINIOS_ASM_SPINLOCK_H 3 | 4 | #ifndef __RUMP_KERNEL__ 5 | #include 6 | #endif 7 | 8 | /* 9 | * Your basic SMP spinlocks, allowing only a single CPU anywhere 10 | */ 11 | 12 | typedef struct { 13 | volatile unsigned int slock; 14 | } spinlock_t; 15 | 16 | 17 | #include 18 | 19 | 20 | #define SPINLOCK_MAGIC 0xdead4ead 21 | 22 | #define SPIN_LOCK_UNLOCKED ARCH_SPIN_LOCK_UNLOCKED 23 | 24 | #define spin_lock_init(x) do { *(x) = (spinlock_t)SPIN_LOCK_UNLOCKED; } while(0) 25 | 26 | /* 27 | * Simple spin lock operations. There are two variants, one clears IRQ's 28 | * on the local processor, one does not. 29 | * 30 | * We make no fairness assumptions. They have a cost. 31 | */ 32 | 33 | #define spin_is_locked(x) arch_spin_is_locked(x) 34 | 35 | #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) 36 | 37 | 38 | #define _spin_trylock(lock) ({_raw_spin_trylock(lock) ? \ 39 | 1 : ({ 0;});}) 40 | 41 | #define _spin_lock(lock) \ 42 | do { \ 43 | _raw_spin_lock(lock); \ 44 | } while(0) 45 | 46 | #define _spin_unlock(lock) \ 47 | do { \ 48 | _raw_spin_unlock(lock); \ 49 | } while (0) 50 | 51 | 52 | #define spin_lock(lock) _spin_lock(lock) 53 | #define spin_unlock(lock) _spin_unlock(lock) 54 | 55 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/time.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | * (C) 2005 - Grzegorz Milos - Intel Research Cambridge 5 | **************************************************************************** 6 | * 7 | * File: time.h 8 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 9 | * Changes: Grzegorz Milos (gm281@cam.ac.uk) 10 | * Robert Kaiser (kaiser@informatik.fh-wiesbaden.de) 11 | * 12 | * Date: Jul 2003, changes: Jun 2005, Sep 2006 13 | * 14 | * Environment: Xen Minimal OS 15 | * Description: Time and timer functions 16 | * 17 | **************************************************************************** 18 | */ 19 | 20 | #ifndef _MINIOS_TIME_H_ 21 | #define _MINIOS_TIME_H_ 22 | #include 23 | 24 | /* 25 | * System Time 26 | * 64 bit value containing the nanoseconds elapsed since boot time. 27 | * This value is adjusted by frequency drift. 28 | * The other macros are for convenience to approximate short intervals 29 | * of real time into system time 30 | */ 31 | typedef int64_t s_time_t; 32 | #define SECONDS(_s) (((s_time_t)(_s)) * 1000000000UL ) 33 | #define TENTHS(_ts) (((s_time_t)(_ts)) * 100000000UL ) 34 | #define HUNDREDTHS(_hs) (((s_time_t)(_hs)) * 10000000UL ) 35 | #define MILLISECS(_ms) (((s_time_t)(_ms)) * 1000000UL ) 36 | #define MICROSECS(_us) (((s_time_t)(_us)) * 1000UL ) 37 | #define Time_Max ((s_time_t) 0x7fffffffffffffffLL) 38 | #define FOREVER Time_Max 39 | #define NSEC_TO_USEC(_nsec) ((_nsec) / 1000UL) 40 | #define NSEC_TO_MSEC(_nsec) ((_nsec) / 1000000ULL) 41 | #define NSEC_TO_SEC(_nsec) ((_nsec) / 1000000000ULL) 42 | 43 | 44 | 45 | /* prototypes */ 46 | void init_time(void); 47 | void fini_time(void); 48 | s_time_t get_s_time(void); 49 | s_time_t get_v_time(void); 50 | void block_domain(s_time_t until); 51 | 52 | #endif /* _MINIOS_TIME_H_ */ 53 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/types.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | **************************************************************************** 5 | * 6 | * File: types.h 7 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 8 | * Changes: 9 | * 10 | * Date: May 2003 11 | * 12 | * Environment: Xen Minimal OS 13 | * Description: a random collection of type definitions 14 | * 15 | **************************************************************************** 16 | * $Id: h-insert.h,v 1.4 2002/11/08 16:03:55 rn Exp $ 17 | **************************************************************************** 18 | */ 19 | 20 | #ifndef _MINIOS_TYPES_H_ 21 | #define _MINIOS_TYPES_H_ 22 | 23 | /* XXX: fix the kernelside Xen driver #include abuse */ 24 | #ifndef __RUMP_KERNEL__ 25 | #include 26 | 27 | #ifndef _BSD_SIZE_T_ 28 | typedef unsigned int u_int; 29 | typedef unsigned long u_long; 30 | typedef unsigned long size_t; 31 | #endif 32 | 33 | #ifndef offsetof 34 | #define offsetof(_t_,_e_) __builtin_offsetof(_t_,_e_) 35 | #endif 36 | #endif 37 | 38 | #ifdef __i386__ 39 | typedef struct { unsigned long pte_low, pte_high; } pte_t; 40 | 41 | #elif defined(__x86_64__) 42 | 43 | typedef struct { unsigned long pte; } pte_t; 44 | #endif /* __i386__ || __x86_64__ */ 45 | 46 | #ifdef __x86_64__ 47 | #define __pte(x) ((pte_t) { (x) } ) 48 | #else 49 | #define __pte(x) ({ unsigned long long _x = (x); \ 50 | ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) 51 | #endif 52 | 53 | #endif /* _MINIOS_TYPES_H_ */ 54 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/waittypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __MINIOS_WAITTYPE_H__ 2 | #define __MINIOS_WAITTYPE_H__ 3 | 4 | #include 5 | #include 6 | 7 | struct wait_queue 8 | { 9 | int waiting; 10 | struct bmk_thread *thread; 11 | STAILQ_ENTRY(wait_queue) thread_list; 12 | }; 13 | 14 | /* TODO - lock required? */ 15 | STAILQ_HEAD(wait_queue_head, wait_queue); 16 | 17 | #define DECLARE_WAIT_QUEUE_HEAD(name) \ 18 | struct wait_queue_head name = STAILQ_HEAD_INITIALIZER(name) 19 | 20 | #define __WAIT_QUEUE_HEAD_INITIALIZER(name) STAILQ_HEAD_INITIALIZER(name) 21 | 22 | #endif 23 | 24 | /* 25 | * Local variables: 26 | * mode: C 27 | * c-set-style: "BSD" 28 | * c-basic-offset: 4 29 | * tab-width: 4 30 | * indent-tabs-mode: nil 31 | * End: 32 | */ 33 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/x86/limits.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ARCH_LIMITS_H__ 3 | #define __ARCH_LIMITS_H__ 4 | 5 | #define __PAGE_SHIFT 12 6 | 7 | #ifdef __ASSEMBLY__ 8 | #define __PAGE_SIZE (1 << __PAGE_SHIFT) 9 | #else 10 | /* XXX: must be ULL for correct integer promotion in pte calculations */ 11 | #define __PAGE_SIZE (1ULL << __PAGE_SHIFT) 12 | #endif 13 | 14 | #define __STACK_SIZE_PAGE_ORDER 6 15 | #define __STACK_SIZE (__PAGE_SIZE * (1 << __STACK_SIZE_PAGE_ORDER)) 16 | 17 | #endif /* __ARCH_LIMITS_H__ */ 18 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/x86/pcpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _BMK_PCPU_PCPU_H_ 2 | #define _BMK_PCPU_PCPU_H_ 3 | 4 | #define BMK_PCPU_PAGE_SHIFT 12UL 5 | #define BMK_PCPU_PAGE_SIZE (1< 8 | #endif 9 | 10 | #include "os.h" 11 | 12 | 13 | #define ARCH_SPIN_LOCK_UNLOCKED { 1 } 14 | 15 | /* 16 | * Simple spin lock operations. There are two variants, one clears IRQ's 17 | * on the local processor, one does not. 18 | * 19 | * We make no fairness assumptions. They have a cost. 20 | */ 21 | 22 | #define arch_spin_is_locked(x) (*(volatile signed char *)(&(x)->slock) <= 0) 23 | #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) 24 | 25 | #define spin_lock_string \ 26 | "1:\n" \ 27 | LOCK \ 28 | "decb %0\n\t" \ 29 | "jns 3f\n" \ 30 | "2:\t" \ 31 | "rep;nop\n\t" \ 32 | "cmpb $0,%0\n\t" \ 33 | "jle 2b\n\t" \ 34 | "jmp 1b\n" \ 35 | "3:\n\t" 36 | 37 | #define spin_lock_string_flags \ 38 | "1:\n" \ 39 | LOCK \ 40 | "decb %0\n\t" \ 41 | "jns 4f\n\t" \ 42 | "2:\t" \ 43 | "testl $0x200, %1\n\t" \ 44 | "jz 3f\n\t" \ 45 | "#sti\n\t" \ 46 | "3:\t" \ 47 | "rep;nop\n\t" \ 48 | "cmpb $0, %0\n\t" \ 49 | "jle 3b\n\t" \ 50 | "#cli\n\t" \ 51 | "jmp 1b\n" \ 52 | "4:\n\t" 53 | 54 | /* 55 | * This works. Despite all the confusion. 56 | * (except on PPro SMP or if we are using OOSTORE) 57 | * (PPro errata 66, 92) 58 | */ 59 | 60 | #define spin_unlock_string \ 61 | "xchgb %b0, %1" \ 62 | :"=q" (oldval), "=m" (lock->slock) \ 63 | :"0" (oldval) : "memory" 64 | 65 | static inline void _raw_spin_unlock(spinlock_t *lock) 66 | { 67 | char oldval = 1; 68 | __asm__ __volatile__( 69 | spin_unlock_string 70 | ); 71 | } 72 | 73 | static inline int _raw_spin_trylock(spinlock_t *lock) 74 | { 75 | char oldval; 76 | __asm__ __volatile__( 77 | "xchgb %b0,%1\n" 78 | :"=q" (oldval), "=m" (lock->slock) 79 | :"0" (0) : "memory"); 80 | return oldval > 0; 81 | } 82 | 83 | static inline void _raw_spin_lock(spinlock_t *lock) 84 | { 85 | __asm__ __volatile__( 86 | spin_lock_string 87 | :"=m" (lock->slock) : : "memory"); 88 | } 89 | 90 | static inline void _raw_spin_lock_flags (spinlock_t *lock, unsigned long flags) 91 | { 92 | __asm__ __volatile__( 93 | spin_lock_string_flags 94 | :"=m" (lock->slock) : "r" (flags) : "memory"); 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /platform/xen/xen/include/mini-os/x86/traps.h: -------------------------------------------------------------------------------- 1 | /* 2 | **************************************************************************** 3 | * (C) 2005 - Grzegorz Milos - Intel Reseach Cambridge 4 | **************************************************************************** 5 | * 6 | * File: traps.h 7 | * Author: Grzegorz Milos (gm281@cam.ac.uk) 8 | * 9 | * Date: Jun 2005 10 | * 11 | * Environment: Xen Minimal OS 12 | * Description: Deals with traps 13 | * 14 | **************************************************************************** 15 | */ 16 | 17 | #ifndef _TRAPS_H_ 18 | #define _TRAPS_H_ 19 | 20 | #ifdef __i386__ 21 | struct pt_regs { 22 | long ebx; 23 | long ecx; 24 | long edx; 25 | long esi; 26 | long edi; 27 | long ebp; 28 | long eax; 29 | int xds; 30 | int xes; 31 | long orig_eax; 32 | long eip; 33 | int xcs; 34 | long eflags; 35 | long esp; 36 | int xss; 37 | }; 38 | #elif __x86_64__ 39 | 40 | struct pt_regs { 41 | unsigned long r15; 42 | unsigned long r14; 43 | unsigned long r13; 44 | unsigned long r12; 45 | unsigned long rbp; 46 | unsigned long rbx; 47 | /* arguments: non interrupts/non tracing syscalls only save upto here*/ 48 | unsigned long r11; 49 | unsigned long r10; 50 | unsigned long r9; 51 | unsigned long r8; 52 | unsigned long rax; 53 | unsigned long rcx; 54 | unsigned long rdx; 55 | unsigned long rsi; 56 | unsigned long rdi; 57 | unsigned long orig_rax; 58 | /* end of arguments */ 59 | /* cpu exception frame or undefined */ 60 | unsigned long rip; 61 | unsigned long cs; 62 | unsigned long eflags; 63 | unsigned long rsp; 64 | unsigned long ss; 65 | /* top of stack page */ 66 | }; 67 | 68 | 69 | #endif 70 | 71 | void dump_regs(struct pt_regs *regs); 72 | void stack_walk(void); 73 | 74 | #define TRAP_PF_PROT 0x1 75 | #define TRAP_PF_WRITE 0x2 76 | #define TRAP_PF_USER 0x4 77 | 78 | #endif /* _TRAPS_H_ */ 79 | -------------------------------------------------------------------------------- /platform/xen/xen/minios.mk: -------------------------------------------------------------------------------- 1 | # 2 | # The file contains the common make rules for building mini-os. 3 | # 4 | 5 | debug = y 6 | 7 | # Define some default flags. 8 | # NB. '-Wcast-qual' is nasty, so I omitted it. 9 | DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls 10 | DEF_CFLAGS-$(call cc-option,-fno-stack-protector) += -fno-stack-protector 11 | DEF_CFLAGS-$(call cc-option,-fgnu89-inline) += -fgnu89-inline 12 | DEF_CFLAGS += $(DEF_CFLAGS-y) 13 | DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline 14 | DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) 15 | 16 | DEF_ASFLAGS += -D__ASSEMBLY__ 17 | 18 | ifeq ($(debug),y) 19 | DEF_CFLAGS += -g 20 | #DEF_CFLAGS += -DMM_DEBUG 21 | DEF_CFLAGS += -DGNT_DEBUG 22 | DEF_CFLAGS += -DGNTMAP_DEBUG 23 | else 24 | DEF_CFLAGS += -O3 25 | endif 26 | 27 | # Build the CFLAGS and ASFLAGS for compiling and assembling. 28 | # DEF_... flags are the common mini-os flags, 29 | # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk 30 | CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) 31 | CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) 32 | ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) 33 | LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS) 34 | 35 | # Special build dependencies. 36 | # Rebuild all after touching this/these file(s) 37 | EXTRA_DEPS += $(MINI-OS_ROOT)/minios.mk 38 | EXTRA_DEPS += $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk 39 | 40 | # Find all header files for checking dependencies. 41 | HDRS := $(wildcard $(MINI-OS_ROOT)/include/mini-os/*.h) 42 | HDRS += $(wildcard $(MINI-OS_ROOT)/include/xen/*.h) 43 | HDRS += $(wildcard $(ARCH_INC)/*.h) 44 | # For special wanted header directories. 45 | extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h)) 46 | HDRS += $(extra_heads) 47 | 48 | # Add the special header directories to the include paths. 49 | override CPPFLAGS := $(CPPFLAGS) $(extra_incl) 50 | 51 | # The name of the architecture specific library. 52 | # This is on x86_32: libx86_32.a 53 | # $(ARCH_LIB) has to built in the architecture specific directory. 54 | ARCH_LIB_NAME = $(XEN_TARGET_ARCH) 55 | ARCH_LIB := lib$(ARCH_LIB_NAME).a 56 | 57 | # This object contains the entrypoint for startup from Xen. 58 | # $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory. 59 | HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o 60 | HEAD_OBJ := $(OBJ_DIR)/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ) 61 | 62 | $(OBJ_DIR)/%.o: %.c $(HDRS) $(EXTRA_DEPS) 63 | $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ 64 | 65 | $(OBJ_DIR)/%.o: %.S $(HDRS) $(EXTRA_DEPS) 66 | $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@ 67 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all-tests 2 | all-tests: 3 | $(MAKE) -C hello 4 | $(MAKE) -C basic 5 | 6 | .PHONY: kernonly-tests 7 | kernonly-tests: 8 | $(MAKE) PLATFORM=${PLATFORM} -C nolibc 9 | 10 | .PHONY: clean 11 | clean: 12 | $(MAKE) -C hello clean 13 | $(MAKE) -C basic clean 14 | $(MAKE) -C nolibc clean 15 | [ ! -f configure/Makefile ] || $(MAKE) -C configure distclean 16 | -------------------------------------------------------------------------------- /tests/Makefile.inc: -------------------------------------------------------------------------------- 1 | include ${RUMPRUN_MKCONF} 2 | 3 | CC= ${RUMPRUN_CC} 4 | CXX= ${RUMPRUN_CXX} 5 | 6 | CFLAGS+= -Wall -Werror -Wmissing-prototypes -Wstrict-prototypes -g 7 | LDLIBS= -lrumprun_tester 8 | 9 | %:: %.c 10 | $(CC) $(CFLAGS) $< -o $@ $(LDLIBS) 11 | 12 | %:: %.cc 13 | $(CXX) $(CXXFLAGS) $< -o $@ $(LDLIBS) 14 | 15 | %.bin: % 16 | $(RUMPRUN_BAKE) $(RUMPBAKE_PLATFORM) $@ $< 17 | -------------------------------------------------------------------------------- /tests/basic/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | ALL=tls_test.bin ctor_test.bin pthread_test.bin misc_test.bin 4 | 5 | all: $(ALL) 6 | 7 | clean: 8 | rm -f $(ALL) 9 | -------------------------------------------------------------------------------- /tests/basic/ctor_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | /* Constructor test. Checks that constructors run in the correct order */ 8 | int myvalue = 2; 9 | static void __attribute__((constructor(2000),used)) 10 | ctor1(void) 11 | { 12 | myvalue = myvalue * 2; 13 | } 14 | 15 | static void __attribute__((constructor(1000),used)) 16 | ctor2(void) 17 | { 18 | myvalue = myvalue + 2; 19 | } 20 | 21 | static void __attribute__((constructor(1000),used)) 22 | ctor3(void) 23 | { 24 | printf("I'm a constructor!\n"); 25 | } 26 | 27 | static void __attribute__((destructor(1000),used)) 28 | dtor1(void) 29 | { 30 | printf("I'm a destructor!\n"); 31 | } 32 | 33 | int 34 | rumprun_test(int argc, char *argv[]) 35 | { 36 | 37 | if (myvalue != 8) { 38 | printf("ERROR running constructor test, myvalue=%d, " 39 | "expected 8\n", myvalue); 40 | return 1; 41 | } 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /tests/basic/tls_test.c: -------------------------------------------------------------------------------- 1 | /* Simple test for TLS support */ 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #define NTHREADS 10 13 | #define LOOPCNT 1000 14 | #define IINITIAL 12345678 15 | 16 | static __thread unsigned long c; 17 | static __thread unsigned long i = IINITIAL; 18 | 19 | static void * 20 | wrkthread(void *arg) 21 | { 22 | unsigned long *ip = &i; 23 | 24 | printf("Thread %d starting\n", (int)(uintptr_t)arg); 25 | if (i != IINITIAL) { 26 | printf("initial i incorrect: %lu vs. %d\n", i, IINITIAL); 27 | return NULL; 28 | } 29 | i++; 30 | if (*ip != IINITIAL+1) { 31 | printf("initial *ip incorrect: %lu vs. %d\n", i, IINITIAL+1); 32 | return NULL; 33 | } 34 | i++; 35 | 36 | while (c < LOOPCNT) { 37 | c++; 38 | sched_yield(); 39 | } 40 | return (void *)(uintptr_t)c; 41 | } 42 | 43 | int 44 | rumprun_test(int argc, char *argv[]) 45 | { 46 | pthread_t threads[NTHREADS]; 47 | int n, rc; 48 | 49 | printf("TLS test\n"); 50 | 51 | for (n = 0; n < NTHREADS; n++) { 52 | rc = pthread_create(&threads[n], NULL, 53 | wrkthread, (void *)(uintptr_t)n); 54 | if (rc != 0) { 55 | errx(1, "pthread_create[%d] failed: %d", n, rc); 56 | } 57 | } 58 | 59 | for (n = NTHREADS-1; n >= 0; n--) { 60 | void *ret; 61 | int rv; 62 | 63 | rc = pthread_join(threads[n], &ret); 64 | if (rc != 0) { 65 | errx(1, "pthread_join[%d] failed: %d", n, rc); 66 | } 67 | rv = (int)(uintptr_t)ret; 68 | if (rv != LOOPCNT) 69 | errx(1, "thread[%d]: expected %d, got %d", 70 | n, LOOPCNT, rv); 71 | } 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /tests/buildtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script builds all tests, including the one which 4 | # tests for configure. I'm sure it would be possible to do it 5 | # with just "make", but a script seems vastly simpler now. 6 | 7 | # we know, we knooooooow 8 | export RUMPRUN_WARNING_STFU=please 9 | 10 | set -e 11 | 12 | TESTMODE=apptools 13 | TESTCONFIGURE=true 14 | TESTCMAKE=$(which cmake || echo "") 15 | 16 | while getopts 'kqh' opt; do 17 | case "$opt" in 18 | 'k') 19 | TESTMODE=kernonly 20 | ;; 21 | 'q') 22 | TESTCONFIGURE=false 23 | ;; 24 | 'h'|'?') 25 | echo "$0 [-k|-q]" 26 | exit 1 27 | esac 28 | done 29 | shift $((${OPTIND} - 1)) 30 | 31 | # XXX: sourcing the file while aiming to use app-tools is plain wrong 32 | [ -n "${RUMPRUN_SHCONF}" ] || { echo '>> need RUMPRUN_SHCONF'; exit 1; } 33 | . "${RUMPRUN_SHCONF}" 34 | unset CC 35 | unset CXX 36 | 37 | cd "$(dirname $0)" 38 | 39 | test_apptools() 40 | { 41 | 42 | case ${PLATFORM} in 43 | hw) 44 | RUMPBAKE_PLATFORM='hw_generic' 45 | ;; 46 | xen) 47 | RUMPBAKE_PLATFORM='xen_pv' 48 | ;; 49 | *) 50 | echo ">> unknown platform \"$PLATFORM\"" 51 | exit 1 52 | esac 53 | 54 | export PATH="${RRDEST}/bin:${PATH}" 55 | export RUMPBAKE_PLATFORM 56 | 57 | make 58 | 59 | if ${TESTCONFIGURE}; then 60 | ( 61 | cd configure 62 | ./configure --host=${TOOLTUPLE} 63 | make 64 | ) 65 | fi 66 | 67 | if [ -n "${TESTCMAKE}" ]; then 68 | ( 69 | mkdir -p cmake/build 70 | cd cmake/build 71 | cmake -DCMAKE_TOOLCHAIN_FILE=${RRDEST}/rumprun-${MACHINE_GNU_ARCH}/share/${TOOLTUPLE}-toolchain.cmake .. 72 | make 73 | ) 74 | fi 75 | } 76 | 77 | test_kernonly() 78 | { 79 | if [ -z "${MAKE}" ]; then 80 | MAKE=make 81 | ! type gmake >/dev/null 2>&1 || MAKE=gmake 82 | fi 83 | 84 | ${MAKE} PLATFORM=${PLATFORM} kernonly-tests 85 | } 86 | 87 | test_${TESTMODE} 88 | 89 | exit 0 90 | -------------------------------------------------------------------------------- /tests/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | project(Test C) 3 | 4 | include(CheckIncludeFile) 5 | include(CheckFunctionExists) 6 | 7 | check_include_file(sys/epoll.h HAVE_SYS_EPOLL_H) 8 | check_function_exists(select HAVE_SELECT) 9 | check_function_exists(sigaction HAVE_SIGACTION) 10 | 11 | configure_file(config.h.in config.h) 12 | 13 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 14 | add_executable(cmake_test test.c) 15 | -------------------------------------------------------------------------------- /tests/cmake/config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine HAVE_SYS_EPOLL_H ${HAVE_SYS_EPOLL_H} 2 | #cmakedefine HAVE_SELECT ${HAVE_SELECT} 3 | #cmakedefine HAVE_SIGACTION ${HAVE_SIGACTION} 4 | -------------------------------------------------------------------------------- /tests/cmake/test.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | /* 8 | * What we're looking for with the next test is something that is likely 9 | * to be present on the host, but unlikely to be present on the target. 10 | * So we assume a Linux host. 11 | */ 12 | 13 | #ifdef HAVE_SYS_EPOLL_H 14 | #error Should not have epoll. In case NetBSD now has epoll, please update test. 15 | #endif 16 | #ifndef HAVE_SELECT 17 | #error Could not find select. Was ist los? 18 | #endif 19 | 20 | /* make sure we offer compat symbols that can be found by autoconf */ 21 | #ifndef HAVE_SIGACTION 22 | #error sigaction not found. libc problem. 23 | #endif 24 | 25 | int 26 | main() 27 | { 28 | 29 | printf("hello, test\n"); 30 | } 31 | -------------------------------------------------------------------------------- /tests/configure/.gitignore: -------------------------------------------------------------------------------- 1 | .deps/ 2 | Makefile 3 | config.h 4 | config.log 5 | config.status 6 | libtool 7 | stamp-h1 8 | test 9 | -------------------------------------------------------------------------------- /tests/configure/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS= foreign 2 | ACLOCAL_AMFLAGS= -I m4 3 | 4 | bin_PROGRAMS= test 5 | 6 | test_SOURCES= test.c 7 | -------------------------------------------------------------------------------- /tests/configure/config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_DLFCN_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_INTTYPES_H 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_MEMORY_H 11 | 12 | /* Define to 1 if you have the `select' function. */ 13 | #undef HAVE_SELECT 14 | 15 | /* Define to 1 if you have the `sigaction' function. */ 16 | #undef HAVE_SIGACTION 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDINT_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STDLIB_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRINGS_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_STRING_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_EPOLL_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_SYS_STAT_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_SYS_TYPES_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_UNISTD_H 41 | 42 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 43 | */ 44 | #undef LT_OBJDIR 45 | 46 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 47 | #undef NO_MINUS_C_MINUS_O 48 | 49 | /* Name of package */ 50 | #undef PACKAGE 51 | 52 | /* Define to the address where bug reports for this package should be sent. */ 53 | #undef PACKAGE_BUGREPORT 54 | 55 | /* Define to the full name of this package. */ 56 | #undef PACKAGE_NAME 57 | 58 | /* Define to the full name and version of this package. */ 59 | #undef PACKAGE_STRING 60 | 61 | /* Define to the one symbol short name of this package. */ 62 | #undef PACKAGE_TARNAME 63 | 64 | /* Define to the home page for this package. */ 65 | #undef PACKAGE_URL 66 | 67 | /* Define to the version of this package. */ 68 | #undef PACKAGE_VERSION 69 | 70 | /* Define to 1 if you have the ANSI C header files. */ 71 | #undef STDC_HEADERS 72 | 73 | /* Version number of package */ 74 | #undef VERSION 75 | -------------------------------------------------------------------------------- /tests/configure/configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.66]) 2 | AC_INIT([apptools-test], [11], [rumpkernel-users@freelists.org]) 3 | 4 | AC_CONFIG_SRCDIR([test.c]) 5 | AC_CONFIG_HEADERS([config.h]) 6 | AC_CONFIG_AUX_DIR([build-aux]) 7 | AC_CONFIG_MACRO_DIR([m4]) 8 | 9 | AC_CANONICAL_TARGET 10 | 11 | AM_INIT_AUTOMAKE([1.11 foreign subdir-objects -Wall -Werror]) 12 | AM_MAINTAINER_MODE 13 | 14 | AC_PROG_CC 15 | AC_PROG_CXX 16 | AC_PROG_CC_C_O 17 | AC_PROG_LIBTOOL 18 | 19 | AC_CHECK_HEADERS([sys/epoll.h]) 20 | AC_CHECK_FUNCS([select sigaction]) 21 | 22 | AC_CONFIG_FILES([Makefile]) 23 | AC_OUTPUT 24 | -------------------------------------------------------------------------------- /tests/configure/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /tests/configure/test.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | /* 8 | * What we're looking for with the next test is something that is likely 9 | * to be present on the host, but unlikely to be present on the target. 10 | * So we assume a Linux host. 11 | */ 12 | 13 | #ifdef HAVE_SYS_EPOLL_H 14 | #error Should not have epoll. In case NetBSD now has epoll, please update test. 15 | #endif 16 | #ifndef HAVE_SELECT 17 | #error Could not find select. Was ist los? 18 | #endif 19 | 20 | /* make sure we offer compat symbols that can be found by autoconf */ 21 | #ifndef HAVE_SIGACTION 22 | #error sigaction not found. libc problem. 23 | #endif 24 | 25 | int 26 | main() 27 | { 28 | 29 | printf("hello, test\n"); 30 | } 31 | -------------------------------------------------------------------------------- /tests/crypto/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | LDLIBS+= -lcrypto 3 | 4 | ALL=md5.bin 5 | 6 | all: $(ALL) 7 | 8 | clean: 9 | rm -f $(ALL) 10 | -------------------------------------------------------------------------------- /tests/crypto/README: -------------------------------------------------------------------------------- 1 | libcrypto is no longer built in rumprun base, so this test 2 | cannot be automatically run. 3 | -------------------------------------------------------------------------------- /tests/crypto/md5.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | #define TESTSTRING "sum test string this is" 10 | 11 | static unsigned char expected[MD5_DIGEST_LENGTH] = { 12 | 0x20, 0x62, 0xda, 0xe2, 0xa3, 0xb4, 0x1d, 0xc7, 13 | 0x0c, 0x23, 0x3f, 0x25, 0xd8, 0xff, 0x5b, 0x6e, 14 | }; 15 | 16 | int 17 | rumprun_test(int argc, char *argv[]) 18 | { 19 | unsigned char md5sum[MD5_DIGEST_LENGTH]; 20 | MD5_CTX md5ctx; 21 | 22 | MD5_Init(&md5ctx); 23 | MD5_Update(&md5ctx, TESTSTRING, sizeof(TESTSTRING)-1); 24 | MD5_Final(md5sum, &md5ctx); 25 | 26 | return memcmp(expected, md5sum, sizeof(expected)); 27 | } 28 | -------------------------------------------------------------------------------- /tests/hello/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | ALL=hello.bin 4 | 5 | ifeq ($(CONFIG_CXX),yes) 6 | ALL += hellopp.bin 7 | endif 8 | 9 | all: $(ALL) 10 | 11 | clean: 12 | rm -f $(ALL) 13 | -------------------------------------------------------------------------------- /tests/hello/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #if defined(__linux__) || !defined(__NetBSD__) 9 | # error compiler wrapper fail 10 | #endif 11 | 12 | int 13 | rumprun_test(int argc, char *argv[]) 14 | { 15 | char *world = getenv("WORLD"); 16 | time_t now; 17 | 18 | if (world) 19 | printf ("Hello, %s!\n", world); 20 | else 21 | printf ("Hello, world!\n"); 22 | 23 | now = time(NULL); 24 | printf("When you do not hear the beep the time will be exactly:\n%s", 25 | ctime(&now)); 26 | 27 | printf("Sleeping 1s...\n"); 28 | sleep(1); 29 | 30 | now = time(NULL); 31 | printf("Goodbye, world, precisely at:\n%s", ctime(&now)); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /tests/hello/hellopp.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int 6 | rumprun_test(int argc, char *argv[]) 7 | { 8 | 9 | std::cout << "hello, c++" << std::endl; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /tests/nolibc/Makefile: -------------------------------------------------------------------------------- 1 | include ../../global.mk 2 | include ${BUILDRUMP_TOOLFLAGS} 3 | 4 | CFLAGS+= ${BUILDRUMP_TOOL_CFLAGS} 5 | 6 | LDFLAGS:= -L$(abspath ../../rumprun/rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}) 7 | LDFLAGS+= -L${RROBJ}/lib/libcompiler_rt 8 | 9 | CPPFLAGS+= -I../../include -I../../rumprun/rumprun-${MACHINE_GNU_ARCH}/include 10 | CPPFLAGS+= -I../../platform/${PLATFORM}/include 11 | 12 | LDSCRIPT= ${RROBJ}/bmk.ldscript 13 | 14 | LDFLAGS+= ${LDFLAGS.${MACHINE_GNU_ARCH}.${PLATFORM}} 15 | 16 | OBJS= main.o ${RROBJ}/rumprun.o 17 | 18 | .PHONY: clean 19 | 20 | main.elf: ${OBJS} 21 | ${CC} ${CFLAGS} ${LDFLAGS} -T${LDSCRIPT} \ 22 | ${OBJS} \ 23 | -nostdlib \ 24 | -Wl,--whole-archive -lrumpvfs -lrump -Wl,--no-whole-archive \ 25 | -lcompiler_rt \ 26 | -o $@ 27 | 28 | clean: 29 | rm -rf main.o main.elf 30 | -------------------------------------------------------------------------------- /tests/nolibc/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "nolibc.h" 7 | 8 | #include 9 | #include 10 | 11 | static ssize_t 12 | writestr(int fd, const char *str) 13 | { 14 | return rump_sys_write(fd, str, bmk_strlen(str)); 15 | } 16 | 17 | void 18 | bmk_mainthread(void *cmdline) 19 | { 20 | int rv, fd; 21 | 22 | rv = rump_init(); 23 | bmk_printf("rump kernel init complete, rv %d\n", rv); 24 | 25 | writestr(1, "Hello, stdout!\n"); 26 | 27 | bmk_printf("open(/notexisting): "); 28 | fd = rump_sys_open("/notexisting", 0); 29 | if (fd == -1) { 30 | int errno = *bmk_sched_geterrno(); 31 | if (errno == RUMP_ENOENT) { 32 | bmk_printf("No such file or directory. All is well.\n"); 33 | } else { 34 | bmk_printf("Something went wrong. errno = %d\n", errno); 35 | } 36 | } else { 37 | bmk_printf("Success?! fd=%d\n", fd); 38 | } 39 | 40 | rump_sys_reboot(0, 0); 41 | } 42 | -------------------------------------------------------------------------------- /tests/nolibc/nolibc.h: -------------------------------------------------------------------------------- 1 | #ifndef _NOLIBC_H_ 2 | #define _NOLIBC_H_ 3 | 4 | #include 5 | #include 6 | 7 | /* fake some POSIX types used in the compat system calls */ 8 | #define RUMP_HOST_NOT_POSIX 9 | 10 | typedef int clockid_t; 11 | typedef unsigned int socklen_t; 12 | typedef int timer_t; 13 | 14 | typedef int pid_t; 15 | typedef long ssize_t; 16 | typedef unsigned long size_t; 17 | typedef long register_t; 18 | 19 | typedef int64_t off_t; 20 | typedef uint64_t dev_t; 21 | typedef uint32_t mode_t; 22 | typedef int gid_t; 23 | typedef int uid_t; 24 | 25 | typedef unsigned int u_int; 26 | typedef unsigned long u_long; 27 | 28 | struct timespec; 29 | struct itimerspec; 30 | struct sigevent; 31 | struct sockaddr; 32 | 33 | typedef void fd_set; 34 | typedef void sigset_t; 35 | 36 | #endif /* _NOLIBC_H_ */ 37 | --------------------------------------------------------------------------------