summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-26 01:54:49 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-11-26 01:54:49 +0000
commit3e99020dbf0a159e34b84e7ae9125f2e368d5390 (patch)
tree0eb6339318f7bf7da1b679b8009cf267b2234566 /EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib
parent68bb5ce77e51cf35791e46f2202e36da97e5e6be (diff)
downloadedk2-platforms-3e99020dbf0a159e34b84e7ae9125f2e368d5390.tar.xz
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib')
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c82
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c16
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S30
6 files changed, 148 insertions, 19 deletions
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
index bc4ca8ee66..1904902c78 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
@@ -70,7 +70,7 @@ PeCoffLoaderLoadImage (
EFI_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
- IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
@@ -565,7 +565,10 @@ Returns:
// Pe image and in Te image header there is not a field to describe the imagesize,
// we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize
//
- ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ if(Hdr.Te->DataDirectory[1].VirtualAddress > Hdr.Te->DataDirectory[0].VirtualAddress) {
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[1].VirtualAddress + Hdr.Te->DataDirectory[1].Size);
+ }
ImageContext->SectionAlignment = 4096;
ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize;
@@ -1013,6 +1016,12 @@ Returns:
UINT32 TempDebugEntryRva;
UINT32 NumberOfRvaAndSizes;
UINT16 Magic;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
+ EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
+#endif
if (NULL == ImageContext) {
return EFI_INVALID_PARAMETER;
@@ -1368,6 +1377,73 @@ Returns:
}
}
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Get Image's HII resource section
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ }
+
+ if (DirectoryEntry->Size != 0) {
+ Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);
+
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {
+ if (ResourceDirectoryEntry->u1.s.NameIsString) {
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);
+
+ if (ResourceDirectoryString->Length == 3 &&
+ ResourceDirectoryString->String[0] == L'H' &&
+ ResourceDirectoryString->String[1] == L'I' &&
+ ResourceDirectoryString->String[2] == L'I') {
+ //
+ // Resource Type "HII" found
+ //
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Name
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Language
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+ }
+ }
+
+ //
+ // Now it ought to be resource Data
+ //
+ if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);
+ ImageContext->HiiResourceData = (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);
+ break;
+ }
+ }
+ }
+
+ ResourceDirectoryEntry++;
+ }
+ }
+ }
+#endif
+
#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress));
#endif
@@ -1378,7 +1454,7 @@ Returns:
EFI_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
- IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
index 824ab4b8ce..11ae5a17f0 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
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
@@ -383,8 +383,8 @@ EFI_STATUS
EFIAPI
PeiLibFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FwVolHeader,
- IN OUT EFI_PEI_FILE_HANDLE *FileHeader
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
/*++
@@ -395,9 +395,9 @@ Routine Description:
Arguments:
SearchType - Filter to find only file of this type.
- FwVolHeader - Pointer to the current FV to search.
+ FvHandle - Pointer to the current FV to search.
FileHandle - Pointer to the file matching SearchType in FwVolHeader.
- - NULL if file not found
+ - NULL if file not found
Returns:
EFI_STATUS
@@ -407,7 +407,7 @@ Returns:
EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer();
- return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader);
+ return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FvHandle, FileHandle);
}
@@ -471,13 +471,13 @@ Returns:
EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer();
- return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData);
+ return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, (EFI_PEI_FILE_HANDLE)FfsFileHeader, SectionData);
}
EFI_STATUS
EFIAPI
PeiLibFfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE *VolumeHandle,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
index 9e01b2cd9e..884ec1cc27 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
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
@@ -35,6 +35,8 @@ typedef struct {
UINT64 R14;
UINT64 R15;
UINT64 Rip;
+ UINT32 MxCsr;
+ UINT8 XmmBuffer[160]; // XMM6-XMM15
} EFI_JUMP_BUFFER;
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
index aa366c2a1f..c930486183 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
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
@@ -84,8 +84,6 @@ Returns:
--*/
{
*This = &mTransferControl;
- mTransferControl.SetJump = TransferControlSetJump;
- mTransferControl.LongJump = TransferControlLongJump;
return EFI_SUCCESS;
}
@@ -112,7 +110,6 @@ Returns:
--*/
{
*This = &mFlushInstructionCache;
- mFlushInstructionCache.Flush = FlushInstructionCacheFlush;
return EFI_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
index b6be0b2f60..418400c15a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
; 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
@@ -73,6 +73,8 @@ _r13 QWORD ?
_r14 QWORD ?
_r15 QWORD ?
_rip QWORD ?
+_MxCsr DWORD ?
+_XmmBuffer DB 160 DUP (?)
_EFI_JUMP_BUFFER ENDS
EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
@@ -116,6 +118,19 @@ TransferControlSetJump PROC
mov (EFI_JUMP_BUFFER PTR [rdx])._r13, r13
mov (EFI_JUMP_BUFFER PTR [rdx])._r14, r14
mov (EFI_JUMP_BUFFER PTR [rdx])._r15, r15
+ ; save non-volatile fp registers
+ stmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu [rax], xmm6
+ movdqu [rax + 10h], xmm7
+ movdqu [rax + 20h], xmm8
+ movdqu [rax + 30h], xmm9
+ movdqu [rax + 40h], xmm10
+ movdqu [rax + 50h], xmm11
+ movdqu [rax + 60h], xmm12
+ movdqu [rax + 70h], xmm13
+ movdqu [rax + 80h], xmm14
+ movdqu [rax + 90h], xmm15
mov rax, QWORD PTR [rsp+0]
mov (EFI_JUMP_BUFFER PTR [rdx])._rip, rax
mov rax, EFI_SUCCESS
@@ -134,6 +149,19 @@ TransferControlSetJump ENDP
;
PUBLIC TransferControlLongJump
TransferControlLongJump PROC
+ ; load non-volatile fp registers
+ ldmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu xmm6, [rax]
+ movdqu xmm7, [rax + 10h]
+ movdqu xmm8, [rax + 20h]
+ movdqu xmm9, [rax + 30h]
+ movdqu xmm10, [rax + 40h]
+ movdqu xmm11, [rax + 50h]
+ movdqu xmm12, [rax + 60h]
+ movdqu xmm13, [rax + 70h]
+ movdqu xmm14, [rax + 80h]
+ movdqu xmm15, [rax + 90h]
; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
mov rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
index 5253c0e2d1..2d464488cc 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# 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
@@ -99,6 +99,19 @@ ASM_PFX(TransferControlSetJump):
mov %r13,0x40(%rdx)
mov %r14,0x48(%rdx)
mov %r15,0x50(%rdx)
+ #; save non-volatile fp registers
+ stmxcsr 0x60(%rdx)
+ lea 0x68(%rdx), %rax
+ movdqu %xmm6, (%rax)
+ movdqu %xmm7, 0x10(%rax)
+ movdqu %xmm8, 0x20(%rax)
+ movdqu %xmm9, 0x30(%rax)
+ movdqu %xmm10, 0x40(%rax)
+ movdqu %xmm11, 0x50(%rax)
+ movdqu %xmm12, 0x60(%rax)
+ movdqu %xmm13, 0x70(%rax)
+ movdqu %xmm14, 0x80(%rax)
+ movdqu %xmm15, 0x90(%rax)
mov (%rsp),%rax
mov %rax,0x58(%rdx)
mov $0x0,%rax
@@ -115,7 +128,20 @@ ASM_PFX(TransferControlSetJump):
#
#
ASM_PFX(TransferControlLongJump):
- # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ #; load non-volatile fp registers
+ ldmxcsr 0x60(%rdx)
+ lea 0x68(%rdx), %rax
+ movdqu (%rax), %xmm6
+ movdqu 0x10(%rax), %xmm7
+ movdqu 0x20(%rax), %xmm8
+ movdqu 0x30(%rax), %xmm9
+ movdqu 0x40(%rax), %xmm10
+ movdqu 0x50(%rax), %xmm11
+ movdqu 0x60(%rax), %xmm12
+ movdqu 0x70(%rax), %xmm13
+ movdqu 0x80(%rax), %xmm14
+ movdqu 0x90(%rax), %xmm15
mov $0x5,%rax
mov (%rdx),%rbx
mov 0x8(%rdx),%rsp