Convert to new Doxygen style.
[bertos.git] / cfg / cpu_detect.h
1 /**
2  * \file
3  * <!--
4  * Copyright 2004, 2005 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 2004 Giovanni Bajo
6  * This file is part of DevLib - See README.devlib for information.
7  * -->
8  *
9  * \brief CPU detection through special preprocessor macros
10  *
11  */
12
13 /*#*
14  *#* $Log$
15  *#* Revision 1.4  2006/07/19 12:56:25  bernie
16  *#* Convert to new Doxygen style.
17  *#*
18  *#* Revision 1.3  2006/02/10 12:37:37  bernie
19  *#* Add support for ARM on IAR.
20  *#*
21  *#* Revision 1.2  2005/06/14 06:15:10  bernie
22  *#* Add X86_64 support.
23  *#*
24  *#* Revision 1.1  2005/04/11 19:04:13  bernie
25  *#* Move top-level headers to cfg/ subdir.
26  *#*
27  *#* Revision 1.4  2005/02/16 20:33:24  bernie
28  *#* Preliminary PPC support.
29  *#*
30  *#* Revision 1.3  2004/12/31 17:39:26  bernie
31  *#* Use C89 comments only.
32  *#*
33  *#* Revision 1.2  2004/08/25 14:12:08  rasky
34  *#* Aggiornato il comment block dei log RCS
35  *#*
36  *#* Revision 1.1  2004/07/30 17:14:49  rasky
37  *#* File sfuggito al commit precedente (nuova gestione unificata del detect della CPU
38  *#*
39  *#* Revision 1.2  2004/07/30 10:31:07  rasky
40  *#* Aggiunto detect per ATmega128
41  *#*/
42
43 #ifndef CPU_DETECT_H
44 #define CPU_DETECT_H
45
46 #if defined(__arm__) /* GCC */ \
47         || defined(__ARM4TM__) /* IAR: defined for all cores >= 4tm */
48         #define CPU_ARM                 1
49         #define CPU_ID                  arm
50 #else
51         #define CPU_ARM                 0
52 #endif
53
54 #if (defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)) \
55         && !defined(__ARM4TM__) /* IAR: if not ARM assume I196 */
56         #define CPU_I196                1
57         #define CPU_ID                  i196
58 #else
59         #define CPU_I196                0
60 #endif
61
62 #if defined(__i386__) /* GCC */ \
63         || (defined(_M_IX86) && !defined(_WIN64)) /* MSVC */
64         #define CPU_X86                 1
65         #define CPU_X86_32              1
66         #define CPU_X86_64              0
67         #define CPU_ID                  x86
68 #elif defined(__x86_64__) /* GCC */ \
69         || (defined(_M_IX86) && defined(_WIN64)) /* MSVC */
70         #define CPU_X86                 1
71         #define CPU_X86_32              0
72         #define CPU_X86_64              1
73         #define CPU_ID                  x86
74 #else
75         #define CPU_X86                 0
76         #define CPU_I386                0
77         #define CPU_X86_64              0
78 #endif
79
80 #if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
81         #define CPU_PPC                 1
82         #define CPU_ID                  ppc
83         #if defined(_ARCH_PPC)
84                 #define CPU_PPC32       1
85         #else
86                 #define CPU_PPC32       0
87         #endif
88         #if defined(_ARCH_PPC64)
89                 #define CPU_PPC64       1
90         #else
91                 #define CPU_PPC64       0
92         #endif
93 #else
94         #define CPU_PPC                 0
95         #define CPU_PPC32               0
96         #define CPU_PPC64               0
97 #endif
98
99 #if defined(__m56800E__) || defined(__m56800__)
100         #define CPU_DSP56K              1
101         #define CPU_ID                  dsp56k
102 #else
103         #define CPU_DSP56K              0
104 #endif
105
106 #if defined (__AVR__)
107         #define CPU_AVR                 1
108         #define CPU_ID                  avr
109
110         #if defined(__AVR_ATmega64__)
111                 #define CPU_AVR_ATMEGA64    1
112         #else
113                 #define CPU_AVR_ATMEGA64    0
114         #endif
115
116         #if defined(__AVR_ATmega103__)
117                 #define CPU_AVR_ATMEGA103   1
118         #else
119                 #define CPU_AVR_ATMEGA103   0
120         #endif
121
122         #if defined(__AVR_ATmega128__)
123                 #define CPU_AVR_ATMEGA128   1
124         #else
125                 #define CPU_AVR_ATMEGA128   0
126         #endif
127
128         #if defined(__AVR_ATmega8__)
129                 #define CPU_AVR_ATMEGA8     1
130         #else
131                 #define CPU_AVR_ATMEGA8     0
132         #endif
133 #else
134         #define CPU_AVR                 0
135         #define CPU_AVR_ATMEGA8         0
136         #define CPU_AVR_ATMEGA64        0
137         #define CPU_AVR_ATMEGA103       0
138         #define CPU_AVR_ATMEGA128       0
139 #endif
140
141
142 /* Self-check for the detection: only one CPU must be detected */
143 #if CPU_ARM + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR == 0
144         #error Unknown CPU
145 #elif !defined(CPU_ID)
146         #error CPU_ID not defined
147 #elif CPU_ARM + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR != 1
148         #error Internal CPU configuration error
149 #endif
150
151
152 #endif /* CPU_DETECT_H */