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