Skip to content

Commit 66f21c8

Browse files
committed
Merge branch 'dev' of github.com:fwsGonzo/IncludeOS into dev
2 parents fea2aae + 7eebb15 commit 66f21c8

35 files changed

Lines changed: 2780 additions & 38 deletions

CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ endif(silent)
110110
# Append optimization level
111111
set(CAPABS "${CAPABS} ${OPTIMIZE}")
112112

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
113128
if (CMAKE_COMPILER_IS_GNUCC)
114129
# gcc/g++ settings
115130
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}\\\"")
@@ -187,6 +202,17 @@ if(libmana)
187202
add_subdirectory(lib/mana)
188203
endif(libmana)
189204

205+
option(libuplink "Build and install uplink" ON)
206+
if(libuplink)
207+
set(libliveupdate ON) # dependent
208+
add_subdirectory(lib/uplink)
209+
endif(libuplink)
210+
211+
option(libliveupdate "Build and install LiveUpdate" ON)
212+
if(libliveupdate)
213+
add_subdirectory(lib/LiveUpdate)
214+
endif(libliveupdate)
215+
190216
#
191217
# Installation
192218
#

api/net/dhcp/options.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct domain_name_servers : public type<DOMAIN_NAME_SERVERS>, public addr_optio
215215
*/
216216
struct domain_name : public type<DOMAIN_NAME>, public base
217217
{
218-
constexpr domain_name(const std::string& dname) noexcept
218+
domain_name(const std::string& dname) noexcept
219219
: base{type::CODE, static_cast<uint8_t>(dname.size())}
220220
{
221221
std::memcpy(&val[0], dname.data(), dname.size());
@@ -296,7 +296,7 @@ struct server_identifier : public type<DHCP_SERVER_IDENTIFIER>, public addr_opti
296296
*/
297297
struct param_req_list : public type<DHCP_PARAMETER_REQUEST_LIST>, public base
298298
{
299-
constexpr param_req_list(const std::vector<Code>& codes) noexcept
299+
param_req_list(const std::vector<Code>& codes) noexcept
300300
: base{DHCP_PARAMETER_REQUEST_LIST, static_cast<uint8_t>(codes.size())}
301301
{
302302
Expects(codes.size() < 50); // or something
@@ -309,7 +309,7 @@ struct param_req_list : public type<DHCP_PARAMETER_REQUEST_LIST>, public base
309309
*/
310310
struct message : public type<DHCP_MESSAGE>, public base
311311
{
312-
constexpr message(const std::string& msg) noexcept
312+
message(const std::string& msg) noexcept
313313
: base{CODE, static_cast<uint8_t>(msg.size())}
314314
{
315315
Expects(not msg.empty() and msg.size() <= 128); // or something

api/net/inet.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ namespace net {
138138
return pckt;
139139
}
140140

141-
Filter_chain(const char* chain_name, std::initializer_list<Packetfilter> filters) :
142-
chain{filters},
143-
name{chain_name} {}
141+
Filter_chain(const char* chain_name, std::initializer_list<Packetfilter> filters)
142+
: chain(filters), name{chain_name}
143+
{}
144144
};
145145

146146
/**

api/net/tcp/connection.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inline Connection& Connection::on_connect(ConnectCallback cb) {
1010

1111
inline Connection& Connection::on_read(size_t recv_bufsz, ReadCallback cb)
1212
{
13-
read_request = std::make_unique<ReadRequest>(recv_bufsz, this->cb.RCV.NXT, cb);
13+
read_request = std::make_unique<ReadRequest>(recv_bufsz, seq_t(this->cb.RCV.NXT), cb);
1414
return *this;
1515
}
1616

api/net/tcp/tcp.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "packet.hpp"
2727

2828
#include <map> // connections, listeners
29-
#include <queue> // writeq
29+
#include <deque> // writeq
3030
#include <net/inet.hpp>
3131
#include <net/socket.hpp>
3232
#include <net/port_util.hpp>
@@ -710,7 +710,7 @@ namespace net {
710710
*
711711
* @param[in] <unnamed> A ptr to a Connection
712712
*/
713-
void queue_offer(tcp::Connection_ptr);
713+
void queue_offer(tcp::Connection&);
714714

715715
/**
716716
* @brief Force the TCP to process the it's queue with the current amount of available packets.

api/util/statman.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class Stat {
100100
Stat& operator=(const Stat& other) = delete;
101101
Stat& operator=(Stat&& other) = delete;
102102

103-
} __attribute__((packed)); //< class Stat
103+
}; //< class Stat
104104

105105

106106
class Statman {

cmake/post.service.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ set(CMAKE_CXX_COMPILER_TARGET ${TRIPLE})
1515
set(CMAKE_C_COMPILER_TARGET ${TRIPLE})
1616
message(STATUS "Target triple ${TRIPLE}")
1717

18+
# defines $CAPABS depending on installation
19+
include(${CMAKE_CURRENT_LIST_DIR}/settings.cmake)
20+
1821
# Arch-specific defines & options
1922
if ("${ARCH}" STREQUAL "x86_64")
2023
set(ARCH_INTERNAL "ARCH_X64")
2124
set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf64")
2225
set(OBJCOPY_TARGET "elf64-x86-64")
26+
set(CAPABS "${CAPABS} -m64")
2327
else()
2428
set(ARCH_INTERNAL "ARCH_X86")
2529
set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf")
2630
set(OBJCOPY_TARGET "elf32-i386")
31+
set(CAPABS "${CAPABS} -m32")
2732
endif()
2833
enable_language(ASM_NASM)
2934

30-
# defines $CAPABS depending on installation
31-
include(${CMAKE_CURRENT_LIST_DIR}/settings.cmake)
32-
3335
# Various global defines
3436
# * OS_TERMINATE_ON_CONTRACT_VIOLATION provides classic assert-like output from Expects / Ensures
3537
# * _GNU_SOURCE enables POSIX-extensions in newlib, such as strnlen. ("everything newlib has", ref. cdefs.h)
@@ -46,8 +48,8 @@ if (debug)
4648
endif()
4749

4850
if (CMAKE_COMPILER_IS_GNUCC)
49-
set(CMAKE_CXX_FLAGS "-m32 -MMD ${CAPABS} ${WARNS} -nostdlib -fno-omit-frame-pointer -c -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1")
50-
set(CMAKE_C_FLAGS "-m32 -MMD ${CAPABS} ${WARNS} -nostdlib -fno-omit-frame-pointer -c")
51+
set(CMAKE_CXX_FLAGS "-MMD ${CAPABS} ${WARNS} -nostdlib -fno-omit-frame-pointer -c -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1")
52+
set(CMAKE_C_FLAGS "-MMD ${CAPABS} ${WARNS} -nostdlib -fno-omit-frame-pointer -c")
5153
else()
5254
# these kinda work with llvm
5355
set(CMAKE_CXX_FLAGS "-MMD ${CAPABS} ${OPTIMIZE} ${WARNS} -nostdlib -nostdlibinc -fno-omit-frame-pointer -c -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1")

lib/LiveUpdate/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 2.8.9)
2+
3+
add_definitions(-DARCH_${ARCH})
4+
add_definitions(-DARCH="${ARCH}")
5+
6+
include_directories(${INCLUDEOS_ROOT}/api/posix)
7+
include_directories(${LIBCXX_INCLUDE_DIR})
8+
include_directories(${NEWLIB_INCLUDE_DIR})
9+
include_directories(${INCLUDEOS_ROOT}/src/include)
10+
include_directories(${INCLUDEOS_ROOT}/api)
11+
include_directories(${INCLUDEOS_ROOT}/mod/GSL/)
12+
13+
add_custom_command(
14+
OUTPUT hotswap64.bin
15+
COMMAND ${CMAKE_ASM_NASM_COMPILER} -f bin -o hotswap64.bin ${CMAKE_CURRENT_SOURCE_DIR}/hotswap64.asm
16+
DEPENDS hotswap64.asm
17+
)
18+
add_custom_target(hotswap64 DEPENDS hotswap64.bin)
19+
20+
# LiveUpdate static library
21+
add_library(liveupdate STATIC
22+
storage.cpp update.cpp resume.cpp rollback.cpp hotswap.cpp
23+
serialize_tcp.cpp hotswap64_blob.asm
24+
)
25+
add_dependencies(liveupdate hotswap64)
26+
install(TARGETS liveupdate DESTINATION includeos/${ARCH}/lib)
27+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/liveupdate.hpp DESTINATION includeos/include RENAME liveupdate)

lib/LiveUpdate/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# LiveUpdate

lib/LiveUpdate/hotswap.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Master thesis
3+
* by Alf-Andre Walla 2016-2017
4+
*
5+
**/
6+
asm(".org 0x8000");
7+
#define SOFT_RESET_MAGIC 0xFEE1DEAD
8+
9+
extern "C" __attribute__((noreturn))
10+
void hotswap(const char* base, int len, char* dest, void* start, void* reset_data)
11+
{
12+
// replace old kernel with new
13+
for (int i = 0; i < len; i++)
14+
dest[i] = base[i];
15+
// jump to _start
16+
asm volatile("jmp *%2" : : "a" (SOFT_RESET_MAGIC), "b" (reset_data), "c" (start));
17+
asm volatile(
18+
".global __hotswap_length;\n"
19+
"__hotswap_length:" );
20+
// we can never get here!
21+
__builtin_unreachable();
22+
}

0 commit comments

Comments
 (0)