]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Move UpdateMapping() out of Map command and added to UefiShellCommandLib...
authorTapan Shah <tapandshah@hp.com>
Mon, 23 Jun 2014 18:36:44 +0000 (18:36 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 23 Jun 2014 18:36:44 +0000 (18:36 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hp.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15580 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Include/Library/ShellCommandLib.h
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c

index 13d526edf7e8dc15565e928a02b2b94ccc2715eb..aed947c1a9814ddb62a842b8df12923e05258cb0 100644 (file)
@@ -4,7 +4,8 @@
   This library is for use ONLY by shell commands linked into the shell application.\r
   This library will not funciton if it is used for UEFI Shell 2.0 Applications.\r
 \r
   This library is for use ONLY by shell commands linked into the shell application.\r
   This library will not funciton if it is used for UEFI Shell 2.0 Applications.\r
 \r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
+  Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -583,6 +584,17 @@ ShellCommandCreateInitialMappingsAndPaths(
   VOID\r
   );\r
 \r
   VOID\r
   );\r
 \r
+/**\r
+  Add mappings for any devices without one.  Do not change any existing maps.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCommandUpdateMapping (\r
+  VOID\r
+  );\r
+\r
 /**\r
   Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
 \r
 /**\r
   Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
 \r
index 48be39f83242b07dd616fd602d72275c621b8df0..18ae9f33844c5dcfa81141624f93c85875aae6e1 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Provides interface to shell internal functions for shell commands.\r
 \r
 /** @file\r
   Provides interface to shell internal functions for shell commands.\r
 \r
+  (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -1198,12 +1199,114 @@ ShellCommandCreateInitialMappingsAndPaths(
   }\r
 \r
   return (EFI_SUCCESS);\r
   }\r
 \r
   return (EFI_SUCCESS);\r
-}\r
-\r
-/**\r
-  Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
-\r
-  @param[in] Handle     The SHELL_FILE_HANDLE to convert.\r
+}
+
+/**
+  Add mappings for any devices without one.  Do not change any existing maps.
+
+  @retval EFI_SUCCESS   The operation was successful.
+**/
+EFI_STATUS
+EFIAPI
+ShellCommandUpdateMapping (
+  VOID
+  )
+{
+  EFI_STATUS                Status;
+  EFI_HANDLE                *HandleList;
+  UINTN                     Count;
+  EFI_DEVICE_PATH_PROTOCOL  **DevicePathList;
+  CHAR16                    *NewDefaultName;
+  CHAR16                    *NewConsistName;
+  EFI_DEVICE_PATH_PROTOCOL  **ConsistMappingTable;
+
+  HandleList  = NULL;
+  Status      = EFI_SUCCESS;
+
+  //
+  // remove mappings that represent removed devices.
+  //
+
+  //
+  // Find each handle with Simple File System
+  //
+  HandleList = GetHandleListByProtocol(&gEfiSimpleFileSystemProtocolGuid);
+  if (HandleList != NULL) {
+    //
+    // Do a count of the handles
+    //
+    for (Count = 0 ; HandleList[Count] != NULL ; Count++);
+
+    //
+    // Get all Device Paths
+    //
+    DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);
+    ASSERT(DevicePathList != NULL);
+
+    for (Count = 0 ; HandleList[Count] != NULL ; Count++) {
+      DevicePathList[Count] = DevicePathFromHandle(HandleList[Count]);
+    }
+
+    //
+    // Sort all DevicePaths
+    //
+    PerformQuickSort(DevicePathList, Count, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);
+
+    ShellCommandConsistMappingInitialize(&ConsistMappingTable);
+
+    //
+    // Assign new Mappings to remainders
+    //
+    for (Count = 0 ; HandleList[Count] != NULL && !EFI_ERROR(Status); Count++) {
+      //
+      // Skip ones that already have
+      //
+      if (gEfiShellProtocol->GetMapFromDevicePath(&DevicePathList[Count]) != NULL) {
+        continue;
+      }
+      //
+      // Get default name
+      //
+      NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem);
+      ASSERT(NewDefaultName != NULL);
+
+      //
+      // Call shell protocol SetMap function now...
+      //
+      Status = gEfiShellProtocol->SetMap(DevicePathList[Count], NewDefaultName);
+
+      if (!EFI_ERROR(Status)) {
+        //
+        // Now do consistent name
+        //
+        NewConsistName = ShellCommandConsistMappingGenMappingName(DevicePathList[Count], ConsistMappingTable);
+        if (NewConsistName != NULL) {
+          Status = gEfiShellProtocol->SetMap(DevicePathList[Count], NewConsistName);
+          FreePool(NewConsistName);
+        }
+      }
+
+      FreePool(NewDefaultName);
+    }
+    ShellCommandConsistMappingUnInitialize(ConsistMappingTable);
+    SHELL_FREE_NON_NULL(HandleList);
+    SHELL_FREE_NON_NULL(DevicePathList);
+
+    HandleList = NULL;
+  } else {
+    Count = (UINTN)-1;
+  }
+  //
+  // Do it all over again for gEfiBlockIoProtocolGuid
+  //
+
+  return (Status);
+}
+
+/**
+  Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.
+
+  @param[in] Handle     The SHELL_FILE_HANDLE to convert.
 \r
   @return a EFI_FILE_PROTOCOL* representing the same file.\r
 **/\r
 \r
   @return a EFI_FILE_PROTOCOL* representing the same file.\r
 **/\r
