SHEL20
authorhfang <hfang@0aefa8ac-fc23-0410-b7a3-bf826d37e4c2>
Wed, 27 May 2009 08:55:16 +0000 (08:55 +0000)
committerhfang <hfang@0aefa8ac-fc23-0410-b7a3-bf826d37e4c2>
Wed, 27 May 2009 08:55:16 +0000 (08:55 +0000)
git-svn-id: https://efi-shell.tianocore.org/svn/efi-shell/trunk/Shell@33 0aefa8ac-fc23-0410-b7a3-bf826d37e4c2

24 files changed:
DeviceTree/DevicetreeStrings.uni
DeviceTree/devicetree.c
EDK_Snapshot.txt
IfConfig/IfConfig.c
Library/EfiShellLib.h
Library/Init.c
Library/Misc.c
Library/Misc.h
devices/DevicesStrings.uni
devices/devices.c
drivers/DriversStrings.uni
drivers/drivers.c
drvcfg/drvcfg.c
drvcfg/drvcfgStrings.uni
drvdiag/drvdiag.c
drvdiag/drvdiagStrings.uni
edit/libEditor.c
hexedit/libEditor.c
pci/pci.c
shellenv/Connect.c
shellenv/ShellenvHelpStrings.uni
shellenv/map.c
shellenv/protid.c
unload/unload.c

index 80f7fca..a2fc17f 100644 (file)
Binary files a/DeviceTree/DevicetreeStrings.uni and b/DeviceTree/DevicetreeStrings.uni differ
index 0d7fc39..147e2cb 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -123,8 +123,6 @@ Returns:
   BOOLEAN                 BestName;
   EFI_STATUS              Status;
   UINTN                   Index;
-  UINTN                   StringIndex;
-  UINTN                   StringLength;
   UINTN                   HandleNumber;
   EFI_HANDLE              Handle;
   SHELL_VAR_CHECK_CODE    RetCode;
@@ -218,28 +216,9 @@ Returns:
     goto Done;
   }
 
-  Language = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
-
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (Language != NULL) {
-      FreePool (Language);
-    }
-
-    StringLength = StrLen (Item->VarStr);
-    Language = AllocatePool (StringLength + 1);
-    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-      Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
-    }
-
-    Language[StringIndex] = 0;
+    Language = LibGetCommandLineLanguage (Item->VarStr);
   }
 
   if (LibCheckVarGetFlag (&ChkPck, L"-d") != NULL) {
@@ -555,45 +534,24 @@ Returns:
   BOOLEAN     BestName;
   EFI_STATUS  Status;
   UINTN       Index;
-  UINTN       StringIndex;
-  UINTN       StringLength;
   BOOLEAN     PrtHelp;
 
   Status    = EFI_SUCCESS;
   PrtHelp   = FALSE;
-  Language  = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
 
   Arg = NULL;
   //
   // Crack args
   //
   BestName = TRUE;
+  Language = NULL;
   for (Index = 1; Index < SI->Argc; Index += 1) {
     Ptr = SI->Argv[Index];
     if (*Ptr == '-') {
       switch (Ptr[1]) {
       case 'l':
       case 'L':
-        if (*(Ptr + 2) != 0) {
-          if (Language != NULL) {
-            FreePool (Language);
-          }
-
-          StringLength = StrLen (Ptr + 2);
-          Language = AllocatePool (StringLength + 1);
-          for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-            Language[StringIndex] = (CHAR8) Ptr[StringIndex + 2];
-          }
-
-          Language[StringIndex] = 0;
-        }
+        Language = LibGetCommandLineLanguage (Ptr + 2);
         break;
 
       case 'd':
@@ -680,5 +638,8 @@ Returns:
   Status = EFI_SUCCESS;
 
 Done:
+  if (Language != NULL) {
+    FreePool (Language);
+  }
   return Status;
 }
index 6e64fb0..032ea92 100644 (file)
@@ -1,5 +1,5 @@
 Notes:
-  This EFI Shell release package has been tested on the 2008-11-21's EDK which snapshot
-is Edk-Dev-Snapshot-20081121, User can get this version EDK from the following URL:
-  https://edk.tianocore.org/files/documents/16/495/Edk-Dev-Snapshot-20081121.zip
+  This EFI Shell release package has been tested on the 2009-05-27's EDK which snapshot
+is Edk-Dev-Snapshot-20090527, User can get this version EDK from the following URL:
+  https://edk.tianocore.org/files/documents/16/526/Edk-Dev-Snapshot-20090527.zip
   We don't guarantee this package can work correctly on the other EDK snapshot.
\ No newline at end of file
index 5098d65..036c4ee 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2006, Intel Corporation                                                         
+Copyright (c) 2006 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -23,10 +23,20 @@ Abstract:
 #include STRING_DEFINES_FILE
 extern UINT8 STRING_ARRAY_NAME[];
 
+#define NET_IFTYPE_ETHERNET    1
+#define NIC_ITEM_CONFIG_SIZE   sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE
+
 EFI_HII_HANDLE  HiiHandle;
 
 EFI_GUID  EfiIfConfigGuid = EFI_IFCONFIG_GUID;
 
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+EFI_HII_CONFIG_ROUTING_PROTOCOL  *mHiiConfigRouting = NULL;
+#endif
+BOOLEAN                          mIp4ConfigExist    = FALSE;
+
+
 SHELL_VAR_CHECK_ITEM  IfConfigCheckList[] = {
   {
     L"-b",
@@ -178,6 +188,517 @@ Returns:
     );
 }
 
+UINTN
+AppendOffsetWidthValue (
+  IN OUT CHAR16               *String,
+  IN UINTN                    Offset,
+  IN UINTN                    Width,
+  IN UINT8                    *Block
+  )
+/*++
+
+Routine Description:
+  Append OFFSET/WIDTH/VALUE items at the beginning of string.
+
+Arguments:
+  String -         Point to the position should be appended.
+  Offset -         Offset value.
+  Width  -         Width value.
+  Block  -         Point to data buffer.
+
+Returns:
+  The count of unicode character was appended.
+
+--*/
+{
+  CHAR16                      *OriString;
+
+  OriString = String;
+
+  StrCpy (String, L"&OFFSET=");
+  String += StrLen (L"&OFFSET=");
+  String += SPrint (String, 0, L"%x", Offset);
+
+  StrCpy (String,L"&WIDTH=");
+  String += StrLen (L"&WIDTH=");
+  String += SPrint (String, 0, L"%x", Width);
+
+  if (Block != NULL) {
+    StrCpy (String,L"&VALUE=");
+    String += StrLen (L"&VALUE=");
+    while ((Width--) != 0) {
+      String += SPrint (String, 0, L"%x", Block[Width]);
+    }
+  }
+  
+  return String - OriString;
+}
+
+CHAR16 *
+ConstructConfigHdr (
+  IN EFI_GUID                *Guid,
+  IN CHAR16                  *Name,
+  IN EFI_HANDLE              DriverHandle
+  )
+/*++
+
+Routine Description:
+  Construct <ConfigHdr> using routing information GUID/NAME/PATH.
+
+Arguments:
+  Guid          - Routing information: GUID.
+  Name          - Routing information: NAME.
+  DriverHandle  - Driver handle which contains the routing information: PATH.
+
+Returns:
+  NULL  - Fails.
+  Other - Pointer to configHdr string.
+
+--*/
+{
+  EFI_STATUS                 Status;
+  CHAR16                     *ConfigHdr;
+  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
+  CHAR16                     *String;
+  CHAR16                     *UpperString;
+  UINTN                      Index;
+  UINT8                      *Buffer;
+  UINTN                      DevicePathLength;
+  UINTN                      NameLength;
+
+  //
+  // Get device path 
+  //
+  Status = BS->HandleProtocol (
+                 DriverHandle,
+                 &gEfiDevicePathProtocolGuid,
+                 (VOID **) &DevicePath
+                 );
+  
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
+
+  DevicePathLength = DevicePathSize (DevicePath);
+  NameLength = StrLen (Name);
+  ConfigHdr = AllocateZeroPool ((5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathLength * 2 + 1) * sizeof (CHAR16));
+  if (ConfigHdr == NULL) {
+    return NULL;
+  } 
+
+  String = ConfigHdr;
+  StrCpy (String, L"GUID=");
+  String += StrLen (L"GUID=");
+
+  //
+  // Append Guid converted to <HexCh>32
+  //
+  UpperString = String;
+  for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) {
+    String += SPrint (String, 0, L"%02x", *Buffer++);
+  }
+  *String = 0;
+  StrLwr (UpperString);
+
+  //
+  // Append L"&NAME="
+  //
+  StrCpy (String, L"&NAME=");
+  String += StrLen (L"&NAME=");
+  UpperString = String;
+  for (Index = 0; Index < NameLength ; Index++) {
+    String += SPrint (String, 0, L"00%x", Name[Index]);
+  }
+  *String = 0;
+  StrLwr (UpperString);
+  
+  //
+  // Append L"&PATH="
+  //
+
+  StrCpy (String, L"&PATH=");
+  String += StrLen (L"&PATH=");
+  UpperString = String;
+  for (Index = 0, Buffer = (UINT8 *) DevicePath; Index < DevicePathLength; Index++) {
+    String += SPrint (String, 0, L"%02x", *Buffer++);
+  }
+  *String = 0;
+  StrLwr (UpperString);
+
+  return ConfigHdr;
+}
+
+EFI_STATUS
+IfConfigGetNicMacInfo (
+  IN  EFI_HANDLE                    ImageHandle,
+  IN  EFI_HANDLE                    Handle,
+  OUT NIC_ADDR                      *NicAddr
+  )    
+/*++
+
+Routine Description:
+  Get network physical device NIC information.
+
+Arguments:
+  ImageHandle - The image handle of this application.
+  Handle      - The network physical device handle.
+  NicAddr     - NIC information.
+
+Returns:
+  EFI_SUCCESS - Get NIC information successfully.
+  Other       - Fails to get NIC information.
+
+--*/                  
+{
+  EFI_STATUS                    Status;
+  EFI_HANDLE                    MnpHandle;
+  EFI_SIMPLE_NETWORK_MODE       SnpMode;
+  EFI_MANAGED_NETWORK_PROTOCOL  *Mnp;
+
+  MnpHandle = NULL;
+  Mnp       = NULL;
+
+  Status = ShellCreateServiceChild (
+             Handle,
+             ImageHandle, 
+             &gEfiManagedNetworkServiceBindingProtocolGuid,
+             &MnpHandle
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  Status = BS->HandleProtocol (
+                  MnpHandle,
+                  &gEfiManagedNetworkProtocolGuid,
+                  (VOID **) &Mnp
+                  );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
+  Status = Mnp->GetModeData (Mnp, NULL, &SnpMode);
+  if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
+    goto ON_ERROR;
+  }
+  NicAddr->Type    = (UINT16) SnpMode.IfType;
+  NicAddr->Len     = (UINT8) SnpMode.HwAddressSize;
+  CopyMem (&NicAddr->MacAddr, &SnpMode.CurrentAddress, NicAddr->Len);
+
+ON_ERROR:
+
+  ShellDestroyServiceChild (
+    Handle,
+    ImageHandle, 
+    &gEfiManagedNetworkServiceBindingProtocolGuid,
+    MnpHandle
+    );
+
+  return Status;
+
+}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+EFI_STATUS
+IfconfigGetAllNicInfoByHii (
+  EFI_HANDLE                  ImageHandle
+  )
+/*++
+
+Routine Description:
+
+  Get all Nic's information through HII service.
+
+Arguments:
+
+  ImageHandle - The image handle of this application.
+
+Returns:
+
+  EFI_SUCCESS - All the nic information is collected.
+  other       - Some error occurs.
+
+--*/
+{
+  EFI_STATUS                    Status;
+  EFI_HANDLE                    *Handles;
+  UINTN                         HandleCount;
+  CHAR16                        *ConfigResp;
+  CHAR16                        *ConfigHdr;
+  UINTN                         Index;
+  CHAR16                        *AccessProgress;
+  CHAR16                        *AccessResults;
+  UINTN                         BufferSize;
+  NIC_INFO                      *NicInfo;
+  NIC_IP4_CONFIG_INFO           *NicConfigRequest;
+  NIC_IP4_CONFIG_INFO           *NicConfig;
+  CHAR16                        *String;
+  UINTN                         Length;
+  UINTN                         Offset;
+
+  AccessResults    = NULL;
+  ConfigHdr        = NULL;
+  ConfigResp       = NULL;
+  NicConfigRequest = NULL;
+
+  InitializeListHead (&NicInfoList);
+
+  //
+  // Check if HII Config Routing protocol available.
+  //
+  Status = BS->LocateProtocol (
+                &gEfiHiiConfigRoutingProtocolGuid,
+                NULL,
+                &mHiiConfigRouting
+                );
+  if (EFI_ERROR (Status)) {
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Locate all network device handles
+  //
+  Status = BS->LocateHandleBuffer (
+                 ByProtocol,
+                 &gEfiManagedNetworkServiceBindingProtocolGuid,
+                 NULL,
+                 &HandleCount,
+                 &Handles
+                 );
+  if (EFI_ERROR (Status) || (HandleCount == 0)) {
+    return EFI_NOT_FOUND;
+  }
+
+  for (Index = 0; Index < HandleCount; Index++) {
+    //
+    // Construct configuration request string header
+    //
+    ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Handles[Index]);
+    Length = StrLen (ConfigHdr);
+    ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
+    if (ConfigResp == NULL) {
+      Status = EFI_OUT_OF_RESOURCES;
+      goto ON_ERROR;
+    }
+    StrCpy (ConfigResp, ConfigHdr);
+    //
+    // Append OFFSET/WIDTH pair
+    //
+    String = ConfigResp + Length;
+    Offset = 0;
+    String += AppendOffsetWidthValue (String, Offset, NIC_ITEM_CONFIG_SIZE, NULL);
+
+
+    NicInfo = AllocateZeroPool (sizeof (NIC_INFO));
+    if (NicInfo == NULL) {
+      Status = EFI_OUT_OF_RESOURCES;
+      goto ON_ERROR;
+    }
+    NicInfo->Handle       = Handles[Index];
+    NicInfo->NicIp4Config = NULL;
+
+    //
+    // Get network physical devcie MAC information
+    //
+    IfConfigGetNicMacInfo (ImageHandle, Handles[Index], &NicInfo->NicAddress);
+    if (NicInfo->NicAddress.Type == NET_IFTYPE_ETHERNET) {
+      SPrint (NicInfo->Name, 0, L"eth%d", Index);
+    } else {
+      SPrint (NicInfo->Name, 0, L"unk%d", Index);
+    }
+
+    NicConfigRequest = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);
+    if (NicConfigRequest == NULL) {
+      Status = EFI_OUT_OF_RESOURCES;
+      goto ON_ERROR;
+    }
+
+    //
+    // Get network parameters by HII service
+    //
+    Status = mHiiConfigRouting->ExtractConfig (
+                                  mHiiConfigRouting,
+                                  ConfigResp,
+                                  &AccessProgress,
+                                  &AccessResults
+                                  );
+    if (!EFI_ERROR (Status)) {
+      BufferSize = NIC_ITEM_CONFIG_SIZE;
+      Status = mHiiConfigRouting->ConfigToBlock (
+                                    mHiiConfigRouting,
+                                    AccessResults,
+                                    (UINT8 *) NicConfigRequest,
+                                    &BufferSize,
+                                    &AccessProgress
+                                    );
+      if (!EFI_ERROR (Status)) {
+        BufferSize = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * NicConfigRequest->Ip4Info.RouteTableSize;
+        NicConfig = AllocateZeroPool (BufferSize);
+        if (NicConfig == NULL) {
+          Status = EFI_OUT_OF_RESOURCES;
+          goto ON_ERROR;
+        }
+        CopyMem (NicConfig, NicConfigRequest, BufferSize);
+
+        //
+        // If succeeds to get NIC configuration, fix up routetable pointer.
+        //
+        NicConfig->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (&NicConfig->Ip4Info + 1);
+        NicInfo->ConfigInfo   = NicConfig;
+
+      } else {
+        NicInfo->ConfigInfo   = NULL;
+      }
+
+      FreePool (AccessResults);
+
+    } else {
+      NicInfo->ConfigInfo   = NULL;
+    }
+
+    //
+    // Add the Nic's info to the global NicInfoList.
+    //
+    InsertTailList (&NicInfoList, &NicInfo->Link);
+
+    FreePool (NicConfigRequest);
+    FreePool (ConfigResp);
+    FreePool (ConfigHdr);
+  }
+
+  return EFI_SUCCESS;
+ON_ERROR:
+  if (AccessResults != NULL) {
+    FreePool (AccessResults);
+  }
+  if (NicConfigRequest != NULL) {
+    FreePool (NicConfigRequest);
+  }
+  if (ConfigResp != NULL) {
+    FreePool (ConfigResp);
+  }
+  if (ConfigHdr != NULL) {
+    FreePool (ConfigHdr);
+  }
+
+  FreePool (Handles);
+
+  return Status;
+}
+
+EFI_STATUS
+IfconfigSetNicAddrByHii (
+  IN  NIC_INFO                      *NicInfo,
+  IN  NIC_IP4_CONFIG_INFO           *Config
+  )
+/*++
+
+Routine Description:
+
+  Set the address for the specified nic by HII service.
+
+Arguments:
+
+  NicInfo - Pointer to the NIC_INFO of the Nic to be configured.
+  Config - The command line arguments for the set operation.
+
+Returns:
+
+  EFI_SUCCESS - The address set operation is done.
+  other       - Some error occurs.
+
+--*/
+{
+  EFI_STATUS                    Status;
+  NIC_IP4_CONFIG_INFO           *NicConfig;
+  CHAR16                        *ConfigResp;
+  CHAR16                        *ConfigHdr;
+  CHAR16                        *AccessProgress;
+  CHAR16                        *AccessResults;
+  CHAR16                        *String;
+  UINTN                         Length;
+  UINTN                         Offset;
+
+  AccessResults  = NULL;
+  ConfigHdr      = NULL;
+  ConfigResp     = NULL;
+  NicConfig      = NULL;
+
+  //
+  // Construct config request string header
+  //
+  ConfigHdr = ConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, NicInfo->Handle);
+
+  Length = StrLen (ConfigHdr);
+  ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
+  StrCpy (ConfigResp, ConfigHdr);
+
+  NicConfig = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);
+  if (NicConfig == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ON_ERROR;
+  }
+
+  if (Config != NULL) {
+    CopyMem (NicConfig, Config, sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * Config->Ip4Info.RouteTableSize);
+  }
+
+  //
+  // Append OFFSET/WIDTH pair
+  //
+  String = ConfigResp + Length;
+  Offset = 0;
+  String += AppendOffsetWidthValue (String, Offset, NIC_ITEM_CONFIG_SIZE, NULL);
+
+  //
+  // Call HII helper function to generate configuration string
+  //
+  Status = mHiiConfigRouting->BlockToConfig (
+                                mHiiConfigRouting,
+                                ConfigResp,
+                                (UINT8 *) NicConfig,
+                                NIC_ITEM_CONFIG_SIZE,
+                                &AccessResults,
+                                &AccessProgress
+                                );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
+  //
+  // Set IP setting by HII servie
+  //
+  Status = mHiiConfigRouting->RouteConfig (
+                                mHiiConfigRouting,
+                                AccessResults,
+                                &AccessProgress
+                                );
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;
+  }
+
+ON_ERROR:
+  if (AccessResults != NULL) {
+    FreePool (AccessResults);
+  }
+  if (NicConfig != NULL) {
+    FreePool (NicConfig);
+  }
+  if (ConfigResp != NULL) {
+    FreePool (ConfigResp);
+  }
+  if (ConfigHdr != NULL) {
+    FreePool (ConfigHdr);
+  }
+
+  return Status;
+}
+#endif
+
+
 EFI_STATUS
 IfconfigGetAllNicInfo (
   VOID
@@ -208,7 +729,7 @@ Returns:
   UINT32                        Index;
   UINTN                         Len;
   EFI_STATUS                    Status;
-
+  
   NicIp4Config = NULL;
   Ip4Config    = NULL;
   NicInfo      = NULL;
@@ -218,20 +739,23 @@ Returns:
   InitializeListHead (&NicInfoList);
 
   //
-  // Locate the handles which has NicIp4Config installed.
+  // Locate the handles which has Ip4Config installed.
   //
   Status = BS->LocateHandleBuffer (
                 ByProtocol,
-                &gEfiNicIp4ConfigProtocolGuid,
+                &gEfiIp4ConfigProtocolGuid,
                 NULL,
                 &HandleCount,
                 &Handles
                 );
   if (EFI_ERROR (Status) || (HandleCount == 0)) {
-    PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiHandle, L"IfConfig", L"Ip4Config protocol");
-    
     return EFI_NOT_FOUND;
   }
