xref: /freebsd/sys/contrib/edk2/Include/Uefi/UefiSpec.h (revision 580fcf642ea2d5a1e60f24947d1c2e97007e44e9)
1 /** @file
2   Include file that supports UEFI.
3 
4   This include file must contain things defined in the UEFI 2.7 specification.
5   If a code construct is defined in the UEFI 2.7 specification it must be included
6   by this include file.
7 
8 Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
9 Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
10 Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
11 
12 SPDX-License-Identifier: BSD-2-Clause-Patent
13 
14 **/
15 
16 #ifndef __UEFI_SPEC_H__
17 #define __UEFI_SPEC_H__
18 
19 #include <Uefi/UefiMultiPhase.h>
20 
21 #include <Protocol/DevicePath.h>
22 #include <Protocol/SimpleTextIn.h>
23 #include <Protocol/SimpleTextInEx.h>
24 #include <Protocol/SimpleTextOut.h>
25 
26 ///
27 /// Enumeration of EFI memory allocation types.
28 ///
29 typedef enum {
30   ///
31   /// Allocate any available range of pages that satisfies the request.
32   ///
33   AllocateAnyPages,
34   ///
35   /// Allocate any available range of pages whose uppermost address is less than
36   /// or equal to a specified maximum address.
37   ///
38   AllocateMaxAddress,
39   ///
40   /// Allocate pages at a specified address.
41   ///
42   AllocateAddress,
43   ///
44   /// Maximum enumeration value that may be used for bounds checking.
45   ///
46   MaxAllocateType
47 } EFI_ALLOCATE_TYPE;
48 
49 //
50 // Bit definitions for EFI_TIME.Daylight
51 //
52 #define EFI_TIME_ADJUST_DAYLIGHT  0x01
53 #define EFI_TIME_IN_DAYLIGHT      0x02
54 
55 ///
56 /// Value definition for EFI_TIME.TimeZone.
57 ///
58 #define EFI_UNSPECIFIED_TIMEZONE  0x07FF
59 
60 //
61 // Memory cacheability attributes
62 //
63 #define EFI_MEMORY_UC   0x0000000000000001ULL
64 #define EFI_MEMORY_WC   0x0000000000000002ULL
65 #define EFI_MEMORY_WT   0x0000000000000004ULL
66 #define EFI_MEMORY_WB   0x0000000000000008ULL
67 #define EFI_MEMORY_UCE  0x0000000000000010ULL
68 //
69 // Physical memory protection attributes
70 //
71 // Note: UEFI spec 2.5 and following: use EFI_MEMORY_RO as write-protected physical memory
72 // protection attribute. Also, EFI_MEMORY_WP means cacheability attribute.
73 //
74 #define EFI_MEMORY_WP  0x0000000000001000ULL
75 #define EFI_MEMORY_RP  0x0000000000002000ULL
76 #define EFI_MEMORY_XP  0x0000000000004000ULL
77 #define EFI_MEMORY_RO  0x0000000000020000ULL
78 //
79 // Physical memory persistence attribute.
80 // The memory region supports byte-addressable non-volatility.
81 //
82 #define EFI_MEMORY_NV  0x0000000000008000ULL
83 //
84 // The memory region provides higher reliability relative to other memory in the system.
85 // If all memory has the same reliability, then this bit is not used.
86 //
87 #define EFI_MEMORY_MORE_RELIABLE  0x0000000000010000ULL
88 
89 //
90 // Note: UEFI spec 2.8 and following:
91 //
92 // Specific-purpose memory (SPM). The memory is earmarked for
93 // specific purposes such as for specific device drivers or applications.
94 // The SPM attribute serves as a hint to the OS to avoid allocating this
95 // memory for core OS data or code that can not be relocated.
96 //
97 #define EFI_MEMORY_SP  0x0000000000040000ULL
98 //
99 // If this flag is set, the memory region is capable of being
100 // protected with the CPU's memory cryptographic
101 // capabilities. If this flag is clear, the memory region is not
102 // capable of being protected with the CPU's memory
103 // cryptographic capabilities or the CPU does not support CPU
104 // memory cryptographic capabilities.
105 //
106 #define EFI_MEMORY_CPU_CRYPTO  0x0000000000080000ULL
107 
108 //
109 // If this flag is set, the memory region is present and capable of having
110 // memory dynamically removed from the platform. This attribute serves as
111 // a hint to the OS prior to its ACPI subsystem initialization to avoid
112 // allocating this memory for core OS data or code that cannot be dynamically
113 // relocated at runtime. If this flag is clear, the memory region is not
114 // capable of being dynamically removed from the platform at runtime.
115 //
116 #define EFI_MEMORY_HOT_PLUGGABLE  0x0000000000100000
117 
118 //
119 // Runtime memory attribute
120 //
121 #define EFI_MEMORY_RUNTIME  0x8000000000000000ULL
122 
123 //
124 // If this flag is set, the memory region is
125 // described with additional ISA-specific memory attributes
126 // as specified in EFI_MEMORY_ISA_MASK.
127 //
128 #define EFI_MEMORY_ISA_VALID  0x4000000000000000ULL
129 
130 //
131 // Defines the bits reserved for describing optional ISA-specific cacheability
132 // attributes that are not covered by the standard UEFI Memory Attributes cacheability
133 // bits (EFI_MEMORY_UC, EFI_MEMORY_WC, EFI_MEMORY_WT, EFI_MEMORY_WB and EFI_MEMORY_UCE).
134 // See Calling Conventions for further ISA-specific enumeration of these bits.
135 //
136 #define EFI_MEMORY_ISA_MASK  0x0FFFF00000000000ULL
137 
138 //
139 // Attributes bitmasks, grouped by type
140 //
141 #define EFI_CACHE_ATTRIBUTE_MASK   (EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_WP)
142 #define EFI_MEMORY_ACCESS_MASK     (EFI_MEMORY_RP | EFI_MEMORY_XP | EFI_MEMORY_RO)
143 #define EFI_MEMORY_ATTRIBUTE_MASK  (EFI_MEMORY_ACCESS_MASK | EFI_MEMORY_SP | EFI_MEMORY_CPU_CRYPTO)
144 
145 ///
146 /// Memory descriptor version number.
147 ///
148 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
149 
150 ///
151 /// Definition of an EFI memory descriptor.
152 ///
153 typedef struct {
154   ///
155   /// Type of the memory region.
156   /// Type EFI_MEMORY_TYPE is defined in the
157   /// AllocatePages() function description.
158   ///
159   UINT32                  Type;
160   ///
161   /// Physical address of the first byte in the memory region. PhysicalStart must be
162   /// aligned on a 4 KiB boundary, and must not be above 0xfffffffffffff000. Type
163   /// EFI_PHYSICAL_ADDRESS is defined in the AllocatePages() function description
164   ///
165   EFI_PHYSICAL_ADDRESS    PhysicalStart;
166   ///
167   /// Virtual address of the first byte in the memory region.
168   /// VirtualStart must be aligned on a 4 KiB boundary,
169   /// and must not be above 0xfffffffffffff000.
170   ///
171   EFI_VIRTUAL_ADDRESS     VirtualStart;
172   ///
173   /// NumberOfPagesNumber of 4 KiB pages in the memory region.
174   /// NumberOfPages must not be 0, and must not be any value
175   /// that would represent a memory page with a start address,
176   /// either physical or virtual, above 0xfffffffffffff000.
177   ///
178   UINT64                  NumberOfPages;
179   ///
180   /// Attributes of the memory region that describe the bit mask of capabilities
181   /// for that memory region, and not necessarily the current settings for that
182   /// memory region.
183   ///
184   UINT64                  Attribute;
185 } EFI_MEMORY_DESCRIPTOR;
186 
187 /**
188   Allocates memory pages from the system.
189 
190   @param[in]       Type         The type of allocation to perform.
191   @param[in]       MemoryType   The type of memory to allocate.
192                                 MemoryType values in the range 0x70000000..0x7FFFFFFF
193                                 are reserved for OEM use. MemoryType values in the range
194                                 0x80000000..0xFFFFFFFF are reserved for use by UEFI OS loaders
195                                 that are provided by operating system vendors.
196   @param[in]       Pages        The number of contiguous 4 KB pages to allocate.
197   @param[in, out]  Memory       The pointer to a physical address. On input, the way in which the address is
198                                 used depends on the value of Type.
199 
200   @retval EFI_SUCCESS           The requested pages were allocated.
201   @retval EFI_INVALID_PARAMETER 1) Type is not AllocateAnyPages or
202                                 AllocateMaxAddress or AllocateAddress.
203                                 2) MemoryType is in the range
204                                 EfiMaxMemoryType..0x6FFFFFFF.
205                                 3) Memory is NULL.
206                                 4) MemoryType is EfiPersistentMemory.
207   @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.
208   @retval EFI_NOT_FOUND         The requested pages could not be found.
209 
210 **/
211 typedef
212 EFI_STATUS
213 (EFIAPI *EFI_ALLOCATE_PAGES)(
214   IN     EFI_ALLOCATE_TYPE            Type,
215   IN     EFI_MEMORY_TYPE              MemoryType,
216   IN     UINTN                        Pages,
217   IN OUT EFI_PHYSICAL_ADDRESS         *Memory
218   );
219 
220 /**
221   Frees memory pages.
222 
223   @param[in]  Memory      The base physical address of the pages to be freed.
224   @param[in]  Pages       The number of contiguous 4 KB pages to free.
225 
226   @retval EFI_SUCCESS           The requested pages were freed.
227   @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.
228   @retval EFI_NOT_FOUND         The requested memory pages were not allocated with
229                                 AllocatePages().
230 
231 **/
232 typedef
233 EFI_STATUS
234 (EFIAPI *EFI_FREE_PAGES)(
235   IN  EFI_PHYSICAL_ADDRESS         Memory,
236   IN  UINTN                        Pages
237   );
238 
239 /**
240   Returns the current memory map.
241 
242   @param[in, out]  MemoryMapSize         A pointer to the size, in bytes, of the MemoryMap buffer.
243                                          On input, this is the size of the buffer allocated by the caller.
244                                          On output, it is the size of the buffer returned by the firmware if
245                                          the buffer was large enough, or the size of the buffer needed to contain
246                                          the map if the buffer was too small.
247   @param[out]      MemoryMap             A pointer to the buffer in which firmware places the current memory
248                                          map.
249   @param[out]      MapKey                A pointer to the location in which firmware returns the key for the
250                                          current memory map.
251   @param[out]      DescriptorSize        A pointer to the location in which firmware returns the size, in bytes, of
252                                          an individual EFI_MEMORY_DESCRIPTOR.
253   @param[out]      DescriptorVersion     A pointer to the location in which firmware returns the version number
254                                          associated with the EFI_MEMORY_DESCRIPTOR.
255 
256   @retval EFI_SUCCESS           The memory map was returned in the MemoryMap buffer.
257   @retval EFI_BUFFER_TOO_SMALL  The MemoryMap buffer was too small. The current buffer size
258                                 needed to hold the memory map is returned in MemoryMapSize.
259   @retval EFI_INVALID_PARAMETER 1) MemoryMapSize is NULL.
260                                 2) The MemoryMap buffer is not too small and MemoryMap is
261                                    NULL.
262 
263 **/
264 typedef
265 EFI_STATUS
266 (EFIAPI *EFI_GET_MEMORY_MAP)(
267   IN OUT UINTN                       *MemoryMapSize,
268   OUT    EFI_MEMORY_DESCRIPTOR       *MemoryMap,
269   OUT    UINTN                       *MapKey,
270   OUT    UINTN                       *DescriptorSize,
271   OUT    UINT32                      *DescriptorVersion
272   );
273 
274 /**
275   Allocates pool memory.
276 
277   @param[in]   PoolType         The type of pool to allocate.
278                                 MemoryType values in the range 0x70000000..0x7FFFFFFF
279                                 are reserved for OEM use. MemoryType values in the range
280                                 0x80000000..0xFFFFFFFF are reserved for use by UEFI OS loaders
281                                 that are provided by operating system vendors.
282   @param[in]   Size             The number of bytes to allocate from the pool.
283   @param[out]  Buffer           A pointer to a pointer to the allocated buffer if the call succeeds;
284                                 undefined otherwise.
285 
286   @retval EFI_SUCCESS           The requested number of bytes was allocated.
287   @retval EFI_OUT_OF_RESOURCES  The pool requested could not be allocated.
288   @retval EFI_INVALID_PARAMETER Buffer is NULL.
289                                 PoolType is in the range EfiMaxMemoryType..0x6FFFFFFF.
290                                 PoolType is EfiPersistentMemory.
291 
292 **/
293 typedef
294 EFI_STATUS
295 (EFIAPI *EFI_ALLOCATE_POOL)(
296   IN  EFI_MEMORY_TYPE              PoolType,
297   IN  UINTN                        Size,
298   OUT VOID                         **Buffer
299   );
300 
301 /**
302   Returns pool memory to the system.
303 
304   @param[in]  Buffer            The pointer to the buffer to free.
305 
306   @retval EFI_SUCCESS           The memory was returned to the system.
307   @retval EFI_INVALID_PARAMETER Buffer was invalid.
308 
309 **/
310 typedef
311 EFI_STATUS
312 (EFIAPI *EFI_FREE_POOL)(
313   IN  VOID                         *Buffer
314   );
315 
316 /**
317   Changes the runtime addressing mode of EFI firmware from physical to virtual.
318 
319   @param[in]  MemoryMapSize     The size in bytes of VirtualMap.
320   @param[in]  DescriptorSize    The size in bytes of an entry in the VirtualMap.
321   @param[in]  DescriptorVersion The version of the structure entries in VirtualMap.
322   @param[in]  VirtualMap        An array of memory descriptors which contain new virtual
323                                 address mapping information for all runtime ranges.
324 
325   @retval EFI_SUCCESS           The virtual address map has been applied.
326   @retval EFI_UNSUPPORTED       EFI firmware is not at runtime, or the EFI firmware is already in
327                                 virtual address mapped mode.
328   @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is invalid.
329   @retval EFI_NO_MAPPING        A virtual address was not supplied for a range in the memory
330                                 map that requires a mapping.
331   @retval EFI_NOT_FOUND         A virtual address was supplied for an address that is not found
332                                 in the memory map.
333   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
334                                 The platform should describe this runtime service as unsupported at runtime
335                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
336 
337 **/
338 typedef
339 EFI_STATUS
340 (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP)(
341   IN  UINTN                        MemoryMapSize,
342   IN  UINTN                        DescriptorSize,
343   IN  UINT32                       DescriptorVersion,
344   IN  EFI_MEMORY_DESCRIPTOR        *VirtualMap
345   );
346 
347 /**
348   Connects one or more drivers to a controller.
349 
350   @param[in]  ControllerHandle      The handle of the controller to which driver(s) are to be connected.
351   @param[in]  DriverImageHandle     A pointer to an ordered list handles that support the
352                                     EFI_DRIVER_BINDING_PROTOCOL.
353   @param[in]  RemainingDevicePath   A pointer to the device path that specifies a child of the
354                                     controller specified by ControllerHandle.
355   @param[in]  Recursive             If TRUE, then ConnectController() is called recursively
356                                     until the entire tree of controllers below the controller specified
357                                     by ControllerHandle have been created. If FALSE, then
358                                     the tree of controllers is only expanded one level.
359 
360   @retval EFI_SUCCESS           1) One or more drivers were connected to ControllerHandle.
361                                 2) No drivers were connected to ControllerHandle, but
362                                 RemainingDevicePath is not NULL, and it is an End Device
363                                 Path Node.
364   @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
365   @retval EFI_NOT_FOUND         1) There are no EFI_DRIVER_BINDING_PROTOCOL instances
366                                 present in the system.
367                                 2) No drivers were connected to ControllerHandle.
368   @retval EFI_SECURITY_VIOLATION
369                                 The user has no permission to start UEFI device drivers on the device path
370                                 associated with the ControllerHandle or specified by the RemainingDevicePath.
371 **/
372 typedef
373 EFI_STATUS
374 (EFIAPI *EFI_CONNECT_CONTROLLER)(
375   IN  EFI_HANDLE                    ControllerHandle,
376   IN  EFI_HANDLE                    *DriverImageHandle    OPTIONAL,
377   IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath  OPTIONAL,
378   IN  BOOLEAN                       Recursive
379   );
380 
381 /**
382   Disconnects one or more drivers from a controller.
383 
384   @param[in]  ControllerHandle      The handle of the controller from which driver(s) are to be disconnected.
385   @param[in]  DriverImageHandle     The driver to disconnect from ControllerHandle.
386                                     If DriverImageHandle is NULL, then all the drivers currently managing
387                                     ControllerHandle are disconnected from ControllerHandle.
388   @param[in]  ChildHandle           The handle of the child to destroy.
389                                     If ChildHandle is NULL, then all the children of ControllerHandle are
390                                     destroyed before the drivers are disconnected from ControllerHandle.
391 
392   @retval EFI_SUCCESS           1) One or more drivers were disconnected from the controller.
393                                 2) On entry, no drivers are managing ControllerHandle.
394                                 3) DriverImageHandle is not NULL, and on entry
395                                    DriverImageHandle is not managing ControllerHandle.
396   @retval EFI_INVALID_PARAMETER 1) ControllerHandle is NULL.
397                                 2) DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
398                                 3) ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
399                                 4) DriverImageHandle does not support the EFI_DRIVER_BINDING_PROTOCOL.
400   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to disconnect any drivers from
401                                 ControllerHandle.
402   @retval EFI_DEVICE_ERROR      The controller could not be disconnected because of a device error.
403 
404 **/
405 typedef
406 EFI_STATUS
407 (EFIAPI *EFI_DISCONNECT_CONTROLLER)(
408   IN  EFI_HANDLE                     ControllerHandle,
409   IN  EFI_HANDLE                     DriverImageHandle  OPTIONAL,
410   IN  EFI_HANDLE                     ChildHandle        OPTIONAL
411   );
412 
413 //
414 // ConvertPointer DebugDisposition type.
415 //
416 #define EFI_OPTIONAL_PTR  0x00000001
417 
418 /**
419   Determines the new virtual address that is to be used on subsequent memory accesses.
420 
421   @param[in]       DebugDisposition  Supplies type information for the pointer being converted.
422   @param[in, out]  Address           A pointer to a pointer that is to be fixed to be the value needed
423                                      for the new virtual address mappings being applied.
424 
425   @retval EFI_SUCCESS           The pointer pointed to by Address was modified.
426   @retval EFI_NOT_FOUND         The pointer pointed to by Address was not found to be part
427                                 of the current memory map. This is normally fatal.
428   @retval EFI_INVALID_PARAMETER Address is NULL.
429   @retval EFI_INVALID_PARAMETER *Address is NULL and DebugDisposition does
430                                 not have the EFI_OPTIONAL_PTR bit set.
431   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
432                                 The platform should describe this runtime service as unsupported at runtime
433                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
434 
435 **/
436 typedef
437 EFI_STATUS
438 (EFIAPI *EFI_CONVERT_POINTER)(
439   IN     UINTN                      DebugDisposition,
440   IN OUT VOID                       **Address
441   );
442 
443 //
444 // These types can be ORed together as needed - for example,
445 // EVT_TIMER might be Ored with EVT_NOTIFY_WAIT or
446 // EVT_NOTIFY_SIGNAL.
447 //
448 #define EVT_TIMER          0x80000000
449 #define EVT_RUNTIME        0x40000000
450 #define EVT_NOTIFY_WAIT    0x00000100
451 #define EVT_NOTIFY_SIGNAL  0x00000200
452 
453 #define EVT_SIGNAL_EXIT_BOOT_SERVICES      0x00000201
454 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE  0x60000202
455 
456 //
457 // The event's NotifyContext pointer points to a runtime memory
458 // address.
459 // The event is deprecated in UEFI2.0 and later specifications.
460 //
461 #define EVT_RUNTIME_CONTEXT  0x20000000
462 
463 /**
464   Invoke a notification event
465 
466   @param[in]  Event                 Event whose notification function is being invoked.
467   @param[in]  Context               The pointer to the notification function's context,
468                                     which is implementation-dependent.
469 
470 **/
471 typedef
472 VOID
473 (EFIAPI *EFI_EVENT_NOTIFY)(
474   IN  EFI_EVENT                Event,
475   IN  VOID                     *Context
476   );
477 
478 /**
479   Creates an event.
480 
481   @param[in]   Type             The type of event to create and its mode and attributes.
482   @param[in]   NotifyTpl        The task priority level of event notifications, if needed.
483   @param[in]   NotifyFunction   The pointer to the event's notification function, if any.
484   @param[in]   NotifyContext    The pointer to the notification function's context; corresponds to parameter
485                                 Context in the notification function.
486   @param[out]  Event            The pointer to the newly created event if the call succeeds; undefined
487                                 otherwise.
488 
489   @retval EFI_SUCCESS           The event structure was created.
490   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
491   @retval EFI_OUT_OF_RESOURCES  The event could not be allocated.
492 
493 **/
494 typedef
495 EFI_STATUS
496 (EFIAPI *EFI_CREATE_EVENT)(
497   IN  UINT32                       Type,
498   IN  EFI_TPL                      NotifyTpl,
499   IN  EFI_EVENT_NOTIFY             NotifyFunction OPTIONAL,
500   IN  VOID                         *NotifyContext OPTIONAL,
501   OUT EFI_EVENT                    *Event
502   );
503 
504 /**
505   Creates an event in a group.
506 
507   @param[in]   Type             The type of event to create and its mode and attributes.
508   @param[in]   NotifyTpl        The task priority level of event notifications,if needed.
509   @param[in]   NotifyFunction   The pointer to the event's notification function, if any.
510   @param[in]   NotifyContext    The pointer to the notification function's context; corresponds to parameter
511                                 Context in the notification function.
512   @param[in]   EventGroup       The pointer to the unique identifier of the group to which this event belongs.
513                                 If this is NULL, then the function behaves as if the parameters were passed
514                                 to CreateEvent.
515   @param[out]  Event            The pointer to the newly created event if the call succeeds; undefined
516                                 otherwise.
517 
518   @retval EFI_SUCCESS           The event structure was created.
519   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
520   @retval EFI_OUT_OF_RESOURCES  The event could not be allocated.
521 
522 **/
523 typedef
524 EFI_STATUS
525 (EFIAPI *EFI_CREATE_EVENT_EX)(
526   IN       UINT32                 Type,
527   IN       EFI_TPL                NotifyTpl,
528   IN       EFI_EVENT_NOTIFY       NotifyFunction OPTIONAL,
529   IN CONST VOID                   *NotifyContext OPTIONAL,
530   IN CONST EFI_GUID               *EventGroup    OPTIONAL,
531   OUT      EFI_EVENT              *Event
532   );
533 
534 ///
535 /// Timer delay types
536 ///
537 typedef enum {
538   ///
539   /// An event's timer settings is to be cancelled and not trigger time is to be set/
540   ///
541   TimerCancel,
542   ///
543   /// An event is to be signaled periodically at a specified interval from the current time.
544   ///
545   TimerPeriodic,
546   ///
547   /// An event is to be signaled once at a specified interval from the current time.
548   ///
549   TimerRelative
550 } EFI_TIMER_DELAY;
551 
552 /**
553   Sets the type of timer and the trigger time for a timer event.
554 
555   @param[in]  Event             The timer event that is to be signaled at the specified time.
556   @param[in]  Type              The type of time that is specified in TriggerTime.
557   @param[in]  TriggerTime       The number of 100ns units until the timer expires.
558                                 A TriggerTime of 0 is legal.
559                                 If Type is TimerRelative and TriggerTime is 0, then the timer
560                                 event will be signaled on the next timer tick.
561                                 If Type is TimerPeriodic and TriggerTime is 0, then the timer
562                                 event will be signaled on every timer tick.
563 
564   @retval EFI_SUCCESS           The event has been set to be signaled at the requested time.
565   @retval EFI_INVALID_PARAMETER Event or Type is not valid.
566 
567 **/
568 typedef
569 EFI_STATUS
570 (EFIAPI *EFI_SET_TIMER)(
571   IN  EFI_EVENT                Event,
572   IN  EFI_TIMER_DELAY          Type,
573   IN  UINT64                   TriggerTime
574   );
575 
576 /**
577   Signals an event.
578 
579   @param[in]  Event             The event to signal.
580 
581   @retval EFI_SUCCESS           The event has been signaled.
582 
583 **/
584 typedef
585 EFI_STATUS
586 (EFIAPI *EFI_SIGNAL_EVENT)(
587   IN  EFI_EVENT                Event
588   );
589 
590 /**
591   Stops execution until an event is signaled.
592 
593   @param[in]   NumberOfEvents   The number of events in the Event array.
594   @param[in]   Event            An array of EFI_EVENT.
595   @param[out]  Index            The pointer to the index of the event which satisfied the wait condition.
596 
597   @retval EFI_SUCCESS           The event indicated by Index was signaled.
598   @retval EFI_INVALID_PARAMETER 1) NumberOfEvents is 0.
599                                 2) The event indicated by Index is of type
600                                    EVT_NOTIFY_SIGNAL.
601   @retval EFI_UNSUPPORTED       The current TPL is not TPL_APPLICATION.
602 
603 **/
604 typedef
605 EFI_STATUS
606 (EFIAPI *EFI_WAIT_FOR_EVENT)(
607   IN  UINTN                    NumberOfEvents,
608   IN  EFI_EVENT                *Event,
609   OUT UINTN                    *Index
610   );
611 
612 /**
613   Closes an event.
614 
615   @param[in]  Event             The event to close.
616 
617   @retval EFI_SUCCESS           The event has been closed.
618 
619 **/
620 typedef
621 EFI_STATUS
622 (EFIAPI *EFI_CLOSE_EVENT)(
623   IN EFI_EVENT                Event
624   );
625 
626 /**
627   Checks whether an event is in the signaled state.
628 
629   @param[in]  Event             The event to check.
630 
631   @retval EFI_SUCCESS           The event is in the signaled state.
632   @retval EFI_NOT_READY         The event is not in the signaled state.
633   @retval EFI_INVALID_PARAMETER Event is of type EVT_NOTIFY_SIGNAL.
634 
635 **/
636 typedef
637 EFI_STATUS
638 (EFIAPI *EFI_CHECK_EVENT)(
639   IN EFI_EVENT                Event
640   );
641 
642 //
643 // Task priority level
644 //
645 #define TPL_APPLICATION  4
646 #define TPL_CALLBACK     8
647 #define TPL_NOTIFY       16
648 #define TPL_HIGH_LEVEL   31
649 
650 /**
651   Raises a task's priority level and returns its previous level.
652 
653   @param[in]  NewTpl          The new task priority level.
654 
655   @return Previous task priority level
656 
657 **/
658 typedef
659 EFI_TPL
660 (EFIAPI *EFI_RAISE_TPL)(
661   IN EFI_TPL      NewTpl
662   );
663 
664 /**
665   Restores a task's priority level to its previous value.
666 
667   @param[in]  OldTpl          The previous task priority level to restore.
668 
669 **/
670 typedef
671 VOID
672 (EFIAPI *EFI_RESTORE_TPL)(
673   IN EFI_TPL      OldTpl
674   );
675 
676 /**
677   Returns the value of a variable.
678 
679   @param[in]       VariableName  A Null-terminated string that is the name of the vendor's
680                                  variable.
681   @param[in]       VendorGuid    A unique identifier for the vendor.
682   @param[out]      Attributes    If not NULL, a pointer to the memory location to return the
683                                  attributes bitmask for the variable.
684   @param[in, out]  DataSize      On input, the size in bytes of the return Data buffer.
685                                  On output the size of data returned in Data.
686   @param[out]      Data          The buffer to return the contents of the variable. May be NULL
687                                  with a zero DataSize in order to determine the size buffer needed.
688 
689   @retval EFI_SUCCESS            The function completed successfully.
690   @retval EFI_NOT_FOUND          The variable was not found.
691   @retval EFI_BUFFER_TOO_SMALL   The DataSize is too small for the result.
692   @retval EFI_INVALID_PARAMETER  VariableName is NULL.
693   @retval EFI_INVALID_PARAMETER  VendorGuid is NULL.
694   @retval EFI_INVALID_PARAMETER  DataSize is NULL.
695   @retval EFI_INVALID_PARAMETER  The DataSize is not too small and Data is NULL.
696   @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.
697   @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.
698   @retval EFI_UNSUPPORTED        After ExitBootServices() has been called, this return code may be returned
699                                  if no variable storage is supported. The platform should describe this
700                                  runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE
701                                  configuration table.
702 
703 **/
704 typedef
705 EFI_STATUS
706 (EFIAPI *EFI_GET_VARIABLE)(
707   IN     CHAR16                      *VariableName,
708   IN     EFI_GUID                    *VendorGuid,
709   OUT    UINT32                      *Attributes     OPTIONAL,
710   IN OUT UINTN                       *DataSize,
711   OUT    VOID                        *Data           OPTIONAL
712   );
713 
714 /**
715   Enumerates the current variable names.
716 
717   @param[in, out]  VariableNameSize The size of the VariableName buffer. The size must be large
718                                     enough to fit input string supplied in VariableName buffer.
719   @param[in, out]  VariableName     On input, supplies the last VariableName that was returned
720                                     by GetNextVariableName(). On output, returns the Nullterminated
721                                     string of the current variable.
722   @param[in, out]  VendorGuid       On input, supplies the last VendorGuid that was returned by
723                                     GetNextVariableName(). On output, returns the
724                                     VendorGuid of the current variable.
725 
726   @retval EFI_SUCCESS           The function completed successfully.
727   @retval EFI_NOT_FOUND         The next variable was not found.
728   @retval EFI_BUFFER_TOO_SMALL  The VariableNameSize is too small for the result.
729                                 VariableNameSize has been updated with the size needed to complete the request.
730   @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
731   @retval EFI_INVALID_PARAMETER VariableName is NULL.
732   @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
733   @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
734                                 GUID of an existing variable.
735   @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
736                                 the input VariableName buffer.
737   @retval EFI_DEVICE_ERROR      The variable could not be retrieved due to a hardware error.
738   @retval EFI_UNSUPPORTED       After ExitBootServices() has been called, this return code may be returned
739                                 if no variable storage is supported. The platform should describe this
740                                 runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE
741                                 configuration table.
742 
743 **/
744 typedef
745 EFI_STATUS
746 (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME)(
747   IN OUT UINTN                    *VariableNameSize,
748   IN OUT CHAR16                   *VariableName,
749   IN OUT EFI_GUID                 *VendorGuid
750   );
751 
752 /**
753   Sets the value of a variable.
754 
755   @param[in]  VariableName       A Null-terminated string that is the name of the vendor's variable.
756                                  Each VariableName is unique for each VendorGuid. VariableName must
757                                  contain 1 or more characters. If VariableName is an empty string,
758                                  then EFI_INVALID_PARAMETER is returned.
759   @param[in]  VendorGuid         A unique identifier for the vendor.
760   @param[in]  Attributes         Attributes bitmask to set for the variable.
761   @param[in]  DataSize           The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE or
762                                  EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
763                                  causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
764                                  set, then a SetVariable() call with a DataSize of zero will not cause any change to
765                                  the variable value (the timestamp associated with the variable may be updated however
766                                  even if no new data value is provided,see the description of the
767                                  EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
768                                  be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
769   @param[in]  Data               The contents for the variable.
770 
771   @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as
772                                  defined by the Attributes.
773   @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits, name, and GUID was supplied, or the
774                                  DataSize exceeds the maximum allowed.
775   @retval EFI_INVALID_PARAMETER  VariableName is an empty string.
776   @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.
777   @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.
778   @retval EFI_WRITE_PROTECTED    The variable in question is read-only.
779   @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.
780   @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set,
781                                  but the AuthInfo does NOT pass the validation check carried out by the firmware.
782 
783   @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.
784   @retval EFI_UNSUPPORTED        This call is not supported by this platform at the time the call is made.
785                                  The platform should describe this runtime service as unsupported at runtime
786                                  via an EFI_RT_PROPERTIES_TABLE configuration table.
787 
788 **/
789 typedef
790 EFI_STATUS
791 (EFIAPI *EFI_SET_VARIABLE)(
792   IN  CHAR16                       *VariableName,
793   IN  EFI_GUID                     *VendorGuid,
794   IN  UINT32                       Attributes,
795   IN  UINTN                        DataSize,
796   IN  VOID                         *Data
797   );
798 
799 ///
800 /// This provides the capabilities of the
801 /// real time clock device as exposed through the EFI interfaces.
802 ///
803 typedef struct {
804   ///
805   /// Provides the reporting resolution of the real-time clock device in
806   /// counts per second. For a normal PC-AT CMOS RTC device, this
807   /// value would be 1 Hz, or 1, to indicate that the device only reports
808   /// the time to the resolution of 1 second.
809   ///
810   UINT32     Resolution;
811   ///
812   /// Provides the timekeeping accuracy of the real-time clock in an
813   /// error rate of 1E-6 parts per million. For a clock with an accuracy
814   /// of 50 parts per million, the value in this field would be
815   /// 50,000,000.
816   ///
817   UINT32     Accuracy;
818   ///
819   /// A TRUE indicates that a time set operation clears the device's
820   /// time below the Resolution reporting level. A FALSE
821   /// indicates that the state below the Resolution level of the
822   /// device is not cleared when the time is set. Normal PC-AT CMOS
823   /// RTC devices set this value to FALSE.
824   ///
825   BOOLEAN    SetsToZero;
826 } EFI_TIME_CAPABILITIES;
827 
828 /**
829   Returns the current time and date information, and the time-keeping capabilities
830   of the hardware platform.
831 
832   @param[out]  Time             A pointer to storage to receive a snapshot of the current time.
833   @param[out]  Capabilities     An optional pointer to a buffer to receive the real time clock
834                                 device's capabilities.
835 
836   @retval EFI_SUCCESS           The operation completed successfully.
837   @retval EFI_INVALID_PARAMETER Time is NULL.
838   @retval EFI_DEVICE_ERROR      The time could not be retrieved due to hardware error.
839   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
840                                 The platform should describe this runtime service as unsupported at runtime
841                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
842 
843 **/
844 typedef
845 EFI_STATUS
846 (EFIAPI *EFI_GET_TIME)(
847   OUT  EFI_TIME                    *Time,
848   OUT  EFI_TIME_CAPABILITIES       *Capabilities OPTIONAL
849   );
850 
851 /**
852   Sets the current local time and date information.
853 
854   @param[in]  Time              A pointer to the current time.
855 
856   @retval EFI_SUCCESS           The operation completed successfully.
857   @retval EFI_INVALID_PARAMETER A time field is out of range.
858   @retval EFI_DEVICE_ERROR      The time could not be set due due to hardware error.
859   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
860                                 The platform should describe this runtime service as unsupported at runtime
861                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
862 
863 **/
864 typedef
865 EFI_STATUS
866 (EFIAPI *EFI_SET_TIME)(
867   IN  EFI_TIME                     *Time
868   );
869 
870 /**
871   Returns the current wakeup alarm clock setting.
872 
873   @param[out]  Enabled          Indicates if the alarm is currently enabled or disabled.
874   @param[out]  Pending          Indicates if the alarm signal is pending and requires acknowledgement.
875   @param[out]  Time             The current alarm setting.
876 
877   @retval EFI_SUCCESS           The alarm settings were returned.
878   @retval EFI_INVALID_PARAMETER Enabled is NULL.
879   @retval EFI_INVALID_PARAMETER Pending is NULL.
880   @retval EFI_INVALID_PARAMETER Time is NULL.
881   @retval EFI_DEVICE_ERROR      The wakeup time could not be retrieved due to a hardware error.
882   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
883                                 The platform should describe this runtime service as unsupported at runtime
884                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
885 
886 **/
887 typedef
888 EFI_STATUS
889 (EFIAPI *EFI_GET_WAKEUP_TIME)(
890   OUT BOOLEAN                     *Enabled,
891   OUT BOOLEAN                     *Pending,
892   OUT EFI_TIME                    *Time
893   );
894 
895 /**
896   Sets the system wakeup alarm clock time.
897 
898   @param[in]  Enable            Enable or disable the wakeup alarm.
899   @param[in]  Time              If Enable is TRUE, the time to set the wakeup alarm for.
900                                 If Enable is FALSE, then this parameter is optional, and may be NULL.
901 
902   @retval EFI_SUCCESS           If Enable is TRUE, then the wakeup alarm was enabled. If
903                                 Enable is FALSE, then the wakeup alarm was disabled.
904   @retval EFI_INVALID_PARAMETER A time field is out of range.
905   @retval EFI_DEVICE_ERROR      The wakeup time could not be set due to a hardware error.
906   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
907                                 The platform should describe this runtime service as unsupported at runtime
908                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
909 
910 **/
911 typedef
912 EFI_STATUS
913 (EFIAPI *EFI_SET_WAKEUP_TIME)(
914   IN  BOOLEAN                      Enable,
915   IN  EFI_TIME                     *Time   OPTIONAL
916   );
917 
918 /**
919   Loads an EFI image into memory.
920 
921   @param[in]   BootPolicy        If TRUE, indicates that the request originates from the boot
922                                  manager, and that the boot manager is attempting to load
923                                  FilePath as a boot selection. Ignored if SourceBuffer is
924                                  not NULL.
925   @param[in]   ParentImageHandle The caller's image handle.
926   @param[in]   DevicePath        The DeviceHandle specific file path from which the image is
927                                  loaded.
928   @param[in]   SourceBuffer      If not NULL, a pointer to the memory location containing a copy
929                                  of the image to be loaded.
930   @param[in]   SourceSize        The size in bytes of SourceBuffer. Ignored if SourceBuffer is NULL.
931   @param[out]  ImageHandle       The pointer to the returned image handle that is created when the
932                                  image is successfully loaded.
933 
934   @retval EFI_SUCCESS            Image was loaded into memory correctly.
935   @retval EFI_NOT_FOUND          Both SourceBuffer and DevicePath are NULL.
936   @retval EFI_INVALID_PARAMETER  One or more parametes are invalid.
937   @retval EFI_UNSUPPORTED        The image type is not supported.
938   @retval EFI_OUT_OF_RESOURCES   Image was not loaded due to insufficient resources.
939   @retval EFI_LOAD_ERROR         Image was not loaded because the image format was corrupt or not
940                                  understood.
941   @retval EFI_DEVICE_ERROR       Image was not loaded because the device returned a read error.
942   @retval EFI_ACCESS_DENIED      Image was not loaded because the platform policy prohibits the
943                                  image from being loaded. NULL is returned in *ImageHandle.
944   @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
945                                  valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
946                                  platform policy specifies that the image should not be started.
947 **/
948 typedef
949 EFI_STATUS
950 (EFIAPI *EFI_IMAGE_LOAD)(
951   IN  BOOLEAN                      BootPolicy,
952   IN  EFI_HANDLE                   ParentImageHandle,
953   IN  EFI_DEVICE_PATH_PROTOCOL     *DevicePath   OPTIONAL,
954   IN  VOID                         *SourceBuffer OPTIONAL,
955   IN  UINTN                        SourceSize,
956   OUT EFI_HANDLE                   *ImageHandle
957   );
958 
959 /**
960   Transfers control to a loaded image's entry point.
961 
962   @param[in]   ImageHandle       Handle of image to be started.
963   @param[out]  ExitDataSize      The pointer to the size, in bytes, of ExitData.
964   @param[out]  ExitData          The pointer to a pointer to a data buffer that includes a Null-terminated
965                                  string, optionally followed by additional binary data.
966 
967   @retval EFI_INVALID_PARAMETER  ImageHandle is either an invalid image handle or the image
968                                  has already been initialized with StartImage.
969   @retval EFI_SECURITY_VIOLATION The current platform policy specifies that the image should not be started.
970   @return Exit code from image
971 
972 **/
973 typedef
974 EFI_STATUS
975 (EFIAPI *EFI_IMAGE_START)(
976   IN  EFI_HANDLE                  ImageHandle,
977   OUT UINTN                       *ExitDataSize,
978   OUT CHAR16                      **ExitData    OPTIONAL
979   );
980 
981 /**
982   Terminates a loaded EFI image and returns control to boot services.
983 
984   @param[in]  ImageHandle       Handle that identifies the image. This parameter is passed to the
985                                 image on entry.
986   @param[in]  ExitStatus        The image's exit code.
987   @param[in]  ExitDataSize      The size, in bytes, of ExitData. Ignored if ExitStatus is EFI_SUCCESS.
988   @param[in]  ExitData          The pointer to a data buffer that includes a Null-terminated string,
989                                 optionally followed by additional binary data. The string is a
990                                 description that the caller may use to further indicate the reason
991                                 for the image's exit. ExitData is only valid if ExitStatus
992                                 is something other than EFI_SUCCESS. The ExitData buffer
993                                 must be allocated by calling AllocatePool().
994 
995   @retval EFI_SUCCESS           The image specified by ImageHandle was unloaded.
996   @retval EFI_INVALID_PARAMETER The image specified by ImageHandle has been loaded and
997                                 started with LoadImage() and StartImage(), but the
998                                 image is not the currently executing image.
999 
1000 **/
1001 typedef
1002 EFI_STATUS
1003 (EFIAPI *EFI_EXIT)(
1004   IN  EFI_HANDLE                   ImageHandle,
1005   IN  EFI_STATUS                   ExitStatus,
1006   IN  UINTN                        ExitDataSize,
1007   IN  CHAR16                       *ExitData     OPTIONAL
1008   );
1009 
1010 /**
1011   Unloads an image.
1012 
1013   @param[in]  ImageHandle       Handle that identifies the image to be unloaded.
1014 
1015   @retval EFI_SUCCESS           The image has been unloaded.
1016   @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
1017 
1018 **/
1019 typedef
1020 EFI_STATUS
1021 (EFIAPI *EFI_IMAGE_UNLOAD)(
1022   IN  EFI_HANDLE                   ImageHandle
1023   );
1024 
1025 /**
1026   Terminates all boot services.
1027 
1028   @param[in]  ImageHandle       Handle that identifies the exiting image.
1029   @param[in]  MapKey            Key to the latest memory map.
1030 
1031   @retval EFI_SUCCESS           Boot services have been terminated.
1032   @retval EFI_INVALID_PARAMETER MapKey is incorrect.
1033 
1034 **/
1035 typedef
1036 EFI_STATUS
1037 (EFIAPI *EFI_EXIT_BOOT_SERVICES)(
1038   IN  EFI_HANDLE                   ImageHandle,
1039   IN  UINTN                        MapKey
1040   );
1041 
1042 /**
1043   Induces a fine-grained stall.
1044 
1045   @param[in]  Microseconds      The number of microseconds to stall execution.
1046 
1047   @retval EFI_SUCCESS           Execution was stalled at least the requested number of
1048                                 Microseconds.
1049 
1050 **/
1051 typedef
1052 EFI_STATUS
1053 (EFIAPI *EFI_STALL)(
1054   IN  UINTN                    Microseconds
1055   );
1056 
1057 /**
1058   Sets the system's watchdog timer.
1059 
1060   @param[in]  Timeout           The number of seconds to set the watchdog timer to.
1061   @param[in]  WatchdogCode      The numeric code to log on a watchdog timer timeout event.
1062   @param[in]  DataSize          The size, in bytes, of WatchdogData.
1063   @param[in]  WatchdogData      A data buffer that includes a Null-terminated string, optionally
1064                                 followed by additional binary data.
1065 
1066   @retval EFI_SUCCESS           The timeout has been set.
1067   @retval EFI_INVALID_PARAMETER The supplied WatchdogCode is invalid.
1068   @retval EFI_UNSUPPORTED       The system does not have a watchdog timer.
1069   @retval EFI_DEVICE_ERROR      The watchdog timer could not be programmed due to a hardware
1070                                 error.
1071 
1072 **/
1073 typedef
1074 EFI_STATUS
1075 (EFIAPI *EFI_SET_WATCHDOG_TIMER)(
1076   IN UINTN                    Timeout,
1077   IN UINT64                   WatchdogCode,
1078   IN UINTN                    DataSize,
1079   IN CHAR16                   *WatchdogData OPTIONAL
1080   );
1081 
1082 /**
1083   Resets the entire platform.
1084 
1085   @param[in]  ResetType         The type of reset to perform.
1086   @param[in]  ResetStatus       The status code for the reset.
1087   @param[in]  DataSize          The size, in bytes, of ResetData.
1088   @param[in]  ResetData         For a ResetType of EfiResetCold, EfiResetWarm, or
1089                                 EfiResetShutdown the data buffer starts with a Null-terminated
1090                                 string, optionally followed by additional binary data.
1091                                 The string is a description that the caller may use to further
1092                                 indicate the reason for the system reset.
1093                                 For a ResetType of EfiResetPlatformSpecific the data buffer
1094                                 also starts with a Null-terminated string that is followed
1095                                 by an EFI_GUID that describes the specific type of reset to perform.
1096 **/
1097 typedef
1098 VOID
1099 (EFIAPI *EFI_RESET_SYSTEM)(
1100   IN EFI_RESET_TYPE           ResetType,
1101   IN EFI_STATUS               ResetStatus,
1102   IN UINTN                    DataSize,
1103   IN VOID                     *ResetData OPTIONAL
1104   );
1105 
1106 /**
1107   Returns a monotonically increasing count for the platform.
1108 
1109   @param[out]  Count            The pointer to returned value.
1110 
1111   @retval EFI_SUCCESS           The next monotonic count was returned.
1112   @retval EFI_INVALID_PARAMETER Count is NULL.
1113   @retval EFI_DEVICE_ERROR      The device is not functioning properly.
1114 
1115 **/
1116 typedef
1117 EFI_STATUS
1118 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT)(
1119   OUT UINT64                  *Count
1120   );
1121 
1122 /**
1123   Returns the next high 32 bits of the platform's monotonic counter.
1124 
1125   @param[out]  HighCount        The pointer to returned value.
1126 
1127   @retval EFI_SUCCESS           The next high monotonic count was returned.
1128   @retval EFI_INVALID_PARAMETER HighCount is NULL.
1129   @retval EFI_DEVICE_ERROR      The device is not functioning properly.
1130   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
1131                                 The platform should describe this runtime service as unsupported at runtime
1132                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
1133 
1134 **/
1135 typedef
1136 EFI_STATUS
1137 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT)(
1138   OUT UINT32                  *HighCount
1139   );
1140 
1141 /**
1142   Computes and returns a 32-bit CRC for a data buffer.
1143 
1144   @param[in]   Data             A pointer to the buffer on which the 32-bit CRC is to be computed.
1145   @param[in]   DataSize         The number of bytes in the buffer Data.
1146   @param[out]  Crc32            The 32-bit CRC that was computed for the data buffer specified by Data
1147                                 and DataSize.
1148 
1149   @retval EFI_SUCCESS           The 32-bit CRC was computed for the data buffer and returned in
1150                                 Crc32.
1151   @retval EFI_INVALID_PARAMETER Data is NULL.
1152   @retval EFI_INVALID_PARAMETER Crc32 is NULL.
1153   @retval EFI_INVALID_PARAMETER DataSize is 0.
1154 
1155 **/
1156 typedef
1157 EFI_STATUS
1158 (EFIAPI *EFI_CALCULATE_CRC32)(
1159   IN  VOID                              *Data,
1160   IN  UINTN                             DataSize,
1161   OUT UINT32                            *Crc32
1162   );
1163 
1164 /**
1165   Copies the contents of one buffer to another buffer.
1166 
1167   @param[in]  Destination       The pointer to the destination buffer of the memory copy.
1168   @param[in]  Source            The pointer to the source buffer of the memory copy.
1169   @param[in]  Length            Number of bytes to copy from Source to Destination.
1170 
1171 **/
1172 typedef
1173 VOID
1174 (EFIAPI *EFI_COPY_MEM)(
1175   IN VOID     *Destination,
1176   IN VOID     *Source,
1177   IN UINTN    Length
1178   );
1179 
1180 /**
1181   The SetMem() function fills a buffer with a specified value.
1182 
1183   @param[in]  Buffer            The pointer to the buffer to fill.
1184   @param[in]  Size              Number of bytes in Buffer to fill.
1185   @param[in]  Value             Value to fill Buffer with.
1186 
1187 **/
1188 typedef
1189 VOID
1190 (EFIAPI *EFI_SET_MEM)(
1191   IN VOID     *Buffer,
1192   IN UINTN    Size,
1193   IN UINT8    Value
1194   );
1195 
1196 ///
1197 /// Enumeration of EFI Interface Types
1198 ///
1199 typedef enum {
1200   ///
1201   /// Indicates that the supplied protocol interface is supplied in native form.
1202   ///
1203   EFI_NATIVE_INTERFACE
1204 } EFI_INTERFACE_TYPE;
1205 
1206 /**
1207   Installs a protocol interface on a device handle. If the handle does not exist, it is created and added
1208   to the list of handles in the system. InstallMultipleProtocolInterfaces() performs
1209   more error checking than InstallProtocolInterface(), so it is recommended that
1210   InstallMultipleProtocolInterfaces() be used in place of
1211   InstallProtocolInterface()
1212 
1213   @param[in, out]  Handle         A pointer to the EFI_HANDLE on which the interface is to be installed.
1214   @param[in]       Protocol       The numeric ID of the protocol interface.
1215   @param[in]       InterfaceType  Indicates whether Interface is supplied in native form.
1216   @param[in]       Interface      A pointer to the protocol interface.
1217 
1218   @retval EFI_SUCCESS           The protocol interface was installed.
1219   @retval EFI_OUT_OF_RESOURCES  Space for a new handle could not be allocated.
1220   @retval EFI_INVALID_PARAMETER Handle is NULL.
1221   @retval EFI_INVALID_PARAMETER Protocol is NULL.
1222   @retval EFI_INVALID_PARAMETER InterfaceType is not EFI_NATIVE_INTERFACE.
1223   @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
1224 
1225 **/
1226 typedef
1227 EFI_STATUS
1228 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE)(
1229   IN OUT EFI_HANDLE               *Handle,
1230   IN     EFI_GUID                 *Protocol,
1231   IN     EFI_INTERFACE_TYPE       InterfaceType,
1232   IN     VOID                     *Interface
1233   );
1234 
1235 /**
1236   Installs one or more protocol interfaces into the boot services environment.
1237 
1238   @param[in, out]  Handle       The pointer to a handle to install the new protocol interfaces on,
1239                                 or a pointer to NULL if a new handle is to be allocated.
1240   @param  ...                   A variable argument list containing pairs of protocol GUIDs and protocol
1241                                 interfaces.
1242 
1243   @retval EFI_SUCCESS           All the protocol interface was installed.
1244   @retval EFI_OUT_OF_RESOURCES  There was not enough memory in pool to install all the protocols.
1245   @retval EFI_ALREADY_STARTED   A Device Path Protocol instance was passed in that is already present in
1246                                 the handle database.
1247   @retval EFI_INVALID_PARAMETER Handle is NULL.
1248   @retval EFI_INVALID_PARAMETER Protocol is already installed on the handle specified by Handle.
1249 
1250 **/
1251 typedef
1252 EFI_STATUS
1253 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)(
1254   IN OUT EFI_HANDLE           *Handle,
1255   ...
1256   );
1257 
1258 /**
1259   Reinstalls a protocol interface on a device handle.
1260 
1261   @param[in]  Handle            Handle on which the interface is to be reinstalled.
1262   @param[in]  Protocol          The numeric ID of the interface.
1263   @param[in]  OldInterface      A pointer to the old interface. NULL can be used if a structure is not
1264                                 associated with Protocol.
1265   @param[in]  NewInterface      A pointer to the new interface.
1266 
1267   @retval EFI_SUCCESS           The protocol interface was reinstalled.
1268   @retval EFI_NOT_FOUND         The OldInterface on the handle was not found.
1269   @retval EFI_ACCESS_DENIED     The protocol interface could not be reinstalled,
1270                                 because OldInterface is still being used by a
1271                                 driver that will not release it.
1272   @retval EFI_INVALID_PARAMETER Handle is NULL.
1273   @retval EFI_INVALID_PARAMETER Protocol is NULL.
1274 
1275 **/
1276 typedef
1277 EFI_STATUS
1278 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE)(
1279   IN EFI_HANDLE               Handle,
1280   IN EFI_GUID                 *Protocol,
1281   IN VOID                     *OldInterface,
1282   IN VOID                     *NewInterface
1283   );
1284 
1285 /**
1286   Removes a protocol interface from a device handle. It is recommended that
1287   UninstallMultipleProtocolInterfaces() be used in place of
1288   UninstallProtocolInterface().
1289 
1290   @param[in]  Handle            The handle on which the interface was installed.
1291   @param[in]  Protocol          The numeric ID of the interface.
1292   @param[in]  Interface         A pointer to the interface.
1293 
1294   @retval EFI_SUCCESS           The interface was removed.
1295   @retval EFI_NOT_FOUND         The interface was not found.
1296   @retval EFI_ACCESS_DENIED     The interface was not removed because the interface
1297                                 is still being used by a driver.
1298   @retval EFI_INVALID_PARAMETER Handle is NULL.
1299   @retval EFI_INVALID_PARAMETER Protocol is NULL.
1300 
1301 **/
1302 typedef
1303 EFI_STATUS
1304 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE)(
1305   IN EFI_HANDLE               Handle,
1306   IN EFI_GUID                 *Protocol,
1307   IN VOID                     *Interface
1308   );
1309 
1310 /**
1311   Removes one or more protocol interfaces into the boot services environment.
1312 
1313   @param[in]  Handle            The handle to remove the protocol interfaces from.
1314   @param  ...                   A variable argument list containing pairs of protocol GUIDs and
1315                                 protocol interfaces.
1316 
1317   @retval EFI_SUCCESS           All the protocol interfaces were removed.
1318   @retval EFI_INVALID_PARAMETER One of the protocol interfaces was not previously installed on Handle.
1319 
1320 **/
1321 typedef
1322 EFI_STATUS
1323 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)(
1324   IN EFI_HANDLE           Handle,
1325   ...
1326   );
1327 
1328 /**
1329   Queries a handle to determine if it supports a specified protocol.
1330 
1331   @param[in]   Handle           The handle being queried.
1332   @param[in]   Protocol         The published unique identifier of the protocol.
1333   @param[out]  Interface        Supplies the address where a pointer to the corresponding Protocol
1334                                 Interface is returned.
1335 
1336   @retval EFI_SUCCESS           The interface information for the specified protocol was returned.
1337   @retval EFI_UNSUPPORTED       The device does not support the specified protocol.
1338   @retval EFI_INVALID_PARAMETER Handle is NULL.
1339   @retval EFI_INVALID_PARAMETER Protocol is NULL.
1340   @retval EFI_INVALID_PARAMETER Interface is NULL.
1341 
1342 **/
1343 typedef
1344 EFI_STATUS
1345 (EFIAPI *EFI_HANDLE_PROTOCOL)(
1346   IN  EFI_HANDLE               Handle,
1347   IN  EFI_GUID                 *Protocol,
1348   OUT VOID                     **Interface
1349   );
1350 
1351 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL   0x00000001
1352 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL         0x00000002
1353 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL        0x00000004
1354 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER  0x00000008
1355 #define EFI_OPEN_PROTOCOL_BY_DRIVER            0x00000010
1356 #define EFI_OPEN_PROTOCOL_EXCLUSIVE            0x00000020
1357 
1358 /**
1359   Queries a handle to determine if it supports a specified protocol. If the protocol is supported by the
1360   handle, it opens the protocol on behalf of the calling agent.
1361 
1362   @param[in]   Handle           The handle for the protocol interface that is being opened.
1363   @param[in]   Protocol         The published unique identifier of the protocol.
1364   @param[out]  Interface        Supplies the address where a pointer to the corresponding Protocol
1365                                 Interface is returned.
1366   @param[in]   AgentHandle      The handle of the agent that is opening the protocol interface
1367                                 specified by Protocol and Interface.
1368   @param[in]   ControllerHandle If the agent that is opening a protocol is a driver that follows the
1369                                 UEFI Driver Model, then this parameter is the controller handle
1370                                 that requires the protocol interface. If the agent does not follow
1371                                 the UEFI Driver Model, then this parameter is optional and may
1372                                 be NULL.
1373   @param[in]   Attributes       The open mode of the protocol interface specified by Handle
1374                                 and Protocol.
1375 
1376   @retval EFI_SUCCESS           An item was added to the open list for the protocol interface, and the
1377                                 protocol interface was returned in Interface.
1378   @retval EFI_UNSUPPORTED       Handle does not support Protocol.
1379   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1380   @retval EFI_ACCESS_DENIED     Required attributes can't be supported in current environment.
1381   @retval EFI_ALREADY_STARTED   Item on the open list already has requierd attributes whose agent
1382                                 handle is the same as AgentHandle.
1383 
1384 **/
1385 typedef
1386 EFI_STATUS
1387 (EFIAPI *EFI_OPEN_PROTOCOL)(
1388   IN  EFI_HANDLE                Handle,
1389   IN  EFI_GUID                  *Protocol,
1390   OUT VOID                      **Interface  OPTIONAL,
1391   IN  EFI_HANDLE                AgentHandle,
1392   IN  EFI_HANDLE                ControllerHandle,
1393   IN  UINT32                    Attributes
1394   );
1395 
1396 /**
1397   Closes a protocol on a handle that was opened using OpenProtocol().
1398 
1399   @param[in]  Handle            The handle for the protocol interface that was previously opened
1400                                 with OpenProtocol(), and is now being closed.
1401   @param[in]  Protocol          The published unique identifier of the protocol.
1402   @param[in]  AgentHandle       The handle of the agent that is closing the protocol interface.
1403   @param[in]  ControllerHandle  If the agent that opened a protocol is a driver that follows the
1404                                 UEFI Driver Model, then this parameter is the controller handle
1405                                 that required the protocol interface.
1406 
1407   @retval EFI_SUCCESS           The protocol instance was closed.
1408   @retval EFI_INVALID_PARAMETER 1) Handle is NULL.
1409                                 2) AgentHandle is NULL.
1410                                 3) ControllerHandle is not NULL and ControllerHandle is not a valid EFI_HANDLE.
1411                                 4) Protocol is NULL.
1412   @retval EFI_NOT_FOUND         1) Handle does not support the protocol specified by Protocol.
1413                                 2) The protocol interface specified by Handle and Protocol is not
1414                                    currently open by AgentHandle and ControllerHandle.
1415 
1416 **/
1417 typedef
1418 EFI_STATUS
1419 (EFIAPI *EFI_CLOSE_PROTOCOL)(
1420   IN EFI_HANDLE               Handle,
1421   IN EFI_GUID                 *Protocol,
1422   IN EFI_HANDLE               AgentHandle,
1423   IN EFI_HANDLE               ControllerHandle
1424   );
1425 
1426 ///
1427 /// EFI Oprn Protocol Information Entry
1428 ///
1429 typedef struct {
1430   EFI_HANDLE    AgentHandle;
1431   EFI_HANDLE    ControllerHandle;
1432   UINT32        Attributes;
1433   UINT32        OpenCount;
1434 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
1435 
1436 /**
1437   Retrieves the list of agents that currently have a protocol interface opened.
1438 
1439   @param[in]   Handle           The handle for the protocol interface that is being queried.
1440   @param[in]   Protocol         The published unique identifier of the protocol.
1441   @param[out]  EntryBuffer      A pointer to a buffer of open protocol information in the form of
1442                                 EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
1443   @param[out]  EntryCount       A pointer to the number of entries in EntryBuffer.
1444 
1445   @retval EFI_SUCCESS           The open protocol information was returned in EntryBuffer, and the
1446                                 number of entries was returned EntryCount.
1447   @retval EFI_OUT_OF_RESOURCES  There are not enough resources available to allocate EntryBuffer.
1448   @retval EFI_NOT_FOUND         Handle does not support the protocol specified by Protocol.
1449 
1450 **/
1451 typedef
1452 EFI_STATUS
1453 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION)(
1454   IN  EFI_HANDLE                          Handle,
1455   IN  EFI_GUID                            *Protocol,
1456   OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
1457   OUT UINTN                               *EntryCount
1458   );
1459 
1460 /**
1461   Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
1462   from pool.
1463 
1464   @param[in]   Handle              The handle from which to retrieve the list of protocol interface
1465                                    GUIDs.
1466   @param[out]  ProtocolBuffer      A pointer to the list of protocol interface GUID pointers that are
1467                                    installed on Handle.
1468   @param[out]  ProtocolBufferCount A pointer to the number of GUID pointers present in
1469                                    ProtocolBuffer.
1470 
1471   @retval EFI_SUCCESS           The list of protocol interface GUIDs installed on Handle was returned in
1472                                 ProtocolBuffer. The number of protocol interface GUIDs was
1473                                 returned in ProtocolBufferCount.
1474   @retval EFI_OUT_OF_RESOURCES  There is not enough pool memory to store the results.
1475   @retval EFI_INVALID_PARAMETER Handle is NULL.
1476   @retval EFI_INVALID_PARAMETER Handle is not a valid EFI_HANDLE.
1477   @retval EFI_INVALID_PARAMETER ProtocolBuffer is NULL.
1478   @retval EFI_INVALID_PARAMETER ProtocolBufferCount is NULL.
1479 
1480 **/
1481 typedef
1482 EFI_STATUS
1483 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE)(
1484   IN  EFI_HANDLE      Handle,
1485   OUT EFI_GUID        ***ProtocolBuffer,
1486   OUT UINTN           *ProtocolBufferCount
1487   );
1488 
1489 /**
1490   Creates an event that is to be signaled whenever an interface is installed for a specified protocol.
1491 
1492   @param[in]   Protocol         The numeric ID of the protocol for which the event is to be registered.
1493   @param[in]   Event            Event that is to be signaled whenever a protocol interface is registered
1494                                 for Protocol.
1495   @param[out]  Registration     A pointer to a memory location to receive the registration value.
1496 
1497   @retval EFI_SUCCESS           The notification event has been registered.
1498   @retval EFI_OUT_OF_RESOURCES  Space for the notification event could not be allocated.
1499   @retval EFI_INVALID_PARAMETER Protocol is NULL.
1500   @retval EFI_INVALID_PARAMETER Event is NULL.
1501   @retval EFI_INVALID_PARAMETER Registration is NULL.
1502 
1503 **/
1504 typedef
1505 EFI_STATUS
1506 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY)(
1507   IN  EFI_GUID                 *Protocol,
1508   IN  EFI_EVENT                Event,
1509   OUT VOID                     **Registration
1510   );
1511 
1512 ///
1513 /// Enumeration of EFI Locate Search Types
1514 ///
1515 typedef enum {
1516   ///
1517   /// Retrieve all the handles in the handle database.
1518   ///
1519   AllHandles,
1520   ///
1521   /// Retrieve the next handle fron a RegisterProtocolNotify() event.
1522   ///
1523   ByRegisterNotify,
1524   ///
1525   /// Retrieve the set of handles from the handle database that support a
1526   /// specified protocol.
1527   ///
1528   ByProtocol
1529 } EFI_LOCATE_SEARCH_TYPE;
1530 
1531 /**
1532   Returns an array of handles that support a specified protocol.
1533 
1534   @param[in]       SearchType   Specifies which handle(s) are to be returned.
1535   @param[in]       Protocol     Specifies the protocol to search by.
1536   @param[in]       SearchKey    Specifies the search key.
1537   @param[in, out]  BufferSize   On input, the size in bytes of Buffer. On output, the size in bytes of
1538                                 the array returned in Buffer (if the buffer was large enough) or the
1539                                 size, in bytes, of the buffer needed to obtain the array (if the buffer was
1540                                 not large enough).
1541   @param[out]      Buffer       The buffer in which the array is returned.
1542 
1543   @retval EFI_SUCCESS           The array of handles was returned.
1544   @retval EFI_NOT_FOUND         No handles match the search.
1545   @retval EFI_BUFFER_TOO_SMALL  The BufferSize is too small for the result.
1546   @retval EFI_INVALID_PARAMETER SearchType is not a member of EFI_LOCATE_SEARCH_TYPE.
1547   @retval EFI_INVALID_PARAMETER SearchType is ByRegisterNotify and SearchKey is NULL.
1548   @retval EFI_INVALID_PARAMETER SearchType is ByProtocol and Protocol is NULL.
1549   @retval EFI_INVALID_PARAMETER One or more matches are found and BufferSize is NULL.
1550   @retval EFI_INVALID_PARAMETER BufferSize is large enough for the result and Buffer is NULL.
1551 
1552 **/
1553 typedef
1554 EFI_STATUS
1555 (EFIAPI *EFI_LOCATE_HANDLE)(
1556   IN     EFI_LOCATE_SEARCH_TYPE   SearchType,
1557   IN     EFI_GUID                 *Protocol     OPTIONAL,
1558   IN     VOID                     *SearchKey    OPTIONAL,
1559   IN OUT UINTN                    *BufferSize,
1560   OUT    EFI_HANDLE               *Buffer
1561   );
1562 
1563 /**
1564   Locates the handle to a device on the device path that supports the specified protocol.
1565 
1566   @param[in]       Protocol     Specifies the protocol to search for.
1567   @param[in, out]  DevicePath   On input, a pointer to a pointer to the device path. On output, the device
1568                                 path pointer is modified to point to the remaining part of the device
1569                                 path.
1570   @param[out]      Device       A pointer to the returned device handle.
1571 
1572   @retval EFI_SUCCESS           The resulting handle was returned.
1573   @retval EFI_NOT_FOUND         No handles match the search.
1574   @retval EFI_INVALID_PARAMETER Protocol is NULL.
1575   @retval EFI_INVALID_PARAMETER DevicePath is NULL.
1576   @retval EFI_INVALID_PARAMETER A handle matched the search and Device is NULL.
1577 
1578 **/
1579 typedef
1580 EFI_STATUS
1581 (EFIAPI *EFI_LOCATE_DEVICE_PATH)(
1582   IN     EFI_GUID                         *Protocol,
1583   IN OUT EFI_DEVICE_PATH_PROTOCOL         **DevicePath,
1584   OUT    EFI_HANDLE                       *Device
1585   );
1586 
1587 /**
1588   Adds, updates, or removes a configuration table entry from the EFI System Table.
1589 
1590   @param[in]  Guid              A pointer to the GUID for the entry to add, update, or remove.
1591   @param[in]  Table             A pointer to the configuration table for the entry to add, update, or
1592                                 remove. May be NULL.
1593 
1594   @retval EFI_SUCCESS           The (Guid, Table) pair was added, updated, or removed.
1595   @retval EFI_NOT_FOUND         An attempt was made to delete a nonexistent entry.
1596   @retval EFI_INVALID_PARAMETER Guid is NULL.
1597   @retval EFI_OUT_OF_RESOURCES  There is not enough memory available to complete the operation.
1598 
1599 **/
1600 typedef
1601 EFI_STATUS
1602 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE)(
1603   IN EFI_GUID                 *Guid,
1604   IN VOID                     *Table
1605   );
1606 
1607 /**
1608   Returns an array of handles that support the requested protocol in a buffer allocated from pool.
1609 
1610   @param[in]       SearchType   Specifies which handle(s) are to be returned.
1611   @param[in]       Protocol     Provides the protocol to search by.
1612                                 This parameter is only valid for a SearchType of ByProtocol.
1613   @param[in]       SearchKey    Supplies the search key depending on the SearchType.
1614   @param[out]      NoHandles    The number of handles returned in Buffer.
1615   @param[out]      Buffer       A pointer to the buffer to return the requested array of handles that
1616                                 support Protocol.
1617 
1618   @retval EFI_SUCCESS           The array of handles was returned in Buffer, and the number of
1619                                 handles in Buffer was returned in NoHandles.
1620   @retval EFI_NOT_FOUND         No handles match the search.
1621   @retval EFI_OUT_OF_RESOURCES  There is not enough pool memory to store the matching results.
1622   @retval EFI_INVALID_PARAMETER NoHandles is NULL.
1623   @retval EFI_INVALID_PARAMETER Buffer is NULL.
1624 
1625 **/
1626 typedef
1627 EFI_STATUS
1628 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER)(
1629   IN     EFI_LOCATE_SEARCH_TYPE       SearchType,
1630   IN     EFI_GUID                     *Protocol       OPTIONAL,
1631   IN     VOID                         *SearchKey      OPTIONAL,
1632   OUT    UINTN                        *NoHandles,
1633   OUT    EFI_HANDLE                   **Buffer
1634   );
1635 
1636 /**
1637   Returns the first protocol instance that matches the given protocol.
1638 
1639   @param[in]  Protocol          Provides the protocol to search for.
1640   @param[in]  Registration      Optional registration key returned from
1641                                 RegisterProtocolNotify().
1642   @param[out]  Interface        On return, a pointer to the first interface that matches Protocol and
1643                                 Registration.
1644 
1645   @retval EFI_SUCCESS           A protocol instance matching Protocol was found and returned in
1646                                 Interface.
1647   @retval EFI_NOT_FOUND         No protocol instances were found that match Protocol and
1648                                 Registration.
1649   @retval EFI_INVALID_PARAMETER Interface is NULL.
1650                                 Protocol is NULL.
1651 
1652 **/
1653 typedef
1654 EFI_STATUS
1655 (EFIAPI *EFI_LOCATE_PROTOCOL)(
1656   IN  EFI_GUID  *Protocol,
1657   IN  VOID      *Registration  OPTIONAL,
1658   OUT VOID      **Interface
1659   );
1660 
1661 ///
1662 /// EFI Capsule Block Descriptor
1663 ///
1664 typedef struct {
1665   ///
1666   /// Length in bytes of the data pointed to by DataBlock/ContinuationPointer.
1667   ///
1668   UINT64    Length;
1669   union {
1670     ///
1671     /// Physical address of the data block. This member of the union is
1672     /// used if Length is not equal to zero.
1673     ///
1674     EFI_PHYSICAL_ADDRESS    DataBlock;
1675     ///
1676     /// Physical address of another block of
1677     /// EFI_CAPSULE_BLOCK_DESCRIPTOR structures. This
1678     /// member of the union is used if Length is equal to zero. If
1679     /// ContinuationPointer is zero this entry represents the end of the list.
1680     ///
1681     EFI_PHYSICAL_ADDRESS    ContinuationPointer;
1682   } Union;
1683 } EFI_CAPSULE_BLOCK_DESCRIPTOR;
1684 
1685 ///
1686 /// EFI Capsule Header.
1687 ///
1688 typedef struct {
1689   ///
1690   /// A GUID that defines the contents of a capsule.
1691   ///
1692   EFI_GUID    CapsuleGuid;
1693   ///
1694   /// The size of the capsule header. This may be larger than the size of
1695   /// the EFI_CAPSULE_HEADER since CapsuleGuid may imply
1696   /// extended header entries
1697   ///
1698   UINT32      HeaderSize;
1699   ///
1700   /// Bit-mapped list describing the capsule attributes. The Flag values
1701   /// of 0x0000 - 0xFFFF are defined by CapsuleGuid. Flag values
1702   /// of 0x10000 - 0xFFFFFFFF are defined by this specification
1703   ///
1704   UINT32      Flags;
1705   ///
1706   /// Size in bytes of the capsule (including capsule header).
1707   ///
1708   UINT32      CapsuleImageSize;
1709 } EFI_CAPSULE_HEADER;
1710 
1711 ///
1712 /// The EFI System Table entry must point to an array of capsules
1713 /// that contain the same CapsuleGuid value. The array must be
1714 /// prefixed by a UINT32 that represents the size of the array of capsules.
1715 ///
1716 typedef struct {
1717   ///
1718   /// the size of the array of capsules.
1719   ///
1720   UINT32    CapsuleArrayNumber;
1721   ///
1722   /// Point to an array of capsules that contain the same CapsuleGuid value.
1723   ///
1724   VOID      *CapsulePtr[1];
1725 } EFI_CAPSULE_TABLE;
1726 
1727 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET   0x00010000
1728 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE  0x00020000
1729 #define CAPSULE_FLAGS_INITIATE_RESET         0x00040000
1730 
1731 /**
1732   Passes capsules to the firmware with both virtual and physical mapping. Depending on the intended
1733   consumption, the firmware may process the capsule immediately. If the payload should persist
1734   across a system reset, the reset value returned from EFI_QueryCapsuleCapabilities must
1735   be passed into ResetSystem() and will cause the capsule to be processed by the firmware as
1736   part of the reset process.
1737 
1738   @param[in]  CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
1739                                  being passed into update capsule.
1740   @param[in]  CapsuleCount       Number of pointers to EFI_CAPSULE_HEADER in
1741                                  CaspuleHeaderArray.
1742   @param[in]  ScatterGatherList  Physical pointer to a set of
1743                                  EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the
1744                                  location in physical memory of a set of capsules.
1745 
1746   @retval EFI_SUCCESS           Valid capsule was passed. If
1747                                 CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the
1748                                 capsule has been successfully processed by the firmware.
1749   @retval EFI_INVALID_PARAMETER CapsuleSize is NULL, or an incompatible set of flags were
1750                                 set in the capsule header.
1751   @retval EFI_INVALID_PARAMETER CapsuleCount is 0.
1752   @retval EFI_DEVICE_ERROR      The capsule update was started, but failed due to a device error.
1753   @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform.
1754   @retval EFI_OUT_OF_RESOURCES  When ExitBootServices() has been previously called this error indicates the capsule
1755                                 is compatible with this platform but is not capable of being submitted or processed
1756                                 in runtime. The caller may resubmit the capsule prior to ExitBootServices().
1757   @retval EFI_OUT_OF_RESOURCES  When ExitBootServices() has not been previously called then this error indicates
1758                                 the capsule is compatible with this platform but there are insufficient resources to process.
1759   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
1760                                 The platform should describe this runtime service as unsupported at runtime
1761                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
1762 
1763 **/
1764 typedef
1765 EFI_STATUS
1766 (EFIAPI *EFI_UPDATE_CAPSULE)(
1767   IN EFI_CAPSULE_HEADER     **CapsuleHeaderArray,
1768   IN UINTN                  CapsuleCount,
1769   IN EFI_PHYSICAL_ADDRESS   ScatterGatherList   OPTIONAL
1770   );
1771 
1772 /**
1773   Returns if the capsule can be supported via UpdateCapsule().
1774 
1775   @param[in]   CapsuleHeaderArray  Virtual pointer to an array of virtual pointers to the capsules
1776                                    being passed into update capsule.
1777   @param[in]   CapsuleCount        Number of pointers to EFI_CAPSULE_HEADER in
1778                                    CaspuleHeaderArray.
1779   @param[out]  MaxiumCapsuleSize   On output the maximum size that UpdateCapsule() can
1780                                    support as an argument to UpdateCapsule() via
1781                                    CapsuleHeaderArray and ScatterGatherList.
1782   @param[out]  ResetType           Returns the type of reset required for the capsule update.
1783 
1784   @retval EFI_SUCCESS           Valid answer returned.
1785   @retval EFI_UNSUPPORTED       The capsule type is not supported on this platform, and
1786                                 MaximumCapsuleSize and ResetType are undefined.
1787   @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
1788   @retval EFI_OUT_OF_RESOURCES  When ExitBootServices() has been previously called this error indicates the capsule
1789                                 is compatible with this platform but is not capable of being submitted or processed
1790                                 in runtime. The caller may resubmit the capsule prior to ExitBootServices().
1791   @retval EFI_OUT_OF_RESOURCES  When ExitBootServices() has not been previously called then this error indicates
1792                                 the capsule is compatible with this platform but there are insufficient resources to process.
1793   @retval EFI_UNSUPPORTED       This call is not supported by this platform at the time the call is made.
1794                                 The platform should describe this runtime service as unsupported at runtime
1795                                 via an EFI_RT_PROPERTIES_TABLE configuration table.
1796 
1797 **/
1798 typedef
1799 EFI_STATUS
1800 (EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES)(
1801   IN  EFI_CAPSULE_HEADER     **CapsuleHeaderArray,
1802   IN  UINTN                  CapsuleCount,
1803   OUT UINT64                 *MaximumCapsuleSize,
1804   OUT EFI_RESET_TYPE         *ResetType
1805   );
1806 
1807 /**
1808   Returns information about the EFI variables.
1809 
1810   @param[in]   Attributes                   Attributes bitmask to specify the type of variables on
1811                                             which to return information.
1812   @param[out]  MaximumVariableStorageSize   On output the maximum size of the storage space
1813                                             available for the EFI variables associated with the
1814                                             attributes specified.
1815   @param[out]  RemainingVariableStorageSize Returns the remaining size of the storage space
1816                                             available for the EFI variables associated with the
1817                                             attributes specified.
1818   @param[out]  MaximumVariableSize          Returns the maximum size of the individual EFI
1819                                             variables associated with the attributes specified.
1820 
1821   @retval EFI_SUCCESS                  Valid answer returned.
1822   @retval EFI_INVALID_PARAMETER        An invalid combination of attribute bits was supplied
1823   @retval EFI_UNSUPPORTED              The attribute is not supported on this platform, and the
1824                                        MaximumVariableStorageSize,
1825                                        RemainingVariableStorageSize, MaximumVariableSize
1826                                        are undefined.
1827 
1828 **/
1829 typedef
1830 EFI_STATUS
1831 (EFIAPI *EFI_QUERY_VARIABLE_INFO)(
1832   IN  UINT32            Attributes,
1833   OUT UINT64            *MaximumVariableStorageSize,
1834   OUT UINT64            *RemainingVariableStorageSize,
1835   OUT UINT64            *MaximumVariableSize
1836   );
1837 
1838 //
1839 // Firmware should stop at a firmware user interface on next boot
1840 //
1841 #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI                    0x0000000000000001
1842 #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION             0x0000000000000002
1843 #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED  0x0000000000000004
1844 #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED            0x0000000000000008
1845 #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED     0x0000000000000010
1846 #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY          0x0000000000000040
1847 #define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH         0x0000000000000080
1848 
1849 //
1850 // EFI Runtime Services Table
1851 //
1852 #define EFI_SYSTEM_TABLE_SIGNATURE       SIGNATURE_64 ('I','B','I',' ','S','Y','S','T')
1853 #define EFI_2_110_SYSTEM_TABLE_REVISION  ((2 << 16) | (110))
1854 #define EFI_2_100_SYSTEM_TABLE_REVISION  ((2 << 16) | (100))
1855 #define EFI_2_90_SYSTEM_TABLE_REVISION   ((2 << 16) | (90))
1856 #define EFI_2_80_SYSTEM_TABLE_REVISION   ((2 << 16) | (80))
1857 #define EFI_2_70_SYSTEM_TABLE_REVISION   ((2 << 16) | (70))
1858 #define EFI_2_60_SYSTEM_TABLE_REVISION   ((2 << 16) | (60))
1859 #define EFI_2_50_SYSTEM_TABLE_REVISION   ((2 << 16) | (50))
1860 #define EFI_2_40_SYSTEM_TABLE_REVISION   ((2 << 16) | (40))
1861 #define EFI_2_31_SYSTEM_TABLE_REVISION   ((2 << 16) | (31))
1862 #define EFI_2_30_SYSTEM_TABLE_REVISION   ((2 << 16) | (30))
1863 #define EFI_2_20_SYSTEM_TABLE_REVISION   ((2 << 16) | (20))
1864 #define EFI_2_10_SYSTEM_TABLE_REVISION   ((2 << 16) | (10))
1865 #define EFI_2_00_SYSTEM_TABLE_REVISION   ((2 << 16) | (00))
1866 #define EFI_1_10_SYSTEM_TABLE_REVISION   ((1 << 16) | (10))
1867 #define EFI_1_02_SYSTEM_TABLE_REVISION   ((1 << 16) | (02))
1868 #define EFI_SYSTEM_TABLE_REVISION        EFI_2_70_SYSTEM_TABLE_REVISION
1869 #define EFI_SPECIFICATION_VERSION        EFI_SYSTEM_TABLE_REVISION
1870 
1871 #define EFI_RUNTIME_SERVICES_SIGNATURE  SIGNATURE_64 ('R','U','N','T','S','E','R','V')
1872 #define EFI_RUNTIME_SERVICES_REVISION   EFI_SPECIFICATION_VERSION
1873 
1874 ///
1875 /// EFI Runtime Services Table.
1876 ///
1877 typedef struct {
1878   ///
1879   /// The table header for the EFI Runtime Services Table.
1880   ///
1881   EFI_TABLE_HEADER                  Hdr;
1882 
1883   //
1884   // Time Services
1885   //
1886   EFI_GET_TIME                      GetTime;
1887   EFI_SET_TIME                      SetTime;
1888   EFI_GET_WAKEUP_TIME               GetWakeupTime;
1889   EFI_SET_WAKEUP_TIME               SetWakeupTime;
1890 
1891   //
1892   // Virtual Memory Services
1893   //
1894   EFI_SET_VIRTUAL_ADDRESS_MAP       SetVirtualAddressMap;
1895   EFI_CONVERT_POINTER               ConvertPointer;
1896 
1897   //
1898   // Variable Services
1899   //
1900   EFI_GET_VARIABLE                  GetVariable;
1901   EFI_GET_NEXT_VARIABLE_NAME        GetNextVariableName;
1902   EFI_SET_VARIABLE                  SetVariable;
1903 
1904   //
1905   // Miscellaneous Services
1906   //
1907   EFI_GET_NEXT_HIGH_MONO_COUNT      GetNextHighMonotonicCount;
1908   EFI_RESET_SYSTEM                  ResetSystem;
1909 
1910   //
1911   // UEFI 2.0 Capsule Services
1912   //
1913   EFI_UPDATE_CAPSULE                UpdateCapsule;
1914   EFI_QUERY_CAPSULE_CAPABILITIES    QueryCapsuleCapabilities;
1915 
1916   //
1917   // Miscellaneous UEFI 2.0 Service
1918   //
1919   EFI_QUERY_VARIABLE_INFO           QueryVariableInfo;
1920 } EFI_RUNTIME_SERVICES;
1921 
1922 #define EFI_BOOT_SERVICES_SIGNATURE  SIGNATURE_64 ('B','O','O','T','S','E','R','V')
1923 #define EFI_BOOT_SERVICES_REVISION   EFI_SPECIFICATION_VERSION
1924 
1925 ///
1926 /// EFI Boot Services Table.
1927 ///
1928 typedef struct {
1929   ///
1930   /// The table header for the EFI Boot Services Table.
1931   ///
1932   EFI_TABLE_HEADER                              Hdr;
1933 
1934   //
1935   // Task Priority Services
1936   //
1937   EFI_RAISE_TPL                                 RaiseTPL;
1938   EFI_RESTORE_TPL                               RestoreTPL;
1939 
1940   //
1941   // Memory Services
1942   //
1943   EFI_ALLOCATE_PAGES                            AllocatePages;
1944   EFI_FREE_PAGES                                FreePages;
1945   EFI_GET_MEMORY_MAP                            GetMemoryMap;
1946   EFI_ALLOCATE_POOL                             AllocatePool;
1947   EFI_FREE_POOL                                 FreePool;
1948 
1949   //
1950   // Event & Timer Services
1951   //
1952   EFI_CREATE_EVENT                              CreateEvent;
1953   EFI_SET_TIMER                                 SetTimer;
1954   EFI_WAIT_FOR_EVENT                            WaitForEvent;
1955   EFI_SIGNAL_EVENT                              SignalEvent;
1956   EFI_CLOSE_EVENT                               CloseEvent;
1957   EFI_CHECK_EVENT                               CheckEvent;
1958 
1959   //
1960   // Protocol Handler Services
1961   //
1962   EFI_INSTALL_PROTOCOL_INTERFACE                InstallProtocolInterface;
1963   EFI_REINSTALL_PROTOCOL_INTERFACE              ReinstallProtocolInterface;
1964   EFI_UNINSTALL_PROTOCOL_INTERFACE              UninstallProtocolInterface;
1965   EFI_HANDLE_PROTOCOL                           HandleProtocol;
1966   VOID                                          *Reserved;
1967   EFI_REGISTER_PROTOCOL_NOTIFY                  RegisterProtocolNotify;
1968   EFI_LOCATE_HANDLE                             LocateHandle;
1969   EFI_LOCATE_DEVICE_PATH                        LocateDevicePath;
1970   EFI_INSTALL_CONFIGURATION_TABLE               InstallConfigurationTable;
1971 
1972   //
1973   // Image Services
1974   //
1975   EFI_IMAGE_LOAD                                LoadImage;
1976   EFI_IMAGE_START                               StartImage;
1977   EFI_EXIT                                      Exit;
1978   EFI_IMAGE_UNLOAD                              UnloadImage;
1979   EFI_EXIT_BOOT_SERVICES                        ExitBootServices;
1980 
1981   //
1982   // Miscellaneous Services
1983   //
1984   EFI_GET_NEXT_MONOTONIC_COUNT                  GetNextMonotonicCount;
1985   EFI_STALL                                     Stall;
1986   EFI_SET_WATCHDOG_TIMER                        SetWatchdogTimer;
1987 
1988   //
1989   // DriverSupport Services
1990   //
1991   EFI_CONNECT_CONTROLLER                        ConnectController;
1992   EFI_DISCONNECT_CONTROLLER                     DisconnectController;
1993 
1994   //
1995   // Open and Close Protocol Services
1996   //
1997   EFI_OPEN_PROTOCOL                             OpenProtocol;
1998   EFI_CLOSE_PROTOCOL                            CloseProtocol;
1999   EFI_OPEN_PROTOCOL_INFORMATION                 OpenProtocolInformation;
2000 
2001   //
2002   // Library Services
2003   //
2004   EFI_PROTOCOLS_PER_HANDLE                      ProtocolsPerHandle;
2005   EFI_LOCATE_HANDLE_BUFFER                      LocateHandleBuffer;
2006   EFI_LOCATE_PROTOCOL                           LocateProtocol;
2007   EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES      InstallMultipleProtocolInterfaces;
2008   EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES    UninstallMultipleProtocolInterfaces;
2009 
2010   //
2011   // 32-bit CRC Services
2012   //
2013   EFI_CALCULATE_CRC32                           CalculateCrc32;
2014 
2015   //
2016   // Miscellaneous Services
2017   //
2018   EFI_COPY_MEM                                  CopyMem;
2019   EFI_SET_MEM                                   SetMem;
2020   EFI_CREATE_EVENT_EX                           CreateEventEx;
2021 } EFI_BOOT_SERVICES;
2022 
2023 ///
2024 /// Contains a set of GUID/pointer pairs comprised of the ConfigurationTable field in the
2025 /// EFI System Table.
2026 ///
2027 typedef struct {
2028   ///
2029   /// The 128-bit GUID value that uniquely identifies the system configuration table.
2030   ///
2031   EFI_GUID    VendorGuid;
2032   ///
2033   /// A pointer to the table associated with VendorGuid.
2034   ///
2035   VOID        *VendorTable;
2036 } EFI_CONFIGURATION_TABLE;
2037 
2038 ///
2039 /// EFI System Table
2040 ///
2041 typedef struct {
2042   ///
2043   /// The table header for the EFI System Table.
2044   ///
2045   EFI_TABLE_HEADER                   Hdr;
2046   ///
2047   /// A pointer to a null terminated string that identifies the vendor
2048   /// that produces the system firmware for the platform.
2049   ///
2050   CHAR16                             *FirmwareVendor;
2051   ///
2052   /// A firmware vendor specific value that identifies the revision
2053   /// of the system firmware for the platform.
2054   ///
2055   UINT32                             FirmwareRevision;
2056   ///
2057   /// The handle for the active console input device. This handle must support
2058   /// EFI_SIMPLE_TEXT_INPUT_PROTOCOL and EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. If
2059   /// there is no active console, these protocols must still be present.
2060   ///
2061   EFI_HANDLE                         ConsoleInHandle;
2062   ///
2063   /// A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is
2064   /// associated with ConsoleInHandle.
2065   ///
2066   EFI_SIMPLE_TEXT_INPUT_PROTOCOL     *ConIn;
2067   ///
2068   /// The handle for the active console output device. This handle must support the
2069   /// EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. If there is no active console, these protocols
2070   /// must still be present.
2071   ///
2072   EFI_HANDLE                         ConsoleOutHandle;
2073   ///
2074   /// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface
2075   /// that is associated with ConsoleOutHandle.
2076   ///
2077   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *ConOut;
2078   ///
2079   /// The handle for the active standard error console device.
2080   /// This handle must support the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. If there
2081   /// is no active console, this protocol must still be present.
2082   ///
2083   EFI_HANDLE                         StandardErrorHandle;
2084   ///
2085   /// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface
2086   /// that is associated with StandardErrorHandle.
2087   ///
2088   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL    *StdErr;
2089   ///
2090   /// A pointer to the EFI Runtime Services Table.
2091   ///
2092   EFI_RUNTIME_SERVICES               *RuntimeServices;
2093   ///
2094   /// A pointer to the EFI Boot Services Table.
2095   ///
2096   EFI_BOOT_SERVICES                  *BootServices;
2097   ///
2098   /// The number of system configuration tables in the buffer ConfigurationTable.
2099   ///
2100   UINTN                              NumberOfTableEntries;
2101   ///
2102   /// A pointer to the system configuration tables.
2103   /// The number of entries in the table is NumberOfTableEntries.
2104   ///
2105   EFI_CONFIGURATION_TABLE            *ConfigurationTable;
2106 } EFI_SYSTEM_TABLE;
2107 
2108 /**
2109   This is the declaration of an EFI image entry point. This entry point is
2110   the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
2111   both device drivers and bus drivers.
2112 
2113   @param[in]  ImageHandle       The firmware allocated handle for the UEFI image.
2114   @param[in]  SystemTable       A pointer to the EFI System Table.
2115 
2116   @retval EFI_SUCCESS           The operation completed successfully.
2117   @retval Others                An unexpected error occurred.
2118 **/
2119 typedef
2120 EFI_STATUS
2121 (EFIAPI *EFI_IMAGE_ENTRY_POINT)(
2122   IN  EFI_HANDLE                   ImageHandle,
2123   IN  EFI_SYSTEM_TABLE             *SystemTable
2124   );
2125 
2126 //
2127 // EFI Load Option. This data structure describes format of UEFI boot option variables.
2128 //
2129 // NOTE: EFI Load Option is a byte packed buffer of variable length fields.
2130 // The first two fields have fixed length. They are declared as members of the
2131 // EFI_LOAD_OPTION structure. All the other fields are variable length fields.
2132 // They are listed in the comment block below for reference purposes.
2133 //
2134 #pragma pack(1)
2135 typedef struct _EFI_LOAD_OPTION {
2136   ///
2137   /// The attributes for this load option entry. All unused bits must be zero
2138   /// and are reserved by the UEFI specification for future growth.
2139   ///
2140   UINT32    Attributes;
2141   ///
2142   /// Length in bytes of the FilePathList. OptionalData starts at offset
2143   /// sizeof(UINT32) + sizeof(UINT16) + StrSize(Description) + FilePathListLength
2144   /// of the EFI_LOAD_OPTION descriptor.
2145   ///
2146   UINT16    FilePathListLength;
2147   ///
2148   /// The user readable description for the load option.
2149   /// This field ends with a Null character.
2150   ///
2151   // CHAR16                        Description[];
2152   ///
2153   /// A packed array of UEFI device paths. The first element of the array is a
2154   /// device path that describes the device and location of the Image for this
2155   /// load option. The FilePathList[0] is specific to the device type. Other
2156   /// device paths may optionally exist in the FilePathList, but their usage is
2157   /// OSV specific. Each element in the array is variable length, and ends at
2158   /// the device path end structure. Because the size of Description is
2159   /// arbitrary, this data structure is not guaranteed to be aligned on a
2160   /// natural boundary. This data structure may have to be copied to an aligned
2161   /// natural boundary before it is used.
2162   ///
2163   // EFI_DEVICE_PATH_PROTOCOL      FilePathList[];
2164   ///
2165   /// The remaining bytes in the load option descriptor are a binary data buffer
2166   /// that is passed to the loaded image. If the field is zero bytes long, a
2167   /// NULL pointer is passed to the loaded image. The number of bytes in
2168   /// OptionalData can be computed by subtracting the starting offset of
2169   /// OptionalData from total size in bytes of the EFI_LOAD_OPTION.
2170   ///
2171   // UINT8                         OptionalData[];
2172 } EFI_LOAD_OPTION;
2173 #pragma pack()
2174 
2175 //
2176 // EFI Load Options Attributes
2177 //
2178 #define LOAD_OPTION_ACTIVE           0x00000001
2179 #define LOAD_OPTION_FORCE_RECONNECT  0x00000002
2180 #define LOAD_OPTION_HIDDEN           0x00000008
2181 #define LOAD_OPTION_CATEGORY         0x00001F00
2182 
2183 #define LOAD_OPTION_CATEGORY_BOOT  0x00000000
2184 #define LOAD_OPTION_CATEGORY_APP   0x00000100
2185 
2186 #define EFI_BOOT_OPTION_SUPPORT_KEY      0x00000001
2187 #define EFI_BOOT_OPTION_SUPPORT_APP      0x00000002
2188 #define EFI_BOOT_OPTION_SUPPORT_SYSPREP  0x00000010
2189 #define EFI_BOOT_OPTION_SUPPORT_COUNT    0x00000300
2190 
2191 ///
2192 /// EFI Boot Key Data
2193 ///
2194 typedef union {
2195   struct {
2196     ///
2197     /// Indicates the revision of the EFI_KEY_OPTION structure. This revision level should be 0.
2198     ///
2199     UINT32    Revision       : 8;
2200     ///
2201     /// Either the left or right Shift keys must be pressed (1) or must not be pressed (0).
2202     ///
2203     UINT32    ShiftPressed   : 1;
2204     ///
2205     /// Either the left or right Control keys must be pressed (1) or must not be pressed (0).
2206     ///
2207     UINT32    ControlPressed : 1;
2208     ///
2209     /// Either the left or right Alt keys must be pressed (1) or must not be pressed (0).
2210     ///
2211     UINT32    AltPressed     : 1;
2212     ///
2213     /// Either the left or right Logo keys must be pressed (1) or must not be pressed (0).
2214     ///
2215     UINT32    LogoPressed    : 1;
2216     ///
2217     /// The Menu key must be pressed (1) or must not be pressed (0).
2218     ///
2219     UINT32    MenuPressed    : 1;
2220     ///
2221     /// The SysReq key must be pressed (1) or must not be pressed (0).
2222     ///
2223     UINT32    SysReqPressed  : 1;
2224     UINT32    Reserved       : 16;
2225     ///
2226     /// Specifies the actual number of entries in EFI_KEY_OPTION.Keys, from 0-3. If
2227     /// zero, then only the shift state is considered. If more than one, then the boot option will
2228     /// only be launched if all of the specified keys are pressed with the same shift state.
2229     ///
2230     UINT32    InputKeyCount  : 2;
2231   } Options;
2232   UINT32    PackedValue;
2233 } EFI_BOOT_KEY_DATA;
2234 
2235 ///
2236 /// EFI Key Option.
2237 ///
2238 #pragma pack(1)
2239 typedef struct {
2240   ///
2241   /// Specifies options about how the key will be processed.
2242   ///
2243   EFI_BOOT_KEY_DATA    KeyData;
2244   ///
2245   /// The CRC-32 which should match the CRC-32 of the entire EFI_LOAD_OPTION to
2246   /// which BootOption refers. If the CRC-32s do not match this value, then this key
2247   /// option is ignored.
2248   ///
2249   UINT32               BootOptionCrc;
2250   ///
2251   /// The Boot#### option which will be invoked if this key is pressed and the boot option
2252   /// is active (LOAD_OPTION_ACTIVE is set).
2253   ///
2254   UINT16               BootOption;
2255   ///
2256   /// The key codes to compare against those returned by the
2257   /// EFI_SIMPLE_TEXT_INPUT and EFI_SIMPLE_TEXT_INPUT_EX protocols.
2258   /// The number of key codes (0-3) is specified by the EFI_KEY_CODE_COUNT field in KeyOptions.
2259   ///
2260   // EFI_INPUT_KEY      Keys[];
2261 } EFI_KEY_OPTION;
2262 #pragma pack()
2263 
2264 //
2265 // EFI File location to boot from on removable media devices
2266 //
2267 #define EFI_REMOVABLE_MEDIA_FILE_NAME_IA32         L"\\EFI\\BOOT\\BOOTIA32.EFI"
2268 #define EFI_REMOVABLE_MEDIA_FILE_NAME_IA64         L"\\EFI\\BOOT\\BOOTIA64.EFI"
2269 #define EFI_REMOVABLE_MEDIA_FILE_NAME_X64          L"\\EFI\\BOOT\\BOOTX64.EFI"
2270 #define EFI_REMOVABLE_MEDIA_FILE_NAME_ARM          L"\\EFI\\BOOT\\BOOTARM.EFI"
2271 #define EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64      L"\\EFI\\BOOT\\BOOTAA64.EFI"
2272 #define EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64      L"\\EFI\\BOOT\\BOOTRISCV64.EFI"
2273 #define EFI_REMOVABLE_MEDIA_FILE_NAME_LOONGARCH64  L"\\EFI\\BOOT\\BOOTLOONGARCH64.EFI"
2274 
2275 #if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
2276   #if   defined (MDE_CPU_IA32)
2277 #define EFI_REMOVABLE_MEDIA_FILE_NAME  EFI_REMOVABLE_MEDIA_FILE_NAME_IA32
2278   #elif defined (MDE_CPU_X64)
2279 #define EFI_REMOVABLE_MEDIA_FILE_NAME  EFI_REMOVABLE_MEDIA_FILE_NAME_X64
2280   #elif defined (MDE_CPU_EBC)
2281   #elif defined (MDE_CPU_ARM)
2282 #define EFI_REMOVABLE_MEDIA_FILE_NAME  EFI_REMOVABLE_MEDIA_FILE_NAME_ARM
2283   #elif defined (MDE_CPU_AARCH64)
2284 #define EFI_REMOVABLE_MEDIA_FILE_NAME  EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64
2285   #elif defined (MDE_CPU_RISCV64)
2286 #define EFI_REMOVABLE_MEDIA_FILE_NAME  EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64
2287   #elif defined (MDE_CPU_LOONGARCH64)
2288 #define EFI_REMOVABLE_MEDIA_FILE_NAME  EFI_REMOVABLE_MEDIA_FILE_NAME_LOONGARCH64
2289   #else
2290     #error Unknown Processor Type
2291   #endif
2292 #endif
2293 
2294 //
2295 // The directory within the active EFI System Partition defined for delivery of capsule to firmware
2296 //
2297 #define EFI_CAPSULE_FILE_DIRECTORY  L"\\EFI\\UpdateCapsule\\"
2298 
2299 #include <Uefi/UefiPxe.h>
2300 #include <Uefi/UefiGpt.h>
2301 #include <Uefi/UefiInternalFormRepresentation.h>
2302 
2303 #endif
2304