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
;
123 RuntimeDriverLibConstruct (
124 IN EFI_HANDLE ImageHandle
,
125 IN EFI_SYSTEM_TABLE
*SystemTable
131 Intialize runtime Driver Lib if it has not yet been initialized.
135 ImageHandle - The firmware allocated handle for the EFI image.
137 SystemTable - A pointer to the EFI System Table.
139 GoVirtualChildEvent - Caller can register a virtual notification event.
143 EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
149 mRT
= SystemTable
->RuntimeServices
;
152 // Register our ExitBootServices () notify function
154 Status
= gBS
->CreateEvent (
155 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
157 RuntimeDriverExitBootServices
,
162 ASSERT_EFI_ERROR (Status
);
165 // Register SetVirtualAddressMap () notify function
167 Status
= gBS
->CreateEvent (
168 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
170 RuntimeLibVirtualNotifyEvent
,
172 &mEfiVirtualNotifyEvent
175 ASSERT_EFI_ERROR (Status
);
182 RuntimeDriverLibDeconstruct (
189 This routine will free some resources which have been allocated in
190 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
191 it must call this routine to free the allocated resource before the exiting.
199 EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
200 EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
207 // Close our ExitBootServices () notify function
209 Status
= gBS
->CloseEvent (mRuntimeNotifyEvent
);
210 ASSERT_EFI_ERROR (Status
);
213 // Close SetVirtualAddressMap () notify function
215 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
216 ASSERT_EFI_ERROR (Status
);
228 Return TRUE if ExitBootServices () has been called
234 TRUE - If ExitBootServices () has been called
238 return mEfiAtRuntime
;
248 Return TRUE if SetVirtualAddressMap () has been called
254 TRUE - If SetVirtualAddressMap () has been called
258 return mEfiGoneVirtual
;