4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2004, 2005, 2006, 2007 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 2004 Giovanni Bajo
34 * \brief CPU detection through special preprocessor macros
39 #if defined(__ARM_ARCH_4T__) /* GCC */ \
40 || defined(__ARM4TM__) /* IAR: defined for all cores >= 4tm */
44 // AT91SAM7S core family
45 #if defined(__ARM_AT91SAM7S32__)
46 #define CPU_ARM_AT91 1
47 #define CPU_ARM_AT91SAM7S32 1
49 #define CPU_ARM_AT91SAM7S32 0
52 #if defined(__ARM_AT91SAM7S64__)
53 #define CPU_ARM_AT91 1
54 #define CPU_ARM_SAM7S_LARGE 1
55 #define CPU_ARM_AT91SAM7S64 1
57 #define CPU_ARM_AT91SAM7S64 0
60 #if defined(__ARM_AT91SAM7S128__)
61 #define CPU_ARM_AT91 1
62 #define CPU_ARM_SAM7S_LARGE 1
63 #define CPU_ARM_AT91SAM7S128 1
65 #define CPU_ARM_AT91SAM7S128 0
68 #if defined(__ARM_AT91SAM7S256__)
69 #define CPU_ARM_AT91 1
70 #define CPU_ARM_SAM7S_LARGE 1
71 #define CPU_ARM_AT91SAM7S256 1
73 #define CPU_ARM_AT91SAM7S256 0
76 #if defined(__ARM_AT91SAM7S512__)
77 #define CPU_ARM_AT91 1
78 #define CPU_ARM_SAM7S_LARGE 1
79 #define CPU_ARM_AT91SAM7S512 1
81 #define CPU_ARM_AT91SAM7S512 0
84 // AT91SAM7X core family
85 #if defined(__ARM_AT91SAM7X128__)
86 #define CPU_ARM_AT91 1
87 #define CPU_ARM_SAM7X 1
88 #define CPU_ARM_AT91SAM7X128 1
90 #define CPU_ARM_AT91SAM7X128 0
93 #if defined(__ARM_AT91SAM7X256__)
94 #define CPU_ARM_AT91 1
95 #define CPU_ARM_SAM7X 1
96 #define CPU_ARM_AT91SAM7X256 1
98 #define CPU_ARM_AT91SAM7X256 0
102 #if defined(__ARM_AT91SAM7X512__)
103 #define CPU_ARM_AT91 1
104 #define CPU_ARM_SAM7X 1
105 #define CPU_ARM_AT91SAM7X512 1
107 #define CPU_ARM_AT91SAM7X512 0
110 #if defined(__ARM_LPC2378__)
111 #define CPU_ARM_LPC2 1
112 #define CPU_ARM_LPC2378 1
114 #define CPU_ARM_LPC2378 0
117 #if !defined(CPU_ARM_SAM7S_LARGE)
118 #define CPU_ARM_SAM7S_LARGE 0
121 #if !defined(CPU_ARM_SAM7X)
122 #define CPU_ARM_SAM7X 0
126 #if defined(CPU_ARM_AT91)
127 #if CPU_ARM_AT91SAM7S32 + CPU_ARM_AT91SAM7S64 \
128 + CPU_ARM_AT91SAM7S128 + CPU_ARM_AT91SAM7S256 \
129 + CPU_ARM_AT91SAM7S512 \
130 + CPU_ARM_AT91SAM7X128 + CPU_ARM_AT91SAM7X256 \
131 + CPU_ARM_AT91SAM7X512 != 1
132 #error ARM CPU configuration error
134 #define CPU_ARM_LPC2 0
136 #elif defined (CPU_ARM_LPC2)
138 #if CPU_ARM_LPC2378 + 0 != 1
139 #error NXP LPC2xxx ARM CPU configuration error
141 #define CPU_ARM_AT91 0
142 /* #elif Add other ARM families here */
144 #define CPU_ARM_AT91 0
145 #define CPU_ARM_LPC2 0
149 #if CPU_ARM_AT91 + CPU_ARM_LPC2 + 0 /* Add other ARM families here */ != 1
150 #error ARM CPU configuration error
156 #define CPU_ARM_AT91 0
157 #define CPU_ARM_LPC2 0
159 /* SAM7 sub-families */
160 #define CPU_ARM_SAM7S_LARGE 0
161 #define CPU_ARM_SAM7X 0
164 #define CPU_ARM_AT91SAM7S32 0
165 #define CPU_ARM_AT91SAM7S64 0
166 #define CPU_ARM_AT91SAM7S128 0
167 #define CPU_ARM_AT91SAM7S256 0
168 #define CPU_ARM_AT91SAM7S512 0
169 #define CPU_ARM_AT91SAM7X128 0
170 #define CPU_ARM_AT91SAM7X256 0
171 #define CPU_ARM_AT91SAM7X512 0
173 #define CPU_ARM_LPC2378 0
176 #if defined(__ARM_ARCH_7M__)
181 #if defined (__ARM_LM3S1968__)
182 #define CPU_CM3_LM3S 1
183 #define CPU_CM3_LM3S1968 1
185 #define CPU_CM3_LM3S1968 0
188 #if defined (__ARM_LM3S8962__)
189 #define CPU_CM3_LM3S 1
190 #define CPU_CM3_LM3S8962 1
192 #define CPU_CM3_LM3S8962 0
195 #if defined (__ARM_STM32F103RB__)
196 #define CPU_CM3_STM32 1
197 #define CPU_CM3_STM32F103RB 1
199 #define CPU_CM3_STM32F103RB 0
202 #if defined (CPU_CM3_LM3S)
203 #if CPU_CM3_LM3S1968 + CPU_CM3_LM3S8962 + 0 != 1
204 #error Luminary Cortex-M3 CPU configuration error
206 #define CPU_CM3_STM32 0
207 #elif defined (CPU_CM3_STM32)
208 #if CPU_CM3_STM32F103RB + 0 != 1
209 #error STM32 Cortex-M3 CPU configuration error
211 #define CPU_CM3_LM3S 0
212 /* #elif Add other Cortex-M3 families here */
214 #define CPU_CM3_LM3S 0
215 #define CPU_CM3_STM32 0
219 #if CPU_CM3_LM3S + CPU_CM3_STM32 + 0 /* Add other Cortex-M3 families here */ != 1
220 #error Cortex-M3 CPU configuration error
226 #define CPU_CM3_LM3S 0
228 #define CPU_CM3_LM3S1968 0
230 #define CPU_CM3_LM3S8968 0
232 #define CPU_CM3_STM32 0
234 #define CPU_CM3_STM32F103RB 0
237 #if (defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)) \
238 && !defined(__ARM4TM__) /* IAR: if not ARM assume I196 */
239 #warning Assuming CPU is I196
246 #if defined(__i386__) /* GCC */ \
247 || (defined(_M_IX86) && !defined(_WIN64)) /* MSVC */
252 #elif defined(__x86_64__) /* GCC */ \
253 || (defined(_M_IX86) && defined(_WIN64)) /* MSVC */
264 #if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
267 #if defined(_ARCH_PPC)
272 #if defined(_ARCH_PPC64)
283 #if defined(__m56800E__) || defined(__m56800__)
285 #define CPU_ID dsp56k
290 #if defined (__AVR__)
294 #if defined(__AVR_ATmega32__)
295 #define CPU_AVR_ATMEGA32 1
297 #define CPU_AVR_ATMEGA32 0
300 #if defined(__AVR_ATmega64__)
301 #define CPU_AVR_ATMEGA64 1
303 #define CPU_AVR_ATMEGA64 0
306 #if defined(__AVR_ATmega103__)
307 #define CPU_AVR_ATMEGA103 1
309 #define CPU_AVR_ATMEGA103 0
312 #if defined(__AVR_ATmega128__)
313 #define CPU_AVR_ATMEGA128 1
315 #define CPU_AVR_ATMEGA128 0
318 #if defined(__AVR_ATmega8__)
319 #define CPU_AVR_ATMEGA8 1
321 #define CPU_AVR_ATMEGA8 0
324 #if defined(__AVR_ATmega168__)
325 #define CPU_AVR_ATMEGA168 1
327 #define CPU_AVR_ATMEGA168 0
330 #if defined(__AVR_ATmega328P__)
331 #define CPU_AVR_ATMEGA328P 1
333 #define CPU_AVR_ATMEGA328P 0
336 #if defined(__AVR_ATmega1281__)
337 #define CPU_AVR_ATMEGA1281 1
339 #define CPU_AVR_ATMEGA1281 0
342 #if defined(__AVR_ATmega1280__)
343 #define CPU_AVR_ATMEGA1280 1
345 #define CPU_AVR_ATMEGA1280 0
348 #if CPU_AVR_ATMEGA32 + CPU_AVR_ATMEGA64 + CPU_AVR_ATMEGA103 + CPU_AVR_ATMEGA128 \
349 + CPU_AVR_ATMEGA8 + CPU_AVR_ATMEGA168 + CPU_AVR_ATMEGA328P + CPU_AVR_ATMEGA1281 \
350 + CPU_AVR_ATMEGA1280 != 1
351 #error AVR CPU configuration error
355 #define CPU_AVR_ATMEGA8 0
356 #define CPU_AVR_ATMEGA168 0
357 #define CPU_AVR_ATMEGA328P 0
358 #define CPU_AVR_ATMEGA32 0
359 #define CPU_AVR_ATMEGA64 0
360 #define CPU_AVR_ATMEGA103 0
361 #define CPU_AVR_ATMEGA128 0
362 #define CPU_AVR_ATMEGA1281 0
363 #define CPU_AVR_ATMEGA1280 0
366 #if defined (__MSP430__)
368 #define CPU_ID msp430
370 #if defined(__MSP430_2274__)
371 #define CPU_MSP430_2274 1
373 #define CPU_MSP430_2274 0
380 /* Self-check for the detection: only one CPU must be detected */
381 #if CPU_ARM + CPU_CM3 + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR + CPU_MSP430 == 0
383 #elif !defined(CPU_ID)
384 #error CPU_ID not defined
385 #elif CPU_ARM + CPU_CM3 + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR + CPU_MSP430 != 1
386 #error Internal CPU configuration error
390 #endif /* CPU_DETECT_H */