mb/google/nissa/var/pujjo: Add new supported memory part
[coreboot2.git] / src / vendorcode / amd / include / Porting.h
blobed1a9c707ee3fc08e7e6babcd4d6c3354481ace2
1 /* $NoKeywords:$ */
2 /**
3 * @file
5 * Describes compiler dependencies - to support several compile time environments
7 * Contains compiler environment porting descriptions
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
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 ***************************************************************************/
43 #ifndef _PORTING_H_
44 #define _PORTING_H_
46 #if defined (_MSC_VER)
47 #include <intrin.h>
48 void _disable (void);
49 void _enable (void);
50 #pragma warning(disable: 4103 4001 4733)
51 #pragma intrinsic (_disable, _enable)
52 #pragma warning(push)
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
64 #if _MSC_VER < 900
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
73 // size.
74 typedef void VOID;
76 // Create the universal 32, 16, and 8-bit data types
77 typedef unsigned long UINTN;
78 typedef long INT32;
79 typedef unsigned long UINT32;
80 typedef int INT16;
81 typedef unsigned int UINT16;
82 typedef char INT8;
83 typedef unsigned char UINT8;
84 typedef char CHAR8;
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
91 } UINT64;
93 // Create the Boolean type
94 #define TRUE 1
95 #define FALSE 0
96 typedef unsigned char BOOLEAN;
98 #define CONST const
99 #define STATIC static
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
112 #pragma pack(1)
114 // Disable WORD->BYTE automatic conversion warnings. Example:
115 // BYTE LocalByte;
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 )
125 #else
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)
139 #ifndef VOID
140 typedef void VOID;
141 #endif
142 // Create the universal 32, 16, and 8-bit data types
143 #ifndef UINTN
144 typedef unsigned __w64 UINTN;
145 #endif
146 typedef __int64 INT64;
147 typedef unsigned __int64 UINT64;
148 typedef int INT32;
149 typedef unsigned int UINT32;
150 typedef short INT16;
151 typedef unsigned short UINT16;
152 typedef char INT8;
153 typedef unsigned char UINT8;
154 typedef char CHAR8;
155 typedef unsigned short CHAR16;
157 // Create the Boolean type
158 #ifndef TRUE
159 #define TRUE 1
160 #endif
161 #ifndef FALSE
162 #define FALSE 0
163 #endif
164 typedef unsigned char BOOLEAN;
166 // Force tight packing of structures
167 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
168 #pragma pack(1)
170 #define CONST const
171 #define STATIC static
172 #define VOLATILE volatile
173 #define CALLCONV
174 #define ROMDATA
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.
181 #if _MSC_VER >= 1400
182 #define VA_ARGS_SUPPORTED
183 #endif
184 // 64 bit of compiler
185 #else
186 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306 4366)
188 #ifndef VOID
189 typedef void VOID;
190 #endif
191 // Create the universal 32, 16, and 8-bit data types
192 #ifndef UINTN
193 typedef unsigned __int64 UINTN;
194 #endif
195 typedef __int64 INT64;
196 typedef unsigned __int64 UINT64;
197 typedef int INT32;
198 typedef unsigned int UINT32;
199 typedef short INT16;
200 typedef unsigned short UINT16;
201 typedef char INT8;
202 typedef unsigned char UINT8;
203 typedef char CHAR8;
204 typedef unsigned short CHAR16;
206 // Create the Boolean type
207 #ifndef TRUE
208 #define TRUE 1
209 #endif
210 #ifndef FALSE
211 #define FALSE 0
212 #endif
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
221 #pragma pack(1)
223 #define CONST const
224 #define STATIC static
225 #define VOLATILE volatile
226 #define CALLCONV
227 #define ROMDATA
228 #endif
229 #endif
230 // -----------------------------------------------------------------------
231 // End of MS compiler versions
233 #elif defined __GNUC__
235 #include <stdint.h>
237 #define IN
238 #define OUT
239 #define STATIC static
240 #define VOLATILE volatile
241 #define TRUE 1
242 #define FALSE 0
243 #define CONST const
244 #define ROMDATA
245 #define CALLCONV
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;
259 typedef int8_t INT8;
260 typedef uint8_t UINT8;
261 typedef char CHAR8;
262 typedef unsigned short CHAR16;
263 typedef unsigned char BOOLEAN;
264 typedef void VOID;
266 #define CODE_GROUP(arg)
267 #define RDATA_GROUP(arg)
269 #pragma pack(1)
271 #define FUNC_ATTRIBUTE(arg) __attribute__((arg))
272 #define MAKE_AS_A_STRING(arg) #arg
273 #include <stddef.h>
274 #include <gcc-intrin.h>
276 #include <assert.h>
277 //#include <console/console.h>
278 //#include <commonlib/loglevel.h>
280 #ifndef NULL
281 #define NULL ((void *)0)
282 #endif
284 #else
285 // -----------------------------------------------------------------------
286 // Unknown or unsupported compiler
288 #error "Unknown compiler in use"
289 #endif
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
299 #define IN
300 #define OUT
302 #endif // _PORTING_H_