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
This commit is contained in:
ajfish
2006-07-26 15:23:35 +00:00
parent dca84bbd41
commit 2ce311322c
47 changed files with 1822 additions and 1332 deletions

View File

@@ -2085,94 +2085,90 @@ AtapiPassThruCheckErrorStatus (
)
{
UINT8 StatusRegister;
//#ifdef EFI_DEBUG
UINT8 ErrorRegister;
//#endif
StatusRegister = ReadPortB (
AtapiScsiPrivate->PciIo,
AtapiScsiPrivate->IoPort->Reg.Status
);
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (StatusRegister & DWF) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Write Fault\n",
StatusRegister)
);
}
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Write Fault\n",
StatusRegister)
);
}
if (StatusRegister & CORR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Corrected Data\n",
StatusRegister)
);
}
if (StatusRegister & CORR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Corrected Data\n",
StatusRegister)
);
}
if (StatusRegister & ERR) {
ErrorRegister = ReadPortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Reg1.Error);
if (StatusRegister & ERR) {
ErrorRegister = ReadPortB (AtapiScsiPrivate->PciIo, AtapiScsiPrivate->IoPort->Reg1.Error);
if (ErrorRegister & BBK_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Bad Block Detected\n",
ErrorRegister)
);
}
if (ErrorRegister & BBK_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Bad Block Detected\n",
ErrorRegister)
);
}
if (ErrorRegister & UNC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Uncorrectable Data\n",
ErrorRegister)
);
}
if (ErrorRegister & UNC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Uncorrectable Data\n",
ErrorRegister)
);
}
if (ErrorRegister & MC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Media Change\n",
ErrorRegister)
);
}
if (ErrorRegister & MC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Media Change\n",
ErrorRegister)
);
}
if (ErrorRegister & ABRT_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Abort\n",
ErrorRegister)
);
}
if (ErrorRegister & ABRT_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Abort\n",
ErrorRegister)
);
}
if (ErrorRegister & TK0NF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Track 0 Not Found\n",
ErrorRegister)
);
}
if (ErrorRegister & TK0NF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Track 0 Not Found\n",
ErrorRegister)
);
}
if (ErrorRegister & AMNF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Address Mark Not Found\n",
ErrorRegister)
);
}
if (ErrorRegister & AMNF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"AtapiPassThruCheckErrorStatus()-- %02x : Error : Address Mark Not Found\n",
ErrorRegister)
);
}
}
}
);
DEBUG_CODE_END ();
if ((StatusRegister & (ERR | DWF | CORR)) == 0) {
return EFI_SUCCESS;
}
return EFI_DEVICE_ERROR;
}
}

View File

