Remove unneede dir.
[bertos.git] / cpu / detect.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
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.
10  *
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.
15  *
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
19  *
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.
28  *
29  * Copyright 2004, 2005, 2006, 2007 Develer S.r.l. (http://www.develer.com/)
30  * Copyright 2004 Giovanni Bajo
31  *
32  * -->
33  *
34  * \brief CPU detection through special preprocessor macros
35  */
36 #ifndef CPU_DETECT_H
37 #define CPU_DETECT_H
38
39 #if defined(__arm__) /* GCC */ \
40         || defined(__ARM4TM__) /* IAR: defined for all cores >= 4tm */
41         #define CPU_ARM                 1
42         #define CPU_ID                  arm
43
44         #if defined(__ARM_AT91SAM7S32__)
45                 #define CPU_ARM_AT91         1
46                 #define CPU_ARM_AT91SAM7S32  1
47         #else
48                 #define CPU_ARM_AT91         0
49                 #define CPU_ARM_AT91SAM7S32  0
50         #endif
51
52         #if defined(__ARM_AT91SAM7S64__)
53                 #define CPU_ARM_AT91         1
54                 #define CPU_ARM_AT91SAM7S64  1
55         #else
56                 #define CPU_ARM_AT91         0
57                 #define CPU_ARM_AT91SAM7S64  0
58         #endif
59
60         #if defined(__ARM_AT91SAM7S128__)
61                 #define CPU_ARM_AT91         1
62                 #define CPU_ARM_AT91SAM7S128 1
63         #else
64                 #define CPU_ARM_AT91         0
65                 #define CPU_ARM_AT91SAM7S128 0
66         #endif
67
68         #if defined(__ARM_AT91SAM7S256__)
69                 #define CPU_ARM_AT91         1
70                 #define CPU_ARM_AT91SAM7S256 1
71         #else
72                 #define CPU_ARM_AT91         0
73                 #define CPU_ARM_AT91SAM7S256 0
74         #endif
75
76         #if CPU_ARM_AT91SAM7S32 + CPU_ARM_AT91SAM7S64 \
77           + CPU_ARM_AT91SAM7S128 + CPU_ARM_AT91SAM7S256 != 1
78                 #error ARM CPU configuration error
79         #endif
80
81         #if CPU_ARM_AT91 + 0 /* Add other ARM families here */ != 1
82                 #error ARM CPU configuration error
83         #endif
84 #else
85         #define CPU_ARM                 0
86
87         /* ARM Families */
88         #define CPU_ARM_AT91            0
89
90         /* ARM CPUs */
91         #define CPU_ARM_AT91SAM7S32     0
92         #define CPU_ARM_AT91SAM7S64     0
93         #define CPU_ARM_AT91SAM7S128    0
94         #define CPU_ARM_AT91SAM7S256    0
95 #endif
96
97 #if (defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)) \
98         && !defined(__ARM4TM__) /* IAR: if not ARM assume I196 */
99         #warning Assuming CPU is I196
100         #define CPU_I196                1
101         #define CPU_ID                  i196
102 #else
103         #define CPU_I196                0
104 #endif
105
106 #if defined(__i386__) /* GCC */ \
107         || (defined(_M_IX86) && !defined(_WIN64)) /* MSVC */
108         #define CPU_X86                 1
109         #define CPU_X86_32              1
110         #define CPU_X86_64              0
111         #define CPU_ID                  x86
112 #elif defined(__x86_64__) /* GCC */ \
113         || (defined(_M_IX86) && defined(_WIN64)) /* MSVC */
114         #define CPU_X86                 1
115         #define CPU_X86_32              0
116         #define CPU_X86_64              1
117         #define CPU_ID                  x86
118 #else
119         #define CPU_X86                 0
120         #define CPU_I386                0
121         #define CPU_X86_64              0
122 #endif
123
124 #if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
125         #define CPU_PPC                 1
126         #define CPU_ID                  ppc
127         #if defined(_ARCH_PPC)
128                 #define CPU_PPC32       1
129         #else
130                 #define CPU_PPC32       0
131         #endif
132         #if defined(_ARCH_PPC64)
133                 #define CPU_PPC64       1
134         #else
135                 #define CPU_PPC64       0
136         #endif
137 #else
138         #define CPU_PPC                 0
139         #define CPU_PPC32               0
140         #define CPU_PPC64               0
141 #endif
142
143 #if defined(__m56800E__) || defined(__m56800__)
144         #define CPU_DSP56K              1
145         #define CPU_ID                  dsp56k
146 #else
147         #define CPU_DSP56K              0
148 #endif
149
150 #if defined (__AVR__)
151         #define CPU_AVR                 1
152         #define CPU_ID                  avr
153
154         #if defined(__AVR_ATmega64__)
155                 #define CPU_AVR_ATMEGA64    1
156         #else
157                 #define CPU_AVR_ATMEGA64    0
158         #endif
159
160         #if defined(__AVR_ATmega103__)
161                 #define CPU_AVR_ATMEGA103   1
162         #else
163                 #define CPU_AVR_ATMEGA103   0
164         #endif
165
166         #if defined(__AVR_ATmega128__)
167                 #define CPU_AVR_ATMEGA128   1
168         #else
169                 #define CPU_AVR_ATMEGA128   0
170         #endif
171
172         #if defined(__AVR_ATmega8__)
173                 #define CPU_AVR_ATMEGA8     1
174         #else
175                 #define CPU_AVR_ATMEGA8     0
176         #endif
177
178         #if defined(__AVR_ATmega168__)
179                 #define CPU_AVR_ATMEGA168   1
180         #else
181                 #define CPU_AVR_ATMEGA168   0
182         #endif
183
184         #if defined(__AVR_ATmega1281__)
185                 #define CPU_AVR_ATMEGA1281  1
186         #else
187                 #define CPU_AVR_ATMEGA1281  0
188         #endif
189
190         #if CPU_AVR_ATMEGA64 + CPU_AVR_ATMEGA103 + CPU_AVR_ATMEGA128 \
191           + CPU_AVR_ATMEGA8 + CPU_AVR_ATMEGA168 + CPU_AVR_ATMEGA1281 != 1
192                 #error AVR CPU configuration error
193         #endif
194 #else
195         #define CPU_AVR                 0
196         #define CPU_AVR_ATMEGA8         0
197         #define CPU_AVR_ATMEGA168       0
198         #define CPU_AVR_ATMEGA64        0
199         #define CPU_AVR_ATMEGA103       0
200         #define CPU_AVR_ATMEGA128       0
201         #define CPU_AVR_ATMEGA1281      0
202 #endif
203
204
205 /* Self-check for the detection: only one CPU must be detected */
206 #if CPU_ARM + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR == 0
207         #error Unknown CPU
208 #elif !defined(CPU_ID)
209         #error CPU_ID not defined
210 #elif CPU_ARM + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR != 1
211         #error Internal CPU configuration error
212 #endif
213
214
215 #endif /* CPU_DETECT_H */