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.
18 #include <RuntimeLibInternal.h>
21 // Driver Lib Module Globals
24 STATIC EFI_EVENT mRuntimeNotifyEvent
;
25 STATIC EFI_EVENT mEfiVirtualNotifyEvent
;
26 STATIC BOOLEAN mEfiGoneVirtual
= FALSE
;
27 STATIC BOOLEAN mEfiAtRuntime
= FALSE
;
29 EFI_RUNTIME_SERVICES
*mRT
;
34 RuntimeDriverExitBootServices (
42 Set AtRuntime flag as TRUE after ExitBootServices
46 Event - The Event that is being processed
48 Context - Event Context
56 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
60 _gDriverExitBootServicesEvent
[Index
] != NULL
;
62 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
63 ChildNotifyEventHandler (Event
, NULL
);
67 // Clear out BootService globals
77 RuntimeLibVirtualNotifyEvent (
85 Fixup internal data so that EFI can be call in virtual mode.
86 Call the passed in Child Notify event and convert any pointers in
91 Event - The Event that is being processed
93 Context - Event Context
102 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
105 _gDriverSetVirtualAddressMapEvent
[Index
] != NULL
;
107 ChildNotifyEventHandler
= _gDriverSetVirtualAddressMapEvent
[Index
];
108 ChildNotifyEventHandler (Event
, NULL
);
112 // Update global for Runtime Services Table and IO
114 EfiConvertPointer (0, (VOID
**) &mRT
);
116 mEfiGoneVirtual
= TRUE
;
121 RuntimeDriverLibConstruct (
122 IN EFI_HANDLE ImageHandle
,
123 IN EFI_SYSTEM_TABLE
*SystemTable
129 Intialize runtime Driver Lib if it has not yet been initialized.
133 ImageHandle - The firmware allocated handle for the EFI image.
135 SystemTable - A pointer to the EFI System Table.
137 GoVirtualChildEvent - Caller can register a virtual notification event.
141 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
147 mRT
= SystemTable
->RuntimeServices
;
150 // Register our ExitBootServices () notify function
152 Status
= gBS
->CreateEvent (
153 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
155 RuntimeDriverExitBootServices
,
160 ASSERT_EFI_ERROR (Status
);
163 // Register SetVirtualAddressMap () notify function
165 Status
= gBS
->CreateEvent (
166 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
168 RuntimeLibVirtualNotifyEvent
,
170 &mEfiVirtualNotifyEvent
173 ASSERT_EFI_ERROR (Status
);
180 RuntimeDriverLibDeconstruct (
187 This routine will free some resources which have been allocated in
188 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
189 it must call this routine to free the allocated resource before the exiting.
197 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
198 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
205 // Close our ExitBootServices () notify function
207 Status
= gBS
->CloseEvent (mRuntimeNotifyEvent
);
208 ASSERT_EFI_ERROR (Status
);
211 // Close SetVirtualAddressMap () notify function
213 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
214 ASSERT_EFI_ERROR (Status
);
227 Return TRUE if ExitBootServices () has been called
233 TRUE - If ExitBootServices () has been called
237 return mEfiAtRuntime
;
248 Return TRUE if SetVirtualAddressMap () has been called
254 TRUE - If SetVirtualAddressMap () has been called
258 return mEfiGoneVirtual
;