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