summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-09 07:26:24 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-09 07:26:24 +0000
commitcfe9de52447337bd470bd831080f5671ed979fe6 (patch)
tree2ddccdf22e0ac37e9308d4a87bca04623c01c7f2
parent189575e88b25f8b4debd08f03a0a30243faac3df (diff)
downloadedk2-cfe9de52447337bd470bd831080f5671ed979fe6.zip
edk2-cfe9de52447337bd470bd831080f5671ed979fe6.tar.gz
edk2-cfe9de52447337bd470bd831080f5671ed979fe6.tar.bz2
1. CoreOpenImageFile(): FilePath should be IN OUT.
2. Use offset address to build device path instead of absolute address. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4294 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c40
-rw-r--r--MdeModulePkg/Core/Dxe/Image.h2
-rw-r--r--MdeModulePkg/Core/Dxe/Image/Image.c3
-rw-r--r--MdeModulePkg/Core/Dxe/Image/ImageFile.c102
4 files changed, 74 insertions, 73 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
index 99c34d5..c3f31be 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c
@@ -1,13 +1,13 @@
/**@file
-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.
+Copyright (c) 2006 - 2007, 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.
**/
@@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Module global for a template of the PCI option ROM Image Device Path Node
//
MEMMAP_DEVICE_PATH mPciOptionRomImageDevicePathNodeTemplate = {
- {
+ {
HARDWARE_DEVICE_PATH,
HW_MEMMAP_DP,
sizeof (MEMMAP_DEVICE_PATH)
@@ -133,7 +133,7 @@ LoadOpRomImage (
/*++
Routine Description:
-
+
Load option rom image for specified PCI device
Arguments:
@@ -265,7 +265,7 @@ Returns:
gBS->FreePool (RomPcir);
return EFI_OUT_OF_RESOURCES;
}
-
+
//
// Copy Rom image into memory
//
@@ -337,7 +337,7 @@ Returns:
for (Offset = 0x10; Offset <= 0x24; Offset += sizeof (UINT32)) {
PciIoWrite (PciIo, EfiPciIoWidthUint32, Offset, 1, &gAllZero);
}
-
+
//
// set the Rom base address: now is hardcode
// enable its decoder
@@ -362,7 +362,7 @@ Returns:
PciEnableCommandRegister(PciDevice, EFI_PCI_COMMAND_MEMORY_SPACE);
} else {
-
+
//
// disable command register decode to memory
//
@@ -400,14 +400,14 @@ ProcessOpRomImage (
Routine Description:
Process the oprom image.
-
+
Arguments:
PciDevice A pointer to a pci device.
Returns:
EFI Status.
-
+
--*/
{
UINT8 Indicator;
@@ -457,7 +457,7 @@ Returns:
ImageSize = (UINT32) (Pcir->ImageLength * 512);
Indicator = Pcir->Indicator;
- if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
+ if ((Pcir->CodeType == PCI_CODE_TYPE_EFI_IMAGE) &&
(EfiRomHeader->EfiSignature == EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE)) {
if ((EfiRomHeader->EfiSubsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
@@ -520,11 +520,11 @@ Returns:
}
if (!SkipImage) {
- //
- // Build full device path to the PCI Option ROM Image being loaded
//
- mPciOptionRomImageDevicePathNodeTemplate.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)RomBarOffset;
- mPciOptionRomImageDevicePathNodeTemplate.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(RomBarOffset + ImageSize - 1);
+ // Build Memory Mapped device path node to record the image offset into the PCI Option ROM
+ //
+ mPciOptionRomImageDevicePathNodeTemplate.StartingAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (RomBarOffset - (UINT8 *) RomBar);
+ mPciOptionRomImageDevicePathNodeTemplate.EndingAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (RomBarOffset + ImageSize - 1 - (UINT8 *) RomBar);
PciOptionRomImageDevicePath = AppendDevicePathNode (PciDevice->DevicePath, (const EFI_DEVICE_PATH_PROTOCOL *)&mPciOptionRomImageDevicePathNodeTemplate);
ASSERT (PciOptionRomImageDevicePath != NULL);
diff --git a/MdeModulePkg/Core/Dxe/Image.h b/MdeModulePkg/Core/Dxe/Image.h
index 8d57de0..13936a5 100644
--- a/MdeModulePkg/Core/Dxe/Image.h
+++ b/MdeModulePkg/Core/Dxe/Image.h
@@ -100,7 +100,7 @@ CoreOpenImageFile (
IN BOOLEAN BootPolicy,
IN VOID *SourceBuffer OPTIONAL,
IN UINTN SourceSize,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
OUT EFI_HANDLE *DeviceHandle,
IN IMAGE_FILE_HANDLE *ImageFileHandle,
OUT UINT32 *AuthenticationStatus
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 99170dc..e38dfae 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -639,7 +639,7 @@ Returns:
BootPolicy,
SourceBuffer,
SourceSize,
- FilePath,
+ &FilePath,
&DeviceHandle,
&FHand,
&AuthenticationStatus
@@ -679,6 +679,7 @@ Returns:
//
// Pull out just the file portion of the DevicePath for the LoadedImage FilePath
//
+ FilePath = OriginalFilePath;
Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);
if (!EFI_ERROR (Status)) {
FilePathSize = CoreDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
diff --git a/MdeModulePkg/Core/Dxe/Image/ImageFile.c b/MdeModulePkg/Core/Dxe/Image/ImageFile.c
index 31b1443..5d8293a 100644
--- a/MdeModulePkg/Core/Dxe/Image/ImageFile.c
+++ b/MdeModulePkg/Core/Dxe/Image/ImageFile.c
@@ -1,22 +1,22 @@
/*++
-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.
+Copyright (c) 2006 - 2007, 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.
Module Name:
-
+
ImageFile.c
Abstract:
-
+
Revision History
@@ -30,7 +30,7 @@ CoreOpenImageFile (
IN BOOLEAN BootPolicy,
IN VOID *SourceBuffer OPTIONAL,
IN UINTN SourceSize,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
OUT EFI_HANDLE *DeviceHandle,
IN IMAGE_FILE_HANDLE *ImageFileHandle,
OUT UINT32 *AuthenticationStatus
@@ -52,16 +52,16 @@ Arguments:
FilePath - The specific file path from which the image is loaded
DeviceHandle - Pointer to the return device handle.
ImageFileHandle - Pointer to the image file handle.
- AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.
-
+ AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.
+
Returns:
EFI_SUCCESS - Image file successfully opened.
-
+
EFI_LOAD_ERROR - If the caller passed a copy of the file, and SourceSize is 0.
-
+
EFI_INVALID_PARAMETER - File path is not valid.
-
+
EFI_NOT_FOUND - File not found.
--*/
@@ -95,7 +95,7 @@ Returns:
ImageFileHandle->Source = SourceBuffer;
ImageFileHandle->SourceSize = SourceSize;
*DeviceHandle = NULL;
- CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, &FilePath, DeviceHandle);
+ CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, FilePath, DeviceHandle);
if (SourceSize > 0) {
Status = EFI_SUCCESS;
} else {
@@ -107,18 +107,18 @@ Returns:
//
// Make sure FilePath is valid
//
- if (FilePath == NULL) {
+ if (*FilePath == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Check to see if it's in a Firmware Volume
//
- FwVolFilePathNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)FilePath;
+ FwVolFilePathNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) *FilePath;
Status = CoreDevicePathToInterface (
- &gEfiFirmwareVolume2ProtocolGuid,
- (EFI_DEVICE_PATH_PROTOCOL **)&FwVolFilePathNode,
- (VOID*)&FwVol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (EFI_DEVICE_PATH_PROTOCOL **)&FwVolFilePathNode,
+ (VOID*)&FwVol,
DeviceHandle
);
if (!EFI_ERROR (Status)) {
@@ -131,9 +131,9 @@ Returns:
SectionType = EFI_SECTION_PE32;
Pe32Buffer = NULL;
Status = FwVol->ReadSection (
- FwVol,
- NameGuid,
- SectionType,
+ FwVol,
+ NameGuid,
+ SectionType,
0,
(VOID **)&Pe32Buffer,
&Pe32BufferSize,
@@ -149,8 +149,8 @@ Returns:
}
Pe32Buffer = NULL;
Status = FwVol->ReadFile (
- FwVol,
- NameGuid,
+ FwVol,
+ NameGuid,
(VOID **)&Pe32Buffer,
&Pe32BufferSize,
&Type,
@@ -158,7 +158,7 @@ Returns:
AuthenticationStatus
);
}
-
+
if (!EFI_ERROR (Status)) {
//
// One of the reads passed so we are done
@@ -174,11 +174,11 @@ Returns:
//
// Attempt to access the file via a file system interface
//
- FilePathNode = (FILEPATH_DEVICE_PATH *) FilePath;
+ FilePathNode = (FILEPATH_DEVICE_PATH *) *FilePath;
Status = CoreDevicePathToInterface (
- &gEfiSimpleFileSystemProtocolGuid,
- (EFI_DEVICE_PATH_PROTOCOL **)&FilePathNode,
- (VOID*)&Volume,
+ &gEfiSimpleFileSystemProtocolGuid,
+ (EFI_DEVICE_PATH_PROTOCOL **)&FilePathNode,
+ (VOID*)&Volume,
DeviceHandle
);
if (!EFI_ERROR (Status)) {
@@ -187,7 +187,7 @@ Returns:
//
Status = Volume->OpenVolume (Volume, &FileHandle);
if (!EFI_ERROR (Status)) {
-
+
//
// Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the
// directory information and filename can be seperate. The goal is to inch
@@ -239,7 +239,7 @@ Returns:
FileHandle,
&gEfiFileInfoGuid,
&FileInfoSize,
- FileInfo
+ FileInfo
);
}
if (!EFI_ERROR (Status)) {
@@ -267,14 +267,14 @@ Returns:
}
}
}
- }
+ }
//
// Try LoadFile style
//
- TempFilePath = FilePath;
+ TempFilePath = *FilePath;
Status = CoreDevicePathToInterface (
&gEfiLoadFileProtocolGuid,
&TempFilePath,
@@ -350,12 +350,12 @@ Routine Description:
Arguments:
UserHandle - Image file handle
-
+
Offset - Offset to the source file
-
+
ReadSize - For input, pointer of size to read;
For output, pointer of size actually read.
-
+
Buffer - Buffer to write into
Returns:
@@ -376,7 +376,7 @@ Returns:
EndPosition = Offset + *ReadSize;
if (EndPosition > FHand->SourceSize) {
*ReadSize = (UINT32)(FHand->SourceSize - Offset);
- }
+ }
if (Offset >= FHand->SourceSize) {
*ReadSize = 0;
}
@@ -402,13 +402,13 @@ Routine Description:
Arguments:
Protocol - The protocol to search for
-
+
FilePath - The specified device path
-
+
Interface - Interface of the protocol on the handle
-
+
Handle - The handle to the device on the specified device path that supports the protocol.
-
+
Returns:
Status code.
@@ -435,7 +435,7 @@ CoreGrowBuffer (
Routine Description:
Helper function called as part of the code needed
- to allocate the proper sized buffer for various
+ to allocate the proper sized buffer for various
EFI interfaces.
Arguments:
@@ -445,10 +445,10 @@ Arguments:
Buffer - Current allocated buffer, or NULL
BufferSize - Current buffer size needed
-
+
Returns:
-
- TRUE - if the buffer was reallocated and the caller
+
+ TRUE - if the buffer was reallocated and the caller
should try the API again.
FALSE - buffer could not be allocated and the caller
@@ -473,7 +473,7 @@ Returns:
//
// If the status code is "buffer too small", resize the buffer
//
-
+
if (*Status == EFI_BUFFER_TOO_SMALL) {
if (*Buffer != NULL) {
CoreFreePool (*Buffer);
@@ -482,9 +482,9 @@ Returns:
*Buffer = CoreAllocateBootServicesPool (BufferSize);
if (*Buffer != NULL) {
TryAgain = TRUE;
- } else {
+ } else {
*Status = EFI_OUT_OF_RESOURCES;
- }
+ }
}
//