]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h
a5191f8f8a7546fe49cfa648c43389099615eeb9
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / Include / EfiMgmtModeRuntimeLib.h
1 /*++
2
3 Copyright (c) 2004, 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 EfiMgmtModeRuntimeLib.h
15
16 Abstract:
17
18 Light weight lib to support EFI drivers.
19
20 --*/
21
22 #ifndef _EFI_RT_SUPPORT_LIB_H_
23 #define _EFI_RT_SUPPORT_LIB_H_
24
25 #ifndef EFI_LOAD_IMAGE_SMM
26 #define EFI_LOAD_DRIVER_SMM FALSE
27 #else
28 #define EFI_LOAD_DRIVER_SMM TRUE
29 #endif
30
31 #ifndef EFI_NO_LOAD_IMAGE_RT
32 #define EFI_NO_LOAD_DRIVER_RT FALSE
33 #else
34 #define EFI_NO_LOAD_DRIVER_RT TRUE
35 #endif
36
37 #include "EfiCommonLib.h"
38 #include "LinkedList.h"
39 #include "ProcDep.h"
40
41 #include EFI_PROTOCOL_DEFINITION (CpuIo)
42 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
43
44 //
45 // Driver Lib Globals.
46 //
47 extern EFI_BOOT_SERVICES *gBS;
48 extern EFI_SYSTEM_TABLE *gST;
49 extern UINTN gRtErrorLevel;
50 extern BOOLEAN mEfiLoadDriverSmm;
51 extern BOOLEAN mEfiNoLoadDriverRt;
52 extern EFI_DEVICE_PATH_PROTOCOL *mFilePath;
53
54 //
55 // Runtime Memory Allocation/De-Allocation tools (Should be used in Boot Phase only)
56 //
57 EFI_STATUS
58 EfiAllocateRuntimeMemoryPool (
59 IN UINTN Size,
60 OUT VOID **Buffer
61 )
62 /*++
63
64 Routine Description:
65
66 Allocate EfiRuntimeServicesData pool of specified size.
67
68 Arguments:
69
70 Size - Pool size
71 Buffer - Memory pointer for output
72
73 Returns:
74
75 Status code
76
77 --*/
78 ;
79
80 EFI_STATUS
81 EfiFreeRuntimeMemoryPool (
82 IN VOID *Buffer
83 )
84 /*++
85
86 Routine Description:
87
88 Free allocated pool
89
90 Arguments:
91
92 Buffer - Pool to be freed
93
94 Returns:
95
96 Status code
97
98 --*/
99 ;
100
101 EFI_STATUS
102 EfiLocateProtocolHandleBuffers (
103 IN EFI_GUID *Protocol,
104 IN OUT UINTN *NumberHandles,
105 OUT EFI_HANDLE **Buffer
106 )
107 /*++
108
109 Routine Description:
110
111 Returns an array of handles that support the requested protocol in a buffer allocated from pool.
112
113 Arguments:
114
115 Protocol - Provides the protocol to search by.
116 NumberHandles - The number of handles returned in Buffer.
117 Buffer - A pointer to the buffer to return the requested array of handles that
118 support Protocol.
119
120 Returns:
121
122 Status code
123
124 --*/
125 ;
126
127 EFI_STATUS
128 EfiHandleProtocol (
129 IN EFI_HANDLE Handle,
130 IN EFI_GUID *Protocol,
131 OUT VOID **Interface
132 )
133 /*++
134
135 Routine Description:
136
137 Queries a handle to determine if it supports a specified protocol.
138
139 Arguments:
140
141 Handle - The handle being queried.
142 Protocol - The published unique identifier of the protocol.
143 Interface - Supplies the address where a pointer to the corresponding Protocol
144 Interface is returned. NULL will be returned in *Interface if a
145 structure is not associated with Protocol.
146
147 Returns:
148
149 Status code
150
151 --*/
152 ;
153
154 EFI_STATUS
155 EfiInstallProtocolInterface (
156 IN OUT EFI_HANDLE *Handle,
157 IN EFI_GUID *Protocol,
158 IN EFI_INTERFACE_TYPE InterfaceType,
159 IN VOID *Interface
160 )
161 /*++
162
163 Routine Description:
164
165 Installs a protocol interface on a device handle. If the handle does not exist, it is created and added
166 to the list of handles in the system.
167
168 Arguments:
169
170 Handle - A pointer to the EFI_HANDLE on which the interface is to be installed.
171 Protocol - The numeric ID of the protocol interface.
172 InterfaceType - Indicates whether Interface is supplied in native form.
173 Interface - A pointer to the protocol interface.
174
175 Returns:
176
177 Status code
178
179 --*/
180 ;
181
182 EFI_STATUS
183 EfiReinstallProtocolInterface (
184 IN EFI_HANDLE SmmProtocolHandle,
185 IN EFI_GUID *Protocol,
186 IN VOID *OldInterface,
187 IN VOID *NewInterface
188 )
189 /*++
190
191 Routine Description:
192
193 Reinstalls a protocol interface on a device handle.
194
195 Arguments:
196
197 SmmProtocolHandle - Handle on which the interface is to be reinstalled.
198 Protocol - The numeric ID of the interface.
199 OldInterface - A pointer to the old interface.
200 NewInterface - A pointer to the new interface.
201
202 Returns:
203
204 Status code
205
206 --*/
207 ;
208
209 EFI_STATUS
210 EfiLocateProtocolInterface (
211 EFI_GUID *Protocol,
212 VOID *Registration, OPTIONAL
213 VOID **Interface
214 )
215 /*++
216
217 Routine Description:
218
219 Returns the first protocol instance that matches the given protocol.
220
221 Arguments:
222
223 Protocol - Provides the protocol to search for.
224 Registration - Optional registration key returned from
225 RegisterProtocolNotify(). If Registration is NULL, then
226 it is ignored.
227 Interface - On return, a pointer to the first interface that matches Protocol and
228 Registration.
229
230 Returns:
231
232 Status code
233
234 --*/
235 ;
236
237 EFI_STATUS
238 UninstallProtocolInterface (
239 IN EFI_HANDLE SmmProtocolHandle,
240 IN EFI_GUID *Protocol,
241 IN VOID *Interface
242 )
243 /*++
244
245 Routine Description:
246
247 Removes a protocol interface from a device handle.
248
249 Arguments:
250
251 SmmProtocolHandle - The handle on which the interface was installed.
252 Protocol - The numeric ID of the interface.
253 Interface - A pointer to the interface.
254
255 Returns:
256
257 Status code
258
259 --*/
260 ;
261
262 EFI_STATUS
263 EfiRegisterProtocolCallback (
264 IN EFI_EVENT_NOTIFY CallbackFunction,
265 IN VOID *Context,
266 IN EFI_GUID *ProtocolGuid,
267 IN EFI_TPL NotifyTpl,
268 OUT VOID **Registeration,
269 OUT EFI_EVENT *Event
270 )
271 /*++
272
273 Routine Description:
274
275 Register a callback function to be signaled whenever an interface is installed for
276 a specified protocol.
277
278 Arguments:
279
280 CallbackFunction - Call back function
281 Context - Context of call back function
282 ProtocolGuid - The numeric ID of the protocol for which the callback function
283 is to be registered.
284 NotifyTpl - Notify tpl of callback function
285 Registeration - A pointer to a memory location to receive the registration value.
286 Event - Event that is to be signaled whenever a protocol interface is registered
287 for Protocol.
288
289 Returns:
290
291 Status code
292
293 --*/
294 ;
295
296 EFI_STATUS
297 EfiSignalProtocolEvent (
298 EFI_EVENT Event
299 )
300 /*++
301
302 Routine Description:
303
304 Signals an event.
305
306 Arguments:
307
308 Event - The event to signal.
309
310 Returns:
311
312 Status code
313
314 --*/
315 ;
316
317 EFI_STATUS
318 EfiInstallVendorConfigurationTable (
319 IN EFI_GUID *Guid,
320 IN VOID *Table
321 )
322 /*++
323
324 Routine Description:
325
326 Adds, updates, or removes a configuration table entry from the EFI System Table.
327
328 Arguments:
329
330 Guid - A pointer to the GUID for the entry to add, update, or remove.
331 Table - A pointer to the configuration table for the entry to add, update, or
332 remove. May be NULL.
333
334 Returns:
335
336 Status code
337
338 --*/
339 ;
340
341 EFI_STATUS
342 EfiGetVendorConfigurationTable (
343 IN EFI_GUID *Guid,
344 OUT VOID **Table
345 )
346 /*++
347
348 Routine Description:
349
350 Return the EFI 1.0 System Tabl entry with TableGuid
351
352 Arguments:
353
354 Guid - Name of entry to return in the system table
355 Table - Pointer in EFI system table associated with TableGuid
356
357 Returns:
358
359 EFI_SUCCESS - Table returned;
360 EFI_NOT_FOUND - TableGuid not in EFI system table
361
362 --*/
363 ;
364
365 EFI_STATUS
366 EfiInitializeUtilsRuntimeDriverLib (
367 IN EFI_HANDLE ImageHandle,
368 IN EFI_SYSTEM_TABLE *SystemTable,
369 IN EFI_EVENT_NOTIFY GoVirtualChildEvent
370 )
371 /*++
372
373 Routine Description:
374
375 Intialize runtime Driver Lib if it has not yet been initialized.
376
377 Arguments:
378
379 ImageHandle - The firmware allocated handle for the EFI image.
380
381 SystemTable - A pointer to the EFI System Table.
382
383 GoVirtualChildEvent - Caller can register a virtual notification event.
384
385 Returns:
386
387 EFI_STATUS always returns EFI_SUCCESS
388
389 --*/
390 ;
391
392 BOOLEAN
393 EfiInManagementInterrupt (
394 VOID
395 )
396 /*++
397
398 Routine Description:
399
400 Indicate whether the caller is already in SMM or not.
401
402 Arguments:
403
404 None
405
406 Returns:
407
408 TRUE - In SMM
409 FALSE - Not in SMM
410
411 --*/
412 ;
413
414 //
415 // This MACRO initializes the RUNTIME invironment and optionally loads Image to SMM or Non-SMM space
416 // based upon the presence of build flags EFI_LOAD_DRIVER_SMM and EFI_NO_LOAD_DRIVER_RT.
417 //
418 #define EFI_INITIALIZE_RUNTIME_DRIVER_LIB(ImageHandle, SystemTable, GoVirtualChildEvent, FilePath) \
419 mEfiLoadDriverSmm = EFI_LOAD_DRIVER_SMM; \
420 mEfiNoLoadDriverRt = EFI_NO_LOAD_DRIVER_RT; \
421 mFilePath = (EFI_DEVICE_PATH_PROTOCOL*) FilePath; \
422 EfiInitializeUtilsRuntimeDriverLib ((EFI_HANDLE) ImageHandle, (EFI_SYSTEM_TABLE*) SystemTable, (EFI_EVENT_NOTIFY) GoVirtualChildEvent); \
423 if (!EfiInManagementInterrupt()) { \
424 if (mEfiNoLoadDriverRt) { \
425 return EFI_SUCCESS; \
426 } \
427 }
428
429 #endif