summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Compatibility
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-18 14:20:01 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-18 14:20:01 +0000
commit19caab516dfb4627be539f1d9aa3158f721b6530 (patch)
treefff76b6148c9c4f27774b6adaa54042ec07fefd0 /EdkCompatibilityPkg/Compatibility
parent9e99ce325a97c4b6d7f5aaaa48b7087b131c4272 (diff)
downloadedk2-platforms-19caab516dfb4627be539f1d9aa3158f721b6530.tar.xz
1) Covert the FvAttributes back to format defined in Framework spec after calling the PI FV Protocol. This behavior is defined in Framework spec.
2) Set the EFI_FV_FILE_ATTRIB_MEMORY_MAPPED before calling PI FV Protocol->WriteFile interface. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6612 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FvToFv2Thunk/FvToFv2Thunk.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FvToFv2Thunk/FvToFv2Thunk.c b/EdkCompatibilityPkg/Compatibility/FvToFv2Thunk/FvToFv2Thunk.c
index ca23c1634d..803bc2c9fe 100644
--- a/EdkCompatibilityPkg/Compatibility/FvToFv2Thunk/FvToFv2Thunk.c
+++ b/EdkCompatibilityPkg/Compatibility/FvToFv2Thunk/FvToFv2Thunk.c
@@ -345,6 +345,17 @@ InitializeFirmwareVolume2 (
return EFI_SUCCESS;
}
+FRAMEWORK_EFI_FV_ATTRIBUTES
+Fv2AttributesToFvAttributes (
+ EFI_FV_ATTRIBUTES Fv2Attributes
+ )
+{
+ //
+ // Clear those filed that is not defined in Framework FV spec and Alignment conversion.
+ //
+ return (Fv2Attributes & 0x1ff) | ((UINTN) EFI_FV_ALIGNMENT_2 << RShiftU64((Fv2Attributes & EFI_FV2_ALIGNMENT), 16));
+}
+
/**
Retrieves attributes, insures positive polarity of attribute bits, returns
resulting attributes in output parameter
@@ -375,7 +386,7 @@ FvGetVolumeAttributes (
Attributes
);
if (!EFI_ERROR (Status)) {
- *Attributes = (*Attributes & 0x1ff) | ((UINTN)EFI_FV_ALIGNMENT_2 << RShiftU64((*Attributes & EFI_FV2_ALIGNMENT), 16));
+ *Attributes = Fv2AttributesToFvAttributes (*Attributes);
}
return Status;
}
@@ -400,21 +411,21 @@ FvSetVolumeAttributes (
{
FIRMWARE_VOLUME_PRIVATE_DATA *Private;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;
- INTN Alignment;
EFI_FV_ATTRIBUTES Fv2Attributes;
+ EFI_STATUS Status;
Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);
FirmwareVolume2 = Private->FirmwareVolume2;
Fv2Attributes = (*Attributes & 0x1ff);
- Alignment = LowBitSet64 (RShiftU64 (*Attributes, 16) & 0xffff);
- if (Alignment != -1) {
- Fv2Attributes |= LShiftU64 (Alignment, 16);
- }
- return FirmwareVolume2->SetVolumeAttributes (
+ Status = FirmwareVolume2->SetVolumeAttributes (
FirmwareVolume2,
&Fv2Attributes
);
+
+ *Attributes = Fv2AttributesToFvAttributes (Fv2Attributes);
+
+ return Status;
}
/**
@@ -459,11 +470,12 @@ FvReadFile (
{
FIRMWARE_VOLUME_PRIVATE_DATA *Private;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;
+ EFI_STATUS Status;
Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);
FirmwareVolume2 = Private->FirmwareVolume2;
- return FirmwareVolume2->ReadFile (
+ Status = FirmwareVolume2->ReadFile (
FirmwareVolume2,
NameGuid,
Buffer,
@@ -472,6 +484,13 @@ FvReadFile (
FileAttributes,
AuthenticationStatus
);
+
+ //
+ // For Framework FV attrbutes, only alignment fields are valid.
+ //
+ *FileAttributes = *FileAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;
+
+ return Status;
}
/**
@@ -562,16 +581,31 @@ FvWriteFile (
{
FIRMWARE_VOLUME_PRIVATE_DATA *Private;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;
+ EFI_FV_WRITE_FILE_DATA *PiFileData;
+ EFI_STATUS Status;
+ UINTN Index;
Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);
FirmwareVolume2 = Private->FirmwareVolume2;
- return FirmwareVolume2->WriteFile (
+ PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData);
+
+ //
+ // Framework Spec assume firmware files are Memory-Mapped.
+ //
+ for (Index = 0; Index < NumberOfFiles; Index++) {
+ PiFileData[Index].FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;
+ }
+
+ Status = FirmwareVolume2->WriteFile (
FirmwareVolume2,
NumberOfFiles,
WritePolicy,
(EFI_FV_WRITE_FILE_DATA *)FileData
);
+
+ FreePool (PiFileData);
+ return Status;
}
/**
@@ -605,11 +639,12 @@ FvGetNextFile (
{
FIRMWARE_VOLUME_PRIVATE_DATA *Private;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;
+ EFI_STATUS Status;
Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);
FirmwareVolume2 = Private->FirmwareVolume2;
- return FirmwareVolume2->GetNextFile (
+ Status = FirmwareVolume2->GetNextFile (
FirmwareVolume2,
Key,
FileType,
@@ -617,4 +652,11 @@ FvGetNextFile (
Attributes,
Size
);
+
+ //
+ // For Framework FV attrbutes, only alignment fields are valid.
+ //
+ *Attributes = *Attributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;
+
+ return Status;
}