]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Refine the code to reduce time cost of 'map -r'
authorQiu Shumin <shumin.qiu@intel.com>
Tue, 8 Dec 2015 02:00:16 +0000 (02:00 +0000)
committershenshushi <shenshushi@Edk2>
Tue, 8 Dec 2015 02:00:16 +0000 (02:00 +0000)
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

ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c

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