drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / src / vendorcode / amd / pi / 00670F00 / Porting.h
blobcf32021f30b781bf78cff15d5d40fd293843e45b
1 /* SPDX-License-Identifier: BSD-3-Clause */
3 /* $NoKeywords:$ */
4 /**
5 * @file
7 * Describes compiler dependencies - to support several compile time environments
9 * Contains compiler environment porting descriptions
11 * @xrefitem bom "File Content Label" "Release Content"
12 * @e project: AGESA
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>
47 #ifndef _PORTING_H_
48 #define _PORTING_H_
50 #if defined (_MSC_VER)
51 #include <intrin.h>
52 void _disable (void);
53 void _enable (void);
54 #pragma warning(disable: 4103 4001 4733)
55 #pragma intrinsic (_disable, _enable)
56 #pragma warning(push)
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
68 #if _MSC_VER < 900
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
77 // size.
78 typedef void VOID;
80 // Create the universal 32, 16, and 8-bit data types
81 typedef unsigned long UINTN;
82 typedef long INT32;
83 typedef unsigned long UINT32;
84 typedef int INT16;
85 typedef unsigned int UINT16;
86 typedef char INT8;
87 typedef unsigned char UINT8;
88 typedef char CHAR8;
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
95 } UINT64;
97 // Create the Boolean type
98 #define TRUE 1
99 #define FALSE 0
100 typedef unsigned char BOOLEAN;
102 #define CONST const
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
116 #pragma pack(1)
118 // Disable WORD->BYTE automatic conversion warnings. Example:
119 // BYTE LocalByte;
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 )
129 #else
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)
143 #ifndef VOID
144 typedef void VOID;
145 #endif
146 // Create the universal 32, 16, and 8-bit data types
147 #ifndef UINTN
148 typedef unsigned __w64 UINTN;
149 #endif
150 typedef __int64 INT64;
151 typedef unsigned __int64 UINT64;
152 typedef int INT32;
153 typedef unsigned int UINT32;
154 typedef short INT16;
155 typedef unsigned short UINT16;
156 typedef char INT8;
157 typedef unsigned char UINT8;
158 typedef char CHAR8;
159 typedef unsigned short CHAR16;
161 // Create the Boolean type
162 #ifndef TRUE
163 #define TRUE 1
164 #endif
165 #ifndef FALSE
166 #define FALSE 0
167 #endif
168 typedef unsigned char BOOLEAN;
170 // Force tight packing of structures
171 // Note: Entire AGESA (Project / Solution) will be using pragma pack 1
172 #pragma pack(1)
174 #define CONST const
175 #define STATIC static
176 #define VOLATILE volatile
177 #define CALLCONV
178 #define ROMDATA
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.
185 #if _MSC_VER >= 1400
186 #define VA_ARGS_SUPPORTED
187 #endif
188 // 64 bit of compiler
189 #else
190 #pragma warning (disable: 4100 4276 4214 4001 4142 4305 4306 4366)
192 #ifndef VOID
193 typedef void VOID;
194 #endif
195 // Create the universal 32, 16, and 8-bit data types
196 #ifndef UINTN
197 typedef unsigned __int64 UINTN;
198 #endif
199 typedef __int64 INT64;
200 typedef unsigned __int64 UINT64;
201 typedef int INT32;
202 typedef unsigned int UINT32;
203 typedef short INT16;
204 typedef unsigned short UINT16;
205 typedef char INT8;
206 typedef unsigned char UINT8;
207 typedef char CHAR8;
208 typedef unsigned short CHAR16;
210 // Create the Boolean type
211 #ifndef TRUE
212 #define TRUE 1
213 #endif
214 #ifndef FALSE
215 #define FALSE 0
216 #endif
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
225 #pragma pack(1)
227 #define CONST const
228 #define STATIC static
229 #define VOLATILE volatile
230 #define CALLCONV
231 #define ROMDATA
232 #endif
233 #endif
234 // -----------------------------------------------------------------------
235 // End of MS compiler versions
237 #elif defined __GNUC__
239 #include <stdint.h>
241 #define IN
242 #define OUT
243 #define STATIC static
244 #define VOLATILE volatile
245 #define TRUE 1
246 #define FALSE 0
247 #define CONST const
248 #define ROMDATA
249 #define CALLCONV
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;
263 typedef int8_t INT8;
264 typedef uint8_t UINT8;
265 typedef char CHAR8;
266 typedef unsigned short CHAR16;
267 typedef unsigned char BOOLEAN;
268 typedef void VOID;
270 #define CODE_GROUP(arg)
271 #define RDATA_GROUP(arg)
273 #pragma pack(1)
275 #define FUNC_ATTRIBUTE(arg) __attribute__((arg))
276 #define MAKE_AS_A_STRING(arg) #arg
277 #include <stddef.h>
278 #include <gcc-intrin.h>
280 #include <assert.h>
281 //#include <console/console.h>
282 //#include <commonlib/loglevel.h>
284 #ifndef NULL
285 #define NULL ((void *)0)
286 #endif
288 #else
289 // -----------------------------------------------------------------------
290 // Unknown or unsupported compiler
292 #error "Unknown compiler in use"
293 #endif
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
303 #define IN
304 #define OUT
306 #endif // _PORTING_H_