Skip to content

Commit 18b3656

Browse files
committed
merged
2 parents 15bb0ab + e71dd66 commit 18b3656

508 files changed

Lines changed: 23230 additions & 19731 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.

.gitignore

Lines changed: 1 addition & 0 deletions
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

.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: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(SCRIPTS ${CMAKE_INSTALL_PREFIX}/includeos/scripts)
1414
if(CMAKE_COMPILER_IS_GNUCC)
1515
# currently gcc is not supported due to problems cross-compiling a unikernel
1616
# (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.")
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.")
1818
endif(CMAKE_COMPILER_IS_GNUCC)
1919

2020
# create OS version string from git describe (used in CXX flags)
@@ -23,10 +23,21 @@ execute_process(COMMAND git describe --dirty
2323
OUTPUT_VARIABLE OS_VERSION)
2424
string(STRIP ${OS_VERSION} OS_VERSION)
2525

26+
option(cpu_feat_vanilla "Restrict use of CPU features to vanilla" ON)
27+
if(cpu_feat_vanilla)
28+
include("cmake/vanilla.cmake")
29+
set(DEFAULT_SETTINGS_CMAKE "vanilla.cmake") # for service cmake
30+
set(DEFAULT_VM "vm.vanilla.json") # vmrunner
31+
else()
32+
include("cmake/cpu_feat.cmake")
33+
set(DEFAULT_SETTINGS_CMAKE "cpu_feat.cmake") # for service cmake
34+
set(DEFAULT_VM "vm.cpu_feat.json") # vmrunner
35+
endif(cpu_feat_vanilla)
36+
2637
# create random hex string as stack protector canary
2738
string(RANDOM LENGTH 8 ALPHABET 0123456789ABCDEF STACK_PROTECTOR_VALUE)
2839

29-
set(CAPABS "-msse3 -fstack-protector-strong -D_STACK_GUARD_VALUE_=0x${STACK_PROTECTOR_VALUE} ")
40+
set(CAPABS "${CAPABS} -fstack-protector-strong -D_STACK_GUARD_VALUE_=0x${STACK_PROTECTOR_VALUE}")
3041

3142
# Various global defines
3243
# * NO_DEBUG disables output from the debug macro
@@ -57,7 +68,7 @@ init_submodule(mod/uzlib)
5768
set(OPTIMIZE "-O2")
5869

5970
if(debug OR debug-info OR debug-all)
60-
set(CAPABS "${CAPABS} -O0")
71+
set(OTPIMIZE "-O0")
6172
endif(debug OR debug-info OR debug-all)
6273

6374
if(minimal)
@@ -81,24 +92,41 @@ endif(silent)
8192
# Append optimization level
8293
set(CAPABS "${CAPABS} ${OPTIMIZE}")
8394

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}\"\"")
95+
if (CMAKE_COMPILER_IS_GNUCC)
96+
# 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}\"\"")
99+
else()
100+
# 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}\"\"")
103+
endif()
87104

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

92-
add_subdirectory(mod)
110+
# Botan Crypto & TLS
111+
# Note: Include order matters!
112+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/botan.cmake)
93113

114+
#
115+
# Subprojects
116+
#
117+
add_subdirectory(mod)
94118
add_subdirectory(src)
95119

120+
#
121+
# External projects
122+
#
96123
option(vmbuild "Build and install vmbuild and elf_syms" ON)
97124
if(vmbuild)
98125
# Install vmbuilder as an external project
99126
ExternalProject_Add(vmbuild
100127
PREFIX vmbuild # Build where
101128
SOURCE_DIR ${INCLUDEOS_ROOT}/vmbuild # Where is project located
129+
BINARY_DIR ${INCLUDEOS_ROOT}/vmbuild/build
102130
INSTALL_DIR ${BIN} # Where to install
103131
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> # Pass installation folder
104132
)
@@ -128,6 +156,7 @@ if(tests)
128156
ExternalProject_Add(unittests
129157
PREFIX unittests
130158
SOURCE_DIR ${INCLUDEOS_ROOT}/test
159+
BINARY_DIR unittests
131160
CMAKE_ARGS -DINCLUDEOS_ROOT=${INCLUDEOS_ROOT} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
132161
)
133162
#add_subdirectory(test)
@@ -145,10 +174,24 @@ if(rapidjson)
145174
install(DIRECTORY mod/rapidjson/include/rapidjson DESTINATION includeos/include)
146175
endif(rapidjson)
147176

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/)
177+
178+
#
179+
# Installation
180+
#
181+
182+
# Install cmake files
183+
install(FILES etc/service.cmake DESTINATION includeos)
184+
install(FILES etc/library.cmake DESTINATION includeos)
185+
install(FILES cmake/${DEFAULT_SETTINGS_CMAKE} DESTINATION includeos RENAME settings.cmake) # cpu_feat_vanilla opt
186+
187+
# Install vmrunner
188+
install(DIRECTORY vmrunner DESTINATION includeos)
189+
install(FILES vmrunner/${DEFAULT_VM} DESTINATION includeos/vmrunner/ RENAME vm.default.json) # cpu_feat_vanilla opt
190+
191+
# Install toolchain
151192
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/i686-elf-toolchain.cmake DESTINATION includeos)
193+
194+
# Install seed
152195
install(DIRECTORY seed/ DESTINATION includeos/seed)
153196

