3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 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.
18 Light weight lib to support Tiano drivers.
23 #include "EfiRuntimeLib.h"
24 #include EFI_GUID_DEFINITION (StatusCodeCallerId)
25 #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
28 // Driver Lib Module Globals
30 static EFI_RUNTIME_SERVICES
*mRT
;
31 static EFI_EVENT mRuntimeNotifyEvent
= NULL
;
32 static BOOLEAN mRuntimeLibInitialized
= FALSE
;
33 static BOOLEAN mEfiGoneVirtual
= FALSE
;
36 // Runtime Global, but you should use the Lib functions
38 BOOLEAN mEfiAtRuntime
= FALSE
;
40 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
41 static EFI_STATUS_CODE_PROTOCOL
*gStatusCode
= NULL
;
46 IN UINTN DebugDisposition
,
53 Determines the new virtual address that is to be used on subsequent memory accesses.
57 DebugDisposition - Supplies type information for the pointer being converted.
58 Address - A pointer to a pointer that is to be fixed to be the value needed
59 for the new virtual address mappings being applied.
67 return mRT
->ConvertPointer (DebugDisposition
, Address
);
72 RuntimeDriverExitBootServices (
80 Set AtRuntime flag as TRUE after ExitBootServices
84 Event - The Event that is being processed
86 Context - Event Context
98 EfiInitializeRuntimeDriverLib (
99 IN EFI_HANDLE ImageHandle
,
100 IN EFI_SYSTEM_TABLE
*SystemTable
,
101 IN EFI_EVENT_NOTIFY GoVirtualChildEvent
107 Intialize runtime Driver Lib if it has not yet been initialized.
111 ImageHandle - The firmware allocated handle for the EFI image.
113 SystemTable - A pointer to the EFI System Table.
115 GoVirtualChildEvent - Caller can register a virtual notification event.
119 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
125 if (mRuntimeLibInitialized
) {
126 return EFI_ALREADY_STARTED
;
129 mRuntimeLibInitialized
= TRUE
;
132 ASSERT (gST
!= NULL
);
134 gBS
= SystemTable
->BootServices
;
135 ASSERT (gBS
!= NULL
);
136 mRT
= SystemTable
->RuntimeServices
;
137 ASSERT (mRT
!= NULL
);
139 Status
= EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid
, (VOID
**) &gDS
);
140 ASSERT_EFI_ERROR (Status
);
142 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
143 Status
= gBS
->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid
, NULL
, (VOID
**)&gStatusCode
);
144 if (EFI_ERROR (Status
)) {
150 // Register our ExitBootServices () notify function
152 Status
= gBS
->CreateEvent (
153 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
155 RuntimeDriverExitBootServices
,
159 ASSERT_EFI_ERROR (Status
);
162 // To NOT register SetVirtualAddressMap () notify function,
163 // because we do not know how to trigger it without our EBC driver.
170 EfiShutdownRuntimeDriverLib (
177 This routine will free some resources which have been allocated in
178 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
179 it must call this routine to free the allocated resource before the exiting.
187 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
188 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
194 if (!mRuntimeLibInitialized
) {
196 // You must call EfiInitializeRuntimeDriverLib() first
198 return EFI_UNSUPPORTED
;
201 mRuntimeLibInitialized
= FALSE
;
204 // Close our ExitBootServices () notify function
206 if (mRuntimeNotifyEvent
!= NULL
) {
207 Status
= gBS
->CloseEvent (mRuntimeNotifyEvent
);
208 ASSERT_EFI_ERROR (Status
);
221 Return TRUE if ExitBootServices () has been called
227 TRUE - If ExitBootServices () has been called
231 return mEfiAtRuntime
;
241 Return TRUE if SetVirtualAddressMap () has been called
247 TRUE - If SetVirtualAddressMap () has been called
251 return mEfiGoneVirtual
;
255 EfiReportStatusCode (
256 IN EFI_STATUS_CODE_TYPE CodeType
,
257 IN EFI_STATUS_CODE_VALUE Value
,
259 IN EFI_GUID
* CallerId
,
260 IN EFI_STATUS_CODE_DATA
* Data OPTIONAL
270 CodeType - Type of Status Code.
272 Value - Value to output for Status Code.
274 Instance - Instance Number of this status code.
276 CallerId - ID of the caller of this status code.
278 Data - Optional data associated with this status code.
286 return EFI_UNSUPPORTED
;
289 // Cache Flush Routine.
293 IN EFI_PHYSICAL_ADDRESS Start
,
300 Flush cache with specified range.
304 Start - Start address
305 Length - Length in bytes
311 EFI_SUCCESS - success