index 4763cfccca535a38ce026fff184071d7d4bf84bf..5329be41921a59f0f8a894a125a052079070619c 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
   Main file for map shell level 2 command.\r
 \r
 /** @file\r
   Main file for map shell level 2 command.\r
 \r
+  (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -117,108 +118,6 @@ SearchList(
   return (FALSE);\r
 }\r
 \r
   return (FALSE);\r
 }\r
 \r
-/**\r
-  Add mappings for any devices without one.  Do not change any existing maps.\r
-\r
-  @retval EFI_SUCCESS   The operation was successful.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UpdateMapping (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  EFI_HANDLE                *HandleList;\r
-  UINTN                     Count;\r
-  EFI_DEVICE_PATH_PROTOCOL  **DevicePathList;\r
-  CHAR16                    *NewDefaultName;\r
-  CHAR16                    *NewConsistName;\r
-  EFI_DEVICE_PATH_PROTOCOL  **ConsistMappingTable;\r
-\r
-  HandleList  = NULL;\r
-  Status      = EFI_SUCCESS;\r
-\r
-  //\r
-  // remove mappings that represent removed devices.\r
-  //\r
-\r
-  //\r
-  // Find each handle with Simple File System\r
-  //\r
-  HandleList = GetHandleListByProtocol(&gEfiSimpleFileSystemProtocolGuid);\r
-  if (HandleList != NULL) {\r
-    //\r
-    // Do a count of the handles\r
-    //\r
-    for (Count = 0 ; HandleList[Count] != NULL ; Count++);\r
-\r
-    //\r
-    // Get all Device Paths\r
-    //\r
-    DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);\r
-    ASSERT(DevicePathList != NULL);\r
-\r
-    for (Count = 0 ; HandleList[Count] != NULL ; Count++) {\r
-      DevicePathList[Count] = DevicePathFromHandle(HandleList[Count]);\r
-    }\r
-\r
-    //\r
-    // Sort all DevicePaths\r
-    //\r
-    PerformQuickSort(DevicePathList, Count, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);\r
-\r
-    ShellCommandConsistMappingInitialize(&ConsistMappingTable);\r
-\r
-    //\r
-    // Assign new Mappings to remainders\r
-    //\r
-    for (Count = 0 ; HandleList[Count] != NULL && !EFI_ERROR(Status); Count++) {\r
-      //\r
-      // Skip ones that already have\r
-      //\r
-      if (gEfiShellProtocol->GetMapFromDevicePath(&DevicePathList[Count]) != NULL) {\r
-        continue;\r
-      }\r
-      //\r
-      // Get default name\r
-      //\r
-      NewDefaultName = ShellCommandCreateNewMappingName(MappingTypeFileSystem);\r
-      ASSERT(NewDefaultName != NULL);\r
-\r
-      //\r
-      // Call shell protocol SetMap function now...\r
-      //\r
-      Status = gEfiShellProtocol->SetMap(DevicePathList[Count], NewDefaultName);\r
-\r
-      if (!EFI_ERROR(Status)) {\r
-        //\r
-        // Now do consistent name\r
-        //\r
-        NewConsistName = ShellCommandConsistMappingGenMappingName(DevicePathList[Count], ConsistMappingTable);\r
-        if (NewConsistName != NULL) {\r
-          Status = gEfiShellProtocol->SetMap(DevicePathList[Count], NewConsistName);\r
-          FreePool(NewConsistName);\r
-        }\r
-      }\r
-\r
-      FreePool(NewDefaultName);\r
-    }\r
-    ShellCommandConsistMappingUnInitialize(ConsistMappingTable);\r
-    SHELL_FREE_NON_NULL(HandleList);\r
-    SHELL_FREE_NON_NULL(DevicePathList);\r
-\r
-    HandleList = NULL;\r
-  } else {\r
-    Count = (UINTN)-1;\r
-  }\r
-  //\r
-  // Do it all over again for gEfiBlockIoProtocolGuid\r
-  //\r
-\r
-  return (Status);\r
-}\r
-\r
 /**\r
   Determine what type of device is represented and return it's string.  The \r
   string is in allocated memory and must be callee freed.  The HII is is listed below.\r
 /**\r
   Determine what type of device is represented and return it's string.  The \r
   string is in allocated memory and must be callee freed.  The HII is is listed below.\r
@@ -1199,7 +1098,7 @@ ShellCommandRunMap (
           //\r
           // Do the Update\r
           //\r
           //\r
           // Do the Update\r
           //\r
-          Status = UpdateMapping();\r
+          Status = ShellCommandUpdateMapping ();\r
           if (EFI_ERROR(Status)) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);\r
             ShellStatus = SHELL_UNSUPPORTED;\r
           if (EFI_ERROR(Status)) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);\r
             ShellStatus = SHELL_UNSUPPORTED;\r