1/******************************************************************************
2 *
3 * Name: acefiex.h - Extra OS specific defines, etc. for EFI
4 *
5 *****************************************************************************/
6
7/******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************/
115
116#ifndef __ACEFIEX_H__
117#define __ACEFIEX_H__
118
119
120#define EFI_ERROR(a)              (((INTN) a) < 0)
121#define EFI_SUCCESS                             0
122#define EFI_LOAD_ERROR                  EFIERR(1)
123#define EFI_INVALID_PARAMETER           EFIERR(2)
124#define EFI_UNSUPPORTED                 EFIERR(3)
125#define EFI_BAD_BUFFER_SIZE             EFIERR(4)
126#define EFI_BUFFER_TOO_SMALL            EFIERR(5)
127#define EFI_NOT_READY                   EFIERR(6)
128#define EFI_DEVICE_ERROR                EFIERR(7)
129#define EFI_WRITE_PROTECTED             EFIERR(8)
130#define EFI_OUT_OF_RESOURCES            EFIERR(9)
131#define EFI_VOLUME_CORRUPTED            EFIERR(10)
132#define EFI_VOLUME_FULL                 EFIERR(11)
133#define EFI_NO_MEDIA                    EFIERR(12)
134#define EFI_MEDIA_CHANGED               EFIERR(13)
135#define EFI_NOT_FOUND                   EFIERR(14)
136#define EFI_ACCESS_DENIED               EFIERR(15)
137#define EFI_NO_RESPONSE                 EFIERR(16)
138#define EFI_NO_MAPPING                  EFIERR(17)
139#define EFI_TIMEOUT                     EFIERR(18)
140#define EFI_NOT_STARTED                 EFIERR(19)
141#define EFI_ALREADY_STARTED             EFIERR(20)
142#define EFI_ABORTED                     EFIERR(21)
143#define EFI_PROTOCOL_ERROR              EFIERR(24)
144
145
146typedef UINTN EFI_STATUS;
147typedef VOID *EFI_HANDLE;
148typedef VOID *EFI_EVENT;
149
150typedef struct {
151    UINT32  Data1;
152    UINT16  Data2;
153    UINT16  Data3;
154    UINT8   Data4[8];
155} EFI_GUID;
156
157typedef struct _EFI_DEVICE_PATH {
158        UINT8                           Type;
159        UINT8                           SubType;
160        UINT8                           Length[2];
161} EFI_DEVICE_PATH;
162
163typedef UINT64          EFI_PHYSICAL_ADDRESS;
164typedef UINT64          EFI_VIRTUAL_ADDRESS;
165
166typedef enum {
167    AllocateAnyPages,
168    AllocateMaxAddress,
169    AllocateAddress,
170    MaxAllocateType
171} EFI_ALLOCATE_TYPE;
172
173typedef enum {
174    EfiReservedMemoryType,
175    EfiLoaderCode,
176    EfiLoaderData,
177    EfiBootServicesCode,
178    EfiBootServicesData,
179    EfiRuntimeServicesCode,
180    EfiRuntimeServicesData,
181    EfiConventionalMemory,
182    EfiUnusableMemory,
183    EfiACPIReclaimMemory,
184    EfiACPIMemoryNVS,
185    EfiMemoryMappedIO,
186    EfiMemoryMappedIOPortSpace,
187    EfiPalCode,
188    EfiMaxMemoryType
189} EFI_MEMORY_TYPE;
190
191/* possible caching types for the memory range */
192#define EFI_MEMORY_UC           0x0000000000000001
193#define EFI_MEMORY_WC           0x0000000000000002
194#define EFI_MEMORY_WT           0x0000000000000004
195#define EFI_MEMORY_WB           0x0000000000000008
196#define EFI_MEMORY_UCE          0x0000000000000010
197
198/* physical memory protection on range */
199#define EFI_MEMORY_WP           0x0000000000001000
200#define EFI_MEMORY_RP           0x0000000000002000
201#define EFI_MEMORY_XP           0x0000000000004000
202
203/* range requires a runtime mapping */
204#define EFI_MEMORY_RUNTIME      0x8000000000000000
205
206#define EFI_MEMORY_DESCRIPTOR_VERSION  1
207typedef struct {
208    UINT32                          Type;
209    UINT32                          Pad;
210    EFI_PHYSICAL_ADDRESS            PhysicalStart;
211    EFI_VIRTUAL_ADDRESS             VirtualStart;
212    UINT64                          NumberOfPages;
213    UINT64                          Attribute;
214} EFI_MEMORY_DESCRIPTOR;
215
216typedef struct _EFI_TABLE_HEARDER {
217    UINT64                      Signature;
218    UINT32                      Revision;
219    UINT32                      HeaderSize;
220    UINT32                      CRC32;
221    UINT32                      Reserved;
222} EFI_TABLE_HEADER;
223
224typedef
225EFI_STATUS
226(EFIAPI *EFI_UNKNOWN_INTERFACE) (
227    void);
228
229
230/*
231 * Text output protocol
232 */
233#define SIMPLE_TEXT_OUTPUT_PROTOCOL \
234    { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
235
236typedef
237EFI_STATUS
238(EFIAPI *EFI_TEXT_RESET) (
239    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
240    BOOLEAN                                 ExtendedVerification);
241
242typedef
243EFI_STATUS
244(EFIAPI *EFI_TEXT_OUTPUT_STRING) (
245    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
246    CHAR16                                  *String);
247
248typedef
249EFI_STATUS
250(EFIAPI *EFI_TEXT_TEST_STRING) (
251    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
252    CHAR16                                  *String);
253
254typedef
255EFI_STATUS
256(EFIAPI *EFI_TEXT_QUERY_MODE) (
257    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
258    UINTN                                   ModeNumber,
259    UINTN                                   *Columns,
260    UINTN                                   *Rows);
261
262typedef
263EFI_STATUS
264(EFIAPI *EFI_TEXT_SET_MODE) (
265    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
266    UINTN                                   ModeNumber);
267
268typedef
269EFI_STATUS
270(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (
271    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
272    UINTN                                   Attribute);
273
274typedef
275EFI_STATUS
276(EFIAPI *EFI_TEXT_CLEAR_SCREEN) (
277    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This);
278
279typedef
280EFI_STATUS
281(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (
282    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
283    UINTN                                   Column,
284    UINTN                                   Row);
285
286typedef
287EFI_STATUS
288(EFIAPI *EFI_TEXT_ENABLE_CURSOR) (
289    struct _SIMPLE_TEXT_OUTPUT_INTERFACE    *This,
290    BOOLEAN                                 Enable);
291
292typedef struct {
293    INT32                           MaxMode;
294    INT32                           Mode;
295    INT32                           Attribute;
296    INT32                           CursorColumn;
297    INT32                           CursorRow;
298    BOOLEAN                         CursorVisible;
299} SIMPLE_TEXT_OUTPUT_MODE;
300
301typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE {
302    EFI_TEXT_RESET                  Reset;
303
304    EFI_TEXT_OUTPUT_STRING          OutputString;
305    EFI_TEXT_TEST_STRING            TestString;
306
307    EFI_TEXT_QUERY_MODE             QueryMode;
308    EFI_TEXT_SET_MODE               SetMode;
309    EFI_TEXT_SET_ATTRIBUTE          SetAttribute;
310
311    EFI_TEXT_CLEAR_SCREEN           ClearScreen;
312    EFI_TEXT_SET_CURSOR_POSITION    SetCursorPosition;
313    EFI_TEXT_ENABLE_CURSOR          EnableCursor;
314
315    SIMPLE_TEXT_OUTPUT_MODE         *Mode;
316} SIMPLE_TEXT_OUTPUT_INTERFACE;
317
318/*
319 * Text input protocol
320 */
321#define SIMPLE_TEXT_INPUT_PROTOCOL  \
322    { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
323
324typedef struct {
325    UINT16                              ScanCode;
326    CHAR16                              UnicodeChar;
327} EFI_INPUT_KEY;
328
329/*
330 * Baseline unicode control chars
331 */
332#define CHAR_NULL                       0x0000
333#define CHAR_BACKSPACE                  0x0008
334#define CHAR_TAB                        0x0009
335#define CHAR_LINEFEED                   0x000A
336#define CHAR_CARRIAGE_RETURN            0x000D
337
338typedef
339EFI_STATUS
340(EFIAPI *EFI_INPUT_RESET) (
341    struct _SIMPLE_INPUT_INTERFACE              *This,
342    BOOLEAN                                     ExtendedVerification);
343
344typedef
345EFI_STATUS
346(EFIAPI *EFI_INPUT_READ_KEY) (
347    struct _SIMPLE_INPUT_INTERFACE              *This,
348    EFI_INPUT_KEY                               *Key);
349
350typedef struct _SIMPLE_INPUT_INTERFACE {
351    EFI_INPUT_RESET                     Reset;
352    EFI_INPUT_READ_KEY                  ReadKeyStroke;
353    EFI_EVENT                           WaitForKey;
354} SIMPLE_INPUT_INTERFACE;
355
356
357/*
358 * Simple file system protocol
359 */
360#define SIMPLE_FILE_SYSTEM_PROTOCOL \
361    { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
362
363typedef
364EFI_STATUS
365(EFIAPI *EFI_VOLUME_OPEN) (
366    struct _EFI_FILE_IO_INTERFACE               *This,
367    struct _EFI_FILE_HANDLE                     **Root);
368
369#define EFI_FILE_IO_INTERFACE_REVISION   0x00010000
370
371typedef struct _EFI_FILE_IO_INTERFACE {
372    UINT64                  Revision;
373    EFI_VOLUME_OPEN         OpenVolume;
374} EFI_FILE_IO_INTERFACE;
375
376typedef
377EFI_STATUS
378(EFIAPI *EFI_FILE_OPEN) (
379    struct _EFI_FILE_HANDLE                     *File,
380    struct _EFI_FILE_HANDLE                     **NewHandle,
381    CHAR16                                      *FileName,
382    UINT64                                      OpenMode,
383    UINT64                                      Attributes);
384
385/* Values for OpenMode used above */
386
387#define EFI_FILE_MODE_READ      0x0000000000000001
388#define EFI_FILE_MODE_WRITE     0x0000000000000002
389#define EFI_FILE_MODE_CREATE    0x8000000000000000
390
391/* Values for Attribute used above */
392
393#define EFI_FILE_READ_ONLY      0x0000000000000001
394#define EFI_FILE_HIDDEN         0x0000000000000002
395#define EFI_FILE_SYSTEM         0x0000000000000004
396#define EFI_FILE_RESERVIED      0x0000000000000008
397#define EFI_FILE_DIRECTORY      0x0000000000000010
398#define EFI_FILE_ARCHIVE        0x0000000000000020
399#define EFI_FILE_VALID_ATTR     0x0000000000000037
400
401typedef
402EFI_STATUS
403(EFIAPI *EFI_FILE_CLOSE) (
404    struct _EFI_FILE_HANDLE                     *File);
405
406typedef
407EFI_STATUS
408(EFIAPI *EFI_FILE_DELETE) (
409    struct _EFI_FILE_HANDLE                     *File);
410
411typedef
412EFI_STATUS
413(EFIAPI *EFI_FILE_READ) (
414    struct _EFI_FILE_HANDLE                     *File,
415    UINTN                                       *BufferSize,
416    VOID                                        *Buffer);
417
418typedef
419EFI_STATUS
420(EFIAPI *EFI_FILE_WRITE) (
421    struct _EFI_FILE_HANDLE                     *File,
422    UINTN                                       *BufferSize,
423    VOID                                        *Buffer);
424
425typedef
426EFI_STATUS
427(EFIAPI *EFI_FILE_SET_POSITION) (
428    struct _EFI_FILE_HANDLE                     *File,
429    UINT64                                      Position);
430
431typedef
432EFI_STATUS
433(EFIAPI *EFI_FILE_GET_POSITION) (
434    struct _EFI_FILE_HANDLE                     *File,
435    UINT64                                      *Position);
436
437typedef
438EFI_STATUS
439(EFIAPI *EFI_FILE_GET_INFO) (
440    struct _EFI_FILE_HANDLE                     *File,
441    EFI_GUID                                    *InformationType,
442    UINTN                                       *BufferSize,
443    VOID                                        *Buffer);
444
445typedef
446EFI_STATUS
447(EFIAPI *EFI_FILE_SET_INFO) (
448    struct _EFI_FILE_HANDLE                     *File,
449    EFI_GUID                                    *InformationType,
450    UINTN                                       BufferSize,
451    VOID                                        *Buffer);
452
453typedef
454EFI_STATUS
455(EFIAPI *EFI_FILE_FLUSH) (
456    struct _EFI_FILE_HANDLE                     *File);
457
458
459#define EFI_FILE_HANDLE_REVISION         0x00010000
460
461typedef struct _EFI_FILE_HANDLE {
462    UINT64                  Revision;
463    EFI_FILE_OPEN           Open;
464    EFI_FILE_CLOSE          Close;
465    EFI_FILE_DELETE         Delete;
466    EFI_FILE_READ           Read;
467    EFI_FILE_WRITE          Write;
468    EFI_FILE_GET_POSITION   GetPosition;
469    EFI_FILE_SET_POSITION   SetPosition;
470    EFI_FILE_GET_INFO       GetInfo;
471    EFI_FILE_SET_INFO       SetInfo;
472    EFI_FILE_FLUSH          Flush;
473} EFI_FILE, *EFI_FILE_HANDLE;
474
475
476/*
477 * Loaded image protocol
478 */
479#define LOADED_IMAGE_PROTOCOL      \
480    { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
481
482typedef
483EFI_STATUS
484(EFIAPI *EFI_IMAGE_ENTRY_POINT) (
485    EFI_HANDLE                              ImageHandle,
486    struct _EFI_SYSTEM_TABLE                *SystemTable);
487
488typedef
489EFI_STATUS
490(EFIAPI *EFI_IMAGE_LOAD) (
491    BOOLEAN                         BootPolicy,
492    EFI_HANDLE                      ParentImageHandle,
493    EFI_DEVICE_PATH                 *FilePath,
494    VOID                            *SourceBuffer,
495    UINTN                           SourceSize,
496    EFI_HANDLE                      *ImageHandle);
497
498typedef
499EFI_STATUS
500(EFIAPI *EFI_IMAGE_START) (
501    EFI_HANDLE                      ImageHandle,
502    UINTN                           *ExitDataSize,
503    CHAR16                          **ExitData);
504
505typedef
506EFI_STATUS
507(EFIAPI *EFI_EXIT) (
508    EFI_HANDLE                      ImageHandle,
509    EFI_STATUS                      ExitStatus,
510    UINTN                           ExitDataSize,
511    CHAR16                          *ExitData);
512
513typedef
514EFI_STATUS
515(EFIAPI *EFI_IMAGE_UNLOAD) (
516    EFI_HANDLE                      ImageHandle);
517
518
519#define EFI_IMAGE_INFORMATION_REVISION      0x1000
520typedef struct {
521    UINT32                          Revision;
522    EFI_HANDLE                      ParentHandle;
523    struct _EFI_SYSTEM_TABLE        *SystemTable;
524    EFI_HANDLE                      DeviceHandle;
525    EFI_DEVICE_PATH                 *FilePath;
526    VOID                            *Reserved;
527    UINT32                          LoadOptionsSize;
528    VOID                            *LoadOptions;
529    VOID                            *ImageBase;
530    UINT64                          ImageSize;
531    EFI_MEMORY_TYPE                 ImageCodeType;
532    EFI_MEMORY_TYPE                 ImageDataType;
533    EFI_IMAGE_UNLOAD                Unload;
534
535} EFI_LOADED_IMAGE;
536
537
538/*
539 * EFI Memory
540 */
541typedef
542EFI_STATUS
543(EFIAPI *EFI_ALLOCATE_PAGES) (
544    EFI_ALLOCATE_TYPE               Type,
545    EFI_MEMORY_TYPE                 MemoryType,
546    UINTN                           NoPages,
547    EFI_PHYSICAL_ADDRESS            *Memory);
548
549typedef
550EFI_STATUS
551(EFIAPI *EFI_FREE_PAGES) (
552    EFI_PHYSICAL_ADDRESS            Memory,
553    UINTN                           NoPages);
554
555typedef
556EFI_STATUS
557(EFIAPI *EFI_GET_MEMORY_MAP) (
558    UINTN                           *MemoryMapSize,
559    EFI_MEMORY_DESCRIPTOR           *MemoryMap,
560    UINTN                           *MapKey,
561    UINTN                           *DescriptorSize,
562    UINT32                          *DescriptorVersion);
563
564#define NextMemoryDescriptor(Ptr,Size)  ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
565
566typedef
567EFI_STATUS
568(EFIAPI *EFI_ALLOCATE_POOL) (
569    EFI_MEMORY_TYPE                 PoolType,
570    UINTN                           Size,
571    VOID                            **Buffer);
572
573typedef
574EFI_STATUS
575(EFIAPI *EFI_FREE_POOL) (
576    VOID                            *Buffer);
577
578
579/*
580 * Protocol handler functions
581 */
582typedef enum {
583    EFI_NATIVE_INTERFACE,
584    EFI_PCODE_INTERFACE
585} EFI_INTERFACE_TYPE;
586
587typedef enum {
588    AllHandles,
589    ByRegisterNotify,
590    ByProtocol
591} EFI_LOCATE_SEARCH_TYPE;
592
593typedef
594EFI_STATUS
595(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
596    EFI_HANDLE                      *Handle,
597    EFI_GUID                        *Protocol,
598    EFI_INTERFACE_TYPE              InterfaceType,
599    VOID                            *Interface);
600
601typedef
602EFI_STATUS
603(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
604    EFI_HANDLE                      Handle,
605    EFI_GUID                        *Protocol,
606    VOID                            *OldInterface,
607    VOID                            *NewInterface);
608
609typedef
610EFI_STATUS
611(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
612    EFI_HANDLE                      Handle,
613    EFI_GUID                        *Protocol,
614    VOID                            *Interface);
615
616typedef
617EFI_STATUS
618(EFIAPI *EFI_HANDLE_PROTOCOL) (
619    EFI_HANDLE                      Handle,
620    EFI_GUID                        *Protocol,
621    VOID                            **Interface);
622
623typedef
624EFI_STATUS
625(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
626    EFI_GUID                        *Protocol,
627    EFI_EVENT                       Event,
628    VOID                            **Registration);
629
630typedef
631EFI_STATUS
632(EFIAPI *EFI_LOCATE_HANDLE) (
633    EFI_LOCATE_SEARCH_TYPE          SearchType,
634    EFI_GUID                        *Protocol,
635    VOID                            *SearchKey,
636    UINTN                           *BufferSize,
637    EFI_HANDLE                      *Buffer);
638
639typedef
640EFI_STATUS
641(EFIAPI *EFI_LOCATE_DEVICE_PATH) (
642    EFI_GUID                        *Protocol,
643    EFI_DEVICE_PATH                 **DevicePath,
644    EFI_HANDLE                      *Device);
645
646typedef
647EFI_STATUS
648(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
649    EFI_GUID                        *Guid,
650    VOID                            *Table);
651
652#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
653#define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
654#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
655#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
656#define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
657#define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
658
659typedef
660EFI_STATUS
661(EFIAPI *EFI_OPEN_PROTOCOL) (
662    EFI_HANDLE                      Handle,
663    EFI_GUID                        *Protocol,
664    VOID                            **Interface,
665    EFI_HANDLE                      AgentHandle,
666    EFI_HANDLE                      ControllerHandle,
667    UINT32                          Attributes);
668
669typedef
670EFI_STATUS
671(EFIAPI *EFI_CLOSE_PROTOCOL) (
672    EFI_HANDLE                      Handle,
673    EFI_GUID                        *Protocol,
674    EFI_HANDLE                      AgentHandle,
675    EFI_HANDLE                      ControllerHandle);
676
677typedef struct {
678    EFI_HANDLE                  AgentHandle;
679    EFI_HANDLE                  ControllerHandle;
680    UINT32                      Attributes;
681    UINT32                      OpenCount;
682} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
683
684typedef
685EFI_STATUS
686(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
687    EFI_HANDLE                      Handle,
688    EFI_GUID                        *Protocol,
689    EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
690    UINTN                           *EntryCount);
691
692typedef
693EFI_STATUS
694(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
695    EFI_HANDLE                      Handle,
696    EFI_GUID                        ***ProtocolBuffer,
697    UINTN                           *ProtocolBufferCount);
698
699typedef
700EFI_STATUS
701(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
702    EFI_LOCATE_SEARCH_TYPE          SearchType,
703    EFI_GUID                        *Protocol,
704    VOID                            *SearchKey,
705    UINTN                           *NoHandles,
706    EFI_HANDLE                      **Buffer);
707
708typedef
709EFI_STATUS
710(EFIAPI *EFI_LOCATE_PROTOCOL) (
711    EFI_GUID                        *Protocol,
712    VOID                            *Registration,
713    VOID                            **Interface);
714
715typedef
716EFI_STATUS
717(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
718    EFI_HANDLE                      *Handle,
719    ...);
720
721typedef
722EFI_STATUS
723(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
724    EFI_HANDLE                      Handle,
725    ...);
726
727typedef
728EFI_STATUS
729(EFIAPI *EFI_CALCULATE_CRC32) (
730    VOID                            *Data,
731    UINTN                           DataSize,
732    UINT32                          *Crc32);
733
734typedef
735VOID
736(EFIAPI *EFI_COPY_MEM) (
737    VOID                            *Destination,
738    VOID                            *Source,
739    UINTN                           Length);
740
741typedef
742VOID
743(EFIAPI *EFI_SET_MEM) (
744    VOID                            *Buffer,
745    UINTN                           Size,
746    UINT8                           Value);
747
748/*
749 * EFI Boot Services Table
750 */
751#define EFI_BOOT_SERVICES_SIGNATURE     0x56524553544f4f42
752#define EFI_BOOT_SERVICES_REVISION      (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
753
754typedef struct _EFI_BOOT_SERVICES {
755    EFI_TABLE_HEADER                Hdr;
756
757#if 0
758    EFI_RAISE_TPL                   RaiseTPL;
759    EFI_RESTORE_TPL                 RestoreTPL;
760#else
761    EFI_UNKNOWN_INTERFACE           RaiseTPL;
762    EFI_UNKNOWN_INTERFACE           RestoreTPL;
763#endif
764
765    EFI_ALLOCATE_PAGES              AllocatePages;
766    EFI_FREE_PAGES                  FreePages;
767    EFI_GET_MEMORY_MAP              GetMemoryMap;
768    EFI_ALLOCATE_POOL               AllocatePool;
769    EFI_FREE_POOL                   FreePool;
770
771#if 0
772    EFI_CREATE_EVENT                CreateEvent;
773    EFI_SET_TIMER                   SetTimer;
774    EFI_WAIT_FOR_EVENT              WaitForEvent;
775    EFI_SIGNAL_EVENT                SignalEvent;
776    EFI_CLOSE_EVENT                 CloseEvent;
777    EFI_CHECK_EVENT                 CheckEvent;
778#else
779    EFI_UNKNOWN_INTERFACE           CreateEvent;
780    EFI_UNKNOWN_INTERFACE           SetTimer;
781    EFI_UNKNOWN_INTERFACE           WaitForEvent;
782    EFI_UNKNOWN_INTERFACE           SignalEvent;
783    EFI_UNKNOWN_INTERFACE           CloseEvent;
784    EFI_UNKNOWN_INTERFACE           CheckEvent;
785#endif
786
787    EFI_INSTALL_PROTOCOL_INTERFACE  InstallProtocolInterface;
788    EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
789    EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
790    EFI_HANDLE_PROTOCOL             HandleProtocol;
791    EFI_HANDLE_PROTOCOL             PCHandleProtocol;
792    EFI_REGISTER_PROTOCOL_NOTIFY    RegisterProtocolNotify;
793    EFI_LOCATE_HANDLE               LocateHandle;
794    EFI_LOCATE_DEVICE_PATH          LocateDevicePath;
795    EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
796
797    EFI_IMAGE_LOAD                  LoadImage;
798    EFI_IMAGE_START                 StartImage;
799    EFI_EXIT                        Exit;
800    EFI_IMAGE_UNLOAD                UnloadImage;
801
802#if 0
803    EFI_EXIT_BOOT_SERVICES          ExitBootServices;
804    EFI_GET_NEXT_MONOTONIC_COUNT    GetNextMonotonicCount;
805    EFI_STALL                       Stall;
806    EFI_SET_WATCHDOG_TIMER          SetWatchdogTimer;
807#else
808    EFI_UNKNOWN_INTERFACE           ExitBootServices;
809    EFI_UNKNOWN_INTERFACE           GetNextMonotonicCount;
810    EFI_UNKNOWN_INTERFACE           Stall;
811    EFI_UNKNOWN_INTERFACE           SetWatchdogTimer;
812#endif
813
814#if 0
815    EFI_CONNECT_CONTROLLER          ConnectController;
816    EFI_DISCONNECT_CONTROLLER       DisconnectController;
817#else
818    EFI_UNKNOWN_INTERFACE           ConnectController;
819    EFI_UNKNOWN_INTERFACE           DisconnectController;
820#endif
821
822    EFI_OPEN_PROTOCOL               OpenProtocol;
823    EFI_CLOSE_PROTOCOL              CloseProtocol;
824    EFI_OPEN_PROTOCOL_INFORMATION   OpenProtocolInformation;
825    EFI_PROTOCOLS_PER_HANDLE        ProtocolsPerHandle;
826    EFI_LOCATE_HANDLE_BUFFER        LocateHandleBuffer;
827    EFI_LOCATE_PROTOCOL             LocateProtocol;
828    EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
829    EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
830
831    EFI_CALCULATE_CRC32             CalculateCrc32;
832
833    EFI_COPY_MEM                    CopyMem;
834    EFI_SET_MEM                     SetMem;
835
836#if 0
837    EFI_CREATE_EVENT_EX             CreateEventEx;
838#else
839    EFI_UNKNOWN_INTERFACE           CreateEventEx;
840#endif
841} EFI_BOOT_SERVICES;
842
843
844/*
845 * EFI System Table
846 */
847
848/*
849 * EFI Configuration Table and GUID definitions
850 */
851#define ACPI_TABLE_GUID    \
852    { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
853#define ACPI_20_TABLE_GUID  \
854    { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
855
856typedef struct _EFI_CONFIGURATION_TABLE {
857    EFI_GUID                VendorGuid;
858    VOID                    *VendorTable;
859} EFI_CONFIGURATION_TABLE;
860
861
862#define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249
863#define EFI_SYSTEM_TABLE_REVISION      (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
864
865typedef struct _EFI_SYSTEM_TABLE {
866    EFI_TABLE_HEADER                Hdr;
867
868    CHAR16                          *FirmwareVendor;
869    UINT32                          FirmwareRevision;
870
871    EFI_HANDLE                      ConsoleInHandle;
872    SIMPLE_INPUT_INTERFACE          *ConIn;
873
874    EFI_HANDLE                      ConsoleOutHandle;
875    SIMPLE_TEXT_OUTPUT_INTERFACE    *ConOut;
876
877    EFI_HANDLE                      StandardErrorHandle;
878    SIMPLE_TEXT_OUTPUT_INTERFACE    *StdErr;
879
880#if 0
881    EFI_RUNTIME_SERVICES            *RuntimeServices;
882#else
883    EFI_HANDLE                      *RuntimeServices;
884#endif
885    EFI_BOOT_SERVICES               *BootServices;
886
887    UINTN                           NumberOfTableEntries;
888    EFI_CONFIGURATION_TABLE         *ConfigurationTable;
889
890} EFI_SYSTEM_TABLE;
891
892
893/* GNU EFI definitions */
894
895#if defined(_GNU_EFI)
896
897/*
898 * This is needed to hide platform specific code from ACPICA
899 */
900UINT64
901DivU64x32 (
902    UINT64                  Dividend,
903    UINTN                   Divisor,
904    UINTN                   *Remainder);
905
906/*
907 * EFI specific prototypes
908 */
909EFI_STATUS
910efi_main (
911    EFI_HANDLE              Image,
912    EFI_SYSTEM_TABLE        *SystemTab);
913
914int
915acpi_main (
916    int                     argc,
917    char                    *argv[]);
918
919
920#endif
921
922extern EFI_GUID AcpiGbl_LoadedImageProtocol;
923extern EFI_GUID AcpiGbl_TextInProtocol;
924extern EFI_GUID AcpiGbl_TextOutProtocol;
925extern EFI_GUID AcpiGbl_FileSystemProtocol;
926
927#endif /* __ACEFIEX_H__ */
928