@@ -640,77 +640,77 @@ CheckErrorStatus (
StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (StatusRegister & DWF) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Write Fault\n",
StatusRegister)
);
}
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Write Fault\n",
StatusRegister)
);
}
if (StatusRegister & CORR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Corrected Data\n",
StatusRegister)
);
}
if (StatusRegister & CORR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Corrected Data\n",
StatusRegister)
);
}
if (StatusRegister & ERR) {
ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
if (StatusRegister & ERR) {
ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
if (ErrorRegister & BBK_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Bad Block Detected\n",
ErrorRegister)
);
}
if (ErrorRegister & BBK_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Bad Block Detected\n",
ErrorRegister)
);
}
if (ErrorRegister & UNC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Uncorrectable Data\n",
ErrorRegister)
);
}
if (ErrorRegister & UNC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Uncorrectable Data\n",
ErrorRegister)
);
}
if (ErrorRegister & MC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Media Change\n",
ErrorRegister)
);
}
if (ErrorRegister & MC_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Media Change\n",
ErrorRegister)
);
}
if (ErrorRegister & ABRT_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Abort\n",
ErrorRegister)
);
}
if (ErrorRegister & ABRT_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Abort\n",
ErrorRegister)
);
}
if (ErrorRegister & TK0NF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Track 0 Not Found\n",
ErrorRegister)
);
}
if (ErrorRegister & TK0NF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Track 0 Not Found\n",
ErrorRegister)
);
}
if (ErrorRegister & AMNF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Address Mark Not Found\n",
ErrorRegister)
);
}
if (ErrorRegister & AMNF_ERR) {
DEBUG (
(EFI_D_BLKIO,
"CheckErrorStatus()-- %02x : Error : Address Mark Not Found\n",
ErrorRegister)
);
}
}
}
);
DEBUG_CODE_END ();
if ((StatusRegister & (ERR | DWF | CORR)) == 0) {
return EFI_SUCCESS;

View File

@@ -1,23 +1,13 @@
<?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>PciBus</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>93B80004-9FB3-11d4-9A3A-0090273FC14D</GuidValue>
<Version>1.0</Version>
<Abstract>Component description file for PciBus module.</Abstract>
<Description>
PCI bus driver. This module will probe all PCI devices and allocate MMIO and IO
space for these devices.
</Description>
<Description>PCI bus driver. This module will probe all PCI devices and allocate MMIO and IO
space for these devices.</Description>
<Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -63,6 +53,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DevicePathLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PeCoffGetEntryPointLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PciBus.h</Filename>

View File

@@ -139,8 +139,6 @@ Returns:
// TODO: EFI_SUCCESS - add return value to function comment
{
EFI_STATUS Status;
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_NT_HEADERS *PeHdr;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
PCI_DRIVER_OVERRIDE_LIST *Node;
EFI_DRIVER_OS_HANDOFF_HEADER *DriverOsHandoffHeader;
@@ -169,14 +167,7 @@ Returns:
PciIoDevice->BusOverride = TRUE;
DosHdr = (EFI_IMAGE_DOS_HEADER *) LoadedImage->ImageBase;
if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {
return EFI_SUCCESS;
}
PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) LoadedImage->ImageBase + DosHdr->e_lfanew);
if (PeHdr->FileHeader.Machine != EFI_IMAGE_MACHINE_EBC) {
if (PeCoffLoaderGetMachineType ((VOID *)(UINTN)LoadedImage->ImageBase) != EFI_IMAGE_MACHINE_EBC) {
return EFI_SUCCESS;
}

View File

@@ -557,9 +557,9 @@ Returns:
//
// Display Architectural protocols that were not loaded if this is DEBUG build
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CoreDisplayMissingArchProtocols ();
);
DEBUG_CODE_END ();
//
// Assert if the Architectural Protocols are not present.
@@ -574,9 +574,9 @@ Returns:
// Display any drivers that were not dispatched because dependency expression
// evaluated to false if this is a debug build
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
CoreDisplayDiscoveredNotDispatched ();
);
DEBUG_CODE_END ();
//
// Transfer control to the BDS Architectural Protocol

View File

@@ -268,6 +268,15 @@ Returns:
return Status;
}
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine)) {
//
// The PE/COFF loader can support loading image types that can be executed.
// If we loaded an image type that we can not execute return EFI_UNSUPORTED.
//
return EFI_UNSUPPORTED;
}
//
// Allocate memory of the correct memory type aligned on the required image boundry
//
@@ -440,8 +449,8 @@ Returns:
// Print the load address and the PDB file name if it is available
//
DEBUG_CODE (
{
DEBUG_CODE_BEGIN ();
UINTN Index;
UINTN StartIndex;
CHAR8 EfiFileName[256];
@@ -473,8 +482,8 @@ Returns:
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex]));
}
DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));
}
);
DEBUG_CODE_END ();
return EFI_SUCCESS;
@@ -924,22 +933,13 @@ Returns:
//
PERF_START (ImageHandle, START_IMAGE_TOK, NULL, 0);
if (sizeof (UINTN) == 4 && Image->Machine == EFI_IMAGE_MACHINE_X64) {
return EFI_UNSUPPORTED;
} else if (sizeof (UINTN) == 8 && Image->Machine == EFI_IMAGE_MACHINE_IA32) {
return EFI_UNSUPPORTED;
} else {
//
// For orther possible cases
//
}
//
// Push the current start image context, and
// link the current image to the head. This is the
// only image that can call Exit()
//
HandleDatabaseKey = CoreGetHandleDatabaseKey();
HandleDatabaseKey = CoreGetHandleDatabaseKey ();
LastImage = mCurrentImage;
mCurrentImage = Image;
Image->Tpl = gEfiCurrentTpl;
@@ -970,11 +970,11 @@ Returns:
// This make the user aware and check if the driver image have already released
// all the resource in this situation.
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (EFI_ERROR (Image->Status)) {
DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
}
);
DEBUG_CODE_END ();
//
// If the image returns, exit it through Exit()
@@ -1003,7 +1003,7 @@ Returns:
//
// Handle the image's returned ExitData
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (Image->ExitDataSize != 0 || Image->ExitData != NULL) {
DEBUG (
@@ -1017,7 +1017,7 @@ Returns:
}
DEBUG ((EFI_D_LOAD, "\n"));
}
);
DEBUG_CODE_END ();
//
// Return the exit data to the caller

