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
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.
14 EfiMgmtModeRuntimeLib.h
18 Light weight lib to support EFI drivers.
22 #ifndef _EFI_RT_SUPPORT_LIB_H_
23 #define _EFI_RT_SUPPORT_LIB_H_
25 #ifndef EFI_LOAD_IMAGE_SMM
26 #define EFI_LOAD_DRIVER_SMM FALSE
28 #define EFI_LOAD_DRIVER_SMM TRUE
31 #ifndef EFI_NO_LOAD_IMAGE_RT
32 #define EFI_NO_LOAD_DRIVER_RT FALSE
34 #define EFI_NO_LOAD_DRIVER_RT TRUE
37 #include "EfiCommonLib.h"
38 #include "LinkedList.h"
41 #include EFI_PROTOCOL_DEFINITION (CpuIo)
42 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
45 // Driver Lib Globals.
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
;
55 // Runtime Memory Allocation/De-Allocation tools (Should be used in Boot Phase only)
58 EfiAllocateRuntimeMemoryPool (
66 Allocate EfiRuntimeServicesData pool of specified size.
71 Buffer - Memory pointer for output
81 EfiFreeRuntimeMemoryPool (
92 Buffer - Pool to be freed
102 EfiLocateProtocolHandleBuffers (
103 IN EFI_GUID
*Protocol
,
104 IN OUT UINTN
*NumberHandles
,
105 OUT EFI_HANDLE
**Buffer
111 Returns an array of handles that support the requested protocol in a buffer allocated from pool.
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
129 IN EFI_HANDLE Handle
,
130 IN EFI_GUID
*Protocol
,
137 Queries a handle to determine if it supports a specified protocol.
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.
155 EfiInstallProtocolInterface (
156 IN OUT EFI_HANDLE
*Handle
,
157 IN EFI_GUID
*Protocol
,
158 IN EFI_INTERFACE_TYPE InterfaceType
,
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.
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.
183 EfiReinstallProtocolInterface (
184 IN EFI_HANDLE SmmProtocolHandle
,
185 IN EFI_GUID
*Protocol
,
186 IN VOID
*OldInterface
,
187 IN VOID
*NewInterface
193 Reinstalls a protocol interface on a device handle.
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.
210 EfiLocateProtocolInterface (
212 VOID
*Registration
, OPTIONAL
219 Returns the first protocol instance that matches the given protocol.
223 Protocol - Provides the protocol to search for.
224 Registration - Optional registration key returned from
225 RegisterProtocolNotify(). If Registration is NULL, then
227 Interface - On return, a pointer to the first interface that matches Protocol and
238 UninstallProtocolInterface (
239 IN EFI_HANDLE SmmProtocolHandle
,
240 IN EFI_GUID
*Protocol
,
247 Removes a protocol interface from a device handle.
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.
263 EfiRegisterProtocolCallback (
264 IN EFI_EVENT_NOTIFY CallbackFunction
,
266 IN EFI_GUID
*ProtocolGuid
,
267 IN EFI_TPL NotifyTpl
,
268 OUT VOID
**Registeration
,
275 Register a callback function to be signaled whenever an interface is installed for
276 a specified protocol.
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
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
297 EfiSignalProtocolEvent (
308 Event - The event to signal.
318 EfiInstallVendorConfigurationTable (
326 Adds, updates, or removes a configuration table entry from the EFI System Table.
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
342 EfiGetVendorConfigurationTable (
350 Return the EFI 1.0 System Tabl entry with TableGuid
354 Guid - Name of entry to return in the system table
355 Table - Pointer in EFI system table associated with TableGuid
359 EFI_SUCCESS - Table returned;
360 EFI_NOT_FOUND - TableGuid not in EFI system table
366 EfiInitializeUtilsRuntimeDriverLib (
367 IN EFI_HANDLE ImageHandle
,
368 IN EFI_SYSTEM_TABLE
*SystemTable
,
369 IN EFI_EVENT_NOTIFY GoVirtualChildEvent
375 Intialize runtime Driver Lib if it has not yet been initialized.
379 ImageHandle - The firmware allocated handle for the EFI image.
381 SystemTable - A pointer to the EFI System Table.
383 GoVirtualChildEvent - Caller can register a virtual notification event.
387 EFI_STATUS always returns EFI_SUCCESS
393 EfiInManagementInterrupt (
400 Indicate whether the caller is already in SMM or not.
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.
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; \