Sistema l'errore da me commesso in fase di conversione...
[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 #ifndef CPU_DETECT_H
12 #define CPU_DETECT_H
13
14 #if defined(__arm__) /* GCC */ \
15         || defined(__ARM4TM__) /* IAR: defined for all cores >= 4tm */
16         #define CPU_ARM                 1
17         #define CPU_ID                  arm
18 #else
19         #define CPU_ARM                 0
20 #endif
21
22 #if (defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)) \
23         && !defined(__ARM4TM__) /* IAR: if not ARM assume I196 */
24         #warning Assuming CPU is I196
25         #define CPU_I196                1
26         #define CPU_ID                  i196
27 #else
28         #define CPU_I196                0
29 #endif
30
31 #if defined(__i386__) /* GCC */ \
32         || (defined(_M_IX86) && !defined(_WIN64)) /* MSVC */
33         #define CPU_X86                 1
34         #define CPU_X86_32              1
35         #define CPU_X86_64              0
36         #define CPU_ID                  x86
37 #elif defined(__x86_64__) /* GCC */ \
38         || (defined(_M_IX86) && defined(_WIN64)) /* MSVC */
39         #define CPU_X86                 1
40         #define CPU_X86_32              0
41         #define CPU_X86_64              1
42         #define CPU_ID                  x86
43 #else
44         #define CPU_X86                 0
45         #define CPU_I386                0
46         #define CPU_X86_64              0
47 #endif
48
49 #if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
50         #define CPU_PPC                 1
51         #define CPU_ID                  ppc
52         #if defined(_ARCH_PPC)
53                 #define CPU_PPC32       1
54         #else
55                 #define CPU_PPC32       0
56         #endif
57         #if defined(_ARCH_PPC64)
58                 #define CPU_PPC64       1
59         #else
60                 #define CPU_PPC64       0
61         #endif
62 #else
63         #define CPU_PPC                 0
64         #define CPU_PPC32               0
65         #define CPU_PPC64               0
66 #endif
67
68 #if defined(__m56800E__) || defined(__m56800__)
69         #define CPU_DSP56K              1
70         #define CPU_ID                  dsp56k
71 #else
72         #define CPU_DSP56K              0
73 #endif
74
75 #if defined (__AVR__)
76         #define CPU_AVR                 1
77         #define CPU_ID                  avr
78
79         #if defined(__AVR_ATmega64__)
80                 #define CPU_AVR_ATMEGA64    1
81         #else
82                 #define CPU_AVR_ATMEGA64    0
83         #endif
84
85         #if defined(__AVR_ATmega103__)
86                 #define CPU_AVR_ATMEGA103   1
87         #else
88                 #define CPU_AVR_ATMEGA103   0
89         #endif
90
91         #if defined(__AVR_ATmega128__)
92                 #define CPU_AVR_ATMEGA128   1
93         #else
94                 #define CPU_AVR_ATMEGA128   0
95         #endif
96
97         #if defined(__AVR_ATmega8__)
98                 #define CPU_AVR_ATMEGA8     1
99         #else
100                 #define CPU_AVR_ATMEGA8     0
101         #endif
102
103         #if defined(__AVR_ATmega168__)
104                 #define CPU_AVR_ATMEGA168   1
105         #else
106                 #define CPU_AVR_ATMEGA168   0
107         #endif
108
109         #if defined(__AVR_ATmega1281__)
110                 #define CPU_AVR_ATMEGA1281  1
111         #else
112                 #define CPU_AVR_ATMEGA1281  0
113         #endif
114 #else
115         #define CPU_AVR                 0
116         #define CPU_AVR_ATMEGA8         0
117         #define CPU_AVR_ATMEGA168       0
118         #define CPU_AVR_ATMEGA64        0
119         #define CPU_AVR_ATMEGA103       0
120         #define CPU_AVR_ATMEGA128       0
121         #define CPU_AVR_ATMEGA1281      0
122 #endif
123
124
125 /* Self-check for the detection: only one CPU must be detected */
126 #if CPU_ARM + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR == 0
127         #error Unknown CPU
128 #elif !defined(CPU_ID)
129         #error CPU_ID not defined
130 #elif CPU_ARM + CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR != 1
131         #error Internal CPU configuration error
132 #endif
133
134
135 #endif /* CPU_DETECT_H */