├── .bintray_descriptor.json ├── .clang-format ├── .clang_complete ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── Dockerfile ├── LICENSE ├── README.md ├── arch ├── aarch64 │ ├── CMakeLists.txt │ ├── include │ │ └── asm │ │ │ ├── atomic.h │ │ │ ├── atomic32.h │ │ │ ├── atomic64.h │ │ │ ├── io.h │ │ │ ├── irq.h │ │ │ ├── irqflags.h │ │ │ ├── limits.h │ │ │ ├── page.h │ │ │ ├── pci.h │ │ │ ├── processor.h │ │ │ ├── stddef.h │ │ │ ├── string.h │ │ │ ├── tasks.h │ │ │ ├── tasks_types.h │ │ │ ├── time.h │ │ │ ├── uart.h │ │ │ └── uhyve.h │ ├── kernel │ │ ├── entry.S │ │ ├── irq.c │ │ ├── processor.c │ │ ├── signal.c │ │ ├── signal.dep │ │ ├── tasks.c │ │ ├── tasks.dep │ │ ├── timer.c │ │ ├── timer.dep │ │ ├── uart.c │ │ └── uart.dep │ ├── libkern │ │ ├── memcpy.S │ │ ├── memset.S │ │ └── strlen.S │ └── mm │ │ ├── memory.c │ │ ├── memory.dep │ │ ├── page.c │ │ ├── page.dep │ │ ├── vma.c │ │ └── vma.dep └── x86_64 │ ├── CMakeLists.txt │ ├── include │ └── asm │ │ ├── apic.h │ │ ├── atomic.h │ │ ├── atomic32.h │ │ ├── atomic64.h │ │ ├── gdt.h │ │ ├── idt.h │ │ ├── io.h │ │ ├── irq.h │ │ ├── irqflags.h │ │ ├── isrs.h │ │ ├── limits.h │ │ ├── multiboot.h │ │ ├── page.h │ │ ├── pci.h │ │ ├── processor.h │ │ ├── stddef.h │ │ ├── string.h │ │ ├── tasks.h │ │ ├── tasks_types.h │ │ ├── time.h │ │ ├── tss.h │ │ ├── uart.h │ │ └── uhyve.h │ ├── kernel │ ├── apic.c │ ├── boot.asm │ ├── entry.asm │ ├── gdt.c │ ├── idt.c │ ├── irq.c │ ├── isrs.c │ ├── pci.c │ ├── pcihdr.h │ ├── processor.c │ ├── signal.c │ ├── syscall.c │ ├── tasks.c │ ├── timer.c │ └── uart.c │ ├── libkern │ └── string.asm │ ├── loader │ ├── CMakeLists.txt │ ├── entry.asm │ ├── include │ │ ├── ctype.h │ │ ├── elf.h │ │ ├── io.h │ │ ├── limits.h │ │ ├── multiboot.h │ │ ├── page.h │ │ ├── stdarg.h │ │ ├── stddef.h │ │ ├── stdio.h │ │ ├── string.h │ │ └── uart.h │ ├── link.ld │ ├── main.c │ ├── page.c │ ├── printf.c │ ├── stdio.c │ ├── string.c │ ├── strstr.c │ ├── strtol.c │ └── uart.c │ └── mm │ ├── hbmemory.c │ ├── memory.c │ ├── page.c │ └── vma.c ├── cmake ├── HermitCore-Application.cmake ├── HermitCore-Configuration.cmake ├── HermitCore-Paths.cmake ├── HermitCore-Toolchain-aarch64-bootstrap.cmake ├── HermitCore-Toolchain-aarch64.cmake ├── HermitCore-Toolchain-x86_64-bootstrap.cmake ├── HermitCore-Toolchain-x86_64.cmake ├── HermitCore-Utils.cmake ├── HermitCore.cmake ├── README.md ├── golang │ ├── CMakeDetermineGoCompiler.cmake │ ├── CMakeGoCompiler.cmake.in │ ├── CMakeGoInformation.cmake │ └── CMakeTestGoCompiler.cmake └── local-cmake.sh ├── config ├── bzImage ├── ifcfg-mmnif ├── initrd.cpio ├── linux_config ├── linux_config_centos7 └── linux_config_fc23 ├── docker └── Dockerfile ├── drivers └── net │ ├── e1000.c │ ├── e1000.h │ ├── mmnif.c │ ├── mmnif.h │ ├── rtl8139.c │ ├── rtl8139.h │ ├── uhyve-net.c │ ├── uhyve-net.h │ ├── util.c │ ├── util.h │ ├── vioif.c │ └── vioif.h ├── img ├── demo.gif ├── hermitcore_logo.png └── hermitcore_logo.svg ├── include ├── hermit │ ├── CMakeLists.txt │ ├── config.asm.in │ ├── config.h.in │ ├── ctype.h │ ├── dequeue.h │ ├── errno.h │ ├── islelock.h │ ├── logging.h │ ├── mailbox.h │ ├── mailbox_types.h │ ├── malloc.h │ ├── memory.h │ ├── processor.h │ ├── rcce.h │ ├── semaphore.h │ ├── semaphore_types.h │ ├── signal.h │ ├── spinlock.h │ ├── spinlock_types.h │ ├── stdarg.h │ ├── stddef.h │ ├── stdio.h │ ├── stdlib.h │ ├── string.h │ ├── syscall.h │ ├── tasks.h │ ├── tasks_types.h │ ├── time.h │ ├── virtio_config.h │ ├── virtio_ids.h │ ├── virtio_net.h │ ├── virtio_pci.h │ ├── virtio_ring.h │ ├── virtio_types.h │ └── vma.h ├── netinet │ ├── in.h │ └── tcp.h ├── stdarg.h ├── stddef.h ├── stdlib.h ├── string.h └── sys │ ├── ipc.h │ ├── poll.h │ ├── shm.h │ └── uio.h ├── kernel ├── main.c ├── syscall.c ├── tasks.c └── timer.c ├── libkern ├── printf.c ├── sprintf.c ├── stdio.c ├── string.c ├── strstr.c ├── strtol.c └── strtoul.c ├── mm ├── malloc.c └── vma.c ├── tests.sh ├── tools ├── demo_ircce.sh ├── demo_kvm.sh ├── demo_omp.sh └── init.sh └── usr ├── benchmarks ├── CMakeLists.txt ├── RCCE_pingping.c ├── RCCE_pingpong.c ├── basic.c ├── hg.c ├── hist.c ├── hist.h ├── init.c ├── init.h ├── netio.c ├── opt.c ├── opt.h ├── rdtsc.c ├── rdtsc.h ├── report.c ├── report.h ├── run.c ├── run.h ├── setup.c ├── setup.h └── stream.c ├── gdb ├── README.md ├── hermit-gdb.py └── hermit │ ├── __init__.py │ └── tasks.py ├── ircce ├── CMakeLists.txt ├── RCCE.h ├── RCCE_admin.c ├── RCCE_bcast.c ├── RCCE_comm.c ├── RCCE_debug.c ├── RCCE_debug.h ├── RCCE_flags.c ├── RCCE_get.c ├── RCCE_lib.h ├── RCCE_malloc.c ├── RCCE_put.c ├── RCCE_qsort.c ├── RCCE_recv.c ├── RCCE_reduce.c ├── RCCE_send.c ├── RCCE_synch.c ├── iRCCE.h ├── iRCCE_admin.c ├── iRCCE_atomic.c ├── iRCCE_get.c ├── iRCCE_irecv.c ├── iRCCE_isend.c ├── iRCCE_lib.h ├── iRCCE_mcast.c ├── iRCCE_put.c ├── iRCCE_srecv.c ├── iRCCE_ssend.c ├── iRCCE_synch.c ├── iRCCE_waitlist.c ├── rte_memcpy.h └── syscall.h ├── openmpbench ├── .gitignore ├── CMakeLists.txt ├── Licence.txt ├── README.txt ├── arraybench.c ├── arraybench.h ├── common.c ├── common.h ├── schedbench.c ├── schedbench.h ├── syncbench.c ├── syncbench.h ├── taskbench.c └── taskbench.h ├── tests ├── CMakeLists.txt ├── RCCE_minimum.c ├── allocator.c ├── argv_envp.c ├── endless.c ├── hello++.cpp ├── hello.c ├── hellof.f90 ├── jacobi.c ├── nweb23.c ├── pi.go ├── server.go ├── signals.c ├── test-malloc-mt.c ├── test-malloc.c └── thr_hello.c └── xray ├── CMakeLists.txt ├── LICENSE ├── README.md ├── browser.c ├── demangle.c ├── hashtable.c ├── libxray.spec ├── parsesymbols.c ├── report.c ├── stringpool.c ├── symtable.c ├── tools ├── conv2kcg.py └── report.xray ├── xray.c ├── xray.h ├── xray.odt └── xray_priv.h /.bintray_descriptor.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "name": "libhermit", 4 | "repo": "REPLACE_REPO", 5 | "subject": "hermitcore", 6 | "website_url": "http://www.hermitcore.org", 7 | "issue_tracker_url": "https://github.com/RWTH-OS/HermitCore/issues", 8 | "vcs_url": "https://github.com/hermitcore/libhermit.git", 9 | "github_release_notes_file": "RELEASE", 10 | "licenses": ["Revised BSD"], 11 | "public_download_numbers": false, 12 | "public_stats": false 13 | }, 14 | 15 | "version": { 16 | "name": "0.2.10", 17 | "desc": "HermitCore's kernel as libOS", 18 | "gpgSign": false 19 | }, 20 | 21 | "files": 22 | [ 23 | { 24 | "includePattern": "../(libhermit[^/]*.deb$)", "uploadPattern": "$1", 25 | "matrixParams": { 26 | "deb_distribution": "REPLACE_OS", 27 | "deb_component": "main", 28 | "deb_architecture": "amd64", 29 | "override": 1} 30 | } 31 | ], 32 | "publish": true 33 | } 34 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true 2 | -------------------------------------------------------------------------------- /.clang_complete: -------------------------------------------------------------------------------- 1 | -Ihermit/include 2 | -Ihermit/arch/x86/include 3 | -Ihermit/lwip/src/include 4 | -Ihermit/lwip/src/include/ipv4 5 | -Ihermit/drivers 6 | -nostdinc 7 | -ffreestanding 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pcap 2 | *.config 3 | *.creator 4 | *.user 5 | *.files 6 | *.includes 7 | *.pyc 8 | *.callgrind 9 | *.xray 10 | *.o 11 | *.ko 12 | **/build/* 13 | .idea/* 14 | qemu-vlan0.pcap 15 | cmake/cmake-3.7.2-Linux-x86_64/* 16 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | IMAGE: ubuntu:with-hermitcore 3 | GIT_SUBMODULE_STRATEGY: normal 4 | 5 | stages: 6 | - prepare 7 | - build 8 | - test 9 | 10 | # Stage: prepare 11 | ############################################################################## 12 | 13 | docker: 14 | stage: prepare 15 | script: 16 | - docker build -t ${IMAGE} . 17 | tags: 18 | - shell 19 | - linux 20 | 21 | # Stage: build 22 | ############################################################################## 23 | 24 | build: 25 | stage: build 26 | script: 27 | - mkdir -p build 28 | - cd build 29 | - cmake -DTOOLCHAIN_BIN_DIR=/opt/hermit/bin -DCMAKE_INSTALL_PREFIX=/opt/hermit .. 30 | - make 31 | image: ${IMAGE} 32 | tags: 33 | - docker 34 | artifacts: 35 | untracked: true 36 | expire_in: 1 week 37 | paths: 38 | - ./build 39 | 40 | # Stage: test 41 | ############################################################################## 42 | test: 43 | stage: test 44 | script: 45 | - lscpu 46 | - cd build 47 | - export TDIR=./local_prefix/opt/hermit/x86_64-hermit/extra 48 | - export FILES="$TDIR/tests/hello $TDIR/tests/hellof $TDIR/tests/hello++ $TDIR/tests/thr_hello $TDIR/tests/pi $TDIR/benchmarks/stream $TDIR/benchmarks/basic $TDIR/tests/signals $TDIR/tests/test-malloc $TDIR/tests/test-malloc-mt $TDIR/tests/argv_envp" 49 | - export PROXY=./local_prefix/opt/hermit/bin/proxy 50 | - for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done 51 | - for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=2 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done 52 | - HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 HERMIT_APP_PORT=8000 $PROXY $TDIR/tests/server & 53 | - sleep 10 54 | - curl http://127.0.0.1:8000/help 55 | - sleep 1 56 | - curl http://127.0.0.1:8000/hello 57 | - sleep 1 58 | - kill $! 59 | image: ${IMAGE} 60 | tags: 61 | - docker 62 | dependencies: 63 | - build 64 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lwip"] 2 | path = lwip 3 | url = https://github.com/hermitcore/LwIP.git 4 | branch = hermit 5 | [submodule "caves"] 6 | path = caves 7 | url = https://github.com/hermitcore/hermit-caves.git 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | git: 3 | depth: 3 4 | submodules: true 5 | env: 6 | matrix: 7 | - OS_TYPE=debian OS_VERSION=9 OS_NAME=stretch 8 | - OS_TYPE=ubuntu OS_VERSION=18.04 OS_NAME=bionic 9 | services: 10 | - docker 11 | addons: 12 | apt: 13 | update: true 14 | before_install: 15 | - sudo apt-get -qq update 16 | - sudo docker pull ${OS_TYPE}:${OS_VERSION} 17 | script: 18 | - docker run -ti -v ${TRAVIS_BUILD_DIR}:/work:rw ${OS_TYPE}:${OS_VERSION} /bin/bash 19 | -c "cd /work; ./tests.sh ${OS_TYPE} ${OS_NAME}" 20 | before_deploy: 21 | - cd ${TRAVIS_BUILD_DIR} 22 | - dpkg-deb -b tmp libhermit-0.2.10-all.deb 23 | - sed -i "s/REPLACE_REPO/$OS_TYPE/" .bintray_descriptor.json 24 | - sed -i "s/REPLACE_OS/$OS_NAME/" .bintray_descriptor.json 25 | deploy: 26 | provider: bintray 27 | on: 28 | branch: master 29 | skip_cleanup: true 30 | file: ".bintray_descriptor.json" 31 | user: 32 | secure: kiTa03QyprxZfL8QuWCLuMnWUpMAhOlmwpHP2BdYsBTNEXS4vfNbOLZSUUWRi29tg1/zdXbIexoUXEmt/ZpDiM0W0kpZrcxvt/bi181RUVei9eoim+GL4jtJ5R7JKBIJuDXbCZiDQTs/oaiIv1EFkMKQeHl6GIiLIl3ehnqNyvpJvJC713uW6PTbxUjz20pfhFiq7B73j/onLVTC1m19L9lFnsryxatDN7zny/qZHmyel3ggDbPokv7jZwSYNs/X6yyOF1RQZ2qqIML0YLtkLqdrCqviSD/8p7OdNN34ACf6I+D5GIzZd1arlrOO2RsB+mIlDxoOiCNtwPbCVs3ReY9DOlNBxs/fABEyVyEWX20VboiLbWbhCok6V4Uk95BCHBbp6ceP06NhQ9gFbqFJwQe6NG/XlQbrKBp7Yj3+GovcNDjWVcHYpSuc4a7+1unM3tfPMFREgloTX0xg017H1eiRiR2viJsMuCmtCXteZ8H9qTx1l8Kf+cXKtg/h+XIkzDbIwhlO/jE3Bss7LSDNghYUBo2meEEJgibbFCuNQCFoA5doYCOMz4rO1YT3uI2fBLisAIqys+e3zGfmHARejjMASjdwT5vZzDNeeiTE8/2zG5X7Ow697TI+HtnFE+/hCZ4RAmu+vz6/IZYYO/Mf7kIAs8WGfcAkuCPzYXBoA10= 33 | key: 34 | secure: fg8+5owyDFPt3H/+Xk8jGHtEBasz1C2K0i+z92f/JnjTyLCrrKn+6DX7VRgcEl4ketTWLex7JduJLl4/7Ftug8qN0NuMwx0OxDCrwzvkoVwbl2DYX8von9ceuuV57p4e+uG35bPjU7E1KblkL+7ERqn9hsp5NbVdb4ueoSl9LedDdfzwcz8iA8JmzpbJ5RwQqg4kmdvuRVEUZMbQeHq4KB3kTznsma3BUeApVSaRQ8BpSaHED0tzFWKUTdjq7GvjBMF6WNpVIsc7Usky78UUyjaGbfMyT/7i9RctC3rAXr2XZryxDrJstAnHo6trqraf/3E40a7r0LhF9y7HWdmlfG99qhT3Vii3/pHeRIDp5O6xpIF8o/QkbYaFTwcvefRCjRQ8YYREqYvYnXOsKge/VaoUx48pTn6fOPzEzvlbyTkJ6Wp7knhx4qzR5JB8yTbIjoozggrkayvkYVfdMZjXvY/2T8TcNbPG0+0+EVkUcNrNMy9ksAH4RgR+eVQ4oI/sg5ldnVpp74jhSSDgAHBKCZQ01tIYMMEIyZm7qhAAdXnjCeV6D78a8/brUN+TSRNGYILx4vTiY3GMLEHsDGH4VEGawef0CtQasBrt5Cc0a/3KDNwuBy8rlbxLxbv+JCCn9vMm+UYQ6sTexsih76V07OHmQliu0xjQgBG5maFaV74= 35 | 36 | after_deploy: 37 | - | 38 | if [ "$OS_TYPE" == "ubuntu" ]; then 39 | docker login -u $DOCKER_USER -p $DOCKER_PASS 40 | export REPO=rwthos/hermitcore 41 | export TAG=`if [ "$TRAVIS_BRANCH" == "master" ]; then echo "latest"; else echo $TRAVIS_BRANCH ; fi` 42 | cd ${TRAVIS_BUILD_DIR}/docker 43 | docker build -f Dockerfile -t $REPO . 44 | docker tag $REPO $REPO:$TAG 45 | docker tag $REPO $REPO:travis-$TRAVIS_BUILD_NUMBER 46 | docker push $REPO 47 | fi 48 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Download base image ubuntu 18.04 2 | FROM ubuntu:18.04 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | # Update Software repository 7 | RUN apt-get -qq update 8 | 9 | # Install required packets from ubuntu repository 10 | RUN apt-get install -y apt-transport-https curl wget vim nano git binutils autoconf automake make cmake qemu-kvm qemu-system-x86 nasm gcc g++ build-essential libtool bsdmainutils 11 | 12 | # add path to hermitcore packets 13 | RUN echo "deb [trusted=yes] https://dl.bintray.com/hermitcore/ubuntu bionic main" | tee -a /etc/apt/sources.list 14 | 15 | # Update Software repository 16 | RUN apt-get -qq update 17 | 18 | # Install required packets from ubuntu repository 19 | RUN apt-get install -y --allow-unauthenticated binutils-hermit newlib-hermit pte-hermit gcc-hermit libhermit libomp-hermit 20 | 21 | ENV PATH="/opt/hermit/bin:${PATH}" 22 | ENV EDITOR=vim 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2010-2017, RWTH Aachen University, Germany 4 | 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 are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /arch/aarch64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore.cmake) 3 | 4 | project(arch_aarch64_kernel C ASM) 5 | 6 | set_parent(AARCH64_KERNEL_TARGET ${PROJECT_NAME}) 7 | set_parent(ARCH_KERNEL_TARGET ${PROJECT_NAME}) 8 | set_parent(AARCH64_KERNEL_C_TARGET ${AARCH64_KERNEL_TARGET}_c) 9 | 10 | set_source_files_properties(kernel/*.S PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") 11 | 12 | add_custom_target(${AARCH64_KERNEL_TARGET}) 13 | 14 | # compiling kernel code here 15 | add_definitions(-D__KERNEL__) 16 | 17 | ### C sources ### 18 | 19 | file(GLOB KERNEL_SOURCES "kernel/*.c") 20 | file(GLOB KERNEL_S_SOURCES "kernel/*.S") 21 | file(GLOB LIBKERN_S_SOURCES "libkern/*.S") 22 | file(GLOB MM_SOURCES "mm/*.c") 23 | 24 | add_library(${AARCH64_KERNEL_C_TARGET} OBJECT 25 | ${KERNEL_SOURCES} ${KERNEL_S_SOURCES} ${MM_SOURCES} ${LIBKERN_S_SOURCES}) 26 | 27 | target_include_directories(${AARCH64_KERNEL_C_TARGET} BEFORE 28 | PUBLIC ${HERMIT_KERNEL_INCLUDES} 29 | PRIVATE ${GENERATED_CONFIG_DIR}) 30 | 31 | target_compile_options(${AARCH64_KERNEL_C_TARGET} 32 | PRIVATE ${HERMIT_KERNEL_FLAGS}) 33 | -------------------------------------------------------------------------------- /arch/aarch64/include/asm/atomic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/arm64/include/asm/atomic.h 31 | * @brief Functions for atomic operations 32 | * 33 | * This file prepare atomic operations on int32 & int64_t variables 34 | * which will be used in locking-mechanisms. 35 | */ 36 | 37 | #ifndef __ARCH_ATOMIC_H__ 38 | #define __ARCH_ATOMIC_H__ 39 | 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | static inline void atomic_barrier(void) 47 | { 48 | asm volatile ("" : : : "memory"); 49 | } 50 | 51 | /** @brief Makro for initialization of atomic vars 52 | * 53 | * Whenever you use an atomic variable, init it with 54 | * this macro first.\n 55 | * Example: atomic_int32_t myAtomicVar = ATOMIC_INIT(123); 56 | * 57 | * @param i The number value you want to init it with. 58 | */ 59 | #define ATOMIC_INIT(i) { (i) } 60 | 61 | 62 | #include 63 | #include 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /arch/aarch64/include/asm/tasks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/arm64/include/asm/tasks.h 31 | * @brief Task related structure definitions 32 | * 33 | * This file contains the task_t structure definition 34 | * and task state define constants 35 | */ 36 | 37 | #ifndef __ASM_TASKS_H__ 38 | #define __ASM_TASKS_H__ 39 | 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @brief Setup a default frame for a new task 47 | * 48 | * @param task Pointer to the task structure 49 | * @param ep The entry point for code execution 50 | * @param arg Arguments list pointer for the task's stack 51 | * @param core_id Id of the core, which is firstly used by the task 52 | * @return 53 | * - 0 on success 54 | * - -EINVAL (-22) on failure 55 | */ 56 | int create_default_frame(task_t* task, entry_point_t ep, void* arg, uint32_t core_id); 57 | 58 | /** @brief Architecture dependent initialize routine 59 | */ 60 | static inline void arch_init_task(task_t* task) {} 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /arch/aarch64/include/asm/tasks_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/arm64/include/asm/tasks_types.h 31 | * @brief Task related structure definitions 32 | * 33 | * This file contains the task_t structure definition 34 | * and task state define constants 35 | */ 36 | 37 | #ifndef __ASM_TASKS_TYPES_H__ 38 | #define __ASM_TASKS_TYPES_H__ 39 | 40 | #include 41 | //#include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | union fpu_state { 48 | int dummy_value; 49 | }; 50 | 51 | #define FPU_STATE_INIT 52 | 53 | /*typedef void (*handle_fpu_state)(union fpu_state* state); 54 | 55 | extern handle_fpu_state save_fpu_state; 56 | extern handle_fpu_state restore_fpu_state; 57 | extern handle_fpu_state fpu_init;*/ 58 | 59 | static inline void save_fpu_state(union fpu_state* state){} 60 | static inline void restore_fpu_state(union fpu_state* state){} 61 | static inline void fpu_init(union fpu_state* state){} 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /arch/aarch64/include/asm/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/arm64/include/asm/string.h 31 | * @brief Time related functions 32 | */ 33 | 34 | #ifndef __ARCH_TIME_H__ 35 | #define __ARCH_TIME_H__ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | int timer_deadline(uint32_t t); 44 | 45 | void timer_disable(void); 46 | 47 | int timer_is_running(void); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /arch/aarch64/include/asm/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2017, Stefan Lankes, Daniel Krebs, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __ARCH_UART_H__ 29 | #define __ARCH_UART_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @brief Initialize UART output 38 | * 39 | * @return Returns 0 on success 40 | */ 41 | int uart_init(void); 42 | 43 | /** @brief Initialize UART output without a device check 44 | * 45 | * @return Returns 0 on success 46 | */ 47 | int uart_early_init(char*); 48 | 49 | /** @brief Simple string output on a serial device. 50 | * 51 | * If you want a new line you will have to "\\n". 52 | * 53 | * @return Length of output in bytes 54 | */ 55 | int uart_puts(const char *text); 56 | 57 | /** @brief Simple character output on a serial device. 58 | * 59 | * @return The original input character casted to int 60 | */ 61 | int uart_putchar(unsigned char c); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /arch/aarch64/include/asm/uhyve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/arm64/include/asm/uhyve.h 31 | * @brief interface to our machine monitor 32 | */ 33 | 34 | #ifndef __ARCH_UHYVE_H__ 35 | #define __ARCH_UHYVE_H__ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | inline static void uhyve_send(unsigned short _port, unsigned int _data) 44 | { 45 | *((unsigned int*)(size_t)_port) = _data; 46 | } 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /arch/aarch64/kernel/signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #include 28 | 29 | int hermit_signal(signal_handler_t handler) 30 | { 31 | //task_t* curr_task = per_core(current_task); 32 | //curr_task->signal_handler = handler; 33 | 34 | return 0; 35 | } 36 | 37 | int hermit_kill(tid_t dest, int signum) 38 | { 39 | return 0; 40 | } 41 | 42 | void signal_init(void) 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /arch/aarch64/kernel/signal.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/kernel/signal.o: arch/arm64/kernel/signal.c \ 2 | /home/stefan/HermitCore/include/hermit/signal.h \ 3 | /home/stefan/HermitCore/include/hermit/stddef.h \ 4 | /home/stefan/HermitCore/include/hermit/config.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 6 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 7 | /home/stefan/HermitCore/include/hermit/semaphore_types.h \ 8 | /home/stefan/HermitCore/include/hermit/spinlock_types.h \ 9 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic.h \ 10 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic32.h \ 11 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic64.h 12 | -------------------------------------------------------------------------------- /arch/aarch64/kernel/tasks.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/kernel/tasks.o: arch/arm64/kernel/tasks.c \ 2 | /home/stefan/HermitCore/include/hermit/stdio.h \ 3 | /home/stefan/HermitCore/include/hermit/config.h \ 4 | /home/stefan/HermitCore/include/hermit/stddef.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 6 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 7 | /home/stefan/HermitCore/include/hermit/stdarg.h \ 8 | /home/stefan/HermitCore/include/hermit/stdlib.h 9 | -------------------------------------------------------------------------------- /arch/aarch64/kernel/timer.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/kernel/timer.o: arch/arm64/kernel/timer.c \ 2 | /home/stefan/HermitCore/include/hermit/stdio.h \ 3 | /home/stefan/HermitCore/include/hermit/config.h \ 4 | /home/stefan/HermitCore/include/hermit/stddef.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 6 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 7 | /home/stefan/HermitCore/include/hermit/stdarg.h \ 8 | /home/stefan/HermitCore/include/hermit/string.h \ 9 | /home/stefan/HermitCore/arch/arm64/include/asm/string.h \ 10 | /home/stefan/HermitCore/include/hermit/processor.h \ 11 | /home/stefan/HermitCore/arch/arm64/include/asm/processor.h \ 12 | /home/stefan/HermitCore/include/hermit/time.h \ 13 | /home/stefan/HermitCore/arch/arm64/include/asm/time.h \ 14 | /home/stefan/HermitCore/include/hermit/tasks.h \ 15 | /home/stefan/HermitCore/include/hermit/tasks_types.h \ 16 | /home/stefan/HermitCore/include/hermit/spinlock_types.h \ 17 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic.h \ 18 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic32.h \ 19 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic64.h \ 20 | /home/stefan/HermitCore/include/hermit/vma.h \ 21 | /home/stefan/HermitCore/arch/arm64/include/asm/page.h \ 22 | /home/stefan/HermitCore/include/hermit/stdlib.h \ 23 | /home/stefan/HermitCore/include/hermit/signal.h \ 24 | /home/stefan/HermitCore/include/hermit/semaphore_types.h \ 25 | /home/stefan/HermitCore/arch/arm64/include/asm/tasks_types.h \ 26 | /home/stefan/HermitCore/arch/arm64/include/asm/tasks.h \ 27 | /home/stefan/HermitCore/include/hermit/errno.h \ 28 | /home/stefan/HermitCore/include/hermit/spinlock.h \ 29 | /home/stefan/HermitCore/include/hermit/logging.h \ 30 | /home/stefan/HermitCore/include/hermit/syscall.h \ 31 | /home/stefan/HermitCore/include/stdlib.h 32 | -------------------------------------------------------------------------------- /arch/aarch64/kernel/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2017, Stefan Lankes, Daniel Krebs, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | volatile static unsigned int* mmio = NULL; 36 | extern unsigned int uart_mmio; 37 | 38 | /* Puts a single character on a serial device */ 39 | int uart_putchar(unsigned char c) 40 | { 41 | if (mmio) 42 | *mmio = (unsigned int) c; 43 | 44 | return (int) c; 45 | } 46 | 47 | /* Uses the routine above to output a string... */ 48 | int uart_puts(const char *text) 49 | { 50 | size_t i, len = strlen(text); 51 | 52 | if (!mmio) 53 | return 0; 54 | 55 | for (i = 0; i < len; i++) 56 | uart_putchar(text[i]); 57 | 58 | return len; 59 | } 60 | 61 | int uart_early_init(char* cmdline) 62 | { 63 | if (is_uhyve()) { 64 | mmio = (unsigned int*) uart_mmio; 65 | } else { 66 | // default value of our QEMU configuration 67 | mmio = (unsigned int*) 0x09000000; 68 | } 69 | 70 | return 0; 71 | } 72 | 73 | int uart_init(void) 74 | { 75 | if (is_uhyve()) { 76 | mmio = (unsigned int*) uart_mmio; 77 | } else { 78 | mmio = (unsigned int*) 0x09000000; 79 | } 80 | 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /arch/aarch64/kernel/uart.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/kernel/uart.o: arch/arm64/kernel/uart.c \ 2 | /home/stefan/HermitCore/include/hermit/stdlib.h \ 3 | /home/stefan/HermitCore/include/hermit/config.h \ 4 | /home/stefan/HermitCore/include/hermit/stddef.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 6 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 7 | /home/stefan/HermitCore/include/hermit/stdio.h \ 8 | /home/stefan/HermitCore/include/hermit/stdarg.h \ 9 | /home/stefan/HermitCore/include/hermit/errno.h \ 10 | /home/stefan/HermitCore/include/hermit/string.h \ 11 | /home/stefan/HermitCore/arch/arm64/include/asm/string.h \ 12 | /home/stefan/HermitCore/include/hermit/ctype.h \ 13 | /home/stefan/HermitCore/arch/arm64/include/asm/uart.h 14 | -------------------------------------------------------------------------------- /arch/aarch64/mm/memory.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/mm/memory.o: arch/arm64/mm/memory.c \ 2 | /home/stefan/HermitCore/include/hermit/stddef.h \ 3 | /home/stefan/HermitCore/include/hermit/config.h \ 4 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 6 | /home/stefan/HermitCore/include/hermit/stdlib.h \ 7 | /home/stefan/HermitCore/include/hermit/stdio.h \ 8 | /home/stefan/HermitCore/include/hermit/stdarg.h \ 9 | /home/stefan/HermitCore/include/hermit/string.h \ 10 | /home/stefan/HermitCore/arch/arm64/include/asm/string.h \ 11 | /home/stefan/HermitCore/include/hermit/spinlock.h \ 12 | /home/stefan/HermitCore/include/hermit/spinlock_types.h \ 13 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic.h \ 14 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic32.h \ 15 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic64.h \ 16 | /home/stefan/HermitCore/include/hermit/tasks_types.h \ 17 | /home/stefan/HermitCore/include/hermit/vma.h \ 18 | /home/stefan/HermitCore/arch/arm64/include/asm/page.h \ 19 | /home/stefan/HermitCore/arch/arm64/include/asm/processor.h \ 20 | /home/stefan/HermitCore/include/hermit/signal.h \ 21 | /home/stefan/HermitCore/include/hermit/semaphore_types.h \ 22 | /home/stefan/HermitCore/arch/arm64/include/asm/tasks_types.h \ 23 | /home/stefan/HermitCore/include/hermit/errno.h \ 24 | /home/stefan/HermitCore/include/hermit/memory.h \ 25 | /home/stefan/HermitCore/include/hermit/logging.h \ 26 | /home/stefan/HermitCore/include/hermit/time.h \ 27 | /home/stefan/HermitCore/arch/arm64/include/asm/time.h \ 28 | /home/stefan/HermitCore/include/hermit/syscall.h \ 29 | /home/stefan/HermitCore/include/stdlib.h 30 | -------------------------------------------------------------------------------- /arch/aarch64/mm/page.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/mm/page.o: arch/arm64/mm/page.c \ 2 | /home/stefan/HermitCore/include/hermit/stdio.h \ 3 | /home/stefan/HermitCore/include/hermit/config.h \ 4 | /home/stefan/HermitCore/include/hermit/stddef.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 6 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 7 | /home/stefan/HermitCore/include/hermit/stdarg.h \ 8 | /home/stefan/HermitCore/include/hermit/memory.h \ 9 | /home/stefan/HermitCore/include/hermit/errno.h \ 10 | /home/stefan/HermitCore/include/hermit/string.h \ 11 | /home/stefan/HermitCore/arch/arm64/include/asm/string.h \ 12 | /home/stefan/HermitCore/include/hermit/spinlock.h \ 13 | /home/stefan/HermitCore/include/hermit/spinlock_types.h \ 14 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic.h \ 15 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic32.h \ 16 | /home/stefan/HermitCore/arch/arm64/include/asm/atomic64.h \ 17 | /home/stefan/HermitCore/include/hermit/tasks_types.h \ 18 | /home/stefan/HermitCore/include/hermit/vma.h \ 19 | /home/stefan/HermitCore/arch/arm64/include/asm/page.h \ 20 | /home/stefan/HermitCore/include/hermit/stdlib.h \ 21 | /home/stefan/HermitCore/arch/arm64/include/asm/processor.h \ 22 | /home/stefan/HermitCore/include/hermit/signal.h \ 23 | /home/stefan/HermitCore/include/hermit/semaphore_types.h \ 24 | /home/stefan/HermitCore/arch/arm64/include/asm/tasks_types.h \ 25 | /home/stefan/HermitCore/include/hermit/tasks.h \ 26 | /home/stefan/HermitCore/arch/arm64/include/asm/tasks.h \ 27 | /home/stefan/HermitCore/include/hermit/logging.h \ 28 | /home/stefan/HermitCore/include/hermit/time.h \ 29 | /home/stefan/HermitCore/arch/arm64/include/asm/time.h \ 30 | /home/stefan/HermitCore/include/hermit/syscall.h \ 31 | /home/stefan/HermitCore/include/stdlib.h 32 | -------------------------------------------------------------------------------- /arch/aarch64/mm/vma.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Steffen Vogel, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | int vma_arch_init(void) 31 | { 32 | // reserve virtual address space for IO ports 33 | return vma_add((size_t)0x00, 2*PAGE_SIZE, VMA_READ|VMA_WRITE); 34 | } 35 | -------------------------------------------------------------------------------- /arch/aarch64/mm/vma.dep: -------------------------------------------------------------------------------- 1 | arch/arm64/mm/vma.o: arch/arm64/mm/vma.c \ 2 | /home/stefan/HermitCore/include/hermit/vma.h \ 3 | /home/stefan/HermitCore/include/hermit/stddef.h \ 4 | /home/stefan/HermitCore/include/hermit/config.h \ 5 | /home/stefan/HermitCore/arch/arm64/include/asm/stddef.h \ 6 | /home/stefan/HermitCore/arch/arm64/include/asm/irqflags.h \ 7 | /home/stefan/HermitCore/arch/arm64/include/asm/page.h \ 8 | /home/stefan/HermitCore/include/hermit/stdlib.h \ 9 | /home/stefan/HermitCore/arch/arm64/include/asm/processor.h 10 | -------------------------------------------------------------------------------- /arch/x86_64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore.cmake) 3 | 4 | project(arch_x86_kernel C ASM_NASM) 5 | 6 | set_parent(X86_KERNEL_TARGET ${PROJECT_NAME}) 7 | set_parent(ARCH_KERNEL_TARGET ${PROJECT_NAME}) 8 | set_parent(X86_KERNEL_ASM_TARGET ${X86_KERNEL_TARGET}_asm) 9 | set_parent(X86_KERNEL_C_TARGET ${X86_KERNEL_TARGET}_c) 10 | 11 | add_custom_target(${X86_KERNEL_TARGET}) 12 | 13 | # compiling kernel code here 14 | add_definitions(-D__KERNEL__) 15 | 16 | 17 | ### ASM sources ### 18 | 19 | add_library(${X86_KERNEL_ASM_TARGET} OBJECT 20 | kernel/entry.asm 21 | libkern/string.asm) 22 | 23 | # HACK: We need to post-process the objects by running elfedit on them, but 24 | # there is currently no way to get the list of objects out of CMake 25 | # except for $, which only works with add_library() 26 | # and add_executable(). 27 | # So predict path to objects and add custom commands that depend on 28 | # the asm target. 29 | # 30 | # Upstream issue: https://gitlab.kitware.com/cmake/cmake/issues/15226 31 | # 32 | set(_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}") 33 | set(_BUILD_DIR "${_BUILD_DIR}/${X86_KERNEL_ASM_TARGET}.dir") 34 | 35 | get_target_property(ASM_SOURCES ${X86_KERNEL_ASM_TARGET} SOURCES) 36 | foreach(SOURCE ${ASM_SOURCES}) 37 | set(OBJECT "${SOURCE}.obj") 38 | set(OBJECT_PATH "${_BUILD_DIR}/${OBJECT}") 39 | 40 | # slash (/) not allowed in target names 41 | string(REPLACE "/" "-" 42 | OBJECT_TARGET_NAME 43 | "${OBJECT}") 44 | 45 | add_custom_target("${OBJECT_TARGET_NAME}" 46 | COMMAND 47 | ${CMAKE_ELFEDIT} --output-osabi Standalone ${OBJECT_PATH} 48 | DEPENDS 49 | ${X86_KERNEL_ASM_TARGET}) 50 | 51 | # make main target depend on this 52 | add_dependencies(${PROJECT_NAME} ${OBJECT_TARGET_NAME}) 53 | endforeach() 54 | 55 | 56 | ### C sources ### 57 | 58 | file(GLOB KERNEL_SOURCES "kernel/*.c") 59 | file(GLOB MM_SOURCES "mm/*.c") 60 | 61 | # add boot.h as source to mark dependency boot.asm -> boot.h -> apic.c 62 | add_library(${X86_KERNEL_C_TARGET} OBJECT 63 | ${KERNEL_SOURCES} ${MM_SOURCES} 64 | ${GENERATED_CONFIG_DIR}/hermit/boot.h) 65 | 66 | target_include_directories(${X86_KERNEL_C_TARGET} BEFORE 67 | PUBLIC ${HERMIT_KERNEL_INCLUDES} 68 | PRIVATE ${GENERATED_CONFIG_DIR}) 69 | 70 | target_compile_options(${X86_KERNEL_C_TARGET} 71 | PRIVATE ${HERMIT_KERNEL_FLAGS}) 72 | 73 | # assemble boot.asm and dump to C-array in boot.h 74 | add_custom_command( 75 | OUTPUT 76 | ${GENERATED_CONFIG_DIR}/hermit/boot.h 77 | DEPENDS 78 | kernel/boot.asm 79 | COMMAND 80 | echo "static const uint8_t boot_code[] = {" > boot.h 81 | COMMAND 82 | nasm -f bin -o boot.bin ${CMAKE_CURRENT_LIST_DIR}/kernel/boot.asm 83 | COMMAND 84 | hexdump -v -e "7/1 \"0x%02X, \" 1/1 \" 0x%02X,\\n\"" boot.bin >> boot.h 85 | COMMAND 86 | echo "};" >> boot.h 87 | WORKING_DIRECTORY 88 | ${GENERATED_CONFIG_DIR}/hermit/ 89 | VERBATIM USES_TERMINAL) 90 | -------------------------------------------------------------------------------- /arch/x86_64/include/asm/atomic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/x86/include/asm/atomic.h 31 | * @brief Functions for atomic operations 32 | * 33 | * This file prepare atomic operations on int32 & int64_t variables 34 | * which will be used in locking-mechanisms. 35 | */ 36 | 37 | #ifndef __ARCH_ATOMIC_H__ 38 | #define __ARCH_ATOMIC_H__ 39 | 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if MAX_CORES > 1 47 | #define LOCK "lock ; " 48 | #else 49 | #define LOCK "" 50 | #endif 51 | 52 | /** @brief Makro for initialization of atomic vars 53 | * 54 | * Whenever you use an atomic variable, init it with 55 | * this macro first.\n 56 | * Example: atomic_int32_t myAtomicVar = ATOMIC_INIT(123); 57 | * 58 | * @param i The number value you want to init it with. 59 | */ 60 | #define ATOMIC_INIT(i) { (i) } 61 | 62 | 63 | #include 64 | #include 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /arch/x86_64/include/asm/isrs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/x86/include/asm/isrs.h 31 | * @brief Installation of interrupt service routines 32 | * 33 | * This file contains the declaration of the ISR installer procedure.\n 34 | * There is more interesting code related to ISRs in the isrs.c file. 35 | */ 36 | 37 | #ifndef __ARCH_ISRS_H__ 38 | #define __ARCH_ISRS_H__ 39 | 40 | #include 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @brief ISR installer procedure 47 | * 48 | * This procedure sets the first 32 entries in the IDT 49 | * to the first 32 ISRs to call one general fault handler 50 | * which will do some dispatching and exception message logging.\n 51 | * The access flags are set to 0x8E (PRESENT, privilege: RING0, size: 32bit gate, type: interrupt gate). 52 | */ 53 | void isrs_install(void); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /arch/x86_64/include/asm/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/x86/include/asm/string.h 31 | * @brief Time related functions 32 | */ 33 | 34 | #ifndef __ARCH_TIME_H__ 35 | #define __ARCH_TIME_H__ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | static inline int timer_deadline(uint32_t t) { return apic_timer_deadline(t); } 44 | 45 | static inline void timer_disable(void) { apic_disable_timer(); } 46 | 47 | static inline int timer_is_running(void) { return apic_timer_is_running(); } 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /arch/x86_64/include/asm/tss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/x86/include/asm/tss.h 31 | * @brief Task state segment structure definition 32 | */ 33 | 34 | #ifndef __ARCH_TSS_H__ 35 | #define __ARCH_TSS_H__ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** @brief The tast state segment structure 44 | */ 45 | typedef struct { 46 | uint16_t res0, res1; // reserved entries 47 | uint64_t rsp0; 48 | uint64_t rsp1; 49 | uint64_t rsp2; 50 | uint32_t res2, res3; // reserved entries 51 | uint64_t ist1; 52 | uint64_t ist2; 53 | uint64_t ist3; 54 | uint64_t ist4; 55 | uint64_t ist5; 56 | uint64_t ist6; 57 | uint64_t ist7; 58 | uint32_t res4, res5; // reserved entries 59 | uint16_t res6, bitmap; 60 | } __attribute__ ((packed)) tss_t; 61 | 62 | /** @brief Set rsp0 & ist1 in TSS of the current core 63 | */ 64 | void set_tss(size_t rsp0, size_t ist1); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /arch/x86_64/include/asm/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016, Stefan Lankes, Daniel Krebs, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __ARCH_UART_H__ 29 | #define __ARCH_UART_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @brief Initialize UART output 38 | * 39 | * @return Returns 0 on success 40 | */ 41 | int uart_init(void); 42 | 43 | /** @brief Simple string output on a serial device. 44 | * 45 | * If you want a new line you will have to "\\n". 46 | * 47 | * @return Length of output in bytes 48 | */ 49 | int uart_puts(const char *text); 50 | 51 | /** @brief Simple character output on a serial device. 52 | * 53 | * @return The original input character casted to int 54 | */ 55 | int uart_putchar(unsigned char c); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /arch/x86_64/include/asm/uhyve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file arch/x86/include/asm/uhyve.h 31 | * @brief interface to our machine monitor 32 | */ 33 | 34 | #ifndef __ARCH_UHYVE_H__ 35 | #define __ARCH_UHYVE_H__ 36 | 37 | #include 38 | #include 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | inline static void uhyve_send(unsigned short _port, unsigned int _data) 45 | { 46 | outportl(_port, _data); 47 | } 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /arch/x86_64/kernel/pcihdr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hermit-os/libhermit/b27b19458cce322fbeb37e9bccfb47df4888659b/arch/x86_64/kernel/pcihdr.h -------------------------------------------------------------------------------- /arch/x86_64/libkern/string.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Written by the Chair for Operating Systems, RWTH Aachen University 3 | ; 4 | ; NO Copyright (C) 2010-2011, Stefan Lankes 5 | ; consider these trivial functions to be public domain. 6 | ; 7 | ; These functions are distributed on an "AS IS" BASIS, 8 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | ; 10 | 11 | %include "hermit/config.asm" 12 | 13 | %ifdef CONFIG_X86_32 14 | [BITS 32] 15 | %else 16 | [BITS 64] 17 | %endif 18 | SECTION .text 19 | global strcpy 20 | strcpy: 21 | %ifdef CONFIG_X86_32 22 | push ebp 23 | mov ebp, esp 24 | push edi 25 | push esi 26 | 27 | mov esi, [ebp+12] 28 | mov edi, [ebp+8] 29 | %else 30 | push rdi 31 | %endif 32 | 33 | L1: 34 | lodsb 35 | stosb 36 | test al, al 37 | jne L1 38 | 39 | %ifdef CONFIG_X86_32 40 | mov eax, [ebp+8] 41 | pop esi 42 | pop edi 43 | pop ebp 44 | %else 45 | pop rax 46 | %endif 47 | ret 48 | 49 | global strncpy 50 | strncpy: 51 | %ifdef CONFIG_X86_32 52 | push ebp 53 | mov ebp, esp 54 | push edi 55 | push esi 56 | 57 | mov ecx, [ebp+16] 58 | mov esi, [ebp+12] 59 | mov edi, [ebp+8] 60 | 61 | L2: 62 | dec ecx 63 | %else 64 | push rdi 65 | mov rcx, rdx 66 | 67 | L2: 68 | dec rcx 69 | %endif 70 | js L3 71 | lodsb 72 | stosb 73 | test al, al 74 | jne L1 75 | rep 76 | stosb 77 | 78 | L3: 79 | %ifdef CONFIG_X86_32 80 | mov eax, [ebp+8] 81 | pop esi 82 | pop edi 83 | pop ebp 84 | %else 85 | pop rax 86 | %endif 87 | ret 88 | 89 | SECTION .note.GNU-stack noalloc noexec nowrite progbits 90 | -------------------------------------------------------------------------------- /arch/x86_64/loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | project(arch_x86_loader C ASM_NASM) 4 | 5 | ## ASM sources 6 | 7 | file(GLOB ASM_SOURCES *.asm) 8 | add_library(arch_x86_loader_asm STATIC ${ASM_SOURCES}) 9 | 10 | ## C sources 11 | 12 | file(GLOB C_SOURCES *.c) 13 | add_executable(arch_x86_loader ${C_SOURCES}) 14 | 15 | target_include_directories(arch_x86_loader 16 | PRIVATE include/) 17 | 18 | target_compile_options(arch_x86_loader 19 | PRIVATE -O2 -Wall -m64 -std=gnu99 -ffreestanding -mno-red-zone 20 | -fomit-frame-pointer -fno-builtin -nostdlib -nostdinc -mno-sse -mno-avx -mno-mmx -mno-3dnow) 21 | 22 | include(CheckCCompilerFlag) 23 | check_c_compiler_flag(-fstrength-reduce HAS_STRENGTH_REDUCE) 24 | if (HAS_STRENGTH_REDUCE) 25 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrength-reduce") 26 | endif() 27 | 28 | check_c_compiler_flag(-finline-functions HAS_INLINE_FUNCTIONS) 29 | if (HAS_INLINE_FUNCTIONS) 30 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finline-functions") 31 | endif() 32 | 33 | set(CMAKE_LINKER_NAME ld CACHE STRING "Name of the binutils linker") 34 | mark_as_advanced(CMAKE_LINKER_NAME) 35 | 36 | find_program(CMAKE_LINKER ${CMAKE_LINKER_NAME}) 37 | mark_as_advanced(CMAKE_LINKER) 38 | 39 | if(NOT CMAKE_LINKER) 40 | message(FATAL_ERROR "Could not find the GNU LD linker: ${CMAKE_LINKER_NAME}") 41 | endif() 42 | 43 | set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} -o ") 44 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_CURRENT_LIST_DIR}/link.ld -z max-page-size=4096 --build-id=none -nostdlib -static") 45 | 46 | target_link_libraries(arch_x86_loader arch_x86_loader_asm) 47 | 48 | # tools/proxy looks for `ldhermit.elf` 49 | set_target_properties(arch_x86_loader PROPERTIES 50 | OUTPUT_NAME ldhermit.elf) 51 | 52 | add_custom_command( 53 | TARGET arch_x86_loader POST_BUILD 54 | # Split debug symbols into seperate file 55 | COMMAND 56 | ${CMAKE_OBJCOPY} --only-keep-debug 57 | $ 58 | $.sym 59 | # Qemu requires 32-bit ELF 60 | COMMAND 61 | ${CMAKE_OBJCOPY} -O elf32-i386 --strip-debug 62 | $) 63 | 64 | install(TARGETS arch_x86_loader 65 | DESTINATION bin) 66 | 67 | # Show include files in IDE 68 | file(GLOB_RECURSE ARCH_X86_LOADER_INCLUDES "include/*") 69 | add_custom_target(arch_x86_loader_includes_ide SOURCES ${ARCH_X86_LOADER_INCLUDES}) 70 | -------------------------------------------------------------------------------- /arch/x86_64/loader/include/stdarg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __STDARG_H__ 29 | #define __STDARG_H__ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | typedef __builtin_va_list va_list; 36 | 37 | /// Initialize a variable argument list 38 | #define va_start __builtin_va_start 39 | /// Retrieve next argument 40 | #define va_arg __builtin_va_arg 41 | /// End using variable argument list 42 | #define va_end __builtin_va_end 43 | /// copies the (previously initialized) variable argument list 44 | #define va_copy __builtin_va_copy 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /arch/x86_64/loader/include/stdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __STDIO_H__ 29 | #define __STDIO_H__ 30 | 31 | #include 32 | #include 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** 39 | * Works like the ANSI C function puts 40 | */ 41 | int kputs(const char *); 42 | 43 | /** 44 | * Works like the ANSI C function putchar 45 | */ 46 | int kputchar(int); 47 | 48 | /** 49 | * Works like the ANSI C function printf 50 | */ 51 | int kprintf(const char*, ...); 52 | 53 | /** 54 | * Initialize the I/O functions 55 | */ 56 | int koutput_init(void); 57 | 58 | /** 59 | * Works like the ANSI c function sprintf 60 | */ 61 | int ksprintf(char *str, const char *format, ...); 62 | 63 | /** 64 | * Works like the ANSI c function sprintf 65 | */ 66 | int ksnprintf(char *str, size_t size, const char *format, ...); 67 | 68 | /** 69 | * Scaled down version of printf(3) 70 | */ 71 | int kvprintf(char const *fmt, void (*func) (int, void *), void *arg, int radix, va_list ap); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /arch/x86_64/loader/include/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __STRING_H__ 29 | #define __STRING_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | void *memcpy(void *dest, const void *src, size_t count); 38 | void *memset(void *dest, int val, size_t count); 39 | size_t strlen(const char *str); 40 | char *strncpy(char *dest, const char *src, size_t n); 41 | char *strcpy(char *dest, const char *src); 42 | int strcmp(const char *s1, const char *s2); 43 | int strncmp(const char *s1, const char *s2, size_t n); 44 | char *_strstr(const char *s, const char *find); 45 | 46 | #define strstr(s, find) _strstr((s), (find)) 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /arch/x86_64/loader/include/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016, Stefan Lankes, Daniel Krebs, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __ARCH_UART_H__ 29 | #define __ARCH_UART_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** @brief Initialize UART output without a device check 38 | * 39 | * @return Returns 0 on success 40 | */ 41 | int uart_init(const char*); 42 | 43 | /** @brief Simple string output on a serial device. 44 | * 45 | * If you want a new line you will have to "\\n". 46 | * 47 | * @return Length of output in bytes 48 | */ 49 | int uart_puts(const char *text); 50 | 51 | /** @brief Simple character output on a serial device. 52 | * 53 | * @return The original input character casted to int 54 | */ 55 | int uart_putchar(unsigned char c); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /arch/x86_64/loader/link.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64") 2 | OUTPUT_ARCH("i386:x86-64") 3 | ENTRY(start) 4 | phys = 0x000000100000; 5 | 6 | SECTIONS 7 | { 8 | kernel_start = phys; 9 | .mboot phys : AT(ADDR(.mboot)) { 10 | *(.mboot) 11 | } 12 | .text ALIGN(4096) : AT(ADDR(.text)) { 13 | *(.text) 14 | } 15 | .rodata ALIGN(4096) : AT(ADDR(.rodata)) { 16 | *(.rodata) 17 | *(.rodata.*) 18 | } 19 | .data ALIGN(4096) : AT(ADDR(.data)) { 20 | *(.data) 21 | } 22 | .bss ALIGN(4096) : AT(ADDR(.bss)) { 23 | bss_start = .; 24 | *(.bss) 25 | } 26 | bss_end = .; 27 | kernel_end = .; 28 | } 29 | -------------------------------------------------------------------------------- /arch/x86_64/loader/stdio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | int koutput_init(void) 33 | { 34 | uart_init((const char*) (size_t)mb_info->cmdline); 35 | 36 | return 0; 37 | } 38 | 39 | int kputchar(int c) 40 | { 41 | uart_putchar(c); 42 | 43 | return 1; 44 | } 45 | 46 | int kputs(const char *str) 47 | { 48 | #ifdef CONFIG_UART 49 | #if 0 50 | int i, len = strlen(str); 51 | 52 | for(i=0; i 12 | 13 | void *memcpy(void *dest, const void *src, size_t count) 14 | { 15 | size_t i; 16 | 17 | if (BUILTIN_EXPECT(!dest || !src, 0)) 18 | return dest; 19 | 20 | for (i = 0; i < count; i++) 21 | ((char*)dest)[i] = ((char*)src)[i]; 22 | 23 | return dest; 24 | } 25 | 26 | void *memset(void *dest, int val, size_t count) 27 | { 28 | size_t i; 29 | 30 | if (BUILTIN_EXPECT(!dest, 0)) 31 | return dest; 32 | 33 | for (i = 0; i < count; i++) 34 | ((char*) dest)[i] = (char) val; 35 | 36 | return dest; 37 | } 38 | 39 | size_t strlen(const char *str) 40 | { 41 | size_t len = 0; 42 | 43 | if (BUILTIN_EXPECT(!str, 0)) 44 | return len; 45 | 46 | while (str[len] != '\0') 47 | len++; 48 | 49 | return len; 50 | } 51 | 52 | char* strncpy(char *dest, const char *src, size_t n) 53 | { 54 | size_t i; 55 | 56 | if (BUILTIN_EXPECT(!dest || !src, 0)) 57 | return dest; 58 | 59 | for (i = 0 ; i < n && src[i] != '\0' ; i++) 60 | dest[i] = src[i]; 61 | if (i < n) 62 | dest[i] = '\0'; 63 | else 64 | dest[n-1] = '\0'; 65 | 66 | return dest; 67 | } 68 | 69 | char* strcpy(char *dest, const char *src) 70 | { 71 | size_t i; 72 | 73 | if (BUILTIN_EXPECT(!dest || !src, 0)) 74 | return dest; 75 | 76 | for (i = 0 ; src[i] != '\0' ; i++) 77 | dest[i] = src[i]; 78 | dest[i] = '\0'; 79 | 80 | return dest; 81 | } 82 | 83 | int strcmp(const char *s1, const char *s2) 84 | { 85 | while (*s1 != '\0' && *s1 == *s2) { 86 | s1++; 87 | s2++; 88 | } 89 | 90 | return (*(unsigned char *) s1) - (*(unsigned char *) s2); 91 | } 92 | 93 | int strncmp(const char *s1, const char *s2, size_t n) 94 | { 95 | if (BUILTIN_EXPECT(n == 0, 0)) 96 | return 0; 97 | 98 | while (n-- != 0 && *s1 == *s2) { 99 | if (n == 0 || *s1 == '\0') 100 | break; 101 | s1++; 102 | s2++; 103 | } 104 | 105 | return (*(unsigned char *) s1) - (*(unsigned char *) s2); 106 | } 107 | -------------------------------------------------------------------------------- /arch/x86_64/loader/strstr.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: strstr.c,v 1.1 2005/12/20 19:28:52 christos Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1990, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * This code is derived from software contributed to Berkeley by 8 | * Chris Torek. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | /* 36 | * The code has been taken from NetBSD (sys/libkern/strstr.c) and is consequently 37 | * BSD-licensed. Unnecessary functions have been removed and all typedefs required 38 | * have been added. 39 | */ 40 | 41 | /* HermiCore prelude */ 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | /* 48 | * Find the first occurrence of find in s. 49 | */ 50 | char * 51 | _strstr(s, find) 52 | const char *s, *find; 53 | { 54 | char c, sc; 55 | size_t len; 56 | 57 | if (BUILTIN_EXPECT(!s, 0)) 58 | return NULL; 59 | if (BUILTIN_EXPECT(!find, 0)) 60 | return NULL; 61 | 62 | if ((c = *find++) != 0) { 63 | len = strlen(find); 64 | do { 65 | do { 66 | if ((sc = *s++) == 0) 67 | return (NULL); 68 | } while (sc != c); 69 | } while (strncmp(s, find, len) != 0); 70 | s--; 71 | } 72 | return ((char *) s); 73 | } 74 | -------------------------------------------------------------------------------- /arch/x86_64/mm/vma.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Steffen Vogel, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | int vma_arch_init(void) 34 | { 35 | int ret = 0; 36 | 37 | if (mb_info) { 38 | ret = vma_add((size_t)mb_info & PAGE_MASK, ((size_t)mb_info & PAGE_MASK) + PAGE_SIZE, 39 | VMA_READ|VMA_WRITE|VMA_CACHEABLE); 40 | if (BUILTIN_EXPECT(ret, 0)) 41 | goto out; 42 | 43 | if ((mb_info->flags & MULTIBOOT_INFO_CMDLINE) && cmdline) { 44 | LOG_INFO("vma_arch_init: map cmdline %p (size 0x%zd)\n", cmdline, cmdsize); 45 | 46 | size_t i = 0; 47 | while(((size_t) cmdline + i) < ((size_t) cmdline + cmdsize)) 48 | { 49 | if ((((size_t)cmdline + i) & PAGE_MASK) != ((size_t) mb_info & PAGE_MASK)) { 50 | ret = vma_add(((size_t)cmdline + i) & PAGE_MASK, (((size_t)cmdline + i) & PAGE_MASK) + PAGE_SIZE, 51 | VMA_READ|VMA_WRITE|VMA_CACHEABLE); 52 | if (BUILTIN_EXPECT(ret, 0)) 53 | goto out; 54 | } 55 | 56 | i += PAGE_SIZE; 57 | } 58 | } 59 | } 60 | 61 | out: 62 | return ret; 63 | } 64 | -------------------------------------------------------------------------------- /cmake/HermitCore-Application.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore.cmake) 2 | include_guard() 3 | 4 | add_compile_options(${HERMIT_APP_FLAGS}) 5 | 6 | # link against and include locally built libraries instead of the ones 7 | # supplied with the toolchain, if built from top-level 8 | link_directories(${LOCAL_PREFIX_ARCH_LIB_DIR}) 9 | include_directories(BEFORE ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}) 10 | -------------------------------------------------------------------------------- /cmake/HermitCore-Configuration.cmake: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "0.2.10" CACHE STRING 2 | "HermitCore current version") 3 | 4 | set(MAX_CORES "512" CACHE STRING 5 | "Maximum number of cores that can be managed") 6 | 7 | set(MAX_TASKS "((MAX_CORES * 2) + 2)" CACHE STRING 8 | "Maximum number of tasks") 9 | 10 | set(MAX_ISLE "8" CACHE STRING 11 | "Maximum number of NUMA isles") 12 | 13 | set(MAX_FNAME "128" CACHE STRING 14 | "Define the maximum length of a file name") 15 | 16 | set(KERNEL_STACK_SIZE 8192 CACHE STRING 17 | "Kernel stack size in bytes") 18 | 19 | set(DEFAULT_STACK_SIZE 262144 CACHE STRING 20 | "Task stack size in bytes") 21 | 22 | set(MAX_ARGC_ENVC 128 CACHE STRING 23 | "Maximum number of command line parameters and enviroment variables 24 | forwarded to uhyve") 25 | 26 | option(DYNAMIC_TICKS 27 | "Don't use a periodic timer event to keep track of time" ON) 28 | 29 | option(SAVE_FPU 30 | "Save FPU registers on context switch" ON) 31 | 32 | set(HAVE_ARCH_MEMSET "1" CACHE STRING 33 | "Use machine specific version of memset") 34 | set(HAVE_ARCH_MEMCPY "1" CACHE STRING 35 | "Use machine specific version of memcpy") 36 | set(HAVE_ARCH_STRLEN "1" CACHE STRING 37 | "Use machine specific version of strlen") 38 | if("${HERMIT_ARCH}" STREQUAL "aarch64") 39 | set(HAVE_ARCH_STRCPY "0" CACHE STRING 40 | "Use machine specific version of strcpy") 41 | set(HAVE_ARCH_STRNCPY "0" CACHE STRING 42 | "Use machine specific version of strncpy") 43 | else() 44 | set(HAVE_ARCH_STRCPY "0" CACHE STRING 45 | "Use machine specific version of strcpy") 46 | set(HAVE_ARCH_STRNCPY "0" CACHE STRING 47 | "Use machine specific version of strncpy") 48 | endif() 49 | -------------------------------------------------------------------------------- /cmake/HermitCore-Paths.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Utils.cmake) 2 | # no include guard here because we have to include this file twice to correctly 3 | # set CMAKE_INSTALL_PREFIX 4 | 5 | # root of HermitCore project 6 | set(HERMIT_ROOT ${CMAKE_CURRENT_LIST_DIR}/..) 7 | 8 | # set default install prefix if user doesn't specify one 9 | if(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT}) 10 | # See CMake docs for reference: 11 | # https://cmake.org/cmake/help/v3.7/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html 12 | set(CMAKE_INSTALL_PREFIX /opt/hermit CACHE PATH "..." FORCE) 13 | endif() 14 | 15 | # we install 3rd party libraries to an intermediate directory and relocate 16 | # them here later when installing the whole project 17 | if(NOT LOCAL_PREFIX_BASE_DIR) 18 | # will be injected into external project because CMAKE_BINARY_DIR will be 19 | # different there 20 | set(LOCAL_PREFIX_BASE_DIR ${CMAKE_BINARY_DIR}/local_prefix) 21 | endif() 22 | 23 | # during build process libraries and external projects will be deployed into 24 | # this directory structure 25 | set(LOCAL_PREFIX_DIR ${LOCAL_PREFIX_BASE_DIR}/${CMAKE_INSTALL_PREFIX}) 26 | set(LOCAL_PREFIX_ARCH_DIR ${LOCAL_PREFIX_DIR}/${TARGET_ARCH}) 27 | set(LOCAL_PREFIX_ARCH_INCLUDE_DIR ${LOCAL_PREFIX_ARCH_DIR}/include) 28 | 29 | # when building applications within the HermitCore project (tests, ...) they 30 | # will link prefarably against libraries in this directory in order to test 31 | # changes in the kernel 32 | set(LOCAL_PREFIX_ARCH_LIB_DIR ${LOCAL_PREFIX_ARCH_DIR}/lib) 33 | 34 | # generated configs will be put here 35 | set(GENERATED_CONFIG_DIR ${CMAKE_BINARY_DIR}/include) 36 | -------------------------------------------------------------------------------- /cmake/HermitCore-Toolchain-aarch64-bootstrap.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Toolchain-aarch64.cmake) 2 | include_guard() 3 | 4 | set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") 5 | set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") 6 | 7 | # bootstrap toolchain cannot compile neither Go nor Fortran 8 | unset(CMAKE_Go_COMPILER) 9 | unset(CMAKE_Fortran_COMPILER) 10 | -------------------------------------------------------------------------------- /cmake/HermitCore-Toolchain-aarch64.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Utils.cmake) 2 | include_guard() 3 | 4 | # let user provide a different path to the toolchain 5 | set_default(TOOLCHAIN_BIN_DIR /opt/hermit/bin) 6 | 7 | set(TARGET_ARCH aarch64-hermit) 8 | set(HERMIT_KERNEL_FLAGS 9 | -Wall -O2 -mgeneral-regs-only 10 | -fno-var-tracking-assignments -fstrength-reduce 11 | -fomit-frame-pointer -finline-functions -ffreestanding 12 | -nostdinc -fno-stack-protector 13 | -fno-delete-null-pointer-checks 14 | -falign-jumps=1 -falign-loops=1 15 | -fno-common -Wframe-larger-than=1024 16 | -fno-strict-aliasing -fno-asynchronous-unwind-tables 17 | -fno-strict-overflow) 18 | 19 | set(HERMIT_APP_FLAGS 20 | -O3 -ftree-vectorize) 21 | 22 | set(CMAKE_SYSTEM_NAME Generic) 23 | 24 | # point CMake to our toolchain 25 | set(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gcc) 26 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-g++) 27 | set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gfortran) 28 | set(CMAKE_Go_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gccgo) 29 | 30 | # hinting the prefix and location is needed in order to correctly detect 31 | # binutils 32 | set(_CMAKE_TOOLCHAIN_PREFIX "${TARGET_ARCH}-") 33 | set(_CMAKE_TOOLCHAIN_LOCATION ${TOOLCHAIN_BIN_DIR}) 34 | -------------------------------------------------------------------------------- /cmake/HermitCore-Toolchain-x86_64-bootstrap.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Toolchain-x86_64.cmake) 2 | include_guard() 3 | 4 | set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") 5 | set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") 6 | 7 | # bootstrap toolchain cannot compile neither Go nor Fortran 8 | unset(CMAKE_Go_COMPILER) 9 | unset(CMAKE_Fortran_COMPILER) 10 | -------------------------------------------------------------------------------- /cmake/HermitCore-Toolchain-x86_64.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Utils.cmake) 2 | include_guard() 3 | 4 | # let user provide a different path to the toolchain 5 | set_default(TOOLCHAIN_BIN_DIR /opt/hermit/bin) 6 | 7 | set(TARGET_ARCH x86_64-hermit) 8 | set(HERMIT_KERNEL_FLAGS 9 | -m64 -Wall -O2 -mno-red-zone 10 | -fno-var-tracking-assignments -fstrength-reduce 11 | -fomit-frame-pointer -finline-functions -ffreestanding 12 | -nostdinc -fno-stack-protector -mno-sse -mno-mmx 13 | -mno-sse2 -mno-3dnow -mno-avx 14 | -fno-delete-null-pointer-checks 15 | -falign-jumps=1 -falign-loops=1 16 | -mno-80387 -mno-fp-ret-in-387 -mskip-rax-setup 17 | -fno-common -Wframe-larger-than=1024 18 | -fno-strict-aliasing -fno-asynchronous-unwind-tables 19 | -fno-strict-overflow -maccumulate-outgoing-args) 20 | 21 | set(HERMIT_APP_FLAGS 22 | -m64 -mtls-direct-seg-refs -O3 -ftree-vectorize) 23 | 24 | set(CMAKE_SYSTEM_NAME Generic) 25 | 26 | # point CMake to our toolchain 27 | set(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gcc) 28 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-g++) 29 | set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gfortran) 30 | set(CMAKE_Go_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gccgo) 31 | 32 | # hinting the prefix and location is needed in order to correctly detect 33 | # binutils 34 | set(_CMAKE_TOOLCHAIN_PREFIX "${TARGET_ARCH}-") 35 | set(_CMAKE_TOOLCHAIN_LOCATION ${TOOLCHAIN_BIN_DIR}) 36 | -------------------------------------------------------------------------------- /cmake/HermitCore.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Utils.cmake) 2 | include_guard() 3 | 4 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Paths.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Configuration.cmake) 6 | 7 | # scripts to detect HermitCore Go compiler 8 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/golang/) 9 | 10 | if(NOT HERMIT_ARCH) 11 | execute_process(COMMAND uname -m OUTPUT_VARIABLE HERMIT_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) 12 | endif() 13 | 14 | if(PROFILING) 15 | # link everything against XRay 16 | link_libraries(-lxray) 17 | 18 | # generate symbol map file for XRay to resolve function names 19 | link_libraries(-Wl,-Map=$.map) 20 | 21 | # enable profiling with XRay 22 | add_compile_options(-falign-functions=32 -finstrument-functions 23 | -finstrument-functions-exclude-function-list=_mm_pause,_mm_setcsr,_mm_getcsr) 24 | add_definitions(-DXRAY -DXRAY_DISABLE_BROWSER_INTEGRATION 25 | -DXRAY_NO_DEMANGLE -DXRAY_ANNOTATE) 26 | endif() 27 | 28 | # use default toolchain if not specified by user 29 | if(NOT CMAKE_TOOLCHAIN_FILE) 30 | if(BOOTSTRAP) 31 | # use bootstrap toolchain if requested 32 | set(_BOOTSTRAP_ARCH_SUFFIX -bootstrap) 33 | endif() 34 | set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/HermitCore-Toolchain-${HERMIT_ARCH}${_BOOTSTRAP_ARCH_SUFFIX}.cmake) 35 | endif() 36 | 37 | # NASM is only required on x86_64 38 | if("${HERMIT_ARCH}" STREQUAL "x86_64") 39 | # NASM detection will change binary format depending on host system, but 40 | # we only want to generate elf64 for HermitCore 41 | # Note: Has to be set *before* ASM_NASM is enabled 42 | set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) 43 | 44 | enable_language(ASM_NASM) 45 | 46 | # NASM hack, because it requires include paths to have a trailing /, whereas 47 | # CMake explicitly will remove it when adding includes the usual way 48 | # Note: Has to be set *after* ASM_NASM is enabled 49 | set(CMAKE_ASM_NASM_FLAGS 50 | "${CMAKE_ASM_NASM_FLAGS} -I ${CMAKE_BINARY_DIR}/include/") 51 | endif() 52 | 53 | if(MTUNE) 54 | set(HERMIT_KERNEL_FLAGS ${HERMIT_KERNEL_FLAGS} -mtune=${MTUNE}) 55 | set(HERMIT_APP_FLAGS ${HERMIT_APP_FLAGS} -mtune=${MTUNE}) 56 | endif() 57 | 58 | set(HERMIT_KERNEL_INCLUDES 59 | ${CMAKE_BINARY_DIR}/include 60 | ${HERMIT_ROOT}/include 61 | ${HERMIT_ROOT}/arch/${HERMIT_ARCH}/include 62 | ${HERMIT_ROOT}/lwip/src/include 63 | ${HERMIT_ROOT}/drivers) 64 | 65 | # HACK: when CMake detects compilers it taints CMAKE_INSTALL_PREFIX, so in 66 | # order to rely on that variable (we redefine it), enable all languages 67 | # here and source pathes again. 68 | # 69 | # Furthermore this will produce a sensible error message if the toolchain cannot 70 | # be found. 71 | if(NOT BOOTSTRAP) 72 | enable_language(C CXX Fortran Go) 73 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Paths.cmake) 74 | endif() 75 | 76 | # find elfedit, CMake doesn't use this program, so we have to find it ourself 77 | find_toolchain_program(elfedit) 78 | -------------------------------------------------------------------------------- /cmake/README.md: -------------------------------------------------------------------------------- 1 | HermitCore CMake build system 2 | ============================= 3 | 4 | HermitCore requires at least CMake version `3.7`, which (at the time of 5 | introduction) is not yet available on most Linux distributions. We therefore 6 | provide a script `cmake/local-cmake.sh` that fetches precompiled binaries from 7 | the CMake project and installs them locally in `cmake/cmake-3.7*`. Only when 8 | sourced for the first time it will download CMake, on further runs it detects 9 | the existing download and adds it to `PATH` automatically. 10 | 11 | ```bash 12 | $ . cmake/local-cmake.sh 13 | -- Downloading CMake 14 | cmake-3.7.2-Linux-x 100%[=================>] 29,26M 837KB/s in 19s 15 | -- Unpacking CMake 16 | -- Local CMake v3.7.2 installed to cmake/cmake-3.7.2-Linux-x86_64 17 | -- Next time you source this script, no download will be neccessary 18 | $ which cmake 19 | /home/[...]/HermitCore/cmake/cmake-3.7.2-Linux-x86_64/bin/cmake 20 | ``` 21 | 22 | ## Directory structure 23 | 24 | ``` 25 | cmake/ 26 | ├── golang 27 | │   ├── CMakeDetermineGoCompiler.cmake 28 | │   ├── CMakeGoCompiler.cmake.in 29 | │   ├── CMakeGoInformation.cmake 30 | │   └── CMakeTestGoCompiler.cmake 31 | ├── HermitCore-Application.cmake 32 | ├── HermitCore.cmake 33 | ├── HermitCore-Paths.cmake 34 | ├── HermitCore-Toolchain-x86_64.cmake 35 | ├── HermitCore-Utils.cmake 36 | ├── local-cmake.sh 37 | └── README.md 38 | ``` 39 | 40 | ## Additional language support 41 | 42 | Currently, HermitCore supports `C, C++, Fortran, Go` through Cmake. While the 43 | former are supported and detected by CMake out-of-the-box, Go support has been 44 | added manually for HermitCore. 45 | 46 | Adding a new language requires you to provide CMake hints where to find the 47 | toolchain and then how to compile and link binaries. The Go support in 48 | `cmake/golang` may serve as an example on how to add a new language. 49 | 50 | To finally enable the language it has to be added to CMake's module path in 51 | `cmake/HermitCore.cmake`: 52 | 53 | ``` 54 | # scripts to detect HermitCore Go compiler 55 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/golang/) 56 | 57 | # scripts to detect new language 58 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/new-language/) 59 | ``` 60 | 61 | 62 | ## User applications 63 | 64 | You just have to include `HermitCore-Application.cmake` before the `project()` 65 | command in your `CMakeLists.txt` in order to build applications for HermitCore. 66 | For configuration parameters of the project, please consult the `README.md` in 67 | the root of this repository. 68 | -------------------------------------------------------------------------------- /cmake/golang/CMakeDetermineGoCompiler.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | # determine the compiler to use for Go programs 5 | # NOTE, a generator may set CMAKE_Go_COMPILER before 6 | # loading this file to force a compiler. 7 | 8 | if(NOT CMAKE_Go_COMPILER) 9 | # prefer the environment variable CC 10 | if(NOT $ENV{GO_COMPILER} STREQUAL "") 11 | get_filename_component(CMAKE_Go_COMPILER_INIT $ENV{GO_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Go_FLAGS_ENV_INIT) 12 | if(CMAKE_Go_FLAGS_ENV_INIT) 13 | set(CMAKE_Go_COMPILER_ARG1 "${CMAKE_Go_FLAGS_ENV_INIT}" CACHE STRING "First argument to Go compiler") 14 | endif() 15 | if(NOT EXISTS ${CMAKE_Go_COMPILER_INIT}) 16 | message(SEND_ERROR "Could not find compiler set in environment variable GO_COMPILER:\n$ENV{GO_COMPILER}.") 17 | endif() 18 | endif() 19 | 20 | set(Go_BIN_PATH 21 | $ENV{GOPATH} 22 | $ENV{GOROOT} 23 | $ENV{GOROOT}/../bin 24 | $ENV{GO_COMPILER} 25 | /usr/bin 26 | /usr/local/bin 27 | ) 28 | # if no compiler has been specified yet, then look for one 29 | if(CMAKE_Go_COMPILER_INIT) 30 | set(CMAKE_Go_COMPILER ${CMAKE_Go_COMPILER_INIT} CACHE PATH "Go Compiler") 31 | else() 32 | find_program(CMAKE_Go_COMPILER 33 | NAMES go 34 | PATHS ${Go_BIN_PATH} 35 | ) 36 | endif() 37 | endif() 38 | mark_as_advanced(CMAKE_Go_COMPILER) 39 | 40 | # configure variables set in this file for fast reload later on 41 | configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeGoCompiler.cmake.in 42 | ${CMAKE_PLATFORM_INFO_DIR}/CMakeGoCompiler.cmake @ONLY) 43 | set(CMAKE_Go_COMPILER_ENV_VAR "GO_COMPILER") 44 | -------------------------------------------------------------------------------- /cmake/golang/CMakeGoCompiler.cmake.in: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | set(CMAKE_Go_COMPILER "@CMAKE_Go_COMPILER@") 5 | set(CMAKE_Go_COMPILER_LOADED 1) 6 | 7 | set(CMAKE_Go_SOURCE_FILE_EXTENSIONS go) 8 | set(CMAKE_Go_LINKER_PREFERENCE 40) 9 | set(CMAKE_Go_OUTPUT_EXTENSION .6) 10 | set(CMAKE_Go_OUTPUT_EXTENSION_REPLACE 1) 11 | set(CMAKE_Go_COMPILER_ENV_VAR "GO_COMPILER") 12 | -------------------------------------------------------------------------------- /cmake/golang/CMakeGoInformation.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | # This should be included before the _INIT variables are 5 | # used to initialize the cache. Since the rule variables 6 | # have if blocks on them, users can still define them here. 7 | # But, it should still be after the platform file so changes can 8 | # be made to those values. 9 | 10 | if(CMAKE_USER_MAKE_RULES_OVERRIDE) 11 | # Save the full path of the file so try_compile can use it. 12 | include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) 13 | set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") 14 | endif() 15 | 16 | if(CMAKE_USER_MAKE_RULES_OVERRIDE_Go) 17 | # Save the full path of the file so try_compile can use it. 18 | include(${CMAKE_USER_MAKE_RULES_OVERRIDE_Go} RESULT_VARIABLE _override) 19 | set(CMAKE_USER_MAKE_RULES_OVERRIDE_Go "${_override}") 20 | endif() 21 | 22 | # refer: /usr/share/cmake-3.7/Modules/CMakeCInformation.cmake 23 | 24 | if(NOT CMAKE_Go_COMPILE_OBJECT) 25 | set(CMAKE_Go_COMPILE_OBJECT " -o -c ") 26 | endif() 27 | 28 | if(NOT CMAKE_Go_LINK_EXECUTABLE) 29 | set(CMAKE_Go_LINK_EXECUTABLE " -pthread -o ") 30 | endif() 31 | -------------------------------------------------------------------------------- /cmake/golang/CMakeTestGoCompiler.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | set(CMAKE_Go_COMPILER_WORKS 1 CACHE INTERNAL "") 5 | -------------------------------------------------------------------------------- /cmake/local-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # which version to fetch 4 | MAJOR="3.7" 5 | MINOR="2" 6 | PLATFORM="Linux-x86_64" 7 | 8 | # assemble url for desired version 9 | URL="https://cmake.org/files/v${MAJOR}/cmake-${MAJOR}.${MINOR}-${PLATFORM}.tar.gz" 10 | 11 | ARCHIVE="$(basename ${URL})" 12 | DIR="$(basename ${ARCHIVE} .tar.gz)" 13 | 14 | 15 | relpath() { 16 | # workaround because Ubuntu seems to use an ancient realpath version 17 | # https://stackoverflow.com/questions/2564634/convert-absolute-path-into-relative-path-given-a-current-directory-using-bash#comment12808306_7305217 18 | python3 -c "import os.path; print(os.path.relpath('${2:-$PWD}','$1'))"; 19 | } 20 | 21 | HERMIT_TOP="$(git rev-parse --show-toplevel)" 22 | HERMIT_CMAKE="${HERMIT_TOP}/cmake" 23 | CMAKE_DIR="${HERMIT_CMAKE}/${DIR}" 24 | CMAKE_DIR_REL="$(relpath ${HERMIT_TOP} ${CMAKE_DIR})" 25 | 26 | # make sure we're sourced, not executed 27 | if [ "$0" = "$BASH_SOURCE" ] 28 | then 29 | echo "You have to source this script:" 30 | echo "\$ . $0" 31 | exit 32 | fi 33 | 34 | # quit if already in path 35 | echo "$PATH" | grep "${CMAKE_DIR_REL}" &>/dev/null && return 36 | 37 | # check if already installed 38 | if which cmake &> /dev/null ; then 39 | if cmake --version | grep "cmake version ${MAJOR}.${MINOR}" &> /dev/null; then 40 | echo "You already have CMake ${MAJOR}.${MINOR}" 41 | return 42 | fi 43 | fi 44 | 45 | if [ ! -d "${CMAKE_DIR}" ] 46 | then 47 | echo "-- Downloading CMake" 48 | wget "${URL}" -O "${ARCHIVE}" || 49 | (echo "Cannot download CMake"; return) 50 | 51 | echo "-- Unpacking CMake" 52 | tar -C "${HERMIT_CMAKE}" -xf "${ARCHIVE}" || 53 | (echo "Cannot unpack CMake archive"; return) 54 | 55 | # delete temporary archive again 56 | rm -f "${ARCHIVE}" 57 | 58 | # add cmake dir to gitignore 59 | GITIGNORE="${HERMIT_TOP}/.gitignore" 60 | if ! grep "${CMAKE_DIR_REL}" "${GITIGNORE}" &>/dev/null 61 | then 62 | echo "${CMAKE_DIR_REL}/*" >> "${GITIGNORE}" 63 | fi 64 | 65 | echo "-- Local CMake v${MAJOR}.${MINOR} installed to ${CMAKE_DIR_REL}" 66 | echo "-- Next time you source this script, no download will be necessary" 67 | fi 68 | 69 | export PATH="${CMAKE_DIR}/bin:${PATH}" 70 | -------------------------------------------------------------------------------- /config/bzImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hermit-os/libhermit/b27b19458cce322fbeb37e9bccfb47df4888659b/config/bzImage -------------------------------------------------------------------------------- /config/ifcfg-mmnif: -------------------------------------------------------------------------------- 1 | DEVICE=mmnif 2 | BOOTPROTO=none 3 | ONBOOT=yes 4 | NETWORK=192.168.28.0 5 | NETMASK=255.255.255.0 6 | IPADDR=192.168.28.1 7 | NM_CONTROLLED=yes 8 | -------------------------------------------------------------------------------- /config/initrd.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hermit-os/libhermit/b27b19458cce322fbeb37e9bccfb47df4888659b/config/initrd.cpio -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Download base image ubuntu 18.04 2 | FROM ubuntu:18.04 3 | 4 | # Update Software repository 5 | RUN apt-get -qq update 6 | 7 | # Install required packets from ubuntu repository 8 | RUN apt-get install -y apt-transport-https curl cmake bsdmainutils wget vim nano git binutils autoconf automake make cmake qemu-kvm qemu-system-x86 nasm gcc g++ ca-certificates build-essential libtool 9 | 10 | # add path to hermitcore packets 11 | RUN echo "deb [trusted=yes] https://dl.bintray.com/hermitcore/ubuntu bionic main" | tee -a /etc/apt/sources.list 12 | 13 | # Update Software repository 14 | RUN apt-get -qq update 15 | 16 | # Install required packets from ubuntu repository 17 | RUN apt-get install -y --allow-unauthenticated binutils-hermit newlib-hermit pte-hermit gcc-hermit libhermit libomp-hermit 18 | 19 | ENV PATH="/opt/hermit/bin:${PATH}" 20 | ENV EDITOR=vim 21 | 22 | CMD echo "This is a HermitCore's toolchain!"; /bin/bash 23 | -------------------------------------------------------------------------------- /drivers/net/mmnif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Carl-Benedikt Krueger, Chair for Operating Systems, 3 | * RWTH Aachen University 4 | * 5 | * This software is available to you under a choice of one of two 6 | * licenses. You may choose to be licensed under the terms of the GNU 7 | * General Public License (GPL) Version 2 (https://www.gnu.org/licenses/gpl-2.0.txt) 8 | * or the BSD license below: 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * * Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __MMNIF_H__ 34 | #define __MMNIF_H__ 35 | 36 | #include 37 | 38 | #include 39 | #include /* lwip netif */ 40 | #include 41 | 42 | err_t mmnif_init(struct netif*); 43 | err_t mmnif_shutdown(void); 44 | int mmnif_worker(void *e); 45 | void mmnif_print_driver_status(void); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /drivers/net/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Carl-Benedikt Krueger, Chair for Operating Systems, 3 | * RWTH Aachen University 4 | * 5 | * This software is available to you under a choice of one of two 6 | * licenses. You may choose to be licensed under the terms of the GNU 7 | * General Public License (GPL) Version 2 (https://www.gnu.org/licenses/gpl-2.0.txt) 8 | * or the BSD license below: 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * * Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | #include 35 | #include "util.h" 36 | 37 | inline int isprint(unsigned char e) 38 | { 39 | if ((e < 0x30) || (e > 0x80)) 40 | return 0; 41 | return 1; 42 | } 43 | 44 | // hex_dumb display network packets in a good way 45 | void hex_dump(unsigned n, const unsigned char *buf) 46 | { 47 | int on_this_line = 0; 48 | 49 | while (n-- > 0) 50 | { 51 | LOG_SAME_LINE(LOG_LEVEL_INFO, "%02X ", *buf++); 52 | on_this_line += 1; 53 | 54 | if (on_this_line == 16 || n == 0) 55 | { 56 | int i; 57 | 58 | LOG_SAME_LINE(LOG_LEVEL_INFO, " "); 59 | for (i = on_this_line; i < 16; i++) 60 | LOG_SAME_LINE(LOG_LEVEL_INFO, " "); 61 | for (i = on_this_line; i > 0; i--) 62 | LOG_SAME_LINE(LOG_LEVEL_INFO, "%c", isprint(buf[-i]) ? buf[-i] : '.'); 63 | LOG_SAME_LINE(LOG_LEVEL_INFO, "\n"); 64 | on_this_line = 0; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /drivers/net/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Carl-Benedikt Krueger, Chair for Operating Systems, 3 | * RWTH Aachen University 4 | * 5 | * This software is available to you under a choice of one of two 6 | * licenses. You may choose to be licensed under the terms of the GNU 7 | * General Public License (GPL) Version 2 (https://www.gnu.org/licenses/gpl-2.0.txt) 8 | * or the BSD license below: 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * * Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __UTIL__ 34 | #define __UTIL__ 35 | 36 | // hex_dumb display network packets in a good way 37 | void hex_dump(unsigned n, const unsigned char *buf); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /drivers/net/vioif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __NET_VIOIF_H__ 29 | #define __NET_VIOIF_H__ 30 | 31 | #include 32 | #include 33 | 34 | #define VIOIF_NUM_QUEUES 2 35 | 36 | typedef struct 37 | { 38 | struct vring vring; 39 | uint64_t virt_buffer; 40 | uint64_t phys_buffer; 41 | uint16_t last_seen_used; 42 | } virt_queue_t; 43 | 44 | /* 45 | * Helper struct to hold private data used to operate your ethernet interface. 46 | */ 47 | typedef struct vioif { 48 | struct eth_addr *ethaddr; 49 | /* Add whatever per-interface state that is needed here. */ 50 | uint32_t iomem; 51 | uint32_t iobase; 52 | uint32_t features; 53 | uint8_t msix_enabled; 54 | uint8_t irq; 55 | uint8_t polling; 56 | virt_queue_t queues[VIOIF_NUM_QUEUES]; 57 | } vioif_t; 58 | 59 | /* 60 | * Initialize the network driver for the virtio network interface 61 | */ 62 | err_t vioif_init(struct netif* netif); 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /img/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hermit-os/libhermit/b27b19458cce322fbeb37e9bccfb47df4888659b/img/demo.gif -------------------------------------------------------------------------------- /img/hermitcore_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hermit-os/libhermit/b27b19458cce322fbeb37e9bccfb47df4888659b/img/hermitcore_logo.png -------------------------------------------------------------------------------- /include/hermit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | configure_file(config.h.in config.h) 4 | configure_file(config.asm.in config.asm) 5 | 6 | # Show include files in IDE 7 | file(GLOB_RECURSE HERMIT_INCLUDES "*") 8 | add_custom_target(hermit_includes_ide SOURCES ${HERMIT_INCLUDES}) 9 | 10 | # install generated config files when building libhermit for bootstrapping 11 | install(FILES 12 | ${GENERATED_CONFIG_DIR}/hermit/config.h 13 | ${GENERATED_CONFIG_DIR}/hermit/config.asm 14 | DESTINATION ${TARGET_ARCH}/include/hermit/ 15 | COMPONENT bootstrap) 16 | -------------------------------------------------------------------------------- /include/hermit/config.asm.in: -------------------------------------------------------------------------------- 1 | %define MAX_CORES @MAX_CORES@ 2 | %define KERNEL_STACK_SIZE @KERNEL_STACK_SIZE@ 3 | %define SAVE_FPU @SAVE_FPU@ 4 | -------------------------------------------------------------------------------- /include/hermit/config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine MAX_CORES (@MAX_CORES@) 2 | #cmakedefine MAX_TASKS (@MAX_TASKS@) 3 | #cmakedefine MAX_ISLE (@MAX_ISLE@) 4 | #cmakedefine KERNEL_STACK_SIZE (@KERNEL_STACK_SIZE@) 5 | #cmakedefine DEFAULT_STACK_SIZE (@DEFAULT_STACK_SIZE@) 6 | #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" 7 | #cmakedefine MAX_FNAME (@MAX_FNAME@) 8 | 9 | #cmakedefine SAVE_FPU 10 | 11 | #cmakedefine DYNAMIC_TICKS 12 | 13 | /* Define to use machine specific version of memcpy */ 14 | #cmakedefine HAVE_ARCH_MEMCPY (@HAVE_ARCH_MEMCPY@) 15 | 16 | /* Define to use machine specific version of memset */ 17 | #cmakedefine HAVE_ARCH_MEMSET (@HAVE_ARCH_MEMSET@) 18 | 19 | /* Define to use machine specific version of strcpy */ 20 | #cmakedefine HAVE_ARCH_STRCPY (@HAVE_ARCH_STRCPY@) 21 | 22 | /* Define to use machine specific version of strlen */ 23 | #cmakedefine HAVE_ARCH_STRLEN (@HAVE_ARCH_STRLEN@) 24 | 25 | /* Define to use machine specific version of strncpy */ 26 | #cmakedefine HAVE_ARCH_STRNCPY (@HAVE_ARCH_STRNCPY@) 27 | -------------------------------------------------------------------------------- /include/hermit/islelock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Stefan Lankes, RWTH Aachen University 3 | * All rights reserved. 4 | * 5 | * This software is available to you under a choice of one of two 6 | * licenses. You may choose to be licensed under the terms of the GNU 7 | * General Public License (GPL) Version 2 (https://www.gnu.org/licenses/gpl-2.0.txt) 8 | * or the BSD license below: 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * * Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __ISLELOCK_H__ 34 | #define __ISLELOCK_H__ 35 | 36 | #include 37 | #include 38 | 39 | typedef struct islelock { 40 | /// Internal queue 41 | atomic_int32_t queue; 42 | /// Internal dequeue 43 | atomic_int32_t dequeue; 44 | } islelock_t; 45 | 46 | inline static int islelock_init(islelock_t* s) 47 | { 48 | atomic_int32_set(&s->queue, 0); 49 | atomic_int32_set(&s->dequeue, 1); 50 | 51 | return 0; 52 | } 53 | 54 | inline static int islelock_destroy(islelock_t* s) 55 | { 56 | return 0; 57 | } 58 | 59 | static inline int islelock_lock(islelock_t* s) 60 | { 61 | int ticket; 62 | 63 | ticket = atomic_int32_inc(&s->queue); 64 | while(atomic_int32_read(&s->dequeue) != ticket) { 65 | PAUSE; 66 | } 67 | 68 | return 0; 69 | } 70 | 71 | static inline int islelock_unlock(islelock_t* s) 72 | { 73 | atomic_int32_inc(&s->dequeue); 74 | 75 | return 0; 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /include/hermit/mailbox_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file include/hermit/mailbox_types.h 31 | * @brief Message type structure definitions for various task return types 32 | */ 33 | 34 | #ifndef __MAILBOX_TYPES_H__ 35 | #define __MAILBOX_TYPES_H__ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** @brief Wait message structure 44 | * 45 | * This message struct keeps a recipient task id and the message itself */ 46 | typedef struct { 47 | /// The task id of the task which is waiting for this message 48 | tid_t id; 49 | /// The message payload 50 | int32_t result; 51 | } wait_msg_t; 52 | 53 | #define MAILBOX_TYPES(name, type) \ 54 | typedef struct mailbox_##name { \ 55 | type buffer[MAILBOX_SIZE]; \ 56 | int wpos, rpos; \ 57 | sem_t mails; \ 58 | sem_t boxes; \ 59 | spinlock_t rlock, wlock; \ 60 | } mailbox_##name##_t; 61 | 62 | MAILBOX_TYPES(wait_msg, wait_msg_t) 63 | MAILBOX_TYPES(int32, int32_t) 64 | MAILBOX_TYPES(int16, int16_t) 65 | MAILBOX_TYPES(int8, int8_t) 66 | MAILBOX_TYPES(uint32, uint32_t) 67 | MAILBOX_TYPES(uint16, uint16_t) 68 | MAILBOX_TYPES(uint8, uint8_t) 69 | MAILBOX_TYPES(ptr, void*) 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/hermit/processor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __PROCESSOR_H__ 29 | #define __PROCESSOR_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/hermit/rcce.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Stefan Lankes, RWTH Aachen University 3 | * All rights reserved. 4 | * 5 | * This software is available to you under a choice of one of two 6 | * licenses. You may choose to be licensed under the terms of the GNU 7 | * General Public License (GPL) Version 2 (https://www.gnu.org/licenses/gpl-2.0.txt) 8 | * or the BSD license below: 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions are met: 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * * Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef __RCCE_H__ 34 | #define __RCCE_H__ 35 | 36 | #include 37 | #include 38 | 39 | #define RCCE_MAXNP 8 40 | #define RCCE_MPB_SIZE (64*1024) 41 | 42 | typedef struct tas { 43 | volatile unsigned char reg; 44 | unsigned char reserved[CACHE_LINE-1]; 45 | } tas_t __attribute__ ((aligned (CACHE_LINE))); 46 | 47 | typedef struct rcce_mpb { 48 | int id; // session id; 49 | volatile size_t mpb[MAX_ISLE]; 50 | } rcce_mpb_t; 51 | 52 | #define MAX_RCCE_SESSIONS ((PAGE_SIZE - CACHE_LINE*(RCCE_MAXNP+1)) / sizeof(rcce_mpb_t)) 53 | 54 | extern islelock_t* rcce_lock; 55 | extern rcce_mpb_t* rcce_mpb; 56 | extern uint64_t phy_rcce_internals; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /include/hermit/semaphore_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file include/hermit/semaphore_types.h 31 | * @brief semaphore type definition 32 | */ 33 | 34 | #ifndef __SEMAPHORE_TYPES_H__ 35 | #define __SEMAPHORE_TYPES_H__ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /** @brief Semaphore structure */ 44 | typedef struct sem { 45 | /// Resource available count 46 | unsigned int value; 47 | /// Queue of waiting tasks 48 | tid_t queue[MAX_TASKS]; 49 | /// Position in queue to add a task 50 | unsigned int wpos; 51 | /// Position in queue to get a task 52 | unsigned int rpos; 53 | /// Access lock 54 | spinlock_irqsave_t lock; 55 | } sem_t; 56 | 57 | /// Macro for initialization of semaphore 58 | #define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_IRQSAVE_INIT} 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/hermit/signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, Daniel Krebs, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Daniel Krebs 30 | * @file include/hermit/signal.h 31 | * @brief Signal related functions 32 | */ 33 | 34 | #ifndef __SIGNAL_H__ 35 | #define __SIGNAL_H__ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #include 42 | #include 43 | 44 | #define MAX_SIGNALS 32 45 | 46 | typedef void (*signal_handler_t)(int); 47 | 48 | // This is used in deqeue.h (HACK) 49 | typedef struct _sig { 50 | tid_t dest; 51 | int signum; 52 | } sig_t; 53 | 54 | /** @brief Send signal to kernel task 55 | * 56 | * @param dest Send signal to this task 57 | * @param signum Signal number 58 | * @return 59 | * - 0 on success 60 | * - -ENOENT (-2) if task not found 61 | */ 62 | int hermit_kill(tid_t dest, int signum); 63 | 64 | /** @brief Register signal handler 65 | * 66 | * @param handler Signal handler 67 | * @return 68 | * - 0 on success 69 | */ 70 | int hermit_signal(signal_handler_t handler); 71 | 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | 76 | #endif // __SIGNAL_H__ 77 | -------------------------------------------------------------------------------- /include/hermit/stdarg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __STDARG_H__ 29 | #define __STDARG_H__ 30 | 31 | /** 32 | * @author Stefan Lankes 33 | * @file include/hermit/stdarg.h 34 | * @brief Definition of variable argument lists 35 | */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef __builtin_va_list va_list; 42 | 43 | /// Initialize a variable argument list 44 | #define va_start __builtin_va_start 45 | /// Retrieve next argument 46 | #define va_arg __builtin_va_arg 47 | /// End using variable argument list 48 | #define va_end __builtin_va_end 49 | /// copies the (previously initialized) variable argument list 50 | #define va_copy __builtin_va_copy 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/hermit/stdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | * @author Stefan Lankes 30 | * @file include/hermit/stdio.h 31 | * @brief Stringstream related functions. Mainly printf-stuff. 32 | */ 33 | 34 | #ifndef __STDIO_H__ 35 | #define __STDIO_H__ 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * Works like the ANSI C function puts 47 | */ 48 | int kputs(const char *); 49 | 50 | /** 51 | * Works like the ANSI C function putchar 52 | */ 53 | int kputchar(int); 54 | 55 | /** 56 | * Works like the ANSI C function printf 57 | */ 58 | int kprintf(const char*, ...); 59 | 60 | /** 61 | * Initialize the I/O functions 62 | */ 63 | int koutput_init(void); 64 | 65 | /** 66 | * Works like the ANSI c function sprintf 67 | */ 68 | int ksprintf(char *str, const char *format, ...); 69 | 70 | /** 71 | * Works like the ANSI c function sprintf 72 | */ 73 | int ksnprintf(char *str, size_t size, const char *format, ...); 74 | 75 | /** 76 | * Scaled down version of printf(3) 77 | */ 78 | int kvprintf(char const *fmt, void (*func) (int, void *), void *arg, int radix, va_list ap); 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/hermit/virtio_ids.h: -------------------------------------------------------------------------------- 1 | #ifndef __VIRTIO_IDS_H 2 | #define __VIRTIO_IDS_H 3 | /* 4 | * Virtio IDs 5 | * 6 | * This header is BSD licensed so anyone can use the definitions to implement 7 | * compatible drivers/servers. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. Neither the name of IBM nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. */ 31 | 32 | #define VIRTIO_ID_NET 1 /* virtio net */ 33 | #define VIRTIO_ID_BLOCK 2 /* virtio block */ 34 | #define VIRTIO_ID_CONSOLE 3 /* virtio console */ 35 | #define VIRTIO_ID_RNG 4 /* virtio rng */ 36 | #define VIRTIO_ID_BALLOON 5 /* virtio balloon */ 37 | #define VIRTIO_ID_RPMSG 7 /* virtio remote processor messaging */ 38 | #define VIRTIO_ID_SCSI 8 /* virtio scsi */ 39 | #define VIRTIO_ID_9P 9 /* 9p virtio console */ 40 | #define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */ 41 | #define VIRTIO_ID_CAIF 12 /* Virtio caif */ 42 | #define VIRTIO_ID_GPU 16 /* virtio GPU */ 43 | #define VIRTIO_ID_INPUT 18 /* virtio input */ 44 | 45 | #endif /* _LINUX_VIRTIO_IDS_H */ 46 | -------------------------------------------------------------------------------- /include/hermit/virtio_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __VIRTIO_TYPES_H 2 | #define __VIRTIO_TYPES_H 3 | /* Type definitions for virtio implementations. 4 | * 5 | * This header is BSD licensed so anyone can use the definitions to implement 6 | * compatible drivers/servers. 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 | * 3. Neither the name of IBM nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 IBM 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 | * Copyright (C) 2014 Red Hat, Inc. 32 | * Author: Michael S. Tsirkin 33 | */ 34 | #include 35 | 36 | /* 37 | * __virtio{16,32,64} have the following meaning: 38 | * - __u{16,32,64} for virtio devices in legacy mode, accessed in native endian 39 | * - __le{16,32,64} for standard-compliant virtio devices 40 | */ 41 | 42 | typedef uint8_t __u8; 43 | typedef uint16_t __u16; 44 | typedef uint32_t __u32; 45 | typedef uint64_t __u64; 46 | 47 | #define __bitwise__ 48 | 49 | typedef __u16 __bitwise__ __virtio16; 50 | typedef __u32 __bitwise__ __virtio32; 51 | typedef __u64 __bitwise__ __virtio64; 52 | typedef __u32 __bitwise__ __le32; 53 | typedef __u16 __bitwise__ __le16; 54 | typedef __u8 __bitwise__ __le8; 55 | 56 | #endif /* __VIRTIO_TYPES_H */ 57 | -------------------------------------------------------------------------------- /include/netinet/in.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by the Chair for Operating Systems, RWTH Aachen University 3 | * 4 | * NO Copyright (C) 2010-2011, Stefan Lankes 5 | * consider these trivial macros to be public domain. 6 | * 7 | * These functions are distributed on an "AS IS" BASIS, 8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | */ 10 | 11 | #ifndef __NETINET_IN_H__ 12 | #define __NETINET_IN_H__ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | { 20 | #endif 21 | 22 | typedef uint16_t in_port_t; 23 | 24 | int inet_pton(int af, const char *src, void *dst); 25 | 26 | /** 255.255.255.255 */ 27 | #define IPADDR_NONE ((uint32_t)0xffffffffUL) 28 | /** 127.0.0.1 */ 29 | #define IPADDR_LOOPBACK ((uint32_t)0x7f000001UL) 30 | /** 0.0.0.0 */ 31 | #define IPADDR_ANY ((uint32_t)0x00000000UL) 32 | /** 255.255.255.255 */ 33 | #define IPADDR_BROADCAST ((uint32_t)0xffffffffUL) 34 | 35 | /** 255.255.255.255 */ 36 | #define INADDR_NONE IPADDR_NONE 37 | /** 127.0.0.1 */ 38 | #define INADDR_LOOPBACK IPADDR_LOOPBACK 39 | /** 0.0.0.0 */ 40 | #define INADDR_ANY IPADDR_ANY 41 | /** 255.255.255.255 */ 42 | #define INADDR_BROADCAST IPADDR_BROADCAST 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* __NETINET_IN_H__ */ 49 | -------------------------------------------------------------------------------- /include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by the Chair for Operating Systems, RWTH Aachen University 3 | * 4 | * NO Copyright (C) 2010-2011, Stefan Lankes 5 | * consider these trivial macros to be public domain. 6 | * 7 | * These functions are distributed on an "AS IS" BASIS, 8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | */ 10 | 11 | #ifndef __NETINET_TCP_H__ 12 | #define __NETINET_TCP_H__ 13 | 14 | #include 15 | 16 | #endif /* __NETINET_TCP_H__ */ 17 | -------------------------------------------------------------------------------- /include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STDARG_H__ 2 | #define __ANSI_STDARG_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define __VALIST va_list 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STDDEF_H__ 2 | #define __ANSI_STDDEF_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STDLIB_H__ 2 | #define __ANSI_STDLIB_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STRING_H__ 2 | #define __ANSI_STRING_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/sys/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __SYS_IPC_H__ 29 | #define __SYS_IPC_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #ifdef __KERNEL__ 38 | typedef long key_t; 39 | #endif 40 | 41 | #define IPC_PRIVATE ((key_t) 0) 42 | 43 | /* Obsolete, used only for backwards compatibility and libc5 compiles */ 44 | struct ipc_perm 45 | { 46 | key_t key; 47 | #if 0 48 | __kernel_uid_t uid; 49 | __kernel_gid_t gid; 50 | __kernel_uid_t cuid; 51 | __kernel_gid_t cgid; 52 | __kernel_mode_t mode; 53 | unsigned short seq; 54 | #endif 55 | }; 56 | 57 | /* resource get request flags */ 58 | #define IPC_CREAT 00001000 /* create if key is nonexistent */ 59 | #define IPC_EXCL 00002000 /* fail if key exists */ 60 | #define IPC_NOWAIT 00004000 /* return error on wait */ 61 | 62 | /* 63 | * Control commands used with semctl, msgctl and shmctl 64 | * see also specific commands in shm.h 65 | */ 66 | #define IPC_RMID 0 /* remove resource */ 67 | #define IPC_SET 1 /* set ipc_perm options */ 68 | #define IPC_STAT 2 /* get ipc_perm options */ 69 | #define IPC_INFO 3 /* see ipcs */ 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/sys/poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __SYS_POLL_H__ 29 | #define __SYS_POLL_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* These are specified by iBCS2 */ 38 | #define POLLIN 0x0001 39 | #define POLLPRI 0x0002 40 | #define POLLOUT 0x0004 41 | #define POLLERR 0x0008 42 | #define POLLHUP 0x0010 43 | #define POLLNVAL 0x0020 44 | 45 | /* The rest seem to be more-or-less nonstandard. Check them! */ 46 | #define POLLRDNORM 0x0040 47 | #define POLLRDBAND 0x0080 48 | #ifndef POLLWRNORM 49 | #define POLLWRNORM 0x0100 50 | #endif 51 | #ifndef POLLWRBAND 52 | #define POLLWRBAND 0x0200 53 | #endif 54 | #ifndef POLLMSG 55 | #define POLLMSG 0x0400 56 | #endif 57 | #ifndef POLLREMOVE 58 | #define POLLREMOVE 0x1000 59 | #endif 60 | #ifndef POLLRDHUP 61 | #define POLLRDHUP 0x2000 62 | #endif 63 | 64 | #define POLLFREE 0x4000 /* currently only for epoll */ 65 | 66 | #define POLL_BUSY_LOOP 0x8000 67 | 68 | struct pollfd { 69 | int fd; 70 | short events; 71 | short revents; 72 | }; 73 | 74 | typedef unsigned long int nfds_t; 75 | 76 | int poll(struct pollfd *fds, nfds_t nfds, int timeout); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/sys/shm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __SYS_SHM_H__ 29 | #define __SYS_SHM_H__ 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | struct shmid_ds { 38 | struct ipc_perm shm_perm; /* operation perms */ 39 | #if 0 40 | int shm_segsz; /* size of segment (bytes) */ 41 | __kernel_time_t shm_atime; /* last attach time */ 42 | __kernel_time_t shm_dtime; /* last detach time */ 43 | __kernel_time_t shm_ctime; /* last change time */ 44 | __kernel_ipc_pid_t shm_cpid; /* pid of creator */ 45 | __kernel_ipc_pid_t shm_lpid; /* pid of last operator */ 46 | unsigned short shm_nattch; /* no. of current attaches */ 47 | unsigned short shm_unused; /* compatibility */ 48 | void *shm_unused2; /* ditto - used by DIPC */ 49 | void *shm_unused3; /* unused */ 50 | #endif 51 | }; 52 | 53 | int shmget(key_t key, size_t size, int shmflg); 54 | void *shmat(int shmid, const void *shmaddr, int shmflg); 55 | int shmdt(const void *shmaddr); 56 | int shmctl(int shmid, int cmd, struct shmid_ds *buf); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/sys/uio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Just an empty dummy handler to be POSIX compliant. 3 | */ 4 | #ifndef __SYS_UIO_H__ 5 | #define __SYS_UIO_H__ 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /kernel/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | struct itimerval; 31 | 32 | int getitimer(int which, struct itimerval *value) 33 | { 34 | return 0; 35 | } 36 | 37 | int setitimer(int which, const struct itimerval *restrict value, struct itimerval * ovalue) 38 | { 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /libkern/sprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | typedef struct { 31 | char *str; 32 | size_t pos; 33 | size_t max; 34 | } sputchar_arg_t; 35 | 36 | static void sputchar(int c, void *arg) 37 | { 38 | sputchar_arg_t *dest = (sputchar_arg_t *) arg; 39 | 40 | if (dest->pos < dest->max) { 41 | dest->str[dest->pos] = (char)c; 42 | dest->pos++; 43 | } 44 | } 45 | 46 | int ksnprintf(char *str, size_t size, const char *format, ...) 47 | { 48 | int ret; 49 | va_list ap; 50 | sputchar_arg_t dest; 51 | 52 | dest.str = str; 53 | dest.pos = 0; 54 | dest.max = size; 55 | 56 | va_start(ap, format); 57 | ret = kvprintf(format, sputchar, &dest, 10, ap); 58 | va_end(ap); 59 | 60 | str[ret] = 0; 61 | 62 | return ret; 63 | } 64 | 65 | int ksprintf(char *str, const char *format, ...) 66 | { 67 | int ret; 68 | va_list ap; 69 | sputchar_arg_t dest; 70 | 71 | dest.str = str; 72 | dest.pos = 0; 73 | dest.max = (size_t) -1; 74 | 75 | va_start(ap, format); 76 | ret = kvprintf(format, sputchar, &dest, 10, ap); 77 | va_end(ap); 78 | 79 | str[ret] = 0; 80 | 81 | return ret; 82 | } 83 | -------------------------------------------------------------------------------- /libkern/strstr.c: -------------------------------------------------------------------------------- 1 | /* $NetBSD: strstr.c,v 1.1 2005/12/20 19:28:52 christos Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1990, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * 7 | * This code is derived from software contributed to Berkeley by 8 | * Chris Torek. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | /* 36 | * The code has been taken from NetBSD (sys/libkern/strstr.c) and is consequently 37 | * BSD-licensed. Unnecessary functions have been removed and all typedefs required 38 | * have been added. 39 | */ 40 | 41 | /* HermiCore prelude */ 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | /* 48 | * Find the first occurrence of find in s. 49 | */ 50 | char * 51 | _strstr(s, find) 52 | const char *s, *find; 53 | { 54 | char c, sc; 55 | size_t len; 56 | 57 | if (BUILTIN_EXPECT(!s, 0)) 58 | return NULL; 59 | if (BUILTIN_EXPECT(!find, 0)) 60 | return NULL; 61 | 62 | if ((c = *find++) != 0) { 63 | len = strlen(find); 64 | do { 65 | do { 66 | if ((sc = *s++) == 0) 67 | return (NULL); 68 | } while (sc != c); 69 | } while (strncmp(s, find, len) != 0); 70 | s--; 71 | } 72 | return ((char *) s); 73 | } 74 | -------------------------------------------------------------------------------- /tools/demo_kvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # do not use this script 4 | # it is written only for internal reasons 5 | 6 | MYPROMPT="~ > " 7 | 8 | clear 9 | echo -n $MYPROMPT 10 | echo -e " \e[92m# HermitCore is also usable as a classical unikernel. By setting the\e[39m" | randtype -m 2 -t 18,6000 11 | echo -n $MYPROMPT 12 | echo -e " \e[92m# environment variable HERMIT_ISLE to qemu, the application will be started\e[39m" | randtype -m 2 -t 18,6000 13 | echo -n $MYPROMPT 14 | echo -e " \e[92m# within a virtual machine. The boot time is about 1s.\e[39m" | randtype -m 0 -t 18,6000 15 | echo -n $MYPROMPT 16 | echo " HERMIT_ISLE=qemu time hermit/usr/tests/hello" | randtype -m 0 -t 18,6000 17 | HERMIT_ISLE=qemu time hermit/usr/tests/hello 18 | echo -n $MYPROMPT 19 | echo -e " \e[92m# The variable HERMIT_CPUS defines the number of virtual cores, while\e[39m" | randtype -m 2 -t 18,6000 20 | echo -n $MYPROMPT 21 | echo -e " \e[92m# HERMIT_MEM specifies the memory size of the virtual machine.\e[39m" | randtype -m 1 -t 18,6000 22 | echo -n $MYPROMPT 23 | echo " HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_MEM=1G hermit/usr/benchmarks/stream" | randtype -m 1 -t 18,6000 24 | HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_MEM=1G hermit/usr/benchmarks/stream 25 | echo -n $MYPROMPT 26 | echo -e " \e[92m# HermitCore's kernel messages are published by setting the environment\e[39m" | randtype -m 1 -t 18,6000 27 | echo -n $MYPROMPT 28 | echo -e " \e[92m# HERMIT_VERBOSE to 1.\e[39m" | randtype -m 1 -t 18,6000 29 | echo -n $MYPROMPT 30 | echo " HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_VERBOSE=1 hermit/usr/benchmarks/stream" | randtype -m 1 -t 18,6000 31 | HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_VERBOSE=1 hermit/usr/benchmarks/stream 32 | #echo $MYPROMPT 33 | echo -n $MYPROMPT 34 | echo -e " \e[92mHermitCore (\e[31mhttp://www.hermitcore.org\e[92m) is an experimental platform.\e[39m" | randtype -m 1 -t 18,6000 35 | echo -n $MYPROMPT 36 | echo -e " \e[92mBut try it out and send us a feedback!\e[39m" | randtype -m 1 -t 18,6000 37 | 38 | -------------------------------------------------------------------------------- /tools/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PROXY=/hermit/bin/proxy 4 | 5 | ELF_OSABI_OFFSET=7 6 | ELF_OSABI="\\x42" 7 | 8 | # Network 9 | /sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up 10 | /sbin/ifconfig eth0 up 10.0.2.15 netmask 255.255.255.0 up 11 | /sbin/ifconfig mmnif up 192.168.28.1 netmask 255.255.255.0 up 12 | /sbin/route add default gw 10.0.2.2 13 | /bin/hostname -F /etc/hostname 14 | echo "Network setup completed" 15 | 16 | # Load binfmt_misc kernel module and mount pseudo FS 17 | test -d /lib/modules && modprobe binfmt_misc 18 | grep binfmt_misc /proc/mounts || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 19 | 20 | # Register new format 21 | echo ":hermit:M:$ELF_OSABI_OFFSET:$ELF_OSABI::$PROXY:" > /proc/sys/fs/binfmt_misc/register 22 | 23 | # Startup completed 24 | sleep 1 && echo -e '\nWelcome to HermitCore (http://www.hermitcore.org/)!' 25 | 26 | /bin/sh 27 | -------------------------------------------------------------------------------- /usr/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore-Application.cmake) 3 | 4 | project(hermit_benchmarks C) 5 | 6 | if("${TARGET_ARCH}" STREQUAL "x86_64-hermit") 7 | add_executable(basic basic.c) 8 | target_link_libraries(basic pthread) 9 | 10 | add_executable(hg hg.c hist.c rdtsc.c run.c init.c opt.c report.c setup.c) 11 | 12 | add_executable(netio netio.c) 13 | 14 | add_executable(RCCE_pingpong RCCE_pingpong.c) 15 | target_link_libraries(RCCE_pingpong ircce) 16 | endif() 17 | 18 | add_executable(stream stream.c) 19 | target_compile_options(stream PRIVATE -fopenmp) 20 | target_link_libraries(stream -fopenmp) 21 | 22 | # deployment 23 | install_local_targets(extra/benchmarks) 24 | -------------------------------------------------------------------------------- /usr/benchmarks/hg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: main.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 14:59:20 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "opt.h" 20 | #include "init.h" 21 | #include "setup.h" 22 | #include "run.h" 23 | #include "report.h" 24 | 25 | #include 26 | #include 27 | 28 | struct opt opts = {0}; 29 | struct result results = {0}; 30 | 31 | int main(int argc, char *argv[]) 32 | { 33 | printf("hourglass\n"); 34 | 35 | opt(argc, argv, &opts); 36 | init(&opts); 37 | 38 | report_params(&opts); 39 | 40 | setup(&opts); 41 | run(&opts, &results); 42 | setdown(&opts); 43 | 44 | report(&opts, &results); 45 | 46 | run_free(&opts, &results); 47 | 48 | deinit(&opts); 49 | 50 | return EXIT_SUCCESS; 51 | } 52 | -------------------------------------------------------------------------------- /usr/benchmarks/hist.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: hist.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 26.07.2014 20:02:34 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "hist.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | static const struct opt *opts; 27 | static uint32_t *hists; 28 | 29 | uint32_t *hist_alloc(const struct opt *opt) 30 | { 31 | opts = opt; 32 | hists = calloc(opt->hist_cnt, sizeof(uint32_t)); 33 | hist_reset(); 34 | return hists; 35 | } 36 | 37 | int hist_reset(void) 38 | { 39 | unsigned i; 40 | for (i=0; ihist_cnt; i++) { 41 | hists[i] = 0; 42 | } 43 | return 0; 44 | } 45 | 46 | void hist_add(uint64_t t) 47 | { 48 | t /= opts->hist_width; 49 | if (t > opts->hist_cnt-1) t = opts->hist_cnt-1; 50 | hists[t]++; 51 | } 52 | 53 | int hist_print(void) 54 | { 55 | unsigned i; 56 | unsigned max=0; 57 | const size_t bar_width = 30; 58 | char bar[bar_width+1]; 59 | 60 | for (i=0; ihist_cnt; i++) { 61 | if (hists[i] > max) max = hists[i]; 62 | } 63 | max = (unsigned)ceil(log10((double)max)); 64 | if (max == 0) max = 1; 65 | memset(bar, '*', bar_width); 66 | bar[bar_width] = 0; 67 | 68 | printf("Histogram (%u bins with %u ticks each)\n", opts->hist_cnt, opts->hist_width); 69 | for (i=0; ihist_cnt; i++) { 70 | printf(" %5u : %5u..%5u : %-10u %s\n", i, 71 | (unsigned)(i*opts->hist_width), 72 | (unsigned)((i+1)*opts->hist_width-1), 73 | (unsigned)(hists[i]), 74 | (char*)bar+(unsigned)(bar_width-((log10(hists[i]+1.)*bar_width)/max))); 75 | } 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /usr/benchmarks/hist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: hist.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 26.07.2014 20:02:48 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __HIST_H__ 20 | #define __HIST_H__ 21 | 22 | #include "opt.h" 23 | 24 | #include 25 | 26 | uint32_t *hist_alloc(const struct opt *opt); 27 | int hist_reset(void); 28 | void hist_add(uint64_t t); 29 | int hist_print(void); 30 | 31 | #endif // __HIST_H__ 32 | -------------------------------------------------------------------------------- /usr/benchmarks/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: init.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:06:05 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "init.h" 20 | #include "rdtsc.h" 21 | 22 | 23 | int init(struct opt *opt) 24 | { 25 | /* 26 | * initialize (if required) 27 | * e.g. read number of processors available or cache parameters 28 | */ 29 | 30 | opt->tps = rdtsc_ticks_per_sec(); // does not work reliably... 31 | //opt->tps = 2530000000; 32 | 33 | 34 | return 0; 35 | } 36 | 37 | 38 | 39 | int deinit(struct opt *opt) 40 | { 41 | /* 42 | * de-initialize (if required) 43 | * e.g. free allocated resources 44 | */ 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /usr/benchmarks/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: init.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:05:13 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __INIT_H__ 20 | #define __INIT_H__ 21 | 22 | #include "opt.h" 23 | 24 | int init(struct opt *opt); 25 | int deinit(struct opt *opt); 26 | 27 | #endif // __INIT_H__ 28 | -------------------------------------------------------------------------------- /usr/benchmarks/opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: opt.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:02:15 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __OPT_H__ 20 | #define __OPT_H__ 21 | 22 | #include 23 | 24 | struct opt { 25 | unsigned secs; 26 | enum {stat, hist, list} mode; 27 | uint64_t tps; 28 | uint64_t threshold; 29 | 30 | unsigned hist_cnt; 31 | unsigned hist_width; 32 | 33 | unsigned list_cnt; 34 | }; 35 | 36 | int opt(int argc, char *argv[], struct opt *opt); 37 | 38 | #endif // __OPT_H__ 39 | -------------------------------------------------------------------------------- /usr/benchmarks/rdtsc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: rdtsc.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 24.01.2011 13:41:30 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef RDTSC_H 20 | #define RDTSC_H 21 | 22 | #include 23 | 24 | /* 25 | * rdtsc_ticks_per_sec(): measure frequency. Takes below a second. 26 | */ 27 | uint64_t rdtsc_ticks_per_sec(void) __attribute__((optimize(3))); 28 | 29 | 30 | typedef union __attribute__((__transparent_union__)) 31 | { 32 | uint64_t *__u64; 33 | struct {uint32_t __low; uint32_t __high;} *__u32; 34 | } tsc_t; 35 | 36 | /* 37 | * rdtsc(): Register-save version (compiler may insert additional push/pop) 38 | * (clobbered-registers not given b/c compiler deduces from output-registers) 39 | */ 40 | static inline void __attribute__((__always_inline__, gnu_inline, optimize(3))) rdtsc(tsc_t tsc) 41 | { 42 | __asm__ volatile ("rdtsc" : "=a"(tsc.__u32->__low), "=d"(tsc.__u32->__high) ); 43 | } 44 | 45 | /* 46 | * rdtsc_serial(): get RDTSC with leading and rear serializing LFENCE instruction 47 | */ 48 | static inline void __attribute__((__always_inline__, gnu_inline, optimize(3))) rdtsc_serialized(tsc_t tsc) 49 | { 50 | #if ! __MIC__ 51 | __asm__ volatile ( 52 | "lfence\n\t" // serialize (needs SSE2, available since AMD Athlon64, Intel Core) 53 | "rdtsc\n\t" 54 | "lfence\n\t" 55 | : "=a"(tsc.__u32->__low), "=d"(tsc.__u32->__high) ); 56 | #else 57 | __asm__ volatile ( 58 | "lock; add $0, 0(%%rsp)\n\t" // serialize 59 | "rdtsc\n\t" 60 | "lock; add $0, 0(%%rsp)\n\t" // serialize 61 | : "=a"(tsc.__u32->__low), "=d"(tsc.__u32->__high) :: "memory" ); 62 | #endif 63 | } 64 | 65 | void rdtsc_loop(uint64_t ticks); 66 | void rdtsc_loop_sec(unsigned seconds); 67 | uint64_t rdtsc_max_freq(int id); 68 | 69 | int rdtsc_is_invariant(void); 70 | uint64_t rdtsc_get_overhead(uint64_t iterations); 71 | uint64_t rdtsc_get_overhead_serialized(uint64_t iterations); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /usr/benchmarks/report.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: report.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:11:54 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "report.h" 20 | #include "hist.h" 21 | 22 | #include 23 | 24 | 25 | int report_params(const struct opt *opt) 26 | { 27 | printf("init: tps = %llu\n", (unsigned long long)opt->tps); 28 | printf("secs : %u\n", opt->secs); 29 | printf("threshold : %llu\n", (unsigned long long)opt->threshold); 30 | if (opt->mode == hist) { 31 | printf("mode : histogram (cnt: %u, width: %u)\n", opt->hist_cnt, opt->hist_width); 32 | } else if (opt->mode == list) { 33 | printf("mode : list (cnt: %u)\n", opt->list_cnt); 34 | } 35 | return 0; 36 | } 37 | 38 | static int report_stat(const struct result *result) 39 | { 40 | printf(" # loops : %15llu\n", 41 | (unsigned long long)result->cnt); 42 | printf(" Min. : %15llu (@loop #%llu)\n", 43 | (unsigned long long)result->min, 44 | (unsigned long long)result->t_min); 45 | printf(" Avg. : %18.2lf\n", 46 | (double)result->sum/(double)result->cnt); 47 | printf(" Max. : %15llu (@loop #%llu)\n", 48 | (unsigned long long)result->max, 49 | (unsigned long long)result->t_max); 50 | return 0; 51 | } 52 | 53 | int report(const struct opt *opt, const struct result *result) 54 | { 55 | /* 56 | * write results to stdout (or file) 57 | * depending on opt 58 | */ 59 | 60 | printf("Dummy result: %llu \n", (unsigned long long)result->dummy); 61 | 62 | report_stat(result); 63 | 64 | if (opt->mode == hist) { 65 | hist_print(); 66 | } else if (opt->mode == list) { 67 | unsigned i; 68 | for (i=0; ilist_cnt; i++) { 69 | if (result->list[i].time > 0) { 70 | printf(" %15llu : %10llu\n", 71 | (unsigned long long)result->list[i].time, 72 | (unsigned long long)result->list[i].gap); 73 | } else break; 74 | } 75 | 76 | } 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /usr/benchmarks/report.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: report.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:11:07 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __REPORT_H__ 20 | #define __REPORT_H__ 21 | 22 | #include "run.h" 23 | #include "opt.h" 24 | 25 | int report_params(const struct opt *opt); 26 | int report(const struct opt *opt, const struct result *result); 27 | 28 | #endif // __REPORT_H__ 29 | -------------------------------------------------------------------------------- /usr/benchmarks/run.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: run.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:08:43 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __RUN_H__ 20 | #define __RUN_H__ 21 | 22 | #include "opt.h" 23 | 24 | #include 25 | struct res_list { 26 | uint64_t time; 27 | uint64_t gap; 28 | }; 29 | 30 | struct result { 31 | uint64_t dummy; 32 | 33 | uint64_t min; 34 | uint64_t max; 35 | uint64_t sum; 36 | uint64_t cnt; 37 | uint64_t t_min; 38 | uint64_t t_max; 39 | 40 | uint32_t *hist; 41 | struct res_list *list; 42 | 43 | }; 44 | 45 | int run(const struct opt *opt, struct result *result); 46 | int run_free(const struct opt *opt, struct result *result); 47 | 48 | 49 | #endif // __RUN_H__ 50 | 51 | -------------------------------------------------------------------------------- /usr/benchmarks/setup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: setup.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:07:43 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "setup.h" 20 | 21 | 22 | int setup(struct opt *opt) 23 | { 24 | /* 25 | * set up run-time environment for benchmark 26 | * depending on opt 27 | * e.g. create cpu-set, move IRQs, etc. 28 | */ 29 | 30 | 31 | return 0; 32 | } 33 | 34 | int setdown(struct opt *opt) 35 | { 36 | /* 37 | * undo things from setup() 38 | */ 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /usr/benchmarks/setup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: setup.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:06:59 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __SETUP_H__ 20 | #define __SETUP_H__ 21 | 22 | #include "opt.h" 23 | 24 | int setup(struct opt *opt); 25 | int setdown(struct opt *opt); 26 | 27 | #endif // __SETUP_H__ 28 | -------------------------------------------------------------------------------- /usr/gdb/hermit-gdb.py: -------------------------------------------------------------------------------- 1 | # 2 | # gdb helper commands and functions for Linux kernel debugging 3 | # 4 | # loader module 5 | # 6 | # Copyright (c) Siemens AG, 2012, 2013 7 | # 8 | # Authors: 9 | # Jan Kiszka 10 | # 11 | # This work is licensed under the terms of the GNU GPL version 2. 12 | # 13 | 14 | import os 15 | 16 | sys.path.insert(0, os.path.dirname(__file__)) 17 | 18 | try: 19 | gdb.parse_and_eval("0") 20 | gdb.execute("", to_string=True) 21 | except: 22 | gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to " 23 | "work.\n") 24 | else: 25 | import hermit.tasks 26 | -------------------------------------------------------------------------------- /usr/gdb/hermit/__init__.py: -------------------------------------------------------------------------------- 1 | # nothing to do for the initialization of this package 2 | -------------------------------------------------------------------------------- /usr/ircce/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore.cmake) 3 | 4 | project(hermit_ircce C) 5 | 6 | add_compile_options(${HERMIT_APP_FLAGS}) 7 | 8 | file(GLOB SOURCES *.c) 9 | 10 | add_library(ircce STATIC ${SOURCES}) 11 | 12 | # deployment 13 | install(TARGETS ircce 14 | DESTINATION ${TARGET_ARCH}/lib) 15 | install(FILES 16 | iRCCE.h iRCCE_lib.h RCCE_debug.h RCCE.h RCCE_lib.h rte_memcpy.h 17 | DESTINATION 18 | ${TARGET_ARCH}/include) 19 | -------------------------------------------------------------------------------- /usr/ircce/RCCE_bcast.c: -------------------------------------------------------------------------------- 1 | //*************************************************************************************** 2 | // Broadcast functions. 3 | //*************************************************************************************** 4 | // Since only collective operations require communication domains, they are the only ones 5 | // that use communicators. All collectives implementations are naive, linear operations. 6 | // There may not be any overlap between target and source. 7 | // 8 | // Author: Rob F. Van der Wijngaart 9 | // Intel Corporation 10 | // Date: 008/30/2010 11 | // 12 | //************************************************************************************** 13 | // 14 | // Copyright 2010 Intel Corporation 15 | // 16 | // Licensed under the Apache License, Version 2.0 (the "License"); 17 | // you may not use this file except in compliance with the License. 18 | // You may obtain a copy of the License at 19 | // 20 | // http://www.apache.org/licenses/LICENSE-2.0 21 | // 22 | // Unless required by applicable law or agreed to in writing, software 23 | // distributed under the License is distributed on an "AS IS" BASIS, 24 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | // See the License for the specific language governing permissions and 26 | // limitations under the License. 27 | // 28 | 29 | #include "RCCE_lib.h" 30 | 31 | #ifdef USE_RCCE_COMM 32 | #ifndef GORY 33 | #include "RCCE_comm/RCCE_bcast.c" 34 | #endif 35 | #else 36 | 37 | #include 38 | #include 39 | 40 | //-------------------------------------------------------------------------------------- 41 | // RCCE_bcast 42 | //-------------------------------------------------------------------------------------- 43 | // function that sends data from UE root to all other UEs in the communicator 44 | //-------------------------------------------------------------------------------------- 45 | int RCCE_bcast( 46 | char *buf, // private memory, used for sending (root) and receiving (other UEs) 47 | size_t num, // number of bytes to be sent 48 | int root, // source within "comm" of broadcast data 49 | RCCE_COMM comm // communication domain 50 | ) { 51 | 52 | int ue, ierr; 53 | #ifdef GORY 54 | printf("Collectives only implemented for simplified API\n"); 55 | return(1); 56 | #else 57 | // check to make sure root is member of the communicator 58 | if (root<0 || root >= comm.size) 59 | return(RCCE_error_return(RCCE_debug_comm,RCCE_ERROR_ID)); 60 | 61 | if (RCCE_IAM == comm.member[root]) { 62 | for (ue=0; ue 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static 8 | uint64_t memparse(const char *ptr) 9 | { 10 | // local pointer to end of parsed string 11 | char *endptr; 12 | 13 | // parse number 14 | uint64_t size = strtoull(ptr, &endptr, 0); 15 | 16 | // parse size extension, intentional fall-through 17 | switch (*endptr) { 18 | case 'E': 19 | case 'e': 20 | size <<= 10; 21 | case 'P': 22 | case 'p': 23 | size <<= 10; 24 | case 'T': 25 | case 't': 26 | size <<= 10; 27 | case 'G': 28 | case 'g': 29 | size <<= 10; 30 | case 'M': 31 | case 'm': 32 | size <<= 10; 33 | case 'K': 34 | case 'k': 35 | size <<= 10; 36 | endptr++; 37 | default: 38 | break; 39 | } 40 | 41 | return size; 42 | } 43 | 44 | int main(int argc, char **argv) { 45 | if (argc != 2) { 46 | fprintf(stderr, "ERROR: You have to specify the size of the memory region to be allocated!\n"); 47 | exit(-1); 48 | } 49 | 50 | uint64_t alloc_size = memparse(argv[1]); 51 | printf("Allocating %llu bytes ...\n", alloc_size); 52 | char *mem_reg = (char*)malloc(alloc_size); 53 | if (mem_reg == NULL) { 54 | fprintf(stderr, "ERROR: Could not allocate %llu bytes of memory!\n", alloc_size); 55 | exit(-1); 56 | } 57 | memset(mem_reg, 0x42, alloc_size); 58 | printf("Allocated and mapped!\n"); 59 | 60 | uint32_t cnt = 0; 61 | while(1) { 62 | uint64_t i; 63 | for (i=0; i 2 | #include 3 | #include 4 | 5 | extern char **environ; 6 | 7 | int main(int argc, char **argv) { 8 | int i; 9 | 10 | printf("argc: %d\n", argc); 11 | for(i=0; i 2 | #include 3 | #include 4 | 5 | 6 | int main(int argc, char **argv) { 7 | int cnt = 0; 8 | #pragma omp parallel 9 | while(1) { 10 | #pragma omp critical 11 | { 12 | printf("Counter %d\n", ++cnt); 13 | } 14 | sys_msleep(500); 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /usr/tests/hello++.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | using namespace std; 32 | 33 | int main(int argc, char** argv) 34 | { 35 | cout << "Hello World from g++!!!" << endl; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /usr/tests/hello.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 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 are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * 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 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #define N 255 36 | 37 | static void test_handler(int s) 38 | { 39 | printf("Receive signal with number %d\n", s); 40 | } 41 | 42 | int main(int argc, char** argv) 43 | { 44 | int i, random; 45 | FILE* file; 46 | 47 | // register test handler 48 | signal(SIGUSR1, test_handler); 49 | 50 | printf("Hello World!!!\n"); 51 | //for(i=0; environ[i]; i++) 52 | // printf("environ[%d] = %s\n", i, environ[i]); 53 | for(i=0; i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef NUM_THREADS 9 | #define NUM_THREADS 2 10 | #endif 11 | 12 | #ifndef NUM_ITER 13 | #define NUM_ITER 10000 14 | #endif 15 | 16 | #ifndef SIZE 17 | #define SIZE 16384 18 | #endif 19 | 20 | __thread void* buf; 21 | 22 | static void* perform_work( void* argument ) 23 | { 24 | int passed_in_value; 25 | 26 | passed_in_value = *( ( int* )argument ); 27 | printf("Hello World! It's me, thread %d with argument %d!\n", getpid(), passed_in_value); 28 | 29 | /* optionally: insert more useful stuff here */ 30 | for(int i=0; i 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef NUM_ITER 7 | #define NUM_ITER 100000 8 | #endif 9 | 10 | #ifndef SIZE 11 | #define SIZE 16*1024 12 | #endif 13 | 14 | void* buf; 15 | 16 | int main(int argc, char** argv) 17 | { 18 | /* optionally: insert more useful stuff here */ 19 | 20 | for(int i=0; i 2 | #include 3 | 4 | #define MAX_THREADS 2 5 | 6 | __thread int id = -1; 7 | 8 | void* thread_func(void* arg) 9 | { 10 | id = *((int*) arg); 11 | 12 | printf("Hello thread!!! id = %d\n", id); 13 | return 0; 14 | } 15 | 16 | int main(int argc, char** argv) 17 | { 18 | pthread_t threads[MAX_THREADS]; 19 | int param[MAX_THREADS]; 20 | 21 | printf("Hello form main thread! id = %d\n", id); 22 | 23 | for(int i=0; i 16 | #include 17 | #include "xray_priv.h" 18 | 19 | #if defined(XRAY) 20 | 21 | struct XRayStringPoolNode { 22 | struct XRayStringPoolNode* next; 23 | char strings[XRAY_STRING_POOL_NODE_SIZE]; 24 | }; 25 | 26 | 27 | struct XRayStringPool { 28 | struct XRayStringPoolNode* head; 29 | struct XRayStringPoolNode* current; 30 | int index; 31 | }; 32 | 33 | 34 | static struct XRayStringPoolNode* XRayStringPoolAllocNode() { 35 | struct XRayStringPoolNode* s; 36 | s = (struct XRayStringPoolNode *)XRayMalloc(sizeof(*s)); 37 | s->next = NULL; 38 | return s; 39 | } 40 | 41 | 42 | static int XRayStringPoolCurrentNodeSpaceAvail(struct XRayStringPool* pool) { 43 | int i = pool->index; 44 | return (XRAY_STRING_POOL_NODE_SIZE - i) - 1; 45 | } 46 | 47 | 48 | /* Append a string to the string pool. */ 49 | char* XRayStringPoolAppend(struct XRayStringPool* pool, const char* src) { 50 | /* Add +1 to STRING_POOL_NODE_SIZE to detect large strings */ 51 | /* Add +1 to strnlen result to account for string termination */ 52 | int n = strnlen(src, XRAY_STRING_POOL_NODE_SIZE + 1) + 1; 53 | int a = XRayStringPoolCurrentNodeSpaceAvail(pool); 54 | char* dst; 55 | /* Don't accept strings larger than the pool node. */ 56 | if (n >= (XRAY_STRING_POOL_NODE_SIZE - 1)) 57 | return NULL; 58 | /* If string doesn't fit, alloc a new node. */ 59 | if (n > a) { 60 | pool->current->next = XRayStringPoolAllocNode(); 61 | pool->current = pool->current->next; 62 | pool->index = 0; 63 | } 64 | /* Copy string and return a pointer to copy. */ 65 | dst = &pool->current->strings[pool->index]; 66 | strcpy(dst, src); 67 | pool->index += n; 68 | return dst; 69 | } 70 | 71 | 72 | /* Create & initialize a string pool instance. */ 73 | struct XRayStringPool* XRayStringPoolCreate() { 74 | struct XRayStringPool* pool; 75 | pool = (struct XRayStringPool*)XRayMalloc(sizeof(*pool)); 76 | pool->head = XRayStringPoolAllocNode(); 77 | pool->current = pool->head; 78 | return pool; 79 | } 80 | 81 | 82 | /* Free a string pool. */ 83 | void XRayStringPoolFree(struct XRayStringPool* pool) { 84 | struct XRayStringPoolNode* n = pool->head; 85 | while (NULL != n) { 86 | struct XRayStringPoolNode* c = n; 87 | n = n->next; 88 | XRayFree(c); 89 | } 90 | XRayFree(pool); 91 | } 92 | 93 | #endif /* XRAY */ 94 | 95 | -------------------------------------------------------------------------------- /usr/xray/xray.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hermit-os/libhermit/b27b19458cce322fbeb37e9bccfb47df4888659b/usr/xray/xray.odt --------------------------------------------------------------------------------