xref: /DragonStub/inc/efiapi.h (revision fd3d9751611a86a1b2e465f6ca3ad68e1531a9f7)
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 
233 // Variable size limitation
234 #define EFI_MAXIMUM_VARIABLE_SIZE           1024
235 
236 typedef
237 EFI_STATUS
238 (EFIAPI *EFI_GET_VARIABLE) (
239     IN CHAR16                       *VariableName,
240     IN EFI_GUID                     *VendorGuid,
241     OUT UINT32                      *Attributes OPTIONAL,
242     IN OUT UINTN                    *DataSize,
243     OUT VOID                        *Data
244     );
245 
246 typedef
247 EFI_STATUS
248 (EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
249     IN OUT UINTN                    *VariableNameSize,
250     IN OUT CHAR16                   *VariableName,
251     IN OUT EFI_GUID                 *VendorGuid
252     );
253 
254 
255 typedef
256 EFI_STATUS
257 (EFIAPI *EFI_SET_VARIABLE) (
258     IN CHAR16                       *VariableName,
259     IN EFI_GUID                     *VendorGuid,
260     IN UINT32                       Attributes,
261     IN UINTN                        DataSize,
262     IN VOID                         *Data
263     );
264 
265 
266 //
267 // EFI Time
268 //
269 
270 typedef struct {
271         UINT32                      Resolution;     // 1e-6 parts per million
272         UINT32                      Accuracy;       // hertz
273         BOOLEAN                     SetsToZero;     // Set clears sub-second time
274 } EFI_TIME_CAPABILITIES;
275 
276 
277 typedef
278 EFI_STATUS
279 (EFIAPI *EFI_GET_TIME) (
280     OUT EFI_TIME                    *Time,
281     OUT EFI_TIME_CAPABILITIES       *Capabilities OPTIONAL
282     );
283 
284 typedef
285 EFI_STATUS
286 (EFIAPI *EFI_SET_TIME) (
287     IN EFI_TIME                     *Time
288     );
289 
290 typedef
291 EFI_STATUS
292 (EFIAPI *EFI_GET_WAKEUP_TIME) (
293     OUT BOOLEAN                     *Enabled,
294     OUT BOOLEAN                     *Pending,
295     OUT EFI_TIME                    *Time
296     );
297 
298 typedef
299 EFI_STATUS
300 (EFIAPI *EFI_SET_WAKEUP_TIME) (
301     IN BOOLEAN                      Enable,
302     IN EFI_TIME                     *Time OPTIONAL
303     );
304 
305 
306 //
307 // Image functions
308 //
309 
310 
311 // PE32+ Subsystem type for EFI images
312 
313 #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
314 #define IMAGE_SUBSYSTEM_EFI_APPLICATION             10
315 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER     11
316 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER          12
317 #endif
318 
319 // PE32+ Machine type for EFI images
320 
321 #if !defined(EFI_IMAGE_MACHINE_IA32)
322 #define EFI_IMAGE_MACHINE_IA32      0x014c
323 #endif
324 
325 #if !defined(EFI_IMAGE_MACHINE_IA64)
326 #define EFI_IMAGE_MACHINE_IA64      0x0200
327 #endif
328 
329 #if !defined(EFI_IMAGE_MACHINE_EBC)
330 #define EFI_IMAGE_MACHINE_EBC      0x0EBC
331 #endif
332 
333 #if !defined(EFI_IMAGE_MACHINE_X64)
334 #define EFI_IMAGE_MACHINE_X64       0x8664
335 #endif
336 
337 #if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
338 #define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
339 #endif
340 
341 #if !defined(EFI_IMAGE_MACHINE_AARCH64)
342 #define EFI_IMAGE_MACHINE_AARCH64   0xAA64
343 #endif
344 
345 #if !defined(EFI_IMAGE_MACHINE_RISCV32)
346 #define EFI_IMAGE_MACHINE_RISCV32   0x5032
347 #endif
348 
349 #if !defined(EFI_IMAGE_MACHINE_RISCV64)
350 #define EFI_IMAGE_MACHINE_RISCV64   0x5064
351 #endif
352 
353 #if !defined(EFI_IMAGE_MACHINE_RISCV128)
354 #define EFI_IMAGE_MACHINE_RISCV128  0x5128
355 #endif
356 
357 #if !defined(EFI_IMAGE_MACHINE_LOONGARCH32)
358 #define EFI_IMAGE_MACHINE_LOONGARCH32   0x6232
359 #endif
360 
361 #if !defined(EFI_IMAGE_MACHINE_LOONGARCH64)
362 #define EFI_IMAGE_MACHINE_LOONGARCH64   0x6264
363 #endif
364 
365 // Image Entry prototype
366 
367 typedef
368 EFI_STATUS
369 (EFIAPI *EFI_IMAGE_ENTRY_POINT) (
370     IN EFI_HANDLE                   ImageHandle,
371     IN struct _EFI_SYSTEM_TABLE     *SystemTable
372     );
373 
374 typedef
375 EFI_STATUS
376 (EFIAPI *EFI_IMAGE_LOAD) (
377     IN BOOLEAN                      BootPolicy,
378     IN EFI_HANDLE                   ParentImageHandle,
379     IN EFI_DEVICE_PATH              *FilePath,
380     IN VOID                         *SourceBuffer   OPTIONAL,
381     IN UINTN                        SourceSize,
382     OUT EFI_HANDLE                  *ImageHandle
383     );
384 
385 typedef
386 EFI_STATUS
387 (EFIAPI *EFI_IMAGE_START) (
388     IN EFI_HANDLE                   ImageHandle,
389     OUT UINTN                       *ExitDataSize,
390     OUT CHAR16                      **ExitData  OPTIONAL
391     );
392 
393 typedef
394 EFI_STATUS
395 (EFIAPI *EFI_EXIT) (
396     IN EFI_HANDLE                   ImageHandle,
397     IN EFI_STATUS                   ExitStatus,
398     IN UINTN                        ExitDataSize,
399     IN CHAR16                       *ExitData OPTIONAL
400     );
401 
402 
403 // Image handle
404 /*#define LOADED_IMAGE_PROTOCOL      \
405     { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} }
406 
407 #define EFI_IMAGE_INFORMATION_REVISION      0x1000
408 typedef struct {
409     UINT32                          Revision;
410     EFI_HANDLE                      ParentHandle;
411     struct _EFI_SYSTEM_TABLE        *SystemTable;
412 
413     // Source location of image
414     EFI_HANDLE                      DeviceHandle;
415     EFI_DEVICE_PATH                 *FilePath;
416     VOID                            *Reserved;
417 
418     // Images load options
419     UINT32                          LoadOptionsSize;
420     VOID                            *LoadOptions;
421 
422     // Location of where image was loaded
423     VOID                            *ImageBase;
424     UINT64                          ImageSize;
425     EFI_MEMORY_TYPE                 ImageCodeType;
426     EFI_MEMORY_TYPE                 ImageDataType;
427 
428     // If the driver image supports a dynamic unload request
429     EFI_IMAGE_UNLOAD                Unload;
430 
431 } EFI_LOADED_IMAGE;*/
432 
433 
434 typedef
435 EFI_STATUS
436 (EFIAPI *EFI_EXIT_BOOT_SERVICES) (
437     IN EFI_HANDLE                   ImageHandle,
438     IN UINTN                        MapKey
439     );
440 
441 //
442 // Misc
443 //
444 
445 
446 typedef
447 EFI_STATUS
448 (EFIAPI *EFI_STALL) (
449     IN UINTN                    Microseconds
450     );
451 
452 typedef
453 EFI_STATUS
454 (EFIAPI *EFI_SET_WATCHDOG_TIMER) (
455     IN UINTN                    Timeout,
456     IN UINT64                   WatchdogCode,
457     IN UINTN                    DataSize,
458     IN CHAR16                   *WatchdogData OPTIONAL
459     );
460 
461 typedef
462 EFI_STATUS
463 (EFIAPI *EFI_CONNECT_CONTROLLER) (
464     IN EFI_HANDLE               ControllerHandle,
465     IN EFI_HANDLE               *DriverImageHandle OPTIONAL,
466     IN EFI_DEVICE_PATH          *RemainingDevicePath OPTIONAL,
467     IN BOOLEAN                  Recursive
468     );
469 
470 typedef
471 EFI_STATUS
472 (EFIAPI *EFI_DISCONNECT_CONTROLLER) (
473     IN EFI_HANDLE               ControllerHandle,
474     IN EFI_HANDLE               DriverImageHandle OPTIONAL,
475     IN EFI_HANDLE               ChildHandle OPTIONAL
476     );
477 
478 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
479 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
480 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
481 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
482 #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
483 #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
484 
485 typedef
486 EFI_STATUS
487 (EFIAPI *EFI_OPEN_PROTOCOL) (
488     IN EFI_HANDLE               Handle,
489     IN EFI_GUID                 *Protocol,
490     OUT VOID                    **Interface OPTIONAL,
491     IN EFI_HANDLE               AgentHandle,
492     IN EFI_HANDLE               ControllerHandle,
493     IN UINT32                   Attributes
494     );
495 
496 typedef
497 EFI_STATUS
498 (EFIAPI *EFI_CLOSE_PROTOCOL) (
499     IN EFI_HANDLE               Handle,
500     IN EFI_GUID                 *Protocol,
501     IN EFI_HANDLE               AgentHandle,
502     IN EFI_HANDLE               ControllerHandle
503     );
504 
505 typedef struct {
506     EFI_HANDLE                  AgentHandle;
507     EFI_HANDLE                  ControllerHandle;
508     UINT32                      Attributes;
509     UINT32                      OpenCount;
510 } EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
511 
512 typedef
513 EFI_STATUS
514 (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
515     IN EFI_HANDLE               Handle,
516     IN EFI_GUID                 *Protocol,
517     OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
518     OUT UINTN                   *EntryCount
519     );
520 
521 typedef
522 EFI_STATUS
523 (EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
524     IN EFI_HANDLE               Handle,
525     OUT EFI_GUID                ***ProtocolBuffer,
526     OUT UINTN                   *ProtocolBufferCount
527     );
528 
529 typedef enum {
530     AllHandles,
531     ByRegisterNotify,
532     ByProtocol
533 } EFI_LOCATE_SEARCH_TYPE;
534 
535 typedef
536 EFI_STATUS
537 (EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
538     IN EFI_LOCATE_SEARCH_TYPE   SearchType,
539     IN EFI_GUID                 *Protocol OPTIONAL,
540     IN VOID                     *SearchKey OPTIONAL,
541     IN OUT UINTN                *NoHandles,
542     OUT EFI_HANDLE              **Buffer
543     );
544 
545 typedef
546 EFI_STATUS
547 (EFIAPI *EFI_LOCATE_PROTOCOL) (
548     IN EFI_GUID                 *Protocol,
549     IN VOID                     *Registration OPTIONAL,
550     OUT VOID                    **Interface
551     );
552 
553 typedef
554 EFI_STATUS
555 (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
556     IN OUT EFI_HANDLE           *Handle,
557     ...
558     );
559 
560 typedef
561 EFI_STATUS
562 (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
563     IN OUT EFI_HANDLE           Handle,
564     ...
565     );
566 
567 typedef
568 EFI_STATUS
569 (EFIAPI *EFI_CALCULATE_CRC32) (
570     IN VOID                     *Data,
571     IN UINTN                    DataSize,
572     OUT UINT32                  *Crc32
573     );
574 
575 typedef
576 VOID
577 (EFIAPI *EFI_COPY_MEM) (
578     IN VOID                     *Destination,
579     IN VOID                     *Source,
580     IN UINTN                    Length
581     );
582 
583 typedef
584 VOID
585 (EFIAPI *EFI_SET_MEM) (
586     IN VOID                     *Buffer,
587     IN UINTN                    Size,
588     IN UINT8                    Value
589     );
590 
591 
592 typedef
593 EFI_STATUS
594 (EFIAPI *EFI_CREATE_EVENT_EX) (
595     IN UINT32                   Type,
596     IN EFI_TPL                  NotifyTpl,
597     IN EFI_EVENT_NOTIFY         NotifyFunction OPTIONAL,
598     IN const VOID               *NotifyContext OPTIONAL,
599     IN const EFI_GUID           *EventGroup OPTIONAL,
600     OUT EFI_EVENT               *Event
601     );
602 
603 typedef enum {
604     EfiResetCold,
605     EfiResetWarm,
606     EfiResetShutdown
607 } EFI_RESET_TYPE;
608 
609 typedef
610 EFI_STATUS
611 (EFIAPI *EFI_RESET_SYSTEM) (
612     IN EFI_RESET_TYPE           ResetType,
613     IN EFI_STATUS               ResetStatus,
614     IN UINTN                    DataSize,
615     IN CHAR16                   *ResetData OPTIONAL
616     );
617 
618 typedef
619 EFI_STATUS
620 (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
621     OUT UINT64                  *Count
622     );
623 
624 typedef
625 EFI_STATUS
626 (EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
627     OUT UINT32                  *HighCount
628     );
629 
630 typedef struct {
631     UINT64                      Length;
632     union {
633         EFI_PHYSICAL_ADDRESS    DataBlock;
634        EFI_PHYSICAL_ADDRESS    ContinuationPointer;
635     } Union;
636 } EFI_CAPSULE_BLOCK_DESCRIPTOR;
637 
638 typedef struct {
639     EFI_GUID                    CapsuleGuid;
640     UINT32                      HeaderSize;
641     UINT32                      Flags;
642     UINT32                      CapsuleImageSize;
643 } EFI_CAPSULE_HEADER;
644 
645 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET    0x00010000
646 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE   0x00020000
647 #define CAPSULE_FLAGS_INITIATE_RESET          0x00040000
648 
649 typedef
650 EFI_STATUS
651 (EFIAPI *EFI_UPDATE_CAPSULE) (
652     IN EFI_CAPSULE_HEADER       **CapsuleHeaderArray,
653     IN UINTN                    CapsuleCount,
654     IN EFI_PHYSICAL_ADDRESS     ScatterGatherList OPTIONAL
655     );
656 
657 typedef
658 EFI_STATUS
659 (EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) (
660     IN  EFI_CAPSULE_HEADER       **CapsuleHeaderArray,
661     IN  UINTN                    CapsuleCount,
662     OUT UINT64                   *MaximumCapsuleSize,
663     OUT EFI_RESET_TYPE           *ResetType
664     );
665 
666 typedef
667 EFI_STATUS
668 (EFIAPI *EFI_QUERY_VARIABLE_INFO) (
669     IN  UINT32                  Attributes,
670     OUT UINT64                  *MaximumVariableStorageSize,
671     OUT UINT64                  *RemainingVariableStorageSize,
672     OUT UINT64                  *MaximumVariableSize
673     );
674 
675 //
676 // Protocol handler functions
677 //
678 
679 typedef enum {
680     EFI_NATIVE_INTERFACE,
681     EFI_PCODE_INTERFACE
682 } EFI_INTERFACE_TYPE;
683 
684 typedef
685 EFI_STATUS
686 (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
687     IN OUT EFI_HANDLE           *Handle,
688     IN EFI_GUID                 *Protocol,
689     IN EFI_INTERFACE_TYPE       InterfaceType,
690     IN VOID                     *Interface
691     );
692 
693 typedef
694 EFI_STATUS
695 (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
696     IN EFI_HANDLE               Handle,
697     IN EFI_GUID                 *Protocol,
698     IN VOID                     *OldInterface,
699     IN VOID                     *NewInterface
700     );
701 
702 typedef
703 EFI_STATUS
704 (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
705     IN EFI_HANDLE               Handle,
706     IN EFI_GUID                 *Protocol,
707     IN VOID                     *Interface
708     );
709 
710 typedef
711 EFI_STATUS
712 (EFIAPI *EFI_HANDLE_PROTOCOL) (
713     IN EFI_HANDLE               Handle,
714     IN EFI_GUID                 *Protocol,
715     OUT VOID                    **Interface
716     );
717 
718 typedef
719 EFI_STATUS
720 (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
721     IN EFI_GUID                 *Protocol,
722     IN EFI_EVENT                Event,
723     OUT VOID                    **Registration
724     );
725 
726 typedef
727 EFI_STATUS
728 (EFIAPI *EFI_LOCATE_HANDLE) (
729     IN EFI_LOCATE_SEARCH_TYPE   SearchType,
730     IN EFI_GUID                 *Protocol OPTIONAL,
731     IN VOID                     *SearchKey OPTIONAL,
732     IN OUT UINTN                *BufferSize,
733     OUT EFI_HANDLE              *Buffer
734     );
735 
736 typedef
737 EFI_STATUS
738 (EFIAPI *EFI_LOCATE_DEVICE_PATH) (
739     IN EFI_GUID                 *Protocol,
740     IN OUT EFI_DEVICE_PATH      **DevicePath,
741     OUT EFI_HANDLE              *Device
742     );
743 
744 typedef
745 EFI_STATUS
746 (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
747     IN EFI_GUID                 *Guid,
748     IN VOID                     *Table
749     );
750 
751 typedef
752 EFI_STATUS
753 (EFIAPI *EFI_RESERVED_SERVICE) (
754     );
755 
756 //
757 // Standard EFI table header
758 //
759 
760 typedef struct _EFI_TABLE_HEADER {
761     UINT64                      Signature;
762     UINT32                      Revision;
763     UINT32                      HeaderSize;
764     UINT32                      CRC32;
765     UINT32                      Reserved;
766 } EFI_TABLE_HEADER;
767 
768 
769 //
770 // EFI Runtime Serivces Table
771 //
772 
773 #define EFI_RUNTIME_SERVICES_SIGNATURE  0x56524553544e5552
774 #define EFI_RUNTIME_SERVICES_REVISION   (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
775 
776 typedef struct  {
777     EFI_TABLE_HEADER                Hdr;
778 
779     //
780     // Time services
781     //
782 
783     EFI_GET_TIME                    GetTime;
784     EFI_SET_TIME                    SetTime;
785     EFI_GET_WAKEUP_TIME             GetWakeupTime;
786     EFI_SET_WAKEUP_TIME             SetWakeupTime;
787 
788     //
789     // Virtual memory services
790     //
791 
792     EFI_SET_VIRTUAL_ADDRESS_MAP     SetVirtualAddressMap;
793     EFI_CONVERT_POINTER             ConvertPointer;
794 
795     //
796     // Variable serviers
797     //
798 
799     EFI_GET_VARIABLE                GetVariable;
800     EFI_GET_NEXT_VARIABLE_NAME      GetNextVariableName;
801     EFI_SET_VARIABLE                SetVariable;
802 
803     //
804     // Misc
805     //
806 
807     EFI_GET_NEXT_HIGH_MONO_COUNT    GetNextHighMonotonicCount;
808     EFI_RESET_SYSTEM                ResetSystem;
809 
810     EFI_UPDATE_CAPSULE              UpdateCapsule;
811     EFI_QUERY_CAPSULE_CAPABILITIES  QueryCapsuleCapabilities;
812     EFI_QUERY_VARIABLE_INFO         QueryVariableInfo;
813 } EFI_RUNTIME_SERVICES;
814 
815 
816 //
817 // EFI Boot Services Table
818 //
819 
820 #define EFI_BOOT_SERVICES_SIGNATURE     0x56524553544f4f42
821 #define EFI_BOOT_SERVICES_REVISION      (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
822 
823 typedef struct _EFI_BOOT_SERVICES {
824 
825     EFI_TABLE_HEADER                Hdr;
826 
827     //
828     // Task priority functions
829     //
830 
831     EFI_RAISE_TPL                   RaiseTPL;
832     EFI_RESTORE_TPL                 RestoreTPL;
833 
834     //
835     // Memory functions
836     //
837 
838     EFI_ALLOCATE_PAGES              AllocatePages;
839     EFI_FREE_PAGES                  FreePages;
840     EFI_GET_MEMORY_MAP              GetMemoryMap;
841     EFI_ALLOCATE_POOL               AllocatePool;
842     EFI_FREE_POOL                   FreePool;
843 
844     //
845     // Event & timer functions
846     //
847 
848     EFI_CREATE_EVENT                CreateEvent;
849     EFI_SET_TIMER                   SetTimer;
850     EFI_WAIT_FOR_EVENT              WaitForEvent;
851     EFI_SIGNAL_EVENT                SignalEvent;
852     EFI_CLOSE_EVENT                 CloseEvent;
853     EFI_CHECK_EVENT                 CheckEvent;
854 
855     //
856     // Protocol handler functions
857     //
858 
859     EFI_INSTALL_PROTOCOL_INTERFACE  InstallProtocolInterface;
860     EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
861     EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
862     EFI_HANDLE_PROTOCOL             HandleProtocol;
863     EFI_HANDLE_PROTOCOL             PCHandleProtocol;
864     EFI_REGISTER_PROTOCOL_NOTIFY    RegisterProtocolNotify;
865     EFI_LOCATE_HANDLE               LocateHandle;
866     EFI_LOCATE_DEVICE_PATH          LocateDevicePath;
867     EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
868 
869     //
870     // Image functions
871     //
872 
873     EFI_IMAGE_LOAD                  LoadImage;
874     EFI_IMAGE_START                 StartImage;
875     EFI_EXIT                        Exit;
876     EFI_IMAGE_UNLOAD                UnloadImage;
877     EFI_EXIT_BOOT_SERVICES          ExitBootServices;
878 
879     //
880     // Misc functions
881     //
882 
883     EFI_GET_NEXT_MONOTONIC_COUNT    GetNextMonotonicCount;
884     EFI_STALL                       Stall;
885     EFI_SET_WATCHDOG_TIMER          SetWatchdogTimer;
886 
887     //
888     // DriverSupport Services
889     //
890 
891     EFI_CONNECT_CONTROLLER          ConnectController;
892     EFI_DISCONNECT_CONTROLLER       DisconnectController;
893 
894     //
895     // Open and Close Protocol Services
896     //
897     EFI_OPEN_PROTOCOL               OpenProtocol;
898     EFI_CLOSE_PROTOCOL              CloseProtocol;
899     EFI_OPEN_PROTOCOL_INFORMATION   OpenProtocolInformation;
900 
901     //
902     // Library Services
903     //
904     EFI_PROTOCOLS_PER_HANDLE        ProtocolsPerHandle;
905     EFI_LOCATE_HANDLE_BUFFER        LocateHandleBuffer;
906     EFI_LOCATE_PROTOCOL             LocateProtocol;
907     EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
908     EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
909 
910     //
911     // 32-bit CRC Services
912     //
913     EFI_CALCULATE_CRC32             CalculateCrc32;
914 
915     //
916     // Misc Services
917     //
918     EFI_COPY_MEM                    CopyMem;
919     EFI_SET_MEM                     SetMem;
920     EFI_CREATE_EVENT_EX             CreateEventEx;
921 } EFI_BOOT_SERVICES;
922 
923 
924 //
925 // EFI Configuration Table and GUID definitions
926 //
927 
928 #define MPS_TABLE_GUID    \
929     { 0xeb9d2d2f, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
930 
931 #define ACPI_TABLE_GUID    \
932     { 0xeb9d2d30, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
933 
934 #define ACPI_20_TABLE_GUID  \
935     { 0x8868e871, 0xe4f1, 0x11d3, {0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} }
936 
937 #define SMBIOS_TABLE_GUID    \
938     { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
939 
940 #define SMBIOS3_TABLE_GUID    \
941     { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} }
942 
943 #define SAL_SYSTEM_TABLE_GUID    \
944     { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
945 
946 #define EFI_DTB_TABLE_GUID \
947     { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} }
948 
949 typedef struct _EFI_CONFIGURATION_TABLE {
950     EFI_GUID                VendorGuid;
951     VOID                    *VendorTable;
952 } EFI_CONFIGURATION_TABLE;
953 
954 
955 //
956 // EFI System Table
957 //
958 
959 
960 
961 
962 #define EFI_SYSTEM_TABLE_SIGNATURE      0x5453595320494249
963 #define EFI_SYSTEM_TABLE_REVISION      (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
964 
965 typedef struct _EFI_SYSTEM_TABLE {
966     EFI_TABLE_HEADER                Hdr;
967 
968     CHAR16                          *FirmwareVendor;
969     UINT32                          FirmwareRevision;
970 
971     EFI_HANDLE                      ConsoleInHandle;
972     SIMPLE_INPUT_INTERFACE          *ConIn;
973 
974     EFI_HANDLE                      ConsoleOutHandle;
975     SIMPLE_TEXT_OUTPUT_INTERFACE    *ConOut;
976 
977     EFI_HANDLE                      StandardErrorHandle;
978     SIMPLE_TEXT_OUTPUT_INTERFACE    *StdErr;
979 
980     EFI_RUNTIME_SERVICES            *RuntimeServices;
981     EFI_BOOT_SERVICES               *BootServices;
982 
983     UINTN                           NumberOfTableEntries;
984     EFI_CONFIGURATION_TABLE         *ConfigurationTable;
985 
986 } EFI_SYSTEM_TABLE;
987 
988 #endif
989 
990