]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Library/EdkUefiRuntimeLib/Ipf/RuntimeLib.c
Remove commented out inclusion of SalApi.h
[mirror_edk2.git] / EdkModulePkg / Library / EdkUefiRuntimeLib / Ipf / RuntimeLib.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 RuntimeLib.c
15
16 --*/
17
18 #include <RuntimeLibInternal.h>
19
20 //
21 // Driver Lib Module Globals
22 //
23 static EFI_EVENT mEfiVirtualNotifyEvent;
24 EFI_RUNTIME_SERVICES *mRT;
25
26 VOID
27 EFIAPI
28 RuntimeDriverExitBootServices (
29 IN EFI_EVENT Event,
30 IN VOID *Context
31 )
32 /*++
33
34 Routine Description:
35
36 Set AtRuntime flag as TRUE after ExitBootServices
37
38 Arguments:
39
40 Event - The Event that is being processed
41
42 Context - Event Context
43
44 Returns:
45
46 None
47
48 --*/
49 {
50 if (EfiAtRuntime()) {
51 return;
52 }
53 }
54
55 VOID
56 EFIAPI
57 RuntimeLibVirtualNotifyEvent (
58 IN EFI_EVENT Event,
59 IN VOID *Context
60 )
61 /*++
62
63 Routine Description:
64
65 Fixup internal data so that EFI can be call in virtual mode.
66 Call the passed in Child Notify event and convert any pointers in
67 lib to virtual mode.
68
69 Arguments:
70
71 Event - The Event that is being processed
72
73 Context - Event Context
74
75 Returns:
76
77 None
78
79 --*/
80 {
81 UINTN Index;
82 EFI_EVENT_NOTIFY ChildNotifyEventHandler;
83
84 for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) {
85 ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];
86 ChildNotifyEventHandler (Event, NULL);
87 }
88
89 //
90 // Update global for Runtime Services Table
91 //
92 EfiConvertPointer (0, (VOID **) &mRT);
93 }
94
95 EFI_STATUS
96 EFIAPI
97 RuntimeDriverLibConstruct (
98 IN EFI_HANDLE ImageHandle,
99 IN EFI_SYSTEM_TABLE *SystemTable
100 )
101 /*++
102
103 Routine Description:
104
105 Intialize runtime Driver Lib if it has not yet been initialized.
106
107 Arguments:
108
109 ImageHandle - The firmware allocated handle for the EFI image.
110
111 SystemTable - A pointer to the EFI System Table.
112
113 GoVirtualChildEvent - Caller can register a virtual notification event.
114
115 Returns:
116
117 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
118
119 --*/
120 {
121 EFI_STATUS Status;
122
123 mRT = SystemTable->RuntimeServices;
124
125 //
126 // Register SetVirtualAddressMap () notify function
127 //
128 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {
129 Status = gBS->CreateEvent (
130 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
131 EFI_TPL_NOTIFY,
132 RuntimeLibVirtualNotifyEvent,
133 NULL,
134 &mEfiVirtualNotifyEvent
135 );
136 ASSERT_EFI_ERROR (Status);
137 }
138
139 return EFI_SUCCESS;
140 }
141
142 EFI_STATUS
143 EFIAPI
144 RuntimeDriverLibDeconstruct (
145 VOID
146 )
147 /*++
148
149 Routine Description:
150
151 This routine will free some resources which have been allocated in
152 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
153 it must call this routine to free the allocated resource before the exiting.
154
155 Arguments:
156
157 None
158
159 Returns:
160
161 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
162 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
163
164 --*/
165 {
166 EFI_STATUS Status;
167
168 //
169 // Close SetVirtualAddressMap () notify function
170 //
171 if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {
172 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
173 ASSERT_EFI_ERROR (Status);
174 }
175
176 return EFI_SUCCESS;
177 }
178
179 BOOLEAN
180 EFIAPI
181 EfiAtRuntime (
182 VOID
183 )
184 /*++
185
186 Routine Description:
187 Return TRUE if ExitBootService () has been called
188
189 Arguments:
190 NONE
191
192 Returns:
193 TRUE - If ExitBootService () has been called
194
195 --*/
196 {
197 EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
198 SAL_RETURN_REGS ReturnReg;
199
200 ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);
201
202 return (BOOLEAN) (ReturnReg.r9 == 1);
203 }
204
205 BOOLEAN
206 EFIAPI
207 EfiGoneVirtual (
208 VOID
209 )
210 /*++
211
212 Routine Description:
213 Return TRUE if SetVirtualAddressMap () has been called
214
215 Arguments:
216 NONE
217
218 Returns:
219 TRUE - If SetVirtualAddressMap () has been called
220
221 --*/
222 {
223 EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
224 SAL_RETURN_REGS ReturnReg;
225
226 ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);
227
228 return (BOOLEAN) (ReturnReg.r9 == 1);
229 }
230