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 if (_gDriverSetVirtualAddressMapEvent
[0] != NULL
) {
106 ASSERT (gBS
!= NULL
);
107 Status
= gBS
->CreateEvent (
108 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
110 RuntimeLibVirtualNotifyEvent
,
112 &mEfiVirtualNotifyEvent
115 ASSERT_EFI_ERROR (Status
);
122 This routine will free some resources which have been allocated in
123 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
124 it must call this routine to free the allocated resource before the exiting.
126 @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully
127 @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all
131 RuntimeDriverLibDeconstruct (
132 IN EFI_HANDLE ImageHandle
,
133 IN EFI_SYSTEM_TABLE
*SystemTable
139 // Close SetVirtualAddressMap () notify function
141 if (_gDriverSetVirtualAddressMapEvent
[0] != NULL
) {
142 ASSERT (gBS
!= NULL
);
143 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
144 ASSERT_EFI_ERROR (Status
);
151 Return TRUE if ExitBootServices () has been called
153 @retval TRUE If ExitBootServices () has been called
161 return mEfiAtRuntime
;
165 Return TRUE if SetVirtualAddressMap () has been called
167 @retval TRUE If SetVirtualAddressMap () has been called
175 return mEfiGoneVirtual
;