1 /* SPDX-License-Identifier: BSD-3-Clause */
7 * Describes compiler dependencies - to support several compile time environments
9 * Contains compiler environment porting descriptions
11 * @xrefitem bom "File Content Label" "Release Content"
13 * @e sub-project: Includes
14 * @e \$Revision: 44324 $ @e \$Date: 2010-12-22 03:16:51 -0600 (Wed, 22 Dec 2010) $
16 /*****************************************************************************
18 * Copyright (c) 2008 - 2013, Advanced Micro Devices, Inc.
19 * All rights reserved.
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 ***************************************************************************/
45 #include <check_for_wrapper.h>
50 #if defined (_MSC_VER)
54 #pragma warning(disable: 4103 4001 4733)
55 #pragma intrinsic (_disable, _enable)
57 // -----------------------------------------------------------------------
58 // Define a code_seg MACRO
60 #define MAKE_AS_A_STRING(arg) #arg
62 #define CODE_GROUP(arg) __pragma (code_seg (MAKE_AS_A_STRING (.t##arg)))
64 #define RDATA_GROUP(arg) __pragma (const_seg (MAKE_AS_A_STRING (.d##arg)))
65 #define FUNC_ATTRIBUTE(arg) __declspec(arg)
66 //#include <intrin.h> // MS has built-in functions
69 // -----------------------------------------------------------------------
70 // Assume MSVC 1.52C (16-bit)
72 // NOTE: When using MSVC 1.52C use the following command line:
74 // CL.EXE /G3 /AL /O1i /Fa <FILENAME.C>
76 // This will produce 32-bit code in USE16 segment that is optimized for code
80 // Create the universal 32, 16, and 8-bit data types
81 typedef unsigned long UINTN
;
83 typedef unsigned long UINT32
;
85 typedef unsigned int UINT16
;
87 typedef unsigned char UINT8
;
89 typedef unsigned short CHAR16
;
91 /// struct for 16-bit environment handling of 64-bit value
92 typedef struct _UINT64
{
93 IN OUT UINT32 lo
; ///< lower 32-bits of 64-bit value
94 IN OUT UINT32 hi
; ///< highest 32-bits of 64-bit value
97 // Create the Boolean type
100 typedef unsigned char BOOLEAN
;
103 #define STATIC static
104 #define VOLATILE volatile
105 #define CALLCONV __pascal
106 #define ROMDATA __based( __segname( "_CODE" ) )
107 #define _16BYTE_ALIGN __declspec(align(16))
108 #define _8BYTE_ALIGN __declspec(align(8))
109 #define _4BYTE_ALIGN __declspec(align(4))
110 #define _2BYTE_ALIGN __declspec(align(2))
111 #define _1BYTE_ALIGN __declspec(align(1))
113 // Force tight packing of structures
114 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
115 #pragma warning( disable : 4103 ) // Disable '#pragma pack' in .h warning
118 // Disable WORD->BYTE automatic conversion warnings. Example:
120 // void MyFunc(BYTE val);
122 // MyFunc(LocalByte*2+1); // Warning, automatic conversion
124 // The problem is any time math is performed on a BYTE, it is converted to a
125 // WORD by MSVC 1.52c, and then when it is converted back to a BYTE, a warning
126 // is generated. Disable warning C4761
127 #pragma warning( disable : 4761 )
130 // -----------------------------------------------------------------------
131 // Assume a 32-bit MSVC++
133 // Disable the following warnings:
134 // 4100 - 'identifier' : unreferenced formal parameter
135 // 4276 - 'function' : no prototype provided; assumed no parameters
136 // 4214 - non standard extension used : bit field types other than int
137 // 4001 - nonstandard extension 'single line comment' was used
138 // 4142 - benign redefinition of type for following declaration
139 // - typedef char INT8
140 #if defined (_M_IX86)
141 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306)
146 // Create the universal 32, 16, and 8-bit data types
148 typedef unsigned __w64 UINTN
;
150 typedef __int64 INT64
;
151 typedef unsigned __int64 UINT64
;
153 typedef unsigned int UINT32
;
155 typedef unsigned short UINT16
;
157 typedef unsigned char UINT8
;
159 typedef unsigned short CHAR16
;
161 // Create the Boolean type
168 typedef unsigned char BOOLEAN
;
170 // Force tight packing of structures
171 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
175 #define STATIC static
176 #define VOLATILE volatile
179 #define _16BYTE_ALIGN __declspec(align(64))
180 #define _8BYTE_ALIGN __declspec(align(8))
181 #define _4BYTE_ALIGN __declspec(align(4))
182 #define _2BYTE_ALIGN __declspec(align(2))
183 #define _1BYTE_ALIGN __declspec(align(1))
184 //Support for variadic macros was introduced in Visual C++ 2005.
186 #define VA_ARGS_SUPPORTED
188 // 64 bit of compiler
190 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306 4366)
195 // Create the universal 32, 16, and 8-bit data types
197 typedef unsigned __int64 UINTN
;
199 typedef __int64 INT64
;
200 typedef unsigned __int64 UINT64
;
202 typedef unsigned int UINT32
;
204 typedef unsigned short UINT16
;
206 typedef unsigned char UINT8
;
208 typedef unsigned short CHAR16
;
210 // Create the Boolean type
217 typedef unsigned char BOOLEAN
;
218 #define _16BYTE_ALIGN __declspec(align(16))
219 #define _8BYTE_ALIGN __declspec(align(8))
220 #define _4BYTE_ALIGN __declspec(align(4))
221 #define _2BYTE_ALIGN __declspec(align(2))
222 #define _1BYTE_ALIGN __declspec(align(1))
223 // Force tight packing of structures
224 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
228 #define STATIC static
229 #define VOLATILE volatile
234 // -----------------------------------------------------------------------
235 // End of MS compiler versions
237 #elif defined __GNUC__
243 #define STATIC static
244 #define VOLATILE volatile
250 #define _16BYTE_ALIGN __attribute__((aligned (16)))
251 #define _8BYTE_ALIGN __attribute__((aligned (8)))
252 #define _4BYTE_ALIGN __attribute__((aligned (4)))
253 #define _2BYTE_ALIGN __attribute__((aligned (2)))
254 #define _1BYTE_ALIGN __attribute__((aligned (1)))
256 typedef uintptr_t UINTN
;
257 typedef int64_t INT64
;
258 typedef uint64_t UINT64
;
259 typedef int32_t INT32
;
260 typedef uint32_t UINT32
;
261 typedef int16_t INT16
;
262 typedef uint16_t UINT16
;
264 typedef uint8_t UINT8
;
266 typedef unsigned short CHAR16
;
267 typedef unsigned char BOOLEAN
;
270 #define CODE_GROUP(arg)
271 #define RDATA_GROUP(arg)
275 #define FUNC_ATTRIBUTE(arg) __attribute__((arg))
276 #define MAKE_AS_A_STRING(arg) #arg
278 #include <gcc-intrin.h>
281 //#include <console/console.h>
282 //#include <commonlib/loglevel.h>
285 #define NULL ((void *)0)
289 // -----------------------------------------------------------------------
290 // Unknown or unsupported compiler
292 #error "Unknown compiler in use"
295 // -----------------------------------------------------------------------
296 // Common definitions for all compilers
299 //Support forward reference construct
300 #define AGESA_FORWARD_DECLARATION(x) typedef struct _##x x
302 // The following are use in conformance to the UEFI style guide
306 #endif // _PORTING_H_