/*
* $Log$
+ * Revision 1.10 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.9 2004/07/29 22:57:09 bernie
* vsprintf(): Remove prototype for backwards compatibility with GCC 3.4; ssize_t: Add definition for inferior compilers.
*
#define COMPILER_H
#include "arch_config.h"
+#include "cpu_detect.h"
#if defined __GNUC__ && defined __GNUC_MINOR__
#define DEPRECATED __attribute__((__deprecated__))
#endif
- #if defined(__i386__)
+ #if CPU_X86
/* hack to avoid conflicts with system type */
#define sigset_t system_sigset_t
#include <stdbool.h>
#undef system_sigset_t
- #elif defined(__AVR__)
+ #elif CPU_AVR
#include <stddef.h>
#include <stdbool.h>
#define PGM_ATTR PROGMEM
#endif
- #endif /* CPU */
+ #endif
-#elif defined(__MWERKS__) && (defined(__m56800E__) || defined(__m56800__))
+#elif defined(__MWERKS__) && CPU_DSP56K
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <setjmp.h>
+ // CodeWarrior has size_t as built-in type, but does not define this symbol.
+ #define _SIZE_T_DEFINED
+
#else
#error unknown compiler
#endif
typedef unsigned short int uint16_t;
typedef unsigned long int uint32_t;
#elif defined(__AVR__)
+ /* TODO: should this detect GCC+AVR combo, or just CPU_AVR? */
/* avr-libc is weird... */
#include <inttypes.h>
#else
*
* \{
*/
-#if (defined(__m56800E__) || defined(__m56800__))
+#if CPU_DSP56K
/* Registers can be accessed only through 16-bit pointers */
typedef volatile uint16_t reg16_t;
#else
/*
* $Log$
+ * Revision 1.8 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.7 2004/07/20 23:26:48 bernie
* Fix two errors introduced by previous commit.
*
#include "compiler.h"
+
//! Initialization value for registers in stack frame
#define CPU_REG_INIT_VALUE(reg) 0
-// Macros for determining CPU endianness
+// Macros for determining CPU endianess
#define CPU_BIG_ENDIAN 0x1234
#define CPU_LITTLE_ENDIAN 0x3412
+// Macros to include cpu-specific version of the headers
+#define CPU_HEADER(module) PP_STRINGIZE(PP_CAT4(module, _, CPU_ID, .h))
-#if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__) /* 80C196 */
+
+#if CPU_I196
#define DISABLE_INTS disable_interrupt()
#define ENABLE_INTS enable_interrupt()
#define CPU_SP_ON_EMPTY_SLOT 0
#define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
-#elif defined(__i386__) || defined(_MSC_VER) /* x86 */
+#elif CPU_X86
#define NOP asm volatile ("nop")
#define DISABLE_INTS /* nothing */
#define CPU_SP_ON_EMPTY_SLOT 0
#define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
-#elif defined(__m56800E__) || defined(__m56800__) /* DSP56K */
+#elif CPU_DSP56K
#define NOP asm(nop)
#define DISABLE_INTS do { asm(bfset #0x0200,SR); asm(nop); } while (0)
#define CPU_STACK_GROWS_UPWARD 0
#define CPU_SP_ON_EMPTY_SLOT 1
#define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
-#else
- #error Unknown CPU
#endif
#endif
-#if defined(__m56800E__) || defined(__m56800__)
+#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.
/*
* $Log$
+ * Revision 1.4 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.3 2004/07/14 14:04:29 rasky
* Merge da SC: spostata bld_set inline perché si ottimizza parecchio tramite propagazione di costanti
*
#ifndef DRV_BUZZERLED_H
#define DRV_BUZZERLED_H
+#include <cpu.h>
+
/*! Include hw.h. We expect hw.h to define enum BLD_DEVICE, which must contain
* an enumarator for each device, plus a special symbol NUM_BLDS containing the
* number of devices.
* should allow fast constant propagation for the common case (where the parameter
* device is a constant).
*/
-#if defined(__m56800__)
- #include "buzzerled_dsp56k.h"
-#else
- #error Unsupported architecture
-#endif
+#include CPU_HEADER(buzzerled)
/*! Initialize the buzzerled library.
/*
* $Log$
+ * Revision 1.7 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.6 2004/07/18 21:49:28 bernie
* Add ATmega8 support.
*
#define KDBG_WRITE_CHAR(c) putchar((c))
#define KDBG_MASK_IRQ(old) do {/*nop*/} while(0)
#define KDBG_RESTORE_IRQ() do {/*nop*/} while(0)
-#elif defined(__I196__)
+#elif CPU_I196
#include "Util196.h"
#define KDBG_WAIT_READY() do {} while (!(SP_STAT & (SPSF_TX_EMPTY | SPSF_TX_INT)))
#define KDBG_WRITE_CHAR(c) do { SBUF = (c); } while(0)
INT_MASK1 &= ~INT1F_TI; \
} while(0)
#define KDBG_RESTORE_IRQ(old) do { INT_MASK1 |= (old); }
-#elif defined(__AVR__)
+#elif CPU_AVR
#include <avr/io.h>
#if CONFIG_KDEBUG_PORT == 0
#if defined(__AVR_ATmega64__)
#else
#error CONFIG_KDEBUG_PORT should be either 0 or 1
#endif
-#elif defined(__MWERKS__) && (defined(__m56800E__) || defined(__m56800__))
+#elif defined(__MWERKS__) && CPU_DSP56K
/* Debugging go through the JTAG interface. The MSL library already
implements the console I/O correctly. */
#include <stdio.h>
void kdbg_init(void)
{
-#if defined(__I196__)
+#if CPU_I196
/* Set serial port for 19200bps 8N1 */
INT_MASK1 &= ~(INT1F_TI | INT1F_RI);
BAUD_RATE = 0x33;
BAUD_RATE = 0x80;
-#elif defined(__AVR__)
+#elif CPU_AVR
/* Compute the baud rate */
uint16_t period = (((CLOCK_FREQ / 16UL) + (CONFIG_KDEBUG_BAUDRATE / 2)) / CONFIG_KDEBUG_BAUDRATE) - 1;
#error Unknown arch
#endif
-#endif /* !__I196__ && !__AVR__ */
+#endif /* !CPU_I196 && !CPU_AVR */
kputs("\n\n*** DBG START ***\n");
}
/*
* $Log$
+ * Revision 1.7 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.6 2004/07/29 22:57:09 bernie
* ser_drain(): New function; Make Serial::is_open a debug-only feature; Switch to new-style CONFIG_* macros.
*
* which are from 0x0100 to 0x8000
*/
/*\{*/
-#if defined(__AVR__)
+#if CPU_AVR
typedef uint8_t serstatus_t;
/* Software errors */
#define SERRF_RXSROVERRUN BV(3) /*!< Rx shift register overrun */
#define SERRF_FRAMEERROR BV(4) /*!< Stop bit missing */
#define SERRF_PARITYERROR BV(7) /*!< Parity error */
-#elif defined(__m56800__)
+#elif CPU_DSP56K
typedef uint16_t serstatus_t;
/* Software errors */
*/
enum
{
-#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
+#if defined(CPU_AVR_ATMEGA64) || defined(CPU_AVR_ATMEGA128)
SER_UART0,
SER_UART1,
SER_SPI,
-#elif defined(__AVR_ATmega103__) || defined(__AVR_ATmega8__)
+#elif defined(CPU_AVR_ATMEGA103) || defined(CPU_AVR_ATMEGA8)
SER_UART0,
SER_SPI,
-#elif defined (__m56800__)
+#elif CPU_DSP56K
SER_UART0,
SER_UART1,
#else
/*
* $Log$
+ * Revision 1.10 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.9 2004/07/21 00:15:13 bernie
* Put timer driver on diet.
*
#include "hw.h"
#include "kdebug.h"
#include "timer.h"
+#include CPU_HEADER(timer)
#if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
#include <kern/proc.h>
#endif
-#if defined(ARCH_EMUL) && (ARCH & ARCH_EMUL)
- #error To be recoded
-#elif defined(__AVR__)
- #include "timer_avr.h"
-#elif defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__) /* 80C196 */
- #include "timer_i196.h"
-#elif defined (__m56800__)
- #include "timer_dsp56k.h"
-#else
- #error Unknown system
-#endif
-
-
//! Master system clock (1ms accuracy)
volatile time_t _clock;
/*
* $Log$
+ * Revision 1.11 2004/07/30 14:15:53 rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
* Revision 1.10 2004/07/29 22:57:09 bernie
* Doxygen fix.
*
}
-#if !defined(__AVR__)
+#if !CPU_AVR
/* No tricks needed on 16/32bit CPUs */
# define fifo_isempty_locked(fb) fifo_isempty((fb))
# define fifo_push_locked(fb, c) fifo_push((fb), (c))
-# define fifo_flush_locked(fb, c) fifo_flush((fb), (c))
+# define fifo_flush_locked(fb) fifo_flush((fb))
-#else /* !__AVR__ */
+#else /* !CPU_AVR */
/*!
* Similar to fifo_isempty(), but with stronger guarantees for