From 0501fe8980657a642560b854acfe06d84307b044 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 8 Jan 2014 15:47:37 +0100 Subject: [PATCH 1/2] native: config_load: set PID as id, net address --- boards/native/board_config.c | 20 +++++++++++++++++++- cpu/native/include/nativenet_internal.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/boards/native/board_config.c b/boards/native/board_config.c index 4247fcb689..68d3e9bb42 100644 --- a/boards/native/board_config.c +++ b/boards/native/board_config.c @@ -17,15 +17,33 @@ #include #include +#include #include "config.h" +#ifdef MODULE_NATIVENET +#include "nativenet.h" +#include "nativenet_internal.h" +#endif + +#define ENABLE_DEBUG (0) +#include "debug.h" + /** * XXX: loading not implemented */ void config_load(void) { - printf("XXX: config_load(): not implemented\n"); + DEBUG("config_load()\n"); + + int pid = getpid(); + + sysconfig.id = pid; + +#ifdef MODULE_NATIVENET + _native_net_addr = pid; +#endif + return; } diff --git a/cpu/native/include/nativenet_internal.h b/cpu/native/include/nativenet_internal.h index 954f4bdcd3..384663a1c3 100644 --- a/cpu/native/include/nativenet_internal.h +++ b/cpu/native/include/nativenet_internal.h @@ -39,6 +39,7 @@ struct rx_buffer_s { extern struct rx_buffer_s _nativenet_rx_buffer[RX_BUF_SIZE]; extern uint64_t _native_net_addr_long; +extern radio_address_t _native_net_addr; void _nativenet_handle_packet(radio_packet_t *packet); int8_t send_buf(radio_packet_t *packet); From e688efdfcfc9b73952c685af1659f19d7e7948be Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Fri, 14 Feb 2014 00:09:19 +0100 Subject: [PATCH 2/2] core: kernel_init: call config_load in kernel_init --- core/kernel_init.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/kernel_init.c b/core/kernel_init.c index 00a4eeddfd..55620803da 100644 --- a/core/kernel_init.c +++ b/core/kernel_init.c @@ -32,10 +32,17 @@ #include "thread.h" #include "hwtimer.h" +#define ENABLE_DEBUG (0) +#include "debug.h" + #ifdef MODULE_AUTO_INIT #include #endif +#ifdef MODULE_CONFIG +#include "config.h" +#endif + volatile int lpm_prevent_sleep = 0; extern int main(void); @@ -81,6 +88,11 @@ void kernel_init(void) printf("kernel_init(): error creating main task.\n"); } +#ifdef MODULE_CONFIG + DEBUG("kernel_init(): loading config\n"); + config_load(); +#endif + printf("kernel_init(): jumping into first task...\n"); cpu_switch_context_exit();