+  
+  //
+  // Found Ip4Config protocol
+  //
+  mIp4ConfigExist = TRUE;
 
   for (Index = 0; Index < HandleCount; Index++) {
     //
@@ -906,12 +1430,38 @@ Returns:
   Config->NicAddr = Info->NicAddress;
   Config->Perment = Perment;
 
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+  if (Info->NicIp4Config == NULL) {
+    //
+    // Try to use HII service to set NIC address
+    //
+    Status = IfconfigSetNicAddrByHii (Info, Config);
+    if (EFI_ERROR (Status)) {
+      PrintToken (STRING_TOKEN (STR_IFCONFIG_SET_FAIL), HiiHandle, Status);
+      goto ON_EXIT;
+    } 
+  } else {
+    //
+    // Try to use NicIp4Config protocol to set NIC address
+    //
+    Status = Info->NicIp4Config->SetInfo (Info->NicIp4Config, Config, TRUE);
+
+    if (EFI_ERROR (Status)) {
+      PrintToken (STRING_TOKEN (STR_IFCONFIG_SET_FAIL), HiiHandle, Status);
+      goto ON_EXIT;
+    } 
+  }
+#else
+  //
+  // Try to use NicIp4Config protocol to set NIC address
+  //
   Status = Info->NicIp4Config->SetInfo (Info->NicIp4Config, Config, TRUE);
 
   if (EFI_ERROR (Status)) {
     PrintToken (STRING_TOKEN (STR_IFCONFIG_SET_FAIL), HiiHandle, Status);
     goto ON_EXIT;
   } 
+#endif
 
   Status = IfconfigStartIp4 (Info, Image);
 
@@ -976,7 +1526,7 @@ Returns:
     } else if (NicInfo->ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC) {
       PrintToken (STRING_TOKEN (STR_IFCONFIG_CONFIG_SOURCE), HiiHandle, L"STATIC");
     } else {
-       PrintToken (STRING_TOKEN (STR_IFCONFIG_CONFIG_SOURCE), HiiHandle, L"Unknown");
+      PrintToken (STRING_TOKEN (STR_IFCONFIG_CONFIG_SOURCE), HiiHandle, L"Unknown");
     }
 
     PrintToken (
@@ -1053,7 +1603,16 @@ Returns:
       continue;
     }
     
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+    if (Info->NicIp4Config == NULL) { 
+      Status = IfconfigSetNicAddrByHii (Info, NULL);
+    } else {
+      Status = Info->NicIp4Config->SetInfo (Info->NicIp4Config, NULL, TRUE);
+    }
+#else 
     Status = Info->NicIp4Config->SetInfo (Info->NicIp4Config, NULL, TRUE);
+#endif
+
 
     if (EFI_ERROR (Status)) {
       return Status;
@@ -1155,10 +1714,31 @@ Returns:
   }
 
   Status = IfconfigGetAllNicInfo ();
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
   if (EFI_ERROR (Status)) {
-    PrintToken (STRING_TOKEN (STR_IFCONFIG_GET_NIC_FAIL), HiiHandle, Status);
-    goto Done;
+    Status = IfconfigGetAllNicInfoByHii (ImageHandle);
+
+    if (EFI_ERROR (Status)) {
+      if (mIp4ConfigExist) {
+        PrintToken (STRING_TOKEN (STR_IFCONFIG_GET_NIC_FAIL), HiiHandle, Status);
+      } else {
+        PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiHandle, L"IfConfig", L"Ip4Config Protocol");
+      }
+
+      return EFI_NOT_FOUND;
+    }
+  } 
+#else 
+  if (EFI_ERROR (Status)) {
+    if (mIp4ConfigExist) {
+      PrintToken (STRING_TOKEN (STR_IFCONFIG_GET_NIC_FAIL), HiiHandle, Status);
+    } else {
+      PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LOC_PROT_ERR_EX), HiiHandle, L"IfConfig", L"Ip4Config Protocol");
+    }
+
+    return EFI_NOT_FOUND;
   }
