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 Light weight lib to support Tiano drivers.
22 #include <RuntimeLibInternal.h>
25 // Driver Lib Module Globals
27 STATIC EFI_EVENT mRuntimeNotifyEvent
;
28 STATIC EFI_EVENT mEfiVirtualNotifyEvent
;
29 STATIC BOOLEAN mEfiGoneVirtual
= FALSE
;
30 STATIC BOOLEAN mEfiAtRuntime
= FALSE
;
32 EFI_RUNTIME_SERVICES
*mRT
= NULL
;
36 RuntimeDriverExitBootServices (
44 Set AtRuntime flag as TRUE after ExitBootServices
48 Event - The Event that is being processed
50 Context - Event Context
58 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
62 _gDriverExitBootServicesEvent
[Index
] != NULL
;
64 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
65 ChildNotifyEventHandler (Event
, NULL
);
74 RuntimeLibVirtualNotifyEvent (
82 Fixup internal data so that EFI can be call in virtual mode.
83 Call the passed in Child Notify event and convert any pointers in
88 Event - The Event that is being processed
90 Context - Event Context
99 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
102 _gDriverSetVirtualAddressMapEvent
[Index
] != NULL
;
104 ChildNotifyEventHandler
= _gDriverSetVirtualAddressMapEvent
[Index
];
105 ChildNotifyEventHandler (Event
, NULL
);
109 // Update global for Runtime Services Table and IO
111 EfiConvertInternalPointer ((VOID
**) &mRT
);
114 // Clear out BootService globals
118 mEfiGoneVirtual
= TRUE
;
122 RuntimeDriverLibConstruct (
123 IN EFI_HANDLE ImageHandle
,
124 IN EFI_SYSTEM_TABLE
*SystemTable
130 Intialize runtime Driver Lib if it has not yet been initialized.
134 ImageHandle - The firmware allocated handle for the EFI image.
136 SystemTable - A pointer to the EFI System Table.
138 GoVirtualChildEvent - Caller can register a virtual notification event.
142 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
148 mRT
= SystemTable
->RuntimeServices
;
151 // Register our ExitBootServices () notify function
153 Status
= gBS
->CreateEvent (
154 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
156 RuntimeDriverExitBootServices
,
161 ASSERT_EFI_ERROR (Status
);
164 // Register SetVirtualAddressMap () notify function
166 Status
= gBS
->CreateEvent (
167 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
169 RuntimeLibVirtualNotifyEvent
,
171 &mEfiVirtualNotifyEvent
174 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
);
226 Return TRUE if ExitBootServices () has been called
232 TRUE - If ExitBootServices () has been called
236 return mEfiAtRuntime
;
246 Return TRUE if SetVirtualAddressMap () has been called
252 TRUE - If SetVirtualAddressMap () has been called
256 return mEfiGoneVirtual
;