Skip to content

Commit ea4f2e9

Browse files
authored
Merge pull request #1451 from hioa-cs/dev
Merge Dev
2 parents 6542c16 + 17ca758 commit ea4f2e9

75 files changed

Lines changed: 1547 additions & 657 deletions

Some content is hidden

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

api/arch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern void __arch_disable_legacy_irq(uint8_t);
3333
extern void __arch_install_irq(uint8_t, void(*)());
3434
extern void __arch_subscribe_irq(uint8_t);
3535
extern void __arch_unsubscribe_irq(uint8_t);
36+
extern void __arch_preempt_forever(void(*)());
3637

3738
inline void __arch_hw_barrier() noexcept;
3839
inline void __sw_barrier() noexcept;

api/kernel/os.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ class OS {
7474
/** Uptime in whole seconds. */
7575
static RTC::timestamp_t uptime();
7676

77+
/** Time spent sleeping (halt) in cycles */
78+
static uint64_t cycles_asleep() noexcept;
79+
80+
/** Time spent sleeping (halt) in micros */
81+
static uint64_t micros_asleep() noexcept;
82+
83+
7784
static MHz cpu_freq() noexcept
7885
{ return cpu_mhz_; }
7986

@@ -178,11 +185,8 @@ class OS {
178185
return memory_end_;
179186
}
180187

181-
/** time spent sleeping (halt) in cycles */
182-
static uint64_t get_cycles_halt() noexcept;
183-
184-
/** total time spent in cycles */
185-
static uint64_t get_cycles_total() noexcept;
188+
/** Returns the automatic location set aside for storing system and program state **/
189+
static void* liveupdate_storage_area() noexcept;
186190

187191
/**
188192
* A map of memory ranges. The key is the starting address in numeric form.
@@ -255,6 +259,7 @@ class OS {
255259

256260
// XXX: Only used by solo5
257261
static RTC::timestamp_t booted_at_;
262+
static uintptr_t liveupdate_loc_;
258263
static std::string version_str_;
259264
static std::string arch_str_;
260265
static Plugin_vec plugins_;

api/kernel/timers.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ class Timers
4545

4646
/// returns the number of current, active timers
4747
static size_t active();
48+
/// returns the number of existing timers
49+
static size_t existing();
50+
/// returns the number of free timers
51+
static size_t free();
52+
53+
/// NOTE: All above operations operate on the current CPU
54+
/// NOTE: There is a separate timer system on each active CPU
4855

4956
/// initialization
5057
typedef delegate<void(duration_t)> start_func_t;

api/net/ip4/addr.hpp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,30 @@ struct Addr {
216216
constexpr bool operator<(const uint32_t raw_addr) const noexcept
217217
{ return ntohl(whole) < ntohl(raw_addr); }
218218

219+
/**
220+
* Operator to check for less-than-or-equal relationship
221+
*
222+
* @param other
223+
* The IPv4 address object to check for less-than-or-equal relationship
224+
*
225+
* @return true if this object is less-than-or-equal to other, false otherwise
226+
*/
227+
constexpr bool operator<=(const Addr other) const noexcept
228+
{ return (*this < other or *this == other); }
229+
230+
/**
231+
* Operator to check for less-than-or-equal relationship
232+
*
233+
* @param raw_addr
234+
* The 32-bit value to check for less-than-or-equal relationship
235+
*
236+
* @return true if this object is less-than-or-equal to raw_addr, false otherwise
237+
*
238+
* @note The 32-bit value must be in network byte order
239+
*/
240+
constexpr bool operator<=(const uint32_t raw_addr) const noexcept
241+
{ return (*this < raw_addr or *this == raw_addr); }
242+
219243
/**
220244
* Operator to check for greater-than relationship
221245
*
@@ -225,7 +249,7 @@ struct Addr {
225249
* @return true if this object is greater-than other, false otherwise
226250
*/
227251
constexpr bool operator>(const Addr other) const noexcept
228-
{ return not (*this < other); }
252+
{ return not (*this <= other); }
229253

230254
/**
231255
* Operator to check for greater-than relationship
@@ -238,7 +262,31 @@ struct Addr {
238262
* @note The 32-bit value must be in network byte order
239263
*/
240264
constexpr bool operator>(const uint32_t raw_addr) const noexcept
241-
{ return not (*this < raw_addr); }
265+
{ return not (*this <= raw_addr); }
266+
267+
/**
268+
* Operator to check for greater-than-or-equal relationship
269+
*
270+
* @param other
271+
* The IPv4 address object to check for greater-than-or-equal relationship
272+
*
273+
* @return true if this object is greater-than-or-equal to other, false otherwise
274+
*/
275+
constexpr bool operator>=(const Addr other) const noexcept
276+
{ return (*this > other or *this == other); }
277+
278+
/**
279+
* Operator to check for greater-than-or-equal relationship
280+
*
281+
* @param raw_addr
282+
* The 32-bit value to check for greater-than-or-equal relationship
283+
*
284+
* @return true if this object is greater-than-or-equal to raw_addr, false otherwise
285+
*
286+
* @note The 32-bit value must be in network byte order
287+
*/
288+
constexpr bool operator>=(const uint32_t raw_addr) const noexcept
289+
{ return (*this > raw_addr or *this == raw_addr); }
242290

243291
/**
244292
* Operator to perform a bitwise-and operation on the given

api/profile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ struct StackSampler
3939
static void begin();
4040

4141
// total number of waking samples taken
42-
static uint64_t samples_total();
42+
static uint64_t samples_total() noexcept;
4343

4444
// total number of samples taken while asleep
45-
static uint64_t samples_asleep();
45+
static uint64_t samples_asleep() noexcept;
4646

4747
// retrieve N top results/hotspots
4848
static std::vector<Sample> results(int N);
@@ -57,6 +57,7 @@ struct StackSampler
5757
enum mode_t {
5858
MODE_CURRENT,
5959
MODE_CALLER,
60+
MODE_DUMMY
6061
};
6162

6263
// set sampling mode

cmake/post.service.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ if (${ELF} STREQUAL "i686")
223223
set(ELF "i386")
224224
endif()
225225

226+
set(PRE_BSS_SIZE "--defsym PRE_BSS_AREA=0x0")
227+
if ("${PLATFORM}" STREQUAL "x86_solo5")
228+
# pre-BSS memory hole for uKVM global variables
229+
set(PRE_BSS_SIZE "--defsym PRE_BSS_AREA=0x200000")
230+
endif()
226231

227-
set(LDFLAGS "-nostdlib -melf_${ELF} -N --eh-frame-hdr ${STRIP_LV} --script=${INSTALL_LOC}/${ARCH}/linker.ld ${INSTALL_LOC}/${ARCH}/lib/crtbegin.o")
232+
set(LDFLAGS "-nostdlib -melf_${ELF} -N --eh-frame-hdr ${STRIP_LV} --script=${INSTALL_LOC}/${ARCH}/linker.ld ${PRE_BSS_SIZE} ${INSTALL_LOC}/${ARCH}/lib/crtbegin.o")
228233

229234
set_target_properties(service PROPERTIES LINK_FLAGS "${LDFLAGS}")
230235

examples/LiveUpdate/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
cmake_minimum_required(VERSION 2.8.9)
2+
3+
# IncludeOS install location
4+
if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
5+
set(ENV{INCLUDEOS_PREFIX} /usr/local)
6+
endif()
7+
include($ENV{INCLUDEOS_PREFIX}/includeos/pre.service.cmake)
8+
project(service)
9+
10+
# Human-readable name of your service
11+
set(SERVICE_NAME "LiveUpdate example")
12+
13+
# Name of your service binary
14+
set(BINARY "liveupdate")
15+
16+
# Source files to be linked with OS library parts to form bootable image
17+
set(SOURCES
18+
service.cpp response.cpp
19+
)
20+
21+
# DRIVERS / PLUGINS:
22+
set(DRIVERS
23+
virtionet
24+
)
25+
26+
set(PLUGINS
27+
autoconf
28+
)
29+
30+
set(LIBRARIES
31+
libliveupdate.a
32+
)
33+
34+
# include service build script
35+
include($ENV{INCLUDEOS_PREFIX}/includeos/post.service.cmake)

examples/LiveUpdate/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### LiveUpdate Demo Service
2+
3+
```
4+
boot .
5+
Ctrl+Shift+T
6+
./update.sh
7+
```
8+
9+
This service should start an instance of IncludeOS that brings up a minimal web service on port 80 with static content. When running test.sh the service should be updated with itself.

examples/LiveUpdate/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"net" : [
3+
{
4+
"iface": 0,
5+
"config": "dhcp-with-fallback",
6+
"address": "10.0.0.42",
7+
"netmask": "255.255.255.0",
8+
"gateway": "10.0.0.1"
9+
}
10+
]
11+
}

examples/LiveUpdate/liu.hpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is a part of the IncludeOS unikernel - www.includeos.org
2+
//
3+
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
4+
// and Alfred Bratterud
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
18+
#pragma once
19+
#include <liveupdate>
20+
#include "server.hpp"
21+
22+
void setup_liveupdate_server(net::Inet<net::IP4>& inet,
23+
const uint16_t PORT,
24+
liu::LiveUpdate::storage_func func)
25+
{
26+
static liu::LiveUpdate::storage_func save_function;
27+
save_function = func;
28+
29+
// listen for live updates
30+
server(inet, PORT,
31+
[] (liu::buffer_t& buffer)
32+
{
33+
printf("* Live updating from %p (len=%u)\n",
34+
buffer.data(), (uint32_t) buffer.size());
35+
try
36+
{
37+
// run live update process
38+
liu::LiveUpdate::exec(buffer, "test", save_function);
39+
}
40+
catch (std::exception& err)
41+
{
42+
liu::LiveUpdate::restore_environment();
43+
printf("Live update failed:\n%s\n", err.what());
44+
throw;
45+
}
46+
});
47+
}

0 commit comments

Comments
 (0)