+#endif
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item != NULL) {
index 46c0316..6243d1d 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -190,7 +190,8 @@ Revision History
 #define VarConsoleInpDev    L"ConInDev"
 #define VarConsoleOutDev    L"ConOutDev"
 #define VarErrorOutDev      L"ErrOutDev"
-#define LanguageCodeEnglish "eng"
+#define DefaultLang         "eng"
+#define DefaultPlatformLang "en-US"
 
 #define ISO_639_2_ENTRY_SIZE  3
 #define RFC_3066_ENTRY_SIZE   12
@@ -321,17 +322,39 @@ DivU64x32 (
   OUT UINTN   *Remainder OPTIONAL
   );
 
-EFI_STATUS
-LibGetComponentNameProtocol (
-  IN EFI_HANDLE                      DriverBindingHandle,
-  OUT EFI_COMPONENT_NAME_PROTOCOL    **ComponentName,
-  OUT EFI_COMPONENT_NAME2_PROTOCOL   **ComponentName2
+CHAR8 *
+GetBestLanguage (
+  IN CHAR8        *SupportedLanguages, 
+  IN BOOLEAN      Iso639Language,
+  ...
+  );
+
+CHAR8 *
+LibGetCommandLineLanguage (
+  IN CHAR16        *CommandLineLanguage
   );
 
 CHAR8 *
-LibConvertSupportedLanguage (
-  IN CHAR8                           *SupportedLanguages,
-  IN CHAR8                           *LangCode
+LibSelectBestLanguage (
+  IN CHAR8        *SupportedLanguages,
+  IN BOOLEAN      Iso639Language,
+  IN CHAR8        *Language
+  );
+
+EFI_STATUS
+LibGetDriverName (
+  IN  EFI_HANDLE  DriverBindingHandle,
+  IN  CHAR8       *Language,
+  OUT CHAR16      **DriverName
+  );
+
+EFI_STATUS
+LibGetControllerName (
+  IN  EFI_HANDLE  DriverBindingHandle,
+  IN  EFI_HANDLE  ControllerHandle,
+  IN  EFI_HANDLE  ChildHandle,
+  IN  CHAR8       *Language,
+  OUT CHAR16      **ControllerName
   );
 
 #endif
index 93d1abe..80dc3a3 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -26,6 +26,133 @@ extern EFI_UNICODE_COLLATION_PROTOCOL LibStubUnicodeInterface;
 
 extern EFI_GUID                       ShellEnvProtocol;
 
+EFI_STATUS
+InitializeUnicodeCollationSupportWorker (
+  IN EFI_HANDLE         AgentHandle,
+  IN EFI_GUID           *ProtocolGuid
+  )
+/*++
+
+Routine Description:
+
+  Worker function to initialize Unicode Collation support.
+  It tries to locate Unicode Collation (2) protocol and matches it with current
+  platform language code and the default language code.
+    
+Arguments:
+
+  AgentHandle  - The handle used to open Unicode Collation (2) protocol.
+  ProtocolGuid - The pointer to Unicode Collation (2) protocol GUID.
+    
+Returns:
+
+  EFI_SUCCESS  - The Unicode Collation (2) protocol has been successfully located.
+  Others       - The Unicode Collation (2) protocol has not been located.
+
+--*/
+{
+  EFI_STATUS                      Status;
+  UINTN                           NumHandles;
+  UINTN                           Index;
+  EFI_HANDLE                      *Handles;
+  EFI_UNICODE_COLLATION_PROTOCOL  *Uci;
+  BOOLEAN                         Iso639Language;
+  CHAR8                           *BestLanguage;
+
+  Status = BS->LocateHandleBuffer (
+                 ByProtocol,
+                 ProtocolGuid,
+                 NULL,
+                 &NumHandles,
+                 &Handles
+                 );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  Iso639Language = (BOOLEAN) (ProtocolGuid == &gEfiUnicodeCollationProtocolGuid);
+
+  Status = EFI_UNSUPPORTED;
+  for (Index = 0; Index < NumHandles; Index++) {
+    //
+    // Open Unicode Collation Protocol
+    //
+    Status = BS->OpenProtocol (
+                   Handles[Index],
+                   ProtocolGuid,
+                   (VOID **) &Uci,
+                   AgentHandle,
+                   NULL,
+                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                   );
+    if (EFI_ERROR (Status)) {
+      continue;
+    }
+
+    //
+    // Find the best matching matching language from the supported languages
+    // of Unicode Collation (2) protocol. 
+    //
+    BestLanguage = LibSelectBestLanguage (
+                     Uci->SupportedLanguages,
+                     Iso639Language,
+                     NULL
+                     );
+    if (BestLanguage != NULL) {
+      FreePool (BestLanguage);
+      UnicodeInterface = Uci;
+      Status = EFI_SUCCESS;
+      break;
+    }
+  }
+
+  FreePool (Handles);
+
+  return Status;
+}
+
+
+EFI_STATUS
+InitializeUnicodeCollationSupport (
+  IN EFI_HANDLE    AgentHandle
+  )
+/*++
+
+Routine Description:
+
+  This function initializes Unicode Collation Support for shell.
+  It tries to locate Unicode Collation (2) protocol and matches it with current
+  platform language code and the default language code.
+    
+Arguments:
+
+  AgentHandle  - The handle used to open Unicode Collation (2) protocol.
+    
+Returns:
+
+  EFI_SUCCESS  - The Unicode Collation (2) protocol has been successfully located.
+  Others       - The Unicode Collation (2) protocol has not been located.
+
+--*/
+{
+
+  EFI_STATUS       Status;
+
+  //
+  // First try to use RFC 4646 Unicode Collation 2 Protocol.
+  //
+  Status = InitializeUnicodeCollationSupportWorker (AgentHandle, &gEfiUnicodeCollation2ProtocolGuid);
+  //
+  // If the attempt to use Unicode Collation 2 Protocol fails, then we fall back
+  // on the ISO 639-2 Unicode Collation Protocol.
+  //
+  if (EFI_ERROR (Status)) {
+    Status = InitializeUnicodeCollationSupportWorker (AgentHandle, &gEfiUnicodeCollationProtocolGuid);
+  }
+
+  return Status;
+}
+
 VOID
 InitializeShellLib (
   IN EFI_HANDLE           ImageHandle,
@@ -50,7 +177,6 @@ Returns:
 {
   EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
   EFI_STATUS                Status;
-  CHAR8                     *LangCode;
 
   if (!ShellLibInitialized) {
     ShellLibInitialized = TRUE;
@@ -84,16 +210,8 @@ Returns:
     InitializeLibPlatform (ImageHandle, SystemTable);
   }
 
-  if (ImageHandle && UnicodeInterface == &LibStubUnicodeInterface) {
-    LangCode  = LibGetVariableLang ();
-    Status    = InitializeUnicodeSupport (LangCode);
-    if (EFI_ERROR (Status)) {
-      Status = InitializeUnicodeSupport (LanguageCodeEnglish);
-    }
-
-    if (LangCode) {
-      FreePool (LangCode);
-    }
+  if ((ImageHandle != NULL) && (UnicodeInterface == &LibStubUnicodeInterface)) {
+    InitializeUnicodeCollationSupport (ImageHandle);
   }
 
   DEBUG_CODE (
@@ -102,86 +220,6 @@ Returns:
   )
 }
 
-EFI_STATUS
-InitializeUnicodeSupport (
-  CHAR8 *LangCode
-  )
-/*++
-
-Routine Description:
-
-  Initializes Unicode support
-    
-Arguments:
-
-  LangCode - Language Code specified
-    
-Returns:
-
-  None
-
---*/
-{
-  EFI_UNICODE_COLLATION_PROTOCOL  *Ui;
-  EFI_STATUS                      Status;
-  CHAR8                           *Languages;
-  UINTN                           Index;
-  UINTN                           NoHandles;
-  EFI_HANDLE                      *Handles;
-  EFI_STATUS                      ReturnStatus;
-
-  ReturnStatus = EFI_UNSUPPORTED;
-  //
-  // If we don't know it, lookup the current language code
-  //
-  LibLocateHandle (ByProtocol, &gEfiUnicodeCollation2ProtocolGuid, NULL, &NoHandles, &Handles);
-  if (NoHandles == 0) {
-    LibLocateHandle (ByProtocol, &gEfiUnicodeCollationProtocolGuid, NULL, &NoHandles, &Handles);
-  }
-  if (!LangCode || !NoHandles) {
-    goto Done;
-  }
-  //
-  // Check all driver's for a matching language code
-  //
-  for (Index = 0; Index < NoHandles; Index++) {
-    Status = BS->HandleProtocol (Handles[Index], &gEfiUnicodeCollation2ProtocolGuid, (VOID *) &Ui);
-    if (EFI_ERROR (Status)) {
-      Status = BS->HandleProtocol (Handles[Index], &gEfiUnicodeCollationProtocolGuid, (VOID *) &Ui);
-    }
-    if (EFI_ERROR (Status)) {
-      continue;
-    }
-    //
-    // Check for a matching language code
-    //
-    if (strstra (Ui->SupportedLanguages, LangCode) == NULL) {
-      Languages = LibConvertSupportedLanguage (Ui->SupportedLanguages, LangCode);
-      if (strcmpa (Languages, LangCode) != 0) {
-        UnicodeInterface  = Ui;
-        ReturnStatus      = EFI_SUCCESS;
-        FreePool (Languages);
-        goto Done;
-      } else {
-        FreePool (Languages);
-      }
-    } else {
-      UnicodeInterface  = Ui;
-      ReturnStatus      = EFI_SUCCESS;
-      goto Done;
-    }
-  }
-
-Done:
-  //
-  // Cleanup
-  //
-  if (Handles) {
-    FreePool (Handles);
-  }
-
-  return ReturnStatus;
-}
 
 #if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 EFI_HII_PROTOCOL *HiiProt        = NULL;
index d5adb14..a4f6faa 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -395,30 +395,27 @@ CHAR8  ca[] = { 3, 1, 2 };
 
 VOID *
 LibGetVariableLang (
-  VOID
+  IN BOOLEAN               Iso639Language
   )
 /*++
 
 Routine Description:
-  Function returns the value of the Language Variable.
+
+  Function returns the value of the Language Variable. If Iso639Language is TRUE,
+  It retrieves ISO 639-2 global variable L"Lang"; if IsoLanguage is FALSE, it
+  retrieves RFC 4646 global variable L"PlatformLang".
 
 Arguments:
-  None
+
+  Iso639Language   - Indicates whether the language is in ISO 639-2 format or RFC 4646 format
 
 Returns:
 
-  None
+  The language variable contents.
 
 --*/
 {
-  VOID *Var;
-
-  Var = LibGetVariable (L"PlatformLang", &gEfiGlobalVariableGuid);
-  if (Var == NULL) {
-    Var = LibGetVariable (L"Lang", &gEfiGlobalVariableGuid);
-  }
-
-  return Var;
+  return LibGetVariable (Iso639Language ? L"Lang" : L"PlatformLang", &gEfiGlobalVariableGuid);
 }
 
 VOID *
@@ -2151,125 +2148,651 @@ Returns:
   return Status;
 }
 
-EFI_STATUS
-LibGetComponentNameProtocol (
-  IN EFI_HANDLE                      DriverBindingHandle,
-  OUT EFI_COMPONENT_NAME_PROTOCOL    **ComponentName,
-  OUT EFI_COMPONENT_NAME2_PROTOCOL   **ComponentName2
+
+CHAR8 *
+LibGetCommandLineLanguage (
+  IN CHAR16        *CommandLineLanguage
+  )
+/*++
+
+Routine Description:
+
+  Gets the language from command line parameter and converts it to an newly allocated ASCII language code.
+
+Arguments:
+  CommandLineLanguage  - An NULL-terminated Unicode language string.
+
+Returns:
+  An allocated ASCII language string correspond to the command line language or NULL if
+  the input command line string is NULL or there is not enough memory .
+
+--*/
+{
+  CHAR8           *Language;
+  UINTN           Length;
+  UINTN           Index;
+
+  Language = NULL;
+  if (CommandLineLanguage != NULL) {
+    Length = StrLen(CommandLineLanguage);
+    Language = AllocatePool (Length + 1);
+    if (Language != NULL) {
+      for (Index = 0; Index <= Length; Index++) {
+        Language[Index] = (CHAR8) CommandLineLanguage[Index];
+      }
+    }
+  }
+
+  return Language;
+}
+
+
+CHAR8 *
+GetBestLanguage (
+  IN CHAR8        *SupportedLanguages, 
+  IN BOOLEAN      Iso639Language,
+  ...
   )
 /*++
 
-  Routine Description:
+Routine Description:
 
-    Get the ComponentName or ComponentName2 protocol according to the driver binding handle
+  Returns a pointer to an allocated buffer that contains the best matching language 
+  from a set of supported languages.  
+  
+  This function supports both ISO 639-2 and RFC 4646 language codes, but language 
+  code types may not be mixed in a single call to this function.  The language 
+  code returned is allocated using AllocatePool().  The caller is responsible for 
+  freeing the allocated buffer using FreePool().  This function supports a variable
+  argument list that allows the caller to pass in a prioritized list of language 
+  codes to test against all the language codes in SupportedLanguages. 
 
-  Arguments:
+  If SupportedLanguages is NULL, then ASSERT()..
 
-    DriverBindingHandle   - The Handle of DriverBinding
-    ComponentName         - Pointer to the ComponentName protocl pointer
-    ComponentName2        - Pointer to the ComponentName2 protocl pointer
+Arguments:
 
-  Returns:
+  SupportedLanguages   -          A pointer to a Null-terminated ASCII string that
+                                  contains a set of language codes in the format 
+                                  specified by Iso639Language.
+  Iso639Language       -          If TRUE, then all language codes are assumed to be
+                                  in ISO 639-2 format.  If FALSE, then all language
+                                  codes are assumed to be in RFC 4646 language format.
+  ...                  -          A variable argument list that contains pointers to 
+                                  Null-terminated ASCII strings that contain one or more
+                                  language codes in the format specified by Iso639Language.
+                                  The first language code from each of these language
+                                  code lists is used to determine if it is an exact or
+                                  close match to any of the language codes in 
+                                  SupportedLanguages.  Close matches only apply to RFC 4646
+                                  language codes, and the matching algorithm from RFC 4647
+                                  is used to determine if a close match is present.  If 
+                                  an exact or close match is found, then the matching
+                                  language code from SupportedLanguages is returned.  If
+                                  no matches are found, then the next variable argument
+                                  parameter is evaluated.  The variable argument list 
+                                  is terminated by a NULL
 
-    EFI_INVALID_PARAMETER - The ComponentName and ComponentName2 parameters are invalid.
-    EFI_NOT_FOUND         - Neither ComponentName nor ComponentName2 has been installed.
+Returns:
+  NULL                -           The best matching language could not be found in SupportedLanguages.
+  NULL                -           There are not enough resources available to return the best matching 
+                                  language.
+  Other               -           A pointer to a Null-terminated ASCII string that is the best matching 
+                                  language in SupportedLanguages.
 
 --*/
 {
-  EFI_STATUS                         Status;
+  VA_LIST      Args;
+  CHAR8        *Language;
+  UINTN        CompareLength;
+  UINTN        LanguageLength;
+  CHAR8        *Supported;
+  CHAR8        *BestLanguage;
+
+  ASSERT (SupportedLanguages != NULL);
+
+  VA_START (Args, Iso639Language);
+  while ((Language = VA_ARG (Args, CHAR8 *)) != NULL) {
+    //
+    // Default to ISO 639-2 mode
+    //
+    CompareLength  = 3;
+    LanguageLength = strlena (Language);
+    if (LanguageLength > 3) {
+      LanguageLength = 3;
+    }
+
+    //
+    // If in RFC 4646 mode, then determine the length of the first RFC 4646 language code in Language
+    //
+    if (!Iso639Language) {
+      for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++);
+    }
 
-  if ((ComponentName == NULL) || (ComponentName2 == NULL)) {
-    return EFI_INVALID_PARAMETER;
+    //
+    // Trim back the length of Language used until it is empty
+    //
+    while (LanguageLength > 0) {
+      //
+      // Loop through all language codes in SupportedLanguages
+      //
+      for (Supported = SupportedLanguages; *Supported != '\0'; Supported += CompareLength) {
+        //
+        // In RFC 4646 mode, then Loop through all language codes in SupportedLanguages
+        //
+        if (!Iso639Language) {
+          //
+          // Skip ';' characters in Supported
+          //
+          for (; *Supported != '\0' && *Supported == ';'; Supported++);
+          //
+          // Determine the length of the next language code in Supported
+          //
+          for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++);
+          //
+          // If Language is longer than the Supported, then skip to the next language
+          //
+          if (LanguageLength > CompareLength) {
+            continue;
+          }
+        }
+        //
+        // See if the first LanguageLength characters in Supported match Language
+        //
+        if (strncmpa (Supported, Language, LanguageLength) == 0) {
+          VA_END (Args);
+          //
+          // Allocate, copy, and return the best matching language code from SupportedLanguages
+          //
+          BestLanguage = AllocateZeroPool (CompareLength + 1);
+          if (BestLanguage == NULL) {
+            return NULL;
+          }
+          CopyMem (BestLanguage, Supported, CompareLength);
+          return BestLanguage;
+        }
+      }
+
+      if (Iso639Language) {
+        //
+        // If ISO 639 mode, then each language can only be tested once
+        //
+        LanguageLength = 0;
+      } else {
+        //
+        // If RFC 4646 mode, then trim Language from the right to the next '-' character 
+        //
+        for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);
+      }
+    }
   }
+  VA_END (Args);
+
+  //
+  // No matches were found 
+  //
+  return NULL;
+}
+
 
-  *ComponentName  = NULL;
-  *ComponentName2 = NULL;
+BOOLEAN
+MatchLanguageFormat (
+  IN CHAR8        *Language,
+  IN BOOLEAN      Iso639Language
+  )
+/*++
+
+Routine Description:
+
+  This function detects whether the input language match current language format. 
+  If Iso639Language is TRUE, it detects whether the input Language is in ISO 639 format.
+  If Iso639Language is FALSE, it detects whether the input Language is in RFC 4646 format.
+
+Arguments:
 
+  Language             -          A pointer to a Null-terminated ASCII string that
+                                  contains a set of language codes.
+  Iso639Language       -          If TRUE, it detects whether the input Language is in ISO 639 format.
+                                  If FALSE, it detects whether the input Language is in RFC 4646 format.
+
+Returns:
+
+  TRUE                 -         The input language format matches the format specified by Iso639Language.
+  FALSE                -         The input language format does not match the format specified by Iso639Language.
+
+--*/
+{
+  UINTN           Length;
+  UINTN           MajorLength;
+
+  Length = strlena (Language);
+
+  MajorLength = 0;
+  while (Language[MajorLength] >= 'a' && Language[MajorLength] <= 'z') {
+    MajorLength++;
+  }
+
+  if (Iso639Language) {
+    //
+    // For ISO 639 language, it must be a 3-character string.
+    //
+    if ((Length == 3) && (MajorLength == 3)) {
+      return TRUE;
+    }
+    return FALSE;
+  } else {
+    //
+    // For RFC 4646 language, we check for the following 3 characteristics,
+    // this is not a complete check, but should be effective since GetBestLanguage()
+    // will ensure the best RFC 4646 language is matched from the supported languages.
+    //
+    if (Length == 0) {
+      return FALSE;
+    }
+    if (MajorLength > 3) {
+      return FALSE;
+    }
+    if ((MajorLength == 1) && (Language[1] != '-')) {
+      return FALSE;
+    }
+
+    return TRUE;
+  }
+}
+
+
+CHAR8 *
+LibSelectBestLanguage (
+  IN CHAR8        *SupportedLanguages,
+  IN BOOLEAN      Iso639Language,
+  IN CHAR8        *Language
+  )
+/*++
+
+Routine Description:
+
+  Select the best matching language according to shell policy for best user experience. 
+  
+  This function supports both ISO 639-2 and RFC 4646 language codes, but language 
+  code types may not be mixed in a single call to this function. Normally, parameter
+  Language is the ASCII string language from shell command line option.
+  If Language is not NULL, it is used to match the SupportedLanguages.
+  If Language is NULL, we will use language variable and system default language
+  to match the SupportedLanguages to ensure of best user experience.
+
+Arguments:
+
+  SupportedLanguages   -          A pointer to a Null-terminated ASCII string that
+                                  contains a set of language codes in the format 
+                                  specified by Iso639Language.
+  Iso639Language       -          If TRUE, then all language codes are assumed to be
+                                  in ISO 639-2 format.  If FALSE, then all language
+                                  codes are assumed to be in RFC 4646 language format.
+  Language             -          An ASCII string that represents the language command line option.
+
+Returns:
+  NULL                 -          The best matching language could not be found in SupportedLanguages.
+  NULL                 -          There are not enough resources available to return the best matching 
+                                  language.
+  Other                -          A pointer to a Null-terminated ASCII string that is the best matching 
+                                  language in SupportedLanguages.
+
+--*/
+{
+  CHAR8           *LanguageVariable;
+  CHAR8           *BestLanguage;
+
+  if (Language != NULL) {
+    //
+    // If a language is specified, we will use this language only and ignore the
+    // language variable and the system default language.
+    //
+    if (MatchLanguageFormat (Language, Iso639Language)) {
+      BestLanguage = GetBestLanguage(
+                       SupportedLanguages,
+                       Iso639Language,
+                       Language,
+                       NULL
+                       );
+    } else {
+      return NULL;
+    }
+  } else {
+    LanguageVariable = LibGetVariableLang (Iso639Language);
+    BestLanguage = GetBestLanguage(
+                     SupportedLanguages,
+                     Iso639Language,
+                     (LanguageVariable != NULL) ? LanguageVariable : "",
+                     Iso639Language ? DefaultLang : DefaultPlatformLang,
+                     NULL
+                     );
+    if (LanguageVariable != NULL) {
+      FreePool (LanguageVariable);
+    }
+  }
+
+  return BestLanguage;
+}
+
+
+EFI_STATUS
+GetComponentNameWorker (
+  IN  EFI_GUID                    *ProtocolGuid,
+  IN  EFI_HANDLE                  DriverBindingHandle,
+  IN  CHAR8                       *Language,
+  OUT EFI_COMPONENT_NAME_PROTOCOL **ComponentName,
+  OUT CHAR8                       **SupportedLanguage
+  )
+/*++
+
+Routine Description:
+
+  This is an internal worker function to get the Component Name (2) protocol interface
+  and the language it supports.
+
+Arguments:
+
+  ProtocolGuid         -          A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
+  DriverBindingHandle  -          The handle on which the Component Name (2) protocol instance is retrieved.
+  Language             -          An ASCII string that represents the language command line option.
+  ComponentName        -          A pointer to the Component Name (2) protocol interface.
+  SupportedLanguage    -          The best suitable language that matches the SupportedLangues interface for the 
+                                  located Component Name (2) instance.
+
+Returns:
+
+  EFI_SUCCESS          -          The Component Name (2) protocol instance is successfully located and we find
+                                  the best matching language it support.
+  EFI_UNSUPPORTED      -          The input Language is not supported by the Component Name (2) protocol.
+  Other                -          Some error occurs when locating Component Name (2) protocol instance or finding
+                                  the supported language.
+
+--*/
+{
+  EFI_STATUS                      Status;
+
+  //
+  // Locate Component Name (2) protocol on the driver binging handle.
+  //
   Status = BS->OpenProtocol (
                  DriverBindingHandle,
-                 &gEfiComponentName2ProtocolGuid,
-                 (VOID **) ComponentName2,
+                 ProtocolGuid,
+                 (VOID **) ComponentName,
                  NULL,
                  NULL,
                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
                  );
-  if (EFI_ERROR(Status)) {
-    Status = BS->OpenProtocol (
-                   DriverBindingHandle,
-                   &gEfiComponentNameProtocolGuid,
-                   (VOID **) ComponentName,
-                   NULL,
-                   NULL,
-                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
-                   );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Apply shell policy to select the best language.
+  //
+  *SupportedLanguage = LibSelectBestLanguage (
+                         (*ComponentName)->SupportedLanguages,
+                         (BOOLEAN) (ProtocolGuid == &gEfiComponentNameProtocolGuid),
+                         Language
+                         );
+  if (*SupportedLanguage == NULL) {
+    Status = EFI_UNSUPPORTED;
   }
 
   return Status;
 }
 
-CHAR8 *
-LibConvertSupportedLanguage (
-  IN CHAR8                           *SupportedLanguages,
-  IN CHAR8                           *LangCode
+
+EFI_STATUS
+GetDriverNameWorker (
+  IN  EFI_GUID    *ProtocolGuid,
+  IN  EFI_HANDLE  DriverBindingHandle,
+  IN  CHAR8       *Language,
+  OUT CHAR16      **DriverName
   )
 /*++
 
-  Routine Description:
+Routine Description:
 
-    Do some convertion for the ComponentName2 supported language. It do 
-    the convertion just for english language code currently.
+  This is an internal worker function to get driver name from Component Name (2) protocol interface.
 
-  Arguments:
+Arguments:
 
-    SupportedLanguages    - Pointer to SupportedLanguages of ComponentName2/ComponentName protocl.
-    LangCode              - The language code in variable "PlatformLang" or "Lang".
+  ProtocolGuid         -          A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
+  DriverBindingHandle  -          The handle on which the Component Name (2) protocol instance is retrieved.
+  Language             -          An ASCII string that represents the language command line option.
+  DriverName           -          A pointer to the Unicode string to return. This Unicode string is the name
+                                  of the driver specified by This.
 
-  Returns:
+Returns:
 
-    Return the duplication of Language if it is not english otherwise return 
-    the supported english language code.
+  EFI_SUCCESS          -          The driver name is successfully retrieved from Component Name (2) protocol
+                                  interface.
+  Other                -          The driver name cannot be retrieved from Component Name (2) protocol
+                                  interface.
 
 --*/
 {
-  CHAR8                              *Languages;
-  CHAR8                              *Lang;
-  UINTN                              Index;
-
-  Lang  = NULL;
-  Languages = NULL;
+  EFI_STATUS                     Status;
+  CHAR8                          *BestLanguage;
+  EFI_COMPONENT_NAME_PROTOCOL    *ComponentName;
 
   //
-  // treat all the english language code (en-xx or eng) equally
+  // Retrieve Component Name (2) protocol instance on the driver binding handle and 
+  // find the best language this instance supports. 
   //
-  if ((strncmpa(LangCode, "en-", 3) == 0) || (strcmpa(LangCode, "eng") == 0)) {
-    Languages = strstra(SupportedLanguages, "en-");
-    if (Languages == NULL) {
-      Languages = strstra(SupportedLanguages, "eng");
-    }
+  Status = GetComponentNameWorker (
+             ProtocolGuid,
+             DriverBindingHandle,
+             Language,
+             &ComponentName,
+             &BestLanguage
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
   }
+  //
+  // Get the driver name from Component Name (2) protocol instance on the driver binging handle.
+  //
+  Status = ComponentName->GetDriverName (
+                            ComponentName,
+                            BestLanguage,
+                            DriverName
+                            );
+  FreePool (BestLanguage);
+  return Status;
+}
+
+
+EFI_STATUS
+LibGetDriverName (
+  IN  EFI_HANDLE  DriverBindingHandle,
+  IN  CHAR8       *Language,
+  OUT CHAR16      **DriverName
+  )
+/*++
+
+Routine Description:
+
+  This function gets driver name from Component Name 2 protocol interface and Component Name protocol interface
+  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the driver name.
+  If the attempt fails, it then gets the driver name from EFI 1.1 Component Name protocol for backward
+  compatibility support. 
+
+Arguments:
+
+  DriverBindingHandle  -          The handle on which the Component Name (2) protocol instance is retrieved.
+  Language             -          An ASCII string that represents the language command line option.
+  DriverName           -          A pointer to the Unicode string to return. This Unicode string is the name
+                                  of the driver specified by This.
+
+Returns:
+
+  EFI_SUCCESS          -          The driver name is successfully retrieved from Component Name (2) protocol
+                                  interface.
+  Other                -          The driver name cannot be retrieved from Component Name (2) protocol
+                                  interface.
+
+--*/
+{
+  EFI_STATUS      Status;
 
   //
-  // Return NULL if it is not english
+  // Get driver name from UEFI 2.0 Component Name 2 protocol interface.
   //
-  if (Languages == NULL) {
-    Languages = LangCode;
+  Status = GetDriverNameWorker (&gEfiComponentName2ProtocolGuid, DriverBindingHandle, Language, DriverName);
+  if (EFI_ERROR (Status)) {
+    //
+    // If it fails to get the driver name from Component Name protocol interface, we should fall back on
+    // EFI 1.1 Component Name protocol interface.
+    //
+    Status = GetDriverNameWorker (&gEfiComponentNameProtocolGuid, DriverBindingHandle, Language, DriverName);
   }
 
+  return Status;
+}
+
+EFI_STATUS
+GetControllerNameWorker (
+  IN  EFI_GUID    *ProtocolGuid,
+  IN  EFI_HANDLE  DriverBindingHandle,
+  IN  EFI_HANDLE  ControllerHandle,
+  IN  EFI_HANDLE  ChildHandle,
+  IN  CHAR8       *Language,
+  OUT CHAR16      **ControllerName
+  )
+/*++
+
+Routine Description:
+
+  This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
+  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name.
+  If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
+  compatibility support. 
+
+Arguments:
+
+  ProtocolGuid         -          A pointer to an EFI_GUID. It points to Component Name (2) protocol GUID.
+  DriverBindingHandle  -          The handle on which the Component Name (2) protocol instance is retrieved.
+  ControllerHandle     -          The handle of a controller that the driver specified by This is managing.
+                                  This handle specifies the controller whose name is to be returned.
+  ChildHandle          -          The handle of the child controller to retrieve the name of. This is an
+                                  optional parameter that may be NULL. It will be NULL for device drivers.
+                                  It will also be NULL for bus drivers that attempt to retrieve the name
+                                  of the bus controller. It will not be NULL for a bus driver that attempts
+                                  to retrieve the name of a child controller.
+  Language             -          An ASCII string that represents the language command line option.
+  ControllerName       -          A pointer to the Unicode string to return. This Unicode string
+                                  is the name of the controller specified by ControllerHandle and ChildHandle.
+
+Returns:
+
+  EFI_SUCCESS          -          The controller name is successfully retrieved from Component Name (2) protocol
+                                  interface.
+  Other                -          The controller name cannot be retrieved from Component Name (2) protocol.
+
+--*/
+{
+  EFI_STATUS                     Status;
+  CHAR8                          *BestLanguage;
+  EFI_COMPONENT_NAME_PROTOCOL    *ComponentName;
+
   //
-  // duplicate the returned language code.
+  // Retrieve Component Name (2) protocol instance on the driver binding handle and 
+  // find the best language this instance supports. 
   //
-  if (strstra(SupportedLanguages, "-") != NULL) {
-    Lang = AllocateZeroPool(32);
-    for(Index = 0; (Index < 31) && (Languages[Index] != '\0') && (Languages[Index] != ';'); Index++) {
-      Lang[Index] = Languages[Index];
-    }
-    Lang[Index] = '\0';
-  } else {
-    Lang = AllocateZeroPool(4);
-    for(Index = 0; (Index < 3) && (Languages[Index] != '\0'); Index++) {
-      Lang[Index] = Languages[Index];
-    }
-    Lang[Index] = '\0';
+  Status = GetComponentNameWorker (
+             ProtocolGuid,
+             DriverBindingHandle,
+             Language,
+             &ComponentName,
+             &BestLanguage
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
   }
-  return Lang;
+
+  //
+  // Get the controller name from Component Name (2) protocol instance on the driver binging handle.
+  //
+  Status = ComponentName->GetControllerName (
+                            ComponentName,
+                            ControllerHandle,
+                            ChildHandle,
+                            BestLanguage,
+                            ControllerName
+                            );
+  FreePool (BestLanguage);
+
+  return Status;
 }
+
+EFI_STATUS
+LibGetControllerName (
+  IN  EFI_HANDLE  DriverBindingHandle,
+  IN  EFI_HANDLE  ControllerHandle,
+  IN  EFI_HANDLE  ChildHandle,
+  IN  CHAR8       *Language,
+  OUT CHAR16      **ControllerName
+  )
+/*++
+
+Routine Description:
+
+  This function gets controller name from Component Name 2 protocol interface and Component Name protocol interface
+  in turn. It first tries UEFI 2.0 Component Name 2 protocol interface and try to get the controller name. 
+  If the attempt fails, it then gets the controller name from EFI 1.1 Component Name protocol for backward
+  compatibility support. 
+
+Arguments:
+
+  DriverBindingHandle  -          The handle on which the Component Name (2) protocol instance is retrieved.
+  ControllerHandle     -          The handle of a controller that the driver specified by This is managing.
+                                  This handle specifies the controller whose name is to be returned.
+  ChildHandle          -          The handle of the child controller to retrieve the name of. This is an
+                                  optional parameter that may be NULL. It will be NULL for device drivers.
+                                  It will also be NULL for bus drivers that attempt to retrieve the name
+                                  of the bus controller. It will not be NULL for a bus driver that attempts
+                                  to retrieve the name of a child controller.
+  Language             -          An ASCII string that represents the language command line option.
+  ControllerName       -          A pointer to the Unicode string to return. This Unicode string
+                                  is the name of the controller specified by ControllerHandle and ChildHandle.
+
+Returns:
+
+  EFI_SUCCESS          -          The controller name is successfully retrieved from Component Name (2) protocol
+                                  interface.
+  Other                -          The controller name cannot be retrieved from Component Name (2) protocol.
+
+--*/
+{
+  EFI_STATUS      Status;
+
+  //
+  // Get controller name from UEFI 2.0 Component Name 2 protocol interface.
+  //
+  Status = GetControllerNameWorker (
+             &gEfiComponentName2ProtocolGuid,
+             DriverBindingHandle,
+             ControllerHandle,
+             ChildHandle,
+             Language,
+             ControllerName
+             );
+  if (EFI_ERROR (Status)) {
+    //
+    // If it fails to get the controller name from Component Name protocol interface, we should fall back on
+    // EFI 1.1 Component Name protocol interface.
+    //
+    Status = GetControllerNameWorker (
+               &gEfiComponentNameProtocolGuid,
+               DriverBindingHandle,
+               ControllerHandle,
+               ChildHandle,
+               Language,
+               ControllerName
+               );
+  }
+
+  return Status;
+}
\ No newline at end of file
index 25082c5..59ed4b4 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2008, Intel Corporation                                                  
+Copyright (c) 2005 - 2009, Intel Corporation                                                  
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -105,7 +105,7 @@ LibMemoryMap (
 
 VOID *
 LibGetVariableLang (
-  VOID
+  IN BOOLEAN                        Iso639Language
   );
 
 VOID                              *
index 56a8bee..af92979 100644 (file)
Binary files a/devices/DevicesStrings.uni and b/devices/DevicesStrings.uni differ
index 7d5d4ba..bcc8beb 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -112,8 +112,6 @@ Returns:
   EFI_STATUS              Status;
   EFI_STATUS              ConfigurationStatus;
   EFI_STATUS              DiagnosticsStatus;
-  UINTN                   StringIndex;
-  UINTN                   StringLength;
   UINTN                   Index;
   CHAR8                   *Language;
   UINTN                   DeviceHandleCount;
@@ -161,15 +159,6 @@ Returns:
   // Setup Handle and Protocol Globals
   //
   ShellInitProtocolInfoEnumerator ();
-  Language = LibGetVariableLang ();
-
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
 
   if (IS_OLD_SHELL) {
     Status = DevicesMainOld (ImageHandle, SystemTable);
@@ -223,17 +212,7 @@ Returns:
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item != NULL) {
-    if (Language != NULL) {
-      FreePool (Language);
-    }
-
-    StringLength = StrLen (Item->VarStr);
-    Language = AllocatePool (StringLength + 1);
-    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-      Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
-    }
-
-    Language[StringIndex] = 0;
+    Language = LibGetCommandLineLanguage (Item->VarStr);
   }
   //
   // Display all device handles
@@ -437,8 +416,6 @@ Returns:
   EFI_STATUS  ConfigurationStatus;
   EFI_STATUS  DiagnosticsStatus;
   CHAR16      *Ptr;
-  UINTN       StringIndex;
-  UINTN       StringLength;
   UINTN       Index;
   CHAR8       *Language;
   UINTN       DeviceHandleCount;
@@ -453,34 +430,15 @@ Returns:
   BOOLEAN     PrtHelp;
 
   PrtHelp   = FALSE;
-  Language  = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
 
+  Language  = NULL;
   for (Index = 1; Index < SI->Argc; Index += 1) {
     Ptr = SI->Argv[Index];
     if (*Ptr == '-') {
       switch (Ptr[1]) {
       case 'l':
       case 'L':
-        if (*(Ptr + 2) != 0) {
-          if (Language != NULL) {
-            FreePool (Language);
-          }
-
-          StringLength = StrLen (Ptr + 2);
-          Language = AllocatePool (StringLength + 1);
-          for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-            Language[StringIndex] = (CHAR8) Ptr[StringIndex + 2];
-          }
-
-          Language[StringIndex] = 0;
-        }
+        Language = LibGetCommandLineLanguage (Ptr + 2);
         break;
 
       case 'b':
@@ -640,6 +598,8 @@ Returns:
   FreePool (DeviceHandleBuffer);
 
 Done:
-  FreePool (Language);
+  if (Language != NULL) {
+    FreePool (Language);
+  }
   return Status;
 }
index 30f238b..db14239 100644 (file)
Binary files a/drivers/DriversStrings.uni and b/drivers/DriversStrings.uni differ
index 157dd18..0c6cfc0 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -87,14 +87,6 @@ ShellDeviceTree (
   IN CHAR8            *Language
   );
 
-EFI_STATUS
-DriversSyntaxOld (
-  IN  EFI_HANDLE         ImageHandle,
-  IN  EFI_SYSTEM_TABLE   *SystemTable,
-  OUT CHAR8              **Language,
-  OUT BOOLEAN            *IsHelp
-  );
-
 EFI_STATUS
 EFIAPI
 DriversMain (
@@ -126,7 +118,6 @@ Returns:
   EFI_STATUS                   Status;
   EFI_STATUS                   DiagnosticsStatus;
   EFI_STATUS                   ConfigurationStatus;
-  UINTN                        StringLength;
   UINTN                        StringIndex;
   UINTN                        Index;
   CHAR8                        *Language;
@@ -135,9 +126,6 @@ Returns:
   UINTN                        HandleIndex;
   EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;
   EFI_LOADED_IMAGE_PROTOCOL    *LoadedImage;
-  EFI_COMPONENT_NAME_PROTOCOL  *ComponentName;
-  EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
-  CHAR8                        *SupportedLanguage;
   CHAR16                       *DriverName;
   CHAR16                       FormattedDriverName[40];
   UINTN                        NumberOfChildren;
@@ -150,6 +138,7 @@ Returns:
   CHAR16                       *Useful;
   SHELL_ARG_LIST               *Item;
   SHELL_VAR_CHECK_PACKAGE      ChkPck;
+  CHAR16                       *Ptr;
 
   Language                = NULL;
   DriverImageHandleCount  = 0;
@@ -181,14 +170,34 @@ Returns:
   }
 
   if (IS_OLD_SHELL) {
-    Status = DriversSyntaxOld (ImageHandle, SystemTable, &Language, &IsHelp);
-    if (EFI_ERROR (Status)) {
-      goto Done;
-    }
-
-    if (IsHelp) {
-      PrintToken (STRING_TOKEN (STR_NO_HELP), HiiHandle);
-      goto Done;
+    for (Index = 1; Index < SI->Argc; Index += 1) {
+      Ptr = SI->Argv[Index];
+      if (*Ptr == '-') {
+        switch (Ptr[1]) {
+        case 'l':
+        case 'L':
+          Language = LibGetCommandLineLanguage (Ptr + 2);
+          break;
+
+        case 'b':
+        case 'B':
+          EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
+          break;
+
+        case '?':
+          PrintToken (STRING_TOKEN (STR_NO_HELP), HiiHandle);
+          goto Done;
+
+        default:
+          PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"drivers", Ptr);
+          Status = EFI_INVALID_PARAMETER;
+          goto Done;
+        }
+      } else {
+        PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"drivers");
+        Status = EFI_INVALID_PARAMETER;
+        goto Done;
+      }
     }
   } else {
     RetCode = LibCheckVariables (SI, DriversCheckList, &ChkPck, &Useful);
@@ -241,30 +250,13 @@ Returns:
       goto Done;
     }
 
-    Language = LibGetVariableLang ();
-    if (Language == NULL) {
-      Language = (CHAR8 *)AllocateZeroPool(strlena(LanguageCodeEnglish) + 1);
-      if (Language == NULL) {
-        return EFI_OUT_OF_RESOURCES;
-      }
-      strcpya(Language, LanguageCodeEnglish);
-    }
-
     Item = LibCheckVarGetFlag (&ChkPck, L"-l");
     if (Item) {
-      if (Language != NULL) {
-        FreePool (Language);
-      }
-
-      StringLength = StrLen (Item->VarStr);
-      Language    = AllocatePool (StringLength + 1);
-      for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-        Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
-      }
-      Language[StringIndex] = 0;
+      Language = LibGetCommandLineLanguage (Item->VarStr);
     }
   }
 
+
   ShellInitProtocolInfoEnumerator ();
   //
   // Display all driver handles
@@ -314,14 +306,6 @@ Returns:
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
 
-    ComponentName  = NULL;
-    ComponentName2 = NULL;
-    Status = LibGetComponentNameProtocol (
-               DriverImageHandleBuffer[Index],
-               &ComponentName,
-               &ComponentName2
-               );
-
     DiagnosticsStatus = BS->OpenProtocol (
                               DriverImageHandleBuffer[Index],
                               &gEfiDriverDiagnostics2ProtocolGuid,
@@ -419,32 +403,7 @@ Returns:
       PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_ONE_VAR_D), HiiHandle, NumberOfChildren);
     }
 
-    Status     = EFI_SUCCESS;
-    DriverName = L"<UNKNOWN>";
-    SupportedLanguage = NULL;
-    if (ComponentName != NULL) {
-      if (ComponentName->GetDriverName != NULL) {
-        SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
-        Status = ComponentName->GetDriverName (
-                                  ComponentName,
-                                  SupportedLanguage,
-                                  &DriverName
-                                  );
-      }
-    } else if (ComponentName2 != NULL) {
-      if (ComponentName2->GetDriverName != NULL) {
-        SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
-        Status = ComponentName2->GetDriverName (
-                                   ComponentName2,
-                                   SupportedLanguage,
-                                   &DriverName
-                                   );
-      }
-    }
-    if (SupportedLanguage != NULL) {
-      FreePool (SupportedLanguage);
-    }
-
+    Status = LibGetDriverName(DriverImageHandleBuffer[Index], Language, &DriverName);
     if (EFI_ERROR (Status)) {
       DriverName = L"<UNKNOWN>";
     }
@@ -520,74 +479,4 @@ Returns:
 {
   return LibCmdGetStringByToken (STRING_ARRAY_NAME, &EfiDriversGuid, STRING_TOKEN (STR_DRIVERS_LINE_HELP), Str);
 }
-//
-// Compatible support
-//
-EFI_STATUS
-DriversSyntaxOld (
-  IN  EFI_HANDLE         ImageHandle,
-  IN  EFI_SYSTEM_TABLE   *SystemTable,
-  OUT CHAR8              **Language,
-  OUT BOOLEAN            *IsHelp
-  )
-{
-  EFI_STATUS  Status;
-  UINTN       Index;
-  UINTN       StringIndex;
-  UINTN       StringLength;
-  CHAR16      *Ptr;
-
-  *Language = LibGetVariableLang ();
-  if (*Language == NULL) {
-    *Language       = AllocatePool (4);
-    (*Language)[0]  = 'e';
-    (*Language)[1]  = 'n';
-    (*Language)[2]  = 'g';
-    (*Language)[3]  = 0;
-  }
-
-  for (Index = 1; Index < SI->Argc; Index += 1) {
-    Ptr = SI->Argv[Index];
-    if (*Ptr == '-') {
-      switch (Ptr[1]) {
-      case 'l':
-      case 'L':
-        if (*(Ptr + 2) != 0) {
-          if (*Language != NULL) {
-            FreePool (*Language);
-          }
-
-          StringLength = StrLen (Ptr + 2);
-          *Language = AllocatePool (StringLength + 1);
-          for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-            (*Language)[StringIndex] = (CHAR8) Ptr[StringIndex + 2];
-          }
-          (*Language)[StringIndex] = 0;
-        }
-        break;
-
-      case 'b':
-      case 'B':
-        EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
-        break;
-
-      case '?':
-        *IsHelp = TRUE;
-        break;
-
-      default:
-        PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"drivers", Ptr);
-        Status = EFI_INVALID_PARAMETER;
-        goto Done;
-      }
-    } else {
-      PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"drivers");
-      Status = EFI_INVALID_PARAMETER;
-      goto Done;
-    }
-  }
 
-  Status = EFI_SUCCESS;
-Done:
-  return Status;
-}
index 07121dd..c0901ea 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -135,11 +135,9 @@ Returns:
   EFI_HANDLE                                DriverImageHandle;
   EFI_HANDLE                                DeviceHandle;
   EFI_HANDLE                                ChildHandle;
-  UINTN                                     StringIndex;
-  UINTN                                     StringLength;
   UINTN                                     Index;
   CHAR8                                     *Language;
-  CHAR8                                     *SupportedLanguages;
+  CHAR8                                     *BestLanguage;
   UINTN                                     DriverImageHandleCount;
   EFI_HANDLE                                *DriverImageHandleBuffer;
   UINTN                                     HandleCount;
@@ -161,6 +159,7 @@ Returns:
   CHAR16                                    *Useful;
   SHELL_ARG_LIST                            *Item;
   SHELL_VAR_CHECK_PACKAGE                   ChkPck;
+  BOOLEAN                                   Iso639Language;
 
   Language                = NULL;
   DriverImageHandle       = NULL;
@@ -257,28 +256,9 @@ Returns:
   //
   // Setup Handle and Protocol Globals
   //
-  Language = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
-
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (Language != NULL) {
-      FreePool (Language);
-    }
-
-    StringLength = StrLen (Item->VarStr);
-    Language = AllocatePool (StringLength + 1);
-    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-      Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
-    }
-
-    Language[StringIndex] = 0;
+    Language = LibGetCommandLineLanguage (Item->VarStr);
   }
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-f");
@@ -415,6 +395,7 @@ Returns:
   // MARMAR:  We need to look at getting the component name exporters to support more than just LANGUAGE_CODE_ENGLISH
   //
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
+    Iso639Language = FALSE;
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
                   &gEfiDriverConfiguration2ProtocolGuid,
