859d77ef7487032da660dc6c517bbba313e32b43
[reactos.git] / reactos / drivers / bus / acpi / acpica / include / platform / acefiex.h
1 /******************************************************************************
2 *
3 * Name: acefiex.h - Extra OS specific defines, etc. for EFI
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2017, 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 MERCHANTIBILITY 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 __ACEFIEX_H__
45 #define __ACEFIEX_H__
46
47
48 #ifndef ACPI_USE_SYSTEM_CLIBRARY
49
50 typedef signed char int8_t;
51 typedef short int int16_t;
52 typedef int int32_t;
53 typedef unsigned char uint8_t;
54 typedef unsigned short int uint16_t;
55 typedef unsigned int uint32_t;
56 typedef COMPILER_DEPENDENT_INT64 int64_t;
57 typedef COMPILER_DEPENDENT_UINT64 uint64_t;
58
59 #endif /* ACPI_USE_SYSTEM_CLIBRARY */
60
61 #define ACPI_EFI_ERROR(a) (((INTN) a) < 0)
62 #define ACPI_EFI_SUCCESS 0
63 #define ACPI_EFI_LOAD_ERROR ACPI_EFI_ERR(1)
64 #define ACPI_EFI_INVALID_PARAMETER ACPI_EFI_ERR(2)
65 #define ACPI_EFI_UNSUPPORTED ACPI_EFI_ERR(3)
66 #define ACPI_EFI_BAD_BUFFER_SIZE ACPI_EFI_ERR(4)
67 #define ACPI_EFI_BUFFER_TOO_SMALL ACPI_EFI_ERR(5)
68 #define ACPI_EFI_NOT_READY ACPI_EFI_ERR(6)
69 #define ACPI_EFI_DEVICE_ERROR ACPI_EFI_ERR(7)
70 #define ACPI_EFI_WRITE_PROTECTED ACPI_EFI_ERR(8)
71 #define ACPI_EFI_OUT_OF_RESOURCES ACPI_EFI_ERR(9)
72 #define ACPI_EFI_VOLUME_CORRUPTED ACPI_EFI_ERR(10)
73 #define ACPI_EFI_VOLUME_FULL ACPI_EFI_ERR(11)
74 #define ACPI_EFI_NO_MEDIA ACPI_EFI_ERR(12)
75 #define ACPI_EFI_MEDIA_CHANGED ACPI_EFI_ERR(13)
76 #define ACPI_EFI_NOT_FOUND ACPI_EFI_ERR(14)
77 #define ACPI_EFI_ACCESS_DENIED ACPI_EFI_ERR(15)
78 #define ACPI_EFI_NO_RESPONSE ACPI_EFI_ERR(16)
79 #define ACPI_EFI_NO_MAPPING ACPI_EFI_ERR(17)
80 #define ACPI_EFI_TIMEOUT ACPI_EFI_ERR(18)
81 #define ACPI_EFI_NOT_STARTED ACPI_EFI_ERR(19)
82 #define ACPI_EFI_ALREADY_STARTED ACPI_EFI_ERR(20)
83 #define ACPI_EFI_ABORTED ACPI_EFI_ERR(21)
84 #define ACPI_EFI_PROTOCOL_ERROR ACPI_EFI_ERR(24)
85
86
87 typedef UINTN ACPI_EFI_STATUS;
88 typedef VOID *ACPI_EFI_HANDLE;
89 typedef VOID *ACPI_EFI_EVENT;
90
91 typedef struct {
92 UINT32 Data1;
93 UINT16 Data2;
94 UINT16 Data3;
95 UINT8 Data4[8];
96 } ACPI_EFI_GUID;
97
98 typedef struct {
99 UINT16 Year; /* 1998 - 20XX */
100 UINT8 Month; /* 1 - 12 */
101 UINT8 Day; /* 1 - 31 */
102 UINT8 Hour; /* 0 - 23 */
103 UINT8 Minute; /* 0 - 59 */
104 UINT8 Second; /* 0 - 59 */
105 UINT8 Pad1;
106 UINT32 Nanosecond; /* 0 - 999,999,999 */
107 INT16 TimeZone; /* -1440 to 1440 or 2047 */
108 UINT8 Daylight;
109 UINT8 Pad2;
110 } ACPI_EFI_TIME;
111
112 typedef struct _ACPI_EFI_DEVICE_PATH {
113 UINT8 Type;
114 UINT8 SubType;
115 UINT8 Length[2];
116 } ACPI_EFI_DEVICE_PATH;
117
118 typedef UINT64 ACPI_EFI_PHYSICAL_ADDRESS;
119 typedef UINT64 ACPI_EFI_VIRTUAL_ADDRESS;
120
121 typedef enum {
122 AcpiEfiAllocateAnyPages,
123 AcpiEfiAllocateMaxAddress,
124 AcpiEfiAllocateAddress,
125 AcpiEfiMaxAllocateType
126 } ACPI_EFI_ALLOCATE_TYPE;
127
128 typedef enum {
129 AcpiEfiReservedMemoryType,
130 AcpiEfiLoaderCode,
131 AcpiEfiLoaderData,
132 AcpiEfiBootServicesCode,
133 AcpiEfiBootServicesData,
134 AcpiEfiRuntimeServicesCode,
135 AcpiEfiRuntimeServicesData,
136 AcpiEfiConventionalMemory,
137 AcpiEfiUnusableMemory,
138 AcpiEfiACPIReclaimMemory,
139 AcpiEfiACPIMemoryNVS,
140 AcpiEfiMemoryMappedIO,
141 AcpiEfiMemoryMappedIOPortSpace,
142 AcpiEfiPalCode,
143 AcpiEfiMaxMemoryType
144 } ACPI_EFI_MEMORY_TYPE;
145
146 /* possible caching types for the memory range */
147 #define ACPI_EFI_MEMORY_UC 0x0000000000000001
148 #define ACPI_EFI_MEMORY_WC 0x0000000000000002
149 #define ACPI_EFI_MEMORY_WT 0x0000000000000004
150 #define ACPI_EFI_MEMORY_WB 0x0000000000000008
151 #define ACPI_EFI_MEMORY_UCE 0x0000000000000010
152
153 /* physical memory protection on range */
154 #define ACPI_EFI_MEMORY_WP 0x0000000000001000
155 #define ACPI_EFI_MEMORY_RP 0x0000000000002000
156 #define ACPI_EFI_MEMORY_XP 0x0000000000004000
157
158 /* range requires a runtime mapping */
159 #define ACPI_EFI_MEMORY_RUNTIME 0x8000000000000000
160
161 #define ACPI_EFI_MEMORY_DESCRIPTOR_VERSION 1
162 typedef struct {
163 UINT32 Type;
164 UINT32 Pad;
165 ACPI_EFI_PHYSICAL_ADDRESS PhysicalStart;
166 ACPI_EFI_VIRTUAL_ADDRESS VirtualStart;
167 UINT64 NumberOfPages;
168 UINT64 Attribute;
169 } ACPI_EFI_MEMORY_DESCRIPTOR;
170
171 typedef struct _ACPI_EFI_TABLE_HEARDER {
172 UINT64 Signature;
173 UINT32 Revision;
174 UINT32 HeaderSize;
175 UINT32 CRC32;
176 UINT32 Reserved;
177 } ACPI_EFI_TABLE_HEADER;
178
179 typedef
180 ACPI_EFI_STATUS
181 (ACPI_EFI_API *ACPI_EFI_UNKNOWN_INTERFACE) (
182 void);
183
184
185 /*
186 * Text output protocol
187 */
188 #define ACPI_SIMPLE_TEXT_OUTPUT_PROTOCOL \
189 { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
190
191 typedef
192 ACPI_EFI_STATUS
193 (ACPI_EFI_API *ACPI_EFI_TEXT_RESET) (
194 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
195 BOOLEAN ExtendedVerification);
196
197 typedef
198 ACPI_EFI_STATUS
199 (ACPI_EFI_API *ACPI_EFI_TEXT_OUTPUT_STRING) (
200 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
201 CHAR16 *String);
202
203 typedef
204 ACPI_EFI_STATUS
205 (ACPI_EFI_API *ACPI_EFI_TEXT_TEST_STRING) (
206 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
207 CHAR16 *String);
208
209 typedef
210 ACPI_EFI_STATUS
211 (ACPI_EFI_API *ACPI_EFI_TEXT_QUERY_MODE) (
212 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
213 UINTN ModeNumber,
214 UINTN *Columns,
215 UINTN *Rows);
216
217 typedef
218 ACPI_EFI_STATUS
219 (ACPI_EFI_API *ACPI_EFI_TEXT_SET_MODE) (
220 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
221 UINTN ModeNumber);
222
223 typedef
224 ACPI_EFI_STATUS
225 (ACPI_EFI_API *ACPI_EFI_TEXT_SET_ATTRIBUTE) (
226 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
227 UINTN Attribute);
228
229 typedef
230 ACPI_EFI_STATUS
231 (ACPI_EFI_API *ACPI_EFI_TEXT_CLEAR_SCREEN) (
232 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This);
233
234 typedef
235 ACPI_EFI_STATUS
236 (ACPI_EFI_API *ACPI_EFI_TEXT_SET_CURSOR_POSITION) (
237 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
238 UINTN Column,
239 UINTN Row);
240
241 typedef
242 ACPI_EFI_STATUS
243 (ACPI_EFI_API *ACPI_EFI_TEXT_ENABLE_CURSOR) (
244 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *This,
245 BOOLEAN Enable);
246
247 typedef struct {
248 INT32 MaxMode;
249 INT32 Mode;
250 INT32 Attribute;
251 INT32 CursorColumn;
252 INT32 CursorRow;
253 BOOLEAN CursorVisible;
254 } ACPI_SIMPLE_TEXT_OUTPUT_MODE;
255
256 typedef struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE {
257 ACPI_EFI_TEXT_RESET Reset;
258
259 ACPI_EFI_TEXT_OUTPUT_STRING OutputString;
260 ACPI_EFI_TEXT_TEST_STRING TestString;
261
262 ACPI_EFI_TEXT_QUERY_MODE QueryMode;
263 ACPI_EFI_TEXT_SET_MODE SetMode;
264 ACPI_EFI_TEXT_SET_ATTRIBUTE SetAttribute;
265
266 ACPI_EFI_TEXT_CLEAR_SCREEN ClearScreen;
267 ACPI_EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
268 ACPI_EFI_TEXT_ENABLE_CURSOR EnableCursor;
269
270 ACPI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
271 } ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE;
272
273 /*
274 * Text input protocol
275 */
276 #define ACPI_SIMPLE_TEXT_INPUT_PROTOCOL \
277 { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
278
279 typedef struct {
280 UINT16 ScanCode;
281 CHAR16 UnicodeChar;
282 } ACPI_EFI_INPUT_KEY;
283
284 /*
285 * Baseline unicode control chars
286 */
287 #define CHAR_NULL 0x0000
288 #define CHAR_BACKSPACE 0x0008
289 #define CHAR_TAB 0x0009
290 #define CHAR_LINEFEED 0x000A
291 #define CHAR_CARRIAGE_RETURN 0x000D
292
293 typedef
294 ACPI_EFI_STATUS
295 (ACPI_EFI_API *ACPI_EFI_INPUT_RESET) (
296 struct _ACPI_SIMPLE_INPUT_INTERFACE *This,
297 BOOLEAN ExtendedVerification);
298
299 typedef
300 ACPI_EFI_STATUS
301 (ACPI_EFI_API *ACPI_EFI_INPUT_READ_KEY) (
302 struct _ACPI_SIMPLE_INPUT_INTERFACE *This,
303 ACPI_EFI_INPUT_KEY *Key);
304
305 typedef struct _ACPI_SIMPLE_INPUT_INTERFACE {
306 ACPI_EFI_INPUT_RESET Reset;
307 ACPI_EFI_INPUT_READ_KEY ReadKeyStroke;
308 ACPI_EFI_EVENT WaitForKey;
309 } ACPI_SIMPLE_INPUT_INTERFACE;
310
311
312 /*
313 * Simple file system protocol
314 */
315 #define ACPI_SIMPLE_FILE_SYSTEM_PROTOCOL \
316 { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
317
318 typedef
319 ACPI_EFI_STATUS
320 (ACPI_EFI_API *ACPI_EFI_VOLUME_OPEN) (
321 struct _ACPI_EFI_FILE_IO_INTERFACE *This,
322 struct _ACPI_EFI_FILE_HANDLE **Root);
323
324 #define ACPI_EFI_FILE_IO_INTERFACE_REVISION 0x00010000
325
326 typedef struct _ACPI_EFI_FILE_IO_INTERFACE {
327 UINT64 Revision;
328 ACPI_EFI_VOLUME_OPEN OpenVolume;
329 } ACPI_EFI_FILE_IO_INTERFACE;
330
331 typedef
332 ACPI_EFI_STATUS
333 (ACPI_EFI_API *ACPI_EFI_FILE_OPEN) (
334 struct _ACPI_EFI_FILE_HANDLE *File,
335 struct _ACPI_EFI_FILE_HANDLE **NewHandle,
336 CHAR16 *FileName,
337 UINT64 OpenMode,
338 UINT64 Attributes);
339
340 /* Values for OpenMode used above */
341
342 #define ACPI_EFI_FILE_MODE_READ 0x0000000000000001
343 #define ACPI_EFI_FILE_MODE_WRITE 0x0000000000000002
344 #define ACPI_EFI_FILE_MODE_CREATE 0x8000000000000000
345
346 /* Values for Attribute used above */
347
348 #define ACPI_EFI_FILE_READ_ONLY 0x0000000000000001
349 #define ACPI_EFI_FILE_HIDDEN 0x0000000000000002
350 #define ACPI_EFI_FILE_SYSTEM 0x0000000000000004
351 #define ACPI_EFI_FILE_RESERVIED 0x0000000000000008
352 #define ACPI_EFI_FILE_DIRECTORY 0x0000000000000010
353 #define ACPI_EFI_FILE_ARCHIVE 0x0000000000000020
354 #define ACPI_EFI_FILE_VALID_ATTR 0x0000000000000037
355
356 typedef
357 ACPI_EFI_STATUS
358 (ACPI_EFI_API *ACPI_EFI_FILE_CLOSE) (
359 struct _ACPI_EFI_FILE_HANDLE *File);
360
361 typedef
362 ACPI_EFI_STATUS
363 (ACPI_EFI_API *ACPI_EFI_FILE_DELETE) (
364 struct _ACPI_EFI_FILE_HANDLE *File);
365
366 typedef
367 ACPI_EFI_STATUS
368 (ACPI_EFI_API *ACPI_EFI_FILE_READ) (
369 struct _ACPI_EFI_FILE_HANDLE *File,
370 UINTN *BufferSize,
371 VOID *Buffer);
372
373 typedef
374 ACPI_EFI_STATUS
375 (ACPI_EFI_API *ACPI_EFI_FILE_WRITE) (
376 struct _ACPI_EFI_FILE_HANDLE *File,
377 UINTN *BufferSize,
378 VOID *Buffer);
379
380 typedef
381 ACPI_EFI_STATUS
382 (ACPI_EFI_API *ACPI_EFI_FILE_SET_POSITION) (
383 struct _ACPI_EFI_FILE_HANDLE *File,
384 UINT64 Position);
385
386 typedef
387 ACPI_EFI_STATUS
388 (ACPI_EFI_API *ACPI_EFI_FILE_GET_POSITION) (
389 struct _ACPI_EFI_FILE_HANDLE *File,
390 UINT64 *Position);
391
392 #define ACPI_EFI_FILE_INFO_ID \
393 { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
394
395 typedef struct {
396 UINT64 Size;
397 UINT64 FileSize;
398 UINT64 PhysicalSize;
399 ACPI_EFI_TIME CreateTime;
400 ACPI_EFI_TIME LastAccessTime;
401 ACPI_EFI_TIME ModificationTime;
402 UINT64 Attribute;
403 CHAR16 FileName[1];
404 } ACPI_EFI_FILE_INFO;
405
406 #define SIZE_OF_ACPI_EFI_FILE_INFO ACPI_OFFSET(ACPI_EFI_FILE_INFO, FileName)
407
408 typedef
409 ACPI_EFI_STATUS
410 (ACPI_EFI_API *ACPI_EFI_FILE_GET_INFO) (
411 struct _ACPI_EFI_FILE_HANDLE *File,
412 ACPI_EFI_GUID *InformationType,
413 UINTN *BufferSize,
414 VOID *Buffer);
415
416 typedef
417 ACPI_EFI_STATUS
418 (ACPI_EFI_API *ACPI_EFI_FILE_SET_INFO) (
419 struct _ACPI_EFI_FILE_HANDLE *File,
420 ACPI_EFI_GUID *InformationType,
421 UINTN BufferSize,
422 VOID *Buffer);
423
424 typedef
425 ACPI_EFI_STATUS
426 (ACPI_EFI_API *ACPI_EFI_FILE_FLUSH) (
427 struct _ACPI_EFI_FILE_HANDLE *File);
428
429
430 #define ACPI_EFI_FILE_HANDLE_REVISION 0x00010000
431
432 typedef struct _ACPI_EFI_FILE_HANDLE {
433 UINT64 Revision;
434 ACPI_EFI_FILE_OPEN Open;
435 ACPI_EFI_FILE_CLOSE Close;
436 ACPI_EFI_FILE_DELETE Delete;
437 ACPI_EFI_FILE_READ Read;
438 ACPI_EFI_FILE_WRITE Write;
439 ACPI_EFI_FILE_GET_POSITION GetPosition;
440 ACPI_EFI_FILE_SET_POSITION SetPosition;
441 ACPI_EFI_FILE_GET_INFO GetInfo;
442 ACPI_EFI_FILE_SET_INFO SetInfo;
443 ACPI_EFI_FILE_FLUSH Flush;
444 } ACPI_EFI_FILE_STRUCT, *ACPI_EFI_FILE_HANDLE;
445
446
447 /*
448 * Loaded image protocol
449 */
450 #define ACPI_EFI_LOADED_IMAGE_PROTOCOL \
451 { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
452
453 typedef
454 ACPI_EFI_STATUS
455 (ACPI_EFI_API *ACPI_EFI_IMAGE_ENTRY_POINT) (
456 ACPI_EFI_HANDLE ImageHandle,
457 struct _ACPI_EFI_SYSTEM_TABLE *SystemTable);
458
459 typedef
460 ACPI_EFI_STATUS
461 (ACPI_EFI_API *ACPI_EFI_IMAGE_LOAD) (
462 BOOLEAN BootPolicy,
463 ACPI_EFI_HANDLE ParentImageHandle,
464 ACPI_EFI_DEVICE_PATH *FilePath,
465 VOID *SourceBuffer,
466 UINTN SourceSize,
467 ACPI_EFI_HANDLE *ImageHandle);
468
469 typedef
470 ACPI_EFI_STATUS
471 (ACPI_EFI_API *ACPI_EFI_IMAGE_START) (
472 ACPI_EFI_HANDLE ImageHandle,
473 UINTN *ExitDataSize,
474 CHAR16 **ExitData);
475
476 typedef
477 ACPI_EFI_STATUS
478 (ACPI_EFI_API *ACPI_EFI_EXIT) (
479 ACPI_EFI_HANDLE ImageHandle,
480 ACPI_EFI_STATUS ExitStatus,
481 UINTN ExitDataSize,
482 CHAR16 *ExitData);
483
484 typedef
485 ACPI_EFI_STATUS
486 (ACPI_EFI_API *ACPI_EFI_IMAGE_UNLOAD) (
487 ACPI_EFI_HANDLE ImageHandle);
488
489
490 typedef
491 ACPI_EFI_STATUS
492 (ACPI_EFI_API *ACPI_EFI_SET_WATCHDOG_TIMER) (
493 UINTN Timeout,
494 UINT64 WatchdogCode,
495 UINTN DataSize,
496 CHAR16 *WatchdogData);
497
498
499 #define EFI_IMAGE_INFORMATION_REVISION 0x1000
500 typedef struct {
501 UINT32 Revision;
502 ACPI_EFI_HANDLE ParentHandle;
503 struct _ACPI_EFI_SYSTEM_TABLE *SystemTable;
504 ACPI_EFI_HANDLE DeviceHandle;
505 ACPI_EFI_DEVICE_PATH *FilePath;
506 VOID *Reserved;
507 UINT32 LoadOptionsSize;
508 VOID *LoadOptions;
509 VOID *ImageBase;
510 UINT64 ImageSize;
511 ACPI_EFI_MEMORY_TYPE ImageCodeType;
512 ACPI_EFI_MEMORY_TYPE ImageDataType;
513 ACPI_EFI_IMAGE_UNLOAD Unload;
514
515 } ACPI_EFI_LOADED_IMAGE;
516
517
518 /*
519 * EFI Memory
520 */
521 typedef
522 ACPI_EFI_STATUS
523 (ACPI_EFI_API *ACPI_EFI_ALLOCATE_PAGES) (
524 ACPI_EFI_ALLOCATE_TYPE Type,
525 ACPI_EFI_MEMORY_TYPE MemoryType,
526 UINTN NoPages,
527 ACPI_EFI_PHYSICAL_ADDRESS *Memory);
528
529 typedef
530 ACPI_EFI_STATUS
531 (ACPI_EFI_API *ACPI_EFI_FREE_PAGES) (
532 ACPI_EFI_PHYSICAL_ADDRESS Memory,
533 UINTN NoPages);
534
535 typedef
536 ACPI_EFI_STATUS
537 (ACPI_EFI_API *ACPI_EFI_GET_MEMORY_MAP) (
538 UINTN *MemoryMapSize,
539 ACPI_EFI_MEMORY_DESCRIPTOR *MemoryMap,
540 UINTN *MapKey,
541 UINTN *DescriptorSize,
542 UINT32 *DescriptorVersion);
543
544 #define NextMemoryDescriptor(Ptr,Size) ((ACPI_EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
545
546 typedef
547 ACPI_EFI_STATUS
548 (ACPI_EFI_API *ACPI_EFI_ALLOCATE_POOL) (
549 ACPI_EFI_MEMORY_TYPE PoolType,
550 UINTN Size,
551 VOID **Buffer);
552
553 typedef
554 ACPI_EFI_STATUS
555 (ACPI_EFI_API *ACPI_EFI_FREE_POOL) (
556 VOID *Buffer);
557
558
559 /*
560 * Protocol handler functions
561 */
562 typedef enum {
563 ACPI_EFI_NATIVE_INTERFACE,
564 ACPI_EFI_PCODE_INTERFACE
565 } ACPI_EFI_INTERFACE_TYPE;
566
567 typedef enum {
568 AcpiEfiAllHandles,
569 AcpiEfiByRegisterNotify,
570 AcpiEfiByProtocol
571 } ACPI_EFI_LOCATE_SEARCH_TYPE;
572
573 typedef
574 ACPI_EFI_STATUS
575 (ACPI_EFI_API *ACPI_EFI_INSTALL_PROTOCOL_INTERFACE) (
576 ACPI_EFI_HANDLE *Handle,
577 ACPI_EFI_GUID *Protocol,
578 ACPI_EFI_INTERFACE_TYPE InterfaceType,
579 VOID *Interface);
580
581 typedef
582 ACPI_EFI_STATUS
583 (ACPI_EFI_API *ACPI_EFI_REINSTALL_PROTOCOL_INTERFACE) (
584 ACPI_EFI_HANDLE Handle,
585 ACPI_EFI_GUID *Protocol,
586 VOID *OldInterface,
587 VOID *NewInterface);
588
589 typedef
590 ACPI_EFI_STATUS
591 (ACPI_EFI_API *ACPI_EFI_UNINSTALL_PROTOCOL_INTERFACE) (
592 ACPI_EFI_HANDLE Handle,
593 ACPI_EFI_GUID *Protocol,
594 VOID *Interface);
595
596 typedef
597 ACPI_EFI_STATUS
598 (ACPI_EFI_API *ACPI_EFI_HANDLE_PROTOCOL) (
599 ACPI_EFI_HANDLE Handle,
600 ACPI_EFI_GUID *Protocol,
601 VOID **Interface);
602
603 typedef
604 ACPI_EFI_STATUS
605 (ACPI_EFI_API *ACPI_EFI_REGISTER_PROTOCOL_NOTIFY) (
606 ACPI_EFI_GUID *Protocol,
607 ACPI_EFI_EVENT Event,
608 VOID **Registration);
609
610 typedef
611 ACPI_EFI_STATUS
612 (ACPI_EFI_API *ACPI_EFI_LOCATE_HANDLE) (
613 ACPI_EFI_LOCATE_SEARCH_TYPE SearchType,
614 ACPI_EFI_GUID *Protocol,
615 VOID *SearchKey,
616 UINTN *BufferSize,
617 ACPI_EFI_HANDLE *Buffer);
618
619 typedef
620 ACPI_EFI_STATUS
621 (ACPI_EFI_API *ACPI_EFI_LOCATE_DEVICE_PATH) (
622 ACPI_EFI_GUID *Protocol,
623 ACPI_EFI_DEVICE_PATH **DevicePath,
624 ACPI_EFI_HANDLE *Device);
625
626 typedef
627 ACPI_EFI_STATUS
628 (ACPI_EFI_API *ACPI_EFI_INSTALL_CONFIGURATION_TABLE) (
629 ACPI_EFI_GUID *Guid,
630 VOID *Table);
631
632 #define ACPI_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
633 #define ACPI_EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
634 #define ACPI_EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
635 #define ACPI_EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
636 #define ACPI_EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
637 #define ACPI_EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
638
639 typedef
640 ACPI_EFI_STATUS
641 (ACPI_EFI_API *ACPI_EFI_OPEN_PROTOCOL) (
642 ACPI_EFI_HANDLE Handle,
643 ACPI_EFI_GUID *Protocol,
644 VOID **Interface,
645 ACPI_EFI_HANDLE AgentHandle,
646 ACPI_EFI_HANDLE ControllerHandle,
647 UINT32 Attributes);
648
649 typedef
650 ACPI_EFI_STATUS
651 (ACPI_EFI_API *ACPI_EFI_CLOSE_PROTOCOL) (
652 ACPI_EFI_HANDLE Handle,
653 ACPI_EFI_GUID *Protocol,
654 ACPI_EFI_HANDLE AgentHandle,
655 ACPI_EFI_HANDLE ControllerHandle);
656
657 typedef struct {
658 ACPI_EFI_HANDLE AgentHandle;
659 ACPI_EFI_HANDLE ControllerHandle;
660 UINT32 Attributes;
661 UINT32 OpenCount;
662 } ACPI_EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
663
664 typedef
665 ACPI_EFI_STATUS
666 (ACPI_EFI_API *ACPI_EFI_OPEN_PROTOCOL_INFORMATION) (
667 ACPI_EFI_HANDLE Handle,
668 ACPI_EFI_GUID *Protocol,
669 ACPI_EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
670 UINTN *EntryCount);
671
672 typedef
673 ACPI_EFI_STATUS
674 (ACPI_EFI_API *ACPI_EFI_PROTOCOLS_PER_HANDLE) (
675 ACPI_EFI_HANDLE Handle,
676 ACPI_EFI_GUID ***ProtocolBuffer,
677 UINTN *ProtocolBufferCount);
678
679 typedef
680 ACPI_EFI_STATUS
681 (ACPI_EFI_API *ACPI_EFI_LOCATE_HANDLE_BUFFER) (
682 ACPI_EFI_LOCATE_SEARCH_TYPE SearchType,
683 ACPI_EFI_GUID *Protocol,
684 VOID *SearchKey,
685 UINTN *NoHandles,
686 ACPI_EFI_HANDLE **Buffer);
687
688 typedef
689 ACPI_EFI_STATUS
690 (ACPI_EFI_API *ACPI_EFI_LOCATE_PROTOCOL) (
691 ACPI_EFI_GUID *Protocol,
692 VOID *Registration,
693 VOID **Interface);
694
695 typedef
696 ACPI_EFI_STATUS
697 (ACPI_EFI_API *ACPI_EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
698 ACPI_EFI_HANDLE *Handle,
699 ...);
700
701 typedef
702 ACPI_EFI_STATUS
703 (ACPI_EFI_API *ACPI_EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
704 ACPI_EFI_HANDLE Handle,
705 ...);
706
707 typedef
708 ACPI_EFI_STATUS
709 (ACPI_EFI_API *ACPI_EFI_CALCULATE_CRC32) (
710 VOID *Data,
711 UINTN DataSize,
712 UINT32 *Crc32);
713
714 typedef
715 VOID
716 (ACPI_EFI_API *ACPI_EFI_COPY_MEM) (
717 VOID *Destination,
718 VOID *Source,
719 UINTN Length);
720
721 typedef
722 VOID
723 (ACPI_EFI_API *ACPI_EFI_SET_MEM) (
724 VOID *Buffer,
725 UINTN Size,
726 UINT8 Value);
727
728 /*
729 * EFI Boot Services Table
730 */
731 #define ACPI_EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
732 #define ACPI_EFI_BOOT_SERVICES_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION)
733
734 typedef struct _ACPI_EFI_BOOT_SERVICES {
735 ACPI_EFI_TABLE_HEADER Hdr;
736
737 #if 0
738 ACPI_EFI_RAISE_TPL RaiseTPL;
739 ACPI_EFI_RESTORE_TPL RestoreTPL;
740 #else
741 ACPI_EFI_UNKNOWN_INTERFACE RaiseTPL;
742 ACPI_EFI_UNKNOWN_INTERFACE RestoreTPL;
743 #endif
744
745 ACPI_EFI_ALLOCATE_PAGES AllocatePages;
746 ACPI_EFI_FREE_PAGES FreePages;
747 ACPI_EFI_GET_MEMORY_MAP GetMemoryMap;
748 ACPI_EFI_ALLOCATE_POOL AllocatePool;
749 ACPI_EFI_FREE_POOL FreePool;
750
751 #if 0
752 ACPI_EFI_CREATE_EVENT CreateEvent;
753 ACPI_EFI_SET_TIMER SetTimer;
754 ACPI_EFI_WAIT_FOR_EVENT WaitForEvent;
755 ACPI_EFI_SIGNAL_EVENT SignalEvent;
756 ACPI_EFI_CLOSE_EVENT CloseEvent;
757 ACPI_EFI_CHECK_EVENT CheckEvent;
758 #else
759 ACPI_EFI_UNKNOWN_INTERFACE CreateEvent;
760 ACPI_EFI_UNKNOWN_INTERFACE SetTimer;
761 ACPI_EFI_UNKNOWN_INTERFACE WaitForEvent;
762 ACPI_EFI_UNKNOWN_INTERFACE SignalEvent;
763 ACPI_EFI_UNKNOWN_INTERFACE CloseEvent;
764 ACPI_EFI_UNKNOWN_INTERFACE CheckEvent;
765 #endif
766
767 ACPI_EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
768 ACPI_EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
769 ACPI_EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
770 ACPI_EFI_HANDLE_PROTOCOL HandleProtocol;
771 ACPI_EFI_HANDLE_PROTOCOL PCHandleProtocol;
772 ACPI_EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
773 ACPI_EFI_LOCATE_HANDLE LocateHandle;
774 ACPI_EFI_LOCATE_DEVICE_PATH LocateDevicePath;
775 ACPI_EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
776
777 ACPI_EFI_IMAGE_LOAD LoadImage;
778 ACPI_EFI_IMAGE_START StartImage;
779 ACPI_EFI_EXIT Exit;
780 ACPI_EFI_IMAGE_UNLOAD UnloadImage;
781
782 #if 0
783 ACPI_EFI_EXIT_BOOT_SERVICES ExitBootServices;
784 ACPI_EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
785 ACPI_EFI_STALL Stall;
786 #else
787 ACPI_EFI_UNKNOWN_INTERFACE ExitBootServices;
788 ACPI_EFI_UNKNOWN_INTERFACE GetNextMonotonicCount;
789 ACPI_EFI_UNKNOWN_INTERFACE Stall;
790 #endif
791 ACPI_EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
792
793 #if 0
794 ACPI_EFI_CONNECT_CONTROLLER ConnectController;
795 ACPI_EFI_DISCONNECT_CONTROLLER DisconnectController;
796 #else
797 ACPI_EFI_UNKNOWN_INTERFACE ConnectController;
798 ACPI_EFI_UNKNOWN_INTERFACE DisconnectController;
799 #endif
800
801 ACPI_EFI_OPEN_PROTOCOL OpenProtocol;
802 ACPI_EFI_CLOSE_PROTOCOL CloseProtocol;
803 ACPI_EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
804 ACPI_EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
805 ACPI_EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
806 ACPI_EFI_LOCATE_PROTOCOL LocateProtocol;
807 ACPI_EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
808 ACPI_EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
809
810 ACPI_EFI_CALCULATE_CRC32 CalculateCrc32;
811
812 ACPI_EFI_COPY_MEM CopyMem;
813 ACPI_EFI_SET_MEM SetMem;
814
815 #if 0
816 ACPI_EFI_CREATE_EVENT_EX CreateEventEx;
817 #else
818 ACPI_EFI_UNKNOWN_INTERFACE CreateEventEx;
819 #endif
820 } ACPI_EFI_BOOT_SERVICES;
821
822
823 /*
824 * EFI System Table
825 */
826
827 /*
828 * EFI Configuration Table and GUID definitions
829 */
830 #define ACPI_TABLE_GUID \
831 { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
832 #define ACPI_20_TABLE_GUID \
833 { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
834
835 typedef struct _ACPI_EFI_CONFIGURATION_TABLE {
836 ACPI_EFI_GUID VendorGuid;
837 VOID *VendorTable;
838 } ACPI_EFI_CONFIGURATION_TABLE;
839
840
841 #define ACPI_EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
842 #define ACPI_EFI_SYSTEM_TABLE_REVISION (ACPI_EFI_SPECIFICATION_MAJOR_REVISION<<16) | (ACPI_EFI_SPECIFICATION_MINOR_REVISION)
843
844 typedef struct _ACPI_EFI_SYSTEM_TABLE {
845 ACPI_EFI_TABLE_HEADER Hdr;
846
847 CHAR16 *FirmwareVendor;
848 UINT32 FirmwareRevision;
849
850 ACPI_EFI_HANDLE ConsoleInHandle;
851 ACPI_SIMPLE_INPUT_INTERFACE *ConIn;
852
853 ACPI_EFI_HANDLE ConsoleOutHandle;
854 ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
855
856 ACPI_EFI_HANDLE StandardErrorHandle;
857 ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr;
858
859 #if 0
860 ACPI_EFI_RUNTIME_SERVICES *RuntimeServices;
861 #else
862 ACPI_EFI_HANDLE *RuntimeServices;
863 #endif
864 ACPI_EFI_BOOT_SERVICES *BootServices;
865
866 UINTN NumberOfTableEntries;
867 ACPI_EFI_CONFIGURATION_TABLE *ConfigurationTable;
868
869 } ACPI_EFI_SYSTEM_TABLE;
870
871
872 /*
873 * EFI PCI I/O Protocol
874 */
875 #define ACPI_EFI_PCI_IO_PROTOCOL \
876 { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a} }
877
878 typedef enum {
879 AcpiEfiPciIoWidthUint8 = 0,
880 AcpiEfiPciIoWidthUint16,
881 AcpiEfiPciIoWidthUint32,
882 AcpiEfiPciIoWidthUint64,
883 AcpiEfiPciIoWidthFifoUint8,
884 AcpiEfiPciIoWidthFifoUint16,
885 AcpiEfiPciIoWidthFifoUint32,
886 AcpiEfiPciIoWidthFifoUint64,
887 AcpiEfiPciIoWidthFillUint8,
888 AcpiEfiPciIoWidthFillUint16,
889 AcpiEfiPciIoWidthFillUint32,
890 AcpiEfiPciIoWidthFillUint64,
891 AcpiEfiPciIoWidthMaximum
892 } ACPI_EFI_PCI_IO_PROTOCOL_WIDTH;
893
894 typedef
895 ACPI_EFI_STATUS
896 (ACPI_EFI_API *ACPI_EFI_PCI_IO_PROTOCOL_CONFIG)(
897 struct _ACPI_EFI_PCI_IO *This,
898 ACPI_EFI_PCI_IO_PROTOCOL_WIDTH Width,
899 UINT32 Offset,
900 UINTN Count,
901 VOID *Buffer);
902
903 typedef struct {
904 ACPI_EFI_PCI_IO_PROTOCOL_CONFIG Read;
905 ACPI_EFI_PCI_IO_PROTOCOL_CONFIG Write;
906 } ACPI_EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS;
907
908 typedef
909 ACPI_EFI_STATUS
910 (ACPI_EFI_API *ACPI_EFI_PCI_IO_PROTOCOL_GET_LOCATION)(
911 struct _ACPI_EFI_PCI_IO *This,
912 UINTN *SegmentNumber,
913 UINTN *BusNumber,
914 UINTN *DeviceNumber,
915 UINTN *FunctionNumber);
916
917 typedef struct _ACPI_EFI_PCI_IO {
918 ACPI_EFI_UNKNOWN_INTERFACE PollMem;
919 ACPI_EFI_UNKNOWN_INTERFACE PollIo;
920 ACPI_EFI_UNKNOWN_INTERFACE Mem;
921 ACPI_EFI_UNKNOWN_INTERFACE Io;
922 ACPI_EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci;
923 ACPI_EFI_UNKNOWN_INTERFACE CopyMem;
924 ACPI_EFI_UNKNOWN_INTERFACE Map;
925 ACPI_EFI_UNKNOWN_INTERFACE Unmap;
926 ACPI_EFI_UNKNOWN_INTERFACE AllocateBuffer;
927 ACPI_EFI_UNKNOWN_INTERFACE FreeBuffer;
928 ACPI_EFI_UNKNOWN_INTERFACE Flush;
929 ACPI_EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation;
930 ACPI_EFI_UNKNOWN_INTERFACE Attributes;
931 ACPI_EFI_UNKNOWN_INTERFACE GetBarAttributes;
932 ACPI_EFI_UNKNOWN_INTERFACE SetBarAttributes;
933 UINT64 RomSize;
934 VOID *RomImage;
935 } ACPI_EFI_PCI_IO;
936
937 /* FILE abstraction */
938
939 union acpi_efi_file {
940 struct _ACPI_EFI_FILE_HANDLE File;
941 struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE ConOut;
942 struct _ACPI_SIMPLE_INPUT_INTERFACE ConIn;
943 };
944
945
946 /* GNU EFI definitions */
947
948 #if defined(_GNU_EFI)
949
950 /*
951 * This is needed to hide platform specific code from ACPICA
952 */
953 UINT64
954 DivU64x32 (
955 UINT64 Dividend,
956 UINTN Divisor,
957 UINTN *Remainder);
958
959 /*
960 * EFI specific prototypes
961 */
962 ACPI_EFI_STATUS
963 efi_main (
964 ACPI_EFI_HANDLE Image,
965 ACPI_EFI_SYSTEM_TABLE *SystemTab);
966
967 int
968 acpi_main (
969 int argc,
970 char *argv[]);
971
972
973 #endif
974
975 extern ACPI_EFI_GUID AcpiGbl_LoadedImageProtocol;
976 extern ACPI_EFI_GUID AcpiGbl_TextInProtocol;
977 extern ACPI_EFI_GUID AcpiGbl_TextOutProtocol;
978 extern ACPI_EFI_GUID AcpiGbl_FileSystemProtocol;
979 extern ACPI_EFI_GUID AcpiGbl_GenericFileInfo;
980
981 #endif /* __ACEFIEX_H__ */