]> git.proxmox.com Git - mirror_edk2.git/blame - EdkNt32Pkg/Sec/SecMain.c
Make NT32 SecMain not depend on ReportStatusCodeLib
[mirror_edk2.git] / EdkNt32Pkg / Sec / SecMain.c
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
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
12Module Name:\r
13\r
14 SecMain.c\r
15\r
16Abstract:\r
17 WinNt emulator of SEC phase. It's really a Win32 application, but this is\r
18 Ok since all the other modules for NT32 are NOT Win32 applications.\r
19\r
20 This program processes Windows environment variables and figures out\r
21 what the memory layout will be, how may FD's will be loaded and also\r
22 what the boot mode is.\r
23\r
24 The SEC registers a set of services with the SEC core. gPrivateDispatchTable\r
25 is a list of PPI's produced by the SEC that are availble for usage in PEI.\r
26\r
27 This code produces 128 K of temporary memory for the PEI stack by opening a\r
28 Windows file and mapping it directly to memory addresses.\r
29\r
30 The system.cmd script is used to set windows environment variables that drive\r
31 the configuration opitons of the SEC.\r
32\r
33--*/\r
34\r
35#include "SecMain.h"\r
f55a0ac9 36#pragma warning(disable : 4996)\r
878ddf1f 37\r
38//\r
39// Globals\r
40//\r
41EFI_PEI_PE_COFF_LOADER_PROTOCOL_INSTANCE mPeiEfiPeiPeCoffLoaderInstance = {\r
42 {\r
43 SecNt32PeCoffGetImageInfo,\r
44 SecNt32PeCoffLoadImage,\r
45 SecNt32PeCoffRelocateImage,\r
46 SecNt32PeCoffUnloadimage\r
47 },\r
48 NULL\r
49};\r
50\r
51\r
52\r
53EFI_PEI_PE_COFF_LOADER_PROTOCOL *gPeiEfiPeiPeCoffLoader = &mPeiEfiPeiPeCoffLoaderInstance.PeCoff;\r
54\r
55NT_PEI_LOAD_FILE_PPI mSecNtLoadFilePpi = { SecWinNtPeiLoadFile };\r
56\r
57PEI_NT_AUTOSCAN_PPI mSecNtAutoScanPpi = { SecWinNtPeiAutoScan };\r
58\r
59PEI_NT_THUNK_PPI mSecWinNtThunkPpi = { SecWinNtWinNtThunkAddress };\r
60\r
61EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { SecPeiReportStatusCode };\r
62\r
63NT_FWH_PPI mSecFwhInformationPpi = { SecWinNtFdAddress };\r
64\r
65\r
66EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {\r
67 {\r
68 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
69 &gEfiPeiPeCoffLoaderGuid,\r
70 NULL\r
71 },\r
72 {\r
73 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
74 &gNtPeiLoadFilePpiGuid,\r
75 &mSecNtLoadFilePpi\r
76 },\r
77 {\r
78 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
79 &gPeiNtAutoScanPpiGuid,\r
80 &mSecNtAutoScanPpi\r
81 },\r
82 {\r
83 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
84 &gPeiNtThunkPpiGuid,\r
85 &mSecWinNtThunkPpi\r
86 },\r
87 {\r
88 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
89 &gEfiPeiStatusCodePpiGuid,\r
90 &mSecStatusCodePpi\r
91 },\r
92 {\r
93 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
94 &gNtFwhPpiGuid,\r
95 &mSecFwhInformationPpi\r
96 }\r
97};\r
98\r
99\r
100//\r
101// Default information about where the FD is located.\r
102// This array gets filled in with information from EFI_FIRMWARE_VOLUMES\r
103// EFI_FIRMWARE_VOLUMES is a Windows environment variable set by system.cmd.\r
104// The number of array elements is allocated base on parsing\r
105// EFI_FIRMWARE_VOLUMES and the memory is never freed.\r
106//\r
107UINTN gFdInfoCount = 0;\r
108NT_FD_INFO *gFdInfo;\r
109\r
110//\r
111// Array that supports seperate memory rantes.\r
112// The memory ranges are set in system.cmd via the EFI_MEMORY_SIZE variable.\r
113// The number of array elements is allocated base on parsing\r
114// EFI_MEMORY_SIZE and the memory is never freed.\r
115//\r
116UINTN gSystemMemoryCount = 0;\r
117NT_SYSTEM_MEMORY *gSystemMemory;\r
118\r
119\r
120UINTN mPdbNameModHandleArraySize = 0;\r
121PDB_NAME_TO_MOD_HANDLE *mPdbNameModHandleArray = NULL;\r
122\r
123\r
124\r
125\r
126INTN\r
127EFIAPI\r
128main (\r
129 IN INTN Argc,\r
130 IN CHAR8 **Argv,\r
131 IN CHAR8 **Envp\r
132 )\r
133/*++\r
134\r
135Routine Description:\r
136 Main entry point to SEC for WinNt. This is a Windows program\r
137\r
138Arguments:\r
139 Argc - Number of command line arguments\r
140 Argv - Array of command line argument strings\r
141 Envp - Array of environmemt variable strings\r
142\r
143Returns:\r
144 0 - Normal exit\r
145 1 - Abnormal exit\r
146\r
147--*/\r
148{\r
149 EFI_STATUS Status;\r
150 EFI_PHYSICAL_ADDRESS InitialStackMemory;\r
151 UINT64 InitialStackMemorySize;\r
152 UINTN Index;\r
153 UINTN Index1;\r
154 UINTN Index2;\r
155 UINTN PeiIndex;\r
156 CHAR16 *FileName;\r
157 CHAR16 *FileNamePtr;\r
158 BOOLEAN Done;\r
159 VOID *PeiCoreFile;\r
160 CHAR16 *MemorySizeStr;\r
161 CHAR16 *FirmwareVolumesStr;\r
162\r
b144ae9a 163 MemorySizeStr = (CHAR16 *)PcdGetPtr (PcdWinNtMemorySizeForSecMain);\r
164 FirmwareVolumesStr = (CHAR16 *)PcdGetPtr (PcdWinNtFirmwareVolume);\r
878ddf1f 165\r
166 printf ("\nEDK SEC Main NT Emulation Environment from www.TianoCore.org\n");\r
167\r
168 //\r
169 // Make some Windows calls to Set the process to the highest priority in the\r
170 // idle class. We need this to have good performance.\r
171 //\r
172 SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS);\r
173 SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST);\r
174\r
175 //\r
176 // Allocate space for gSystemMemory Array\r
177 //\r
178 gSystemMemoryCount = CountSeperatorsInString (MemorySizeStr, '!') + 1;\r
179 gSystemMemory = calloc (gSystemMemoryCount, sizeof (NT_SYSTEM_MEMORY));\r
180 if (gSystemMemory == NULL) {\r
181 printf ("ERROR : Can not allocate memory for %s. Exiting.\n", MemorySizeStr);\r
182 exit (1);\r
183 }\r
184 //\r
185 // Allocate space for gSystemMemory Array\r
186 //\r
187 gFdInfoCount = CountSeperatorsInString (FirmwareVolumesStr, '!') + 1;\r
188 gFdInfo = calloc (gFdInfoCount, sizeof (NT_FD_INFO));\r
189 if (gFdInfo == NULL) {\r
190 printf ("ERROR : Can not allocate memory for %s. Exiting.\n", FirmwareVolumesStr);\r
191 exit (1);\r
192 }\r
193 //\r
194 // Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION)\r
195 //\r
196 printf (" BootMode 0x%02x\n", FixedPcdGet32 (PcdWinNtBootMode));\r
197\r
198 //\r
199 // Open up a 128K file to emulate temp memory for PEI.\r
200 // on a real platform this would be SRAM, or using the cache as RAM.\r
201 // Set InitialStackMemory to zero so WinNtOpenFile will allocate a new mapping\r
202 //\r
203 InitialStackMemory = 0;\r
204 InitialStackMemorySize = 0x20000;\r
205 Status = WinNtOpenFile (\r
206 L"SecStack",\r
207 (UINT32) InitialStackMemorySize,\r
208 OPEN_ALWAYS,\r
209 &InitialStackMemory,\r
210 &InitialStackMemorySize\r
211 );\r
212 if (EFI_ERROR (Status)) {\r
213 printf ("ERROR : Can not open SecStack Exiting\n");\r
214 exit (1);\r
215 }\r
216\r
217 printf (" SEC passing in %d bytes of temp RAM to PEI\n", InitialStackMemorySize);\r
218\r
219 //\r
220 // Open All the firmware volumes and remember the info in the gFdInfo global\r
221 //\r
222 FileNamePtr = (CHAR16 *)malloc (StrLen ((CHAR16 *)FirmwareVolumesStr) * sizeof(CHAR16));\r
223 if (FileNamePtr == NULL) {\r
224 printf ("ERROR : Can not allocate memory for firmware volume string\n");\r
225 exit (1);\r
226 }\r
227\r
228 StrCpy (FileNamePtr, (CHAR16*)FirmwareVolumesStr);\r
229\r
230 for (Done = FALSE, Index = 0, PeiIndex = 0, PeiCoreFile = NULL; !Done; Index++) {\r
231 FileName = FileNamePtr;\r
232 for (Index1 = 0; (FileNamePtr[Index1] != '!') && (FileNamePtr[Index1] != 0); Index1++)\r
233 ;\r
234 if (FileNamePtr[Index1] == 0) {\r
235 Done = TRUE;\r
236 } else {\r
237 FileNamePtr[Index1] = '\0';\r
238 FileNamePtr = FileNamePtr + Index1 + 1;\r
239 }\r
240\r
241 //\r
242 // Open the FD and remmeber where it got mapped into our processes address space\r
243 //\r
244 Status = WinNtOpenFile (\r
245 FileName,\r
246 0,\r
247 OPEN_EXISTING,\r
248 &gFdInfo[Index].Address,\r
249 &gFdInfo[Index].Size\r
250 );\r
251 if (EFI_ERROR (Status)) {\r
252 printf ("ERROR : Can not open Firmware Device File %S (%r). Exiting.\n", FileName, Status);\r
253 exit (1);\r
254 }\r
255\r
256 printf (" FD loaded from");\r
257 //\r
258 // printf can't print filenames directly as the \ gets interperted as an\r
259 // escape character.\r
260 //\r
261 for (Index2 = 0; FileName[Index2] != '\0'; Index2++) {\r
262 printf ("%c", FileName[Index2]);\r
263 }\r
264\r
265 if (PeiCoreFile == NULL) {\r
266 //\r
267 // Assume the beginning of the FD is an FV and look for the PEI Core.\r
268 // Load the first one we find.\r
269 //\r
270 Status = SecFfsFindPeiCore ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) gFdInfo[Index].Address, &PeiCoreFile);\r
271 if (!EFI_ERROR (Status)) {\r
272 PeiIndex = Index;\r
273 printf (" contains SEC Core");\r
274 }\r
275 }\r
276\r
277 printf ("\n");\r
278 }\r
279 //\r
280 // Calculate memory regions and store the information in the gSystemMemory\r
281 // global for later use. The autosizing code will use this data to\r
282 // map this memory into the SEC process memory space.\r
283 //\r
284 for (Index = 0, Done = FALSE; !Done; Index++) {\r
285 //\r
286 // Save the size of the memory and make a Unicode filename SystemMemory00, ...\r
287 //\r
288 gSystemMemory[Index].Size = _wtoi (MemorySizeStr) * 0x100000;\r
289 _snwprintf (gSystemMemory[Index].FileName, NT_SYSTEM_MEMORY_FILENAME_SIZE, L"SystemMemory%02d", Index);\r
290\r
291 //\r
292 // Find the next region\r
293 //\r
294 for (Index1 = 0; MemorySizeStr[Index1] != '!' && MemorySizeStr[Index1] != 0; Index1++)\r
295 ;\r
296 if (MemorySizeStr[Index1] == 0) {\r
297 Done = TRUE;\r
298 }\r
299\r
300 MemorySizeStr = MemorySizeStr + Index1 + 1;\r
301 }\r
302\r
303 printf ("\n");\r
304\r
305 //\r
306 // Hand off to PEI Core\r
307 //\r
308 SecLoadFromCore ((UINTN) InitialStackMemory, (UINTN) InitialStackMemorySize, (UINTN) gFdInfo[0].Address, PeiCoreFile);\r
309\r
310 //\r
311 // If we get here, then the PEI Core returned. This is an error as PEI should\r
312 // always hand off to DXE.\r
313 //\r
314 printf ("ERROR : PEI Core returned\n");\r
315 exit (1);\r
316}\r
317\r
318EFI_STATUS\r
319WinNtOpenFile (\r
320 IN CHAR16 *FileName,\r
321 IN UINT32 MapSize,\r
322 IN DWORD CreationDisposition,\r
323 IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,\r
324 OUT UINT64 *Length\r
325 )\r
326/*++\r
327\r
328Routine Description:\r
329 Opens and memory maps a file using WinNt services. If BaseAddress is non zero\r
330 the process will try and allocate the memory starting at BaseAddress.\r
331\r
332Arguments:\r
333 FileName - The name of the file to open and map\r
334 MapSize - The amount of the file to map in bytes\r
335 CreationDisposition - The flags to pass to CreateFile(). Use to create new files for\r
336 memory emulation, and exiting files for firmware volume emulation\r
337 BaseAddress - The base address of the mapped file in the user address space.\r
338 If passed in as NULL the a new memory region is used.\r
339 If passed in as non NULL the request memory region is used for\r
340 the mapping of the file into the process space.\r
341 Length - The size of the mapped region in bytes\r
342\r
343Returns:\r
344 EFI_SUCCESS - The file was opened and mapped.\r
345 EFI_NOT_FOUND - FileName was not found in the current directory\r
346 EFI_DEVICE_ERROR - An error occured attempting to map the opened file\r
347\r
348--*/\r
349{\r
350 HANDLE NtFileHandle;\r
351 HANDLE NtMapHandle;\r
352 VOID *VirtualAddress;\r
353 UINTN FileSize;\r
354\r
355 //\r
356 // Use Win API to open/create a file\r
357 //\r
358 NtFileHandle = CreateFile (\r
359 FileName,\r
360 GENERIC_READ | GENERIC_WRITE,\r
361 FILE_SHARE_READ,\r
362 NULL,\r
363 CreationDisposition,\r
364 FILE_ATTRIBUTE_NORMAL,\r
365 NULL\r
366 );\r
367 if (NtFileHandle == INVALID_HANDLE_VALUE) {\r
368 return EFI_NOT_FOUND;\r
369 }\r
370 //\r
371 // Map the open file into a memory range\r
372 //\r
373 NtMapHandle = CreateFileMapping (\r
374 NtFileHandle,\r
375 NULL,\r
376 PAGE_READWRITE,\r
377 0,\r
378 MapSize,\r
379 NULL\r
380 );\r
381 if (NtMapHandle == NULL) {\r
382 return EFI_DEVICE_ERROR;\r
383 }\r
384 //\r
385 // Get the virtual address (address in the emulator) of the mapped file\r
386 //\r
387 VirtualAddress = MapViewOfFileEx (\r
388 NtMapHandle,\r
389 FILE_MAP_ALL_ACCESS,\r
390 0,\r
391 0,\r
392 MapSize,\r
393 (LPVOID) (UINTN) *BaseAddress\r
394 );\r
395 if (VirtualAddress == NULL) {\r
396 return EFI_DEVICE_ERROR;\r
397 }\r
398\r
399 if (MapSize == 0) {\r
400 //\r
401 // Seek to the end of the file to figure out the true file size.\r
402 //\r
403 FileSize = SetFilePointer (\r
404 NtFileHandle,\r
405 0,\r
406 NULL,\r
407 FILE_END\r
408 );\r
409 if (FileSize == -1) {\r
410 return EFI_DEVICE_ERROR;\r
411 }\r
412\r
413 *Length = (UINT64) FileSize;\r
414 } else {\r
415 *Length = (UINT64) MapSize;\r
416 }\r
417\r
418 *BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) VirtualAddress;\r
419\r
420 return EFI_SUCCESS;\r
421}\r
422\r
423#define BYTES_PER_RECORD 512\r
424\r
35b309d6 425/**\r
426 Extracts ASSERT() information from a status code structure.\r
427\r
428 Converts the status code specified by CodeType, Value, and Data to the ASSERT()\r
429 arguments specified by Filename, Description, and LineNumber. If CodeType is \r
430 an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and \r
431 Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract \r
432 Filename, Description, and LineNumber from the optional data area of the \r
433 status code buffer specified by Data. The optional data area of Data contains \r
434 a Null-terminated ASCII string for the FileName, followed by a Null-terminated \r
435 ASCII string for the Description, followed by a 32-bit LineNumber. If the \r
436 ASSERT() information could be extracted from Data, then return TRUE. \r
437 Otherwise, FALSE is returned. \r
438\r
439 If Data is NULL, then ASSERT().\r
440 If Filename is NULL, then ASSERT().\r
441 If Description is NULL, then ASSERT().\r
442 If LineNumber is NULL, then ASSERT().\r
443\r
444 @param CodeType The type of status code being converted.\r
445 @param Value The status code value being converted.\r
446 @param Data Pointer to status code data buffer. \r
447 @param Filename Pointer to the source file name that generated the ASSERT().\r
448 @param Description Pointer to the description of the ASSERT().\r
449 @param LineNumber Pointer to source line number that generated the ASSERT().\r
450\r
451 @retval TRUE The status code specified by CodeType, Value, and Data was \r
452 converted ASSERT() arguments specified by Filename, Description, \r
453 and LineNumber.\r
454 @retval FALSE The status code specified by CodeType, Value, and Data could \r
455 not be converted to ASSERT() arguments.\r
456\r
457**/\r
458STATIC\r
459BOOLEAN\r
460ReportStatusCodeExtractAssertInfo (\r
461 IN EFI_STATUS_CODE_TYPE CodeType,\r
462 IN EFI_STATUS_CODE_VALUE Value, \r
463 IN CONST EFI_STATUS_CODE_DATA *Data, \r
464 OUT CHAR8 **Filename,\r
465 OUT CHAR8 **Description,\r
466 OUT UINT32 *LineNumber\r
467 )\r
468{\r
469 EFI_DEBUG_ASSERT_DATA *AssertData;\r
470\r
471 ASSERT (Data != NULL);\r
472 ASSERT (Filename != NULL);\r
473 ASSERT (Description != NULL);\r
474 ASSERT (LineNumber != NULL);\r
475\r
476 if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) && \r
477 ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&\r
478 ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {\r
479 AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);\r
480 *Filename = (CHAR8 *)(AssertData + 1);\r
481 *Description = *Filename + AsciiStrLen (*Filename) + 1;\r
482 *LineNumber = AssertData->LineNumber;\r
483 return TRUE;\r
484 }\r
485 return FALSE;\r
486}\r
487\r
878ddf1f 488EFI_STATUS\r
489EFIAPI\r
490SecPeiReportStatusCode (\r
491 IN EFI_PEI_SERVICES **PeiServices,\r
492 IN EFI_STATUS_CODE_TYPE CodeType,\r
493 IN EFI_STATUS_CODE_VALUE Value,\r
494 IN UINT32 Instance,\r
495 IN EFI_GUID * CallerId,\r
496 IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r
497 )\r
498/*++\r
499\r
500Routine Description:\r
501\r
502 This routine produces the ReportStatusCode PEI service. It's passed\r
503 up to the PEI Core via a PPI. T\r
504\r
505 This code currently uses the NT clib printf. This does not work the same way\r
506 as the EFI Print (), as %t, %g, %s as Unicode are not supported.\r
507\r
508Arguments:\r
509 (see EFI_PEI_REPORT_STATUS_CODE)\r
510\r
511Returns:\r
512 EFI_SUCCESS - Always return success\r
513\r
514--*/\r
515// TODO: PeiServices - add argument and description to function comment\r
516// TODO: CodeType - add argument and description to function comment\r
517// TODO: Value - add argument and description to function comment\r
518// TODO: Instance - add argument and description to function comment\r
519// TODO: CallerId - add argument and description to function comment\r
520// TODO: Data - add argument and description to function comment\r
521{\r
522 CHAR8 *Format;\r
523 EFI_DEBUG_INFO *DebugInfo;\r
524 VA_LIST Marker;\r
525 CHAR8 PrintBuffer[BYTES_PER_RECORD * 2];\r
526 CHAR8 *Filename;\r
527 CHAR8 *Description;\r
528 UINT32 LineNumber;\r
529\r
530 if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {\r
531 //\r
532 // This supports DEBUG () marcos\r
533 // Data format\r
534 // EFI_STATUS_CODE_DATA\r
535 // EFI_DEBUG_INFO\r
536 //\r
537 // The first 12 * UINT64 bytes of the string are really an\r
538 // arguement stack to support varargs on the Format string.\r
539 //\r
21802505 540 if (Data != NULL) {\r
541 DebugInfo = (EFI_DEBUG_INFO *) (Data + 1);\r
542 Marker = (VA_LIST) (DebugInfo + 1);\r
543 Format = (CHAR8 *) (((UINT64 *) Marker) + 12);\r
878ddf1f 544\r
21802505 545 AsciiVSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker);\r
546 printf (PrintBuffer);\r
547 } else {\r
548 printf ("DEBUG <null>\n");\r
549 }\r
878ddf1f 550 }\r
551\r
552 if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&\r
553 ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED)\r
554 ) {\r
21802505 555 if (Data != NULL && ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {\r
878ddf1f 556 //\r
557 // Support ASSERT () macro\r
558 //\r
559 printf ("ASSERT %s(%d): %s\n", Filename, LineNumber, Description);\r
21802505 560 } else {\r
561 printf ("ASSERT <null>\n");\r
878ddf1f 562 }\r
21802505 563 CpuBreakpoint ();\r
878ddf1f 564 }\r
565\r
566 return EFI_SUCCESS;\r
567}\r
568\r
569\r
570VOID\r
571SecLoadFromCore (\r
572 IN UINTN LargestRegion,\r
573 IN UINTN LargestRegionSize,\r
574 IN UINTN BootFirmwareVolumeBase,\r
575 IN VOID *PeiCorePe32File\r
576 )\r
577/*++\r
578\r
579Routine Description:\r
580 This is the service to load the PEI Core from the Firmware Volume\r
581\r
582Arguments:\r
583 LargestRegion - Memory to use for PEI.\r
584 LargestRegionSize - Size of Memory to use for PEI\r
585 BootFirmwareVolumeBase - Start of the Boot FV\r
586 PeiCorePe32File - PEI Core PE32\r
587\r
588Returns:\r
589 Success means control is transfered and thus we should never return\r
590\r
591--*/\r
592{\r
593 EFI_STATUS Status;\r
594 EFI_PHYSICAL_ADDRESS TopOfMemory;\r
595 VOID *TopOfStack;\r
596 UINT64 PeiCoreSize;\r
597 EFI_PHYSICAL_ADDRESS PeiCoreEntryPoint;\r
598 EFI_PHYSICAL_ADDRESS PeiImageAddress;\r
599 EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup;\r
600\r
601 //\r
602 // Compute Top Of Memory for Stack and PEI Core Allocations\r
603 //\r
604 TopOfMemory = LargestRegion + ((LargestRegionSize) & (~15));\r
605\r
606 //\r
607 // Allocate 128KB for the Stack\r
608 //\r
609 TopOfStack = (VOID *) (UINTN) (TopOfMemory - sizeof (EFI_PEI_STARTUP_DESCRIPTOR));\r
610 TopOfMemory = TopOfMemory - STACK_SIZE;\r
611\r
612 //\r
613 // Patch value in dispatch table values\r
614 //\r
615 gPrivateDispatchTable[0].Ppi = gPeiEfiPeiPeCoffLoader;\r
616\r
617 //\r
618 // Bind this information into the SEC hand-off state\r
619 //\r
620 PeiStartup = (EFI_PEI_STARTUP_DESCRIPTOR *) (UINTN) TopOfStack;\r
621 PeiStartup->DispatchTable = (EFI_PEI_PPI_DESCRIPTOR *) &gPrivateDispatchTable;\r
622 PeiStartup->SizeOfCacheAsRam = STACK_SIZE;\r
623 PeiStartup->BootFirmwareVolume = BootFirmwareVolumeBase;\r
624\r
625 //\r
626 // Load the PEI Core from a Firmware Volume\r
627 //\r
628 Status = SecWinNtPeiLoadFile (\r
629 PeiCorePe32File,\r
630 &PeiImageAddress,\r
631 &PeiCoreSize,\r
632 &PeiCoreEntryPoint\r
633 );\r
634 if (EFI_ERROR (Status)) {\r
635 return ;\r
636 }\r
637 //\r
638 // Transfer control to the PEI Core\r
639 //\r
640 SwitchStack (\r
641 (SWITCH_STACK_ENTRY_POINT) (UINTN) PeiCoreEntryPoint,\r
642 PeiStartup,\r
643 NULL,\r
644 TopOfStack\r
645 );\r
646 //\r
647 // If we get here, then the PEI Core returned. This is an error\r
648 //\r
649 return ;\r
650}\r
651\r
652EFI_STATUS\r
653EFIAPI\r
654SecWinNtPeiAutoScan (\r
655 IN UINTN Index,\r
656 OUT EFI_PHYSICAL_ADDRESS *MemoryBase,\r
657 OUT UINT64 *MemorySize\r
658 )\r
659/*++\r
660\r
661Routine Description:\r
662 This service is called from Index == 0 until it returns EFI_UNSUPPORTED.\r
663 It allows discontiguous memory regions to be supported by the emulator.\r
664 It uses gSystemMemory[] and gSystemMemoryCount that were created by\r
665 parsing the Windows environment variable EFI_MEMORY_SIZE.\r
666 The size comes from the varaible and the address comes from the call to\r
667 WinNtOpenFile.\r
668\r
669Arguments:\r
670 Index - Which memory region to use\r
671 MemoryBase - Return Base address of memory region\r
672 MemorySize - Return size in bytes of the memory region\r
673\r
674Returns:\r
675 EFI_SUCCESS - If memory region was mapped\r
676 EFI_UNSUPPORTED - If Index is not supported\r
677\r
678--*/\r
679{\r
680 EFI_STATUS Status;\r
681\r
682 if (Index >= gSystemMemoryCount) {\r
683 return EFI_UNSUPPORTED;\r
684 }\r
685\r
686 *MemoryBase = 0;\r
687 Status = WinNtOpenFile (\r
688 gSystemMemory[Index].FileName,\r
689 (UINT32) gSystemMemory[Index].Size,\r
690 OPEN_ALWAYS,\r
691 MemoryBase,\r
692 MemorySize\r
693 );\r
694\r
695 gSystemMemory[Index].Memory = *MemoryBase;\r
696\r
697 return Status;\r
698}\r
699\r
700VOID *\r
701EFIAPI\r
702SecWinNtWinNtThunkAddress (\r
703 VOID\r
704 )\r
705/*++\r
706\r
707Routine Description:\r
708 Since the SEC is the only Windows program in stack it must export\r
709 an interface to do Win API calls. That's what the WinNtThunk address\r
710 is for. gWinNt is initailized in WinNtThunk.c.\r
711\r
712Arguments:\r
713 InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);\r
714 InterfaceBase - Address of the gWinNt global\r
715\r
716Returns:\r
717 EFI_SUCCESS - Data returned\r
718\r
719--*/\r
720{\r
721 return gWinNt;\r
722}\r
723\r
724\r
725EFI_STATUS\r
726EFIAPI\r
727SecWinNtPeiLoadFile (\r
728 IN VOID *Pe32Data,\r
729 IN EFI_PHYSICAL_ADDRESS *ImageAddress,\r
730 IN UINT64 *ImageSize,\r
731 IN EFI_PHYSICAL_ADDRESS *EntryPoint\r
732 )\r
733/*++\r
734\r
735Routine Description:\r
736 Loads and relocates a PE/COFF image into memory.\r
737\r
738Arguments:\r
739 Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated\r
740 ImageAddress - The base address of the relocated PE/COFF image\r
741 ImageSize - The size of the relocated PE/COFF image\r
742 EntryPoint - The entry point of the relocated PE/COFF image\r
743\r
744Returns:\r
745 EFI_SUCCESS - The file was loaded and relocated\r
746 EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
747\r
748--*/\r
749{\r
750 EFI_STATUS Status;\r
751 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
752\r
753 ZeroMem (&ImageContext, sizeof (ImageContext));\r
754 ImageContext.Handle = Pe32Data;\r
755\r
756 ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) SecImageRead;\r
757\r
758 Status = gPeiEfiPeiPeCoffLoader->GetImageInfo (gPeiEfiPeiPeCoffLoader, &ImageContext);\r
759 if (EFI_ERROR (Status)) {\r
760 return Status;\r
761 }\r
762 //\r
763 // Allocate space in NT (not emulator) memory. Extra space is for alignment\r
764 //\r
765 ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) malloc ((UINTN) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)));\r
766 if (ImageContext.ImageAddress == 0) {\r
767 return EFI_OUT_OF_RESOURCES;\r
768 }\r
769 //\r
770 // Align buffer on section boundry\r
771 //\r
772 ImageContext.ImageAddress += ImageContext.SectionAlignment;\r
773 ImageContext.ImageAddress &= ~(ImageContext.SectionAlignment - 1);\r
774\r
775 Status = gPeiEfiPeiPeCoffLoader->LoadImage (gPeiEfiPeiPeCoffLoader, &ImageContext);\r
776 if (EFI_ERROR (Status)) {\r
777 return Status;\r
778 }\r
779\r
780 Status = gPeiEfiPeiPeCoffLoader->RelocateImage (gPeiEfiPeiPeCoffLoader, &ImageContext);\r
781 if (EFI_ERROR (Status)) {\r
782 return Status;\r
783 }\r
784\r
785 //\r
786 // BugBug: Flush Instruction Cache Here when CPU Lib is ready\r
787 //\r
788\r
789 *ImageAddress = ImageContext.ImageAddress;\r
790 *ImageSize = ImageContext.ImageSize;\r
791 *EntryPoint = ImageContext.EntryPoint;\r
792\r
793 return EFI_SUCCESS;\r
794}\r
795\r
796EFI_STATUS\r
797EFIAPI\r
798SecWinNtFdAddress (\r
799 IN UINTN Index,\r
800 IN OUT EFI_PHYSICAL_ADDRESS *FdBase,\r
801 IN OUT UINT64 *FdSize\r
802 )\r
803/*++\r
804\r
805Routine Description:\r
806 Return the FD Size and base address. Since the FD is loaded from a\r
807 file into Windows memory only the SEC will know it's address.\r
808\r
809Arguments:\r
810 Index - Which FD, starts at zero.\r
811 FdSize - Size of the FD in bytes\r
812 FdBase - Start address of the FD. Assume it points to an FV Header\r
813\r
814Returns:\r
815 EFI_SUCCESS - Return the Base address and size of the FV\r
816 EFI_UNSUPPORTED - Index does nto map to an FD in the system\r
817\r
818--*/\r
819{\r
820 if (Index >= gFdInfoCount) {\r
821 return EFI_UNSUPPORTED;\r
822 }\r
823\r
824 *FdBase = gFdInfo[Index].Address;\r
825 *FdSize = gFdInfo[Index].Size;\r
826\r
827 if (*FdBase == 0 && *FdSize == 0) {\r
828 return EFI_UNSUPPORTED;\r
829 }\r
830\r
831 return EFI_SUCCESS;\r
832}\r
833\r
834EFI_STATUS\r
835EFIAPI\r
836SecImageRead (\r
837 IN VOID *FileHandle,\r
838 IN UINTN FileOffset,\r
839 IN OUT UINTN *ReadSize,\r
840 OUT VOID *Buffer\r
841 )\r
842/*++\r
843\r
844Routine Description:\r
845 Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file\r
846\r
847Arguments:\r
848 FileHandle - The handle to the PE/COFF file\r
849 FileOffset - The offset, in bytes, into the file to read\r
850 ReadSize - The number of bytes to read from the file starting at FileOffset\r
851 Buffer - A pointer to the buffer to read the data into.\r
852\r
853Returns:\r
854 EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset\r
855\r
856--*/\r
857{\r
858 CHAR8 *Destination8;\r
859 CHAR8 *Source8;\r
860 UINTN Length;\r
861\r
862 Destination8 = Buffer;\r
863 Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
864 Length = *ReadSize;\r
865 while (Length--) {\r
866 *(Destination8++) = *(Source8++);\r
867 }\r
868\r
869 return EFI_SUCCESS;\r
870}\r
871\r
872CHAR16 *\r
873AsciiToUnicode (\r
874 IN CHAR8 *Ascii,\r
875 IN UINTN *StrLen OPTIONAL\r
876 )\r
877/*++\r
878\r
879Routine Description:\r
880 Convert the passed in Ascii string to Unicode.\r
881 Optionally return the length of the strings.\r
882\r
883Arguments:\r
884 Ascii - Ascii string to convert\r
885 StrLen - Length of string\r
886\r
887Returns:\r
888 Pointer to malloc'ed Unicode version of Ascii\r
889\r
890--*/\r
891{\r
892 UINTN Index;\r
893 CHAR16 *Unicode;\r
894\r
895 //\r
896 // Allocate a buffer for unicode string\r
897 //\r
898 for (Index = 0; Ascii[Index] != '\0'; Index++)\r
899 ;\r
900 Unicode = malloc ((Index + 1) * sizeof (CHAR16));\r
901 if (Unicode == NULL) {\r
902 return NULL;\r
903 }\r
904\r
905 for (Index = 0; Ascii[Index] != '\0'; Index++) {\r
906 Unicode[Index] = (CHAR16) Ascii[Index];\r
907 }\r
908\r
909 Unicode[Index] = '\0';\r
910\r
911 if (StrLen != NULL) {\r
912 *StrLen = Index;\r
913 }\r
914\r
915 return Unicode;\r
916}\r
917\r
918UINTN\r
919CountSeperatorsInString (\r
920 IN const CHAR16 *String,\r
921 IN CHAR16 Seperator\r
922 )\r
923/*++\r
924\r
925Routine Description:\r
926 Count the number of seperators in String\r
927\r
928Arguments:\r
929 String - String to process\r
930 Seperator - Item to count\r
931\r
932Returns:\r
933 Number of Seperator in String\r
934\r
935--*/\r
936{\r
937 UINTN Count;\r
938\r
939 for (Count = 0; *String != '\0'; String++) {\r
940 if (*String == Seperator) {\r
941 Count++;\r
942 }\r
943 }\r
944\r
945 return Count;\r
946}\r
947\r
948\r
949EFI_STATUS\r
950AddModHandle (\r
951 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,\r
952 IN VOID *ModHandle\r
953 )\r
954/*++\r
955\r
956Routine Description:\r
957 Store the ModHandle in an array indexed by the Pdb File name.\r
958 The ModHandle is needed to unload the image. \r
959\r
960Arguments:\r
961 ImageContext - Input data returned from PE Laoder Library. Used to find the \r
962 .PDB file name of the PE Image.\r
963 ModHandle - Returned from LoadLibraryEx() and stored for call to \r
964 FreeLibrary().\r
965\r
966Returns:\r
967 EFI_SUCCESS - ModHandle was stored. \r
968\r
969--*/\r
970{\r
971 UINTN Index;\r
972 PDB_NAME_TO_MOD_HANDLE *Array;\r
973 UINTN PreviousSize;\r
974\r
975\r
976 Array = mPdbNameModHandleArray;\r
977 for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {\r
978 if (Array->PdbPointer == NULL) {\r
979 //\r
980 // Make a copy of the stirng and store the ModHandle\r
981 //\r
982 Array->PdbPointer = malloc (strlen (ImageContext->PdbPointer) + 1);\r
983 ASSERT (Array->PdbPointer != NULL);\r
984\r
985 strcpy (Array->PdbPointer, ImageContext->PdbPointer);\r
986 Array->ModHandle = ModHandle;\r
987 return EFI_SUCCESS;\r
988 }\r
989 }\r
990 \r
991 //\r
992 // No free space in mPdbNameModHandleArray so grow it by \r
993 // MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE entires. realloc will\r
994 // copy the old values to the new locaiton. But it does\r
995 // not zero the new memory area.\r
996 //\r
997 PreviousSize = mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE);\r
998 mPdbNameModHandleArraySize += MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE;\r
999\r
1000 mPdbNameModHandleArray = realloc (mPdbNameModHandleArray, mPdbNameModHandleArraySize * sizeof (PDB_NAME_TO_MOD_HANDLE));\r
1001 if (mPdbNameModHandleArray == NULL) {\r
1002 ASSERT (FALSE);\r
1003 return EFI_OUT_OF_RESOURCES;\r
1004 }\r
1005 \r
1006 memset (mPdbNameModHandleArray + PreviousSize, 0, MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE * sizeof (PDB_NAME_TO_MOD_HANDLE));\r
1007 \r
1008 return AddModHandle (ImageContext, ModHandle);\r
1009}\r
1010\r
1011\r
1012VOID *\r
1013RemoveModeHandle (\r
1014 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
1015 )\r
1016/*++\r
1017\r
1018Routine Description:\r
1019 Return the ModHandle and delete the entry in the array.\r
1020\r
1021Arguments:\r
1022 ImageContext - Input data returned from PE Laoder Library. Used to find the \r
1023 .PDB file name of the PE Image.\r
1024\r
1025Returns:\r
1026 ModHandle - ModHandle assoicated with ImageContext is returned\r
1027 NULL - No ModHandle associated with ImageContext\r
1028\r
1029--*/\r
1030{\r
1031 UINTN Index;\r
1032 PDB_NAME_TO_MOD_HANDLE *Array;\r
1033\r
1034 if (ImageContext->PdbPointer == NULL) {\r
1035 //\r
1036 // If no PDB pointer there is no ModHandle so return NULL\r
1037 //\r
1038 return NULL;\r
1039 }\r
1040\r
1041 Array = mPdbNameModHandleArray;\r
1042 for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {\r
1043 if ((Array->PdbPointer != NULL) && (strcmp(Array->PdbPointer, ImageContext->PdbPointer) == 0)) {\r
1044 //\r
1045 // If you find a match return it and delete the entry\r
1046 //\r
1047 free (Array->PdbPointer);\r
1048 Array->PdbPointer = NULL;\r
1049 return Array->ModHandle;\r
1050 }\r
1051 }\r
1052\r
1053 return NULL;\r
1054}\r
1055\r
1056\r
1057\r
1058EFI_STATUS\r
1059EFIAPI\r
1060SecNt32PeCoffGetImageInfo (\r
1061 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
1062 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
1063 )\r
1064{\r
1065 EFI_STATUS Status;\r
1066\r
1067 Status = PeCoffLoaderGetImageInfo (ImageContext);\r
1068 if (EFI_ERROR (Status)) {\r
1069 return Status;\r
1070 }\r
1071\r
1072 switch (ImageContext->ImageType) {\r
1073\r
1074 case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:\r
1075 ImageContext->ImageCodeMemoryType = EfiLoaderCode;\r
1076 ImageContext->ImageDataMemoryType = EfiLoaderData;\r
1077 break;\r
1078\r
1079 case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:\r
1080 ImageContext->ImageCodeMemoryType = EfiBootServicesCode;\r
1081 ImageContext->ImageDataMemoryType = EfiBootServicesData;\r
1082 break;\r
1083\r
1084 case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
1085 case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:\r
1086 ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode;\r
1087 ImageContext->ImageDataMemoryType = EfiRuntimeServicesData;\r
1088 break;\r
1089\r
1090 default:\r
1091 ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
1092 return RETURN_UNSUPPORTED;\r
1093 }\r
1094\r
1095 return Status;\r
1096}\r
1097\r
1098EFI_STATUS\r
1099EFIAPI\r
1100SecNt32PeCoffLoadImage (\r
1101 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
1102 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
1103 )\r
1104{\r
1105 EFI_STATUS Status;\r
1106\r
1107 Status = PeCoffLoaderLoadImage (ImageContext);\r
1108 return Status;\r
1109}\r
1110\r
1111EFI_STATUS\r
1112EFIAPI\r
1113SecNt32PeCoffRelocateImage (\r
1114 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
1115 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
1116 )\r
1117{\r
1118 EFI_STATUS Status;\r
1119 VOID *DllEntryPoint;\r
1120 CHAR16 *DllFileName;\r
1121 HMODULE Library;\r
1122 UINTN Index;\r
1123\r
1124\r
1125 Status = PeCoffLoaderRelocateImage (ImageContext);\r
1126 if (EFI_ERROR (Status)) {\r
1127 //\r
1128 // We could not relocated the image in memory properly\r
1129 //\r
1130 return Status;\r
1131 }\r
1132\r
1133 //\r
1134 // If we load our own PE COFF images the Windows debugger can not source\r
1135 // level debug our code. If a valid PDB pointer exists usw it to load\r
1136 // the *.dll file as a library using Windows* APIs. This allows \r
1137 // source level debug. The image is still loaded and reloaced\r
1138 // in the Framework memory space like on a real system (by the code above),\r
1139 // but the entry point points into the DLL loaded by the code bellow. \r
1140 //\r
1141\r
1142 DllEntryPoint = NULL;\r
1143\r
1144 //\r
1145 // Load the DLL if it's not an EBC image.\r
1146 //\r
1147 if ((ImageContext->PdbPointer != NULL) &&\r
1148 (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) {\r
1149 //\r
1150 // Convert filename from ASCII to Unicode\r
1151 //\r
1152 DllFileName = AsciiToUnicode (ImageContext->PdbPointer, &Index);\r
1153\r
1154 //\r
1155 // Check that we have a valid filename\r
1156 //\r
1157 if (Index < 5 || DllFileName[Index - 4] != '.') {\r
1158 free (DllFileName);\r
1159\r
1160 //\r
1161 // Never return an error if PeCoffLoaderRelocateImage() succeeded.\r
1162 // The image will run, but we just can't source level debug. If we\r
1163 // return an error the image will not run.\r
1164 //\r
1165 return EFI_SUCCESS;\r
1166 }\r
1167 //\r
1168 // Replace .PDB with .DLL on the filename\r
1169 //\r
1170 DllFileName[Index - 3] = 'D';\r
1171 DllFileName[Index - 2] = 'L';\r
1172 DllFileName[Index - 1] = 'L';\r
1173\r
1174 //\r
1175 // Load the .DLL file into the user process's address space for source \r
1176 // level debug\r
1177 //\r
1178 Library = LoadLibraryEx (DllFileName, NULL, DONT_RESOLVE_DLL_REFERENCES);\r
1179 if (Library != NULL) {\r
1180 //\r
1181 // InitializeDriver is the entry point we put in all our EFI DLL's. The\r
1182 // DONT_RESOLVE_DLL_REFERENCES argument to LoadLIbraryEx() supresses the \r
1183 // normal DLL entry point of DllMain, and prevents other modules that are\r
1184 // referenced in side the DllFileName from being loaded. There is no error \r
1185 // checking as the we can point to the PE32 image loaded by Tiano. This \r
1186 // step is only needed for source level debuging\r
1187 //\r
1188 DllEntryPoint = (VOID *) (UINTN) GetProcAddress (Library, "InitializeDriver");\r
1189\r
1190 }\r
1191\r
1192 if ((Library != NULL) && (DllEntryPoint != NULL)) {\r
1193 AddModHandle (ImageContext, Library);\r
1194 ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;\r
1195 wprintf (L"LoadLibraryEx (%s,\n NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName);\r
1196 } else {\r
1197 wprintf (L"WARNING: No source level debug %s. \n", DllFileName);\r
1198 }\r
1199\r
1200 free (DllFileName);\r
1201 }\r
1202\r
1203 //\r
1204 // Never return an error if PeCoffLoaderRelocateImage() succeeded.\r
1205 // The image will run, but we just can't source level debug. If we\r
1206 // return an error the image will not run.\r
1207 //\r
1208 return EFI_SUCCESS;\r
1209}\r
1210\r
1211\r
1212EFI_STATUS\r
1213EFIAPI\r
1214SecNt32PeCoffUnloadimage (\r
1215 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,\r
1216 IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
1217 )\r
1218{\r
1219 VOID *ModHandle;\r
1220\r
1221 ModHandle = RemoveModeHandle (ImageContext);\r
1222 if (ModHandle != NULL) {\r
1223 FreeLibrary (ModHandle);\r
1224 }\r
1225 return EFI_SUCCESS;\r
1226}\r
1227\r
1228VOID\r
1229_ModuleEntryPoint (\r
1230 VOID\r
1231 )\r
1232{\r
1233}\r
f55a0ac9 1234\r
1235#pragma warning(default : 4996)\r