Nuovo supporto unificato per detect della CPU
authorrasky <rasky@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 30 Jul 2004 14:15:53 +0000 (14:15 +0000)
committerrasky <rasky@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 30 Jul 2004 14:15:53 +0000 (14:15 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@89 38d2e660-2303-0410-9eaa-f027e97ec537

compiler.h
cpu.h
drv/buzzerled.h
drv/kdebug.c
drv/ser.h
drv/timer.c
mware/fifobuf.h

index e15059e229c35ecc670e06a87de2972dfeebb5b3..863fbbe40266c92375c02dd1076f0ccfcdfef1e9 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*
  * $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.
  *
@@ -50,6 +53,7 @@
 #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
@@ -301,6 +308,7 @@ typedef unsigned char page_t;
        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
@@ -316,7 +324,7 @@ typedef unsigned char page_t;
  *
  * \{
  */
-#if (defined(__m56800E__) || defined(__m56800__))
+#if CPU_DSP56K
        /* Registers can be accessed only through 16-bit pointers */
        typedef volatile uint16_t  reg16_t;
 #else
diff --git a/cpu.h b/cpu.h
index 4715908b3d5666804b1a7209fb8f2f7a1ffdb41e..c8a242f22645931af2252572d9ed3d8027a21d46 100755 (executable)
--- a/cpu.h
+++ b/cpu.h
@@ -17,6 +17,9 @@
 
 /*
  * $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()
@@ -66,7 +73,7 @@
        #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 */
@@ -80,7 +87,7 @@
        #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.
index ec1c65309615fc0b9865de774ed13c40513c5840..cbf243690abbc67086102c124f4488e2f5a6a02f 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*
  * $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
  *
@@ -29,6 +32,8 @@
 #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.
index e631eabb4d09683f123e321d79ac84d51719d9a6..943148b3d7013978b6ec865428b968c8426426b2 100755 (executable)
@@ -16,6 +16,9 @@
 
 /*
  * $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.
  *
@@ -49,7 +52,7 @@
        #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)
@@ -59,7 +62,7 @@
                        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__)
@@ -82,7 +85,7 @@
        #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);
@@ -107,7 +110,7 @@ void kdbg_init(void)
        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;
@@ -131,7 +134,7 @@ void kdbg_init(void)
                #error Unknown arch
        #endif
 
-#endif /* !__I196__ && !__AVR__ */
+#endif /* !CPU_I196 && !CPU_AVR */
 
        kputs("\n\n*** DBG START ***\n");
 }
index 57d66cb0b4aa5556fe699ef8205c8061d8e47fe4..e43505566443e6adfc9b817a29c9961596fe106c 100755 (executable)
--- a/drv/ser.h
+++ b/drv/ser.h
@@ -14,6 +14,9 @@
 
 /*
  * $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.
  *
@@ -48,7 +51,7 @@
  *        which are from 0x0100 to 0x8000
  */
 /*\{*/
-#if defined(__AVR__)
+#if CPU_AVR
        typedef uint8_t serstatus_t;
 
        /* Software errors */
@@ -60,7 +63,7 @@
        #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
index 0621336856fb561587d4d7ea00a68ae2f4be7ad0..f471cb57ad7ac3824ddda0429153430542d5b08d 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*
  * $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;
 
index 67528b97dd2170567d5abda0be9883977284fe10..a643a7e6ed2e2fe9a0986fd9d3ad2f2e5596755a 100755 (executable)
@@ -43,6 +43,9 @@
 
 /*
  * $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.
  *
@@ -184,14 +187,14 @@ INLINE void fifo_flush(FIFOBuffer *fb)
 }
 
 
-#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