• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2014 The Android Open Source Project
4  *  Copyright 2002 - 2004 Open Interface North America, Inc. All rights
5  *                        reserved.
6  *
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at:
10  *
11  *  http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *
19  ******************************************************************************/
20 #ifndef _OI_CPU_DEP_H
21 #define _OI_CPU_DEP_H
22 
23 #include <stdint.h>
24 
25 /**
26  * @file
27  * This file contains definitions for characteristics of the target CPU and
28  * compiler, including primitive data types and endianness.
29  *
30  * This file defines the byte order and primitive data types for various
31  * CPU families. The preprocessor symbol 'CPU' must be defined to be an
32  * appropriate value or this header will generate a compile-time error.
33  *
34  * @note The documentation for this header file uses the x86 family of
35  * processors as an illustrative example for CPU/compiler-dependent data type
36  * definitions. Go to the source code of this header file to see the details of
37  * primitive type definitions for each platform.
38  *
39  * Additional information is available in the @ref data_types_docpage section.
40  */
41 
42 /*******************************************************************************
43   $Revision: #1 $
44  ******************************************************************************/
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /** \addtogroup Misc Miscellaneous APIs */
51 /**@{*/
52 
53 /** @name Definitions indicating family of target OI_CPU_TYPE
54  *  @{
55  */
56 
57 #define OI_CPU_X86 1 /**< x86 processor family */
58 #define OI_CPU_ARM                            \
59   2 /**< ARM processor family.                \
60          @deprecated Use #OI_CPU_ARM7_LEND or \
61          #OI_CPU_ARM7_BEND. */
62 #define OI_CPU_ARC                                               \
63   3                     /**< ARC processor family.               \
64                              @deprecated Use #OI_CPU_ARC_LEND or \
65                              #OI_CPU_ARC_BEND. */
66 #define OI_CPU_SH3 4    /**< Hitachi SH-3 processor family */
67 #define OI_CPU_H8 5     /**< Hitachi H8 processor family */
68 #define OI_CPU_MIPS 6   /**< MIPS processor family */
69 #define OI_CPU_SPARC 7  /**< SPARC processor family */
70 #define OI_CPU_M68000 8 /**< Motorola M68000 processor family */
71 #define OI_CPU_PPC 9    /**< PowerPC (PPC) processor family */
72 #define OI_CPU_SH4_7750 \
73   10                  /**< Hitachi SH7750 series in SH-4 processor family */
74 #define OI_CPU_SH2 11 /**< Hitachi SH-2 processor family */
75 #define OI_CPU_ARM7_LEND 12 /**< ARM7, little-endian */
76 #define OI_CPU_ARM7_BEND 13 /**< ARM7, big-endian */
77 #define OI_CPU_GDM1202 14   /**< GCT GDM1202 */
78 #define OI_CPU_ARC_LEND 15  /**< ARC processor family, little-endian */
79 #define OI_CPU_ARC_BEND 16  /**< ARC processor family, big-endian */
80 #define OI_CPU_M30833F 17   /**< Mitsubishi M308 processor family */
81 #define OI_CPU_CR16C 18  /**< National Semiconductor 16 bit processor family */
82 #define OI_CPU_M64111 19 /**< Renesas M64111 processor (M32R family) */
83 #define OI_CPU_ARMV5_LEND 20  //*< ARM5, little-endian */
84 
85 #define OI_CPU_TYPE 12
86 
87 #ifndef OI_CPU_TYPE
88 #error "OI_CPU_TYPE type not defined"
89 #endif
90 
91 /**@}*/
92 
93 /** @name Definitions indicating byte-wise endianness of target CPU
94  *  @{
95  */
96 
97 #define OI_BIG_ENDIAN_BYTE_ORDER                                           \
98   0 /**< Multiple-byte values are stored in memory beginning with the most \
99        significant byte at the lowest address.  */
100 #define OI_LITTLE_ENDIAN_BYTE_ORDER                                         \
101   1 /**< Multiple-byte values are stored in memory beginning with the least \
102        significant byte at the lowest address. */
103 
104 /**@}*/
105 
106 /** @name  CPU/compiler-independent primitive data type definitions
107  *  @{
108  */
109 
110 typedef int
111     OI_BOOL; /**< Boolean values use native integer data type for target CPU. */
112 typedef int
113     OI_INT; /**< Integer values use native integer data type for target CPU. */
114 typedef unsigned int OI_UINT;  /**< Unsigned integer values use native unsigned
115                                   integer data type for target CPU. */
116 typedef unsigned char OI_BYTE; /**< Raw bytes type uses native character data
117                                   type for target CPU. */
118 typedef uint32_t OI_ELEMENT_UNION; /**< Type for first element of a union to
119                                       support all data types up to pointer
120                                       width. */
121 
122 /**@}*/
123 
124 /******************************************************************************/
125 
126 #if OI_CPU_TYPE == OI_CPU_X86
127 
128 #define OI_CPU_BYTE_ORDER                                                      \
129   OI_LITTLE_ENDIAN_BYTE_ORDER /**< x86 platform byte ordering is little-endian \
130                                  */
131 
132 #endif
133 
134 /******************************************************************************/
135 
136 #if OI_CPU_TYPE == OI_CPU_ARM
137 /* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARM7_LEND
138  * or OI_CPU_ARM7_BEND for little-endian or big-endian configurations of the
139  * ARM7, respectively. */
140 #error OI_CPU_ARM is deprecated
141 #endif
142 
143 /******************************************************************************/
144 
145 #if OI_CPU_TYPE == OI_CPU_ARC
146 /* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARC_LEND
147  * or OI_CPU_ARC_BEND for little-endian or big-endian configurations of the
148  * ARC, respectively. */
149 #error OI_CPU_ARC is deprecated
150 #endif
151 
152 /******************************************************************************/
153 
154 #if OI_CPU_TYPE == OI_CPU_SH3
155 /* The Hitachi SH C compiler defines _LIT or _BIG, depending on the endianness
156     specified to the compiler on the command line. */
157 #if defined(_LIT)
158 #define OI_CPU_BYTE_ORDER                                                 \
159   OI_LITTLE_ENDIAN_BYTE_ORDER /**< If _LIT is defined, SH-3 platform byte \
160                                  ordering is little-endian. */
161 #elif defined(_BIG)
162 #define OI_CPU_BYTE_ORDER                                              \
163   OI_BIG_ENDIAN_BYTE_ORDER /**< If _BIG is defined, SH-3 platform byte \
164                               ordering is big-endian. */
165 #else
166 #error SH compiler endianness undefined
167 #endif
168 
169 #endif
170 /******************************************************************************/
171 
172 #if OI_CPU_TYPE == OI_CPU_SH2
173 
174 #define OI_CPU_BYTE_ORDER \
175   OI_BIG_ENDIAN_BYTE_ORDER /**< SH-2 platform byte ordering is big-endian. */
176 
177 #endif
178 /******************************************************************************/
179 
180 #if OI_CPU_TYPE == OI_CPU_H8
181 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
182 #error basic types not defined
183 #endif
184 
185 /******************************************************************************/
186 
187 #if OI_CPU_TYPE == OI_CPU_MIPS
188 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
189 #endif
190 
191 /******************************************************************************/
192 
193 #if OI_CPU_TYPE == OI_CPU_SPARC
194 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
195 #error basic types not defined
196 #endif
197 
198 /******************************************************************************/
199 
200 #if OI_CPU_TYPE == OI_CPU_M68000
201 #define OI_CPU_BYTE_ORDER                                                    \
202   OI_BIG_ENDIAN_BYTE_ORDER /**< M68000 platform byte ordering is big-endian. \
203                               */
204 #endif
205 
206 /******************************************************************************/
207 
208 #if OI_CPU_TYPE == OI_CPU_PPC
209 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
210 #endif
211 
212 /******************************************************************************/
213 
214 #if OI_CPU_TYPE == OI_CPU_SH4_7750
215 #define OI_CPU_BYTE_ORDER                                                    \
216   OI_BIG_ENDIAN_BYTE_ORDER /**< SH7750 platform byte ordering is big-endian. \
217                               */
218 #endif
219 
220 /******************************************************************************/
221 
222 #if OI_CPU_TYPE == OI_CPU_ARM7_LEND
223 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
224 #endif
225 
226 /******************************************************************************/
227 
228 #if OI_CPU_TYPE == OI_CPU_ARM7_BEND
229 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
230 #endif
231 
232 /******************************************************************************/
233 
234 #if OI_CPU_TYPE == OI_CPU_GDM1202
235 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
236 #endif
237 
238 /******************************************************************************/
239 
240 #if OI_CPU_TYPE == OI_CPU_ARC_LEND
241 
242 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
243 #endif
244 
245 /******************************************************************************/
246 
247 #if OI_CPU_TYPE == OI_CPU_ARC_BEND
248 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
249 #endif
250 
251 /******************************************************************************/
252 
253 #if OI_CPU_TYPE == OI_CPU_M30833F
254 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
255 #endif
256 
257 /******************************************************************************/
258 
259 #if OI_CPU_TYPE == OI_CPU_CR16C
260 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
261 #endif
262 
263 /******************************************************************************/
264 
265 #if OI_CPU_TYPE == OI_CPU_M64111
266 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER
267 #endif
268 
269 /******************************************************************************/
270 
271 #if OI_CPU_TYPE == OI_CPU_ARMV5_LEND
272 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER
273 #endif
274 
275 /******************************************************************************/
276 
277 #ifndef OI_CPU_BYTE_ORDER
278 #error "Byte order (endian-ness) not defined"
279 #endif
280 
281 /**@}*/
282 
283 #ifdef __cplusplus
284 }
285 #endif
286 
287 /******************************************************************************/
288 #endif /* _OI_CPU_DEP_H */
289