]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | RuntimeLib.c\r | |
15 | \r | |
878ddf1f | 16 | --*/\r |
17 | \r | |
18 | #include <SalApi.h>\r | |
19 | #include <RuntimeLibInternal.h>\r | |
20 | \r | |
21 | //\r | |
22 | // Driver Lib Module Globals\r | |
23 | //\r | |
f1cd55fe | 24 | static EFI_EVENT mEfiVirtualNotifyEvent;\r |
25 | EFI_RUNTIME_SERVICES *mRT;\r | |
878ddf1f | 26 | \r |
878ddf1f | 27 | VOID\r |
28 | EFIAPI\r | |
29 | RuntimeDriverExitBootServices (\r | |
30 | IN EFI_EVENT Event,\r | |
31 | IN VOID *Context\r | |
32 | )\r | |
33 | /*++\r | |
34 | \r | |
35 | Routine Description:\r | |
36 | \r | |
37 | Set AtRuntime flag as TRUE after ExitBootServices\r | |
38 | \r | |
39 | Arguments:\r | |
40 | \r | |
41 | Event - The Event that is being processed\r | |
42 | \r | |
43 | Context - Event Context\r | |
44 | \r | |
45 | Returns: \r | |
46 | \r | |
47 | None\r | |
48 | \r | |
49 | --*/\r | |
50 | {\r | |
f1cd55fe | 51 | if (EfiAtRuntime()) {\r |
52 | return;\r | |
878ddf1f | 53 | }\r |
54 | }\r | |
55 | \r | |
878ddf1f | 56 | VOID\r |
57 | EFIAPI\r | |
58 | RuntimeLibVirtualNotifyEvent (\r | |
59 | IN EFI_EVENT Event,\r | |
60 | IN VOID *Context\r | |
61 | )\r | |
62 | /*++\r | |
63 | \r | |
64 | Routine Description:\r | |
65 | \r | |
66 | Fixup internal data so that EFI can be call in virtual mode.\r | |
67 | Call the passed in Child Notify event and convert any pointers in \r | |
68 | lib to virtual mode.\r | |
69 | \r | |
70 | Arguments:\r | |
71 | \r | |
72 | Event - The Event that is being processed\r | |
73 | \r | |
74 | Context - Event Context\r | |
75 | \r | |
76 | Returns: \r | |
77 | \r | |
78 | None\r | |
79 | \r | |
80 | --*/\r | |
81 | {\r | |
f1cd55fe | 82 | UINTN Index;\r |
878ddf1f | 83 | EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r |
84 | \r | |
85 | for (Index = 0; _gDriverSetVirtualAddressMapEvent[Index] != NULL; Index++) {\r | |
86 | ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];\r | |
87 | ChildNotifyEventHandler (Event, NULL);\r | |
88 | }\r | |
89 | \r | |
c25aaa00 | 90 | //\r |
91 | // Update global for Runtime Services Table\r | |
92 | //\r | |
93 | EfiConvertPointer (0, (VOID **) &mRT);\r | |
878ddf1f | 94 | }\r |
95 | \r | |
96 | EFI_STATUS\r | |
a5e465a7 | 97 | EFIAPI\r |
878ddf1f | 98 | RuntimeDriverLibConstruct (\r |
99 | IN EFI_HANDLE ImageHandle,\r | |
100 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
101 | )\r | |
102 | /*++\r | |
103 | \r | |
104 | Routine Description:\r | |
105 | \r | |
106 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
107 | \r | |
108 | Arguments:\r | |
109 | \r | |
110 | ImageHandle - The firmware allocated handle for the EFI image.\r | |
111 | \r | |
112 | SystemTable - A pointer to the EFI System Table.\r | |
113 | \r | |
114 | GoVirtualChildEvent - Caller can register a virtual notification event.\r | |
115 | \r | |
116 | Returns: \r | |
117 | \r | |
118 | EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
119 | \r | |
120 | --*/\r | |
121 | {\r | |
878ddf1f | 122 | EFI_STATUS Status;\r |
123 | \r | |
124 | mRT = SystemTable->RuntimeServices;\r | |
125 | \r | |
878ddf1f | 126 | //\r |
127 | // Register SetVirtualAddressMap () notify function\r | |
128 | //\r | |
f1cd55fe | 129 | if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r |
130 | Status = gBS->CreateEvent (\r | |
131 | EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r | |
132 | EFI_TPL_NOTIFY,\r | |
133 | RuntimeLibVirtualNotifyEvent,\r | |
134 | NULL,\r | |
135 | &mEfiVirtualNotifyEvent\r | |
136 | );\r | |
137 | ASSERT_EFI_ERROR (Status);\r | |
138 | }\r | |
878ddf1f | 139 | \r |
140 | return EFI_SUCCESS;\r | |
141 | }\r | |
142 | \r | |
143 | EFI_STATUS\r | |
a5e465a7 | 144 | EFIAPI\r |
878ddf1f | 145 | RuntimeDriverLibDeconstruct (\r |
146 | VOID\r | |
147 | )\r | |
148 | /*++\r | |
149 | \r | |
150 | Routine Description:\r | |
151 | \r | |
152 | This routine will free some resources which have been allocated in\r | |
153 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r | |
154 | it must call this routine to free the allocated resource before the exiting.\r | |
155 | \r | |
156 | Arguments:\r | |
157 | \r | |
158 | None\r | |
159 | \r | |
160 | Returns: \r | |
161 | \r | |
162 | EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r | |
163 | EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r | |
164 | \r | |
165 | --*/\r | |
166 | {\r | |
167 | EFI_STATUS Status;\r | |
168 | \r | |
878ddf1f | 169 | //\r |
170 | // Close SetVirtualAddressMap () notify function\r | |
171 | //\r | |
f1cd55fe | 172 | if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {\r |
173 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
174 | ASSERT_EFI_ERROR (Status);\r | |
175 | }\r | |
878ddf1f | 176 | \r |
177 | return EFI_SUCCESS;\r | |
178 | }\r | |
179 | \r | |
180 | BOOLEAN\r | |
e8a3bee0 | 181 | EFIAPI\r |
878ddf1f | 182 | EfiAtRuntime (\r |
183 | VOID\r | |
184 | )\r | |
185 | /*++\r | |
186 | \r | |
187 | Routine Description:\r | |
188 | Return TRUE if ExitBootService () has been called\r | |
189 | \r | |
190 | Arguments:\r | |
191 | NONE\r | |
192 | \r | |
193 | Returns: \r | |
194 | TRUE - If ExitBootService () has been called\r | |
195 | \r | |
196 | --*/\r | |
197 | {\r | |
198 | EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r | |
199 | SAL_RETURN_REGS ReturnReg;\r | |
200 | \r | |
201 | ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);\r | |
202 | \r | |
203 | return (BOOLEAN) (ReturnReg.r9 == 1);\r | |
204 | }\r | |
205 | \r | |
206 | BOOLEAN\r | |
e8a3bee0 | 207 | EFIAPI\r |
878ddf1f | 208 | EfiGoneVirtual (\r |
209 | VOID\r | |
210 | )\r | |
211 | /*++\r | |
212 | \r | |
213 | Routine Description:\r | |
214 | Return TRUE if SetVirtualAddressMap () has been called\r | |
215 | \r | |
216 | Arguments:\r | |
217 | NONE\r | |
218 | \r | |
219 | Returns: \r | |
220 | TRUE - If SetVirtualAddressMap () has been called\r | |
221 | \r | |
222 | --*/\r | |
223 | {\r | |
224 | EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;\r | |
225 | SAL_RETURN_REGS ReturnReg;\r | |
226 | \r | |
227 | ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);\r | |
228 | \r | |
229 | return (BOOLEAN) (ReturnReg.r9 == 1);\r | |
230 | }\r | |
e8a3bee0 | 231 | \r |