]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add compatibility modules for Firmware Volume, PCI CFG, and Read Only Variable
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 3 Apr 2008 00:03:04 +0000 (00:03 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 3 Apr 2008 00:03:04 +0000 (00:03 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4984 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
EdkCompatibilityPkg/Compatiblity/Fv2ToFvThunk/Fv2ToFvThunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/Fv2ToFvThunk/Fv2ToFvThunk.inf [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/FvToFv2Thunk/FvToFv2Thunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/FvToFv2Thunk/FvToFv2Thunk.inf [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/PciCfg2ToPciCfgThunk/PciCfg2ToPciCfgThunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/PciCfg2ToPciCfgThunk/PciCfg2ToPciCfgThunk.inf [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.inf [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.inf [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.c [new file with mode: 0644]
EdkCompatibilityPkg/Compatiblity/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.inf [new file with mode: 0644]

diff --git a/EdkCompatibilityPkg/Compatiblity/Fv2ToFvThunk/Fv2ToFvThunk.c b/EdkCompatibilityPkg/Compatiblity/Fv2ToFvThunk/Fv2ToFvThunk.c
new file mode 100644 (file)
index 0000000..da2ada6
--- /dev/null
@@ -0,0 +1,1492 @@
+/*++\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
+  FvToFv2Thunk.c\r
+\r
+Abstract:\r
+\r
+  DXE driver \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
+  \r
+  Because of constraints imposed by the underlying firmware\r
+  storage, an instance of the Firmware Volume Protocol may not\r
+  be to able to support all possible variations of this\r
+  architecture. These constraints and the current state of the\r
+  firmware volume are exposed to the caller using the\r
+  GetVolumeAttributes() function. GetVolumeAttributes() is\r
+  callable only from TPL_NOTIFY and below. Behavior of\r
+  GetVolumeAttributes() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r
+  2.0 specification.\r
+  \r
+  @param  This    Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                  instance.\r
+  \r
+  @param  FvAttributes  Pointer to an EFI_FV_ATTRIBUTES in which\r
+                        the attributes and current settings are\r
+                        returned.\r
+\r
+\r
+  @retval EFI_SUCCESS   The firmware volume attributes were\r
+                        returned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2GetVolumeAttributes (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  OUT       EFI_FV_ATTRIBUTES             *FvAttributes\r
+  );\r
+\r
+\r
+/**\r
+  The SetVolumeAttributes() function is used to set configurable\r
+  firmware volume attributes. Only EFI_FV_READ_STATUS,\r
+  EFI_FV_WRITE_STATUS, and EFI_FV_LOCK_STATUS may be modified, and\r
+   then only in accordance with the declared capabilities. All\r
+  other bits of FvAttributes are ignored on input. On successful\r
+  return, all bits of *FvAttributes are valid and it contains the\r
+  completed EFI_FV_ATTRIBUTES for the volume. To modify an\r
+  attribute, the corresponding status bit in the EFI_FV_ATTRIBUTES\r
+  is set to the desired value on input. The EFI_FV_LOCK_STATUS bit\r
+  does not affect the ability to read or write the firmware\r
+  volume. Rather, once the EFI_FV_LOCK_STATUS bit is set, it\r
+  prevents further modification to all the attribute bits.\r
+  SetVolumeAttributes() is callable only from TPL_NOTIFY and\r
+  below. Behavior of SetVolumeAttributes() at any EFI_TPL above\r
+  TPL_NOTIFY is undefined. Type EFI_TPL is defined in\r
+  RaiseTPL() in the UEFI 2.0 specification.\r
+\r
+\r
+  @param  This  Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance.\r
+  \r
+  @param  FvAttributes  On input, FvAttributes is a pointer to\r
+                        an EFI_FV_ATTRIBUTES containing the\r
+                        desired firmware volume settings. On\r
+                        successful return, it contains the new\r
+                        settings of the firmware volume. On\r
+                        unsuccessful return, FvAttributes is not\r
+                        modified and the firmware volume\r
+                        settings are not changed.\r
+  \r
+  @retval EFI_SUCCESS   The requested firmware volume attributes\r
+                        were set and the resulting\r
+                        EFI_FV_ATTRIBUTES is returned in\r
+                        FvAttributes.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r
+                                is set to 1 on input, but the\r
+                                device does not support enabling\r
+                                reads\r
+                                (FvAttributes:EFI_FV_READ_ENABLE\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r
+                                is cleared to 0 on input, but\r
+                                the device does not support\r
+                                disabling reads\r
+                                (FvAttributes:EFI_FV_READ_DISABL\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r
+                                is set to 1 on input, but the\r
+                                device does not support enabling\r
+                                writes\r
+                                (FvAttributes:EFI_FV_WRITE_ENABL\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r
+                                is cleared to 0 on input, but\r
+                                the device does not support\r
+                                disabling writes\r
+                                (FvAttributes:EFI_FV_WRITE_DISAB\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_LOCK_STATUS\r
+                                is set on input, but the device\r
+                                does not support locking\r
+                                (FvAttributes:EFI_FV_LOCK_CAP is\r
+                                clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_ACCESS_DENIED     Device is locked and does not\r
+                                allow attribute modification\r
+                                (FvAttributes:EFI_FV_LOCK_STATUS\r
+                                is set on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2SetVolumeAttributes (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN OUT    EFI_FV_ATTRIBUTES             *FvAttributes\r
+  );\r
+\r
+\r
+/**\r
+  ReadFile() is used to retrieve any file from a firmware volume\r
+  during the DXE phase. The actual binary encoding of the file in\r
+  the firmware volume media may be in any arbitrary format as long\r
+  as it does the following: ?It is accessed using the Firmware\r
+  Volume Protocol. ?The image that is returned follows the image\r
+  format defined in Code Definitions: PI Firmware File Format.\r
+  If the input value of Buffer==NULL, it indicates the caller is\r
+  requesting only that the type, attributes, and size of the\r
+  file be returned and that there is no output buffer. In this\r
+  case, the following occurs:\r
+  - BufferSize is returned with the size that is required to\r
+    successfully complete the read.\r
+  - The output parameters FoundType and *FileAttributes are\r
+  returned with valid values.\r
+  - The returned value of *AuthenticationStatus is undefined.\r
+\r
+  If the input value of Buffer!=NULL, the output buffer is\r
+  specified by a double indirection of the Buffer parameter. The\r
+  input value of *Buffer is used to determine if the output\r
+  buffer is caller allocated or is dynamically allocated by\r
+  ReadFile(). If the input value of *Buffer!=NULL, it indicates\r
+  the output buffer is caller allocated. In this case, the input\r
+   value of *BufferSize indicates the size of the\r
+  caller-allocated output buffer. If the output buffer is not\r
+  large enough to contain the entire requested output, it is\r
+  filled up to the point that the output buffer is exhausted and\r
+  EFI_WARN_BUFFER_TOO_SMALL is returned, and then BufferSize is\r
+   returned with the size required to successfully complete the\r
+  read. All other output parameters are returned with valid\r
+  values. If the input value of *Buffer==NULL, it indicates the\r
+  output buffer is to be allocated by ReadFile(). In this case,\r
+  ReadFile() will allocate an appropriately sized buffer from\r
+  boot services pool memory, which will be returned in Buffer.\r
+  The size of the new buffer is returned in BufferSize and all\r
+  other output parameters are returned with valid values.\r
+  ReadFile() is callable only from TPL_NOTIFY and below.\r
+  Behavior of ReadFile() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r
+  2.0 specification.\r
+  \r
+  @param  This  Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance.\r
+  \r
+  @param  NameGuid  Pointer to an EFI_GUID, which is the file\r
+                    name. All firmware file names are EFI_GUIDs.\r
+                    A single firmware volume must not have two\r
+                    valid files with the same file name\r
+                    EFI_GUID.\r
+  \r
+  @param  Buffer  Pointer to a pointer to a buffer in which the\r
+                  file contents are returned, not including the\r
+                  file header.\r
+  @param  BufferSize  Pointer to a caller-allocated UINTN. It\r
+                      indicates the size of the memory\r
+                      represented by Buffer.\r
+  \r
+  @param  FoundType   Pointer to a caller-allocated\r
+                      EFI_FV_FILETYPE.\r
+  \r
+  @param  FileAttributes  Pointer to a  caller-allocated\r
+                          EFI_FV_FILE_ATTRIBUTES.\r
+  \r
+  @param  AuthenticationStatus  Pointer to a caller-allocated\r
+                                UINT32 in which the\r
+                                authentication status is\r
+                                returned.\r
+  \r
+  @retval EFI_SUCCESS   The call completed successfully.\r
+  \r
+  @retval EFI_WARN_BUFFER_TOO_SMALL   The buffer is too small to\r
+                                      contain the requested\r
+                                      output. The buffer is\r
+                                      filled and the output is\r
+                                      truncated.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  An allocation failure occurred.\r
+\r
+  @retavl EFI_NOT_FOUND   Name was not found in the firmware\r
+                          volume.\r
+\r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware\r
+                            volume.\r
+\r
+  @retval EFI_ACCESS_DENIED The firmware volume is configured to\r
+                            isallow reads.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2ReadFile (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  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
+  ReadSection() is used to retrieve a specific section from a file\r
+  within a firmware volume. The section returned is determined\r
+  using a depth-first, left-to-right search algorithm through all\r
+  sections found in the specified file. See\r
+   ????Firmware File Sections???? on page 9 for more details about\r
+  sections. The output buffer is specified by a double indirection\r
+  of the Buffer parameter. The input value of Buffer is used to\r
+  determine if the output buffer is caller allocated or is\r
+  dynamically allocated by ReadSection(). If the input value of\r
+  Buffer!=NULL, it indicates that the output buffer is caller\r
+  allocated. In this case, the input value of *BufferSize\r
+  indicates the size of the caller-allocated output buffer. If\r
+  the output buffer is not large enough to contain the entire\r
+  requested output, it is filled up to the point that the output\r
+  buffer is exhausted and EFI_WARN_BUFFER_TOO_SMALL is returned,\r
+  and then BufferSize is returned with the size that is required\r
+  to successfully complete the read. All other\r
+  output parameters are returned with valid values. If the input\r
+  value of *Buffer==NULL, it indicates the output buffer is to\r
+  be allocated by ReadSection(). In this case, ReadSection()\r
+  will allocate an appropriately sized buffer from boot services\r
+  pool memory, which will be returned in *Buffer. The size of\r
+  the new buffer is returned in *BufferSize and all other output\r
+  parameters are returned with valid values. ReadSection() is\r
+  callable only from TPL_NOTIFY and below. Behavior of\r
+  ReadSection() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r
+  2.0 specification.\r
+\r
+\r
+  @param This   Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance.\r
+  \r
+  @param NameGuid   Pointer to an EFI_GUID, which indicates the\r
+                    file name from which the requested section\r
+                    will be read.\r
+  \r
+  @param SectionType  Indicates the section type to return.\r
+                      SectionType in conjunction with\r
+                      SectionInstance indicates which section to\r
+                      return.\r
+  \r
+  @param SectionInstance  Indicates which instance of sections\r
+                          with a type of SectionType to return.\r
+                          SectionType in conjunction with\r
+                          SectionInstance indicates which\r
+                          section to return. SectionInstance is\r
+                          zero based.\r
+  \r
+  @param Buffer   Pointer to a pointer to a buffer in which the\r
+                  section contents are returned, not including\r
+                  the section header.\r
+  \r
+  @param BufferSize   Pointer to a caller-allocated UINTN. It\r
+                      indicates the size of the memory\r
+                      represented by Buffer.\r
+  \r
+  @param AuthenticationStatus Pointer to a caller-allocated\r
+                              UINT32 in which the authentication\r
+                              status is returned.\r
+  \r
+  \r
+  @retval EFI_SUCCESS   The call completed successfully.\r
+  \r
+  @retval EFI_WARN_BUFFER_TOO_SMALL   The caller-allocated\r
+                                      buffer is too small to\r
+                                      contain the requested\r
+                                      output. The buffer is\r
+                                      filled and the output is\r
+                                      truncated.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES  An allocation failure occurred.\r
+  \r
+  @retval EFI_NOT_FOUND   The requested file was not found in\r
+                          the firmware volume. EFI_NOT_FOUND The\r
+                          requested section was not found in the\r
+                          specified file.\r
+  \r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware\r
+                            volume.\r
+  \r
+  @retval EFI_ACCESS_DENIED The firmware volume is configured to\r
+                            disallow reads. EFI_PROTOCOL_ERROR\r
+                            The requested section was not found,\r
+                            but the file could not be fully\r
+                            parsed because a required\r
+                            GUIDED_SECTION_EXTRACTION_PROTOCOL\r
+                            was not found. It is possible the\r
+                            requested section exists within the\r
+                            file and could be successfully\r
+                            extracted once the required\r
+                            GUIDED_SECTION_EXTRACTION_PROTOCOL\r
+                            is published.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2ReadSection (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  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
+  WriteFile() is used to write one or more files to a firmware\r
+  volume. Each file to be written is described by an\r
+  EFI_FV_WRITE_FILE_DATA structure. The caller must ensure that\r
+  any required alignment for all files listed in the FileData\r
+  array is compatible with the firmware volume. Firmware volume\r
+  capabilities can be determined using the GetVolumeAttributes()\r
+  call. Similarly, if the WritePolicy is set to\r
+  EFI_FV_RELIABLE_WRITE, the caller must check the firmware volume\r
+  capabilities to ensure EFI_FV_RELIABLE_WRITE is supported by the\r
+  firmware volume. EFI_FV_UNRELIABLE_WRITE must always be\r
+  supported. Writing a file with a size of zero\r
+  (FileData[n].BufferSize == 0) deletes the file from the firmware\r
+  volume if it exists. Deleting a file must be done one at a time.\r
+  Deleting a file as part of a multiple file write is not allowed.\r
+  Platform Initialization Specification VOLUME 3 Shared\r
+  Architectural Elements 84 August 21, 2006 Version 1.0\r
+  WriteFile() is callable only from TPL_NOTIFY and below.\r
+  Behavior of WriteFile() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r
+  specification.\r
+\r
+  @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+              instance. NumberOfFiles Indicates the number of\r
+              elements in the array pointed to by FileData.\r
+\r
+\r
+  @param WritePolicy  Indicates the level of reliability for the\r
+                      write in the event of a power failure or\r
+                      other system failure during the write\r
+                      operation.\r
+\r
+  @param FileData   Pointer to an array of\r
+                    EFI_FV_WRITE_FILE_DATA. Each element of\r
+                    FileData[] represents a file to be written.\r
+\r
+\r
+  @retval EFI_SUCCESS The write completed successfully.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES  The firmware volume does not\r
+                                have enough free space to\r
+                                storefile(s).\r
+  \r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware volume.\r
+  \r
+  @retval EFI_WRITE_PROTECTED   The firmware volume is\r
+                                configured to disallow writes.\r
+  \r
+  @retval EFI_NOT_FOUND   A delete was requested, but the\r
+                          requested file was not found in the\r
+                          firmware volume.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   A delete was requested with a\r
+                                  multiple file write.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   An unsupported WritePolicy was\r
+                                  requested.\r
+\r
+  @retval EFI_INVALID_PARAMETER   An unknown file type was\r
+                                  specified.\r
+\r
+  @retval EFI_INVALID_PARAMETER   A file system specific error\r
+                                  has occurred.\r
+  \r
+**/\r
+EFI_STATUS \r
+EFIAPI\r
+Fv2WriteFile (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN        UINT32                        NumberOfFiles,\r
+  IN        EFI_FV_WRITE_POLICY           WritePolicy,\r
+  IN        EFI_FV_WRITE_FILE_DATA        *FileData\r
+  );\r
+\r
+/**\r
+  GetNextFile() is the interface that is used to search a firmware\r
+  volume for a particular file. It is called successively until\r
+  the desired file is located or the function returns\r
+   EFI_NOT_FOUND. To filter uninteresting files from the output,\r
+  the type of file to search for may be specified in FileType. For\r
+  example, if *FileType is EFI_FV_FILETYPE_DRIVER, only files of\r
+  this type will be returned in the output. If *FileType is\r
+  EFI_FV_FILETYPE_ALL, no filtering of file types is done. The Key\r
+  parameter is used to indicate a starting point of the search. If\r
+  the buffer *Key is completely initialized to zero, the search\r
+  re-initialized and starts at the beginning. Subsequent calls to\r
+  GetNextFile() must maintain the value of *Key returned by the\r
+  immediately previous call. The actual contents of *Key are\r
+  implementation specific and no semantic content is implied.\r
+  GetNextFile() is callable only from TPL_NOTIFY and below.\r
+  Behavior of GetNextFile() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r
+  specification. Status Codes Returned\r
+\r
+\r
+  @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+              instance. Key Pointer to a caller-allocated buffer\r
+              that contains implementation-specific data that is\r
+              used to track where to begin the search for the\r
+              next file. The size of the buffer must be at least\r
+              This->KeySize bytes long. To re-initialize the\r
+              search and begin from the beginning of the\r
+              firmware volume, the entire buffer must be cleared\r
+              to zero. Other than clearing the buffer to\r
+              initiate a new search, the caller must not modify\r
+              the data in the buffer between calls to\r
+              GetNextFile().\r
+\r
+  @param FileType   Pointer to a caller-allocated\r
+                    EFI_FV_FILETYPE. The GetNextFile() API can\r
+                    filter its search for files based on the\r
+                    value of the FileType input. A *FileType\r
+                    input of EFI_FV_FILETYPE_ALL causes\r
+                    GetNextFile() to search for files of all\r
+                    types. If a file is found, the file's type\r
+                    is returned in FileType. *FileType is not\r
+                    modified if no file is found.\r
+\r
+  @param NameGuid   Pointer to a caller-allocated EFI_GUID. If a\r
+                    matching file is found, the file's name is\r
+                    returned in NameGuid. If no matching file is\r
+                    found, *NameGuid is not modified.\r
+\r
+  @param Attributes Pointer to a caller-allocated\r
+                    EFI_FV_FILE_ATTRIBUTES. If a matching file\r
+                    is found, the file's attributes are returned\r
+                    in Attributes. If no matching file is found,\r
+                    Attributes is not modified. Type\r
+                    EFI_FV_FILE_ATTRIBUTES is defined in\r
+                    ReadFile().\r
+\r
+  @param Size   Pointer to a caller-allocated UINTN. If a\r
+                matching file is found, the file's size is\r
+                returned in *Size. If no matching file is found,\r
+                Size is not modified.\r
+\r
+  @retval EFI_SUCCESS The output parameters are filled with data\r
+                      obtained from the first matching file that\r
+                      was found.\r
+\r
+  @retval FI_NOT_FOUND  No files of type FileType were found.\r
+\r
+\r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware\r
+                            volume.\r
+\r
+  @retval EFI_ACCESS_DENIED The firmware volume is configured to\r
+                            disallow reads.\r
+\r
+   \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2GetNextFile (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_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
+/**\r
+  The GetInfo() function returns information of type\r
+  InformationType for the requested firmware volume. If the volume\r
+  does not support the requested information type, then\r
+  EFI_UNSUPPORTED is returned. If the buffer is not large enough\r
+  to hold the requested structure, EFI_BUFFER_TOO_SMALL is\r
+  returned and the BufferSize is set to the size of buffer that is\r
+  required to make the request. The information types defined by\r
+  this specification are required information types that all file\r
+  systems must support.\r
+\r
+  @param This A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+              instance that is the file handle the requested\r
+              information is for.\r
+  \r
+  @param InformationType  The type identifier for the\r
+                          information being requested.\r
+  \r
+  @param BufferSize   On input, the size of Buffer. On output,\r
+                      the amount of data returned in Buffer. In\r
+                      both cases, the size is measured in bytes.\r
+  \r
+  @param Buffer   A pointer to the data buffer to return. The\r
+                  buffer's type is indicated by InformationType.\r
+  \r
+  \r
+  @retval EFI_SUCCESS   The information was retrieved.\r
+  \r
+  @retval EFI_UNSUPPORTED   The InformationType is not known.\r
+  \r
+  @retval EFI_NO_MEDIA  The device has no medium.\r
+  \r
+  @retval EFI_DEVICE_ERROR  The device reported an error.\r
+  \r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are\r
+                                corrupted.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize is too small to\r
+                                read the current directory\r
+                                entry. BufferSize has been\r
+                                updated with the size needed to\r
+                                complete the request.\r
+\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2GetInfo (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  EFI_GUID                      *InformationType,\r
+  IN OUT    UINTN                         *BufferSize,\r
+  OUT       VOID                          *Buffer\r
+  );\r
+\r
+/**\r
+\r
+  The SetInfo() function sets information of type InformationType\r
+  on the requested firmware volume.\r
+\r
+\r
+  @param This   A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance that is the file handle the information\r
+                is for.\r
+\r
+  @param InformationType  The type identifier for the\r
+                          information being set.\r
+\r
+  @param BufferSize   The size, in bytes, of Buffer.\r
+\r
+  @param Buffer A pointer to the data buffer to write. The\r
+                buffer's type is indicated by InformationType.\r
+\r
+  @retval EFI_SUCCESS The information was set.\r
+\r
+  @retval EFI_UNSUPPORTED The InformationType is not known.\r
+\r
+  @retval EFI_NO_MEDIA  The device has no medium.\r
+\r
+  @retval EFI_DEVICE_ERROR  The device reported an error.\r
+\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are\r
+                                corrupted.\r
+\r
+\r
+  @retval EFI_WRITE_PROTECTED The media is read only.\r
+\r
+  @retval EFI_VOLUME_FULL   The volume is full.\r
+\r
+  @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the\r
+                              size of the type indicated by\r
+                              InformationType.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2SetInfo (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  EFI_GUID                      *InformationType,\r
+  IN        UINTN                         BufferSize,\r
+  IN CONST  VOID                          *Buffer\r
+  );\r
+\r
+//\r
+//\r
+//\r
+#define FIRMWARE_VOLUME2_PRIVATE_DATA_SIGNATURE  EFI_SIGNATURE_32 ('f', 'v', '2', 't')\r
+\r
+typedef struct {\r
+  UINTN                          Signature;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL  FirmwareVolume2;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+} FIRMWARE_VOLUME2_PRIVATE_DATA;\r
+\r
+#define FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS(a) CR (a, FIRMWARE_VOLUME2_PRIVATE_DATA, FirmwareVolume2, FIRMWARE_VOLUME2_PRIVATE_DATA_SIGNATURE)\r
+\r
+//\r
+// Firmware Volume Protocol template\r
+//\r
+EFI_EVENT  mFv2Registration;\r
+\r
+FIRMWARE_VOLUME2_PRIVATE_DATA gFirmwareVolume2PrivateDataTemplate = {\r
+  FIRMWARE_VOLUME2_PRIVATE_DATA_SIGNATURE,\r
+  {\r
+    Fv2GetVolumeAttributes,\r
+    Fv2SetVolumeAttributes,\r
+    Fv2ReadFile,\r
+    Fv2ReadSection,\r
+    Fv2WriteFile,\r
+    Fv2GetNextFile,\r
+    0,\r
+    NULL,\r
+    Fv2GetInfo,\r
+    Fv2SetInfo\r
+  },\r
+  NULL\r
+};\r
+\r
+//\r
+// Module globals\r
+//\r
+\r
+VOID\r
+EFIAPI\r
+Fv2NotificationEvent (\r
+  IN  EFI_EVENT       Event,\r
+  IN  VOID            *Context\r
+  )\r
+{\r
+  EFI_STATUS                     Status;\r
+  UINTN                          BufferSize;\r
+  EFI_HANDLE                     Handle;\r
+  FIRMWARE_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *FirmwareVolume2;\r
+\r
+  while (TRUE) {\r
+    BufferSize = sizeof (Handle);\r
+    Status = gBS->LocateHandle (\r
+                    ByRegisterNotify,\r
+                    &gEfiFirmwareVolumeProtocolGuid,\r
+                    mFv2Registration,\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
+                    &gEfiFirmwareVolume2ProtocolGuid,\r
+                    (VOID **)&FirmwareVolume2\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Allocate private data structure\r
+    //\r
+    Private = AllocateCopyPool (sizeof (FIRMWARE_VOLUME2_PRIVATE_DATA), &gFirmwareVolume2PrivateDataTemplate);\r
+    if (Private == NULL) {\r
+      continue;\r
+    }\r
+\r
+    //\r
+    // Retrieve the Firmware Volume2 Protocol\r
+    //\r
+    Status = gBS->HandleProtocol (\r
+                    Handle,\r
+                    &gEfiFirmwareVolumeProtocolGuid,\r
+                    (VOID **)&Private->FirmwareVolume\r
+                    );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    //\r
+    // Fill in rest of private data structure\r
+    //\r
+    Private->FirmwareVolume2.KeySize      = Private->FirmwareVolume->KeySize;\r
+    Private->FirmwareVolume2.ParentHandle = Private->FirmwareVolume->ParentHandle;\r
+\r
+    //\r
+    // Install Firmware Volume Protocol onto same handle\r
+    //\r
+    Status = gBS->InstallMultipleProtocolInterfaces (\r
+                    &Handle,\r
+                    &gEfiFirmwareVolume2ProtocolGuid,\r
+                    &Private->FirmwareVolume2,\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
+InitializeFirmwareVolume (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EfiCreateProtocolNotifyEvent (\r
+    &gEfiFirmwareVolumeProtocolGuid,\r
+    TPL_CALLBACK,\r
+    Fv2NotificationEvent,\r
+    NULL,\r
+    &mFv2Registration\r
+    );\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  \r
+  Because of constraints imposed by the underlying firmware\r
+  storage, an instance of the Firmware Volume Protocol may not\r
+  be to able to support all possible variations of this\r
+  architecture. These constraints and the current state of the\r
+  firmware volume are exposed to the caller using the\r
+  GetVolumeAttributes() function. GetVolumeAttributes() is\r
+  callable only from TPL_NOTIFY and below. Behavior of\r
+  GetVolumeAttributes() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r
+  2.0 specification.\r
+  \r
+  @param  This    Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                  instance.\r
+  \r
+  @param  FvAttributes  Pointer to an EFI_FV_ATTRIBUTES in which\r
+                        the attributes and current settings are\r
+                        returned.\r
+\r
+\r
+  @retval EFI_SUCCESS   The firmware volume attributes were\r
+                        returned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2GetVolumeAttributes (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  OUT       EFI_FV_ATTRIBUTES             *FvAttributes\r
+  )\r
+{\r
+  EFI_STATUS                     Status;\r
+  FIRMWARE_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+  INTN                           Alignment;\r
+\r
+  Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume = Private->FirmwareVolume;\r
+  Status = FirmwareVolume->GetVolumeAttributes (\r
+                             FirmwareVolume,\r
+                             (FRAMEWORK_EFI_FV_ATTRIBUTES *)FvAttributes\r
+                             );\r
+  if (!EFI_ERROR (Status)) {\r
+    Alignment = LowBitSet64 (RShiftU64 (*FvAttributes, 16) & 0xffff);\r
+    if (Alignment != -1) {\r
+      Alignment = Alignment << 16;\r
+    } else {\r
+      Alignment = 0;\r
+    }\r
+    *FvAttributes = (*FvAttributes & 0x1ff) | Alignment;\r
+  }\r
+  return Status;\r
+}\r
+\r
+/**\r
+  The SetVolumeAttributes() function is used to set configurable\r
+  firmware volume attributes. Only EFI_FV_READ_STATUS,\r
+  EFI_FV_WRITE_STATUS, and EFI_FV_LOCK_STATUS may be modified, and\r
+   then only in accordance with the declared capabilities. All\r
+  other bits of FvAttributes are ignored on input. On successful\r
+  return, all bits of *FvAttributes are valid and it contains the\r
+  completed EFI_FV_ATTRIBUTES for the volume. To modify an\r
+  attribute, the corresponding status bit in the EFI_FV_ATTRIBUTES\r
+  is set to the desired value on input. The EFI_FV_LOCK_STATUS bit\r
+  does not affect the ability to read or write the firmware\r
+  volume. Rather, once the EFI_FV_LOCK_STATUS bit is set, it\r
+  prevents further modification to all the attribute bits.\r
+  SetVolumeAttributes() is callable only from TPL_NOTIFY and\r
+  below. Behavior of SetVolumeAttributes() at any EFI_TPL above\r
+  TPL_NOTIFY is undefined. Type EFI_TPL is defined in\r
+  RaiseTPL() in the UEFI 2.0 specification.\r
+\r
+\r
+  @param  This  Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance.\r
+  \r
+  @param  FvAttributes  On input, FvAttributes is a pointer to\r
+                        an EFI_FV_ATTRIBUTES containing the\r
+                        desired firmware volume settings. On\r
+                        successful return, it contains the new\r
+                        settings of the firmware volume. On\r
+                        unsuccessful return, FvAttributes is not\r
+                        modified and the firmware volume\r
+                        settings are not changed.\r
+  \r
+  @retval EFI_SUCCESS   The requested firmware volume attributes\r
+                        were set and the resulting\r
+                        EFI_FV_ATTRIBUTES is returned in\r
+                        FvAttributes.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r
+                                is set to 1 on input, but the\r
+                                device does not support enabling\r
+                                reads\r
+                                (FvAttributes:EFI_FV_READ_ENABLE\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_READ_STATUS\r
+                                is cleared to 0 on input, but\r
+                                the device does not support\r
+                                disabling reads\r
+                                (FvAttributes:EFI_FV_READ_DISABL\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r
+                                is set to 1 on input, but the\r
+                                device does not support enabling\r
+                                writes\r
+                                (FvAttributes:EFI_FV_WRITE_ENABL\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_WRITE_STATUS\r
+                                is cleared to 0 on input, but\r
+                                the device does not support\r
+                                disabling writes\r
+                                (FvAttributes:EFI_FV_WRITE_DISAB\r
+                                is clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_INVALID_PARAMETER FvAttributes:EFI_FV_LOCK_STATUS\r
+                                is set on input, but the device\r
+                                does not support locking\r
+                                (FvAttributes:EFI_FV_LOCK_CAP is\r
+                                clear on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+  @retval EFI_ACCESS_DENIED     Device is locked and does not\r
+                                allow attribute modification\r
+                                (FvAttributes:EFI_FV_LOCK_STATUS\r
+                                is set on return from\r
+                                GetVolumeAttributes()). Actual\r
+                                volume attributes are unchanged.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2SetVolumeAttributes (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN OUT    EFI_FV_ATTRIBUTES             *FvAttributes\r
+  )\r
+{\r
+  FIRMWARE_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+  FRAMEWORK_EFI_FV_ATTRIBUTES    FrameworkFvAttributes; \r
+\r
+  Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume = Private->FirmwareVolume;\r
+\r
+  FrameworkFvAttributes = (*FvAttributes & 0x1ff) | ((UINTN)EFI_FV_ALIGNMENT_2 << ((*FvAttributes & EFI_FV2_ALIGNMENT) >> 16));\r
+\r
+  return FirmwareVolume->SetVolumeAttributes (\r
+                           FirmwareVolume,\r
+                           &FrameworkFvAttributes\r
+                           );\r
+}\r
+\r
+/**\r
+  ReadFile() is used to retrieve any file from a firmware volume\r
+  during the DXE phase. The actual binary encoding of the file in\r
+  the firmware volume media may be in any arbitrary format as long\r
+  as it does the following: ?It is accessed using the Firmware\r
+  Volume Protocol. ?The image that is returned follows the image\r
+  format defined in Code Definitions: PI Firmware File Format.\r
+  If the input value of Buffer==NULL, it indicates the caller is\r
+  requesting only that the type, attributes, and size of the\r
+  file be returned and that there is no output buffer. In this\r
+  case, the following occurs:\r
+  - BufferSize is returned with the size that is required to\r
+    successfully complete the read.\r
+  - The output parameters FoundType and *FileAttributes are\r
+  returned with valid values.\r
+  - The returned value of *AuthenticationStatus is undefined.\r
+\r
+  If the input value of Buffer!=NULL, the output buffer is\r
+  specified by a double indirection of the Buffer parameter. The\r
+  input value of *Buffer is used to determine if the output\r
+  buffer is caller allocated or is dynamically allocated by\r
+  ReadFile(). If the input value of *Buffer!=NULL, it indicates\r
+  the output buffer is caller allocated. In this case, the input\r
+   value of *BufferSize indicates the size of the\r
+  caller-allocated output buffer. If the output buffer is not\r
+  large enough to contain the entire requested output, it is\r
+  filled up to the point that the output buffer is exhausted and\r
+  EFI_WARN_BUFFER_TOO_SMALL is returned, and then BufferSize is\r
+   returned with the size required to successfully complete the\r
+  read. All other output parameters are returned with valid\r
+  values. If the input value of *Buffer==NULL, it indicates the\r
+  output buffer is to be allocated by ReadFile(). In this case,\r
+  ReadFile() will allocate an appropriately sized buffer from\r
+  boot services pool memory, which will be returned in Buffer.\r
+  The size of the new buffer is returned in BufferSize and all\r
+  other output parameters are returned with valid values.\r
+  ReadFile() is callable only from TPL_NOTIFY and below.\r
+  Behavior of ReadFile() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r
+  2.0 specification.\r
+  \r
+  @param  This  Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance.\r
+  \r
+  @param  NameGuid  Pointer to an EFI_GUID, which is the file\r
+                    name. All firmware file names are EFI_GUIDs.\r
+                    A single firmware volume must not have two\r
+                    valid files with the same file name\r
+                    EFI_GUID.\r
+  \r
+  @param  Buffer  Pointer to a pointer to a buffer in which the\r
+                  file contents are returned, not including the\r
+                  file header.\r
+  @param  BufferSize  Pointer to a caller-allocated UINTN. It\r
+                      indicates the size of the memory\r
+                      represented by Buffer.\r
+  \r
+  @param  FoundType   Pointer to a caller-allocated\r
+                      EFI_FV_FILETYPE.\r
+  \r
+  @param  FileAttributes  Pointer to a  caller-allocated\r
+                          EFI_FV_FILE_ATTRIBUTES.\r
+  \r
+  @param  AuthenticationStatus  Pointer to a caller-allocated\r
+                                UINT32 in which the\r
+                                authentication status is\r
+                                returned.\r
+  \r
+  @retval EFI_SUCCESS   The call completed successfully.\r
+  \r
+  @retval EFI_WARN_BUFFER_TOO_SMALL   The buffer is too small to\r
+                                      contain the requested\r
+                                      output. The buffer is\r
+                                      filled and the output is\r
+                                      truncated.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  An allocation failure occurred.\r
+\r
+  @retavl EFI_NOT_FOUND   Name was not found in the firmware\r
+                          volume.\r
+\r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware\r
+                            volume.\r
+\r
+  @retval EFI_ACCESS_DENIED The firmware volume is configured to\r
+                            isallow reads.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2ReadFile (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  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_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+\r
+  Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume = Private->FirmwareVolume;\r
+\r
+  return FirmwareVolume->ReadFile (\r
+                           FirmwareVolume,\r
+                           (EFI_GUID *)NameGuid,\r
+                           Buffer,\r
+                           BufferSize,\r
+                           FoundType,\r
+                           FileAttributes,\r
+                           AuthenticationStatus\r
+                           );\r
+}\r
+\r
+/**\r
+  ReadSection() is used to retrieve a specific section from a file\r
+  within a firmware volume. The section returned is determined\r
+  using a depth-first, left-to-right search algorithm through all\r
+  sections found in the specified file. See\r
+   ????Firmware File Sections???? on page 9 for more details about\r
+  sections. The output buffer is specified by a double indirection\r
+  of the Buffer parameter. The input value of Buffer is used to\r
+  determine if the output buffer is caller allocated or is\r
+  dynamically allocated by ReadSection(). If the input value of\r
+  Buffer!=NULL, it indicates that the output buffer is caller\r
+  allocated. In this case, the input value of *BufferSize\r
+  indicates the size of the caller-allocated output buffer. If\r
+  the output buffer is not large enough to contain the entire\r
+  requested output, it is filled up to the point that the output\r
+  buffer is exhausted and EFI_WARN_BUFFER_TOO_SMALL is returned,\r
+  and then BufferSize is returned with the size that is required\r
+  to successfully complete the read. All other\r
+  output parameters are returned with valid values. If the input\r
+  value of *Buffer==NULL, it indicates the output buffer is to\r
+  be allocated by ReadSection(). In this case, ReadSection()\r
+  will allocate an appropriately sized buffer from boot services\r
+  pool memory, which will be returned in *Buffer. The size of\r
+  the new buffer is returned in *BufferSize and all other output\r
+  parameters are returned with valid values. ReadSection() is\r
+  callable only from TPL_NOTIFY and below. Behavior of\r
+  ReadSection() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI\r
+  2.0 specification.\r
+\r
+\r
+  @param This   Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance.\r
+  \r
+  @param NameGuid   Pointer to an EFI_GUID, which indicates the\r
+                    file name from which the requested section\r
+                    will be read.\r
+  \r
+  @param SectionType  Indicates the section type to return.\r
+                      SectionType in conjunction with\r
+                      SectionInstance indicates which section to\r
+                      return.\r
+  \r
+  @param SectionInstance  Indicates which instance of sections\r
+                          with a type of SectionType to return.\r
+                          SectionType in conjunction with\r
+                          SectionInstance indicates which\r
+                          section to return. SectionInstance is\r
+                          zero based.\r
+  \r
+  @param Buffer   Pointer to a pointer to a buffer in which the\r
+                  section contents are returned, not including\r
+                  the section header.\r
+  \r
+  @param BufferSize   Pointer to a caller-allocated UINTN. It\r
+                      indicates the size of the memory\r
+                      represented by Buffer.\r
+  \r
+  @param AuthenticationStatus Pointer to a caller-allocated\r
+                              UINT32 in which the authentication\r
+                              status is returned.\r
+  \r
+  \r
+  @retval EFI_SUCCESS   The call completed successfully.\r
+  \r
+  @retval EFI_WARN_BUFFER_TOO_SMALL   The caller-allocated\r
+                                      buffer is too small to\r
+                                      contain the requested\r
+                                      output. The buffer is\r
+                                      filled and the output is\r
+                                      truncated.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES  An allocation failure occurred.\r
+  \r
+  @retval EFI_NOT_FOUND   The requested file was not found in\r
+                          the firmware volume. EFI_NOT_FOUND The\r
+                          requested section was not found in the\r
+                          specified file.\r
+  \r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware\r
+                            volume.\r
+  \r
+  @retval EFI_ACCESS_DENIED The firmware volume is configured to\r
+                            disallow reads. EFI_PROTOCOL_ERROR\r
+                            The requested section was not found,\r
+                            but the file could not be fully\r
+                            parsed because a required\r
+                            GUIDED_SECTION_EXTRACTION_PROTOCOL\r
+                            was not found. It is possible the\r
+                            requested section exists within the\r
+                            file and could be successfully\r
+                            extracted once the required\r
+                            GUIDED_SECTION_EXTRACTION_PROTOCOL\r
+                            is published.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2ReadSection (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  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_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+\r
+  Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume = Private->FirmwareVolume;\r
+\r
+  return FirmwareVolume->ReadSection (\r
+                           FirmwareVolume,\r
+                           (EFI_GUID *)NameGuid,\r
+                           SectionType,\r
+                           SectionInstance,\r
+                           Buffer,\r
+                           BufferSize,\r
+                           AuthenticationStatus\r
+                           );\r
+}\r
+\r
+/**\r
+  WriteFile() is used to write one or more files to a firmware\r
+  volume. Each file to be written is described by an\r
+  EFI_FV_WRITE_FILE_DATA structure. The caller must ensure that\r
+  any required alignment for all files listed in the FileData\r
+  array is compatible with the firmware volume. Firmware volume\r
+  capabilities can be determined using the GetVolumeAttributes()\r
+  call. Similarly, if the WritePolicy is set to\r
+  EFI_FV_RELIABLE_WRITE, the caller must check the firmware volume\r
+  capabilities to ensure EFI_FV_RELIABLE_WRITE is supported by the\r
+  firmware volume. EFI_FV_UNRELIABLE_WRITE must always be\r
+  supported. Writing a file with a size of zero\r
+  (FileData[n].BufferSize == 0) deletes the file from the firmware\r
+  volume if it exists. Deleting a file must be done one at a time.\r
+  Deleting a file as part of a multiple file write is not allowed.\r
+  Platform Initialization Specification VOLUME 3 Shared\r
+  Architectural Elements 84 August 21, 2006 Version 1.0\r
+  WriteFile() is callable only from TPL_NOTIFY and below.\r
+  Behavior of WriteFile() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r
+  specification.\r
+\r
+  @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+              instance. NumberOfFiles Indicates the number of\r
+              elements in the array pointed to by FileData.\r
+\r
+\r
+  @param WritePolicy  Indicates the level of reliability for the\r
+                      write in the event of a power failure or\r
+                      other system failure during the write\r
+                      operation.\r
+\r
+  @param FileData   Pointer to an array of\r
+                    EFI_FV_WRITE_FILE_DATA. Each element of\r
+                    FileData[] represents a file to be written.\r
+\r
+\r
+  @retval EFI_SUCCESS The write completed successfully.\r
+  \r
+  @retval EFI_OUT_OF_RESOURCES  The firmware volume does not\r
+                                have enough free space to\r
+                                storefile(s).\r
+  \r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware volume.\r
+  \r
+  @retval EFI_WRITE_PROTECTED   The firmware volume is\r
+                                configured to disallow writes.\r
+  \r
+  @retval EFI_NOT_FOUND   A delete was requested, but the\r
+                          requested file was not found in the\r
+                          firmware volume.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   A delete was requested with a\r
+                                  multiple file write.\r
+  \r
+  @retval EFI_INVALID_PARAMETER   An unsupported WritePolicy was\r
+                                  requested.\r
+\r
+  @retval EFI_INVALID_PARAMETER   An unknown file type was\r
+                                  specified.\r
+\r
+  @retval EFI_INVALID_PARAMETER   A file system specific error\r
+                                  has occurred.\r
+  \r
+**/\r
+EFI_STATUS \r
+EFIAPI\r
+Fv2WriteFile (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN        UINT32                        NumberOfFiles,\r
+  IN        EFI_FV_WRITE_POLICY           WritePolicy,\r
+  IN        EFI_FV_WRITE_FILE_DATA        *FileData\r
+  )\r
+{\r
+  FIRMWARE_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+\r
+  Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume = Private->FirmwareVolume;\r
+\r
+  return FirmwareVolume->WriteFile (\r
+                           FirmwareVolume,\r
+                           NumberOfFiles,\r
+                           WritePolicy,\r
+                           (FRAMEWORK_EFI_FV_WRITE_FILE_DATA *)FileData\r
+                           );\r
+}\r
+\r
+/**\r
+  GetNextFile() is the interface that is used to search a firmware\r
+  volume for a particular file. It is called successively until\r
+  the desired file is located or the function returns\r
+   EFI_NOT_FOUND. To filter uninteresting files from the output,\r
+  the type of file to search for may be specified in FileType. For\r
+  example, if *FileType is EFI_FV_FILETYPE_DRIVER, only files of\r
+  this type will be returned in the output. If *FileType is\r
+  EFI_FV_FILETYPE_ALL, no filtering of file types is done. The Key\r
+  parameter is used to indicate a starting point of the search. If\r
+  the buffer *Key is completely initialized to zero, the search\r
+  re-initialized and starts at the beginning. Subsequent calls to\r
+  GetNextFile() must maintain the value of *Key returned by the\r
+  immediately previous call. The actual contents of *Key are\r
+  implementation specific and no semantic content is implied.\r
+  GetNextFile() is callable only from TPL_NOTIFY and below.\r
+  Behavior of GetNextFile() at any EFI_TPL above TPL_NOTIFY is\r
+  undefined. Type EFI_TPL is defined in RaiseTPL() in the UEFI 2.0\r
+  specification. Status Codes Returned\r
+\r
+\r
+  @param This Indicates the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+              instance. Key Pointer to a caller-allocated buffer\r
+              that contains implementation-specific data that is\r
+              used to track where to begin the search for the\r
+              next file. The size of the buffer must be at least\r
+              This->KeySize bytes long. To re-initialize the\r
+              search and begin from the beginning of the\r
+              firmware volume, the entire buffer must be cleared\r
+              to zero. Other than clearing the buffer to\r
+              initiate a new search, the caller must not modify\r
+              the data in the buffer between calls to\r
+              GetNextFile().\r
+\r
+  @param FileType   Pointer to a caller-allocated\r
+                    EFI_FV_FILETYPE. The GetNextFile() API can\r
+                    filter its search for files based on the\r
+                    value of the FileType input. A *FileType\r
+                    input of EFI_FV_FILETYPE_ALL causes\r
+                    GetNextFile() to search for files of all\r
+                    types. If a file is found, the file's type\r
+                    is returned in FileType. *FileType is not\r
+                    modified if no file is found.\r
+\r
+  @param NameGuid   Pointer to a caller-allocated EFI_GUID. If a\r
+                    matching file is found, the file's name is\r
+                    returned in NameGuid. If no matching file is\r
+                    found, *NameGuid is not modified.\r
+\r
+  @param Attributes Pointer to a caller-allocated\r
+                    EFI_FV_FILE_ATTRIBUTES. If a matching file\r
+                    is found, the file's attributes are returned\r
+                    in Attributes. If no matching file is found,\r
+                    Attributes is not modified. Type\r
+                    EFI_FV_FILE_ATTRIBUTES is defined in\r
+                    ReadFile().\r
+\r
+  @param Size   Pointer to a caller-allocated UINTN. If a\r
+                matching file is found, the file's size is\r
+                returned in *Size. If no matching file is found,\r
+                Size is not modified.\r
+\r
+  @retval EFI_SUCCESS The output parameters are filled with data\r
+                      obtained from the first matching file that\r
+                      was found.\r
+\r
+  @retval FI_NOT_FOUND  No files of type FileType were found.\r
+\r
+\r
+  @retval EFI_DEVICE_ERROR  A hardware error occurred when\r
+                            attempting to access the firmware\r
+                            volume.\r
+\r
+  @retval EFI_ACCESS_DENIED The firmware volume is configured to\r
+                            disallow reads.\r
+\r
+   \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2GetNextFile (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_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_VOLUME2_PRIVATE_DATA  *Private;\r
+  EFI_FIRMWARE_VOLUME_PROTOCOL   *FirmwareVolume;\r
+\r
+  Private = FIRMWARE_VOLUME2_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume = Private->FirmwareVolume;\r
+\r
+  return FirmwareVolume->GetNextFile (\r
+                           FirmwareVolume,\r
+                           Key,\r
+                           FileType,\r
+                           NameGuid,\r
+                           Attributes,\r
+                           Size\r
+                           );\r
+}\r
+\r
+/**\r
+  The GetInfo() function returns information of type\r
+  InformationType for the requested firmware volume. If the volume\r
+  does not support the requested information type, then\r
+  EFI_UNSUPPORTED is returned. If the buffer is not large enough\r
+  to hold the requested structure, EFI_BUFFER_TOO_SMALL is\r
+  returned and the BufferSize is set to the size of buffer that is\r
+  required to make the request. The information types defined by\r
+  this specification are required information types that all file\r
+  systems must support.\r
+\r
+  @param This A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+              instance that is the file handle the requested\r
+              information is for.\r
+  \r
+  @param InformationType  The type identifier for the\r
+                          information being requested.\r
+  \r
+  @param BufferSize   On input, the size of Buffer. On output,\r
+                      the amount of data returned in Buffer. In\r
+                      both cases, the size is measured in bytes.\r
+  \r
+  @param Buffer   A pointer to the data buffer to return. The\r
+                  buffer's type is indicated by InformationType.\r
+  \r
+  \r
+  @retval EFI_SUCCESS   The information was retrieved.\r
+  \r
+  @retval EFI_UNSUPPORTED   The InformationType is not known.\r
+  \r
+  @retval EFI_NO_MEDIA  The device has no medium.\r
+  \r
+  @retval EFI_DEVICE_ERROR  The device reported an error.\r
+  \r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are\r
+                                corrupted.\r
+  \r
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize is too small to\r
+                                read the current directory\r
+                                entry. BufferSize has been\r
+                                updated with the size needed to\r
+                                complete the request.\r
+\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2GetInfo (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  EFI_GUID                      *InformationType,\r
+  IN OUT    UINTN                         *BufferSize,\r
+  OUT       VOID                          *Buffer\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+\r
+  The SetInfo() function sets information of type InformationType\r
+  on the requested firmware volume.\r
+\r
+\r
+  @param This   A pointer to the EFI_FIRMWARE_VOLUME2_PROTOCOL\r
+                instance that is the file handle the information\r
+                is for.\r
+\r
+  @param InformationType  The type identifier for the\r
+                          information being set.\r
+\r
+  @param BufferSize   The size, in bytes, of Buffer.\r
+\r
+  @param Buffer A pointer to the data buffer to write. The\r
+                buffer's type is indicated by InformationType.\r
+\r
+  @retval EFI_SUCCESS The information was set.\r
+\r
+  @retval EFI_UNSUPPORTED The InformationType is not known.\r
+\r
+  @retval EFI_NO_MEDIA  The device has no medium.\r
+\r
+  @retval EFI_DEVICE_ERROR  The device reported an error.\r
+\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are\r
+                                corrupted.\r
+\r
+\r
+  @retval EFI_WRITE_PROTECTED The media is read only.\r
+\r
+  @retval EFI_VOLUME_FULL   The volume is full.\r
+\r
+  @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the\r
+                              size of the type indicated by\r
+                              InformationType.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Fv2SetInfo (\r
+  IN CONST  EFI_FIRMWARE_VOLUME2_PROTOCOL *This,\r
+  IN CONST  EFI_GUID                      *InformationType,\r
+  IN        UINTN                         BufferSize,\r
+  IN CONST  VOID                          *Buffer\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatiblity/Fv2ToFvThunk/Fv2ToFvThunk.inf b/EdkCompatibilityPkg/Compatiblity/Fv2ToFvThunk/Fv2ToFvThunk.inf
new file mode 100644 (file)
index 0000000..b7a3862
--- /dev/null
@@ -0,0 +1,53 @@
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, 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                      = Fv2ToFvThunk\r
+  FILE_GUID                      = D8A6F4A6-0E97-4a8b-A475-39F1B28B5AEC\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+  ENTRY_POINT                    = InitializeFirmwareVolume\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
+  Fv2ToFvThunk.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
diff --git a/EdkCompatibilityPkg/Compatiblity/FvToFv2Thunk/FvToFv2Thunk.c b/EdkCompatibilityPkg/Compatiblity/FvToFv2Thunk/FvToFv2Thunk.c
new file mode 100644 (file)
index 0000000..61b2b04
--- /dev/null
@@ -0,0 +1,619 @@
+/*++\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
+  FvToFv2Thunk.c\r
+\r
+Abstract:\r
+\r
+  DXE driver \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  EFI_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
+  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 = (*Attributes & 0x1ff) | ((UINTN)EFI_FV_ALIGNMENT_2 << ((*Attributes & EFI_FV2_ALIGNMENT) >> 16));\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
+  INTN                           Alignment;\r
+  EFI_FV_ATTRIBUTES              Fv2Attributes; \r
+\r
+  Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+  Fv2Attributes = (*Attributes & 0x1ff);\r
+  Alignment = LowBitSet64 (RShiftU64 (*Attributes, 16) & 0xffff);\r
+  if (Alignment != -1) {\r
+    Fv2Attributes |= LShiftU64 (Alignment, 16);\r
+  }\r
+  return FirmwareVolume2->SetVolumeAttributes (\r
+                            FirmwareVolume2,\r
+                            &Fv2Attributes\r
+                            );\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
+\r
+  Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+  return FirmwareVolume2->ReadFile (\r
+                            FirmwareVolume2,\r
+                            NameGuid,\r
+                            Buffer,\r
+                            BufferSize,\r
+                            FoundType,\r
+                            FileAttributes,\r
+                            AuthenticationStatus\r
+                            );\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
+\r
+  Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+  return FirmwareVolume2->WriteFile (\r
+                            FirmwareVolume2,\r
+                            NumberOfFiles,\r
+                            WritePolicy,\r
+                            (EFI_FV_WRITE_FILE_DATA *)FileData\r
+                            );\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
+\r
+  Private = FIRMWARE_VOLUME_PRIVATE_DATA_FROM_THIS (This);\r
+  FirmwareVolume2 = Private->FirmwareVolume2;\r
+\r
+  return FirmwareVolume2->GetNextFile (\r
+                            FirmwareVolume2,\r
+                            Key,\r
+                            FileType,\r
+                            NameGuid,\r
+                            Attributes,\r
+                            Size\r
+                            );\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatiblity/FvToFv2Thunk/FvToFv2Thunk.inf b/EdkCompatibilityPkg/Compatiblity/FvToFv2Thunk/FvToFv2Thunk.inf
new file mode 100644 (file)
index 0000000..8eaf4a2
--- /dev/null
@@ -0,0 +1,53 @@
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, 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                      = FvToFv2Thunk\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
+  FvToFv2Thunk.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
diff --git a/EdkCompatibilityPkg/Compatiblity/PciCfg2ToPciCfgThunk/PciCfg2ToPciCfgThunk.c b/EdkCompatibilityPkg/Compatiblity/PciCfg2ToPciCfgThunk/PciCfg2ToPciCfgThunk.c
new file mode 100644 (file)
index 0000000..9cdf65a
--- /dev/null
@@ -0,0 +1,219 @@
+/*++\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
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  PEIM to provide the Variable functionality\r
+\r
+--*/\r
+\r
+#include <PiPei.h>\r
+#include <Ppi/PciCfg.h>\r
+#include <Ppi/PciCfg2.h>\r
+#include <Ppi/EcpPciCfg.h>\r
+#include <Library/DebugLib.h>\r
+\r
+//\r
+// Function Prototypes - Callbacks\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+EcpPciCfgPpiNotifyCallback (\r
+  IN EFI_PEI_SERVICES              **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
+  IN VOID                          *Ppi\r
+  );\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Read (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN OUT    VOID                      *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Write (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN OUT    VOID                      *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Modify (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN CONST  VOID                      *SetBits,\r
+  IN CONST  VOID                      *ClearBits\r
+  );\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnEcpPciCfgList = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEcpPeiPciCfgPpiGuid,\r
+  EcpPciCfgPpiNotifyCallback \r
+};\r
+\r
+EFI_PEI_PCI_CFG2_PPI mPciCfg2Ppi = {\r
+  PciCfg2Read,\r
+  PciCfg2Write,\r
+  PciCfg2Modify,\r
+  0\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR mPpiListPciCfg2 = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPciCfg2PpiGuid,\r
+  &mPciCfg2Ppi\r
+};\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializePciCfg2 (\r
+  IN EFI_FFS_FILE_HEADER     *FfsHeader,\r
+  IN CONST EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  FfsHeadher  - The FFS file header\r
+  PeiServices - General purpose services available to every PEIM.\r
+\r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS if the interface could be successfully\r
+            installed\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  //\r
+  // Register a notification for ECP PCI CFG PPI\r
+  //\r
+  Status = (*PeiServices)->NotifyPpi (PeiServices, &mNotifyOnEcpPciCfgList);\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EcpPciCfgPpiNotifyCallback (\r
+  IN EFI_PEI_SERVICES              **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
+  IN VOID                          *Ppi\r
+  )\r
+{\r
+  //\r
+  // When ECP PCI CFG PPI is installed, publish the PCI CFG2 PPI in the \r
+  // PEI Services Table and the PPI database\r
+  //\r
+  (*PeiServices)->PciCfg = &mPciCfg2Ppi;\r
+  return (*PeiServices)->InstallPpi ((CONST EFI_PEI_SERVICES **)PeiServices, &mPpiListPciCfg2);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Read (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN OUT    VOID                      *Buffer\r
+  )\r
+{\r
+  EFI_STATUS           Status;\r
+  EFI_PEI_PCI_CFG_PPI  *PciCfg;\r
+\r
+  Status = (*PeiServices)->LocatePpi (\r
+             PeiServices,\r
+             &gEcpPeiPciCfgPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&PciCfg\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return PciCfg->Read ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Write (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN OUT    VOID                      *Buffer\r
+  )\r
+{\r
+  EFI_STATUS           Status;\r
+  EFI_PEI_PCI_CFG_PPI  *PciCfg;\r
+\r
+  Status = (*PeiServices)->LocatePpi (\r
+             PeiServices,\r
+             &gEcpPeiPciCfgPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&PciCfg\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return PciCfg->Write ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfg2Modify (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN CONST  VOID                      *SetBits,\r
+  IN CONST  VOID                      *ClearBits\r
+  )\r
+{\r
+  EFI_STATUS           Status;\r
+  EFI_PEI_PCI_CFG_PPI  *PciCfg;\r
+\r
+  Status = (*PeiServices)->LocatePpi (\r
+             PeiServices,\r
+             &gEcpPeiPciCfgPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&PciCfg\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return PciCfg->Modify ((EFI_PEI_SERVICES **)PeiServices, PciCfg, Width, Address, *(UINTN *)SetBits, *(UINTN *)ClearBits);\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatiblity/PciCfg2ToPciCfgThunk/PciCfg2ToPciCfgThunk.inf b/EdkCompatibilityPkg/Compatiblity/PciCfg2ToPciCfgThunk/PciCfg2ToPciCfgThunk.inf
new file mode 100644 (file)
index 0000000..85e84e5
--- /dev/null
@@ -0,0 +1,53 @@
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, 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                      = PciCfg2ToPciCfgThunk\r
+  FILE_GUID                      = 41401688-2862-431b-BAAC-6ECADAC384AB\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = PeimInitializePciCfg2\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
+  PciCfg2ToPciCfgThunk.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+  EdkCompatibilityPkg/EdkCompatibilityPkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEfiPciCfgPpiInServiceTableGuid\r
+  gEfiPciCfg2PpiGuid\r
+  gEcpPeiPciCfgPpiGuid\r
+\r
+[Depex]\r
+  TRUE\r
+#  gEcpPeiPciCfgPpiGuid\r
diff --git a/EdkCompatibilityPkg/Compatiblity/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.c b/EdkCompatibilityPkg/Compatiblity/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.c
new file mode 100644 (file)
index 0000000..9821253
--- /dev/null
@@ -0,0 +1,155 @@
+/*++\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
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  PEIM to provide the Variable functionality\r
+\r
+--*/\r
+\r
+#include <PiPei.h>\r
+#include <Ppi/PciCfg.h>\r
+#include <Ppi/PciCfg2.h>\r
+#include <Library/DebugLib.h>\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfgRead (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_PCI_CFG_PPI          *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                       Address,\r
+  IN OUT VOID                     *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfgWrite (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_PCI_CFG_PPI          *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                       Address,\r
+  IN OUT VOID                     *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfgModify (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_PCI_CFG_PPI          *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                       Address,\r
+  IN UINTN                        SetBits,\r
+  IN UINTN                        ClearBits\r
+  );\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_PCI_CFG_PPI mPciCfgPpi = {\r
+  PciCfgRead,\r
+  PciCfgWrite,\r
+  PciCfgModify,\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR     mPpiListPciCfg = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPciCfgPpiInServiceTableGuid,\r
+  &mPciCfgPpi\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializePciCfg (\r
+  IN EFI_FFS_FILE_HEADER     *FfsHeader,\r
+  IN CONST EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  FfsHeadher  - The FFS file header\r
+  PeiServices - General purpose services available to every PEIM.\r
+\r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS if the interface could be successfully\r
+            installed\r
+\r
+--*/\r
+{\r
+  //\r
+  // Publish the variable capability to other modules\r
+  //\r
+  return (*PeiServices)->InstallPpi (PeiServices, &mPpiListPciCfg);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfgRead (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_PCI_CFG_PPI          *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                       Address,\r
+  IN OUT VOID                     *Buffer\r
+  )\r
+{\r
+  EFI_PEI_PCI_CFG2_PPI  *PciCfg2;\r
+\r
+  PciCfg2 = (*PeiServices)->PciCfg;\r
+\r
+  return PciCfg2->Read ((CONST EFI_PEI_SERVICES **)PeiServices, PciCfg2, Width, Address, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfgWrite (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_PCI_CFG_PPI          *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                       Address,\r
+  IN OUT VOID                     *Buffer\r
+  )\r
+{\r
+  EFI_PEI_PCI_CFG2_PPI  *PciCfg2;\r
+\r
+  PciCfg2 = (*PeiServices)->PciCfg;\r
+\r
+  return PciCfg2->Write ((CONST EFI_PEI_SERVICES **)PeiServices, PciCfg2, Width, Address, Buffer);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciCfgModify (\r
+  IN EFI_PEI_SERVICES             **PeiServices,\r
+  IN EFI_PEI_PCI_CFG_PPI          *This,\r
+  IN EFI_PEI_PCI_CFG_PPI_WIDTH    Width,\r
+  IN UINT64                       Address,\r
+  IN UINTN                        SetBits,\r
+  IN UINTN                        ClearBits\r
+  )\r
+{\r
+  EFI_PEI_PCI_CFG2_PPI  *PciCfg2;\r
+\r
+  PciCfg2 = (*PeiServices)->PciCfg;\r
+\r
+  return PciCfg2->Modify ((CONST EFI_PEI_SERVICES **)PeiServices, PciCfg2, Width, Address, &SetBits, &ClearBits);\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatiblity/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.inf b/EdkCompatibilityPkg/Compatiblity/PciCfgToPciCfg2Thunk/PciCfgToPciCfg2Thunk.inf
new file mode 100644 (file)
index 0000000..a264ab4
--- /dev/null
@@ -0,0 +1,50 @@
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, 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                      = PciCfgToPciCfg2Thunk\r
+  FILE_GUID                      = 717886AB-C40A-44cf-9114-4119E84B0DC7\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = PeimInitializePciCfg\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
+  PciCfgToPciCfg2Thunk.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEfiPciCfgPpiInServiceTableGuid\r
+  gEfiPciCfg2PpiGuid\r
+\r
+[Depex]\r
+  gEfiPciCfg2PpiGuid\r
diff --git a/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.c b/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.c
new file mode 100644 (file)
index 0000000..832dc52
--- /dev/null
@@ -0,0 +1,208 @@
+/*++\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
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  PEIM to provide the Variable functionality\r
+\r
+--*/\r
+\r
+#include <PiPei.h>\r
+#include <Ppi/ReadOnlyVariable2.h>\r
+#include <Ppi/ReadOnlyVariable.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetVariable (\r
+  IN CONST  EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
+  IN CONST  CHAR16                          *VariableName,\r
+  IN CONST  EFI_GUID                        *VariableGuid,\r
+  OUT       UINT32                          *Attributes,\r
+  IN OUT    UINTN                           *DataSize,\r
+  OUT       VOID                            *Data\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetNextVariableName (\r
+  IN CONST  EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
+  IN OUT UINTN                              *VariableNameSize,\r
+  IN OUT CHAR16                             *VariableName,\r
+  IN OUT EFI_GUID                           *VariableGuid\r
+  );\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_READ_ONLY_VARIABLE2_PPI mVariablePpi = {\r
+  PeiGetVariable,\r
+  PeiGetNextVariableName\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR     mPpiListVariable = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiReadOnlyVariable2PpiGuid,\r
+  &mVariablePpi\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeReadOnlyVariable2 (\r
+  IN EFI_FFS_FILE_HEADER       *FfsHeader,\r
+  IN EFI_PEI_SERVICES          **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  FfsHeadher  - The FFS file header\r
+  PeiServices - General purpose services available to every PEIM.\r
+\r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS if the interface could be successfully\r
+            installed\r
+\r
+--*/\r
+{\r
+  //\r
+  // Publish the variable capability to other modules\r
+  //\r
+  return PeiServicesInstallPpi (&mPpiListVariable);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetVariable (\r
+  IN CONST  EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
+  IN CONST  CHAR16                          *VariableName,\r
+  IN CONST  EFI_GUID                        *VariableGuid,\r
+  OUT       UINT32                          *Attributes,\r
+  IN OUT    UINTN                           *DataSize,\r
+  OUT       VOID                            *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the read variable functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM.\r
+\r
+  VariableName     - The variable name\r
+\r
+  VendorGuid       - The vendor's GUID\r
+\r
+  Attributes       - Pointer to the attribute\r
+\r
+  DataSize         - Size of data\r
+\r
+  Data             - Pointer to data\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The interface could be successfully installed\r
+\r
+  EFI_NOT_FOUND         - The variable could not be discovered\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The caller buffer is not large enough\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                     Status;\r
+  EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
+\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiReadOnlyVariablePpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&ReadOnlyVariable\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return ReadOnlyVariable->PeiGetVariable (\r
+                             GetPeiServicesTablePointer (),\r
+                             (CHAR16 *)VariableName,\r
+                             (EFI_GUID *)VariableGuid,\r
+                             Attributes,\r
+                             DataSize,\r
+                             Data\r
+                             );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetNextVariableName (\r
+  IN CONST  EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,\r
+  IN OUT UINTN                              *VariableNameSize,\r
+  IN OUT CHAR16                             *VariableName,\r
+  IN OUT EFI_GUID                           *VariableGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the get next variable functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  PeiServices        - General purpose services available to every PEIM.\r
+  VariabvleNameSize  - The variable name's size.\r
+  VariableName       - A pointer to the variable's name.\r
+  VariableGuid       - A pointer to the EFI_GUID structure.\r
+\r
+  VariableNameSize - Size of the variable name\r
+\r
+  VariableName     - The variable name\r
+\r
+  VendorGuid       - The vendor's GUID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - The interface could be successfully installed\r
+\r
+  EFI_NOT_FOUND - The variable could not be discovered\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                     Status;\r
+  EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVariable;\r
+\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiReadOnlyVariablePpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&ReadOnlyVariable\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return ReadOnlyVariable->PeiGetNextVariableName (\r
+                             GetPeiServicesTablePointer (),\r
+                             VariableNameSize,\r
+                             VariableName,\r
+                             VariableGuid\r
+                             );\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.inf b/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariable2ToReadOnlyVariableThunk/ReadOnlyVariable2ToReadOnlyVariableThunk.inf
new file mode 100644 (file)
index 0000000..c9b08f1
--- /dev/null
@@ -0,0 +1,52 @@
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, 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                      = ReadOnlyVariable2ToReadOnlyVariableThunk\r
+  FILE_GUID                      = 950216A2-A621-479c-A13D-2990617BDFE7\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = PeimInitializeReadOnlyVariable2\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
+  ReadOnlyVariable2ToReadOnlyVariableThunk.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  PeiServicesLib\r
+  PeiServicesTablePointerLib\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEfiPeiReadOnlyVariablePpiGuid                 # PPI ALWAYS_CONSUMED\r
+  gEfiPeiReadOnlyVariable2PpiGuid                # PPI ALWAYS_PRODUCED\r
+\r
+[Depex]\r
+  gEfiPeiReadOnlyVariablePpiGuid\r
diff --git a/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.c b/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.c
new file mode 100644 (file)
index 0000000..8da77e1
--- /dev/null
@@ -0,0 +1,208 @@
+/*++\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
+  Variable.c\r
+\r
+Abstract:\r
+\r
+  PEIM to provide the Variable functionality\r
+\r
+--*/\r
+\r
+#include <PiPei.h>\r
+#include <Ppi/ReadOnlyVariable.h>\r
+#include <Ppi/ReadOnlyVariable2.h>\r
+#include <Library/DebugLib.h>\r
+\r
+//\r
+// Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetVariable (\r
+  IN  EFI_PEI_SERVICES  **PeiServices,\r
+  IN  CHAR16            *VariableName,\r
+  IN  EFI_GUID          *VendorGuid,\r
+  OUT UINT32            *Attributes OPTIONAL,\r
+  IN  OUT UINTN         *DataSize,\r
+  OUT VOID              *Data\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetNextVariableName (\r
+  IN EFI_PEI_SERVICES  **PeiServices,\r
+  IN OUT UINTN         *VariableNameSize,\r
+  IN OUT CHAR16        *VariableName,\r
+  IN OUT EFI_GUID      *VendorGuid\r
+  );\r
+\r
+//\r
+// Module globals\r
+//\r
+EFI_PEI_READ_ONLY_VARIABLE_PPI mVariablePpi = {\r
+  PeiGetVariable,\r
+  PeiGetNextVariableName\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR     mPpiListVariable = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEfiPeiReadOnlyVariablePpiGuid,\r
+  &mVariablePpi\r
+};\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeimInitializeReadOnlyVariable (\r
+  IN EFI_FFS_FILE_HEADER     *FfsHeader,\r
+  IN CONST EFI_PEI_SERVICES  **PeiServices\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  FfsHeadher  - The FFS file header\r
+  PeiServices - General purpose services available to every PEIM.\r
+\r
+Returns:\r
+\r
+  Status -  EFI_SUCCESS if the interface could be successfully\r
+            installed\r
+\r
+--*/\r
+{\r
+  //\r
+  // Publish the variable capability to other modules\r
+  //\r
+  return (*PeiServices)->InstallPpi (PeiServices, &mPpiListVariable);\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetVariable (\r
+  IN  EFI_PEI_SERVICES  **PeiServices,\r
+  IN  CHAR16            *VariableName,\r
+  IN  EFI_GUID          *VendorGuid,\r
+  OUT UINT32            *Attributes OPTIONAL,\r
+  IN  OUT UINTN         *DataSize,\r
+  OUT VOID              *Data\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the read variable functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  PeiServices - General purpose services available to every PEIM.\r
+\r
+  VariableName     - The variable name\r
+\r
+  VendorGuid       - The vendor's GUID\r
+\r
+  Attributes       - Pointer to the attribute\r
+\r
+  DataSize         - Size of data\r
+\r
+  Data             - Pointer to data\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS           - The interface could be successfully installed\r
+\r
+  EFI_NOT_FOUND         - The variable could not be discovered\r
+\r
+  EFI_BUFFER_TOO_SMALL  - The caller buffer is not large enough\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
+\r
+  Status = (*PeiServices)->LocatePpi (\r
+                             (CONST EFI_PEI_SERVICES **)PeiServices, \r
+                             &gEfiPeiReadOnlyVariable2PpiGuid, \r
+                             0, \r
+                             NULL, \r
+                             (VOID **)&ReadOnlyVariable2\r
+                             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return ReadOnlyVariable2->GetVariable (\r
+                              ReadOnlyVariable2,\r
+                              VariableName,\r
+                              VendorGuid,\r
+                              Attributes,\r
+                              DataSize,\r
+                              Data\r
+                              );\r
+}\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetNextVariableName (\r
+  IN EFI_PEI_SERVICES  **PeiServices,\r
+  IN OUT UINTN         *VariableNameSize,\r
+  IN OUT CHAR16        *VariableName,\r
+  IN OUT EFI_GUID      *VendorGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Provide the get next variable functionality of the variable services.\r
+\r
+Arguments:\r
+\r
+  PeiServices        - General purpose services available to every PEIM.\r
+  VariabvleNameSize  - The variable name's size.\r
+  VariableName       - A pointer to the variable's name.\r
+  VariableGuid       - A pointer to the EFI_GUID structure.\r
+\r
+  VariableNameSize - Size of the variable name\r
+\r
+  VariableName     - The variable name\r
+\r
+  VendorGuid       - The vendor's GUID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS - The interface could be successfully installed\r
+\r
+  EFI_NOT_FOUND - The variable could not be discovered\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_PEI_READ_ONLY_VARIABLE2_PPI *ReadOnlyVariable2;\r
+\r
+  Status = (*PeiServices)->LocatePpi (\r
+                             (CONST EFI_PEI_SERVICES **)PeiServices, \r
+                             &gEfiPeiReadOnlyVariable2PpiGuid, \r
+                             0, \r
+                             NULL, \r
+                             (VOID **)&ReadOnlyVariable2\r
+                             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return ReadOnlyVariable2->NextVariableName (\r
+                              ReadOnlyVariable2,\r
+                              VariableNameSize,\r
+                              VariableName,\r
+                              VendorGuid\r
+                              );\r
+}\r
diff --git a/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.inf b/EdkCompatibilityPkg/Compatiblity/ReadOnlyVariableToReadOnlyVariable2Thunk/ReadOnlyVariableToReadOnlyVariable2Thunk.inf
new file mode 100644 (file)
index 0000000..3142eed
--- /dev/null
@@ -0,0 +1,52 @@
+#/** @file\r
+# Component description file for PeiVariable module.\r
+#\r
+# PEIM to provide the Variable functionality.\r
+# Copyright (c) 2006 - 2007, 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                      = ReadOnlyVariableToReadOnlyVariable2Thunk\r
+  FILE_GUID                      = 0FDB764B-E669-4c69-83AC-5EDD99A2711E\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+  ENTRY_POINT                    = PeimInitializeReadOnlyVariable\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
+  ReadOnlyVariableToReadOnlyVariable2Thunk.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  IntelFrameworkPkg/IntelFrameworkPkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+#  PeiServicesLib\r
+#  PeiServicesTablePointerLib\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEfiPeiReadOnlyVariable2PpiGuid               # PPI ALWAYS_CONSUMED\r
+  gEfiPeiReadOnlyVariablePpiGuid                # PPI ALWAYS_PRODUCED\r
+\r
+[Depex]\r
+  gEfiPeiReadOnlyVariable2PpiGuid\r