]>
Commit | Line | Data |
---|---|---|
f2abdc91 | 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 | Runtime.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Runtime Architectural Protocol as defined in the DXE CIS\r | |
19 | \r | |
20 | This code is used to produce the EFI runtime virtual switch over\r | |
21 | \r | |
22 | THIS IS VERY DANGEROUS CODE BE VERY CAREFUL IF YOU CHANGE IT\r | |
23 | \r | |
24 | The transition for calling EFI Runtime functions in physical mode to calling\r | |
25 | them in virtual mode is very very complex. Every pointer in needs to be\r | |
26 | converted from physical mode to virtual mode. Be very careful walking linked\r | |
27 | lists! Then to make it really hard the code it's self needs be relocated into\r | |
28 | the new virtual address space.\r | |
29 | \r | |
30 | So here is the concept. The code in this module will never ever be called in\r | |
31 | virtual mode. This is the code that collects the information needed to convert\r | |
32 | to virtual mode (DXE core registers runtime stuff with this code). Since this\r | |
33 | code is used to fixup all runtime images, it CAN NOT fix it's self up. So some\r | |
34 | code has to stay behind and that is us.\r | |
35 | \r | |
36 | Also you need to be careful about when you allocate memory, as once we are in\r | |
37 | runtime (including our EVT_SIGNAL_EXIT_BOOT_SERVICES event) you can no longer\r | |
38 | allocate memory.\r | |
39 | \r | |
40 | Any runtime driver that gets loaded before us will not be callable in virtual\r | |
41 | mode. This is due to the fact that the DXE core can not register the info\r | |
42 | needed with us. This is good, since it keeps the code in this file from\r | |
43 | getting registered.\r | |
44 | \r | |
45 | \r | |
46 | Revision History:\r | |
47 | \r | |
48 | - Move the CalculateCrc32 function from Runtime Arch Protocol to Boot Service.\r | |
49 | Runtime Arch Protocol definition no longer contains CalculateCrc32. Boot Service\r | |
50 | Table now contains an item named CalculateCrc32.\r | |
51 | \r | |
52 | --*/\r | |
53 | \r | |
54 | #include "Runtime.h"\r | |
55 | \r | |
56 | //\r | |
57 | // Global Variables\r | |
58 | //\r | |
59 | EFI_MEMORY_DESCRIPTOR *mVirtualMap = NULL;\r | |
60 | UINTN mVirtualMapDescriptorSize;\r | |
61 | UINTN mVirtualMapMaxIndex;\r | |
62 | VOID *mMyImageBase;\r | |
63 | \r | |
64 | //\r | |
65 | // The handle onto which the Runtime Architectural Protocol instance is installed\r | |
66 | //\r | |
67 | EFI_HANDLE mRuntimeHandle = NULL;\r | |
68 | \r | |
69 | //\r | |
70 | // The Runtime Architectural Protocol instance produced by this driver\r | |
71 | //\r | |
72 | EFI_RUNTIME_ARCH_PROTOCOL mRuntime = {\r | |
73 | INITIALIZE_LIST_HEAD_VARIABLE (mRuntime.ImageHead),\r | |
74 | INITIALIZE_LIST_HEAD_VARIABLE (mRuntime.EventHead),\r | |
75 | \r | |
76 | //\r | |
77 | // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will\r | |
78 | // prevent people from having pointer math bugs in their code.\r | |
79 | // now you have to use *DescriptorSize to make things work.\r | |
80 | //\r | |
81 | sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),\r | |
82 | EFI_MEMORY_DESCRIPTOR_VERSION,\r | |
83 | 0,\r | |
84 | NULL,\r | |
85 | NULL,\r | |
86 | FALSE,\r | |
87 | FALSE\r | |
88 | };\r | |
89 | \r | |
90 | //\r | |
91 | // Worker Functions\r | |
92 | //\r | |
93 | STATIC\r | |
94 | VOID\r | |
95 | RuntimeDriverCalculateEfiHdrCrc (\r | |
96 | IN OUT EFI_TABLE_HEADER *Hdr\r | |
97 | )\r | |
98 | /*++\r | |
99 | \r | |
100 | Routine Description:\r | |
101 | \r | |
102 | Calcualte the 32-bit CRC in a EFI table using the Runtime Drivers\r | |
103 | internal function. The EFI Boot Services Table can not be used because\r | |
104 | the EFI Boot Services Table was destroyed at ExitBootServices()\r | |
105 | \r | |
106 | Arguments:\r | |
107 | \r | |
108 | Hdr - Pointer to an EFI standard header\r | |
109 | \r | |
110 | Returns:\r | |
111 | \r | |
112 | None\r | |
113 | \r | |
114 | --*/\r | |
115 | {\r | |
116 | UINT32 Crc;\r | |
117 | \r | |
118 | Hdr->CRC32 = 0;\r | |
119 | \r | |
120 | Crc = 0;\r | |
121 | RuntimeDriverCalculateCrc32 ((UINT8 *) Hdr, Hdr->HeaderSize, &Crc);\r | |
122 | Hdr->CRC32 = Crc;\r | |
123 | }\r | |
124 | \r | |
125 | EFI_STATUS\r | |
126 | EFIAPI\r | |
127 | RuntimeDriverConvertPointer (\r | |
128 | IN UINTN DebugDisposition,\r | |
129 | IN OUT VOID **ConvertAddress\r | |
130 | )\r | |
131 | /*++\r | |
132 | \r | |
133 | Routine Description:\r | |
134 | \r | |
135 | Determines the new virtual address that is to be used on subsequent memory accesses.\r | |
136 | \r | |
137 | Arguments:\r | |
138 | \r | |
139 | DebugDisposition - Supplies type information for the pointer being converted.\r | |
140 | ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed\r | |
141 | for the new virtual address mappings being applied.\r | |
142 | \r | |
143 | Returns:\r | |
144 | \r | |
145 | EFI_SUCCESS - The pointer pointed to by Address was modified.\r | |
146 | EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part\r | |
147 | of the current memory map. This is normally fatal.\r | |
148 | EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r | |
149 | \r | |
150 | --*/\r | |
151 | {\r | |
152 | UINTN Address;\r | |
153 | UINT64 VirtEndOfRange;\r | |
154 | EFI_MEMORY_DESCRIPTOR *VirtEntry;\r | |
155 | UINTN Index;\r | |
156 | \r | |
157 | //\r | |
158 | // Make sure ConvertAddress is a valid pointer\r | |
159 | //\r | |
160 | if (ConvertAddress == NULL) {\r | |
161 | return EFI_INVALID_PARAMETER;\r | |
162 | }\r | |
163 | //\r | |
164 | // Get the address to convert\r | |
165 | //\r | |
166 | Address = (UINTN) *ConvertAddress;\r | |
167 | \r | |
168 | //\r | |
169 | // If this is a null pointer, return if it's allowed\r | |
170 | //\r | |
171 | if (Address == 0) {\r | |
172 | if (DebugDisposition & EFI_OPTIONAL_POINTER) {\r | |
173 | return EFI_SUCCESS;\r | |
174 | }\r | |
175 | \r | |
176 | return EFI_INVALID_PARAMETER;\r | |
177 | }\r | |
178 | \r | |
179 | VirtEntry = mVirtualMap;\r | |
180 | for (Index = 0; Index < mVirtualMapMaxIndex; Index++) {\r | |
181 | //\r | |
182 | // To prevent the inclusion of 64-bit math functions a UINTN was placed in\r | |
183 | // front of VirtEntry->NumberOfPages to cast it to a 32-bit thing on IA-32\r | |
184 | // platforms. If you get this ASSERT remove the UINTN and do a 64-bit\r | |
185 | // multiply.\r | |
186 | //\r | |
187 | ASSERT (((UINTN) VirtEntry->NumberOfPages < 0xffffffff) || (sizeof (UINTN) > 4));\r | |
188 | \r | |
189 | if ((VirtEntry->Attribute & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME) {\r | |
190 | if (Address >= VirtEntry->PhysicalStart) {\r | |
191 | VirtEndOfRange = VirtEntry->PhysicalStart + (((UINTN) VirtEntry->NumberOfPages) * EFI_PAGE_SIZE);\r | |
192 | if (Address < VirtEndOfRange) {\r | |
193 | //\r | |
194 | // Compute new address\r | |
195 | //\r | |
196 | *ConvertAddress = (VOID *) (Address - (UINTN) VirtEntry->PhysicalStart + (UINTN) VirtEntry->VirtualStart);\r | |
197 | return EFI_SUCCESS;\r | |
198 | }\r | |
199 | }\r | |
200 | }\r | |
201 | \r | |
202 | VirtEntry = NextMemoryDescriptor (VirtEntry, mVirtualMapDescriptorSize);\r | |
203 | }\r | |
204 | \r | |
205 | return EFI_NOT_FOUND;\r | |
206 | }\r | |
207 | \r | |
208 | STATIC\r | |
209 | EFI_STATUS\r | |
210 | RuntimeDriverConvertInternalPointer (\r | |
211 | IN OUT VOID **ConvertAddress\r | |
212 | )\r | |
213 | /*++\r | |
214 | \r | |
215 | Routine Description:\r | |
216 | \r | |
217 | Determines the new virtual address that is to be used on subsequent memory accesses\r | |
218 | for internal pointers.\r | |
219 | \r | |
220 | Arguments:\r | |
221 | \r | |
222 | ConvertAddress - A pointer to a pointer that is to be fixed to be the value needed\r | |
223 | for the new virtual address mappings being applied.\r | |
224 | \r | |
225 | Returns:\r | |
226 | \r | |
227 | EFI_SUCCESS - The pointer pointed to by Address was modified.\r | |
228 | EFI_NOT_FOUND - The pointer pointed to by Address was not found to be part\r | |
229 | of the current memory map. This is normally fatal.\r | |
230 | EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r | |
231 | \r | |
232 | --*/\r | |
233 | {\r | |
234 | return RuntimeDriverConvertPointer (0x0, ConvertAddress);\r | |
235 | }\r | |
236 | \r | |
237 | EFI_STATUS\r | |
238 | EFIAPI\r | |
239 | RuntimeDriverSetVirtualAddressMap (\r | |
240 | IN UINTN MemoryMapSize,\r | |
241 | IN UINTN DescriptorSize,\r | |
242 | IN UINT32 DescriptorVersion,\r | |
243 | IN EFI_MEMORY_DESCRIPTOR *VirtualMap\r | |
244 | )\r | |
245 | /*++\r | |
246 | \r | |
247 | Routine Description:\r | |
248 | \r | |
249 | Changes the runtime addressing mode of EFI firmware from physical to virtual.\r | |
250 | \r | |
251 | Arguments:\r | |
252 | \r | |
253 | MemoryMapSize - The size in bytes of VirtualMap.\r | |
254 | DescriptorSize - The size in bytes of an entry in the VirtualMap.\r | |
255 | DescriptorVersion - The version of the structure entries in VirtualMap.\r | |
256 | VirtualMap - An array of memory descriptors which contain new virtual\r | |
257 | address mapping information for all runtime ranges.\r | |
258 | \r | |
259 | Returns:\r | |
260 | \r | |
261 | EFI_SUCCESS - The virtual address map has been applied.\r | |
262 | EFI_UNSUPPORTED - EFI firmware is not at runtime, or the EFI firmware is already in\r | |
263 | virtual address mapped mode.\r | |
264 | EFI_INVALID_PARAMETER - DescriptorSize or DescriptorVersion is invalid.\r | |
265 | EFI_NO_MAPPING - A virtual address was not supplied for a range in the memory\r | |
266 | map that requires a mapping.\r | |
267 | EFI_NOT_FOUND - A virtual address was supplied for an address that is not found\r | |
268 | in the memory map.\r | |
269 | \r | |
270 | --*/\r | |
271 | {\r | |
272 | EFI_STATUS Status;\r | |
273 | EFI_RUNTIME_EVENT_ENTRY *RuntimeEvent;\r | |
274 | EFI_RUNTIME_IMAGE_ENTRY *RuntimeImage;\r | |
275 | LIST_ENTRY *Link;\r | |
276 | EFI_PHYSICAL_ADDRESS VirtImageBase;\r | |
10e2e070 LG |
277 | UINTN Index;\r |
278 | UINTN Index1;\r | |
279 | UINTN Index2;\r | |
280 | UINTN Index3;\r | |
281 | EFI_CAPSULE_TABLE *CapsuleTable; \r | |
282 | EFI_CAPSULE_INFO_TABLE *CapsuleInfoTable; \r | |
f2abdc91 | 283 | \r |
284 | //\r | |
285 | // Can only switch to virtual addresses once the memory map is locked down,\r | |
286 | // and can only set it once\r | |
287 | //\r | |
288 | if (!mRuntime.AtRuntime || mRuntime.VirtualMode) {\r | |
289 | return EFI_UNSUPPORTED;\r | |
290 | }\r | |
291 | //\r | |
292 | // Only understand the original descriptor format\r | |
293 | //\r | |
294 | if (DescriptorVersion != EFI_MEMORY_DESCRIPTOR_VERSION || DescriptorSize < sizeof (EFI_MEMORY_DESCRIPTOR)) {\r | |
295 | return EFI_INVALID_PARAMETER;\r | |
296 | }\r | |
297 | //\r | |
298 | // We are now committed to go to virtual mode, so lets get to it!\r | |
299 | //\r | |
300 | mRuntime.VirtualMode = TRUE;\r | |
301 | \r | |
302 | //\r | |
303 | // ConvertPointer() needs this mVirtualMap to do the conversion. So set up\r | |
304 | // globals we need to parse the virtual address map.\r | |
305 | //\r | |
306 | mVirtualMapDescriptorSize = DescriptorSize;\r | |
307 | mVirtualMapMaxIndex = MemoryMapSize / DescriptorSize;\r | |
308 | mVirtualMap = VirtualMap;\r | |
309 | \r | |
310 | //\r | |
311 | // Currently the bug in StatusCode/RuntimeLib has been fixed, it will\r | |
312 | // check whether in Runtime or not (this is judged by looking at\r | |
313 | // mEfiAtRuntime global So this ReportStatusCode will work\r | |
314 | //\r | |
315 | REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdStatusCodeValueSetVirtualAddressMap));\r | |
316 | \r | |
317 | //\r | |
318 | // Signal all the EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE events.\r | |
319 | // All runtime events are stored in a list in Runtime AP.\r | |
320 | //\r | |
321 | for (Link = mRuntime.EventHead.ForwardLink; Link != &mRuntime.EventHead; Link = Link->ForwardLink) {\r | |
322 | RuntimeEvent = _CR (Link, EFI_RUNTIME_EVENT_ENTRY, Link);\r | |
323 | if ((RuntimeEvent->Type & EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) == EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {\r | |
324 | RuntimeEvent->NotifyFunction (\r | |
325 | RuntimeEvent->Event,\r | |
326 | RuntimeEvent->NotifyContext\r | |
327 | );\r | |
328 | }\r | |
329 | }\r | |
330 | \r | |
331 | //\r | |
332 | // Relocate runtime images. All runtime images are stored in a list in Runtime AP.\r | |
333 | //\r | |
334 | for (Link = mRuntime.ImageHead.ForwardLink; Link != &mRuntime.ImageHead; Link = Link->ForwardLink) {\r | |
335 | RuntimeImage = _CR (Link, EFI_RUNTIME_IMAGE_ENTRY, Link);\r | |
336 | //\r | |
337 | // We don't want to relocate our selves, as we only run in physical mode.\r | |
338 | //\r | |
339 | if (mMyImageBase != RuntimeImage->ImageBase) {\r | |
340 | \r | |
341 | VirtImageBase = (EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase;\r | |
342 | Status = RuntimeDriverConvertPointer (0, (VOID **) &VirtImageBase);\r | |
343 | ASSERT_EFI_ERROR (Status);\r | |
344 | \r | |
345 | PeCoffLoaderRelocateImageForRuntime (\r | |
346 | (EFI_PHYSICAL_ADDRESS) (UINTN) RuntimeImage->ImageBase,\r | |
347 | VirtImageBase,\r | |
348 | (UINTN) RuntimeImage->ImageSize,\r | |
349 | RuntimeImage->RelocationData\r | |
350 | );\r | |
351 | \r | |
352 | InvalidateInstructionCacheRange (RuntimeImage->ImageBase, (UINTN)RuntimeImage->ImageSize);\r | |
353 | }\r | |
354 | }\r | |
355 | \r | |
356 | //\r | |
357 | // Convert all the Runtime Services except ConvertPointer() and SetVirtualAddressMap()\r | |
358 | // and recompute the CRC-32\r | |
359 | //\r | |
360 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetTime);\r | |
361 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetTime);\r | |
362 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetWakeupTime);\r | |
363 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetWakeupTime);\r | |
364 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->ResetSystem);\r | |
365 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetNextHighMonotonicCount);\r | |
366 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetVariable);\r | |
367 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->SetVariable);\r | |
368 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->GetNextVariableName);\r | |
369 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->QueryVariableInfo);\r | |
370 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->UpdateCapsule);\r | |
371 | RuntimeDriverConvertInternalPointer ((VOID **) &gRT->QueryCapsuleCapabilities);\r | |
372 | RuntimeDriverCalculateEfiHdrCrc (&gRT->Hdr);\r | |
373 | \r | |
374 | //\r | |
375 | // BugBug: PI requires System Configuration Tables Conversion.\r | |
376 | // Currently, we do not implement it.\r | |
377 | //\r | |
10e2e070 LG |
378 | for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {\r |
379 | //\r | |
380 | // CapsuleInfoGuid in ConfigTable refers to an array of CapsuleGuid, it is information\r | |
381 | // from which you can tell which vendorGuids in ConfigTable are related to CapsuleTable.\r | |
382 | // Each CapsuleTable points to a array of capsules across a system reset. Then convert \r | |
383 | // the array contents to make these capsules visiable in Runtime.\r | |
384 | //\r | |
385 | \r | |
386 | //\r | |
387 | // Firstly, Get CapsulInfoGuid in ConfigTable, it points to CapsuleInfoTable, which\r | |
388 | // gather all the installed capsules' guids.\r | |
389 | //\r | |
390 | if (CompareGuid (&gEfiCapsuleInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r | |
391 | CapsuleInfoTable = gST->ConfigurationTable[Index].VendorTable;\r | |
392 | //\r | |
393 | // For each known CapsuleGuid in CapsuleInfoTable, loop the whole ConfigTable to\r | |
394 | // find out this guid related to CapsuleTable.\r | |
395 | //\r | |
396 | for (Index1 = 0; Index1 < CapsuleInfoTable->CapsuleGuidNumber; Index1++) {\r | |
397 | for (Index2 = 0; Index2 < gST->NumberOfTableEntries; Index2++) {\r | |
398 | //\r | |
399 | // Find out certain CapsuleTable, go through its contents array, and convert them.\r | |
400 | //\r | |
401 | if (CompareGuid (&CapsuleInfoTable->CapsuleGuidPtr[Index1], &(gST->ConfigurationTable[Index2].VendorGuid))) {\r | |
402 | CapsuleTable = gST->ConfigurationTable[Index2].VendorTable;\r | |
403 | for (Index3 = 0; Index3 < CapsuleTable->CapsuleArrayNumber; Index3++) {\r | |
404 | RuntimeDriverConvertInternalPointer ((VOID **) &CapsuleTable->CapsulePtr[Index3]);\r | |
405 | } \r | |
406 | RuntimeDriverConvertInternalPointer ((VOID **) &(gST->ConfigurationTable[Index2].VendorTable));\r | |
407 | }\r | |
408 | }\r | |
409 | }\r | |
410 | break;\r | |
411 | }\r | |
412 | }\r | |
f2abdc91 | 413 | \r |
414 | //\r | |
415 | // Convert the runtime fields of the EFI System Table and recompute the CRC-32\r | |
416 | //\r | |
417 | RuntimeDriverConvertInternalPointer ((VOID **) &gST->FirmwareVendor);\r | |
418 | RuntimeDriverConvertInternalPointer ((VOID **) &gST->ConfigurationTable);\r | |
419 | RuntimeDriverConvertInternalPointer ((VOID **) &gST->RuntimeServices);\r | |
420 | RuntimeDriverCalculateEfiHdrCrc (&gST->Hdr);\r | |
421 | \r | |
422 | //\r | |
423 | // At this point, gRT and gST are physical pointers, but the contents of these tables\r | |
424 | // have been converted to runtime.\r | |
425 | //\r | |
426 | //\r | |
427 | // mVirtualMap is only valid during SetVirtualAddressMap() call\r | |
428 | //\r | |
429 | mVirtualMap = NULL;\r | |
430 | \r | |
431 | return EFI_SUCCESS;\r | |
432 | }\r | |
433 | \r | |
434 | EFI_STATUS\r | |
435 | EFIAPI\r | |
436 | RuntimeDriverInitialize (\r | |
437 | IN EFI_HANDLE ImageHandle,\r | |
438 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
439 | )\r | |
440 | /*++\r | |
441 | \r | |
442 | Routine Description:\r | |
443 | Install Runtime AP. This code includes the EfiDriverLib, but it functions at\r | |
444 | RT in physical mode. The only Lib services are gBS, gRT, and the DEBUG and\r | |
445 | ASSERT macros (they do ReportStatusCode).\r | |
446 | \r | |
447 | Arguments:\r | |
448 | (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r | |
449 | \r | |
450 | Returns:\r | |
451 | \r | |
452 | EFI_SUCEESS - Runtime Driver Architectural Protocol Installed\r | |
453 | \r | |
454 | Other - Return value from gBS->InstallMultipleProtocolInterfaces\r | |
455 | \r | |
456 | --*/\r | |
457 | {\r | |
458 | EFI_STATUS Status;\r | |
459 | EFI_LOADED_IMAGE_PROTOCOL *MyLoadedImage;\r | |
460 | \r | |
461 | //\r | |
462 | // This image needs to be exclued from relocation for virtual mode, so cache\r | |
463 | // a copy of the Loaded Image protocol to test later.\r | |
464 | //\r | |
465 | Status = gBS->HandleProtocol (\r | |
466 | ImageHandle,\r | |
467 | &gEfiLoadedImageProtocolGuid,\r | |
468 | (VOID**)&MyLoadedImage\r | |
469 | );\r | |
470 | ASSERT_EFI_ERROR (Status);\r | |
471 | mMyImageBase = MyLoadedImage->ImageBase;\r | |
472 | \r | |
473 | //\r | |
474 | // Initialize the table used to compute 32-bit CRCs\r | |
475 | //\r | |
476 | RuntimeDriverInitializeCrc32Table ();\r | |
477 | \r | |
478 | //\r | |
479 | // Fill in the entries of the EFI Boot Services and EFI Runtime Services Tables\r | |
480 | //\r | |
481 | gBS->CalculateCrc32 = RuntimeDriverCalculateCrc32;\r | |
482 | gRT->SetVirtualAddressMap = RuntimeDriverSetVirtualAddressMap;\r | |
483 | gRT->ConvertPointer = RuntimeDriverConvertPointer;\r | |
484 | \r | |
485 | //\r | |
486 | // Install the Runtime Architectural Protocol onto a new handle\r | |
487 | //\r | |
488 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
489 | &mRuntimeHandle,\r | |
490 | &gEfiRuntimeArchProtocolGuid,\r | |
491 | &mRuntime,\r | |
492 | NULL\r | |
493 | );\r | |
494 | ASSERT_EFI_ERROR (Status);\r | |
495 | \r | |
496 | return EFI_SUCCESS;\r | |
497 | }\r |