1/** @file
2  Include file that supports UEFI.
3
4  This include file must only contain things defined in the UEFI 2.1 specification.
5  If a code construct is defined in the UEFI 2.1 specification it must be included
6  by this include file.
7
8  Copyright (c) 2006 - 2008, Intel Corporation
9  All rights reserved. This program and the accompanying materials
10  are licensed and made available under the terms and conditions of the BSD License
11  which accompanies this distribution.  The full text of the license may be found at
12  http://opensource.org/licenses/bsd-license.php
13
14  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17**/
18
19#ifndef __UEFI_SPEC_H__
20#define __UEFI_SPEC_H__
21
22#include <gpxe/efi/Uefi/UefiMultiPhase.h>
23
24#include <gpxe/efi/Protocol/DevicePath.h>
25#include <gpxe/efi/Protocol/SimpleTextIn.h>
26#include <gpxe/efi/Protocol/SimpleTextOut.h>
27
28///
29/// Enumeration of memory allocation.
30///
31typedef enum {
32  AllocateAnyPages,
33  AllocateMaxAddress,
34  AllocateAddress,
35  MaxAllocateType
36} EFI_ALLOCATE_TYPE;
37
38//
39// Bit definitions for EFI_TIME.Daylight
40//
41#define EFI_TIME_ADJUST_DAYLIGHT  0x01
42#define EFI_TIME_IN_DAYLIGHT      0x02
43
44///
45/// Value definition for EFI_TIME.TimeZone
46///
47#define EFI_UNSPECIFIED_TIMEZONE  0x07FF
48
49//
50// Memory cacheability attributes
51//
52#define EFI_MEMORY_UC   0x0000000000000001ULL
53#define EFI_MEMORY_WC   0x0000000000000002ULL
54#define EFI_MEMORY_WT   0x0000000000000004ULL
55#define EFI_MEMORY_WB   0x0000000000000008ULL
56#define EFI_MEMORY_UCE  0x0000000000000010ULL
57//
58// Physical memory protection attributes
59//
60#define EFI_MEMORY_WP   0x0000000000001000ULL
61#define EFI_MEMORY_RP   0x0000000000002000ULL
62#define EFI_MEMORY_XP   0x0000000000004000ULL
63//
64// Runtime memory attribute
65//
66#define EFI_MEMORY_RUNTIME  0x8000000000000000ULL
67
68///
69/// Memory descriptor version number
70///
71#define EFI_MEMORY_DESCRIPTOR_VERSION 1
72
73///
74/// Definition of memory descriptor
75///
76typedef struct {
77  UINT32                Type;
78  EFI_PHYSICAL_ADDRESS  PhysicalStart;
79  EFI_VIRTUAL_ADDRESS   VirtualStart;
80  UINT64                NumberOfPages;
81  UINT64                Attribute;
82} EFI_MEMORY_DESCRIPTOR;
83
84///
85/// Build macros to find next EFI_MEMORY_DESCRIPTOR.
86///
87#define NEXT_MEMORY_DESCRIPTOR(_Ptr, _Size)   ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) (_Ptr)) + (_Size)))
88
89///
90/// Declare forward referenced data structures
91///
92typedef struct _EFI_SYSTEM_TABLE   EFI_SYSTEM_TABLE;
93
94/**
95  Allocates memory pages from the system.
96
97  @param  Type        The type of allocation to perform.
98  @param  MemoryType  The type of memory to allocate.
99  @param  Pages       The number of contiguous 4 KB pages to allocate.
100  @param  Memory      Pointer to a physical address. On input, the way in which the address is
101                      used depends on the value of Type.
102
103  @retval EFI_SUCCESS           The requested pages were allocated.
104  @retval EFI_INVALID_PARAMETER 1) Type is not AllocateAnyPages or
105                                AllocateMaxAddress or AllocateAddress.
106                                2) MemoryType is in the range
107                                EfiMaxMemoryType..0x7FFFFFFF.
108  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.
109  @retval EFI_NOT_FOUND         The requested pages could not be found.
110
111**/
112typedef
113EFI_STATUS
114(EFIAPI *EFI_ALLOCATE_PAGES)(
115  IN     EFI_ALLOCATE_TYPE            Type,
116  IN     EFI_MEMORY_TYPE              MemoryType,
117  IN     UINTN                        Pages,
118  IN OUT EFI_PHYSICAL_ADDRESS         *Memory
119  );
120
121/**
122  Frees memory pages.
123
124  @param  Memory      The base physical address of the pages to be freed.
125  @param  Pages       The number of contiguous 4 KB pages to free.
126
127  @retval EFI_SUCCESS           The requested pages were freed.
128  @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.
129  @retval EFI_NOT_FOUND         The requested memory pages were not allocated with
130                                AllocatePages().
131
132**/
133typedef
134EFI_STATUS
135(EFIAPI *EFI_FREE_PAGES)(
136  IN  EFI_PHYSICAL_ADDRESS         Memory,
137  IN  UINTN                        Pages
138  );
139
140/**
141  Returns the current memory map.
142
143  @param  MemoryMapSize         A pointer to the size, in bytes, of the MemoryMap buffer.
144                                On input, this is the size of the buffer allocated by the caller.
145                                On output, it is the size of the buffer returned by the firmware if
146                                the buffer was large enough, or the size of the buffer needed to contain
147                                the map if the buffer was too small.
148  @param  MemoryMap             A pointer to the buffer in which firmware places the current memory
149                                map.
150  @param  MapKey                A pointer to the location in which firmware returns the key for the
151                                current memory map.
152  @param  DescriptorSize        A pointer to the location in which firmware returns the size, in bytes, of
153                                an individual EFI_MEMORY_DESCRIPTOR.
154  @param  DescriptorVersion     A pointer to the location in which firmware returns the version number
155                                associated with the EFI_MEMORY_DESCRIPTOR.
156
157  @retval EFI_SUCCESS           The memory map was returned in the MemoryMap buffer.
158  @retval EFI_BUFFER_TOO_SMALL  The MemoryMap buffer was too small. The current buffer size
159                                needed to hold the memory map is returned in MemoryMapSize.
160  @retval EFI_INVALID_PARAMETER 1) MemoryMapSize is NULL.
161                                2) The MemoryMap buffer is not too small and MemoryMap is
162                                   NULL.
163
164**/
165typedef
166EFI_STATUS
167(EFIAPI *EFI_GET_MEMORY_MAP)(
168  IN OUT UINTN                       *MemoryMapSize,
169  IN OUT EFI_MEMORY_DESCRIPTOR       *MemoryMap,
170  OUT    UINTN                       *MapKey,
171  OUT    UINTN                       *DescriptorSize,
172  OUT    UINT32                      *DescriptorVersion
173  );
174
175/**
176  Allocates pool memory.
177
178  @param  PoolType              The type of pool to allocate.
179  @param  Size                  The number of bytes to allocate from the pool.
180  @param  Buffer                A pointer to a pointer to the allocated buffer if the call succeeds;
181                                undefined otherwise.
182
183  @retval EFI_SUCCESS           The requested number of bytes was allocated.
184  @retval EFI_OUT_OF_RESOURCES  The pool requested could not be allocated.
185  @retval EFI_INVALID_PARAMETER PoolType was invalid.
186
187**/
188typedef
189EFI_STATUS
190(EFIAPI *EFI_ALLOCATE_POOL)(
191  IN  EFI_MEMORY_TYPE              PoolType,
192  IN  UINTN                        Size,
193  OUT VOID                         **Buffer
194  );
195
196/**
197  Returns pool memory to the system.
198
199  @param  Buffer                Pointer to the buffer to free.
200
201  @retval EFI_SUCCESS           The memory was returned to the system.
202  @retval EFI_INVALID_PARAMETER Buffer was invalid.
203
204**/
205typedef
206EFI_STATUS
207(EFIAPI *EFI_FREE_POOL)(
208  IN  VOID                         *Buffer
209  );
210
211/**
212  Changes the runtime addressing mode of EFI firmware from physical to virtual.
213
214  @param  MemoryMapSize         The size in bytes of VirtualMap.
215  @param  DescriptorSize        The size in bytes of an entry in the VirtualMap.
216  @param  DescriptorVersion     The version of the structure entries in VirtualMap.
217  @param  VirtualMap            An array of memory descriptors which contain new virtual
218                                address mapping information for all runtime ranges.
219
220  @retval EFI_SUCCESS           The virtual address map has been applied.
221  @retval EFI_UNSUPPORTED       EFI firmware is not at runtime, or the EFI firmware is already in
222                                virtual address mapped mode.
223  @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is invalid.
224  @retval EFI_NO_MAPPING        A virtual address was not supplied for a range in the memory
225                                map that requires a mapping.
226  @retval EFI_NOT_FOUND         A virtual address was supplied for an address that is not found
227                                in the memory map.
228
229**/
230typedef
231EFI_STATUS
232(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP)(
233  IN  UINTN                        MemoryMapSize,
234  IN  UINTN                        DescriptorSize,
235  IN  UINT32                       DescriptorVersion,
236  IN  EFI_MEMORY_DESCRIPTOR        *VirtualMap
237  );
238
239/**
240  Connects one or more drivers to a controller.
241
242  @param  ControllerHandle      The handle of the controller to which driver(s) are to be connected.
243  @param  DriverImageHandle     A pointer to an ordered list handles that support the
244                                EFI_DRIVER_BINDING_PROTOCOL.
245  @param  RemainingDevicePath   A pointer to the device path that specifies a child of the
246                                controller specified by ControllerHandle.
247  @param  Recursive             If TRUE, then ConnectController() is called recursively
248                                until the entire tree of controllers below the controller specified
249                                by ControllerHandle have been created. If FALSE, then
250                                the tree of controllers is only expanded one level.
251
252  @retval EFI_SUCCESS           1) One or more drivers were connected to ControllerHandle.
253                                2) No drivers were connected to ControllerHandle, but
254                                RemainingDevicePath is not NULL, and it is an End Device
255                                Path Node.
256  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
257  @retval EFI_NOT_FOUND         1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
258                                present in the system.
259                                2) No drivers were connected to ControllerHandle.
260
261**/
262typedef
263EFI_STATUS
264(EFIAPI *EFI_CONNECT_CONTROLLER)(
265  IN  EFI_HANDLE                    ControllerHandle,
266  IN  EFI_HANDLE                    *DriverImageHandle,   OPTIONAL
267  IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath, OPTIONAL
268  IN  BOOLEAN                       Recursive
269  );
270
271/**
272  Disconnects one or more drivers from a controller.
273
274  @param  ControllerHandle      The handle of the controller from which driver(s) are to be disconnected.
275  @param  DriverImageHandle     The driver to disconnect from ControllerHandle.
276                                If DriverImageHandle is NULL, then all the drivers currently managing
277                                ControllerHandle are disconnected from ControllerHandle.
278  @param  ChildHandle           The handle of the child to destroy.
279                                If ChildHandle is NULL, then all the children of ControllerHandle are
280                                destroyed before the drivers are disconnected from ControllerHandle.
281
282  @retval EFI_SUCCESS           1) One or more drivers were disconnected from the controller.
283                                2) On entry, no drivers are managing ControllerHandle.
284                                3) DriverImageHandle is not NULL, and on entry
285                                   DriverImageHandle is not managing ControllerHandle.
286  @retval EFI_INVALID_PARAMETER 1) ControllerHandle is not a valid EFI_HANDLE.
287                                2) DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
288                                3) ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
289                                4) DriverImageHandle does not support the EFI_DRIVER_BINDING_PROTOCOL.
290  @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to disconnect any drivers from
291                                ControllerHandle.
292  @retval EFI_DEVICE_ERROR      The controller could not be disconnected because of a device error.
293
294**/
295typedef
296EFI_STATUS
297(EFIAPI *EFI_DISCONNECT_CONTROLLER)(
298  IN  EFI_HANDLE                     ControllerHandle,
299  IN  EFI_HANDLE                     DriverImageHandle, OPTIONAL
300  IN  EFI_HANDLE                     ChildHandle        OPTIONAL
301  );
302
303
304
305//
306// ConvertPointer DebugDisposition type.
307//
308#define EFI_OPTIONAL_PTR     0x00000001
309#define EFI_OPTIONAL_POINTER EFI_OPTIONAL_PTR
310
311/**
312  Determines the new virtual address that is to be used on subsequent memory accesses.
313
314  @param  DebugDisposition      Supplies type information for the pointer being converted.
315  @param  Address               A pointer to a pointer that is to be fixed to be the value needed
316                                for the new virtual address mappings being applied.
317
318  @retval EFI_SUCCESS           The pointer pointed to by Address was modified.
319  @retval EFI_INVALID_PARAMETER 1) Address is NULL.
320                                2) *Address is NULL and DebugDisposition does
321                                not have the EFI_OPTIONAL_PTR bit set.
322  @retval EFI_NOT_FOUND         The pointer pointed to by Address was not found to be part
323                                of the current memory map. This is normally fatal.
324
325**/
326typedef
327EFI_STATUS
328(EFIAPI *EFI_CONVERT_POINTER)(
329  IN     UINTN                      DebugDisposition,
330  IN OUT VOID                       **Address
331  );
332
333
334//
335// These types can be ORed together as needed - for example,
336// EVT_TIMER might be Ored with EVT_NOTIFY_WAIT or
337// EVT_NOTIFY_SIGNAL.
338//
339#define EVT_TIMER                         0x80000000
340#define EVT_RUNTIME                       0x40000000
341#define EVT_NOTIFY_WAIT                   0x00000100
342#define EVT_NOTIFY_SIGNAL                 0x00000200
343
344#define EVT_SIGNAL_EXIT_BOOT_SERVICES     0x00000201
345#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
346
347//
348// The event's NotifyContext pointer points to a runtime memory
349// address.
350// The event is deprecated in UEFI2.0 and later specifications.
351//
352#define EVT_RUNTIME_CONTEXT               0x20000000
353
354
355/**
356  Invoke a notification event
357
358  @param  Event                 Event whose notification function is being invoked.
359  @param  Context               Pointer to the notification function's context,
360                                which is implementation-dependent.
361
362**/
363typedef
364VOID
365(EFIAPI *EFI_EVENT_NOTIFY)(
366  IN  EFI_EVENT                Event,
367  IN  VOID                     *Context
368  );
369
370/**
371  Creates an event.
372
373  @param  Type                  The type of event to create and its mode and attributes.
374  @param  NotifyTpl             The task priority level of event notifications, if needed.
375  @param  NotifyFunction        Pointer to the event's notification function, if any.
376  @param  NotifyContext         Pointer to the notification function's context; corresponds to parameter
377                                Context in the notification function.
378  @param  Event                 Pointer to the newly created event if the call succeeds; undefined
379                                otherwise.
380
381  @retval EFI_SUCCESS           The event structure was created.
382  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
383  @retval EFI_OUT_OF_RESOURCES  The event could not be allocated.
384
385**/
386typedef
387EFI_STATUS
388(EFIAPI *EFI_CREATE_EVENT)(
389  IN  UINT32                       Type,
390  IN  EFI_TPL                      NotifyTpl,
391  IN  EFI_EVENT_NOTIFY             NotifyFunction,
392  IN  VOID                         *NotifyContext,
393  OUT EFI_EVENT                    *Event
394  );
395
396/**
397  Creates an event in a group.
398
399  @param  Type                  The type of event to create and its mode and attributes.
400  @param  NotifyTpl             The task priority level of event notifications,if needed.
401  @param  NotifyFunction        Pointer to the event's notification function, if any.
402  @param  NotifyContext         Pointer to the notification function's context; corresponds to parameter
403                                Context in the notification function.
404  @param  EventGroup            Pointer to the unique identifier of the group to which this event belongs.
405                                If this is NULL, then the function behaves as if the parameters were passed
406                                to CreateEvent.
407  @param  Event                 Pointer to the newly created event if the call succeeds; undefined
408                                otherwise.
409
410  @retval EFI_SUCCESS           The event structure was created.
411  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
412  @retval EFI_OUT_OF_RESOURCES  The event could not be allocated.
413
414**/
415typedef
416EFI_STATUS
417(EFIAPI *EFI_CREATE_EVENT_EX)(
418  IN       UINT32                 Type,
419  IN       EFI_TPL                NotifyTpl,
420  IN       EFI_EVENT_NOTIFY       NotifyFunction OPTIONAL,
421  IN CONST VOID                   *NotifyContext OPTIONAL,
422  IN CONST EFI_GUID               *EventGroup    OPTIONAL,
423  OUT      EFI_EVENT              *Event
424  );
425
426///
427/// Timer delay types
428///
429typedef enum {
430  TimerCancel,
431  TimerPeriodic,
432  TimerRelative
433} EFI_TIMER_DELAY;
434
435/**
436  Sets the type of timer and the trigger time for a timer event.
437
438  @param  Event                 The timer event that is to be signaled at the specified time.
439  @param  Type                  The type of time that is specified in TriggerTime.
440  @param  TriggerTime           The number of 100ns units until the timer expires.
441                                A TriggerTime of 0 is legal.
442                                If Type is TimerRelative and TriggerTime is 0, then the timer
443                                event will be signaled on the next timer tick.
444                                If Type is TimerPeriodic and TriggerTime is 0, then the timer
445                                event will be signaled on every timer tick.
446
447  @retval EFI_SUCCESS           The event has been set to be signaled at the requested time.
448  @retval EFI_INVALID_PARAMETER Event or Type is not valid.
449
450**/
451typedef
452EFI_STATUS
453(EFIAPI *EFI_SET_TIMER)(
454  IN  EFI_EVENT                Event,
455  IN  EFI_TIMER_DELAY          Type,
456  IN  UINT64                   TriggerTime
457  );
458
459/**
460  Signals an event.
461
462  @param  Event                 The event to signal.
463
464  @retval EFI_SUCCESS           The event has been signaled.
465
466**/
467typedef
468EFI_STATUS
469(EFIAPI *EFI_SIGNAL_EVENT)(
470  IN  EFI_EVENT                Event
471  );
472
473/**
474  Stops execution until an event is signaled.
475
476  @param  NumberOfEvents        The number of events in the Event array.
477  @param  Event                 An array of EFI_EVENT.
478  @param  Index                 Pointer to the index of the event which satisfied the wait condition.
479
480  @retval EFI_SUCCESS           The event indicated by Index was signaled.
481  @retval EFI_INVALID_PARAMETER 1) NumberOfEvents is 0.
482                                2) The event indicated by Index is of type
483                                   EVT_NOTIFY_SIGNAL.
484  @retval EFI_UNSUPPORTED       The current TPL is not TPL_APPLICATION.
485
486**/
487typedef
488EFI_STATUS
489(EFIAPI *EFI_WAIT_FOR_EVENT)(
490  IN  UINTN                    NumberOfEvents,
491  IN  EFI_EVENT                *Event,
492  OUT UINTN                    *Index
493  );
494
495/**
496  Closes an event.
497
498  @param  Event                 The event to close.
499
500  @retval EFI_SUCCESS           The event has been closed.
501
502**/
503typedef
504EFI_STATUS
505(EFIAPI *EFI_CLOSE_EVENT)(
506  IN EFI_EVENT                Event
507  );
508
509/**
510  Checks whether an event is in the signaled state.
511
512  @param  Event                 The event to check.
513
514  @retval EFI_SUCCESS           The event is in the signaled state.
515  @retval EFI_NOT_READY         The event is not in the signaled state.
516  @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL.
517
518**/
519typedef
520EFI_STATUS
521(EFIAPI *EFI_CHECK_EVENT)(
522  IN EFI_EVENT                Event
523  );
524
525
526//
527// Task priority level
528//
529#define TPL_APPLICATION       4
530#define TPL_CALLBACK          8
531#define TPL_NOTIFY            16
532#define TPL_HIGH_LEVEL        31
533
534
535/**
536  Raises a task's priority level and returns its previous level.
537
538  @param  NewTpl                The new task priority level.
539
540  @return Previous task priority level
541
542**/
543typedef
544EFI_TPL
545(EFIAPI *EFI_RAISE_TPL)(
546  IN EFI_TPL      NewTpl
547  );
548
549/**
550  Restores a task's priority level to its previous value.
551
552  @param  OldTpl                The previous task priority level to restore.
553
554**/
555typedef
556VOID
557(EFIAPI *EFI_RESTORE_TPL)(
558  IN EFI_TPL      OldTpl
559  );
560
561/**
562  Returns the value of a variable.
563
564  @param  VariableName          A Null-terminated Unicode string that is the name of the
565                                vendor's variable.
566  @param  VendorGuid            A unique identifier for the vendor.
567  @param  Attributes            If not NULL, a pointer to the memory location to return the
568                                attributes bitmask for the variable.
569  @param  DataSize              On input, the size in bytes of the return Data buffer.
570                                On output the size of data returned in Data.
571  @param  Data                  The buffer to return the contents of the variable.
572
573  @retval EFI_SUCCESS            The function completed successfully.
574  @retval EFI_NOT_FOUND          The variable was not found.
575  @retval EFI_BUFFER_TOO_SMALL   The DataSize is too small for the result.
576  @retval EFI_INVALID_PARAMETER  VariableName is NULL.
577  @retval EFI_INVALID_PARAMETER  VendorGuid is NULL.
578  @retval EFI_INVALID_PARAMETER  DataSize is NULL.
579  @retval EFI_INVALID_PARAMETER  The DataSize is not too small and Data is NULL.
580  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.
581  @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.
582
583**/
584typedef
585EFI_STATUS
586(EFIAPI *EFI_GET_VARIABLE)(
587  IN     CHAR16                      *VariableName,
588  IN     EFI_GUID                    *VendorGuid,
589  OUT    UINT32                      *Attributes,    OPTIONAL
590  IN OUT UINTN                       *DataSize,
591  OUT    VOID                        *Data
592  );
593
594/**
595  Enumerates the current variable names.
596
597  @param  VariableNameSize      The size of the VariableName buffer.
598  @param  VariableName          On input, supplies the last VariableName that was returned
599                                by GetNextVariableName(). On output, returns the Nullterminated
600                                Unicode string of the current variable.
601  @param  VendorGuid            On input, supplies the last VendorGuid that was returned by
602                                GetNextVariableName(). On output, returns the
603                                VendorGuid of the current variable.
604
605  @retval EFI_SUCCESS           The function completed successfully.
606  @retval EFI_NOT_FOUND         The next variable was not found.
607  @retval EFI_BUFFER_TOO_SMALL  The VariableNameSize is too small for the result.
608  @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
609  @retval EFI_INVALID_PARAMETER VariableName is NULL.
610  @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
611  @retval EFI_DEVICE_ERROR      The variable could not be retrieved due to a hardware error.
612
613**/
614typedef
615EFI_STATUS
616(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME)(
617  IN OUT UINTN                    *VariableNameSize,
618  IN OUT CHAR16                   *VariableName,
619  IN OUT EFI_GUID                 *VendorGuid
620  );
621
622/**
623  Sets the value of a variable.
624
625  @param  VariableName          A Null-terminated Unicode string that is the name of the
626                                vendor's variable.
627  @param  VendorGuid            A unique identifier for the vendor.
628  @param  Attributes            Attributes bitmask to set for the variable.
629  @param  DataSize              The size in bytes of the Data buffer.
630  @param  Data                  The contents for the variable.
631
632  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as
633                                 defined by the Attributes.
634  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the
635                                 DataSize exceeds the maximum allowed.
636  @retval EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.
637  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.
638  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.
639  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.
640  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.
641  @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.
642  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.
643
644**/
645typedef
646EFI_STATUS
647(EFIAPI *EFI_SET_VARIABLE)(
648  IN  CHAR16                       *VariableName,
649  IN  EFI_GUID                     *VendorGuid,
650  IN  UINT32                       Attributes,
651  IN  UINTN                        DataSize,
652  IN  VOID                         *Data
653  );
654
655
656///
657/// This provides the capabilities of the
658/// real time clock device as exposed through the EFI interfaces.
659///
660typedef struct {
661  UINT32    Resolution;
662  UINT32    Accuracy;
663  BOOLEAN   SetsToZero;
664} EFI_TIME_CAPABILITIES;
665
666/**
667  Returns the current time and date information, and the time-keeping capabilities
668  of the hardware platform.
669
670  @param  Time                  A pointer to storage to receive a snapshot of the current time.
671  @param  Capabilities          An optional pointer to a buffer to receive the real time clock
672                                device's capabilities.
673
674  @retval EFI_SUCCESS           The operation completed successfully.
675  @retval EFI_INVALID_PARAMETER Time is NULL.
676  @retval EFI_DEVICE_ERROR      The time could not be retrieved due to hardware error.
677
678**/
679typedef
680EFI_STATUS
681(EFIAPI *EFI_GET_TIME)(
682  OUT  EFI_TIME                    *Time,
683  OUT  EFI_TIME_CAPABILITIES       *Capabilities OPTIONAL
684  );
685
686/**
687  Sets the current local time and date information.
688
689  @param  Time                  A pointer to the current time.
690
691  @retval EFI_SUCCESS           The operation completed successfully.
692  @retval EFI_INVALID_PARAMETER A time field is out of range.
693  @retval EFI_DEVICE_ERROR      The time could not be set due due to hardware error.
694
695**/
696typedef
697EFI_STATUS
698(EFIAPI *EFI_SET_TIME)(
699  IN  EFI_TIME                     *Time
700  );
701
702/**
703  Returns the current wakeup alarm clock setting.
704
705  @param  Enabled               Indicates if the alarm is currently enabled or disabled.
706  @param  Pending               Indicates if the alarm signal is pending and requires acknowledgement.
707  @param  Time                  The current alarm setting.
708
709  @retval EFI_SUCCESS           The alarm settings were returned.
710  @retval EFI_INVALID_PARAMETER Enabled is NULL.
711  @retval EFI_INVALID_PARAMETER Pending is NULL.
712  @retval EFI_INVALID_PARAMETER Time is NULL.
713  @retval EFI_DEVICE_ERROR      The wakeup time could not be retrieved due to a hardware error.
714  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.
715
716**/
717typedef
718EFI_STATUS
719(EFIAPI *EFI_GET_WAKEUP_TIME)(
720  OUT BOOLEAN                     *Enabled,
721  OUT BOOLEAN                     *Pending,
722  OUT EFI_TIME                    *Time
723  );
724
725/**
726  Sets the system wakeup alarm clock time.
727
728  @param  Enabled               Enable or disable the wakeup alarm.
729  @param  Time                  If Enable is TRUE, the time to set the wakeup alarm for.
730                                If Enable is FALSE, then this parameter is optional, and may be NULL.
731
732  @retval EFI_SUCCESS           If Enable is TRUE, then the wakeup alarm was enabled. If
733                                Enable is FALSE, then the wakeup alarm was disabled.
734  @retval EFI_INVALID_PARAMETER A time field is out of range.
735  @retval EFI_DEVICE_ERROR      The wakeup time could not be set due to a hardware error.
736  @retval EFI_UNSUPPORTED       A wakeup timer is not supported on this platform.
737
738**/
739typedef
740EFI_STATUS
741(EFIAPI *EFI_SET_WAKEUP_TIME)(
742  IN  BOOLEAN                      Enable,
743  IN  EFI_TIME                     *Time   OPTIONAL
744  );
745
746/**
747  This is the declaration of an EFI image entry point. This entry point is
748  the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
749  both device drivers and bus drivers.
750
751  @param  ImageHandle           The firmware allocated handle for the UEFI image.
752  @param  SystemTable           A pointer to the EFI System Table.
753
754  @retval EFI_SUCCESS           The operation completed successfully.
755  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
756
757**/
758typedef
759EFI_STATUS
760(EFIAPI *EFI_IMAGE_ENTRY_POINT)(
761  IN  EFI_HANDLE                   ImageHandle,
762  IN  EFI_SYSTEM_TABLE             *SystemTable
763  );
764
765/**
766  Loads an EFI image into memory.
767
768  @param  BootPolicy            If TRUE, indicates that the request originates from the boot
769                                manager, and that the boot manager is attempting to load
770                                FilePath as a boot selection. Ignored if SourceBuffer is
771                                not NULL.
772  @param  ParentImageHandle     The caller's image handle.
773  @param  DevicePath            The DeviceHandle specific file path from which the image is
774                                loaded.
775  @param  SourceBuffer          If not NULL, a pointer to the memory location containing a copy
776                                of the image to be loaded.
777  @param  SourceSize            The size in bytes of SourceBuffer. Ignored if SourceBuffer is NULL.
778  @param  ImageHandle           Pointer to the returned image handle that is created when the
779                                image is successfully loaded.
780
781  @retval EFI_SUCCESS           Image was loaded into memory correctly.
782  @retval EFI_NOT_FOUND         Both SourceBuffer and DevicePath are NULL.
783  @retval EFI_INVALID_PARAMETER One or more parametes are invalid.
784  @retval EFI_UNSUPPORTED       The image type is not supported.
785  @retval EFI_OUT_OF_RESOURCES  Image was not loaded due to insufficient resources.
786  @retval EFI_LOAD_ERROR        Image was not loaded because the image format was corrupt or not
787                                understood.
788  @retval EFI_DEVICE_ERROR      Image was not loaded because the device returned a read error.
789
790**/
791typedef
792EFI_STATUS
793(EFIAPI *EFI_IMAGE_LOAD)(
794  IN  BOOLEAN                      BootPolicy,
795  IN  EFI_HANDLE                   ParentImageHandle,
796  IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath,
797  IN  VOID                         *SourceBuffer OPTIONAL,
798  IN  UINTN                        SourceSize,
799  OUT EFI_HANDLE                   *ImageHandle
800  );
801
802/**
803  Transfers control to a loaded image's entry point.
804
805  @param  ImageHandle           Handle of image to be started.
806  @param  ExitDataSize          Pointer to the size, in bytes, of ExitData.
807  @param  ExitData              Pointer to a pointer to a data buffer that includes a Null-terminated
808                                Unicode string, optionally followed by additional binary data.
809
810  @retval EFI_INVALID_PARAMETER ImageHandle is either an invalid image handle or the image
811                                has already been initialized with StartImage
812  @return Exit code from image
813
814**/
815typedef
816EFI_STATUS
817(EFIAPI *EFI_IMAGE_START)(
818  IN  EFI_HANDLE                  ImageHandle,
819  OUT UINTN                       *ExitDataSize,
820  OUT CHAR16                      **ExitData    OPTIONAL
821  );
822
823/**
824  Terminates a loaded EFI image and returns control to boot services.
825
826  @param  ImageHandle           Handle that identifies the image.
827  @param  ExitStatus            The image's exit code.
828  @param  ExitDataSize          The size, in bytes, of ExitData.
829  @param  ExitData              Pointer to a data buffer that includes a Null-terminated Unicode string,
830                                optionally followed by additional binary data.
831
832  @retval EFI_SUCCESS           The image specified by ImageHandle was unloaded.
833  @retval EFI_INVALID_PARAMETER The image specified by ImageHandle has been loaded and
834                                started with LoadImage() and StartImage(), but the
835                                image is not the currently executing image.
836
837**/
838typedef
839EFI_STATUS
840(EFIAPI *EFI_EXIT)(
841  IN  EFI_HANDLE                   ImageHandle,
842  IN  EFI_STATUS                   ExitStatus,
843  IN  UINTN                        ExitDataSize,
844  IN  CHAR16                       *ExitData     OPTIONAL
845  );
846
847/**
848  Unloads an image.
849
850  @param  ImageHandle           Handle that identifies the image to be unloaded.
851
852  @retval EFI_SUCCESS           The image has been unloaded.
853  @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
854  @retval EFI_UNSUPPORTED       The image has been started, and does not support unload.
855  @return Exit code from the image's unload handler
856
857**/
858typedef
859EFI_STATUS
860(EFIAPI *EFI_IMAGE_UNLOAD)(
861  IN  EFI_HANDLE                   ImageHandle
862  );
863
864/**
865  Terminates all boot services.
866
867  @param  ImageHandle           Handle that identifies the exiting image.
868  @param  MapKey                Key to the latest memory map.
869
870  @retval EFI_SUCCESS           Boot services have been terminated.
871  @retval EFI_INVALID_PARAMETER MapKey is incorrect.
872
873**/
874typedef
875EFI_STATUS
876(EFIAPI *EFI_EXIT_BOOT_SERVICES)(
877  IN  EFI_HANDLE                   ImageHandle,
878  IN  UINTN                        MapKey
879  );
880
881/**
882  Induces a fine-grained stall.
883
884  @param  Microseconds          The number of microseconds to stall execution.
885
886  @retval EFI_SUCCESS           Execution was stalled at least the requested number of
887                                Microseconds.
888
889**/
890typedef
891EFI_STATUS
892(EFIAPI *EFI_STALL)(
893  IN  UINTN                    Microseconds
894  );
895
896/**
897  Sets the system's watchdog timer.
898
899  @param  Timeout               The number of seconds to set the watchdog timer to.
900  @param  WatchdogCode          The numeric code to log on a watchdog timer timeout event.
901  @param  DataSize              The size, in bytes, of WatchdogData.
902  @param  WatchdogData          A data buffer that includes a Null-terminated Unicode string, optionally
903                                followed by additional binary data.
904
905  @retval EFI_SUCCESS           The timeout has been set.
906  @retval EFI_INVALID_PARAMETER The supplied WatchdogCode is invalid.
907  @retval EFI_UNSUPPORTED       The system does not have a watchdog timer.
908  @retval EFI_DEVICE_ERROR      The watch dog timer could not be programmed due to a hardware
909                                error.
910
911**/
912typedef
913EFI_STATUS
914(EFIAPI *EFI_SET_WATCHDOG_TIMER)(
915  IN UINTN                    Timeout,
916  IN UINT64                   WatchdogCode,
917  IN UINTN                    DataSize,
918  IN CHAR16                   *WatchdogData OPTIONAL
919  );
920
921///
922/// Enumeration of reset types.
923///
924typedef enum {
925  EfiResetCold,
926  EfiResetWarm,
927  EfiResetShutdown,
928  EfiResetUpdate
929} EFI_RESET_TYPE;
930
931/**
932  Resets the entire platform.
933
934  @param  ResetType             The type of reset to perform.
935  @param  ResetStatus           The status code for the reset.
936  @param  DataSize              The size, in bytes, of WatchdogData.
937  @param  ResetData             For a ResetType of EfiResetCold, EfiResetWarm, or
938                                EfiResetShutdown the data buffer starts with a Null-terminated
939                                Unicode string, optionally followed by additional binary data.
940
941**/
942typedef
943VOID
944(EFIAPI *EFI_RESET_SYSTEM)(
945  IN EFI_RESET_TYPE           ResetType,
946  IN EFI_STATUS               ResetStatus,
947  IN UINTN                    DataSize,
948  IN CHAR16                   *ResetData OPTIONAL
949  );
950
951/**
952  Returns a monotonically increasing count for the platform.
953
954  @param  Count                 Pointer to returned value.
955
956  @retval EFI_SUCCESS           The next monotonic count was returned.
957  @retval EFI_INVALID_PARAMETER Count is NULL.
958  @retval EFI_DEVICE_ERROR      The device is not functioning properly.
959
960**/
961typedef
962EFI_STATUS
963(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT)(
964  OUT UINT64                  *Count
965  );
966
967/**
968  Returns the next high 32 bits of the platform's monotonic counter.
969
970  @param  HighCount             Pointer to returned value.
971
972  @retval EFI_SUCCESS           The next high monotonic count was returned.
973  @retval EFI_INVALID_PARAMETER HighCount is NULL.
974  @retval EFI_DEVICE_ERROR      The device is not functioning properly.
975
976**/
977typedef
978EFI_STATUS
979(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT)(
980  OUT UINT32                  *HighCount
981  );
982
983/**
984  Computes and returns a 32-bit CRC for a data buffer.
985
986  @param  Data                  A pointer to the buffer on which the 32-bit CRC is to be computed.
987  @param  DataSize              The number of bytes in the buffer Data.
988  @param  Crc32                 The 32-bit CRC that was computed for the data buffer specified by Data
989                                and DataSize.
990
991  @retval EFI_SUCCESS           The 32-bit CRC was computed for the data buffer and returned in
992                                Crc32.
993  @retval EFI_INVALID_PARAMETER Data is NULL.
994  @retval EFI_INVALID_PARAMETER Crc32 is NULL.
995  @retval EFI_INVALID_PARAMETER DataSize is 0.
996
997**/
998typedef
999EFI_STATUS
1000(EFIAPI *EFI_CALCULATE_CRC32)(
1001  IN  VOID                              *Data,
1002  IN  UINTN                             DataSize,
1003  OUT UINT32                            *Crc32
1004  );
1005
1006/**
1007  Copies the contents of one buffer to another buffer.
1008
1009  @param  Destination           Pointer to the destination buffer of the memory copy.
1010  @param  Source                Pointer to the source buffer of the memory copy.
1011  @param  Length                Number of bytes to copy from Source to Destination.
1012
1013**/
1014typedef
1015VOID
1016(EFIAPI *EFI_COPY_MEM)(
1017  IN VOID     *Destination,
1018  IN VOID     *Source,
1019  IN UINTN    Length
1020  );
1021
1022/**
1023  The SetMem() function fills a buffer with a specified value.
1024
1025  @param  Buffer                Pointer to the buffer to fill.
1026  @param  Size                  Number of bytes in Buffer to fill.
1027  @param  Value                 Value to fill Buffer with.
1028
1029**/
1030typedef
1031VOID
1032(EFIAPI *EFI_SET_MEM)(
1033  IN VOID     *Buffer,
1034  IN UINTN    Size,
1035  IN UINT8    Value
1036  );
1037
1038
1039//
1040// Protocol handler functions
1041//
1042typedef enum {
1043  EFI_NATIVE_INTERFACE
1044} EFI_INTERFACE_TYPE;
1045
1046/**
1047  Installs a protocol interface on a device handle. If the handle does not exist, it is created and added
1048  to the list of handles in the system. InstallMultipleProtocolInterfaces() performs
1049  more error checking than InstallProtocolInterface(), so it is recommended that
1050  InstallMultipleProtocolInterfaces() be used in place of
1051  InstallProtocolInterface()
1052
1053  @param  Handle                A pointer to the EFI_HANDLE on which the interface is to be installed.
1054  @param  Protocol              The numeric ID of the protocol interface.
1055  @param  InterfaceType         Indicates whether Interface is supplied in native form.
1056  @param  Interface             A pointer to the protocol interface.
1057
1058  @retval EFI_SUCCESS           The protocol interface was installed.
1059  @retval EFI_OUT_OF_RESOURCES  Space for a new handle could not be allocated.
1060  @retval EFI_INVALID_PARAMETER Handle is NULL.
1061  @retval EFI_INVALID_PARAMETER Protocol is NULL.
1062  @retval EFI_INVALID_PARAMETER InterfaceType is not EFI_NATIVE_INTERFACE.
1063  @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
1064
1065**/
1066typedef
1067EFI_STATUS
1068(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE)(
1069  IN OUT EFI_HANDLE               *Handle,
1070  IN     EFI_GUID                 *Protocol,
1071  IN     EFI_INTERFACE_TYPE       InterfaceType,
1072  IN     VOID                     *Interface
1073  );
1074
1075/**
1076  Installs one or more protocol interfaces into the boot services environment.
1077
1078  @param  Handle                The handle to install the new protocol interfaces on, or NULL if a new
1079                                handle is to be allocated.
1080  @param  ...                   A variable argument list containing pairs of protocol GUIDs and protocol
1081                                interfaces.
1082
1083  @retval EFI_SUCCESS           All the protocol interface was installed.
1084  @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.
1085  @retval EFI_ALREADY_STARTED   A Device Path Protocol instance was passed in that is already present in
1086                                the handle database.
1087
1088**/
1089typedef
1090EFI_STATUS
1091(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)(
1092  IN OUT EFI_HANDLE           *Handle,
1093  ...
1094  );
1095
1096/**
1097  Reinstalls a protocol interface on a device handle.
1098
1099  @param  Handle                Handle on which the interface is to be reinstalled.
1100  @param  Protocol              The numeric ID of the interface.
1101  @param  OldInterface          A pointer to the old interface. NULL can be used if a structure is not
1102                                associated with Protocol.
1103  @param  NewInterface          A pointer to the new interface.
1104
1105  @retval EFI_SUCCESS           The protocol interface was reinstalled.
1106  @retval EFI_NOT_FOUND         The OldInterface on the handle was not found.
1107  @retval EFI_ACCESS_DENIED     The protocol interface could not be reinstalled,
1108                                because OldInterface is still being used by a
1109                                driver that will not release it.
1110  @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
1111  @retval EFI_INVALID_PARAMETER Protocol is NULL.
1112
1113**/
1114typedef
1115EFI_STATUS
1116(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE)(
1117  IN EFI_HANDLE               Handle,
1118  IN EFI_GUID                 *Protocol,
1119  IN VOID                     *OldInterface,
1120  IN VOID                     *NewInterface
1121  );
1122
1123/**
1124  Removes a protocol interface from a device handle. It is recommended that
1125  UninstallMultipleProtocolInterfaces() be used in place of
1126  UninstallProtocolInterface().
1127
1128  @param  Handle                The handle on which the interface was installed.
1129  @param  Protocol              The numeric ID of the interface.
1130  @param  Interface             A pointer to the interface.
1131
1132  @retval EFI_SUCCESS           The interface was removed.
1133  @retval EFI_NOT_FOUND         The interface was not found.
1134  @retval EFI_ACCESS_DENIED     The interface was not removed because the interface
1135                                is still being used by a driver.
1136  @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
1137  @retval EFI_INVALID_PARAMETER Protocol is NULL.
1138
1139**/
1140typedef
1141EFI_STATUS
1142(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE)(
1143  IN EFI_HANDLE               Handle,
1144  IN EFI_GUID                 *Protocol,
1145  IN VOID                     *Interface
1146  );
1147
1148/**
1149  Removes one or more protocol interfaces into the boot services environment.
1150
1151  @param  Handle                The handle to remove the protocol interfaces from.
1152  @param  ...                   A variable argument list containing pairs of protocol GUIDs and
1153                                protocol interfaces.
1154
1155  @retval EFI_SUCCESS           All the protocol interfaces were removed.
1156  @retval EFI_INVALID_PARAMETER One of the protocol interfaces was not previously installed on Handle.
1157
1158**/
1159typedef
1160EFI_STATUS
1161(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)(
1162  IN EFI_HANDLE           Handle,
1163  ...
1164  );
1165
1166/**
1167  Queries a handle to determine if it supports a specified protocol.
1168
1169  @param  Handle                The handle being queried.
1170  @param  Protocol              The published unique identifier of the protocol.
1171  @param  Interface             Supplies the address where a pointer to the corresponding Protocol
1172                                Interface is returned.
1173
1174  @retval EFI_SUCCESS           The interface information for the specified protocol was returned.
1175  @retval EFI_UNSUPPORTED       The device does not support the specified protocol.
1176  @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
1177  @retval EFI_INVALID_PARAMETER Protocol is NULL.
1178  @retval EFI_INVALID_PARAMETER Interface is NULL.
1179
1180**/
1181typedef
1182EFI_STATUS
1183(EFIAPI *EFI_HANDLE_PROTOCOL)(
1184  IN  EFI_HANDLE               Handle,
1185  IN  EFI_GUID                 *Protocol,
1186  OUT VOID                     **Interface
1187  );
1188
1189#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
1190#define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
1191#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
1192#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
1193#define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
1194#define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
1195
1196/**
1197  Queries a handle to determine if it supports a specified protocol. If the protocol is supported by the
1198  handle, it opens the protocol on behalf of the calling agent.
1199
1200  @param  Handle                The handle for the protocol interface that is being opened.
1201  @param  Protocol              The published unique identifier of the protocol.
1202  @param  Interface             Supplies the address where a pointer to the corresponding Protocol
1203                                Interface is returned.
1204  @param  AgentHandle           The handle of the agent that is opening the protocol interface
1205                                specified by Protocol and Interface.
1206  @param  ControllerHandle      If the agent that is opening a protocol is a driver that follows the
1207                                UEFI Driver Model, then this parameter is the controller handle
1208                                that requires the protocol interface. If the agent does not follow
1209                                the UEFI Driver Model, then this parameter is optional and may
1210                                be NULL.
1211  @param  Attributes            The open mode of the protocol interface specified by Handle
1212                                and Protocol.
1213
1214  @retval EFI_SUCCESS           An item was added to the open list for the protocol interface, and the
1215                                protocol interface was returned in Interface.
1216  @retval EFI_UNSUPPORTED       Handle does not support Protocol.
1217  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1218  @retval EFI_ACCESS_DENIED     Required attributes can't be supported in current environment.
1219  @retval EFI_ALREADY_STARTED   Item on the open list already has requierd attributes whose agent
1220                                handle is the same as AgentHandle.
1221
1222**/
1223typedef
1224EFI_STATUS
1225(EFIAPI *EFI_OPEN_PROTOCOL)(
1226  IN  EFI_HANDLE                Handle,
1227  IN  EFI_GUID                  *Protocol,
1228  OUT VOID                      **Interface, OPTIONAL
1229  IN  EFI_HANDLE                AgentHandle,
1230  IN  EFI_HANDLE                ControllerHandle,
1231  IN  UINT32                    Attributes
1232  );
1233
1234
1235/**
1236  Closes a protocol on a handle that was opened using OpenProtocol().
1237
1238  @param  Handle                The handle for the protocol interface that was previously opened
1239                                with OpenProtocol(), and is now being closed.
1240  @param  Protocol              The published unique identifier of the protocol.
1241  @param  AgentHandle           The handle of the agent that is closing the protocol interface.
1242  @param  ControllerHandle      If the agent that opened a protocol is a driver that follows the
1243                                UEFI Driver Model, then this parameter is the controller handle
1244                                that required the protocol interface.
1245
1246  @retval EFI_SUCCESS           The protocol instance was closed.
1247  @retval EFI_INVALID_PARAMETER 1) Handle is not a valid EFI_HANDLE.
1248                                2) AgentHandle is not a valid EFI_HANDLE.
1249                                3) ControllerHandle is not NULL and ControllerHandle is not a valid EFI_HANDLE.
1250                                4) Protocol is NULL.
1251  @retval EFI_NOT_FOUND         1) Handle does not support the protocol specified by Protocol.
1252                                2) The protocol interface specified by Handle and Protocol is not
1253                                   currently open by AgentHandle and ControllerHandle.
1254
1255**/
1256typedef
1257EFI_STATUS
1258(EFIAPI *EFI_CLOSE_PROTOCOL)(
1259  IN EFI_HANDLE               Handle,
1260  IN EFI_GUID                 *Protocol,
1261  IN EFI_HANDLE               AgentHandle,
1262  IN EFI_HANDLE               ControllerHandle
1263  );
1264
1265
1266typedef struct {
1267  EFI_HANDLE  AgentHandle;
1268  EFI_HANDLE  ControllerHandle;
1269  UINT32      Attributes;
1270  UINT32      OpenCount;
1271} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
1272
1273/**
1274  Retrieves the list of agents that currently have a protocol interface opened.
1275
1276  @param  Handle                The handle for the protocol interface that is being queried.
1277  @param  Protocol              The published unique identifier of the protocol.
1278  @param  EntryBuffer           A pointer to a buffer of open protocol information in the form of
1279                                EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
1280  @param  EntryCount            A pointer to the number of entries in EntryBuffer.
1281
1282  @retval EFI_SUCCESS           The open protocol information was returned in EntryBuffer, and the
1283                                number of entries was returned EntryCount.
1284  @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to allocate EntryBuffer.
1285  @retval EFI_NOT_FOUND         Handle does not support the protocol specified by Protocol.
1286
1287**/
1288typedef
1289EFI_STATUS
1290(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION)(
1291  IN  EFI_HANDLE                          Handle,
1292  IN  EFI_GUID                            *Protocol,
1293  OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
1294  OUT UINTN                               *EntryCount
1295  );
1296
1297/**
1298  Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
1299  from pool.
1300
1301  @param  Handle                The handle from which to retrieve the list of protocol interface
1302                                GUIDs.
1303  @param  ProtocolBuffer        A pointer to the list of protocol interface GUID pointers that are
1304                                installed on Handle.
1305  @param  ProtocolBufferCount   A pointer to the number of GUID pointers present in
1306                                ProtocolBuffer.
1307
1308  @retval EFI_SUCCESS           The list of protocol interface GUIDs installed on Handle was returned in
1309                                ProtocolBuffer. The number of protocol interface GUIDs was
1310                                returned in ProtocolBufferCount.
1311  @retval EFI_OUT_OF_RESOURCES  There is not enough pool memory to store the results.
1312  @retval EFI_INVALID_PARAMETER Handle is NULL.
1313  @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
1314  @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
1315  @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
1316
1317**/
1318typedef
1319EFI_STATUS
1320(EFIAPI *EFI_PROTOCOLS_PER_HANDLE)(
1321  IN  EFI_HANDLE      Handle,
1322  OUT EFI_GUID        ***ProtocolBuffer,
1323  OUT UINTN           *ProtocolBufferCount
1324  );
1325
1326/**
1327  Creates an event that is to be signaled whenever an interface is installed for a specified protocol.
1328
1329  @param  Protocol              The numeric ID of the protocol for which the event is to be registered.
1330  @param  Event                 Event that is to be signaled whenever a protocol interface is registered
1331                                for Protocol.
1332  @param  Registration          A pointer to a memory location to receive the registration value.
1333
1334  @retval EFI_SUCCESS           The notification event has been registered.
1335  @retval EFI_OUT_OF_RESOURCES  Space for the notification event could not be allocated.
1336  @retval EFI_INVALID_PARAMETER Protocol is NULL.
1337  @retval EFI_INVALID_PARAMETER Event is NULL.
1338  @retval EFI_INVALID_PARAMETER Registration is NULL.
1339
1340**/
1341typedef
1342EFI_STATUS
1343(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY)(
1344  IN  EFI_GUID                 *Protocol,
1345  IN  EFI_EVENT                Event,
1346  OUT VOID                     **Registration
1347  );
1348
1349
1350typedef enum {
1351  AllHandles,
1352  ByRegisterNotify,
1353  ByProtocol
1354} EFI_LOCATE_SEARCH_TYPE;
1355
1356/**
1357  Returns an array of handles that support a specified protocol.
1358
1359  @param  SearchType            Specifies which handle(s) are to be returned.
1360  @param  Protocol              Specifies the protocol to search by.
1361  @param  SearchKey             Specifies the search key.
1362  @param  BufferSize            On input, the size in bytes of Buffer. On output, the size in bytes of
1363                                the array returned in Buffer (if the buffer was large enough) or the
1364                                size, in bytes, of the buffer needed to obtain the array (if the buffer was
1365                                not large enough).
1366  @param  Buffer                The buffer in which the array is returned.
1367
1368  @retval EFI_SUCCESS           The array of handles was returned.
1369  @retval EFI_NOT_FOUND         No handles match the search.
1370  @retval EFI_BUFFER_TOO_SMALL  The BufferSize is too small for the result.
1371  @retval EFI_INVALID_PARAMETER SearchType is not a member of EFI_LOCATE_SEARCH_TYPE.
1372  @retval EFI_INVALID_PARAMETER SearchType is ByRegisterNotify and SearchKey is NULL.
1373  @retval EFI_INVALID_PARAMETER SearchType is ByProtocol and Protocol is NULL.
1374  @retval EFI_INVALID_PARAMETER One or more matches are found and BufferSize is NULL.
1375  @retval EFI_INVALID_PARAMETER BufferSize is large enough for the result and Buffer is NULL.
1376
1377**/
1378typedef
1379EFI_STATUS
1380(EFIAPI *EFI_LOCATE_HANDLE)(
1381  IN     EFI_LOCATE_SEARCH_TYPE   SearchType,
1382  IN     EFI_GUID                 *Protocol,    OPTIONAL
1383  IN     VOID                     *SearchKey,   OPTIONAL
1384  IN OUT UINTN                    *BufferSize,
1385  OUT    EFI_HANDLE               *Buffer
1386  );
1387
1388/**
1389  Locates the handle to a device on the device path that supports the specified protocol.
1390
1391  @param  Protocol              Specifies the protocol to search for.
1392  @param  DevicePath            On input, a pointer to a pointer to the device path. On output, the device
1393                                path pointer is modified to point to the remaining part of the device
1394                                path.
1395  @param  Device                A pointer to the returned device handle.
1396
1397  @retval EFI_SUCCESS           The resulting handle was returned.
1398  @retval EFI_NOT_FOUND         No handles match the search.
1399  @retval EFI_INVALID_PARAMETER Protocol is NULL.
1400  @retval EFI_INVALID_PARAMETER DevicePath is NULL.
1401  @retval EFI_INVALID_PARAMETER A handle matched the search and Device is NULL.
1402
1403**/
1404typedef
1405EFI_STATUS
1406(EFIAPI *EFI_LOCATE_DEVICE_PATH)(
1407  IN     EFI_GUID                         *Protocol,
1408  IN OUT EFI_DEVICE_PATH_PROTOCOL         **DevicePath,
1409  OUT    EFI_HANDLE                       *Device
1410  );
1411
1412/**
1413  Adds, updates, or removes a configuration table entry from the EFI System Table.
1414
1415  @param  Guid                  A pointer to the GUID for the entry to add, update, or remove.
1416  @param  Table                 A pointer to the configuration table for the entry to add, update, or
1417                                remove. May be NULL.
1418
1419  @retval EFI_SUCCESS           The (Guid, Table) pair was added, updated, or removed.
1420  @retval EFI_NOT_FOUND         An attempt was made to delete a nonexistent entry.
1421  @retval EFI_INVALID_PARAMETER Guid is not valid.
1422  @retval EFI_OUT_OF_RESOURCES  There is not enough memory available to complete the operation.
1423
1424**/
1425typedef
1426EFI_STATUS
1427(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE)(
1428  IN EFI_GUID                 *Guid,
1429  IN VOID                     *Table
1430  );
1431
1432
1433/**
1434  Returns an array of handles that support the requested protocol in a buffer allocated from pool.
1435
1436  @param  SearchType            Specifies which handle(s) are to be returned.
1437  @param  Protocol              Provides the protocol to search by.
1438                                This parameter is only valid for a SearchType of ByProtocol.
1439  @param  SearchKey             Supplies the search key depending on the SearchType.
1440  @param  NoHandles             The number of handles returned in Buffer.
1441  @param  Buffer                A pointer to the buffer to return the requested array of handles that
1442                                support Protocol.
1443
1444  @retval EFI_SUCCESS           The array of handles was returned in Buffer, and the number of
1445                                handles in Buffer was returned in NoHandles.
1446  @retval EFI_NOT_FOUND         No handles match the search.
1447  @retval EFI_OUT_OF_RESOURCES  There is not enough pool memory to store the matching results.
1448  @retval EFI_INVALID_PARAMETER NoHandles is NULL.
1449  @retval EFI_INVALID_PARAMETER Buffer is NULL.
1450
1451**/
1452typedef
1453EFI_STATUS
1454(EFIAPI *EFI_LOCATE_HANDLE_BUFFER)(
1455  IN     EFI_LOCATE_SEARCH_TYPE       SearchType,
1456  IN     EFI_GUID                     *Protocol,      OPTIONAL
1457  IN     VOID                         *SearchKey,     OPTIONAL
1458  IN OUT UINTN                        *NoHandles,
1459  OUT    EFI_HANDLE                   **Buffer
1460  );
1461
1462/**
1463  Returns the first protocol instance that matches the given protocol.
1464
1465  @param  Protocol              Provides the protocol to search for.
1466  @param  Registration          Optional registration key returned from
1467                                RegisterProtocolNotify().
1468  @param  Interface             On return, a pointer to the first interface that matches Protocol and
1469                                Registration.
1470
1471  @retval EFI_SUCCESS           A protocol instance matching Protocol was found and returned in
1472                                Interface.
1473  @retval EFI_NOT_FOUND         No protocol instances were found that match Protocol and
1474                                Registration.
1475  @retval EFI_INVALID_PARAMETER Interface is NULL.
1476
1477**/
1478typedef
1479EFI_STATUS
1480(EFIAPI *EFI_LOCATE_PROTOCOL)(
1481  IN  EFI_GUID  *Protocol,
1482  IN  VOID      *Registration, OPTIONAL
1483  OUT VOID      **Interface
1484  );
1485
1486typedef struct {
1487  UINT64                            Length;
1488  union {
1489    EFI_PHYSICAL_ADDRESS  DataBlock;
1490    EFI_PHYSICAL_ADDRESS  ContinuationPointer;
1491  } Union;
1492} EFI_CAPSULE_BLOCK_DESCRIPTOR;
1493
1494typedef struct {
1495  EFI_GUID          CapsuleGuid;
1496  UINT32            HeaderSize;
1497  UINT32            Flags;
1498  UINT32            CapsuleImageSize;
1499} EFI_CAPSULE_HEADER;
1500
1501//
1502// The EFI System Table entry must point to an array of capsules
1503// that contain the same CapsuleGuid value. The array must be
1504// prefixed by a UINT32 that represents the size of the array of capsules.
1505//
1506typedef struct {
1507  UINT32   CapsuleArrayNumber;
1508  VOID*    CapsulePtr[1];
1509} EFI_CAPSULE_TABLE;
1510
1511#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET          0x00010000
1512#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE         0x00020000
1513
1514/**
1515  Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended
1516  consumption, the firmware may process the capsule immediately. If the payload should persist
1517  across a system reset, the reset value returned from EFI_QueryCapsuleCapabilities must
1518  be passed into ResetSystem() and will cause the capsule to be processed by the firmware as
1519  part of the reset process.
1520
1521  @param  CapsuleHeaderArray    Virtual pointer to an array of virtual pointers to the capsules
1522                                being passed into update capsule.
1523  @param  CapsuleCount          Number of pointers to EFI_CAPSULE_HEADER in
1524                                CaspuleHeaderArray.
1525  @param  ScatterGatherList     Physical pointer to a set of
1526                                EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the
1527                                location in physical memory of a set of capsules.
1528
1529  @retval EFI_SUCCESS           Valid capsule was passed. If
1530                                CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the
1531                                capsule has been successfully processed by the firmware.
1532  @retval EFI_DEVICE_ERROR      The capsule update was started, but failed due to a device error.
1533  @retval EFI_INVALID_PARAMETER CapsuleSize is NULL.
1534  @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform.
1535  @retval EFI_OUT_OF_RESOURCES  There were insufficient resources to process the capsule.
1536
1537**/
1538typedef
1539EFI_STATUS
1540(EFIAPI *EFI_UPDATE_CAPSULE)(
1541  IN EFI_CAPSULE_HEADER     **CapsuleHeaderArray,
1542  IN UINTN                  CapsuleCount,
1543  IN EFI_PHYSICAL_ADDRESS   ScatterGatherList   OPTIONAL
1544  );
1545
1546/**
1547  Returns if the capsule can be supported via UpdateCapsule().
1548
1549  @param  CapsuleHeaderArray    Virtual pointer to an array of virtual pointers to the capsules
1550                                being passed into update capsule.
1551  @param  CapsuleCount          Number of pointers to EFI_CAPSULE_HEADER in
1552                                CaspuleHeaderArray.
1553  @param  MaxiumCapsuleSize     On output the maximum size that UpdateCapsule() can
1554                                support as an argument to UpdateCapsule() via
1555                                CapsuleHeaderArray and ScatterGatherList.
1556  @param  ResetType             Returns the type of reset required for the capsule update.
1557
1558  @retval EFI_SUCCESS           Valid answer returned.
1559  @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform, and
1560                                MaximumCapsuleSize and ResetType are undefined.
1561  @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
1562  @retval EFI_OUT_OF_RESOURCES  There were insufficient resources to process the query request.
1563
1564**/
1565typedef
1566EFI_STATUS
1567(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES)(
1568  IN  EFI_CAPSULE_HEADER     **CapsuleHeaderArray,
1569  IN  UINTN                  CapsuleCount,
1570  OUT UINT64                 *MaximumCapsuleSize,
1571  OUT EFI_RESET_TYPE         *ResetType
1572  );
1573
1574/**
1575  Returns information about the EFI variables.
1576
1577  @param  Attributes                   Attributes bitmask to specify the type of variables on
1578                                       which to return information.
1579  @param  MaximumVariableStorageSize   On output the maximum size of the storage space
1580                                       available for the EFI variables associated with the
1581                                       attributes specified.
1582  @param  RemainingVariableStorageSize Returns the remaining size of the storage space
1583                                       available for the EFI variables associated with the
1584                                       attributes specified.
1585  @param  MaximumVariableSize          Returns the maximum size of the individual EFI
1586                                       variables associated with the attributes specified.
1587
1588  @retval EFI_SUCCESS                  Valid answer returned.
1589  @retval EFI_INVALID_PARAMETER        An invalid combination of attribute bits was supplied
1590  @retval EFI_UNSUPPORTED              The attribute is not supported on this platform, and the
1591                                       MaximumVariableStorageSize,
1592                                       RemainingVariableStorageSize, MaximumVariableSize
1593                                       are undefined.
1594
1595**/
1596typedef
1597EFI_STATUS
1598(EFIAPI *EFI_QUERY_VARIABLE_INFO)(
1599  IN  UINT32            Attributes,
1600  OUT UINT64            *MaximumVariableStorageSize,
1601  OUT UINT64            *RemainingVariableStorageSize,
1602  OUT UINT64            *MaximumVariableSize
1603  );
1604
1605
1606//
1607// EFI Runtime Services Table
1608//
1609#define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249ULL
1610#define EFI_SYSTEM_TABLE_REVISION       ((2<<16) | (10))
1611#define EFI_2_10_SYSTEM_TABLE_REVISION  ((2<<16) | (10))
1612#define EFI_2_00_SYSTEM_TABLE_REVISION  ((2<<16) | (00))
1613#define EFI_1_10_SYSTEM_TABLE_REVISION  ((1<<16) | (10))
1614#define EFI_1_02_SYSTEM_TABLE_REVISION  ((1<<16) | (02))
1615
1616#define EFI_RUNTIME_SERVICES_SIGNATURE  0x56524553544e5552ULL
1617#define EFI_RUNTIME_SERVICES_REVISION   EFI_2_10_SYSTEM_TABLE_REVISION
1618
1619///
1620/// EFI Runtime Services Table
1621///
1622typedef struct {
1623  ///
1624  /// The table header for the EFI Runtime Services Table.
1625  ///
1626  EFI_TABLE_HEADER                Hdr;
1627
1628  //
1629  // Time Services
1630  //
1631  EFI_GET_TIME                    GetTime;
1632  EFI_SET_TIME                    SetTime;
1633  EFI_GET_WAKEUP_TIME             GetWakeupTime;
1634  EFI_SET_WAKEUP_TIME             SetWakeupTime;
1635
1636  //
1637  // Virtual Memory Services
1638  //
1639  EFI_SET_VIRTUAL_ADDRESS_MAP     SetVirtualAddressMap;
1640  EFI_CONVERT_POINTER             ConvertPointer;
1641
1642  //
1643  // Variable Services
1644  //
1645  EFI_GET_VARIABLE                GetVariable;
1646  EFI_GET_NEXT_VARIABLE_NAME      GetNextVariableName;
1647  EFI_SET_VARIABLE                SetVariable;
1648
1649  //
1650  // Miscellaneous Services
1651  //
1652  EFI_GET_NEXT_HIGH_MONO_COUNT    GetNextHighMonotonicCount;
1653  EFI_RESET_SYSTEM                ResetSystem;
1654
1655  //
1656  // UEFI 2.0 Capsule Services
1657  //
1658  EFI_UPDATE_CAPSULE              UpdateCapsule;
1659  EFI_QUERY_CAPSULE_CAPABILITIES  QueryCapsuleCapabilities;
1660
1661  //
1662  // Miscellaneous UEFI 2.0 Service
1663  //
1664  EFI_QUERY_VARIABLE_INFO         QueryVariableInfo;
1665} EFI_RUNTIME_SERVICES;
1666
1667
1668#define EFI_BOOT_SERVICES_SIGNATURE   0x56524553544f4f42ULL
1669#define EFI_BOOT_SERVICES_REVISION    EFI_2_10_SYSTEM_TABLE_REVISION
1670
1671///
1672/// EFI Boot Services Table
1673///
1674typedef struct {
1675  ///
1676  /// The table header for the EFI Boot Services Table.
1677  ///
1678  EFI_TABLE_HEADER                Hdr;
1679
1680  //
1681  // Task Priority Services
1682  //
1683  EFI_RAISE_TPL                   RaiseTPL;
1684  EFI_RESTORE_TPL                 RestoreTPL;
1685
1686  //
1687  // Memory Services
1688  //
1689  EFI_ALLOCATE_PAGES              AllocatePages;
1690  EFI_FREE_PAGES                  FreePages;
1691  EFI_GET_MEMORY_MAP              GetMemoryMap;
1692  EFI_ALLOCATE_POOL               AllocatePool;
1693  EFI_FREE_POOL                   FreePool;
1694
1695  //
1696  // Event & Timer Services
1697  //
1698  EFI_CREATE_EVENT                  CreateEvent;
1699  EFI_SET_TIMER                     SetTimer;
1700  EFI_WAIT_FOR_EVENT                WaitForEvent;
1701  EFI_SIGNAL_EVENT                  SignalEvent;
1702  EFI_CLOSE_EVENT                   CloseEvent;
1703  EFI_CHECK_EVENT                   CheckEvent;
1704
1705  //
1706  // Protocol Handler Services
1707  //
1708  EFI_INSTALL_PROTOCOL_INTERFACE    InstallProtocolInterface;
1709  EFI_REINSTALL_PROTOCOL_INTERFACE  ReinstallProtocolInterface;
1710  EFI_UNINSTALL_PROTOCOL_INTERFACE  UninstallProtocolInterface;
1711  EFI_HANDLE_PROTOCOL               HandleProtocol;
1712  VOID                              *Reserved;
1713  EFI_REGISTER_PROTOCOL_NOTIFY      RegisterProtocolNotify;
1714  EFI_LOCATE_HANDLE                 LocateHandle;
1715  EFI_LOCATE_DEVICE_PATH            LocateDevicePath;
1716  EFI_INSTALL_CONFIGURATION_TABLE   InstallConfigurationTable;
1717
1718  //
1719  // Image Services
1720  //
1721  EFI_IMAGE_LOAD                    LoadImage;
1722  EFI_IMAGE_START                   StartImage;
1723  EFI_EXIT                          Exit;
1724  EFI_IMAGE_UNLOAD                  UnloadImage;
1725  EFI_EXIT_BOOT_SERVICES            ExitBootServices;
1726
1727  //
1728  // Miscellaneous Services
1729  //
1730  EFI_GET_NEXT_MONOTONIC_COUNT      GetNextMonotonicCount;
1731  EFI_STALL                         Stall;
1732  EFI_SET_WATCHDOG_TIMER            SetWatchdogTimer;
1733
1734  //
1735  // DriverSupport Services
1736  //
1737  EFI_CONNECT_CONTROLLER            ConnectController;
1738  EFI_DISCONNECT_CONTROLLER         DisconnectController;
1739
1740  //
1741  // Open and Close Protocol Services
1742  //
1743  EFI_OPEN_PROTOCOL                 OpenProtocol;
1744  EFI_CLOSE_PROTOCOL                CloseProtocol;
1745  EFI_OPEN_PROTOCOL_INFORMATION     OpenProtocolInformation;
1746
1747  //
1748  // Library Services
1749  //
1750  EFI_PROTOCOLS_PER_HANDLE          ProtocolsPerHandle;
1751  EFI_LOCATE_HANDLE_BUFFER          LocateHandleBuffer;
1752  EFI_LOCATE_PROTOCOL               LocateProtocol;
1753  EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES    InstallMultipleProtocolInterfaces;
1754  EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES  UninstallMultipleProtocolInterfaces;
1755
1756  //
1757  // 32-bit CRC Services
1758  //
1759  EFI_CALCULATE_CRC32               CalculateCrc32;
1760
1761  //
1762  // Miscellaneous Services
1763  //
1764  EFI_COPY_MEM                      CopyMem;
1765  EFI_SET_MEM                       SetMem;
1766  EFI_CREATE_EVENT_EX               CreateEventEx;
1767} EFI_BOOT_SERVICES;
1768
1769///
1770/// Contains a set of GUID/pointer pairs comprised of the ConfigurationTable field in the
1771/// EFI System Table.
1772///
1773typedef struct{
1774  ///
1775  /// The 128-bit GUID value that uniquely identifies the system configuration table.
1776  ///
1777  EFI_GUID                          VendorGuid;
1778  ///
1779  /// A pointer to the table associated with VendorGuid.
1780  ///
1781  VOID                              *VendorTable;
1782} EFI_CONFIGURATION_TABLE;
1783
1784///
1785/// EFI System Table
1786///
1787struct _EFI_SYSTEM_TABLE {
1788  ///
1789  /// The table header for the EFI System Table.
1790  ///
1791  EFI_TABLE_HEADER                  Hdr;
1792  ///
1793  /// A pointer to a null terminated Unicode string that identifies
1794  /// the vendor that produces the system firmware for the platform.
1795  ///
1796  CHAR16                            *FirmwareVendor;
1797  ///
1798  /// A firmware vendor specific value that identifies the revision
1799  /// of the system firmware for the platform.
1800  ///
1801  UINT32                            FirmwareRevision;
1802  ///
1803  /// The handle for the active console input device.
1804  ///
1805  EFI_HANDLE                        ConsoleInHandle;
1806  ///
1807  /// A pointer to the SIMPLE_INPUT_PROTOCOL interface that is
1808  /// associated with ConsoleInHandle.
1809  ///
1810  EFI_SIMPLE_TEXT_INPUT_PROTOCOL    *ConIn;
1811  ///
1812  /// The handle for the active console output device.
1813  ///
1814  EFI_HANDLE                        ConsoleOutHandle;
1815  ///
1816  /// A pointer to the SIMPLE_TEXT_OUTPUT_PROTOCOL interface
1817  /// that is associated with ConsoleOutHandle.
1818  ///
1819  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut;
1820  ///
1821  /// The handle for the active standard error console device.
1822  ///
1823  EFI_HANDLE                        StandardErrorHandle;
1824  ///
1825  /// A pointer to the SIMPLE_TEXT_OUTPUT_PROTOCOL interface
1826  /// that is associated with StandardErrorHandle.
1827  ///
1828  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *StdErr;
1829  ///
1830  /// A pointer to the EFI Runtime Services Table.
1831  ///
1832  EFI_RUNTIME_SERVICES              *RuntimeServices;
1833  ///
1834  /// A pointer to the EFI Boot Services Table.
1835  ///
1836  EFI_BOOT_SERVICES                 *BootServices;
1837  ///
1838  /// The number of system configuration tables in the buffer ConfigurationTable.
1839  ///
1840  UINTN                             NumberOfTableEntries;
1841  ///
1842  /// A pointer to the system configuration tables.
1843  /// The number of entries in the table is NumberOfTableEntries.
1844  ///
1845  EFI_CONFIGURATION_TABLE           *ConfigurationTable;
1846};
1847
1848//
1849// EFI Load Options Attributes
1850//
1851#define LOAD_OPTION_ACTIVE            0x00000001
1852#define LOAD_OPTION_FORCE_RECONNECT   0x00000002
1853#define LOAD_OPTION_HIDDEN            0x00000008
1854#define LOAD_OPTION_CATEGORY          0x00001F00
1855
1856#define LOAD_OPTION_CATEGORY_BOOT     0x00000000
1857#define LOAD_OPTION_CATEGORY_APP      0x00000100
1858
1859#define EFI_BOOT_OPTION_SUPPORT_KEY   0x00000001
1860#define EFI_BOOT_OPTION_SUPPORT_APP   0x00000002
1861#define EFI_BOOT_OPTION_SUPPORT_COUNT 0x00000300
1862
1863typedef union {
1864  struct {
1865    UINT32  Revision        : 8;
1866    UINT32  ShiftPressed    : 1;
1867    UINT32  ControlPressed  : 1;
1868    UINT32  AltPressed      : 1;
1869    UINT32  LogoPressed     : 1;
1870    UINT32  MenuPressed     : 1;
1871    UINT32  SysReqPessed    : 1;
1872    UINT32  Reserved        : 16;
1873    UINT32  InputKeyCount   : 2;
1874  } Options;
1875  UINT32  PackedValue;
1876} HOT_KEY_EFI_KEY_DATA;
1877
1878typedef struct {
1879  HOT_KEY_EFI_KEY_DATA  KeyOptions;
1880  UINT32                BootOptionCrc;
1881  UINT16                BootOption;
1882//EFI_INPUT_KEY         Keys[];
1883} EFI_KEY_OPTION;
1884
1885#define EFI_KEY_OPTION_SHIFT     0x00000001
1886#define EFI_KEY_OPTION_CONTROL   0x00000002
1887#define EFI_KEY_OPTION_ALT       0x00000004
1888#define EFI_KEY_OPTION_LOGO      0x00000008
1889#define EFI_KEY_OPTION_MENU      0x00000010
1890#define EFI_KEY_OPTION_SYSREQ    0x00000020
1891#define EFI_KEY_CODE_COUNT       0x00000300
1892
1893
1894//
1895// EFI File location to boot from on removable media devices
1896//
1897#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA32    L"\\EFI\\BOOT\\BOOTIA32.EFI"
1898#define EFI_REMOVABLE_MEDIA_FILE_NAME_IA64    L"\\EFI\\BOOT\\BOOTIA64.EFI"
1899#define EFI_REMOVABLE_MEDIA_FILE_NAME_X64     L"\\EFI\\BOOT\\BOOTX64.EFI"
1900
1901#if   defined (MDE_CPU_IA32)
1902  #define EFI_REMOVABLE_MEDIA_FILE_NAME   EFI_REMOVABLE_MEDIA_FILE_NAME_IA32
1903#elif defined (MDE_CPU_IPF)
1904  #define EFI_REMOVABLE_MEDIA_FILE_NAME   EFI_REMOVABLE_MEDIA_FILE_NAME_IA64
1905#elif defined (MDE_CPU_X64)
1906  #define EFI_REMOVABLE_MEDIA_FILE_NAME   EFI_REMOVABLE_MEDIA_FILE_NAME_X64
1907#elif defined (MDE_CPU_EBC)
1908#else
1909  #error Unknown Processor Type
1910#endif
1911
1912#include <gpxe/efi/Uefi/UefiPxe.h>
1913#include <gpxe/efi/Uefi/UefiGpt.h>
1914#include <gpxe/efi/Uefi/UefiInternalFormRepresentation.h>
1915
1916#endif
1917