Skip to content

Commit dd329d2

Browse files
committed
Merge branch 'dev' of github.com:fwsGonzo/IncludeOS into dev
2 parents 0c9d09b + 2cea10c commit dd329d2

24 files changed

Lines changed: 262 additions & 726 deletions

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
[submodule "test/lest"]
99
path = test/lest
1010
url = https://github.com/martinmoene/lest.git
11+
[submodule "mod/fiber"]
12+
path = mod/fiber
13+
url = https://github.com/boostorg/fiber.git

api/kernel/context.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
#ifndef KERNEL_CONTEXT_HPP
20+
#define KERNEL_CONTEXT_HPP
21+
22+
#include <delegate>
23+
24+
struct Context
25+
{
26+
typedef delegate<void()> context_func;
27+
28+
// create and switch to a new stack with size @stack_size and call func
29+
static void create(unsigned stack_size, context_func);
30+
// switch to a pre-allocated location and call func
31+
static void jump(void* location, context_func);
32+
};
33+
34+
#endif

api/kernel/os.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ class OS {
8484
*/
8585
static void halt();
8686

87+
/**
88+
* Returns true when the OS will still be running, and not shutting down.
89+
*/
90+
static bool is_running() {
91+
return power_;
92+
}
93+
8794
/**
8895
* Add handler for standard output.
8996
*/

api/net/tcp/connection.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919
#ifndef NET_TCP_CONNECTION_HPP
2020
#define NET_TCP_CONNECTION_HPP
2121

22-
#include <hw/pit.hpp>
23-
2422
#include "common.hpp"
2523
#include "read_request.hpp"
2624
#include "rttm.hpp"
2725
#include "socket.hpp"
2826
#include "tcp_errors.hpp"
2927
#include "write_queue.hpp"
28+
#include <delegate>
3029

3130
namespace net {
3231
class TCP;
@@ -229,6 +228,9 @@ class Connection : public std::enable_shared_from_this<Connection> {
229228
bool is_closing() const
230229
{ return state_->is_closing(); }
231230

231+
bool is_closed() const
232+
{ return state_->is_closed(); };
233+
232234
/*
233235
Helper function for state checks.
234236
*/
@@ -307,6 +309,9 @@ class Connection : public std::enable_shared_from_this<Connection> {
307309
virtual bool is_closing() const
308310
{ return false; }
309311

312+
virtual bool is_closed() const
313+
{ return false; }
314+
310315
protected:
311316
/*
312317
Helper functions

api/net/tcp/connection_states.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ class Connection::Closed : public State {
5353
5454
=> SynSent
5555
*/
56-
virtual Result handle(Connection&, Packet_ptr in) override;
56+
Result handle(Connection&, Packet_ptr in) override;
5757

58-
inline virtual std::string to_string() const override {
58+
bool is_closed() const override {
59+
return true;
60+
}
61+
62+
std::string to_string() const override {
5963
return "CLOSED";
6064
};
6165
private:
@@ -378,11 +382,14 @@ class Connection::TimeWait : public State {
378382
*/
379383
virtual Result handle(Connection&, Packet_ptr in) override;
380384

381-
inline virtual std::string to_string() const override {
385+
std::string to_string() const override {
382386
return "TIME-WAIT";
383387
};
384388

385-
inline virtual bool is_closing() const override {
389+
bool is_closing() const override {
390+
return true;
391+
}
392+
bool is_closed() const override {
386393
return true;
387394
}
388395

api/net/tcp/read_request.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define NET_TCP_READ_REQUEST_HPP
2121

2222
#include "read_buffer.hpp"
23+
#include <delegate>
2324

2425
namespace net {
2526
namespace tcp {

mod/fiber

Submodule fiber added at a54425d

src/Makefile

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ INC_NEWLIB=$(INSTALL)/newlib/include
4040
CC = $(shell command -v clang-3.8 || command -v clang-3.6)
4141
CPP = $(shell command -v clang++-3.8 || command -v clang++-3.6 || command -v clang++)
4242
# Set defaults if not defined
43-
ifndef LD_INC
44-
LD_INC = ld
45-
endif
4643
ifndef AR_INC
4744
AR_INC = ar
4845
endif
@@ -54,12 +51,11 @@ endif
5451
CCOPTS = -target i686-elf
5552
CPPOPTS = -target i686-elf
5653

57-
INCLUDES = -I../api/sys -I$(INSTALL)/libcxx/include -I$(INC_NEWLIB) -Iinclude -I../api -I../mod/GSL
54+
INCLUDES = -I../api/sys -I$(INSTALL)/libcxx/include -I$(INC_NEWLIB) -Iinclude -I../api -I../mod/GSL -I../mod/fiber/include
5855
CINCLUDES = -I../api/sys -I$(INC_NEWLIB) -Iinclude -I../api
5956

6057
CCOPTS += $(CAPABS) $(WARNS) -c -m32 -march=i686 $(CINCLUDES)
6158
CPPOPTS += $(CAPABS) $(WARNS) -c -m32 -std=c++14 $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION="\"$(shell git describe --dirty)\""
62-
LDOPTS = -nostdlib -melf_i386 -N --eh-frame-hdr --script=linker.ld
6359

6460
# Objects
6561
###################################################
@@ -70,7 +66,7 @@ OS_OBJECTS = kernel/start.o kernel/kernel_start.o kernel/syscalls.o \
7066
kernel/interrupts.o kernel/os.o kernel/os_stdout.o kernel/cpuid.o \
7167
kernel/memmap.o kernel/irq_manager.o kernel/pci_manager.o \
7268
kernel/elf.o kernel/terminal.o kernel/terminal_disk.o \
73-
kernel/vga.o kernel/debug_new.o \
69+
kernel/vga.o kernel/debug_new.o kernel/context.o kernel/context_asm.o \
7470
kernel/profile.o kernel/profile_intr.o \
7571
kernel/timers.o kernel/rtc.o util/memstream.o util/async.o util/statman.o \
7672
crt/c_abi.o crt/string.o crt/quick_exit.o crt/cxx_abi.o crt/mman.o \
@@ -88,7 +84,10 @@ OS_OBJECTS = kernel/start.o kernel/kernel_start.o kernel/syscalls.o \
8884
net/buffer_store.o net/inet4.o \
8985
fs/disk.o fs/filesystem.o fs/mbr.o fs/path.o \
9086
fs/ext4.o fs/fat.o fs/fat_async.o fs/fat_sync.o fs/memdisk.o
91-
# virtio/console.o
87+
#../mod/fiber/src/barrier.o ../mod/fiber/src/context.o ../mod/fiber/src/condition_variable.o \
88+
#../mod/fiber/src/fiber.o ../mod/fiber/src/future.o ../mod/fiber/src/properties.o ../mod/fiber/src/mutex.o \
89+
# ../mod/fiber/src/recursive_mutex.o ../mod/fiber/src/recursive_timed_mutex.o \
90+
#../mod/fiber/src/recursive_mutex.o ../mod/fiber/src/scheduler.o ../mod/fiber/src/timed_mutex.o
9291

9392
DRIVERS = drivers/virtioblk.o drivers/virtionet.o
9493
DRIVERS_DEPS = $(DRIVERS:.o=.d)
@@ -103,7 +102,7 @@ CRTN_OBJ = crt/crtn.o
103102
###################################################
104103
OS_DEPS = $(OS_OBJECTS:.o=.d)
105104

106-
.PHONY: memdisk all debug stripped minimal clean
105+
.PHONY: all stripped minimal debug silent clean
107106

108107
# Complete OS build
109108
###################################################
@@ -115,10 +114,12 @@ all: CAPABS += -O2
115114
all: includeos
116115
@echo "\n>>> Built OS-library. Install to '"$(INSTALL)"' using 'make install'"
117116

118-
stripped: CAPABS += -Os
119-
stripped: LDOPTS += -s
117+
stripped: CAPABS += -O2
120118
stripped: includeos
121119

120+
minimal: CAPABS += -Os
121+
minimal: includeos
122+
122123
# Build like "all" but with debugging output (i.e. the 'debug'-macro) enabled
123124
debug-info: CAPABS += -UNO_DEBUG
124125
debug-info: CAPABS += -DGSL_THROW_ON_CONTRACT_VIOLATION
@@ -141,31 +142,8 @@ debug-all: includeos test
141142
silent: CPPOPTS += -DNO_INFO=1
142143
silent: includeos
143144

144-
minimal: CPPOPTS += -ffunction-sections -fdata-sections
145-
minimal: LDOPTS += --gc-sections
146-
minimal: stripped
147-
148145
includeos: bootloader multiboot libc++abi.a os.a drivers platforms
149146

150-
# Test service
151-
###################################################
152-
LIBS_OBJ = os.a $(LIBCXX) os.a $(LIBC_OBJ) $(LIBM_OBJ) $(LIBGCC)
153-
154-
155-
CRTBEGIN_OBJ = $(CRTI_OBJ) $(INSTALL)/crt/crtbegin.o
156-
CRTEND_OBJ = $(INSTALL)/crt/crtend.o $(CRTN_OBJ)
157-
158-
TEST_OBJ = debug/test_service.o util/service_name.o
159-
160-
test_service: CPPOPTS += -DSERVICE_NAME="\"Test Service\""
161-
test_service: $(TEST_OBJ) $(CRTI_OBJ) $(CRTN_OBJ)
162-
@echo "\n>> Linking test service"
163-
@echo "\n>> LDOPTS = $(LDOPTS)"
164-
touch smalldisk
165-
$(LD_INC) -v $(LDOPTS) $(CRTBEGIN_OBJ) $(TEST_OBJ) $(LIBS_OBJ) $(CRTEND_OBJ) -o debug/$@
166-
167-
test: test_service
168-
169147
# OS libraries
170148
###################################################
171149
# OS
@@ -249,10 +227,7 @@ etags:
249227

250228
# Cleanup
251229
###################################################
252-
clean_tests:
253-
$(RM) debug/*.o debug/*.d debug/*.img debug/test_service debug/test_ipv6 debug/test_tcp
254-
255-
clean: clean_tests
230+
clean:
256231
$(RM) $(OS_OBJECTS) $(CXXABI_OBJ) $(OS_DEPS) $(DRIVERS) $(DRIVERS_DEPS) $(PLATFORMS) $(PLATFORMS_DEPS)
257232
$(RM) os.a libc++abi.a
258233
$(RM) bootloader apic_boot apic_boot.o boot/multiboot.o

0 commit comments

Comments
 (0)