本文整理汇总了C++中EFI_BLOCK_IO_PROTOCOL::FlushBlocks方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_BLOCK_IO_PROTOCOL::FlushBlocks方法的具体用法?C++ EFI_BLOCK_IO_PROTOCOL::FlushBlocks怎么用?C++ EFI_BLOCK_IO_PROTOCOL::FlushBlocks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_BLOCK_IO_PROTOCOL
的用法示例。
在下文中一共展示了EFI_BLOCK_IO_PROTOCOL::FlushBlocks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FreePool
//.........这里部分代码省略.........
gBS->CloseProtocol (
ControllerHandle,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
return EFI_SUCCESS;
}
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIoProtocolGuid,
(VOID **) &BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
//
// Try to locate BlockIo2.
//
gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIo2ProtocolGuid,
(VOID **) &BlockIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
Status = gBS->CloseProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ChildHandleBuffer[Index]
);
//
// All Software protocols have be freed from the handle so remove it.
// Remove the BlockIo Protocol if has.
// Remove the BlockIo2 Protocol if has.
//
if (BlockIo2 != NULL) {
BlockIo->FlushBlocks (BlockIo);
BlockIo2->FlushBlocksEx (BlockIo2, NULL);
Status = gBS->UninstallMultipleProtocolInterfaces (
ChildHandleBuffer[Index],
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
&gEfiBlockIoProtocolGuid,
&Private->BlockIo,
&gEfiBlockIo2ProtocolGuid,
&Private->BlockIo2,
Private->EspGuid,
NULL,
NULL
);
} else {
BlockIo->FlushBlocks (BlockIo);
Status = gBS->UninstallMultipleProtocolInterfaces (
ChildHandleBuffer[Index],
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
&gEfiBlockIoProtocolGuid,
&Private->BlockIo,
Private->EspGuid,
NULL,
NULL
);
}
if (EFI_ERROR (Status)) {
gBS->OpenProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
(VOID **) &DiskIo,
This->DriverBindingHandle,
ChildHandleBuffer[Index],
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
);
} else {
FreePool (Private->DevicePath);
FreePool (Private);
}
if (EFI_ERROR (Status)) {
AllChildrenStopped = FALSE;
}
}
if (!AllChildrenStopped) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
示例2: AsciiStrToUnicodeStr
EFI_STATUS
ArmFastbootPlatformFlashPartition (
IN CHAR8 *PartitionName,
IN UINTN Size,
IN VOID *Image
)
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_DISK_IO_PROTOCOL *DiskIo;
UINT32 MediaId;
UINTN PartitionSize;
FASTBOOT_PARTITION_LIST *Entry;
CHAR16 PartitionNameUnicode[60];
BOOLEAN PartitionFound;
AsciiStrToUnicodeStr (PartitionName, PartitionNameUnicode);
PartitionFound = FALSE;
Entry = (FASTBOOT_PARTITION_LIST *) GetFirstNode (&(mPartitionListHead));
while (!IsNull (&mPartitionListHead, &Entry->Link)) {
// Search the partition list for the partition named by PartitionName
if (StrCmp (Entry->PartitionName, PartitionNameUnicode) == 0) {
PartitionFound = TRUE;
break;
}
Entry = (FASTBOOT_PARTITION_LIST *) GetNextNode (&mPartitionListHead, &(Entry)->Link);
}
if (!PartitionFound) {
return EFI_NOT_FOUND;
}
Status = gBS->OpenProtocol (
Entry->PartitionHandle,
&gEfiBlockIoProtocolGuid,
(VOID **) &BlockIo,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Fastboot platform: couldn't open Block IO for flash: %r\n", Status));
return EFI_NOT_FOUND;
}
// Check image will fit on device
PartitionSize = (BlockIo->Media->LastBlock + 1) * BlockIo->Media->BlockSize;
if (PartitionSize < Size) {
DEBUG ((EFI_D_ERROR, "Partition not big enough.\n"));
DEBUG ((EFI_D_ERROR, "Partition Size:\t%d\nImage Size:\t%d\n", PartitionSize, Size));
return EFI_VOLUME_FULL;
}
MediaId = BlockIo->Media->MediaId;
Status = gBS->OpenProtocol (
Entry->PartitionHandle,
&gEfiDiskIoProtocolGuid,
(VOID **) &DiskIo,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
ASSERT_EFI_ERROR (Status);
Status = DiskIo->WriteDisk (DiskIo, MediaId, 0, Size, Image);
if (EFI_ERROR (Status)) {
return Status;
}
BlockIo->FlushBlocks(BlockIo);
return Status;
}
示例3: DEBUG
//.........这里部分代码省略.........
AllChildrenStopped = TRUE;
for (Index = 0; Index < NumberOfChildren; Index++) {
gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIoProtocolGuid,
(VOID **) &BlockIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
//
// Try to locate BlockIo2.
//
gBS->OpenProtocol (
ChildHandleBuffer[Index],
&gEfiBlockIo2ProtocolGuid,
(VOID **) &BlockIo2,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
if (Private->InStop) {
//
// If the child handle is going to be stopped again during the re-entry
// of DriverBindingStop, just do nothing.
//
break;
}
Private->InStop = TRUE;
BlockIo->FlushBlocks (BlockIo);
if (BlockIo2 != NULL) {
Status = BlockIo2->FlushBlocksEx (BlockIo2, NULL);
DEBUG((EFI_D_ERROR, "PartitionDriverBindingStop: FlushBlocksEx returned with %r\n", Status));
} else {
Status = EFI_SUCCESS;
}
gBS->CloseProtocol (
ControllerHandle,
&gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ChildHandleBuffer[Index]
);
if (IsZeroGuid (&Private->TypeGuid)) {
TypeGuid = NULL;
} else {
TypeGuid = &Private->TypeGuid;
}
//
// All Software protocols have be freed from the handle so remove it.
// Remove the BlockIo Protocol if has.
// Remove the BlockIo2 Protocol if has.
//
if (BlockIo2 != NULL) {
//
// Some device drivers might re-install the BlockIO(2) protocols for a
// media change condition. Therefore, if the FlushBlocksEx returned with
// EFI_MEDIA_CHANGED, just let the BindingStop fail to avoid potential
// reference of already stopped child handle.
示例4: LocateDevicePathFromBlockIo
//.........这里部分代码省略.........
StatusRead1 = BlockIo->ReadBlocks (
BlockIo,
MediaId,
NewLba,
NewBufferSize,
(VOID*)Buffer
);
if (EFI_ERROR(StatusRead1)) {
AssertionTypeRead1 = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionTypeRead1 = EFI_TEST_ASSERTION_PASSED;
}
//
// Write specified buffer2 differ from buffer to the device
//
StatusWrite1 = BlockIo->WriteBlocks (
BlockIo,
MediaId,
NewLba,
NewBufferSize,
(VOID*)Buffer2
);
if (EFI_ERROR(StatusWrite1)) {
AssertionTypeWrite1 = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionTypeWrite1 = EFI_TEST_ASSERTION_PASSED;
}
//
// if write-cached, then flush the data to physical device
//
if (WriteCaching) {
BlockIo->FlushBlocks (BlockIo);
}
//
// Read Block with same LBA and BufferSize again and save data into Buffer3
//
StatusRead2 = BlockIo->ReadBlocks (
BlockIo,
MediaId,
NewLba,
NewBufferSize,
(VOID*)Buffer3
);
if (EFI_ERROR(StatusRead2)) {
AssertionTypeRead2 = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionTypeRead2 = EFI_TEST_ASSERTION_PASSED;
}
//
// verification on Write and Read blocks on valid media
//
CountComp1 = VerifyBuffer (Buffer2, Buffer3, NewBufferSize);
if (CountComp1 > 0) {
AssertionTypeComp1 = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionTypeComp1 = EFI_TEST_ASSERTION_PASSED;
}
//
// Write buffer read in the first call of ReadBlocks back to the device
//
StatusWrite2 = BlockIo->WriteBlocks (
示例5: BootMonFsFindSpaceForNewFile
//.........这里部分代码省略.........
BlockIo = Instance->BlockIo;
DiskIo = Instance->DiskIo;
BlockSize = BlockIo->Media->BlockSize;
// If the file doesn't exist then find a space for it
if (File->HwDescription.RegionCount == 0) {
Status = BootMonFsFindSpaceForNewFile (File, &FileStart);
// FileStart has changed so we need to recompute RegionEnd
if (EFI_ERROR (Status)) {
return Status;
}
} else {
FileStart = File->HwDescription.BlockStart * BlockSize;
}
// FileEnd is the NOR address of the end of the file's data
FileEnd = FileStart + BootMonFsGetImageLength (File);
for (RegionToFlushLink = GetFirstNode (&File->RegionToFlushLink);
!IsNull (&File->RegionToFlushLink, RegionToFlushLink);
RegionToFlushLink = GetNextNode (&File->RegionToFlushLink, RegionToFlushLink)
)
{
Region = (BOOTMON_FS_FILE_REGION*)RegionToFlushLink;
// RegionStart and RegionEnd are the the intended NOR address of the
// start and end of the region
RegionStart = FileStart + Region->Offset;
RegionEnd = RegionStart + Region->Size;
if (RegionEnd < FileEnd) {
// Handle regions representing edits to existing portions of the file
// Write the region data straight into the file
Status = DiskIo->WriteDisk (DiskIo,
BlockIo->Media->MediaId,
RegionStart,
Region->Size,
Region->Buffer
);
if (EFI_ERROR (Status)) {
return Status;
}
} else {
// Handle regions representing appends to the file
//
// Note: Since seeking past the end of the file with SetPosition() is
// valid, it's possible there will be a gap between the current end of
// the file and the beginning of the new region. Since the UEFI spec
// says nothing about this case (except "a subsequent write would grow
// the file"), we just leave garbage in the gap.
// Check if there is space to append the new region
HasSpace = FALSE;
NewFileSize = (RegionEnd - FileStart) + sizeof (HW_IMAGE_DESCRIPTION);
CurrentPhysicalSize = BootMonFsGetPhysicalSize (File);
if (NewFileSize <= CurrentPhysicalSize) {
HasSpace = TRUE;
} else {
// Get the File Description for the next file
FileLink = GetNextNode (&Instance->RootFile->Link, &File->Link);
if (!IsNull (&Instance->RootFile->Link, FileLink)) {
NextFile = BOOTMON_FS_FILE_FROM_LINK_THIS (FileLink);
// If there is space between the beginning of the current file and the
// beginning of the next file then use it
EndOfAppendSpace = NextFile->HwDescription.BlockStart * BlockSize;
} else {
// We are flushing the last file.
EndOfAppendSpace = (BlockIo->Media->LastBlock + 1) * BlockSize;
}
if (EndOfAppendSpace - FileStart >= NewFileSize) {
HasSpace = TRUE;
}
}
if (HasSpace == TRUE) {
Status = FlushAppendRegion (File, Region, NewFileSize, FileStart);
if (EFI_ERROR (Status)) {
return Status;
}
} else {
// There isn't a space for the file.
// Options here are to move the file or fragment it. However as files
// may represent boot images at fixed positions, these options will
// break booting if the bootloader doesn't use BootMonFs to find the
// image.
return EFI_VOLUME_FULL;
}
}
}
FreeFileRegions (File);
// Flush DiskIo Buffers (see UEFI Spec 12.7 - DiskIo buffers are flushed by
// calling FlushBlocks on the same device's BlockIo).
BlockIo->FlushBlocks (BlockIo);
return Status;
}