本文整理汇总了C++中EFI_FIRMWARE_VOLUME2_PROTOCOL::ReadSection方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_FIRMWARE_VOLUME2_PROTOCOL::ReadSection方法的具体用法?C++ EFI_FIRMWARE_VOLUME2_PROTOCOL::ReadSection怎么用?C++ EFI_FIRMWARE_VOLUME2_PROTOCOL::ReadSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_FIRMWARE_VOLUME2_PROTOCOL
的用法示例。
在下文中一共展示了EFI_FIRMWARE_VOLUME2_PROTOCOL::ReadSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SmmPreProcessDepex
/**
Read Depex and pre-process the Depex for Before and After. If Section Extraction
protocol returns an error via ReadSection defer the reading of the Depex.
@param DriverEntry Driver to work on.
@retval EFI_SUCCESS Depex read and preprossesed
@retval EFI_PROTOCOL_ERROR The section extraction protocol returned an error
and Depex reading needs to be retried.
@retval Error DEPEX not found.
**/
EFI_STATUS
SmmGetDepexSectionAndPreProccess (
IN EFI_SMM_DRIVER_ENTRY *DriverEntry
)
{
EFI_STATUS Status;
EFI_SECTION_TYPE SectionType;
UINT32 AuthenticationStatus;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
Fv = DriverEntry->Fv;
//
// Grab Depex info, it will never be free'ed.
// (Note: DriverEntry->Depex is in DXE memory)
//
SectionType = EFI_SECTION_SMM_DEPEX;
Status = Fv->ReadSection (
DriverEntry->Fv,
&DriverEntry->FileName,
SectionType,
0,
&DriverEntry->Depex,
(UINTN *)&DriverEntry->DepexSize,
&AuthenticationStatus
);
if (EFI_ERROR (Status)) {
if (Status == EFI_PROTOCOL_ERROR) {
//
// The section extraction protocol failed so set protocol error flag
//
DriverEntry->DepexProtocolError = TRUE;
} else {
//
// If no Depex assume depend on all architectural protocols
//
DriverEntry->Depex = NULL;
DriverEntry->Dependent = TRUE;
DriverEntry->DepexProtocolError = FALSE;
}
} else {
//
// Set Before and After state information based on Depex
// Driver will be put in Dependent state
//
SmmPreProcessDepex (DriverEntry);
DriverEntry->DepexProtocolError = FALSE;
}
return Status;
}
示例2: ASSERT
//.........这里部分代码省略.........
Status = AcpiTable->InstallAcpiTable (
AcpiTable,
CurrentTable,
CurrentTable->Length,
&TableHandle
);
ASSERT_EFI_ERROR (Status);
CurrentTable = NULL;
//
// Init Pci Device PRT PRW information structure from PCD
//
mConfigData = (PCI_DEVICE_SETTING *)AllocateZeroPool (sizeof (PCI_DEVICE_SETTING));
ASSERT_EFI_ERROR (mConfigData);
InitPciDeviceInfoStructure (mConfigData);
//
// Get the Acpi SDT protocol for manipulation on acpi table
//
Status = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID **)&mAcpiSdt);
ASSERT_EFI_ERROR (Status);
//
// Locate the firmware volume protocol
//
Status = LocateSupportProtocol (&gEfiFirmwareVolume2ProtocolGuid, (VOID**)&FwVol, 1);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Read tables from the storage file.
//
while (Status == EFI_SUCCESS) {
Status = FwVol->ReadSection (
FwVol,
(EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile),
EFI_SECTION_RAW,
Instance,
(VOID**)&CurrentTable,
&Size,
&FvStatus
);
if (!EFI_ERROR(Status)) {
//
// Perform any table specific updates.
//
AcpiUpdateTable ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable, &Version);
//
// Update the check sum
// It needs to be zeroed before the checksum calculation
//
((EFI_ACPI_SDT_HEADER *)CurrentTable)->Checksum = 0;
((EFI_ACPI_SDT_HEADER *)CurrentTable)->Checksum =
CalculateCheckSum8 ((VOID *)CurrentTable, CurrentTable->Length);
//
// Add the table
//
TableHandle = 0;
Status = AcpiTable->InstallAcpiTable (
AcpiTable,
CurrentTable,
((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length,
&TableHandle
示例3:
EFI_STATUS
EFIAPI
LoadBmp(
OUT EFI_PHYSICAL_ADDRESS *BmpAddress,
OUT UINT32 *BmpSize
)
{
EFI_STATUS Status;
UINTN FvProtocolCount;
EFI_HANDLE *FvHandles;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
UINTN Index;
UINT32 AuthenticationStatus;
UINT8 *Buffer;
UINTN BmpBufferSize;
Buffer = 0;
FvHandles = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&FvProtocolCount,
&FvHandles
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < FvProtocolCount; Index++) {
Status = gBS->HandleProtocol (
FvHandles[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv
);
BmpBufferSize = 0;
Status = Fv->ReadSection (
Fv,
(EFI_GUID *)PcdGetPtr(PcdLogoFile),
EFI_SECTION_RAW,
0,
(void **)&Buffer,
&BmpBufferSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
*BmpAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
*BmpSize = (UINT32)BmpBufferSize;
Status = EFI_SUCCESS;
break;
}
}
} else {
Status = EFI_NOT_FOUND;
}
if (FvHandles != NULL) {
gBS->FreePool (FvHandles);
FvHandles = NULL;
}
return Status;
}
示例4: GetDevicePathSize
/**
Loads an EFI image into SMRAM.
@param DriverEntry EFI_SMM_DRIVER_ENTRY instance
@return EFI_STATUS
**/
EFI_STATUS
EFIAPI
SmmLoadImage (
IN OUT EFI_SMM_DRIVER_ENTRY *DriverEntry
)
{
UINT32 AuthenticationStatus;
UINTN FilePathSize;
VOID *Buffer;
UINTN Size;
UINTN PageCount;
EFI_GUID *NameGuid;
EFI_STATUS Status;
EFI_STATUS SecurityStatus;
EFI_HANDLE DeviceHandle;
EFI_PHYSICAL_ADDRESS DstBuffer;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
EFI_DEVICE_PATH_PROTOCOL *OriginalFilePath;
EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
Buffer = NULL;
Size = 0;
Fv = DriverEntry->Fv;
NameGuid = &DriverEntry->FileName;
FilePath = DriverEntry->FvFileDevicePath;
OriginalFilePath = FilePath;
HandleFilePath = FilePath;
DeviceHandle = NULL;
SecurityStatus = EFI_SUCCESS;
Status = EFI_SUCCESS;
AuthenticationStatus = 0;
//
// Try to get the image device handle by checking the match protocol.
//
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &HandleFilePath, &DeviceHandle);
if (EFI_ERROR(Status)) {
return Status;
}
//
// If the Security Architectural Protocol has not been located yet, then attempt to locate it
//
if (mSecurity == NULL) {
gBS->LocateProtocol (&gEfiSecurityArchProtocolGuid, NULL, (VOID**)&mSecurity);
}
//
// Verify the Authentication Status through the Security Architectural Protocol
//
if ((mSecurity != NULL) && (OriginalFilePath != NULL)) {
SecurityStatus = mSecurity->FileAuthenticationState (
mSecurity,
AuthenticationStatus,
OriginalFilePath
);
if (EFI_ERROR (SecurityStatus) && SecurityStatus != EFI_SECURITY_VIOLATION) {
Status = SecurityStatus;
return Status;
}
}
//
// Pull out just the file portion of the DevicePath for the LoadedImage FilePath
//
FilePath = OriginalFilePath;
Status = gBS->HandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, (VOID **)&HandleFilePath);
if (!EFI_ERROR (Status)) {
FilePathSize = GetDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
FilePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *)FilePath) + FilePathSize );
}
//
// Try reading PE32 section firstly
//
Status = Fv->ReadSection (
Fv,
NameGuid,
EFI_SECTION_PE32,
0,
&Buffer,
&Size,
&AuthenticationStatus
);
if (EFI_ERROR (Status)) {
//
// Try reading TE section secondly
//
//.........这里部分代码省略.........
示例5:
EFI_STATUS
EFIAPI
GetVbtData (
OUT EFI_PHYSICAL_ADDRESS *VbtAddress,
OUT UINT32 *VbtSize
)
{
EFI_STATUS Status;
UINTN FvProtocolCount;
EFI_HANDLE *FvHandles;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
UINTN Index;
UINT32 AuthenticationStatus;
UINT8 *Buffer;
UINTN VbtBufferSize;
Buffer = 0;
FvHandles = NULL;
if (VbtAddress == NULL || VbtSize == NULL){
return EFI_INVALID_PARAMETER;
}
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&FvProtocolCount,
&FvHandles
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < FvProtocolCount; Index++) {
Status = gBS->HandleProtocol (
FvHandles[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv
);
VbtBufferSize = 0;
Status = Fv->ReadSection (
Fv,
&gBmpImageGuid,
EFI_SECTION_RAW,
0,
(void **)&Buffer,
&VbtBufferSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
*VbtAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
*VbtSize = (UINT32)VbtBufferSize;
Status = EFI_SUCCESS;
break;
}
}
} else {
Status = EFI_NOT_FOUND;
}
if (FvHandles != NULL) {
gBS->FreePool (FvHandles);
FvHandles = NULL;
}
return Status;
}
示例6: LocateFvInstanceWithTables
/**
Entrypoint of Acpi Platform driver.
@param ImageHandle
@param SystemTable
@return EFI_SUCCESS
@return EFI_LOAD_ERROR
@return EFI_OUT_OF_RESOURCES
**/
EFI_STATUS
EFIAPI
AcpiPlatformEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
INTN Instance;
EFI_ACPI_COMMON_HEADER *CurrentTable;
UINTN TableHandle;
UINT32 FvStatus;
UINTN TableSize;
UINTN Size;
Instance = 0;
CurrentTable = NULL;
TableHandle = 0;
//
// Find the AcpiTable protocol
//
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Locate the firmware volume protocol
//
Status = LocateFvInstanceWithTables (&FwVol);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Read tables from the storage file.
//
while (Status == EFI_SUCCESS) {
Status = FwVol->ReadSection (
FwVol,
(EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile),
EFI_SECTION_RAW,
Instance,
(VOID**) &CurrentTable,
&Size,
&FvStatus
);
if (!EFI_ERROR(Status)) {
//
// Add the table
//
TableHandle = 0;
TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;
ASSERT (Size >= TableSize);
//
// Checksum ACPI table
//
AcpiPlatformChecksum ((UINT8*)CurrentTable, TableSize);
//
// Install ACPI table
//
Status = AcpiTable->InstallAcpiTable (
AcpiTable,
CurrentTable,
TableSize,
&TableHandle
);
//
// Free memory allocated by ReadSection
//
gBS->FreePool (CurrentTable);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
//
// Increment the instance
//
Instance++;
CurrentTable = NULL;
}
//.........这里部分代码省略.........
示例7: ASSERT
/**
Allocate and fill a buffer from a Firmware Section identified by a Firmware File GUID name, a Firmware
Section type and instance number from the specified Firmware Volume.
This functions first locate the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance on FvHandle in order to
carry out the Firmware Volume read operation. The function then reads the Firmware Section found sepcifed
by NameGuid, SectionType and SectionInstance.
The details of this search order is defined in description of EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection ()
found in PI Specification.
If SectionType is EFI_SECTION_TE, EFI_SECTION_TE is used as section type to start the search. If EFI_SECTION_TE section
is not found, EFI_SECTION_PE32 will be used to try the search again. If no EFI_SECTION_PE32 section is found, EFI_NOT_FOUND
is returned.
The data and size is returned by Buffer and Size. The caller is responsible to free the Buffer allocated
by this function. This function can be only called at TPL_NOTIFY and below.
If FvHandle is NULL, then ASSERT ();
If NameGuid is NULL, then ASSERT();
If Buffer is NULL, then ASSERT();
If Size is NULL, then ASSERT().
@param FvHandle The device handle that contains a instance of
EFI_FIRMWARE_VOLUME2_PROTOCOL instance.
@param NameGuid The GUID name of a Firmware File.
@param SectionType The Firmware Section type.
@param SectionInstance The instance number of Firmware Section to
read from starting from 0.
@param Buffer On output, Buffer contains the the data read
from the section in the Firmware File found.
@param Size On output, the size of Buffer.
@retval EFI_SUCCESS The image is found and data and size is returned.
@retval EFI_NOT_FOUND The image specified by NameGuid and SectionType
can't be found.
@retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
output data buffer or complete the operations.
@retval EFI_DEVICE_ERROR A hardware error occurs during reading from the
Firmware Volume.
@retval EFI_ACCESS_DENIED The firmware volume containing the searched
Firmware File is configured to disallow reads.
**/
EFI_STATUS
InternalGetSectionFromFv (
IN EFI_HANDLE FvHandle,
IN CONST EFI_GUID *NameGuid,
IN EFI_SECTION_TYPE SectionType,
IN UINTN SectionInstance,
OUT VOID **Buffer,
OUT UINTN *Size
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
UINT32 AuthenticationStatus;
ASSERT (NameGuid != NULL);
ASSERT (Buffer != NULL);
ASSERT (Size != NULL);
ASSERT (FvHandle != NULL);
Status = gBS->HandleProtocol (
FvHandle,
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv
);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
//
// Read desired section content in NameGuid file
//
*Buffer = NULL;
*Size = 0;
Status = Fv->ReadSection (
Fv,
NameGuid,
SectionType,
SectionInstance,
Buffer,
Size,
&AuthenticationStatus
);
if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {
//
// Try reading PE32 section, if the required section is TE type
//
*Buffer = NULL;
*Size = 0;
Status = Fv->ReadSection (
Fv,
NameGuid,
EFI_SECTION_PE32,
SectionInstance,
Buffer,
//.........这里部分代码省略.........
示例8: LocateFvInstanceWithTables
/**
Find ACPI tables in an FV and parses them. This function is useful for QEMU and KVM.
@param AcpiTable Protocol instance pointer
**/
EFI_STATUS
EFIAPI
FindAcpiTablesInFv (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
INTN Instance;
EFI_ACPI_COMMON_HEADER *CurrentTable;
UINTN TableHandle;
UINT32 FvStatus;
UINTN TableSize;
UINTN Size;
EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction;
Instance = 0;
CurrentTable = NULL;
TableHandle = 0;
if (QemuDetected ()) {
TableInstallFunction = QemuInstallAcpiTable;
} else {
TableInstallFunction = InstallAcpiTable;
}
//
// Locate the firmware volume protocol
//
Status = LocateFvInstanceWithTables (&FwVol);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Read tables from the storage file.
//
while (Status == EFI_SUCCESS) {
Status = FwVol->ReadSection (
FwVol,
(EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile),
EFI_SECTION_RAW,
Instance,
(VOID**) &CurrentTable,
&Size,
&FvStatus
);
if (!EFI_ERROR (Status)) {
//
// Add the table
//
TableHandle = 0;
TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;
ASSERT (Size >= TableSize);
//
// Install ACPI table
//
Status = TableInstallFunction (
AcpiTable,
CurrentTable,
TableSize,
&TableHandle
);
//
// Free memory allocated by ReadSection
//
gBS->FreePool (CurrentTable);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Increment the instance
//
Instance++;
CurrentTable = NULL;
}
}
return EFI_SUCCESS;
}
示例9: section
/**
Firmware volume inherits authentication status from the FV image file and section(in another firmware volume)
where it came from.
@param FvDevice A pointer to the FvDevice.
**/
VOID
FwVolInheritAuthenticationStatus (
IN FV_DEVICE *FvDevice
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME_HEADER *CachedFvHeader;
EFI_FIRMWARE_VOLUME_EXT_HEADER *CachedFvExtHeader;
EFI_FIRMWARE_VOLUME2_PROTOCOL *ParentFvProtocol;
UINTN Key;
EFI_GUID FileNameGuid;
EFI_FV_FILETYPE FileType;
EFI_FV_FILE_ATTRIBUTES FileAttributes;
UINTN FileSize;
EFI_SECTION_TYPE SectionType;
UINT32 AuthenticationStatus;
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_FIRMWARE_VOLUME_EXT_HEADER *FvExtHeader;
UINTN BufferSize;
CachedFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvDevice->CachedFv;
if (FvDevice->Fv.ParentHandle != NULL) {
//
// By Parent Handle, find out the FV image file and section(in another firmware volume) where the firmware volume came from
//
Status = gBS->HandleProtocol (FvDevice->Fv.ParentHandle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **) &ParentFvProtocol);
if (!EFI_ERROR (Status) && (ParentFvProtocol != NULL)) {
Key = 0;
do {
FileType = EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE;
Status = ParentFvProtocol->GetNextFile (
ParentFvProtocol,
&Key,
&FileType,
&FileNameGuid,
&FileAttributes,
&FileSize
);
if (EFI_ERROR (Status)) {
return;
}
SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
FvHeader = NULL;
BufferSize = 0;
Status = ParentFvProtocol->ReadSection (
ParentFvProtocol,
&FileNameGuid,
SectionType,
0,
(VOID **) &FvHeader,
&BufferSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
if ((FvHeader->FvLength == CachedFvHeader->FvLength) &&
(FvHeader->ExtHeaderOffset == CachedFvHeader->ExtHeaderOffset)) {
if (FvHeader->ExtHeaderOffset !=0) {
//
// Both FVs contain extension header, then compare their FV Name GUID
//
FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINTN) FvHeader + FvHeader->ExtHeaderOffset);
CachedFvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINTN) CachedFvHeader + CachedFvHeader->ExtHeaderOffset);
if (CompareGuid (&FvExtHeader->FvName, &CachedFvExtHeader->FvName)) {
//
// Found the FV image section where the firmware volume came from,
// and then inherit authentication status from it.
//
FvDevice->AuthenticationStatus = AuthenticationStatus;
FreePool ((VOID *) FvHeader);
return;
}
} else {
//
// Both FVs don't contain extension header, then compare their whole FV Image.
//
if (CompareMem ((VOID *) FvHeader, (VOID *) CachedFvHeader, (UINTN) FvHeader->FvLength) == 0) {
//
// Found the FV image section where the firmware volume came from
// and then inherit authentication status from it.
//
FvDevice->AuthenticationStatus = AuthenticationStatus;
FreePool ((VOID *) FvHeader);
return;
}
}
}
FreePool ((VOID *) FvHeader);
}
} while (TRUE);
}
//.........这里部分代码省略.........
示例10: LocateSupportProtocol
EFI_STATUS
PublishAcpiTablesFromFv (
VOID
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
EFI_ACPI_COMMON_HEADER *CurrentTable;
UINT32 FvStatus;
UINTN Size;
EFI_ACPI_TABLE_VERSION Version;
UINTN TableHandle;
INTN Instance;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
Instance = 0;
TableHandle = 0;
CurrentTable = NULL;
FwVol = NULL;
//
// Find the AcpiTable protocol
//
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Locate the firmware volume protocol
//
Status = LocateSupportProtocol (&gEfiFirmwareVolume2ProtocolGuid, (VOID**)&FwVol, 1);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
//
// Read tables from the storage file.
//
while (Status == EFI_SUCCESS) {
Status = FwVol->ReadSection (
FwVol,
&gEfiCallerIdGuid,
EFI_SECTION_RAW,
Instance,
(VOID**)&CurrentTable,
&Size,
&FvStatus
);
if (!EFI_ERROR(Status)) {
//
// Perform any table specific updates.
//
AcpiUpdateTable ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable, &Version);
//
// Add the table
//
TableHandle = 0;
Status = AcpiTable->InstallAcpiTable (
AcpiTable,
CurrentTable,
((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length,
&TableHandle
);
if (EFI_ERROR(Status)) {
return EFI_ABORTED;
}
//
// Increment the instance
//
Instance++;
CurrentTable = NULL;
}
}
//
// Finished
//
return EFI_SUCCESS;
}
示例11: EfiGetCwd
//.........这里部分代码省略.........
do {
Type = SearchType;
GetNextFileStatus = Fv->GetNextFile (
Fv,
&Key,
&Type,
&NameGuid,
&Attributes,
&Size
);
if (!EFI_ERROR (GetNextFileStatus)) {
TotalSize += Size;
// Calculate size of entire file
Section = NULL;
Size = 0;
Status = Fv->ReadFile (
Fv,
&NameGuid,
Section,
&Size,
&Type,
&Attributes,
&AuthenticationStatus
);
if (!((Status == EFI_BUFFER_TOO_SMALL) || !EFI_ERROR (Status))) {
// EFI_SUCCESS or EFI_BUFFER_TOO_SMALL mean size is valid
Size = 0;
}
TypeStr = (Type <= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) ? gFvFileType[Type] : "UNKNOWN";
// read the UI seciton to do a name match.
Section = NULL;
Status = Fv->ReadSection (
Fv,
&NameGuid,
EFI_SECTION_USER_INTERFACE,
0,
&Section,
&SectionSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
if (StrStr (Section, MatchSubString) != NULL) {
AsciiPrint ("%,9d %7a %g %s\n", Size, TypeStr, &NameGuid, Section);
if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
break;
}
}
FreePool (Section);
} else {
if (*MatchSubString == '\0') {
AsciiPrint ("%,9d %7a %g\n", Size, TypeStr, &NameGuid);
if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
break;
}
}
}
}
} while (!EFI_ERROR (GetNextFileStatus));
if (SearchType == EFI_FV_FILETYPE_ALL) {
AsciiPrint ("%,20d bytes in files %,d bytes free\n", TotalSize, File->FvSize - File->FvHeaderSize - TotalSize);
}
示例12: DuplicateDevicePath
EFIAPI
GetFileBufferByFilePath (
IN BOOLEAN BootPolicy,
IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath,
OUT UINTN *FileSize,
OUT UINT32 *AuthenticationStatus
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *OrigDevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePathNode;
EFI_HANDLE Handle;
EFI_GUID *FvNameGuid;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
EFI_SECTION_TYPE SectionType;
UINT8 *ImageBuffer;
UINTN ImageBufferSize;
EFI_FV_FILETYPE Type;
EFI_FV_FILE_ATTRIBUTES Attrib;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
EFI_FILE_HANDLE FileHandle;
EFI_FILE_HANDLE LastHandle;
EFI_FILE_INFO *FileInfo;
UINTN FileInfoSize;
EFI_LOAD_FILE_PROTOCOL *LoadFile;
EFI_LOAD_FILE2_PROTOCOL *LoadFile2;
EFI_STATUS Status;
//
// Check input File device path.
//
if (FilePath == NULL || FileSize == NULL || AuthenticationStatus == NULL) {
return NULL;
}
//
// Init local variable
//
TempDevicePathNode = NULL;
FvNameGuid = NULL;
FileInfo = NULL;
FileHandle = NULL;
ImageBuffer = NULL;
ImageBufferSize = 0;
*AuthenticationStatus = 0;
//
// Copy File Device Path
//
OrigDevicePathNode = DuplicateDevicePath (FilePath);
if (OrigDevicePathNode == NULL) {
return NULL;
}
//
// Check whether this device path support FV2 protocol.
// Is so, this device path may contain a Image.
//
DevicePathNode = OrigDevicePathNode;
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePathNode, &Handle);
if (!EFI_ERROR (Status)) {
//
// For FwVol File system there is only a single file name that is a GUID.
//
FvNameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePathNode);
if (FvNameGuid == NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
//
// Read image from the firmware file
//
Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID**)&FwVol);
if (!EFI_ERROR (Status)) {
SectionType = EFI_SECTION_PE32;
ImageBuffer = NULL;
Status = FwVol->ReadSection (
FwVol,
FvNameGuid,
SectionType,
0,
(VOID **)&ImageBuffer,
&ImageBufferSize,
AuthenticationStatus
);
if (EFI_ERROR (Status)) {
//
// Try a raw file, since a PE32 SECTION does not exist
//
if (ImageBuffer != NULL) {
FreePool (ImageBuffer);
*AuthenticationStatus = 0;
}
ImageBuffer = NULL;
Status = FwVol->ReadFile (
FwVol,
FvNameGuid,
(VOID **)&ImageBuffer,
&ImageBufferSize,
&Type,
&Attrib,
//.........这里部分代码省略.........
示例13: DEBUG
EFI_STATUS
FindApplicationMatchingUiSection (
IN CHAR16 *UiString,
OUT EFI_HANDLE *FvHandle,
OUT EFI_GUID *NameGuid
)
{
EFI_STATUS Status;
EFI_STATUS NextStatus;
UINTN NoHandles;
EFI_HANDLE *Buffer;
UINTN Index;
EFI_FV_FILETYPE FileType;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
VOID *Key;
EFI_FV_FILE_ATTRIBUTES Attributes;
UINTN Size;
UINTN UiStringLen;
CHAR16 *UiSection;
UINT32 Authentication;
UiStringLen = 0;
if (UiString != NULL) {
DEBUG ((DEBUG_ERROR, "UiString %s\n", UiString));
UiStringLen = StrLen (UiString);
}
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &NoHandles, &Buffer);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < NoHandles; Index++) {
Status = gBS->HandleProtocol (Buffer[Index], &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);
if (!EFI_ERROR (Status)) {
Key = AllocatePool (Fv->KeySize);
ASSERT (Key != NULL);
ZeroMem (Key, Fv->KeySize);
FileType = EFI_FV_FILETYPE_APPLICATION;
do {
NextStatus = Fv->GetNextFile (Fv, Key, &FileType, NameGuid, &Attributes, &Size);
if (!EFI_ERROR (NextStatus)) {
if (UiString == NULL) {
//
// If UiString is NULL match first application we find.
//
*FvHandle = Buffer[Index];
FreePool (Key);
return Status;
}
UiSection = NULL;
Status = Fv->ReadSection (
Fv,
NameGuid,
EFI_SECTION_USER_INTERFACE,
0,
(VOID **)&UiSection,
&Size,
&Authentication
);
if (!EFI_ERROR (Status)) {
if (StrnCmp (UiString, UiSection, UiStringLen) == 0) {
//
// We found a UiString match.
//
*FvHandle = Buffer[Index];
FreePool (Key);
FreePool (UiSection);
return Status;
}
FreePool (UiSection);
}
}
} while (!EFI_ERROR (NextStatus));
FreePool (Key);
}
}
FreePool (Buffer);
}
return EFI_NOT_FOUND;
}
示例14: FillSysTablesInfo
/**
Entrypoint of Acpi Platform driver.
@param ImageHandle
@param SystemTable
@return EFI_SUCCESS
@return EFI_LOAD_ERROR
@return EFI_OUT_OF_RESOURCES
**/
EFI_STATUS
EFIAPI
AcpiPlatformEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
#ifdef VBOX
VOID *VBoxTables[10];
#else
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
#endif
INTN Instance;
EFI_ACPI_COMMON_HEADER *CurrentTable;
UINTN TableHandle;
#ifndef VBOX
UINT32 FvStatus;
#endif
UINTN TableSize;
UINTN Size;
Instance = 0;
CurrentTable = NULL;
TableHandle = 0;
//
// Find the AcpiTable protocol
//
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
#ifdef VBOX
//
// VBOX already has tables prepared in memory - just reuse them.
//
FillSysTablesInfo(VBoxTables, sizeof(VBoxTables)/sizeof(VBoxTables[0]));
#else
//
//
// Locate the firmware volume protocol
//
Status = LocateFvInstanceWithTables (&FwVol);
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
#endif
//
// Read tables from the storage file.
//
while (Status == EFI_SUCCESS) {
#ifdef VBOX
CurrentTable = (EFI_ACPI_COMMON_HEADER *)VBoxTables[Instance];
Status = (CurrentTable == NULL) ? EFI_NOT_FOUND : EFI_SUCCESS;
if (CurrentTable) {
Size = CurrentTable->Length;
DEBUG((EFI_D_ERROR, "adding %p %d\n", CurrentTable, Size));
} else
Size = 0; // Just to shut up the compiler.
#else
Status = FwVol->ReadSection (
FwVol,
(EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile),
EFI_SECTION_RAW,
Instance,
(VOID**) &CurrentTable,
&Size,
&FvStatus
);
#endif
if (!EFI_ERROR(Status)) {
//
// Add the table
//
TableHandle = 0;
TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;
#ifdef VBOX
DEBUG((DEBUG_INFO, "Size:%d, TableSize:%d\n", Size, TableSize));
#endif
ASSERT (Size >= TableSize);
//
// Checksum ACPI table
//
//.........这里部分代码省略.........
示例15: OpenVolume
/**
Open the root directory on a volume.
@param This A pointer to the volume to open the root directory.
@param RootFile A pointer to the location to return the opened file handle for the
root directory.
@retval EFI_SUCCESS The device was opened.
@retval EFI_UNSUPPORTED This volume does not support the requested file system type.
@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_ACCESS_DENIED The service denied access to the file.
@retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
@retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
longer supported. Any existing file handles for this volume are
no longer valid. To access the files on the new medium, the
volume must be reopened with OpenVolume().
**/
EFI_STATUS
EFIAPI
FvSimpleFileSystemOpenVolume (
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
OUT EFI_FILE_PROTOCOL **RootFile
)
{
EFI_STATUS Status;
FV_FILESYSTEM_FILE *Root;
CHAR16 *UiSection;
EFI_GUID NameGuid;
EFI_FV_FILE_ATTRIBUTES Attributes;
UINT32 Authentication;
UINTN Key;
EFI_FV_FILETYPE FileType;
UINTN Size;
FV_FILESYSTEM_INSTANCE *Instance;
FV_FILESYSTEM_FILE_INFO *FvFileInfo;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvProtocol;
CHAR16 *Name;
UINTN NameLen;
UINTN NumChars;
UINTN DestMax;
Instance = FVFS_INSTANCE_FROM_SIMPLE_FS_THIS (This);
Status = EFI_SUCCESS;
if (Instance->Root == NULL) {
//
// Allocate file structure for root file
//
Root = AllocateZeroPool (sizeof (FV_FILESYSTEM_FILE));
if (Root == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Instance->Root = Root;
Root->Instance = Instance;
Root->Signature = FVFS_FILE_SIGNATURE;
CopyMem (&Root->FileProtocol, &mFileSystemTemplate, sizeof (mFileSystemTemplate));
Root->FvFileInfo = AllocateZeroPool (sizeof (FV_FILESYSTEM_FILE_INFO));
if (Root->FvFileInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Root->FvFileInfo->FileInfo.Size = sizeof (EFI_FILE_INFO);
Root->FvFileInfo->FileInfo.Attribute = EFI_FILE_DIRECTORY | EFI_FILE_READ_ONLY;
//
// Populate the instance's list of files. We consider anything a file that
// has a UI_SECTION, which we consider to be its filename.
//
FvProtocol = Instance->FvProtocol;
//
// Allocate Key
//
Key = 0;
do {
FileType = EFI_FV_FILETYPE_ALL;
Status = FvProtocol->GetNextFile (
FvProtocol,
&Key,
&FileType,
&NameGuid,
&Attributes,
&Size
);
if (EFI_ERROR (Status)) {
ASSERT (Status == EFI_NOT_FOUND);
break;
}
//
// Get a file's name: If it has a UI section, use that, otherwise use
// its NameGuid.
//
UiSection = NULL;
Status = FvProtocol->ReadSection (
FvProtocol,
//.........这里部分代码省略.........