1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/native/startup.c

62 lines
1.2 KiB
C
Raw Normal View History

2013-03-06 10:29:49 +01:00
/**
* Native CPU entry code
*
* Copyright (C) 2013 Ludwig Ortmann
*
* 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>
* @}
*/
#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>
#include <stdlib.h>
#include <err.h>
2013-03-06 01:08:15 +01:00
#include "kernel_internal.h"
#include "cpu.h"
#include "native_internal.h"
#include "tap.h"
2013-03-06 01:08:15 +01:00
__attribute__((constructor)) static void startup(int argc, char **argv)
2013-03-06 01:08:15 +01:00
{
/* get system read/write */
*(void **)(&real_read) = dlsym(RTLD_NEXT, "read");
*(void **)(&real_write) = dlsym(RTLD_NEXT, "write");
2013-08-08 11:08:33 +02:00
#ifdef MODULE_NATIVENET
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;
#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
tap_init(argv[1]);
#endif
2013-03-06 01:08:15 +01:00
board_init();
puts("RIOT native hardware initialization complete.\n");
kernel_init();
}