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
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.
19 #include <RuntimeLibInternal.h>
22 // Driver Lib Module Globals
25 STATIC EFI_EVENT mRuntimeNotifyEvent
;
26 STATIC EFI_EVENT mEfiVirtualNotifyEvent
;
28 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
55 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
58 for (Index
= 0; _gDriverExitBootServicesEvent
[Index
] != NULL
; Index
++) {
59 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
60 ChildNotifyEventHandler (Event
, NULL
);
64 // Clear out BootService globals
72 RuntimeLibVirtualNotifyEvent (
80 Fixup internal data so that EFI can be call in virtual mode.
81 Call the passed in Child Notify event and convert any pointers in
86 Event - The Event that is being processed
88 Context - Event Context
97 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
99 for (Index
= 0; _gDriverSetVirtualAddressMapEvent
[Index
] != NULL
; Index
++) {
100 ChildNotifyEventHandler
= _gDriverSetVirtualAddressMapEvent
[Index
];
101 ChildNotifyEventHandler (Event
, NULL
);
105 // Update global for Runtime Services Table
107 EfiConvertPointer (0, (VOID
**) &mRT
);
112 RuntimeDriverLibConstruct (
113 IN EFI_HANDLE ImageHandle
,
114 IN EFI_SYSTEM_TABLE
*SystemTable
120 Intialize runtime Driver Lib if it has not yet been initialized.
124 ImageHandle - The firmware allocated handle for the EFI image.
126 SystemTable - A pointer to the EFI System Table.
128 GoVirtualChildEvent - Caller can register a virtual notification event.
132 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
138 mRT
= SystemTable
->RuntimeServices
;
141 // Register our ExitBootServices () notify function
144 Status
= gBS
->CreateEvent (
145 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
147 RuntimeDriverExitBootServices
,
151 ASSERT_EFI_ERROR (Status
);
154 // Register SetVirtualAddressMap () notify function
157 Status
= gBS
->CreateEvent (
158 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
160 RuntimeLibVirtualNotifyEvent
,
162 &mEfiVirtualNotifyEvent
164 ASSERT_EFI_ERROR (Status
);
171 RuntimeDriverLibDeconstruct (
178 This routine will free some resources which have been allocated in
179 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
180 it must call this routine to free the allocated resource before the exiting.
188 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
189 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
196 // Close our ExitBootServices () notify function
198 Status
= gBS
->CloseEvent (mRuntimeNotifyEvent
);
199 ASSERT_EFI_ERROR (Status
);
202 // Close SetVirtualAddressMap () notify function
204 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
205 ASSERT_EFI_ERROR (Status
);
218 Return TRUE if ExitBootService () has been called
224 TRUE - If ExitBootService () has been called
228 EFI_GUID Guid
= EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID
;
229 SAL_RETURN_REGS ReturnReg
;
231 ReturnReg
= EfiCallEsalService (&Guid
, IsEfiRuntime
, 0, 0, 0, 0, 0, 0, 0);
233 return (BOOLEAN
) (ReturnReg
.r9
== 1);
244 Return TRUE if SetVirtualAddressMap () has been called
250 TRUE - If SetVirtualAddressMap () has been called
254 EFI_GUID Guid
= EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID
;
255 SAL_RETURN_REGS ReturnReg
;
257 ReturnReg
= EfiCallEsalService (&Guid
, IsVirtual
, 0, 0, 0, 0, 0, 0, 0);
259 return (BOOLEAN
) (ReturnReg
.r9
== 1);