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 STATIC EFI_EVENT mEfiVirtualNotifyEvent
;
22 STATIC EFI_EVENT mEfiExitBootServicesEvent
;
23 STATIC BOOLEAN mEfiGoneVirtual
= FALSE
;
24 STATIC BOOLEAN mEfiAtRuntime
= FALSE
;
25 EFI_RUNTIME_SERVICES
*mRT
;
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
**) &mRT
);
68 mEfiGoneVirtual
= TRUE
;
72 Intialize 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
->CreateEvent (
98 EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
,
100 RuntimeLibVirtualNotifyEvent
,
102 &mEfiVirtualNotifyEvent
105 ASSERT_EFI_ERROR (Status
);
107 Status
= gBS
->CreateEvent (
108 EVT_SIGNAL_EXIT_BOOT_SERVICES
,
110 RuntimeLibExitBootServicesEvent
,
112 &mEfiExitBootServicesEvent
115 ASSERT_EFI_ERROR (Status
);
121 If a runtime driver exits with an error, it must call this routine
122 to free the allocated resource before the exiting.
123 It will ASSERT() if gBS is NULL.
124 It will ASSERT() if that operation fails.
126 @param[in] ImageHandle The firmware allocated handle for the EFI image.
127 @param[in] SystemTable A pointer to the EFI System Table.
129 @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully
130 @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all
134 RuntimeDriverLibDeconstruct (
135 IN EFI_HANDLE ImageHandle
,
136 IN EFI_SYSTEM_TABLE
*SystemTable
142 // Close SetVirtualAddressMap () notify function
144 ASSERT (gBS
!= NULL
);
145 Status
= gBS
->CloseEvent (mEfiVirtualNotifyEvent
);
146 ASSERT_EFI_ERROR (Status
);
148 Status
= gBS
->CloseEvent (mEfiExitBootServicesEvent
);
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
;