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
Ludwig Ortmann 7b9d199ec8 make system calls safer/clean up headers
wrap some libc functions that do system calls (terminal output)
wrap read/write with syscall guard
define real_read/write (next dynamic linker find for read/write)
guard system calls in remaining code
introduce native_internhal.h
throw out some debug statements that break things
clean up includes a bit
declare board_init in native_internhal.h
add -ldl to LINKFLAGS for cpu/syscalls
2013-11-13 00:01:42 +01:00

62 lines
1.2 KiB
C

/**
* 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.
*
* @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
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include "kernel_internal.h"
#include "cpu.h"
#include "native_internal.h"
#include "tap.h"
__attribute__((constructor)) static void startup(int argc, char **argv)
{
/* get system read/write */
*(void **)(&real_read) = dlsym(RTLD_NEXT, "read");
*(void **)(&real_write) = dlsym(RTLD_NEXT, "write");
#ifdef MODULE_NATIVENET
if (argc < 2) {
printf("usage: %s <tap interface>\n", argv[0]);
exit(EXIT_FAILURE);
}
#else /* args unused here */
(void) argc;
(void) argv;
#endif
native_cpu_init();
native_interrupt_init();
#ifdef MODULE_NATIVENET
tap_init(argv[1]);
#endif
board_init();
puts("RIOT native hardware initialization complete.\n");
kernel_init();
}