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 10 /**< Hitachi SH7750 series in SH-4 processor family */ 73 #define OI_CPU_SH2 11 /**< Hitachi SH-2 processor family */ 74 #define OI_CPU_ARM7_LEND 12 /**< ARM7, little-endian */ 75 #define OI_CPU_ARM7_BEND 13 /**< ARM7, big-endian */ 76 #define OI_CPU_GDM1202 14 /**< GCT GDM1202 */ 77 #define OI_CPU_ARC_LEND 15 /**< ARC processor family, little-endian */ 78 #define OI_CPU_ARC_BEND 16 /**< ARC processor family, big-endian */ 79 #define OI_CPU_M30833F 17 /**< Mitsubishi M308 processor family */ 80 #define OI_CPU_CR16C 18 /**< National Semiconductor 16 bit processor family */ 81 #define OI_CPU_M64111 19 /**< Renesas M64111 processor (M32R family) */ 82 #define OI_CPU_ARMV5_LEND 20 //*< ARM5, little-endian */ 83 84 #define OI_CPU_TYPE 12 85 86 #ifndef OI_CPU_TYPE 87 #error "OI_CPU_TYPE type not defined" 88 #endif 89 90 /**@}*/ 91 92 /** @name Definitions indicating byte-wise endianness of target CPU 93 * @{ 94 */ 95 96 #define OI_BIG_ENDIAN_BYTE_ORDER \ 97 0 /**< Multiple-byte values are stored in memory beginning with the most \ 98 significant byte at the lowest address. */ 99 #define OI_LITTLE_ENDIAN_BYTE_ORDER \ 100 1 /**< Multiple-byte values are stored in memory beginning with the least \ 101 significant byte at the lowest address. */ 102 103 /**@}*/ 104 105 /** @name CPU/compiler-independent primitive data type definitions 106 * @{ 107 */ 108 109 typedef int OI_BOOL; /**< Boolean values use native integer data type for target CPU. */ 110 typedef int OI_INT; /**< Integer values use native integer data type for target CPU. */ 111 typedef unsigned int OI_UINT; /**< Unsigned integer values use native unsigned 112 integer data type for target CPU. */ 113 typedef unsigned char OI_BYTE; /**< Raw bytes type uses native character data 114 type for target CPU. */ 115 typedef uint32_t OI_ELEMENT_UNION; /**< Type for first element of a union to 116 support all data types up to pointer 117 width. */ 118 119 /**@}*/ 120 121 /******************************************************************************/ 122 123 #if OI_CPU_TYPE == OI_CPU_X86 124 125 #define OI_CPU_BYTE_ORDER \ 126 OI_LITTLE_ENDIAN_BYTE_ORDER /**< x86 platform byte ordering is little-endian \ 127 */ 128 129 #endif 130 131 /******************************************************************************/ 132 133 #if OI_CPU_TYPE == OI_CPU_ARM 134 /* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARM7_LEND 135 * or OI_CPU_ARM7_BEND for little-endian or big-endian configurations of the 136 * ARM7, respectively. */ 137 #error OI_CPU_ARM is deprecated 138 #endif 139 140 /******************************************************************************/ 141 142 #if OI_CPU_TYPE == OI_CPU_ARC 143 /* This CPU type is deprecated (removed from use). Instead, use OI_CPU_ARC_LEND 144 * or OI_CPU_ARC_BEND for little-endian or big-endian configurations of the 145 * ARC, respectively. */ 146 #error OI_CPU_ARC is deprecated 147 #endif 148 149 /******************************************************************************/ 150 151 #if OI_CPU_TYPE == OI_CPU_SH3 152 /* The Hitachi SH C compiler defines _LIT or _BIG, depending on the endianness 153 specified to the compiler on the command line. */ 154 #if defined(_LIT) 155 #define OI_CPU_BYTE_ORDER \ 156 OI_LITTLE_ENDIAN_BYTE_ORDER /**< If _LIT is defined, SH-3 platform byte \ 157 ordering is little-endian. */ 158 #elif defined(_BIG) 159 #define OI_CPU_BYTE_ORDER \ 160 OI_BIG_ENDIAN_BYTE_ORDER /**< If _BIG is defined, SH-3 platform byte \ 161 ordering is big-endian. */ 162 #else 163 #error SH compiler endianness undefined 164 #endif 165 166 #endif 167 /******************************************************************************/ 168 169 #if OI_CPU_TYPE == OI_CPU_SH2 170 171 #define OI_CPU_BYTE_ORDER \ 172 OI_BIG_ENDIAN_BYTE_ORDER /**< SH-2 platform byte ordering is big-endian. */ 173 174 #endif 175 /******************************************************************************/ 176 177 #if OI_CPU_TYPE == OI_CPU_H8 178 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER 179 #error basic types not defined 180 #endif 181 182 /******************************************************************************/ 183 184 #if OI_CPU_TYPE == OI_CPU_MIPS 185 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 186 #endif 187 188 /******************************************************************************/ 189 190 #if OI_CPU_TYPE == OI_CPU_SPARC 191 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 192 #error basic types not defined 193 #endif 194 195 /******************************************************************************/ 196 197 #if OI_CPU_TYPE == OI_CPU_M68000 198 #define OI_CPU_BYTE_ORDER \ 199 OI_BIG_ENDIAN_BYTE_ORDER /**< M68000 platform byte ordering is big-endian. \ 200 */ 201 #endif 202 203 /******************************************************************************/ 204 205 #if OI_CPU_TYPE == OI_CPU_PPC 206 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER 207 #endif 208 209 /******************************************************************************/ 210 211 #if OI_CPU_TYPE == OI_CPU_SH4_7750 212 #define OI_CPU_BYTE_ORDER \ 213 OI_BIG_ENDIAN_BYTE_ORDER /**< SH7750 platform byte ordering is big-endian. \ 214 */ 215 #endif 216 217 /******************************************************************************/ 218 219 #if OI_CPU_TYPE == OI_CPU_ARM7_LEND 220 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 221 #endif 222 223 /******************************************************************************/ 224 225 #if OI_CPU_TYPE == OI_CPU_ARM7_BEND 226 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER 227 #endif 228 229 /******************************************************************************/ 230 231 #if OI_CPU_TYPE == OI_CPU_GDM1202 232 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER 233 #endif 234 235 /******************************************************************************/ 236 237 #if OI_CPU_TYPE == OI_CPU_ARC_LEND 238 239 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 240 #endif 241 242 /******************************************************************************/ 243 244 #if OI_CPU_TYPE == OI_CPU_ARC_BEND 245 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER 246 #endif 247 248 /******************************************************************************/ 249 250 #if OI_CPU_TYPE == OI_CPU_M30833F 251 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 252 #endif 253 254 /******************************************************************************/ 255 256 #if OI_CPU_TYPE == OI_CPU_CR16C 257 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 258 #endif 259 260 /******************************************************************************/ 261 262 #if OI_CPU_TYPE == OI_CPU_M64111 263 #define OI_CPU_BYTE_ORDER OI_BIG_ENDIAN_BYTE_ORDER 264 #endif 265 266 /******************************************************************************/ 267 268 #if OI_CPU_TYPE == OI_CPU_ARMV5_LEND 269 #define OI_CPU_BYTE_ORDER OI_LITTLE_ENDIAN_BYTE_ORDER 270 #endif 271 272 /******************************************************************************/ 273 274 #ifndef OI_CPU_BYTE_ORDER 275 #error "Byte order (endian-ness) not defined" 276 #endif 277 278 /**@}*/ 279 280 #ifdef __cplusplus 281 } 282 #endif 283 284 /******************************************************************************/ 285 #endif /* _OI_CPU_DEP_H */ 286