xref: /DragonStub/inc/efiapi.h (revision f412fd2a1a248b546b7085648dece8d908077fab)
1 #ifndef _EFI_API_H
2 #define _EFI_API_H
3 
4 /*++
5 
6 Copyright (c) 1998  Intel Corporation
7 
8 Module Name:
9 
10     efiapi.h
11 
12 Abstract:
13 
14     Global EFI runtime & boot service interfaces
15 
16 
17 
18 
19 Revision History
20 
21 --*/
22 
23 //
24 // EFI Specification Revision
25 //
26 
27 #define EFI_SPECIFICATION_REVISION_MAJORMINOR(major, minor) ((major<<16) | (minor))
28 #define EFI_SPECIFICATION_MAJOR_REVISION 1
29 #define EFI_SPECIFICATION_MINOR_REVISION 02
30 #define EFI_SPECIFICATION_VERSION EFI_SPECIFICATION_REVISION_MAJORMINOR(EFI_SPECIFICATION_MAJOR_REVISION, EFI_SPECIFICATION_MINOR_REVISION)
31 
32 //
33 // Declare forward referenced data structures
34 //
35 
36 INTERFACE_DECL(_EFI_SYSTEM_TABLE);
37 
38 //
39 // EFI Memory
40 //
41 
42 typedef
43 EFI_STATUS
44 (EFIAPI *EFI_ALLOCATE_PAGES) (
45     IN EFI_ALLOCATE_TYPE            Type,
46     IN EFI_MEMORY_TYPE              MemoryType,
47     IN UINTN                        NoPages,
48     OUT EFI_PHYSICAL_ADDRESS        *Memory
49     );
50 
51 typedef
52 EFI_STATUS
53 (EFIAPI *EFI_FREE_PAGES) (
54     IN EFI_PHYSICAL_ADDRESS         Memory,
55     IN UINTN                        NoPages
56     );
57 
58 typedef
59 EFI_STATUS
60 (EFIAPI *EFI_GET_MEMORY_MAP) (
61     IN OUT UINTN                    *MemoryMapSize,
62     IN OUT EFI_MEMORY_DESCRIPTOR    *MemoryMap,
63     OUT UINTN                       *MapKey,
64     OUT UINTN                       *DescriptorSize,
65     OUT UINT32                      *DescriptorVersion
66     );
67 
68 #define NextMemoryDescriptor(Ptr,Size)  ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
69 
70 
71 typedef
72 EFI_STATUS
73 (EFIAPI *EFI_ALLOCATE_POOL) (
74     IN EFI_MEMORY_TYPE              PoolType,
75     IN UINTN                        Size,
76     OUT VOID                        **Buffer
77     );
78 
79 typedef
80 EFI_STATUS
81 (EFIAPI *EFI_FREE_POOL) (
82     IN VOID                         *Buffer
83     );
84 
85 typedef
86 EFI_STATUS
87 (EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
88     IN UINTN                        MemoryMapSize,
89     IN UINTN                        DescriptorSize,
90     IN UINT32                       DescriptorVersion,
91     IN EFI_MEMORY_DESCRIPTOR        *VirtualMap
92     );
93 
94 
95 #define EFI_OPTIONAL_PTR            0x00000001
96 #define EFI_INTERNAL_FNC            0x00000002      // Pointer to internal runtime fnc
97 #define EFI_INTERNAL_PTR            0x00000004      // Pointer to internal runtime data
98 
99 
100 typedef
101 EFI_STATUS
102 (EFIAPI *EFI_CONVERT_POINTER) (
103     IN UINTN                        DebugDisposition,
104     IN OUT VOID                     **Address
105     );
106 
107 
108 //
109 // EFI Events
110 //
111 
112 #define EVT_TIMER                           0x80000000
113 #define EVT_RUNTIME                         0x40000000
114 #define EVT_RUNTIME_CONTEXT                 0x20000000
115 
116 #define EVT_NOTIFY_WAIT                     0x00000100
117 #define EVT_NOTIFY_SIGNAL                   0x00000200
118 
119 #define EVT_SIGNAL_EXIT_BOOT_SERVICES       0x00000201
120 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE   0x60000202
121 
122 #define EVT_EFI_SIGNAL_MASK                 0x000000FF
123 #define EVT_EFI_SIGNAL_MAX                  4
124 
125 #define EFI_EVENT_TIMER                         EVT_TIMER
126 #define EFI_EVENT_RUNTIME                       EVT_RUNTIME
127 #define EFI_EVENT_RUNTIME_CONTEXT               EVT_RUNTIME_CONTEXT
128 #define EFI_EVENT_NOTIFY_WAIT                   EVT_NOTIFY_WAIT
129 #define EFI_EVENT_NOTIFY_SIGNAL                 EVT_NOTIFY_SIGNAL
130 #define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES     EVT_SIGNAL_EXIT_BOOT_SERVICES
131 #define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
132 #define EFI_EVENT_EFI_SIGNAL_MASK               EVT_EFI_SIGNAL_MASK
133 #define EFI_EVENT_EFI_SIGNAL_MAX                EVT_EFI_SIGNAL_MAX
134 
135 
136 typedef
137 VOID
138 (EFIAPI *EFI_EVENT_NOTIFY) (
139     IN EFI_EVENT                Event,
140     IN VOID                     *Context
141     );
142 
143 typedef
144 EFI_STATUS
145 (EFIAPI *EFI_CREATE_EVENT) (
146     IN UINT32                       Type,
147     IN EFI_TPL                      NotifyTpl,
148     IN EFI_EVENT_NOTIFY             NotifyFunction,
149     IN VOID                         *NotifyContext,
150     OUT EFI_EVENT                   *Event
151     );
152 
153 typedef enum {
154     TimerCancel,
155     TimerPeriodic,
156     TimerRelative,
157     TimerTypeMax
158 } EFI_TIMER_DELAY;
159 
160 typedef
161 EFI_STATUS
162 (EFIAPI *EFI_SET_TIMER) (
163     IN EFI_EVENT                Event,
164     IN EFI_TIMER_DELAY          Type,
165     IN UINT64                   TriggerTime
166     );
167 
168 typedef
169 EFI_STATUS
170 (EFIAPI *EFI_SIGNAL_EVENT) (
171     IN EFI_EVENT                Event
172     );
173 
174 typedef
175 EFI_STATUS
176 (EFIAPI *EFI_WAIT_FOR_EVENT) (
177     IN UINTN                    NumberOfEvents,
178     IN EFI_EVENT                *Event,
179     OUT UINTN                   *Index
180     );
181 
182 typedef
183 EFI_STATUS
184 (EFIAPI *EFI_CLOSE_EVENT) (
185     IN EFI_EVENT                Event
186     );
187 
188 typedef
189 EFI_STATUS
190 (EFIAPI *EFI_CHECK_EVENT) (
191     IN EFI_EVENT                Event
192     );
193 
194 //
195 // Task priority level
196 //
197 
198 #define TPL_APPLICATION       4
199 #define TPL_CALLBACK          8
200 #define TPL_NOTIFY           16
201 #define TPL_HIGH_LEVEL       31
202 #define EFI_TPL_APPLICATION  TPL_APPLICATION
203 #define EFI_TPL_CALLBACK     TPL_CALLBACK
204 #define EFI_TPL_NOTIFY       TPL_NOTIFY
205 #define EFI_TPL_HIGH_LEVEL   TPL_HIGH_LEVEL
206 typedef
207 EFI_TPL
208 (EFIAPI *EFI_RAISE_TPL) (
209     IN EFI_TPL      NewTpl
210     );
211 
212 typedef
213 VOID
214 (EFIAPI *EFI_RESTORE_TPL) (
215     IN EFI_TPL      OldTpl
216     );
217 
218 
219 //
220 // EFI platform varibles
221 //
222 
223 #define EFI_GLOBAL_VARIABLE     \
224     { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} }
225 
226 // Variable attributes
227 #define EFI_VARIABLE_NON_VOLATILE                          0x00000001
228 #define EFI_VARIABLE_BOOTSERVICE_ACCESS                    0x00000002
229 #define EFI_VARIABLE_RUNTIME_ACCESS                        0x00000004
230 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD                 0x00000008
231 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS            0x00000010
232 #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020
233 #define EFI_VARIABLE_APPEND_WRITE                          0x00000040
234 #define EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS	   0x00000080
235 
236 // Variable size limitation
237 #define EFI_MAXIMUM_VARIABLE_SIZE           1024
238 
239 typedef
240 EFI_STATUS
241 (EFIAPI *EFI_GET_VARIABLE) (
242     IN CHAR16                       *VariableName,
243     IN EFI_GUID                     *VendorGuid,
244     OUT UINT32                      *Attributes OPTIONAL,
245     IN OUT UINTN                    *DataSize,
246     OUT VOID                        *Data
247     );
248 
249 typedef
250 EFI_STATUS
251 (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
252     IN OUT UINTN                    *VariableNameSize,
253     IN OUT CHAR16                   *VariableName,
254     IN OUT EFI_GUID                 *VendorGuid
255     );
256 
257 
258 typedef
259 EFI_STATUS
260 (EFIAPI *EFI_SET_VARIABLE) (
261     IN CHAR16                       *VariableName,
262     IN EFI_GUID                     *VendorGuid,
263     IN UINT32                       Attributes,
264     IN UINTN                        DataSize,
265     IN VOID                         *Data
266     );
267 
268 
269 //
270 // EFI Time
271 //
272 
273 typedef struct {
274         UINT32                      Resolution;     // 1e-6 parts per million
275         UINT32                      Accuracy;       // hertz
276         BOOLEAN                     SetsToZero;     // Set clears sub-second time
277 } EFI_TIME_CAPABILITIES;
278 
279 
280 typedef
281 EFI_STATUS
282 (EFIAPI *EFI_GET_TIME) (
283     OUT EFI_TIME                    *Time,
284     OUT EFI_TIME_CAPABILITIES       *Capabilities OPTIONAL
285     );
286 
287 typedef
288 EFI_STATUS
289 (EFIAPI *EFI_SET_TIME) (
290     IN EFI_TIME                     *Time
291     );
292 
293 typedef
294 EFI_STATUS
295 (EFIAPI *EFI_GET_WAKEUP_TIME) (
296     OUT BOOLEAN                     *Enabled,
297     OUT BOOLEAN                     *Pending,
298     OUT EFI_TIME                    *Time
299     );
300 
301 typedef
302 EFI_STATUS
303 (EFIAPI *EFI_SET_WAKEUP_TIME) (
304     IN BOOLEAN                      Enable,
305     IN EFI_TIME                     *Time OPTIONAL
306     );
307 
308 
309 //
310 // Image functions
311 //
312 
313 
314 // PE32+ Subsystem type for EFI images
315 
316 #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
317 #define IMAGE_SUBSYSTEM_EFI_APPLICATION             10
318 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER     11
319 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER          12
320 #endif
321 
322 // PE32+ Machine type for EFI images
323 
324 #if !defined(EFI_IMAGE_MACHINE_IA32)
325 #define EFI_IMAGE_MACHINE_IA32      0x014c
326 #endif
327 
328 #if !defined(EFI_IMAGE_MACHINE_IA64)
329 #define EFI_IMAGE_MACHINE_IA64      0x0200
330 #endif
331 
332 #if !defined(EFI_IMAGE_MACHINE_EBC)
333 #define EFI_IMAGE_MACHINE_EBC      0x0EBC
334 #endif
335 
336 #if !defined(EFI_IMAGE_MACHINE_X64)
337 #define EFI_IMAGE_MACHINE_X64       0x8664
338 #endif
339 
340 #if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
341 #define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
342 #endif
343 
344 #if !defined(EFI_IMAGE_MACHINE_AARCH64)
345 #define EFI_IMAGE_MACHINE_AARCH64   0xAA64
346 #endif
347 
348 #if !defined(EFI_IMAGE_MACHINE_RISCV32)
349 #define EFI_IMAGE_MACHINE_RISCV32   0x5032
350 #endif
351 
352 #if !defined(EFI_IMAGE_MACHINE_RISCV64)
353 #define EFI_IMAGE_MACHINE_RISCV64   0x5064
354 #endif
355 
356 #if !defined(EFI_IMAGE_MACHINE_RISCV128)
357 #define EFI_IMAGE_MACHINE_RISCV128  0x5128
358 #endif
359 
360 #if !defined(EFI_IMAGE_MACHINE_LOONGARCH32)
361 #define EFI_IMAGE_MACHINE_LOONGARCH32   0x6232
362 #endif
363 
364 #if !defined(EFI_IMAGE_MACHINE_LOONGARCH64)
365 #define EFI_IMAGE_MACHINE_LOONGARCH64   0x6264
366 #endif
367 
368 // Image Entry prototype
369 
370 typedef
371 EFI_STATUS
372 (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
373     IN EFI_HANDLE                   ImageHandle,
374     IN struct _EFI_SYSTEM_TABLE     *SystemTable
375     );
376 
377 typedef
378 EFI_STATUS
379 (EFIAPI *EFI_IMAGE_LOAD) (
380     IN BOOLEAN                      BootPolicy,
381     IN EFI_HANDLE                   ParentImageHandle,
382     IN EFI_DEVICE_PATH              *FilePath,
383     IN VOID                         *SourceBuffer   OPTIONAL,
384     IN UINTN                        SourceSize,
385     OUT EFI_HANDLE                  *ImageHandle
386     );
387 
388 typedef
389 EFI_STATUS
390 (EFIAPI *EFI_IMAGE_START) (
391     IN EFI_HANDLE                   ImageHandle,
392     OUT UINTN                       *ExitDataSize,
393     OUT CHAR16                      **ExitData  OPTIONAL
394     );
395 
396 typedef
397 EFI_STATUS
398 (EFIAPI *EFI_EXIT) (
399     IN EFI_HANDLE                   ImageHandle,
400     IN EFI_STATUS                   ExitStatus,
401     IN UINTN                        ExitDataSize,
402     IN CHAR16                       *ExitData OPTIONAL
403     );
404 
405 
406 // Image handle
407 /*#define LOADED_IMAGE_PROTOCOL      \
408     { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
409 
410 #define EFI_IMAGE_INFORMATION_REVISION      0x1000
411 typedef struct {
412     UINT32                          Revision;
413     EFI_HANDLE                      ParentHandle;
414     struct _EFI_SYSTEM_TABLE        *SystemTable;
415 
416     // Source location of image
417     EFI_HANDLE                      DeviceHandle;
418     EFI_DEVICE_PATH                 *FilePath;
419     VOID                            *Reserved;
420 
421     // Images load options
422     UINT32                          LoadOptionsSize;
423     VOID                            *LoadOptions;
424 
425     // Location of where image was loaded
426     VOID                            *ImageBase;
427     UINT64                          ImageSize;
428     EFI_MEMORY_TYPE                 ImageCodeType;
429     EFI_MEMORY_TYPE                 ImageDataType;
430 
431     // If the driver image supports a dynamic unload request
432     EFI_IMAGE_UNLOAD                Unload;
433 
434 } EFI_LOADED_IMAGE;*/
435 
436 
437 typedef
438 EFI_STATUS
439 (EFIAPI *EFI_EXIT_BOOT_SERVICES) (
440     IN EFI_HANDLE                   ImageHandle,
441     IN UINTN                        MapKey
442     );
443 
444 //
445 // Misc
446 //
447 
448 
449 typedef
450 EFI_STATUS
451 (EFIAPI *EFI_STALL) (
452     IN UINTN                    Microseconds
453     );
454 
455 typedef
456 EFI_STATUS
457 (EFIAPI *EFI_SET_WATCHDOG_TIMER) (
458     IN UINTN                    Timeout,
459     IN UINT64                   WatchdogCode,
460     IN UINTN                    DataSize,
461     IN CHAR16                   *WatchdogData OPTIONAL
462     );
463 
464 typedef
465 EFI_STATUS
466 (EFIAPI *EFI_CONNECT_CONTROLLER) (
467     IN EFI_HANDLE               ControllerHandle,
468     IN EFI_HANDLE               *DriverImageHandle OPTIONAL,
469     IN EFI_DEVICE_PATH          *RemainingDevicePath OPTIONAL,
470     IN BOOLEAN                  Recursive
471     );
472 
473 typedef
474 EFI_STATUS
475 (EFIAPI *EFI_DISCONNECT_CONTROLLER) (
476     IN EFI_HANDLE               ControllerHandle,
477     IN EFI_HANDLE               DriverImageHandle OPTIONAL,
478     IN EFI_HANDLE               ChildHandle OPTIONAL
479     );
480 
481 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
482 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
483 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
484 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
485 #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
486 #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
487 
488 typedef
489 EFI_STATUS
490 (EFIAPI *EFI_OPEN_PROTOCOL) (
491     IN EFI_HANDLE               Handle,
492     IN EFI_GUID                 *Protocol,
493     OUT VOID                    **Interface OPTIONAL,
494     IN EFI_HANDLE               AgentHandle,
495     IN EFI_HANDLE               ControllerHandle,
496     IN UINT32                   Attributes
497     );
498 
499 typedef
500 EFI_STATUS
501 (EFIAPI *EFI_CLOSE_PROTOCOL) (
502     IN EFI_HANDLE               Handle,
503     IN EFI_GUID                 *Protocol,
504     IN EFI_HANDLE               AgentHandle,
505     IN EFI_HANDLE               ControllerHandle
506     );
507 
508 typedef struct {
509     EFI_HANDLE                  AgentHandle;
510     EFI_HANDLE                  ControllerHandle;
511     UINT32                      Attributes;
512     UINT32                      OpenCount;
513 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
514 
515 typedef
516 EFI_STATUS
517 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
518     IN EFI_HANDLE               Handle,
519     IN EFI_GUID                 *Protocol,
520     OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
521     OUT UINTN                   *EntryCount
522     );
523 
524 typedef
525 EFI_STATUS
526 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
527     IN EFI_HANDLE               Handle,
528     OUT EFI_GUID                ***ProtocolBuffer,
529     OUT UINTN                   *ProtocolBufferCount
530     );
531 
532 typedef enum {
533     AllHandles,
534     ByRegisterNotify,
535     ByProtocol
536 } EFI_LOCATE_SEARCH_TYPE;
537 
538 typedef
539 EFI_STATUS
540 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
541     IN EFI_LOCATE_SEARCH_TYPE   SearchType,
542     IN EFI_GUID                 *Protocol OPTIONAL,
543     IN VOID                     *SearchKey OPTIONAL,
544     IN OUT UINTN                *NoHandles,
545     OUT EFI_HANDLE              **Buffer
546     );
547 
548 typedef
549 EFI_STATUS
550 (EFIAPI *EFI_LOCATE_PROTOCOL) (
551     IN EFI_GUID                 *Protocol,
552     IN VOID                     *Registration OPTIONAL,
553     OUT VOID                    **Interface
554     );
555 
556 typedef
557 EFI_STATUS
558 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
559     IN OUT EFI_HANDLE           *Handle,
560     ...
561     );
562 
563 typedef
564 EFI_STATUS
565 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
566     IN OUT EFI_HANDLE           Handle,
567     ...
568     );
569 
570 typedef
571 EFI_STATUS
572 (EFIAPI *EFI_CALCULATE_CRC32) (
573     IN VOID                     *Data,
574     IN UINTN                    DataSize,
575     OUT UINT32                  *Crc32
576     );
577 
578 typedef
579 VOID
580 (EFIAPI *EFI_COPY_MEM) (
581     IN VOID                     *Destination,
582     IN VOID                     *Source,
583     IN UINTN                    Length
584     );
585 
586 typedef
587 VOID
588 (EFIAPI *EFI_SET_MEM) (
589     IN VOID                     *Buffer,
590     IN UINTN                    Size,
591     IN UINT8                    Value
592     );
593 
594 
595 typedef
596 EFI_STATUS
597 (EFIAPI *EFI_CREATE_EVENT_EX) (
598     IN UINT32                   Type,
599     IN EFI_TPL                  NotifyTpl,
600     IN EFI_EVENT_NOTIFY         NotifyFunction OPTIONAL,
601     IN const VOID               *NotifyContext OPTIONAL,
602     IN const EFI_GUID           *EventGroup OPTIONAL,
603     OUT EFI_EVENT               *Event
604     );
605 
606 typedef enum {
607     EfiResetCold,
608     EfiResetWarm,
609     EfiResetShutdown
610 } EFI_RESET_TYPE;
611 
612 typedef
613 EFI_STATUS
614 (EFIAPI *EFI_RESET_SYSTEM) (
615     IN EFI_RESET_TYPE           ResetType,
616     IN EFI_STATUS               ResetStatus,
617     IN UINTN                    DataSize,
618     IN CHAR16                   *ResetData OPTIONAL
619     );
620 
621 typedef
622 EFI_STATUS
623 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
624     OUT UINT64                  *Count
625     );
626 
627 typedef
628 EFI_STATUS
629 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
630     OUT UINT32                  *HighCount
631     );
632 
633 typedef struct {
634     UINT64                      Length;
635     union {
636         EFI_PHYSICAL_ADDRESS    DataBlock;
637        EFI_PHYSICAL_ADDRESS    ContinuationPointer;
638     } Union;
639 } EFI_CAPSULE_BLOCK_DESCRIPTOR;
640 
641 typedef struct {
642     EFI_GUID                    CapsuleGuid;
643     UINT32                      HeaderSize;
644     UINT32                      Flags;
645     UINT32                      CapsuleImageSize;
646 } EFI_CAPSULE_HEADER;
647 
648 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET    0x00010000
649 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE   0x00020000
650 #define CAPSULE_FLAGS_INITIATE_RESET          0x00040000
651 
652 typedef
653 EFI_STATUS
654 (EFIAPI *EFI_UPDATE_CAPSULE) (
655     IN EFI_CAPSULE_HEADER       **CapsuleHeaderArray,
656     IN UINTN                    CapsuleCount,
657     IN EFI_PHYSICAL_ADDRESS     ScatterGatherList OPTIONAL
658     );
659 
660 typedef
661 EFI_STATUS
662 (EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) (
663     IN  EFI_CAPSULE_HEADER       **CapsuleHeaderArray,
664     IN  UINTN                    CapsuleCount,
665     OUT UINT64                   *MaximumCapsuleSize,
666     OUT EFI_RESET_TYPE           *ResetType
667     );
668 
669 typedef
670 EFI_STATUS
671 (EFIAPI *EFI_QUERY_VARIABLE_INFO) (
672     IN  UINT32                  Attributes,
673     OUT UINT64                  *MaximumVariableStorageSize,
674     OUT UINT64                  *RemainingVariableStorageSize,
675     OUT UINT64                  *MaximumVariableSize
676     );
677 
678 //
679 // Protocol handler functions
680 //
681 
682 typedef enum {
683     EFI_NATIVE_INTERFACE,
684     EFI_PCODE_INTERFACE
685 } EFI_INTERFACE_TYPE;
686 
687 typedef
688 EFI_STATUS
689 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
690     IN OUT EFI_HANDLE           *Handle,
691     IN EFI_GUID                 *Protocol,
692     IN EFI_INTERFACE_TYPE       InterfaceType,
693     IN VOID                     *Interface
694     );
695 
696 typedef
697 EFI_STATUS
698 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
699     IN EFI_HANDLE               Handle,
700     IN EFI_GUID                 *Protocol,
701     IN VOID                     *OldInterface,
702     IN VOID                     *NewInterface
703     );
704 
705 typedef
706 EFI_STATUS
707 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
708     IN EFI_HANDLE               Handle,
709     IN EFI_GUID                 *Protocol,
710     IN VOID                     *Interface
711     );
712 
713 typedef
714 EFI_STATUS
715 (EFIAPI *EFI_HANDLE_PROTOCOL) (
716     IN EFI_HANDLE               Handle,
717     IN EFI_GUID                 *Protocol,
718     OUT VOID                    **Interface
719     );
720 
721 typedef
722 EFI_STATUS
723 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
724     IN EFI_GUID                 *Protocol,
725     IN EFI_EVENT                Event,
726     OUT VOID                    **Registration
727     );
728 
729 typedef
730 EFI_STATUS
731 (EFIAPI *EFI_LOCATE_HANDLE) (
732     IN EFI_LOCATE_SEARCH_TYPE   SearchType,
733     IN EFI_GUID                 *Protocol OPTIONAL,
734     IN VOID                     *SearchKey OPTIONAL,
735     IN OUT UINTN                *BufferSize,
736     OUT EFI_HANDLE              *Buffer
737     );
738 
739 typedef
740 EFI_STATUS
741 (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
742     IN EFI_GUID                 *Protocol,
743     IN OUT EFI_DEVICE_PATH      **DevicePath,
744     OUT EFI_HANDLE              *Device
745     );
746 
747 typedef
748 EFI_STATUS
749 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
750     IN EFI_GUID                 *Guid,
751     IN VOID                     *Table
752     );
753 
754 typedef
755 EFI_STATUS
756 (EFIAPI *EFI_RESERVED_SERVICE) (
757     );
758 
759 //
760 // Standard EFI table header
761 //
762 
763 typedef struct _EFI_TABLE_HEADER {
764     UINT64                      Signature;
765     UINT32                      Revision;
766     UINT32                      HeaderSize;
767     UINT32                      CRC32;
768     UINT32                      Reserved;
769 } EFI_TABLE_HEADER;
770 
771 
772 //
773 // EFI Runtime Serivces Table
774 //
775 
776 #define EFI_RUNTIME_SERVICES_SIGNATURE      0x56524553544e5552
777 #define EFI_1_02_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 02)
778 #define EFI_1_10_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 10)
779 #define EFI_2_00_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 00)
780 #define EFI_2_10_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 10)
781 #define EFI_2_20_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 20)
782 #define EFI_2_30_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 30)
783 #define EFI_2_31_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 31)
784 #define EFI_2_40_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 40)
785 #define EFI_2_50_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 50)
786 #define EFI_2_60_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 60)
787 #define EFI_2_70_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 70)
788 #define EFI_2_80_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 80)
789 #define EFI_2_90_RUNTIME_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 90)
790 #define EFI_2_100_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 100)
791 #define EFI_RUNTIME_SERVICES_REVISION       EFI_SPECIFICATION_VERSION
792 
793 typedef struct  {
794     EFI_TABLE_HEADER                Hdr;
795 
796     //
797     // Time services
798     //
799 
800     EFI_GET_TIME                    GetTime;
801     EFI_SET_TIME                    SetTime;
802     EFI_GET_WAKEUP_TIME             GetWakeupTime;
803     EFI_SET_WAKEUP_TIME             SetWakeupTime;
804 
805     //
806     // Virtual memory services
807     //
808 
809     EFI_SET_VIRTUAL_ADDRESS_MAP     SetVirtualAddressMap;
810     EFI_CONVERT_POINTER             ConvertPointer;
811 
812     //
813     // Variable serviers
814     //
815 
816     EFI_GET_VARIABLE                GetVariable;
817     EFI_GET_NEXT_VARIABLE_NAME      GetNextVariableName;
818     EFI_SET_VARIABLE                SetVariable;
819 
820     //
821     // Misc
822     //
823 
824     EFI_GET_NEXT_HIGH_MONO_COUNT    GetNextHighMonotonicCount;
825     EFI_RESET_SYSTEM                ResetSystem;
826 
827     EFI_UPDATE_CAPSULE              UpdateCapsule;
828     EFI_QUERY_CAPSULE_CAPABILITIES  QueryCapsuleCapabilities;
829     EFI_QUERY_VARIABLE_INFO         QueryVariableInfo;
830 } EFI_RUNTIME_SERVICES;
831 
832 
833 //
834 // EFI Boot Services Table
835 //
836 
837 #define EFI_BOOT_SERVICES_SIGNATURE      0x56524553544f4f42
838 #define EFI_1_02_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 02)
839 #define EFI_1_10_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 10)
840 #define EFI_2_00_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 00)
841 #define EFI_2_10_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 10)
842 #define EFI_2_20_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 20)
843 #define EFI_2_30_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 30)
844 #define EFI_2_31_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 31)
845 #define EFI_2_40_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 40)
846 #define EFI_2_50_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 50)
847 #define EFI_2_60_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 60)
848 #define EFI_2_70_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 70)
849 #define EFI_2_80_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 80)
850 #define EFI_2_90_BOOT_SERVICES_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 90)
851 #define EFI_2_100_BOOT_SERVICES_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 100)
852 #define EFI_BOOT_SERVICES_REVISION       EFI_SPECIFICATION_VERSION
853 
854 typedef struct _EFI_BOOT_SERVICES {
855 
856     EFI_TABLE_HEADER                Hdr;
857 
858     //
859     // Task priority functions
860     //
861 
862     EFI_RAISE_TPL                   RaiseTPL;
863     EFI_RESTORE_TPL                 RestoreTPL;
864 
865     //
866     // Memory functions
867     //
868 
869     EFI_ALLOCATE_PAGES              AllocatePages;
870     EFI_FREE_PAGES                  FreePages;
871     EFI_GET_MEMORY_MAP              GetMemoryMap;
872     EFI_ALLOCATE_POOL               AllocatePool;
873     EFI_FREE_POOL                   FreePool;
874 
875     //
876     // Event & timer functions
877     //
878 
879     EFI_CREATE_EVENT                CreateEvent;
880     EFI_SET_TIMER                   SetTimer;
881     EFI_WAIT_FOR_EVENT              WaitForEvent;
882     EFI_SIGNAL_EVENT                SignalEvent;
883     EFI_CLOSE_EVENT                 CloseEvent;
884     EFI_CHECK_EVENT                 CheckEvent;
885 
886     //
887     // Protocol handler functions
888     //
889 
890     EFI_INSTALL_PROTOCOL_INTERFACE  InstallProtocolInterface;
891     EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
892     EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
893     EFI_HANDLE_PROTOCOL             HandleProtocol;
894     EFI_HANDLE_PROTOCOL             PCHandleProtocol;
895     EFI_REGISTER_PROTOCOL_NOTIFY    RegisterProtocolNotify;
896     EFI_LOCATE_HANDLE               LocateHandle;
897     EFI_LOCATE_DEVICE_PATH          LocateDevicePath;
898     EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
899 
900     //
901     // Image functions
902     //
903 
904     EFI_IMAGE_LOAD                  LoadImage;
905     EFI_IMAGE_START                 StartImage;
906     EFI_EXIT                        Exit;
907     EFI_IMAGE_UNLOAD                UnloadImage;
908     EFI_EXIT_BOOT_SERVICES          ExitBootServices;
909 
910     //
911     // Misc functions
912     //
913 
914     EFI_GET_NEXT_MONOTONIC_COUNT    GetNextMonotonicCount;
915     EFI_STALL                       Stall;
916     EFI_SET_WATCHDOG_TIMER          SetWatchdogTimer;
917 
918     //
919     // DriverSupport Services
920     //
921 
922     EFI_CONNECT_CONTROLLER          ConnectController;
923     EFI_DISCONNECT_CONTROLLER       DisconnectController;
924 
925     //
926     // Open and Close Protocol Services
927     //
928     EFI_OPEN_PROTOCOL               OpenProtocol;
929     EFI_CLOSE_PROTOCOL              CloseProtocol;
930     EFI_OPEN_PROTOCOL_INFORMATION   OpenProtocolInformation;
931 
932     //
933     // Library Services
934     //
935     EFI_PROTOCOLS_PER_HANDLE        ProtocolsPerHandle;
936     EFI_LOCATE_HANDLE_BUFFER        LocateHandleBuffer;
937     EFI_LOCATE_PROTOCOL             LocateProtocol;
938     EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
939     EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
940 
941     //
942     // 32-bit CRC Services
943     //
944     EFI_CALCULATE_CRC32             CalculateCrc32;
945 
946     //
947     // Misc Services
948     //
949     EFI_COPY_MEM                    CopyMem;
950     EFI_SET_MEM                     SetMem;
951     EFI_CREATE_EVENT_EX             CreateEventEx;
952 } EFI_BOOT_SERVICES;
953 
954 
955 //
956 // EFI Configuration Table and GUID definitions
957 //
958 
959 #define MPS_TABLE_GUID    \
960     { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
961 
962 #define ACPI_TABLE_GUID    \
963     { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
964 
965 #define ACPI_20_TABLE_GUID  \
966     { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
967 
968 #define SMBIOS_TABLE_GUID    \
969     { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
970 
971 #define SMBIOS3_TABLE_GUID    \
972     { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} }
973 
974 #define SAL_SYSTEM_TABLE_GUID    \
975     { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
976 
977 #define EFI_DTB_TABLE_GUID \
978     { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} }
979 
980 typedef struct _EFI_CONFIGURATION_TABLE {
981     EFI_GUID                VendorGuid;
982     VOID                    *VendorTable;
983 } EFI_CONFIGURATION_TABLE;
984 
985 
986 //
987 // EFI System Table
988 //
989 
990 
991 
992 
993 #define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249
994 #define EFI_1_02_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 02)
995 #define EFI_1_10_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(1, 10)
996 #define EFI_2_00_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 00)
997 #define EFI_2_10_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 10)
998 #define EFI_2_20_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 20)
999 #define EFI_2_30_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 30)
1000 #define EFI_2_31_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 31)
1001 #define EFI_2_40_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 40)
1002 #define EFI_2_50_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 50)
1003 #define EFI_2_60_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 60)
1004 #define EFI_2_70_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 70)
1005 #define EFI_2_80_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 80)
1006 #define EFI_2_90_SYSTEM_TABLE_REVISION  EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 90)
1007 #define EFI_2_100_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_REVISION_MAJORMINOR(2, 100)
1008 #define EFI_SYSTEM_TABLE_REVISION       EFI_SPECIFICATION_VERSION
1009 
1010 typedef struct _EFI_SYSTEM_TABLE {
1011     EFI_TABLE_HEADER                Hdr;
1012 
1013     CHAR16                          *FirmwareVendor;
1014     UINT32                          FirmwareRevision;
1015 
1016     EFI_HANDLE                      ConsoleInHandle;
1017     SIMPLE_INPUT_INTERFACE          *ConIn;
1018 
1019     EFI_HANDLE                      ConsoleOutHandle;
1020     SIMPLE_TEXT_OUTPUT_INTERFACE    *ConOut;
1021 
1022     EFI_HANDLE                      StandardErrorHandle;
1023     SIMPLE_TEXT_OUTPUT_INTERFACE    *StdErr;
1024 
1025     EFI_RUNTIME_SERVICES            *RuntimeServices;
1026     EFI_BOOT_SERVICES               *BootServices;
1027 
1028     UINTN                           NumberOfTableEntries;
1029     EFI_CONFIGURATION_TABLE         *ConfigurationTable;
1030 
1031 } EFI_SYSTEM_TABLE;
1032 
1033 #endif
1034 
1035