xref: /illumos-gate/usr/src/uts/intel/sys/acpi/platform/acefiex.h (revision 8c69cc8fbe729fa7b091e901c4b50508ccc6bb33)
1 /******************************************************************************
2  *
3  * Name: acefiex.h - Extra OS specific defines, etc. for EFI
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, 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 #define EFI_ERROR(a)              (((INTN) a) < 0)
49 #define EFI_SUCCESS                             0
50 #define EFI_LOAD_ERROR                  EFIERR(1)
51 #define EFI_INVALID_PARAMETER           EFIERR(2)
52 #define EFI_UNSUPPORTED                 EFIERR(3)
53 #define EFI_BAD_BUFFER_SIZE             EFIERR(4)
54 #define EFI_BUFFER_TOO_SMALL            EFIERR(5)
55 #define EFI_NOT_READY                   EFIERR(6)
56 #define EFI_DEVICE_ERROR                EFIERR(7)
57 #define EFI_WRITE_PROTECTED             EFIERR(8)
58 #define EFI_OUT_OF_RESOURCES            EFIERR(9)
59 #define EFI_VOLUME_CORRUPTED            EFIERR(10)
60 #define EFI_VOLUME_FULL                 EFIERR(11)
61 #define EFI_NO_MEDIA                    EFIERR(12)
62 #define EFI_MEDIA_CHANGED               EFIERR(13)
63 #define EFI_NOT_FOUND                   EFIERR(14)
64 #define EFI_ACCESS_DENIED               EFIERR(15)
65 #define EFI_NO_RESPONSE                 EFIERR(16)
66 #define EFI_NO_MAPPING                  EFIERR(17)
67 #define EFI_TIMEOUT                     EFIERR(18)
68 #define EFI_NOT_STARTED                 EFIERR(19)
69 #define EFI_ALREADY_STARTED             EFIERR(20)
70 #define EFI_ABORTED                     EFIERR(21)
71 #define EFI_PROTOCOL_ERROR              EFIERR(24)
72 
73 
74 typedef UINTN EFI_STATUS;
75 typedef VOID *EFI_HANDLE;
76 typedef VOID *EFI_EVENT;
77 
78 typedef struct {
79     UINT32  Data1;
80     UINT16  Data2;
81     UINT16  Data3;
82     UINT8   Data4[8];
83 } EFI_GUID;
84 
85 typedef struct _EFI_DEVICE_PATH {
86         UINT8                           Type;
87         UINT8                           SubType;
88         UINT8                           Length[2];
89 } EFI_DEVICE_PATH;
90 
91 typedef UINT64          EFI_PHYSICAL_ADDRESS;
92 typedef UINT64          EFI_VIRTUAL_ADDRESS;
93 
94 typedef enum {
95     AllocateAnyPages,
96     AllocateMaxAddress,
97     AllocateAddress,
98     MaxAllocateType
99 } EFI_ALLOCATE_TYPE;
100 
101 typedef enum {
102     EfiReservedMemoryType,
103     EfiLoaderCode,
104     EfiLoaderData,
105     EfiBootServicesCode,
106     EfiBootServicesData,
107     EfiRuntimeServicesCode,
108     EfiRuntimeServicesData,
109     EfiConventionalMemory,
110     EfiUnusableMemory,
111     EfiACPIReclaimMemory,
112     EfiACPIMemoryNVS,
113     EfiMemoryMappedIO,
114     EfiMemoryMappedIOPortSpace,
115     EfiPalCode,
116     EfiMaxMemoryType
117 } EFI_MEMORY_TYPE;
118 
119 /* possible caching types for the memory range */
120 #define EFI_MEMORY_UC           0x0000000000000001
121 #define EFI_MEMORY_WC           0x0000000000000002
122 #define EFI_MEMORY_WT           0x0000000000000004
123 #define EFI_MEMORY_WB           0x0000000000000008
124 #define EFI_MEMORY_UCE          0x0000000000000010
125 
126 /* physical memory protection on range */
127 #define EFI_MEMORY_WP           0x0000000000001000
128 #define EFI_MEMORY_RP           0x0000000000002000
129 #define EFI_MEMORY_XP           0x0000000000004000
130 
131 /* range requires a runtime mapping */
132 #define EFI_MEMORY_RUNTIME      0x8000000000000000
133 
134 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
135 typedef struct {
136     UINT32                          Type;
137     UINT32                          Pad;
138     EFI_PHYSICAL_ADDRESS            PhysicalStart;
139     EFI_VIRTUAL_ADDRESS             VirtualStart;
140     UINT64                          NumberOfPages;
141     UINT64                          Attribute;
142 } EFI_MEMORY_DESCRIPTOR;
143 
144 typedef struct _EFI_TABLE_HEARDER {
145     UINT64                      Signature;
146     UINT32                      Revision;
147     UINT32                      HeaderSize;
148     UINT32                      CRC32;
149     UINT32                      Reserved;
150 } EFI_TABLE_HEADER;
151 
152 typedef
153 EFI_STATUS
154 (EFIAPI *EFI_UNKNOWN_INTERFACE) (
155     void);
156 
157 
158 /*
159  * Text output protocol
160  */
161 #define SIMPLE_TEXT_OUTPUT_PROTOCOL \
162     { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
163 
164 typedef
165 EFI_STATUS
166 (EFIAPI *EFI_TEXT_RESET) (
167     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
168     BOOLEAN                                 ExtendedVerification);
169 
170 typedef
171 EFI_STATUS
172 (EFIAPI *EFI_TEXT_OUTPUT_STRING) (
173     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
174     CHAR16                                  *String);
175 
176 typedef
177 EFI_STATUS
178 (EFIAPI *EFI_TEXT_TEST_STRING) (
179     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
180     CHAR16                                  *String);
181 
182 typedef
183 EFI_STATUS
184 (EFIAPI *EFI_TEXT_QUERY_MODE) (
185     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
186     UINTN                                   ModeNumber,
187     UINTN                                   *Columns,
188     UINTN                                   *Rows);
189 
190 typedef
191 EFI_STATUS
192 (EFIAPI *EFI_TEXT_SET_MODE) (
193     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
194     UINTN                                   ModeNumber);
195 
196 typedef
197 EFI_STATUS
198 (EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (
199     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
200     UINTN                                   Attribute);
201 
202 typedef
203 EFI_STATUS
204 (EFIAPI *EFI_TEXT_CLEAR_SCREEN) (
205     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This);
206 
207 typedef
208 EFI_STATUS
209 (EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (
210     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
211     UINTN                                   Column,
212     UINTN                                   Row);
213 
214 typedef
215 EFI_STATUS
216 (EFIAPI *EFI_TEXT_ENABLE_CURSOR) (
217     struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
218     BOOLEAN                                 Enable);
219 
220 typedef struct {
221     INT32                           MaxMode;
222     INT32                           Mode;
223     INT32                           Attribute;
224     INT32                           CursorColumn;
225     INT32                           CursorRow;
226     BOOLEAN                         CursorVisible;
227 } SIMPLE_TEXT_OUTPUT_MODE;
228 
229 typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE {
230     EFI_TEXT_RESET                  Reset;
231 
232     EFI_TEXT_OUTPUT_STRING          OutputString;
233     EFI_TEXT_TEST_STRING            TestString;
234 
235     EFI_TEXT_QUERY_MODE             QueryMode;
236     EFI_TEXT_SET_MODE               SetMode;
237     EFI_TEXT_SET_ATTRIBUTE          SetAttribute;
238 
239     EFI_TEXT_CLEAR_SCREEN           ClearScreen;
240     EFI_TEXT_SET_CURSOR_POSITION    SetCursorPosition;
241     EFI_TEXT_ENABLE_CURSOR          EnableCursor;
242 
243     SIMPLE_TEXT_OUTPUT_MODE         *Mode;
244 } SIMPLE_TEXT_OUTPUT_INTERFACE;
245 
246 /*
247  * Text input protocol
248  */
249 #define SIMPLE_TEXT_INPUT_PROTOCOL  \
250     { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
251 
252 typedef struct {
253     UINT16                              ScanCode;
254     CHAR16                              UnicodeChar;
255 } EFI_INPUT_KEY;
256 
257 /*
258  * Baseline unicode control chars
259  */
260 #define CHAR_NULL                       0x0000
261 #define CHAR_BACKSPACE                  0x0008
262 #define CHAR_TAB                        0x0009
263 #define CHAR_LINEFEED                   0x000A
264 #define CHAR_CARRIAGE_RETURN            0x000D
265 
266 typedef
267 EFI_STATUS
268 (EFIAPI *EFI_INPUT_RESET) (
269     struct _SIMPLE_INPUT_INTERFACE              *This,
270     BOOLEAN                                     ExtendedVerification);
271 
272 typedef
273 EFI_STATUS
274 (EFIAPI *EFI_INPUT_READ_KEY) (
275     struct _SIMPLE_INPUT_INTERFACE              *This,
276     EFI_INPUT_KEY                               *Key);
277 
278 typedef struct _SIMPLE_INPUT_INTERFACE {
279     EFI_INPUT_RESET                     Reset;
280     EFI_INPUT_READ_KEY                  ReadKeyStroke;
281     EFI_EVENT                           WaitForKey;
282 } SIMPLE_INPUT_INTERFACE;
283 
284 
285 /*
286  * Simple file system protocol
287  */
288 #define SIMPLE_FILE_SYSTEM_PROTOCOL \
289     { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
290 
291 typedef
292 EFI_STATUS
293 (EFIAPI *EFI_VOLUME_OPEN) (
294     struct _EFI_FILE_IO_INTERFACE               *This,
295     struct _EFI_FILE_HANDLE                     **Root);
296 
297 #define EFI_FILE_IO_INTERFACE_REVISION   0x00010000
298 
299 typedef struct _EFI_FILE_IO_INTERFACE {
300     UINT64                  Revision;
301     EFI_VOLUME_OPEN         OpenVolume;
302 } EFI_FILE_IO_INTERFACE;
303 
304 typedef
305 EFI_STATUS
306 (EFIAPI *EFI_FILE_OPEN) (
307     struct _EFI_FILE_HANDLE                     *File,
308     struct _EFI_FILE_HANDLE                     **NewHandle,
309     CHAR16                                      *FileName,
310     UINT64                                      OpenMode,
311     UINT64                                      Attributes);
312 
313 /* Values for OpenMode used above */
314 
315 #define EFI_FILE_MODE_READ      0x0000000000000001
316 #define EFI_FILE_MODE_WRITE     0x0000000000000002
317 #define EFI_FILE_MODE_CREATE    0x8000000000000000
318 
319 /* Values for Attribute used above */
320 
321 #define EFI_FILE_READ_ONLY      0x0000000000000001
322 #define EFI_FILE_HIDDEN         0x0000000000000002
323 #define EFI_FILE_SYSTEM         0x0000000000000004
324 #define EFI_FILE_RESERVIED      0x0000000000000008
325 #define EFI_FILE_DIRECTORY      0x0000000000000010
326 #define EFI_FILE_ARCHIVE        0x0000000000000020
327 #define EFI_FILE_VALID_ATTR     0x0000000000000037
328 
329 typedef
330 EFI_STATUS
331 (EFIAPI *EFI_FILE_CLOSE) (
332     struct _EFI_FILE_HANDLE                     *File);
333 
334 typedef
335 EFI_STATUS
336 (EFIAPI *EFI_FILE_DELETE) (
337     struct _EFI_FILE_HANDLE                     *File);
338 
339 typedef
340 EFI_STATUS
341 (EFIAPI *EFI_FILE_READ) (
342     struct _EFI_FILE_HANDLE                     *File,
343     UINTN                                       *BufferSize,
344     VOID                                        *Buffer);
345 
346 typedef
347 EFI_STATUS
348 (EFIAPI *EFI_FILE_WRITE) (
349     struct _EFI_FILE_HANDLE                     *File,
350     UINTN                                       *BufferSize,
351     VOID                                        *Buffer);
352 
353 typedef
354 EFI_STATUS
355 (EFIAPI *EFI_FILE_SET_POSITION) (
356     struct _EFI_FILE_HANDLE                     *File,
357     UINT64                                      Position);
358 
359 typedef
360 EFI_STATUS
361 (EFIAPI *EFI_FILE_GET_POSITION) (
362     struct _EFI_FILE_HANDLE                     *File,
363     UINT64                                      *Position);
364 
365 typedef
366 EFI_STATUS
367 (EFIAPI *EFI_FILE_GET_INFO) (
368     struct _EFI_FILE_HANDLE                     *File,
369     EFI_GUID                                    *InformationType,
370     UINTN                                       *BufferSize,
371     VOID                                        *Buffer);
372 
373 typedef
374 EFI_STATUS
375 (EFIAPI *EFI_FILE_SET_INFO) (
376     struct _EFI_FILE_HANDLE                     *File,
377     EFI_GUID                                    *InformationType,
378     UINTN                                       BufferSize,
379     VOID                                        *Buffer);
380 
381 typedef
382 EFI_STATUS
383 (EFIAPI *EFI_FILE_FLUSH) (
384     struct _EFI_FILE_HANDLE                     *File);
385 
386 
387 #define EFI_FILE_HANDLE_REVISION         0x00010000
388 
389 typedef struct _EFI_FILE_HANDLE {
390     UINT64                  Revision;
391     EFI_FILE_OPEN           Open;
392     EFI_FILE_CLOSE          Close;
393     EFI_FILE_DELETE         Delete;
394     EFI_FILE_READ           Read;
395     EFI_FILE_WRITE          Write;
396     EFI_FILE_GET_POSITION   GetPosition;
397     EFI_FILE_SET_POSITION   SetPosition;
398     EFI_FILE_GET_INFO       GetInfo;
399     EFI_FILE_SET_INFO       SetInfo;
400     EFI_FILE_FLUSH          Flush;
401 } EFI_FILE, *EFI_FILE_HANDLE;
402 
403 
404 /*
405  * Loaded image protocol
406  */
407 #define LOADED_IMAGE_PROTOCOL      \
408     { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
409 
410 typedef
411 EFI_STATUS
412 (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
413     EFI_HANDLE                              ImageHandle,
414     struct _EFI_SYSTEM_TABLE                *SystemTable);
415 
416 typedef
417 EFI_STATUS
418 (EFIAPI *EFI_IMAGE_LOAD) (
419     BOOLEAN                         BootPolicy,
420     EFI_HANDLE                      ParentImageHandle,
421     EFI_DEVICE_PATH                 *FilePath,
422     VOID                            *SourceBuffer,
423     UINTN                           SourceSize,
424     EFI_HANDLE                      *ImageHandle);
425 
426 typedef
427 EFI_STATUS
428 (EFIAPI *EFI_IMAGE_START) (
429     EFI_HANDLE                      ImageHandle,
430     UINTN                           *ExitDataSize,
431     CHAR16                          **ExitData);
432 
433 typedef
434 EFI_STATUS
435 (EFIAPI *EFI_EXIT) (
436     EFI_HANDLE                      ImageHandle,
437     EFI_STATUS                      ExitStatus,
438     UINTN                           ExitDataSize,
439     CHAR16                          *ExitData);
440 
441 typedef
442 EFI_STATUS
443 (EFIAPI *EFI_IMAGE_UNLOAD) (
444     EFI_HANDLE                      ImageHandle);
445 
446 
447 #define EFI_IMAGE_INFORMATION_REVISION      0x1000
448 typedef struct {
449     UINT32                          Revision;
450     EFI_HANDLE                      ParentHandle;
451     struct _EFI_SYSTEM_TABLE        *SystemTable;
452     EFI_HANDLE                      DeviceHandle;
453     EFI_DEVICE_PATH                 *FilePath;
454     VOID                            *Reserved;
455     UINT32                          LoadOptionsSize;
456     VOID                            *LoadOptions;
457     VOID                            *ImageBase;
458     UINT64                          ImageSize;
459     EFI_MEMORY_TYPE                 ImageCodeType;
460     EFI_MEMORY_TYPE                 ImageDataType;
461     EFI_IMAGE_UNLOAD                Unload;
462 
463 } EFI_LOADED_IMAGE;
464 
465 
466 /*
467  * EFI Memory
468  */
469 typedef
470 EFI_STATUS
471 (EFIAPI *EFI_ALLOCATE_PAGES) (
472     EFI_ALLOCATE_TYPE               Type,
473     EFI_MEMORY_TYPE                 MemoryType,
474     UINTN                           NoPages,
475     EFI_PHYSICAL_ADDRESS            *Memory);
476 
477 typedef
478 EFI_STATUS
479 (EFIAPI *EFI_FREE_PAGES) (
480     EFI_PHYSICAL_ADDRESS            Memory,
481     UINTN                           NoPages);
482 
483 typedef
484 EFI_STATUS
485 (EFIAPI *EFI_GET_MEMORY_MAP) (
486     UINTN                           *MemoryMapSize,
487     EFI_MEMORY_DESCRIPTOR           *MemoryMap,
488     UINTN                           *MapKey,
489     UINTN                           *DescriptorSize,
490     UINT32                          *DescriptorVersion);
491 
492 #define NextMemoryDescriptor(Ptr,Size)  ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
493 
494 typedef
495 EFI_STATUS
496 (EFIAPI *EFI_ALLOCATE_POOL) (
497     EFI_MEMORY_TYPE                 PoolType,
498     UINTN                           Size,
499     VOID                            **Buffer);
500 
501 typedef
502 EFI_STATUS
503 (EFIAPI *EFI_FREE_POOL) (
504     VOID                            *Buffer);
505 
506 
507 /*
508  * Protocol handler functions
509  */
510 typedef enum {
511     EFI_NATIVE_INTERFACE,
512     EFI_PCODE_INTERFACE
513 } EFI_INTERFACE_TYPE;
514 
515 typedef enum {
516     AllHandles,
517     ByRegisterNotify,
518     ByProtocol
519 } EFI_LOCATE_SEARCH_TYPE;
520 
521 typedef
522 EFI_STATUS
523 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
524     EFI_HANDLE                      *Handle,
525     EFI_GUID                        *Protocol,
526     EFI_INTERFACE_TYPE              InterfaceType,
527     VOID                            *Interface);
528 
529 typedef
530 EFI_STATUS
531 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
532     EFI_HANDLE                      Handle,
533     EFI_GUID                        *Protocol,
534     VOID                            *OldInterface,
535     VOID                            *NewInterface);
536 
537 typedef
538 EFI_STATUS
539 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
540     EFI_HANDLE                      Handle,
541     EFI_GUID                        *Protocol,
542     VOID                            *Interface);
543 
544 typedef
545 EFI_STATUS
546 (EFIAPI *EFI_HANDLE_PROTOCOL) (
547     EFI_HANDLE                      Handle,
548     EFI_GUID                        *Protocol,
549     VOID                            **Interface);
550 
551 typedef
552 EFI_STATUS
553 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
554     EFI_GUID                        *Protocol,
555     EFI_EVENT                       Event,
556     VOID                            **Registration);
557 
558 typedef
559 EFI_STATUS
560 (EFIAPI *EFI_LOCATE_HANDLE) (
561     EFI_LOCATE_SEARCH_TYPE          SearchType,
562     EFI_GUID                        *Protocol,
563     VOID                            *SearchKey,
564     UINTN                           *BufferSize,
565     EFI_HANDLE                      *Buffer);
566 
567 typedef
568 EFI_STATUS
569 (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
570     EFI_GUID                        *Protocol,
571     EFI_DEVICE_PATH                 **DevicePath,
572     EFI_HANDLE                      *Device);
573 
574 typedef
575 EFI_STATUS
576 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
577     EFI_GUID                        *Guid,
578     VOID                            *Table);
579 
580 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
581 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
582 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
583 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
584 #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
585 #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
586 
587 typedef
588 EFI_STATUS
589 (EFIAPI *EFI_OPEN_PROTOCOL) (
590     EFI_HANDLE                      Handle,
591     EFI_GUID                        *Protocol,
592     VOID                            **Interface,
593     EFI_HANDLE                      AgentHandle,
594     EFI_HANDLE                      ControllerHandle,
595     UINT32                          Attributes);
596 
597 typedef
598 EFI_STATUS
599 (EFIAPI *EFI_CLOSE_PROTOCOL) (
600     EFI_HANDLE                      Handle,
601     EFI_GUID                        *Protocol,
602     EFI_HANDLE                      AgentHandle,
603     EFI_HANDLE                      ControllerHandle);
604 
605 typedef struct {
606     EFI_HANDLE                  AgentHandle;
607     EFI_HANDLE                  ControllerHandle;
608     UINT32                      Attributes;
609     UINT32                      OpenCount;
610 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
611 
612 typedef
613 EFI_STATUS
614 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
615     EFI_HANDLE                      Handle,
616     EFI_GUID                        *Protocol,
617     EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
618     UINTN                           *EntryCount);
619 
620 typedef
621 EFI_STATUS
622 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
623     EFI_HANDLE                      Handle,
624     EFI_GUID                        ***ProtocolBuffer,
625     UINTN                           *ProtocolBufferCount);
626 
627 typedef
628 EFI_STATUS
629 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
630     EFI_LOCATE_SEARCH_TYPE          SearchType,
631     EFI_GUID                        *Protocol,
632     VOID                            *SearchKey,
633     UINTN                           *NoHandles,
634     EFI_HANDLE                      **Buffer);
635 
636 typedef
637 EFI_STATUS
638 (EFIAPI *EFI_LOCATE_PROTOCOL) (
639     EFI_GUID                        *Protocol,
640     VOID                            *Registration,
641     VOID                            **Interface);
642 
643 typedef
644 EFI_STATUS
645 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
646     EFI_HANDLE                      *Handle,
647     ...);
648 
649 typedef
650 EFI_STATUS
651 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
652     EFI_HANDLE                      Handle,
653     ...);
654 
655 typedef
656 EFI_STATUS
657 (EFIAPI *EFI_CALCULATE_CRC32) (
658     VOID                            *Data,
659     UINTN                           DataSize,
660     UINT32                          *Crc32);
661 
662 typedef
663 VOID
664 (EFIAPI *EFI_COPY_MEM) (
665     VOID                            *Destination,
666     VOID                            *Source,
667     UINTN                           Length);
668 
669 typedef
670 VOID
671 (EFIAPI *EFI_SET_MEM) (
672     VOID                            *Buffer,
673     UINTN                           Size,
674     UINT8                           Value);
675 
676 /*
677  * EFI Boot Services Table
678  */
679 #define EFI_BOOT_SERVICES_SIGNATURE     0x56524553544f4f42
680 #define EFI_BOOT_SERVICES_REVISION      (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
681 
682 typedef struct _EFI_BOOT_SERVICES {
683     EFI_TABLE_HEADER                Hdr;
684 
685 #if 0
686     EFI_RAISE_TPL                   RaiseTPL;
687     EFI_RESTORE_TPL                 RestoreTPL;
688 #else
689     EFI_UNKNOWN_INTERFACE           RaiseTPL;
690     EFI_UNKNOWN_INTERFACE           RestoreTPL;
691 #endif
692 
693     EFI_ALLOCATE_PAGES              AllocatePages;
694     EFI_FREE_PAGES                  FreePages;
695     EFI_GET_MEMORY_MAP              GetMemoryMap;
696     EFI_ALLOCATE_POOL               AllocatePool;
697     EFI_FREE_POOL                   FreePool;
698 
699 #if 0
700     EFI_CREATE_EVENT                CreateEvent;
701     EFI_SET_TIMER                   SetTimer;
702     EFI_WAIT_FOR_EVENT              WaitForEvent;
703     EFI_SIGNAL_EVENT                SignalEvent;
704     EFI_CLOSE_EVENT                 CloseEvent;
705     EFI_CHECK_EVENT                 CheckEvent;
706 #else
707     EFI_UNKNOWN_INTERFACE           CreateEvent;
708     EFI_UNKNOWN_INTERFACE           SetTimer;
709     EFI_UNKNOWN_INTERFACE           WaitForEvent;
710     EFI_UNKNOWN_INTERFACE           SignalEvent;
711     EFI_UNKNOWN_INTERFACE           CloseEvent;
712     EFI_UNKNOWN_INTERFACE           CheckEvent;
713 #endif
714 
715     EFI_INSTALL_PROTOCOL_INTERFACE  InstallProtocolInterface;
716     EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
717     EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
718     EFI_HANDLE_PROTOCOL             HandleProtocol;
719     EFI_HANDLE_PROTOCOL             PCHandleProtocol;
720     EFI_REGISTER_PROTOCOL_NOTIFY    RegisterProtocolNotify;
721     EFI_LOCATE_HANDLE               LocateHandle;
722     EFI_LOCATE_DEVICE_PATH          LocateDevicePath;
723     EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
724 
725     EFI_IMAGE_LOAD                  LoadImage;
726     EFI_IMAGE_START                 StartImage;
727     EFI_EXIT                        Exit;
728     EFI_IMAGE_UNLOAD                UnloadImage;
729 
730 #if 0
731     EFI_EXIT_BOOT_SERVICES          ExitBootServices;
732     EFI_GET_NEXT_MONOTONIC_COUNT    GetNextMonotonicCount;
733     EFI_STALL                       Stall;
734     EFI_SET_WATCHDOG_TIMER          SetWatchdogTimer;
735 #else
736     EFI_UNKNOWN_INTERFACE           ExitBootServices;
737     EFI_UNKNOWN_INTERFACE           GetNextMonotonicCount;
738     EFI_UNKNOWN_INTERFACE           Stall;
739     EFI_UNKNOWN_INTERFACE           SetWatchdogTimer;
740 #endif
741 
742 #if 0
743     EFI_CONNECT_CONTROLLER          ConnectController;
744     EFI_DISCONNECT_CONTROLLER       DisconnectController;
745 #else
746     EFI_UNKNOWN_INTERFACE           ConnectController;
747     EFI_UNKNOWN_INTERFACE           DisconnectController;
748 #endif
749 
750     EFI_OPEN_PROTOCOL               OpenProtocol;
751     EFI_CLOSE_PROTOCOL              CloseProtocol;
752     EFI_OPEN_PROTOCOL_INFORMATION   OpenProtocolInformation;
753     EFI_PROTOCOLS_PER_HANDLE        ProtocolsPerHandle;
754     EFI_LOCATE_HANDLE_BUFFER        LocateHandleBuffer;
755     EFI_LOCATE_PROTOCOL             LocateProtocol;
756     EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
757     EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
758 
759     EFI_CALCULATE_CRC32             CalculateCrc32;
760 
761     EFI_COPY_MEM                    CopyMem;
762     EFI_SET_MEM                     SetMem;
763 
764 #if 0
765     EFI_CREATE_EVENT_EX             CreateEventEx;
766 #else
767     EFI_UNKNOWN_INTERFACE           CreateEventEx;
768 #endif
769 } EFI_BOOT_SERVICES;
770 
771 
772 /*
773  * EFI System Table
774  */
775 
776 /*
777  * EFI Configuration Table and GUID definitions
778  */
779 #define ACPI_TABLE_GUID    \
780     { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
781 #define ACPI_20_TABLE_GUID  \
782     { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
783 
784 typedef struct _EFI_CONFIGURATION_TABLE {
785     EFI_GUID                VendorGuid;
786     VOID                    *VendorTable;
787 } EFI_CONFIGURATION_TABLE;
788 
789 
790 #define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249
791 #define EFI_SYSTEM_TABLE_REVISION      (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
792 
793 typedef struct _EFI_SYSTEM_TABLE {
794     EFI_TABLE_HEADER                Hdr;
795 
796     CHAR16                          *FirmwareVendor;
797     UINT32                          FirmwareRevision;
798 
799     EFI_HANDLE                      ConsoleInHandle;
800     SIMPLE_INPUT_INTERFACE          *ConIn;
801 
802     EFI_HANDLE                      ConsoleOutHandle;
803     SIMPLE_TEXT_OUTPUT_INTERFACE    *ConOut;
804 
805     EFI_HANDLE                      StandardErrorHandle;
806     SIMPLE_TEXT_OUTPUT_INTERFACE    *StdErr;
807 
808 #if 0
809     EFI_RUNTIME_SERVICES            *RuntimeServices;
810 #else
811     EFI_HANDLE                      *RuntimeServices;
812 #endif
813     EFI_BOOT_SERVICES               *BootServices;
814 
815     UINTN                           NumberOfTableEntries;
816     EFI_CONFIGURATION_TABLE         *ConfigurationTable;
817 
818 } EFI_SYSTEM_TABLE;
819 
820 
821 /* GNU EFI definitions */
822 
823 #if defined(_GNU_EFI)
824 
825 /*
826  * This is needed to hide platform specific code from ACPICA
827  */
828 UINT64
829 DivU64x32 (
830     UINT64                  Dividend,
831     UINTN                   Divisor,
832     UINTN                   *Remainder);
833 
834 /*
835  * EFI specific prototypes
836  */
837 EFI_STATUS
838 efi_main (
839     EFI_HANDLE              Image,
840     EFI_SYSTEM_TABLE        *SystemTab);
841 
842 int
843 acpi_main (
844     int                     argc,
845     char                    *argv[]);
846 
847 
848 #endif
849 
850 extern EFI_GUID AcpiGbl_LoadedImageProtocol;
851 extern EFI_GUID AcpiGbl_TextInProtocol;
852 extern EFI_GUID AcpiGbl_TextOutProtocol;
853 extern EFI_GUID AcpiGbl_FileSystemProtocol;
854 
855 #endif /* __ACEFIEX_H__ */
856