2 UEFI Runtime Library implementation for non IPF processor types.
4 Copyright (c) 2006 - 2008 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 EFI_EVENT mEfiVirtualNotifyEvent
;
22 EFI_EVENT mEfiExitBootServicesEvent
;
23 BOOLEAN mEfiGoneVirtual
= FALSE
;
24 BOOLEAN mEfiAtRuntime
= FALSE
;
25 EFI_RUNTIME_SERVICES
*gInternalRT
;
28 Set AtRuntime flag as TRUE after ExitBootServices.
30 @param[in] Event The Event that is being processed
31 @param[in] Context Event Context
35 RuntimeLibExitBootServicesEvent (
41 // Clear out BootService globals
49 Fixup internal data so that EFI can be call in virtual mode.
50 Call the passed in Child Notify event and convert any pointers in
53 @param[in] Event The Event that is being processed
54 @param[in] Context Event Context
58 RuntimeLibVirtualNotifyEvent (
64 // Update global for Runtime Services Table and IO
66 EfiConvertPointer (0, (VOID
**) &gInternalRT
);
68 mEfiGoneVirtual
= TRUE
;
72 Initialize runtime Driver Lib if it has not yet been initialized.
73 It will ASSERT() if gRT is NULL or gBS is NULL.
74 It will ASSERT() if that operation fails.
76 @param[in] ImageHandle The firmware allocated handle for the EFI image.
77 @param[in] SystemTable A pointer to the EFI System Table.
79 @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
83 RuntimeDriverLibConstruct (
84 IN EFI_HANDLE ImageHandle
,
85 IN EFI_SYSTEM_TABLE
*SystemTable
95 // Register SetVirtualAddressMap () notify function
97 Status
= gBS
->CreateEventEx (
100 RuntimeLibVirtualNotifyEvent
,
102 &gEfiEventVirtualAddressChangeGuid
,
103 &mEfiVirtualNotifyEvent
106 ASSERT_EFI_ERROR (Status
);
108 Status
= gBS
->CreateEventEx (
111 RuntimeLibExitBootServicesEvent
,
113 &gEfiEventExitBootServicesGuid
,
114 &mEfiExitBootServicesEvent
117 ASSERT_EFI_ERROR (Status
);
123 If a runtime driver exits with an error, it must call this routine
124 to free the allocated resource before the exiting.
125 It will ASSERT() if gBS is NULL.
126 It will ASSERT() if that operation fails.
128 @param[in] ImageHandle The firmware allocated handle for the EFI image.
129 @param[in] SystemTable A pointer to the EFI System Table.
131 @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully
132 @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all
136 RuntimeDriverLibDeconstruct (
137 IN EFI_HANDLE ImageHandle
,
138 IN EFI_SYSTEM_TABLE
*SystemTable
144 // Close SetVirtualAddressMap () notify function
146 ASSERT (gBS
!= NULL
);
147 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
148 ASSERT_EFI_ERROR (Status
);
150 Status
= gBS
->CloseEvent (mEfiExitBootServicesEvent
);
151 ASSERT_EFI_ERROR (Status
);
157 This function allows the caller to determine if UEFI ExitBootServices() has been called.
159 This function returns TRUE after all the EVT_SIGNAL_EXIT_BOOT_SERVICES functions have
160 executed as a result of the OS calling ExitBootServices(). Prior to this time FALSE
161 is returned. This function is used by runtime code to decide it is legal to access
162 services that go away after ExitBootServices().
164 @retval TRUE The system has finished executing the EVT_SIGNAL_EXIT_BOOT_SERVICES event.
165 @retval FALSE The system has not finished executing the EVT_SIGNAL_EXIT_BOOT_SERVICES event.
174 return mEfiAtRuntime
;
178 This function allows the caller to determine if UEFI SetVirtualAddressMap() has been called.
180 This function returns TRUE after all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE functions have
181 executed as a result of the OS calling SetVirtualAddressMap(). Prior to this time FALSE
182 is returned. This function is used by runtime code to decide it is legal to access services
183 that go away after SetVirtualAddressMap().
185 @retval TRUE The system has finished executing the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
186 @retval FALSE The system has not finished executing the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
195 return mEfiGoneVirtual
;