From 19bee90c32772dd225332193858d9c2fcd2930aa Mon Sep 17 00:00:00 2001 From: lgao4 Date: Thu, 17 Jul 2008 08:45:10 +0000 Subject: [PATCH] Correct ECC Error for MdePkg/Include/Protocol and Correct PeCofferLib bug to set ImageContext->EntryPoint after relocate when the destination address is specified. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5514 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Include/Protocol/BlockIo.h | 30 ++++++++--------- MdePkg/Include/Protocol/DebugSupport.h | 32 +------------------ MdePkg/Include/Protocol/DevicePathUtilities.h | 2 +- MdePkg/Include/Protocol/FirmwareVolume2.h | 2 +- MdePkg/Include/Protocol/ManagedNetwork.h | 4 +-- MdePkg/Include/Protocol/UgaIo.h | 32 +++++++------------ MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 16 ++++++---- 7 files changed, 42 insertions(+), 76 deletions(-) diff --git a/MdePkg/Include/Protocol/BlockIo.h b/MdePkg/Include/Protocol/BlockIo.h index 91c56e7c82..c42ecc5da0 100644 --- a/MdePkg/Include/Protocol/BlockIo.h +++ b/MdePkg/Include/Protocol/BlockIo.h @@ -135,28 +135,28 @@ EFI_STATUS **/ typedef struct { - UINT32 MediaId; ///< The curent media Id. If the media changes, this value is changed. - BOOLEAN RemovableMedia; ///< TRUE if the media is removable; otherwise, FALSE. + UINT32 MediaId; /**< The curent media Id. If the media changes, this value is changed.**/ + BOOLEAN RemovableMedia; /**< TRUE if the media is removable; otherwise, FALSE.**/ BOOLEAN MediaPresent; /**< TRUE if there is a media currently present in the device; - othersise, FALSE. THis field shows the media present status - as of the most recent ReadBlocks() or WriteBlocks() call. - **/ + othersise, FALSE. THis field shows the media present status + as of the most recent ReadBlocks() or WriteBlocks() call. + **/ BOOLEAN LogicalPartition; /**< TRUE if LBA 0 is the first block of a partition; otherwise - FALSE. For media with only one partition this would be TRUE. - **/ + FALSE. For media with only one partition this would be TRUE. + **/ BOOLEAN ReadOnly; /**< TRUE if the media is marked read-only otherwise, FALSE. - This field shows the read-only status as of the most recent WriteBlocks () call. - **/ - BOOLEAN WriteCaching; ///< TRUE if the WriteBlock () function caches write data. + This field shows the read-only status as of the most recent WriteBlocks () call. + **/ + BOOLEAN WriteCaching; /**< TRUE if the WriteBlock () function caches write data.**/ UINT32 BlockSize; /**< The intrinsic block size of the device. If the media changes, then - this field is updated. - **/ - UINT32 IoAlign; ///< Supplies the alignment requirement for any buffer to read or write block(s). + this field is updated. + **/ + UINT32 IoAlign; /**< Supplies the alignment requirement for any buffer to read or write block(s).**/ EFI_LBA LastBlock; /**< The last logical block address on the device. - If the media changes, then this field is updated. - **/ + If the media changes, then this field is updated. + **/ } EFI_BLOCK_IO_MEDIA; #define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000 diff --git a/MdePkg/Include/Protocol/DebugSupport.h b/MdePkg/Include/Protocol/DebugSupport.h index b3d431ddc8..c16cf44120 100644 --- a/MdePkg/Include/Protocol/DebugSupport.h +++ b/MdePkg/Include/Protocol/DebugSupport.h @@ -76,7 +76,6 @@ typedef struct { UINT32 DataOffset; UINT16 Ds; UINT8 Reserved2[10]; -#if (EFI_SPECIFICATION_VERSION >= 0x00020000) UINT8 St0Mm0[10], Reserved3[6]; UINT8 St1Mm1[10], Reserved4[6]; UINT8 St2Mm2[10], Reserved5[6]; @@ -95,26 +94,10 @@ typedef struct { UINT8 Xmm7[16]; UINT8 Reserved11[14 * 16]; } EFI_FX_SAVE_STATE_IA32; -#else - UINT8 St0Mm0[10], Reserved3[6]; - UINT8 St0Mm1[10], Reserved4[6]; - UINT8 St0Mm2[10], Reserved5[6]; - UINT8 St0Mm3[10], Reserved6[6]; - UINT8 St0Mm4[10], Reserved7[6]; - UINT8 St0Mm5[10], Reserved8[6]; - UINT8 St0Mm6[10], Reserved9[6]; - UINT8 St0Mm7[10], Reserved10[6]; - UINT8 Reserved11[22 * 16]; -} EFI_FX_SAVE_STATE; -#endif typedef struct { UINT32 ExceptionData; -#if (EFI_SPECIFICATION_VERSION >= 0x00020000) EFI_FX_SAVE_STATE_IA32 FxSaveState; -#else - EFI_FX_SAVE_STATE FxSaveState; -#endif UINT32 Dr0; UINT32 Dr1; UINT32 Dr2; @@ -199,23 +182,10 @@ typedef struct { UINT8 Xmm5[16]; UINT8 Xmm6[16]; UINT8 Xmm7[16]; -#if (EFI_SPECIFICATION_VERSION >= 0x00020000) // - // NOTE: UEFI 2.0 spec definition as follows. It should be updated - // after spec update. + // NOTE: UEFI 2.0 spec definition as follows. // UINT8 Reserved11[14 * 16]; -#else - UINT8 Xmm8[16]; - UINT8 Xmm9[16]; - UINT8 Xmm10[16]; - UINT8 Xmm11[16]; - UINT8 Xmm12[16]; - UINT8 Xmm13[16]; - UINT8 Xmm14[16]; - UINT8 Xmm15[16]; - UINT8 Reserved10[6 * 16]; -#endif } EFI_FX_SAVE_STATE_X64; typedef struct { diff --git a/MdePkg/Include/Protocol/DevicePathUtilities.h b/MdePkg/Include/Protocol/DevicePathUtilities.h index 96b8368a32..3874d63491 100644 --- a/MdePkg/Include/Protocol/DevicePathUtilities.h +++ b/MdePkg/Include/Protocol/DevicePathUtilities.h @@ -32,7 +32,7 @@ @param DevicePath Points to the start of the EFI device path. - @revtal Size Size of the specified device path, in bytes, including the end-of-path tag. + @retval Size Size of the specified device path, in bytes, including the end-of-path tag. **/ typedef diff --git a/MdePkg/Include/Protocol/FirmwareVolume2.h b/MdePkg/Include/Protocol/FirmwareVolume2.h index cb76d9b079..66fa1e4a39 100644 --- a/MdePkg/Include/Protocol/FirmwareVolume2.h +++ b/MdePkg/Include/Protocol/FirmwareVolume2.h @@ -291,7 +291,7 @@ EFI_STATUS @retval EFI_OUT_OF_RESOURCES An allocation failure occurred. - @retavl EFI_NOT_FOUND Name was not found in the firmware + @retval EFI_NOT_FOUND Name was not found in the firmware volume. @retval EFI_DEVICE_ERROR A hardware error occurred when diff --git a/MdePkg/Include/Protocol/ManagedNetwork.h b/MdePkg/Include/Protocol/ManagedNetwork.h index fb6b43b1cd..45ff98270b 100644 --- a/MdePkg/Include/Protocol/ManagedNetwork.h +++ b/MdePkg/Include/Protocol/ManagedNetwork.h @@ -13,8 +13,8 @@ **/ -#ifndef _EFI_MANAGED_NETWORK_PROTOCOL_H -#define _EFI_MANAGED_NETWORK_PROTOCOL_H +#ifndef __EFI_MANAGED_NETWORK_PROTOCOL_H__ +#define __EFI_MANAGED_NETWORK_PROTOCOL_H__ #include diff --git a/MdePkg/Include/Protocol/UgaIo.h b/MdePkg/Include/Protocol/UgaIo.h index 5457920aec..19dee485f6 100644 --- a/MdePkg/Include/Protocol/UgaIo.h +++ b/MdePkg/Include/Protocol/UgaIo.h @@ -54,10 +54,6 @@ typedef struct _UGA_DEVICE { } UGA_DEVICE, *PUGA_DEVICE; -#ifndef UGA_IO_REQUEST_CODE -// -// Prevent conflicts with UGA typedefs. -// typedef enum { UgaIoGetVersion = 1, UgaIoGetChildDevice, @@ -85,8 +81,6 @@ typedef enum { } UGA_IO_REQUEST_CODE, *PUGA_IO_REQUEST_CODE; -#endif - typedef struct { IN UGA_IO_REQUEST_CODE ioRequestCode; IN VOID *pvInBuffer; @@ -146,32 +140,30 @@ EFI_STATUS IN UGA_DEVICE * Device ); - -typedef UGA_STATUS (EFIAPI *PUGA_FW_SERVICE_DISPATCH)(IN PUGA_DEVICE pDevice, IN OUT PUGA_IO_REQUEST pIoRequest); - /** + This is the main UGA service dispatch routine for all UGA_IO_REQUEST s. - Routine Description: - - This is the main UGA service dispatch routine for all UGA_IO_REQUEST s. - - Arguments: - - pDevice - pDevice specifies a pointer to a device object associated with a + @param pDevice pDevice specifies a pointer to a device object associated with a device enumerated by a pIoRequest->ioRequestCode of type UgaIoGetChildDevice. The root device for the EFI_UGA_IO_PROTOCOL is represented by pDevice being set to NULL. - pIoRequest - pIoRequest points to a caller allocated buffer that contains data + @param pIoRequest + pIoRequest points to a caller allocated buffer that contains data defined by pIoRequest->ioRequestCode. See Related Definitions for a definition of UGA_IO_REQUEST_CODE s and their associated data structures. - Returns: - - Varies depending on pIoRequest. + @return UGA_STATUS **/ +typedef UGA_STATUS +(EFIAPI *PUGA_FW_SERVICE_DISPATCH)( + IN PUGA_DEVICE pDevice, + IN OUT PUGA_IO_REQUEST pIoRequest + ); + + struct _EFI_UGA_IO_PROTOCOL { EFI_UGA_IO_PROTOCOL_CREATE_DEVICE CreateDevice; EFI_UGA_IO_PROTOCOL_DELETE_DEVICE DeleteDevice; diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c index 6d06c7e2a6..d46178dd25 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c @@ -544,11 +544,8 @@ PeCoffLoaderRelocateImage ( // if (ImageContext->DestinationAddress != 0) { BaseAddress = ImageContext->DestinationAddress; - } else if (!(ImageContext->IsTeImage)) { - BaseAddress = ImageContext->ImageAddress; } else { - Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); - BaseAddress = ImageContext->ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize; + BaseAddress = ImageContext->ImageAddress; } if (!(ImageContext->IsTeImage)) { @@ -597,8 +594,8 @@ PeCoffLoaderRelocateImage ( } } else { Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress); - Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase); - Hdr.Te->ImageBase = (UINT64) (BaseAddress); + Adjust = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->ImageBase); + Hdr.Te->ImageBase = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER)); // // Find the relocation block @@ -711,6 +708,13 @@ PeCoffLoaderRelocateImage ( RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; } + // + // Adjust the EntryPoint to match the linked-to address + // + if (ImageContext->DestinationAddress != 0) { + ImageContext->EntryPoint -= (UINT64) ImageContext->ImageAddress; + ImageContext->EntryPoint += (UINT64) ImageContext->DestinationAddress; + } return RETURN_SUCCESS; } -- 2.39.5