Add FvNameGuid for FV extension header.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7851 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2009-03-10 09:27:59 +00:00
parent 84266565f5
commit eb9203646f
3 changed files with 80 additions and 34 deletions

View File

@ -52,31 +52,55 @@ Revision History
ESAL_FWB_GLOBAL *mFvbModuleGlobal; ESAL_FWB_GLOBAL *mFvbModuleGlobal;
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = { FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
FVB_DEVICE_SIGNATURE,
{
{ {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_MEMMAP_DP, HW_MEMMAP_DP,
{ {
sizeof (MEMMAP_DEVICE_PATH), (UINT8)(sizeof (MEMMAP_DEVICE_PATH)),
0 (UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8)
} }
}, },
EfiMemoryMappedIO, EfiMemoryMappedIO,
0, (EFI_PHYSICAL_ADDRESS) 0,
0, (EFI_PHYSICAL_ADDRESS) 0,
}, },
{ {
END_DEVICE_PATH_TYPE, END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
{ {
sizeof (EFI_DEVICE_PATH_PROTOCOL), END_DEVICE_PATH_LENGTH,
0 0
} }
} }
};
FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
{
{
MEDIA_DEVICE_PATH,
MEDIA_PIWG_FW_VOL_DP,
{
(UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH)),
(UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH) >> 8)
}
}, },
{ 0 }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
};
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
FVB_DEVICE_SIGNATURE,
NULL,
0, 0,
{ {
FvbProtocolGetAttributes, FvbProtocolGetAttributes,
@ -1097,6 +1121,7 @@ Returns:
) { ) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Verify the header checksum // Verify the header checksum
// //
@ -1113,6 +1138,13 @@ Returns:
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
//
// PI specification defines the name guid of FV exists in extension header.
//
if (FwVolHeader->ExtHeaderOffset == 0) {
return EFI_NOT_FOUND;
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1143,8 +1175,6 @@ Returns:
EFI_HANDLE FwbHandle; EFI_HANDLE FwbHandle;
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface; EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
EFI_DEVICE_PATH_PROTOCOL *TempFwbDevicePath;
FV_DEVICE_PATH TempFvbDevicePathData;
UINT32 MaxLbaSize; UINT32 MaxLbaSize;
EFI_PHYSICAL_ADDRESS BaseAddress; EFI_PHYSICAL_ADDRESS BaseAddress;
UINT64 Length; UINT64 Length;
@ -1298,18 +1328,28 @@ Returns:
FvbDevice->Instance = mFvbModuleGlobal->NumFv; FvbDevice->Instance = mFvbModuleGlobal->NumFv;
mFvbModuleGlobal->NumFv++; mFvbModuleGlobal->NumFv++;
// //
// Set up the devicepath // Set up the devicepath
// //
FvbDevice->DevicePath.MemMapDevPath.StartingAddress = BaseAddress; if (FwVolHeader->ExtHeaderOffset == 0) {
FvbDevice->DevicePath.MemMapDevPath.EndingAddress = BaseAddress + (FwVolHeader->FvLength - 1); //
// FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
//
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.StartingAddress = BaseAddress;
((FV_MEMMAP_DEVICE_PATH *) FvbDevice->DevicePath)->MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1;
} else {
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
CopyGuid (
&((FV_PIWG_DEVICE_PATH *)FvbDevice->DevicePath)->FvDevPath.FvName,
(GUID *)(UINTN)(BaseAddress + FwVolHeader->ExtHeaderOffset)
);
}
// //
// Find a handle with a matching device path that has supports FW Block protocol // Find a handle with a matching device path that has supports FW Block protocol
// //
TempFwbDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) &TempFvbDevicePathData; Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &FvbDevice->DevicePath, &FwbHandle);
CopyMem (TempFwbDevicePath, &FvbDevice->DevicePath, sizeof (FV_DEVICE_PATH));
Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid, &TempFwbDevicePath, &FwbHandle);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// LocateDevicePath fails so install a new interface and device path // LocateDevicePath fails so install a new interface and device path
@ -1324,7 +1364,7 @@ Returns:
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} else if (IsDevicePathEnd (TempFwbDevicePath)) { } else if (IsDevicePathEnd (FvbDevice->DevicePath)) {
// //
// Device allready exists, so reinstall the FVB protocol // Device allready exists, so reinstall the FVB protocol
// //

View File

@ -48,14 +48,19 @@ typedef struct {
#define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE) #define FVB_EXTEND_DEVICE_FROM_THIS(a) CR (a, EFI_FW_VOL_BLOCK_DEVICE, FvbExtension, FVB_DEVICE_SIGNATURE)
#define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N') #define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'N')
typedef struct {
MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
EFI_DEVICE_PATH_PROTOCOL EndDevPath;
} FV_PIWG_DEVICE_PATH;
typedef struct { typedef struct {
MEMMAP_DEVICE_PATH MemMapDevPath; MEMMAP_DEVICE_PATH MemMapDevPath;
EFI_DEVICE_PATH_PROTOCOL EndDevPath; EFI_DEVICE_PATH_PROTOCOL EndDevPath;
} FV_DEVICE_PATH; } FV_MEMMAP_DEVICE_PATH;
typedef struct { typedef struct {
UINTN Signature; UINTN Signature;
FV_DEVICE_PATH DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN Instance; UINTN Instance;
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
} EFI_FW_VOL_BLOCK_DEVICE; } EFI_FW_VOL_BLOCK_DEVICE;

View File

@ -133,6 +133,7 @@ READ_ENABLED_CAP = TRUE
READ_STATUS = TRUE READ_STATUS = TRUE
READ_LOCK_CAP = TRUE READ_LOCK_CAP = TRUE
READ_LOCK_STATUS = TRUE READ_LOCK_STATUS = TRUE
FvNameGuid = 6D99E806-3D38-42c2-A095-5F4300BFD7DC
################################################################################ ################################################################################
# #