--- /dev/null
+/** @file\r
+UEFI PI specification supersedes Inte's Framework Specification.\r
+EFI_FIRMWARE_VOLUME_PROTOCOL defined in Intel Framework Pkg is replaced by\r
+EFI_FIRMWARE_VOLUME2_PROTOCOL in MdePkg.\r
+This module produces FV on top of FV2. This module is used on platform when both of\r
+these two conditions are true:\r
+1) Framework module consuming FV is present\r
+2) And the platform only produces FV2\r
+\r
+Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Module Name:\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
+#include <Protocol/FirmwareVolume.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+/**\r
+ Retrieves attributes, insures positive polarity of attribute bits, returns\r
+ resulting attributes in output parameter\r
+\r
+ @param This Calling context\r
+ @param Attributes output buffer which contains attributes\r
+\r
+ @retval EFI_INVALID_PARAMETER\r
+ @retval EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvGetVolumeAttributes (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
+ );\r
+\r
+/**\r
+ Sets volume attributes\r
+\r
+ @param This Calling context\r
+ @param Attributes Buffer which contains attributes\r
+\r
+ @retval EFI_INVALID_PARAMETER\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvSetVolumeAttributes (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
+ );\r
+\r
+/**\r
+ Read the requested file (NameGuid) and returns data in Buffer.\r
+\r
+ @param This Calling context\r
+ @param NameGuid Filename identifying which file to read\r
+ @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
+ <br>\r
+ If Buffer is NULL, only type, attributes, and size are returned as\r
+ there is no output buffer.\r
+ <br>\r
+ If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
+ from BS pool by ReadFile\r
+ <br>\r
+ If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
+ allocated by the caller and is being passed in.\r
+ @param BufferSize Indicates the buffer size passed in, and on output the size\r
+ required to complete the read\r
+ @param FoundType Indicates the type of the file who's data is returned\r
+ @param FileAttributes Indicates the attributes of the file who's data is resturned\r
+ @param AuthenticationStatus Indicates the authentication status of the data\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_WARN_BUFFER_TOO_SMALL\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_ACCESS_DENIED\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvReadFile (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN EFI_GUID *NameGuid,\r
+ IN OUT VOID **Buffer,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT EFI_FV_FILETYPE *FoundType,\r
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
+ OUT UINT32 *AuthenticationStatus\r
+ );\r
+\r
+/**\r
+ Read the requested section from the specified file and returns data in Buffer.\r
+\r
+ @param This Calling context\r
+ @param NameGuid Filename identifying the file from which to read\r
+ @param SectionType Indicates what section type to retrieve\r
+ @param SectionInstance Indicates which instance of SectionType to retrieve\r
+ @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
+ <br>\r
+ If Buffer is NULL, only type, attributes, and size are returned as\r
+ there is no output buffer.\r
+ <br>\r
+ If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
+ from BS pool by ReadFile\r
+ <br>\r
+ If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
+ allocated by the caller and is being passed in.\r
+ @param BufferSize Indicates the buffer size passed in, and on output the size\r
+ required to complete the read\r
+ @param AuthenticationStatus Indicates the authentication status of the data\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_WARN_BUFFER_TOO_SMALL\r
+ @retval EFI_OUT_OF_RESOURCES\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_ACCESS_DENIED\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FvReadSection (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN EFI_GUID *NameGuid,\r
+ IN EFI_SECTION_TYPE SectionType,\r
+ IN UINTN SectionInstance,\r
+ IN OUT VOID **Buffer,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT UINT32 *AuthenticationStatus\r
+ );\r
+\r
+/**\r
+ Write the supplied file (NameGuid) to the FV.\r
+\r
+ @param This Calling context\r
+ @param NumberOfFiles Indicates the number of file records pointed to by FileData\r
+ @param WritePolicy Indicates the level of reliability of the write with respect to\r
+ things like power failure events.\r
+ @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA structures. Each\r
+ element in the array indicates a file to write, and there are\r
+ NumberOfFiles elements in the input array.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_OUT_OF_RESOURCES\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_WRITE_PROTECTED\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_INVALID_PARAMETER\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FvWriteFile (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN UINT32 NumberOfFiles,\r
+ IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,\r
+ IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData\r
+ );\r
+\r
+/**\r
+ Given the input key, search for the next matching file in the volume.\r
+\r
+ @param This Calling context\r
+ @param Key Pointer to a caller allocated buffer that contains an implementation\r
+ specific key that is used to track where to begin searching on\r
+ successive calls.\r
+ @param FileType Indicates the file type to filter for\r
+ @param NameGuid Guid filename of the file found\r
+ @param Attributes Attributes of the file found\r
+ @param Size Size in bytes of the file found\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_ACCESS_DENIED\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FvGetNextFile (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN OUT VOID *Key,\r
+ IN OUT EFI_FV_FILETYPE *FileType,\r
+ OUT EFI_GUID *NameGuid,\r
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
+ OUT UINTN *Size\r
+ );\r
+\r
+#define FIRMWARE_VOLUME_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f', 'v', 't', 'h')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_FIRMWARE_VOLUME_PROTOCOL FirmwareVolume;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+} FIRMWARE_VOLUME_PRIVATE_DATA;\r
+\r
+#define FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS(a) CR (a, FIRMWARE_VOLUME_PRIVATE_DATA, FirmwareVolume, FIRMWARE_VOLUME_PRIVATE_DATA_SIGNATURE)\r
+\r
+//\r
+// Firmware Volume Protocol template\r
+//\r
+EFI_EVENT mFvRegistration;\r
+\r
+FIRMWARE_VOLUME_PRIVATE_DATA gFirmwareVolumePrivateDataTemplate = {\r
+ FIRMWARE_VOLUME_PRIVATE_DATA_SIGNATURE,\r
+ {\r
+ FvGetVolumeAttributes,\r
+ FvSetVolumeAttributes,\r
+ FvReadFile,\r
+ FvReadSection,\r
+ FvWriteFile,\r
+ FvGetNextFile,\r
+ 0,\r
+ NULL\r
+ },\r
+ NULL\r
+};\r
+\r
+//\r
+// Module globals\r
+//\r
+\r
+VOID\r
+EFIAPI\r
+FvNotificationEvent (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN BufferSize;\r
+ EFI_HANDLE Handle;\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r
+\r
+ while (TRUE) {\r
+ BufferSize = sizeof (Handle);\r
+ Status = gBS->LocateHandle (\r
+ ByRegisterNotify,\r
+ &gEfiFirmwareVolume2ProtocolGuid,\r
+ mFvRegistration,\r
+ &BufferSize,\r
+ &Handle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Exit Path of While Loop....\r
+ //\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Skip this handle if the Firmware Volume Protocol is already installed\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiFirmwareVolumeProtocolGuid,\r
+ (VOID **)&FirmwareVolume\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // Allocate private data structure\r
+ //\r
+ Private = AllocateCopyPool (sizeof (FIRMWARE_VOLUME_PRIVATE_DATA), &gFirmwareVolumePrivateDataTemplate);\r
+ if (Private == NULL) {\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // Retrieve the Firmware Volume2 Protocol\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ Handle,\r
+ &gEfiFirmwareVolume2ProtocolGuid,\r
+ (VOID **)&Private->FirmwareVolume2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Fill in rest of private data structure\r
+ //\r
+ Private->FirmwareVolume.KeySize = Private->FirmwareVolume2->KeySize;\r
+ Private->FirmwareVolume.ParentHandle = Private->FirmwareVolume2->ParentHandle;\r
+\r
+ //\r
+ // Install Firmware Volume Protocol onto same handle\r
+ //\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Handle,\r
+ &gEfiFirmwareVolumeProtocolGuid,\r
+ &Private->FirmwareVolume,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+}\r
+\r
+\r
+/**\r
+ The user Entry Point for DXE driver. The user code starts with this function\r
+ as the real entry point for the image goes into a library that calls this \r
+ function.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeFirmwareVolume2 (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EfiCreateProtocolNotifyEvent (\r
+ &gEfiFirmwareVolume2ProtocolGuid,\r
+ TPL_CALLBACK,\r
+ FvNotificationEvent,\r
+ NULL,\r
+ &mFvRegistration\r
+ );\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Convert FV attrbiutes to FV2 attributes.\r
+\r
+ @param Fv2Attributes FV2 attributes.\r
+\r
+ @return FV attributes.\r
+\r
+**/\r
+FRAMEWORK_EFI_FV_ATTRIBUTES\r
+Fv2AttributesToFvAttributes (\r
+ IN EFI_FV_ATTRIBUTES Fv2Attributes\r
+ )\r
+{\r
+ //\r
+ // Clear those filed that is not defined in Framework FV spec and Alignment conversion.\r
+ //\r
+ return (Fv2Attributes & 0x1ff) | ((UINTN) EFI_FV_ALIGNMENT_2 << RShiftU64((Fv2Attributes & EFI_FV2_ALIGNMENT), 16));\r
+}\r
+\r
+/**\r
+ Retrieves attributes, insures positive polarity of attribute bits, returns\r
+ resulting attributes in output parameter\r
+\r
+ @param This Calling context\r
+ @param Attributes output buffer which contains attributes\r
+\r
+ @retval EFI_INVALID_PARAMETER\r
+ @retval EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvGetVolumeAttributes (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+\r
+ Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+ FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+ Status = FirmwareVolume2->GetVolumeAttributes (\r
+ FirmwareVolume2,\r
+ Attributes\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ *Attributes = Fv2AttributesToFvAttributes (*Attributes);\r
+ }\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Sets volume attributes\r
+\r
+ @param This Calling context\r
+ @param Attributes Buffer which contains attributes\r
+\r
+ @retval EFI_INVALID_PARAMETER\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_SUCCESS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvSetVolumeAttributes (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
+ )\r
+{\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+ EFI_FV_ATTRIBUTES Fv2Attributes; \r
+ EFI_STATUS Status;\r
+\r
+ Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+ FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+ Fv2Attributes = (*Attributes & 0x1ff);\r
+ Status = FirmwareVolume2->SetVolumeAttributes (\r
+ FirmwareVolume2,\r
+ &Fv2Attributes\r
+ );\r
+\r
+ *Attributes = Fv2AttributesToFvAttributes (Fv2Attributes);\r
+ \r
+ return Status;\r
+}\r
+\r
+/**\r
+ Read the requested file (NameGuid) and returns data in Buffer.\r
+\r
+ @param This Calling context\r
+ @param NameGuid Filename identifying which file to read\r
+ @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
+ <br>\r
+ If Buffer is NULL, only type, attributes, and size are returned as\r
+ there is no output buffer.\r
+ <br>\r
+ If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
+ from BS pool by ReadFile\r
+ <br>\r
+ If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
+ allocated by the caller and is being passed in.\r
+ @param BufferSize Indicates the buffer size passed in, and on output the size\r
+ required to complete the read\r
+ @param FoundType Indicates the type of the file who's data is returned\r
+ @param FileAttributes Indicates the attributes of the file who's data is resturned\r
+ @param AuthenticationStatus Indicates the authentication status of the data\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_WARN_BUFFER_TOO_SMALL\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_ACCESS_DENIED\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FvReadFile (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN EFI_GUID *NameGuid,\r
+ IN OUT VOID **Buffer,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT EFI_FV_FILETYPE *FoundType,\r
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
+ OUT UINT32 *AuthenticationStatus\r
+ )\r
+{\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+ EFI_STATUS Status;\r
+\r
+ Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+ FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+ Status = FirmwareVolume2->ReadFile (\r
+ FirmwareVolume2,\r
+ NameGuid,\r
+ Buffer,\r
+ BufferSize,\r
+ FoundType,\r
+ FileAttributes,\r
+ AuthenticationStatus\r
+ );\r
+\r
+ //\r
+ // For Framework FV attrbutes, only alignment fields are valid.\r
+ //\r
+ *FileAttributes = *FileAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;\r
+ \r
+ return Status;\r
+}\r
+\r
+/**\r
+ Read the requested section from the specified file and returns data in Buffer.\r
+\r
+ @param This Calling context\r
+ @param NameGuid Filename identifying the file from which to read\r
+ @param SectionType Indicates what section type to retrieve\r
+ @param SectionInstance Indicates which instance of SectionType to retrieve\r
+ @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
+ <br>\r
+ If Buffer is NULL, only type, attributes, and size are returned as\r
+ there is no output buffer.\r
+ <br>\r
+ If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
+ from BS pool by ReadFile\r
+ <br>\r
+ If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
+ allocated by the caller and is being passed in.\r
+ @param BufferSize Indicates the buffer size passed in, and on output the size\r
+ required to complete the read\r
+ @param AuthenticationStatus Indicates the authentication status of the data\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_WARN_BUFFER_TOO_SMALL\r
+ @retval EFI_OUT_OF_RESOURCES\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_ACCESS_DENIED\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FvReadSection (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN EFI_GUID *NameGuid,\r
+ IN EFI_SECTION_TYPE SectionType,\r
+ IN UINTN SectionInstance,\r
+ IN OUT VOID **Buffer,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT UINT32 *AuthenticationStatus\r
+ )\r
+{\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+\r
+ Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+ FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+ return FirmwareVolume2->ReadSection (\r
+ FirmwareVolume2,\r
+ NameGuid,\r
+ SectionType,\r
+ SectionInstance,\r
+ Buffer,\r
+ BufferSize,\r
+ AuthenticationStatus\r
+ );\r
+}\r
+\r
+/**\r
+ Write the supplied file (NameGuid) to the FV.\r
+\r
+ @param This Calling context\r
+ @param NumberOfFiles Indicates the number of file records pointed to by FileData\r
+ @param WritePolicy Indicates the level of reliability of the write with respect to\r
+ things like power failure events.\r
+ @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA structures. Each\r
+ element in the array indicates a file to write, and there are\r
+ NumberOfFiles elements in the input array.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_OUT_OF_RESOURCES\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_WRITE_PROTECTED\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_INVALID_PARAMETER\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FvWriteFile (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN UINT32 NumberOfFiles,\r
+ IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,\r
+ IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData\r
+ )\r
+{\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+ EFI_FV_WRITE_FILE_DATA *PiFileData;\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+\r
+ Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+ FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+ PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData);\r
+\r
+ //\r
+ // Framework Spec assume firmware files are Memory-Mapped.\r
+ //\r
+ for (Index = 0; Index < NumberOfFiles; Index++) {\r
+ PiFileData[Index].FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
+ }\r
+\r
+ Status = FirmwareVolume2->WriteFile (\r
+ FirmwareVolume2,\r
+ NumberOfFiles,\r
+ WritePolicy,\r
+ (EFI_FV_WRITE_FILE_DATA *)FileData\r
+ );\r
+\r
+ FreePool (PiFileData);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Given the input key, search for the next matching file in the volume.\r
+\r
+ @param This Calling context\r
+ @param Key Pointer to a caller allocated buffer that contains an implementation\r
+ specific key that is used to track where to begin searching on\r
+ successive calls.\r
+ @param FileType Indicates the file type to filter for\r
+ @param NameGuid Guid filename of the file found\r
+ @param Attributes Attributes of the file found\r
+ @param Size Size in bytes of the file found\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_NOT_FOUND\r
+ @retval EFI_DEVICE_ERROR\r
+ @retval EFI_ACCESS_DENIED\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+FvGetNextFile (\r
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
+ IN OUT VOID *Key,\r
+ IN OUT EFI_FV_FILETYPE *FileType,\r
+ OUT EFI_GUID *NameGuid,\r
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
+ OUT UINTN *Size\r
+ )\r
+{\r
+ FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
+ EFI_STATUS Status;\r
+\r
+ Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+ FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+ Status = FirmwareVolume2->GetNextFile (\r
+ FirmwareVolume2,\r
+ Key,\r
+ FileType,\r
+ NameGuid,\r
+ Attributes,\r
+ Size\r
+ );\r
+\r
+ //\r
+ // For Framework FV attrbutes, only alignment fields are valid.\r
+ //\r
+ *Attributes = *Attributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;\r
+ \r
+ return Status;\r
+}\r
--- /dev/null
+#/** @file\r
+# Module produce FV on top of FV2.\r
+#\r
+# UEFI PI specification supersedes Inte's Framework Specification.\r
+# EFI_FIRMWARE_VOLUME_PROTOCOL defined in Intel Framework Pkg is replaced by\r
+# EFI_FIRMWARE_VOLUME2_PROTOCOL in MdePkg.\r
+# This module produces FV on top of FV2. This module is used on platform when both of\r
+# these two conditions are true:\r
+# 1) Framework module consuming FV is present\r
+# 2) And the platform only produces FV2\r
+#\r
+# Copyright (c) 2006 - 2008, Intel Corporation\r
+#\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#\r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = FvOnFv2Thunk\r
+ FILE_GUID = 5007A40E-A5E0-44f7-86AE-662F9A91DA26\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ EDK_RELEASE_VERSION = 0x00020000\r
+ EFI_SPECIFICATION_VERSION = 0x00020000\r
+ ENTRY_POINT = InitializeFirmwareVolume2\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources.common]\r
+ FvOnFv2Thunk.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+ UefiDriverEntryPoint\r
+ UefiBootServicesTableLib\r
+ BaseLib\r
+ DebugLib\r
+ UefiLib\r
+ MemoryAllocationLib\r
+\r
+[Protocols]\r
+ gEfiFirmwareVolume2ProtocolGuid\r
+ gEfiFirmwareVolumeProtocolGuid\r
+\r
+[Depex]\r
+ TRUE\r
+++ /dev/null
-/** @file\r
-UEFI PI specification supersedes Inte's Framework Specification.\r
-EFI_FIRMWARE_VOLUME_PROTOCOL defined in Intel Framework Pkg is replaced by\r
-EFI_FIRMWARE_VOLUME2_PROTOCOL in MdePkg.\r
-This module produces FV on top of FV2. This module is used on platform when both of\r
-these two conditions are true:\r
-1) Framework module consuming FV is present\r
-2) And the platform only produces FV2\r
-\r
-Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-Module Name:\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
-#include <Protocol/FirmwareVolume.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-\r
-/**\r
- Retrieves attributes, insures positive polarity of attribute bits, returns\r
- resulting attributes in output parameter\r
-\r
- @param This Calling context\r
- @param Attributes output buffer which contains attributes\r
-\r
- @retval EFI_INVALID_PARAMETER\r
- @retval EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeAttributes (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
- );\r
-\r
-/**\r
- Sets volume attributes\r
-\r
- @param This Calling context\r
- @param Attributes Buffer which contains attributes\r
-\r
- @retval EFI_INVALID_PARAMETER\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeAttributes (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
- );\r
-\r
-/**\r
- Read the requested file (NameGuid) and returns data in Buffer.\r
-\r
- @param This Calling context\r
- @param NameGuid Filename identifying which file to read\r
- @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
- <br>\r
- If Buffer is NULL, only type, attributes, and size are returned as\r
- there is no output buffer.\r
- <br>\r
- If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
- from BS pool by ReadFile\r
- <br>\r
- If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
- allocated by the caller and is being passed in.\r
- @param BufferSize Indicates the buffer size passed in, and on output the size\r
- required to complete the read\r
- @param FoundType Indicates the type of the file who's data is returned\r
- @param FileAttributes Indicates the attributes of the file who's data is resturned\r
- @param AuthenticationStatus Indicates the authentication status of the data\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_WARN_BUFFER_TOO_SMALL\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_ACCESS_DENIED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFile (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN EFI_GUID *NameGuid,\r
- IN OUT VOID **Buffer,\r
- IN OUT UINTN *BufferSize,\r
- OUT EFI_FV_FILETYPE *FoundType,\r
- OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
- OUT UINT32 *AuthenticationStatus\r
- );\r
-\r
-/**\r
- Read the requested section from the specified file and returns data in Buffer.\r
-\r
- @param This Calling context\r
- @param NameGuid Filename identifying the file from which to read\r
- @param SectionType Indicates what section type to retrieve\r
- @param SectionInstance Indicates which instance of SectionType to retrieve\r
- @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
- <br>\r
- If Buffer is NULL, only type, attributes, and size are returned as\r
- there is no output buffer.\r
- <br>\r
- If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
- from BS pool by ReadFile\r
- <br>\r
- If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
- allocated by the caller and is being passed in.\r
- @param BufferSize Indicates the buffer size passed in, and on output the size\r
- required to complete the read\r
- @param AuthenticationStatus Indicates the authentication status of the data\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_WARN_BUFFER_TOO_SMALL\r
- @retval EFI_OUT_OF_RESOURCES\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_ACCESS_DENIED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-FvReadSection (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN EFI_GUID *NameGuid,\r
- IN EFI_SECTION_TYPE SectionType,\r
- IN UINTN SectionInstance,\r
- IN OUT VOID **Buffer,\r
- IN OUT UINTN *BufferSize,\r
- OUT UINT32 *AuthenticationStatus\r
- );\r
-\r
-/**\r
- Write the supplied file (NameGuid) to the FV.\r
-\r
- @param This Calling context\r
- @param NumberOfFiles Indicates the number of file records pointed to by FileData\r
- @param WritePolicy Indicates the level of reliability of the write with respect to\r
- things like power failure events.\r
- @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA structures. Each\r
- element in the array indicates a file to write, and there are\r
- NumberOfFiles elements in the input array.\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_OUT_OF_RESOURCES\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_WRITE_PROTECTED\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_INVALID_PARAMETER\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-FvWriteFile (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN UINT32 NumberOfFiles,\r
- IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,\r
- IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData\r
- );\r
-\r
-/**\r
- Given the input key, search for the next matching file in the volume.\r
-\r
- @param This Calling context\r
- @param Key Pointer to a caller allocated buffer that contains an implementation\r
- specific key that is used to track where to begin searching on\r
- successive calls.\r
- @param FileType Indicates the file type to filter for\r
- @param NameGuid Guid filename of the file found\r
- @param Attributes Attributes of the file found\r
- @param Size Size in bytes of the file found\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_ACCESS_DENIED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-FvGetNextFile (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN OUT VOID *Key,\r
- IN OUT EFI_FV_FILETYPE *FileType,\r
- OUT EFI_GUID *NameGuid,\r
- OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
- OUT UINTN *Size\r
- );\r
-\r
-#define FIRMWARE_VOLUME_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f', 'v', 't', 'h')\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_FIRMWARE_VOLUME_PROTOCOL FirmwareVolume;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
-} FIRMWARE_VOLUME_PRIVATE_DATA;\r
-\r
-#define FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS(a) CR (a, FIRMWARE_VOLUME_PRIVATE_DATA, FirmwareVolume, FIRMWARE_VOLUME_PRIVATE_DATA_SIGNATURE)\r
-\r
-//\r
-// Firmware Volume Protocol template\r
-//\r
-EFI_EVENT mFvRegistration;\r
-\r
-FIRMWARE_VOLUME_PRIVATE_DATA gFirmwareVolumePrivateDataTemplate = {\r
- FIRMWARE_VOLUME_PRIVATE_DATA_SIGNATURE,\r
- {\r
- FvGetVolumeAttributes,\r
- FvSetVolumeAttributes,\r
- FvReadFile,\r
- FvReadSection,\r
- FvWriteFile,\r
- FvGetNextFile,\r
- 0,\r
- NULL\r
- },\r
- NULL\r
-};\r
-\r
-//\r
-// Module globals\r
-//\r
-\r
-VOID\r
-EFIAPI\r
-FvNotificationEvent (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN BufferSize;\r
- EFI_HANDLE Handle;\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME_PROTOCOL *FirmwareVolume;\r
-\r
- while (TRUE) {\r
- BufferSize = sizeof (Handle);\r
- Status = gBS->LocateHandle (\r
- ByRegisterNotify,\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- mFvRegistration,\r
- &BufferSize,\r
- &Handle\r
- );\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Exit Path of While Loop....\r
- //\r
- break;\r
- }\r
-\r
- //\r
- // Skip this handle if the Firmware Volume Protocol is already installed\r
- //\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiFirmwareVolumeProtocolGuid,\r
- (VOID **)&FirmwareVolume\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- //\r
- // Allocate private data structure\r
- //\r
- Private = AllocateCopyPool (sizeof (FIRMWARE_VOLUME_PRIVATE_DATA), &gFirmwareVolumePrivateDataTemplate);\r
- if (Private == NULL) {\r
- continue;\r
- }\r
-\r
- //\r
- // Retrieve the Firmware Volume2 Protocol\r
- //\r
- Status = gBS->HandleProtocol (\r
- Handle,\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- (VOID **)&Private->FirmwareVolume2\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Fill in rest of private data structure\r
- //\r
- Private->FirmwareVolume.KeySize = Private->FirmwareVolume2->KeySize;\r
- Private->FirmwareVolume.ParentHandle = Private->FirmwareVolume2->ParentHandle;\r
-\r
- //\r
- // Install Firmware Volume Protocol onto same handle\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &Handle,\r
- &gEfiFirmwareVolumeProtocolGuid,\r
- &Private->FirmwareVolume,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
-}\r
-\r
-\r
-/**\r
- The user Entry Point for DXE driver. The user code starts with this function\r
- as the real entry point for the image goes into a library that calls this \r
- function.\r
-\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
- @param[in] SystemTable A pointer to the EFI System Table.\r
- \r
- @retval EFI_SUCCESS The entry point is executed successfully.\r
- @retval other Some error occurs when executing this entry point.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeFirmwareVolume2 (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EfiCreateProtocolNotifyEvent (\r
- &gEfiFirmwareVolume2ProtocolGuid,\r
- TPL_CALLBACK,\r
- FvNotificationEvent,\r
- NULL,\r
- &mFvRegistration\r
- );\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Convert FV attrbiutes to FV2 attributes.\r
-\r
- @param Fv2Attributes FV2 attributes.\r
-\r
- @return FV attributes.\r
-\r
-**/\r
-FRAMEWORK_EFI_FV_ATTRIBUTES\r
-Fv2AttributesToFvAttributes (\r
- IN EFI_FV_ATTRIBUTES Fv2Attributes\r
- )\r
-{\r
- //\r
- // Clear those filed that is not defined in Framework FV spec and Alignment conversion.\r
- //\r
- return (Fv2Attributes & 0x1ff) | ((UINTN) EFI_FV_ALIGNMENT_2 << RShiftU64((Fv2Attributes & EFI_FV2_ALIGNMENT), 16));\r
-}\r
-\r
-/**\r
- Retrieves attributes, insures positive polarity of attribute bits, returns\r
- resulting attributes in output parameter\r
-\r
- @param This Calling context\r
- @param Attributes output buffer which contains attributes\r
-\r
- @retval EFI_INVALID_PARAMETER\r
- @retval EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvGetVolumeAttributes (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
- )\r
-{\r
- EFI_STATUS Status;\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
-\r
- Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
- FirmwareVolume2 = Private->FirmwareVolume2;\r
-\r
- Status = FirmwareVolume2->GetVolumeAttributes (\r
- FirmwareVolume2,\r
- Attributes\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- *Attributes = Fv2AttributesToFvAttributes (*Attributes);\r
- }\r
- return Status;\r
-}\r
-\r
-/**\r
- Sets volume attributes\r
-\r
- @param This Calling context\r
- @param Attributes Buffer which contains attributes\r
-\r
- @retval EFI_INVALID_PARAMETER\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_SUCCESS\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvSetVolumeAttributes (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES *Attributes\r
- )\r
-{\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
- EFI_FV_ATTRIBUTES Fv2Attributes; \r
- EFI_STATUS Status;\r
-\r
- Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
- FirmwareVolume2 = Private->FirmwareVolume2;\r
-\r
- Fv2Attributes = (*Attributes & 0x1ff);\r
- Status = FirmwareVolume2->SetVolumeAttributes (\r
- FirmwareVolume2,\r
- &Fv2Attributes\r
- );\r
-\r
- *Attributes = Fv2AttributesToFvAttributes (Fv2Attributes);\r
- \r
- return Status;\r
-}\r
-\r
-/**\r
- Read the requested file (NameGuid) and returns data in Buffer.\r
-\r
- @param This Calling context\r
- @param NameGuid Filename identifying which file to read\r
- @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
- <br>\r
- If Buffer is NULL, only type, attributes, and size are returned as\r
- there is no output buffer.\r
- <br>\r
- If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
- from BS pool by ReadFile\r
- <br>\r
- If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
- allocated by the caller and is being passed in.\r
- @param BufferSize Indicates the buffer size passed in, and on output the size\r
- required to complete the read\r
- @param FoundType Indicates the type of the file who's data is returned\r
- @param FileAttributes Indicates the attributes of the file who's data is resturned\r
- @param AuthenticationStatus Indicates the authentication status of the data\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_WARN_BUFFER_TOO_SMALL\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_ACCESS_DENIED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FvReadFile (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN EFI_GUID *NameGuid,\r
- IN OUT VOID **Buffer,\r
- IN OUT UINTN *BufferSize,\r
- OUT EFI_FV_FILETYPE *FoundType,\r
- OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,\r
- OUT UINT32 *AuthenticationStatus\r
- )\r
-{\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
- EFI_STATUS Status;\r
-\r
- Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
- FirmwareVolume2 = Private->FirmwareVolume2;\r
-\r
- Status = FirmwareVolume2->ReadFile (\r
- FirmwareVolume2,\r
- NameGuid,\r
- Buffer,\r
- BufferSize,\r
- FoundType,\r
- FileAttributes,\r
- AuthenticationStatus\r
- );\r
-\r
- //\r
- // For Framework FV attrbutes, only alignment fields are valid.\r
- //\r
- *FileAttributes = *FileAttributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;\r
- \r
- return Status;\r
-}\r
-\r
-/**\r
- Read the requested section from the specified file and returns data in Buffer.\r
-\r
- @param This Calling context\r
- @param NameGuid Filename identifying the file from which to read\r
- @param SectionType Indicates what section type to retrieve\r
- @param SectionInstance Indicates which instance of SectionType to retrieve\r
- @param Buffer Pointer to pointer to buffer in which contents of file are returned.\r
- <br>\r
- If Buffer is NULL, only type, attributes, and size are returned as\r
- there is no output buffer.\r
- <br>\r
- If Buffer != NULL and *Buffer == NULL, the output buffer is allocated\r
- from BS pool by ReadFile\r
- <br>\r
- If Buffer != NULL and *Buffer != NULL, the output buffer has been\r
- allocated by the caller and is being passed in.\r
- @param BufferSize Indicates the buffer size passed in, and on output the size\r
- required to complete the read\r
- @param AuthenticationStatus Indicates the authentication status of the data\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_WARN_BUFFER_TOO_SMALL\r
- @retval EFI_OUT_OF_RESOURCES\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_ACCESS_DENIED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-FvReadSection (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN EFI_GUID *NameGuid,\r
- IN EFI_SECTION_TYPE SectionType,\r
- IN UINTN SectionInstance,\r
- IN OUT VOID **Buffer,\r
- IN OUT UINTN *BufferSize,\r
- OUT UINT32 *AuthenticationStatus\r
- )\r
-{\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
-\r
- Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
- FirmwareVolume2 = Private->FirmwareVolume2;\r
-\r
- return FirmwareVolume2->ReadSection (\r
- FirmwareVolume2,\r
- NameGuid,\r
- SectionType,\r
- SectionInstance,\r
- Buffer,\r
- BufferSize,\r
- AuthenticationStatus\r
- );\r
-}\r
-\r
-/**\r
- Write the supplied file (NameGuid) to the FV.\r
-\r
- @param This Calling context\r
- @param NumberOfFiles Indicates the number of file records pointed to by FileData\r
- @param WritePolicy Indicates the level of reliability of the write with respect to\r
- things like power failure events.\r
- @param FileData A pointer to an array of EFI_FV_WRITE_FILE_DATA structures. Each\r
- element in the array indicates a file to write, and there are\r
- NumberOfFiles elements in the input array.\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_OUT_OF_RESOURCES\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_WRITE_PROTECTED\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_INVALID_PARAMETER\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-FvWriteFile (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN UINT32 NumberOfFiles,\r
- IN FRAMEWORK_EFI_FV_WRITE_POLICY WritePolicy,\r
- IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA *FileData\r
- )\r
-{\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
- EFI_FV_WRITE_FILE_DATA *PiFileData;\r
- EFI_STATUS Status;\r
- UINTN Index;\r
-\r
- Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
- FirmwareVolume2 = Private->FirmwareVolume2;\r
-\r
- PiFileData = AllocateCopyPool (sizeof (EFI_FV_WRITE_FILE_DATA), FileData);\r
-\r
- //\r
- // Framework Spec assume firmware files are Memory-Mapped.\r
- //\r
- for (Index = 0; Index < NumberOfFiles; Index++) {\r
- PiFileData[Index].FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
- }\r
-\r
- Status = FirmwareVolume2->WriteFile (\r
- FirmwareVolume2,\r
- NumberOfFiles,\r
- WritePolicy,\r
- (EFI_FV_WRITE_FILE_DATA *)FileData\r
- );\r
-\r
- FreePool (PiFileData);\r
- return Status;\r
-}\r
-\r
-/**\r
- Given the input key, search for the next matching file in the volume.\r
-\r
- @param This Calling context\r
- @param Key Pointer to a caller allocated buffer that contains an implementation\r
- specific key that is used to track where to begin searching on\r
- successive calls.\r
- @param FileType Indicates the file type to filter for\r
- @param NameGuid Guid filename of the file found\r
- @param Attributes Attributes of the file found\r
- @param Size Size in bytes of the file found\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_NOT_FOUND\r
- @retval EFI_DEVICE_ERROR\r
- @retval EFI_ACCESS_DENIED\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI \r
-FvGetNextFile (\r
- IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,\r
- IN OUT VOID *Key,\r
- IN OUT EFI_FV_FILETYPE *FileType,\r
- OUT EFI_GUID *NameGuid,\r
- OUT EFI_FV_FILE_ATTRIBUTES *Attributes,\r
- OUT UINTN *Size\r
- )\r
-{\r
- FIRMWARE_VOLUME_PRIVATE_DATA *Private;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FirmwareVolume2;\r
- EFI_STATUS Status;\r
-\r
- Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
- FirmwareVolume2 = Private->FirmwareVolume2;\r
-\r
- Status = FirmwareVolume2->GetNextFile (\r
- FirmwareVolume2,\r
- Key,\r
- FileType,\r
- NameGuid,\r
- Attributes,\r
- Size\r
- );\r
-\r
- //\r
- // For Framework FV attrbutes, only alignment fields are valid.\r
- //\r
- *Attributes = *Attributes & EFI_FV_FILE_ATTRIB_ALIGNMENT;\r
- \r
- return Status;\r
-}\r
+++ /dev/null
-#/** @file\r
-# Module produce FV on top of FV2.\r
-#\r
-# UEFI PI specification supersedes Inte's Framework Specification.\r
-# EFI_FIRMWARE_VOLUME_PROTOCOL defined in Intel Framework Pkg is replaced by\r
-# EFI_FIRMWARE_VOLUME2_PROTOCOL in MdePkg.\r
-# This module produces FV on top of FV2. This module is used on platform when both of\r
-# these two conditions are true:\r
-# 1) Framework module consuming FV is present\r
-# 2) And the platform only produces FV2\r
-#\r
-# Copyright (c) 2006 - 2008, Intel Corporation\r
-#\r
-# All rights reserved. This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#\r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = FvOnFv2Thunk\r
- FILE_GUID = 5007A40E-A5E0-44f7-86AE-662F9A91DA26\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
- EDK_RELEASE_VERSION = 0x00020000\r
- EFI_SPECIFICATION_VERSION = 0x00020000\r
- ENTRY_POINT = InitializeFirmwareVolume2\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
- FvOnFv2Thunk.c\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- IntelFrameworkPkg/IntelFrameworkPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiDriverEntryPoint\r
- UefiBootServicesTableLib\r
- BaseLib\r
- DebugLib\r
- UefiLib\r
- MemoryAllocationLib\r
-\r
-[Protocols]\r
- gEfiFirmwareVolume2ProtocolGuid\r
- gEfiFirmwareVolumeProtocolGuid\r
-\r
-[Depex]\r
- TRUE\r