Skip to content

Commit c186da5

Browse files
authored
Merge pull request #1362 from hioa-cs/dev
Merge dev
2 parents 15bb0ab + e74f402 commit c186da5

662 files changed

Lines changed: 30782 additions & 22528 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ indent_size = 4
2121

2222
[boot]
2323
indent_size = 4
24+
25+
[*.asm]
26+
indent_size = 4

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*.d
1515
*.pyc
1616
*.ropeproject
17+
*.xml
1718
nbproject
1819

1920
!Dockerfile
@@ -38,7 +39,9 @@ src/compile_commands.json
3839
/examples/demo_service/IncludeOS_Demo_Service
3940
/seed/My_Service
4041

41-
build
42+
build/
43+
build_i686/
44+
build_x86_64/
4245

4346
# cmake related
4447
CMakeFiles*

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
matrix:
2+
include:
3+
- os: osx
4+
env: COMPILER='clang++'
5+
osx_image: xcode8.2
6+
- os: osx
7+
env: COMPILER='clang++'
8+
osx_image: xcode8
9+
10+
install:
11+
- if [ $TRAVIS_OS_NAME == osx ]; then brew update ; brew uninstall --force cmake; brew install cmake ; fi
12+
- git submodule update --init --recursive
13+
14+
before_script:
15+
- export CXX=$COMPILER
16+
- cd test
17+
- mkdir darwin && cd darwin
18+
19+
script:
20+
- cmake .. -DTRAVIS=ON -DEXTRA_TESTS=ON
21+
- make VERBOSE=1 && ./unittests --pass

CMakeLists.txt

Lines changed: 78 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,63 @@ cmake_minimum_required(VERSION 2.8.9)
22

33
set(INCLUDEOS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/)
44

5-
set(CMAKE_TOOLCHAIN_FILE ${INCLUDEOS_ROOT}/cmake/i686-elf-toolchain.cmake)
5+
# Target CPU Architecture
6+
if(DEFINED ENV{ARCH})
7+
set(ARCH "$ENV{ARCH}" CACHE STRING "Architecture")
8+
else()
9+
set(ARCH "x86_64" CACHE STRING "Architecture (default)")
10+
endif()
611

7-
project (includeos)
12+
message(STATUS "Target CPU ${ARCH}")
13+
14+
set(TRIPLE "${ARCH}-pc-linux-elf")
15+
set(CMAKE_CXX_COMPILER_TARGET ${TRIPLE})
16+
set(CMAKE_C_COMPILER_TARGET ${TRIPLE})
17+
18+
message(STATUS "Target triple ${TRIPLE}")
19+
20+
set(CMAKE_TOOLCHAIN_FILE ${INCLUDEOS_ROOT}/cmake/${ARCH}-elf-toolchain.cmake)
21+
22+
project (includeos C CXX)
823

924
set(LIB ${CMAKE_INSTALL_PREFIX}/includeos/lib)
1025
set(BIN ${CMAKE_INSTALL_PREFIX}/includeos/bin)
1126
set(SCRIPTS ${CMAKE_INSTALL_PREFIX}/includeos/scripts)
1227

13-
# test compiler
14-
if(CMAKE_COMPILER_IS_GNUCC)
15-
# currently gcc is not supported due to problems cross-compiling a unikernel
16-
# (i.e., building a 32bit unikernel (only supported for now) on a 64bit system)
17-
message(FATAL_ERROR "Building IncludeOS with gcc is not currently supported. Please clean-up build directory and configure for clang through CC and CXX environmental variables.")
18-
endif(CMAKE_COMPILER_IS_GNUCC)
28+
# C++ version
29+
set(CMAKE_CXX_STANDARD 14)
1930

2031
# create OS version string from git describe (used in CXX flags)
2132
execute_process(COMMAND git describe --dirty
2233
WORKING_DIRECTORY ${INCLUDEOS_ROOT}
2334
OUTPUT_VARIABLE OS_VERSION)
2435
string(STRIP ${OS_VERSION} OS_VERSION)
2536

