Skip to content

Commit f4a739f

Browse files
committed
Merge branch 'dev' of github.com:hioa-cs/IncludeOS into dev
2 parents 0319d4d + 6894276 commit f4a739f

8 files changed

Lines changed: 65 additions & 23 deletions

File tree

lib/uplink/starbase/config.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
2-
"net" : [["10.20.17.111", "255.255.255.0", "10.20.17.1", "10.20.17.1"]],
2+
"net" : [
3+
{
4+
"iface": 0,
5+
"config": "static",
6+
"address": "10.0.0.42",
7+
"netmask": "255.255.255.0",
8+
"gateway": "10.0.0.1"
9+
}
10+
],
311
"uplink" : {
4-
"url" : "10.20.17.12:9090",
12+
"url" : "10.0.0.1:9090",
513
"token" : "kappa123",
614
"reboot" : true
715
}

src/arch/x86_64/arch_start.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern __multiboot_addr
2424
%define P4_TAB 0x1000
2525
%define P3_TAB 0x2000 ;; - 0x5fff
2626
%define P2_TAB 0x100000
27-
%define STACK_LOCATION 0x9fff00
27+
%define STACK_LOCATION 0x9ffff0
2828

2929
[BITS 32]
3030
__arch_start:

src/arch/x86_64/ist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ extern gdtr64 __gdt64_base_pointer;
1111

1212
#define INTR_SIZE 4096
1313
#define NMI_SIZE 20480
14-
#define DFI_SIZE 20480
14+
#define DFI_SIZE 4096
1515

1616
namespace x86
1717
{
1818
struct alignas(SMP_ALIGN) LM_IST
1919
{
2020
char* intr; // 4kb
2121
char* nmi; // 20kb
22-
char* dfi; // 20kb
22+
char* dfi; // 4kb
2323

2424
AMD64_TSS tss;
2525
};

src/kernel/syscalls.cpp

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ void OS::on_panic(on_panic_func func)
151151
panic_handler = std::move(func);
152152
}
153153

154+
extern "C" __attribute__((noreturn)) void panic_epilogue(const char*);
155+
156+
154157
/**
155158
* panic:
156159
* Display reason for kernel panic
@@ -193,21 +196,37 @@ asm("panic_begin:");
193196
fflush(stderr);
194197
SMP::global_unlock();
195198

196-
// call custom on panic handler (if present)
197-
if (panic_handler) panic_handler(why);
199+
panic_epilogue(why);
200+
}
198201

199-
#if defined(ARCH_x86)
202+
extern "C"
203+
void double_fault(const char* why)
204+
{
200205
SMP::global_lock();
201-
// Signal End-Of-Transmission
202-
kprint("\x04");
206+
fprintf(stderr, "\n%s\nCPU: %d, Reason: %s\n",
207+
panic_signature, SMP::cpu_id(), why);
203208
SMP::global_unlock();
204209

205-
// .. if we return from the panic handler, go to permanent sleep
206-
while (1) asm("cli; hlt");
210+
panic_epilogue(why);
211+
}
212+
213+
void panic_epilogue(const char* why)
214+
{
215+
// call custom on panic handler (if present)
216+
if (panic_handler) panic_handler(why);
217+
218+
#if defined(ARCH_x86)
219+
SMP::global_lock();
220+
// Signal End-Of-Transmission
221+
kprint("\x04");
222+
SMP::global_unlock();
223+
224+
// .. if we return from the panic handler, go to permanent sleep
225+
while (1) asm("cli; hlt");
226+
#else
227+
#warning "panic() handler not implemented for selected arch"
228+
#endif
207229
__builtin_unreachable();
208-
#else
209-
#warning "panic() handler not implemented for selected arch"
210-
#endif
211230
}
212231

213232
// Shutdown the machine when one of the exit functions are called

src/net/configure.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ void configure(const rapidjson::Value& net)
8181

8282
std::string method = val["config"].GetString();
8383

84+
double timeout = (val.HasMember("timeout")) ? val["timeout"].GetDouble() : 10.0;
85+
8486
if(method == "dhcp")
8587
{
86-
stack.negotiate_dhcp(5.0);
88+
stack.negotiate_dhcp(timeout);
8789
}
8890
else if(method == "static")
8991
{
@@ -92,14 +94,14 @@ void configure(const rapidjson::Value& net)
9294
else if(method == "dhcp-with-fallback")
9395
{
9496
auto addresses = parse_iface(val);
95-
auto static_cfg = [addresses, &stack] (bool timeout)
97+
auto static_cfg = [addresses, &stack] (bool timedout)
9698
{
97-
if(timeout) {
99+
if(timedout) {
98100
MYINFO("DHCP timeout (%s) - falling back to static configuration", stack.ifname().c_str());
99101
config_stack(stack, addresses);
100102
}
101103
};
102-
stack.negotiate_dhcp(5.0, static_cfg);
104+
stack.negotiate_dhcp(timeout, static_cfg);
103105
}
104106
}
105107

src/net/inet4.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void Inet4::error_report(Error& err, Packet_ptr orig_pckt) {
164164
}
165165

166166
void Inet4::negotiate_dhcp(double timeout, dhcp_timeout_func handler) {
167-
INFO("Inet4", "Negotiating DHCP...");
167+
INFO("Inet4", "Negotiating DHCP (%.1fs timeout)...", timeout);
168168
if (!dhcp_)
169169
dhcp_ = std::make_shared<DHClient>(*this);
170170
// @timeout for DHCP-server negotation

src/platform/x86_pc/idt.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ static void cpu_dump_regs(uintptr_t* regs)
259259
fprintf(stderr, "\n");
260260
}
261261

262+
extern "C" void double_fault(const char*);
263+
262264
extern "C"
263265
__attribute__((noreturn, optnone))
264266
void __cpu_exception(uintptr_t* regs, int error, uint32_t code)
@@ -270,8 +272,17 @@ void __cpu_exception(uintptr_t* regs, int error, uint32_t code)
270272
exception_names[error], error, (void*) regs[RIP_REG], code);
271273
cpu_dump_regs(regs);
272274
SMP::global_unlock();
273-
// call panic, which will decide what to do next
275+
// error message:
274276
char buffer[64];
275277
snprintf(buffer, sizeof(buffer), "%s (%d)", exception_names[error], error);
276-
panic(buffer);
278+
// normal CPU exception
279+
if (error != 0x8) {
280+
// call panic, which will decide what to do next
281+
panic(buffer);
282+
}
283+
else {
284+
// handle double faults differently
285+
double_fault(buffer);
286+
}
287+
__builtin_unreachable();
277288
}

test/net/integration/configure/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
},
2222
{
2323
"iface": 3,
24-
"config": "dhcp"
24+
"config": "dhcp",
25+
"timeout": 5.0
2526
},
2627
{
2728
"iface": 5,
2829
"config": "dhcp-with-fallback",
30+
"timeout": 10,
2931
"address": "10.0.0.44",
3032
"netmask": "255.255.255.0",
3133
"gateway": "10.0.0.1"

0 commit comments

Comments
 (0)