View File

@@ -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

View File

@@ -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);

View File

@@ -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"));

View File

@@ -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;

View File

@@ -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>

View File

@@ -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

View File

@@ -1032,6 +1032,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -1293,6 +1294,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="b1ee6c28-54aa-4d17-b705-3e28ccb27b2e" PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674"/>
<Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
@@ -3139,7 +3141,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
<C_Name>PcdMaximumUnicodeStringLength</C_Name>
@@ -5422,6 +5425,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -5684,6 +5688,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="331deb15-454b-48d8-9b74-70d01f3f3556" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -7448,6 +7453,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -9357,6 +9363,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -9620,6 +9627,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="3ddc3b12-99ea-4364-b315-6310a2050be5" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="61999c3c-72a5-4506-a4ff-4271d18a1d14" PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -11387,6 +11395,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -13296,6 +13305,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="bda39d3a-451b-4350-8266-81ab10fa0523" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -14905,6 +14915,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="27d67720-ea68-48ae-93da-a3a074c90e30" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="4674739d-3195-4fb2-8094-ac1d22d00194" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="91c1677a-e57f-4191-8b8e-eb7711a716e0" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Instance ModuleGuid="be490364-73d2-420d-950e-f6450ca75dfb" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">

View File

@@ -423,9 +423,9 @@ GraphicsConsoleControllerDriverStart (
goto Error;
}
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");
);
DEBUG_CODE_END ();
//
// Install protocol interfaces for the Graphics Console device.

View File

@@ -191,7 +191,7 @@ Returns:
{
static BOOLEAN InHandler = FALSE;
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (InHandler) {
EfiDebugPrint (EFI_D_GENERIC, "ERROR: Re-entered debugger!\n"
" ExceptionType == %X\n"
@@ -205,7 +205,8 @@ Returns:
Context.SystemContextIpf->CrIpsr,
InHandler);
}
)
DEBUG_CODE_END ();
ASSERT (!InHandler);
InHandler = TRUE;
if (IvtEntryTable[ExceptionType].RegisteredCallback != NULL) {

View File

@@ -368,7 +368,7 @@ Returns:
);
if (EFI_ERROR (Status)) {
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
UINTN BufferSize;
BufferSize = 48;
@@ -378,7 +378,7 @@ Returns:
&BufferSize,
"DebugPort driver failed to open child controller\n\n"
);
);
DEBUG_CODE_END ();
gBS->CloseProtocol (
ControllerHandle,
@@ -389,7 +389,7 @@ Returns:
return Status;
}
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
UINTN BufferSize;
BufferSize = 38;
@@ -399,7 +399,7 @@ Returns:
&BufferSize,
"Hello World from the DebugPort driver\n\n"
);
);
DEBUG_CODE_END ();
return EFI_SUCCESS;
}

View File

