Import into DevLib.
[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.1  2005/04/11 19:04:13  bernie
16  *#* Move top-level headers to cfg/ subdir.
17  *#*
18  *#* Revision 1.4  2005/02/16 20:33:24  bernie
19  *#* Preliminary PPC support.
20  *#*
21  *#* Revision 1.3  2004/12/31 17:39:26  bernie
22  *#* Use C89 comments only.
23  *#*
24  *#* Revision 1.2  2004/08/25 14:12:08  rasky
25  *#* Aggiornato il comment block dei log RCS
26  *#*
27  *#* Revision 1.1  2004/07/30 17:14:49  rasky
28  *#* File sfuggito al commit precedente (nuova gestione unificata del detect della CPU
29  *#*
30  *#* Revision 1.2  2004/07/30 10:31:07  rasky
31  *#* Aggiunto detect per ATmega128
32  *#*/
33
34 #ifndef CPU_DETECT_H
35 #define CPU_DETECT_H
36
37 #if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
38         #define CPU_I196                1
39         #define CPU_ID                  i196
40 #else
41         #define CPU_I196                0
42 #endif
43
44 #if defined(__i386__) || defined(_MSC_VER)
45         #define CPU_X86                 1
46         #define CPU_ID                  x86
47 #else
48         #define CPU_X86                 0
49 #endif
50
51 #if defined (_ARCH_PPC) || defined(_ARCH_PPC64)
52         #define CPU_PPC                 1
53         #define CPU_ID                  ppc
54         #if defined(_ARCH_PPC)
55                 #define CPU_PPC32       1
56         #else
57                 #define CPU_PPC32       0
58         #endif
59         #if defined(_ARCH_PPC64)
60                 #define CPU_PPC64       1
61         #else
62                 #define CPU_PPC64       0
63         #endif
64 #else
65         #define CPU_PPC                 0
66         #define CPU_PPC32               0
67         #define CPU_PPC64               0
68 #endif
69
70 #if defined(__m56800E__) || defined(__m56800__)
71         #define CPU_DSP56K              1
72         #define CPU_ID                  dsp56k
73 #else
74         #define CPU_DSP56K              0
75 #endif
76
77 #if defined (__AVR__)
78         #define CPU_AVR                 1
79         #define CPU_ID                  avr
80
81         #if defined(__AVR_ATmega64__)
82                 #define CPU_AVR_ATMEGA64    1
83         #else
84                 #define CPU_AVR_ATMEGA64    0
85         #endif
86
87         #if defined(__AVR_ATmega103__)
88                 #define CPU_AVR_ATMEGA103   1
89         #else
90                 #define CPU_AVR_ATMEGA103   0
91         #endif
92
93         #if defined(__AVR_ATmega128__)
94                 #define CPU_AVR_ATMEGA128   1
95         #else
96                 #define CPU_AVR_ATMEGA128   0
97         #endif
98
99         #if defined(__AVR_ATmega8__)
100                 #define CPU_AVR_ATMEGA8     1
101         #else
102                 #define CPU_AVR_ATMEGA8     0
103         #endif
104 #else
105         #define CPU_AVR                 0
106         #define CPU_AVR_ATMEGA8         0
107         #define CPU_AVR_ATMEGA64        0
108         #define CPU_AVR_ATMEGA103       0
109         #define CPU_AVR_ATMEGA128       0
110 #endif
111
112
113 /* Self-check for the detection: only one CPU must be detected */
114 #if CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR == 0
115         #error Unknown CPU
116 #elif !defined(CPU_ID)
117         #error CPU_ID not defined
118 #elif CPU_I196 + CPU_X86 + CPU_PPC + CPU_DSP56K + CPU_AVR != 1
119         #error Internal CPU configuration error
120 #endif
121
122
123 #endif /* CPU_DETECT_H */