@@ -424,6 +405,7 @@ Returns:
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
     if (EFI_ERROR (Status)) {
+      Iso639Language = TRUE;
       Status = BS->OpenProtocol (
                     DriverImageHandleBuffer[Index],
                     &gEfiDriverConfigurationProtocolGuid,
@@ -442,21 +424,13 @@ Returns:
       continue;
     }
 
-    Status = EFI_NOT_FOUND;
-    if (strstra (DriverConfiguration->SupportedLanguages, Language) == NULL) {
-      SupportedLanguages = LibConvertSupportedLanguage (DriverConfiguration->SupportedLanguages, Language);
-      if (strcmpa (SupportedLanguages, Language) != 0) {
-        FreePool (Language);
-        Language = SupportedLanguages;
-        Status = EFI_SUCCESS;
-      } else {
-        FreePool (SupportedLanguages);
-      }
-    } else {
-      Status = EFI_SUCCESS;
-    }
-
-    if (EFI_ERROR (Status)) {
+    
+    BestLanguage = LibSelectBestLanguage (
+                          DriverConfiguration->SupportedLanguages,
+                          Iso639Language,
+                          Language
+                          );
+    if (BestLanguage == NULL) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_HANDLE_NOT_SUPPORT_LANG),
         HiiHandle,
@@ -486,7 +460,7 @@ Returns:
                                       DriverConfiguration,
                                       NULL,
                                       NULL,
-                                      Language,
+                                      BestLanguage,
                                       &ActionRequired
                                       );
       ST->ConOut->ClearScreen (ST->ConOut);
