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