Revision: 19194
          http://sourceforge.net/p/edk2/code/19194
Author:   vanjeff
Date:     2015-12-10 07:21:12 +0000 (Thu, 10 Dec 2015)
Log Message:
-----------
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.

(Sync patch r19149 from main trunk.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/19149

Modified Paths:
--------------
    branches/UDK2015/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c

Modified: branches/UDK2015/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
===================================================================
--- branches/UDK2015/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c      
2015-12-10 07:20:43 UTC (rev 19193)
+++ branches/UDK2015/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c      
2015-12-10 07:21:12 UTC (rev 19194)
@@ -16,7 +16,11 @@
 #include <Library/SortLib.h>
 #include <Library/UefiLib.h>
 #include <Protocol/UsbIo.h>
+#include <Protocol/BlockIo.h>
+#include <Protocol/SimpleFileSystem.h>
 
+
+
 typedef enum {
   MTDTypeUnknown,
   MTDTypeFloppy,
@@ -1349,21 +1353,23 @@
   OUT EFI_DEVICE_PATH_PROTOCOL           ***Table
   )
 {
-  EFI_HANDLE                *HandleBuffer;
-  UINTN                     HandleNum;
-  UINTN                     HandleLoop;
-  EFI_DEVICE_PATH_PROTOCOL  **TempTable;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  EFI_DEVICE_PATH_PROTOCOL  *HIDevicePath;
-  UINTN                     Index;
-  EFI_STATUS                Status;
+  EFI_HANDLE                      *HandleBuffer;
+  UINTN                           HandleNum;
+  UINTN                           HandleLoop;
+  EFI_DEVICE_PATH_PROTOCOL        **TempTable;
+  EFI_DEVICE_PATH_PROTOCOL        *DevicePath;
+  EFI_DEVICE_PATH_PROTOCOL        *HIDevicePath;
+  EFI_BLOCK_IO_PROTOCOL           *BlockIo;
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+  UINTN                           Index;
+  EFI_STATUS                      Status;
 
   HandleBuffer              = NULL;
 
   Status = gBS->LocateHandleBuffer (
-              AllHandles,
+              ByProtocol,
+              &gEfiDevicePathProtocolGuid,
               NULL,
-              NULL,
               &HandleNum,
               &HandleBuffer
              );
@@ -1385,6 +1391,20 @@
       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++) {
       if (DevicePathCompare (&TempTable[Index], &HIDevicePath) == 0) {
         FreePool (HIDevicePath);


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to