2013-03-06 10:29:49 +01:00
|
|
|
/**
|
|
|
|
* Native CPU entry code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Ludwig Ortmann
|
|
|
|
*
|
2013-06-18 17:21:38 +02:00
|
|
|
* This file subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
2013-03-06 10:29:49 +01:00
|
|
|
*
|
|
|
|
* @ingroup arch
|
|
|
|
* @{
|
|
|
|
* @file
|
|
|
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2013-11-07 17:23:08 +01:00
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#else
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
2013-03-06 01:08:15 +01:00
|
|
|
#include <stdio.h>
|
2013-06-26 23:29:09 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <err.h>
|
|
|
|
|
2013-03-06 01:08:15 +01:00
|
|
|
|
2013-11-07 17:23:08 +01:00
|
|
|
#include "kernel_internal.h"
|
|
|
|
#include "cpu.h"
|
2013-06-26 23:29:09 +02:00
|
|
|
|
2013-11-07 17:23:08 +01:00
|
|
|
#include "native_internal.h"
|
|
|
|
#include "tap.h"
|
2013-03-06 01:08:15 +01:00
|
|
|
|
2013-06-26 23:29:09 +02:00
|
|
|
__attribute__((constructor)) static void startup(int argc, char **argv)
|
2013-03-06 01:08:15 +01:00
|
|
|
{
|
2013-11-07 17:23:08 +01:00
|
|
|
/* get system read/write */
|
|
|
|
*(void **)(&real_read) = dlsym(RTLD_NEXT, "read");
|
|
|
|
*(void **)(&real_write) = dlsym(RTLD_NEXT, "write");
|
2013-06-26 23:29:09 +02:00
|
|
|
|
2013-08-08 11:08:33 +02:00
|
|
|
#ifdef MODULE_NATIVENET
|
2013-06-26 23:29:09 +02:00
|
|
|
if (argc < 2) {
|
|
|
|
printf("usage: %s <tap interface>\n", argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2013-08-15 23:20:30 +02:00
|
|
|
#else /* args unused here */
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
2013-06-26 23:29:09 +02:00
|
|
|
#endif
|
|
|
|
|
2013-03-06 01:08:15 +01:00
|
|
|
native_cpu_init();
|
|
|
|
native_interrupt_init();
|
2013-08-08 11:08:33 +02:00
|
|
|
#ifdef MODULE_NATIVENET
|
2013-06-26 23:29:09 +02:00
|
|
|
tap_init(argv[1]);
|
|
|
|
#endif
|
2013-03-06 01:08:15 +01:00
|
|
|
|
|
|
|
board_init();
|
|
|
|
|
|
|
|
puts("RIOT native hardware initialization complete.\n");
|
|
|
|
kernel_init();
|
|
|
|
}
|