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