37+
option(cpu_feat_vanilla "Restrict use of CPU features to vanilla" ON)
38+
if(cpu_feat_vanilla)
39+
include("cmake/vanilla.cmake")
40+
set(DEFAULT_SETTINGS_CMAKE "vanilla.cmake") # for service cmake
41+
set(DEFAULT_VM "vm.vanilla.json") # vmrunner
42+
else()
43+
include("cmake/cpu_feat.cmake")
44+
set(DEFAULT_SETTINGS_CMAKE "cpu_feat.cmake") # for service cmake
45+
set(DEFAULT_VM "vm.cpu_feat.json") # vmrunner
46+
endif(cpu_feat_vanilla)
47+
48+
option(single_threaded "Compile without SMP support" ON)
49+
2650
# create random hex string as stack protector canary
2751
string(RANDOM LENGTH 8 ALPHABET 0123456789ABCDEF STACK_PROTECTOR_VALUE)
2852

29-
set(CAPABS "-msse3 -fstack-protector-strong -D_STACK_GUARD_VALUE_=0x${STACK_PROTECTOR_VALUE} ")
53+
set(CAPABS "${CAPABS} -mno-red-zone -fstack-protector-strong -D_STACK_GUARD_VALUE_=0x${STACK_PROTECTOR_VALUE}")
3054

3155
# Various global defines
3256
# * NO_DEBUG disables output from the debug macro
3357
# * OS_TERMINATE_ON_CONTRACT_VIOLATION provides classic assert-like output from Expects / Ensures
3458
# * _GNU_SOURCE enables POSIX-extensions in newlib, such as strnlen. ("everything newlib has", ref. cdefs.h)
3559
set(CAPABS "${CAPABS} -DNO_DEBUG=1 -DOS_TERMINATE_ON_CONTRACT_VIOLATION -D_GNU_SOURCE")
3660

37-
set(WARNS "-Wall -Wextra") #-pedantic
61+
set(WARNS "-Wall -Wextra")
3862

3963
# configure options
4064
option(debug "Build with debugging symbols (OBS: Dramatically increases binary size)" OFF)
@@ -52,12 +76,15 @@ endfunction()
5276
init_submodule(mod/GSL)
5377
init_submodule(mod/http-parser)
5478
init_submodule(mod/uzlib)
79+
init_submodule(mod/rapidjson)
80+
81+
install(DIRECTORY mod/rapidjson/include/rapidjson DESTINATION includeos/include)
5582

5683
# set optimization level
5784
set(OPTIMIZE "-O2")
5885

5986
if(debug OR debug-info OR debug-all)
60-
set(CAPABS "${CAPABS} -O0")
87+
set(OTPIMIZE "-O0")
6188
endif(debug OR debug-info OR debug-all)
6289

6390
if(minimal)
@@ -81,24 +108,41 @@ endif(silent)
81108
# Append optimization level
82109
set(CAPABS "${CAPABS} ${OPTIMIZE}")
83110