@@ -758,11 +758,11 @@ Returns:
//
// return status
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (OrgCrc != Crc) {
DEBUG ((EFI_D_ERROR, "CheckCrc32: Crc check failed\n"));
}
);
DEBUG_CODE_END ();
return (BOOLEAN) (OrgCrc == Crc);
}

View File

@@ -685,9 +685,6 @@ Returns:
EFI_STATUS Status;
EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *EbcSimpleDebugger;
//
// end DEBUG_CODE
//
EbcSimpleDebugger = NULL;
Status = EFI_SUCCESS;
StackCorrupted = 0;
@@ -704,7 +701,7 @@ Returns:
//
// Try to get the debug support for EBC
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
Status = gBS->LocateProtocol (
&mEbcSimpleDebuggerProtocolGuid,
NULL,
@@ -713,7 +710,7 @@ Returns:
if (EFI_ERROR (Status)) {
EbcSimpleDebugger = NULL;
}
);
DEBUG_CODE_END ();
//
// Save the start IP for debug. For example, if we take an exception we
@@ -731,11 +728,11 @@ Returns:
//
// If we've found a simple debugger protocol, call it
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (EbcSimpleDebugger != NULL) {
EbcSimpleDebugger->Debugger (EbcSimpleDebugger, VmPtr);
}
);
DEBUG_CODE_END ();
//
// Verify the opcode is in range. Otherwise generate an exception.

View File

@@ -298,9 +298,9 @@ Returns:
//
// Produce a VM test interface protocol. Not required for execution.
//
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
InitEbcVmTestProtocol (&ImageHandle);
);
DEBUG_CODE_END ();
return Status;
}
@@ -908,10 +908,10 @@ Returns:
}
EbcVmTestProtocol->Execute = (EBC_VM_TEST_EXECUTE) EbcExecuteInstructions;
DEBUG_CODE(
DEBUG_CODE_BEGIN ();
EbcVmTestProtocol->Assemble = (EBC_VM_TEST_ASM) EbcVmTestUnsupported;
EbcVmTestProtocol->Disassemble = (EBC_VM_TEST_DASM) EbcVmTestUnsupported;
);
DEBUG_CODE_END ();
//
// Publish the protocol

View File

@@ -173,21 +173,23 @@ Note:
Status = PciRootBridgeIo->Pci.Write (
PciRootBridgeIo,
EfiPciWidthUint32,
EFI_PCI_ADDRESS (LPC_BUS_NUMBER,
LPC_DEVICE_NUMBER,
LPC_IF,
GEN_STATUS),
EFI_PCI_ADDRESS (
LPC_BUS_NUMBER,
LPC_DEVICE_NUMBER,
LPC_IF,
GEN_STATUS
),
1,
&GenStatus
);
DEBUG_CODE (
DEBUG_CODE_BEGIN ();
if (TopSwap) {
DEBUG ((EFI_D_ERROR, "SAR: Set top swap\n"));
} else {
DEBUG ((EFI_D_ERROR, "SAR: Clear top swap\n"));
}
);
DEBUG_CODE_END ();
return EFI_SUCCESS;
}

View File

@@ -24,38 +24,6 @@ Revision History
#include "Runtime.h"
EFI_STATUS
PeHotRelocateImageEx (
IN UINT16 *Reloc,
IN OUT CHAR8 *Fixup,
IN OUT CHAR8 **FixupData,
IN UINT64 Adjust
)
/*++
Routine Description:
Performs an Itanium-based platform specific relocation fixup
Arguments:
Reloc - Pointer to the relocation record
Fixup - Pointer to the address to fix up
FixupData - Pointer to a buffer to log the fixups
Adjust - The offset to adjust the fixup
Returns:
EFI_SUCCESS
--*/
{
return EFI_SUCCESS;
}
//
// Cache Flush Routine.

View File

