3 Copyright (c) 2004 - 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
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.
23 #include "../RuntimeLibInternal.h"
26 // Driver Lib Module Globals
28 static EFI_EVENT mEfiVirtualNotifyEvent
;
29 EFI_RUNTIME_SERVICES
*mRT
;
33 RuntimeDriverExitBootServices (
41 Set AtRuntime flag as TRUE after ExitBootServices
45 Event - The Event that is being processed
47 Context - Event Context
63 RuntimeLibVirtualNotifyEvent (
71 Fixup internal data so that EFI can be call in virtual mode.
72 Call the passed in Child Notify event and convert any pointers in
77 Event - The Event that is being processed
79 Context - Event Context
88 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
90 for (Index
= 0; _gDriverSetVirtualAddressMapEvent
[Index
] != NULL
; Index
++) {
91 ChildNotifyEventHandler
= _gDriverSetVirtualAddressMapEvent
[Index
];
92 ChildNotifyEventHandler (Event
, NULL
);
96 // Update global for Runtime Services Table
98 EfiConvertPointer (0, (VOID
**) &mRT
);
103 RuntimeDriverLibConstruct (
104 IN EFI_HANDLE ImageHandle
,
105 IN EFI_SYSTEM_TABLE
*SystemTable
111 Intialize runtime Driver Lib if it has not yet been initialized.
115 ImageHandle - The firmware allocated handle for the EFI image.
117 SystemTable - A pointer to the EFI System Table.
119 GoVirtualChildEvent - Caller can register a virtual notification event.
123 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
129 mRT
= SystemTable
->RuntimeServices
;
132 // Register SetVirtualAddressMap () notify function
134 if (_gDriverSetVirtualAddressMapEvent
[0] != NULL
) {
135 Status
= gBS
->CreateEvent (
136 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
138 RuntimeLibVirtualNotifyEvent
,
140 &mEfiVirtualNotifyEvent
142 ASSERT_EFI_ERROR (Status
);
150 RuntimeDriverLibDeconstruct (
151 IN EFI_HANDLE ImageHandle
,
152 IN EFI_SYSTEM_TABLE
*SystemTable
158 This routine will free some resources which have been allocated in
159 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
160 it must call this routine to free the allocated resource before the exiting.
168 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
169 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
176 // Close SetVirtualAddressMap () notify function
178 if (_gDriverSetVirtualAddressMapEvent
[0] != NULL
) {
179 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
180 ASSERT_EFI_ERROR (Status
);
194 Return TRUE if ExitBootService () has been called
200 TRUE - If ExitBootService () has been called
205 SAL_RETURN_REGS ReturnReg
;
207 *((UINT64
*) &Guid
) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO
;
208 *(((UINT64
*)&Guid
) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI
;
210 ReturnReg
= EfiCallEsalService (&Guid
, IsEfiRuntime
, 0, 0, 0, 0, 0, 0, 0);
212 return (BOOLEAN
) (ReturnReg
.r9
== 1);
223 Return TRUE if SetVirtualAddressMap () has been called
229 TRUE - If SetVirtualAddressMap () has been called
234 SAL_RETURN_REGS ReturnReg
;
236 *((UINT64
*) &Guid
) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_LO
;
237 *(((UINT64
*)&Guid
) + 1) = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID_HI
;
239 ReturnReg
= EfiCallEsalService (&Guid
, IsVirtual
, 0, 0, 0, 0, 0, 0, 0);
241 return (BOOLEAN
) (ReturnReg
.r9
== 1);