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 03:16:51 -0600 (Wed, 22 Dec 2010) $
14 /*****************************************************************************
16 * Copyright (c) 2008 - 2013, 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.
41 ***************************************************************************/
46 #if defined (_MSC_VER)
50 #pragma warning(disable: 4103 4001 4733)
51 #pragma intrinsic (_disable, _enable)
53 // -----------------------------------------------------------------------
54 // Define a code_seg MACRO
56 #define MAKE_AS_A_STRING(arg) #arg
58 #define CODE_GROUP(arg) __pragma (code_seg (MAKE_AS_A_STRING (.t##arg)))
60 #define RDATA_GROUP(arg) __pragma (const_seg (MAKE_AS_A_STRING (.d##arg)))
61 #define FUNC_ATTRIBUTE(arg) __declspec(arg)
62 //#include <intrin.h> // MS has built-in functions
65 // -----------------------------------------------------------------------
66 // Assume MSVC 1.52C (16-bit)
68 // NOTE: When using MSVC 1.52C use the following command line:
70 // CL.EXE /G3 /AL /O1i /Fa <FILENAME.C>
72 // This will produce 32-bit code in USE16 segment that is optimized for code
76 // Create the universal 32, 16, and 8-bit data types
77 typedef unsigned long UINTN
;
79 typedef unsigned long UINT32
;
81 typedef unsigned int UINT16
;
83 typedef unsigned char UINT8
;
85 typedef unsigned short CHAR16
;
87 /// struct for 16-bit environment handling of 64-bit value
88 typedef struct _UINT64
{
89 IN OUT UINT32 lo
; ///< lower 32-bits of 64-bit value
90 IN OUT UINT32 hi
; ///< highest 32-bits of 64-bit value
93 // Create the Boolean type
96 typedef unsigned char BOOLEAN
;
100 #define VOLATILE volatile
101 #define CALLCONV __pascal
102 #define ROMDATA __based( __segname( "_CODE" ) )
103 #define _16BYTE_ALIGN __declspec(align(16))
104 #define _8BYTE_ALIGN __declspec(align(8))
105 #define _4BYTE_ALIGN __declspec(align(4))
106 #define _2BYTE_ALIGN __declspec(align(2))
107 #define _1BYTE_ALIGN __declspec(align(1))
109 // Force tight packing of structures
110 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
111 #pragma warning( disable : 4103 ) // Disable '#pragma pack' in .h warning
114 // Disable WORD->BYTE automatic conversion warnings. Example:
116 // void MyFunc(BYTE val);
118 // MyFunc(LocalByte*2+1); // Warning, automatic conversion
120 // The problem is any time math is performed on a BYTE, it is converted to a
121 // WORD by MSVC 1.52c, and then when it is converted back to a BYTE, a warning
122 // is generated. Disable warning C4761
123 #pragma warning( disable : 4761 )
126 // -----------------------------------------------------------------------
127 // Assume a 32-bit MSVC++
129 // Disable the following warnings:
130 // 4100 - 'identifier' : unreferenced formal parameter
131 // 4276 - 'function' : no prototype provided; assumed no parameters
132 // 4214 - non standard extension used : bit field types other than int
133 // 4001 - nonstandard extension 'single line comment' was used
134 // 4142 - benign redefinition of type for following declaration
135 // - typedef char INT8
136 #if defined (_M_IX86)
137 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306)
142 // Create the universal 32, 16, and 8-bit data types
144 typedef unsigned __w64 UINTN
;
146 typedef __int64 INT64
;
147 typedef unsigned __int64 UINT64
;
149 typedef unsigned int UINT32
;
151 typedef unsigned short UINT16
;
153 typedef unsigned char UINT8
;
155 typedef unsigned short CHAR16
;
157 // Create the Boolean type
164 typedef unsigned char BOOLEAN
;
166 // Force tight packing of structures
167 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
171 #define STATIC static
172 #define VOLATILE volatile
175 #define _16BYTE_ALIGN __declspec(align(64))
176 #define _8BYTE_ALIGN __declspec(align(8))
177 #define _4BYTE_ALIGN __declspec(align(4))
178 #define _2BYTE_ALIGN __declspec(align(2))
179 #define _1BYTE_ALIGN __declspec(align(1))
180 //Support for variadic macros was introduced in Visual C++ 2005.
182 #define VA_ARGS_SUPPORTED
184 // 64 bit of compiler
186 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306 4366)
191 // Create the universal 32, 16, and 8-bit data types
193 typedef unsigned __int64 UINTN
;
195 typedef __int64 INT64
;
196 typedef unsigned __int64 UINT64
;
198 typedef unsigned int UINT32
;
200 typedef unsigned short UINT16
;
202 typedef unsigned char UINT8
;
204 typedef unsigned short CHAR16
;
206 // Create the Boolean type
213 typedef unsigned char BOOLEAN
;
214 #define _16BYTE_ALIGN __declspec(align(16))
215 #define _8BYTE_ALIGN __declspec(align(8))
216 #define _4BYTE_ALIGN __declspec(align(4))
217 #define _2BYTE_ALIGN __declspec(align(2))
218 #define _1BYTE_ALIGN __declspec(align(1))
219 // Force tight packing of structures
220 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
224 #define STATIC static
225 #define VOLATILE volatile
230 // -----------------------------------------------------------------------
231 // End of MS compiler versions
233 #elif defined __GNUC__
239 #define STATIC static
240 #define VOLATILE volatile
246 #define _16BYTE_ALIGN __attribute__((aligned (16)))
247 #define _8BYTE_ALIGN __attribute__((aligned (8)))
248 #define _4BYTE_ALIGN __attribute__((aligned (4)))
249 #define _2BYTE_ALIGN __attribute__((aligned (2)))
250 #define _1BYTE_ALIGN __attribute__((aligned (1)))
252 typedef uintptr_t UINTN
;
253 typedef int64_t INT64
;
254 typedef uint64_t UINT64
;
255 typedef int32_t INT32
;
256 typedef uint32_t UINT32
;
257 typedef int16_t INT16
;
258 typedef uint16_t UINT16
;
260 typedef uint8_t UINT8
;
262 typedef unsigned short CHAR16
;
263 typedef unsigned char BOOLEAN
;
266 #define CODE_GROUP(arg)
267 #define RDATA_GROUP(arg)
271 #define FUNC_ATTRIBUTE(arg) __attribute__((arg))
272 #define MAKE_AS_A_STRING(arg) #arg
274 #include <gcc-intrin.h>
277 //#include <console/console.h>
278 //#include <commonlib/loglevel.h>
281 #define NULL ((void *)0)
285 // -----------------------------------------------------------------------
286 // Unknown or unsupported compiler
288 #error "Unknown compiler in use"
291 // -----------------------------------------------------------------------
292 // Common definitions for all compilers
295 //Support forward reference construct
296 #define AGESA_FORWARD_DECLARATION(x) typedef struct _##x x
298 // The following are use in conformance to the UEFI style guide
302 #endif // _PORTING_H_