5 * Describes compiler dependencies - to support several compile time environments
7 * Contains compiler environment porting descriptions
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: Includes
12 * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 02:16:51 -0700 (Wed, 22 Dec 2010) $
14 /*****************************************************************************
16 * Copyright (C) 2012 Advanced Micro Devices, Inc.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are met:
21 * * Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * * Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
34 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 ***************************************************************************/
47 #if defined (_MSC_VER)
51 #pragma warning(disable: 4103 4001 4733)
52 #pragma intrinsic (_disable, _enable)
54 // -----------------------------------------------------------------------
55 // Define a code_seg MACRO
57 #define MAKE_AS_A_STRING(arg) #arg
59 #define CODE_GROUP(arg) __pragma (code_seg (MAKE_AS_A_STRING (.t##arg)))
61 #define RDATA_GROUP(arg) __pragma (const_seg (MAKE_AS_A_STRING (.d##arg)))
63 //#include <intrin.h> // MS has built-in functions
66 // -----------------------------------------------------------------------
67 // Assume MSVC 1.52C (16-bit)
69 // NOTE: When using MSVC 1.52C use the following command line:
71 // CL.EXE /G3 /AL /O1i /Fa <FILENAME.C>
73 // This will produce 32-bit code in USE16 segment that is optimized for code
77 // Create the universal 32, 16, and 8-bit data types
78 typedef unsigned long UINTN;
80 typedef unsigned long UINT32;
82 typedef unsigned int UINT16;
84 typedef unsigned char UINT8;
86 typedef unsigned short CHAR16;
88 /// struct for 16-bit environment handling of 64-bit value
89 typedef struct _UINT64 {
90 IN OUT UINT32 lo; ///< lower 32-bits of 64-bit value
91 IN OUT UINT32 hi; ///< highest 32-bits of 64-bit value
94 // Create the Boolean type
97 typedef unsigned char BOOLEAN;
100 #define STATIC static
101 #define VOLATILE volatile
102 #define CALLCONV __pascal
103 #define ROMDATA __based( __segname( "_CODE" ) )
104 #define _16BYTE_ALIGN __declspec(align(16))
106 // Force tight packing of structures
107 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
108 #pragma warning( disable : 4103 ) // Disable '#pragma pack' in .h warning
111 // Disable WORD->BYTE automatic conversion warnings. Example:
113 // void MyFunc(BYTE val);
115 // MyFunc(LocalByte*2+1); // Warning, automatic conversion
117 // The problem is any time math is performed on a BYTE, it is converted to a
118 // WORD by MSVC 1.52c, and then when it is converted back to a BYTE, a warning
119 // is generated. Disable warning C4761
120 #pragma warning( disable : 4761 )
123 // -----------------------------------------------------------------------
124 // Assume a 32-bit MSVC++
126 // Disable the following warnings:
127 // 4100 - 'identifier' : unreferenced formal parameter
128 // 4276 - 'function' : no prototype provided; assumed no parameters
129 // 4214 - non standard extension used : bit field types other than int
130 // 4001 - nonstandard extension 'single line comment' was used
131 // 4142 - benign redefinition of type for following declaration
132 // - typedef char INT8
133 #if defined (_M_IX86)
134 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306)
139 // Create the universal 32, 16, and 8-bit data types
141 typedef unsigned __w64 UINTN;
143 typedef __int64 INT64;
144 typedef unsigned __int64 UINT64;
146 typedef unsigned int UINT32;
148 typedef unsigned short UINT16;
150 typedef unsigned char UINT8;
152 typedef unsigned short CHAR16;
154 // Create the Boolean type
161 typedef unsigned char BOOLEAN;
163 // Force tight packing of structures
164 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
168 #define STATIC static
169 #define VOLATILE volatile
172 #define _16BYTE_ALIGN __declspec(align(64))
173 // 64 bit of compiler
175 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306 4366)
180 // Create the universal 32, 16, and 8-bit data types
182 typedef unsigned __int64 UINTN;
184 typedef __int64 INT64;
185 typedef unsigned __int64 UINT64;
187 typedef unsigned int UINT32;
189 typedef unsigned short UINT16;
191 typedef unsigned char UINT8;
193 typedef unsigned short CHAR16;
195 // Create the Boolean type
202 typedef unsigned char BOOLEAN;
204 // Force tight packing of structures
205 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
209 #define STATIC static
210 #define VOLATILE volatile
215 // -----------------------------------------------------------------------
216 // End of MS compiler versions
219 #elif defined __GNUC__
223 #define STATIC static
224 #define VOLATILE volatile
230 #define _16BYTE_ALIGN __attribute__ ((aligned (16)))
232 typedef unsigned char BOOLEAN;
233 typedef signed char INT8;
234 typedef signed short INT16;
235 typedef signed long INT32;
236 typedef unsigned char CHAR8;
237 typedef unsigned char UINT8;
238 typedef unsigned short UINT16;
239 typedef unsigned long UINT32;
240 typedef unsigned long UINTN;
241 typedef unsigned long long UINT64;
243 //typedef unsigned long size_t;
244 //typedef unsigned int uintptr_t;
245 // Force tight packing of structures
246 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
249 #define CODE_GROUP(arg)
250 #define RDATA_GROUP(arg)
252 #define FUNC_ATTRIBUTE(arg) __attribute__((arg))
253 #define MAKE_AS_A_STRING(arg) #arg
255 // -----------------------------------------------------------------------
256 // Common definitions for all compilers
259 #include "gcc-intrin.h"
262 #include <console/console.h>
263 #include <console/loglevel.h>
265 #define NULL (void *)0
269 // -----------------------------------------------------------------------
270 // Unknown or unsupported compiler
272 #error "Unknown compiler in use"
277 // -----------------------------------------------------------------------
278 // Common definitions for all compilers
281 //Support forward reference construct
282 #define AGESA_FORWARD_DECLARATION(x) typedef struct _##x x
285 // The following are use in conformance to the UEFI style guide
289 #endif // _PORTING_H_