]> git.proxmox.com Git - mirror_edk2.git/commitdiff
consist mapping - add comments and change variable names.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 21:09:21 +0000 (21:09 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 21:09:21 +0000 (21:09 +0000)
UefiShellCommandLib - add comments and zero out memory allocations.

add guid to inf file.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11433 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf

index c29e7e93fe18f9b8ad6f0ab34e524aec9160f4e7..fc9b906ffdd53d9e1c5d1bb7e3a3a5a50f416d49 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for support of shell consist mapping.\r
 \r
 /** @file\r
   Main file for support of shell consist mapping.\r
 \r
-  Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2005 - 2011, 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
@@ -29,9 +29,9 @@ typedef struct {
 } POOL_PRINT;\r
 \r
 typedef struct {\r
 } POOL_PRINT;\r
 \r
 typedef struct {\r
-  UINTN       HI;\r
-  MTD_TYPE    MTD;\r
-  POOL_PRINT  CSD;\r
+  UINTN       Hi;\r
+  MTD_TYPE    Mtd;\r
+  POOL_PRINT  Csd;\r
   BOOLEAN     Digital;\r
 } DEVICE_CONSIST_MAPPING_INFO;\r
 \r
   BOOLEAN     Digital;\r
 } DEVICE_CONSIST_MAPPING_INFO;\r
 \r
@@ -43,8 +43,8 @@ typedef struct {
 typedef struct {\r
   UINT8 Type;\r
   UINT8 SubType;\r
 typedef struct {\r
   UINT8 Type;\r
   UINT8 SubType;\r
-  VOID (EFIAPI *SerialFun) (EFI_DEVICE_PATH_PROTOCOL *, DEVICE_CONSIST_MAPPING_INFO *);\r
-  INTN (EFIAPI *CompareFun) (EFI_DEVICE_PATH_PROTOCOL *, EFI_DEVICE_PATH_PROTOCOL *);\r
+  VOID (EFIAPI *SerialFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, DEVICE_CONSIST_MAPPING_INFO *MapInfo);\r
+  INTN (EFIAPI *CompareFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);\r
 } DEV_PATH_CONSIST_MAPPING_TABLE;\r
 \r
 \r
 } DEV_PATH_CONSIST_MAPPING_TABLE;\r
 \r
 \r
@@ -128,7 +128,17 @@ MTD_NAME  mMTDName[] = {
   }\r
 };\r
 \r
   }\r
 };\r
 \r
-VOID\r
+/**\r
+  Function to append a 64 bit number / 25 onto the string.\r
+\r
+  @param[in,out] Str          The string so append onto.\r
+  @param[in]     Num          The number to divide and append.\r
+\r
+  @retval EFI_INVALID_PARAMETER   A parameter was NULL.\r
+  @retval EFI_SUCCESS             The appending was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
 AppendCSDNum2 (\r
   IN OUT POOL_PRINT       *Str,\r
   IN UINT64               Num\r
 AppendCSDNum2 (\r
   IN OUT POOL_PRINT       *Str,\r
   IN UINT64               Num\r
@@ -137,7 +147,9 @@ AppendCSDNum2 (
   UINT64  Result;\r
   UINT32   Rem;\r
 \r
   UINT64  Result;\r
   UINT32   Rem;\r
 \r
-  ASSERT(Str != NULL);\r
+  if (Str == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
 \r
   Result = DivU64x32Remainder (Num, 25, &Rem);\r
   if (Result > 0) {\r
 \r
   Result = DivU64x32Remainder (Num, 25, &Rem);\r
   if (Result > 0) {\r
@@ -145,35 +157,61 @@ AppendCSDNum2 (
   }\r
 \r
   CatPrint (Str, L"%c", Rem + 'a');\r
   }\r
 \r
   CatPrint (Str, L"%c", Rem + 'a');\r
+  return (EFI_SUCCESS);\r
 }\r
 \r
 }\r
 \r
-VOID\r
+/**\r
+  Function to append a 64 bit number onto the mapping info.\r
+\r
+  @param[in,out] MappingItem  The mapping info object to append onto.\r
+  @param[in]     Num          The info to append.\r
+\r
+  @retval EFI_INVALID_PARAMETER   A parameter was NULL.\r
+  @retval EFI_SUCCESS             The appending was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
 AppendCSDNum (\r
 AppendCSDNum (\r
-  DEVICE_CONSIST_MAPPING_INFO            *MappingItem,\r
-  UINT64                                 Num\r
+  IN OUT DEVICE_CONSIST_MAPPING_INFO            *MappingItem,\r
+  IN     UINT64                                 Num\r
   )\r
 {\r
   )\r
 {\r
-  ASSERT(MappingItem != NULL);\r
+  if (MappingItem == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
   if (MappingItem->Digital) {\r
 \r
   if (MappingItem->Digital) {\r
-    CatPrint (&MappingItem->CSD, L"%ld", Num);\r
+    CatPrint (&MappingItem->Csd, L"%ld", Num);\r
   } else {\r
   } else {\r
-    AppendCSDNum2 (&MappingItem->CSD, Num);\r
+    AppendCSDNum2 (&MappingItem->Csd, Num);\r
   }\r
 \r
   MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);\r
   }\r
 \r
   MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);\r
+\r
+  return (EFI_SUCCESS);\r
 }\r
 \r
 }\r
 \r
-VOID\r
+/**\r
+  Function to append string into the mapping info.\r
+\r
+  @param[in,out] MappingItem  The mapping info object to append onto.\r
+  @param[in]     Str          The info to append.\r
+\r
+  @retval EFI_INVALID_PARAMETER   A parameter was NULL.\r
+  @retval EFI_SUCCESS             The appending was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
 AppendCSDStr (\r
 AppendCSDStr (\r
-  DEVICE_CONSIST_MAPPING_INFO            *MappingItem,\r
-  CHAR16                                 *Str\r
+  IN OUT DEVICE_CONSIST_MAPPING_INFO            *MappingItem,\r
+  IN     CHAR16                                 *Str\r
   )\r
 {\r
   CHAR16  *Index;\r
 \r
   )\r
 {\r
   CHAR16  *Index;\r
 \r
-  ASSERT(Str != NULL);\r
-  ASSERT(MappingItem != NULL);\r
+  if (Str == NULL || MappingItem == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
 \r
   if (MappingItem->Digital) {\r
     //\r
 \r
   if (MappingItem->Digital) {\r
     //\r
@@ -192,11 +230,11 @@ AppendCSDStr (
       case '7':\r
       case '8':\r
       case '9':\r
       case '7':\r
       case '8':\r
       case '9':\r
-        CatPrint (&MappingItem->CSD, L"%c", *Index);\r
+        CatPrint (&MappingItem->Csd, L"%c", *Index);\r
         break;\r
 \r
       case '1':\r
         break;\r
 \r
       case '1':\r
-        CatPrint (&MappingItem->CSD, L"16");\r
+        CatPrint (&MappingItem->Csd, L"16");\r
         break;\r
 \r
       case 'a':\r
         break;\r
 \r
       case 'a':\r
@@ -205,7 +243,7 @@ AppendCSDStr (
       case 'd':\r
       case 'e':\r
       case 'f':\r
       case 'd':\r
       case 'e':\r
       case 'f':\r
-        CatPrint (&MappingItem->CSD, L"1%c", *Index - 'a' + '0');\r
+        CatPrint (&MappingItem->Csd, L"1%c", *Index - 'a' + '0');\r
         break;\r
 \r
       case 'A':\r
         break;\r
 \r
       case 'A':\r
@@ -214,7 +252,7 @@ AppendCSDStr (
       case 'D':\r
       case 'E':\r
       case 'F':\r
       case 'D':\r
       case 'E':\r
       case 'F':\r
-        CatPrint (&MappingItem->CSD, L"1%c", *Index - 'A' + '0');\r
+        CatPrint (&MappingItem->Csd, L"1%c", *Index - 'A' + '0');\r
         break;\r
       }\r
     }\r
         break;\r
       }\r
     }\r
@@ -226,27 +264,41 @@ AppendCSDStr (
       //  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p\r
       //\r
       if (*Index >= '0' && *Index <= '9') {\r
       //  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p\r
       //\r
       if (*Index >= '0' && *Index <= '9') {\r
-        CatPrint (&MappingItem->CSD, L"%c", *Index - '0' + 'a');\r
+        CatPrint (&MappingItem->Csd, L"%c", *Index - '0' + 'a');\r
       } else if (*Index >= 'a' && *Index <= 'f') {\r
       } else if (*Index >= 'a' && *Index <= 'f') {\r
-        CatPrint (&MappingItem->CSD, L"%c", *Index - 'a' + 'k');\r
+        CatPrint (&MappingItem->Csd, L"%c", *Index - 'a' + 'k');\r
       } else if (*Index >= 'A' && *Index <= 'F') {\r
       } else if (*Index >= 'A' && *Index <= 'F') {\r
-        CatPrint (&MappingItem->CSD, L"%c", *Index - 'A' + 'k');\r
+        CatPrint (&MappingItem->Csd, L"%c", *Index - 'A' + 'k');\r
       }\r
     }\r
   }\r
 \r
   MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);\r
       }\r
     }\r
   }\r
 \r
   MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);\r
+\r
+  return (EFI_SUCCESS);\r
 }\r
 \r
 }\r
 \r
-VOID\r
+/**\r
+  Function to append a Guid to the mapping item.\r
+\r
+  @param[in,out] MappingItem  The item to append onto.\r
+  @param[in]     Guid         The guid to append.\r
+\r
+  @retval EFI_SUCCESS           The appending operation was successful.\r
+  @retval EFI_INVALID_PARAMETER A parameter was NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
 AppendCSDGuid (\r
   DEVICE_CONSIST_MAPPING_INFO            *MappingItem,\r
   EFI_GUID                               *Guid\r
   )\r
 {\r
   CHAR16  Buffer[64];\r
 AppendCSDGuid (\r
   DEVICE_CONSIST_MAPPING_INFO            *MappingItem,\r
   EFI_GUID                               *Guid\r
   )\r
 {\r
   CHAR16  Buffer[64];\r
-  ASSERT(Guid != NULL);\r
-  ASSERT(MappingItem != NULL);\r
+\r
+  if (Guid == NULL || MappingItem == NULL) {\r
+    return (EFI_INVALID_PARAMETER);\r
+  }\r
 \r
   UnicodeSPrint (\r
     Buffer,\r
 \r
   UnicodeSPrint (\r
     Buffer,\r
@@ -254,13 +306,24 @@ AppendCSDGuid (
     L"%g",\r
     Guid\r
    );\r
     L"%g",\r
     Guid\r
    );\r
-//  StrLwr (Buffer);\r
+\r
   AppendCSDStr (MappingItem, Buffer);\r
   AppendCSDStr (MappingItem, Buffer);\r
+\r
+  return (EFI_SUCCESS);\r
 }\r
 \r
 }\r
 \r
+/**\r
+  Function to compare 2 APCI device paths.\r
+\r
+  @param[in] DevicePath1        The first device path to compare.\r
+  @param[in] DevicePath2        The second device path to compare.\r
+\r
+  @retval 0 The device paths represent the same device.\r
+  @return   Non zero if the devices are different, zero otherwise.\r
+**/\r
 INTN\r
 EFIAPI\r
 INTN\r
 EFIAPI\r
-_DevPathCompareAcpi (\r
+DevPathCompareAcpi (\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath1,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath2\r
   )\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath1,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath2\r
   )\r
@@ -268,8 +331,9 @@ _DevPathCompareAcpi (
   ACPI_HID_DEVICE_PATH  *Acpi1;\r
   ACPI_HID_DEVICE_PATH  *Acpi2;\r
 \r
   ACPI_HID_DEVICE_PATH  *Acpi1;\r
   ACPI_HID_DEVICE_PATH  *Acpi2;\r
 \r
-  ASSERT(DevicePath1 != NULL);\r
-  ASSERT(DevicePath2 != NULL);\r
+  if (DevicePath1 == NULL || DevicePath2 == NULL) {\r
+    return (-2);\r
+  }\r
 \r
   Acpi1 = (ACPI_HID_DEVICE_PATH *) DevicePath1;\r
   Acpi2 = (ACPI_HID_DEVICE_PATH *) DevicePath2;\r
 \r
   Acpi1 = (ACPI_HID_DEVICE_PATH *) DevicePath1;\r
   Acpi2 = (ACPI_HID_DEVICE_PATH *) DevicePath2;\r
@@ -284,9 +348,18 @@ _DevPathCompareAcpi (
   return -1;\r
 }\r
 \r
   return -1;\r
 }\r
 \r
+/**\r
+  Function to compare 2 PCI device paths.\r
+\r
+  @param[in] DevicePath1        The first device path to compare.\r
+  @param[in] DevicePath2        The second device path to compare.\r
+\r
+  @retval 0 The device paths represent the same device.\r
+  @return   Non zero if the devices are different, zero otherwise.\r
+**/\r
 INTN\r
 EFIAPI\r
 INTN\r
 EFIAPI\r
-_DevPathComparePci (\r
+DevPathComparePci (\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath1,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath2\r
   )\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath1,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *DevicePath2\r
   )\r
@@ -363,8 +436,8 @@ DevPathSerialHardDrive (
   ASSERT(MappingItem != NULL);\r
 \r
   Hd = (HARDDRIVE_DEVICE_PATH *) DevicePathNode;\r
   ASSERT(MappingItem != NULL);\r
 \r
   Hd = (HARDDRIVE_DEVICE_PATH *) DevicePathNode;\r
-  if (MappingItem->MTD == MTDTypeUnknown) {\r
-    MappingItem->MTD = MTDTypeHardDisk;\r
+  if (MappingItem->Mtd == MTDTypeUnknown) {\r
+    MappingItem->Mtd = MTDTypeHardDisk;\r
   }\r
 \r
   AppendCSDNum (MappingItem, Hd->PartitionNumber);\r
   }\r
 \r
   AppendCSDNum (MappingItem, Hd->PartitionNumber);\r
@@ -411,7 +484,7 @@ DevPathSerialCdRom (
   ASSERT(MappingItem != NULL);\r
 \r
   Cd                = (CDROM_DEVICE_PATH *) DevicePathNode;\r
   ASSERT(MappingItem != NULL);\r
 \r
   Cd                = (CDROM_DEVICE_PATH *) DevicePathNode;\r
-  MappingItem->MTD  = MTDTypeCDRom;\r
+  MappingItem->Mtd  = MTDTypeCDRom;\r
   AppendCSDNum (MappingItem, Cd->BootEntry);\r
 }\r
 \r
   AppendCSDNum (MappingItem, Cd->BootEntry);\r
 }\r
 \r
@@ -491,6 +564,7 @@ DevPathSerialUsb (
 \r
   @param[in] DevicePathNode   The node to get info on.\r
   @param[in] MappingItem      The info item to populate.\r
 \r
   @param[in] DevicePathNode   The node to get info on.\r
   @param[in] MappingItem      The info item to populate.\r
+\r
 **/\r
 VOID\r
 EFIAPI\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -501,15 +575,15 @@ DevPathSerialVendor (
 {\r
   VENDOR_DEVICE_PATH  *Vendor;\r
   SAS_DEVICE_PATH     *Sas;\r
 {\r
   VENDOR_DEVICE_PATH  *Vendor;\r
   SAS_DEVICE_PATH     *Sas;\r
-  EFI_GUID            SasVendorGuid = DEVICE_PATH_MESSAGING_SAS;\r
 \r
 \r
-  ASSERT(DevicePathNode != NULL);\r
-  ASSERT(MappingItem != NULL);\r
+  if (DevicePathNode == NULL || MappingItem == NULL) {\r
+    return;\r
+  }\r
 \r
   Vendor = (VENDOR_DEVICE_PATH *) DevicePathNode;\r
   AppendCSDGuid (MappingItem, &Vendor->Guid);\r
 \r
 \r
   Vendor = (VENDOR_DEVICE_PATH *) DevicePathNode;\r
   AppendCSDGuid (MappingItem, &Vendor->Guid);\r
 \r
-  if (CompareGuid (&SasVendorGuid, &Vendor->Guid) == 0) {\r
+  if (CompareGuid (&gEfiSasDevicePathGuid, &Vendor->Guid)) {\r
     Sas = (SAS_DEVICE_PATH *) Vendor;\r
     AppendCSDNum (MappingItem, Sas->SasAddress);\r
     AppendCSDNum (MappingItem, Sas->Lun);\r
     Sas = (SAS_DEVICE_PATH *) Vendor;\r
     AppendCSDNum (MappingItem, Sas->SasAddress);\r
     AppendCSDNum (MappingItem, Sas->Lun);\r
@@ -579,7 +653,7 @@ DevPathSerialIScsi (
 {\r
 ///@todo make this a PCD\r
 //\r
 {\r
 ///@todo make this a PCD\r
 //\r
-// As CSD of ISCSI node is quite long, we comment\r
+// As Csd of ISCSI node is quite long, we comment\r
 // the code below to keep the consistent mapping\r
 // short. Uncomment if you really need it.\r
 //\r
 // the code below to keep the consistent mapping\r
 // short. Uncomment if you really need it.\r
 //\r
@@ -626,13 +700,13 @@ DevPathSerialI2O (
   IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem\r
   )\r
 {\r
   IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem\r
   )\r
 {\r
-  I2O_DEVICE_PATH *I2O;\r
+  I2O_DEVICE_PATH *DevicePath_I20;\r
 \r
   ASSERT(DevicePathNode != NULL);\r
   ASSERT(MappingItem != NULL);\r
 \r
 \r
   ASSERT(DevicePathNode != NULL);\r
   ASSERT(MappingItem != NULL);\r
 \r
-  I2O = (I2O_DEVICE_PATH *) DevicePathNode;\r
-  AppendCSDNum (MappingItem, I2O->Tid);\r
+  DevicePath_I20 = (I2O_DEVICE_PATH *) DevicePathNode;\r
+  AppendCSDNum (MappingItem, DevicePath_I20->Tid);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -819,14 +893,14 @@ DevPathSerial1394 (
   IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem\r
   )\r
 {\r
   IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem\r
   )\r
 {\r
-  F1394_DEVICE_PATH *F1394;\r
+  F1394_DEVICE_PATH *DevicePath_F1394;\r
   CHAR16            Buffer[20];\r
 \r
   ASSERT(DevicePathNode != NULL);\r
   ASSERT(MappingItem != NULL);\r
 \r
   CHAR16            Buffer[20];\r
 \r
   ASSERT(DevicePathNode != NULL);\r
   ASSERT(MappingItem != NULL);\r
 \r
-  F1394 = (F1394_DEVICE_PATH *) DevicePathNode;\r
-  UnicodeSPrint (Buffer, 0, L"%lx", F1394->Guid);\r
+  DevicePath_F1394 = (F1394_DEVICE_PATH *) DevicePathNode;\r
+  UnicodeSPrint (Buffer, 0, L"%lx", DevicePath_F1394->Guid);\r
   AppendCSDStr (MappingItem, Buffer);\r
 }\r
 \r
   AppendCSDStr (MappingItem, Buffer);\r
 }\r
 \r
@@ -851,7 +925,7 @@ DevPathSerialAcpi (
   Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode;\r
   if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
     if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {\r
   Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode;\r
   if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {\r
     if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {\r
-      MappingItem->MTD = MTDTypeFloppy;\r
+      MappingItem->Mtd = MTDTypeFloppy;\r
       AppendCSDNum (MappingItem, Acpi->UID);\r
     }\r
   }\r
       AppendCSDNum (MappingItem, Acpi->UID);\r
     }\r
   }\r
@@ -860,6 +934,9 @@ DevPathSerialAcpi (
 /**\r
   Empty function used for unknown devices.\r
 \r
 /**\r
   Empty function used for unknown devices.\r
 \r
+  @param[in] DevicePathNode       Ignored.\r
+  @param[in] MappingItem          Ignored.\r
+\r
   Does nothing.\r
 **/\r
 VOID\r
   Does nothing.\r
 **/\r
 VOID\r
@@ -869,17 +946,18 @@ DevPathSerialDefault (
   IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem\r
   )\r
 {\r
   IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem\r
   )\r
 {\r
+  return;\r
 }\r
 \r
 DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {\r
   HARDWARE_DEVICE_PATH,\r
   HW_PCI_DP,\r
   DevPathSerialDefault,\r
 }\r
 \r
 DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {\r
   HARDWARE_DEVICE_PATH,\r
   HW_PCI_DP,\r
   DevPathSerialDefault,\r
-  _DevPathComparePci,\r
+  DevPathComparePci,\r
   ACPI_DEVICE_PATH,\r
   ACPI_DP,\r
   DevPathSerialAcpi,\r
   ACPI_DEVICE_PATH,\r
   ACPI_DP,\r
   DevPathSerialAcpi,\r
-  _DevPathCompareAcpi,\r
+  DevPathCompareAcpi,\r
   MESSAGING_DEVICE_PATH,\r
   MSG_ATAPI_DP,\r
   DevPathSerialAtapi,\r
   MESSAGING_DEVICE_PATH,\r
   MSG_ATAPI_DP,\r
   DevPathSerialAtapi,\r
@@ -963,8 +1041,8 @@ DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {
 \r
   @param[in] DevicePathNode   The node to check.\r
 \r
 \r
   @param[in] DevicePathNode   The node to check.\r
 \r
-  @retval TRUE    The node is HI.\r
-  @retval FALSE   The node is not HI.\r
+  @retval TRUE    The node is Hi.\r
+  @retval FALSE   The node is not Hi.\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
@@ -997,11 +1075,11 @@ IsHIDevicePathNode (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Function to convert a standard device path structure into a HI version.\r
+  Function to convert a standard device path structure into a Hi version.\r
 \r
   @param[in] DevicePath   The device path to convert.\r
 \r
 \r
   @param[in] DevicePath   The device path to convert.\r
 \r
-  @return   the device path portion that is HI.\r
+  @return   the device path portion that is Hi.\r
 **/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
 EFIAPI\r
 **/\r
 EFI_DEVICE_PATH_PROTOCOL *\r
 EFIAPI\r
@@ -1019,7 +1097,7 @@ GetHIDevicePath (
 \r
   NonHIDevicePathNodeCount  = 0;\r
 \r
 \r
   NonHIDevicePathNodeCount  = 0;\r
 \r
-  HIDevicePath              = AllocatePool (sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+  HIDevicePath              = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
   SetDevicePathEndNode (HIDevicePath);\r
 \r
   Node.DevPath.Type       = END_DEVICE_PATH_TYPE;\r
   SetDevicePathEndNode (HIDevicePath);\r
 \r
   Node.DevPath.Type       = END_DEVICE_PATH_TYPE;\r
@@ -1072,7 +1150,7 @@ GetDeviceConsistMappingInfo (
   ASSERT(DevicePath != NULL);\r
   ASSERT(MappingItem != NULL);\r
 \r
   ASSERT(DevicePath != NULL);\r
   ASSERT(MappingItem != NULL);\r
 \r
-  SetMem (&MappingItem->CSD, sizeof (POOL_PRINT), 0);\r
+  SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0);\r
 \r
   while (!IsDevicePathEnd (DevicePath)) {\r
     //\r
 \r
   while (!IsDevicePathEnd (DevicePath)) {\r
     //\r
@@ -1212,7 +1290,7 @@ ShellCommandConsistMappingUnInitialize (
   This must be called after ShellCommandConsistMappingInitialize() and\r
   before ShellCommandConsistMappingUnInitialize() is called.\r
 \r
   This must be called after ShellCommandConsistMappingInitialize() and\r
   before ShellCommandConsistMappingUnInitialize() is called.\r
 \r
-  @param[in] DeviecPath   The pointer to the dev path for the device.\r
+  @param[in] DevicePath   The pointer to the dev path for the device.\r
   @param[in] Table        The Table of mapping information.\r
 \r
   @retval NULL            A consistent mapped name could not be created.\r
   @param[in] Table        The Table of mapping information.\r
 \r
   @retval NULL            A consistent mapped name could not be created.\r
@@ -1221,8 +1299,8 @@ ShellCommandConsistMappingUnInitialize (
 CHAR16 *\r
 EFIAPI\r
 ShellCommandConsistMappingGenMappingName (\r
 CHAR16 *\r
 EFIAPI\r
 ShellCommandConsistMappingGenMappingName (\r
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath,\r
-  EFI_DEVICE_PATH_PROTOCOL    **Table\r
+  IN EFI_DEVICE_PATH_PROTOCOL    *DevicePath,\r
+  IN EFI_DEVICE_PATH_PROTOCOL    **Table\r
   )\r
 {\r
   POOL_PRINT                  Str;\r
   )\r
 {\r
   POOL_PRINT                  Str;\r
@@ -1250,15 +1328,15 @@ ShellCommandConsistMappingGenMappingName (
     return NULL;\r
   }\r
 \r
     return NULL;\r
   }\r
 \r
-  MappingInfo.HI      = Index;\r
-  MappingInfo.MTD     = MTDTypeUnknown;\r
+  MappingInfo.Hi      = Index;\r
+  MappingInfo.Mtd     = MTDTypeUnknown;\r
   MappingInfo.Digital = FALSE;\r
 \r
   GetDeviceConsistMappingInfo (&MappingInfo, DevicePath);\r
 \r
   SetMem (&Str, sizeof (Str), 0);\r
   for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) {\r
   MappingInfo.Digital = FALSE;\r
 \r
   GetDeviceConsistMappingInfo (&MappingInfo, DevicePath);\r
 \r
   SetMem (&Str, sizeof (Str), 0);\r
   for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) {\r
-    if (MappingInfo.MTD == mMTDName[Index].MTDType) {\r
+    if (MappingInfo.Mtd == mMTDName[Index].MTDType) {\r
       break;\r
     }\r
   }\r
       break;\r
     }\r
   }\r
@@ -1267,10 +1345,10 @@ ShellCommandConsistMappingGenMappingName (
     CatPrint (&Str, L"%s", mMTDName[Index].Name);\r
   }\r
 \r
     CatPrint (&Str, L"%s", mMTDName[Index].Name);\r
   }\r
 \r
-  CatPrint (&Str, L"%d", (UINTN) MappingInfo.HI);\r
-  if (MappingInfo.CSD.Str != NULL) {\r
-    CatPrint (&Str, L"%s", MappingInfo.CSD.Str);\r
-    FreePool (MappingInfo.CSD.Str);\r
+  CatPrint (&Str, L"%d", (UINTN) MappingInfo.Hi);\r
+  if (MappingInfo.Csd.Str != NULL) {\r
+    CatPrint (&Str, L"%s", MappingInfo.Csd.Str);\r
+    FreePool (MappingInfo.Csd.Str);\r
   }\r
 \r
   if (Str.Str != NULL) {\r
   }\r
 \r
   if (Str.Str != NULL) {\r
index 2dd39ef3cf453b091903b3c72d44e0e501c58625..9e7cd0e6e1464a1b9074f50a7528ad8431aef37a 100644 (file)
@@ -1,7 +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
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, 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
@@ -17,7 +17,7 @@
 /// The tag for use in identifying UNICODE files.\r
 /// If the file is UNICODE, the first 16 bits of the file will equal this value.\r
 enum {\r
 /// The tag for use in identifying UNICODE files.\r
 /// If the file is UNICODE, the first 16 bits of the file will equal this value.\r
 enum {\r
-  UnicodeFileTag = 0xFEFF\r
+  gUnicodeFileTag = 0xFEFF\r
 };\r
 \r
 // STATIC local variables\r
 };\r
 \r
 // STATIC local variables\r
@@ -207,6 +207,12 @@ ShellCommandLibDestructor (
     FreePool(mProfileList);\r
   }\r
 \r
     FreePool(mProfileList);\r
   }\r
 \r
+  gEfiShellProtocol            = NULL;\r
+  gEfiShellParametersProtocol  = NULL;\r
+  gUnicodeCollation            = NULL;\r
+  gDevPathToText               = NULL;\r
+  gShellCurDir                 = NULL;\r
+\r
   return (RETURN_SUCCESS);\r
 }\r
 \r
   return (RETURN_SUCCESS);\r
 }\r
 \r
@@ -374,9 +380,9 @@ ShellCommandRegisterCommandName (
   //\r
   // allocate memory for new struct\r
   //\r
   //\r
   // allocate memory for new struct\r
   //\r
-  Node = AllocatePool(sizeof(SHELL_COMMAND_INTERNAL_LIST_ENTRY));\r
+  Node = AllocateZeroPool(sizeof(SHELL_COMMAND_INTERNAL_LIST_ENTRY));\r
   ASSERT(Node != NULL);\r
   ASSERT(Node != NULL);\r
-  Node->CommandString = AllocatePool(StrSize(CommandString));\r
+  Node->CommandString = AllocateZeroPool(StrSize(CommandString));\r
   ASSERT(Node->CommandString != NULL);\r
 \r
   //\r
   ASSERT(Node->CommandString != NULL);\r
 \r
   //\r
@@ -440,8 +446,6 @@ ShellCommandGetProfileList (
   information will be returned. If Sections is NULL, then all help text information\r
   available will be returned.\r
 \r
   information will be returned. If Sections is NULL, then all help text information\r
   available will be returned.\r
 \r
-  @param          Sections          pointer to string representing which section to get help on.\r
-\r
   @param[in]  CommandString         Pointer to the command name.  This is the name\r
                                     found on the command line in the shell.\r
   @param[in,out] RetVal             Pointer to the return vaule from the command handler.\r
   @param[in]  CommandString         Pointer to the command name.  This is the name\r
                                     found on the command line in the shell.\r
   @param[in,out] RetVal             Pointer to the return vaule from the command handler.\r
@@ -546,13 +550,19 @@ ShellCommandGetManFileNameHandler (
   (via LIST_ENTRY structure).  enumerate through it using the BaseLib linked\r
   list functions.  do not modify the values.\r
 \r
   (via LIST_ENTRY structure).  enumerate through it using the BaseLib linked\r
   list functions.  do not modify the values.\r
 \r
+  @param[in] Sort       TRUE to alphabetically sort the values first.  FALSE otherwise.\r
+\r
   @return a Linked list of all available shell commands.\r
 **/\r
 CONST COMMAND_LIST*\r
 EFIAPI\r
 ShellCommandGetCommandList (\r
   @return a Linked list of all available shell commands.\r
 **/\r
 CONST COMMAND_LIST*\r
 EFIAPI\r
 ShellCommandGetCommandList (\r
+  IN CONST BOOLEAN Sort\r
   )\r
 {\r
   )\r
 {\r
+//  if (!Sort) {\r
+//    return ((COMMAND_LIST*)(&mCommandList));\r
+//  }\r
   return ((COMMAND_LIST*)(&mCommandList));\r
 }\r
 \r
   return ((COMMAND_LIST*)(&mCommandList));\r
 }\r
 \r
@@ -587,10 +597,10 @@ ShellCommandRegisterAlias (
   //\r
   // allocate memory for new struct\r
   //\r
   //\r
   // allocate memory for new struct\r
   //\r
-  Node = AllocatePool(sizeof(ALIAS_LIST));\r
+  Node = AllocateZeroPool(sizeof(ALIAS_LIST));\r
   ASSERT(Node != NULL);\r
   ASSERT(Node != NULL);\r
-  Node->CommandString = AllocatePool(StrSize(Command));\r
-  Node->Alias = AllocatePool(StrSize(Alias));\r
+  Node->CommandString = AllocateZeroPool(StrSize(Command));\r
+  Node->Alias = AllocateZeroPool(StrSize(Alias));\r
   ASSERT(Node->CommandString != NULL);\r
   ASSERT(Node->Alias != NULL);\r
 \r
   ASSERT(Node->CommandString != NULL);\r
   ASSERT(Node->Alias != NULL);\r
 \r
@@ -625,7 +635,7 @@ ShellCommandGetInitAliasList (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Determine if a given alias is on the list of built in alias'\r
+  Determine if a given alias is on the list of built in alias'.\r
 \r
   @param[in] Alias              The alias to test for\r
 \r
 \r
   @param[in] Alias              The alias to test for\r
 \r
@@ -694,6 +704,8 @@ ShellCommandGetEchoState(
 \r
   If State is TRUE, Echo will be enabled.\r
   If State is FALSE, Echo will be disabled.\r
 \r
   If State is TRUE, Echo will be enabled.\r
   If State is FALSE, Echo will be disabled.\r
+\r
+  @param[in] State      How to set echo.\r
 **/\r
 VOID\r
 EFIAPI\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -1040,7 +1052,7 @@ ShellCommandCreateInitialMappingsAndPaths(
     //\r
     // Get all Device Paths\r
     //\r
     //\r
     // Get all Device Paths\r
     //\r
-    DevicePathList = AllocatePool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);\r
+    DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);\r
     ASSERT(DevicePathList != NULL);\r
 \r
     for (Count = 0 ; HandleList[Count] != NULL ; Count++) {\r
     ASSERT(DevicePathList != NULL);\r
 \r
     for (Count = 0 ; HandleList[Count] != NULL ; Count++) {\r
@@ -1097,7 +1109,7 @@ ShellCommandCreateInitialMappingsAndPaths(
     //\r
     // Get all Device Paths\r
     //\r
     //\r
     // Get all Device Paths\r
     //\r
-    DevicePathList = AllocatePool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);\r
+    DevicePathList = AllocateZeroPool(sizeof(EFI_DEVICE_PATH_PROTOCOL*) * Count);\r
     ASSERT(DevicePathList != NULL);\r
 \r
     for (Count = 0 ; HandleList[Count] != NULL ; Count++) {\r
     ASSERT(DevicePathList != NULL);\r
 \r
     for (Count = 0 ; HandleList[Count] != NULL ; Count++) {\r
@@ -1132,6 +1144,13 @@ ShellCommandCreateInitialMappingsAndPaths(
   return (EFI_SUCCESS);\r
 }\r
 \r
   return (EFI_SUCCESS);\r
 }\r
 \r
+/**\r
+  Function to make sure all directory delimeters are backslashes.\r
+\r
+  @param[in,out] Path     The path to modify.\r
+\r
+  @return Path.\r
+**/\r
 CHAR16*\r
 EFIAPI\r
 ShellCommandCleanPath (\r
 CHAR16*\r
 EFIAPI\r
 ShellCommandCleanPath (\r
@@ -1189,7 +1208,7 @@ ConvertEfiFileProtocolToShellHandle(
     if (Buffer == NULL) {\r
       return (NULL);\r
     }\r
     if (Buffer == NULL) {\r
       return (NULL);\r
     }\r
-    NewNode             = AllocatePool(sizeof(BUFFER_LIST));\r
+    NewNode             = AllocateZeroPool(sizeof(BUFFER_LIST));\r
     if (NewNode == NULL) {\r
       return (NULL);\r
     }\r
     if (NewNode == NULL) {\r
       return (NULL);\r
     }\r
@@ -1232,7 +1251,7 @@ ShellFileHandleGetPath(
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Remove a SHELL_FILE_HANDLE frmo the list of SHELL_FILE_HANDLES.\r
+  Remove a SHELL_FILE_HANDLE from the list of SHELL_FILE_HANDLES.\r
 \r
   @param[in] Handle     The SHELL_FILE_HANDLE to remove.\r
 \r
 \r
   @param[in] Handle     The SHELL_FILE_HANDLE to remove.\r
 \r
@@ -1340,7 +1359,7 @@ ShellFileHandleReturnLine(
 \r
   Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
 \r
   Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    RetVal = AllocatePool(Size);\r
+    RetVal = AllocateZeroPool(Size);\r
     Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
   }\r
   ASSERT_EFI_ERROR(Status);\r
     Status = ShellFileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
   }\r
   ASSERT_EFI_ERROR(Status);\r
@@ -1409,7 +1428,7 @@ ShellFileHandleReadLine(
     CharSize = sizeof(CHAR16);\r
     Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);\r
     ASSERT_EFI_ERROR(Status);\r
     CharSize = sizeof(CHAR16);\r
     Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);\r
     ASSERT_EFI_ERROR(Status);\r
-    if (CharBuffer == UnicodeFileTag) {\r
+    if (CharBuffer == gUnicodeFileTag) {\r
       *Ascii = FALSE;\r
     } else {\r
       *Ascii = TRUE;\r
       *Ascii = FALSE;\r
     } else {\r
       *Ascii = TRUE;\r
@@ -1462,6 +1481,8 @@ ShellFileHandleReadLine(
 }\r
 /**\r
   Frees any BUFFER_LIST defined type.\r
 }\r
 /**\r
   Frees any BUFFER_LIST defined type.\r
+\r
+  @param[in] List     The BUFFER_LIST object to free.\r
 **/\r
 VOID\r
 EFIAPI\r
 **/\r
 VOID\r
 EFIAPI\r
@@ -1493,7 +1514,7 @@ FreeBufferList (
 /**\r
   Chops off last directory or file entry in a path leaving the trailing slash\r
 \r
 /**\r
   Chops off last directory or file entry in a path leaving the trailing slash\r
 \r
-  @param[in,out] Path\r
+  @param[in,out] PathToReturn The path to modify.\r
 \r
   @retval FALSE     No directory was found to chop off.\r
   @retval TRUE      A directory was chopped off.\r
 \r
   @retval FALSE     No directory was found to chop off.\r
   @retval TRUE      A directory was chopped off.\r
@@ -1505,11 +1526,11 @@ ChopLastSlash(
   )\r
 {\r
   CHAR16        *Walker;\r
   )\r
 {\r
   CHAR16        *Walker;\r
-  CHAR16        *LastSlash = NULL;\r
+  CHAR16        *LastSlash;\r
   //\r
   // get directory name from path... ('chop' off extra)\r
   //\r
   //\r
   // get directory name from path... ('chop' off extra)\r
   //\r
-  for ( Walker = PathToReturn\r
+  for ( Walker = PathToReturn, LastSlash = NULL\r
       ; Walker != NULL && *Walker != CHAR_NULL\r
       ; Walker++\r
      ){\r
       ; Walker != NULL && *Walker != CHAR_NULL\r
       ; Walker++\r
      ){\r
index e3fa29a0e7fa52a15ac4c1881bf6a4dc232acd88..fb361a67f4ad705d01cbd1d7ea12f7a64ab60449 100644 (file)
@@ -1,7 +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
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>\r
+#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. <BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -54,7 +54,7 @@
   gEfiDevicePathToTextProtocolGuid                        # ALWAYS_CONSUMED\r
 \r
 [Guids]\r
   gEfiDevicePathToTextProtocolGuid                        # ALWAYS_CONSUMED\r
 \r
 [Guids]\r
-\r
+  gEfiSasDevicePathGuid                                   # ALWAYS_CONSUMED\r
 \r
 [Pcd.common]\r
   gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel         ## ALWAYS_CONSUMED\r
 \r
 [Pcd.common]\r
   gEfiShellPkgTokenSpaceGuid.PcdShellSupportLevel         ## ALWAYS_CONSUMED\r