84-
# these kinda work with llvm
85-
set(CMAKE_CXX_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
86-
set(CMAKE_C_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -DOS_VERSION=\"\"${OS_VERSION}\"\"")
111+
if (CMAKE_COMPILER_IS_GNUCC)
112+
# gcc/g++ settings
113+
set(CMAKE_CXX_FLAGS " -MMD ${CAPABS} ${WARNS} -Wno-frame-address -nostdlib -fno-omit-frame-pointer -c -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
114+
set(CMAKE_C_FLAGS " -MMD ${CAPABS} ${WARNS} -nostdlib -fno-omit-frame-pointer -c -DOS_VERSION=\"\"${OS_VERSION}\"\"")
115+
else()
116+
# these kinda work with llvm
117+
set(CMAKE_CXX_FLAGS "-MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -fno-omit-frame-pointer -c -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
118+
set(CMAKE_C_FLAGS "-MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -fno-omit-frame-pointer -c -DOS_VERSION=\"\"${OS_VERSION}\"\"")
119+
endif()
87120

88121
# either download or cross-compile needed libraries
89-
option(from_bundle "Download and use pre-compiled libraries for cross-comilation" ON)
122+
#option(from_bundle "Download and use pre-compiled libraries for cross-comilation" ON)
123+
set(BUNDLE_LOC "" CACHE STRING "Local path of bundle with pre-compile libraries")
90124
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cross_compiled_libraries.txt)
91125

92-
add_subdirectory(mod)
126+
# Botan Crypto & TLS
127+
# Note: Include order matters!
128+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/botan.cmake)
93129

130+
#
131+
# Subprojects
132+
#
133+
add_subdirectory(mod)
94134
add_subdirectory(src)
95135

136+
#
137+
# External projects
138+
#
96139
option(vmbuild "Build and install vmbuild and elf_syms" ON)
97140
if(vmbuild)
98141
# Install vmbuilder as an external project
99142
ExternalProject_Add(vmbuild
100143
PREFIX vmbuild # Build where
101144
SOURCE_DIR ${INCLUDEOS_ROOT}/vmbuild # Where is project located
145+
BINARY_DIR ${INCLUDEOS_ROOT}/vmbuild/build
102146
INSTALL_DIR ${BIN} # Where to install
103147
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> # Pass installation folder
104148
)
@@ -128,27 +172,35 @@ if(tests)
128172
ExternalProject_Add(unittests
129173
PREFIX unittests
130174
SOURCE_DIR ${INCLUDEOS_ROOT}/test
175+
BINARY_DIR unittests
131176
CMAKE_ARGS -DINCLUDEOS_ROOT=${INCLUDEOS_ROOT} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
132177
)
133178
#add_subdirectory(test)
134179
endif(tests)
135180

136181
option(libmana "Build and install mana web application framework library" ON)
137182
if(libmana)
138-
set(rapidjson ON) # Dependent on rapidjson
139183
add_subdirectory(lib/mana)
140184
endif(libmana)
141185

142-
option(rapidjson "Download and install rapidjson submodule" ON)
143-
if(rapidjson)
144-
init_submodule(mod/rapidjson)
145-
install(DIRECTORY mod/rapidjson/include/rapidjson DESTINATION includeos/include)
146-
endif(rapidjson)
186+
#
187+
# Installation
188+
#
189+
190+
# Install cmake files
191+
install(FILES cmake/pre.service.cmake DESTINATION includeos)
192+
install(FILES cmake/post.service.cmake DESTINATION includeos)
193+
install(FILES cmake/library.cmake DESTINATION includeos)
194+
install(FILES cmake/${DEFAULT_SETTINGS_CMAKE} DESTINATION includeos RENAME settings.cmake) # cpu_feat_vanilla opt
195+
196+
# Install vmrunner
197+
install(DIRECTORY vmrunner DESTINATION includeos)
198+
install(FILES vmrunner/${DEFAULT_VM} DESTINATION includeos/vmrunner/ RENAME vm.default.json) # cpu_feat_vanilla opt
199+
200+
# Install toolchain
201+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${ARCH}-elf-toolchain.cmake DESTINATION includeos)
147202

148-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/service.cmake DESTINATION includeos)
149-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/library.cmake DESTINATION includeos)
150-
install(DIRECTORY vmrunner DESTINATION includeos/)
151-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/i686-elf-toolchain.cmake DESTINATION includeos)
203+
# Install seed
152204
install(DIRECTORY seed/ DESTINATION includeos/seed)
153205

154206
# Install boot util

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ IncludeOS is free software, with "no warranties or restrictions of any kind".
2222

2323
## Build status
2424