@@ -579,7 +553,7 @@ Returns:
                                           DriverConfiguration,
                                           HandleBuffer[HandleIndex],
                                           NULL,
-                                          Language,
+                                          BestLanguage,
                                           &ActionRequired
                                           );
           ST->ConOut->ClearScreen (ST->ConOut);
@@ -684,7 +658,7 @@ Returns:
                                           DriverConfiguration,
                                           HandleBuffer[HandleIndex],
                                           ChildHandleBuffer[ChildIndex],
-                                          Language,
+                                          BestLanguage,
                                           &ActionRequired
                                           );
           ST->ConOut->ClearScreen (ST->ConOut);
@@ -718,6 +692,7 @@ Returns:
       FreePool (ChildHandleType);
     }
 
+    FreePool (BestLanguage);
     FreePool (HandleBuffer);
     FreePool (HandleType);
   }
@@ -842,11 +817,9 @@ Returns:
   EFI_HANDLE                                DriverImageHandle;
   EFI_HANDLE                                DeviceHandle;
   EFI_HANDLE                                ChildHandle;
-  UINTN                                     StringIndex;
-  UINTN                                     StringLength;
   UINTN                                     Index;
   CHAR8                                     *Language;
-  CHAR8                                     *SupportedLanguages;
+  CHAR8                                     *BestLanguage;
   UINTN                                     DriverImageHandleCount;
   EFI_HANDLE                                *DriverImageHandleBuffer;
   UINTN                                     HandleCount;
