1 /* $NetBSD: efiapi.h,v 1.1 2006/04/07 14:21:29 cherry Exp $ */
2 /* $FreeBSD: src/sys/boot/efi/include/efiapi.h,v 1.6 2003/12/10 19:08:09 jhb Exp $ */
8 Copyright (c) 1998 Intel Corporation
16 Global EFI runtime & boot service interfaces
26 * EFI Specification Revision
29 #define EFI_SPECIFICATION_MAJOR_REVISION 1
30 #define EFI_SPECIFICATION_MINOR_REVISION 02
33 * Declare forward referenced data structures
36 INTERFACE_DECL(_EFI_SYSTEM_TABLE
);
44 (EFIAPI
*EFI_ALLOCATE_PAGES
) (
45 IN EFI_ALLOCATE_TYPE Type
,
46 IN EFI_MEMORY_TYPE MemoryType
,
48 OUT EFI_PHYSICAL_ADDRESS
*Memory
53 (EFIAPI
*EFI_FREE_PAGES
) (
54 IN EFI_PHYSICAL_ADDRESS Memory
,
60 (EFIAPI
*EFI_GET_MEMORY_MAP
) (
61 IN OUT UINTN
*MemoryMapSize
,
62 IN OUT EFI_MEMORY_DESCRIPTOR
*MemoryMap
,
64 OUT UINTN
*DescriptorSize
,
65 OUT UINT32
*DescriptorVersion
68 #define NextMemoryDescriptor(Ptr,Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) Ptr) + Size))
73 (EFIAPI
*EFI_ALLOCATE_POOL
) (
74 IN EFI_MEMORY_TYPE PoolType
,
81 (EFIAPI
*EFI_FREE_POOL
) (
87 (EFIAPI
*EFI_SET_VIRTUAL_ADDRESS_MAP
) (
88 IN UINTN MemoryMapSize
,
89 IN UINTN DescriptorSize
,
90 IN UINT32 DescriptorVersion
,
91 IN EFI_MEMORY_DESCRIPTOR
*VirtualMap
95 #define EFI_OPTIONAL_PTR 0x00000001
96 #define EFI_INTERNAL_FNC 0x00000002 /* Pointer to internal runtime fnc */
97 #define EFI_INTERNAL_PTR 0x00000004 /* Pointer to internal runtime data */
102 (EFIAPI
*EFI_CONVERT_POINTER
) (
103 IN UINTN DebugDisposition
,
104 IN OUT VOID
**Address
114 #define EVT_TIMER 0x80000000
115 #define EVT_RUNTIME 0x40000000
116 #define EVT_RUNTIME_CONTEXT 0x20000000
118 #define EVT_NOTIFY_WAIT 0x00000100
119 #define EVT_NOTIFY_SIGNAL 0x00000200
121 #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
122 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
124 #define EVT_EFI_SIGNAL_MASK 0x000000FF
125 #define EVT_EFI_SIGNAL_MAX 2
129 (EFIAPI
*EFI_EVENT_NOTIFY
) (
136 (EFIAPI
*EFI_CREATE_EVENT
) (
138 IN EFI_TPL NotifyTpl
,
139 IN EFI_EVENT_NOTIFY NotifyFunction
,
140 IN VOID
*NotifyContext
,
153 (EFIAPI
*EFI_SET_TIMER
) (
155 IN EFI_TIMER_DELAY Type
,
156 IN UINT64 TriggerTime
161 (EFIAPI
*EFI_SIGNAL_EVENT
) (
167 (EFIAPI
*EFI_WAIT_FOR_EVENT
) (
168 IN UINTN NumberOfEvents
,
175 (EFIAPI
*EFI_CLOSE_EVENT
) (
181 (EFIAPI
*EFI_CHECK_EVENT
) (
186 * Task priority level
189 #define TPL_APPLICATION 4
190 #define TPL_CALLBACK 8
191 #define TPL_NOTIFY 16
192 #define TPL_HIGH_LEVEL 31
196 (EFIAPI
*EFI_RAISE_TPL
) (
202 (EFIAPI
*EFI_RESTORE_TPL
) (
208 * EFI platform variables
211 #define EFI_GLOBAL_VARIABLE \
212 { 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }
214 /* Variable attributes */
215 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
216 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
217 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
219 /* Variable size limitation */
220 #define EFI_MAXIMUM_VARIABLE_SIZE 1024
224 (EFIAPI
*EFI_GET_VARIABLE
) (
225 IN CHAR16
*VariableName
,
226 IN EFI_GUID
*VendorGuid
,
227 OUT UINT32
*Attributes OPTIONAL
,
228 IN OUT UINTN
*DataSize
,
234 (EFIAPI
*EFI_GET_NEXT_VARIABLE_NAME
) (
235 IN OUT UINTN
*VariableNameSize
,
236 IN OUT CHAR16
*VariableName
,
237 IN OUT EFI_GUID
*VendorGuid
243 (EFIAPI
*EFI_SET_VARIABLE
) (
244 IN CHAR16
*VariableName
,
245 IN EFI_GUID
*VendorGuid
,
246 IN UINT32 Attributes
,
257 UINT32 Resolution
; /* 1e-6 parts per million */
258 UINT32 Accuracy
; /* hertz */
259 BOOLEAN SetsToZero
; /* Set clears sub-second time */
260 } EFI_TIME_CAPABILITIES
;
265 (EFIAPI
*EFI_GET_TIME
) (
267 OUT EFI_TIME_CAPABILITIES
*Capabilities OPTIONAL
272 (EFIAPI
*EFI_SET_TIME
) (
278 (EFIAPI
*EFI_GET_WAKEUP_TIME
) (
279 OUT BOOLEAN
*Enabled
,
280 OUT BOOLEAN
*Pending
,
286 (EFIAPI
*EFI_SET_WAKEUP_TIME
) (
288 IN EFI_TIME
*Time OPTIONAL
297 /* PE32+ Subsystem type for EFI images */
299 #if !defined(IMAGE_SUBSYSTEM_EFI_APPLICATION)
300 #define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
301 #define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
302 #define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
305 /* PE32+ Machine type for EFI images */
307 #if !defined(EFI_IMAGE_MACHINE_IA32)
308 #define EFI_IMAGE_MACHINE_IA32 0x014c
311 #if !defined(EFI_IMAGE_MACHINE_IA64)
312 #define EFI_IMAGE_MACHINE_IA64 0x0200
315 /* Image Entry prototype */
319 (EFIAPI
*EFI_IMAGE_ENTRY_POINT
) (
320 IN EFI_HANDLE ImageHandle
,
321 IN
struct _EFI_SYSTEM_TABLE
*SystemTable
326 (EFIAPI
*EFI_IMAGE_LOAD
) (
327 IN BOOLEAN BootPolicy
,
328 IN EFI_HANDLE ParentImageHandle
,
329 IN EFI_DEVICE_PATH
*FilePath
,
330 IN VOID
*SourceBuffer OPTIONAL
,
332 OUT EFI_HANDLE
*ImageHandle
337 (EFIAPI
*EFI_IMAGE_START
) (
338 IN EFI_HANDLE ImageHandle
,
339 OUT UINTN
*ExitDataSize
,
340 OUT CHAR16
**ExitData OPTIONAL
346 IN EFI_HANDLE ImageHandle
,
347 IN EFI_STATUS ExitStatus
,
348 IN UINTN ExitDataSize
,
349 IN CHAR16
*ExitData OPTIONAL
354 (EFIAPI
*EFI_IMAGE_UNLOAD
) (
355 IN EFI_HANDLE ImageHandle
360 #define LOADED_IMAGE_PROTOCOL \
361 { 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }
363 #define EFI_IMAGE_INFORMATION_REVISION 0x1000
366 EFI_HANDLE ParentHandle
;
367 struct _EFI_SYSTEM_TABLE
*SystemTable
;
369 /* Source location of image */
370 EFI_HANDLE DeviceHandle
;
371 EFI_DEVICE_PATH
*FilePath
;
374 /* Images load options */
375 UINT32 LoadOptionsSize
;
378 /* Location of where image was loaded */
381 EFI_MEMORY_TYPE ImageCodeType
;
382 EFI_MEMORY_TYPE ImageDataType
;
384 /* If the driver image supports a dynamic unload request */
385 EFI_IMAGE_UNLOAD Unload
;
392 (EFIAPI
*EFI_EXIT_BOOT_SERVICES
) (
393 IN EFI_HANDLE ImageHandle
,
404 (EFIAPI
*EFI_STALL
) (
405 IN UINTN Microseconds
410 (EFIAPI
*EFI_SET_WATCHDOG_TIMER
) (
412 IN UINT64 WatchdogCode
,
414 IN CHAR16
*WatchdogData OPTIONAL
425 (EFIAPI
*EFI_RESET_SYSTEM
) (
426 IN EFI_RESET_TYPE ResetType
,
427 IN EFI_STATUS ResetStatus
,
429 IN CHAR16
*ResetData OPTIONAL
434 (EFIAPI
*EFI_GET_NEXT_MONOTONIC_COUNT
) (
440 (EFIAPI
*EFI_GET_NEXT_HIGH_MONO_COUNT
) (
441 OUT UINT32
*HighCount
445 * Protocol handler functions
449 EFI_NATIVE_INTERFACE
,
451 } EFI_INTERFACE_TYPE
;
455 (EFIAPI
*EFI_INSTALL_PROTOCOL_INTERFACE
) (
456 IN OUT EFI_HANDLE
*Handle
,
457 IN EFI_GUID
*Protocol
,
458 IN EFI_INTERFACE_TYPE InterfaceType
,
464 (EFIAPI
*EFI_REINSTALL_PROTOCOL_INTERFACE
) (
465 IN EFI_HANDLE Handle
,
466 IN EFI_GUID
*Protocol
,
467 IN VOID
*OldInterface
,
468 IN VOID
*NewInterface
473 (EFIAPI
*EFI_UNINSTALL_PROTOCOL_INTERFACE
) (
474 IN EFI_HANDLE Handle
,
475 IN EFI_GUID
*Protocol
,
481 (EFIAPI
*EFI_HANDLE_PROTOCOL
) (
482 IN EFI_HANDLE Handle
,
483 IN EFI_GUID
*Protocol
,
489 (EFIAPI
*EFI_REGISTER_PROTOCOL_NOTIFY
) (
490 IN EFI_GUID
*Protocol
,
492 OUT VOID
**Registration
499 } EFI_LOCATE_SEARCH_TYPE
;
503 (EFIAPI
*EFI_LOCATE_HANDLE
) (
504 IN EFI_LOCATE_SEARCH_TYPE SearchType
,
505 IN EFI_GUID
*Protocol OPTIONAL
,
506 IN VOID
*SearchKey OPTIONAL
,
507 IN OUT UINTN
*BufferSize
,
508 OUT EFI_HANDLE
*Buffer
513 (EFIAPI
*EFI_LOCATE_DEVICE_PATH
) (
514 IN EFI_GUID
*Protocol
,
515 IN OUT EFI_DEVICE_PATH
**DevicePath
,
516 OUT EFI_HANDLE
*Device
521 (EFIAPI
*EFI_INSTALL_CONFIGURATION_TABLE
) (
528 (EFIAPI
*EFI_RESERVED_SERVICE
) (
533 * Standard EFI table header
536 typedef struct _EFI_TABLE_HEARDER
{
546 * EFI Runtime Serivces Table
549 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
550 #define EFI_RUNTIME_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
553 EFI_TABLE_HEADER Hdr
;
557 EFI_GET_TIME GetTime
;
558 EFI_SET_TIME SetTime
;
559 EFI_GET_WAKEUP_TIME GetWakeupTime
;
560 EFI_SET_WAKEUP_TIME SetWakeupTime
;
562 /* Virtual memory services */
564 EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap
;
565 EFI_CONVERT_POINTER ConvertPointer
;
567 /* Variable serviers */
569 EFI_GET_VARIABLE GetVariable
;
570 EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName
;
571 EFI_SET_VARIABLE SetVariable
;
575 EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount
;
576 EFI_RESET_SYSTEM ResetSystem
;
578 } EFI_RUNTIME_SERVICES
;
582 * EFI Boot Services Table
585 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
586 #define EFI_BOOT_SERVICES_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
588 typedef struct _EFI_BOOT_SERVICES
{
590 EFI_TABLE_HEADER Hdr
;
592 /* Task priority functions */
594 EFI_RAISE_TPL RaiseTPL
;
595 EFI_RESTORE_TPL RestoreTPL
;
597 /* Memory functions */
599 EFI_ALLOCATE_PAGES AllocatePages
;
600 EFI_FREE_PAGES FreePages
;
601 EFI_GET_MEMORY_MAP GetMemoryMap
;
602 EFI_ALLOCATE_POOL AllocatePool
;
603 EFI_FREE_POOL FreePool
;
605 /* Event & timer functions */
607 EFI_CREATE_EVENT CreateEvent
;
608 EFI_SET_TIMER SetTimer
;
609 EFI_WAIT_FOR_EVENT WaitForEvent
;
610 EFI_SIGNAL_EVENT SignalEvent
;
611 EFI_CLOSE_EVENT CloseEvent
;
612 EFI_CHECK_EVENT CheckEvent
;
614 /* Protocol handler functions */
616 EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface
;
617 EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface
;
618 EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface
;
619 EFI_HANDLE_PROTOCOL HandleProtocol
;
620 EFI_HANDLE_PROTOCOL PCHandleProtocol
;
621 EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify
;
622 EFI_LOCATE_HANDLE LocateHandle
;
623 EFI_LOCATE_DEVICE_PATH LocateDevicePath
;
624 EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable
;
626 /* Image functions */
628 EFI_IMAGE_LOAD LoadImage
;
629 EFI_IMAGE_START StartImage
;
631 EFI_IMAGE_UNLOAD UnloadImage
;
632 EFI_EXIT_BOOT_SERVICES ExitBootServices
;
636 EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount
;
638 EFI_SET_WATCHDOG_TIMER SetWatchdogTimer
;
644 * EFI Configuration Table and GUID definitions
647 #define MPS_TABLE_GUID \
648 { 0xeb9d2d2f, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
650 #define ACPI_TABLE_GUID \
651 { 0xeb9d2d30, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
653 #define ACPI_20_TABLE_GUID \
654 { 0x8868e871, 0xe4f1, 0x11d3, { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
656 #define SMBIOS_TABLE_GUID \
657 { 0xeb9d2d31, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
659 #define SAL_SYSTEM_TABLE_GUID \
660 { 0xeb9d2d32, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
662 /* DIG64 Headless Console & Debug Port Table. */
663 #define HCDP_TABLE_GUID \
664 {0xf951938d,0x620b,0x42ef,{0x82,0x79,0xa8,0x4b,0x79,0x61,0x78,0x98}}
666 typedef struct _EFI_CONFIGURATION_TABLE
{
669 } EFI_CONFIGURATION_TABLE
;
679 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
680 #define EFI_SYSTEM_TABLE_REVISION (EFI_SPECIFICATION_MAJOR_REVISION<<16) | (EFI_SPECIFICATION_MINOR_REVISION)
682 typedef struct _EFI_SYSTEM_TABLE
{
683 EFI_TABLE_HEADER Hdr
;
685 CHAR16
*FirmwareVendor
;
686 UINT32 FirmwareRevision
;
688 EFI_HANDLE ConsoleInHandle
;
689 SIMPLE_INPUT_INTERFACE
*ConIn
;
691 EFI_HANDLE ConsoleOutHandle
;
692 SIMPLE_TEXT_OUTPUT_INTERFACE
*ConOut
;
694 EFI_HANDLE StandardErrorHandle
;
695 SIMPLE_TEXT_OUTPUT_INTERFACE
*StdErr
;
697 EFI_RUNTIME_SERVICES
*RuntimeServices
;
698 EFI_BOOT_SERVICES
*BootServices
;
700 UINTN NumberOfTableEntries
;
701 EFI_CONFIGURATION_TABLE
*ConfigurationTable
;