Skip to content

Commit c2f38f2

Browse files
committed
Merge branch 'master' of github.com:hioa-cs/IncludeOS
2 parents 5f025bd + af634ec commit c2f38f2

525 files changed

Lines changed: 21995 additions & 7711 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ src/compile_commands.json
3939
/examples/demo_service/IncludeOS_Demo_Service
4040
/seed/My_Service
4141

42-
build
42+
build/
43+
build_i686/
44+
build_x86_64/
4345

4446
# cmake related
4547
CMakeFiles*
4648
CMakeCache*
4749
cmake_install.cmake
50+
51+
dummy.disk

CMakeLists.txt

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,33 @@ 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()
11+
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+
option(WITH_SOLO5 "Install with solo5 support" ON)
21+
22+
set(CMAKE_TOOLCHAIN_FILE ${INCLUDEOS_ROOT}/cmake/${ARCH}-elf-toolchain.cmake)
623

7-
project (includeos)
24+
project (includeos C CXX)
825

926
set(LIB ${CMAKE_INSTALL_PREFIX}/includeos/lib)
1027
set(BIN ${CMAKE_INSTALL_PREFIX}/includeos/bin)
1128
set(SCRIPTS ${CMAKE_INSTALL_PREFIX}/includeos/scripts)
1229

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)
30+
# C++ version
31+
set(CMAKE_CXX_STANDARD 14)
1932