@@ -865,6 +838,7 @@ Returns:
   BOOLEAN                                   SetOptions;
   BOOLEAN                                   AllChildren;
   BOOLEAN                                   GetHelp;
+  BOOLEAN                                   Iso639Language;
 
   //
   // Setup Handle and Protocol Globals
@@ -880,35 +854,15 @@ Returns:
   DriverImageHandleCount  = 0;
   DriverImageHandleBuffer = NULL;
   GetHelp                 = FALSE;
-
-  Language                = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
-
+  Language                = NULL;
+  
   for (Index = 1; Index < SI->Argc; Index += 1) {
     Ptr = SI->Argv[Index];
     if (*Ptr == '-') {
       switch (Ptr[1]) {
       case 'l':
       case 'L':
-        if (*(Ptr + 2) != 0) {
-          if (Language != NULL) {
-            FreePool (Language);
-          }
-
-          StringLength = StrLen (Ptr + 2);
-          Language = AllocatePool (StringLength + 1);
-          for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-            Language[StringIndex] = (CHAR8) Ptr[StringIndex + 2];
-          }
-
-          Language[StringIndex] = 0;
-        }
+        Language = LibGetCommandLineLanguage (Ptr + 2);
         break;
 
       case 'c':
@@ -1044,6 +998,7 @@ Returns:
   // MARMAR:  We need to look at getting the component name exporters to support more than just LANGUAGE_CODE_ENGLISH
   //
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
+    Iso639Language = FALSE;
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
                   &gEfiDriverConfiguration2ProtocolGuid,
@@ -1053,6 +1008,7 @@ Returns:
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
     if (EFI_ERROR (Status)) {
+      Iso639Language = TRUE;
       Status = BS->OpenProtocol (
                     DriverImageHandleBuffer[Index],
                     &gEfiDriverConfigurationProtocolGuid,
@@ -1071,21 +1027,8 @@ Returns:
       continue;
     }
 
-    Status = EFI_NOT_FOUND;
-    if (strstra (DriverConfiguration->SupportedLanguages, Language) == NULL) {
-      SupportedLanguages = LibConvertSupportedLanguage (DriverConfiguration->SupportedLanguages, Language);
-      if (strcmpa (SupportedLanguages, Language) != 0) {
-        FreePool (Language);
-        Language = SupportedLanguages;
-        Status = EFI_SUCCESS;
-      } else {
-        FreePool (SupportedLanguages);
-      }
-    } else {
-      Status = EFI_SUCCESS;
-    }
-
-    if (EFI_ERROR (Status)) {
+    BestLanguage = LibSelectBestLanguage (DriverConfiguration->SupportedLanguages, Iso639Language, Language);
+    if (BestLanguage == NULL) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_HANDLE_NOT_SUPPORT_LANG),
         HiiHandle,
@@ -1115,7 +1058,7 @@ Returns:
                                       DriverConfiguration,
                                       NULL,
                                       NULL,
-                                      Language,
+                                      BestLanguage,
                                       &ActionRequired
                                       );
       ST->ConOut->ClearScreen (ST->ConOut);
@@ -1208,7 +1151,7 @@ Returns:
                                           DriverConfiguration,
                                           HandleBuffer[HandleIndex],
                                           NULL,
-                                          Language,
+                                          BestLanguage,
                                           &ActionRequired
                                           );
           ST->ConOut->ClearScreen (ST->ConOut);
@@ -1313,7 +1256,7 @@ Returns:
                                           DriverConfiguration,
                                           HandleBuffer[HandleIndex],
                                           ChildHandleBuffer[ChildIndex],
-                                          Language,
+                                          BestLanguage,
                                           &ActionRequired
                                           );
           ST->ConOut->ClearScreen (ST->ConOut);
@@ -1347,6 +1290,7 @@ Returns:
       FreePool (ChildHandleType);
     }
 
+    FreePool (BestLanguage);
     FreePool (HandleBuffer);
     FreePool (HandleType);
   }
@@ -1355,7 +1299,9 @@ Done:
   if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
     FreePool (DriverImageHandleBuffer);
   }
-
-  FreePool (Language);
+  
+  if (Language != NULL) {
+    FreePool (Language);
+  }
   return EFI_SUCCESS;
 }
index a9e4b0e..4b50220 100644 (file)
Binary files a/drvcfg/drvcfgStrings.uni and b/drvcfg/drvcfgStrings.uni differ
index 3846266..3a9435c 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -152,11 +152,8 @@ Returns:
   EFI_HANDLE                      DriverImageHandle;
   EFI_HANDLE                      DeviceHandle;
   EFI_HANDLE                      ChildHandle;
-  UINTN                           StringIndex;
-  UINTN                           StringLength;
   UINTN                           Index;
   CHAR8                           *Language;
-  CHAR8                           *SupportedLanguages;
   EFI_DRIVER_DIAGNOSTIC_TYPE      DiagnosticType;
   EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
   UINTN                           DriverImageHandleCount;
@@ -176,6 +173,8 @@ Returns:
   CHAR16                          *Useful;
   SHELL_ARG_LIST                  *Item;
   SHELL_VAR_CHECK_PACKAGE         ChkPck;
+  BOOLEAN                         Iso639Language;
+  CHAR8                           *BestLanguage;
 
   Language                = NULL;
   DriverImageHandle       = NULL;
@@ -268,28 +267,9 @@ Returns:
   //
   // Setup Handle and Protocol Globals
   //
-  Language = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
-
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (Language != NULL) {
-      FreePool (Language);
-    }
-
-    StringLength = StrLen (Item->VarStr);
-    Language = AllocatePool (StringLength + 1);
-    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-      Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
-    }
-
-    Language[StringIndex] = 0;
+    Language = LibGetCommandLineLanguage (Item->VarStr);
   }
 
   if (LibCheckVarGetFlag (&ChkPck, L"-c")) {
@@ -414,6 +394,7 @@ Returns:
 
   Found = TRUE;
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
+    Iso639Language = FALSE;
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
                   &gEfiDriverDiagnostics2ProtocolGuid,
@@ -423,6 +404,7 @@ Returns:
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
     if (EFI_ERROR (Status)) {
+      Iso639Language = TRUE;
       Status = BS->OpenProtocol (
                     DriverImageHandleBuffer[Index],
                     &gEfiDriverDiagnosticsProtocolGuid,
@@ -452,21 +434,12 @@ Returns:
       ShellHandleToIndex (DriverImageHandleBuffer[Index])
       );
 
-    Status = EFI_NOT_FOUND;
-    if (strstra (DriverDiagnostics->SupportedLanguages, Language) == NULL) {
-      SupportedLanguages = LibConvertSupportedLanguage (DriverDiagnostics->SupportedLanguages, Language);
-      if (strcmpa (SupportedLanguages, Language) != 0) {
-        FreePool (Language);
-        Language = SupportedLanguages;
-        Status = EFI_SUCCESS;
-      } else {
-        FreePool (SupportedLanguages);
-      }
-    } else {
-      Status = EFI_SUCCESS;
-    }
-
-    if (EFI_ERROR (Status)) {
+    BestLanguage = LibSelectBestLanguage (
+                     DriverDiagnostics->SupportedLanguages,
+                     Iso639Language,
+                     Language
+                     );
+    if (BestLanguage == NULL) {
       PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DRVDIAG_SUPPORT_LANG), HiiHandle, Language);
       continue;
     }
@@ -516,7 +489,7 @@ Returns:
             HandleBuffer[HandleIndex],
             NULL,
             DiagnosticType,
-            Language
+            BestLanguage
             );
 
         } else {
@@ -572,7 +545,7 @@ Returns:
             HandleBuffer[HandleIndex],
             ChildHandleBuffer[ChildIndex],
             DiagnosticType,
-            Language
+            BestLanguage
             );
 
         } else {
@@ -584,6 +557,7 @@ Returns:
       FreePool (ChildHandleType);
     }
 
+    FreePool (BestLanguage);
     FreePool (HandleBuffer);
     FreePool (HandleType);
   }
