2 Library utility functions for Runtime driver.
4 Copyright (c) 2006 Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <RuntimeLibInternal.h>
18 /// Driver Lib Module Globals
21 STATIC EFI_EVENT mEfiVirtualNotifyEvent
;
22 STATIC BOOLEAN mEfiGoneVirtual
= FALSE
;
23 STATIC BOOLEAN mEfiAtRuntime
= FALSE
;
24 EFI_RUNTIME_SERVICES
*mRT
;
27 Set AtRuntime flag as TRUE after ExitBootServices
29 @param[in] Event The Event that is being processed
30 @param[in] Context Event Context
34 RuntimeDriverExitBootServices (
40 // Clear out BootService globals
48 Fixup internal data so that EFI can be call in virtual mode.
49 Call the passed in Child Notify event and convert any pointers in
52 @param[in] Event The Event that is being processed
53 @param[in] Context Event Context
58 RuntimeLibVirtualNotifyEvent (
64 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
67 _gDriverSetVirtualAddressMapEvent
[Index
] != NULL
;
69 ChildNotifyEventHandler
= _gDriverSetVirtualAddressMapEvent
[Index
];
70 ChildNotifyEventHandler (Event
, NULL
);
74 // Update global for Runtime Services Table and IO
76 EfiConvertPointer (0, (VOID
**) &mRT
);
78 mEfiGoneVirtual
= TRUE
;
82 Intialize runtime Driver Lib if it has not yet been initialized.
84 @param[in] ImageHandle The firmware allocated handle for the EFI image.
85 @param[in] SystemTable A pointer to the EFI System Table.
87 @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
91 RuntimeDriverLibConstruct (
92 IN EFI_HANDLE ImageHandle
,
93 IN EFI_SYSTEM_TABLE
*SystemTable
98 ASSERT (SystemTable
!= NULL
);
99 mRT
= SystemTable
->RuntimeServices
;
100 ASSERT (mRT
!= NULL
);
103 // Register SetVirtualAddressMap () notify function
105 ASSERT (gBS
!= NULL
);
106 Status
= gBS
->CreateEvent (
107 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
109 RuntimeLibVirtualNotifyEvent
,
111 &mEfiVirtualNotifyEvent
114 ASSERT_EFI_ERROR (Status
);
120 This routine will free some resources which have been allocated in
121 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
122 it must call this routine to free the allocated resource before the exiting.
124 @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully
125 @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all
129 RuntimeDriverLibDeconstruct (
130 IN EFI_HANDLE ImageHandle
,
131 IN EFI_SYSTEM_TABLE
*SystemTable
137 // Close SetVirtualAddressMap () notify function
139 ASSERT (gBS
!= NULL
);
140 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
141 ASSERT_EFI_ERROR (Status
);
147 Return TRUE if ExitBootServices () has been called
149 @retval TRUE If ExitBootServices () has been called
157 return mEfiAtRuntime
;
161 Return TRUE if SetVirtualAddressMap () has been called
163 @retval TRUE If SetVirtualAddressMap () has been called
171 return mEfiGoneVirtual
;