2013-03-06 10:29:49 +01:00
|
|
|
/**
|
|
|
|
* Native CPU interface
|
|
|
|
*
|
2013-03-13 21:56:56 +01:00
|
|
|
* The native CPU uses system calls to simulate hardware access.
|
|
|
|
*
|
2013-03-06 10:29:49 +01:00
|
|
|
* Copyright (C) 2013 Ludwig Ortmann
|
|
|
|
*
|
|
|
|
* This file subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file LICENSE in the top level directory for more details.
|
2013-03-13 21:56:56 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-03-06 10:29:49 +01:00
|
|
|
* @ingroup arch
|
2013-03-13 21:56:56 +01:00
|
|
|
* @defgroup native_cpu Native CPU
|
2013-03-06 10:29:49 +01:00
|
|
|
* @{
|
|
|
|
* @author Ludwig Ortmann <ludwig.ortmann@fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
2013-03-06 01:08:15 +01:00
|
|
|
#ifndef _CPU_H
|
|
|
|
#define _CPU_H
|
|
|
|
|
2013-06-03 13:10:42 +02:00
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
/* enable signal handler register access on different platforms
|
|
|
|
* check here for more:
|
|
|
|
* http://sourceforge.net/p/predef/wiki/OperatingSystems/
|
|
|
|
*/
|
|
|
|
#ifdef BSD // BSD = (FreeBSD, Darwin, ...)
|
2013-05-15 17:45:43 +02:00
|
|
|
#define _XOPEN_SOURCE
|
2013-06-03 13:10:42 +02:00
|
|
|
#elif defined(__linux__)
|
|
|
|
#define __USE_GNU
|
2013-05-15 17:45:43 +02:00
|
|
|
#endif
|
2013-03-06 01:08:15 +01:00
|
|
|
#include <ucontext.h>
|
2013-06-03 13:10:42 +02:00
|
|
|
#ifdef BSD
|
2013-05-15 17:45:43 +02:00
|
|
|
#undef _XOPEN_SOURCE
|
2013-06-03 13:10:42 +02:00
|
|
|
#elif defined(__linux__)
|
|
|
|
#undef __USE_GNU
|
2013-05-15 17:45:43 +02:00
|
|
|
#endif
|
2013-03-06 01:08:15 +01:00
|
|
|
|
|
|
|
#include "kernel_intern.h"
|
|
|
|
#include "sched.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include "cpu-conf.h"
|
|
|
|
|
|
|
|
/* TODO: choose better value? */
|
|
|
|
#define F_CPU 1000000
|
|
|
|
|
|
|
|
void dINT(void);
|
|
|
|
void eINT(void);
|
|
|
|
|
2013-03-13 21:56:56 +01:00
|
|
|
/**
|
|
|
|
* register interrupt handler handler for interrupt sig
|
|
|
|
*/
|
2013-03-06 01:08:15 +01:00
|
|
|
int register_interrupt(int sig, void *handler);
|
2013-03-13 21:56:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* unregister interrupt handler for interrupt sig
|
|
|
|
*/
|
2013-03-06 01:08:15 +01:00
|
|
|
int unregister_interrupt(int sig);
|
2013-03-13 21:56:56 +01:00
|
|
|
|
|
|
|
/* this should be defined elsewhere */
|
2013-03-06 01:08:15 +01:00
|
|
|
void thread_yield(void);
|
|
|
|
|
2013-05-14 18:31:47 +02:00
|
|
|
extern void _native_sig_leave_tramp(void);
|
|
|
|
extern ucontext_t *_native_cur_ctx, *_native_isr_ctx;
|
|
|
|
extern unsigned int _native_saved_eip;
|
|
|
|
extern int _native_in_isr;
|
|
|
|
extern int _native_in_syscall;
|
|
|
|
extern int _native_sigpend;
|
2013-03-13 21:56:56 +01:00
|
|
|
/** @} */
|
2013-03-06 01:08:15 +01:00
|
|
|
#endif //_CPU_H
|