@@ -710,11 +684,8 @@ Returns:
   EFI_HANDLE                      DriverImageHandle;
   EFI_HANDLE                      DeviceHandle;
   EFI_HANDLE                      ChildHandle;
-  UINTN                           StringIndex;
-  UINTN                           StringLength;
   UINTN                           Index;
   CHAR8                           *Language;
-  CHAR8                           *SupportedLanguages;
   EFI_DRIVER_DIAGNOSTIC_TYPE      DiagnosticType;
   EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
   UINTN                           DriverImageHandleCount;
@@ -730,6 +701,8 @@ Returns:
   EFI_HANDLE                      *ChildHandleBuffer;
   UINT32                          *ChildHandleType;
   BOOLEAN                         GetHelp;
+  BOOLEAN                         Iso639Language;
+  CHAR8                           *BestLanguage;
 
   //
   // Setup Handle and Protocol Globals
@@ -744,34 +717,15 @@ Returns:
   DriverImageHandleBuffer = NULL;
   GetHelp                 = FALSE;
 
-  Language                = LibGetVariableLang ();
-  if (Language == NULL) {
-    Language    = AllocatePool (4);
-    Language[0] = 'e';
-    Language[1] = 'n';
-    Language[2] = 'g';
-    Language[3] = 0;
-  }
 
+  Language = NULL;
   for (Index = 1; Index < SI->Argc; Index += 1) {
     Ptr = SI->Argv[Index];
     if (*Ptr == '-') {
       switch (Ptr[1]) {
       case 'l':
       case 'L':
-        if (*(Ptr + 2) != 0) {
-          if (Language != NULL) {
-            FreePool (Language);
-          }
-
-          StringLength = StrLen (Ptr + 2);
-          Language = AllocatePool (StringLength + 1);
-          for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
-            Language[StringIndex] = (CHAR8) Ptr[StringIndex + 2];
-          }
-
-          Language[StringIndex] = 0;
-        }
+        Language = LibGetCommandLineLanguage (Ptr + 2);
         break;
 
       case 'c':
@@ -881,6 +835,7 @@ Returns:
   }
 
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
+    Iso639Language = FALSE;
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
                   &gEfiDriverDiagnostics2ProtocolGuid,
@@ -890,6 +845,7 @@ Returns:
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
     if (EFI_ERROR (Status)) {
+      Iso639Language = TRUE;
       Status = BS->OpenProtocol (
                     DriverImageHandleBuffer[Index],
                     &gEfiDriverDiagnosticsProtocolGuid,
@@ -908,21 +864,8 @@ Returns:
       continue;
     }
 
-    Status = EFI_NOT_FOUND;
-    if (strstra (DriverDiagnostics->SupportedLanguages, Language) == NULL) {
-      SupportedLanguages = LibConvertSupportedLanguage (DriverDiagnostics->SupportedLanguages, Language);
-      if (strcmpa (SupportedLanguages, Language) != 0) {
-        FreePool (Language);
-        Language = SupportedLanguages;
-        Status = EFI_SUCCESS;
-      } else {
-        FreePool (SupportedLanguages);
-      }
-    } else {
-      Status = EFI_SUCCESS;
-    }
-
-    if (EFI_ERROR (Status)) {
+    BestLanguage = LibSelectBestLanguage (DriverDiagnostics->SupportedLanguages, Iso639Language, Language);
+    if (BestLanguage == NULL) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVDIAG_HANDLE_NOT_SUPPORT_LANG),
         HiiHandle,
@@ -971,7 +914,7 @@ Returns:
             HandleBuffer[HandleIndex],
             NULL,
             DiagnosticType,
-            Language
+            BestLanguage
             );
 
         } else {
@@ -1022,7 +965,7 @@ Returns:
             HandleBuffer[HandleIndex],
             ChildHandleBuffer[ChildIndex],
             DiagnosticType,
-            Language
+            BestLanguage
             );
 
         } else {
@@ -1034,6 +977,7 @@ Returns:
       FreePool (ChildHandleType);
     }
 
+    FreePool (BestLanguage);
     FreePool (HandleBuffer);
     FreePool (HandleType);
   }
@@ -1042,7 +986,9 @@ Done:
   if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
     FreePool (DriverImageHandleBuffer);
   }
-
-  FreePool (Language);
+  
+  if (Language != NULL) {
+    FreePool (Language);
+  }
   return EFI_SUCCESS;
 }
