summaryrefslogtreecommitdiff
path: root/EdkNt32Pkg
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 /EdkNt32Pkg
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 'EdkNt32Pkg')
-rw-r--r--EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c76
-rw-r--r--EdkNt32Pkg/Library/EdkGenericBdsLib/Performance.c56
-rw-r--r--EdkNt32Pkg/Nt32.fpd5
3 files changed, 55 insertions, 82 deletions
diff --git a/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c b/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c
index 3c21b12..13e8275 100644
--- a/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c
+++ b/EdkNt32Pkg/Dxe/PlatformBds/Generic/BootMaint/BootOption.c
@@ -1165,6 +1165,30 @@ Returns:
return FALSE;
}
+
+RETURN_STATUS
+EFIAPI
+IsEfiAppReadFromFile (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE File;
+
+ File = (EFI_FILE_HANDLE)FileHandle;
+ Status = File->SetPosition (File, FileOffset);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return File->Read (File, ReadSize, Buffer);
+}
+
+
+
BOOLEAN
BOpt_IsEfiApp (
IN EFI_FILE_HANDLE Dir,
@@ -1185,60 +1209,32 @@ Returns:
--*/
{
- UINTN BufferSize;
- EFI_IMAGE_DOS_HEADER DosHdr;
- EFI_IMAGE_NT_HEADERS PeHdr;
- EFI_IMAGE_OPTIONAL_HEADER32 *PeOpt32;
- EFI_IMAGE_OPTIONAL_HEADER64 *PeOpt64;
- UINT16 Subsystem;
- EFI_FILE_HANDLE File;
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+ EFI_FILE_HANDLE File;
Status = Dir->Open (Dir, &File, FileName, EFI_FILE_MODE_READ, 0);
-
if (EFI_ERROR (Status)) {
return FALSE;
}
- BufferSize = sizeof (EFI_IMAGE_DOS_HEADER);
- File->Read (File, &BufferSize, &DosHdr);
- if (DosHdr.e_magic != EFI_IMAGE_DOS_SIGNATURE) {
- File->Close (File);
- return FALSE;
- }
+ ZeroMem (&ImageContext, sizeof (ImageContext));
+ ImageContext.Handle = (VOID *)File;
+ ImageContext.ImageRead = IsEfiAppReadFromFile;
- File->SetPosition (File, DosHdr.e_lfanew);
- BufferSize = sizeof (EFI_IMAGE_NT_HEADERS);
- File->Read (File, &BufferSize, &PeHdr);
- if (PeHdr.Signature != EFI_IMAGE_NT_SIGNATURE) {
- File->Close (File);
- return FALSE;
- }
- //
- // Determine PE type and read subsytem
- // BugBug : We should be using EFI_IMAGE_MACHINE_TYPE_SUPPORTED (machine)
- // macro to detect the machine type.
- // We should not be using EFI_IMAGE_OPTIONAL_HEADER32 and
- // EFI_IMAGE_OPTIONAL_HEADER64
- //
- if (PeHdr.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
- PeOpt32 = (EFI_IMAGE_OPTIONAL_HEADER32 *) &(PeHdr.OptionalHeader);
- Subsystem = PeOpt32->Subsystem;
- } else if (PeHdr.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
- PeOpt64 = (EFI_IMAGE_OPTIONAL_HEADER64 *) &(PeHdr.OptionalHeader);
- Subsystem = PeOpt64->Subsystem;
- } else {
+ Status = PeCoffLoaderGetImageInfo (&ImageContext);
+ File->Close (File);
+ if (EFI_ERROR (Status)) {
return FALSE;
}
- if (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {
- File->Close (File);
+ if (ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {
return TRUE;
} else {
- File->Close (File);
return FALSE;
}
-}
+ }
+
EFI_STATUS
BOpt_FindDrivers (
diff --git a/EdkNt32Pkg/Library/EdkGenericBdsLib/Performance.c b/EdkNt32Pkg/Library/EdkGenericBdsLib/Performance.c
index 320d6b7..c7b6bc9 100644
--- a/EdkNt32Pkg/Library/EdkGenericBdsLib/Performance.c
+++ b/EdkNt32Pkg/Library/EdkGenericBdsLib/Performance.c
@@ -28,6 +28,9 @@ ClearDebugRegisters (
VOID
)
{
+ //
+ // BugBug: We should not need to do this. We need to root cause this bug!!!!
+ //
AsmWriteDr0 (0);
AsmWriteDr1 (0);
}
@@ -85,6 +88,8 @@ Returns:
return ;
}
+
+
STATIC
CHAR8 *
GetPdbPath (
@@ -107,51 +112,18 @@ Returns:
--*/
{
- CHAR8 *PdbPath;
- UINT32 DirCount;
- EFI_IMAGE_DOS_HEADER *DosHdr;
- EFI_IMAGE_NT_HEADERS *NtHdr;
- EFI_IMAGE_OPTIONAL_HEADER *OptionalHdr;
- EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
- EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
- VOID *CodeViewEntryPointer;
-
- CodeViewEntryPointer = NULL;
- PdbPath = NULL;
- DosHdr = ImageBase;
-
- if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
- NtHdr = (EFI_IMAGE_NT_HEADERS *) ((UINT8 *) DosHdr + DosHdr->e_lfanew);
- OptionalHdr = (VOID *) &NtHdr->OptionalHeader;
- DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
- if (DirectoryEntry->VirtualAddress != 0) {
- for (DirCount = 0;
- (DirCount < DirectoryEntry->Size / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) && CodeViewEntryPointer == NULL;
- DirCount++
- ) {
- DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (DirectoryEntry->VirtualAddress + (UINTN) ImageBase + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));
- if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
- CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageBase);
- switch (*(UINT32 *) CodeViewEntryPointer) {
- case CODEVIEW_SIGNATURE_NB10:
- PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
- break;
-
- case CODEVIEW_SIGNATURE_RSDS:
- PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
- break;
-
- default:
- break;
- }
- }
- }
- }
- }
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+
+ ZeroMem (&ImageContext, sizeof (ImageContext));
+ ImageContext.Handle = ImageBase;
+ ImageContext.ImageRead = PeCoffLoaderImageReadFromMemory;
- return PdbPath;
+ PeCoffLoaderGetImageInfo (&ImageContext);
+
+ return ImageContext.PdbPointer;
}
+
STATIC
VOID
GetNameFromHandle (
diff --git a/EdkNt32Pkg/Nt32.fpd b/EdkNt32Pkg/Nt32.fpd
index f0bd9bf..24b1a53 100644
--- a/EdkNt32Pkg/Nt32.fpd
+++ b/EdkNt32Pkg/Nt32.fpd
@@ -272,6 +272,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Instance ModuleGuid="8c690838-7a22-45c4-aa58-a33e3e515cd4" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<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="556f5d10-7309-4af4-b80a-8196bd60946f" PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
</Libraries>
<PcdBuildDefinition>
<PcdData ItemType="FIXED_AT_BUILD">
@@ -2027,6 +2028,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<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="FC120ED3-40E1-46dc-8C9C-AAE3CA139ACF" 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">
@@ -2200,6 +2203,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">
@@ -4169,6 +4173,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">