+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001,2002,2003 Bernardo Innocenti <bernie@codewiz.org>
- * This file is part of DevLib - See devlib/README for information.
- * -->
- *
- * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- *
- * \brief Set system configuration
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.3 2004/08/25 14:12:08 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 17:48:35 bernie
- *#* Add top-level files.
- *#*
- *#*/
-
-#ifndef ARCH_CONFIG_H
-#define ARCH_CONFIG_H
-
-/*!
- * \name Architectures
- * \{
- */
-#error Add project-specific architectures
-#define ARCH_FOO (1<<0)
-#define ARCH_BAR (1<<1)
-#define ARCH_EMUL (1<<8)
-/*\}*/
-
-#endif /* ARCH_CONFIG_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2001,2002,2003 Bernardo Innocenti <bernie@codewiz.org>
+ * This file is part of DevLib - See devlib/README for information.
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ *
+ * \brief Set system configuration
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.3 2004/08/25 14:12:08 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 17:48:35 bernie
+ *#* Add top-level files.
+ *#*
+ *#*/
+
+#ifndef ARCH_CONFIG_H
+#define ARCH_CONFIG_H
+
+/*!
+ * \name Architectures
+ * \{
+ */
+#error Add project-specific architectures
+#define ARCH_FOO (1<<0)
+#define ARCH_BAR (1<<1)
+#define ARCH_EMUL (1<<8)
+/*\}*/
+
+#endif /* ARCH_CONFIG_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2001, 2002, 2003 Bernardo Innocenti <bernie@codewiz.org>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Additional support macros for compiler independance
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.44 2005/03/29 06:39:59 bernie
+ *#* setjmp.h, time_t: Remove ancient retrocompatibility; Remove MSVC double to float hack.
+ *#*
+ *#* Revision 1.43 2005/03/01 23:15:12 bernie
+ *#* Remove compatibility hack.
+ *#*
+ *#* Revision 1.42 2005/02/16 20:28:46 bernie
+ *#* Move PGM macros to mware/pgm.h
+ *#*
+ *#* Revision 1.41 2005/01/22 04:19:22 bernie
+ *#* MTIME_INFINITE: New constant.
+ *#*
+ *#* Revision 1.40 2005/01/20 18:46:04 aleph
+ *#* Add progmem datatypes; PSTR() definition.
+ *#*/
+#ifndef DEVLIB_COMPILER_H
+#define DEVLIB_COMPILER_H
+
+#include "cpu_detect.h"
+
+
+#if defined __GNUC__ && defined __GNUC_MINOR__
+ #define GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+ #define GNUC_PREREQ(maj, min) 0
+#endif
+
+/* Some CW versions do not allow enabling C99 from the settings panel. */
+#if defined(__MWERKS__)
+ #pragma c99 on
+#endif
+
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+ #define COMPILER_C99 1
+#else
+ #define COMPILER_C99 0
+#endif
+
+
+/*! Concatenate two different preprocessor tokens (allowing macros to expand) */
+#define PP_CAT(x,y) PP_CAT__(x,y)
+#define PP_CAT__(x,y) x ## y
+#define PP_CAT3(x,y,z) PP_CAT(PP_CAT(x,y),z)
+#define PP_CAT4(x,y,z,w) PP_CAT(PP_CAT3(x,y,z),w)
+#define PP_CAT5(x,y,z,w,j) PP_CAT(PP_CAT4(x,y,z,w),j)
+
+/*! String-ize a token (allowing macros to expand) */
+#define PP_STRINGIZE(x) PP_STRINGIZE__(x)
+#define PP_STRINGIZE__(x) #x
+
+
+#if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
+ #pragma language=extended
+ #define INTERRUPT(x) interrupt [x]
+ #define REGISTER shortad
+ #define INLINE /* unsupported */
+
+ /*
+ * Imported from <longjmp.h>. Unfortunately, we can't just include
+ * this header because it typedefs jmp_buf to be an array of chars.
+ * This would allow the compiler to place the buffer on an odd address.
+ * The CPU _should_ be able to perform word accesses to
+ * unaligned data, but there are *BUGS* in the 80196KC with
+ * some combinations of opcodes and addressing modes. One of
+ * these, "ST SP,[?GR]+" is used in the longjmp() implementation
+ * provided by the IAR compiler ANSI C library. When ?GR contains
+ * an odd address, surprisingly the CPU will copy the high order
+ * byte of the source operand (SP) in the low order byte of the
+ * destination operand (the memory location pointed to by ?GR).
+ *
+ * We also need to replace the library setjmp()/longjmp() with
+ * our own versions because the IAR implementation "forgets" to
+ * save the contents of local registers (?LR).
+ */
+ struct _JMP_BUF
+ {
+ void *sp; /* Stack pointer */
+ void *return_addr; /* Return address */
+ int lr[6]; /* 6 local registers */
+ };
+
+ typedef struct _JMP_BUF jmp_buf[1];
+
+ int setjmp(jmp_buf env);
+ void longjmp(jmp_buf env, int val);
+
+ /* Fake bool support */
+ #define true (1==1)
+ #define false (1!=1)
+ typedef unsigned char bool;
+
+#elif defined(_MSC_VER) /* Win32 emulation support */
+
+ /* MSVC doesn't provide <stdbool.h>. */
+ #ifndef __cplusplus
+ #define true (1==1)
+ #define false (1!=1)
+ typedef int bool;
+ #endif /* !__cplusplus */
+
+ /* These C99 functions are oddly named in MSVCRT32.lib */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
+
+#elif defined(__GNUC__)
+
+ /* Compiler features */
+ #define COMPILER_VARIADIC_MACROS 1 /* Even in C++ */
+ #define COMPILER_TYPEOF 1
+ #define COMPILER_STATEMENT_EXPRESSIONS 1
+
+ /* GCC attributes */
+ #define FORMAT(type,fmt,first) __attribute__((__format__(type, fmt, first)))
+ #define NORETURN __attribute__((__noreturn__))
+ #define UNUSED_ARG(type,arg) __attribute__((__unused__)) type arg
+ #define UNUSED_VAR(type,name) __attribute__((__unused__)) type name
+ #define USED_VAR(type,name) __attribute__((__used__)) type name
+ #define INLINE static inline __attribute__((__always_inline__))
+ #define LIKELY(x) __builtin_expect(!!(x), 1)
+ #define UNLIKELY(x) __builtin_expect(!!(x), 0)
+ #define PURE_FUNC __attribute__((pure))
+ #define CONST_FUNC __attribute__((const))
+ #define UNUSED_FUNC __attribute__((unused))
+ #define USED_FUNC __attribute__((__used__))
+ #define RESTRICT __restrict__
+ #define MUST_CHECK __attribute__((warn_unused_result))
+ #if GNUC_PREREQ(3,1)
+ #define DEPRECATED __attribute__((__deprecated__))
+ #endif
+
+ #if CPU_AVR
+ #include <stddef.h>
+ #include <stdbool.h>
+ #else
+ /* Include some standard C89/C99 stuff */
+ #include <stddef.h>
+ #include <stdbool.h>
+ #endif
+
+ #ifndef __cplusplus
+ /*
+ * Disallow some C++ keywords as identifiers in C programs,
+ * for improved portability.
+ */
+ #pragma GCC poison new delete class template typename
+ #pragma GCC poison private protected public operator
+ #pragma GCC poison friend mutable using namespace
+ #pragma GCC poison cin cout cerr clog
+ #endif
+
+#elif defined(__MWERKS__) && CPU_DSP56K
+
+ /* Compiler features */
+ #define COMPILER_VARIADIC_MACROS 1
+ #define COMPILER_TYPEOF 1
+ #define COMPILER_STATEMENT_EXPRESSIONS 1
+
+ #define typeof __typeof__
+
+ #include <stdint.h>
+ #include <stddef.h>
+ #include <stdbool.h>
+
+ // CodeWarrior has size_t as built-in type, but does not define this symbol.
+ #define _SIZE_T_DEFINED
+
+#else
+ #error unknown compiler
+#endif
+
+
+/* Defaults for compiler extensions. */
+
+/*!
+ * \def COMPILER_VARIADIC_MACROS
+ * Support for macros with variable arguments.
+ */
+#ifndef COMPILER_VARIADIC_MACROS
+#define COMPILER_VARIADIC_MACROS (COMPILER_C99 != 0)
+#endif
+
+/*!
+ * \def COMPILER_TYPEOF
+ * Support for macros with variable arguments.
+ */
+#ifndef COMPILER_TYPEOF
+#define COMPILER_TYPEOF 0
+#endif
+
+/*!
+ * \def COMPILER_STATEMENT_EXPRESSIONS
+ * Support for macros with variable arguments.
+ */
+#ifndef COMPILER_STATEMENT_EXPRESSIONS
+#define COMPILER_STATEMENT_EXPRESSIONS 0
+#endif
+
+/* A few defaults for missing compiler features. */
+#ifndef INLINE
+#define INLINE static inline
+#endif
+#ifndef NORETURN
+#define NORETURN /* nothing */
+#endif
+#ifndef FORMAT
+#define FORMAT(type,fmt,first) /* nothing */
+#endif
+#ifndef DEPRECATED
+#define DEPRECATED /* nothing */
+#endif
+#ifndef UNUSED_ARG
+#define UNUSED_ARG(type,arg) type arg
+#endif
+#define UNUSED UNUSED_ARG /* OBSOLETE */
+#ifndef UNUSED_VAR
+#define UNUSED_VAR(type,name) type name
+#endif
+#ifndef USED_VAR
+#define USED_VAR(type,name) type name
+#endif
+#ifndef REGISTER
+#define REGISTER /* nothing */
+#endif
+#ifndef INTERRUPT
+#define INTERRUPT(x) ERROR_NOT_IMPLEMENTED
+#endif
+#ifndef LIKELY
+#define LIKELY(x) x
+#endif
+#ifndef UNLIKELY
+#define UNLIKELY(x) x
+#endif
+#ifndef PURE_FUNC
+#define PURE_FUNC /* nothing */
+#endif
+#ifndef CONST_FUNC
+#define CONST_FUNC /* nothing */
+#endif
+#ifndef UNUSED_FUNC
+#define UNUSED_FUNC /* nothing */
+#endif
+#ifndef USED_FUNC
+#define USED_FUNC /* nothing */
+#endif
+#ifndef RESTRICT
+#define RESTRICT /* nothing */
+#endif
+#ifndef MUST_CHECK
+#define MUST_CHECK /* nothing */
+#endif
+
+/* Misc definitions */
+#ifndef NULL
+#define NULL (void *)0
+#endif
+#ifndef EOF
+#define EOF (-1)
+#endif
+
+
+/* Support for hybrid C/C++ applications. */
+#ifdef __cplusplus
+ #define EXTERN_C extern "C"
+ #define EXTERN_C_BEGIN extern "C" {
+ #define EXTERN_C_END }
+#else
+ #define EXTERN_C extern
+ #define EXTERN_C_BEGIN /* nothing */
+ #define EXTERN_C_END /* nothing */
+#endif
+
+
+#if (defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__))
+ /*!
+ * \name ISO C99 fixed-size types
+ *
+ * These should be in <stdint.h>, but many compilers lack them.
+ * \{
+ */
+ typedef signed char int8_t;
+ typedef short int int16_t;
+ typedef long int int32_t;
+ typedef unsigned char uint8_t;
+ typedef unsigned short int uint16_t;
+ typedef unsigned long int uint32_t;
+ /* \} */
+#elif defined(__GNUC__) && CPU_AVR
+ /* avr-libc is weird... */
+ #include <inttypes.h>
+#else
+ /* This is the correct location. */
+ #include <stdint.h>
+#endif
+
+#if CPU_AVR_ATMEGA8
+ /*
+ * The ATmega8 has a very small Flash, so we can't afford
+ * to link in support routines for 32bit integer arithmetic.
+ */
+ typedef int16_t mtime_t; /*!< Type for time expressed in milliseconds. */
+ typedef int16_t utime_t; /*!< Type for time expressed in microseconds. */
+ #define SIZEOF_MTIME_T (16 / CPU_BITS_PER_CHAR)
+ #define SIZEOF_UTIME_T (16 / CPU_BITS_PER_CHAR)
+ #define MTIME_INFINITE 0x7FFFL
+#else
+ typedef int32_t mtime_t; /*!< Type for time expressed in milliseconds. */
+ typedef int32_t utime_t; /*!< Type for time expressed in microseconds. */
+ #define SIZEOF_MTIME_T (32 / CPU_BITS_PER_CHAR)
+ #define SIZEOF_UTIME_T (32 / CPU_BITS_PER_CHAR)
+ #define MTIME_INFINITE 0x7FFFFFFFL
+#endif
+
+/*! Bulk storage large enough for both pointers or integers. */
+typedef void * iptr_t;
+typedef const void * const_iptr_t;
+
+typedef unsigned char sig_t; /*!< Type for signal bits. */
+typedef unsigned char sigmask_t; /*!< Type for signal masks. */
+typedef unsigned char page_t; /*!< Type for banked memory pages. */
+
+
+/*!
+ * \name Standard type definitions.
+ *
+ * These should be in <sys/types.h> or <stddef.h>, but many compilers
+ * and C libraries lack them.
+ *
+ * We check for some common definitions to avoid redefinitions:
+ *
+ * glibc, avr-libc: _SIZE_T_DEFINED
+ * Darwin libc: _BSD_SIZE_T_DEFINED_
+ *
+ * \{
+ */
+#if !(defined(size_t) || defined(_SIZE_T_DEFINED) || defined(_BSD_SIZE_T_DEFINED_))
+ #if CPU_REG_BITS > 32
+ /* 64bit. */
+ typedef unsigned long size_t;
+ typedef long ssize_t;
+ #else
+ /* 32bit or 16bit. */
+ typedef unsigned int size_t;
+ typedef int ssize_t;
+ #endif
+#endif
+/*\}*/
+
+
+/*!
+ * \name Types for hardware registers.
+ *
+ * Only use these types for registers whose contents can
+ * be changed asynchronously by external hardware.
+ *
+ * \{
+ */
+#if CPU_DSP56K
+ /* Registers can be accessed only through 16-bit pointers */
+ typedef volatile uint16_t reg16_t;
+#else
+ typedef volatile uint8_t reg8_t;
+ typedef volatile uint16_t reg16_t;
+ typedef volatile uint32_t reg32_t;
+#endif
+/*\}*/
+
+
+/* Quasi-ANSI macros */
+#ifndef offsetof
+ /*!
+ * Return the byte offset of the member \a m in struct \a s.
+ *
+ * \note This macro should be defined in "stddef.h" and is sometimes
+ * compiler-specific (g++ has a builtin for it).
+ */
+ #define offsetof(s,m) (size_t)&(((s *)0)->m)
+#endif
+#ifndef countof
+ /*!
+ * Count the number of elements in the static array \a a.
+ *
+ * \note This macro is non-standard, but implements a very common idiom
+ */
+ #define countof(a) (sizeof(a) / sizeof(*(a)))
+#endif
+
+/*! Issue a compilation error if the \a condition is false */
+#define STATIC_ASSERT(condition) \
+ UNUSED_VAR(extern char,PP_CAT(CT_ASSERT___, __LINE__)[(condition) ? 1 : -1])
+
+#endif /* DEVLIB_COMPILER_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief DevLib configuration options
+ *
+ * You should copy this header in your project and rename it to
+ * "config.h" and delete the CONFIG_ macros for the modules
+ * you're not using.
+ *
+ * <h2>Working with multiple applications</h2>
+ *
+ * If your project is made of multiple DevLib-based applications,
+ * create a custom "config.h" file in each application subdirectory
+ * and play with the compiler include path to get the desired result.
+ * You can share common options by creationg a "config_common.h" header
+ * and including it from all your "config.h" copies.
+ *
+ * <h2>Configuration style</h2>
+ *
+ * For improved compile-time checking of configuration options,
+ * the preferred way to use a \c CONFIG_ symbol is keeping it
+ * always defined with a value of either 0 or 1. This lets
+ * you write tests like this:
+ *
+ * \code
+ * #if CONFIG_FOO
+ * void foo(void)
+ * {
+ * if (CONFIG_BAR)
+ * bar();
+ * }
+ * #endif // CONFIG_FOO
+ * \endcode
+ *
+ * In most cases, we rely on the optimizer to discard checks
+ * on constant values and performing dead-code elimination.
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.5 2004/12/08 08:04:28 bernie
+ *#* Add missing config options.
+ *#*
+ *#* Revision 1.4 2004/08/25 14:12:08 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.3 2004/08/24 14:30:11 bernie
+ *#* Use new-style config macros for drv/timer.c
+ *#*
+ *#* Revision 1.2 2004/08/05 18:46:52 bernie
+ *#* Documentation improvements.
+ *#*
+ *#* Revision 1.1 2004/07/29 23:34:32 bernie
+ *#* Add template configuration file.
+ *#*
+ *#*/
+
+#ifndef CONFIG_COMMON_H
+#define CONFIG_COMMON_H
+
+/*! Baud-rate for the kdebug console */
+#define CONFIG_KDEBUG_BAUDRATE 19200
+
+/*!
+ * printf()-style formatter configuration.
+ *
+ * \sa PRINTF_DISABLED
+ * \sa PRINTF_NOMODIFIERS
+ * \sa PRINTF_REDUCED
+ * \sa PRINTF_NOFLOAT
+ * \sa PRINTF_FULL
+ */
+#define CONFIG_PRINTF PRINTF_FULL
+
+/*!
+ * Multithreading kernel
+ *
+ * /sa config_kernel.h
+ */
+#define CONFIG_KERNEL 0
+
+/*!
+ * \name Serial driver parameters
+ * \{
+ */
+ /*! Size of the outbound FIFO buffer for all ports (bytes) */
+ #define CONFIG_SER_TXBUFSIZE 32
+ /*! Size of the inbound FIFO buffer for all ports (bytes) */
+ #define CONFIG_SER_RXBUFSIZE 64
+
+ /*! Default transmit timeout (ms). Set to -1 to disable timeout support */
+ #define CONFIG_SER_TXTIMEOUT -1
+ /*! Default receive timeout (ms). Set to -1 to disable timeout support */
+ #define CONFIG_SER_RXTIMEOUT -1
+
+ /*! Use RTS/CTS handshake */
+ #define CONFIG_SER_HWHANDSHAKE 0
+
+ /*! Default baud rate (set to 0 to disable) */
+ #define CONFIG_SER_DEFBAUDRATE 0
+
+ /*! Enable ser_gets() and ser_gets_echo() */
+ #define CONFIG_SER_GETS 0
+
+ /*!
+ * Transmit always something on serial port 0 TX
+ * to avoid interference when sending burst of data,
+ * using AVR multiprocessor serial mode
+ */
+ #define CONFIG_SER_TXFILL 0
+
+ #define CONFIG_SER_STROBE 0
+/*\}*/
+
+/*!
+ * \name KBus configuration
+ * \{
+ */
+ /*! Board address for KBus */
+ #define CONFIG_KBUS_ADDR KBUS_ADDR_FOOBAR
+
+ /*! Disable KBUS escaping support */
+ #define CONFIG_KBUS_ESCAPE 0
+
+ /*! Serial port for internal KBUS communication */
+ #define CONFIG_KBUS_PORT 0
+
+ /*! Serial port speed for KBus communication */
+ #define CONFIG_KBUS_BAUDRATE 19200
+/*\}*/
+
+//! Hardware timer selection for drv/timer.c
+#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE2
+
+#define CONFIG_TIMER_STROBE 0
+
+//! EEPROM type for drv/eeprom.c
+#define CONFIG_EEPROM_TYPE EEPROM_24XX256
+
+#endif /* CONFIG_COMMON_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2001,2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See devlib/README for information.
+ * -->
+ *
+ * \brief Kernel configuration parameters
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.5 2004/08/25 14:12:08 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.4 2004/08/24 16:19:38 bernie
+ *#* Add missing header.
+ *#*
+ *#* Revision 1.3 2004/07/30 14:24:16 rasky
+ *#* Task switching con salvataggio perfetto stato di interrupt (SR)
+ *#* Kernel monitor per dump informazioni su stack dei processi
+ *#*
+ *#* Revision 1.2 2004/06/03 11:27:09 bernie
+ *#* Add dual-license information.
+ *#*
+ *#* Revision 1.1 2004/05/23 17:48:35 bernie
+ *#* Add top-level files.
+ *#*
+ *#*/
+#ifndef CONFIG_KERN_H
+#define CONFIG_KERN_H
+
+#include <arch_config.h> /* ARCH_EMUL */
+
+/*!
+ * \name Modules activation
+ *
+ * \{
+ */
+/* Module/option Active Dependencies */
+#define CONFIG_KERN_SCHED (1)
+#define CONFIG_KERN_SIGNALS (1 && CONFIG_KERN_SCHED)
+#define CONFIG_KERN_TIMER (1)
+#define CONFIG_KERN_HEAP (0)
+#define CONFIG_KERN_SEMAPHORES (0 && CONFIG_KERN_SIGNALS)
+#define CONFIG_KERN_MONITOR (1 && CONFIG_KERN_SCHED)
+/*\}*/
+
+/* EXPERIMENTAL */
+#define CONFIG_KERN_PREEMPTIVE (0 && CONFIG_KERN_SCHED && CONFIG_KERN_TIMER)
+
+
+#define CONFIG_KERN_HEAPSIZE 0x4000 /*!< Heap size (16KB) */
+#define CONFIG_KERN_QUANTUM 50 /*!< Scheduler time sharing quantum in ticks */
+
+#if (ARCH & ARCH_EMUL)
+ #define CONFIG_KERN_DEFSTACKSIZE 65536
+#else
+ #define CONFIG_KERN_DEFSTACKSIZE 128 /*!< Default stack size for each thread */
+#endif
+
+/* Memory fill codes to help debugging */
+#if CONFIG_KERN_MONITOR
+ #define CONFIG_KERN_STACKFILLCODE 0xA5A5
+ #define CONFIG_KERN_MEMFILLCODE 0xDBDB
+#endif
+
+
+#endif /* CONFIG_KERN_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief DevLib configuration options
+ *
+ * You should copy this header in your project and rename it to
+ * "config.h" and delete the CONFIG_ macros for the modules
+ * you're not using.
+ *
+ * <h2>Working with multiple applications</h2>
+ *
+ * If your project is made of multiple DevLib-based applications,
+ * create a custom "config.h" file in each application subdirectory
+ * and play with the compiler include path to get the desired result.
+ * You can share common options by creationg a "config_common.h" header
+ * and including it from all your "config.h" copies.
+ *
+ * <h2>Configuration style</h2>
+ *
+ * For improved compile-time checking of configuration options,
+ * the preferred way to use a \c CONFIG_ symbol is keeping it
+ * always defined with a value of either 0 or 1. This lets
+ * you write tests like this:
+ *
+ * \code
+ * #if CONFIG_FOO
+ * void foo(void)
+ * {
+ * if (CONFIG_BAR)
+ * bar();
+ * }
+ * #endif // CONFIG_FOO
+ * \endcode
+ *
+ * In most cases, we rely on the optimizer to discard checks
+ * on constant values and performing dead-code elimination.
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.5 2004/12/08 08:04:28 bernie
+ *#* Add missing config options.
+ *#*
+ *#* Revision 1.4 2004/08/25 14:12:08 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.3 2004/08/24 14:30:11 bernie
+ *#* Use new-style config macros for drv/timer.c
+ *#*
+ *#* Revision 1.2 2004/08/05 18:46:52 bernie
+ *#* Documentation improvements.
+ *#*
+ *#* Revision 1.1 2004/07/29 23:34:32 bernie
+ *#* Add template configuration file.
+ *#*
+ *#*/
+
+#ifndef CONFIG_COMMON_H
+#define CONFIG_COMMON_H
+
+/*! Baud-rate for the kdebug console */
+#define CONFIG_KDEBUG_BAUDRATE 19200
+
+/*!
+ * printf()-style formatter configuration.
+ *
+ * \sa PRINTF_DISABLED
+ * \sa PRINTF_NOMODIFIERS
+ * \sa PRINTF_REDUCED
+ * \sa PRINTF_NOFLOAT
+ * \sa PRINTF_FULL
+ */
+#define CONFIG_PRINTF PRINTF_FULL
+
+/*!
+ * Multithreading kernel
+ *
+ * /sa config_kernel.h
+ */
+#define CONFIG_KERNEL 0
+
+/*!
+ * \name Serial driver parameters
+ * \{
+ */
+ /*! Size of the outbound FIFO buffer for all ports (bytes) */
+ #define CONFIG_SER_TXBUFSIZE 32
+ /*! Size of the inbound FIFO buffer for all ports (bytes) */
+ #define CONFIG_SER_RXBUFSIZE 64
+
+ /*! Default transmit timeout (ms). Set to -1 to disable timeout support */
+ #define CONFIG_SER_TXTIMEOUT -1
+ /*! Default receive timeout (ms). Set to -1 to disable timeout support */
+ #define CONFIG_SER_RXTIMEOUT -1
+
+ /*! Use RTS/CTS handshake */
+ #define CONFIG_SER_HWHANDSHAKE 0
+
+ /*! Default baud rate (set to 0 to disable) */
+ #define CONFIG_SER_DEFBAUDRATE 0
+
+ /*! Enable ser_gets() and ser_gets_echo() */
+ #define CONFIG_SER_GETS 0
+
+ /*!
+ * Transmit always something on serial port 0 TX
+ * to avoid interference when sending burst of data,
+ * using AVR multiprocessor serial mode
+ */
+ #define CONFIG_SER_TXFILL 0
+
+ #define CONFIG_SER_STROBE 0
+/*\}*/
+
+/*!
+ * \name KBus configuration
+ * \{
+ */
+ /*! Board address for KBus */
+ #define CONFIG_KBUS_ADDR KBUS_ADDR_FOOBAR
+
+ /*! Disable KBUS escaping support */
+ #define CONFIG_KBUS_ESCAPE 0
+
+ /*! Serial port for internal KBUS communication */
+ #define CONFIG_KBUS_PORT 0
+
+ /*! Serial port speed for KBus communication */
+ #define CONFIG_KBUS_BAUDRATE 19200
+/*\}*/
+
+//! Hardware timer selection for drv/timer.c
+#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE2
+
+#define CONFIG_TIMER_STROBE 0
+
+//! EEPROM type for drv/eeprom.c
+#define CONFIG_EEPROM_TYPE EEPROM_24XX256
+
+#endif /* CONFIG_COMMON_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2004 Giovanni Bajo
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief CPU-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Giovanni Bajo <rasky@develer.com>
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.30 2005/03/15 00:20:09 bernie
+ *#* BREAKPOINT, IRQ_RUNNING(), IRQ_GETSTATE(): New DSP56K macros.
+ *#*
+ *#* Revision 1.29 2005/02/16 20:33:24 bernie
+ *#* Preliminary PPC support.
+ *#*
+ *#* Revision 1.28 2004/12/31 17:39:41 bernie
+ *#* Fix documentation.
+ *#*
+ *#* Revision 1.27 2004/12/31 17:02:47 bernie
+ *#* IRQ_SAVE_DISABLE(), IRQ_RESTORE(): Add null stubs for x86.
+ *#*
+ *#* Revision 1.26 2004/12/13 12:08:12 bernie
+ *#* DISABLE_IRQSAVE, ENABLE_IRQRESTORE, DISABLE_INTS, ENABLE_INTS: Remove obsolete macros.
+ *#*
+ *#* Revision 1.25 2004/12/08 08:31:02 bernie
+ *#* CPU_HARVARD: Define to 1 for AVR and DSP56K.
+ *#*/
+#ifndef DEVLIB_CPU_H
+#define DEVLIB_CPU_H
+
+#include "compiler.h" /* for uintXX_t */
+
+
+/*!
+ * \name Macros for determining CPU endianness.
+ * \{
+ */
+#define CPU_BIG_ENDIAN 0x1234
+#define CPU_LITTLE_ENDIAN 0x3412
+/*\}*/
+
+/*! Macro to include cpu-specific versions of the headers. */
+#define CPU_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, CPU_ID).h)
+
+
+#if CPU_I196
+
+ #define NOP nop_instruction()
+ #define IRQ_DISABLE disable_interrupt()
+ #define IRQ_ENABLE enable_interrupt()
+
+ typedef uint16_t cpuflags_t; // FIXME
+ typedef unsigned int cpustack_t;
+
+ #define CPU_REG_BITS 16
+ #define CPU_REGS_CNT 16
+ #define CPU_STACK_GROWS_UPWARD 0
+ #define CPU_SP_ON_EMPTY_SLOT 0
+ #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
+ #define CPU_HARVARD 0
+
+#elif CPU_X86
+
+ #define NOP asm volatile ("nop")
+ #define IRQ_DISABLE /* nothing */
+ #define IRQ_ENABLE /* nothing */
+ #define IRQ_SAVE_DISABLE(x) /* nothing */
+ #define IRQ_RESTORE(x) /* nothing */
+
+ typedef uint32_t cpuflags_t; // FIXME
+ typedef uint32_t cpustack_t;
+
+ #define CPU_REG_BITS 32
+ #define CPU_REGS_CNT 7
+ #define CPU_STACK_GROWS_UPWARD 0
+ #define CPU_SP_ON_EMPTY_SLOT 0
+ #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
+ #define CPU_HARVARD 0
+
+#elif CPU_PPC
+ #define NOP asm volatile ("nop" ::)
+ #define IRQ_DISABLE FIXME
+ #define IRQ_ENABLE FIXME
+ #define IRQ_SAVE_DISABLE(x) FIXME
+ #define IRQ_RESTORE(x) FIXME
+ #define IRQ_GETSTATE() FIXME
+
+ typedef uint32_t cpuflags_t; // FIXME
+ typedef uint32_t cpustack_t; // FIXME
+
+ /* Register counts include SREG too */
+ #define CPU_REG_BITS (CPU_PPC32 ? 32 : 64)
+ #define CPU_REGS_CNT FIXME
+ #define CPU_SAVED_REGS_CNT FIXME
+ #define CPU_STACK_GROWS_UPWARD 0 //FIXME
+ #define CPU_SP_ON_EMPTY_SLOT 0 //FIXME
+ #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
+ #define CPU_HARVARD 0
+
+#elif CPU_DSP56K
+
+ #define NOP asm(nop)
+ #define BREAKPOINT asm(debug)
+ #define IRQ_DISABLE do { asm(bfset #0x0200,SR); asm(nop); } while (0)
+ #define IRQ_ENABLE do { asm(bfclr #0x0200,SR); asm(nop); } while (0)
+
+ #define IRQ_SAVE_DISABLE(x) \
+ do { (void)x; asm(move SR,x); asm(bfset #0x0200,SR); } while (0)
+ #define IRQ_RESTORE(x) \
+ do { (void)x; asm(move x,SR); } while (0)
+
+ static inline bool irq_running(void)
+ {
+ extern void *user_sp;
+ return !!user_sp;
+ }
+ #define IRQ_RUNNING() irq_running()
+
+ static inline bool irq_getstate(void)
+ {
+ uint16_t x;
+ asm(move SR,x);
+ return !(x & 0x0200);
+ }
+ #define IRQ_GETSTATE() irq_getstate()
+
+
+
+ typedef uint16_t cpuflags_t;
+ typedef unsigned int cpustack_t;
+
+ #define CPU_REG_BITS 16
+ #define CPU_REGS_CNT FIXME
+ #define CPU_SAVED_REGS_CNT 8
+ #define CPU_STACK_GROWS_UPWARD 1
+ #define CPU_SP_ON_EMPTY_SLOT 0
+ #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
+ #define CPU_HARVARD 1
+
+ /* Memory is word-addessed in the DSP56K */
+ #define CPU_BITS_PER_CHAR 16
+ #define SIZEOF_SHORT 1
+ #define SIZEOF_INT 1
+ #define SIZEOF_LONG 2
+ #define SIZEOF_PTR 1
+
+#elif CPU_AVR
+
+ #define NOP asm volatile ("nop" ::)
+ #define IRQ_DISABLE asm volatile ("cli" ::)
+ #define IRQ_ENABLE asm volatile ("sei" ::)
+
+ #define IRQ_SAVE_DISABLE(x) \
+ do { \
+ __asm__ __volatile__( \
+ "in %0,__SREG__\n\t" \
+ "cli" \
+ : "=r" (x) : /* no inputs */ : "cc" \
+ ); \
+ } while (0)
+
+ #define IRQ_RESTORE(x) \
+ do { \
+ __asm__ __volatile__( \
+ "out __SREG__,%0" : /* no outputs */ : "r" (x) : "cc" \
+ ); \
+ } while (0)
+
+ #define IRQ_GETSTATE() \
+ ({ \
+ uint8_t sreg; \
+ __asm__ __volatile__( \
+ "in %0,__SREG__\n\t" \
+ : "=r" (sreg) /* no inputs & no clobbers */ \
+ ); \
+ (bool)(sreg & 0x80); \
+ })
+
+ typedef uint8_t cpuflags_t;
+ typedef uint8_t cpustack_t;
+
+ /* Register counts include SREG too */
+ #define CPU_REG_BITS 8
+ #define CPU_REGS_CNT 33
+ #define CPU_SAVED_REGS_CNT 19
+ #define CPU_STACK_GROWS_UPWARD 0
+ #define CPU_SP_ON_EMPTY_SLOT 1
+ #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
+ #define CPU_HARVARD 1
+
+ /*!
+ * Initialization value for registers in stack frame.
+ * The register index is not directly corrispondent to CPU
+ * register numbers. Index 0 is the SREG register: the initial
+ * value is all 0 but the interrupt bit (bit 7).
+ */
+ #define CPU_REG_INIT_VALUE(reg) (reg == 0 ? 0x80 : 0)
+
+#endif
+
+/*!
+ * Execute \a CODE atomically with respect to interrupts.
+ *
+ * \see IRQ_SAVE_DISABLE IRQ_RESTORE
+ */
+#define ATOMIC(CODE) \
+ do { \
+ cpuflags_t __flags; \
+ IRQ_SAVE_DISABLE(__flags); \
+ CODE; \
+ IRQ_RESTORE(__flags); \
+ } while (0)
+
+
+//! Default for macro not defined in the right arch section
+#ifndef CPU_REG_INIT_VALUE
+ #define CPU_REG_INIT_VALUE(reg) 0
+#endif
+
+
+#ifndef CPU_STACK_GROWS_UPWARD
+ #error CPU_STACK_GROWS_UPWARD should have been defined to either 0 or 1
+#endif
+
+#ifndef CPU_SP_ON_EMPTY_SLOT
+ #error CPU_SP_ON_EMPTY_SLOT should have been defined to either 0 or 1
+#endif
+
+/*
+ * Support stack handling peculiarities of a few CPUs.
+ *
+ * Most processors let their stack grow downward and
+ * keep SP pointing at the last pushed value.
+ */
+#if !CPU_STACK_GROWS_UPWARD
+ #if !CPU_SP_ON_EMPTY_SLOT
+ /* Most microprocessors (x86, m68k...) */
+ #define CPU_PUSH_WORD(sp, data) \
+ do { *--(sp) = (data); } while (0)
+ #define CPU_POP_WORD(sp) \
+ (*(sp)++)
+ #else
+ /* AVR insanity */
+ #define CPU_PUSH_WORD(sp, data) \
+ do { *(sp)-- = (data); } while (0)
+ #define CPU_POP_WORD(sp) \
+ (*++(sp))
+ #endif
+
+#else /* CPU_STACK_GROWS_UPWARD */
+
+ #if !CPU_SP_ON_EMPTY_SLOT
+ /* DSP56K and other weirdos */
+ #define CPU_PUSH_WORD(sp, data) \
+ do { *++(sp) = (cpustack_t)(data); } while (0)
+ #define CPU_POP_WORD(sp) \
+ (*(sp)--)
+ #else
+ #error I bet you cannot find a CPU like this
+ #endif
+#endif
+
+
+#if CPU_DSP56K
+ /*
+ * DSP56k pushes both PC and SR to the stack in the JSR instruction, but
+ * RTS discards SR while returning (it does not restore it). So we push
+ * 0 to fake the same context.
+ */
+ #define CPU_PUSH_CALL_CONTEXT(sp, func) \
+ do { \
+ CPU_PUSH_WORD((sp), (func)); \
+ CPU_PUSH_WORD((sp), 0x100); \
+ } while (0);
+
+#elif CPU_AVR
+ /*
+ * In AVR, the addresses are pushed into the stack as little-endian, while
+ * memory accesses are big-endian (actually, it's a 8-bit CPU, so there is
+ * no natural endianess).
+ */
+ #define CPU_PUSH_CALL_CONTEXT(sp, func) \
+ do { \
+ uint16_t funcaddr = (uint16_t)(func); \
+ CPU_PUSH_WORD((sp), funcaddr); \
+ CPU_PUSH_WORD((sp), funcaddr>>8); \
+ } while (0)
+
+#else
+ #define CPU_PUSH_CALL_CONTEXT(sp, func) \
+ CPU_PUSH_WORD((sp), (func))
+#endif
+
+
+/*!
+ * \name Default type sizes.
+ *
+ * These defaults are reasonable for most 16/32bit machines.
+ * Some of these macros may be overridden by CPU-specific code above.
+ *
+ * ANSI C requires that the following equations be true:
+ * \code
+ * sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
+ * sizeof(float) <= sizeof(double)
+ * CPU_BITS_PER_CHAR >= 8
+ * CPU_BITS_PER_SHORT >= 8
+ * CPU_BITS_PER_INT >= 16
+ * CPU_BITS_PER_LONG >= 32
+ * \endcode
+ * \{
+ */
+#ifndef SIZEOF_CHAR
+#define SIZEOF_CHAR 1
+#endif
+
+#ifndef SIZEOF_SHORT
+#define SIZEOF_SHORT 2
+#endif
+
+#ifndef SIZEOF_INT
+#if CPU_REG_BITS < 32
+ #define SIZEOF_INT 2
+#else
+ #define SIZEOF_INT 4
+#endif
+#endif /* !SIZEOF_INT */
+
+#ifndef SIZEOF_LONG
+#if CPU_REG_BITS > 32
+ #define SIZEOF_LONG 8
+#else
+ #define SIZEOF_LONG 4
+#endif
+#endif
+
+#ifndef SIZEOF_PTR
+#define SIZEOF_PTR SIZEOF_INT
+#endif
+
+#ifndef CPU_BITS_PER_CHAR
+#define CPU_BITS_PER_CHAR (SIZEOF_CHAR * 8)
+#endif
+
+#ifndef CPU_BITS_PER_SHORT
+#define CPU_BITS_PER_SHORT (SIZEOF_SHORT * CPU_BITS_PER_CHAR)
+#endif
+
+#ifndef CPU_BITS_PER_INT
+#define CPU_BITS_PER_INT (SIZEOF_INT * CPU_BITS_PER_CHAR)
+#endif
+
+#ifndef CPU_BITS_PER_LONG
+#define CPU_BITS_PER_LONG (SIZEOF_LONG * CPU_BITS_PER_CHAR)
+#endif
+
+#ifndef CPU_BITS_PER_PTR
+#define CPU_BITS_PER_PTR (SIZEOF_PTR * CPU_BITS_PER_CHAR)
+#endif
+
+#ifndef BREAKPOINT
+#define BREAKPOINT /* nop */
+#endif
+
+/*\}*/
+
+/* Sanity checks for the above definitions */
+STATIC_ASSERT(sizeof(char) == SIZEOF_CHAR);
+STATIC_ASSERT(sizeof(short) == SIZEOF_SHORT);
+STATIC_ASSERT(sizeof(long) == SIZEOF_LONG);
+STATIC_ASSERT(sizeof(int) == SIZEOF_INT);
+
+
+/*!
+ * \def CPU_IDLE
+ *
+ * \brief Invoked by the scheduler to stop the CPU when idle.
+ *
+ * This hook can be redefined to put the CPU in low-power mode, or to
+ * profile system load with an external strobe, or to save CPU cycles
+ * in hosted environments such as emulators.
+ */
+#ifndef CPU_IDLE
+ #if defined(ARCH_EMUL) && (ARCH & ARCH_EMUL)
+ /* This emulator hook should yield the CPU to the host. */
+ EXTERN_C_BEGIN
+ void SchedulerIdle(void);
+ EXTERN_C_END
+ #define CPU_IDLE SchedulerIdle()
+ #else /* !ARCH_EMUL */
+ #define CPU_IDLE do { /* nothing */ } while (0)
+ #endif /* !ARCH_EMUL */
+#endif /* !CPU_IDLE */
+
+/* OBSOLETE */
+#define SCHEDULER_IDLE CPU_IDLE
+
+#endif /* DEVLIB_CPU_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2004 Giovanni Bajo
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief CPU detection through special preprocessor macros
+ *
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.4 2005/02/16 20:33:24 bernie
+ *#* Preliminary PPC support.
+ *#*
+ *#* Revision 1.3 2004/12/31 17:39:26 bernie
+ *#* Use C89 comments only.
+ *#*
+ *#* Revision 1.2 2004/08/25 14:12:08 rasky
+ *#* Aggiornato il comment block dei log RCS
+ *#*
+ *#* Revision 1.1 2004/07/30 17:14:49 rasky
+ *#* File sfuggito al commit precedente (nuova gestione unificata del detect della CPU
+ *#*
+ *#* Revision 1.2 2004/07/30 10:31:07 rasky
+ *#* Aggiunto detect per ATmega128
+ *#*/
+
+#ifndef CPU_DETECT_H
+#define CPU_DETECT_H
+
+#if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
+ #define CPU_I196 1
+ #define CPU_ID i196
+#else
+ #define CPU_I196 0
+#endif
+
+#if defined(__i386__) || defined(_MSC_VER)
+ #define CPU_X86 1
+ #define CPU_ID x86
+#else
+ #define CPU_X86 0
+#endif
+
+#if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
+ #define CPU_PPC 1
+ #define CPU_ID ppc
+ #if defined(_ARCH_PPC)
+ #define CPU_PPC32 1
+ #else
+ #define CPU_PPC32 0
+ #endif
+ #if defined(_ARCH_PPC64)
+ #define CPU_PPC64 1
+ #else
+ #define CPU_PPC64 0
+ #endif
+#else
+ #define CPU_PPC 0
+ #define CPU_PPC32 0
+ #define CPU_PPC64 0
+#endif
+
+#if defined(__m56800E__) || defined(__m56800__)
+ #define CPU_DSP56K 1
+ #define CPU_ID dsp56k
+#else
+ #define CPU_DSP56K 0
+#endif
+
+#if defined (__AVR__)
+ #define CPU_AVR 1
+ #define CPU_ID avr
+
+ #if defined(__AVR_ATmega64__)
+ #define CPU_AVR_ATMEGA64 1
+ #else
+ #define CPU_AVR_ATMEGA64 0
+ #endif
+
+ #if defined(__AVR_ATmega103__)
+ #define CPU_AVR_ATMEGA103 1
+ #else
+ #define CPU_AVR_ATMEGA103 0
+ #endif
+
+ #if defined(__AVR_ATmega128__)
+ #define CPU_AVR_ATMEGA128 1
+ #else
+ #define CPU_AVR_ATMEGA128 0
+ #endif
+
+ #if defined(__AVR_ATmega8__)
+ #define CPU_AVR_ATMEGA8 1
+ #else
+ #define CPU_AVR_ATMEGA8 0
+ #endif
+#else
+ #define CPU_AVR 0
+ #define CPU_AVR_ATMEGA8 0
+ #define CPU_AVR_ATMEGA64 0
+ #define CPU_AVR_ATMEGA103 0
+ #define CPU_AVR_ATMEGA128 0
+#endif
+
+
+/* Self-check for the detection: only one CPU must be detected */
+#if CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR == 0
+ #error Unknown CPU
+#elif !defined(CPU_ID)
+ #error CPU_ID not defined
+#elif CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR != 1
+ #error Internal CPU configuration error
+#endif
+
+
+#endif /* CPU_DETECT_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Simple debug facilities for hosted and embedded C/C++ applications.
+ *
+ * Debug output goes to stderr in hosted applications.
+ * Freestanding (AKA embedded) applications use \c drv/kdebug.c to output
+ * diagnostic messages to a serial terminal or a JTAG debugger.
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.13 2005/03/01 23:23:58 bernie
+ *#* Provide defaults for CONFIG_KDEBUG_DISABLE_TRACE and CONFIG_KDEBUG_ASSERT_NO_TEXT.
+ *#*
+ *#* Revision 1.12 2005/02/18 11:18:33 bernie
+ *#* Fixes for Harvard processors from project_ks.
+ *#*
+ *#* Revision 1.11 2005/02/16 20:29:48 bernie
+ *#* TRACE(), TRACEMSG(): Reduce code and data footprint.
+ *#*
+ *#* Revision 1.10 2005/02/09 21:50:28 bernie
+ *#* Declare dummy ASSERT* macros as ((void)0) to work around a warning I can't remember any more.
+ *#*
+ *#* Revision 1.9 2005/01/25 08:36:40 bernie
+ *#* kputnum(): Export.
+ *#*
+ *#* Revision 1.8 2005/01/11 18:08:08 aleph
+ *#* Add empty kdump definition for debug off
+ *#*
+ *#* Revision 1.7 2004/12/31 17:43:09 bernie
+ *#* Use UNUSED_ARG instead of obsolete UNUSED macro.
+ *#*
+ *#* Revision 1.6 2004/12/08 08:52:00 bernie
+ *#* Save some more RAM on AVR.
+ *#*/
+#ifndef DEVLIB_DEBUG_H
+#define DEVLIB_DEBUG_H
+
+/*
+ * Try to guess whether we're running in a hosted or embedded environment.
+ */
+#ifndef OS_HOSTED
+ #if defined(__unix__) || defined(_WIN32)
+ #define OS_HOSTED 1
+ #else
+ #define OS_HOSTED 0
+ #endif
+#endif /* !OS_HOSTED */
+
+#if OS_HOSTED
+ /*
+ * For now, avoid dependency on compiler.h
+ */
+ #ifndef FORMAT
+ #define FORMAT(x,y,z) /* nothing */
+ #endif
+ #ifndef INLINE
+ #define INLINE static inline
+ #endif
+ #ifndef UNUSED_ARG
+ #ifdef __cplusplus
+ #define UNUSED_ARG(type,name) type
+ #else
+ #define UNUSED_ARG(type,name) type name
+ #endif
+ #endif
+#else /* !OS_HOSTED */
+ #include <compiler.h>
+#endif /* !OS_HOSTED */
+
+
+/*
+ * Defaults for rarely used config stuff.
+ */
+#ifndef CONFIG_KDEBUG_DISABLE_TRACE
+#define CONFIG_KDEBUG_DISABLE_TRACE 0
+#endif
+
+#ifndef CONFIG_KDEBUG_ASSERT_NO_TEXT
+#define CONFIG_KDEBUG_ASSERT_NO_TEXT 0
+#endif
+
+
+/*!
+ * \def _DEBUG
+ *
+ * This preprocessor symbol is defined only in debug builds.
+ *
+ * The build infrastructure must arrange for _DEBUG to
+ * be prepredefined for all source files being compiled.
+ *
+ * This is compatible with the Microsoft convention for
+ * the default Debug and Release targets.
+ */
+#ifdef _DEBUG
+
+ // STLport specific: enable extra checks
+ #define __STL_DEBUG 1
+
+ // MSVC specific: Enable memory allocation debug
+ #if defined(_MSC_VER)
+ #include <crtdbg.h>
+ #endif
+
+ /*
+ * On UNIX systems the extabilished practice is to define
+ * NDEBUG for release builds and nothing for debug builds.
+ */
+ #ifdef NDEBUG
+ #undef NDEBUG
+ #endif
+
+ /*!
+ * This macro duplicates the old MSVC trick of redefining
+ * THIS_FILE locally to avoid the overhead of many duplicate
+ * strings in ASSERT().
+ */
+ #ifndef THIS_FILE
+ #define THIS_FILE __FILE__
+ #endif
+
+ /*!
+ * This macro can be used to conditionally exclude one or more
+ * statements conditioned on \c _DEBUG, avoiding the clutter
+ * of #ifdef/#endif pairs.
+ *
+ * \code
+ * struct FooBar
+ * {
+ * int foo;
+ * bool bar;
+ * DB(int ref_count;) // Track number of users
+ *
+ * void release()
+ * {
+ * DB(--ref_count;)
+ * }
+ * };
+ * \endcode
+ */
+ #define DB(x) x
+
+ #if OS_HOSTED
+ #include <stdio.h>
+ #include <stdarg.h>
+
+ INLINE void kdbg_init(void) { /* nop */ }
+ INLINE void kputchar(char c)
+ {
+ putc(c, stderr);
+ }
+ INLINE void kputs(const char *str)
+ {
+ fputs(str, stderr);
+ }
+ /* G++ can't inline functions with variable arguments... */
+ #define kprintf(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
+ void kdump(const void *buf, size_t len); /* UNIMPLEMENTED */
+
+ #ifndef ASSERT
+ #include <assert.h>
+ #define ASSERT(x) assert(x)
+ #endif /* ASSERT */
+
+ /*!
+ * Check that the given pointer is not NULL or pointing to raw memory.
+ *
+ * The assumption here is that valid pointers never point to low
+ * memory regions. This helps catching pointers taken from
+ * struct/class memebers when the struct pointer was NULL.
+ */
+ #define ASSERT_VALID_PTR(p) ASSERT((unsigned long)(p) > 0x200)
+
+ #define ASSERT_VALID_PTR_OR_NULL(p) ASSERT((((p) == NULL) || ((unsigned long)(p) >= 0x200)))
+ #else /* !OS_HOSTED */
+
+ #include <config.h> /* CONFIG_KDEBUG_ASSERT_NO_TEXT */
+ #include <cpu.h> /* CPU_HARVARD */
+
+ /* These are implemented in drv/kdebug.c */
+ void kdbg_init(void);
+ void kputchar(char c);
+ int kputnum(int num);
+ void kdump(const void *buf, size_t len);
+ void __init_wall(long *wall, int size);
+
+ #if CPU_HARVARD
+ #include <mware/pgm.h>
+ void kputs_P(const char *PROGMEM str);
+ void kprintf_P(const char *PROGMEM fmt, ...) FORMAT(__printf__, 1, 2);
+ int __assert_P(const char *PROGMEM cond, const char *PROGMEM file, int line);
+ void __trace_P(const char *func);
+ void __tracemsg_P(const char *func, const char *PROGMEM fmt, ...);
+ int __invalid_ptr_P(void *p, const char *PROGMEM name, const char *PROGMEM file, int line);
+ int __check_wall_P(long *wall, int size, const char * PGM_ATTR name, const char * PGM_ATTR file, int line);
+ #define kputs(str) kputs_P(PSTR(str))
+ #define kprintf(fmt, ...) kprintf_P(PSTR(fmt) ,## __VA_ARGS__)
+ #define __assert(cond, file, line) __assert_P(PSTR(cond), PSTR(file), (line))
+ #define __trace(func) __trace_P(func)
+ #define __tracemsg(func, fmt, ...) __tracemsg_P(func, PSTR(fmt), ## __VA_ARGS__)
+ #define __invalid_ptr(p, name, file, line) __invalid_ptr_P((p), PSTR(name), PSTR(file), (line))
+ #define __check_wall(wall, size, name, file, line) __check_wall_P(wall, size, PSTR(name), PSTR(file), (line))
+ #else /* !CPU_HARVARD */
+ void kputs(const char *str);
+ void kprintf(const char *fmt, ...) FORMAT(__printf__, 1, 2);
+ int __assert(const char *cond, const char *file, int line);
+ void __trace(const char *func);
+ void __tracemsg(const char *func, const char *fmt, ...) FORMAT(__printf__, 2, 3);
+ int __invalid_ptr(void *p, const char *name, const char *file, int line);
+ int __check_wall(long *wall, int size, const char *name, const char *file, int line);
+ #endif /* !CPU_HARVARD */
+
+ #if !CONFIG_KDEBUG_ASSERT_NO_TEXT
+ #define ASSERT(x) ((void)(LIKELY(x) ? 0 : __assert(#x, THIS_FILE, __LINE__)))
+ #define ASSERT2(x, help) ((void)(LIKELY(x) ? 0 : __assert(help " (" #x ")", THIS_FILE, __LINE__)))
+ #else
+ #define ASSERT(x) ((void)(LIKELY(x) ? 0 : __assert("", THIS_FILE, __LINE__)))
+ #define ASSERT2(x, help) ((void)ASSERT(x))
+ #endif
+
+ #define ASSERT_VALID_PTR(p) ((void)(LIKELY((p) >= 0x200) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__)))
+ #define ASSERT_VALID_PTR_OR_NULL(p) ((void)(LIKELY((p == NULL) || ((p) >= 0x200)) ? 0 : __invalid_ptr((p), #p, THIS_FILE, __LINE__)))
+
+ #if !CONFIG_KDEBUG_DISABLE_TRACE
+ #define TRACE __trace(__func__)
+ #define TRACEMSG(msg,...) __tracemsg(__func__, msg, ## __VA_ARGS__)
+ #else
+ #define TRACE do {} while(0)
+ #define TRACEMSG(...) do {} while(0)
+ #endif
+
+ #endif /* !OS_HOSTED */
+
+ /*!
+ * \name Walls to detect data corruption
+ * \{
+ */
+ #define WALL_SIZE 8
+ #define WALL_VALUE (long)0xABADCAFEL
+ #define DECLARE_WALL(name,size) long name[(size) / sizeof(long)];
+ #define FWD_DECLARE_WALL(name,size) extern long name[(size) / sizeof(long)];
+ #define INIT_WALL(name) __init_wall((name), countof(name))
+ #define CHECK_WALL(name) __check_wall((name), countof(name), #name, THIS_FILE, __LINE__)
+ /*\}*/
+
+ /*!
+ * Check that the given pointer actually points to an object
+ * of the specified type.
+ */
+ #define ASSERT_VALID_OBJ(_t, _o) do { \
+ ASSERT_VALID_PTR((_o)); \
+ ASSERT(dynamic_cast<_t>((_o)) != NULL); \
+ }
+
+ /*!
+ * \name Debug object creation and destruction.
+ *
+ * These macros help track some kinds of leaks in C++ programs.
+ * Usage is as follows:
+ *
+ * \code
+ * class Foo
+ * {
+ * DECLARE_INSTANCE_TRACKING(Foo)
+ *
+ * Foo()
+ * {
+ * NEW_INSTANCE(Foo);
+ * // ...
+ * }
+ *
+ * ~Foo()
+ * {
+ * DELETE_INSTANCE(Foo);
+ * // ...
+ * }
+ * };
+ *
+ * // Put this in the implementation file of the class
+ * IMPLEMENT_INSTANCE_TRACKING(Foo)
+ *
+ * // Client code
+ * int main(void)
+ * {
+ * Foo *foo = new Foo;
+ * cout << GET_INSTANCE_COUNT(Foo) << endl; // prints "1"
+ * delete foo;
+ * ASSERT_ZERO_INSTANCES(Foo); // OK
+ * }
+ * \endcode
+ * \{
+ */
+ #define NEW_INSTANCE(CLASS) do { ++CLASS::__instances } while (0)
+ #define DELETE_INSTANCE(CLASS) do { --CLASS::__instances } while (0)
+ #define ASSERT_ZERO_INSTANCES(CLASS) ASSERT(CLASS::__instances == 0)
+ #define GET_INSTANCE_COUNT(CLASS) (CLASS::__instances)
+ #define DECLARE_INSTANCE_TRACKING(CLASS) static int __instances
+ #define IMPLEMENT_INSTANCE_TRACKING(CLASS) int CLASS::__instances = 0
+ /*\}*/
+
+#else /* !_DEBUG */
+
+ /*
+ * On UNIX systems the extabilished practice is to define
+ * NDEBUG for release builds and nothing for debug builds.
+ */
+ #ifndef NDEBUG
+ #define NDEBUG 1
+ #endif
+
+ #define DB(x) /* nothing */
+ #ifndef ASSERT
+ #define ASSERT(x) ((void)0)
+ #endif /* ASSERT */
+ #define ASSERT2(x, help) ((void)0)
+ #define ASSERT_VALID_PTR(p) ((void)0)
+ #define ASSERT_VALID_PTR_OR_NULL(p) ((void)0)
+ #define ASSERT_VALID_OBJ(_t, _o) ((void)0)
+ #define TRACE do {} while (0)
+ #define TRACEMSG(x,...) do {} while (0)
+
+ #define DECLARE_WALL(name, size) /* nothing */
+ #define FWD_DECLARE_WALL(name, size) /* nothing */
+ #define INIT_WALL(name) do {} while (0)
+ #define CHECK_WALL(name) do {} while (0)
+
+ #define NEW_INSTANCE(CLASS) do {} while (0)
+ #define DELETE_INSTANCE(CLASS) do {} while (0)
+ #define ASSERT_ZERO_INSTANCES(CLASS) do {} while (0)
+ #define GET_INSTANCE_COUNT(CLASS) ERROR_ONLY_FOR_DEBUG
+ #define DECLARE_INSTANCE_TRACKING(CLASS)
+ #define IMPLEMENT_INSTANCE_TRACKING(CLASS)
+
+ INLINE void kdbg_init(void) { /* nop */ }
+ INLINE void kputchar(UNUSED_ARG(char, c)) { /* nop */ }
+ INLINE int kputnum(UNUSED_ARG(int, num)) { return 0; }
+ INLINE void kputs(UNUSED_ARG(const char *, str)) { /* nop */ }
+ INLINE void kdump(UNUSED_ARG(const void *, buf), UNUSED_ARG(size_t, len)) { /* nop */ }
+
+ #ifdef __cplusplus
+ /* G++ can't inline functions with variable arguments... */
+ #define kprintf(fmt,...) do { (void)(fmt); } while(0)
+ #else
+ /* ...but GCC can. */
+ INLINE void kprintf(UNUSED_ARG(const char *, fmt), ...) { /* nop */ }
+ #endif
+
+#endif /* _DEBUG */
+
+#endif /* DEVLIB_DEBUG_H */
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See devlib/README for information.
+ * -->
+ *
+ * \brief Common and handy function macros
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ * \author Giovanni Bajo <rasky@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.10 2005/01/22 04:19:50 bernie
+ *#* Use non-uglified typeof().
+ *#*
+ *#* Revision 1.9 2004/12/08 08:51:34 bernie
+ *#* Add type-generic macros for C++.
+ *#*
+ *#* Revision 1.8 2004/10/19 07:14:20 bernie
+ *#* Add macros to test for specific compiler features.
+ *#*
+ *#* Revision 1.7 2004/09/20 03:30:45 bernie
+ *#* C++ also has variadic macros.
+ *#*
+ *#* Revision 1.6 2004/09/14 21:02:04 bernie
+ *#* SWAP(), MINMAX(): New macros.
+ *#*
+ *#* Revision 1.5 2004/08/29 21:57:58 bernie
+ *#* Move back STATIC_ASSERT() to compiler.h as it's needed in cpu.h;
+ *#* iptr_t, const_iptr_t: Replace IPTR macro with a real typedef.
+ *#*
+ *#* Revision 1.3 2004/08/24 14:13:48 bernie
+ *#* Restore a few macros that were lost in the way.
+ *#*
+ *#* Revision 1.2 2004/08/24 13:32:14 bernie
+ *#* PP_CAT(), PP_STRINGIZE(): Move back to compiler.h to break circular dependency between cpu.h/compiler.h/macros.h;
+ *#* offsetof(), countof(): Move back to compiler.h to avoid including macros.h almost everywhere;
+ *#* Trim CVS log;
+ *#* Rename header guards;
+ *#* Don't include arch_config.h in compiler.h as it's not needed there.
+ *#*
+ *#* Revision 1.1 2004/08/14 19:37:57 rasky
+ *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
+ *#*
+ *#* Revision 1.4 2004/08/14 18:36:50 rasky
+ *#* Doxygen fix e un livello di parentesi aggiuntivi per la macro
+ *#*
+ *#* Revision 1.3 2004/08/12 20:01:32 rasky
+ *#* Aggiunte macro BIT_CHANGE e BIT_CHANGE_BV
+ *#*
+ *#* Revision 1.2 2004/08/10 21:36:14 rasky
+ *#* Aggiunto include macros.h dove serve
+ *#* Aggiunta dipendenza da compiler.h in macros.h
+ *#*
+ *#* Revision 1.1 2004/08/10 21:30:00 rasky
+ *#* Estratte le funzioni macro in macros.h
+ *#*
+ *#*/
+
+#ifndef MACROS_H
+#define MACROS_H
+
+#include <compiler.h>
+
+/* avr-gcc does not seem to support libstdc++ */
+#if defined(__cplusplus) && !CPU_AVR
+ /* Type-generic macros implemented with template functions. */
+ #include <algorithm>
+
+ template<class T> inline T ABS(T n) { return n >= 0 ? n : -n; }
+ #define MIN(a,b) std::min(a, b)
+ #define MAX(a,b) std::max(a, b)
+ #define SWAP(a,b) std::swap(a, b)
+#elif (COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF)
+ /* Type-generic macros implemented with statement expressions. */
+ #define ABS(n) ({ \
+ typeof(n) _n = (n); \
+ (_n < 0) ? -_n : _n; \
+ })
+ #define MIN(a,b) ({ \
+ typeof(a) _a = (a); \
+ typeof(b) _b = (b); \
+ (void)(&_a == &_b); /* ensure same type */ \
+ (_a < _b) ? _a : _b; \
+ })
+ #define MAX(a,b) ({ \
+ typeof(a) _a = (a); \
+ typeof(b) _b = (b); \
+ (void)(&_a == &_b); /* ensure same type */ \
+ (_a > _b) ? _a : _b; \
+ })
+#else /* !(COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF) */
+ /* Buggy macros for inferior compilers. */
+ #define ABS(a) (((a) < 0) ? -(a) : (a))
+ #define MIN(a,b) (((a) < (b)) ? (a) : (b))
+ #define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif /* !(COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF) */
+
+/*! Bound \a x between \a min and \a max. */
+#define MINMAX(min,x,max) (MIN(MAX(min, x), max))
+
+#ifdef __cplusplus
+ /* Use standard implementation from <algorithm> */
+ #define SWAP(a,b) std::swap(a, b)
+#elif COMPILER_TYPEOF
+ /*!
+ * Type-generic macro to swap \a a with \a b.
+ *
+ * \note Arguments are evaluated multiple times.
+ */
+ #define SWAP(a, b) \
+ do { \
+ (void)(&(a) == &(b)); /* type check */ \
+ typeof(a) tmp; \
+ tmp = (a); \
+ (a) = (b); \
+ (b) = tmp; \
+ } while (0)
+#else /* !COMPILER_TYPEOF */
+ /* Sub-optimal implementation that only works with integral types. */
+ #define SWAP(a, b) ((a) ^= (b) ^= (a) ^= (b))
+#endif /* COMPILER_TYPEOF */
+
+#ifndef BV
+ /*! Convert a bit value to a binary flag. */
+ #define BV(x) (1<<(x))
+#endif
+
+/*! Round up \a x to an even multiple of the 2's power \a pad */
+#define ROUND2(x, pad) (((x) + ((pad) - 1)) & ~((pad) - 1))
+
+//! Check if \a x is an integer power of 2
+#define IS_POW2(x) (!(bool)((x) & ((x)-1)))
+
+/*! Calculate a compile-time log2 for a uint8_t */
+#define UINT8_LOG2(x) \
+ ((x) < 2 ? 0 : \
+ ((x) < 4 ? 1 : \
+ ((x) < 8 ? 2 : \
+ ((x) < 16 ? 3 : \
+ ((x) < 32 ? 4 : \
+ ((x) < 64 ? 5 : \
+ ((x) < 128 ? 6 : 7)))))))
+
+/*! Calculate a compile-time log2 for a uint16_t */
+#define UINT16_LOG2(x) \
+ ((x < 256) ? UINT8_LOG2(x) : UINT8_LOG2((x) >> 8) + 8)
+
+/*! Calculate a compile-time log2 for a uint32_t */
+#define UINT32_LOG2(x) \
+ ((x < 65536UL) ? UINT16_LOG2(x) : UINT16_LOG2((x) >> 16) + 16)
+
+#if COMPILER_VARIADIC_MACROS
+ /*! Count the number of arguments (up to 16). */
+ #define PP_COUNT(...) \
+ PP_COUNT__(__VA_ARGS__,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
+ #define PP_COUNT__(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,count,...) \
+ count
+#endif
+
+#if COMPILER_VARIADIC_MACROS
+ /*!
+ * \def BIT_CHANGE(reg, (mask, value), ...)
+ *
+ * This macro allows for efficient and compact bit toggling in a hardware
+ * register. It is meant to replace hand-coded cruft which toggles bits
+ * in sequence.
+ *
+ * It is possible to specify an unlimited pair of (mask, value) parameters.
+ * For instance:
+ *
+ * \code
+ * void set_timer(bool start)
+ * {
+ * BIT_CHANGE(REG_CTRL_TIMER,
+ * (TIMER_MODE, MODE_COUNT),
+ * (OVL_IRQ, 1),
+ * (CMP_IRQ, 1),
+ * (START, start)
+ * );
+ * }
+ * \endcode
+ *
+ * The macro expansion will be roughly the following:
+ *
+ * \code
+ * REG_CTRL_TIMER = (REG_CTRL_TIMER & ~(TIMER_MODE|OVL_IRQ|CMP_IRQ|START)
+ * | (MODE_COUNT|OVL_IRQ|CMP_IRQ|(start ? START : 0));
+ * \endcode
+ *
+ * It is up to the compiler to produce the optimal code. We checked that GCC produces
+ * the best code in most cases. We preferred this expansion over the use of a block
+ * with a local variable because CodeWarrior 6.1 was not able to remove completely the
+ * allocation of the local from the stack.
+ *
+ * \note This macro is available only in C99 because it makes use of variadic macros.
+ * It would be possible to make up an implementation with a slightly different syntax
+ * for use with C90 compilers, through Boost Preprocessor.
+ */
+
+ /*!
+ * \def BIT_CHANGE_BV(reg, (bit, value), ...)
+ *
+ * Similar to BIT_CHANGE(), but get bits instead of masks (and applies BV() to convert
+ * them to masks).
+ */
+
+ #define BIT_EXTRACT_FLAG_0(bit, value) bit
+ #define BIT_EXTRACT_FLAG_1(bit, value) BV(bit)
+ #define BIT_EXTRACT_VALUE__(bit, value) value
+
+ #define BIT_MASK_SINGLE__(use_bv, index, max, arg) \
+ ((index < max) ? (PP_CAT(BIT_EXTRACT_FLAG_, use_bv) arg) : 0) \
+ /**/
+
+ #define BIT_MASK_IF_SINGLE__(use_bv, index, max, arg) \
+ (((index < max) && (BIT_EXTRACT_VALUE__ arg)) ? (PP_CAT(BIT_EXTRACT_FLAG_, use_bv) arg) : 0) \
+ /**/
+
+ #define BIT_ITER__2(macro, use_bv, max, a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15, ...) \
+ (macro(use_bv, 0, max, a0) | \
+ macro(use_bv, 1, max, a1) | \
+ macro(use_bv, 2, max, a2) | \
+ macro(use_bv, 3, max, a3) | \
+ macro(use_bv, 4, max, a4) | \
+ macro(use_bv, 5, max, a5) | \
+ macro(use_bv, 6, max, a6) | \
+ macro(use_bv, 7, max, a7) | \
+ macro(use_bv, 8, max, a8) | \
+ macro(use_bv, 9, max, a9) | \
+ macro(use_bv, 10, max, a10) | \
+ macro(use_bv, 11, max, a11) | \
+ macro(use_bv, 12, max, a12) | \
+ macro(use_bv, 13, max, a13) | \
+ macro(use_bv, 14, max, a14) | \
+ macro(use_bv, 15, max, a15)) \
+ /**/
+
+ #define BIT_ITER__(macro, use_bv, ...) \
+ BIT_ITER__2(macro, use_bv, PP_COUNT(__VA_ARGS__), __VA_ARGS__, (0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1)) \
+ /**/
+
+ #define BIT_MASKS__(use_bv, ...) \
+ BIT_ITER__(BIT_MASK_SINGLE__, use_bv, __VA_ARGS__)
+ /**/
+
+ #define BIT_MASKS_CONDITIONAL__(use_bv, ...) \
+ BIT_ITER__(BIT_MASK_IF_SINGLE__, use_bv, __VA_ARGS__)
+ /**/
+
+ #define BIT_CHANGE__(reg, use_bv, ...) \
+ ((reg) = ((reg) & ~BIT_MASKS__(use_bv, __VA_ARGS__)) | BIT_MASKS_CONDITIONAL__(use_bv, __VA_ARGS__)) \
+ /**/
+
+ #define BIT_CHANGE(reg, ...) BIT_CHANGE__(reg, 0, __VA_ARGS__)
+ #define BIT_CHANGE_BV(reg, ...) BIT_CHANGE__(reg, 1, __VA_ARGS__)
+
+#endif /* COMPILER_VARIADIC_MACROS */
+
+#endif /* MACROS_H */
+
--- /dev/null
+/*!
+ * \file
+ * <!--
+ * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
+ * This file is part of DevLib - See devlib/README for information.
+ * -->
+ *
+ * \brief OS-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2005/04/11 19:04:13 bernie
+ *#* Move top-level headers to cfg/ subdir.
+ *#*
+ *#* Revision 1.1 2004/12/31 17:40:24 bernie
+ *#* Add OS detection code.
+ *#*
+ *#*/
+#ifndef DEVLIB_OS_H
+#define DEVLIB_OS_H
+
+
+/*! Macro to include OS-specific versions of the headers. */
+#define OS_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).h)
+
+/*
+ * OS autodetection (Some systems trigger multiple OS definitions)
+ */
+#ifdef _WIN32
+ #define OS_WIN32 1
+ #define OS_ID win32
+#else
+ #define OS_WIN32 0
+#endif
+
+#ifdef __unix__
+ #define OS_UNIX 1
+ #define OS_POSIX 1 /* Not strictly UNIX, but no way to autodetect it. */
+ #define OS_ID unix
+#else
+ #define OS_UNIX 0
+ #define OS_POSIX 0
+#endif
+
+#ifdef __linux__
+ #define OS_LINUX 1
+#else
+ #define OS_LINUX 0
+#endif
+
+#if defined(__APPLE__) && defined(__MACH__)
+ #define OS_DARWIN 1
+#else
+ #define OS_DARWIN 0
+#endif
+
+/*
+ * Summarize hosted environments as OS_HOSTED.
+ */
+#if OS_WIN32 || OS_UNIX
+ #define OS_HOSTED 1
+#else
+ #define OS_HOSTED 0
+#endif
+
+/*
+ * Summarize embedded environments as OS_EMBEDDED.
+ */
+#if CPU_AVR || CPU_DSP56K || CPU_I196 || defined(__embedded__)
+ #define OS_EMBEDDED 1
+#else
+ #define OS_EMBEDDED 0
+#endif
+
+
+/* Self-check for the detection */
+#if CPU_I196 + CPU_X86 + CPU_DSP56K + CPU_AVR == 0
+ #error Unknown CPU
+#endif
+#if !defined(OS_ID)
+ #error OS_ID not defined
+#endif
+#if OS_HOSTED && OS_EMBEDDED
+ #error Both hosted and embedded OS environment
+#endif
+#if !OS_HOSTED && !OS_EMBEDDED
+ #error Neither hosted nor embedded OS environment
+#endif
+
+#endif /* DEVLIB_OS_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001, 2002, 2003 Bernardo Innocenti <bernie@codewiz.org>
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief Additional support macros for compiler independance
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.44 2005/03/29 06:39:59 bernie
- *#* setjmp.h, time_t: Remove ancient retrocompatibility; Remove MSVC double to float hack.
- *#*
- *#* Revision 1.43 2005/03/01 23:15:12 bernie
- *#* Remove compatibility hack.
- *#*
- *#* Revision 1.42 2005/02/16 20:28:46 bernie
- *#* Move PGM macros to mware/pgm.h
- *#*
- *#* Revision 1.41 2005/01/22 04:19:22 bernie
- *#* MTIME_INFINITE: New constant.
- *#*
- *#* Revision 1.40 2005/01/20 18:46:04 aleph
- *#* Add progmem datatypes; PSTR() definition.
- *#*/
-#ifndef DEVLIB_COMPILER_H
-#define DEVLIB_COMPILER_H
-
-#include "cpu_detect.h"
-
-
-#if defined __GNUC__ && defined __GNUC_MINOR__
- #define GNUC_PREREQ(maj, min) \
- ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
- #define GNUC_PREREQ(maj, min) 0
-#endif
-
-/* Some CW versions do not allow enabling C99 from the settings panel. */
-#if defined(__MWERKS__)
- #pragma c99 on
-#endif
-
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
- #define COMPILER_C99 1
-#else
- #define COMPILER_C99 0
-#endif
-
-
-/*! Concatenate two different preprocessor tokens (allowing macros to expand) */
-#define PP_CAT(x,y) PP_CAT__(x,y)
-#define PP_CAT__(x,y) x ## y
-#define PP_CAT3(x,y,z) PP_CAT(PP_CAT(x,y),z)
-#define PP_CAT4(x,y,z,w) PP_CAT(PP_CAT3(x,y,z),w)
-#define PP_CAT5(x,y,z,w,j) PP_CAT(PP_CAT4(x,y,z,w),j)
-
-/*! String-ize a token (allowing macros to expand) */
-#define PP_STRINGIZE(x) PP_STRINGIZE__(x)
-#define PP_STRINGIZE__(x) #x
-
-
-#if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
- #pragma language=extended
- #define INTERRUPT(x) interrupt [x]
- #define REGISTER shortad
- #define INLINE /* unsupported */
-
- /*
- * Imported from <longjmp.h>. Unfortunately, we can't just include
- * this header because it typedefs jmp_buf to be an array of chars.
- * This would allow the compiler to place the buffer on an odd address.
- * The CPU _should_ be able to perform word accesses to
- * unaligned data, but there are *BUGS* in the 80196KC with
- * some combinations of opcodes and addressing modes. One of
- * these, "ST SP,[?GR]+" is used in the longjmp() implementation
- * provided by the IAR compiler ANSI C library. When ?GR contains
- * an odd address, surprisingly the CPU will copy the high order
- * byte of the source operand (SP) in the low order byte of the
- * destination operand (the memory location pointed to by ?GR).
- *
- * We also need to replace the library setjmp()/longjmp() with
- * our own versions because the IAR implementation "forgets" to
- * save the contents of local registers (?LR).
- */
- struct _JMP_BUF
- {
- void *sp; /* Stack pointer */
- void *return_addr; /* Return address */
- int lr[6]; /* 6 local registers */
- };
-
- typedef struct _JMP_BUF jmp_buf[1];
-
- int setjmp(jmp_buf env);
- void longjmp(jmp_buf env, int val);
-
- /* Fake bool support */
- #define true (1==1)
- #define false (1!=1)
- typedef unsigned char bool;
-
-#elif defined(_MSC_VER) /* Win32 emulation support */
-
- /* MSVC doesn't provide <stdbool.h>. */
- #ifndef __cplusplus
- #define true (1==1)
- #define false (1!=1)
- typedef int bool;
- #endif /* !__cplusplus */
-
- /* These C99 functions are oddly named in MSVCRT32.lib */
- #define snprintf _snprintf
- #define vsnprintf _vsnprintf
-
-#elif defined(__GNUC__)
-
- /* Compiler features */
- #define COMPILER_VARIADIC_MACROS 1 /* Even in C++ */
- #define COMPILER_TYPEOF 1
- #define COMPILER_STATEMENT_EXPRESSIONS 1
-
- /* GCC attributes */
- #define FORMAT(type,fmt,first) __attribute__((__format__(type, fmt, first)))
- #define NORETURN __attribute__((__noreturn__))
- #define UNUSED_ARG(type,arg) __attribute__((__unused__)) type arg
- #define UNUSED_VAR(type,name) __attribute__((__unused__)) type name
- #define USED_VAR(type,name) __attribute__((__used__)) type name
- #define INLINE static inline __attribute__((__always_inline__))
- #define LIKELY(x) __builtin_expect(!!(x), 1)
- #define UNLIKELY(x) __builtin_expect(!!(x), 0)
- #define PURE_FUNC __attribute__((pure))
- #define CONST_FUNC __attribute__((const))
- #define UNUSED_FUNC __attribute__((unused))
- #define USED_FUNC __attribute__((__used__))
- #define RESTRICT __restrict__
- #define MUST_CHECK __attribute__((warn_unused_result))
- #if GNUC_PREREQ(3,1)
- #define DEPRECATED __attribute__((__deprecated__))
- #endif
-
- #if CPU_AVR
- #include <stddef.h>
- #include <stdbool.h>
- #else
- /* Include some standard C89/C99 stuff */
- #include <stddef.h>
- #include <stdbool.h>
- #endif
-
- #ifndef __cplusplus
- /*
- * Disallow some C++ keywords as identifiers in C programs,
- * for improved portability.
- */
- #pragma GCC poison new delete class template typename
- #pragma GCC poison private protected public operator
- #pragma GCC poison friend mutable using namespace
- #pragma GCC poison cin cout cerr clog
- #endif
-
-#elif defined(__MWERKS__) && CPU_DSP56K
-
- /* Compiler features */
- #define COMPILER_VARIADIC_MACROS 1
- #define COMPILER_TYPEOF 1
- #define COMPILER_STATEMENT_EXPRESSIONS 1
-
- #define typeof __typeof__
-
- #include <stdint.h>
- #include <stddef.h>
- #include <stdbool.h>
-
- // CodeWarrior has size_t as built-in type, but does not define this symbol.
- #define _SIZE_T_DEFINED
-
-#else
- #error unknown compiler
-#endif
-
-
-/* Defaults for compiler extensions. */
-
-/*!
- * \def COMPILER_VARIADIC_MACROS
- * Support for macros with variable arguments.
- */
-#ifndef COMPILER_VARIADIC_MACROS
-#define COMPILER_VARIADIC_MACROS (COMPILER_C99 != 0)
-#endif
-
-/*!
- * \def COMPILER_TYPEOF
- * Support for macros with variable arguments.
- */
-#ifndef COMPILER_TYPEOF
-#define COMPILER_TYPEOF 0
-#endif
-
-/*!
- * \def COMPILER_STATEMENT_EXPRESSIONS
- * Support for macros with variable arguments.
- */
-#ifndef COMPILER_STATEMENT_EXPRESSIONS
-#define COMPILER_STATEMENT_EXPRESSIONS 0
-#endif
-
-/* A few defaults for missing compiler features. */
-#ifndef INLINE
-#define INLINE static inline
-#endif
-#ifndef NORETURN
-#define NORETURN /* nothing */
-#endif
-#ifndef FORMAT
-#define FORMAT(type,fmt,first) /* nothing */
-#endif
-#ifndef DEPRECATED
-#define DEPRECATED /* nothing */
-#endif
-#ifndef UNUSED_ARG
-#define UNUSED_ARG(type,arg) type arg
-#endif
-#define UNUSED UNUSED_ARG /* OBSOLETE */
-#ifndef UNUSED_VAR
-#define UNUSED_VAR(type,name) type name
-#endif
-#ifndef USED_VAR
-#define USED_VAR(type,name) type name
-#endif
-#ifndef REGISTER
-#define REGISTER /* nothing */
-#endif
-#ifndef INTERRUPT
-#define INTERRUPT(x) ERROR_NOT_IMPLEMENTED
-#endif
-#ifndef LIKELY
-#define LIKELY(x) x
-#endif
-#ifndef UNLIKELY
-#define UNLIKELY(x) x
-#endif
-#ifndef PURE_FUNC
-#define PURE_FUNC /* nothing */
-#endif
-#ifndef CONST_FUNC
-#define CONST_FUNC /* nothing */
-#endif
-#ifndef UNUSED_FUNC
-#define UNUSED_FUNC /* nothing */
-#endif
-#ifndef USED_FUNC
-#define USED_FUNC /* nothing */
-#endif
-#ifndef RESTRICT
-#define RESTRICT /* nothing */
-#endif
-#ifndef MUST_CHECK
-#define MUST_CHECK /* nothing */
-#endif
-
-/* Misc definitions */
-#ifndef NULL
-#define NULL (void *)0
-#endif
-#ifndef EOF
-#define EOF (-1)
-#endif
-
-
-/* Support for hybrid C/C++ applications. */
-#ifdef __cplusplus
- #define EXTERN_C extern "C"
- #define EXTERN_C_BEGIN extern "C" {
- #define EXTERN_C_END }
-#else
- #define EXTERN_C extern
- #define EXTERN_C_BEGIN /* nothing */
- #define EXTERN_C_END /* nothing */
-#endif
-
-
-#if (defined(_MSC_VER) || defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__))
- /*!
- * \name ISO C99 fixed-size types
- *
- * These should be in <stdint.h>, but many compilers lack them.
- * \{
- */
- typedef signed char int8_t;
- typedef short int int16_t;
- typedef long int int32_t;
- typedef unsigned char uint8_t;
- typedef unsigned short int uint16_t;
- typedef unsigned long int uint32_t;
- /* \} */
-#elif defined(__GNUC__) && CPU_AVR
- /* avr-libc is weird... */
- #include <inttypes.h>
-#else
- /* This is the correct location. */
- #include <stdint.h>
-#endif
-
-#if CPU_AVR_ATMEGA8
- /*
- * The ATmega8 has a very small Flash, so we can't afford
- * to link in support routines for 32bit integer arithmetic.
- */
- typedef int16_t mtime_t; /*!< Type for time expressed in milliseconds. */
- typedef int16_t utime_t; /*!< Type for time expressed in microseconds. */
- #define SIZEOF_MTIME_T (16 / CPU_BITS_PER_CHAR)
- #define SIZEOF_UTIME_T (16 / CPU_BITS_PER_CHAR)
- #define MTIME_INFINITE 0x7FFFL
-#else
- typedef int32_t mtime_t; /*!< Type for time expressed in milliseconds. */
- typedef int32_t utime_t; /*!< Type for time expressed in microseconds. */
- #define SIZEOF_MTIME_T (32 / CPU_BITS_PER_CHAR)
- #define SIZEOF_UTIME_T (32 / CPU_BITS_PER_CHAR)
- #define MTIME_INFINITE 0x7FFFFFFFL
-#endif
-
-/*! Bulk storage large enough for both pointers or integers. */
-typedef void * iptr_t;
-typedef const void * const_iptr_t;
-
-typedef unsigned char sig_t; /*!< Type for signal bits. */
-typedef unsigned char sigmask_t; /*!< Type for signal masks. */
-typedef unsigned char page_t; /*!< Type for banked memory pages. */
-
-
-/*!
- * \name Standard type definitions.
- *
- * These should be in <sys/types.h> or <stddef.h>, but many compilers
- * and C libraries lack them.
- *
- * We check for some common definitions to avoid redefinitions:
- *
- * glibc, avr-libc: _SIZE_T_DEFINED
- * Darwin libc: _BSD_SIZE_T_DEFINED_
- *
- * \{
- */
-#if !(defined(size_t) || defined(_SIZE_T_DEFINED) || defined(_BSD_SIZE_T_DEFINED_))
- #if CPU_REG_BITS > 32
- /* 64bit. */
- typedef unsigned long size_t;
- typedef long ssize_t;
- #else
- /* 32bit or 16bit. */
- typedef unsigned int size_t;
- typedef int ssize_t;
- #endif
-#endif
-/*\}*/
-
-
-/*!
- * \name Types for hardware registers.
- *
- * Only use these types for registers whose contents can
- * be changed asynchronously by external hardware.
- *
- * \{
- */
-#if CPU_DSP56K
- /* Registers can be accessed only through 16-bit pointers */
- typedef volatile uint16_t reg16_t;
-#else
- typedef volatile uint8_t reg8_t;
- typedef volatile uint16_t reg16_t;
- typedef volatile uint32_t reg32_t;
-#endif
-/*\}*/
-
-
-/* Quasi-ANSI macros */
-#ifndef offsetof
- /*!
- * Return the byte offset of the member \a m in struct \a s.
- *
- * \note This macro should be defined in "stddef.h" and is sometimes
- * compiler-specific (g++ has a builtin for it).
- */
- #define offsetof(s,m) (size_t)&(((s *)0)->m)
-#endif
-#ifndef countof
- /*!
- * Count the number of elements in the static array \a a.
- *
- * \note This macro is non-standard, but implements a very common idiom
- */
- #define countof(a) (sizeof(a) / sizeof(*(a)))
-#endif
-
-/*! Issue a compilation error if the \a condition is false */
-#define STATIC_ASSERT(condition) \
- UNUSED_VAR(extern char,PP_CAT(CT_ASSERT___, __LINE__)[(condition) ? 1 : -1])
-
-#endif /* DEVLIB_COMPILER_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2001,2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
- * This file is part of DevLib - See devlib/README for information.
- * -->
- *
- * \brief Kernel configuration parameters
- *
- * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.5 2004/08/25 14:12:08 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.4 2004/08/24 16:19:38 bernie
- *#* Add missing header.
- *#*
- *#* Revision 1.3 2004/07/30 14:24:16 rasky
- *#* Task switching con salvataggio perfetto stato di interrupt (SR)
- *#* Kernel monitor per dump informazioni su stack dei processi
- *#*
- *#* Revision 1.2 2004/06/03 11:27:09 bernie
- *#* Add dual-license information.
- *#*
- *#* Revision 1.1 2004/05/23 17:48:35 bernie
- *#* Add top-level files.
- *#*
- *#*/
-#ifndef CONFIG_KERN_H
-#define CONFIG_KERN_H
-
-#include <arch_config.h> /* ARCH_EMUL */
-
-/*!
- * \name Modules activation
- *
- * \{
- */
-/* Module/option Active Dependencies */
-#define CONFIG_KERN_SCHED (1)
-#define CONFIG_KERN_SIGNALS (1 && CONFIG_KERN_SCHED)
-#define CONFIG_KERN_TIMER (1)
-#define CONFIG_KERN_HEAP (0)
-#define CONFIG_KERN_SEMAPHORES (0 && CONFIG_KERN_SIGNALS)
-#define CONFIG_KERN_MONITOR (1 && CONFIG_KERN_SCHED)
-/*\}*/
-
-/* EXPERIMENTAL */
-#define CONFIG_KERN_PREEMPTIVE (0 && CONFIG_KERN_SCHED && CONFIG_KERN_TIMER)
-
-
-#define CONFIG_KERN_HEAPSIZE 0x4000 /*!< Heap size (16KB) */
-#define CONFIG_KERN_QUANTUM 50 /*!< Scheduler time sharing quantum in ticks */
-
-#if (ARCH & ARCH_EMUL)
- #define CONFIG_KERN_DEFSTACKSIZE 65536
-#else
- #define CONFIG_KERN_DEFSTACKSIZE 128 /*!< Default stack size for each thread */
-#endif
-
-/* Memory fill codes to help debugging */
-#if CONFIG_KERN_MONITOR
- #define CONFIG_KERN_STACKFILLCODE 0xA5A5
- #define CONFIG_KERN_MEMFILLCODE 0xDBDB
-#endif
-
-
-#endif /* CONFIG_KERN_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief DevLib configuration options
- *
- * You should copy this header in your project and rename it to
- * "config.h" and delete the CONFIG_ macros for the modules
- * you're not using.
- *
- * <h2>Working with multiple applications</h2>
- *
- * If your project is made of multiple DevLib-based applications,
- * create a custom "config.h" file in each application subdirectory
- * and play with the compiler include path to get the desired result.
- * You can share common options by creationg a "config_common.h" header
- * and including it from all your "config.h" copies.
- *
- * <h2>Configuration style</h2>
- *
- * For improved compile-time checking of configuration options,
- * the preferred way to use a \c CONFIG_ symbol is keeping it
- * always defined with a value of either 0 or 1. This lets
- * you write tests like this:
- *
- * \code
- * #if CONFIG_FOO
- * void foo(void)
- * {
- * if (CONFIG_BAR)
- * bar();
- * }
- * #endif // CONFIG_FOO
- * \endcode
- *
- * In most cases, we rely on the optimizer to discard checks
- * on constant values and performing dead-code elimination.
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.5 2004/12/08 08:04:28 bernie
- *#* Add missing config options.
- *#*
- *#* Revision 1.4 2004/08/25 14:12:08 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.3 2004/08/24 14:30:11 bernie
- *#* Use new-style config macros for drv/timer.c
- *#*
- *#* Revision 1.2 2004/08/05 18:46:52 bernie
- *#* Documentation improvements.
- *#*
- *#* Revision 1.1 2004/07/29 23:34:32 bernie
- *#* Add template configuration file.
- *#*
- *#*/
-
-#ifndef CONFIG_COMMON_H
-#define CONFIG_COMMON_H
-
-/*! Baud-rate for the kdebug console */
-#define CONFIG_KDEBUG_BAUDRATE 19200
-
-/*!
- * printf()-style formatter configuration.
- *
- * \sa PRINTF_DISABLED
- * \sa PRINTF_NOMODIFIERS
- * \sa PRINTF_REDUCED
- * \sa PRINTF_NOFLOAT
- * \sa PRINTF_FULL
- */
-#define CONFIG_PRINTF PRINTF_FULL
-
-/*!
- * Multithreading kernel
- *
- * /sa config_kernel.h
- */
-#define CONFIG_KERNEL 0
-
-/*!
- * \name Serial driver parameters
- * \{
- */
- /*! Size of the outbound FIFO buffer for all ports (bytes) */
- #define CONFIG_SER_TXBUFSIZE 32
- /*! Size of the inbound FIFO buffer for all ports (bytes) */
- #define CONFIG_SER_RXBUFSIZE 64
-
- /*! Default transmit timeout (ms). Set to -1 to disable timeout support */
- #define CONFIG_SER_TXTIMEOUT -1
- /*! Default receive timeout (ms). Set to -1 to disable timeout support */
- #define CONFIG_SER_RXTIMEOUT -1
-
- /*! Use RTS/CTS handshake */
- #define CONFIG_SER_HWHANDSHAKE 0
-
- /*! Default baud rate (set to 0 to disable) */
- #define CONFIG_SER_DEFBAUDRATE 0
-
- /*! Enable ser_gets() and ser_gets_echo() */
- #define CONFIG_SER_GETS 0
-
- /*!
- * Transmit always something on serial port 0 TX
- * to avoid interference when sending burst of data,
- * using AVR multiprocessor serial mode
- */
- #define CONFIG_SER_TXFILL 0
-
- #define CONFIG_SER_STROBE 0
-/*\}*/
-
-/*!
- * \name KBus configuration
- * \{
- */
- /*! Board address for KBus */
- #define CONFIG_KBUS_ADDR KBUS_ADDR_FOOBAR
-
- /*! Disable KBUS escaping support */
- #define CONFIG_KBUS_ESCAPE 0
-
- /*! Serial port for internal KBUS communication */
- #define CONFIG_KBUS_PORT 0
-
- /*! Serial port speed for KBus communication */
- #define CONFIG_KBUS_BAUDRATE 19200
-/*\}*/
-
-//! Hardware timer selection for drv/timer.c
-#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE2
-
-#define CONFIG_TIMER_STROBE 0
-
-//! EEPROM type for drv/eeprom.c
-#define CONFIG_EEPROM_TYPE EEPROM_24XX256
-
-#endif /* CONFIG_COMMON_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2004 Giovanni Bajo
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief CPU-specific definitions
- *
- * \version $Id$
- *
- * \author Giovanni Bajo <rasky@develer.com>
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.30 2005/03/15 00:20:09 bernie
- *#* BREAKPOINT, IRQ_RUNNING(), IRQ_GETSTATE(): New DSP56K macros.
- *#*
- *#* Revision 1.29 2005/02/16 20:33:24 bernie
- *#* Preliminary PPC support.
- *#*
- *#* Revision 1.28 2004/12/31 17:39:41 bernie
- *#* Fix documentation.
- *#*
- *#* Revision 1.27 2004/12/31 17:02:47 bernie
- *#* IRQ_SAVE_DISABLE(), IRQ_RESTORE(): Add null stubs for x86.
- *#*
- *#* Revision 1.26 2004/12/13 12:08:12 bernie
- *#* DISABLE_IRQSAVE, ENABLE_IRQRESTORE, DISABLE_INTS, ENABLE_INTS: Remove obsolete macros.
- *#*
- *#* Revision 1.25 2004/12/08 08:31:02 bernie
- *#* CPU_HARVARD: Define to 1 for AVR and DSP56K.
- *#*/
-#ifndef DEVLIB_CPU_H
-#define DEVLIB_CPU_H
-
-#include "compiler.h" /* for uintXX_t */
-
-
-/*!
- * \name Macros for determining CPU endianness.
- * \{
- */
-#define CPU_BIG_ENDIAN 0x1234
-#define CPU_LITTLE_ENDIAN 0x3412
-/*\}*/
-
-/*! Macro to include cpu-specific versions of the headers. */
-#define CPU_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, CPU_ID).h)
-
-
-#if CPU_I196
-
- #define NOP nop_instruction()
- #define IRQ_DISABLE disable_interrupt()
- #define IRQ_ENABLE enable_interrupt()
-
- typedef uint16_t cpuflags_t; // FIXME
- typedef unsigned int cpustack_t;
-
- #define CPU_REG_BITS 16
- #define CPU_REGS_CNT 16
- #define CPU_STACK_GROWS_UPWARD 0
- #define CPU_SP_ON_EMPTY_SLOT 0
- #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
- #define CPU_HARVARD 0
-
-#elif CPU_X86
-
- #define NOP asm volatile ("nop")
- #define IRQ_DISABLE /* nothing */
- #define IRQ_ENABLE /* nothing */
- #define IRQ_SAVE_DISABLE(x) /* nothing */
- #define IRQ_RESTORE(x) /* nothing */
-
- typedef uint32_t cpuflags_t; // FIXME
- typedef uint32_t cpustack_t;
-
- #define CPU_REG_BITS 32
- #define CPU_REGS_CNT 7
- #define CPU_STACK_GROWS_UPWARD 0
- #define CPU_SP_ON_EMPTY_SLOT 0
- #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
- #define CPU_HARVARD 0
-
-#elif CPU_PPC
- #define NOP asm volatile ("nop" ::)
- #define IRQ_DISABLE FIXME
- #define IRQ_ENABLE FIXME
- #define IRQ_SAVE_DISABLE(x) FIXME
- #define IRQ_RESTORE(x) FIXME
- #define IRQ_GETSTATE() FIXME
-
- typedef uint32_t cpuflags_t; // FIXME
- typedef uint32_t cpustack_t; // FIXME
-
- /* Register counts include SREG too */
- #define CPU_REG_BITS (CPU_PPC32 ? 32 : 64)
- #define CPU_REGS_CNT FIXME
- #define CPU_SAVED_REGS_CNT FIXME
- #define CPU_STACK_GROWS_UPWARD 0 //FIXME
- #define CPU_SP_ON_EMPTY_SLOT 0 //FIXME
- #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
- #define CPU_HARVARD 0
-
-#elif CPU_DSP56K
-
- #define NOP asm(nop)
- #define BREAKPOINT asm(debug)
- #define IRQ_DISABLE do { asm(bfset #0x0200,SR); asm(nop); } while (0)
- #define IRQ_ENABLE do { asm(bfclr #0x0200,SR); asm(nop); } while (0)
-
- #define IRQ_SAVE_DISABLE(x) \
- do { (void)x; asm(move SR,x); asm(bfset #0x0200,SR); } while (0)
- #define IRQ_RESTORE(x) \
- do { (void)x; asm(move x,SR); } while (0)
-
- static inline bool irq_running(void)
- {
- extern void *user_sp;
- return !!user_sp;
- }
- #define IRQ_RUNNING() irq_running()
-
- static inline bool irq_getstate(void)
- {
- uint16_t x;
- asm(move SR,x);
- return !(x & 0x0200);
- }
- #define IRQ_GETSTATE() irq_getstate()
-
-
-
- typedef uint16_t cpuflags_t;
- typedef unsigned int cpustack_t;
-
- #define CPU_REG_BITS 16
- #define CPU_REGS_CNT FIXME
- #define CPU_SAVED_REGS_CNT 8
- #define CPU_STACK_GROWS_UPWARD 1
- #define CPU_SP_ON_EMPTY_SLOT 0
- #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
- #define CPU_HARVARD 1
-
- /* Memory is word-addessed in the DSP56K */
- #define CPU_BITS_PER_CHAR 16
- #define SIZEOF_SHORT 1
- #define SIZEOF_INT 1
- #define SIZEOF_LONG 2
- #define SIZEOF_PTR 1
-
-#elif CPU_AVR
-
- #define NOP asm volatile ("nop" ::)
- #define IRQ_DISABLE asm volatile ("cli" ::)
- #define IRQ_ENABLE asm volatile ("sei" ::)
-
- #define IRQ_SAVE_DISABLE(x) \
- do { \
- __asm__ __volatile__( \
- "in %0,__SREG__\n\t" \
- "cli" \
- : "=r" (x) : /* no inputs */ : "cc" \
- ); \
- } while (0)
-
- #define IRQ_RESTORE(x) \
- do { \
- __asm__ __volatile__( \
- "out __SREG__,%0" : /* no outputs */ : "r" (x) : "cc" \
- ); \
- } while (0)
-
- #define IRQ_GETSTATE() \
- ({ \
- uint8_t sreg; \
- __asm__ __volatile__( \
- "in %0,__SREG__\n\t" \
- : "=r" (sreg) /* no inputs & no clobbers */ \
- ); \
- (bool)(sreg & 0x80); \
- })
-
- typedef uint8_t cpuflags_t;
- typedef uint8_t cpustack_t;
-
- /* Register counts include SREG too */
- #define CPU_REG_BITS 8
- #define CPU_REGS_CNT 33
- #define CPU_SAVED_REGS_CNT 19
- #define CPU_STACK_GROWS_UPWARD 0
- #define CPU_SP_ON_EMPTY_SLOT 1
- #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
- #define CPU_HARVARD 1
-
- /*!
- * Initialization value for registers in stack frame.
- * The register index is not directly corrispondent to CPU
- * register numbers. Index 0 is the SREG register: the initial
- * value is all 0 but the interrupt bit (bit 7).
- */
- #define CPU_REG_INIT_VALUE(reg) (reg == 0 ? 0x80 : 0)
-
-#endif
-
-/*!
- * Execute \a CODE atomically with respect to interrupts.
- *
- * \see IRQ_SAVE_DISABLE IRQ_RESTORE
- */
-#define ATOMIC(CODE) \
- do { \
- cpuflags_t __flags; \
- IRQ_SAVE_DISABLE(__flags); \
- CODE; \
- IRQ_RESTORE(__flags); \
- } while (0)
-
-
-//! Default for macro not defined in the right arch section
-#ifndef CPU_REG_INIT_VALUE
- #define CPU_REG_INIT_VALUE(reg) 0
-#endif
-
-
-#ifndef CPU_STACK_GROWS_UPWARD
- #error CPU_STACK_GROWS_UPWARD should have been defined to either 0 or 1
-#endif
-
-#ifndef CPU_SP_ON_EMPTY_SLOT
- #error CPU_SP_ON_EMPTY_SLOT should have been defined to either 0 or 1
-#endif
-
-/*
- * Support stack handling peculiarities of a few CPUs.
- *
- * Most processors let their stack grow downward and
- * keep SP pointing at the last pushed value.
- */
-#if !CPU_STACK_GROWS_UPWARD
- #if !CPU_SP_ON_EMPTY_SLOT
- /* Most microprocessors (x86, m68k...) */
- #define CPU_PUSH_WORD(sp, data) \
- do { *--(sp) = (data); } while (0)
- #define CPU_POP_WORD(sp) \
- (*(sp)++)
- #else
- /* AVR insanity */
- #define CPU_PUSH_WORD(sp, data) \
- do { *(sp)-- = (data); } while (0)
- #define CPU_POP_WORD(sp) \
- (*++(sp))
- #endif
-
-#else /* CPU_STACK_GROWS_UPWARD */
-
- #if !CPU_SP_ON_EMPTY_SLOT
- /* DSP56K and other weirdos */
- #define CPU_PUSH_WORD(sp, data) \
- do { *++(sp) = (cpustack_t)(data); } while (0)
- #define CPU_POP_WORD(sp) \
- (*(sp)--)
- #else
- #error I bet you cannot find a CPU like this
- #endif
-#endif
-
-
-#if CPU_DSP56K
- /*
- * DSP56k pushes both PC and SR to the stack in the JSR instruction, but
- * RTS discards SR while returning (it does not restore it). So we push
- * 0 to fake the same context.
- */
- #define CPU_PUSH_CALL_CONTEXT(sp, func) \
- do { \
- CPU_PUSH_WORD((sp), (func)); \
- CPU_PUSH_WORD((sp), 0x100); \
- } while (0);
-
-#elif CPU_AVR
- /*
- * In AVR, the addresses are pushed into the stack as little-endian, while
- * memory accesses are big-endian (actually, it's a 8-bit CPU, so there is
- * no natural endianess).
- */
- #define CPU_PUSH_CALL_CONTEXT(sp, func) \
- do { \
- uint16_t funcaddr = (uint16_t)(func); \
- CPU_PUSH_WORD((sp), funcaddr); \
- CPU_PUSH_WORD((sp), funcaddr>>8); \
- } while (0)
-
-#else
- #define CPU_PUSH_CALL_CONTEXT(sp, func) \
- CPU_PUSH_WORD((sp), (func))
-#endif
-
-
-/*!
- * \name Default type sizes.
- *
- * These defaults are reasonable for most 16/32bit machines.
- * Some of these macros may be overridden by CPU-specific code above.
- *
- * ANSI C requires that the following equations be true:
- * \code
- * sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
- * sizeof(float) <= sizeof(double)
- * CPU_BITS_PER_CHAR >= 8
- * CPU_BITS_PER_SHORT >= 8
- * CPU_BITS_PER_INT >= 16
- * CPU_BITS_PER_LONG >= 32
- * \endcode
- * \{
- */
-#ifndef SIZEOF_CHAR
-#define SIZEOF_CHAR 1
-#endif
-
-#ifndef SIZEOF_SHORT
-#define SIZEOF_SHORT 2
-#endif
-
-#ifndef SIZEOF_INT
-#if CPU_REG_BITS < 32
- #define SIZEOF_INT 2
-#else
- #define SIZEOF_INT 4
-#endif
-#endif /* !SIZEOF_INT */
-
-#ifndef SIZEOF_LONG
-#if CPU_REG_BITS > 32
- #define SIZEOF_LONG 8
-#else
- #define SIZEOF_LONG 4
-#endif
-#endif
-
-#ifndef SIZEOF_PTR
-#define SIZEOF_PTR SIZEOF_INT
-#endif
-
-#ifndef CPU_BITS_PER_CHAR
-#define CPU_BITS_PER_CHAR (SIZEOF_CHAR * 8)
-#endif
-
-#ifndef CPU_BITS_PER_SHORT
-#define CPU_BITS_PER_SHORT (SIZEOF_SHORT * CPU_BITS_PER_CHAR)
-#endif
-
-#ifndef CPU_BITS_PER_INT
-#define CPU_BITS_PER_INT (SIZEOF_INT * CPU_BITS_PER_CHAR)
-#endif
-
-#ifndef CPU_BITS_PER_LONG
-#define CPU_BITS_PER_LONG (SIZEOF_LONG * CPU_BITS_PER_CHAR)
-#endif
-
-#ifndef CPU_BITS_PER_PTR
-#define CPU_BITS_PER_PTR (SIZEOF_PTR * CPU_BITS_PER_CHAR)
-#endif
-
-#ifndef BREAKPOINT
-#define BREAKPOINT /* nop */
-#endif
-
-/*\}*/
-
-/* Sanity checks for the above definitions */
-STATIC_ASSERT(sizeof(char) == SIZEOF_CHAR);
-STATIC_ASSERT(sizeof(short) == SIZEOF_SHORT);
-STATIC_ASSERT(sizeof(long) == SIZEOF_LONG);
-STATIC_ASSERT(sizeof(int) == SIZEOF_INT);
-
-
-/*!
- * \def CPU_IDLE
- *
- * \brief Invoked by the scheduler to stop the CPU when idle.
- *
- * This hook can be redefined to put the CPU in low-power mode, or to
- * profile system load with an external strobe, or to save CPU cycles
- * in hosted environments such as emulators.
- */
-#ifndef CPU_IDLE
- #if defined(ARCH_EMUL) && (ARCH & ARCH_EMUL)
- /* This emulator hook should yield the CPU to the host. */
- EXTERN_C_BEGIN
- void SchedulerIdle(void);
- EXTERN_C_END
- #define CPU_IDLE SchedulerIdle()
- #else /* !ARCH_EMUL */
- #define CPU_IDLE do { /* nothing */ } while (0)
- #endif /* !ARCH_EMUL */
-#endif /* !CPU_IDLE */
-
-/* OBSOLETE */
-#define SCHEDULER_IDLE CPU_IDLE
-
-#endif /* DEVLIB_CPU_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2004 Giovanni Bajo
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief CPU detection through special preprocessor macros
- *
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.4 2005/02/16 20:33:24 bernie
- *#* Preliminary PPC support.
- *#*
- *#* Revision 1.3 2004/12/31 17:39:26 bernie
- *#* Use C89 comments only.
- *#*
- *#* Revision 1.2 2004/08/25 14:12:08 rasky
- *#* Aggiornato il comment block dei log RCS
- *#*
- *#* Revision 1.1 2004/07/30 17:14:49 rasky
- *#* File sfuggito al commit precedente (nuova gestione unificata del detect della CPU
- *#*
- *#* Revision 1.2 2004/07/30 10:31:07 rasky
- *#* Aggiunto detect per ATmega128
- *#*/
-
-#ifndef CPU_DETECT_H
-#define CPU_DETECT_H
-
-#if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
- #define CPU_I196 1
- #define CPU_ID i196
-#else
- #define CPU_I196 0
-#endif
-
-#if defined(__i386__) || defined(_MSC_VER)
- #define CPU_X86 1
- #define CPU_ID x86
-#else
- #define CPU_X86 0
-#endif
-
-#if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
- #define CPU_PPC 1
- #define CPU_ID ppc
- #if defined(_ARCH_PPC)
- #define CPU_PPC32 1
- #else
- #define CPU_PPC32 0
- #endif
- #if defined(_ARCH_PPC64)
- #define CPU_PPC64 1
- #else
- #define CPU_PPC64 0
- #endif
-#else
- #define CPU_PPC 0
- #define CPU_PPC32 0
- #define CPU_PPC64 0
-#endif
-
-#if defined(__m56800E__) || defined(__m56800__)
- #define CPU_DSP56K 1
- #define CPU_ID dsp56k
-#else
- #define CPU_DSP56K 0
-#endif
-
-#if defined (__AVR__)
- #define CPU_AVR 1
- #define CPU_ID avr
-
- #if defined(__AVR_ATmega64__)
- #define CPU_AVR_ATMEGA64 1
- #else
- #define CPU_AVR_ATMEGA64 0
- #endif
-
- #if defined(__AVR_ATmega103__)
- #define CPU_AVR_ATMEGA103 1
- #else
- #define CPU_AVR_ATMEGA103 0
- #endif
-
- #if defined(__AVR_ATmega128__)
- #define CPU_AVR_ATMEGA128 1
- #else
- #define CPU_AVR_ATMEGA128 0
- #endif
-
- #if defined(__AVR_ATmega8__)
- #define CPU_AVR_ATMEGA8 1
- #else
- #define CPU_AVR_ATMEGA8 0
- #endif
-#else
- #define CPU_AVR 0
- #define CPU_AVR_ATMEGA8 0
- #define CPU_AVR_ATMEGA64 0
- #define CPU_AVR_ATMEGA103 0
- #define CPU_AVR_ATMEGA128 0
-#endif
-
-
-/* Self-check for the detection: only one CPU must be detected */
-#if CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR == 0
- #error Unknown CPU
-#elif !defined(CPU_ID)
- #error CPU_ID not defined
-#elif CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR != 1
- #error Internal CPU configuration error
-#endif
-
-
-#endif /* CPU_DETECT_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See README.devlib for information.
- * -->
- *
- * \brief Simple debug facilities for hosted and embedded C/C++ applications.
- *
- * Debug output goes to stderr in hosted applications.
- * Freestanding (AKA embedded) applications use \c drv/kdebug.c to output
- * diagnostic messages to a serial terminal or a JTAG debugger.
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.13 2005/03/01 23:23:58 bernie
- *#* Provide defaults for CONFIG_KDEBUG_DISABLE_TRACE and CONFIG_KDEBUG_ASSERT_NO_TEXT.
- *#*
- *#* Revision 1.12 2005/02/18 11:18:33 bernie
- *#* Fixes for Harvard processors from project_ks.
- *#*
- *#* Revision 1.11 2005/02/16 20:29:48 bernie
- *#* TRACE(), TRACEMSG(): Reduce code and data footprint.
- *#*
- *#* Revision 1.10 2005/02/09 21:50:28 bernie
- *#* Declare dummy ASSERT* macros as ((void)0) to work around a warning I can't remember any more.
- *#*
- *#* Revision 1.9 2005/01/25 08:36:40 bernie
- *#* kputnum(): Export.
- *#*
- *#* Revision 1.8 2005/01/11 18:08:08 aleph
- *#* Add empty kdump definition for debug off
- *#*
- *#* Revision 1.7 2004/12/31 17:43:09 bernie
- *#* Use UNUSED_ARG instead of obsolete UNUSED macro.
- *#*
- *#* Revision 1.6 2004/12/08 08:52:00 bernie
- *#* Save some more RAM on AVR.
- *#*/
-#ifndef DEVLIB_DEBUG_H
-#define DEVLIB_DEBUG_H
-
-/*
- * Try to guess whether we're running in a hosted or embedded environment.
- */
-#ifndef OS_HOSTED
- #if defined(__unix__) || defined(_WIN32)
- #define OS_HOSTED 1
- #else
- #define OS_HOSTED 0
- #endif
-#endif /* !OS_HOSTED */
-
-#if OS_HOSTED
- /*
- * For now, avoid dependency on compiler.h
- */
- #ifndef FORMAT
- #define FORMAT(x,y,z) /* nothing */
- #endif
- #ifndef INLINE
- #define INLINE static inline
- #endif
- #ifndef UNUSED_ARG
- #ifdef __cplusplus
- #define UNUSED_ARG(type,name) type
- #else
- #define UNUSED_ARG(type,name) type name
- #endif
- #endif
-#else /* !OS_HOSTED */
- #include <compiler.h>
-#endif /* !OS_HOSTED */
-
-
-/*
- * Defaults for rarely used config stuff.
- */
-#ifndef CONFIG_KDEBUG_DISABLE_TRACE
-#define CONFIG_KDEBUG_DISABLE_TRACE 0
-#endif
-
-#ifndef CONFIG_KDEBUG_ASSERT_NO_TEXT
-#define CONFIG_KDEBUG_ASSERT_NO_TEXT 0
-#endif
-
-
-/*!
- * \def _DEBUG
- *
- * This preprocessor symbol is defined only in debug builds.
- *
- * The build infrastructure must arrange for _DEBUG to
- * be prepredefined for all source files being compiled.
- *
- * This is compatible with the Microsoft convention for
- * the default Debug and Release targets.
- */
-#ifdef _DEBUG
-
- // STLport specific: enable extra checks
- #define __STL_DEBUG 1
-
- // MSVC specific: Enable memory allocation debug
- #if defined(_MSC_VER)
- #include <crtdbg.h>
- #endif
-
- /*
- * On UNIX systems the extabilished practice is to define
- * NDEBUG for release builds and nothing for debug builds.
- */
- #ifdef NDEBUG
- #undef NDEBUG
- #endif
-
- /*!
- * This macro duplicates the old MSVC trick of redefining
- * THIS_FILE locally to avoid the overhead of many duplicate
- * strings in ASSERT().
- */
- #ifndef THIS_FILE
- #define THIS_FILE __FILE__
- #endif
-
- /*!
- * This macro can be used to conditionally exclude one or more
- * statements conditioned on \c _DEBUG, avoiding the clutter
- * of #ifdef/#endif pairs.
- *
- * \code
- * struct FooBar
- * {
- * int foo;
- * bool bar;
- * DB(int ref_count;) // Track number of users
- *
- * void release()
- * {
- * DB(--ref_count;)
- * }
- * };
- * \endcode
- */
- #define DB(x) x
-
- #if OS_HOSTED
- #include <stdio.h>
- #include <stdarg.h>
-
- INLINE void kdbg_init(void) { /* nop */ }
- INLINE void kputchar(char c)
- {
- putc(c, stderr);
- }
- INLINE void kputs(const char *str)
- {
- fputs(str, stderr);
- }
- /* G++ can't inline functions with variable arguments... */
- #define kprintf(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
- void kdump(const void *buf, size_t len); /* UNIMPLEMENTED */
-
- #ifndef ASSERT
- #include <assert.h>
- #define ASSERT(x) assert(x)
- #endif /* ASSERT */
-
- /*!
- * Check that the given pointer is not NULL or pointing to raw memory.
- *
- * The assumption here is that valid pointers never point to low
- * memory regions. This helps catching pointers taken from
- * struct/class memebers when the struct pointer was NULL.
- */
- #define ASSERT_VALID_PTR(p) ASSERT((unsigned long)(p) > 0x200)
-
- #define ASSERT_VALID_PTR_OR_NULL(p) ASSERT((((p) == NULL) || ((unsigned long)(p) >= 0x200)))
- #else /* !OS_HOSTED */
-
- #include <config.h> /* CONFIG_KDEBUG_ASSERT_NO_TEXT */
- #include <cpu.h> /* CPU_HARVARD */
-
- /* These are implemented in drv/kdebug.c */
- void kdbg_init(void);
- void kputchar(char c);
- int kputnum(int num);
- void kdump(const void *buf, size_t len);
- void __init_wall(long *wall, int size);
-
- #if CPU_HARVARD
- #include <mware/pgm.h>
- void kputs_P(const char *PROGMEM str);
- void kprintf_P(const char *PROGMEM fmt, ...) FORMAT(__printf__, 1, 2);
- int __assert_P(const char *PROGMEM cond, const char *PROGMEM file, int line);
- void __trace_P(const char *func);
- void __tracemsg_P(const char *func, const char *PROGMEM fmt, ...);
- int __invalid_ptr_P(void *p, const char *PROGMEM name, const char *PROGMEM file, int line);
- int __check_wall_P(long *wall, int size, const char * PGM_ATTR name, const char * PGM_ATTR file, int line);
- #define kputs(str) kputs_P(PSTR(str))
- #define kprintf(fmt, ...) kprintf_P(PSTR(fmt) ,## __VA_ARGS__)
- #define __assert(cond, file, line) __assert_P(PSTR(cond), PSTR(file), (line))
- #define __trace(func) __trace_P(func)
- #define __tracemsg(func, fmt, ...) __tracemsg_P(func, PSTR(fmt), ## __VA_ARGS__)
- #define __invalid_ptr(p, name, file, line) __invalid_ptr_P((p), PSTR(name), PSTR(file), (line))
- #define __check_wall(wall, size, name, file, line) __check_wall_P(wall, size, PSTR(name), PSTR(file), (line))
- #else /* !CPU_HARVARD */
- void kputs(const char *str);
- void kprintf(const char *fmt, ...) FORMAT(__printf__, 1, 2);
- int __assert(const char *cond, const char *file, int line);
- void __trace(const char *func);
- void __tracemsg(const char *func, const char *fmt, ...) FORMAT(__printf__, 2, 3);
- int __invalid_ptr(void *p, const char *name, const char *file, int line);
- int __check_wall(long *wall, int size, const char *name, const char *file, int line);
- #endif /* !CPU_HARVARD */
-
- #if !CONFIG_KDEBUG_ASSERT_NO_TEXT
- #define ASSERT(x) ((void)(LIKELY(x) ? 0 : __assert(#x, THIS_FILE, __LINE__)))
- #define ASSERT2(x, help) ((void)(LIKELY(x) ? 0 : __assert(help " (" #x ")", THIS_FILE, __LINE__)))
- #else
- #define ASSERT(x) ((void)(LIKELY(x) ? 0 : __assert("", THIS_FILE, __LINE__)))
- #define ASSERT2(x, help) ((void)ASSERT(x))
- #endif
-
- #define ASSERT_VALID_PTR(p) ((void)(LIKELY((p) >= 0x200) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__)))
- #define ASSERT_VALID_PTR_OR_NULL(p) ((void)(LIKELY((p == NULL) || ((p) >= 0x200)) ? 0 : __invalid_ptr((p), #p, THIS_FILE, __LINE__)))
-
- #if !CONFIG_KDEBUG_DISABLE_TRACE
- #define TRACE __trace(__func__)
- #define TRACEMSG(msg,...) __tracemsg(__func__, msg, ## __VA_ARGS__)
- #else
- #define TRACE do {} while(0)
- #define TRACEMSG(...) do {} while(0)
- #endif
-
- #endif /* !OS_HOSTED */
-
- /*!
- * \name Walls to detect data corruption
- * \{
- */
- #define WALL_SIZE 8
- #define WALL_VALUE (long)0xABADCAFEL
- #define DECLARE_WALL(name,size) long name[(size) / sizeof(long)];
- #define FWD_DECLARE_WALL(name,size) extern long name[(size) / sizeof(long)];
- #define INIT_WALL(name) __init_wall((name), countof(name))
- #define CHECK_WALL(name) __check_wall((name), countof(name), #name, THIS_FILE, __LINE__)
- /*\}*/
-
- /*!
- * Check that the given pointer actually points to an object
- * of the specified type.
- */
- #define ASSERT_VALID_OBJ(_t, _o) do { \
- ASSERT_VALID_PTR((_o)); \
- ASSERT(dynamic_cast<_t>((_o)) != NULL); \
- }
-
- /*!
- * \name Debug object creation and destruction.
- *
- * These macros help track some kinds of leaks in C++ programs.
- * Usage is as follows:
- *
- * \code
- * class Foo
- * {
- * DECLARE_INSTANCE_TRACKING(Foo)
- *
- * Foo()
- * {
- * NEW_INSTANCE(Foo);
- * // ...
- * }
- *
- * ~Foo()
- * {
- * DELETE_INSTANCE(Foo);
- * // ...
- * }
- * };
- *
- * // Put this in the implementation file of the class
- * IMPLEMENT_INSTANCE_TRACKING(Foo)
- *
- * // Client code
- * int main(void)
- * {
- * Foo *foo = new Foo;
- * cout << GET_INSTANCE_COUNT(Foo) << endl; // prints "1"
- * delete foo;
- * ASSERT_ZERO_INSTANCES(Foo); // OK
- * }
- * \endcode
- * \{
- */
- #define NEW_INSTANCE(CLASS) do { ++CLASS::__instances } while (0)
- #define DELETE_INSTANCE(CLASS) do { --CLASS::__instances } while (0)
- #define ASSERT_ZERO_INSTANCES(CLASS) ASSERT(CLASS::__instances == 0)
- #define GET_INSTANCE_COUNT(CLASS) (CLASS::__instances)
- #define DECLARE_INSTANCE_TRACKING(CLASS) static int __instances
- #define IMPLEMENT_INSTANCE_TRACKING(CLASS) int CLASS::__instances = 0
- /*\}*/
-
-#else /* !_DEBUG */
-
- /*
- * On UNIX systems the extabilished practice is to define
- * NDEBUG for release builds and nothing for debug builds.
- */
- #ifndef NDEBUG
- #define NDEBUG 1
- #endif
-
- #define DB(x) /* nothing */
- #ifndef ASSERT
- #define ASSERT(x) ((void)0)
- #endif /* ASSERT */
- #define ASSERT2(x, help) ((void)0)
- #define ASSERT_VALID_PTR(p) ((void)0)
- #define ASSERT_VALID_PTR_OR_NULL(p) ((void)0)
- #define ASSERT_VALID_OBJ(_t, _o) ((void)0)
- #define TRACE do {} while (0)
- #define TRACEMSG(x,...) do {} while (0)
-
- #define DECLARE_WALL(name, size) /* nothing */
- #define FWD_DECLARE_WALL(name, size) /* nothing */
- #define INIT_WALL(name) do {} while (0)
- #define CHECK_WALL(name) do {} while (0)
-
- #define NEW_INSTANCE(CLASS) do {} while (0)
- #define DELETE_INSTANCE(CLASS) do {} while (0)
- #define ASSERT_ZERO_INSTANCES(CLASS) do {} while (0)
- #define GET_INSTANCE_COUNT(CLASS) ERROR_ONLY_FOR_DEBUG
- #define DECLARE_INSTANCE_TRACKING(CLASS)
- #define IMPLEMENT_INSTANCE_TRACKING(CLASS)
-
- INLINE void kdbg_init(void) { /* nop */ }
- INLINE void kputchar(UNUSED_ARG(char, c)) { /* nop */ }
- INLINE int kputnum(UNUSED_ARG(int, num)) { return 0; }
- INLINE void kputs(UNUSED_ARG(const char *, str)) { /* nop */ }
- INLINE void kdump(UNUSED_ARG(const void *, buf), UNUSED_ARG(size_t, len)) { /* nop */ }
-
- #ifdef __cplusplus
- /* G++ can't inline functions with variable arguments... */
- #define kprintf(fmt,...) do { (void)(fmt); } while(0)
- #else
- /* ...but GCC can. */
- INLINE void kprintf(UNUSED_ARG(const char *, fmt), ...) { /* nop */ }
- #endif
-
-#endif /* _DEBUG */
-
-#endif /* DEVLIB_DEBUG_H */
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See devlib/README for information.
- * -->
- *
- * \brief Common and handy function macros
- *
- * \version $Id$
- * \author Bernardo Innocenti <bernie@develer.com>
- * \author Giovanni Bajo <rasky@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.10 2005/01/22 04:19:50 bernie
- *#* Use non-uglified typeof().
- *#*
- *#* Revision 1.9 2004/12/08 08:51:34 bernie
- *#* Add type-generic macros for C++.
- *#*
- *#* Revision 1.8 2004/10/19 07:14:20 bernie
- *#* Add macros to test for specific compiler features.
- *#*
- *#* Revision 1.7 2004/09/20 03:30:45 bernie
- *#* C++ also has variadic macros.
- *#*
- *#* Revision 1.6 2004/09/14 21:02:04 bernie
- *#* SWAP(), MINMAX(): New macros.
- *#*
- *#* Revision 1.5 2004/08/29 21:57:58 bernie
- *#* Move back STATIC_ASSERT() to compiler.h as it's needed in cpu.h;
- *#* iptr_t, const_iptr_t: Replace IPTR macro with a real typedef.
- *#*
- *#* Revision 1.3 2004/08/24 14:13:48 bernie
- *#* Restore a few macros that were lost in the way.
- *#*
- *#* Revision 1.2 2004/08/24 13:32:14 bernie
- *#* PP_CAT(), PP_STRINGIZE(): Move back to compiler.h to break circular dependency between cpu.h/compiler.h/macros.h;
- *#* offsetof(), countof(): Move back to compiler.h to avoid including macros.h almost everywhere;
- *#* Trim CVS log;
- *#* Rename header guards;
- *#* Don't include arch_config.h in compiler.h as it's not needed there.
- *#*
- *#* Revision 1.1 2004/08/14 19:37:57 rasky
- *#* Merge da SC: macros.h, pool.h, BIT_CHANGE, nome dei processi, etc.
- *#*
- *#* Revision 1.4 2004/08/14 18:36:50 rasky
- *#* Doxygen fix e un livello di parentesi aggiuntivi per la macro
- *#*
- *#* Revision 1.3 2004/08/12 20:01:32 rasky
- *#* Aggiunte macro BIT_CHANGE e BIT_CHANGE_BV
- *#*
- *#* Revision 1.2 2004/08/10 21:36:14 rasky
- *#* Aggiunto include macros.h dove serve
- *#* Aggiunta dipendenza da compiler.h in macros.h
- *#*
- *#* Revision 1.1 2004/08/10 21:30:00 rasky
- *#* Estratte le funzioni macro in macros.h
- *#*
- *#*/
-
-#ifndef MACROS_H
-#define MACROS_H
-
-#include <compiler.h>
-
-/* avr-gcc does not seem to support libstdc++ */
-#if defined(__cplusplus) && !CPU_AVR
- /* Type-generic macros implemented with template functions. */
- #include <algorithm>
-
- template<class T> inline T ABS(T n) { return n >= 0 ? n : -n; }
- #define MIN(a,b) std::min(a, b)
- #define MAX(a,b) std::max(a, b)
- #define SWAP(a,b) std::swap(a, b)
-#elif (COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF)
- /* Type-generic macros implemented with statement expressions. */
- #define ABS(n) ({ \
- typeof(n) _n = (n); \
- (_n < 0) ? -_n : _n; \
- })
- #define MIN(a,b) ({ \
- typeof(a) _a = (a); \
- typeof(b) _b = (b); \
- (void)(&_a == &_b); /* ensure same type */ \
- (_a < _b) ? _a : _b; \
- })
- #define MAX(a,b) ({ \
- typeof(a) _a = (a); \
- typeof(b) _b = (b); \
- (void)(&_a == &_b); /* ensure same type */ \
- (_a > _b) ? _a : _b; \
- })
-#else /* !(COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF) */
- /* Buggy macros for inferior compilers. */
- #define ABS(a) (((a) < 0) ? -(a) : (a))
- #define MIN(a,b) (((a) < (b)) ? (a) : (b))
- #define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif /* !(COMPILER_STATEMENT_EXPRESSIONS && COMPILER_TYPEOF) */
-
-/*! Bound \a x between \a min and \a max. */
-#define MINMAX(min,x,max) (MIN(MAX(min, x), max))
-
-#ifdef __cplusplus
- /* Use standard implementation from <algorithm> */
- #define SWAP(a,b) std::swap(a, b)
-#elif COMPILER_TYPEOF
- /*!
- * Type-generic macro to swap \a a with \a b.
- *
- * \note Arguments are evaluated multiple times.
- */
- #define SWAP(a, b) \
- do { \
- (void)(&(a) == &(b)); /* type check */ \
- typeof(a) tmp; \
- tmp = (a); \
- (a) = (b); \
- (b) = tmp; \
- } while (0)
-#else /* !COMPILER_TYPEOF */
- /* Sub-optimal implementation that only works with integral types. */
- #define SWAP(a, b) ((a) ^= (b) ^= (a) ^= (b))
-#endif /* COMPILER_TYPEOF */
-
-#ifndef BV
- /*! Convert a bit value to a binary flag. */
- #define BV(x) (1<<(x))
-#endif
-
-/*! Round up \a x to an even multiple of the 2's power \a pad */
-#define ROUND2(x, pad) (((x) + ((pad) - 1)) & ~((pad) - 1))
-
-//! Check if \a x is an integer power of 2
-#define IS_POW2(x) (!(bool)((x) & ((x)-1)))
-
-/*! Calculate a compile-time log2 for a uint8_t */
-#define UINT8_LOG2(x) \
- ((x) < 2 ? 0 : \
- ((x) < 4 ? 1 : \
- ((x) < 8 ? 2 : \
- ((x) < 16 ? 3 : \
- ((x) < 32 ? 4 : \
- ((x) < 64 ? 5 : \
- ((x) < 128 ? 6 : 7)))))))
-
-/*! Calculate a compile-time log2 for a uint16_t */
-#define UINT16_LOG2(x) \
- ((x < 256) ? UINT8_LOG2(x) : UINT8_LOG2((x) >> 8) + 8)
-
-/*! Calculate a compile-time log2 for a uint32_t */
-#define UINT32_LOG2(x) \
- ((x < 65536UL) ? UINT16_LOG2(x) : UINT16_LOG2((x) >> 16) + 16)
-
-#if COMPILER_VARIADIC_MACROS
- /*! Count the number of arguments (up to 16). */
- #define PP_COUNT(...) \
- PP_COUNT__(__VA_ARGS__,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
- #define PP_COUNT__(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,count,...) \
- count
-#endif
-
-#if COMPILER_VARIADIC_MACROS
- /*!
- * \def BIT_CHANGE(reg, (mask, value), ...)
- *
- * This macro allows for efficient and compact bit toggling in a hardware
- * register. It is meant to replace hand-coded cruft which toggles bits
- * in sequence.
- *
- * It is possible to specify an unlimited pair of (mask, value) parameters.
- * For instance:
- *
- * \code
- * void set_timer(bool start)
- * {
- * BIT_CHANGE(REG_CTRL_TIMER,
- * (TIMER_MODE, MODE_COUNT),
- * (OVL_IRQ, 1),
- * (CMP_IRQ, 1),
- * (START, start)
- * );
- * }
- * \endcode
- *
- * The macro expansion will be roughly the following:
- *
- * \code
- * REG_CTRL_TIMER = (REG_CTRL_TIMER & ~(TIMER_MODE|OVL_IRQ|CMP_IRQ|START)
- * | (MODE_COUNT|OVL_IRQ|CMP_IRQ|(start ? START : 0));
- * \endcode
- *
- * It is up to the compiler to produce the optimal code. We checked that GCC produces
- * the best code in most cases. We preferred this expansion over the use of a block
- * with a local variable because CodeWarrior 6.1 was not able to remove completely the
- * allocation of the local from the stack.
- *
- * \note This macro is available only in C99 because it makes use of variadic macros.
- * It would be possible to make up an implementation with a slightly different syntax
- * for use with C90 compilers, through Boost Preprocessor.
- */
-
- /*!
- * \def BIT_CHANGE_BV(reg, (bit, value), ...)
- *
- * Similar to BIT_CHANGE(), but get bits instead of masks (and applies BV() to convert
- * them to masks).
- */
-
- #define BIT_EXTRACT_FLAG_0(bit, value) bit
- #define BIT_EXTRACT_FLAG_1(bit, value) BV(bit)
- #define BIT_EXTRACT_VALUE__(bit, value) value
-
- #define BIT_MASK_SINGLE__(use_bv, index, max, arg) \
- ((index < max) ? (PP_CAT(BIT_EXTRACT_FLAG_, use_bv) arg) : 0) \
- /**/
-
- #define BIT_MASK_IF_SINGLE__(use_bv, index, max, arg) \
- (((index < max) && (BIT_EXTRACT_VALUE__ arg)) ? (PP_CAT(BIT_EXTRACT_FLAG_, use_bv) arg) : 0) \
- /**/
-
- #define BIT_ITER__2(macro, use_bv, max, a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15, ...) \
- (macro(use_bv, 0, max, a0) | \
- macro(use_bv, 1, max, a1) | \
- macro(use_bv, 2, max, a2) | \
- macro(use_bv, 3, max, a3) | \
- macro(use_bv, 4, max, a4) | \
- macro(use_bv, 5, max, a5) | \
- macro(use_bv, 6, max, a6) | \
- macro(use_bv, 7, max, a7) | \
- macro(use_bv, 8, max, a8) | \
- macro(use_bv, 9, max, a9) | \
- macro(use_bv, 10, max, a10) | \
- macro(use_bv, 11, max, a11) | \
- macro(use_bv, 12, max, a12) | \
- macro(use_bv, 13, max, a13) | \
- macro(use_bv, 14, max, a14) | \
- macro(use_bv, 15, max, a15)) \
- /**/
-
- #define BIT_ITER__(macro, use_bv, ...) \
- BIT_ITER__2(macro, use_bv, PP_COUNT(__VA_ARGS__), __VA_ARGS__, (0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1)) \
- /**/
-
- #define BIT_MASKS__(use_bv, ...) \
- BIT_ITER__(BIT_MASK_SINGLE__, use_bv, __VA_ARGS__)
- /**/
-
- #define BIT_MASKS_CONDITIONAL__(use_bv, ...) \
- BIT_ITER__(BIT_MASK_IF_SINGLE__, use_bv, __VA_ARGS__)
- /**/
-
- #define BIT_CHANGE__(reg, use_bv, ...) \
- ((reg) = ((reg) & ~BIT_MASKS__(use_bv, __VA_ARGS__)) | BIT_MASKS_CONDITIONAL__(use_bv, __VA_ARGS__)) \
- /**/
-
- #define BIT_CHANGE(reg, ...) BIT_CHANGE__(reg, 0, __VA_ARGS__)
- #define BIT_CHANGE_BV(reg, ...) BIT_CHANGE__(reg, 1, __VA_ARGS__)
-
-#endif /* COMPILER_VARIADIC_MACROS */
-
-#endif /* MACROS_H */
-
+++ /dev/null
-/*!
- * \file
- * <!--
- * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
- * This file is part of DevLib - See devlib/README for information.
- * -->
- *
- * \brief OS-specific definitions
- *
- * \version $Id$
- *
- * \author Bernardo Innocenti <bernie@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.1 2004/12/31 17:40:24 bernie
- *#* Add OS detection code.
- *#*
- *#*/
-#ifndef DEVLIB_OS_H
-#define DEVLIB_OS_H
-
-
-/*! Macro to include OS-specific versions of the headers. */
-#define OS_HEADER(module) PP_STRINGIZE(PP_CAT3(module, _, OS_ID).h)
-
-/*
- * OS autodetection (Some systems trigger multiple OS definitions)
- */
-#ifdef _WIN32
- #define OS_WIN32 1
- #define OS_ID win32
-#else
- #define OS_WIN32 0
-#endif
-
-#ifdef __unix__
- #define OS_UNIX 1
- #define OS_POSIX 1 /* Not strictly UNIX, but no way to autodetect it. */
- #define OS_ID unix
-#else
- #define OS_UNIX 0
- #define OS_POSIX 0
-#endif
-
-#ifdef __linux__
- #define OS_LINUX 1
-#else
- #define OS_LINUX 0
-#endif
-
-#if defined(__APPLE__) && defined(__MACH__)
- #define OS_DARWIN 1
-#else
- #define OS_DARWIN 0
-#endif
-
-/*
- * Summarize hosted environments as OS_HOSTED.
- */
-#if OS_WIN32 || OS_UNIX
- #define OS_HOSTED 1
-#else
- #define OS_HOSTED 0
-#endif
-
-/*
- * Summarize embedded environments as OS_EMBEDDED.
- */
-#if CPU_AVR || CPU_DSP56K || CPU_I196 || defined(__embedded__)
- #define OS_EMBEDDED 1
-#else
- #define OS_EMBEDDED 0
-#endif
-
-
-/* Self-check for the detection */
-#if CPU_I196 + CPU_X86 + CPU_DSP56K + CPU_AVR == 0
- #error Unknown CPU
-#endif
-#if !defined(OS_ID)
- #error OS_ID not defined
-#endif
-#if OS_HOSTED && OS_EMBEDDED
- #error Both hosted and embedded OS environment
-#endif
-#if !OS_HOSTED && !OS_EMBEDDED
- #error Neither hosted nor embedded OS environment
-#endif
-
-#endif /* DEVLIB_OS_H */