index 24184e8..8e47021 100644 (file)
Binary files a/drvdiag/drvdiagStrings.uni and b/drvdiag/drvdiagStrings.uni differ
index a50e572..b39a2f0 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -90,6 +90,7 @@ MainEditorInit (
   EFI_STATUS  Status;
   EFI_HANDLE  *HandleBuffer;
   UINTN       HandleCount;
+  UINTN       Index;
 
   //
   // basic initialization
@@ -117,38 +118,52 @@ MainEditorInit (
         );
 
   //
-  // Find mouse
+  // Find mouse in System Table ConsoleInHandle
   //
-  HandleBuffer = NULL;
-  Status = LibLocateHandle (
-            ByProtocol,
-            &gEfiPrimaryConsoleInDeviceGuid,
-            NULL,
-            &HandleCount,
-            &HandleBuffer
-            );
-
-  if (!EFI_ERROR (Status)) {
-    if (HandleCount > 0) {
-      Status = BS->HandleProtocol (
-                    HandleBuffer[0],
-                    &gEfiSimplePointerProtocolGuid,
-                    &MainEditor.MouseInterface
-                    );
-
-      if (EFI_ERROR (Status)) {
-        MainEditor.MouseInterface = NULL;
-      } else {
-        MainEditor.MouseAccumulatorX  = 0;
-        MainEditor.MouseAccumulatorY  = 0;
-        MainEditor.MouseSupported     = TRUE;
+  Status = BS->HandleProtocol (
+                In,
+                &gEfiSimplePointerProtocolGuid,
+                &MainEditor.MouseInterface
+                );
+  if (EFI_ERROR (Status)) {
+    //
+    // If there is no Simple Pointer Protocol on System Table
+    //
+    HandleBuffer = NULL;
+    MainEditor.MouseInterface = NULL;
+    Status = BS->LocateHandleBuffer (
+                  ByProtocol,
+                  &gEfiSimplePointerProtocolGuid,
+                  NULL,
+                  &HandleCount,
+                  &HandleBuffer
+                  );
+    if (!EFI_ERROR (Status) && HandleCount > 0) {
+      //
+      // Try to find the first available mouse device
+      //
+      for (Index = 0; Index < HandleCount; Index++) {
+        Status = BS->HandleProtocol (
+                      HandleBuffer[Index],
+                      &gEfiSimplePointerProtocolGuid,
+                      &MainEditor.MouseInterface
+                      );
+        if (!EFI_ERROR (Status)) {
+          break;
+        }
       }
     }
+    if (HandleBuffer != NULL) {
+      FreePool (HandleBuffer);
+    }
   }
 
-  if (HandleBuffer) {
-    FreePool (HandleBuffer);
+  if (!EFI_ERROR (Status) && MainEditor.MouseInterface != NULL) {
+    MainEditor.MouseAccumulatorX  = 0;
+    MainEditor.MouseAccumulatorY  = 0;
+    MainEditor.MouseSupported     = TRUE;
   }
+
   //
   // below will call the five components' init function
   //
index 17bdf08..f511020 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -102,6 +102,7 @@ Returns:
   EFI_STATUS  Status;
   EFI_HANDLE  *HandleBuffer;
   UINTN       HandleCount;
+  UINTN       Index;
 
   //
   // basic initialization
@@ -129,36 +130,53 @@ Returns:
         &(HMainEditor.ScreenSize.Row)
         );
 
-  HandleBuffer = NULL;
-  Status = LibLocateHandle (
-            ByProtocol,
-            &gEfiPrimaryConsoleInDeviceGuid,
-            NULL,
-            &HandleCount,
-            &HandleBuffer
-            );
-
-  if (!EFI_ERROR (Status)) {
-
-    if (HandleCount > 0) {
-      Status = BS->HandleProtocol (
-                    HandleBuffer[0],
-                    &gEfiSimplePointerProtocolGuid,
-                    &HMainEditor.MouseInterface
-                    );
-      if (EFI_ERROR (Status)) {
-        HMainEditor.MouseInterface = NULL;
-      } else {
-        HMainEditor.MouseAccumulatorX = 0;
-        HMainEditor.MouseAccumulatorY = 0;
-        HMainEditor.MouseSupported    = TRUE;
+  //
+  // Find mouse in System Table ConsoleInHandle
+  //
+  Status = BS->HandleProtocol (
+                In,
+                &gEfiSimplePointerProtocolGuid,
+                &HMainEditor.MouseInterface
+                );
+  if (EFI_ERROR (Status)) {
+    //
+    // If there is no Simple Pointer Protocol on System Table
+    //
+    HandleBuffer = NULL;
+    HMainEditor.MouseInterface = NULL;
+    Status = BS->LocateHandleBuffer (
+                  ByProtocol,
+                  &gEfiSimplePointerProtocolGuid,
+                  NULL,
+                  &HandleCount,
+                  &HandleBuffer
+                  );
+    if (!EFI_ERROR (Status) && HandleCount > 0) {
+      //
+      // Try to find the first available mouse device
+      //
+      for (Index = 0; Index < HandleCount; Index++) {
+        Status = BS->HandleProtocol (
+                      HandleBuffer[Index],
+                      &gEfiSimplePointerProtocolGuid,
+                      &HMainEditor.MouseInterface
+                      );
+        if (!EFI_ERROR (Status)) {
+          break;
+        }
       }
     }
+    if (HandleBuffer != NULL) {
+      FreePool (HandleBuffer);
+    }
   }
 
-  if (HandleBuffer != NULL) {
-    FreePool (HandleBuffer);
+  if (!EFI_ERROR (Status) && HMainEditor.MouseInterface != NULL) {
+    HMainEditor.MouseAccumulatorX  = 0;
+    HMainEditor.MouseAccumulatorY  = 0;
+    HMainEditor.MouseSupported     = TRUE;
   }
+
   //
   // below will call the five components' init function
   //
index 958977d..8fbd45d 100644 (file)
--- a/pci/pci.c
+++ b/pci/pci.c
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -1104,6 +1104,8 @@ Returns:
     if ((*Descriptors)->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
       *MinBus = (UINT16) (*Descriptors)->AddrRangeMin;
       *MaxBus = (UINT16) (*Descriptors)->AddrRangeMax;
+      (*Descriptors)++;
+      break;
     }
 
     (*Descriptors)++;
@@ -2333,12 +2335,7 @@ PciExplainCapabilityStruct (
   //
   // Go through the Capability list
   //
-  while (CapabilityPtr > 0x3F) {
-    //
-    // Mask it to DWORD alignment per PCI spec
-    //
-    CapabilityPtr &= 0xFC;
-
+  while ((CapabilityPtr >= 0x40) && ((CapabilityPtr & 0x03) == 0x00)) { 
     RegAddress = Address + CapabilityPtr;
     IoDev->Pci.Read (IoDev, EfiPciWidthUint16, RegAddress, 1, &CapabilityEntry);
 
index 640b358..d5ebb86 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -831,6 +831,16 @@ Returns:
     return Status;
   }
 
+  //
+  // Close proxy console before disconnect all devices.
+  //
+  SEnvCloseConsoleProxy (
+    ST->ConsoleInHandle,
+    &ST->ConIn,
+    ST->ConsoleOutHandle,
+    &ST->ConOut
+    );
+
   for (Index = 0; Index < AllHandleCount; Index++) {
     //
     // Check whether the handle is still in handle database
@@ -1004,7 +1014,6 @@ SEnvConnectDevicePath (
 VOID
 SEnvConnectConsole (
   CHAR16      *VariableName,
-  EFI_GUID    *PrimaryGuid,
   EFI_GUID    *ConsoleGuid,
   EFI_HANDLE  *ConsoleHandle,
   VOID        **ConsoleInterface
@@ -1018,27 +1027,36 @@ SEnvConnectConsole (
   EFI_HANDLE                *AllHandleBuffer;
   VOID                      *Interface;
 
-  *ConsoleHandle    = NULL;
-  *ConsoleInterface = NULL;
   ConsoleIndex      = 0;
+  AllHandleBuffer   = NULL;
 
   DevicePath        = LibGetVariable (VariableName, &gEfiGlobalVariableGuid);
-  if (DevicePath != NULL) {
-    SEnvConnectDevicePath (DevicePath);
-    FreePool (DevicePath);
+  if (DevicePath == NULL) {
+    //
+    // If no any device defined in EFI variable, do nothing
+    //
+    return;
   }
 
-  AllHandleBuffer = NULL;
-  Status = BS->LocateHandleBuffer (
-                ByProtocol,
-                PrimaryGuid,
-                NULL,
-                &AllHandleCount,
-                &AllHandleBuffer
-                );
-  if (!EFI_ERROR (Status) && AllHandleCount > 0) {
-    *ConsoleHandle = AllHandleBuffer[0];
-  } else if (*ConsoleHandle == NULL) {
+  //
+  // Connect all console devices
+  //
+  SEnvConnectDevicePath (DevicePath);
+  FreePool (DevicePath);
+
+  Status = EFI_NOT_FOUND;
+  //
+  // Check ConsoleHandle validation whatever it was updated or not.
+  //
+  if (*ConsoleHandle != NULL) {
+    Status = BS->HandleProtocol (
+                  *ConsoleHandle,
+                  ConsoleGuid,
+                  &Interface
+                  );
+  } 
+
+  if (EFI_ERROR (Status)) {
     AllHandleBuffer = NULL;
     Status = BS->LocateHandleBuffer (
                   ByProtocol,
@@ -1063,16 +1081,16 @@ SEnvConnectConsole (
                       &gEfiDevicePathProtocolGuid,
                       &Interface
                       );
-        if (EFI_ERROR (Status)) {
+        if (!EFI_ERROR (Status)) {
           ConsoleIndex = Index;
           break;
         }
       }
+      
+      *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
     }
   }
 
-  *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
-
   if (*ConsoleHandle != NULL) {
     BS->HandleProtocol (
           *ConsoleHandle,
@@ -1081,7 +1099,7 @@ SEnvConnectConsole (
           );
   }
 
-  if (AllHandleBuffer) {
+  if (AllHandleBuffer != NULL) {
     FreePool (AllHandleBuffer);
   }
 }
@@ -1189,8 +1207,7 @@ SEnvConnectAllConsoles (
   EFI_STATUS  Status;
 
   //
-  // Check current ConIn and ConOut to ensure it is the ConsoleProxy
-  // Otherwise, the Console should not be close
+  // Check current ConIn and ConOut to judge it is the ConsoleProxy
   //
   Status = SEnvCheckConsoleProxy (
             ST->ConsoleInHandle,
@@ -1203,23 +1220,21 @@ SEnvConnectAllConsoles (
   // Indicate the Console is replaced by redirection operation
   // It is not safe to connect Console here
   //
-  if (EFI_ERROR (Status)) {
-    return ;
+  if (!EFI_ERROR (Status)) {
+    //
+    // It is proxy console, to prevent the proxy console form being restored to original console,
+    // close it temporary before connect all console
+    //
+    SEnvCloseConsoleProxy (
+      ST->ConsoleInHandle,
+      &ST->ConIn,
+      ST->ConsoleOutHandle,
+      &ST->ConOut
+      );
   }
-  //
-  // To prevent the proxy console form being restored to original console,
-  // close it temporary before connect all console
-  //
-  SEnvCloseConsoleProxy (
-    ST->ConsoleInHandle,
-    &ST->ConIn,
-    ST->ConsoleOutHandle,
-    &ST->ConOut
-    );
 
   SEnvConnectConsole (
     VarErrorOut,
-    &gEfiPrimaryStandardErrorDeviceGuid,
     &gEfiSimpleTextOutProtocolGuid,
     &ST->StandardErrorHandle,
     (VOID **) &ST->StdErr
@@ -1227,7 +1242,6 @@ SEnvConnectAllConsoles (
 
   SEnvConnectConsole (
     VarConsoleOut,
-    &gEfiPrimaryConsoleOutDeviceGuid,
     &gEfiSimpleTextOutProtocolGuid,
     &ST->ConsoleOutHandle,
     (VOID **) &ST->ConOut
@@ -1235,7 +1249,6 @@ SEnvConnectAllConsoles (
 
   SEnvConnectConsole (
     VarConsoleIn,
-    &gEfiPrimaryConsoleInDeviceGuid,
     &gEfiSimpleTextInProtocolGuid,
     &ST->ConsoleInHandle,
     (VOID **) &ST->ConIn
index 226715b..b786406 100644 (file)
Binary files a/shellenv/ShellenvHelpStrings.uni and b/shellenv/ShellenvHelpStrings.uni differ
index f28eba1..3ebf2b4 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -507,7 +507,7 @@ DumpMappingItem (
       PrintToken (STRING_TOKEN (STR_SHELLENV_MAP_HANDLE_NOT_FOUND), HiiEnvHandle, SLen + 3);
     } else {
       PrintToken (STRING_TOKEN (STR_SHELLENV_MAP_HANDLE), HiiEnvHandle, SLen + 3, L"");
-      SEnvDHProt (FALSE, FALSE, 0, DeviceHandle, LanguageCodeEnglish);
+      SEnvDHProt (FALSE, FALSE, 0, DeviceHandle, NULL);
     }
 
     PrintToken (STRING_TOKEN (STR_SHELLENV_MAP_MEDIA_TYPE), HiiEnvHandle, SLen, L"", MediaName);
@@ -2585,7 +2585,7 @@ Returns:
       PrintToken (STRING_TOKEN (STR_SHELLENV_MAP_HANDLE_NOT_FOUND), HiiEnvHandle, SLen + 3);
     } else {
       PrintToken (STRING_TOKEN (STR_SHELLENV_MAP_HANDLE), HiiEnvHandle, SLen + 3, L"");
-      SEnvDHProt (FALSE, FALSE, 0, DeviceHandle, LanguageCodeEnglish);
+      SEnvDHProt (FALSE, FALSE, 0, DeviceHandle, NULL);
     }
     //
     // print current directory for this mapping
index 2d162d3..b1c4f00 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -1155,9 +1155,6 @@ GetDriverName (
   EFI_STATUS                    Status;
   EFI_DRIVER_BINDING_PROTOCOL   *DriverBinding;
   EFI_LOADED_IMAGE_PROTOCOL     *Image;
-  EFI_COMPONENT_NAME_PROTOCOL   *ComponentName;
-  EFI_COMPONENT_NAME2_PROTOCOL  *ComponentName2;
-  CHAR8                         *SupportedLanguage;
 
   *DriverName = NULL;
 
@@ -1186,35 +1183,7 @@ GetDriverName (
       *DriverName = LibDevicePathToStr (Image->FilePath);
     }
   } else {
-    Status = LibGetComponentNameProtocol (
-               DriverBindingHandle, 
-               &ComponentName,
-               &ComponentName2
-               );
-    if (!EFI_ERROR (Status)) {
-      //
-      // Make sure the interface has been implemented
-      //
-      SupportedLanguage = NULL;
-      if ((ComponentName != NULL) && (ComponentName->GetDriverName != NULL)) {
-        SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
-        Status = ComponentName->GetDriverName (
-                                  ComponentName,
-                                  SupportedLanguage,
-                                  DriverName
-                                  );
-      } else if ((ComponentName2 != NULL) && (ComponentName2->GetDriverName != NULL)) {
-        SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
-        Status = ComponentName2->GetDriverName (
-                                   ComponentName2,
-                                   SupportedLanguage,
-                                   DriverName
-                                   );
-      }
-      if (SupportedLanguage != NULL) {
-        FreePool (SupportedLanguage);
-      }
-    }
+    LibGetDriverName (DriverBindingHandle, Language, DriverName);
   }
 
   return EFI_SUCCESS;
@@ -1250,9 +1219,6 @@ SEnvGetDeviceName (
   EFI_HANDLE                  *ChildHandleBuffer;
   EFI_DEVICE_PATH_PROTOCOL    *DevicePath;
   CHAR16                      *ControllerName;
-  EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
-  EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
-  CHAR8                       *SupportedLanguage;
   UINTN                       Index;
   BOOLEAN                     First;
 
@@ -1330,46 +1296,16 @@ SEnvGetDeviceName (
       *DiagnosticsStatus = EFI_SUCCESS;
     }
 
-    Status = LibGetComponentNameProtocol (
-               DriverBindingHandleBuffer[HandleIndex], 
-               &ComponentName,
-               &ComponentName2
+    Status = LibGetControllerName (
+               DriverBindingHandleBuffer[HandleIndex],
+               DeviceHandle,
+               NULL,
+               Language,
+               &ControllerName
                );
     if (EFI_ERROR (Status)) {
       continue;
     }
-    //
-    // Make sure this interface has been implemented
-    //
-    SupportedLanguage = NULL;
-    if ((ComponentName != NULL) && (ComponentName->GetControllerName != NULL)) {
-      SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
-      Status = ComponentName->GetControllerName (
-                                ComponentName,
-                                DeviceHandle,
-                                NULL,
-                                SupportedLanguage,
-                                &ControllerName
-                                );
-    } else if ((ComponentName2 != NULL) && (ComponentName2->GetControllerName != NULL)) {
-      SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
-      Status = ComponentName2->GetControllerName (
-                                 ComponentName2,
-                                 DeviceHandle,
-                                 NULL,
-                                 SupportedLanguage,
-                                 &ControllerName
-                                 );
-    } else {
-      Status = EFI_UNSUPPORTED;
-    }
-    if (SupportedLanguage != NULL) {
-      FreePool (SupportedLanguage);
-    }
-
-    if (EFI_ERROR (Status)) {
-      continue;
-    }
 
     if (Display) {
       if (!First) {
@@ -1464,46 +1400,16 @@ SEnvGetDeviceName (
             *DiagnosticsStatus = EFI_SUCCESS;
           }
 
-          Status = LibGetComponentNameProtocol (
-                     ParentDriverBindingHandleBuffer[ParentDriverIndex], 
-                     &ComponentName,
-                     &ComponentName2
+          Status = LibGetControllerName (
+                     ParentDriverBindingHandleBuffer[ParentDriverIndex],
+                     ParentControllerHandleBuffer[HandleIndex],
+                     DeviceHandle,
+                     Language,
+                     &ControllerName
                      );
           if (EFI_ERROR (Status)) {
             continue;
           }
-          //
-          // Make sure this interface has been implemented
-          //
-          SupportedLanguage = NULL;
-          if ((ComponentName != NULL) && (ComponentName->GetControllerName != NULL)) {
-            SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
-            Status = ComponentName->GetControllerName (
-                                      ComponentName,
-                                      ParentControllerHandleBuffer[HandleIndex],
-                                      DeviceHandle,
-                                      SupportedLanguage,
-                                      &ControllerName
-                                      );
-          } else if ((ComponentName2 != NULL) && (ComponentName2->GetControllerName != NULL)) {
-            SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
-            Status = ComponentName2->GetControllerName (
-                                       ComponentName2,
-                                       ParentControllerHandleBuffer[HandleIndex],
-                                       DeviceHandle,
-                                       SupportedLanguage,
-                                       &ControllerName
-                                       );
-          } else {
-            Status = EFI_UNSUPPORTED;
-          }
-          if (SupportedLanguage != NULL) {
-            FreePool (SupportedLanguage);
-          }
-
-          if (EFI_ERROR (Status)) {
-            continue;
-          }
 
           if (Display) {
             if (!First) {
@@ -2177,7 +2083,6 @@ Returns:
   PROTOCOL_INFO           *Prot;
   BOOLEAN                 Verbose;
   BOOLEAN                 DriverModel;
-  UINTN                   StringIndex;
   CHAR8                   *Language;
   SHELL_VAR_CHECK_CODE    RetCode;
   CHAR16                  *Useful;
@@ -2191,11 +2096,11 @@ Returns:
 
   EnableOutputTabPause ();
 
+  Language    = NULL;
   Arg         = NULL;
   ArgVar      = 0;
   ByProtocol  = FALSE;
   Status      = EFI_SUCCESS;
-  Language    = LibGetVariableLang ();
   ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
 
   if (!EFI_PROPER_VERSION (1, 10)) {
@@ -2209,10 +2114,6 @@ Returns:
     goto Done;
   }
 
-  if (Language == NULL) {
-    Language = (CHAR8 *) AllocatePool(strlena(LanguageCodeEnglish) + 1);
-    strcpya (Language, LanguageCodeEnglish);
-  }
 
   RetCode = LibCheckVariables (SI, DHCheckList, &ChkPck, &Useful);
   if (VarCheckOk != RetCode) {
@@ -2281,16 +2182,10 @@ Returns:
     Status = EFI_INVALID_PARAMETER;
     goto Done;
   }
-
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (Language != NULL) {
-      FreePool(Language);
-    }
-    Language = (CHAR8 *) AllocateZeroPool(StrLen(Item->VarStr));
-    for (StringIndex = 0; Item->VarStr[StringIndex] != L'\0'; StringIndex++) {
-      Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
-    }
+    Language = LibGetCommandLineLanguage (Item->VarStr);
   }
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-d");
index 086e5e2..100f16b 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2008, Intel Corporation                                                         
+Copyright (c) 2005 - 2009, Intel Corporation                                                         
 All rights reserved. This program and the accompanying materials                          
 are licensed and made available under the terms and conditions of the BSD License         
 which accompanies this distribution. The full text of the license may be found at         
@@ -82,9 +82,6 @@ _UnloadGetDriverName (
   EFI_STATUS                   Status;
   EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;
   EFI_LOADED_IMAGE_PROTOCOL    *Image;
-  EFI_COMPONENT_NAME_PROTOCOL  *ComponentName;
-  EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
-  CHAR8                        *SupportedLanguage;
 
   *DriverName = NULL;
 
@@ -113,37 +110,7 @@ _UnloadGetDriverName (
       *DriverName = LibDevicePathToStr (Image->FilePath);
     }
   } else {
-    Status = LibGetComponentNameProtocol(
-               DriverBinding->ImageHandle, 
-               &ComponentName, 
-               &ComponentName2
-               );
-    if (EFI_ERROR(Status)) {
-      return EFI_SUCCESS;
-    }
-
-    //
-    // Make sure the interface has been implemented
-    //
-    SupportedLanguage = NULL;
-    if ((ComponentName != NULL) && (ComponentName->GetDriverName != NULL)) {
-      SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
-      Status = ComponentName->GetDriverName (
-                                 ComponentName,
-                                 SupportedLanguage,
-                                 DriverName
-                                 );
-    } else if ((ComponentName2 != NULL) && (ComponentName2->GetDriverName != NULL)) {
-      SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
-      Status = ComponentName2->GetDriverName (
-                                 ComponentName2,
-                                 SupportedLanguage,
-                                 DriverName
-                                 );
-    }
-    if (SupportedLanguage != NULL) {
-      FreePool (SupportedLanguage);
-    }
+    LibGetDriverName(DriverBindingHandle, Language, DriverName);
   }
 
   return EFI_SUCCESS;
@@ -896,7 +863,7 @@ Returns:
     Status = EFI_INVALID_PARAMETER;
   } else {
     TargetHandle = ShellHandleFromIndex (Index);
-    _DHProt (Verbose, FALSE, Index + 1, TargetHandle, LanguageCodeEnglish);
+    _DHProt (Verbose, FALSE, Index + 1, TargetHandle, NULL);
     //
     // Make sure it is an image handle to a protocol
     //