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