本文整理汇总了C++中EFI_BLOCK_IO_PROTOCOL::ReadBlocks方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_BLOCK_IO_PROTOCOL::ReadBlocks方法的具体用法?C++ EFI_BLOCK_IO_PROTOCOL::ReadBlocks怎么用?C++ EFI_BLOCK_IO_PROTOCOL::ReadBlocks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_BLOCK_IO_PROTOCOL
的用法示例。
在下文中一共展示了EFI_BLOCK_IO_PROTOCOL::ReadBlocks方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEBUG
EFI_STATUS
CheckStore (
IN EFI_HANDLE SimpleFileSystemHandle,
IN UINT32 VolumeId,
OUT EFI_DEVICE_PATH_PROTOCOL **Device
)
{
#define BLOCK_SIZE 0x200
#define FAT16_VOLUME_ID_OFFSET 39
#define FAT32_VOLUME_ID_OFFSET 67
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlkIo;
UINT8 BootSector[BLOCK_SIZE];
*Device = NULL;
Status = gBS->HandleProtocol (
SimpleFileSystemHandle,
&gEfiBlockIoProtocolGuid, // BlockIo should be supported if it supports SimpleFileSystem
(VOID*)&BlkIo
);
if (EFI_ERROR (Status)) {
goto ErrHandle;
}
if (!BlkIo->Media->MediaPresent) {
DEBUG ((EFI_D_ERROR, "FwhMappedFile: Media not present!\n"));
Status = EFI_NO_MEDIA;
goto ErrHandle;
}
if (BlkIo->Media->ReadOnly) {
DEBUG ((EFI_D_ERROR, "FwhMappedFile: Media is read-only!\n"));
Status = EFI_ACCESS_DENIED;
goto ErrHandle;
}
Status = BlkIo->ReadBlocks(
BlkIo,
BlkIo->Media->MediaId,
0,
BLOCK_SIZE,
BootSector
);
ASSERT_EFI_ERROR (Status);
if ((*(UINT32 *) &BootSector[FAT16_VOLUME_ID_OFFSET] != VolumeId) &&
(*(UINT32 *) &BootSector[FAT32_VOLUME_ID_OFFSET] != VolumeId)
) {
Status = EFI_NOT_FOUND;
goto ErrHandle;
}
*Device = DuplicateDevicePath (DevicePathFromHandle (SimpleFileSystemHandle));
ASSERT (*Device != NULL);
ErrHandle:
return Status;
}
示例2: AllocatePool
EFI_STATUS
BootMonFsDiscoverNextImage (
IN BOOTMON_FS_INSTANCE *Instance,
IN EFI_LBA *LbaStart,
OUT HW_IMAGE_DESCRIPTION *Image
)
{
EFI_BLOCK_IO_PROTOCOL *Blocks;
EFI_LBA CurrentLba;
VOID *Out;
Blocks = Instance->BlockIo;
// Allocate an output buffer
Out = AllocatePool (Instance->Media->BlockSize);
if (Out == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Blocks->Reset (Blocks, FALSE);
CurrentLba = *LbaStart;
// Look for images in the rest of this block
while (CurrentLba <= Instance->Media->LastBlock) {
// Read in the next block
Blocks->ReadBlocks (Blocks, Instance->Media->MediaId, CurrentLba, Instance->Media->BlockSize, Out);
// Check for an image in the current block
if (BootMonFsImageInThisBlock (Out, Instance->Media->BlockSize, (CurrentLba - Instance->Media->LowestAlignedLba), Image)) {
DEBUG ((EFI_D_ERROR, "Found image: %a in block %d.\n", &(Image->Footer.Filename), (UINTN)(CurrentLba - Instance->Media->LowestAlignedLba)));
FreePool (Out);
*LbaStart = Image->BlockEnd + 1;
return EFI_SUCCESS;
} else {
CurrentLba++;
}
}
*LbaStart = CurrentLba;
FreePool (Out);
return EFI_NOT_FOUND;
}
示例3: return
/**
Display blocks to the screen.
@param[in] DevPath The device path to get the blocks from.
@param[in] Lba The Lba number to start from.
@param[in] BlockCount How many blocks to display.
@retval SHELL_SUCCESS The display was successful.
**/
SHELL_STATUS
EFIAPI
DisplayTheBlocks(
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath,
IN CONST UINT64 Lba,
IN CONST UINT8 BlockCount
)
{
EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_HANDLE BlockIoHandle;
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
UINT8 *Buffer;
UINTN BufferSize;
ShellStatus = SHELL_SUCCESS;
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, (EFI_DEVICE_PATH_PROTOCOL **)&DevPath, &BlockIoHandle);
if (EFI_ERROR(Status)) {
return (SHELL_NOT_FOUND);
}
Status = gBS->OpenProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, (VOID**)&BlockIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR(Status)) {
return (SHELL_NOT_FOUND);
}
BufferSize = BlockIo->Media->BlockSize * BlockCount;
if (BufferSize > 0) {
Buffer = AllocateZeroPool(BufferSize);
} else {
ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", BlockIo->Media->BlockSize, BlockCount);
Buffer = NULL;
}
Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer);
if (!EFI_ERROR(Status) && Buffer != NULL) {
ShellPrintHiiEx(
-1,
-1,
NULL,
STRING_TOKEN (STR_DBLK_HEADER),
gShellDebug1HiiHandle,
Lba,
BufferSize,
BlockIo
);
DumpHex(2,0,BufferSize,Buffer);
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_READ_FAIL), gShellDebug1HiiHandle, L"BlockIo", Status);
ShellStatus = SHELL_DEVICE_ERROR;
}
if (Buffer != NULL) {
FreePool(Buffer);
}
gBS->CloseProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle, NULL);
return (ShellStatus);
}
示例4: StatusBarSetStatusString
/**
Read a disk from disk into HBufferImage.
@param[in] DeviceName filename to read.
@param[in] Offset The offset.
@param[in] Size The size.
@param[in] Recover if is for recover, no information print.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@retval EFI_LOAD_ERROR A load error occured.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
**/
EFI_STATUS
HDiskImageRead (
IN CONST CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
)
{
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;
EFI_DEVICE_PATH_PROTOCOL *DupDevicePathForFree;
EFI_HANDLE Handle;
EFI_BLOCK_IO_PROTOCOL *BlkIo;
EFI_STATUS Status;
VOID *Buffer;
CHAR16 *Str;
UINTN Bytes;
HEFI_EDITOR_LINE *Line;
UINT64 ByteOffset;
EDIT_FILE_TYPE BufferTypeBackup;
BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = FileTypeDiskBuffer;
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);
if (DevicePath == NULL) {
StatusBarSetStatusString (L"Cannot Find Device");
return EFI_INVALID_PARAMETER;
}
DupDevicePath = DuplicateDevicePath(DevicePath);
DupDevicePathForFree = DupDevicePath;
//
// get blkio interface
//
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle);
FreePool(DupDevicePathForFree);
if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
if (EFI_ERROR (Status)) {
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
//
// if Offset exceeds LastBlock,
// return error
//
if (Offset > BlkIo->Media->LastBlock || Offset + Size > BlkIo->Media->LastBlock) {
StatusBarSetStatusString (L"Invalid Offset + Size");
return EFI_LOAD_ERROR;
}
Bytes = BlkIo->Media->BlockSize * Size;
Buffer = AllocateZeroPool (Bytes);
if (Buffer == NULL) {
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);
//
// read from disk
//
Status = BlkIo->ReadBlocks (
BlkIo,
BlkIo->Media->MediaId,
Offset,
Bytes,
Buffer
);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_LOAD_ERROR;
}
HBufferImageFree ();
//
//.........这里部分代码省略.........
示例5: Print
//.........这里部分代码省略.........
else {
UINT32 Remainder;
UINT64 MByte;
MByte = DivU64x32Remainder ( MediaBytes,
1000 * 1000,
&Remainder );
Print ( L" Media Size: %d.%03d MiBytes (%d.%03d MBytes)\r\n",
(UINT32)DivU64x32 ( MediaBytes, MIBYTE ),
((UINT32)(( MediaBytes % MIBYTE ) / KIBYTE ) * 1000 ) / KIBYTE,
(UINT32)MByte,
Remainder / 1000 );
}
Print ( L" Test Count: %d runs\r\n", TEST_COUNT );
Print ( L" Warm-up reads: %d\r\n", WarmUpBlocks / BlocksPerRead );
Print ( L"\r\n" );
//
// Compute the timeout
//
Timeout = Seconds;
Timeout *= 1000L * 1000L * 10L;
//
// Get the media ID value
//
MediaId = pMedia->MediaId;
//
// Warm-up the data path
//
Lba = LbaMax - WarmUpBlocks;
while ( LbaMax > Lba ) {
if ( bBlockIo2 ) {
Status = pBlockIo2->ReadBlocksEx ( pBlockIo2,
MediaId,
Lba,
NULL,
BytesToRead,
&mBuffer[ 0 ]);
}
else {
Status = pBlockIo->ReadBlocks ( pBlockIo,
MediaId,
Lba,
BytesToRead,
&mBuffer[ 0 ]);
}
if ( EFI_ERROR ( Status )) {
Print ( L"ERROR - Read failure during warm-up, Lba: 0x%016Lx, Status: %r\r\n",
Lba,
Status );
break;
}
Lba += BlocksPerRead;
}
if ( !EFI_ERROR ( Status )) {
//
// Perform each of the tests
//
for ( TestCount = 1; TEST_COUNT >= TestCount; TestCount++ ) {
//
// Initialize the tokens
//
pToken = &mTokens[ 0 ];
while ( pTokenEnd > pToken ) {
gBS->SignalEvent ( pToken->Event );
示例6: ShellGetMap
EFI_STATUS
HDiskImageRead (
IN CHAR16 *DeviceName,
IN UINTN Offset,
IN UINTN Size,
IN BOOLEAN Recover
)
/*++
Routine Description:
Read a disk from disk into HBufferImage
Arguments:
DeviceName - filename to read
Offset - The offset
Size - The size
Recover - if is for recover, no information print
Returns:
EFI_SUCCESS
EFI_LOAD_ERROR
EFI_OUT_OF_RESOURCES
EFI_INVALID_PARAMETER
--*/
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_BLOCK_IO_PROTOCOL *BlkIo;
EFI_STATUS Status;
VOID *Buffer;
CHAR16 *Str;
UINTN Bytes;
HEFI_EDITOR_LINE *Line;
UINT64 ByteOffset;
HEFI_EDITOR_ACTIVE_BUFFER_TYPE BufferTypeBackup;
BufferTypeBackup = HBufferImage.BufferType;
HBufferImage.BufferType = DISK_BUFFER;
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ShellGetMap (DeviceName);
if (DevicePath == NULL) {
HMainStatusBarSetStatusString (L"Cannot Find Device");
return EFI_INVALID_PARAMETER;
}
//
// get blkio interface
//
Status = LibDevicePathToInterface (
&gEfiBlockIoProtocolGuid,
DevicePath,
&BlkIo
);
if (EFI_ERROR (Status)) {
HMainStatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
//
// if Offset exceeds LastBlock,
// return error
//
if (Offset > BlkIo->Media->LastBlock || Offset + Size > BlkIo->Media->LastBlock) {
HMainStatusBarSetStatusString (L"Invalid Offset + Size");
return EFI_LOAD_ERROR;
}
Bytes = BlkIo->Media->BlockSize * Size;
Buffer = AllocatePool (Bytes);
if (Buffer == NULL) {
HMainStatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);
//
// read from disk
//
Status = BlkIo->ReadBlocks (
BlkIo,
BlkIo->Media->MediaId,
Offset,
Bytes,
Buffer
);
if (EFI_ERROR (Status)) {
FreePool (Buffer);
HMainStatusBarSetStatusString (L"Read Disk Failed");
return EFI_LOAD_ERROR;
}
HBufferImageFree ();
//.........这里部分代码省略.........
示例7: MINIMUM
//.........这里部分代码省略.........
} else {
Print (L"Insert media into device ");
}
DevicePathStr = DevicePathToStr (DevicePath);
if (DevicePathStr != NULL) {
Print (DevicePathStr);
Status = gtBS->FreePool (DevicePathStr);
if (EFI_ERROR(Status)) {
StandardLib->RecordAssertion (
StandardLib,
EFI_TEST_ASSERTION_FAILED,
gTestGenericFailureGuid,
L"BS.FreePool - Free device path string",
L"%a:%d:Status - %r",
__FILE__,
__LINE__,
Status
);
goto FreeBuffer;
}
DevicePathStr = NULL;
}
if (AutoJudge (50, FALSE, L"\r\nReady?\r\n") != TRUE) {
goto AssertionPoint2;
}
//
// Call ReadBlocks to force re-install device
//
Status = BlockIo->ReadBlocks (
BlockIo,
MediaId,
0,
BlockSize,
(VOID*)Buffer
);
if (EFI_ERROR(Status)) {
//
// No Status check here.
//
}
//
// Begin to re-locate the BlockIo interface according to the DevicePath
//
LocateBlockIoFromDevicePath (&BlockIo, DevicePath, StandardLib);
if (MediaPresent == BlockIo->Media->MediaPresent) {
AssertionType = EFI_TEST_ASSERTION_FAILED;
} else {
AssertionType = EFI_TEST_ASSERTION_PASSED;
}
StandardLib->RecordAssertion (
StandardLib,
AssertionType,
gBlockIoFunctionTestAssertionGuid017,
L"EFI_BLOCK_IO_PROTOCOL.Media->MediaPresent,Media remove or insert of device must affect the MediaPresent field",
L"%a:%d:Previous MediaPresent=%d, After MediaPresent=%d",
__FILE__,
__LINE__,
MediaPresent,
示例8: LocateDevicePathFromBlockIo
//.........这里部分代码省略.........
break;
}
for (IndexJ = 0; IndexJ < 3 * MAX_DIFFERENT_LBA_FOR_TEST; IndexJ++) {
//
// prepare test data
//
if (IndexJ < MAX_DIFFERENT_LBA_FOR_TEST) {
// from 1 to MAX_DIFFERENT_LBA_FOR_TEST
NewLba = IndexJ;
} else if (IndexJ < 2 * MAX_DIFFERENT_LBA_FOR_TEST) {
// from (LastBlock - MAX_DIFFERENT_LBA_FOR_TEST - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST) to (LastBlock - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST)
NewLba = IndexJ + LastBlock - 2 * MAX_DIFFERENT_LBA_FOR_TEST - MAX_DIFFERENT_BUFFERSIZE_FOR_TEST;
} else {
// from (LastBlock/2 - MAX_DIFFERENT_LBA_FOR_TEST/2) to (LastBlock/2 + MAX_DIFFERENT_LBA_FOR_TEST/2)
NewLba = IndexJ - 2 * MAX_DIFFERENT_LBA_FOR_TEST + (DivU64x32 (LastBlock, 2, &Remainder) - MAX_DIFFERENT_LBA_FOR_TEST / 2);
}
//
//parameter verification on NewLba
//
if (NewLba + NewBufferSize / BlockSize > LastBlock + 1) {
continue;
}
//
// To avoid the LOG information is destroied, the LOG information will
// be recorded after the original data is written again.
//
//
// Call ReadBlocks with the specified LBA and BufferSize
//
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) {
示例9: AllocatePool
VOID
EFIAPI
SEnvBlkIo (
IN EFI_HANDLE h,
IN VOID *Interface
)
/*++
Routine Description:
Arguments:
h - An EFI handle
Interface - The interface
Returns:
--*/
{
EFI_BLOCK_IO_PROTOCOL *BlkIo;
EFI_BLOCK_IO_MEDIA *BlkMedia;
VOID *Buffer;
BlkIo = Interface;
BlkMedia = BlkIo->Media;
//
// Issue a dummy read to the device to check for media change
//
Buffer = AllocatePool (BlkMedia->BlockSize);
if (Buffer) {
BlkIo->ReadBlocks (
BlkIo,
BlkMedia->MediaId,
0,
BlkMedia->BlockSize,
Buffer
);
FreePool (Buffer);
}
//
// Dump BlkIo Info
//
PrintToken (
STRING_TOKEN (STR_SHELLENV_DPROT_MID),
HiiEnvHandle,
BlkMedia->RemovableMedia ? L"Removable " : L"Fixed ",
BlkMedia->MediaPresent ? L"" : L"not-present ",
BlkMedia->MediaId
);
PrintToken (
STRING_TOKEN (STR_SHELLENV_DPROT_BSIZE_LBLOCK),
HiiEnvHandle,
BlkMedia->BlockSize,
BlkMedia->LastBlock,
MultU64x32 (BlkMedia->LastBlock + 1, BlkMedia->BlockSize),
BlkMedia->LogicalPartition ? L"partition" : L"raw",
BlkMedia->ReadOnly ? L"ro" : L"rw",
BlkMedia->WriteCaching ? L"cached" : L"!cached"
);
}
示例10: InitializeListHead
EFI_STATUS
BOpt_FindFileSystem (
IN BMM_CALLBACK_DATA *CallbackData
)
/*++
Routine Description
Find file systems for current Extensible Firmware
Including Handles that support Simple File System
protocol, Load File protocol.
Building up the FileSystem Menu for user selection
All file system will be stored in FsOptionMenu
for future use.
Arguments:
CallbackData - BMM context data
Returns:
EFI_SUCCESS - Success find the file system
EFI_OUT_OF_RESOURCES - Can not create menu entry
--*/
{
UINTN NoBlkIoHandles;
UINTN NoSimpleFsHandles;
UINTN NoLoadFileHandles;
EFI_HANDLE *BlkIoHandle;
EFI_HANDLE *SimpleFsHandle;
EFI_HANDLE *LoadFileHandle;
UINT16 *VolumeLabel;
EFI_BLOCK_IO_PROTOCOL *BlkIo;
UINTN Index;
EFI_STATUS Status;
BM_MENU_ENTRY *MenuEntry;
BM_FILE_CONTEXT *FileContext;
UINT16 *TempStr;
UINTN OptionNumber;
VOID *Buffer;
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
UINT16 DeviceType;
BBS_BBS_DEVICE_PATH BbsDevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
BOOLEAN RemovableMedia;
NoSimpleFsHandles = 0;
NoLoadFileHandles = 0;
OptionNumber = 0;
InitializeListHead (&FsOptionMenu.Head);
//
// Locate Handles that support BlockIo protocol
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiBlockIoProtocolGuid,
NULL,
&NoBlkIoHandles,
&BlkIoHandle
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < NoBlkIoHandles; Index++) {
Status = gBS->HandleProtocol (
BlkIoHandle[Index],
&gEfiBlockIoProtocolGuid,
&BlkIo
);
if (EFI_ERROR (Status)) {
continue;
}
//
// Issue a dummy read to trigger reinstall of BlockIo protocol for removable media
//
if (BlkIo->Media->RemovableMedia) {
Buffer = EfiAllocateZeroPool (BlkIo->Media->BlockSize);
if (NULL == Buffer) {
SafeFreePool (BlkIoHandle);
return EFI_OUT_OF_RESOURCES;
}
BlkIo->ReadBlocks (
BlkIo,
BlkIo->Media->MediaId,
0,
BlkIo->Media->BlockSize,
Buffer
);
SafeFreePool (Buffer);
}
}
SafeFreePool (BlkIoHandle);
}
//
// Locate Handles that support Simple File System protocol
//
//.........这里部分代码省略.........
示例11: InitializeListHead
/**
This function builds the FsOptionMenu list which records all
available file system in the system. They include all instances
of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, all instances of EFI_LOAD_FILE_SYSTEM
and all type of legacy boot device.
@retval EFI_SUCCESS Success find the file system
@retval EFI_OUT_OF_RESOURCES Can not create menu entry
**/
EFI_STATUS
FindFileSystem (
VOID
)
{
UINTN NoBlkIoHandles;
UINTN NoSimpleFsHandles;
EFI_HANDLE *BlkIoHandle;
EFI_HANDLE *SimpleFsHandle;
UINT16 *VolumeLabel;
EFI_BLOCK_IO_PROTOCOL *BlkIo;
UINTN Index;
EFI_STATUS Status;
SECUREBOOT_MENU_ENTRY *MenuEntry;
SECUREBOOT_FILE_CONTEXT *FileContext;
UINT16 *TempStr;
UINTN OptionNumber;
VOID *Buffer;
BOOLEAN RemovableMedia;
NoSimpleFsHandles = 0;
OptionNumber = 0;
InitializeListHead (&FsOptionMenu.Head);
//
// Locate Handles that support BlockIo protocol
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiBlockIoProtocolGuid,
NULL,
&NoBlkIoHandles,
&BlkIoHandle
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < NoBlkIoHandles; Index++) {
Status = gBS->HandleProtocol (
BlkIoHandle[Index],
&gEfiBlockIoProtocolGuid,
(VOID **) &BlkIo
);
if (EFI_ERROR (Status)) {
continue;
}
//
// Issue a dummy read to trigger reinstall of BlockIo protocol for removable media
//
if (BlkIo->Media->RemovableMedia) {
Buffer = AllocateZeroPool (BlkIo->Media->BlockSize);
if (NULL == Buffer) {
FreePool (BlkIoHandle);
return EFI_OUT_OF_RESOURCES;
}
BlkIo->ReadBlocks (
BlkIo,
BlkIo->Media->MediaId,
0,
BlkIo->Media->BlockSize,
Buffer
);
FreePool (Buffer);
}
}
FreePool (BlkIoHandle);
}
//
// Locate Handles that support Simple File System protocol
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
NULL,
&NoSimpleFsHandles,
&SimpleFsHandle
);
if (!EFI_ERROR (Status)) {
//
// Find all the instances of the File System prototocol
//
for (Index = 0; Index < NoSimpleFsHandles; Index++) {
Status = gBS->HandleProtocol (
SimpleFsHandle[Index],
&gEfiBlockIoProtocolGuid,
//.........这里部分代码省略.........