summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Core/Pei
diff options
context:
space:
mode:
authorajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-26 15:23:35 +0000
committerajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-26 15:23:35 +0000
commit2ce311322c72857f73138c45358e722607a1e80c (patch)
treefc382467b7924a9fa6c2d80132beae70207f4b0e /EdkModulePkg/Core/Pei
parentdca84bbd419fdeaa8cf26ad4ab95e6f37588ea0b (diff)
downloadedk2-2ce311322c72857f73138c45358e722607a1e80c.zip
edk2-2ce311322c72857f73138c45358e722607a1e80c.tar.gz
edk2-2ce311322c72857f73138c45358e722607a1e80c.tar.bz2
Removed cross references from PciCf8Lib and PciExpressLib class to PciLib class.
Added PeCoffLoaderGetMachineType to the PeCoffGetEntryPointLibrary Class. Document to be updated. Added the PeCoffLoaderImageReadFromMemory() and PeCoffLoaderRelocateImageForRuntime () to the PcCoffLib. Updated EfiImage.h and removed EFI_IMAGE_OPTIONAL_HEADER and EFI_IMAGE_NT_HEADERS as they were replaced with checking the MachineType. PeCoffLib – Added checks for MachineType so the PeCoff lib can load any PE32 or PE32+ image. The relocations are still limited to IA32, X64, IPF, and EBC. I also added a re-relocator function to remove PeLoader Code from Runtime Lib. Even though there is only one instance of the re-relocator I wanted to get all the PeCoff loader code together. Replaced DEBUG_CODE() macro with DEBUG_CODE_START() and DEBUG_CODE_END() so you can debug through the DEBUG_CODE() macros. Also removed PE/COFF code and replaced with library usage. I also updated the IO Instrinsic lib to use _ReadWriteBarrior() to help with sync problems git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1103 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Core/Pei')
-rw-r--r--EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c12
-rw-r--r--EdkModulePkg/Core/Pei/Hob/Hob.c4
-rw-r--r--EdkModulePkg/Core/Pei/Image/Image.c119
-rw-r--r--EdkModulePkg/Core/Pei/Memory/MemoryServices.c8
-rw-r--r--EdkModulePkg/Core/Pei/PeiMain.msa15
-rw-r--r--EdkModulePkg/Core/Pei/PeiMain/PeiMain.c6
6 files changed, 45 insertions, 119 deletions
diff --git a/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index 1eb5a4a..6d32368 100644
--- a/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/EdkModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -105,7 +105,7 @@ Returns:
//
if (Status == EFI_SUCCESS) {
- DEBUG_CODE (
+ DEBUG_CODE_BEGIN ();
//
// Fill list of found Peims for later list of those not installed
@@ -116,7 +116,7 @@ Returns:
sizeof (EFI_GUID)
);
- );
+ DEBUG_CODE_END ();
if (!Dispatched (
DispatchData->CurrentPeim,
@@ -320,7 +320,7 @@ Returns:
DispatchData->CurrentFvAddress = DefaultFvAddress;
}
- DEBUG_CODE (
+ DEBUG_CODE_BEGIN ();
//
// Debug data for uninstalled Peim list
//
@@ -345,10 +345,10 @@ Returns:
DebugFoundPeimPoint++;
DebugNotDispatchedBitmap >>= 1;
}
+
+ DEBUG_CODE_END ();
- );
-
- return EFI_NOT_FOUND;
+ return EFI_NOT_FOUND;
}
VOID
diff --git a/EdkModulePkg/Core/Pei/Hob/Hob.c b/EdkModulePkg/Core/Pei/Hob/Hob.c
index 1eadf94..259d44b 100644
--- a/EdkModulePkg/Core/Pei/Hob/Hob.c
+++ b/EdkModulePkg/Core/Pei/Hob/Hob.c
@@ -53,11 +53,11 @@ Returns:
// Only check this parameter in debug mode
//
- DEBUG_CODE (
+ DEBUG_CODE_BEGIN ();
if (HobList == NULL) {
return EFI_INVALID_PARAMETER;
}
- );
+ DEBUG_CODE_END ();
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
diff --git a/EdkModulePkg/Core/Pei/Image/Image.c b/EdkModulePkg/Core/Pei/Image/Image.c
index 5edc847..9df12f8 100644
--- a/EdkModulePkg/Core/Pei/Image/Image.c
+++ b/EdkModulePkg/Core/Pei/Image/Image.c
@@ -21,6 +21,8 @@ Abstract:
#include <PeiMain.h>
+
+
EFI_STATUS
PeiLoadImage (
IN EFI_PEI_SERVICES **PeiServices,
@@ -130,106 +132,35 @@ Returns:
// Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi
//
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%08x EntryPoint=0x%08x ", Pe32Data, *EntryPoint));
- DEBUG_CODE (
- EFI_IMAGE_DATA_DIRECTORY * DirectoryEntry;
- EFI_IMAGE_DEBUG_DIRECTORY_ENTRY * DebugEntry;
- UINTN DirCount;
- UINTN Index;
- UINTN Index1;
- BOOLEAN FileNameFound;
- CHAR8 *AsciiString;
- CHAR8 AsciiBuffer[512];
- VOID *CodeViewEntryPointer;
- INTN TEImageAdjust;
- EFI_IMAGE_DOS_HEADER *DosHeader;
- EFI_IMAGE_NT_HEADERS *PeHeader;
+ DEBUG_CODE_BEGIN ();
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+ UINTN Index;
+ CHAR8 *PdbStr;
+ CHAR8 AsciiBuffer[512];
- //
- // Pe32Data is NULL when load TE image
- //
- PeHeader = NULL;
- if (TEImageHeader == NULL) {
- DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
- if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
- //
- // DOS image header is present, so read the PE header after the DOS image header
- //
- PeHeader = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));
- } else {
- //
- // DOS image header is not present, so PE header is at the image base
- //
- PeHeader = (EFI_IMAGE_NT_HEADERS *) Pe32Data;
- }
- }
- //
- // Find the codeview info in the image and display the file name
- // being loaded.
- //
- // Per the PE/COFF spec, you can't assume that a given data directory
- // is present in the image. You have to check the NumberOfRvaAndSizes in
- // the optional header to verify a desired directory entry is there.
- //
- DebugEntry = NULL;
- DirectoryEntry = NULL;
- TEImageAdjust = 0;
- if (TEImageHeader == NULL) {
- if (PeHeader->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHeader->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) ImageAddress + DirectoryEntry->VirtualAddress);
- }
- } else {
- if (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
- DirectoryEntry = &TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
- TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize;
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) TEImageHeader +
- TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
- TEImageAdjust);
- }
- }
+ ZeroMem (&ImageContext, sizeof (ImageContext));
+ ImageContext.Handle = Pe32Data;
+ ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
- if (DebugEntry != NULL && DirectoryEntry != NULL) {
- for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {
- if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
- if (DebugEntry->SizeOfData > 0) {
- CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageAddress + (UINTN)TEImageAdjust);
- switch (* (UINT32 *) CodeViewEntryPointer) {
- case CODEVIEW_SIGNATURE_NB10:
- AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
- break;
-
- case CODEVIEW_SIGNATURE_RSDS:
- AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
- break;
-
- default:
- AsciiString = NULL;
- break;
- }
- if (AsciiString != NULL) {
- FileNameFound = FALSE;
- for (Index = 0, Index1 = 0; AsciiString[Index] != 0; Index++) {
- if (AsciiString[Index] == '\\') {
- Index1 = Index;
- FileNameFound = TRUE;
- }
- }
-
- if (FileNameFound) {
- for (Index = Index1 + 1; AsciiString[Index] != '.'; Index++) {
- AsciiBuffer[Index - (Index1 + 1)] = AsciiString[Index];
- }
- AsciiBuffer[Index - (Index1 + 1)] = 0;
- DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));
- break;
- }
- }
- }
+ PeCoffLoaderGetImageInfo (&ImageContext);
+
+ if (ImageContext.PdbPointer != NULL) {
+ //
+ // Copy PDB pointer to AsciiBuffer and replace .PDB with .EFI
+ //
+ PdbStr = ImageContext.PdbPointer;
+ for (Index = 0; PdbStr != 0; Index++, PdbStr++) {
+ AsciiBuffer[Index] = *PdbStr;
+ if (*PdbStr == '.') {
+ AsciiBuffer[Index] = '\0';
}
}
+
+ DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));
}
- );
+
+ DEBUG_CODE_END ();
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));
diff --git a/EdkModulePkg/Core/Pei/Memory/MemoryServices.c b/EdkModulePkg/Core/Pei/Memory/MemoryServices.c
index 3da3e53..d49b742 100644
--- a/EdkModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/EdkModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -65,10 +65,10 @@ Returns:
SizeOfCarHeap = (UINT64) PeiStartupDescriptor->SizeOfCacheAsRam;
SizeOfCarHeap = RShiftU64 (SizeOfCarHeap, 1);
- DEBUG_CODE (
- PrivateData->SizeOfCacheAsRam = PeiStartupDescriptor->SizeOfCacheAsRam;
- PrivateData->MaxTopOfCarHeap = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) SizeOfCarHeap);
- );
+ DEBUG_CODE_BEGIN ();
+ PrivateData->SizeOfCacheAsRam = PeiStartupDescriptor->SizeOfCacheAsRam;
+ PrivateData->MaxTopOfCarHeap = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) SizeOfCarHeap);
+ DEBUG_CODE_END ();
PrivateData->HobList.Raw = PrivateData->BottomOfCarHeap;
diff --git a/EdkModulePkg/Core/Pei/PeiMain.msa b/EdkModulePkg/Core/Pei/PeiMain.msa
index 18ec53d..549820ef 100644
--- a/EdkModulePkg/Core/Pei/PeiMain.msa
+++ b/EdkModulePkg/Core/Pei/PeiMain.msa
@@ -1,13 +1,5 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+<?xml version="1.0" encoding="UTF-8"?>
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>PeiMain</ModuleName>
<ModuleType>PEI_CORE</ModuleType>
@@ -60,6 +52,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>TimerLib</Keyword>
</LibraryClass>
+ <LibraryClass Usage="SOMETIMES_CONSUMED">
+ <Keyword>PeCoffLib</Keyword>
+ </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PeiMain.h</Filename>
diff --git a/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c b/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c
index b6d57f9..c94331c 100644
--- a/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/EdkModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -150,10 +150,10 @@ Returns:
//
// The following code dumps out interesting cache as RAM usage information
// so we can keep tabs on how the cache as RAM is being utilized. The
- // DEBUG_CODE macro is used to prevent this code from being compiled
+ // DEBUG_CODE_BEGIN macro is used to prevent this code from being compiled
// on a debug build.
//
- DEBUG_CODE (
+ DEBUG_CODE_BEGIN ();
UINTN *StackPointer;
UINTN StackValue;
@@ -173,7 +173,7 @@ Returns:
((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom -
(UINTN) OldCoreData->HobList.Raw)
));
- );
+ DEBUG_CODE_END ();
//
// Alert any listeners that there is permanent memory available