X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcfg%2Fos.h;h=2089cc4fc1e977b69333b09ce7214a9d1339d12f;hb=32d1445272120a254d77ce8d1af1f527da7a2c17;hp=c29bd59ea5df387b8ca6cc9a96c2ad872d26b6d9;hpb=4893c48a2b4ec84cf94ff75cefde767ca26bcf6e;p=bertos.git diff --git a/bertos/cfg/os.h b/bertos/cfg/os.h index c29bd59e..2089cc4f 100644 --- a/bertos/cfg/os.h +++ b/bertos/cfg/os.h @@ -27,22 +27,19 @@ * the GNU General Public License. * * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/) - * + * Copyright 2008 Bernie Innocenti * --> * * \brief OS-specific definitions * * \version $Id$ - * * \author Bernie Innocenti */ -#ifndef DEVLIB_OS_H -#define DEVLIB_OS_H +#ifndef CFG_OS_H +#define CFG_OS_H -/** Macro to include OS-specific versions of the headers. */ -#define OS_HEADER(module) PP_STRINGIZE(emul/PP_CAT3(module, _, OS_ID).h) -#define OS_CSOURCE(module) PP_STRINGIZE(emul/PP_CAT3(module, _, OS_ID).c) +#include "cfg/cfg_proc.h" /* * OS autodetection (Some systems trigger multiple OS definitions) @@ -52,11 +49,11 @@ #define OS_ID win32 // FIXME: Maybe disable Win32 exceptions? - typedef int cpuflags_t; - #define IRQ_DISABLE /* FIXME */ - #define IRQ_ENABLE /* FIXME */ - #define IRQ_SAVE_DISABLE(old_sigs) /* FIXME */ - #define IRQ_RESTORE(old_sigs) /* FIXME */ + typedef int cpu_flags_t; + #define IRQ_DISABLE FIXME + #define IRQ_ENABLE FIXME + #define IRQ_SAVE_DISABLE(old_sigs) FIXME + #define IRQ_RESTORE(old_sigs) FIXME #else #define OS_WIN32 0 @@ -71,7 +68,7 @@ * The POSIX moral equivalent of disabling IRQs is disabling signals. */ #include - typedef sigset_t cpuflags_t; + typedef sigset_t cpu_flags_t; #define SET_ALL_SIGNALS(sigs) \ do { \ @@ -114,6 +111,40 @@ sigismember(&sigs__, SIGALRM) ? false : true; \ }) + #if CONFIG_KERN_PREEMPT + #define DECLARE_ISR_CONTEXT_SWITCH(vect) \ + void vect(UNUSED_ARG(int, arg)); \ + INLINE void __isr_##vect(void); \ + void vect(UNUSED_ARG(int, arg)) \ + { \ + __isr_##vect(); \ + IRQ_PREEMPT_HANDLER(); \ + } \ + INLINE void __isr_##vect(void) + /** + * With task priorities enabled each ISR is used a point to + * check if we need to perform a context switch. + * + * Instead, without priorities a context switch can occur only + * when the running task expires its time quantum. In this last + * case, the context switch can only occur in the timer ISR, + * that must be always declared with the + * DECLARE_ISR_CONTEXT_SWITCH() macro. + */ + #if CONFIG_KERN_PRI + #define DECLARE_ISR(vect) \ + DECLARE_ISR_CONTEXT_SWITCH(vect) + #endif /* CONFIG_KERN_PRI */ + #endif + #ifndef DECLARE_ISR + #define DECLARE_ISR(vect) \ + void vect(UNUSED_ARG(int, arg)) + #endif + #ifndef DECLARE_ISR_CONTEXT_SWITCH + #define DECLARE_ISR_CONTEXT_SWITCH(vect) \ + void vect(UNUSED_ARG(int, arg)) + #endif + #else #define OS_UNIX 0 #define OS_POSIX 0 @@ -131,6 +162,9 @@ #define OS_DARWIN 0 #endif + +#include "cfg/cfg_arch.h" /* For ARCH_QT */ + /* * We want Qt and other frameworks to look like OSes because you would * tipically want their portable abstractions if you're using one of these. @@ -169,4 +203,18 @@ #error Neither hosted nor embedded OS environment #endif -#endif /* DEVLIB_OS_H */ +#if OS_HOSTED + + /// Macro to include OS-specific headers. + #define OS_HEADER(module) PP_STRINGIZE(emul/PP_CAT3(module, _, OS_ID).h) + + /// Macro to include OS-specific source files. + #define OS_CSOURCE(module) PP_STRINGIZE(emul/PP_CAT3(module, _, OS_ID).c) + +#else + // Fallbacks for embedded systems + #define OS_HEADER(module) CPU_HEADER(module) + #define OS_CSOURCE(module) CPU_CSOURCE(module) +#endif + +#endif /* CFG_OS_H */