From: rasky Date: Fri, 30 Jul 2004 14:15:53 +0000 (+0000) Subject: Nuovo supporto unificato per detect della CPU X-Git-Tag: 1.0.0~1152 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=d8c41d44af59c3b699736024da1ccc11efa52384;p=bertos.git Nuovo supporto unificato per detect della CPU git-svn-id: https://src.develer.com/svnoss/bertos/trunk@89 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/compiler.h b/compiler.h index e15059e2..863fbbe4 100755 --- a/compiler.h +++ b/compiler.h @@ -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__ @@ -125,7 +129,7 @@ #define DEPRECATED __attribute__((__deprecated__)) #endif - #if defined(__i386__) + #if CPU_X86 /* hack to avoid conflicts with system type */ #define sigset_t system_sigset_t @@ -134,7 +138,7 @@ #include #undef system_sigset_t - #elif defined(__AVR__) + #elif CPU_AVR #include #include @@ -151,15 +155,18 @@ #define PGM_ATTR PROGMEM #endif - #endif /* CPU */ + #endif -#elif defined(__MWERKS__) && (defined(__m56800E__) || defined(__m56800__)) +#elif defined(__MWERKS__) && CPU_DSP56K #include #include #include #include + // 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 #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 4715908b..c8a242f2 100755 --- 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. * @@ -44,15 +47,19 @@ #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) @@ -144,8 +151,6 @@ #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 @@ -192,7 +197,7 @@ #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. diff --git a/drv/buzzerled.h b/drv/buzzerled.h index ec1c6530..cbf24369 100755 --- a/drv/buzzerled.h +++ b/drv/buzzerled.h @@ -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 + /*! 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. @@ -40,11 +45,7 @@ * 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. diff --git a/drv/kdebug.c b/drv/kdebug.c index e631eabb..943148b3 100755 --- a/drv/kdebug.c +++ b/drv/kdebug.c @@ -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 #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 @@ -97,7 +100,7 @@ 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"); } diff --git a/drv/ser.h b/drv/ser.h index 57d66cb0..e4350556 100755 --- 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 */ @@ -92,14 +95,14 @@ */ 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 diff --git a/drv/timer.c b/drv/timer.c index 06213368..f471cb57 100755 --- a/drv/timer.c +++ b/drv/timer.c @@ -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. * @@ -44,24 +47,12 @@ #include "hw.h" #include "kdebug.h" #include "timer.h" +#include CPU_HEADER(timer) #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS #include #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; diff --git a/mware/fifobuf.h b/mware/fifobuf.h index 67528b97..a643a7e6 100755 --- a/mware/fifobuf.h +++ b/mware/fifobuf.h @@ -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