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