]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
4ea9375a HT |
3 | Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r |
4 | This program and the accompanying materials \r | |
3eb9473e | 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 | |
16 | Abstract:\r | |
17 | \r | |
18 | Light weight lib to support Tiano drivers.\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Tiano.h"\r | |
23 | #include "EfiRuntimeLib.h"\r | |
24 | #include EFI_GUID_DEFINITION (StatusCodeCallerId)\r | |
25 | #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r | |
26 | \r | |
27 | //\r | |
28 | // Driver Lib Module Globals\r | |
29 | //\r | |
30 | static EFI_RUNTIME_SERVICES *mRT;\r | |
31 | static EFI_EVENT mRuntimeNotifyEvent = NULL;\r | |
32 | static BOOLEAN mRuntimeLibInitialized = FALSE;\r | |
33 | static BOOLEAN mEfiGoneVirtual = FALSE;\r | |
34 | \r | |
35 | //\r | |
36 | // Runtime Global, but you should use the Lib functions\r | |
37 | //\r | |
38 | BOOLEAN mEfiAtRuntime = FALSE;\r | |
39 | \r | |
40 | #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r | |
41 | static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;\r | |
42 | #endif\r | |
43 | \r | |
44 | EFI_STATUS\r | |
45 | EfiConvertPointer (\r | |
46 | IN UINTN DebugDisposition,\r | |
47 | IN OUT VOID *Address\r | |
48 | )\r | |
49 | /*++\r | |
50 | \r | |
51 | Routine Description:\r | |
52 | \r | |
53 | Determines the new virtual address that is to be used on subsequent memory accesses.\r | |
54 | \r | |
55 | Arguments:\r | |
56 | \r | |
57 | DebugDisposition - Supplies type information for the pointer being converted.\r | |
58 | Address - A pointer to a pointer that is to be fixed to be the value needed\r | |
59 | for the new virtual address mappings being applied.\r | |
60 | \r | |
61 | Returns:\r | |
62 | \r | |
63 | Status code\r | |
64 | \r | |
65 | --*/\r | |
66 | {\r | |
67 | return mRT->ConvertPointer (DebugDisposition, Address);\r | |
68 | }\r | |
69 | \r | |
70 | VOID\r | |
71 | EFIAPI\r | |
72 | RuntimeDriverExitBootServices (\r | |
73 | IN EFI_EVENT Event,\r | |
74 | IN VOID *Context\r | |
75 | )\r | |
76 | /*++\r | |
77 | \r | |
78 | Routine Description:\r | |
79 | \r | |
80 | Set AtRuntime flag as TRUE after ExitBootServices\r | |
81 | \r | |
82 | Arguments:\r | |
83 | \r | |
84 | Event - The Event that is being processed\r | |
85 | \r | |
86 | Context - Event Context\r | |
87 | \r | |
88 | Returns: \r | |
89 | \r | |
90 | None\r | |
91 | \r | |
92 | --*/\r | |
93 | {\r | |
94 | mEfiAtRuntime = TRUE;\r | |
95 | }\r | |
96 | \r | |
97 | EFI_STATUS\r | |
98 | EfiInitializeRuntimeDriverLib (\r | |
99 | IN EFI_HANDLE ImageHandle,\r | |
100 | IN EFI_SYSTEM_TABLE *SystemTable,\r | |
101 | IN EFI_EVENT_NOTIFY GoVirtualChildEvent\r | |
102 | )\r | |
103 | /*++\r | |
104 | \r | |
105 | Routine Description:\r | |
106 | \r | |
107 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
108 | \r | |
109 | Arguments:\r | |
110 | \r | |
111 | ImageHandle - The firmware allocated handle for the EFI image.\r | |
112 | \r | |
113 | SystemTable - A pointer to the EFI System Table.\r | |
114 | \r | |
115 | GoVirtualChildEvent - Caller can register a virtual notification event.\r | |
116 | \r | |
117 | Returns: \r | |
118 | \r | |
119 | EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
120 | \r | |
121 | --*/\r | |
122 | {\r | |
123 | EFI_STATUS Status;\r | |
124 | \r | |
125 | if (mRuntimeLibInitialized) {\r | |
126 | return EFI_ALREADY_STARTED;\r | |
127 | }\r | |
128 | \r | |
129 | mRuntimeLibInitialized = TRUE;\r | |
130 | \r | |
131 | gST = SystemTable;\r | |
132 | ASSERT (gST != NULL);\r | |
133 | \r | |
134 | gBS = SystemTable->BootServices;\r | |
135 | ASSERT (gBS != NULL);\r | |
136 | mRT = SystemTable->RuntimeServices;\r | |
137 | ASSERT (mRT != NULL);\r | |
138 | \r | |
139 | Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r | |
140 | ASSERT_EFI_ERROR (Status);\r | |
141 | \r | |
142 | #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r | |
143 | Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r | |
144 | if (EFI_ERROR (Status)) {\r | |
145 | gStatusCode = NULL;\r | |
146 | }\r | |
147 | #endif\r | |
148 | \r | |
149 | //\r | |
150 | // Register our ExitBootServices () notify function\r | |
151 | //\r | |
152 | Status = gBS->CreateEvent (\r | |
153 | EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r | |
154 | EFI_TPL_NOTIFY,\r | |
155 | RuntimeDriverExitBootServices,\r | |
156 | NULL,\r | |
157 | &mRuntimeNotifyEvent\r | |
158 | );\r | |
159 | ASSERT_EFI_ERROR (Status);\r | |
160 | \r | |
161 | //\r | |
162 | // To NOT register SetVirtualAddressMap () notify function,\r | |
163 | // because we do not know how to trigger it without our EBC driver.\r | |
164 | //\r | |
165 | \r | |
166 | return EFI_SUCCESS;\r | |
167 | }\r | |
168 | \r | |
169 | EFI_STATUS\r | |
170 | EfiShutdownRuntimeDriverLib (\r | |
171 | VOID\r | |
172 | )\r | |
173 | /*++\r | |
174 | \r | |
175 | Routine Description:\r | |
176 | \r | |
177 | This routine will free some resources which have been allocated in\r | |
178 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r | |
179 | it must call this routine to free the allocated resource before the exiting.\r | |
180 | \r | |
181 | Arguments:\r | |
182 | \r | |
183 | None\r | |
184 | \r | |
185 | Returns: \r | |
186 | \r | |
187 | EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r | |
188 | EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r | |
189 | \r | |
190 | --*/\r | |
191 | {\r | |
192 | EFI_STATUS Status;\r | |
193 | \r | |
194 | if (!mRuntimeLibInitialized) {\r | |
195 | //\r | |
196 | // You must call EfiInitializeRuntimeDriverLib() first\r | |
197 | //\r | |
198 | return EFI_UNSUPPORTED;\r | |
199 | }\r | |
200 | \r | |
201 | mRuntimeLibInitialized = FALSE;\r | |
202 | \r | |
203 | //\r | |
204 | // Close our ExitBootServices () notify function\r | |
205 | //\r | |
206 | if (mRuntimeNotifyEvent != NULL) {\r | |
207 | Status = gBS->CloseEvent (mRuntimeNotifyEvent);\r | |
208 | ASSERT_EFI_ERROR (Status);\r | |
209 | }\r | |
210 | \r | |
211 | return EFI_SUCCESS;\r | |
212 | }\r | |
213 | \r | |
214 | BOOLEAN\r | |
215 | EfiAtRuntime (\r | |
216 | VOID\r | |
217 | )\r | |
218 | /*++\r | |
219 | \r | |
220 | Routine Description:\r | |
221 | Return TRUE if ExitBootServices () has been called\r | |
222 | \r | |
223 | Arguments:\r | |
224 | NONE\r | |
225 | \r | |
226 | Returns: \r | |
227 | TRUE - If ExitBootServices () has been called\r | |
228 | \r | |
229 | --*/\r | |
230 | {\r | |
231 | return mEfiAtRuntime;\r | |
232 | }\r | |
233 | \r | |
234 | BOOLEAN\r | |
235 | EfiGoneVirtual (\r | |
236 | VOID\r | |
237 | )\r | |
238 | /*++\r | |
239 | \r | |
240 | Routine Description:\r | |
241 | Return TRUE if SetVirtualAddressMap () has been called\r | |
242 | \r | |
243 | Arguments:\r | |
244 | NONE\r | |
245 | \r | |
246 | Returns: \r | |
247 | TRUE - If SetVirtualAddressMap () has been called\r | |
248 | \r | |
249 | --*/\r | |
250 | {\r | |
251 | return mEfiGoneVirtual;\r | |
252 | }\r | |
253 | \r | |
254 | EFI_STATUS\r | |
255 | EfiReportStatusCode (\r | |
256 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
257 | IN EFI_STATUS_CODE_VALUE Value,\r | |
258 | IN UINT32 Instance,\r | |
259 | IN EFI_GUID * CallerId,\r | |
260 | IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r | |
261 | )\r | |
262 | /*++\r | |
263 | \r | |
264 | Routine Description:\r | |
265 | \r | |
266 | Status Code reporter\r | |
267 | \r | |
268 | Arguments:\r | |
269 | \r | |
270 | CodeType - Type of Status Code.\r | |
271 | \r | |
272 | Value - Value to output for Status Code.\r | |
273 | \r | |
274 | Instance - Instance Number of this status code.\r | |
275 | \r | |
276 | CallerId - ID of the caller of this status code.\r | |
277 | \r | |
278 | Data - Optional data associated with this status code.\r | |
279 | \r | |
280 | Returns:\r | |
281 | \r | |
282 | Status code\r | |
283 | \r | |
284 | --*/\r | |
285 | {\r | |
286 | return EFI_UNSUPPORTED;\r | |
287 | }\r | |
288 | //\r | |
289 | // Cache Flush Routine.\r | |
290 | //\r | |
291 | EFI_STATUS\r | |
292 | EfiCpuFlushCache (\r | |
293 | IN EFI_PHYSICAL_ADDRESS Start,\r | |
294 | IN UINT64 Length\r | |
295 | )\r | |
296 | /*++\r | |
297 | \r | |
298 | Routine Description:\r | |
299 | \r | |
300 | Flush cache with specified range.\r | |
301 | \r | |
302 | Arguments:\r | |
303 | \r | |
304 | Start - Start address\r | |
305 | Length - Length in bytes\r | |
306 | \r | |
307 | Returns:\r | |
308 | \r | |
309 | Status code\r | |
310 | \r | |
311 | EFI_SUCCESS - success\r | |
312 | \r | |
313 | --*/\r | |
314 | {\r | |
315 | return EFI_SUCCESS;\r | |
316 | }\r |