ReactOS 0.4.15-dev-7704-gc07eb9f
acefi.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Name: acefi.h - OS specific defines, etc.
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACEFI_H__
45#define __ACEFI_H__
46
47/*
48 * Single threaded environment where Mutex/Event/Sleep are fake. This model is
49 * sufficient for pre-boot AcpiExec.
50 */
51#ifndef DEBUGGER_THREADING
52#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
53#endif /* !DEBUGGER_THREADING */
54
55/* EDK2 EFI environment */
56
57#if defined(_EDK2_EFI)
58
59#ifdef USE_STDLIB
60#define ACPI_USE_STANDARD_HEADERS
61#define ACPI_USE_SYSTEM_CLIBRARY
62#define ACPI_USE_NATIVE_DIVIDE
63#define ACPI_USE_NATIVE_MATH64
64#endif
65
66#endif
67
68#if defined(__x86_64__)
69#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
70#define USE_MS_ABI 1
71#endif
72#endif
73
74#ifdef _MSC_EXTENSIONS
75#define ACPI_EFI_API __cdecl
76#elif USE_MS_ABI
77#define ACPI_EFI_API __attribute__((ms_abi))
78#else
79#define ACPI_EFI_API
80#endif
81
82#define VOID void
83
84#if defined(__ia64__) || defined(__x86_64__)
85
86#define ACPI_MACHINE_WIDTH 64
87
88#if defined(__x86_64__)
89
90/* for x86_64, EFI_FUNCTION_WRAPPER must be defined */
91
92#ifndef USE_MS_ABI
93#define USE_EFI_FUNCTION_WRAPPER
94#endif
95
96#ifdef _MSC_EXTENSIONS
97#pragma warning ( disable : 4731 ) /* Suppress warnings about modification of EBP */
98#endif
99
100#endif
101
102#ifndef USE_STDLIB
103#define UINTN uint64_t
104#define INTN int64_t
105#endif
106
107#define ACPI_EFI_ERR(a) (0x8000000000000000 | a)
108
109#else
110
111#define ACPI_MACHINE_WIDTH 32
112
113#ifndef USE_STDLIB
114#define UINTN uint32_t
115#define INTN int32_t
116#endif
117
118#define ACPI_EFI_ERR(a) (0x80000000 | a)
119
120#endif
121
122#define CHAR16 uint16_t
123
124#ifdef USE_EFI_FUNCTION_WRAPPER
125#define __VA_NARG__(...) \
126 __VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N())
127#define __VA_NARG_(...) \
128 __VA_ARG_N(__VA_ARGS__)
129#define __VA_ARG_N( \
130 _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,N,...) N
131#define __RSEQ_N() \
132 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
133
134#define __VA_ARG_NSUFFIX__(prefix,...) \
135 __VA_ARG_NSUFFIX_N(prefix, __VA_NARG__(__VA_ARGS__))
136#define __VA_ARG_NSUFFIX_N(prefix,nargs) \
137 __VA_ARG_NSUFFIX_N_(prefix, nargs)
138#define __VA_ARG_NSUFFIX_N_(prefix,nargs) \
139 prefix ## nargs
140
141/* Prototypes of EFI cdecl -> stdcall trampolines */
142
143UINT64 efi_call0(void *func);
144UINT64 efi_call1(void *func, UINT64 arg1);
145UINT64 efi_call2(void *func, UINT64 arg1, UINT64 arg2);
146UINT64 efi_call3(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3);
147UINT64 efi_call4(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
148 UINT64 arg4);
149UINT64 efi_call5(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
150 UINT64 arg4, UINT64 arg5);
151UINT64 efi_call6(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
152 UINT64 arg4, UINT64 arg5, UINT64 arg6);
153UINT64 efi_call7(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
154 UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7);
155UINT64 efi_call8(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
156 UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7,
157 UINT64 arg8);
158UINT64 efi_call9(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
159 UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7,
160 UINT64 arg8, UINT64 arg9);
161UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3,
162 UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7,
163 UINT64 arg8, UINT64 arg9, UINT64 arg10);
164
165/* Front-ends to efi_callX to avoid compiler warnings */
166
167#define _cast64_efi_call0(f) \
168 efi_call0(f)
169#define _cast64_efi_call1(f,a1) \
170 efi_call1(f, (UINT64)(a1))
171#define _cast64_efi_call2(f,a1,a2) \
172 efi_call2(f, (UINT64)(a1), (UINT64)(a2))
173#define _cast64_efi_call3(f,a1,a2,a3) \
174 efi_call3(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3))
175#define _cast64_efi_call4(f,a1,a2,a3,a4) \
176 efi_call4(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4))
177#define _cast64_efi_call5(f,a1,a2,a3,a4,a5) \
178 efi_call5(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
179 (UINT64)(a5))
180#define _cast64_efi_call6(f,a1,a2,a3,a4,a5,a6) \
181 efi_call6(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
182 (UINT64)(a5), (UINT64)(a6))
183#define _cast64_efi_call7(f,a1,a2,a3,a4,a5,a6,a7) \
184 efi_call7(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
185 (UINT64)(a5), (UINT64)(a6), (UINT64)(a7))
186#define _cast64_efi_call8(f,a1,a2,a3,a4,a5,a6,a7,a8) \
187 efi_call8(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
188 (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8))
189#define _cast64_efi_call9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
190 efi_call9(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
191 (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \
192 (UINT64)(a9))
193#define _cast64_efi_call10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
194 efi_call10(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \
195 (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \
196 (UINT64)(a9), (UINT64)(a10))
197
198/* main wrapper (va_num ignored) */
199
200#define uefi_call_wrapper(func,va_num,...) \
201 __VA_ARG_NSUFFIX__(_cast64_efi_call, __VA_ARGS__) (func , ##__VA_ARGS__)
202
203#else
204
205#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
206
207#endif
208
209/* AED EFI definitions */
210
211#if defined(_AED_EFI)
212
213/* _int64 works for both IA32 and IA64 */
214
215#define COMPILER_DEPENDENT_INT64 __int64
216#define COMPILER_DEPENDENT_UINT64 unsigned __int64
217
218/*
219 * Calling conventions:
220 *
221 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
222 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
223 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
224 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
225 */
226#define ACPI_SYSTEM_XFACE
227#define ACPI_EXTERNAL_XFACE
228#define ACPI_INTERNAL_XFACE
229#define ACPI_INTERNAL_VAR_XFACE
230
231/* warn C4142: redefinition of type */
232
233#pragma warning(disable:4142)
234
235#endif
236
237
238/* EFI math64 definitions */
239
240#if defined(_GNU_EFI) || defined(_EDK2_EFI)
241/*
242 * Math helpers, GNU EFI provided a platform independent 64-bit math
243 * support.
244 */
245#ifndef ACPI_DIV_64_BY_32
246#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
247 do { \
248 UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
249 (q32) = (UINT32) DivU64x32 ((__n), (d32), &(r32)); \
250 } while (0)
251#endif
252
253#ifndef ACPI_MUL_64_BY_32
254#define ACPI_MUL_64_BY_32(n_hi, n_lo, m32, p32, c32) \
255 do { \
256 UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
257 UINT64 __p = MultU64x32 (__n, (m32)); \
258 (p32) = (UINT32) __p; \
259 (c32) = (UINT32) (__p >> 32); \
260 } while (0)
261#endif
262
263#ifndef ACPI_SHIFT_LEFT_64_by_32
264#define ACPI_SHIFT_LEFT_64_BY_32(n_hi, n_lo, s32) \
265 do { \
266 UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
267 UINT64 __r = LShiftU64 (__n, (s32)); \
268 (n_lo) = (UINT32) __r; \
269 (n_hi) = (UINT32) (__r >> 32); \
270 } while (0)
271#endif
272
273#ifndef ACPI_SHIFT_RIGHT_64_BY_32
274#define ACPI_SHIFT_RIGHT_64_BY_32(n_hi, n_lo, s32) \
275 do { \
276 UINT64 __n = ((UINT64) n_hi) << 32 | (n_lo); \
277 UINT64 __r = RShiftU64 (__n, (s32)); \
278 (n_lo) = (UINT32) __r; \
279 (n_hi) = (UINT32) (__r >> 32); \
280 } while (0)
281#endif
282
283#ifndef ACPI_SHIFT_RIGHT_64
284#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
285 do { \
286 (n_lo) >>= 1; \
287 (n_lo) |= (((n_hi) & 1) << 31); \
288 (n_hi) >>= 1; \
289 } while (0)
290#endif
291#endif
292
300struct _ACPI_EFI_PCI_IO;
301
302extern struct _ACPI_EFI_SYSTEM_TABLE *ST;
303extern struct _ACPI_EFI_BOOT_SERVICES *BS;
304extern struct _ACPI_EFI_RUNTIME_SERVICES *RT;
305
306#ifndef USE_STDLIB
308#define FILE ACPI_EFI_FILE
309
310extern FILE *stdin;
311extern FILE *stdout;
312extern FILE *stderr;
313#endif
314
315#endif /* __ACEFI_H__ */
unsigned long long UINT64
struct _ACPI_EFI_RUNTIME_SERVICES * RT
struct _ACPI_EFI_BOOT_SERVICES * BS
struct _ACPI_EFI_SYSTEM_TABLE * ST
FILE * stdout
FILE * stderr
FILE * stdin
GLenum func
Definition: glext.h:6028
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:9513
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
Definition: glext.h:9515
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:9514