25-
| | Build from bundle |
26-
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
27-
| Master | [![Build Status](https://jenkins.includeos.org/buildStatus/icon?job=shield_master_bundle)](https://jenkins.includeos.org/job/shield_master_bundle/) |
28-
| Dev | [![Build Status](https://jenkins.includeos.org/buildStatus/icon?job=shield_dev_bundle)](https://jenkins.includeos.org/job/shield_dev_bundle/) |
25+
| | Build from bundle | Integration tests |
26+
|--------|-------------------|-------------------|
27+
| Master | [![Build Status](https://img.shields.io/jenkins/s/https/jenkins.includeos.org/shield_master_bundle.svg)](https://jenkins.includeos.org/job/shield_master_bundle/) | Coming soon |
28+
| Dev | [![Build Status](https://img.shields.io/jenkins/s/https/jenkins.includeos.org/shield_dev_bundle.svg)](https://jenkins.includeos.org/job/shield_dev_bundle/) | [![Jenkins tests](https://img.shields.io/jenkins/t/https/jenkins.includeos.org/shield_dev_integration_tests.svg)](https://jenkins.includeos.org/job/shield_dev_integration_tests/) |
2929

3030
### Key features
3131

3232
* **Extreme memory footprint**: A minimal bootable image, including bootloader, operating system components and a complete C++ standard library is currently 707K when optimized for size.
33-
* **KVM and VirtualBox support** with full virtualization, using [x86 hardware virtualization](https://en.wikipedia.org/wiki/X86_virtualization), available on any modern x86 CPUs). In principle IncludeOS should run on any x86 hardware platform, even on a physical x86 computer, given appropriate drivers. Officially, we develop for- and test on [Linux KVM](http://www.linux-kvm.org/page/Main_Page), which power the [OpenStack IaaS cloud](https://www.openstack.org/), and [VirtualBox](https://www.virtualbox.org), which means that you can run your IncludeOS service on both Linux, Microsoft Windows and macOS.
33+
* **KVM, VirtualBox and VMWare support** with full virtualization, using [x86 hardware virtualization](https://en.wikipedia.org/wiki/X86_virtualization), available on any modern x86 CPUs). In principle IncludeOS should run on any x86 hardware platform, even on a physical x86 computer, given appropriate drivers. Officially, we develop for- and test on [Linux KVM](http://www.linux-kvm.org/page/Main_Page), which power the [OpenStack IaaS cloud](https://www.openstack.org/), and [VirtualBox](https://www.virtualbox.org), which means that you can run your IncludeOS service on both Linux, Microsoft Windows and macOS.
3434
* **C++11/14 support**
3535
* Full C++11/14 language support with [clang](http://clang.llvm.org) v3.8 and later.
3636
* Standard C++ library (STL) [libc++](http://libcxx.llvm.org) from [LLVM](http://llvm.org/).

api/arch.hpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// -*-C++-*-
2+
// This file is a part of the IncludeOS unikernel - www.includeos.org
3+
//
4+
// Copyright 2017 Oslo and Akershus University College of Applied Sciences
5+
// and Alfred Bratterud
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
#pragma once
20+
#ifndef INCLUDEOS_ARCH_HEADER
21+
#define INCLUDEOS_ARCH_HEADER
22+
23+
#include <cstddef>
24+
#include <cstdint>
25+
#include <cassert>
26+
27+
extern void __arch_init();
28+
extern void __arch_poweroff();
29+
extern void __arch_reboot();
30+
extern void __arch_enable_legacy_irq(uint8_t);
31+
extern void __arch_disable_legacy_irq(uint8_t);
32+
inline void __arch_hw_barrier() noexcept;
33+
inline void __sw_barrier() noexcept;
34+
inline uint64_t __arch_cpu_cycles() noexcept;
35+
36+
37+
inline void __sw_barrier() noexcept
38+
{
39+
asm volatile("" ::: "memory");
40+
}
41+
42+
// Include arch specific inline implementations
43+
#if defined(ARCH_x86_64)
44+
#include "arch/x86_64.hpp"
45+
#elif defined(ARCH_i686)
46+
#include "arch/i686.hpp"
47+
#else
48+
#error "Unsupported arch specified"
49+
#endif
50+
51+
#endif

api/arch/i686.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// -*-C++-*-
2+
// This file is a part of the IncludeOS unikernel - www.includeos.org
3+
//
4+
// Copyright 2017 Oslo and Akershus University College of Applied Sciences
5+
// and Alfred Bratterud
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
#ifndef i686_ARCH_HPP
20+
#define i686_ARCH_HPP
21+
22+
#include <arch/x86.hpp>
23+
24+
inline uint64_t __arch_cpu_cycles() noexcept {
25+
uint64_t ret;
26+
asm("rdtsc" : "=A" (ret));
27+
return ret;
28+
}
29+
30+
31+
#endif

api/arch/x86.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// -*-C++-*-
2+
// This file is a part of the IncludeOS unikernel - www.includeos.org
3+
//
4+
// Copyright 2017 Oslo and Akershus University College of Applied Sciences
5+
// and Alfred Bratterud
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
#ifndef X86_ARCH_HPP
20+
#define X86_ARCH_HPP
21+
22+
#define ARCH_x86
23+
24+
25+
inline void __arch_hw_barrier() noexcept
26+
{
27+
asm volatile("mfence" ::: "memory");
28+
}
29+
30+
#endif

api/arch/x86_64.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// -*-C++-*-
2+
// This file is a part of the IncludeOS unikernel - www.includeos.org
3+
//
4+
// Copyright 2017 Oslo and Akershus University College of Applied Sciences
5+
// and Alfred Bratterud
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
#ifndef X86_64_ARCH_HPP
20+
#define X86_64_ARCH_HPP
21+
22+
#include <arch/x86.hpp>
23+
24+
inline uint64_t __arch_cpu_cycles() noexcept {
25+
uint32_t hi, lo;
26+
asm("rdtsc" : "=a"(lo), "=d"(hi));
27+
return ((uint64_t) lo) | ((uint64_t) hi) << 32;
28+
}
29+
30+
#endif

0 commit comments

Comments
 (0)