@@ -23,192 +23,6 @@ Revision History
--*/
#include "Runtime.h"
#include "PeHotRelocateEx.h"
EFI_STATUS
PeHotRelocateImageEx (
IN UINT16 *Reloc,
IN OUT CHAR8 *Fixup,
IN OUT CHAR8 **FixupData,
IN UINT64 Adjust
)
/*++
Routine Description:
Performs an IPF specific relocation fixup
Arguments:
Reloc - Pointer to the relocation record
Fixup - Pointer to the address to fix up
FixupData - Pointer to a buffer to log the fixups
Adjust - The offset to adjust the fixup
Returns:
None
--*/
{
UINT64 *F64;
UINT64 FixupVal;
switch ((*Reloc) >> 12) {
case EFI_IMAGE_REL_BASED_DIR64:
F64 = (UINT64 *) Fixup;
*FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64));
if (*(UINT64 *) (*FixupData) == *F64) {
*F64 = *F64 + (UINT64) Adjust;
}
*FixupData = *FixupData + sizeof (UINT64);
break;
case EFI_IMAGE_REL_BASED_IA64_IMM64:
F64 = (UINT64 *) Fixup;
*FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64));
if (*(UINT64 *) (*FixupData) == *F64) {
//
// Align it to bundle address before fixing up the
// 64-bit immediate value of the movl instruction.
//
//
Fixup = (CHAR8 *) ((UINT64) Fixup & (UINT64)~(15));
FixupVal = (UINT64) 0;
//
// Extract the lower 32 bits of IMM64 from bundle
//
EXT_IMM64 (
FixupVal,
(UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X,
IMM64_IMM7B_SIZE_X,
IMM64_IMM7B_INST_WORD_POS_X,
IMM64_IMM7B_VAL_POS_X
);
EXT_IMM64 (
FixupVal,
(UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X,
IMM64_IMM9D_SIZE_X,
IMM64_IMM9D_INST_WORD_POS_X,
IMM64_IMM9D_VAL_POS_X
);
EXT_IMM64 (
FixupVal,
(UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X,
IMM64_IMM5C_SIZE_X,
IMM64_IMM5C_INST_WORD_POS_X,
IMM64_IMM5C_VAL_POS_X
);
EXT_IMM64 (
FixupVal,
(UINT32 *) Fixup + IMM64_IC_INST_WORD_X,
IMM64_IC_SIZE_X,
IMM64_IC_INST_WORD_POS_X,
IMM64_IC_VAL_POS_X
);
EXT_IMM64 (
FixupVal,
(UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X,
IMM64_IMM41a_SIZE_X,
IMM64_IMM41a_INST_WORD_POS_X,
IMM64_IMM41a_VAL_POS_X
);
//
// Update 64-bit address
//
FixupVal += Adjust;
//
// Insert IMM64 into bundle
//
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X),
IMM64_IMM7B_SIZE_X,
IMM64_IMM7B_INST_WORD_POS_X,
IMM64_IMM7B_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X),
IMM64_IMM9D_SIZE_X,
IMM64_IMM9D_INST_WORD_POS_X,
IMM64_IMM9D_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X),
IMM64_IMM5C_SIZE_X,
IMM64_IMM5C_INST_WORD_POS_X,
IMM64_IMM5C_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IC_INST_WORD_X),
IMM64_IC_SIZE_X,
IMM64_IC_INST_WORD_POS_X,
IMM64_IC_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X),
IMM64_IMM41a_SIZE_X,
IMM64_IMM41a_INST_WORD_POS_X,
IMM64_IMM41a_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IMM41b_INST_WORD_X),
IMM64_IMM41b_SIZE_X,
IMM64_IMM41b_INST_WORD_POS_X,
IMM64_IMM41b_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_IMM41c_INST_WORD_X),
IMM64_IMM41c_SIZE_X,
IMM64_IMM41c_INST_WORD_POS_X,
IMM64_IMM41c_VAL_POS_X
);
INS_IMM64 (
FixupVal,
((UINT32 *) Fixup + IMM64_SIGN_INST_WORD_X),
IMM64_SIGN_SIZE_X,
IMM64_SIGN_INST_WORD_POS_X,
IMM64_SIGN_VAL_POS_X
);
*(UINT64 *) (*FixupData) = *F64;
}
*FixupData = *FixupData + sizeof (UINT64);
break;
default:
DEBUG ((EFI_D_ERROR, "PeHotRelocateEx:unknown fixed type\n"));
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
//
// Cache Flush Routine.

