]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / EdkDxeRuntimeDriverLib / Common / RuntimeLib.c
CommitLineData
3eb9473e 1/*++\r
2\r
2c7e5c2f
HT
3Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12\r
13Module Name:\r
14\r
15 RuntimeLib.c\r
16\r
17Abstract:\r
18\r
19 Runtime lib\r
20\r
21--*/\r
22\r
10d315bc 23#include "../RuntimeLibInternal.h"\r
3eb9473e 24\r
25//\r
26// Driver Lib Module Globals\r
27//\r
28\r
29STATIC EFI_EVENT mEfiVirtualNotifyEvent;\r
30STATIC BOOLEAN mEfiGoneVirtual = FALSE;\r
31STATIC BOOLEAN mEfiAtRuntime = FALSE;\r
32EFI_RUNTIME_SERVICES *mRT;\r
33\r
34/**\r
35 Set AtRuntime flag as TRUE after ExitBootServices\r
36 \r
37 @param[in] Event The Event that is being processed\r
38 @param[in] Context Event Context\r
39**/\r
40VOID\r
41EFIAPI\r
42RuntimeDriverExitBootServices (\r
43 IN EFI_EVENT Event,\r
44 IN VOID *Context\r
45 )\r
46{\r
47 //\r
48 // Clear out BootService globals\r
49 //\r
50 gBS = NULL;\r
51\r
52 mEfiAtRuntime = TRUE;\r
53}\r
54\r
55/**\r
56 Fixup internal data so that EFI can be call in virtual mode.\r
57 Call the passed in Child Notify event and convert any pointers in \r
58 lib to virtual mode.\r
59 \r
60 @param[in] Event The Event that is being processed\r
61 @param[in] Context Event Context\r
62**/\r
63STATIC\r
64VOID\r
65EFIAPI\r
66RuntimeLibVirtualNotifyEvent (\r
67 IN EFI_EVENT Event,\r
68 IN VOID *Context\r
69 )\r
70{\r
71 UINTN Index;\r
72 EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r
73\r
74 for (Index = 0; \r
75 _gDriverSetVirtualAddressMapEvent[Index] != NULL;\r
76 Index++) {\r
77 ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r
78 ChildNotifyEventHandler (Event, NULL);\r
79 }\r
80\r
81 //\r
82 // Update global for Runtime Services Table and IO\r
83 //\r
84 EfiConvertPointer (0, (VOID **) &mRT);\r
85\r
86 mEfiGoneVirtual = TRUE;\r
87}\r
88\r
89/**\r
90 Intialize runtime Driver Lib if it has not yet been initialized. \r
91 \r
92 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
93 @param[in] SystemTable A pointer to the EFI System Table.\r
94 \r
95 @return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r
96**/\r
97EFI_STATUS\r
98EFIAPI\r
99RuntimeDriverLibConstruct (\r
100 IN EFI_HANDLE ImageHandle,\r
101 IN EFI_SYSTEM_TABLE *SystemTable\r
102 )\r
103{\r
104 EFI_STATUS Status;\r
105\r
106 ASSERT (SystemTable != NULL);\r
107 mRT = SystemTable->RuntimeServices;\r
108 ASSERT (mRT != NULL);\r
109 \r
110 //\r
111 // Register SetVirtualAddressMap () notify function\r
112 // \r
113 ASSERT (gBS != NULL);\r
114 Status = gBS->CreateEvent (\r
115 EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r
116 EFI_TPL_NOTIFY,\r
117 RuntimeLibVirtualNotifyEvent,\r
118 NULL,\r
119 &mEfiVirtualNotifyEvent\r
120 );\r
121\r
122 ASSERT_EFI_ERROR (Status);\r
123\r
c7f33ca4 124 return Status;\r
3eb9473e 125}\r
126\r
127/**\r
128 This routine will free some resources which have been allocated in\r
129 EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r
130 it must call this routine to free the allocated resource before the exiting.\r
131\r
132 @retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully\r
133 @retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all\r
134**/\r
135EFI_STATUS\r
136EFIAPI\r
137RuntimeDriverLibDeconstruct (\r
138 IN EFI_HANDLE ImageHandle,\r
139 IN EFI_SYSTEM_TABLE *SystemTable\r
140 )\r
141{\r
142 EFI_STATUS Status;\r
143\r
144 //\r
145 // Close SetVirtualAddressMap () notify function\r
146 //\r
147 ASSERT (gBS != NULL);\r
148 Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r
149 ASSERT_EFI_ERROR (Status);\r
c7f33ca4 150 \r
151 return Status;\r
3eb9473e 152}\r
153\r
154/**\r
155 Return TRUE if ExitBootServices () has been called\r
156 \r
157 @retval TRUE If ExitBootServices () has been called\r
158**/\r
159BOOLEAN\r
160EFIAPI\r
161EfiAtRuntime (\r
162 VOID\r
163 )\r
164{\r
165 return mEfiAtRuntime;\r
166}\r
167\r
168/**\r
169 Return TRUE if SetVirtualAddressMap () has been called\r
170 \r
171 @retval TRUE If SetVirtualAddressMap () has been called\r
172**/\r
173BOOLEAN\r
174EFIAPI\r
175EfiGoneVirtual (\r
176 VOID\r
177 )\r
178{\r
179 return mEfiGoneVirtual;\r
180}\r
181\r