2033
# create OS version string from git describe (used in CXX flags)
2134
execute_process(COMMAND git describe --dirty
@@ -34,8 +47,10 @@ else()
3447
set(DEFAULT_VM "vm.cpu_feat.json") # vmrunner
3548
endif(cpu_feat_vanilla)
3649

50+
option(single_threaded "Compile without SMP support" ON)
51+
3752
# create random hex string as stack protector canary
38-
string(RANDOM LENGTH 8 ALPHABET 0123456789ABCDEF STACK_PROTECTOR_VALUE)
53+
string(RANDOM LENGTH 16 ALPHABET 0123456789ABCDEF STACK_PROTECTOR_VALUE)
3954

4055
set(CAPABS "${CAPABS} -fstack-protector-strong -D_STACK_GUARD_VALUE_=0x${STACK_PROTECTOR_VALUE}")
4156

@@ -45,7 +60,7 @@ set(CAPABS "${CAPABS} -fstack-protector-strong -D_STACK_GUARD_VALUE_=0x${STACK_P
4560
# * _GNU_SOURCE enables POSIX-extensions in newlib, such as strnlen. ("everything newlib has", ref. cdefs.h)
4661
set(CAPABS "${CAPABS} -DNO_DEBUG=1 -DOS_TERMINATE_ON_CONTRACT_VIOLATION -D_GNU_SOURCE")
4762

48-
set(WARNS "-Wall -Wextra") #-pedantic
63+
set(WARNS "-Wall -Wextra")
4964

5065
# configure options
5166
option(debug "Build with debugging symbols (OBS: Dramatically increases binary size)" OFF)
@@ -63,6 +78,9 @@ endfunction()
6378
init_submodule(mod/GSL)
6479
init_submodule(mod/http-parser)
6580
init_submodule(mod/uzlib)
81+
init_submodule(mod/rapidjson)
82+
83+
install(DIRECTORY mod/rapidjson/include/rapidjson DESTINATION includeos/include)
6684

6785
# set optimization level
6886
set(OPTIMIZE "-O2")
@@ -92,14 +110,29 @@ endif(silent)
92110
# Append optimization level
93111
set(CAPABS "${CAPABS} ${OPTIMIZE}")
94112

113+
# object format needs to be set BEFORE enabling ASM
114+
# see: https://cmake.org/Bug/bug_relationship_graph.php?bug_id=13166
115+
if ("${ARCH}" STREQUAL "i686")
116+
set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf")
117+
set(OBJCOPY_TARGET "elf32-i386")
118+
set(CAPABS "${CAPABS} -m32")
119+
else()
120+
set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf64")
121+
set(OBJCOPY_TARGET "elf64-x86-64")
122+
set(CAPABS "${CAPABS} -m64")
123+
endif()
124+
125+
enable_language(ASM_NASM)
126+
127+
# initialize C and C++ compiler flags
95128
if (CMAKE_COMPILER_IS_GNUCC)
96129
# gcc/g++ settings
97-
set(CMAKE_CXX_FLAGS "-m32 -MMD ${CAPABS} ${WARNS} -Wno-frame-address -nostdlib -c -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
98-
set(CMAKE_C_FLAGS "-m32 -MMD ${CAPABS} ${WARNS} -nostdlib -c -DOS_VERSION=\"\"${OS_VERSION}\"\"")
130+
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}\\\"")
131+
set(CMAKE_C_FLAGS " -MMD ${CAPABS} ${WARNS} -nostdlib -fno-omit-frame-pointer -c -DOS_VERSION=\"\"${OS_VERSION}\"\"")
99132
else()
100133
# these kinda work with llvm
101-
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}\\\"")
102-
set(CMAKE_C_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -DOS_VERSION=\"\"${OS_VERSION}\"\"")
134+
set(CMAKE_CXX_FLAGS "-MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -fno-omit-frame-pointer -c -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
135+
set(CMAKE_C_FLAGS "-MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -fno-omit-frame-pointer -c -DOS_VERSION=\"\"${OS_VERSION}\"\"")
103136
endif()
104137

105138
# either download or cross-compile needed libraries
@@ -125,6 +158,7 @@ if(vmbuild)
125158
# Install vmbuilder as an external project
126159
ExternalProject_Add(vmbuild
127160
PREFIX vmbuild # Build where
161+
BUILD_ALWAYS 1
128162
SOURCE_DIR ${INCLUDEOS_ROOT}/vmbuild # Where is project located
129163
BINARY_DIR ${INCLUDEOS_ROOT}/vmbuild/build
130164
INSTALL_DIR ${BIN} # Where to install
@@ -135,6 +169,7 @@ endif(vmbuild)
135169
option(diskbuilder "Build and install memdisk helper tool" ON)
136170
if(diskbuilder)
137171
ExternalProject_Add(diskbuilder
172+
BUILD_ALWAYS 1
138173
SOURCE_DIR ${INCLUDEOS_ROOT}/diskimagebuild
139174
BINARY_DIR ${INCLUDEOS_ROOT}/diskimagebuild/build
140175
INSTALL_DIR ${BIN}
@@ -164,32 +199,36 @@ endif(tests)
164199

165200
option(libmana "Build and install mana web application framework library" ON)
166201
if(libmana)
167-
set(rapidjson ON) # Dependent on rapidjson
168202
add_subdirectory(lib/mana)
169203
endif(libmana)
170204

171-
option(rapidjson "Download and install rapidjson submodule" ON)
172-
if(rapidjson)
173-
init_submodule(mod/rapidjson)
174-
install(DIRECTORY mod/rapidjson/include/rapidjson DESTINATION includeos/include)
175-
endif(rapidjson)
205+
option(libuplink "Build and install uplink" ON)
206+
if(libuplink)
207+
set(libliveupdate ON) # dependent
208+
add_subdirectory(lib/uplink)
209+
endif(libuplink)
176210

211+
option(libliveupdate "Build and install LiveUpdate" ON)
212+
if(libliveupdate)
213+
add_subdirectory(lib/LiveUpdate)
214+
endif(libliveupdate)
177215

178216
#
179217
# Installation
180218
#
181219

182220
# Install cmake files
183-
install(FILES etc/service.cmake DESTINATION includeos)
184-
install(FILES etc/library.cmake DESTINATION includeos)
221+
install(FILES cmake/pre.service.cmake DESTINATION includeos)
222+
install(FILES cmake/post.service.cmake DESTINATION includeos)
223+
install(FILES cmake/library.cmake DESTINATION includeos)
185224
install(FILES cmake/${DEFAULT_SETTINGS_CMAKE} DESTINATION includeos RENAME settings.cmake) # cpu_feat_vanilla opt
186225

187226
# Install vmrunner
188227
install(DIRECTORY vmrunner DESTINATION includeos)
189228
install(FILES vmrunner/${DEFAULT_VM} DESTINATION includeos/vmrunner/ RENAME vm.default.json) # cpu_feat_vanilla opt
190229

191230
# Install toolchain
192-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/i686-elf-toolchain.cmake DESTINATION includeos)
231+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${ARCH}-elf-toolchain.cmake DESTINATION includeos)
193232

194233
# Install seed
195234
install(DIRECTORY seed/ DESTINATION includeos/seed)
@@ -204,6 +243,7 @@ install(PROGRAMS
204243
${CMAKE_CURRENT_SOURCE_DIR}/etc/scripts/grubify.sh
205244
${CMAKE_CURRENT_SOURCE_DIR}/etc/scripts/qemu-ifup
206245
${CMAKE_CURRENT_SOURCE_DIR}/etc/scripts/qemu_cmd.sh
246+
${CMAKE_CURRENT_SOURCE_DIR}/etc/scripts/ukvm-ifup.sh
207247
${CMAKE_CURRENT_SOURCE_DIR}/etc/scripts/run.sh
208248
DESTINATION includeos/scripts)
209249

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
![IncludeOS Logo](./doc/logo.png)
22
================================================
33

4-
**Update**: Check out [Acorn](examples/acorn/), the innovative web server appliance we [demoed at CppCon](https://www.youtube.com/watch?v=t4etEwG2_LY). Built using [Mana](lib/mana/), the new C++ Web Application Framework for IncludeOS.
5-
6-
A *live demo* of Acorn can be found at [acorn2.unofficial.includeos.io](http://acorn2.unofficial.includeos.io) (sporadically unavailable)
7-
84
**IncludeOS** is an includable, minimal [unikernel](https://en.wikipedia.org/wiki/Unikernel) operating system for C++ services running in the cloud. Starting a program with `#include <os>` will literally include a tiny operating system into your service during link-time.
95

106
The build system will:
@@ -24,8 +20,8 @@ IncludeOS is free software, with "no warranties or restrictions of any kind".
2420

2521
| | Build from bundle | Integration tests |
2622
|--------|-------------------|-------------------|
27-
| Master | [![Build Status](https://jenkins.includeos.org/buildStatus/icon?job=shield_master_bundle)](https://jenkins.includeos.org/job/shield_master_bundle/) | Coming soon |
28-
| Dev | [![Build Status](https://jenkins.includeos.org/buildStatus/icon?job=shield_dev_bundle)](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/) |
23+
| 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 |
24+
| 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/) |
2925

3026
### Key features
3127

@@ -48,22 +44,22 @@ A longer list of features and limitations is on the [wiki feature list](https://
4844

4945
By default the project is installed to /usr/local/includeos.
5046

51-
However, it is recommended to choose a custom location as well as select the compiler we want clang to find.
47+
However, it is recommended to choose a custom location as well as select the compiler we want clang to find. In this document we assume you install IncludeOS in your home directory, in the folder ~/includeos.
5248

53-
To do this we can edit ~/.bashrc (in the home folder), adding these lines at the end of the file:
49+
To do this we can edit ~/.bash_profile (mac os) or ~/.bashrc (linux), adding these lines at the end of the file:
5450

5551
```
56-
export CC=/usr/bin/clang-3.8
57-
export CXX=/usr/bin/clang++-3.8
58-
export INCLUDEOS_PREFIX=<HOME FOLDER>/includeos
52+
export INCLUDEOS_PREFIX=~/includeos/
5953
export PATH=$PATH:$INCLUDEOS_PREFIX/bin
6054
```
6155

6256
This will also crucially make the boot program visible globally, so that you can simply run ```boot <myservice>``` inside any service folder.
6357

6458
### Install libraries
6559

66-
**NOTE:** The script will install packages and create a network bridge.
60+
If you want to install IncludeOS on Mac OS you'll need a working installation of [brew] so the install script can install its dependencies.
61+
62+
**NOTE:** The script will install packages.
6763

6864
```
6965
$ git clone https://github.com/hioa-cs/IncludeOS
@@ -85,19 +81,20 @@ Configuration of your IncludeOS installation can be done inside `build/` with `c
8581

8682
### Testing the installation
8783

88-
A successful setup enables you to build and run a virtual machine. Running:
84+
A successful setup enables you to build and run a virtual machine. There are a few demonstration services in the source folder. If you look in the `examples/` folder you see these. If you enter `demo_service` and type `boot --create-bridge .` this script will build the service and boot it using [qemu].
8985

9086
```
91-
$ ./test.sh
87+
$ cd examples/demo_service
88+
$ boot --create-bridge .
9289
```
9390

94-
will build and run [this example service](./examples/demo_service/service.cpp).
91+
will build and run [this example service](./examples/demo_service/service.cpp). You can visit the service on [http://10.0.0.42/](http://10.0.0.42/).
9592

9693
More information is [available on the wiki](https://github.com/hioa-cs/IncludeOS/wiki/Testing-the-example-service).
9794

9895
### Writing your first service
9996

100-
1. Copy the [./seed/service](./seed/service) directory to a convenient location like `~/your_service`. Then, just start implementing the `Service::start` function in the `Service` class, located in [your_service/service.cpp](./seed/service/service.cpp) (Very simple example provided). This function will be called once the OS is up and running.
97+
1. Copy the [./seed/service](./seed/service) directory to a convenient location like `~/your_service`. Then, just start implementing the `Service::start` function in the `Service` class, located in [your_service/service.cpp](./seed/service/service.cpp) (very simple example provided). This function will be called once the OS is up and running.
10198
2. Update the [CMakeLists.txt](./seed/service/CMakeLists.txt) to specify the name of your project, enable any needed drivers or plugins, etc.
10299

103100
**Example:**
@@ -130,3 +127,7 @@ We want to adhere as much as possible to the [ISO C++ Core Guidelines](https://g
130127
We're trying to grow a Wiki, and some questions might already be answered here in the [FAQ](https://github.com/hioa-cs/IncludeOS/wiki/FAQ).
131128

132129
See the [Wiki front page](https://github.com/hioa-cs/IncludeOS/wiki) for a complete introduction, system overview, and more detailed guides.
130+
131+
132+
[brew]: https://brew.sh/
133+
[qemu]: https://www.qemu.org/

api/arch.hpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
33+
extern void __arch_install_irq(uint8_t, void(*)());
34+
extern void __arch_subscribe_irq(uint8_t);
35+
extern void __arch_unsubscribe_irq(uint8_t);
36+
extern void __arch_preempt_forever(void(*)());
37+
38+
inline void __arch_hw_barrier() noexcept;
39+
inline void __sw_barrier() noexcept;
40+
inline uint64_t __arch_cpu_cycles() noexcept;
41+
42+
43+
inline void __sw_barrier() noexcept
44+
{
45+
asm volatile("" ::: "memory");
46+
}
47+
48+
// Include arch specific inline implementations
49+
#if defined(ARCH_x86_64)
50+
#include "arch/x86_64.hpp"
51+
#elif defined(ARCH_i686)
52+
#include "arch/i686.hpp"
53+
#else
54+
#error "Unsupported arch specified"
55+
#endif
56+
57+
#endif
Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// -*-C++-*-
22
// This file is a part of the IncludeOS unikernel - www.includeos.org
33
//
4-
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
4+
// Copyright 2017 Oslo and Akershus University College of Applied Sciences
55
// and Alfred Bratterud
66
//
77
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,30 +16,16 @@
1616
// See the License for the specific language governing permissions and
1717
// limitations under the License.
1818

19-
#pragma once
20-
#ifndef INCLUDEOS_ARCH_HEADER
21-
#define INCLUDEOS_ARCH_HEADER
19+
#ifndef i686_ARCH_HPP
20+
#define i686_ARCH_HPP
2221

23-
#include <cstddef>
24-
#include <cstdint>
22+
#include <arch/x86.hpp>
2523

26-
extern void __arch_init();
27-
extern void __arch_poweroff();
28-
extern void __arch_reboot();
29-
extern void __arch_enable_legacy_irq(uint8_t);
30-
extern void __arch_disable_legacy_irq(uint8_t);
31-
32-
#ifdef ARCH_X86
3324
inline uint64_t __arch_cpu_cycles() noexcept {
3425
uint64_t ret;
3526
asm("rdtsc" : "=A" (ret));
3627
return ret;
3728
}
38-
#else
39-
inline uint64_t __arch_cpu_cycles() noexcept {
40-
return 0;
41-
}
42-
#endif
4329

44-
#endif
4530

31+
#endif

0 commit comments

Comments
 (0)