xref: /illumos-gate/usr/src/boot/efi/include/Protocol/Runtime.h (revision f334afcfaebea1b7dc3430015651d8d748fa8a3e)
1 /** @file
2   Runtime Architectural Protocol as defined in PI Specification VOLUME 2 DXE
3 
4   Allows the runtime functionality of the DXE Foundation to be contained
5   in a separate driver. It also provides hooks for the DXE Foundation to
6   export information that is needed at runtime. As such, this protocol allows
7   services to the DXE Foundation to manage runtime drivers and events.
8   This protocol also implies that the runtime services required to transition
9   to virtual mode, SetVirtualAddressMap() and ConvertPointer(), have been
10   registered into the UEFI Runtime Table in the UEFI System Table. This protocol
11   must be produced by a runtime DXE driver and may only be consumed by the DXE Foundation.
12 
13   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
14   SPDX-License-Identifier: BSD-2-Clause-Patent
15 
16 **/
17 
18 #ifndef __ARCH_PROTOCOL_RUNTIME_H__
19 #define __ARCH_PROTOCOL_RUNTIME_H__
20 
21 ///
22 /// Global ID for the Runtime Architectural Protocol
23 ///
24 #define EFI_RUNTIME_ARCH_PROTOCOL_GUID \
25   { 0xb7dfb4e1, 0x52f, 0x449f, {0x87, 0xbe, 0x98, 0x18, 0xfc, 0x91, 0xb7, 0x33 } }
26 
27 typedef struct _EFI_RUNTIME_ARCH_PROTOCOL EFI_RUNTIME_ARCH_PROTOCOL;
28 
29 ///
30 /// LIST_ENTRY from BaseType
31 ///
32 typedef LIST_ENTRY EFI_LIST_ENTRY;
33 
34 typedef struct _EFI_RUNTIME_IMAGE_ENTRY EFI_RUNTIME_IMAGE_ENTRY;
35 
36 ///
37 /// EFI_RUNTIME_IMAGE_ENTRY
38 ///
39 struct _EFI_RUNTIME_IMAGE_ENTRY {
40   ///
41   /// Start of image that has been loaded in memory. It is a pointer
42   /// to either the DOS header or PE header of the image.
43   ///
44   VOID              *ImageBase;
45   ///
46   /// Size in bytes of the image represented by ImageBase.
47   ///
48   UINT64            ImageSize;
49   ///
50   /// Information about the fix-ups that were performed on ImageBase when it was
51   /// loaded into memory.
52   ///
53   VOID              *RelocationData;
54   ///
55   /// The ImageHandle passed into ImageBase when it was loaded.
56   ///
57   EFI_HANDLE        Handle;
58   ///
59   /// Entry for this node in the EFI_RUNTIME_ARCHITECTURE_PROTOCOL.ImageHead list.
60   ///
61   EFI_LIST_ENTRY    Link;
62 };
63 
64 typedef struct _EFI_RUNTIME_EVENT_ENTRY EFI_RUNTIME_EVENT_ENTRY;
65 
66 ///
67 /// EFI_RUNTIME_EVENT_ENTRY
68 ///
69 struct _EFI_RUNTIME_EVENT_ENTRY {
70   ///
71   /// The same as Type passed into CreateEvent().
72   ///
73   UINT32              Type;
74   ///
75   /// The same as NotifyTpl passed into CreateEvent().
76   ///
77   EFI_TPL             NotifyTpl;
78   ///
79   /// The same as NotifyFunction passed into CreateEvent().
80   ///
81   EFI_EVENT_NOTIFY    NotifyFunction;
82   ///
83   /// The same as NotifyContext passed into CreateEvent().
84   ///
85   VOID                *NotifyContext;
86   ///
87   /// The EFI_EVENT returned by CreateEvent(). Event must be in runtime memory.
88   ///
89   EFI_EVENT           *Event;
90   ///
91   /// Entry for this node in the
92   /// EFI_RUNTIME_ARCHITECTURE_PROTOCOL.EventHead list.
93   ///
94   EFI_LIST_ENTRY      Link;
95 };
96 
97 ///
98 /// Allows the runtime functionality of the DXE Foundation to be contained in a
99 /// separate driver. It also provides hooks for the DXE Foundation to export
100 /// information that is needed at runtime. As such, this protocol allows the DXE
101 /// Foundation to manage runtime drivers and events. This protocol also implies
102 /// that the runtime services required to transition to virtual mode,
103 /// SetVirtualAddressMap() and ConvertPointer(), have been registered into the
104 /// EFI Runtime Table in the EFI System Partition.  This protocol must be produced
105 /// by a runtime DXE driver and may only be consumed by the DXE Foundation.
106 ///
107 struct _EFI_RUNTIME_ARCH_PROTOCOL {
108   EFI_LIST_ENTRY           ImageHead;              ///< A list of type EFI_RUNTIME_IMAGE_ENTRY.
109   EFI_LIST_ENTRY           EventHead;              ///< A list of type EFI_RUNTIME_EVENT_ENTRY.
110   UINTN                    MemoryDescriptorSize;   ///< Size of a memory descriptor that is returned by GetMemoryMap().
111   UINT32                   MemoryDesciptorVersion; ///< Version of a memory descriptor that is returned by GetMemoryMap().
112   UINTN                    MemoryMapSize;          ///< Size of the memory map in bytes contained in MemoryMapPhysical and MemoryMapVirtual.
113   EFI_MEMORY_DESCRIPTOR    *MemoryMapPhysical;     ///< Pointer to a runtime buffer that contains a copy of
114                                                    ///< the memory map returned via GetMemoryMap().
115   EFI_MEMORY_DESCRIPTOR    *MemoryMapVirtual;      ///< Pointer to MemoryMapPhysical that is updated to virtual mode after SetVirtualAddressMap().
116   BOOLEAN                  VirtualMode;            ///< Boolean that is TRUE if SetVirtualAddressMap() has been called.
117   BOOLEAN                  AtRuntime;              ///< Boolean that is TRUE if ExitBootServices () has been called.
118 };
119 
120 extern EFI_GUID  gEfiRuntimeArchProtocolGuid;
121 
122 #endif
123