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