View File

@@ -51,166 +51,3 @@ Returns:
return (CHAR8 *) ((UINTN) Image->ImageBase + Address);
}
VOID
RelocatePeImageForRuntime (
RUNTIME_IMAGE_RELOCATION_DATA *Image
)
{
CHAR8 *OldBase;
CHAR8 *NewBase;
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_NT_HEADERS *PeHdr;
UINT32 NumberOfRvaAndSizes;
EFI_IMAGE_DATA_DIRECTORY *DataDirectory;
EFI_IMAGE_DATA_DIRECTORY *RelocDir;
EFI_IMAGE_BASE_RELOCATION *RelocBase;
EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;
UINT16 *Reloc;
UINT16 *RelocEnd;
CHAR8 *Fixup;
CHAR8 *FixupBase;
UINT16 *F16;
UINT32 *F32;
CHAR8 *FixupData;
UINTN Adjust;
EFI_STATUS Status;
OldBase = (CHAR8 *) ((UINTN) Image->ImageBase);
NewBase = (CHAR8 *) ((UINTN) Image->ImageBase);
Status = RuntimeDriverConvertPointer (0, (VOID **) &NewBase);
ASSERT_EFI_ERROR (Status);
Adjust = (UINTN) NewBase - (UINTN) OldBase;
//
// Find the image's relocate dir info
//
DosHdr = (EFI_IMAGE_DOS_HEADER *) OldBase;
if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
//
// Valid DOS header so get address of PE header
//
PeHdr = (EFI_IMAGE_NT_HEADERS *) (((CHAR8 *) DosHdr) + DosHdr->e_lfanew);
} else {
//
// No Dos header so assume image starts with PE header.
//
PeHdr = (EFI_IMAGE_NT_HEADERS *) OldBase;
}
if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) {
//
// Not a valid PE image so Exit
//
return ;
}
//
// Get some data from the PE type dependent data
//
NumberOfRvaAndSizes = PeHdr->OptionalHeader.NumberOfRvaAndSizes;
DataDirectory = &PeHdr->OptionalHeader.DataDirectory[0];
//
// Find the relocation block
//
// 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.
//
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
RelocBase = RuntimePeImageAddress (Image, RelocDir->VirtualAddress);
RelocBaseEnd = RuntimePeImageAddress (Image, RelocDir->VirtualAddress + RelocDir->Size);
} else {
//
// Cannot find relocations, cannot continue
//
ASSERT (FALSE);
return ;
}
ASSERT (RelocBase != NULL && RelocBaseEnd != NULL);
//
// Run the whole relocation block. And re-fixup data that has not been
// modified. The FixupData is used to see if the image has been modified
// since it was relocated. This is so data sections that have been updated
// by code will not be fixed up, since that would set them back to
// defaults.
//
FixupData = Image->RelocationData;
while (RelocBase < RelocBaseEnd) {
Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
RelocEnd = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock);
FixupBase = (CHAR8 *) ((UINTN) Image->ImageBase) + RelocBase->VirtualAddress;
//
// Run this relocation record
//
while (Reloc < RelocEnd) {
Fixup = FixupBase + (*Reloc & 0xFFF);
switch ((*Reloc) >> 12) {
case EFI_IMAGE_REL_BASED_ABSOLUTE:
break;
case EFI_IMAGE_REL_BASED_HIGH:
F16 = (UINT16 *) Fixup;
if (*(UINT16 *) FixupData == *F16) {
*F16 = (UINT16) ((*F16 << 16) + ((UINT16) Adjust & 0xffff));
}
FixupData = FixupData + sizeof (UINT16);
break;
case EFI_IMAGE_REL_BASED_LOW:
F16 = (UINT16 *) Fixup;
if (*(UINT16 *) FixupData == *F16) {
*F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff));
}
FixupData = FixupData + sizeof (UINT16);
break;
case EFI_IMAGE_REL_BASED_HIGHLOW:
F32 = (UINT32 *) Fixup;
FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
if (*(UINT32 *) FixupData == *F32) {
*F32 = *F32 + (UINT32) Adjust;
}
FixupData = FixupData + sizeof (UINT32);
break;
case EFI_IMAGE_REL_BASED_HIGHADJ:
//
// Not implemented, but not used in EFI 1.0
//
ASSERT (FALSE);
break;
default:
//
// Only Itanium requires ConvertPeImage_Ex
//
Status = PeHotRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
if (EFI_ERROR (Status)) {
return ;
}
}
//
// Next relocation record
//
Reloc += 1;
}
//
// next reloc block
//
RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
}
FlushCpuCache (Image->ImageBase, (UINT64) Image->ImageSize);
}

