2013-11-07 17:23:08 +01:00
|
|
|
/**
|
|
|
|
* Native CPU internal declarations
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup arch
|
|
|
|
* @defgroup native_cpu Native CPU
|
|
|
|
* @{
|
|
|
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NATIVE_INTERNAL_H
|
|
|
|
#define _NATIVE_INTERNAL_H
|
|
|
|
|
2013-12-22 23:26:54 +01:00
|
|
|
#include <signal.h>
|
2014-04-10 14:58:12 +02:00
|
|
|
/* enable signal handler register access on different platforms
|
|
|
|
* check here for more:
|
|
|
|
* http://sourceforge.net/p/predef/wiki/OperatingSystems/
|
|
|
|
*/
|
|
|
|
#if (defined(__FreeBSD__) || defined(__MACH__))
|
|
|
|
#ifndef _XOPEN_SOURCE
|
|
|
|
#define _XOPEN_SOURCE
|
|
|
|
#include <ucontext.h>
|
|
|
|
#undef _XOPEN_SOURCE
|
|
|
|
#else
|
|
|
|
#include <ucontext.h>
|
|
|
|
#endif
|
|
|
|
#elif defined(__linux__)
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define GNU_SOURCE
|
|
|
|
#include <ucontext.h>
|
|
|
|
#undef GNU_SOURCE
|
|
|
|
#else
|
|
|
|
#include <ucontext.h>
|
|
|
|
#endif
|
|
|
|
#endif // BSD/Linux
|
|
|
|
|
2013-11-07 17:23:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* internal functions
|
|
|
|
*/
|
|
|
|
void native_cpu_init(void);
|
|
|
|
void native_interrupt_init(void);
|
2014-05-07 13:29:34 +02:00
|
|
|
extern void native_hwtimer_pre_init(void);
|
2013-11-07 17:23:08 +01:00
|
|
|
|
2014-05-07 13:29:34 +02:00
|
|
|
void native_irq_handler(void);
|
2013-11-07 17:23:08 +01:00
|
|
|
extern void _native_sig_leave_tramp(void);
|
|
|
|
|
2014-05-07 13:29:34 +02:00
|
|
|
void _native_syscall_leave(void);
|
|
|
|
void _native_syscall_enter(void);
|
2013-11-07 17:23:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* external functions regularly wrapped in native for direct use
|
|
|
|
*/
|
|
|
|
extern ssize_t (*real_read)(int fd, void *buf, size_t count);
|
|
|
|
extern ssize_t (*real_write)(int fd, const void *buf, size_t count);
|
2014-01-24 17:03:01 +01:00
|
|
|
extern void* (*real_malloc)(size_t size);
|
|
|
|
extern void (*real_free)(void *ptr);
|
|
|
|
extern void* (*real_calloc)(size_t nmemb, size_t size);
|
|
|
|
extern void* (*real_realloc)(void *ptr, size_t size);
|
2014-05-13 17:41:36 +02:00
|
|
|
extern int (*real_getpid)(void);
|
2013-11-07 17:23:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* data structures
|
|
|
|
*/
|
|
|
|
extern volatile int native_interrupts_enabled;
|
|
|
|
extern volatile unsigned int _native_saved_eip;
|
|
|
|
extern int _sig_pipefd[2];
|
|
|
|
extern volatile int _native_sigpend;
|
|
|
|
extern volatile int _native_in_isr;
|
|
|
|
extern volatile int _native_in_syscall;
|
|
|
|
|
|
|
|
extern char __isr_stack[SIGSTKSZ];
|
|
|
|
extern char __end_stack[SIGSTKSZ];
|
|
|
|
extern ucontext_t native_isr_context;
|
|
|
|
extern ucontext_t end_context;
|
|
|
|
extern ucontext_t *_native_cur_ctx, *_native_isr_ctx;
|
|
|
|
|
2013-12-10 12:10:05 +01:00
|
|
|
extern const char *_progname;
|
2014-02-14 16:18:40 +01:00
|
|
|
extern char **_native_argv;
|
2014-05-13 16:53:36 +02:00
|
|
|
extern pid_t _native_pid;
|
2014-05-19 19:58:40 +02:00
|
|
|
extern const char *_native_unix_socket_path;
|
2013-12-10 12:10:05 +01:00
|
|
|
|
2013-11-07 17:23:08 +01:00
|
|
|
#ifdef MODULE_UART0
|
|
|
|
#include <sys/select.h>
|
|
|
|
extern fd_set _native_rfds;
|
|
|
|
#endif
|
|
|
|
|
2014-03-26 13:49:01 +01:00
|
|
|
ssize_t _native_read(int fd, void *buf, size_t count);
|
|
|
|
ssize_t _native_write(int fd, const void *buf, size_t count);
|
2013-12-22 23:26:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* register interrupt handler handler for interrupt sig
|
|
|
|
*/
|
|
|
|
int register_interrupt(int sig, void (*handler)(void));
|
|
|
|
|
|
|
|
/**
|
|
|
|
* unregister interrupt handler for interrupt sig
|
|
|
|
*/
|
|
|
|
int unregister_interrupt(int sig);
|
|
|
|
|
|
|
|
//#include <sys/param.h>
|
|
|
|
|
|
|
|
#include "kernel_internal.h"
|
|
|
|
#include "sched.h"
|
|
|
|
|
|
|
|
|
2013-11-07 17:23:08 +01:00
|
|
|
/** @} */
|
|
|
|
#endif /* _NATIVE_INTERNAL_H */
|