154197
# 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://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/) |
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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// -*-C++-*-
2+
// This file is a part of the IncludeOS unikernel - www.includeos.org
3+
//
4+
// Copyright 2015 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+
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
33+
inline uint64_t __arch_cpu_cycles() noexcept {
34+
uint64_t ret;
35+
asm("rdtsc" : "=A" (ret));
36+
return ret;
37+
}
38+
#else
39+
inline uint64_t __arch_cpu_cycles() noexcept {
40+
return 0;
41+
}
42+
#endif
43+
44+
#endif
45+

api/common

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -*-C++-*-
1+
// -*- C++ -*-
22
// This file is a part of the IncludeOS unikernel - www.includeos.org
33
//
44
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
@@ -53,27 +53,11 @@
5353
#undef Expects
5454
#undef Ensures
5555

56-
#define Expects(cond) \
57-
do { \
58-
if (UNLIKELY(not (cond))) { \
59-
std::cerr << "OS: Precondition (" OS_STRINGIFY(cond) \
60-
<< ") failed...\n" << "\t...in function: " \
61-
<< __func__ << " @" << __FILE__ << ":" \
62-
<< __LINE__ << '\n'; \
63-
std::terminate(); \
64-
} \
65-
} while(0)
56+
#define Expects(cond) \
57+
assert(LIKELY(cond) && "OS: Precondition failed")
6658

67-
#define Ensures(cond) \
68-
do { \
69-
if (UNLIKELY(not (cond))) { \
70-
std::cerr << "OS: Postcondition (" OS_STRINGIFY(cond) \
71-
<< ") failed...\n" << "\t...in function: " \
72-
<< __func__ << " @" << __FILE__ << ":" \
73-
<< __LINE__ << '\n'; \
74-
std::terminate(); \
75-
} \
76-
} while(0)
59+
#define Ensures(cond) \
60+
assert(LIKELY(cond) && "OS: Postcondition failed")
7761

7862
#endif //< defined(OS_TERMINATE_ON_CONTRACT_VIOLATION)
7963

api/fs/common.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828

2929
namespace fs {
3030

31-
// Generic structure for directory entries
3231
struct Dirent;
33-
32+
struct File_system;
3433

3534
/**
3635
* @brief Type used as a building block to represent buffers
@@ -185,24 +184,23 @@ namespace fs {
185184
/** @var no_error: Always returns boolean false when used in expressions */
186185
extern error_t no_error;
187186

188-
/** Async function types **/
189-
using on_init_func = delegate<void(error_t)>;
187+
/** Async function types **/
188+
using on_init_func = delegate<void(error_t, File_system&)>;
190189
using on_ls_func = delegate<void(error_t, dirvec_t)>;
191190
using on_read_func = delegate<void(error_t, buffer_t, uint64_t)>;
192-
using on_stat_func = delegate<void(error_t, const Dirent&)>;
191+
using on_stat_func = delegate<void(error_t, Dirent)>;
193192

194193

195-
struct List {
194+
struct List
195+
{
196196
error_t error;
197197
dirvec_t entries;
198198
auto begin() { return entries->begin(); }
199199
auto end() { return entries->end(); }
200200
auto cbegin() { return entries->cbegin(); }
201201
auto cend() { return entries->cend(); }
202-
203202
};
204203

204+
} //< fs
205205

206-
} //< namespace fs
207-
208-
#endif //< FS_ERROR_HPP
206+
#endif //< FS_COMMON_HPP

api/fs/disk.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace fs {
4242

4343
struct Partition;
4444
using on_parts_func = delegate<void(fs::error_t, std::vector<Partition>&)>;
45-
using on_init_func = delegate<void(fs::error_t)>;
45+
using on_init_func = delegate<void(fs::error_t, File_system&)>;
4646
using lba_t = uint32_t;
4747

4848
enum partition_t {

api/fs/filesystem.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ namespace fs {
2727
struct Dirent;
2828

2929
struct File_system {
30-
31-
/** Initialize this filesystem with LBA at @base_sector */
32-
virtual void init(uint64_t lba, uint64_t size, on_init_func on_init) = 0;
33-
3430
/** Get unique (per device type) device id for underlying device.*/
3531
virtual Device_id device_id() = 0;
3632

@@ -76,6 +72,9 @@ namespace fs {
7672
/** Returns the name of this filesystem */
7773
virtual std::string name() const = 0;
7874

75+
/** Initialize this filesystem with LBA at @base_sector */
76+
virtual void init(uint64_t lba, uint64_t size, on_init_func on_init) = 0;
77+
7978
/** Default destructor */
8079
virtual ~File_system() noexcept = default;
8180
}; //< class File_system

api/fs/vfs.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
#ifndef FS_VFS_HPP
1919
#define FS_VFS_HPP
2020

21-
#include <memory>
2221
#include <fs/disk.hpp>
2322
#include <fs/filesystem.hpp>
2423
#include <fs/path.hpp>
2524
#include <hw/devices.hpp>
26-
#include <typeinfo>
27-
#include <stdexcept>
2825
#include <algorithm>
26+
#include <map>
27+
#include <memory>
28+
#include <stdexcept>
29+
#include <typeinfo>
2930

3031
// Demangle
3132
extern "C" char* __cxa_demangle(const char* mangled_name,

0 commit comments

Comments
 (0)