View File

@@ -352,6 +352,7 @@ RuntimeDriverSetVirtualAddressMap (
IN EFI_MEMORY_DESCRIPTOR *VirtualMap
)
{
EFI_STATUS Status;
RUNTIME_NOTIFY_EVENT_DATA *RuntimeEvent;
RUNTIME_IMAGE_RELOCATION_DATA *RuntimeImage;
LIST_ENTRY *Link;
@@ -359,6 +360,7 @@ RuntimeDriverSetVirtualAddressMap (
UINTN Index1;
EFI_DRIVER_OS_HANDOFF_HEADER *DriverOsHandoffHeader;
EFI_DRIVER_OS_HANDOFF *DriverOsHandoff;
EFI_PHYSICAL_ADDRESS VirtImageBase;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
EFI_CAPSULE_TABLE *CapsuleTable;
#endif
@@ -454,7 +456,19 @@ RuntimeDriverSetVirtualAddressMap (
for (Link = mRelocationList.ForwardLink; Link != &mRelocationList; Link = Link->ForwardLink) {
RuntimeImage = _CR (Link, RUNTIME_IMAGE_RELOCATION_DATA, Link);
if (RuntimeImage->Valid) {
RelocatePeImageForRuntime (RuntimeImage);
VirtImageBase = RuntimeImage->ImageBase;
Status = RuntimeDriverConvertPointer (0, (VOID **) &VirtImageBase);
ASSERT_EFI_ERROR (Status);
PeCoffLoaderRelocateImageForRuntime (
RuntimeImage->ImageBase,
VirtImageBase,
RuntimeImage->ImageSize,
RuntimeImage->RelocationData
);
FlushCpuCache (RuntimeImage->ImageBase, (UINT64)RuntimeImage->ImageSize);
}
}
//

View File

@@ -53,15 +53,6 @@ RelocatePeImageForRuntime (
)
;
EFI_STATUS
PeHotRelocateImageEx (
IN UINT16 *Reloc,
IN OUT CHAR8 *Fixup,
IN OUT CHAR8 **FixupData,
IN UINT64 Adjust
)
;
EFI_STATUS
EFIAPI
RuntimeDriverCalculateCrc32 (

View File

@@ -60,7 +60,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.-->
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Runtime.dxs</Filename>
<Filename>PeHotRelocate.c</Filename>
<Filename>Runtime.c</Filename>
<Filename>Runtime.h</Filename>
<Filename>Crc32.c</Filename>

View File

@@ -24,38 +24,6 @@ Revision History
#include "Runtime.h"
EFI_STATUS
PeHotRelocateImageEx (
IN UINT16 *Reloc,
IN OUT CHAR8 *Fixup,
IN OUT CHAR8 **FixupData,
IN UINT64 Adjust
)
/*++
Routine Description:
Performs an Itanium-based platform specific relocation fixup
Arguments:
Reloc - Pointer to the relocation record
Fixup - Pointer to the address to fix up
FixupData - Pointer to a buffer to log the fixups
Adjust - The offset to adjust the fixup
Returns:
EFI_SUCCESS
--*/
{
return EFI_SUCCESS;
}
//
// Cache Flush Routine.