ShellPkg: Refine the code to reduce time cost of 'map -r'

In some platform 'map -r' may cost more than 1 min. This patch filter the target handles by
BlockIO and SimpleFileSystem protocol to reduce the time cost.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19149 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Qiu Shumin 2015-12-08 02:00:16 +00:00 committed by shenshushi
parent fb48e7780e
commit e9fc538781
1 changed files with 30 additions and 10 deletions

View File

@ -16,6 +16,10 @@
#include <Library/SortLib.h> #include <Library/SortLib.h>
#include <Library/UefiLib.h> #include <Library/UefiLib.h>
#include <Protocol/UsbIo.h> #include <Protocol/UsbIo.h>
#include <Protocol/BlockIo.h>
#include <Protocol/SimpleFileSystem.h>
typedef enum { typedef enum {
MTDTypeUnknown, MTDTypeUnknown,
@ -1349,20 +1353,22 @@ ShellCommandConsistMappingInitialize (
OUT EFI_DEVICE_PATH_PROTOCOL ***Table OUT EFI_DEVICE_PATH_PROTOCOL ***Table
) )
{ {
EFI_HANDLE *HandleBuffer; EFI_HANDLE *HandleBuffer;
UINTN HandleNum; UINTN HandleNum;
UINTN HandleLoop; UINTN HandleLoop;
EFI_DEVICE_PATH_PROTOCOL **TempTable; EFI_DEVICE_PATH_PROTOCOL **TempTable;
EFI_DEVICE_PATH_PROTOCOL *DevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath; EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
UINTN Index; EFI_BLOCK_IO_PROTOCOL *BlockIo;
EFI_STATUS Status; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
UINTN Index;
EFI_STATUS Status;
HandleBuffer = NULL; HandleBuffer = NULL;
Status = gBS->LocateHandleBuffer ( Status = gBS->LocateHandleBuffer (
AllHandles, ByProtocol,
NULL, &gEfiDevicePathProtocolGuid,
NULL, NULL,
&HandleNum, &HandleNum,
&HandleBuffer &HandleBuffer
@ -1385,6 +1391,20 @@ ShellCommandConsistMappingInitialize (
continue; continue;
} }
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop],
&gEfiBlockIoProtocolGuid,
(VOID **)&BlockIo
);
if (EFI_ERROR(Status)) {
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop],
&gEfiSimpleFileSystemProtocolGuid,
(VOID **)&SimpleFileSystem
);
if (EFI_ERROR(Status)) {
continue;
}
}
for (Index = 0; TempTable[Index] != NULL; Index++) { for (Index = 0; TempTable[Index] != NULL; Index++) {
if (DevicePathCompare (&TempTable[Index], &HIDevicePath) == 0) { if (DevicePathCompare (&TempTable[Index], &HIDevicePath) == 0) {
FreePool (HIDevicePath); FreePool (HIDevicePath);