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