Skip to content

Commit 9c8f9a6

Browse files
committed
merged upstream dev
2 parents b8bf028 + 8910c7a commit 9c8f9a6

60 files changed

Lines changed: 648 additions & 368 deletions

Some content is hidden

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

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ before_script:
1717
- mkdir darwin && cd darwin
1818

1919
script:
20-
- cmake .. -DTRAVIS=ON
20+
- cmake .. -DTRAVIS=ON -DEXTRA_TESTS=ON
2121
- make VERBOSE=1 && ./unittests --pass

CMakeLists.txt

Lines changed: 35 additions & 8 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
@@ -81,9 +92,15 @@ 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
89106
#option(from_bundle "Download and use pre-compiled libraries for cross-comilation" ON)
@@ -161,10 +178,20 @@ endif(rapidjson)
161178
#
162179
# Installation
163180
#
164-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/service.cmake DESTINATION includeos)
165-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/library.cmake DESTINATION includeos)
166-
install(DIRECTORY vmrunner DESTINATION includeos/)
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
167192
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/i686-elf-toolchain.cmake DESTINATION includeos)
193+
194+
# Install seed
168195
install(DIRECTORY seed/ DESTINATION includeos/seed)
169196

170197
# Install boot util

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ IncludeOS is free software, with "no warranties or restrictions of any kind".
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/fs/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ namespace fs {
188188
using on_init_func = delegate<void(error_t, File_system&)>;
189189
using on_ls_func = delegate<void(error_t, dirvec_t)>;
190190
using on_read_func = delegate<void(error_t, buffer_t, uint64_t)>;
191-
using on_stat_func = delegate<void(error_t, const Dirent&)>;
191+
using on_stat_func = delegate<void(error_t, Dirent)>;
192192

193193

194194
struct List

api/http

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
// limitations under the License.
1818

1919
#pragma once
20-
#ifndef ___HTTP_API___
21-
#define ___HTTP_API___
20+
#ifndef INCLUDEOS_HTTP_API_HPP
21+
#define INCLUDEOS_HTTP_API_HPP
2222

23-
#include "net/http/response.hpp"
24-
#include "net/http/request.hpp"
23+
#include "net/http/client.hpp"
24+
#include "net/http/server.hpp"
2525

26-
#endif //< ___HTTP_API___
26+
#endif //< INCLUDEOS_HTTP_API_HPP

api/hw/block_device.hpp

Lines changed: 126 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is a part of the IncludeOS unikernel - www.includeos.org
22
//
3-
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
3+
// Copyright 2015-2017 Oslo and Akershus University College of Applied Sciences
44
// and Alfred Bratterud
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,71 +16,148 @@
1616
// limitations under the License.
1717

1818
#pragma once
19-
#ifndef HW_DRIVE_HPP
20-
#define HW_DRIVE_HPP
19+
#ifndef HW_BLOCK_DEVICE_HPP
20+
#define HW_BLOCK_DEVICE_HPP
2121

22-
#include <memory>
2322
#include <cstdint>
2423
#include <delegate>
24+
#include <memory>
2525

26-
namespace hw
27-
{
28-
29-
/**
30-
* Abstract interface for block devices of various driver types
31-
**/
32-
class Block_device {
33-
public:
34-
using block_t = uint64_t; //< Disk device block size
35-
using buffer_t = std::shared_ptr<uint8_t>;
36-
37-
// Delegate for result of reading a disk sector
38-
//using on_read_func = delegate<void(buffer_t)>;
39-
using on_read_func = delegate<void(buffer_t)>;
26+
namespace hw {
4027

41-
using Device_id = int;
28+
/**
29+
* This class is an abstract interface for block devices
30+
*/
31+
class Block_device {
32+
public:
33+
using block_t = uint64_t; //< Representation for a device's block size
34+
using buffer_t = std::shared_ptr<uint8_t>; //< Representation for a block device's buffer
35+
using Device_id = int32_t; //< Representation for a block device's identifier
36+
using on_read_func = delegate<void(buffer_t)>; //< Delegate for result of reading from a block device
4237

43-
static const char* device_type()
44-
{ return "Block device"; }
38+
/**
39+
* Method to get the type of device
40+
*
41+
* @return The type of device as a C-String
42+
*/
43+
static const char* device_type() noexcept
44+
{ return "Block device"; }
4545

46-
virtual std::string device_name() const = 0;
46+
/**
47+
* Method to get the name of the device
48+
*
49+
* @return The name of the device as a std::string
50+
*/
51+
virtual std::string device_name() const = 0;
4752

48-
Device_id id() const { return id_; }
53+
/**
54+
* Method to get the device's identifier
55+
*
56+
* @return The device's identifier
57+
*/
58+
Device_id id() const noexcept
59+
{ return id_; }
4960

50-
/** Human-readable name of this disk controller */
51-
virtual const char* driver_name() const noexcept = 0;
61+
/**
62+
* Get the human-readable name of this device's controller
63+
*
64+
* @return The human-readable name of this device's controller
65+
*/
66+
virtual const char* driver_name() const noexcept = 0;
5267

53-
/** The size of the disk in whole sectors */
54-
virtual block_t size() const noexcept = 0;
68+
/**
69+
* Get the size of the device as total number of blocks
70+
*
71+
* @return The size of the device as total number of blocks
72+
*/
73+
virtual block_t size() const noexcept = 0;
5574

56-
/** Returns the optimal block size for this device */
57-
virtual block_t block_size() const noexcept = 0;
75+
/**
76+
* Get the optimal block size for this device
77+
*
78+
* @return The optimal block size for this device
79+
*/
80+
virtual block_t block_size() const noexcept = 0;
5881

59-
/**
60-
* Read block(s) from blk and call func with result
61-
* A null-pointer is passed to result if something bad happened
62-
* Validate using !buffer_t:
63-
* if (!buffer)
64-
* error("Device failed to read sector");
65-
**/
66-
virtual void read(block_t blk, on_read_func func) = 0;
67-
virtual void read(block_t blk, size_t count, on_read_func) = 0;
82+
/**
83+
* Read a block of data asynchronously from the device
84+
*
85+
* @param blk
86+
* The block of data to read from the device
87+
*
88+
* @param reader
89+
* An operation to perform asynchronously
90+
*
91+
* @note A nullptr is passed to the reader if an error occurred
92+
* @note Validate the reader's input
93+
*
94+
* @example
95+
* if (buffer == nullptr) {
96+
* error("Device failed to read sector");
97+
* }
98+
*/
99+
virtual void read(block_t blk, on_read_func reader) = 0;
68100

69-
/** read synchronously the block @blk */
70-
virtual buffer_t read_sync(block_t blk) = 0;
71-
virtual buffer_t read_sync(block_t blk, size_t count) = 0;
101+
/**
102+
* Read blocks of data asynchronously from the device
103+
*
104+
* @param blk
105+
* The starting block of data to read from the device
106+
*
107+
* @param count
108+
* The number of blocks to read from the device
109+
*
110+
* @param reader
111+
* An operation to perform asynchronously
112+
*
113+
* @note A nullptr is passed to the reader if an error occurred
114+
* @note Validate the reader's input
115+
*
116+
* @example
117+
* if (buffer == nullptr) {
118+
* error("Device failed to read sector");
119+
* }
120+
*/
121+
virtual void read(block_t blk, size_t count, on_read_func reader) = 0;
72122

73-
virtual void deactivate() = 0;
123+
/**
124+
* Read a block of data synchronously from the device
125+
*
126+
* @param blk
127+
* The block of data to read from the device
128+
*
129+
* @return A buffer containing the data or nullptr if an error occurred
130+
*/
131+
virtual buffer_t read_sync(block_t blk) = 0;
74132

75-
virtual ~Block_device() noexcept = default;
133+
/**
134+
* Read blocks of data synchronously from the device
135+
*
136+
* @param blk
137+
* The starting block of data to read from the device
138+
*
139+
* @param count
140+
* The number of blocks to read from the device
141+
*
142+
* @return A buffer containing the data or nullptr if an error occurred
143+
*/
144+
virtual buffer_t read_sync(block_t blk, size_t count) = 0;
76145

77-
protected:
78-
Block_device();
146+
/**
147+
* Method to deactivate the block device
148+
*/
149+
virtual void deactivate() = 0;
79150

80-
private:
81-
int id_;
82-
}; //< class Drive
151+
/**
152+
* Default destructor
153+
*/
154+
virtual ~Block_device() noexcept = default;
155+
protected:
156+
Block_device();
157+
private:
158+
Device_id id_;
159+
}; //< class Block_device
83160

84161
} //< namespace hw
85162

86-
#endif //< HW_DRIVE_HPP
163+
#endif //< HW_BLOCK_DEVICE_HPP

api/net/ethernet/header.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
// See the License for the specific language governing permissions and
1616
// limitations under the License.
17-
#pragma once
1817

18+
#pragma once
1919
#ifndef NET_ETHERNET_HEADER_HPP
2020
#define NET_ETHERNET_HEADER_HPP
2121

@@ -40,7 +40,7 @@ class Header {
4040
const MAC::Addr& src() const noexcept
4141
{ return src_; }
4242

43-
const Ethertype& type() const noexcept
43+
Ethertype type() const noexcept
4444
{ return type_; }
4545

4646
void set_dest(const MAC::Addr& dest)

api/net/inet.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace net {
179179
///
180180

181181
/** Get Maximum Transmission Unit **/
182-
virtual constexpr uint16_t MTU() const = 0;
182+
virtual uint16_t MTU() const = 0;
183183

184184
/** Provision empty anonymous packet **/
185185
virtual Packet_ptr create_packet() = 0;

api/net/ip4/icmp4_common.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ namespace net {
9595
return "TIMESTAMP REPLY (14)";
9696
case Type::NO_REPLY:
9797
return "NO REPLY";
98+
default:
99+
return "UNKNOWN";
98100
};
99101
}();
100102
}

api/net/ip4/ip4.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace net {
5757
/*
5858
Maximum Datagram Data Size
5959
*/
60-
constexpr uint16_t MDDS() const
60+
uint16_t MDDS() const
6161
{ return stack_.MTU() - sizeof(ip4::Header); }
6262

6363
/** Upstream: Input from link layer */

0 commit comments

Comments
 (0)