]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/FvOnFv2Thunk/FvOnFv2Thunk.c
EdkCompatibilityPkg: Remove EdkCompatibilityPkg
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FvOnFv2Thunk / FvOnFv2Thunk.c
diff --git a/EdkCompatibilityPkg/Compatibility/FvOnFv2Thunk/FvOnFv2Thunk.c b/EdkCompatibilityPkg/Compatibility/FvOnFv2Thunk/FvOnFv2Thunk.c
deleted file mode 100644 (file)
index e13ebc2..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-/** @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 - 2010, Intel Corporation. All rights reserved.<BR>\r
-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
-#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
-  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_SUCCESS           The firmware volume attributes were returned.\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 A bit in Attributes was invalid\r
-  @retval EFI_SUCCESS           The requested firmware volume attributes were set \r
-                                and the resulting EFI_FV_ATTRIBUTES is returned in\r
-                                Attributes.\r
-  @retval EFI_ACCESS_DENIED     The Device is locked and does not permit modification. \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               The call completed successfully\r
-  @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.\r
-                                    The buffer is filled and the output is truncated.\r
-  @retval EFI_NOT_FOUND             NameGuid was not found in the firmware volume.\r
-  @retval EFI_DEVICE_ERROR          A hardware error occurred when attempting to access the firmware volume.\r
-  @retval EFI_ACCESS_DENIED         The firmware volume is configured to disallow reads.\r
-  @retval EFI_OUT_OF_RESOURCES      An allocation failure occurred.\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                The call completed successfully.\r
-  @retval EFI_WARN_BUFFER_TOO_SMALL  The buffer is too small to contain the requested output. \r
-                                     The buffer is filled and the output is truncated.\r
-  @retval EFI_OUT_OF_RESOURCES       An allocation failure occurred.\r
-  @retval EFI_NOT_FOUND              Name was not found in the firmware volume.\r
-  @retval EFI_DEVICE_ERROR           A hardware error occurred when attempting to access the firmware volume.\r
-  @retval EFI_ACCESS_DENIED          The firmware volume is configured to disallow reads.\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           The write completed successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  The firmware volume does not have enough free space to store file(s).\r
-  @retval EFI_DEVICE_ERROR      A hardware error occurred when attempting to access the firmware volume.\r
-  @retval EFI_WRITE_PROTECTED   The firmware volume is configured to disallow writes.\r
-  @retval EFI_NOT_FOUND         A delete was requested, but the requested file was not \r
-                                found in the firmware volume.\r
-  @retval EFI_INVALID_PARAMETER A delete was requested with a multiple file write.\r
-                                An unsupported WritePolicy was requested.\r
-                                An unknown file type was specified.\r
-                                A file system specific error has occurred.\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
-  ASSERT (PiFileData != NULL);\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           The output parameters are filled with data obtained from \r
-                                the first matching file that was found.\r
-  @retval EFI_NOT_FOUND         No files of type FileType were found.\r
-  @retval EFI_DEVICE_ERROR      A hardware error occurred when attempting to access \r
-                                the firmware volume.\r
-  @retval EFI_ACCESS_DENIED     The firmware volume is configured to disallow reads.\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
-\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
-  This notification function is invoked when an instance of the\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL is produced. It installs another instance of the\r
-  EFI_FIRMWARE_VOLUME_PROTOCOL on the same handle.\r
-\r
-  @param  Event                 The event that occured\r
-  @param  Context               Context of event. Not used in this nofication function.\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