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
29 STATIC EFI_EVENT mEfiVirtualNotifyEvent
;
30 STATIC BOOLEAN mEfiGoneVirtual
= FALSE
;
31 STATIC BOOLEAN mEfiAtRuntime
= FALSE
;
32 EFI_RUNTIME_SERVICES
*mRT
;
35 Set AtRuntime flag as TRUE after ExitBootServices
37 @param[in] Event The Event that is being processed
38 @param[in] Context Event Context
42 RuntimeDriverExitBootServices (
48 // Clear out BootService globals
56 Fixup internal data so that EFI can be call in virtual mode.
57 Call the passed in Child Notify event and convert any pointers in
60 @param[in] Event The Event that is being processed
61 @param[in] Context Event Context
66 RuntimeLibVirtualNotifyEvent (
72 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
75 _gDriverSetVirtualAddressMapEvent
[Index
] != NULL
;
77 ChildNotifyEventHandler
= _gDriverSetVirtualAddressMapEvent
[Index
];
78 ChildNotifyEventHandler (Event
, NULL
);
82 // Update global for Runtime Services Table and IO
84 EfiConvertPointer (0, (VOID
**) &mRT
);
86 mEfiGoneVirtual
= TRUE
;
90 Intialize runtime Driver Lib if it has not yet been initialized.
92 @param[in] ImageHandle The firmware allocated handle for the EFI image.
93 @param[in] SystemTable A pointer to the EFI System Table.
95 @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
99 RuntimeDriverLibConstruct (
100 IN EFI_HANDLE ImageHandle
,
101 IN EFI_SYSTEM_TABLE
*SystemTable
106 ASSERT (SystemTable
!= NULL
);
107 mRT
= SystemTable
->RuntimeServices
;
108 ASSERT (mRT
!= NULL
);
111 // Register SetVirtualAddressMap () notify function
113 ASSERT (gBS
!= NULL
);
114 Status
= gBS
->CreateEvent (
115 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
117 RuntimeLibVirtualNotifyEvent
,
119 &mEfiVirtualNotifyEvent
122 ASSERT_EFI_ERROR (Status
);
128 This routine will free some resources which have been allocated in
129 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
130 it must call this routine to free the allocated resource before the exiting.
132 @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully
133 @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all
137 RuntimeDriverLibDeconstruct (
138 IN EFI_HANDLE ImageHandle
,
139 IN EFI_SYSTEM_TABLE
*SystemTable
145 // Close SetVirtualAddressMap () notify function
147 ASSERT (gBS
!= NULL
);
148 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
149 ASSERT_EFI_ERROR (Status
);
155 Return TRUE if ExitBootServices () has been called
157 @retval TRUE If ExitBootServices () has been called
165 return mEfiAtRuntime
;
169 Return TRUE if SetVirtualAddressMap () has been called
171 @retval TRUE If SetVirtualAddressMap () has been called
179 return mEfiGoneVirtual
;