SHEL10
authorhfang <hfang@0aefa8ac-fc23-0410-b7a3-bf826d37e4c2>
Thu, 14 Aug 2008 06:02:46 +0000 (06:02 +0000)
committerhfang <hfang@0aefa8ac-fc23-0410-b7a3-bf826d37e4c2>
Thu, 14 Aug 2008 06:02:46 +0000 (06:02 +0000)
git-svn-id: https://efi-shell.tianocore.org/svn/efi-shell/trunk/Shell@30 0aefa8ac-fc23-0410-b7a3-bf826d37e4c2

52 files changed:
DeviceTree/devicetree.c
EDK_Snapshot.txt
IfConfig/IfConfig.c
Library/ConsistMapping.c
Library/DPath.c
Library/DPath.h
Library/EfiShellLib.h
Library/EfiShellLib.inf
Library/FileIO.c
Library/Handle.c
Library/HiiSupport.c [new file with mode: 0644]
Library/HiiSupport.h [new file with mode: 0644]
Library/IO.c
Library/Init.c
Library/Misc.c
Library/Misc.h
Ping/Ping.h
Shell.inf
ShellFull.inf
SmbiosView/LibSmbios.h
SmbiosView/PrintInfo.c
SmbiosView/PrintInfo.h
SmbiosView/QueryTable.c
SmbiosView/SmBiosViewStrings.uni
SmbiosView/smbiosview.c
devices/devices.c
dmpstore/dmpstore.c
drivers/drivers.c
drvcfg/drvcfg.c
drvdiag/drvdiag.c
edit/editor.h
edit/libMenuBar.c
edit/main.c
hexedit/heditor.h
hexedit/libMenuBar.c
hexedit/main.c
newshell/FakeHii.c
newshell/FakeHii.h
newshell/init.c
pci/PciStrings.uni
pci/pci.c
pci/pci.h
shellenv/ShellenvHelpStrings.uni
shellenv/ShellenvStrings.uni
shellenv/dprot.c
shellenv/init.c
shellenv/map.c
shellenv/protid.c
shellenv/shelle.h
shellenv/var.c
unload/unload.c
ver/Ver.inf

index b752899..0d7fc39 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -124,6 +124,7 @@ Returns:
   EFI_STATUS              Status;
   UINTN                   Index;
   UINTN                   StringIndex;
+  UINTN                   StringLength;
   UINTN                   HandleNumber;
   EFI_HANDLE              Handle;
   SHELL_VAR_CHECK_CODE    RetCode;
@@ -217,7 +218,7 @@ Returns:
     goto Done;
   }
 
-  Language = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -228,13 +229,13 @@ Returns:
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (StrLen (Item->VarStr) != 3) {
-      PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEVTREE_BAD_LANG), HiiHandle, L"devtree", Item->VarStr);
-      Status = EFI_INVALID_PARAMETER;
-      goto Done;
+    if (Language != NULL) {
+      FreePool (Language);
     }
 
-    for (StringIndex = 0; StringIndex < 3; StringIndex++) {
+    StringLength = StrLen (Item->VarStr);
+    Language = AllocatePool (StringLength + 1);
+    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
       Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
     }
 
@@ -555,11 +556,12 @@ Returns:
   EFI_STATUS  Status;
   UINTN       Index;
   UINTN       StringIndex;
+  UINTN       StringLength;
   BOOLEAN     PrtHelp;
 
   Status    = EFI_SUCCESS;
   PrtHelp   = FALSE;
-  Language  = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language  = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -580,7 +582,13 @@ Returns:
       case 'l':
       case 'L':
         if (*(Ptr + 2) != 0) {
-          for (StringIndex = 0; StringIndex < 3 && Ptr[StringIndex + 2] != 0; StringIndex++) {
+          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];
           }
 
index 7d0f44a..10de6e3 100644 (file)
@@ -1,5 +1,5 @@
 Notes:
-  This EFI Shell release package has been tested on the 2007-06-25's EDK which snapshot
-is Edk-Dev-Snapshot-20070625, User can get this version EDK from the following URL:
-  https://edk.tianocore.org/files/documents/16/390/Edk-Dev-Snapshot-20070625.zip
+  This EFI Shell release package has been tested on the 2008-06-23's EDK which snapshot
+is Edk-Dev-Snapshot-20080623, User can get this version EDK from the following URL:
+  https://edk.tianocore.org/files/documents/16/470/Edk-Dev-Snapshot-20080623.zip
   We don't guarantee this package can work correctly on the other EDK snapshot.
\ No newline at end of file
index b8120d4..3b0f6f5 100644 (file)
@@ -353,13 +353,14 @@ Returns:
 
 --*/
 {
-  EFI_IPv4_ADDRESS              IpAddr;
-  UINT32                        Index;
-  UINTN                         Byte;
-  CHAR16                        Number[8];
-  CHAR16                        *NumPtr;
+  EFI_IP_ADDRESS              IpAddr;
+  UINT32                      Index;
+  UINTN                       Byte;
+  CHAR16                      Number[8];
+  CHAR16                      *NumPtr;
+
+  IpAddr.Addr[0] = 0;
 
-  EFI_IP4_TO_U32 (IpAddr) = 0;
   if (!SHELL_IS_DIGIT (*String)) {
     return EFI_INVALID_PARAMETER;
   }
@@ -381,7 +382,7 @@ Returns:
       return EFI_INVALID_PARAMETER;
     }
 
-    IpAddr.Addr[Index]  = (UINT8) Byte;
+    IpAddr.v4.Addr[Index]  = (UINT8) Byte;
 
     if ((*String != '.') || !SHELL_IS_DIGIT (*(String + 1))) {
       break;
@@ -394,7 +395,7 @@ Returns:
     return EFI_INVALID_PARAMETER;
   }
 
-  *Ip = IpAddr;
+  *Ip = IpAddr.v4;
   return EFI_SUCCESS;
 }
 
@@ -668,8 +669,8 @@ Returns:
   Ip4ConfigData.AcceptBroadcast          = FALSE;
   Ip4ConfigData.AcceptPromiscuous        = FALSE;
   Ip4ConfigData.UseDefaultAddress        = TRUE;
-  EFI_IP4_TO_U32 (Ip4ConfigData.StationAddress) = 0;
-  EFI_IP4_TO_U32 (Ip4ConfigData.SubnetMask)     = 0;
+  ZeroMem (&Ip4ConfigData.StationAddress, sizeof (EFI_IPv4_ADDRESS));
+  ZeroMem (&Ip4ConfigData.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
   Ip4ConfigData.TypeOfService            = 0;
   Ip4ConfigData.TimeToLive               = 1;
   Ip4ConfigData.DoNotFragment            = FALSE;
@@ -769,9 +770,9 @@ Returns:
 {
   NIC_IP4_CONFIG_INFO           *Config;
   NIC_IP4_CONFIG_INFO           *OldConfig;
-  EFI_IPv4_ADDRESS              Ip;
-  EFI_IPv4_ADDRESS              Mask;
-  EFI_IPv4_ADDRESS              Gateway;
+  EFI_IP_ADDRESS                Ip;
+  EFI_IP_ADDRESS                Mask;
+  EFI_IP_ADDRESS                Gateway;
   NIC_INFO                      *Info;
   BOOLEAN                       Perment;
   EFI_STATUS                    Status;
@@ -783,11 +784,13 @@ Returns:
     return EFI_NOT_FOUND;
   }
 
-  Config = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE));
+  Config = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));
   if (Config == NULL) {
     return EFI_OUT_OF_RESOURCES;
   }
 
+  Config->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (Config + 1);
+
   OldConfig = Info->ConfigInfo;
   Perment   = FALSE;
   Status    = EFI_INVALID_PARAMETER;
@@ -835,19 +838,19 @@ Returns:
     }
 
     VarList = VarList->Next;
-    if (EFI_ERROR (StrToIp (VarList->VarStr, &Ip))) {
+    if (EFI_ERROR (StrToIp (VarList->VarStr, &Ip.v4))) {
       PrintToken (STRING_TOKEN (STR_IFCONFIG_INVALID_IP_STR), HiiHandle, VarList->VarStr);
       goto ON_EXIT;
     }
 
     VarList = VarList->Next;
-    if (EFI_ERROR (StrToIp (VarList->VarStr, &Mask))) {
+    if (EFI_ERROR (StrToIp (VarList->VarStr, &Mask.v4))) {
       PrintToken (STRING_TOKEN (STR_IFCONFIG_INVALID_IP_STR), HiiHandle, VarList->VarStr);
       goto ON_EXIT;
     }
 
     VarList = VarList->Next;
-    if (EFI_ERROR (StrToIp (VarList->VarStr, &Gateway))) {
+    if (EFI_ERROR (StrToIp (VarList->VarStr, &Gateway.v4))) {
       PrintToken (STRING_TOKEN (STR_IFCONFIG_INVALID_IP_STR), HiiHandle, VarList->VarStr);
       goto ON_EXIT;
     }
@@ -864,15 +867,15 @@ Returns:
       Perment = TRUE;
     }
 
-    if ((EFI_IP4_TO_U32 (Ip) == 0) || (EFI_IP4_TO_U32 (Mask) == 0) ||
-        !ShellIp4IsUnicast (EFI_IP4_NTOHL (Ip), EFI_IP4_NTOHL (Mask))) {
+    if ((Ip.Addr[0] == 0) || (Mask.Addr[0] == 0) ||
+        !ShellIp4IsUnicast (NTOHL (Ip.Addr[0]), NTOHL (Mask.Addr[0]))) {
 
       PrintToken (STRING_TOKEN (STR_IFCONFIG_INVALID_ADDR_PAIR), HiiHandle);
       goto ON_EXIT;
     }
 
-    if (!IP4_EQUAL_MASK (EFI_IP4_NTOHL (Ip), EFI_IP4_NTOHL (Gateway), EFI_IP4_NTOHL (Mask)) ||
-        !ShellIp4IsUnicast (EFI_IP4_NTOHL (Gateway), EFI_IP4_NTOHL (Mask))) {
+    if (!IP4_EQUAL_MASK (Ip.Addr[0], Gateway.Addr[0], Mask.Addr[0]) ||
+        !ShellIp4IsUnicast (NTOHL (Gateway.Addr[0]), NTOHL (Mask.Addr[0]))) {
         
       PrintToken (STRING_TOKEN (STR_IFCONFIG_INVALID_GATEWAY), HiiHandle);
       goto ON_EXIT;
@@ -885,12 +888,16 @@ Returns:
     // by AllocateZeroPool
     //
     Config->Source = IP4_CONFIG_SOURCE_STATIC;
-    Config->Ip4Info.StationAddress = Ip;
-    Config->Ip4Info.SubnetMask     = Mask;
     Config->Ip4Info.RouteTableSize = 2;
-    Config->Ip4Info.RouteTable[0].SubnetAddress  = Ip;
-    Config->Ip4Info.RouteTable[0].SubnetMask     = Mask;
-    Config->Ip4Info.RouteTable[1].GatewayAddress = Gateway;
+
+    CopyMem (&Config->Ip4Info.StationAddress, &Ip.v4, sizeof (EFI_IPv4_ADDRESS));
+    CopyMem (&Config->Ip4Info.SubnetMask, &Mask.v4, sizeof (EFI_IPv4_ADDRESS));
+
+    Ip.Addr[0] = Ip.Addr[0] & Mask.Addr[0];
+
+    CopyMem (&Config->Ip4Info.RouteTable[0].SubnetAddress, &Ip.v4, sizeof (EFI_IPv4_ADDRESS));
+    CopyMem (&Config->Ip4Info.RouteTable[0].SubnetMask, &Mask.v4, sizeof (EFI_IPv4_ADDRESS));
+    CopyMem (&Config->Ip4Info.RouteTable[1].GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));
   } else {
     PrintToken (STRING_TOKEN (STR_IFCONFIG_PROMPT_HELP), HiiHandle);
     goto ON_EXIT;
@@ -947,6 +954,7 @@ Returns:
   UINT32                        Index;
   EFI_IP4_IPCONFIG_DATA         *Ip4Config;
   EFI_IPv4_ADDRESS              Gateway;
+  EFI_IPv4_ADDRESS              ZeroIp;
 
   EFI_LIST_FOR_EACH (Entry, &NicInfoList) {
     NicInfo = _CR (Entry, NIC_INFO, Link);
@@ -984,12 +992,13 @@ Returns:
     PrintIp (L"  IP address : ", &Ip4Config->StationAddress);
     PrintIp (L"  Mask       : ", &Ip4Config->SubnetMask);
 
-    EFI_IP4_TO_U32 (Gateway) = 0;
+    ZeroMem (&Gateway, sizeof (EFI_IPv4_ADDRESS));
+    ZeroMem (&ZeroIp, sizeof (EFI_IPv4_ADDRESS));
     
     for (Index = 0; Index < Ip4Config->RouteTableSize; Index++) {
-      if ((EFI_IP4_TO_U32 (Ip4Config->RouteTable[Index].SubnetAddress) == 0) &&
-          (EFI_IP4_TO_U32 (Ip4Config->RouteTable[Index].SubnetMask) == 0)) {
-        Gateway = Ip4Config->RouteTable[Index].GatewayAddress;
+      if ((CompareMem (&Ip4Config->RouteTable[Index].SubnetAddress, &ZeroIp, sizeof (EFI_IPv4_ADDRESS)) == 0) &&
+        (CompareMem (&Ip4Config->RouteTable[Index].SubnetMask, &ZeroIp, sizeof (EFI_IPv4_ADDRESS)) == 0)) {
+        CopyMem (&Gateway, &Ip4Config->RouteTable[Index].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
       }
     }
    
@@ -1199,6 +1208,11 @@ Done:
     Info  = _CR (Entry, NIC_INFO, Link);
 
     RemoveEntryList (Entry);
+
+    if (Info->ConfigInfo != NULL) {
+      FreePool (Info->ConfigInfo);
+    }
+
     FreePool (Info);
   }
 
index 14992ae..9a8c0aa 100644 (file)
@@ -366,12 +366,101 @@ _DevPathSerialVendor (
   )
 {
   VENDOR_DEVICE_PATH  *Vendor;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+  SAS_DEVICE_PATH     *Sas;
+  EFI_GUID            SasVendorGuid = DEVICE_PATH_MESSAGING_SAS;
+#endif
 
   ASSERT(DevicePathNode != NULL);
   ASSERT(MappingItem != NULL);
 
   Vendor = (VENDOR_DEVICE_PATH *) DevicePathNode;
   AppendCSDGuid (MappingItem, &Vendor->Guid);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+  if (CompareGuid (&SasVendorGuid, &Vendor->Guid) == 0) {
+    Sas = (SAS_DEVICE_PATH *) Vendor;
+    AppendCSDNum (MappingItem, Sas->SasAddress);
+    AppendCSDNum (MappingItem, Sas->Lun);
+    AppendCSDNum (MappingItem, Sas->DeviceTopology);
+    AppendCSDNum (MappingItem, Sas->RelativeTargetPort);
+  }
+#endif
+}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+VOID
+_DevPathSerialLUN (
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevicePathNode,
+  IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem
+  )
+{
+  DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun;
+
+  ASSERT(DevicePathNode != NULL);
+  ASSERT(MappingItem != NULL);
+
+  Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) DevicePathNode;
+  AppendCSDNum (MappingItem, Lun->Lun);
+}
+#endif
+
+VOID
+_DevPathSerialSata (
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevicePathNode,
+  IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem
+  )
+{
+  SATA_DEVICE_PATH  *Sata;
+
+  ASSERT(DevicePathNode != NULL);
+  ASSERT(MappingItem != NULL);
+
+  Sata = (SATA_DEVICE_PATH  *) DevicePathNode;
+  AppendCSDNum (MappingItem, Sata->HBAPortNumber);
+  AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber);
+  AppendCSDNum (MappingItem, Sata->Lun);
+}
+
+VOID
+_DevPathSerialIScsi (
+  IN EFI_DEVICE_PATH_PROTOCOL     *DevicePathNode,
+  IN DEVICE_CONSIST_MAPPING_INFO  *MappingItem
+  )
+{
+//
+// As CSD of ISCSI node is quite long, we comment
+// the code below to keep the consistent mapping
+// short. Uncomment if you really need it.
+//
+/*
+  ISCSI_DEVICE_PATH  *IScsi;
+  UINT8              *IScsiTargetName;
+  CHAR16             *TargetName;
+  UINTN              TargetNameLength;
+  UINTN              Index;
+
+  ASSERT(DevicePathNode != NULL);
+  ASSERT(MappingItem != NULL);
+
+  IScsi = (ISCSI_DEVICE_PATH  *) DevicePathNode;
+  AppendCSDNum (MappingItem, IScsi->NetworkProtocol);
+  AppendCSDNum (MappingItem, IScsi->LoginOption);
+  AppendCSDNum (MappingItem, IScsi->Lun);
+  AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);
+  TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);
+  if (TargetNameLength > 0) {
+    TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));
+    if (TargetName != NULL) {
+      IScsiTargetName = (UINT8 *) (IScsi + 1);
+      for (Index = 0; Index < TargetNameLength; Index++) {
+        TargetName[Index] = (CHAR16) IScsiTargetName[Index];
+      }
+      AppendCSDStr (MappingItem, TargetName);
+      FreePool (TargetName);
+    }
+  }
+ */
 }
 
 VOID
@@ -575,22 +664,6 @@ DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {
   HW_PCI_DP,
   _DevPathSerialDefault,
   _DevPathComparePci,
-  HARDWARE_DEVICE_PATH,
-  HW_PCCARD_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-  HARDWARE_DEVICE_PATH,
-  HW_MEMMAP_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-  HARDWARE_DEVICE_PATH,
-  HW_VENDOR_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-  HARDWARE_DEVICE_PATH,
-  HW_CONTROLLER_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
   ACPI_DEVICE_PATH,
   ACPI_DP,
   _DevPathSerialAcpi,
@@ -616,10 +689,6 @@ DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {
   _DevPathSerialUsb,
   _DevPathCompareDefault,
   MESSAGING_DEVICE_PATH,
-  MSG_USB_CLASS_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-  MESSAGING_DEVICE_PATH,
   MSG_I2O_DP,
   _DevPathSerialI2O,
   _DevPathCompareDefault,
@@ -647,6 +716,20 @@ DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {
   MSG_VENDOR_DP,
   _DevPathSerialVendor,
   _DevPathCompareDefault,
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+  MESSAGING_DEVICE_PATH,
+  MSG_DEVICE_LOGICAL_UNIT_DP,
+  _DevPathSerialLUN,
+  _DevPathCompareDefault,
+#endif
+  MESSAGING_DEVICE_PATH,
+  MSG_SATA_DP,
+  _DevPathSerialSata,
+  _DevPathCompareDefault,
+  MESSAGING_DEVICE_PATH,
+  MSG_ISCSI_DP,
+  _DevPathSerialIScsi,
+  _DevPathCompareDefault,
   MEDIA_DEVICE_PATH,
   MEDIA_HARDDRIVE_DP,
   _DevPathSerialHardDrive,
@@ -659,28 +742,6 @@ DEV_PATH_CONSIST_MAPPING_TABLE  DevPathConsistMappingTable[] = {
   MEDIA_VENDOR_DP,
   _DevPathSerialVendor,
   _DevPathCompareDefault,
-  MEDIA_DEVICE_PATH,
-  MEDIA_FILEPATH_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-  MEDIA_DEVICE_PATH,
-  MEDIA_PROTOCOL_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-#if (EFI_SPECIFICATION_VERSION != 0x00020000)
-  MEDIA_DEVICE_PATH,
-  MEDIA_FV_FILEPATH_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-#endif
-  BBS_DEVICE_PATH,
-  BBS_BBS_DP,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
-  END_DEVICE_PATH_TYPE,
-  END_INSTANCE_DEVICE_PATH_SUBTYPE,
-  _DevPathSerialDefault,
-  _DevPathCompareDefault,
   0,
   0,
   NULL,
index 5f55484..da8ef6e 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -1248,6 +1248,10 @@ _DevPathBssBss (
     Type = L"Net";
     break;
 
+  case BBS_TYPE_BEV:
+    Type = L"BEV";
+    break;
+
   default:
     Type = L"?";
     break;
@@ -1278,6 +1282,23 @@ _DevPathNodeUnknown (
   CatPrint (Str, L"?");
 }
 
+#if (EFI_SPECIFICATION_VERSION > 0x00020000)
+VOID
+_DevPathFvPath (
+  IN OUT POOL_PRINT       *Str,
+  IN VOID                 *DevPath
+  )
+{
+  MEDIA_FW_VOL_DEVICE_PATH *FvPath;
+
+  ASSERT (Str != NULL);
+  ASSERT (DevPath != NULL);
+
+  FvPath = DevPath;
+  CatPrint (Str, L"Fv(%g)", &FvPath->NameGuid);
+}
+#endif
+
 struct {
   UINT8 Type;
   UINT8 SubType;
@@ -1378,6 +1399,11 @@ DevPathTable[] = {
   MEDIA_DEVICE_PATH,
   MEDIA_PROTOCOL_DP,
   _DevPathMediaProtocol,
+#if (EFI_SPECIFICATION_VERSION > 0x00020000)
+  MEDIA_DEVICE_PATH,
+  MEDIA_FV_DP,
+  _DevPathFvPath,
+#endif
 #if (EFI_SPECIFICATION_VERSION != 0x00020000)
   MEDIA_DEVICE_PATH,
   MEDIA_FV_FILEPATH_DP,
@@ -1419,11 +1445,30 @@ Returns:
   UINTN Index;
   UINTN NewSize;
 
+  EFI_STATUS                       Status;
+  CHAR16                           *ToText;
+  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
+
   ZeroMem (&Str, sizeof (Str));
 
   if (DevPath == NULL) {
     goto Done;
   }
+  
+  Status = LibLocateProtocol (
+             &gEfiDevicePathToTextProtocolGuid,
+             &DevPathToText
+             );
+  if (!EFI_ERROR (Status)) {
+    ToText = DevPathToText->ConvertDevicePathToText (
+                              DevPath,
+                              FALSE,
+                              TRUE
+                              );
+    ASSERT (ToText != NULL);
+    return ToText;
+  }
+
   //
   // Unpacked the device path
   //
@@ -1949,18 +1994,36 @@ Returns:
 
 --*/
 {
-#if (EFI_SPECIFICATION_VERSION != 0x00020000) 
+#if (EFI_SPECIFICATION_VERSION > 0x00020000)
+  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_EFI_2_00 *FvDevicePathNodeUefi_2_00;
+  
+  if (ST->Hdr.Revision != 0x00020000) {
+    if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
+        DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
+      return &FvDevicePathNode->NameGuid;
+    }    
+  } else {
+    FvDevicePathNodeUefi_2_00 = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_EFI_2_00 *)FvDevicePathNode;
+    if (DevicePathType (&FvDevicePathNodeUefi_2_00->Piwg.Header) == MEDIA_DEVICE_PATH &&
+        DevicePathSubType (&FvDevicePathNodeUefi_2_00->Piwg.Header) == MEDIA_VENDOR_DP) {
+      if (CompareMem (&gEfiFrameworkDevicePathGuid, &FvDevicePathNodeUefi_2_00->Piwg.PiwgSpecificDevicePath, sizeof(EFI_GUID)) == 0) {
+        if (FvDevicePathNodeUefi_2_00->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {
+          return &FvDevicePathNodeUefi_2_00->NameGuid;
+        }
+      }
+    }    
+  }
+#elif (EFI_SPECIFICATION_VERSION < 0x00020000) 
   //
-  // Use old Device Path that conflicts with UEFI
+  // Use old Device Path that conflicts with UEFI2.0
   //
   if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
       DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
     return &FvDevicePathNode->NameGuid;
   }
-
 #else
   //
-  // Use the new Device path that does not conflict with the UEFI
+  // Use the new Device path that does not conflict with the UEFI2.0
   //
   if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH &&
       DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) {
index 45f79c3..fdca789 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -156,4 +156,27 @@ GetNameGuidFromFwVolDevicePathNode (
   IN  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH   *FvDevicePathNode
   );
 
+
+#pragma pack(1)
+
+#if (EFI_SPECIFICATION_VERSION > 0x00020000)
+//
+// For UEFI2.0 FV file device path
+//
+typedef struct {
+  EFI_DEVICE_PATH_PROTOCOL  Header;
+  EFI_GUID                  PiwgSpecificDevicePath;
+  UINT32                    Type;
+} PIWG_DEVICE_PATH;
+
+#define PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE         0x01
+typedef struct {
+  PIWG_DEVICE_PATH      Piwg;
+  EFI_GUID              NameGuid;
+} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_EFI_2_00;
+
+#endif
+
+#pragma pack()
+
 #endif
index 0a72cbe..1ad6470 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -54,6 +54,9 @@ Revision History
 #include EFI_GUID_DEFINITION (Smbios)
 #include EFI_GUID_DEFINITION (StandardErrorDevice)
 #include EFI_GUID_DEFINITION (FrameworkDevicePath)
+#include EFI_PROTOCOL_DEFINITION (AbsolutePointer)
+#include EFI_PROTOCOL_DEFINITION (AcpiTable)
+#include EFI_PROTOCOL_DEFINITION (Bis)
 #include EFI_PROTOCOL_DEFINITION (BlockIo)
 #include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride)
 #include EFI_PROTOCOL_DEFINITION (ComponentName)
@@ -66,10 +69,15 @@ Revision History
 #include EFI_PROTOCOL_DEFINITION (Decompress)
 #include EFI_PROTOCOL_DEFINITION (DeviceIO)
 #include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_PROTOCOL_DEFINITION (DevicePathFromText)
+#include EFI_PROTOCOL_DEFINITION (DevicePathToText)
+#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities)
 #include EFI_PROTOCOL_DEFINITION (DiskIo)
 #include EFI_PROTOCOL_DEFINITION (DriverBinding)
 #include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration2)
 #include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2)
 #include EFI_PROTOCOL_DEFINITION (Ebc)
 #include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier)
 #include EFI_PROTOCOL_DEFINITION (FileSystemInfo)
@@ -77,16 +85,30 @@ Revision History
 #include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
 #include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)
 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (Hash)
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
+#include EFI_PROTOCOL_DEFINITION (HiiString)
+#include EFI_PROTOCOL_DEFINITION (HiiDatabase)
+#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess)
+#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting)
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+#include EFI_PROTOCOL_DEFINITION (HiiImage)
+#else
 #include EFI_PROTOCOL_DEFINITION (FormBrowser)
 #include EFI_PROTOCOL_DEFINITION (FormCallback)
 #include EFI_PROTOCOL_DEFINITION (Hii)
+#endif
 #include EFI_PROTOCOL_DEFINITION (IsaAcpi)
 #include EFI_PROTOCOL_DEFINITION (IsaIo)
+#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName)
 #include EFI_PROTOCOL_DEFINITION (LoadedImage)
+#include EFI_PROTOCOL_DEFINITION (LoadedImageDevicePath)
 #include EFI_PROTOCOL_DEFINITION (LoadFile)
 #include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)
 #include EFI_PROTOCOL_DEFINITION (PciIo)
 #include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)
+#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)
 #include EFI_PROTOCOL_DEFINITION (PxeBaseCode)
 #include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallback)
 #include EFI_PROTOCOL_DEFINITION (ScsiIo)
@@ -96,7 +118,10 @@ Revision History
 #include EFI_PROTOCOL_DEFINITION (SimpleFileSystem)
 #include EFI_PROTOCOL_DEFINITION (SimpleNetwork)
 #include EFI_PROTOCOL_DEFINITION (SimplePointer)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextInputEx)
 #include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
+#include EFI_PROTOCOL_DEFINITION (TapeIo)
 #include EFI_PROTOCOL_DEFINITION (Tcp)
 #include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
 #include EFI_PROTOCOL_DEFINITION (EdidDiscovered)
@@ -106,6 +131,7 @@ Revision History
 #include EFI_PROTOCOL_DEFINITION (UgaIo)
 #include EFI_PROTOCOL_DEFINITION (UgaSplash)
 #include EFI_PROTOCOL_DEFINITION (UnicodeCollation)
+#include EFI_PROTOCOL_DEFINITION (UnicodeCollation2)
 #include EFI_PROTOCOL_DEFINITION (UsbHostController)
 #include EFI_PROTOCOL_DEFINITION (UsbIo)
 #include EFI_PROTOCOL_DEFINITION (VariableStore)
@@ -120,6 +146,9 @@ Revision History
 #include EFI_PROTOCOL_DEFINITION (Udp4)
 #include EFI_PROTOCOL_DEFINITION (Mtftp4)
 #include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_PROTOCOL_DEFINITION (AuthenticationInfo)
+#include EFI_PROTOCOL_DEFINITION (DriverSupportedEfiVersion)
+#include EFI_PROTOCOL_DEFINITION (PlatformToDriverConfiguration)
 
 #include "efilibplat.h"
 #include "efipart.h"
@@ -138,6 +167,9 @@ Revision History
 #include "Str.h"
 #include "VarCheck.h"
 #include "ConsistMapping.h"
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include "HiiSupport.h"
+#endif
 
 //
 //  Environment variable name constants
@@ -160,6 +192,7 @@ Revision History
 #define LanguageCodeEnglish "eng"
 
 #define ISO_639_2_ENTRY_SIZE  3
+#define RFC_3066_ENTRY_SIZE   12
 
 #define ALIGN_SIZE(a) ((a % MIN_ALIGNMENT_SIZE) ? MIN_ALIGNMENT_SIZE - (a % MIN_ALIGNMENT_SIZE) : 0)
 
@@ -295,9 +328,9 @@ LibGetComponentNameProtocol (
   );
 
 CHAR8 *
-LibConvertComponentName2SupportLanguage (
-  IN EFI_COMPONENT_NAME2_PROTOCOL    *ComponentName,
-  IN CHAR8                           *Language
+LibConvertSupportedLanguage (
+  IN CHAR8                           *SupportedLanguages,
+  IN CHAR8                           *LangCode
   );
 
 #endif
index ee07ec8..d450f9d 100644 (file)
@@ -1,6 +1,6 @@
 #/*++
 #
-# Copyright (c) 2005 - 2006, Intel Corporation                                                         
+# Copyright (c) 2005 - 2007, 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         
@@ -42,6 +42,7 @@ COMPONENT_TYPE  = LIBRARY
   Event.c
   Perf.c
   VarCheck.c
+  HiiSupport.c
 
 [sources.ia32]
   ia32\math.c
index 1fbb606..40c67d1 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -253,14 +253,16 @@ Returns:
 
 --*/
 {
-  EFI_STATUS            Status;
-  EFI_FILE_HANDLE       LastHandle;
-  FILEPATH_DEVICE_PATH  *FilePathNode;
+  EFI_STATUS                Status;
+  EFI_FILE_HANDLE           LastHandle;
+  FILEPATH_DEVICE_PATH      *FilePathNode;
+  EFI_DEVICE_PATH_PROTOCOL  *AlignedFilePath;
 
   ASSERT (FilePath != NULL);
   ASSERT (DeviceHandle != NULL);
   ASSERT (FileHandle != NULL);
-  
+
+  AlignedFilePath = NULL;
   //
   // File the file system for this file path
   //
@@ -274,12 +276,26 @@ Returns:
   *FileHandle = LibOpenRoot (*DeviceHandle);
   Status      = *FileHandle ? EFI_SUCCESS : EFI_UNSUPPORTED;
 
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Duplicate FilePath to make sure it is aligned so that
+  // FilePathNode->PathName below is 16-bit aligned.
+  //
+  AlignedFilePath = DuplicateDevicePath(*FilePath);
+  if (AlignedFilePath == NULL) {
+    (*FileHandle)->Close (*FileHandle);
+    *FileHandle = NULL;
+    return EFI_OUT_OF_RESOURCES;
+  }
+  FilePathNode = (FILEPATH_DEVICE_PATH *)AlignedFilePath;
   //
   // To access as a file system, the file path should only
   // contain file path components.  Follow the file path nodes
   // and find the target file
   //
-  FilePathNode = (FILEPATH_DEVICE_PATH *) *FilePath;
   while (!IsDevicePathEnd (&FilePathNode->Header)) {
     //
     // For file system access each node should be a file path component
@@ -332,6 +348,7 @@ Returns:
   if (EFI_ERROR (Status)) {
     *FileHandle = NULL;
   }
+  FreePool(AlignedFilePath);
 
   return Status;
 }
index 3793ef8..33f925d 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -873,10 +873,18 @@ LibScanHandleDatabase (
           (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_BINDING_HANDLE;
         }
 
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfiguration2ProtocolGuid) == 0) {
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE;
+        }
+
         if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverConfigurationProtocolGuid) == 0) {
           (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE;
         }
 
+        if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnostics2ProtocolGuid) == 0) {
+          (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE;
+        }
+
         if (CompareGuid (ProtocolGuidArray[ProtocolIndex], &gEfiDriverDiagnosticsProtocolGuid) == 0) {
           (*HandleType)[HandleIndex] |= EFI_HANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE;
         }
diff --git a/Library/HiiSupport.c b/Library/HiiSupport.c
new file mode 100644 (file)
index 0000000..5a2e52f
--- /dev/null
@@ -0,0 +1,299 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution. The full text of the license may be found at         \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  HiiSupport.c\r
+\r
+Abstract:\r
+\r
+  Implements some helper functions for hii operations.\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#include "EfiShelllib.h"\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+\r
+//\r
+// Hii relative protocols\r
+//\r
+BOOLEAN  mHiiProtocolsInitialized = FALSE;\r
+\r
+EFI_HII_DATABASE_PROTOCOL *gLibHiiDatabase = NULL;\r
+EFI_HII_STRING_PROTOCOL   *gLibHiiString = NULL;\r
+\r
+EFI_STATUS\r
+LocateHiiProtocols (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function locate Hii relative protocols for later usage.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  Status code.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (mHiiProtocolsInitialized) {\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  Status = LibLocateProtocol (&gEfiHiiDatabaseProtocolGuid, &gLibHiiDatabase);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  Status = LibLocateProtocol (&gEfiHiiStringProtocolGuid, &gLibHiiString);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }  \r
+  \r
+  mHiiProtocolsInitialized = TRUE;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_HII_PACKAGE_LIST_HEADER *\r
+PreparePackageList (\r
+  IN UINTN                    PkgNumber,\r
+  IN EFI_GUID                 *GuidId,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.\r
+\r
+Arguments:\r
+\r
+  NumberOfPackages  -  Number of packages.\r
+  GuidId            -  Package GUID.\r
+\r
+Returns:\r
+\r
+  Pointer of EFI_HII_PACKAGE_LIST_HEADER.\r
+\r
+--*/\r
+{\r
+  VA_LIST                     Args;\r
+  EFI_HII_PACKAGE_LIST_HEADER *PkgListHdr;\r
+  CHAR8                       *PkgListData;\r
+  UINT32                      PkgListLen;\r
+  UINT32                      PkgLen;\r
+  EFI_HII_PACKAGE_HEADER      PkgHdr = {0, 0};\r
+  UINT8                       *PkgAddr;\r
+  UINTN                       Index;\r
+\r
+  PkgListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+\r
+  VA_START (Args, GuidId);\r
+  for (Index = 0; Index < PkgNumber; Index++) {\r
+    CopyMem (&PkgLen, VA_ARG (Args, VOID *), sizeof (UINT32));\r
+    PkgListLen += (PkgLen - sizeof (UINT32));\r
+  }\r
+\r
+  //\r
+  // Include the lenght of EFI_HII_PACKAGE_END\r
+  //\r
+  PkgListLen += sizeof (EFI_HII_PACKAGE_HEADER);\r
+\r
+  VA_END (Args);\r
+\r
+  PkgListHdr = AllocateZeroPool (PkgListLen);\r
+  ASSERT (PkgListHdr != NULL);\r
+  CopyMem (&PkgListHdr->PackageListGuid, GuidId, sizeof (EFI_GUID));\r
+  PkgListHdr->PackageLength = PkgListLen;\r
+\r
+  PkgListData = (CHAR8 *)PkgListHdr + sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+\r
+  VA_START (Args, GuidId);\r
+  for (Index = 0; Index < PkgNumber; Index++) {\r
+    PkgAddr = (UINT8 *)VA_ARG (Args, VOID *);\r
+    CopyMem (&PkgLen, PkgAddr, sizeof (UINT32));\r
+    PkgLen  -= sizeof (UINT32);\r
+    PkgAddr += sizeof (UINT32);\r
+    CopyMem (PkgListData, PkgAddr, PkgLen);\r
+    PkgListData += PkgLen;\r
+  }\r
+  VA_END (Args);\r
+\r
+  //\r
+  // Append EFI_HII_PACKAGE_END\r
+  //\r
+  PkgHdr.Type = EFI_HII_PACKAGE_END;\r
+  PkgHdr.Length = sizeof (EFI_HII_PACKAGE_HEADER);\r
+  CopyMem (PkgListData, &PkgHdr, PkgHdr.Length);\r
+\r
+  return PkgListHdr;\r
+}\r
+\r
+EFI_STATUS\r
+GetCurrentLanguage (\r
+  OUT     CHAR8               *Lang\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Determine what is the current language setting\r
+\r
+Arguments:\r
+  Lang      - Pointer of system language\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  UINTN       Size;\r
+\r
+  //\r
+  // Get current language setting\r
+  //\r
+  Size = RFC_3066_ENTRY_SIZE;\r
+  Status = RT->GetVariable (\r
+                 L"PlatformLang",\r
+                 &gEfiGlobalVariableGuid,\r
+                 NULL,\r
+                 &Size,\r
+                 Lang\r
+                 );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    strcpya (Lang, "en-US");\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+BOOLEAN\r
+CompareLanguage (\r
+  IN  CHAR8  *Language1,\r
+  IN  CHAR8  *Language2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compare whether two names of languages are identical.\r
+\r
+Arguments:\r
+\r
+  Language1 - Name of language 1\r
+  Language2 - Name of language 2\r
+\r
+Returns:\r
+\r
+  TRUE      - same\r
+  FALSE     - not same\r
+\r
+--*/\r
+{\r
+  UINTN Index;\r
+  \r
+  for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {\r
+    if (Language1[Index] != Language2[Index]) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  if (((Language1[Index] == 0) && (Language2[Index] == 0))   || \r
+      ((Language1[Index] == 0) && (Language2[Index] != ';')) ||\r
+      ((Language1[Index] == ';') && (Language2[Index] != 0)) ||\r
+      ((Language1[Index] == ';') && (Language2[Index] != ';'))) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+EFI_STATUS\r
+LibGetString (\r
+  IN  EFI_HII_HANDLE                  PackageList,\r
+  IN  EFI_STRING_ID                   StringId,\r
+  OUT EFI_STRING                      String,\r
+  IN  OUT UINTN                       *StringSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    This function try to retrieve string from String package of current language.\r
+    If fail, it try to retrieve string from String package of first language it support.\r
+\r
+  Arguments:\r
+    PackageList       - The package list in the HII database to search for the specified string.\r
+    StringId          - The string's id, which is unique within PackageList.\r
+    String            - Points to the new null-terminated string.\r
+    StringSize        - On entry, points to the size of the buffer pointed to by String, in bytes. On return,\r
+                        points to the length of the string, in bytes.\r
+\r
+  Returns:\r
+    EFI_SUCCESS            - The string was returned successfully.\r
+    EFI_NOT_FOUND          - The string specified by StringId is not available.\r
+    EFI_BUFFER_TOO_SMALL   - The buffer specified by StringLength is too small to hold the string.\r
+    EFI_INVALID_PARAMETER  - The String or StringSize was NULL.\r
+    EFI_UNSUPPORTED        - This operation is not supported since the protocol\r
+                             interface is unavailable.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS Status;\r
+  CHAR8      CurrentLang[RFC_3066_ENTRY_SIZE];\r
+\r
+  Status = LocateHiiProtocols ();\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  GetCurrentLanguage (CurrentLang);\r
+\r
+  Status = gLibHiiString->GetString (\r
+                            gLibHiiString,\r
+                            CurrentLang,\r
+                            PackageList,\r
+                            StringId,\r
+                            String,\r
+                            StringSize,\r
+                            NULL\r
+                            );\r
+\r
+  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {\r
+    //\r
+    // Since en-US should be supported by all shell strings, if we cannot get \r
+    // the string in current language, use the en-US instead.\r
+    //\r
+    strcpya (CurrentLang, "en-US");\r
+\r
+    Status = gLibHiiString->GetString (\r
+                              gLibHiiString,\r
+                              CurrentLang,\r
+                              PackageList,\r
+                              StringId,\r
+                              String,\r
+                              StringSize,\r
+                              NULL\r
+                              );\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+#endif\r
+\r
diff --git a/Library/HiiSupport.h b/Library/HiiSupport.h
new file mode 100644 (file)
index 0000000..b04c443
--- /dev/null
@@ -0,0 +1,144 @@
+/*++\r
+\r
+Copyright (c) 2007, Intel Corporation                                                         \r
+All rights reserved. This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution. The full text of the license may be found at         \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  HiiSupport.h\r
+\r
+Abstract:\r
+\r
+  Declare some helper functions for hii operations.\r
\r
+Revision History\r
+\r
+--*/\r
+#ifndef _HII_SUPPORT_H\r
+#define _HII_SUPPORT_H\r
+\r
+#define STRING_TOKEN(t) t\r
+\r
+extern EFI_HII_DATABASE_PROTOCOL *gLibHiiDatabase;\r
+extern EFI_HII_STRING_PROTOCOL   *gLibHiiString;\r
+\r
+EFI_STATUS\r
+LocateHiiProtocols (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function locate Hii relative protocols for later usage.\r
+\r
+Arguments:\r
+  None.\r
+\r
+Returns:\r
+  Status code.\r
+\r
+--*/\r
+;\r
+\r
+EFI_HII_PACKAGE_LIST_HEADER *\r
+PreparePackageList (\r
+  IN UINTN                    PkgNumber,\r
+  IN EFI_GUID                 *GuidId,\r
+  ...\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.\r
+\r
+Arguments:\r
+\r
+  NumberOfPackages  -  Number of packages.\r
+  GuidId            -  Package GUID.\r
+\r
+Returns:\r
+\r
+  Pointer of EFI_HII_PACKAGE_LIST_HEADER.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+GetCurrentLanguage (\r
+  OUT     CHAR8               *Lang\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Determine what is the current language setting\r
+\r
+Arguments:\r
+  Lang      - Pointer of system language\r
+\r
+Returns:\r
+  Status code\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+CompareLanguage (\r
+  IN  CHAR8  *Language1,\r
+  IN  CHAR8  *Language2\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Compare whether two names of languages are identical.\r
+\r
+Arguments:\r
+\r
+  Language1 - Name of language 1\r
+  Language2 - Name of language 2\r
+\r
+Returns:\r
+\r
+  TRUE      - same\r
+  FALSE     - not same\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+LibGetString (\r
+  IN  EFI_HII_HANDLE                  PackageList,\r
+  IN  EFI_STRING_ID                   StringId,\r
+  OUT EFI_STRING                      String,\r
+  IN  OUT UINTN                       *StringSize\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+    This function try to retrieve string from String package of current language.\r
+    If fail, it try to retrieve string from String package of first language it support.\r
+\r
+  Arguments:\r
+    PackageList       - The package list in the HII database to search for the specified string.\r
+    StringId          - The string's id, which is unique within PackageList.\r
+    String            - Points to the new null-terminated string.\r
+    StringSize        - On entry, points to the size of the buffer pointed to by String, in bytes. On return,\r
+                        points to the length of the string, in bytes.\r
+\r
+  Returns:\r
+    EFI_SUCCESS            - The string was returned successfully.\r
+    EFI_NOT_FOUND          - The string specified by StringId is not available.\r
+    EFI_BUFFER_TOO_SMALL   - The buffer specified by StringLength is too small to hold the string.\r
+    EFI_INVALID_PARAMETER  - The String or StringSize was NULL.\r
+\r
+--*/\r
+;\r
+\r
+#endif\r
index 9bd440a..81f26fd 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -449,14 +449,16 @@ Returns:
   VA_LIST           args;
   CHAR16            *StringPtr;
   UINTN             StringSize;
-  EFI_HII_PROTOCOL  *Hii;
   UINTN             Value;
   EFI_STATUS        Status;
-
-  Hii         = NULL;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+  EFI_HII_PROTOCOL  *Hii = NULL;
+#endif
+  
   StringPtr   = NULL;
   StringSize  = 0x1000;
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   //
   // There should only be one HII protocol
   //
@@ -464,10 +466,10 @@ Returns:
             &gEfiHiiProtocolGuid,
             (VOID **) &Hii
             );
-
   if (EFI_ERROR (Status)) {
     return 0;
   }
+#endif
   //
   // Allocate BufferSize amount of memory
   //
@@ -479,7 +481,11 @@ Returns:
   //
   // Retrieve string from HII
   //
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   Status = Hii->GetString (Hii, Handle, Token, FALSE, NULL, &StringSize, StringPtr);
+#else
+  Status = LibGetString (Handle, Token, StringPtr, &StringSize);
+#endif
 
   if (EFI_ERROR (Status)) {
     if (Status == EFI_BUFFER_TOO_SMALL) {
@@ -489,7 +495,11 @@ Returns:
       //
       // Retrieve string from HII
       //
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
       Status = Hii->GetString (Hii, Handle, Token, FALSE, NULL, &StringSize, StringPtr);
+#else
+      Status = LibGetString (Handle, Token, StringPtr, &StringSize);
+#endif
 
       if (EFI_ERROR (Status)) {
         return 0;
index c50ab84..93d1abe 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -16,9 +16,6 @@ Module Name:
 
 Abstract:
 
-
-
-
 Revision History
 
 --*/
@@ -88,7 +85,7 @@ Returns:
   }
 
   if (ImageHandle && UnicodeInterface == &LibStubUnicodeInterface) {
-    LangCode  = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+    LangCode  = LibGetVariableLang ();
     Status    = InitializeUnicodeSupport (LangCode);
     if (EFI_ERROR (Status)) {
       Status = InitializeUnicodeSupport (LanguageCodeEnglish);
@@ -129,8 +126,6 @@ Returns:
   EFI_STATUS                      Status;
   CHAR8                           *Languages;
   UINTN                           Index;
-  UINTN                           Position;
-  UINTN                           Length;
   UINTN                           NoHandles;
   EFI_HANDLE                      *Handles;
   EFI_STATUS                      ReturnStatus;
@@ -139,7 +134,10 @@ Returns:
   //
   // If we don't know it, lookup the current language code
   //
-  LibLocateHandle (ByProtocol, &gEfiUnicodeCollationProtocolGuid, NULL, &NoHandles, &Handles);
+  LibLocateHandle (ByProtocol, &gEfiUnicodeCollation2ProtocolGuid, NULL, &NoHandles, &Handles);
+  if (NoHandles == 0) {
+    LibLocateHandle (ByProtocol, &gEfiUnicodeCollationProtocolGuid, NULL, &NoHandles, &Handles);
+  }
   if (!LangCode || !NoHandles) {
     goto Done;
   }
@@ -147,24 +145,30 @@ Returns:
   // Check all driver's for a matching language code
   //
   for (Index = 0; Index < NoHandles; Index++) {
-    Status = BS->HandleProtocol (Handles[Index], &gEfiUnicodeCollationProtocolGuid, (VOID *) &Ui);
+    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
     //
-    Languages = Ui->SupportedLanguages;
-    Length    = strlena (Languages);
-    for (Position = 0; Position < Length; Position += ISO_639_2_ENTRY_SIZE) {
-      //
-      // If this code matches, use this driver
-      //
-      if (CompareMem (Languages + Position, LangCode, ISO_639_2_ENTRY_SIZE) == 0) {
+    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;
     }
   }
 
@@ -179,7 +183,9 @@ Done:
   return ReturnStatus;
 }
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 EFI_HII_PROTOCOL *HiiProt        = NULL;
+#endif
 EFI_HII_HANDLE   HiiLibHandle    = (EFI_HII_HANDLE) 0;
 BOOLEAN          HiiInitialized  = FALSE;
 UINTN            NumStrings      = 0;
@@ -198,7 +204,6 @@ Routine Description:
   If previously registered, simply return the handle.
 
 Arguments:
-
   HiiLibHandle    - A pointer to the handle which is used to reference our string data.
   StringPack      - String package
   StringPackGuid  - String package guid
@@ -208,9 +213,15 @@ Returns:
 
 --*/
 {
-  EFI_STATUS        Status;
-  EFI_HII_PACKAGES  *HiiPackages;
-  VOID              **Package;
+  EFI_STATUS                  Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+  EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+  EFI_GUID                    PackageListGuid;
+  UINT64                      MonotonicCount;  
+#else
+  EFI_HII_PACKAGES            *HiiPackages;
+  VOID                        **Package;
+#endif
 
   ASSERT (HiiHandle);
   
@@ -225,6 +236,29 @@ Returns:
   }
 
   HiiInitialized = TRUE;
+  
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+  LocateHiiProtocols ();
+  //
+  // Update the incoming StringPackGuid to make it unique to be a GUID of a 
+  // package list. 
+  //  
+  CopyMem (&PackageListGuid, StringPackGuid, sizeof (EFI_GUID));
+  BS->GetNextMonotonicCount (&MonotonicCount);
+  MonotonicCount += *((UINT64 *) (PackageListGuid.Data4));
+  CopyMem (PackageListGuid.Data4, &MonotonicCount, sizeof (UINT64));
+
+  PackageList = PreparePackageList (1, &PackageListGuid, StringPack);
+  ASSERT (PackageList != NULL);
+  Status = gLibHiiDatabase->NewPackageList (
+                              gLibHiiDatabase,
+                              PackageList,
+                              NULL,
+                              HiiHandle
+                              );
+  FreePool (PackageList);
+  
+#else
   //
   // Find the HII protocol
   //
@@ -242,11 +276,12 @@ Returns:
   HiiPackages->NumberOfPackages = 1;
   Package                       = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
   *Package                      = (EFI_HII_STRING_PACK *) StringPack;
-  Status                        = HiiProt->NewPack (HiiProt, HiiPackages, HiiHandle);
+  Status                        = HiiProt->NewPack (HiiProt, HiiPackages, HiiHandle);  
+  FreePool (HiiPackages);
+  
+#endif  
   NumStrings++;
-
   HiiLibHandle = *HiiHandle;
-  FreePool (HiiPackages);
   return Status;
 }
 
@@ -259,10 +294,16 @@ LibUnInitializeStrings (
 
   Status = EFI_SUCCESS;
   NumStrings--;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+  LocateHiiProtocols ();
+  if (gLibHiiDatabase != NULL && NumStrings == 0) {
+    Status = gLibHiiDatabase->RemovePackageList (gLibHiiDatabase, HiiLibHandle);
+  }
+#else
   if (HiiProt != NULL && NumStrings == 0) {
     Status = HiiProt->RemovePack (HiiProt, HiiLibHandle);
-  }
-
+  }  
+#endif
   return Status;
 }
 
index 989a0c6..cc019d1 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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,9 +23,31 @@ Revision History
 
 #include "EfiShelllib.h"
 
+#if (PLATFORM == NT32)
+#define LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID \
+  { \
+    0x58c518b1, 0x76f3, 0x11d4, 0xbc, 0xea, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+  }
+
+#define LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID \
+  { \
+    0x96eb4ad6, 0xa32a, 0x11d4, 0xbc, 0xfd, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+  }
+
+#define LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID \
+  { \
+    0xc95a93d, 0xa006, 0x11d4, 0xbc, 0xfa, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+  }
+EFI_GUID WinNtThunkProtocolGuid = LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID;
+EFI_GUID WinNtIoProtocolGuid    = LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID;
+EFI_GUID WinNtSerialPortGuid    = LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID;
+#endif
+
 EFI_GUID        ShellInterfaceProtocol  = SHELL_INTERFACE_PROTOCOL;
 EFI_GUID        PcAnsiProtocol          = DEVICE_PATH_MESSAGING_PC_ANSI;
 EFI_GUID        Vt100Protocol           = DEVICE_PATH_MESSAGING_VT_100;
+EFI_GUID        Vt100PlusProtocol       = DEVICE_PATH_MESSAGING_VT_100_PLUS;
+EFI_GUID        VtUtf8Protocol          = DEVICE_PATH_MESSAGING_VT_UTF8;
 
 #define DEFAULT_FORM_BUFFER_SIZE  0xFFFF
 
@@ -34,63 +56,299 @@ struct {
   CHAR16    *GuidName;
 }
 KnownGuids[] = {
-  &NullGuid,
-  L"G0",
-  &gEfiGlobalVariableGuid,
-  L"Efi",
-
-  &gEfiVariableStoreProtocolGuid,
-  L"varstore",
-  &gEfiDevicePathProtocolGuid,
-  L"dpath",
+  //
+  // Loaded Image
+  //
   &gEfiLoadedImageProtocolGuid,
-  L"image",
+  L"Image",
+  //
+  // Device Path
+  //
+  &gEfiDevicePathProtocolGuid,
+  L"Dpath",
+  &gEfiLoadedImageDevicePathProtocolGuid,
+  L"ImageDPath",
+  &gEfiDevicePathUtilitiesProtocolGuid,
+  L"DpathUtil",
+  &gEfiDevicePathToTextProtocolGuid,
+  L"DpathToText",
+  &gEfiDevicePathFromTextProtocolGuid,
+  L"DpathFromText",
+  &PcAnsiProtocol,
+  L"PcAnsi",
+  &Vt100Protocol,
+  L"Vt100",
+  &Vt100PlusProtocol,
+  L"Vt100+",
+  &VtUtf8Protocol,
+  L"VtUtf8",
+  //
+  // Driver Model
+  //
+  &gEfiDriverBindingProtocolGuid,
+  L"DriverBinding",
+  &gEfiPlatformDriverOverrideProtocolGuid,
+  L"PlatformOverride",
+  &gEfiBusSpecificDriverOverrideProtocolGuid,
+  L"BusSpecificDriverOverride",
+  &gEfiDriverDiagnosticsProtocolGuid,
+  L"Diagnostics",
+  &gEfiDriverDiagnostics2ProtocolGuid,
+  L"Diagnostics2",
+  &gEfiComponentNameProtocolGuid,
+  L"ComponentName",
+  &gEfiComponentName2ProtocolGuid,
+  L"ComponentName2",
+  &gEfiPlatformToDriverConfigurationProtocolGuid,
+  L"PlatformDriverConfig",
+  &gEfiDriverSupportedEfiVersionProtocolGuid,
+  L"DriverEFIVersion",
+  //
+  // Console Support
+  //
+  &gEfiSimpleTextInputExProtocolGuid,
+  L"TxtinEx",
   &gEfiSimpleTextInProtocolGuid,
-  L"txtin",
+  L"Txtin",
   &gEfiSimpleTextOutProtocolGuid,
-  L"txtout",
-  &gEfiBlockIoProtocolGuid,
-  L"blkio",
-  &gEfiDiskIoProtocolGuid,
-  L"diskio",
-  &gEfiSimpleFileSystemProtocolGuid,
-  L"fs",
+  L"Txtout",
+  &gEfiSimplePointerProtocolGuid,
+  L"SimplePointer",
+  &gEfiAbsolutePointerProtocolGuid,
+  L"AbsolutePointer",
+  &gEfiSerialIoProtocolGuid,
+  L"SerialIo",
+  &gEfiGraphicsOutputProtocolGuid,
+  L"GraphicsOutput",
+  &gEfiEdidDiscoveredProtocolGuid,
+  L"EdidDiscovered",
+  &gEfiEdidActiveProtocolGuid,
+  L"EdidActive",
+  &gEfiEdidOverrideProtocolGuid,
+  L"EdidOverride",
+  &gEfiConsoleInDeviceGuid,
+  L"ConIn",
+  &gEfiConsoleOutDeviceGuid,
+  L"ConOut",
+  &gEfiStandardErrorDeviceGuid,
+  L"StdErr",
+  //
+  // Media Access
+  //
   &gEfiLoadFileProtocolGuid,
-  L"load",
-  &gEfiDeviceIoProtocolGuid,
-  L"DevIo",
-
+  L"Load",
+  &gEfiSimpleFileSystemProtocolGuid,
+  L"Fs",
   &gEfiFileInfoGuid,
   L"GenFileInfo",
   &gEfiFileSystemInfoGuid,
   L"FileSysInfo",
-
+  &gEfiTapeIoProtocolGuid,
+  L"TapeIo",
+  &gEfiDiskIoProtocolGuid,
+  L"DiskIo",
+  &gEfiBlockIoProtocolGuid,
+  L"BlkIo",
   &gEfiUnicodeCollationProtocolGuid,
   L"UnicodeCollation",
-  &gEfiSerialIoProtocolGuid,
-  L"serialio",
+  &gEfiUnicodeCollation2ProtocolGuid,
+  L"UnicodeCollation2",
+  //
+  // PCI Bus Support
+  //
+  &gEfiPciRootBridgeIoProtocolGuid,
+  L"PciRootBridgeIo",
+  &gEfiPciIoProtocolGuid,
+  L"PciIo",
+  //
+  // SCSI Bus Support
+  //
+  &gEfiScsiPassThruProtocolGuid,
+  L"ScsiPassThru",
+  &gEfiScsiIoProtocolGuid,
+  L"ScsiIo",
+  &gEfiExtScsiPassThruProtocolGuid,
+  L"ExtScsiPassThru",
+  //
+  // iSCSI
+  //
+  &gEfiIScsiInitiatorNameProtocolGuid,
+  L"IScsiInitName",
+  //
+  // USB Support
+  //
+  &gEfiUsbIoProtocolGuid,
+  L"UsbIo",
+  &gEfiUsb2HcProtocolGuid,
+  L"UsbHc",
+  &gEfiUsb2HcProtocolGuid,
+  L"UsbHc2", 
+  //
+  // Debugger Support
+  //
+  &gEfiDebugSupportProtocolGuid,
+  L"DebugSupport",
+  &gEfiDebugPortDevicePathGuid,
+  L"DebugPort",
+  //
+  // Decompression Algorithm
+  //
+  &gEfiDecompressProtocolGuid,
+  L"Decompress",
+  //
+  // ACPI
+  //
+  &gEfiAcpiTableProtocolGuid,
+  L"AcpiTable",
+  // EBC
+  //
+  &gEfiEbcProtocolGuid,
+  L"EbcInterp",
+  //
+  // SNP, PXE, BIS
+  //
   &gEfiSimpleNetworkProtocolGuid,
-  L"net",
+  L"Net",
   &gEfiNetworkInterfaceIdentifierProtocolGuid,
-  L"nii",
+  L"Nii",
   &gEfiPxeBaseCodeProtocolGuid,
-  L"pxebc",
+  L"Pxebc",
   &gEfiPxeBaseCodeCallbackProtocolGuid,
-  L"pxecb",
-
-  &PcAnsiProtocol,
-  L"PcAnsi",
-  &Vt100Protocol,
-  L"Vt100",
-  &UnknownDeviceGuid,
-  L"Unknown Device",
+  L"PxebcCallback",
+  &gEfiBisProtocolGuid,
+  L"Bis",
+  //
+  // Managed Network
+  //
+  &gEfiManagedNetworkServiceBindingProtocolGuid,
+  L"MNPSb",
+  &gEfiManagedNetworkProtocolGuid,
+  L"MNP",
+  //
+  // ARP, DHCPv4
+  //
+  &gEfiArpServiceBindingProtocolGuid,
+  L"ARPSb",
+  &gEfiArpProtocolGuid,
+  L"ARP",
+  &gEfiDhcp4ServiceBindingProtocolGuid,
+  L"DHCPv4Sb",
+  &gEfiDhcp4ProtocolGuid,
+  L"DHCPv4",
+  //
+  // TCPv4, IPv4 and Configuration
+  //
+  &gEfiTcp4ServiceBindingProtocolGuid,
+  L"TCPv4Sb",
+  &gEfiTcp4ProtocolGuid,
+  L"TCPv4",
+  &gEfiIp4ServiceBindingProtocolGuid,
+  L"IPv4Sb",
+  &gEfiIp4ProtocolGuid,
+  L"IPv4",
+  &gEfiIp4ConfigProtocolGuid,
+  L"IPv4Config",
+  //
+  // UDPv4, MTFTPv4
+  //
+  &gEfiUdp4ServiceBindingProtocolGuid,
+  L"UDPv4Sb",
+  &gEfiUdp4ProtocolGuid,
+  L"UDPv4",
+  &gEfiMtftp4ServiceBindingProtocolGuid,
+  L"MTFTPv4Sb",
+  &gEfiMtftp4ProtocolGuid,
+  L"MTFTPv4",
+  //
+  // Security
+  //
+  &gEfiAuthenticationInfoProtocolGuid,
+  L"AuthInfo",
+  &gEfiHashServiceBindingProtocolGuid,
+  L"HashSb",
+  &gEfiHashProtocolGuid,
+  L"Hash",
+  //
+  // HII 
+  //
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+  &gEfiHiiFontProtocolGuid,
+  L"HiiFont",
+  &gEfiHiiStringProtocolGuid,
+  L"HiiString",
+  &gEfiHiiImageProtocolGuid,
+  L"HiiImage",
+  &gEfiHiiDatabaseProtocolGuid,
+  L"HiiDatabase",
+  //
+  // HII Configuration Processing and Browser
+  //
+  &gEfiHiiConfigRoutingProtocolGuid,
+  L"HiiConfRouting",
+  &gEfiHiiConfigAccessProtocolGuid,
+  L"HiiConfAccess",
+  &gEfiFormBrowser2ProtocolGuid,
+  L"FormBrowser2",
+#else
+  &gEfiHiiProtocolGuid,
+  L"Hii",
+  &gEfiFormBrowserProtocolGuid,
+  L"FormBrowser",
+  &gEfiFormCallbackProtocolGuid,
+  L"FormCallback",
+#endif
+  //
+  // Shell Specific
+  //
+  &NullGuid,
+  L"G0",
+  &ShellInterfaceProtocol,
+  L"ShellInt",
+  //
+  // Deprecated
+  //
+  &gEfiDeviceIoProtocolGuid,
+  L"DevIo",
+  &gEfiTcpProtocolGuid,
+  L"Tcp",
+  &gEfiUgaDrawProtocolGuid,
+  L"UgaDraw",
+  &gEfiUgaIoProtocolGuid,
+  L"UgaIo",
+  &gEfiGlobalVariableGuid,
+  L"Efi",
+  &gEfiFileSystemInfoGuid,
+  L"FileSysInfo",
   &gEfiPartTypeSystemPartGuid,
   L"ESP",
   &gEfiPartTypeLegacyMbrGuid,
   L"GPT MBR",
-
-  &ShellInterfaceProtocol,
-  L"ShellInt",
+  &gEfiDriverConfigurationProtocolGuid,
+  L"Configuration",
+  &gEfiDriverConfiguration2ProtocolGuid,
+  L"Configuration2",
+  &gEfiIsaIoProtocolGuid,
+  L"IsaIo",
+  &gEfiIsaAcpiProtocolGuid,
+  L"IsaAcpi",
+  //
+  // NT32
+  //
+#if (PLATFORM == NT32)
+  &WinNtThunkProtocolGuid,
+  L"WinNtThunk",
+  &WinNtIoProtocolGuid,
+  L"WinNtDriverIo",
+  &WinNtSerialPortGuid,
+  L"SerialPrivate",
+#endif
+  //
+  // Misc
+  //
+  &gEfiVariableStoreProtocolGuid,
+  L"varstore",
+  &UnknownDeviceGuid,
+  L"Unknown Device",
 
   NULL
 };
@@ -133,6 +391,34 @@ CHAR16        *ShellLibMemoryTypeDesc[EfiMaxMemoryType] = {
 
 CHAR8  ca[] = { 3, 1, 2 };
 
+VOID *
+LibGetVariableLang (
+  VOID
+  )
+/*++
+
+Routine Description:
+  Function returns the value of the Language Variable.
+
+Arguments:
+  None
+
+Returns:
+
+  None
+
+--*/
+{
+  VOID *Var;
+
+  Var = LibGetVariable (L"PlatformLang", &gEfiGlobalVariableGuid);
+  if (Var == NULL) {
+    Var = LibGetVariable (L"Lang", &gEfiGlobalVariableGuid);
+  }
+
+  return Var;
+}
+
 VOID *
 LibGetVariable (
   IN CHAR16               *Name,
@@ -472,6 +758,7 @@ Notes:
   }
 }
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 EFI_STATUS
 LibExtractDataFromHiiHandle (
   IN      EFI_HII_HANDLE      HiiHandle,
@@ -675,6 +962,8 @@ Returns:
   return Status;
 }
 
+#endif
+
 CHAR16 *
 MemoryTypeStr (
   IN EFI_MEMORY_TYPE  Type
@@ -1146,7 +1435,6 @@ Returns:
   EFI_STATUS                        Status;
   EFI_DEVICE_PATH_PROTOCOL          *DevPath;
   EFI_DEVICE_PATH_PROTOCOL          *DevPathNode;
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
   VOID                              *Buffer;
   UINTN                             BufferSize;
   UINT32                            AuthenticationStatus;
@@ -1173,7 +1461,6 @@ Returns:
     //
     NameGuid = GetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevPathNode);
     if (NameGuid != NULL) {
-      FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevPathNode;
       Status = BS->HandleProtocol (
                     Image->DeviceHandle,
                     &gEfiFirmwareVolumeProtocolGuid,
@@ -1182,7 +1469,7 @@ Returns:
       if (!EFI_ERROR (Status)) {
         Status = FV->ReadSection (
                       FV,
-                      &FvFilePath->NameGuid,
+                      NameGuid,
                       EFI_SECTION_USER_INTERFACE,
                       0,
                       &Buffer,
@@ -1203,7 +1490,7 @@ Returns:
         if (!EFI_ERROR (Status)) {
           Status = FV2->ReadSection (
                           FV2,
-                          &FvFilePath->NameGuid,
+                          NameGuid,
                           EFI_SECTION_USER_INTERFACE,
                           0,
                           &Buffer,
@@ -1283,17 +1570,23 @@ Returns:
 {
   EFI_STATUS        Status;
   UINTN             StringSize;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   EFI_HII_PROTOCOL  *HiiProt;
+#endif
 
   ASSERT (String);
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   Status = LibLocateProtocol (&gEfiHiiProtocolGuid, (VOID **) &HiiProt);
   if (EFI_ERROR (Status)) {
     return EFI_UNSUPPORTED;
   }
+#endif
 
   StringSize  = 0;
   *String     = NULL;
+
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   Status = HiiProt->GetString (
                       HiiProt,
                       HiiHandle,
@@ -1303,12 +1596,15 @@ Returns:
                       &StringSize,
                       *String
                       );
+#else
+  Status = LibGetString (HiiHandle, Token, *String, &StringSize);
+#endif
   if (EFI_BUFFER_TOO_SMALL == Status) {
     *String = AllocatePool (StringSize);
     if (NULL == *String) {
       return EFI_OUT_OF_RESOURCES;
     }
-
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
     Status = HiiProt->GetString (
                         HiiProt,
                         HiiHandle,
@@ -1318,6 +1614,9 @@ Returns:
                         &StringSize,
                         *String
                         );
+#else
+  Status = LibGetString (HiiHandle, Token, *String, &StringSize);
+#endif
   }
 
   return Status;
@@ -1907,9 +2206,9 @@ LibGetComponentNameProtocol (
 }
 
 CHAR8 *
-LibConvertComponentName2SupportLanguage (
-  IN EFI_COMPONENT_NAME2_PROTOCOL    *ComponentName,
-  IN CHAR8                           *Language
+LibConvertSupportedLanguage (
+  IN CHAR8                           *SupportedLanguages,
+  IN CHAR8                           *LangCode
   )
 /*++
 
@@ -1920,8 +2219,8 @@ LibConvertComponentName2SupportLanguage (
 
   Arguments:
 
-    ComponentName         - Pointer to the ComponentName2 protocl pointer.
-    Language              - The language string.
+    SupportedLanguages    - Pointer to SupportedLanguages of ComponentName2/ComponentName protocl.
+    LangCode              - The language code in variable "PlatformLang" or "Lang".
 
   Returns:
 
@@ -1930,46 +2229,45 @@ LibConvertComponentName2SupportLanguage (
 
 --*/
 {
-  CHAR8                              *SupportedLanguages;
-  CHAR8                              *LangCode;
+  CHAR8                              *Languages;
+  CHAR8                              *Lang;
   UINTN                              Index;
 
-  LangCode           = NULL;
-  SupportedLanguages = NULL;
+  Lang  = NULL;
+  Languages = NULL;
 
   //
   // treat all the english language code (en-xx or eng) equally
   //
-  if ((strncmpa(Language, "en-", 3) == 0) || (strcmpa(Language, "eng") == 0)) {
-    SupportedLanguages = strstra(ComponentName->SupportedLanguages, "en-");
-    if (SupportedLanguages == NULL) {
-      SupportedLanguages = strstra(ComponentName->SupportedLanguages, "eng");
+  if ((strncmpa(LangCode, "en-", 3) == 0) || (strcmpa(LangCode, "eng") == 0)) {
+    Languages = strstra(SupportedLanguages, "en-");
+    if (Languages == NULL) {
+      Languages = strstra(SupportedLanguages, "eng");
     }
   }
 
   //
-  // duplicate the Language if it is not english
+  // Return NULL if it is not english
   //
-  if (SupportedLanguages == NULL) {
-    SupportedLanguages = Language;
+  if (Languages == NULL) {
+    Languages = LangCode;
   }
 
   //
   // duplicate the returned language code.
   //
   if (strstra(SupportedLanguages, "-") != NULL) {
-    LangCode = AllocateZeroPool(32);
-    for(Index = 0; (Index < 31) && (SupportedLanguages[Index] != '\0') && (SupportedLanguages[Index] != ';'); Index++) {
-      LangCode[Index] = SupportedLanguages[Index];
+    Lang = AllocateZeroPool(32);
+    for(Index = 0; (Index < 31) && (Languages[Index] != '\0') && (Languages[Index] != ';'); Index++) {
+      Lang[Index] = Languages[Index];
     }
-    LangCode[Index] = '\0';
+    Lang[Index] = '\0';
   } else {
-    LangCode = AllocateZeroPool(4);
-    for(Index = 0; (Index < 3) && (SupportedLanguages[Index] != '\0'); Index++) {
-      LangCode[Index] = SupportedLanguages[Index];
+    Lang = AllocateZeroPool(4);
+    for(Index = 0; (Index < 3) && (Languages[Index] != '\0'); Index++) {
+      Lang[Index] = Languages[Index];
     }
-    LangCode[Index] = '\0';
+    Lang[Index] = '\0';
   }
-  return LangCode;
+  return Lang;
 }
-
index 7098222..25082c5 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -39,25 +39,14 @@ LibExtractDataFromHiiHandle (
   OUT     EFI_GUID            *Guid
   );
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 EFI_STATUS
 LibGetHiiInterface (
   OUT     EFI_HII_PROTOCOL    **Hii
   );
+#endif
 
-VOID                                  *
-LibGetVariable (
-  IN CHAR16               *Name,
-  IN EFI_GUID             *VendorGuid
-  );
-
-VOID                                  *
-LibGetVariableAndSize (
-  IN CHAR16               *Name,
-  IN EFI_GUID             *VendorGuid,
-  OUT UINTN               *VarSize
-  );
-
-void
+VOID
 ValueToHex (
   IN CHAR16   *Buffer,
   IN UINT64   v
@@ -114,6 +103,11 @@ LibMemoryMap (
   OUT UINT32                        *DescriptorVersion
   );
 
+VOID *
+LibGetVariableLang (
+  VOID
+  );
+
 VOID                              *
 LibGetVariable (
   IN CHAR16                         *Name,
index fddc8eb..8f6727e 100644 (file)
@@ -38,8 +38,7 @@ Revision History
 
 #define PING_MAX_BUFFER_SIZE    32768
 
-#define EFI_IP4(IpAddr)         (*(UINT32 *) ((IpAddr).Addr))
-#define EFI_IP4_EQUAL(Ip1, Ip2) (EFI_IP4(Ip1) == EFI_IP4(Ip2))
+#define EFI_IP4_EQUAL(Ip1, Ip2) (CompareMem (&(Ip1), &(Ip2), sizeof (EFI_IPv4_ADDRESS)) == 0)
 
 #pragma pack(1)
 typedef struct _EFI_ICMP_ECHO_REQUEST {
index 00df0a3..fee3558 100644 (file)
--- a/Shell.inf
+++ b/Shell.inf
@@ -43,6 +43,7 @@ COMPONENT_TYPE       = APPLICATION
   Library\Event.c
   Library\Perf.c
   Library\VarCheck.c
+  Library\HiiSupport.c  
 
   newshell\NshellStrings.uni
   newshell\init.c
index a843fca..832dc79 100644 (file)
@@ -43,6 +43,7 @@ COMPONENT_TYPE       = APPLICATION
   Library\Event.c
   Library\Perf.c
   Library\VarCheck.c
+  Library\HiiSupport.c
 
   newshell\NshellStrings.uni
   newshell\init.c
index 5b4b442..b13fd6b 100644 (file)
@@ -1,5 +1,5 @@
 /*++
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -63,6 +63,11 @@ typedef struct {
   SMBIOS_STRING BiosReleaseDate;
   UINT8         BiosSize;
   UINT64        BiosCharacteristics;
+  UINT8         BIOSCharacteristicsExtensionBytes[2];
+  UINT8         SystemBiosMajorRelease;
+  UINT8         SystemBiosMinorRelease;
+  UINT8         EmbeddedControllerFirmwareMajorRelease;
+  UINT8         EmbeddedControllerFirmwareMinorRelease;
 } SMBIOS_TYPE0;
 
 typedef struct {
@@ -73,6 +78,8 @@ typedef struct {
   SMBIOS_STRING SerialNumber;
   EFI_GUID      Uuid;
   UINT8         WakeUpType;
+  SMBIOS_STRING SKUNumber;
+  SMBIOS_STRING Family;
 } SMBIOS_TYPE1;
 
 typedef struct {
@@ -81,8 +88,21 @@ typedef struct {
   SMBIOS_STRING ProductName;
   SMBIOS_STRING Version;
   SMBIOS_STRING SerialNumber;
+  SMBIOS_STRING AssetTag;
+  UINT8         FeatureFlag;
+  SMBIOS_STRING LocationInChassis;
+  UINT16        ChassisHandle;
+  UINT8         BoardType;
+  UINT8         NumberOfContainedObjectHandles;
+  UINT16        ContainedObjectHandles[1];
 } SMBIOS_TYPE2;
 
+typedef struct {
+  UINT8         ContainedElementType;
+  UINT8         ContainedElementMinimum;
+  UINT8         ContainedElementMaximum;
+} CONTAINED_ELEMENT;
+
 typedef struct {
   SMBIOS_HEADER Hdr;
   SMBIOS_STRING Manufacturer;
@@ -95,6 +115,11 @@ typedef struct {
   UINT8         ThermalState;
   UINT8         SecurityStatus;
   UINT8         OemDefined[4];
+  UINT8         Height;
+  UINT8         NumberofPowerCords;
+  UINT8         ContainedElementCount;
+  UINT8         ContainedElementRecordLength;
+  CONTAINED_ELEMENT     ContainedElements[1];
 } SMBIOS_TYPE3;
 
 typedef struct {
@@ -117,6 +142,17 @@ typedef struct {
   SMBIOS_STRING SerialNumber;
   SMBIOS_STRING AssetTag;
   SMBIOS_STRING PartNumber;
+  //
+  // Add for smbios 2.5
+  //  
+  UINT8         CoreCount;
+  UINT8         EnabledCoreCount;
+  UINT8         ThreadCount;
+  UINT16        ProcessorCharacteristics;
+  //
+  // Add for smbios 2.6
+  //  
+  UINT16        ProcessorFamily2;
 } SMBIOS_TYPE4;
 
 typedef struct {
@@ -130,6 +166,7 @@ typedef struct {
   UINT16        SupportMemoryType;
   UINT8         MemoryModuleVoltage;
   UINT8         AssociatedMemorySlotNum;
+  UINT16        MemoryModuleConfigHandles[1];
 } SMBIOS_TYPE5;
 
 typedef struct {
@@ -176,6 +213,12 @@ typedef struct {
   UINT16        SlotID;
   UINT8         SlotCharacteristics1;
   UINT8         SlotCharacteristics2;
+  //
+  // Add for smbios 2.6
+  //  
+  UINT16        SegmentGroupNum;
+  UINT8         BusNum;
+  UINT8         DevFuncNum;  
 } SMBIOS_TYPE9;
 
 typedef struct DeviceStruct {
@@ -261,6 +304,10 @@ typedef struct {
   SMBIOS_STRING SerialNumber;
   SMBIOS_STRING AssetTag;
   SMBIOS_STRING PartNumber;
+  //
+  // Add for smbios 2.6
+  //    
+  UINT8         Attributes;
 } SMBIOS_TYPE17;
 
 typedef struct {
@@ -398,6 +445,13 @@ typedef struct {
 
 typedef struct {
   SMBIOS_HEADER Hdr;
+  UINT8                 Checksum;
+  UINT8                 Reserved1;
+  UINT16                Reserved2;
+  UINT32                BisEntry16;
+  UINT32                BisEntry32;
+  UINT64                Reserved3;
+  UINT32                Reserved4;
 } SMBIOS_TYPE31;
 
 typedef struct {
@@ -438,7 +492,7 @@ typedef struct {
   UINT16        LowerThresholdNonCritical;
   UINT16        UpperThresholdNonCritical;
   UINT16        LowerThresholdCritical;
-  UINT16        UpperThreaholdCritical;
+  UINT16        UpperThresholdCritical;
   UINT16        LowerThresholdNonRecoverable;
   UINT16        UpperThresholdNonRecoverable;
 } SMBIOS_TYPE36;
@@ -482,6 +536,33 @@ typedef struct {
   UINT16        InputCurrentProbeHandle;
 } SMBIOS_TYPE39;
 
+//
+// Add type 40 and type 41 for smbios 2.6
+//
+typedef struct {                       
+  UINT8                   EntryLength; 
+  UINT16                  ReferencedHandle;
+  UINT8                   ReferencedOffset;
+  SMBIOS_STRING           EntryString;
+  UINT8                   Value[1];
+} ADDITIONAL_INFORMATION_ENTRY;
+
+typedef struct {
+  SMBIOS_HEADER                   Hdr;
+  UINT8                           NumberOfAdditionalInformationEntries;
+  ADDITIONAL_INFORMATION_ENTRY    AdditionalInfoEntries[1];
+} SMBIOS_TYPE40;
+
+typedef struct {
+  SMBIOS_HEADER     Hdr;
+  SMBIOS_STRING     ReferenceDesignation;
+  UINT8             DeviceType;
+  UINT8             DeviceTypeInstance;
+  UINT16            SegmentGroupNum;
+  UINT8             BusNum;
+  UINT8             DevFuncNum;  
+} SMBIOS_TYPE41;
+
 typedef struct {
   SMBIOS_HEADER Hdr;
 } SMBIOS_TYPE126;
@@ -538,6 +619,8 @@ typedef union {
   SMBIOS_TYPE37   *Type37;
   SMBIOS_TYPE38   *Type38;
   SMBIOS_TYPE39   *Type39;
+  SMBIOS_TYPE40   *Type40;
+  SMBIOS_TYPE41   *Type41;
   SMBIOS_TYPE126  *Type126;
   SMBIOS_TYPE127  *Type127;
   UINT8           *Raw;
index 3833f37..819a4fd 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006 Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -47,6 +47,15 @@ Revision History
     APrint (": %a\n", StringBuf); \
   } while (0);
 
+#define PrintSmbiosString(pStruct, stringnumber, element) \
+  do { \
+    CHAR8 StringBuf[64]; \
+    SetMem (StringBuf, sizeof (StringBuf), 0x00); \
+    SmbiosGetPendingString ((pStruct), (stringnumber), StringBuf); \
+    APrint (#element); \
+    APrint (": %a\n", StringBuf); \
+  } while (0);
+
 #define PrintStructValue(pStruct, type, element) \
   do { \
     APrint (#element); \
@@ -67,6 +76,14 @@ Revision History
     DumpHex (0, 0, size, &(pStruct->type->element)); \
   } while (0);
 
+#define PrintSmbiosBitField(pStruct, startaddress, element, size) \
+  do { \
+    PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DUMP), HiiHandle); \
+    APrint (#element); \
+    PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SIZE), HiiHandle, size); \
+    DumpHex (0, 0, size, startaddress); \
+  } while (0);
+
 //
 /////////////////////////////////////////
 //
@@ -246,7 +263,7 @@ Returns:
     PrintPendingString (pStruct, Type0, BiosVersion);
     PrintStructValue (pStruct, Type0, BiosSegment);
     PrintPendingString (pStruct, Type0, BiosReleaseDate);
-    PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_SIZE), 64 * (pStruct->Type0->BiosSize + 1));
+    PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_BIOS_SIZE), HiiHandle, 64 * (pStruct->Type0->BiosSize + 1));
 
     if (Option < SHOW_DETAIL) {
       PrintStructValueH (pStruct, Type0, BiosCharacteristics);
@@ -325,7 +342,15 @@ Returns:
   case 4:
     PrintStructValue (pStruct, Type4, Socket);
     DisplayProcessorType (pStruct->Type4->ProcessorType, Option);
-    DisplayProcessorFamily (pStruct->Type4->ProcessorFamily, Option);
+    if ((SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x6)) && 
+        (pStruct->Type4->ProcessorFamily == 0xFE)) {
+      //
+      // Get family from ProcessorFamily2 field
+      //
+      DisplayProcessorFamily2 (pStruct->Type4->ProcessorFamily2, Option);
+    } else {
+      DisplayProcessorFamily (pStruct->Type4->ProcessorFamily, Option);
+    }
     PrintPendingString (pStruct, Type4, ProcessorManufacture);
     PrintBitField (pStruct, Type4, ProcessorId, 8);
     PrintPendingString (pStruct, Type4, ProcessorVersion);
@@ -341,6 +366,12 @@ Returns:
     PrintPendingString (pStruct, Type4, SerialNumber);
     PrintPendingString (pStruct, Type4, AssetTag);
     PrintPendingString (pStruct, Type4, PartNumber);
+    if (SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x5)) {
+      PrintStructValue (pStruct, Type4, CoreCount);
+      PrintStructValue (pStruct, Type4, EnabledCoreCount);
+      PrintStructValue (pStruct, Type4, ThreadCount);
+      PrintStructValueH (pStruct, Type4, ProcessorCharacteristics);
+    }
     break;
 
   //
@@ -431,6 +462,11 @@ Returns:
       );
     DisplaySlotCharacteristics1 (pStruct->Type9->SlotCharacteristics1, Option);
     DisplaySlotCharacteristics2 (pStruct->Type9->SlotCharacteristics2, Option);
+    if (SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x6)) {
+      PrintStructValueH (pStruct, Type9, SegmentGroupNum);
+      PrintStructValueH (pStruct, Type9, BusNum);
+      PrintStructValueH (pStruct, Type9, DevFuncNum);
+    }
     break;
 
   //
@@ -592,6 +628,9 @@ Returns:
     PrintPendingString (pStruct, Type17, SerialNumber);
     PrintPendingString (pStruct, Type17, AssetTag);
     PrintPendingString (pStruct, Type17, PartNumber);
+    if (SmbiosMajorVersion > 0x2 || (SmbiosMajorVersion == 0x2 && SmbiosMinorVersion >= 0x6)) { 
+      PrintStructValueH (pStruct, Type17, Attributes);
+    }
     break;
 
   //
@@ -791,7 +830,7 @@ Returns:
     PrintStructValueH (pStruct, Type36, LowerThresholdNonCritical);
     PrintStructValueH (pStruct, Type36, UpperThresholdNonCritical);
     PrintStructValueH (pStruct, Type36, LowerThresholdCritical);
-    PrintStructValueH (pStruct, Type36, UpperThreaholdCritical);
+    PrintStructValueH (pStruct, Type36, UpperThresholdCritical);
     PrintStructValueH (pStruct, Type36, LowerThresholdNonRecoverable);
     PrintStructValueH (pStruct, Type36, UpperThresholdNonRecoverable);
     break;
@@ -850,6 +889,45 @@ Returns:
     PrintStructValueH (pStruct, Type39, InputCurrentProbeHandle);
     break;
 
+  //
+  // Additional Information (Type 40)
+  //
+  case 40:
+    {
+      UINT8                          NumberOfEntries;
+      UINT8                          EntryLength;
+      ADDITIONAL_INFORMATION_ENTRY   *Entries;
+      
+      EntryLength     = 0;
+      Entries         = pStruct->Type40->AdditionalInfoEntries;
+      NumberOfEntries = pStruct->Type40->NumberOfAdditionalInformationEntries;
+    
+      PrintStructValueH (pStruct, Type40, NumberOfAdditionalInformationEntries);
+      
+      for (Index = 0; Index < NumberOfEntries; Index++) {
+        EntryLength = Entries->EntryLength;
+        PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_ENTRYLEN), HiiHandle, EntryLength);
+        PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_REFERENCEDHANDLE), HiiHandle, Entries->ReferencedHandle);
+        PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_REFERENCEDOFFSET), HiiHandle, Entries->ReferencedOffset);
+        PrintSmbiosString (pStruct, Entries->EntryString, String);
+        PrintSmbiosBitField (pStruct, Entries->Value, Value, EntryLength - 5);
+        Entries = (ADDITIONAL_INFORMATION_ENTRY *) ((UINT8 *)Entries + EntryLength);
+      }
+    }
+    break;
+    
+  //
+  // Onboard Devices Extended Information (Type 41)
+  //
+  case 41:   
+    PrintPendingString (pStruct, Type41, ReferenceDesignation);
+    PrintStructValueH (pStruct, Type41, DeviceType);
+    PrintStructValueH (pStruct, Type41, DeviceTypeInstance);
+    PrintStructValueH (pStruct, Type41, SegmentGroupNum);
+    PrintStructValueH (pStruct, Type41, BusNum);
+    PrintStructValueH (pStruct, Type41, DevFuncNum);
+    break;
+
   case 126:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_INACTIVE_STRUCT), HiiHandle);
     break;
@@ -1182,6 +1260,10 @@ DisplayProcessorFamily (
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_M1_FAMILY), HiiHandle);
     break;
 
+  case 0x18:
+    Print (L"AMD Duron\n");
+    break;
+
   case 0x19:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_K5_FAMILY), HiiHandle);
     break;
@@ -1206,18 +1288,110 @@ DisplayProcessorFamily (
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_POWER_PC_604), HiiHandle);
     break;
 
+  case 0x25:
+    Print (L"Power PC 620\n");
+    break;
+
+  case 0x26:
+    Print (L"Power PC 704\n");
+    break;
+
+  case 0x27:
+    Print (L"Power PC 750\n");
+    break;
+
   case 0x30:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ALPHA_FAMILY_2), HiiHandle);
     break;
 
+  case 0x31:
+    Print (L"Alpha 21064\n");
+    break;
+
+  case 0x32:
+    Print (L"Alpha 21066\n");
+    break;
+
+  case 0x33:
+    Print (L"Alpha 21164\n");
+    break;
+
+  case 0x34:
+    Print (L"Alpha 21164PC\n");
+    break;
+
+  case 0x35:
+    Print (L"Alpha 21164a\n");
+    break;
+
+  case 0x36:
+    Print (L"Alpha 21264\n");
+    break;
+
+  case 0x37:
+    Print (L"Alpha 21364\n");
+    break;
+
   case 0x40:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_MIPS_FAMILY), HiiHandle);
     break;
 
+  case 0x41:
+    Print (L"MIPS R4000\n");
+    break;
+
+  case 0x42:
+    Print (L"MIPS R4200\n");
+    break;
+
+  case 0x43:
+    Print (L"MIPS R4400\n");
+    break;
+
+  case 0x44:
+    Print (L"MIPS R4600\n");
+    break;
+
+  case 0x45:
+    Print (L"MIPS R10000\n");
+    break;
+
   case 0x50:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SPARC_FAMILY), HiiHandle);
     break;
 
+  case 0x51:
+    Print (L"SuperSparc\n");
+    break;
+
+  case 0x52:
+    Print (L"microSparc II\n");
+    break;
+
+  case 0x53:
+    Print (L"microSparc IIep\n");
+    break;
+
+  case 0x54:
+    Print (L"UltraSparc\n");
+    break;
+
+  case 0x55:
+    Print (L"UltraSparc II\n");
+    break;
+
+  case 0x56:
+    Print (L"UltraSparcIIi\n");
+    break;
+
+  case 0x57:
+    Print (L"UltraSparcIII\n");
+    break;
+
+  case 0x58:
+    Print (L"UltraSparcIIIi\n");
+    break;
+
   case 0x60:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_68040_FAMILY), HiiHandle);
     break;
@@ -1246,10 +1420,54 @@ DisplayProcessorFamily (
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_HOBBIT_FAMILY), HiiHandle);
     break;
 
+  case 0x78:
+    Print (L"Crusoe TM5000\n");
+    break;
+
+  case 0x79:
+    Print (L"Crusoe TM3000\n");
+    break;
+
+  case 0x7A:
+    Print (L"Efficeon TM8000\n");
+    break;
+
   case 0x80:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_WEITEK), HiiHandle);
     break;
 
+  case 0x82:
+    Print (L"Itanium\n");
+    break;
+
+  case 0x83:
+    Print (L"AMD Athlon64\n");
+    break;
+
+  case 0x84:
+    Print (L"AMD Opteron\n");
+    break;
+
+  case 0x85:
+    Print (L"AMD Sempron\n");
+    break;
+
+  case 0x86:
+    Print (L"AMD Turion64 Mobile\n");
+    break;
+
+  case 0x87:
+    Print (L"Dual-Core AMD Opteron\n");
+    break;
+
+  case 0x88:
+    Print (L"AMD Athlon 64X2 DualCore\n");
+    break;
+
+  case 0x89:
+    Print (L"AMD Turion 64X2 Mobile\n");
+    break;
+
   case 0x90:
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PA_RISC_FAMILY), HiiHandle);
     break;
@@ -1262,6 +1480,50 @@ DisplayProcessorFamily (
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PENTIUM_III_XEON), HiiHandle);
     break;
 
+  case 0xC8:
+    Print (L"IBM 390\n");
+    break;
+
+  case 0xC9:
+    Print (L"G4\n");
+    break;
+
+  case 0xCA:
+    Print (L"G5\n");
+    break;
+
+  case 0xCB:
+    Print (L"G6\n");
+    break;
+
+  case 0xCC:
+    Print (L"zArchitectur\n");
+    break;
+
+  case 0xD2:
+    Print (L"ViaC7M\n");
+    break;
+
+  case 0xD3:
+    Print (L"ViaC7D\n");
+    break;
+
+  case 0xD4:
+    Print (L"ViaC7\n");
+    break;
+
+  case 0xD5:
+    Print (L"Eden\n");
+    break;
+
+  case 0xFA:
+    Print (L"i860\n");
+    break;
+
+  case 0xFB:
+    Print (L"i960\n");
+    break;
+
   default:
     //
     // In order to reduce code quality notice of
@@ -1269,7 +1531,7 @@ DisplayProcessorFamily (
     // move multiple case into the else part and
     // use if/else to check value.
     //
-    if (Family >= 0x13 && Family <= 0x18) {
+    if (Family >= 0x13 && Family <= 0x17) {
       PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FOR_SPEC_M1), HiiHandle);
     } else if (Family >= 0x1A && Family <= 0x1F) {
       PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_RSVD_FOR_SPEC_K5), HiiHandle);
@@ -1284,6 +1546,72 @@ DisplayProcessorFamily (
   //
 }
 
+VOID
+DisplayProcessorFamily2 (
+  UINT16 Family2,
+  UINT8  Option
+  )
+{
+  //
+  // Print prompt message
+  //
+  PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_PROCESSOR_FAMILY), HiiHandle);
+  
+  //
+  // Print option
+  //
+  PRINT_INFO_OPTION (Family2, Option);
+
+  //
+  // Use switch to check
+  //
+  switch (Family2) {
+    case 0x104:
+      Print (L"SH-3\n");
+      break;
+    
+    case 0x105:
+      Print (L"SH-4\n");
+      break;
+      
+    case 0x118:
+      Print (L"ARM\n");
+      break;
+
+    case 0x119:
+      Print (L"StrongARM\n");
+      break; 
+
+    case 0x12C:
+      Print (L"6x86\n");
+      break;
+
+    case 0x12D:
+      Print (L"MediaGX\n");
+      break;
+    case 0x12E:
+      Print (L"MII\n");
+      break; 
+      
+    case 0x140:
+      Print (L"WinChip\n");
+      break;
+
+    case 0x15E:
+      Print (L"DSP\n");
+      break;
+
+    case 0x1F4:
+      Print (L"Video Processor\n");
+      break;
+    
+    default:
+     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_UNDEFINED_PROC_FAMILY), HiiHandle);
+  }
+  
+}
+
 VOID
 DisplayProcessorVoltage (
   UINT8 Voltage,
index a3f9c59..608dfb1 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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,9 @@ Revision History
 
 #include "LibSmbios.h"
 
+extern UINT8  SmbiosMajorVersion;
+extern UINT8  SmbiosMinorVersion;
+
 #define SHOW_NONE     0x00
 #define SHOW_OUTLINE  0x01
 #define SHOW_NORMAL   0x02
@@ -79,6 +82,13 @@ DisplayProcessorFamily (
   UINT8 Family,
   UINT8 Option
   );
+
+VOID
+DisplayProcessorFamily2 (
+  UINT16 Family2,
+  UINT8  Option
+  );  
+  
 VOID
 DisplayProcessorVoltage (
   UINT8 Voltage,
index 1030648..0f226fb 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006 Intel Corporation                                                         
+Copyright (c) 2005 - 2007 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         
@@ -159,6 +159,26 @@ TABLE_ITEM  SystemEnclosureTypeTable[] = {
     0x18,
     L"  Sealed-case PC"
   },
+  {
+    0x19,
+    L"  Multi-system Chassis"
+  },
+  {
+    0x1A,
+    L"  CompactPCI"
+  },
+  {
+    0x1B,
+    L"  AdvancedTCA"
+  },
+  {
+    0x1C,
+    L"  Blade"
+  }, 
+  {
+    0x1D,
+    L"  Blade Enclosure"
+  },
 };
 
 TABLE_ITEM  SystemEnclosureStatusTable[] = {
@@ -767,6 +787,10 @@ TABLE_ITEM  PortConnectorTypeTable[] = {
     0x21,
     L"1394"
   },
+  {
+    0x22,
+    L"SAS/SATA Plug Receptacle"
+  },  
   {
     0xA0,
     L"PC-98"
@@ -922,6 +946,14 @@ TABLE_ITEM  PortTypeTable[] = {
     0x1F,
     L"Network Port"
   },
+  {
+    0x20,
+    L"SATA Port"
+  },
+  {
+    0x21,
+    L"SAS Port"
+  },      
   {
     0xA0,
     L"8251 Compatible"
@@ -1033,6 +1065,26 @@ TABLE_ITEM  SystemSlotTypeTable[] = {
     0xA5,
     L"PCI Express "
   },
+  {
+    0xA6,
+    L"PCI Express X1"
+  },
+  {
+    0xA7,
+    L"PCI Express X2"
+  },
+  {
+    0xA8,
+    L"PCI Express X4"
+  },
+  {
+    0xA9,
+    L"PCI Express X8"
+  },
+  {
+    0xAA,
+    L"PCI Express X16"
+  },    
 };
 
 TABLE_ITEM  SystemSlotDataBusWidthTable[] = {
@@ -1184,6 +1236,18 @@ TABLE_ITEM  OnboardDeviceTypesTable[] = {
     0x07,
     L"  Sound"
   },
+  {
+    0x08,
+    L"  Pata Controller"
+  },
+  {
+    0x09,
+    L"  Sata Controller"
+  },
+  {
+    0x0A,
+    L"  Sas Controller"
+  },         
 };
 
 TABLE_ITEM  SELTypesTable[] = {
index d7e89c3..3a8e004 100644 (file)
Binary files a/SmbiosView/SmBiosViewStrings.uni and b/SmbiosView/SmBiosViewStrings.uni differ
index b19de03..13b4fb7 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -39,6 +39,9 @@ UINT8                       gShowType         = SHOW_DETAIL;
 STATIC STRUCTURE_STATISTICS *mStatisticsTable = NULL;
 STATIC EFI_HANDLE           *mMyImageHandle   = NULL;
 
+UINT8  SmbiosMajorVersion;
+UINT8  SmbiosMinorVersion;
+
 //
 // Global Variables
 //
@@ -330,6 +333,9 @@ SMBiosView (
     // Have get SMBIOS table
     //
     SmbiosPrintEPSInfo (SMBiosTable, Option);
+    
+    SmbiosMajorVersion = SMBiosTable->MajorVersion;
+    SmbiosMinorVersion = SMBiosTable->MinorVersion;
 
     Print (L"=========================================================\n");
     PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_QUERY_STRUCT_COND), HiiHandle);
index 8c2c6a3..7d5d4ba 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -113,6 +113,7 @@ Returns:
   EFI_STATUS              ConfigurationStatus;
   EFI_STATUS              DiagnosticsStatus;
   UINTN                   StringIndex;
+  UINTN                   StringLength;
   UINTN                   Index;
   CHAR8                   *Language;
   UINTN                   DeviceHandleCount;
@@ -160,7 +161,7 @@ Returns:
   // Setup Handle and Protocol Globals
   //
   ShellInitProtocolInfoEnumerator ();
-  Language = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language = LibGetVariableLang ();
 
   if (Language == NULL) {
     Language    = AllocatePool (4);
@@ -222,13 +223,13 @@ Returns:
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item != NULL) {
-    if (StrLen (Item->VarStr) != 3) {
-      PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEVICES_BAD_LANG), HiiHandle, L"devices", Item->VarStr);
-      Status = EFI_INVALID_PARAMETER;
-      goto Done;
+    if (Language != NULL) {
+      FreePool (Language);
     }
 
-    for (StringIndex = 0; StringIndex < 3; StringIndex++) {
+    StringLength = StrLen (Item->VarStr);
+    Language = AllocatePool (StringLength + 1);
+    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
       Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
     }
 
@@ -374,6 +375,8 @@ Returns:
 
   FreePool (DeviceHandleBuffer);
 
+  Status = EFI_SUCCESS;
+
 Done:
   if (Language != NULL) {
     FreePool (Language);
@@ -435,6 +438,7 @@ Returns:
   EFI_STATUS  DiagnosticsStatus;
   CHAR16      *Ptr;
   UINTN       StringIndex;
+  UINTN       StringLength;
   UINTN       Index;
   CHAR8       *Language;
   UINTN       DeviceHandleCount;
@@ -449,7 +453,7 @@ Returns:
   BOOLEAN     PrtHelp;
 
   PrtHelp   = FALSE;
-  Language  = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language  = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -465,7 +469,13 @@ Returns:
       case 'l':
       case 'L':
         if (*(Ptr + 2) != 0) {
-          for (StringIndex = 0; StringIndex < 3 && Ptr[StringIndex + 2] != 0; StringIndex++) {
+          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];
           }
 
index 8764f40..2e26d03 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -24,6 +24,7 @@ Revision History
 --*/
 
 #include "EfiShellLib.h"
+#include "EfiVariable.h"
 #include "dmpstore.h"
 
 extern UINT8  STRING_ARRAY_NAME[];
@@ -33,10 +34,7 @@ extern UINT8  STRING_ARRAY_NAME[];
 //
 #include STRING_DEFINES_FILE
 
-//
-// DEBUG_NAME_SIZE > MAX_VARIABLE_SIZE
-//
-#define DEBUG_NAME_SIZE 1050
+#define DEBUG_NAME_SIZE MAX_VARIABLE_SIZE
 
 STATIC CHAR16   *AttrType[] = {
   L"invalid",   // 000
index 71e675c..157dd18 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -29,7 +29,9 @@ Revision History
 #include EFI_PROTOCOL_DEFINITION (ComponentName)
 #include EFI_PROTOCOL_DEFINITION (ComponentName2)
 #include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration2)
 #include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2)
 
 extern UINT8  STRING_ARRAY_NAME[];
 
@@ -239,7 +241,7 @@ Returns:
       goto Done;
     }
 
-    Language = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+    Language = LibGetVariableLang ();
     if (Language == NULL) {
       Language = (CHAR8 *)AllocateZeroPool(strlena(LanguageCodeEnglish) + 1);
       if (Language == NULL) {
@@ -322,21 +324,41 @@ Returns:
 
     DiagnosticsStatus = BS->OpenProtocol (
                               DriverImageHandleBuffer[Index],
-                              &gEfiDriverDiagnosticsProtocolGuid,
+                              &gEfiDriverDiagnostics2ProtocolGuid,
                               NULL,
                               NULL,
                               NULL,
                               EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                               );
+    if (EFI_ERROR (DiagnosticsStatus)) {
+      DiagnosticsStatus = BS->OpenProtocol (
+                                DriverImageHandleBuffer[Index],
+                                &gEfiDriverDiagnosticsProtocolGuid,
+                                NULL,
+                                NULL,
+                                NULL,
+                                EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                                );
+    }
 
     ConfigurationStatus = BS->OpenProtocol (
                                 DriverImageHandleBuffer[Index],
-                                &gEfiDriverConfigurationProtocolGuid,
+                                &gEfiDriverConfiguration2ProtocolGuid,
                                 NULL,
                                 NULL,
                                 NULL,
                                 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                                 );
+    if (EFI_ERROR (ConfigurationStatus)) {
+      ConfigurationStatus = BS->OpenProtocol (
+                                  DriverImageHandleBuffer[Index],
+                                  &gEfiDriverConfigurationProtocolGuid,
+                                  NULL,
+                                  NULL,
+                                  NULL,
+                                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                                  );
+    }
 
     NumberOfChildren = 0;
     Status = LibGetManagedControllerHandles (
@@ -399,25 +421,30 @@ Returns:
 
     Status     = EFI_SUCCESS;
     DriverName = L"<UNKNOWN>";
+    SupportedLanguage = NULL;
     if (ComponentName != NULL) {
       if (ComponentName->GetDriverName != NULL) {
+        SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
         Status = ComponentName->GetDriverName (
                                   ComponentName,
-                                  Language,
+                                  SupportedLanguage,
                                   &DriverName
                                   );
       }
     } else if (ComponentName2 != NULL) {
       if (ComponentName2->GetDriverName != NULL) {
-        SupportedLanguage = LibConvertComponentName2SupportLanguage (ComponentName2, Language);
+        SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
         Status = ComponentName2->GetDriverName (
                                    ComponentName2,
                                    SupportedLanguage,
                                    &DriverName
                                    );
-        FreePool(SupportedLanguage);
       }
     }
+    if (SupportedLanguage != NULL) {
+      FreePool (SupportedLanguage);
+    }
+
     if (EFI_ERROR (Status)) {
       DriverName = L"<UNKNOWN>";
     }
@@ -507,9 +534,10 @@ DriversSyntaxOld (
   EFI_STATUS  Status;
   UINTN       Index;
   UINTN       StringIndex;
+  UINTN       StringLength;
   CHAR16      *Ptr;
 
-  *Language = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  *Language = LibGetVariableLang ();
   if (*Language == NULL) {
     *Language       = AllocatePool (4);
     (*Language)[0]  = 'e';
@@ -525,7 +553,13 @@ DriversSyntaxOld (
       case 'l':
       case 'L':
         if (*(Ptr + 2) != 0) {
-          for (StringIndex = 0; StringIndex < 3 && Ptr[StringIndex + 2] != 0; StringIndex++) {
+          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;
index b980711..07121dd 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -136,6 +136,7 @@ Returns:
   EFI_HANDLE                                DeviceHandle;
   EFI_HANDLE                                ChildHandle;
   UINTN                                     StringIndex;
+  UINTN                                     StringLength;
   UINTN                                     Index;
   CHAR8                                     *Language;
   CHAR8                                     *SupportedLanguages;
@@ -256,7 +257,7 @@ Returns:
   //
   // Setup Handle and Protocol Globals
   //
-  Language = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -267,13 +268,13 @@ Returns:
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (StrLen (Item->VarStr) != 3) {
-      PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_BAD_LANG), HiiHandle, L"drvcfg", Item->VarStr);
-      Status = EFI_INVALID_PARAMETER;
-      goto Done;
+    if (Language != NULL) {
+      FreePool (Language);
     }
 
-    for (StringIndex = 0; StringIndex < 3; StringIndex++) {
+    StringLength = StrLen (Item->VarStr);
+    Language = AllocatePool (StringLength + 1);
+    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
       Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
     }
 
@@ -381,11 +382,21 @@ Returns:
   if (DriverImageHandle == NULL) {
     Status = LibLocateHandle (
               ByProtocol,
-              &gEfiDriverConfigurationProtocolGuid,
+              &gEfiDriverConfiguration2ProtocolGuid,
               NULL,
               &DriverImageHandleCount,
               &DriverImageHandleBuffer
               );
+
+    if (EFI_ERROR (Status)) {
+      Status = LibLocateHandle (
+                ByProtocol,
+                &gEfiDriverConfigurationProtocolGuid,
+                NULL,
+                &DriverImageHandleCount,
+                &DriverImageHandleBuffer
+                );
+    }
     if (EFI_ERROR (Status)) {
       Status = EFI_NOT_FOUND;
       goto Done;
@@ -406,12 +417,22 @@ Returns:
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
-                  &gEfiDriverConfigurationProtocolGuid,
+                  &gEfiDriverConfiguration2ProtocolGuid,
                   (VOID **) &DriverConfiguration,
                   NULL,
                   NULL,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
+    if (EFI_ERROR (Status)) {
+      Status = BS->OpenProtocol (
+                    DriverImageHandleBuffer[Index],
+                    &gEfiDriverConfigurationProtocolGuid,
+                    (VOID **) &DriverConfiguration,
+                    NULL,
+                    NULL,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    }
     if (EFI_ERROR (Status)) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_NOT_SUPPORT_PROT),
@@ -422,13 +443,17 @@ Returns:
     }
 
     Status = EFI_NOT_FOUND;
-    for (SupportedLanguages = DriverConfiguration->SupportedLanguages;
-         SupportedLanguages[0] != 0;
-         SupportedLanguages += 3
-        ) {
-      if (CompareMem (SupportedLanguages, Language, 3) == 0) {
+    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)) {
@@ -818,6 +843,7 @@ Returns:
   EFI_HANDLE                                DeviceHandle;
   EFI_HANDLE                                ChildHandle;
   UINTN                                     StringIndex;
+  UINTN                                     StringLength;
   UINTN                                     Index;
   CHAR8                                     *Language;
   CHAR8                                     *SupportedLanguages;
@@ -855,7 +881,7 @@ Returns:
   DriverImageHandleBuffer = NULL;
   GetHelp                 = FALSE;
 
-  Language                = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language                = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -871,7 +897,13 @@ Returns:
       case 'l':
       case 'L':
         if (*(Ptr + 2) != 0) {
-          for (StringIndex = 0; StringIndex < 3 && Ptr[StringIndex + 2] != 0; StringIndex++) {
+          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];
           }
 
@@ -979,11 +1011,21 @@ Returns:
   if (DriverImageHandle == NULL) {
     Status = LibLocateHandle (
               ByProtocol,
-              &gEfiDriverConfigurationProtocolGuid,
+              &gEfiDriverConfiguration2ProtocolGuid,
               NULL,
               &DriverImageHandleCount,
               &DriverImageHandleBuffer
               );
+
+    if (EFI_ERROR (Status)) {
+      Status = LibLocateHandle (
+                ByProtocol,
+                &gEfiDriverConfigurationProtocolGuid,
+                NULL,
+                &DriverImageHandleCount,
+                &DriverImageHandleBuffer
+                );
+    }
     if (EFI_ERROR (Status)) {
       Status = EFI_NOT_FOUND;
       goto Done;
@@ -1004,12 +1046,22 @@ Returns:
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
-                  &gEfiDriverConfigurationProtocolGuid,
+                  &gEfiDriverConfiguration2ProtocolGuid,
                   (VOID **) &DriverConfiguration,
                   NULL,
                   NULL,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
+    if (EFI_ERROR (Status)) {
+      Status = BS->OpenProtocol (
+                    DriverImageHandleBuffer[Index],
+                    &gEfiDriverConfigurationProtocolGuid,
+                    (VOID **) &DriverConfiguration,
+                    NULL,
+                    NULL,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    }
     if (EFI_ERROR (Status)) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_NOT_SUPPORT_PROT),
@@ -1020,13 +1072,17 @@ Returns:
     }
 
     Status = EFI_NOT_FOUND;
-    for (SupportedLanguages = DriverConfiguration->SupportedLanguages;
-         SupportedLanguages[0] != 0;
-         SupportedLanguages += 3
-        ) {
-      if (CompareMem (SupportedLanguages, Language, 3) == 0) {
+    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)) {
index 1eb7d3e..3846266 100644 (file)
@@ -1,6 +1,6 @@
 /*++
  
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -28,6 +28,7 @@ Revision History
 
 #include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
 #include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2)
 #include EFI_PROTOCOL_DEFINITION (DriverBinding)
 
 extern UINT8  STRING_ARRAY_NAME[];
@@ -152,6 +153,7 @@ Returns:
   EFI_HANDLE                      DeviceHandle;
   EFI_HANDLE                      ChildHandle;
   UINTN                           StringIndex;
+  UINTN                           StringLength;
   UINTN                           Index;
   CHAR8                           *Language;
   CHAR8                           *SupportedLanguages;
@@ -266,7 +268,7 @@ Returns:
   //
   // Setup Handle and Protocol Globals
   //
-  Language = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -277,13 +279,13 @@ Returns:
 
   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
   if (Item) {
-    if (StrLen (Item->VarStr) != 3) {
-      PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DRVDIAG_BAD_LANG), HiiHandle, L"drvdiag", Item->VarStr);
-      Status = EFI_INVALID_PARAMETER;
-      goto Done;
+    if (Language != NULL) {
+      FreePool (Language);
     }
 
-    for (StringIndex = 0; StringIndex < 3; StringIndex++) {
+    StringLength = StrLen (Item->VarStr);
+    Language = AllocatePool (StringLength + 1);
+    for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
       Language[StringIndex] = (CHAR8) Item->VarStr[StringIndex];
     }
 
@@ -379,11 +381,22 @@ Returns:
   if (DriverImageHandle == NULL) {
     Status = LibLocateHandle (
               ByProtocol,
-              &gEfiDriverDiagnosticsProtocolGuid,
+              &gEfiDriverDiagnostics2ProtocolGuid,
               NULL,
               &DriverImageHandleCount,
               &DriverImageHandleBuffer
               );
+
+    if (EFI_ERROR (Status)) {
+      Status = LibLocateHandle (
+                ByProtocol,
+                &gEfiDriverDiagnosticsProtocolGuid,
+                NULL,
+                &DriverImageHandleCount,
+                &DriverImageHandleBuffer
+                );
+    }
+
     if (EFI_ERROR (Status)) {
       Status = EFI_NOT_FOUND;
       goto Done;
@@ -403,12 +416,23 @@ Returns:
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
-                  &gEfiDriverDiagnosticsProtocolGuid,
+                  &gEfiDriverDiagnostics2ProtocolGuid,
                   (VOID **) &DriverDiagnostics,
                   NULL,
                   NULL,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
+    if (EFI_ERROR (Status)) {
+      Status = BS->OpenProtocol (
+                    DriverImageHandleBuffer[Index],
+                    &gEfiDriverDiagnosticsProtocolGuid,
+                    (VOID **) &DriverDiagnostics,
+                    NULL,
+                    NULL,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    }
+
     if (EFI_ERROR (Status)) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVDIAG_HANDLE_NOT_SUPPORT_PROT),
@@ -429,13 +453,17 @@ Returns:
       );
 
     Status = EFI_NOT_FOUND;
-    for (SupportedLanguages = DriverDiagnostics->SupportedLanguages;
-         SupportedLanguages[0] != 0;
-         SupportedLanguages += 3
-        ) {
-      if (CompareMem (SupportedLanguages, Language, 3) == 0) {
+    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)) {
@@ -683,6 +711,7 @@ Returns:
   EFI_HANDLE                      DeviceHandle;
   EFI_HANDLE                      ChildHandle;
   UINTN                           StringIndex;
+  UINTN                           StringLength;
   UINTN                           Index;
   CHAR8                           *Language;
   CHAR8                           *SupportedLanguages;
@@ -715,7 +744,7 @@ Returns:
   DriverImageHandleBuffer = NULL;
   GetHelp                 = FALSE;
 
-  Language                = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language                = LibGetVariableLang ();
   if (Language == NULL) {
     Language    = AllocatePool (4);
     Language[0] = 'e';
@@ -731,7 +760,13 @@ Returns:
       case 'l':
       case 'L':
         if (*(Ptr + 2) != 0) {
-          for (StringIndex = 0; StringIndex < 3 && Ptr[StringIndex + 2] != 0; StringIndex++) {
+          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];
           }
 
@@ -815,11 +850,21 @@ Returns:
   if (DriverImageHandle == NULL) {
     Status = LibLocateHandle (
               ByProtocol,
-              &gEfiDriverDiagnosticsProtocolGuid,
+              &gEfiDriverDiagnostics2ProtocolGuid,
               NULL,
               &DriverImageHandleCount,
               &DriverImageHandleBuffer
               );
+
+    if (EFI_ERROR (Status)) {
+      Status = LibLocateHandle (
+                ByProtocol,
+                &gEfiDriverDiagnosticsProtocolGuid,
+                NULL,
+                &DriverImageHandleCount,
+                &DriverImageHandleBuffer
+                );
+    }
     if (EFI_ERROR (Status)) {
       Status = EFI_NOT_FOUND;
       goto Done;
@@ -838,12 +883,22 @@ Returns:
   for (Index = 0; Index < DriverImageHandleCount; Index++) {
     Status = BS->OpenProtocol (
                   DriverImageHandleBuffer[Index],
-                  &gEfiDriverDiagnosticsProtocolGuid,
+                  &gEfiDriverDiagnostics2ProtocolGuid,
                   (VOID **) &DriverDiagnostics,
                   NULL,
                   NULL,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   );
+    if (EFI_ERROR (Status)) {
+      Status = BS->OpenProtocol (
+                    DriverImageHandleBuffer[Index],
+                    &gEfiDriverDiagnosticsProtocolGuid,
+                    (VOID **) &DriverDiagnostics,
+                    NULL,
+                    NULL,
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                    );
+    }
     if (EFI_ERROR (Status)) {
       PrintToken (
         STRING_TOKEN (STR_SHELLENV_PROTID_DRVDIAG_HANDLE_NOT_SUPPORT_PROT),
@@ -854,13 +909,17 @@ Returns:
     }
 
     Status = EFI_NOT_FOUND;
-    for (SupportedLanguages = DriverDiagnostics->SupportedLanguages;
-         SupportedLanguages[0] != 0;
-         SupportedLanguages += 3
-        ) {
-      if (CompareMem (SupportedLanguages, Language, 3) == 0) {
+    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)) {
index 8b67e0e..c18db6a 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -9,11 +9,11 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
 
-  Module Name: 
-    Editor.h
+Module Name: 
+  Editor.h
 
-  Abstract:
-    Main include file for text editor
+Abstract:
+  Main include file for text editor
 
 --*/
 
@@ -44,6 +44,8 @@ extern BOOLEAN                  EditorFirst;
 extern BOOLEAN                  EditorExit;
 
 extern EFI_HII_HANDLE           HiiHandle;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 extern EFI_HII_PROTOCOL         *Hii;
+#endif
 
 #endif // _EFI_EDITOR_H_
index 32e5c05..8fe612c 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -9,11 +9,11 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
 
-  Module Name:
-    libMenuBar.c
+Module Name:
+  libMenuBar.c
 
-  Abstract:
-    Definition of the Menu Bar for the text editor
+Abstract:
+  Definition of the Menu Bar for the text editor
 
 --*/
 
@@ -219,7 +219,11 @@ MainMenuBarRefresh (
     NameString        = AllocatePool (BufferSize);
     FunctionKeyString = AllocatePool (BufferSize);
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
     Status            = Hii->GetString (Hii, HiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
+#else
+    Status            = LibGetString (HiiHandle, Item->NameToken, NameString, &BufferSize);
+#endif
 
     Width             = max ((StrLen (NameString) + 6), 20);
     if (((Col + Width) > MAX_TEXT_COLUMNS)) {
@@ -227,7 +231,11 @@ MainMenuBarRefresh (
       Col = 1;
     }
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
     Status = Hii->GetString (Hii, HiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
+#else
+    Status = LibGetString (HiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
+#endif    
     PrintAt (Col - 1, Row - 1, L"%E%s%N  %H%s%N  ", FunctionKeyString, NameString);
 
     FreePool (NameString);
index 6c8a2ec..5322e53 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -9,10 +9,10 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
 
-  Module Name:
-    main.c
+Module Name:
+  main.c
 
-  Abstract:
+Abstract:
      
 
 --*/
@@ -35,7 +35,9 @@ EFI_BOOTSHELL_CODE(
 // Global Variables
 //
 EFI_HII_HANDLE    HiiHandle;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 EFI_HII_PROTOCOL  *Hii;
+#endif
 EFI_GUID          EfiEditGuid = EFI_EDIT_GUID;
 SHELL_VAR_CHECK_ITEM    EditCheckList[] = {
   {
@@ -115,6 +117,7 @@ Returns:
   // Register our string package with HII and return the handle to it.
   // If previously registered we will simply receive the handle
   //
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   //
   // There should only be one HII protocol
   //
@@ -122,6 +125,7 @@ Returns:
   if (EFI_ERROR (Status) || NULL == Hii) {
     return EFI_ABORTED;
   }
+#endif
 
   Status = LibInitializeStrings (&HiiHandle, STRING_ARRAY_NAME, &EfiEditGuid);
 
index b66fdae..09196d6 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -9,11 +9,11 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
 
-  Module Name:
-    HEditor.h
+Module Name:
+  HEditor.h
 
-  Abstract:
-    Main include file for hex editor
+Abstract:
+  Main include file for hex editor
 
 --*/
 
@@ -53,6 +53,8 @@ extern BOOLEAN                    HEditorFirst;
 extern BOOLEAN                    HEditorExit;
 
 extern EFI_HII_HANDLE             HiiHandle;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 extern EFI_HII_PROTOCOL           *Hii;
+#endif
 
 #endif // _HEDITOR_H
index 99ab564..5ecb694 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -9,10 +9,10 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
 
-  Module Name:
+Module Name:
   libMenuBar.c
 
-  Abstract:
+Abstract:
   Definition of the Menu Bar for the text editor
 
 --*/
@@ -254,7 +254,11 @@ Returns:
     NameString        = AllocatePool (BufferSize);
     FunctionKeyString = AllocatePool (BufferSize);
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
     Status            = Hii->GetString (Hii, HiiHandle, Item->NameToken, FALSE, NULL, &BufferSize, NameString);
+#else
+    Status            = LibGetString (HiiHandle, Item->NameToken, NameString, &BufferSize);
+#endif
 
     Width             = max ((StrLen (NameString) + 6), 18);
     if (((Col + Width) > MAX_TEXT_COLUMNS)) {
@@ -262,8 +266,11 @@ Returns:
       Col = 1;
     }
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
     Status = Hii->GetString (Hii, HiiHandle, Item->FunctionKeyToken, FALSE, NULL, &BufferSize, FunctionKeyString);
-
+#else
+    Status = LibGetString (HiiHandle, Item->FunctionKeyToken, FunctionKeyString, &BufferSize);
+#endif
     if (Index >= 10) {
       PrintAt (Col - 1, Row - 1, L"%E%s%N %H%s%N  ", FunctionKeyString, NameString);
     } else {
index 879d531..12943b2 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -9,10 +9,10 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
 
-  Module Name:
+Module Name:
   main.c
 
-  Abstract:
+Abstract:
   Main entry point of editor
   
 
@@ -27,7 +27,9 @@ extern UINT8      STRING_ARRAY_NAME[];
 // Global Variables
 //
 EFI_HII_HANDLE    HiiHandle;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
 EFI_HII_PROTOCOL  *Hii;
+#endif
 EFI_GUID          EfiHexeditGuid = EFI_HEXEDIT_GUID;
 SHELL_VAR_CHECK_ITEM    HexeditCheckList[] = {
   {
@@ -143,10 +145,14 @@ Returns:
 
   EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
 
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   Status = LibLocateProtocol (&gEfiHiiProtocolGuid, &Hii);
   if (EFI_ERROR (Status)) {
     return Status;
   }
+#else
+  Status = EFI_SUCCESS;
+#endif
   //
   // Register our string package with HII and return the handle to it.
   // If previously registered we will simply receive the handle
index 44dee95..a78b774 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -28,6 +28,41 @@ Revision History
 
 EFI_HANDLE mFakeHiiHandle = NULL;
 
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+STATIC EFI_FAKE_HII_DATA mFakeHiiData = {
+  EFI_FAKE_HII_DATA_SIGNATURE,
+  0,
+  {
+    (struct _EFI_LIST_ENTRY *) NULL,
+    (struct _EFI_LIST_ENTRY *) NULL
+  },
+  {
+    (struct _EFI_LIST_ENTRY *) NULL,
+    (struct _EFI_LIST_ENTRY *) NULL
+  },
+  {
+    FakeHiiNewString,
+    FakeHiiGetString,
+    FakeHiiSetString,
+    FakeHiiGetLanguages,
+    FakeHiiGetSecondaryLanguages    
+  },
+  {
+    FakeHiiNewPackageList,
+    FakeHiiRemovePackageList,
+    FakeHiiUpdatePackageList,
+    FakeHiiListPackageLists,
+    FakeHiiExportPackageLists,
+    FakeHiiRegisterPackageNotify,
+    FakeHiiUnregisterPackageNotify,
+    FakeHiiFindKeyboardLayouts,
+    FakeHiiGetKeyboardLayout,
+    FakeHiiSetKeyboardLayout,
+    FakeHiiGetPackageListHandle    
+  }  
+};
+#endif
+
 EFI_STATUS
 FakeInitializeHiiDatabase (
   IN     EFI_HANDLE                         ImageHandle,
@@ -49,14 +84,19 @@ Returns:
 --*/
 {
   EFI_STATUS            Status;
+  BOOLEAN               HiiInstalled;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
   UINTN                 HandleCount;
   EFI_HANDLE            *HandleBuffer;
   EFI_FAKE_HII_DATA     *HiiData;
-  EFI_HANDLE            Handle;
-  BOOLEAN               HiiInstalled;
+#endif
 
   HiiInstalled = FALSE;
+  
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+
   HiiData = NULL;
+
   Status = LibLocateHandle (
             ByProtocol,
             &gEfiHiiProtocolGuid,
@@ -86,8 +126,19 @@ Returns:
     HiiData->Hii.GetPrimaryLanguages  = FakeHiiGetPrimaryLanguages;
     HiiData->Hii.GetString            = FakeHiiGetString;
     HiiData->Hii.GetForms             = FakeHiiGetForms;
+    
+    HiiData->Hii.ExportDatabase        = FakeHiiExportDatabase;
+    HiiData->Hii.GetDefaultImage       = FakeHiiGetDefaultImage;
+    HiiData->Hii.GetGlyph              = FakeHiiGetGlyph;
+    HiiData->Hii.GetKeyboardLayout     = FakeHiiGetKeyboardLayout;
+    HiiData->Hii.GetLine               = FakeHiiGetLine;
+    HiiData->Hii.GetSecondaryLanguages = FakeHiiGetSecondaryLanguages;
+    HiiData->Hii.GlyphToBlt            = FakeHiiGlyphToBlt;
+    HiiData->Hii.NewString             = FakeHiiNewString;
+    HiiData->Hii.ResetStrings          = FakeHiiResetStrings;
+    HiiData->Hii.TestString            = FakeHiiTestString;
+    HiiData->Hii.UpdateForm            = FakeHiiUpdateForm;
   
-    Handle = NULL;
     Status = BS->InstallProtocolInterface (
                   &mFakeHiiHandle,
                   &gEfiHiiProtocolGuid,
@@ -99,8 +150,32 @@ Returns:
       FreePool (HiiData);
       return Status;
     } 
+  }  
+  
+#else
+
+  Status = LocateHiiProtocols ();
+  if (!EFI_ERROR (Status)) {
+    HiiInstalled = TRUE;
+  }
+
+             
+  if (!HiiInstalled) {
+    InitializeListHead (&mFakeHiiData.DatabaseList);
+    InitializeListHead (&mFakeHiiData.HiiHandleList);
+    return BS->InstallMultipleProtocolInterfaces (
+                 &mFakeHiiHandle,
+                 &gEfiHiiStringProtocolGuid,
+                 &mFakeHiiData.HiiString,
+                 &gEfiHiiDatabaseProtocolGuid,
+                 &mFakeHiiData.HiiDatabase,
+                 NULL
+                 );
+    
   }
   
+#endif  
+
   return Status;
 }
 
@@ -110,11 +185,14 @@ FakeUninstallHiiDatabase (
   VOID
   )
 {                                    
-  EFI_STATUS              Status;
-  EFI_HII_PROTOCOL        *FakeHii;
-  EFI_FAKE_HII_DATA       *HiiData;
+  EFI_STATUS                Status;  
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+  EFI_HII_PROTOCOL          *FakeHii;
+  EFI_FAKE_HII_DATA         *HiiData;
+#endif  
   
   if (mFakeHiiHandle != NULL) {
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
     Status = BS->HandleProtocol (
                   mFakeHiiHandle,
                   &gEfiHiiProtocolGuid,
@@ -126,13 +204,644 @@ FakeUninstallHiiDatabase (
                   FakeHii
                   );
     HiiData = EFI_FAKE_HII_DATA_FROM_THIS (FakeHii);
-    mFakeHiiHandle = NULL;
     FreePool (HiiData);
+#else
+    Status = LocateHiiProtocols ();
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+    Status =  BS->UninstallMultipleProtocolInterfaces (
+                    mFakeHiiHandle,
+                    &gEfiHiiStringProtocolGuid,
+                    gLibHiiString,
+                    &gEfiHiiDatabaseProtocolGuid,
+                    gLibHiiDatabase,
+                    NULL
+                    );
+    if (EFI_ERROR (Status)) {
+      return Status;
+    }
+#endif    
+    mFakeHiiHandle = NULL;
   }
   
   return EFI_SUCCESS;
 }
 
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+
+STATIC
+VOID
+GetStringTextSize (
+  IN  UINT8            *StringSrc,
+  IN  OUT UINTN        *BufferSize
+  )
+/*++
+
+  Routine Description:
+    Calculate the size of StringSrc and output it. 
+    
+  Arguments:          
+    StringSrc              - Points to current null-terminated string.
+    BufferSize             - Length of the buffer.
+
+  Returns:
+    None.
+                             
+--*/    
+  
+{
+  UINTN  StringSize;
+  CHAR16 Zero;
+  UINT8  *StringPtr;
+  
+  ASSERT (StringSrc != NULL && BufferSize != NULL);
+
+  ZeroMem (&Zero, sizeof (CHAR16));
+  StringSize = sizeof (CHAR16);
+  StringPtr  = StringSrc;
+  while (CompareMem (StringPtr, &Zero, sizeof (CHAR16)) != 0) {
+    StringSize += sizeof (CHAR16);
+    StringPtr += sizeof (CHAR16);
+  }
+  
+  *BufferSize = StringSize;
+}
+
+STATIC
+EFI_STATUS
+InsertStringPackage (
+  IN     UINT8                       *PackageHdr,
+  IN OUT FAKE_HII_DATABASE_RECORD    *PackageList
+  )
+/*++
+
+  Routine Description:
+    This function insert a String package to the specified package list node.
+    
+  Arguments:          
+    PackageHdr        - Pointer to a buffer stored with String package information.
+    PackageList       - Pointer to a package list which will be inserted to.
+    
+  Returns:
+    EFI_SUCCESS            - String Package is inserted successfully.             
+    EFI_OUT_OF_RESOURCES   - Unable to allocate necessary resources for the
+                             new String package.
+    EFI_INVALID_PARAMETER  - PackageHdr is NULL or PackageList is NULL.
+    EFI_UNSUPPORTED        - A string package with the same language already exists
+                             in current package list.
+     
+--*/  
+  
+{
+  FAKE_HII_STRING_PACKAGE     *StringPackage;
+  UINT32                      HeaderSize;
+  UINT32                      StringInfoOffset;
+  UINT8                       *Pointer;
+  CHAR8                       *Language;
+  UINT32                      LanguageSize;
+  EFI_LIST_ENTRY              *Link;
+  FAKE_HII_STRING_BLOCK       *Block;
+  UINTN                       StrSize;
+  EFI_STRING_ID               CurrentStringId;
+  UINT16                      SkipCount;
+
+  Pointer = PackageHdr + sizeof (EFI_HII_PACKAGE_HEADER);
+  CopyMem (&HeaderSize, Pointer, sizeof (UINT32));
+  Pointer += sizeof (UINT32);
+  CopyMem (&StringInfoOffset, Pointer, sizeof (UINT32));
+
+  //
+  // It is illegal to have two string packages with same language within one packagelist
+  // since the stringid will be duplicate if so. Check it to avoid this potential issue.
+  //
+  LanguageSize = HeaderSize - sizeof (EFI_HII_STRING_PACKAGE_HDR) + sizeof (CHAR8);
+  Language = (CHAR8 *) AllocateZeroPool (LanguageSize);
+  if (Language == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  strcpya (Language, (UINT8 *) PackageHdr + HeaderSize - LanguageSize);
+  for (Link = PackageList->StringPkgHdr.Flink; Link != &PackageList->StringPkgHdr; Link = Link->Flink) {
+    StringPackage = CR (Link, FAKE_HII_STRING_PACKAGE, Entry, FAKE_HII_STRING_PACKAGE_SIGNATURE);
+    if (CompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
+      FreePool (Language);
+      return EFI_UNSUPPORTED;
+    }    
+  }  
+  FreePool (Language);
+  
+  //
+  // Create a String package node
+  //
+  StringPackage = AllocateZeroPool (sizeof (FAKE_HII_STRING_PACKAGE));
+  if (StringPackage == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }  
+  StringPackage->Signature = FAKE_HII_STRING_PACKAGE_SIGNATURE;
+  StringPackage->StringPkgHdr = AllocateZeroPool (HeaderSize);
+  if (StringPackage->StringPkgHdr == NULL) {
+    FreePool (StringPackage);    
+    return EFI_OUT_OF_RESOURCES;
+  }   
+  InitializeListHead (&StringPackage->StringBlockHdr);
+  
+  //
+  // Copy the String package header.
+  //
+  CopyMem (StringPackage->StringPkgHdr, PackageHdr, HeaderSize);
+
+  //
+  // Copy the String blocks
+  //
+  Pointer = PackageHdr + StringInfoOffset;
+  CurrentStringId = 1;
+  while (*Pointer != EFI_HII_SIBT_END) {
+    switch (*Pointer) {
+      case EFI_HII_SIBT_STRING_UCS2:
+        Block = AllocateZeroPool (sizeof (FAKE_HII_STRING_BLOCK));
+        if (Block == NULL) {
+          FreePool (StringPackage->StringPkgHdr);
+          FreePool (StringPackage);
+          return EFI_OUT_OF_RESOURCES;
+        }
+        Block->Signature = FAKE_HII_STRING_BLOCK_SIGNATURE;
+        
+        Pointer += sizeof (EFI_HII_STRING_BLOCK);
+        GetStringTextSize (Pointer, &StrSize);
+        Block->StringBlock = AllocateZeroPool (StrSize);
+        if (Block->StringBlock == NULL) {
+          FreePool (Block);
+          FreePool (StringPackage->StringPkgHdr);
+          FreePool (StringPackage);
+          return EFI_OUT_OF_RESOURCES;
+        }
+        
+        CopyMem (Block->StringBlock, Pointer, StrSize);
+        Block->StringId  = CurrentStringId;
+        Block->BlockSize = StrSize;
+        InsertTailList (&StringPackage->StringBlockHdr, &Block->Entry);
+        
+        Pointer += StrSize;
+        CurrentStringId++;
+        break;
+        
+      case EFI_HII_SIBT_SKIP1:
+        Pointer += sizeof (EFI_HII_STRING_BLOCK);
+        CurrentStringId = CurrentStringId + *Pointer;
+        Pointer += sizeof (UINT8);
+        break;
+        
+      case EFI_HII_SIBT_SKIP2:
+        Pointer += sizeof (EFI_HII_STRING_BLOCK);
+        CopyMem (&SkipCount, Pointer, sizeof (UINT16));
+        CurrentStringId = CurrentStringId + SkipCount;
+        Pointer += sizeof (UINT16);
+        break;
+        
+      default:
+        FreePool (StringPackage->StringPkgHdr);
+        FreePool (StringPackage);
+        return EFI_UNSUPPORTED;      
+    }
+  }
+  
+  //
+  // Insert to String package array
+  //
+  InsertTailList (&PackageList->StringPkgHdr, &StringPackage->Entry); 
+  return EFI_SUCCESS;
+}
+
+STATIC
+VOID
+RemoveStringPackages (
+  IN EFI_LIST_ENTRY            *ListHead
+  )
+/*++
+
+  Routine Description:
+    This function deletes all String packages from a package list node.
+    
+  Arguments:          
+    ListHead       - Array header of all string packages to be removed.
+    
+  Returns:
+     
+--*/   
+{
+  FAKE_HII_STRING_PACKAGE     *Package;
+  FAKE_HII_STRING_BLOCK       *Block;  
+  
+  while (!IsListEmpty (ListHead)) {
+    Package = CR (
+                ListHead->Flink, 
+                FAKE_HII_STRING_PACKAGE, 
+                Entry, 
+                FAKE_HII_STRING_PACKAGE_SIGNATURE
+                );
+    //
+    // Remove all string blocks
+    //
+    while (!IsListEmpty (&Package->StringBlockHdr)) {
+      Block = CR (
+                Package->StringBlockHdr.Flink, 
+                FAKE_HII_STRING_BLOCK, 
+                Entry, 
+                FAKE_HII_STRING_BLOCK_SIGNATURE
+                );
+      RemoveEntryList (&Block->Entry);
+      FreePool (Block->StringBlock);
+      FreePool (Block);
+    }    
+    
+    RemoveEntryList (&Package->Entry);    
+    FreePool (Package->StringPkgHdr);    
+    FreePool (Package);    
+  }
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiNewPackageList (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN CONST EFI_HII_PACKAGE_LIST_HEADER  *PackageList,
+  IN CONST EFI_HANDLE                   DriverHandle,
+  OUT EFI_HII_HANDLE                    *Handle
+  )
+{
+  EFI_STATUS                            Status;
+  EFI_FAKE_HII_DATA                     *Private;
+  FAKE_HII_DATABASE_RECORD              *DatabaseRecord;
+  EFI_LIST_ENTRY                        *Link;
+  EFI_GUID                              PackageListGuid;  
+  FAKE_HII_HANDLE                       *HiiHandle; 
+  UINT8                                 *PackageListPtr;
+  EFI_HII_PACKAGE_HEADER                PackageHeader;  
+
+  if (This == NULL || PackageList == NULL || Handle == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = EFI_FAKE_HII_DATA_FROM_THIS (This);
+  CopyMem (&PackageListGuid, (VOID *) PackageList, sizeof (EFI_GUID));
+
+  //
+  // Check the Package list GUID to guarantee this GUID is unique in database.
+  //
+  for (Link = Private->DatabaseList.Flink; Link != &Private->DatabaseList; Link = Link->Flink) {
+    DatabaseRecord = CR (Link, FAKE_HII_DATABASE_RECORD, Entry, FAKE_HII_DATABASE_RECORD_SIGNATURE);
+    if (CompareGuid (&(DatabaseRecord->PackageListHdr.PackageListGuid), &PackageListGuid) == 0) {
+      return EFI_INVALID_PARAMETER;
+    }       
+  }
+  //
+  // Build a PackageList node
+  //  
+  DatabaseRecord = AllocateZeroPool (sizeof (FAKE_HII_DATABASE_RECORD));
+  if (DatabaseRecord == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  DatabaseRecord->Signature = FAKE_HII_DATABASE_RECORD_SIGNATURE;
+  InitializeListHead (&DatabaseRecord->StringPkgHdr);
+  CopyMem (&DatabaseRecord->PackageListHdr, (VOID *) PackageList, sizeof (EFI_HII_PACKAGE_LIST_HEADER));
+   
+  //
+  // Insert the string packages if any.
+  //
+  PackageListPtr = (UINT8 *) PackageList + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+  CopyMem (&PackageHeader, PackageListPtr, sizeof (EFI_HII_PACKAGE_HEADER));
+  while (PackageHeader.Type != EFI_HII_PACKAGE_END) {
+    switch (PackageHeader.Type) {
+    case EFI_HII_PACKAGE_STRINGS:
+      Status = InsertStringPackage (PackageListPtr, DatabaseRecord);
+      if (EFI_ERROR (Status)) {
+        FreePool (DatabaseRecord);
+        return Status;
+      }      
+      break;
+    default:
+      FreePool (DatabaseRecord);
+      return EFI_UNSUPPORTED;
+    }
+    PackageListPtr += PackageHeader.Length;
+    CopyMem (&PackageHeader, PackageListPtr, sizeof (EFI_HII_PACKAGE_HEADER));
+  }
+
+  //
+  // Create a new hii handle
+  //
+  HiiHandle = AllocateZeroPool (sizeof (FAKE_HII_HANDLE));
+  if (HiiHandle == NULL) {
+    FreePool (DatabaseRecord);
+    return EFI_OUT_OF_RESOURCES;
+  }
+  HiiHandle->Signature = FAKE_HII_HANDLE_SIGNATURE;
+  Private->HiiHandleCount++;
+  HiiHandle->Key = Private->HiiHandleCount;
+  InsertTailList (&Private->HiiHandleList, &HiiHandle->Handle);
+
+  DatabaseRecord->Handle = (EFI_HII_HANDLE) HiiHandle;  
+  InsertTailList (&Private->DatabaseList, &DatabaseRecord->Entry);
+
+  *Handle = DatabaseRecord->Handle;
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiRemovePackageList (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                     Handle
+  )
+{
+  EFI_FAKE_HII_DATA                     *Private;
+  EFI_LIST_ENTRY                        *Link;
+  FAKE_HII_DATABASE_RECORD              *Node;
+  FAKE_HII_HANDLE                       *HiiHandle;
+  BOOLEAN                               Matched = FALSE;
+  
+  if (This == NULL || Handle == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  HiiHandle = (FAKE_HII_HANDLE *) Handle;
+  if (HiiHandle->Signature != FAKE_HII_HANDLE_SIGNATURE) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = EFI_FAKE_HII_DATA_FROM_THIS (This);
+  
+  Node = NULL;
+  for (Link = Private->DatabaseList.Flink; Link != &Private->DatabaseList; Link = Link->Flink) {
+    Node = CR (Link, FAKE_HII_DATABASE_RECORD, Entry, FAKE_HII_DATABASE_RECORD_SIGNATURE);
+    if (Node->Handle == Handle) {
+      Matched = TRUE;
+      break;
+    }    
+  }
+
+  if (!Matched) {
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Free resources: recorded string packages and corresponding hii handle.
+  //
+  RemoveStringPackages (&Node->StringPkgHdr);
+  RemoveEntryList (&HiiHandle->Handle);      
+  Private->HiiHandleCount--;
+  FreePool (HiiHandle);
+  RemoveEntryList (&Node->Entry);  
+  FreePool (Node);
+  
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiUpdatePackageList (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                     Handle,
+  IN CONST EFI_HII_PACKAGE_LIST_HEADER  *PackageList
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiListPackageLists (
+  IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
+  IN  UINT8                             PackageType,
+  IN  CONST EFI_GUID                    *PackageGuid,
+  IN  OUT UINTN                         *HandleBufferLength,
+  OUT EFI_HII_HANDLE                    *Handle
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiExportPackageLists (
+  IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
+  IN  EFI_HII_HANDLE                    Handle,
+  IN  OUT UINTN                         *BufferSize,
+  OUT EFI_HII_PACKAGE_LIST_HEADER       *Buffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiRegisterPackageNotify (
+  IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
+  IN  UINT8                             PackageType,
+  IN  CONST EFI_GUID                    *PackageGuid,
+  IN  CONST EFI_HII_DATABASE_NOTIFY     PackageNotifyFn,
+  IN  EFI_HII_DATABASE_NOTIFY_TYPE      NotifyType,
+  OUT EFI_HANDLE                        *NotifyHandle
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiUnregisterPackageNotify (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN EFI_HANDLE                         NotificationHandle
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiFindKeyboardLayouts (
+  IN  EFI_HII_DATABASE_PROTOCOL         *This,
+  IN  OUT UINT16                        *KeyGuidBufferLength,
+  OUT EFI_GUID                          *KeyGuidBuffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiGetKeyboardLayout (
+  IN  EFI_HII_DATABASE_PROTOCOL         *This,
+  IN  EFI_GUID                          *KeyGuid,
+  IN OUT UINT16                         *KeyboardLayoutLength,
+  OUT EFI_HII_KEYBOARD_LAYOUT           *KeyboardLayout
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiSetKeyboardLayout (
+  IN EFI_HII_DATABASE_PROTOCOL          *This,
+  IN EFI_GUID                           *KeyGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiGetPackageListHandle (
+  IN  EFI_HII_DATABASE_PROTOCOL         *This,
+  IN  EFI_HII_HANDLE                    PackageListHandle,
+  OUT EFI_HANDLE                        *DriverHandle
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiNewString (
+  IN  CONST EFI_HII_STRING_PROTOCOL   *This,
+  IN  EFI_HII_HANDLE                  PackageList,
+  OUT EFI_STRING_ID                   *StringId,
+  IN  CONST CHAR8                     *Language,
+  IN  CONST CHAR16                    *LanguageName, OPTIONAL
+  IN  CONST EFI_STRING                String,
+  IN  CONST EFI_FONT_INFO             *StringFontInfo OPTIONAL
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiGetString (
+  IN  CONST EFI_HII_STRING_PROTOCOL   *This,
+  IN  CONST CHAR8                     *Language,
+  IN  EFI_HII_HANDLE                  PackageList,
+  IN  EFI_STRING_ID                   StringId,
+  OUT EFI_STRING                      String,
+  IN  OUT UINTN                       *StringSize,
+  OUT EFI_FONT_INFO                   **StringFontInfo OPTIONAL
+  )
+{
+  EFI_FAKE_HII_DATA                     *Private;
+  FAKE_HII_DATABASE_RECORD              *DatabaseRecord;
+  EFI_LIST_ENTRY                        *Link;
+  FAKE_HII_STRING_PACKAGE               *StringPackage;  
+  FAKE_HII_STRING_BLOCK                 *Block;  
+  BOOLEAN                               Matched = FALSE; 
+  if (This == NULL || Language == NULL || PackageList == NULL || StringSize == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  if (StringId < 1 || (String == NULL && *StringSize != 0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+  if (((FAKE_HII_HANDLE *) PackageList)->Signature != FAKE_HII_HANDLE_SIGNATURE) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  //
+  // Get the specified package list.
+  //
+  Private = EFI_STRING_FAKE_HII_DATA_FROM_THIS (This);
+  DatabaseRecord = NULL;
+  for (Link = Private->DatabaseList.Flink; Link != &Private->DatabaseList; Link = Link->Flink) {
+    DatabaseRecord = CR (Link, FAKE_HII_DATABASE_RECORD, Entry, FAKE_HII_DATABASE_RECORD_SIGNATURE);
+    if (DatabaseRecord->Handle == PackageList) {
+      Matched = TRUE;
+      break;
+    }
+  }
+
+  if (!Matched) {
+    return EFI_NOT_FOUND;
+  }
+  
+  //
+  // Get the string package by language.
+  //
+  Matched = FALSE;
+  StringPackage = NULL;
+  for (Link = DatabaseRecord->StringPkgHdr.Flink; Link != &DatabaseRecord->StringPkgHdr; Link = Link->Flink) {
+    StringPackage = CR (Link, FAKE_HII_STRING_PACKAGE, Entry, FAKE_HII_STRING_PACKAGE_SIGNATURE);
+    if (CompareLanguage (StringPackage->StringPkgHdr->Language, (UINT8 *) Language)) {
+      Matched = TRUE;
+      break;
+    }
+  }
+
+  if (!Matched) {
+    return EFI_NOT_FOUND;
+  }
+
+  //
+  // Get the string block by stringid.
+  //
+  for (Link = StringPackage->StringBlockHdr.Flink; Link != &StringPackage->StringBlockHdr; Link = Link->Flink) {
+    Block = CR (Link, FAKE_HII_STRING_BLOCK, Entry, FAKE_HII_STRING_BLOCK_SIGNATURE);
+    if (Block->StringId == StringId) {
+      if (*StringSize < Block->BlockSize) {
+        *StringSize = Block->BlockSize;
+        return EFI_BUFFER_TOO_SMALL;
+      }
+      if (String != NULL) {
+        CopyMem (String, Block->StringBlock, Block->BlockSize);
+      }
+      *StringSize = Block->BlockSize;
+      return EFI_SUCCESS;
+    }
+  }
+
+  return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiSetString (
+  IN CONST EFI_HII_STRING_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                   PackageList,
+  IN EFI_STRING_ID                    StringId,
+  IN CONST CHAR8                      *Language,
+  IN CONST EFI_STRING                 String,
+  IN CONST EFI_FONT_INFO              *StringFontInfo OPTIONAL
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+FakeHiiGetLanguages (
+  IN CONST EFI_HII_STRING_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                   PackageList,
+  IN OUT CHAR8                        *Languages,
+  IN OUT UINTN                        *LanguagesSize
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI 
+FakeHiiGetSecondaryLanguages (
+  IN CONST EFI_HII_STRING_PROTOCOL   *This,
+  IN EFI_HII_HANDLE                  PackageList,
+  IN CONST CHAR8                     *FirstLanguage,
+  IN OUT CHAR8                       *SecondLanguages,
+  IN OUT UINTN                       *SecondLanguagesSize
+  )
+{
+  return EFI_UNSUPPORTED;
+}  
+
+#else
+
 EFI_STATUS
 FakeGetPackSize (
   IN  VOID                *Pack,
@@ -1477,3 +2186,136 @@ Returns:
 
   return EFI_SUCCESS;
 }
+
+EFI_STATUS
+FakeHiiExportDatabase (
+  IN     EFI_HII_PROTOCOL *This,
+  IN     EFI_HII_HANDLE   Handle,
+  IN OUT UINTN            *BufferSize,
+  OUT    VOID             *Buffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiGetDefaultImage (
+  IN     EFI_HII_PROTOCOL           *This,
+  IN     EFI_HII_HANDLE             Handle,
+  IN     UINTN                      DefaultMask,
+  OUT    EFI_HII_VARIABLE_PACK_LIST **VariablePackList
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiGetGlyph (
+  IN     EFI_HII_PROTOCOL  *This,
+  IN     CHAR16            *Source,
+  IN OUT UINT16            *Index,
+  OUT    UINT8             **GlyphBuffer,
+  OUT    UINT16            *BitWidth,
+  IN OUT UINT32            *InternalStatus
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiGetKeyboardLayout (
+  IN     EFI_HII_PROTOCOL    * This,
+  OUT    UINT16              *DescriptorCount,
+  OUT    EFI_KEY_DESCRIPTOR  * Descriptor
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiGetLine (
+  IN     EFI_HII_PROTOCOL  *This,
+  IN     EFI_HII_HANDLE    Handle,
+  IN     STRING_REF        Token,
+  IN OUT UINT16            *Index,
+  IN     UINT16            LineWidth,
+  IN     CHAR16            *LanguageString,
+  IN OUT UINT16            *BufferLength,
+  OUT    EFI_STRING        StringBuffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiGetSecondaryLanguages (
+  IN  EFI_HII_PROTOCOL    *This,
+  IN  EFI_HII_HANDLE      Handle,
+  IN  CHAR16              *PrimaryLanguage,
+  OUT EFI_STRING          *LanguageString
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiGlyphToBlt (
+  IN     EFI_HII_PROTOCOL               *This,
+  IN     UINT8                          *GlyphBuffer,
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground,
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background,
+  IN     UINTN                          Count,
+  IN     UINTN                          Width,
+  IN     UINTN                          Height,
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiNewString (
+  IN     EFI_HII_PROTOCOL      *This,
+  IN     CHAR16                *Language,
+  IN     EFI_HII_HANDLE        Handle,
+  IN OUT STRING_REF            *Reference,
+  IN     CHAR16                *NewString
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiResetStrings (
+  IN     EFI_HII_PROTOCOL   *This,
+  IN     EFI_HII_HANDLE     Handle
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiTestString (
+  IN     EFI_HII_PROTOCOL  *This,
+  IN     CHAR16            *StringToTest,
+  IN OUT UINT32            *FirstMissing,
+  OUT    UINT32            *GlyphBufferSize
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+FakeHiiUpdateForm (
+  IN EFI_HII_PROTOCOL     *This,
+  IN EFI_HII_HANDLE       Handle,
+  IN EFI_FORM_LABEL       Label,
+  IN BOOLEAN              AddData,
+  IN EFI_HII_UPDATE_DATA  *Data
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+#endif
+
index 7af4edc..a73332b 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -29,6 +29,247 @@ Revision History
 
 #include "EfiShellLib.h"
 
+#define EFI_FAKE_HII_DATA_SIGNATURE     EFI_SIGNATURE_32 ('F', 'H', 'I', 'I')
+
+EFI_STATUS
+FakeInitializeHiiDatabase (
+  IN     EFI_HANDLE                     ImageHandle,
+  IN     EFI_SYSTEM_TABLE               *SystemTable
+  );
+
+EFI_STATUS
+FakeUninstallHiiDatabase (
+  VOID
+  );
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+
+typedef struct _EFI_FAKE_HII_DATA {
+  UINTN                         Signature;
+  UINTN                         HiiHandleCount;  
+  EFI_LIST_ENTRY                DatabaseList;
+  EFI_LIST_ENTRY                HiiHandleList;
+  EFI_HII_STRING_PROTOCOL       HiiString;
+  EFI_HII_DATABASE_PROTOCOL     HiiDatabase;
+} EFI_FAKE_HII_DATA;
+
+#define EFI_FAKE_HII_DATA_FROM_THIS(a) \
+  CR (a, \
+      EFI_FAKE_HII_DATA, \
+      HiiDatabase, \
+      EFI_FAKE_HII_DATA_SIGNATURE \
+      )
+
+#define EFI_STRING_FAKE_HII_DATA_FROM_THIS(a) \
+  CR (a, \
+      EFI_FAKE_HII_DATA, \
+      HiiString, \
+      EFI_FAKE_HII_DATA_SIGNATURE \
+      )
+
+#define FAKE_HII_DATABASE_RECORD_SIGNATURE   EFI_SIGNATURE_32 ('F','H','D','R')
+
+typedef struct _FAKE_HII_DATABASE_RECORD {
+  UINTN                                 Signature;
+  EFI_HII_HANDLE                        Handle;
+  EFI_LIST_ENTRY                        StringPkgHdr;
+  EFI_LIST_ENTRY                        Entry;
+  EFI_HII_PACKAGE_LIST_HEADER           PackageListHdr;  
+} FAKE_HII_DATABASE_RECORD;
+
+#define FAKE_HII_HANDLE_SIGNATURE            EFI_SIGNATURE_32 ('F','H','I','H')
+
+typedef struct _FAKE_HII_HANDLE {
+  UINTN                                 Signature;
+  EFI_LIST_ENTRY                        Handle;
+  UINTN                                 Key;            
+} FAKE_HII_HANDLE;
+
+#define FAKE_HII_STRING_BLOCK_SIGNATURE      EFI_SIGNATURE_32 ('F','H','S','B')
+
+typedef struct _FAKE_HII_STRING_BLOCK {
+  UINTN                                 Signature;
+  UINTN                                 BlockSize;
+  EFI_LIST_ENTRY                        Entry;
+  EFI_STRING_ID                         StringId;
+  UINT8                                 *StringBlock;
+} FAKE_HII_STRING_BLOCK;
+
+#define FAKE_HII_STRING_PACKAGE_SIGNATURE    EFI_SIGNATURE_32 ('F','H','S','P')
+
+typedef struct _FAKE_HII_STRING_PACKAGE {
+  UINTN                                 Signature;  
+  EFI_HII_STRING_PACKAGE_HDR            *StringPkgHdr;
+  EFI_LIST_ENTRY                        StringBlockHdr;
+  EFI_LIST_ENTRY                        Entry;
+} FAKE_HII_STRING_PACKAGE;
+
+EFI_STATUS
+EFIAPI
+FakeHiiNewString (
+  IN  CONST EFI_HII_STRING_PROTOCOL   *This,
+  IN  EFI_HII_HANDLE                  PackageList,
+  OUT EFI_STRING_ID                   *StringId,
+  IN  CONST CHAR8                     *Language,
+  IN  CONST CHAR16                    *LanguageName, OPTIONAL
+  IN  CONST EFI_STRING                String,
+  IN  CONST EFI_FONT_INFO             *StringFontInfo OPTIONAL
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiGetString (
+  IN  CONST EFI_HII_STRING_PROTOCOL   *This,
+  IN  CONST CHAR8                     *Language,
+  IN  EFI_HII_HANDLE                  PackageList,
+  IN  EFI_STRING_ID                   StringId,
+  OUT EFI_STRING                      String,
+  IN  OUT UINTN                       *StringSize,
+  OUT EFI_FONT_INFO                   **StringFontInfo OPTIONAL
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiSetString (
+  IN CONST EFI_HII_STRING_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                   PackageList,
+  IN EFI_STRING_ID                    StringId,
+  IN CONST CHAR8                      *Language,
+  IN CONST EFI_STRING                 String,
+  IN CONST EFI_FONT_INFO              *StringFontInfo OPTIONAL
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiGetLanguages (
+  IN CONST EFI_HII_STRING_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                   PackageList,
+  IN OUT CHAR8                        *Languages,
+  IN OUT UINTN                        *LanguagesSize
+  )
+;
+
+EFI_STATUS
+EFIAPI 
+FakeHiiGetSecondaryLanguages (
+  IN CONST EFI_HII_STRING_PROTOCOL   *This,
+  IN EFI_HII_HANDLE                  PackageList,
+  IN CONST CHAR8                     *FirstLanguage,
+  IN OUT CHAR8                       *SecondLanguages,
+  IN OUT UINTN                       *SecondLanguagesSize
+  )
+;
+
+EFI_STATUS
+EFIAPI 
+FakeHiiNewPackageList (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN CONST EFI_HII_PACKAGE_LIST_HEADER  *PackageList,
+  IN CONST EFI_HANDLE                   DriverHandle,
+  OUT EFI_HII_HANDLE                    *Handle
+  )
+;
+
+EFI_STATUS
+EFIAPI 
+FakeHiiRemovePackageList (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                     Handle
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiUpdatePackageList (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN EFI_HII_HANDLE                     Handle,
+  IN CONST EFI_HII_PACKAGE_LIST_HEADER  *PackageList
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiListPackageLists (
+  IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
+  IN  UINT8                             PackageType,
+  IN  CONST EFI_GUID                    *PackageGuid,
+  IN  OUT UINTN                         *HandleBufferLength,
+  OUT EFI_HII_HANDLE                    *Handle
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiExportPackageLists (
+  IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
+  IN  EFI_HII_HANDLE                    Handle,
+  IN  OUT UINTN                         *BufferSize,
+  OUT EFI_HII_PACKAGE_LIST_HEADER       *Buffer
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiRegisterPackageNotify (
+  IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
+  IN  UINT8                             PackageType,
+  IN  CONST EFI_GUID                    *PackageGuid,
+  IN  CONST EFI_HII_DATABASE_NOTIFY     PackageNotifyFn,
+  IN  EFI_HII_DATABASE_NOTIFY_TYPE      NotifyType,
+  OUT EFI_HANDLE                        *NotifyHandle
+  )
+;
+
+EFI_STATUS
+EFIAPI 
+FakeHiiUnregisterPackageNotify (
+  IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
+  IN EFI_HANDLE                         NotificationHandle
+  )
+;  
+
+EFI_STATUS
+EFIAPI 
+FakeHiiFindKeyboardLayouts (
+  IN  EFI_HII_DATABASE_PROTOCOL         *This,
+  IN  OUT UINT16                        *KeyGuidBufferLength,
+  OUT EFI_GUID                          *KeyGuidBuffer
+  )
+;
+
+EFI_STATUS
+EFIAPI 
+FakeHiiGetKeyboardLayout (
+  IN  EFI_HII_DATABASE_PROTOCOL         *This,
+  IN  EFI_GUID                          *KeyGuid,
+  IN OUT UINT16                         *KeyboardLayoutLength,
+  OUT EFI_HII_KEYBOARD_LAYOUT           *KeyboardLayout
+  )
+;
+
+EFI_STATUS
+EFIAPI 
+FakeHiiSetKeyboardLayout (
+  IN EFI_HII_DATABASE_PROTOCOL          *This,
+  IN EFI_GUID                           *KeyGuid
+  )
+;
+
+EFI_STATUS
+EFIAPI
+FakeHiiGetPackageListHandle (
+  IN  EFI_HII_DATABASE_PROTOCOL         *This,
+  IN  EFI_HII_HANDLE                    PackageListHandle,
+  OUT EFI_HANDLE                        *DriverHandle
+  )
+;
+
+
+#else
+
 #include EFI_PROTOCOL_DEFINITION (Hii)
 #include EFI_GUID_DEFINITION (GlobalVariable)
 
@@ -84,17 +325,6 @@ typedef struct {
 
 #define EFI_FAKE_HII_DATA_FROM_THIS(a)      CR (a, EFI_FAKE_HII_DATA, Hii, EFI_FAKE_HII_DATA_SIGNATURE)
 
-EFI_STATUS
-FakeInitializeHiiDatabase (
-  IN     EFI_HANDLE                     ImageHandle,
-  IN     EFI_SYSTEM_TABLE               *SystemTable
-  );
-
-EFI_STATUS
-FakeUninstallHiiDatabase (
-  VOID
-  );
-
 EFI_STATUS
 EFIAPI
 FakeHiiNewPack (
@@ -148,6 +378,104 @@ FakeHiiGetForms (
   OUT    UINT8              *Buffer
   );
 
+EFI_STATUS
+FakeHiiExportDatabase (
+  IN     EFI_HII_PROTOCOL *This,
+  IN     EFI_HII_HANDLE   Handle,
+  IN OUT UINTN            *BufferSize,
+  OUT    VOID             *Buffer
+  );
+
+EFI_STATUS
+FakeHiiGetDefaultImage (
+  IN     EFI_HII_PROTOCOL           *This,
+  IN     EFI_HII_HANDLE             Handle,
+  IN     UINTN                      DefaultMask,
+  OUT    EFI_HII_VARIABLE_PACK_LIST **VariablePackList
+  );
+
+EFI_STATUS
+FakeHiiGetGlyph (
+  IN     EFI_HII_PROTOCOL  *This,
+  IN     CHAR16            *Source,
+  IN OUT UINT16            *Index,
+  OUT    UINT8             **GlyphBuffer,
+  OUT    UINT16            *BitWidth,
+  IN OUT UINT32            *InternalStatus
+  );
+
+EFI_STATUS
+FakeHiiGetKeyboardLayout (
+  IN     EFI_HII_PROTOCOL    * This,
+  OUT    UINT16              *DescriptorCount,
+  OUT    EFI_KEY_DESCRIPTOR  * Descriptor
+  );
+
+EFI_STATUS
+FakeHiiGetLine (
+  IN     EFI_HII_PROTOCOL  *This,
+  IN     EFI_HII_HANDLE    Handle,
+  IN     STRING_REF        Token,
+  IN OUT UINT16            *Index,
+  IN     UINT16            LineWidth,
+  IN     CHAR16            *LanguageString,
+  IN OUT UINT16            *BufferLength,
+  OUT    EFI_STRING        StringBuffer
+  );
+
+EFI_STATUS
+FakeHiiGetSecondaryLanguages (
+  IN  EFI_HII_PROTOCOL    *This,
+  IN  EFI_HII_HANDLE      Handle,
+  IN  CHAR16              *PrimaryLanguage,
+  OUT EFI_STRING          *LanguageString
+  );
+
+EFI_STATUS
+FakeHiiGlyphToBlt (
+  IN     EFI_HII_PROTOCOL               *This,
+  IN     UINT8                          *GlyphBuffer,
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Foreground,
+  IN     EFI_GRAPHICS_OUTPUT_BLT_PIXEL  Background,
+  IN     UINTN                          Count,
+  IN     UINTN                          Width,
+  IN     UINTN                          Height,
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer
+  );
+
+EFI_STATUS
+FakeHiiNewString (
+  IN     EFI_HII_PROTOCOL      *This,
+  IN     CHAR16                *Language,
+  IN     EFI_HII_HANDLE        Handle,
+  IN OUT STRING_REF            *Reference,
+  IN     CHAR16                *NewString
+  );
+
+EFI_STATUS
+FakeHiiResetStrings (
+  IN     EFI_HII_PROTOCOL   *This,
+  IN     EFI_HII_HANDLE     Handle
+  );
+
+EFI_STATUS
+FakeHiiTestString (
+  IN     EFI_HII_PROTOCOL  *This,
+  IN     CHAR16            *StringToTest,
+  IN OUT UINT32            *FirstMissing,
+  OUT    UINT32            *GlyphBufferSize
+  );
+
+EFI_STATUS
+FakeHiiUpdateForm (
+  IN EFI_HII_PROTOCOL     *This,
+  IN EFI_HII_HANDLE       Handle,
+  IN EFI_FORM_LABEL       Label,
+  IN BOOLEAN              AddData,
+  IN EFI_HII_UPDATE_DATA  *Data
+  );
+
 extern BOOLEAN  gHiiInitialized;
+#endif
 
 #endif
index 978d9c6..3cfd66b 100644 (file)
@@ -42,6 +42,8 @@ CHAR16              *ShellEnvPathName[] = {
 
 EFI_CONSOLE_CONTROL_SCREEN_MODE  mOldCurrentMode = EfiConsoleControlScreenText;
 
+BOOLEAN mOldCursorVisible = FALSE;
+
 EFI_SHELL_INTERFACE *OldSI;
 
 EFI_STATUS
@@ -227,6 +229,13 @@ _DoInit (
     }
   }
 
+  //
+  // Enable cursor for console output
+  //
+  ASSERT (ST->ConOut != NULL);
+  mOldCursorVisible = ST->ConOut->Mode->CursorVisible;
+  ST->ConOut->EnableCursor (ST->ConOut, TRUE);
+
   //
   // When running under EFI1.1, there is no HII support
   // so we have to provide our embedded HII support
@@ -522,6 +531,12 @@ _CleanUpOnExit (
   LibUnInitializeStrings ();
   FakeUninstallHiiDatabase();
 
+  //
+  // Restore the original cursor state
+  //
+  ASSERT (ST->ConOut != NULL);
+  ST->ConOut->EnableCursor (ST->ConOut, mOldCursorVisible);
+
   //
   // If EFI_CONSOLE_CONTROL_PROTOCOL is available,
   // switch back to the original console mode.
index 9b65a2f..c076c01 100644 (file)
Binary files a/pci/PciStrings.uni and b/pci/PciStrings.uni differ
index 74321ad..958977d 100644 (file)
--- a/pci/pci.c
+++ b/pci/pci.c
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2006, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -134,6 +134,212 @@ PciExplainPciExpress (
   IN  UINT8                                   CapabilityPtr
   );
 
+EFI_STATUS
+ExplainPcieCapReg (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieDeviceCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieDeviceControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieDeviceStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieLinkCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieLinkControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieLinkStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieSlotCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieSlotControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieSlotStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieRootControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieRootCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+EFI_STATUS
+ExplainPcieRootStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+);
+
+typedef EFI_STATUS (*PCIE_EXPLAIN_FUNCTION) (IN PCIE_CAP_STURCTURE *PciExpressCap);
+
+typedef enum {
+  FieldWidthUINT8,
+  FieldWidthUINT16,
+  FieldWidthUINT32
+} PCIE_CAPREG_FIELD_WIDTH;
+
+typedef enum {
+  PcieExplainTypeCommon,
+  PcieExplainTypeDevice,
+  PcieExplainTypeLink,
+  PcieExplainTypeSlot,
+  PcieExplainTypeRoot,
+  PcieExplainTypeMax
+} PCIE_EXPLAIN_TYPE;
+
+typedef struct
+{
+  UINT16                  Token;
+  UINTN                   Offset;
+  PCIE_CAPREG_FIELD_WIDTH Width;
+  PCIE_EXPLAIN_FUNCTION   Func;
+  PCIE_EXPLAIN_TYPE       Type;
+} PCIE_EXPLAIN_STRUCT;
+
+PCIE_EXPLAIN_STRUCT PcieExplainList[] = {
+  {
+    STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID),
+    0x00,
+    FieldWidthUINT8,
+    NULL,
+    PcieExplainTypeCommon
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR),
+    0x01,
+    FieldWidthUINT8,
+    NULL,
+    PcieExplainTypeCommon
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_CAP_REGISTER),
+    0x02,
+    FieldWidthUINT16,
+    ExplainPcieCapReg,
+    PcieExplainTypeCommon
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_DEVICE_CAP),
+    0x04,
+    FieldWidthUINT32,
+    ExplainPcieDeviceCap,
+    PcieExplainTypeDevice
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL),
+    0x08,
+    FieldWidthUINT16,
+    ExplainPcieDeviceControl,
+    PcieExplainTypeDevice
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_DEVICE_STATUS),
+    0x0a,
+    FieldWidthUINT16,
+    ExplainPcieDeviceStatus,
+    PcieExplainTypeDevice
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES),
+    0x0c,
+    FieldWidthUINT32,
+    ExplainPcieLinkCap,
+    PcieExplainTypeLink
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_LINK_CONTROL),
+    0x10,
+    FieldWidthUINT16,
+    ExplainPcieLinkControl,
+    PcieExplainTypeLink
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_LINK_STATUS),
+    0x12,
+    FieldWidthUINT16,
+    ExplainPcieLinkStatus,
+    PcieExplainTypeLink
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES),
+    0x14,
+    FieldWidthUINT32,
+    ExplainPcieSlotCap,
+    PcieExplainTypeSlot
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_SLOT_CONTROL),
+    0x18,
+    FieldWidthUINT16,
+    ExplainPcieSlotControl,
+    PcieExplainTypeSlot
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_SLOT_STATUS),
+    0x1a,
+    FieldWidthUINT16,
+    ExplainPcieSlotStatus,
+    PcieExplainTypeSlot
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_ROOT_CONTROL),
+    0x1c,
+    FieldWidthUINT16,
+    ExplainPcieRootControl,
+    PcieExplainTypeRoot
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_RSVDP),
+    0x1e,
+    FieldWidthUINT16,
+    ExplainPcieRootCap,
+    PcieExplainTypeRoot
+  },
+  {
+    STRING_TOKEN (STR_PCIEX_ROOT_STATUS),
+    0x20,
+    FieldWidthUINT32,
+    ExplainPcieRootStatus,
+    PcieExplainTypeRoot
+  },
+  {
+    0,
+    0,
+    0,
+    NULL,
+    PcieExplainTypeMax
+  }
+};
+
 //
 // Global Variables
 //
@@ -173,6 +379,63 @@ SHELL_VAR_CHECK_ITEM    PciCheckList[] = {
   }
 };
 
+CHAR16 *DevicePortTypeTable[] = {
+  L"PCI Express Endpoint",
+  L"Legacy PCI Express Endpoint",
+  L"Unknown Type",
+  L"Unknonw Type",
+  L"Root Port of PCI Express Root Complex",
+  L"Upstream Port of PCI Express Switch",
+  L"Downstream Port of PCI Express Switch",
+  L"PCI Express to PCI/PCI-X Bridge",
+  L"PCI/PCI-X to PCI Express Bridge",
+  L"Root Complex Integrated Endpoint",
+  L"Root Complex Event Collector"
+};
+
+CHAR16 *L0sLatencyStrTable[] = {
+  L"Less than 64ns",
+  L"64ns to less than 128ns",
+  L"128ns to less than 256ns",
+  L"256ns to less than 512ns",
+  L"512ns to less than 1us",
+  L"1us to less than 2us",
+  L"2us-4us",
+  L"More than 4us"
+};
+
+CHAR16 *L1LatencyStrTable[] = {
+  L"Less than 1us",
+  L"1us to less than 2us",
+  L"2us to less than 4us",
+  L"4us to less than 8us",
+  L"8us to less than 16us",
+  L"16us to less than 32us",
+  L"32us-64us",
+  L"More than 64us"
+};
+
+CHAR16 *ASPMCtrlStrTable[] = {
+  L"Disabled",
+  L"L0s Entry Enabled",
+  L"L1 Entry Enabled",
+  L"L0s and L1 Entry Enabled"
+};
+
+CHAR16 *SlotPwrLmtScaleTable[] = {
+  L"1.0x",
+  L"0.1x",
+  L"0.01x",
+  L"0.001x"
+};
+
+CHAR16 *IndicatorTable[] = {
+  L"Reserved",
+  L"On",
+  L"Blink",
+  L"Off"
+};
+
 EFI_BOOTSHELL_CODE(
   EFI_APPLICATION_ENTRY_POINT(PciDump)
 )
@@ -404,6 +667,10 @@ Returns:
             // For each function, read its configuration space and print summary
             //
             for (Func = 0; Func <= PCI_MAX_FUNC; Func++) {
+              if (GetExecutionBreak ()) {
+                Status = EFI_SUCCESS;
+                goto Done;
+              }
               Address = CALC_EFI_PCI_ADDRESS (Bus, Device, Func, 0);
               IoDev->Pci.Read (
                           IoDev,
@@ -618,13 +885,13 @@ Returns:
   //
   SizeOfHeader = sizeof (ConfigSpace.Common) + sizeof (ConfigSpace.NonCommon);
 
-  DumpHex (2, 0, SizeOfHeader, &ConfigSpace);
+  PrivateDumpHex (2, 0, SizeOfHeader, &ConfigSpace);
   Print (L"\n");
 
   //
   // Dump device dependent Part of configuration space
   //
-  DumpHex (
+  PrivateDumpHex (
     2,
     SizeOfHeader,
     sizeof (ConfigSpace) - SizeOfHeader,
@@ -990,6 +1257,10 @@ Returns:
   PciPrintClassCode ((UINT8 *) Common->ClassCode, TRUE);
   Print (L"\n");
 
+  if (GetExecutionBreak ()) {
+    return EFI_SUCCESS;
+  }
+
   //
   // Interpret remaining part of PCI configuration header depending on
   // HeaderType
@@ -2090,182 +2361,771 @@ PciExplainCapabilityStruct (
 }
 
 EFI_STATUS
-PciExplainPciExpress (
-  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL         *IoDev,
-  IN  UINT64                                  Address,
-  IN  UINT8                                   CapabilityPtr
-  )
+ExplainPcieCapReg (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
 {
+  UINT16 PcieCapReg;
+  CHAR16 *DevicePortType;
 
-  PCIE_CAP_STURCTURE  PciExpressCap;
-  EFI_STATUS          Status;
-  UINT64              RegAddress;
-  UINT8               Bus;
-  UINT8               Dev;
-  UINT8               Func;
-  UINT8               *ExRegBuffer;
-  UINTN               ExtendRegSize;
-  UINT64              Pciex_Address;
-
-  RegAddress = Address + CapabilityPtr;
-  IoDev->Pci.Read (
-              IoDev,
-              EfiPciWidthUint32,
-              RegAddress,
-              sizeof (PciExpressCap) / sizeof (UINT32),
-              &PciExpressCap
-              );
-
-  Print (L"\nPci Express device capability structure:\n");
-  //
-  // Print PciExpress Capability ID, should be 0x10 per PCI sepc.
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_CAPABILITY_CAPID),
-    HiiHandle,
-    0x00,
-    PciExpressCap.PcieCapId
+  PcieCapReg = PciExpressCap->PcieCapReg;
+  Print (
+    L"  Capability Version(3:0):          %E0x%04x%N\n",
+    PCIE_CAP_VERSION (PcieCapReg)
+    );
+  if ((UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) < PCIE_DEVICE_PORT_TYPE_MAX) {
+    DevicePortType = DevicePortTypeTable[PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg)];
+  } else {
+    DevicePortType = L"Unknown Type";
+  }
+  Print (
+    L"  Device/PortType(7:4):             %E%s%N\n",
+    DevicePortType
     );
-
   //
-  // Print Next capability pointer in PciExpress Capability structure
+  // 'Slot Implemented' is only valid for:
+  // a) Root Port of PCI Express Root Complex, or
+  // b) Downstream Port of PCI Express Switch
   //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_NEXTCAP_PTR),
-    HiiHandle,
-    0x01,
-    PciExpressCap.NextCapPtr
+  if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_ROOT_COMPLEX_ROOT_PORT ||
+      PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_SWITCH_DOWNSTREAM_PORT) {
+    Print (
+      L"  Slot Implemented(8):              %E%d%N\n",
+      PCIE_CAP_SLOT_IMPLEMENTED (PcieCapReg)
+      );
+  }
+  Print (
+    L"  Interrupt Message Number(13:9):   %E0x%05x%N\n",
+    PCIE_CAP_INT_MSG_NUM (PcieCapReg)
     );
+  return EFI_SUCCESS;
+}
 
+EFI_STATUS
+ExplainPcieDeviceCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieCapReg;
+  UINT32 PcieDeviceCap;
+  UINT8  DevicePortType;
+  UINT8  L0sLatency;
+  UINT8  L1Latency;
+
+  PcieCapReg     = PciExpressCap->PcieCapReg;
+  PcieDeviceCap  = PciExpressCap->PcieDeviceCap;
+  DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg);
+  Print (L"  Max_Payload_Size Supported(2:0):          ");
+  if (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) < 6) {
+    Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD (PcieDeviceCap) + 7));
+  } else {
+    Print (L"%EUnknown%N\n");
+  }
+  Print (
+    L"  Phantom Functions Supported(4:3):         %E%d%N\n",
+    PCIE_CAP_PHANTOM_FUNC (PcieDeviceCap)
+    );
+  Print (
+    L"  Extended Tag Field Supported(5):          %E%d-bit Tag field supported%N\n",
+    PCIE_CAP_EXTENDED_TAG (PcieDeviceCap) ? 8 : 5
+    );
   //
-  // Print Capabilities register in PciExpress Capability structure
+  // Endpoint L0s and L1 Acceptable Latency is only valid for Endpoint
   //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_CAP_REGISTER),
-    HiiHandle,
-    0x02,
-    PciExpressCap.PcieCapReg
+  if (IS_PCIE_ENDPOINT (DevicePortType)) {
+    L0sLatency = (UINT8) PCIE_CAP_L0sLatency (PcieDeviceCap);
+    L1Latency  = (UINT8) PCIE_CAP_L1Latency (PcieDeviceCap);
+    Print (L"  Endpoint L0s Acceptable Latency(8:6):     ");
+    if (L0sLatency < 4) {
+      Print (L"%EMaximum of %d ns%N\n", 1 << (L0sLatency + 6));
+    } else {
+      if (L0sLatency < 7) {
+        Print (L"%EMaximum of %d us%N\n", 1 << (L0sLatency - 3));
+      } else {
+        Print (L"%ENo limit%N\n");
+      }
+    }
+    Print (L"  Endpoint L1 Acceptable Latency(11:9):     ");
+    if (L1Latency < 7) {
+      Print (L"%EMaximum of %d us%N\n", 1 << (L1Latency + 1));
+    } else {
+      Print (L"%ENo limit%N\n");
+    }
+  }
+  Print (
+    L"  Role-based Error Reporting(15):           %E%d%N\n",
+    PCIE_CAP_ERR_REPORTING (PcieDeviceCap)
     );
-
   //
-  // Print Device capabilities in PciExpress Capability structure
+  // Only valid for Upstream Port:
+  // a) Captured Slot Power Limit Value
+  // b) Captured Slot Power Scale
   //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_DEVICE_CAP),
-    HiiHandle,
-    0x04,
-    PciExpressCap.PcieDeviceCap
-    );
-
+  if (DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) {
+    Print (
+      L"  Captured Slot Power Limit Value(25:18):   %E0x%02x%N\n",
+      PCIE_CAP_SLOT_POWER_VALUE (PcieDeviceCap)
+      );
+    Print (
+      L"  Captured Slot Power Limit Scale(27:26):   %E%s%N\n",
+      SlotPwrLmtScaleTable[PCIE_CAP_SLOT_POWER_SCALE (PcieDeviceCap)]
+      );
+  }
   //
-  // Print DeviceStatus in PciExpress Capability structure
+  // Function Level Reset Capability is only valid for Endpoint
   //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_DEVICE_CONTROL),
-    HiiHandle,
-    0x08,
-    PciExpressCap.DeviceControl
-    );
+  if (IS_PCIE_ENDPOINT (DevicePortType)) {
+    Print (
+      L"  Function Level Reset Capability(28):      %E%d%N\n",
+      PCIE_CAP_FUNC_LEVEL_RESET (PcieDeviceCap)
+      );
+  }
+  return EFI_SUCCESS;
+}
 
+EFI_STATUS
+ExplainPcieDeviceControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieCapReg;
+  UINT16 PcieDeviceControl;
+
+  PcieCapReg        = PciExpressCap->PcieCapReg;
+  PcieDeviceControl = PciExpressCap->DeviceControl;
+  Print (
+    L"  Correctable Error Reporting Enable(0):    %E%d%N\n",
+    PCIE_CAP_COR_ERR_REPORTING_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Non-Fatal Error Reporting Enable(1):      %E%d%N\n",
+    PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Fatal Error Reporting Enable(2):          %E%d%N\n",
+    PCIE_CAP_FATAL_ERR_REPORTING_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Unsupported Request Reporting Enable(3):  %E%d%N\n",
+    PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Enable Relaxed Ordering(4):               %E%d%N\n",
+    PCIE_CAP_RELAXED_ORDERING_ENABLE (PcieDeviceControl)
+    );
+  Print (L"  Max_Payload_Size(7:5):                    ");
+  if (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) < 6) {
+    Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_PAYLOAD_SIZE (PcieDeviceControl) + 7));
+  } else {
+    Print (L"%EUnknown%N\n");
+  }
+  Print (
+    L"  Extended Tag Field Enable(8):             %E%d%N\n",
+    PCIE_CAP_EXTENDED_TAG_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Phantom Functions Enable(9):              %E%d%N\n",
+    PCIE_CAP_PHANTOM_FUNC_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Auxiliary (AUX) Power PM Enable(10):      %E%d%N\n",
+    PCIE_CAP_AUX_PM_ENABLE (PcieDeviceControl)
+    );
+  Print (
+    L"  Enable No Snoop(11):                      %E%d%N\n",
+    PCIE_CAP_NO_SNOOP_ENABLE (PcieDeviceControl)
+    );
+  Print (L"  Max_Read_Request_Size(14:12):             ");
+  if (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) < 6) {
+    Print (L"%E%d bytes%N\n", 1 << (PCIE_CAP_MAX_READ_REQ_SIZE (PcieDeviceControl) + 7));
+  } else {
+    Print (L"%EUnknown%N\n");
+  }
   //
-  // Print DeviceStatus in PciExpress Capability structure
+  // Read operation is only valid for PCI Express to PCI/PCI-X Bridges
   //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_DEVICE_STATUS),
-    HiiHandle,
-    0x0A,
-    PciExpressCap.DeviceStatus
+  if (PCIE_CAP_DEVICEPORT_TYPE (PcieCapReg) == PCIE_PCIE_TO_PCIX_BRIDGE) {
+    Print (
+      L"  Bridge Configuration Retry Enable(15):  %E%d%N\n",
+      PCIE_CAP_BRG_CONF_RETRY (PcieDeviceControl)
+      );
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ExplainPcieDeviceStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieDeviceStatus;
+
+  PcieDeviceStatus = PciExpressCap->DeviceStatus;
+  Print (
+    L"  Correctable Error Detected(0):            %E%d%N\n",
+    PCIE_CAP_COR_ERR_DETECTED (PcieDeviceStatus)
+    );
+  Print (
+    L"  Non-Fatal Error Detected(1):              %E%d%N\n",
+    PCIE_CAP_NONFAT_ERR_DETECTED (PcieDeviceStatus)
     );
+  Print (
+    L"  Fatal Error Detected(2):                  %E%d%N\n",
+    PCIE_CAP_FATAL_ERR_DETECTED (PcieDeviceStatus)
+    );
+  Print (
+    L"  Unsupported Request Detected(3):          %E%d%N\n",
+    PCIE_CAP_UNSUP_REQ_DETECTED (PcieDeviceStatus)
+    );
+  Print (
+    L"  AUX Power Detected(4):                    %E%d%N\n",
+    PCIE_CAP_AUX_POWER_DETECTED (PcieDeviceStatus)
+    );
+  Print (
+    L"  Transactions Pending(5):                  %E%d%N\n",
+    PCIE_CAP_TRANSACTION_PENDING (PcieDeviceStatus)
+    );
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print Link Capabilities in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_LINK_CAPABILITIES),
-    HiiHandle,
-    0x0C,
-    PciExpressCap.LinkCap
+EFI_STATUS
+ExplainPcieLinkCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT32 PcieLinkCap;
+  CHAR16 *SupLinkSpeeds;
+  CHAR16 *ASPM;
+
+  PcieLinkCap = PciExpressCap->LinkCap;
+  switch (PCIE_CAP_SUP_LINK_SPEEDS (PcieLinkCap)) {
+    case 1:
+      SupLinkSpeeds = L"2.5 GT/s";
+      break;
+    case 2:
+      SupLinkSpeeds = L"5.0 GT/s and 2.5 GT/s";
+      break;
+    default:
+      SupLinkSpeeds = L"Unknown";
+      break;
+  }
+  Print (
+    L"  Supported Link Speeds(3:0):                         %E%s supported%N\n",
+    SupLinkSpeeds
+    );
+  Print (
+    L"  Maximum Link Width(9:4):                            %Ex%d%N\n",
+    PCIE_CAP_MAX_LINK_WIDTH (PcieLinkCap)
+    );
+  switch (PCIE_CAP_ASPM_SUPPORT (PcieLinkCap)) {
+    case 1:
+      ASPM = L"L0s Entry";
+      break;
+    case 3:
+      ASPM = L"L0s and L1";
+      break;
+    default:
+      ASPM = L"Reserved";
+      break;
+  }
+  Print (
+    L"  Active State Power Management Support(11:10):       %E%s Supported%N\n",
+    ASPM
+    );
+  Print (
+    L"  L0s Exit Latency(14:12):                            %E%s%N\n",
+    L0sLatencyStrTable[PCIE_CAP_L0s_LATENCY (PcieLinkCap)]
+    );
+  Print (
+    L"  L1 Exit Latency(17:15):                             %E%s%N\n",
+    L1LatencyStrTable[PCIE_CAP_L0s_LATENCY (PcieLinkCap)]
+    );
+  Print (
+    L"  Clock Power Management(18):                         %E%d%N\n",
+    PCIE_CAP_CLOCK_PM (PcieLinkCap)
     );
+  Print (
+    L"  Surprise Down Error Reporting Capable(19):          %E%d%N\n",
+    PCIE_CAP_SUP_DOWN_ERR_REPORTING (PcieLinkCap)
+    );
+  Print (
+    L"  Data Link Layer Link Active Reporting Capable(20):  %E%d%N\n",
+    PCIE_CAP_LINK_ACTIVE_REPORTING (PcieLinkCap)
+    );
+  Print (
+    L"  Link Bandwidth Notification Capability(21):         %E%d%N\n",
+    PCIE_CAP_LINK_BWD_NOTIF_CAP (PcieLinkCap)
+    );
+  Print (
+    L"  Port Number(31:24):                                 %E0x%02x%N\n",
+    PCIE_CAP_PORT_NUMBER (PcieLinkCap)
+    );
+  return EFI_SUCCESS;
+}
 
+EFI_STATUS
+ExplainPcieLinkControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieLinkControl;
+  UINT8  DevicePortType;
+
+  PcieLinkControl = PciExpressCap->LinkControl;
+  DevicePortType  = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap->PcieCapReg);
+  Print (
+    L"  Active State Power Management Control(1:0):         %E%s%N\n",
+    ASPMCtrlStrTable[PCIE_CAP_ASPM_CONTROL (PcieLinkControl)]
+    );
   //
-  // Print LinkControl in PciExpress Capability structure
+  // RCB is not applicable to switches
   //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_LINK_CONTROL),
-    HiiHandle,
-    0x10,
-    PciExpressCap.LinkControl
+  if (!IS_PCIE_SWITCH(DevicePortType)) {
+    Print (
+      L"  Read Completion Boundary (RCB)(3):                  %E%d byte%N\n",
+      1 << (PCIE_CAP_RCB (PcieLinkControl) + 6)
+      );
+  }
+  //
+  // Link Disable is reserved on
+  // a) Endpoints
+  // b) PCI Express to PCI/PCI-X bridges
+  // c) Upstream Ports of Switches
+  //
+  if (!IS_PCIE_ENDPOINT (DevicePortType) &&
+      DevicePortType != PCIE_SWITCH_UPSTREAM_PORT &&
+      DevicePortType != PCIE_PCIE_TO_PCIX_BRIDGE) {
+    Print (
+      L"  Link Disable(4):                                    %E%d%N\n",
+      PCIE_CAP_LINK_DISABLE (PcieLinkControl)
+      );
+  }
+  Print (
+    L"  Common Clock Configuration(6):                      %E%d%N\n",
+    PCIE_CAP_COMMON_CLK_CONF (PcieLinkControl)
+    );
+  Print (
+    L"  Extended Synch(7):                                  %E%d%N\n",
+    PCIE_CAP_EXT_SYNC (PcieLinkControl)
     );
+  Print (
+    L"  Enable Clock Power Management(8):                   %E%d%N\n",
+    PCIE_CAP_CLK_PWR_MNG (PcieLinkControl)
+    );
+  Print (
+    L"  Hardware Autonomous Width Disable(9):               %E%d%N\n",
+    PCIE_CAP_HW_AUTO_WIDTH_DISABLE (PcieLinkControl)
+    );
+  Print (
+    L"  Link Bandwidth Management Interrupt Enable(10):     %E%d%N\n",
+    PCIE_CAP_LINK_BDW_MNG_INT_EN (PcieLinkControl)
+    );
+  Print (
+    L"  Link Autonomous Bandwidth Interrupt Enable(11):     %E%d%N\n",
+    PCIE_CAP_LINK_AUTO_BDW_INT_EN (PcieLinkControl)
+    );
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print LinkStatus in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_LINK_STATUS),
-    HiiHandle,
-    0x12,
-    PciExpressCap.LinkStatus
+EFI_STATUS
+ExplainPcieLinkStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieLinkStatus;
+  CHAR16 *SupLinkSpeeds;
+
+  PcieLinkStatus = PciExpressCap->LinkStatus;
+  switch (PCIE_CAP_CUR_LINK_SPEED (PcieLinkStatus)) {
+    case 1:
+      SupLinkSpeeds = L"2.5 GT/s";
+      break;
+    case 2:
+      SupLinkSpeeds = L"5.0 GT/s";
+      break;
+    default:
+      SupLinkSpeeds = L"Reserved";
+      break;
+  }
+  Print (
+    L"  Current Link Speed(3:0):                            %E%s%N\n",
+    SupLinkSpeeds
+    );
+  Print (
+    L"  Negotiated Link Width(9:4):                         %Ex%d%N\n",
+    PCIE_CAP_NEGO_LINK_WIDTH (PcieLinkStatus)
     );
+  Print (
+    L"  Link Training(11):                                  %E%d%N\n",
+    PCIE_CAP_LINK_TRAINING (PcieLinkStatus)
+    );
+  Print (
+    L"  Slot Clock Configuration(12):                       %E%d%N\n",
+    PCIE_CAP_SLOT_CLK_CONF (PcieLinkStatus)
+    );
+  Print (
+    L"  Data Link Layer Link Active(13):                    %E%d%N\n",
+    PCIE_CAP_DATA_LINK_ACTIVE (PcieLinkStatus)
+    );
+  Print (
+    L"  Link Bandwidth Management Status(14):               %E%d%N\n",
+    PCIE_CAP_LINK_BDW_MNG_STAT (PcieLinkStatus)
+    );
+  Print (
+    L"  Link Autonomous Bandwidth Status(15):               %E%d%N\n",
+    PCIE_CAP_LINK_AUTO_BDW_STAT (PcieLinkStatus)
+    );
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print RootCap in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_SLOT_CAPABILITIES),
-    HiiHandle,
-    0x14,
-    PciExpressCap.SlotCap
+EFI_STATUS
+ExplainPcieSlotCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT32 PcieSlotCap;
+
+  PcieSlotCap = PciExpressCap->SlotCap;
+
+  Print (
+    L"  Attention Button Present(0):                        %E%d%N\n",
+    PCIE_CAP_ATT_BUT_PRESENT (PcieSlotCap)
+    );
+  Print (
+    L"  Power Controller Present(1):                        %E%d%N\n",
+    PCIE_CAP_PWR_CTRLLER_PRESENT (PcieSlotCap)
+    );
+  Print (
+    L"  MRL Sensor Present(2):                              %E%d%N\n",
+    PCIE_CAP_MRL_SENSOR_PRESENT (PcieSlotCap)
+    );
+  Print (
+    L"  Attention Indicator Present(3):                     %E%d%N\n",
+    PCIE_CAP_ATT_IND_PRESENT (PcieSlotCap)
+    );
+  Print (
+    L"  Power Indicator Present(4):                         %E%d%N\n",
+    PCIE_CAP_PWD_IND_PRESENT (PcieSlotCap)
     );
+  Print (
+    L"  Hot-Plug Surprise(5):                               %E%d%N\n",
+    PCIE_CAP_HOTPLUG_SUPPRISE (PcieSlotCap)
+    );
+  Print (
+    L"  Hot-Plug Capable(6):                                %E%d%N\n",
+    PCIE_CAP_HOTPLUG_CAPABLE (PcieSlotCap)
+    );
+  Print (
+    L"  Slot Power Limit Value(14:7):                       %E0x%02x%N\n",
+    PCIE_CAP_SLOT_PWR_LIMIT_VALUE (PcieSlotCap)
+    );
+  Print (
+    L"  Slot Power Limit Scale(16:15):                      %E%s%N\n",
+    SlotPwrLmtScaleTable[PCIE_CAP_SLOT_PWR_LIMIT_SCALE (PcieSlotCap)]
+    );
+  Print (
+    L"  Electromechanical Interlock Present(17):            %E%d%N\n",
+    PCIE_CAP_ELEC_INTERLOCK_PRESENT (PcieSlotCap)
+    );
+  Print (
+    L"  No Command Completed Support(18):                   %E%d%N\n",
+    PCIE_CAP_NO_COMM_COMPLETED_SUP (PcieSlotCap)
+    );
+  Print (
+    L"  Physical Slot Number(31:19):                        %E%d%N\n",
+    PCIE_CAP_PHY_SLOT_NUM (PcieSlotCap)
+    );
+    
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print SlotControl in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_SLOT_CONTROL),
-    HiiHandle,
-    0x18,
-    PciExpressCap.SlotControl
+EFI_STATUS
+ExplainPcieSlotControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieSlotControl;
+
+  PcieSlotControl = PciExpressCap->SlotControl;
+  Print (
+    L"  Attention Button Pressed Enable(0):                 %E%d%N\n",
+    PCIE_CAP_ATT_BUT_ENABLE (PcieSlotControl)
+    );
+  Print (
+    L"  Power Fault Detected Enable(1):                     %E%d%N\n",
+    PCIE_CAP_PWR_FLT_DETECT_ENABLE (PcieSlotControl)
+    );
+  Print (
+    L"  MRL Sensor Changed Enable(2):                       %E%d%N\n",
+    PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE (PcieSlotControl)
+    );
+  Print (
+    L"  Presence Detect Changed Enable(3):                  %E%d%N\n",
+    PCIE_CAP_PRES_DETECT_CHANGE_ENABLE (PcieSlotControl)
+    );
+  Print (
+    L"  Command Completed Interrupt Enable(4):              %E%d%N\n",
+    PCIE_CAP_COMM_CMPL_INT_ENABLE (PcieSlotControl)
+    );
+  Print (
+    L"  Hot-Plug Interrupt Enable(5):                       %E%d%N\n",
+    PCIE_CAP_HOTPLUG_INT_ENABLE (PcieSlotControl)
+    );
+  Print (
+    L"  Attention Indicator Control(7:6):                   %E%s%N\n",
+    IndicatorTable[PCIE_CAP_ATT_IND_CTRL (PcieSlotControl)]
+    );
+  Print (
+    L"  Power Indicator Control(9:8):                       %E%s%N\n",
+    IndicatorTable[PCIE_CAP_PWR_IND_CTRL (PcieSlotControl)]
+    );
+  Print (L"  Power Controller Control(10):                       %EPower ");
+  if (PCIE_CAP_PWR_CTRLLER_CTRL (PcieSlotControl)) {
+    Print (L"Off%N\n");
+  } else {
+    Print (L"On%N\n");
+  }
+  Print (
+    L"  Electromechanical Interlock Control(11):            %E%d%N\n",
+    PCIE_CAP_ELEC_INTERLOCK_CTRL (PcieSlotControl)
+    );
+  Print (
+    L"  Data Link Layer State Changed Enable(12):           %E%d%N\n",
+    PCIE_CAP_DLINK_STAT_CHANGE_ENABLE (PcieSlotControl)
     );
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print SlotStatus in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_SLOT_STATUS),
-    HiiHandle,
-    0x1A,
-    PciExpressCap.SlotStatus
+EFI_STATUS
+ExplainPcieSlotStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieSlotStatus;
+
+  PcieSlotStatus = PciExpressCap->SlotStatus;
+
+  Print (
+    L"  Attention Button Pressed(0):           %E%d%N\n",
+    PCIE_CAP_ATT_BUT_PRESSED (PcieSlotStatus)
     );
+  Print (
+    L"  Power Fault Detected(1):               %E%d%N\n",
+    PCIE_CAP_PWR_FLT_DETECTED (PcieSlotStatus)
+    );
+  Print (
+    L"  MRL Sensor Changed(2):                 %E%d%N\n",
+    PCIE_CAP_MRL_SENSOR_CHANGED (PcieSlotStatus)
+    );
+  Print (
+    L"  Presence Detect Changed(3):            %E%d%N\n",
+    PCIE_CAP_PRES_DETECT_CHANGED (PcieSlotStatus)
+    );
+  Print (
+    L"  Command Completed(4):                  %E%d%N\n",
+    PCIE_CAP_COMM_COMPLETED (PcieSlotStatus)
+    );
+  Print (L"  MRL Sensor State(5):                   %EMRL ");
+  if (PCIE_CAP_MRL_SENSOR_STATE (PcieSlotStatus)) {
+    Print (L" Opened%N\n");
+  } else {
+    Print (L" Closed%N\n");
+  }
+  Print (L"  Presence Detect State(6):              ");
+  if (PCIE_CAP_PRES_DETECT_STATE (PcieSlotStatus)) {
+    Print (L"%ECard Present in slot%N\n");
+  } else {
+    Print (L"%ESlot Empty%N\n");
+  }
+  Print (L"  Electromechanical Interlock Status(7): %EElectromechanical Interlock ");
+  if (PCIE_CAP_ELEC_INTERLOCK_STATE (PcieSlotStatus)) {
+    Print (L"Engaged%N\n");
+  } else {
+    Print (L"Disengaged%N\n");
+  }
+  Print (
+    L"  Data Link Layer State Changed(8):      %E%d%N\n",
+    PCIE_CAP_DLINK_STAT_CHANGED (PcieSlotStatus)
+    );
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print RootControl in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_ROOT_CONTROL),
-    HiiHandle,
-    0x1C,
-    PciExpressCap.RootControl
+EFI_STATUS
+ExplainPcieRootControl (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieRootControl;
+
+  PcieRootControl = PciExpressCap->RootControl;
+
+  Print (
+    L"  System Error on Correctable Error Enable(0):  %E%d%N\n",
+    PCIE_CAP_SYSERR_ON_CORERR_EN (PcieRootControl)
+    );
+  Print (
+    L"  System Error on Non-Fatal Error Enable(1):    %E%d%N\n",
+    PCIE_CAP_SYSERR_ON_NONFATERR_EN (PcieRootControl)
+    );
+  Print (
+    L"  System Error on Fatal Error Enable(2):        %E%d%N\n",
+    PCIE_CAP_SYSERR_ON_FATERR_EN (PcieRootControl)
+    );
+  Print (
+    L"  PME Interrupt Enable(3):                      %E%d%N\n",
+    PCIE_CAP_PME_INT_ENABLE (PcieRootControl)
     );
+  Print (
+    L"  CRS Software Visibility Enable(4):            %E%d%N\n",
+    PCIE_CAP_CRS_SW_VIS_ENABLE (PcieRootControl)
+    );
+    
+  return EFI_SUCCESS;
+}
 
-  //
-  // Print RsvdP in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_RSVDP),
-    HiiHandle,
-    0x1E,
-    PciExpressCap.RsvdP
+EFI_STATUS
+ExplainPcieRootCap (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT16 PcieRootCap;
+
+  PcieRootCap = PciExpressCap->RsvdP;
+
+  Print (
+    L"  CRS Software Visibility(0):                   %E%d%N\n",
+    PCIE_CAP_CRS_SW_VIS (PcieRootCap)
     );
 
-  //
-  // Print RootStatus in PciExpress Capability structure
-  //
-  PrintToken (
-    STRING_TOKEN (STR_PCIEX_ROOT_STATUS),
-    HiiHandle,
-    0x20,
-    PciExpressCap.RootStatus
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ExplainPcieRootStatus (
+  IN PCIE_CAP_STURCTURE *PciExpressCap
+)
+{
+  UINT32 PcieRootStatus;
+
+  PcieRootStatus = PciExpressCap->RootStatus;
+
+  Print (
+    L"  PME Requester ID(15:0):                       %E0x%04x%N\n",
+    PCIE_CAP_PME_REQ_ID (PcieRootStatus)
+    );
+  Print (
+    L"  PME Status(16):                               %E%d%N\n",
+    PCIE_CAP_PME_STATUS (PcieRootStatus)
     );
+  Print (
+    L"  PME Pending(17):                              %E%d%N\n",
+    PCIE_CAP_PME_PENDING (PcieRootStatus)
+    );
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PciExplainPciExpress (
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL         *IoDev,
+  IN  UINT64                                  Address,
+  IN  UINT8                                   CapabilityPtr
+  )
+{
+
+  PCIE_CAP_STURCTURE  PciExpressCap;
+  EFI_STATUS          Status;
+  UINT64              CapRegAddress;
+  UINT8               Bus;
+  UINT8               Dev;
+  UINT8               Func;
+  UINT8               *ExRegBuffer;
+  UINTN               ExtendRegSize;
+  UINT64              Pciex_Address;
+  UINT8               DevicePortType;
+  UINTN               Index;
+  UINT8               *RegAddr;
+  UINTN               RegValue;
+
+  CapRegAddress = Address + CapabilityPtr;
+  IoDev->Pci.Read (
+              IoDev,
+              EfiPciWidthUint32,
+              CapRegAddress,
+              sizeof (PciExpressCap) / sizeof (UINT32),
+              &PciExpressCap
+              );
+
+  DevicePortType = (UINT8) PCIE_CAP_DEVICEPORT_TYPE (PciExpressCap.PcieCapReg);
+  
+  Print (L"\nPci Express device capability structure:\n");
+
+  for (Index = 0; PcieExplainList[Index].Type < PcieExplainTypeMax; Index++) {
+    if (GetExecutionBreak ()) {
+      goto Done;
+    }
+    RegAddr = ((UINT8 *) &PciExpressCap) + PcieExplainList[Index].Offset;
+    switch (PcieExplainList[Index].Width) {
+      case FieldWidthUINT8:
+        RegValue = *(UINT8 *) RegAddr;
+        break;
+      case FieldWidthUINT16:
+        RegValue = *(UINT16 *) RegAddr;
+        break;
+      case FieldWidthUINT32:
+        RegValue = *(UINT32 *) RegAddr;
+        break;
+      default:
+        RegValue = 0;
+        break;
+    }
+    PrintToken (
+      PcieExplainList[Index].Token,
+      HiiHandle,
+      PcieExplainList[Index].Offset,
+      RegValue
+      );
+    if (PcieExplainList[Index].Func == NULL) {
+      continue;
+    }
+    switch (PcieExplainList[Index].Type) {
+      case PcieExplainTypeLink:
+        //
+        // Link registers should not be used by
+        // a) Root Complex Integrated Endpoint
+        // b) Root Complex Event Collector
+        //
+        if (DevicePortType == PCIE_ROOT_COMPLEX_INTEGRATED_PORT ||
+            DevicePortType == PCIE_ROOT_COMPLEX_EVENT_COLLECTOR) {
+          continue;
+        }
+        break;
+      case PcieExplainTypeSlot:
+        //
+        // Slot registers are only valid for
+        // a) Root Port of PCI Express Root Complex
+        // b) Downstream Port of PCI Express Switch
+        // and when SlotImplemented bit is set in PCIE cap register.
+        //
+        if ((DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT &&
+             DevicePortType != PCIE_SWITCH_DOWNSTREAM_PORT) ||
+            !PCIE_CAP_SLOT_IMPLEMENTED (PciExpressCap.PcieCapReg)) {
+          continue;
+        }
+        break;
+      case PcieExplainTypeRoot:
+        //
+        // Root registers are only valid for
+        // Root Port of PCI Express Root Complex
+        //
+        if (DevicePortType != PCIE_ROOT_COMPLEX_ROOT_PORT) {
+          continue;
+        }
+        break;
+      default:
+        break;
+    }
+    PcieExplainList[Index].Func (&PciExpressCap);
+  }
 
   Bus           = (UINT8) (RShiftU64 (Address, 24));
   Dev           = (UINT8) (RShiftU64 (Address, 16));
@@ -2297,7 +3157,7 @@ PciExplainPciExpress (
   //
   Print (L"\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\n\n");
 
-  DumpHex (
+  PrivateDumpHex (
     2,
     0x100,
     ExtendRegSize,
@@ -2305,6 +3165,8 @@ PciExplainPciExpress (
     );
 
   FreePool ((VOID *) ExRegBuffer);
+
+Done:
   return EFI_SUCCESS;
 }
 
index 7e1ab5f..0716bee 100644 (file)
--- a/pci/pci.h
+++ b/pci/pci.h
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -46,6 +46,7 @@ typedef enum {
 #define MAX_FUNCTION_NUMBER           7
 
 #define EFI_PCI_CAPABILITY_ID_PCIEXP  0x10
+#define EFI_PCI_CAPABILITY_ID_PCIX    0x07
 
 #define EFI_PCI_STATUS_CAPABILITY     0x0010
 
@@ -75,6 +76,265 @@ typedef enum {
 #define PCI_BIT_14                                    0x00004000
 #define PCI_BIT_15                                    0x00008000
 
+//
+// PCIE device/port types
+//
+#define PCIE_PCIE_ENDPOINT                            0
+#define PCIE_LEGACY_PCIE_ENDPOINT                     1
+#define PCIE_ROOT_COMPLEX_ROOT_PORT                   4
+#define PCIE_SWITCH_UPSTREAM_PORT                     5
+#define PCIE_SWITCH_DOWNSTREAM_PORT                   6
+#define PCIE_PCIE_TO_PCIX_BRIDGE                      7
+#define PCIE_PCIX_TO_PCIE_BRIDGE                      8
+#define PCIE_ROOT_COMPLEX_INTEGRATED_PORT             9
+#define PCIE_ROOT_COMPLEX_EVENT_COLLECTOR             10
+#define PCIE_DEVICE_PORT_TYPE_MAX                     11
+
+#define IS_PCIE_ENDPOINT(DevicePortType) \
+    ((DevicePortType) == PCIE_PCIE_ENDPOINT || \
+     (DevicePortType) == PCIE_LEGACY_PCIE_ENDPOINT || \
+     (DevicePortType) == PCIE_ROOT_COMPLEX_INTEGRATED_PORT)
+
+#define IS_PCIE_SWITCH(DevicePortType) \
+    ((DevicePortType == PCIE_SWITCH_UPSTREAM_PORT) || \
+     (DevicePortType == PCIE_SWITCH_DOWNSTREAM_PORT))
+
+//
+// Capabilities Register
+//
+#define PCIE_CAP_VERSION(PcieCapReg) \
+    ((PcieCapReg) & 0x0f)
+#define PCIE_CAP_DEVICEPORT_TYPE(PcieCapReg) \
+    (((PcieCapReg) >> 4) & 0x0f)
+#define PCIE_CAP_SLOT_IMPLEMENTED(PcieCapReg) \
+    (((PcieCapReg) >> 8) & 0x1)
+#define PCIE_CAP_INT_MSG_NUM(PcieCapReg) \
+    (((PcieCapReg) >> 9) & 0x1f)
+//
+// Device Capabilities Register
+//
+#define PCIE_CAP_MAX_PAYLOAD(PcieDeviceCap) \
+    ((PcieDeviceCap) & 0x7)
+#define PCIE_CAP_PHANTOM_FUNC(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 3) & 0x3)
+#define PCIE_CAP_EXTENDED_TAG(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 5) & 0x1)
+#define PCIE_CAP_L0sLatency(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 6) & 0x7)
+#define PCIE_CAP_L1Latency(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 9) & 0x7)
+#define PCIE_CAP_ERR_REPORTING(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 15) & 0x1)
+#define PCIE_CAP_SLOT_POWER_VALUE(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 18) & 0x0ff)
+#define PCIE_CAP_SLOT_POWER_SCALE(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 26) & 0x3)
+#define PCIE_CAP_FUNC_LEVEL_RESET(PcieDeviceCap) \
+    (((PcieDeviceCap) >> 28) & 0x1)
+//
+// Device Control Register
+//
+#define PCIE_CAP_COR_ERR_REPORTING_ENABLE(PcieDeviceControl) \
+    ((PcieDeviceControl) & 0x1)
+#define PCIE_CAP_NONFAT_ERR_REPORTING_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 1) & 0x1)
+#define PCIE_CAP_FATAL_ERR_REPORTING_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 2) & 0x1)
+#define PCIE_CAP_UNSUP_REQ_REPORTING_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 3) & 0x1)
+#define PCIE_CAP_RELAXED_ORDERING_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 4) & 0x1)
+#define PCIE_CAP_MAX_PAYLOAD_SIZE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 5) & 0x7)
+#define PCIE_CAP_EXTENDED_TAG_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 8) & 0x1)
+#define PCIE_CAP_PHANTOM_FUNC_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 9) & 0x1)
+#define PCIE_CAP_AUX_PM_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 10) & 0x1)
+#define PCIE_CAP_NO_SNOOP_ENABLE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 11) & 0x1)
+#define PCIE_CAP_MAX_READ_REQ_SIZE(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 12) & 0x7)
+#define PCIE_CAP_BRG_CONF_RETRY(PcieDeviceControl) \
+    (((PcieDeviceControl) >> 15) & 0x1)
+//
+// Device Status Register
+//
+#define PCIE_CAP_COR_ERR_DETECTED(PcieDeviceStatus) \
+    ((PcieDeviceStatus) & 0x1)
+#define PCIE_CAP_NONFAT_ERR_DETECTED(PcieDeviceStatus) \
+    (((PcieDeviceStatus) >> 1) & 0x1)
+#define PCIE_CAP_FATAL_ERR_DETECTED(PcieDeviceStatus) \
+    (((PcieDeviceStatus) >> 2) & 0x1)
+#define PCIE_CAP_UNSUP_REQ_DETECTED(PcieDeviceStatus) \
+    (((PcieDeviceStatus) >> 3) & 0x1)
+#define PCIE_CAP_AUX_POWER_DETECTED(PcieDeviceStatus) \
+    (((PcieDeviceStatus) >> 4) & 0x1)
+#define PCIE_CAP_TRANSACTION_PENDING(PcieDeviceStatus) \
+    (((PcieDeviceStatus) >> 5) & 0x1)
+//
+// Link Capabilities Register
+//
+#define PCIE_CAP_SUP_LINK_SPEEDS(PcieLinkCap) \
+    ((PcieLinkCap) & 0x0f)
+#define PCIE_CAP_MAX_LINK_WIDTH(PcieLinkCap) \
+    (((PcieLinkCap) >> 4) & 0x3f)
+#define PCIE_CAP_ASPM_SUPPORT(PcieLinkCap) \
+    (((PcieLinkCap) >> 10) & 0x3)
+#define PCIE_CAP_L0s_LATENCY(PcieLinkCap) \
+    (((PcieLinkCap) >> 12) & 0x7)
+#define PCIE_CAP_L1_LATENCY(PcieLinkCap) \
+    (((PcieLinkCap) >> 15) & 0x7)
+#define PCIE_CAP_CLOCK_PM(PcieLinkCap) \
+    (((PcieLinkCap) >> 18) & 0x1)
+#define PCIE_CAP_SUP_DOWN_ERR_REPORTING(PcieLinkCap) \
+    (((PcieLinkCap) >> 19) & 0x1)
+#define PCIE_CAP_LINK_ACTIVE_REPORTING(PcieLinkCap) \
+    (((PcieLinkCap) >> 20) & 0x1)
+#define PCIE_CAP_LINK_BWD_NOTIF_CAP(PcieLinkCap) \
+    (((PcieLinkCap) >> 21) & 0x1)
+#define PCIE_CAP_PORT_NUMBER(PcieLinkCap) \
+    (((PcieLinkCap) >> 24) & 0x0ff)
+//
+// Link Control Register
+//
+#define PCIE_CAP_ASPM_CONTROL(PcieLinkControl) \
+    ((PcieLinkControl) & 0x3)
+#define PCIE_CAP_RCB(PcieLinkControl) \
+    (((PcieLinkControl) >> 3) & 0x1)
+#define PCIE_CAP_LINK_DISABLE(PcieLinkControl) \
+    (((PcieLinkControl) >> 4) & 0x1)
+#define PCIE_CAP_COMMON_CLK_CONF(PcieLinkControl) \
+    (((PcieLinkControl) >> 6) & 0x1)
+#define PCIE_CAP_EXT_SYNC(PcieLinkControl) \
+    (((PcieLinkControl) >> 7) & 0x1)
+#define PCIE_CAP_CLK_PWR_MNG(PcieLinkControl) \
+    (((PcieLinkControl) >> 8) & 0x1)
+#define PCIE_CAP_HW_AUTO_WIDTH_DISABLE(PcieLinkControl) \
+    (((PcieLinkControl) >> 9) & 0x1)
+#define PCIE_CAP_LINK_BDW_MNG_INT_EN(PcieLinkControl) \
+    (((PcieLinkControl) >> 10) & 0x1)
+#define PCIE_CAP_LINK_AUTO_BDW_INT_EN(PcieLinkControl) \
+    (((PcieLinkControl) >> 11) & 0x1)
+//
+// Link Status Register
+//
+#define PCIE_CAP_CUR_LINK_SPEED(PcieLinkStatus) \
+    ((PcieLinkStatus) & 0x0f)
+#define PCIE_CAP_NEGO_LINK_WIDTH(PcieLinkStatus) \
+    (((PcieLinkStatus) >> 4) & 0x3f)
+#define PCIE_CAP_LINK_TRAINING(PcieLinkStatus) \
+    (((PcieLinkStatus) >> 11) & 0x1)
+#define PCIE_CAP_SLOT_CLK_CONF(PcieLinkStatus) \
+    (((PcieLinkStatus) >> 12) & 0x1)
+#define PCIE_CAP_DATA_LINK_ACTIVE(PcieLinkStatus) \
+    (((PcieLinkStatus) >> 13) & 0x1)
+#define PCIE_CAP_LINK_BDW_MNG_STAT(PcieLinkStatus) \
+    (((PcieLinkStatus) >> 14) & 0x1)
+#define PCIE_CAP_LINK_AUTO_BDW_STAT(PcieLinkStatus) \
+    (((PcieLinkStatus) >> 15) & 0x1)
+//
+// Slot Capabilities Register
+//
+#define PCIE_CAP_ATT_BUT_PRESENT(PcieSlotCap) \
+    ((PcieSlotCap) & 0x1)
+#define PCIE_CAP_PWR_CTRLLER_PRESENT(PcieSlotCap) \
+    (((PcieSlotCap) >> 1) & 0x1)
+#define PCIE_CAP_MRL_SENSOR_PRESENT(PcieSlotCap) \
+    (((PcieSlotCap) >> 2) & 0x1)
+#define PCIE_CAP_ATT_IND_PRESENT(PcieSlotCap) \
+    (((PcieSlotCap) >> 3) & 0x1)
+#define PCIE_CAP_PWD_IND_PRESENT(PcieSlotCap) \
+    (((PcieSlotCap) >> 4) & 0x1)
+#define PCIE_CAP_HOTPLUG_SUPPRISE(PcieSlotCap) \
+    (((PcieSlotCap) >> 5) & 0x1)
+#define PCIE_CAP_HOTPLUG_CAPABLE(PcieSlotCap) \
+    (((PcieSlotCap) >> 6) & 0x1)
+#define PCIE_CAP_SLOT_PWR_LIMIT_VALUE(PcieSlotCap) \
+    (((PcieSlotCap) >> 7) & 0x0ff)
+#define PCIE_CAP_SLOT_PWR_LIMIT_SCALE(PcieSlotCap) \
+    (((PcieSlotCap) >> 15) & 0x3)
+#define PCIE_CAP_ELEC_INTERLOCK_PRESENT(PcieSlotCap) \
+    (((PcieSlotCap) >> 17) & 0x1)
+#define PCIE_CAP_NO_COMM_COMPLETED_SUP(PcieSlotCap) \
+    (((PcieSlotCap) >> 18) & 0x1)
+#define PCIE_CAP_PHY_SLOT_NUM(PcieSlotCap) \
+    (((PcieSlotCap) >> 19) & 0x1fff)
+//
+// Slot Control Register
+//
+#define PCIE_CAP_ATT_BUT_ENABLE(PcieSlotControl) \
+    ((PcieSlotControl) & 0x1)
+#define PCIE_CAP_PWR_FLT_DETECT_ENABLE(PcieSlotControl) \
+    (((PcieSlotControl) >> 1) & 0x1)
+#define PCIE_CAP_MRL_SENSOR_CHANGE_ENABLE(PcieSlotControl) \
+    (((PcieSlotControl) >> 2) & 0x1)
+#define PCIE_CAP_PRES_DETECT_CHANGE_ENABLE(PcieSlotControl) \
+    (((PcieSlotControl) >> 3) & 0x1)
+#define PCIE_CAP_COMM_CMPL_INT_ENABLE(PcieSlotControl) \
+    (((PcieSlotControl) >> 4) & 0x1)
+#define PCIE_CAP_HOTPLUG_INT_ENABLE(PcieSlotControl) \
+    (((PcieSlotControl) >> 5) & 0x1)
+#define PCIE_CAP_ATT_IND_CTRL(PcieSlotControl) \
+    (((PcieSlotControl) >> 6) & 0x3)
+#define PCIE_CAP_PWR_IND_CTRL(PcieSlotControl) \
+    (((PcieSlotControl) >> 8) & 0x3)
+#define PCIE_CAP_PWR_CTRLLER_CTRL(PcieSlotControl) \
+    (((PcieSlotControl) >> 10) & 0x1)
+#define PCIE_CAP_ELEC_INTERLOCK_CTRL(PcieSlotControl) \
+    (((PcieSlotControl) >> 11) & 0x1)
+#define PCIE_CAP_DLINK_STAT_CHANGE_ENABLE(PcieSlotControl) \
+    (((PcieSlotControl) >> 12) & 0x1)
+//
+// Slot Status Register
+//
+#define PCIE_CAP_ATT_BUT_PRESSED(PcieSlotStatus) \
+    ((PcieSlotStatus) & 0x1)
+#define PCIE_CAP_PWR_FLT_DETECTED(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 1) & 0x1)
+#define PCIE_CAP_MRL_SENSOR_CHANGED(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 2) & 0x1)
+#define PCIE_CAP_PRES_DETECT_CHANGED(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 3) & 0x1)
+#define PCIE_CAP_COMM_COMPLETED(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 4) & 0x1)
+#define PCIE_CAP_MRL_SENSOR_STATE(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 5) & 0x1)
+#define PCIE_CAP_PRES_DETECT_STATE(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 6) & 0x1)
+#define PCIE_CAP_ELEC_INTERLOCK_STATE(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 7) & 0x1)
+#define PCIE_CAP_DLINK_STAT_CHANGED(PcieSlotStatus) \
+    (((PcieSlotStatus) >> 8) & 0x1)
+//
+// Root Control Register
+//
+#define PCIE_CAP_SYSERR_ON_CORERR_EN(PcieRootControl) \
+    ((PcieRootControl) & 0x1)
+#define PCIE_CAP_SYSERR_ON_NONFATERR_EN(PcieRootControl) \
+    (((PcieRootControl) >> 1) & 0x1)
+#define PCIE_CAP_SYSERR_ON_FATERR_EN(PcieRootControl) \
+    (((PcieRootControl) >> 2) & 0x1)
+#define PCIE_CAP_PME_INT_ENABLE(PcieRootControl) \
+    (((PcieRootControl) >> 3) & 0x1)
+#define PCIE_CAP_CRS_SW_VIS_ENABLE(PcieRootControl) \
+    (((PcieRootControl) >> 4) & 0x1)
+//
+// Root Capabilities Register
+//
+#define PCIE_CAP_CRS_SW_VIS(PcieRootCap) \
+    ((PcieRootCap) & 0x1)
+//
+// Root Status Register
+//
+#define PCIE_CAP_PME_REQ_ID(PcieRootStatus) \
+    ((PcieRootStatus) & 0x0ffff)
+#define PCIE_CAP_PME_STATUS(PcieRootStatus) \
+    (((PcieRootStatus) >> 16) & 0x1)
+#define PCIE_CAP_PME_PENDING(PcieRootStatus) \
+    (((PcieRootStatus) >> 17) & 0x1)
+
 #pragma pack(1)
 //
 // Common part of the PCI configuration space header for devices, P2P bridges,
index 6c8b564..226715b 100644 (file)
Binary files a/shellenv/ShellenvHelpStrings.uni and b/shellenv/ShellenvHelpStrings.uni differ
index ea7043f..b390e67 100644 (file)
Binary files a/shellenv/ShellenvStrings.uni and b/shellenv/ShellenvStrings.uni differ
index b41dd4e..d19a833 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -54,7 +54,11 @@ STATIC CHAR16 *SEnvDP_MessageStr[] = {
   L"IPv4",
   L"IPv6",
   L"UART",
-  L"USB Class"
+  L"USB Class",
+  L"USB WWID",
+  L"Device Logical Unit",
+  L"SATA",
+  L"iSCSI"
 };
 
 STATIC CHAR16 *SEnvDP_MediaStr[] = {
@@ -63,7 +67,9 @@ STATIC CHAR16 *SEnvDP_MediaStr[] = {
   L"CD-ROM",
   L"Vender-Defined",
   L"File Path",
-  L"Media Protocol"
+  L"Media Protocol",
+  L"PIWG FV",
+  L"PIWG Firmware File",
 };
 
 STATIC CHAR16 *SEnvDP_BBS_Str[] = { L"Illegal", L"BIOS Boot Spec" };
@@ -668,12 +674,12 @@ struct DevicePathTypes  SEnvDP_Strings[] = {
   SEnvDP_ACPI_Str,
   SEnvAcpiDevicePathEntry,
   0x03,
-  0x0f,
+  0x13,
   L"Messaging",
   SEnvDP_MessageStr,
   SEnvMessagingDevicePathEntry,
   0x04,
-  0x05,
+  0x07,
   L"Media",
   SEnvDP_MediaStr,
   SEnvMediaDevicePathEntry,
@@ -831,6 +837,54 @@ Returns:
   }
 }
 
+VOID
+EFIAPI
+SEnvImageDPathTok (
+  IN EFI_HANDLE   h,
+  IN VOID         *Interface
+  )
+/*++
+
+Routine Description:
+
+Arguments:
+
+  h         - An EFI handle
+  Interface - The interface
+
+Returns:
+
+--*/
+{
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+  CHAR16                    *Str;
+  CHAR16                    *Disp;
+  UINTN                     Len;
+
+  DevicePath  = Interface;
+  Str         = LibDevicePathToStr (DevicePath);
+  Disp        = L"";
+
+  //
+  // Print device path token
+  //
+  if (Str) {
+    Len   = StrLen (Str);
+    Disp  = Str;
+    if (Len > 30) {
+      Disp    = Str + Len - 30;
+      Disp[0] = '.';
+      Disp[1] = '.';
+    }
+  }
+
+  PrintToken (STRING_TOKEN (STR_SHELLENV_DPROT_IMAGE_DEVPATH), HiiEnvHandle, Disp);
+
+  if (Str) {
+    FreePool (Str);
+  }
+}
+
 VOID
 EFIAPI
 SEnvTextOut (
@@ -1616,3 +1670,37 @@ SEnvGraphicsOutput (
     Mode->FrameBufferSize
     );
 }
+
+VOID
+EFIAPI
+SEnvDriverEFIVersion (
+  IN EFI_HANDLE      h,
+  IN VOID            *Interface
+  )
+{
+  EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;
+
+  DriverEfiVersion = (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *) Interface;
+  PrintToken (
+    STRING_TOKEN (STR_SHELLENV_PROTID_DRV_EFI_VER),
+    HiiEnvHandle,
+    DriverEfiVersion->FirmwareVersion
+    );
+}
+
+VOID
+EFIAPI
+SEnvDriverEFIVersionTok (
+  IN EFI_HANDLE      h,
+  IN VOID            *Interface
+  )
+{
+  EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *DriverEfiVersion;
+
+  DriverEfiVersion = (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL *) Interface;
+  PrintToken (
+    STRING_TOKEN (STR_SHELLENV_PROTID_DRV_EFI_VER_TOK),
+    HiiEnvHandle,
+    DriverEfiVersion->FirmwareVersion
+    );
+}
\ No newline at end of file
index 1debf66..dad9002 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2007, 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         
@@ -25,13 +25,6 @@ Revision History
 #include "shellenvguid.h"
 
 extern UINT8              STRING_ARRAY_NAME[];
-extern EFI_STATUS
-FakeInitializeHiiDatabase (
-  EFI_HANDLE,
-  EFI_SYSTEM_TABLE *,
-  EFI_HII_PROTOCOL **
-  );
-
 EFI_LIST_ENTRY            SEnvCurMapping;
 ENV_SHELL_INTERFACE_ITEM  *mOldSEnv = NULL;
 //
index da1733a..27c8154 100644 (file)
@@ -56,8 +56,6 @@ typedef struct {
 typedef struct {
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
   CHAR16                    *ConsistMappingName;
-  CHAR16                    *FSName;
-  CHAR16                    *BlkName;
   EFI_HANDLE                Handle;
   UINTN                     MediaType;
   BOOLEAN                   Removeable;
@@ -65,6 +63,25 @@ typedef struct {
   BOOLEAN                   FSDevice;
 } MAPPING_NAME_INFO;
 
+#define MAPPING_HISTORY_NODE_SIGNATURE EFI_SIGNATURE_32 ('m', 'h', 'n', 's')
+
+typedef enum {
+  MappingNodeBlockFs,
+  MappingNodeNT,
+  MappingNodeBlock,
+  MappingNodeCustomize,
+  MappingNodeMax
+} MAPPING_NODE_TYPE;
+
+typedef struct {
+  UINT32                    Signature;
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+  CHAR16                    *Name;
+  BOOLEAN                   Valid;
+  MAPPING_NODE_TYPE         NodeType;
+  EFI_LIST_ENTRY            Link;
+} MAPPING_HISTORY_NODE;
+
 #define MediaFloppy         0x01
 #define MediaHardDisk       0x02
 #define MediaCDRom          0x04
@@ -113,7 +130,7 @@ SHELL_VAR_CHECK_ITEM    MapCheckList[] = {
   {
     L"-r",
     0x01,
-    0x4,
+    0x104,
     FlagTypeSingle
   },
   {
@@ -158,6 +175,12 @@ SHELL_VAR_CHECK_ITEM    MapCheckList[] = {
     0,
     FlagTypeSingle
   },
+  {
+    L"-u",
+    0x100,
+    0x5,
+    FlagTypeSingle
+  },
   {
     NULL,
     0,
@@ -198,6 +221,8 @@ extern EFI_LIST_ENTRY SEnvMap;
 
 STATIC CHAR16         *SEnvCurDevice;
 
+STATIC EFI_LIST_ENTRY SEnvMapHistory;
+
 //
 // Private worker function prototypes
 //
@@ -240,7 +265,7 @@ CopyToDefaultMappingTable (
 
 EFI_STATUS
 Remapping (
-  VOID
+  BOOLEAN  KeepHistory
   );
 
 EFI_STATUS
@@ -261,6 +286,52 @@ SEnvCmdMapOld (
   IN EFI_SYSTEM_TABLE         *SystemTable
   );
 
+STATIC
+EFI_STATUS
+CheckCdFilePath (
+  IN   EFI_DEVICE_PATH_PROTOCOL  *FilePath,
+  OUT  CHAR16                    **AbsoluteDir
+  );
+
+STATIC
+VOID
+InitializeMapHistory (
+  VOID
+  );
+
+STATIC
+VOID
+AddHistoryMappingNamesToVariable (
+  VOID
+  );
+
+STATIC
+VOID
+InvalidMappingHistory (
+  VOID
+  );
+
+STATIC
+EFI_STATUS
+ObtainHistoryMappingName (
+  IN   EFI_DEVICE_PATH_PROTOCOL  *DevicePath,
+  IN   CHAR16                    *MappingName,
+  IN   MAPPING_NODE_TYPE         NodeType,
+  OUT  CHAR16                    **MappingNameObtained
+  );
+
+STATIC
+VOID
+RemoveHistoryMappingName (
+  IN   CHAR16  *Name
+  );
+
+STATIC
+VOID
+ClearHistoryMapping (
+  VOID
+  );
+
 //
 // Function implementation
 //
@@ -282,6 +353,7 @@ Returns:
   // Init the default map device
   //
   SEnvCurDevice = StrDuplicate (L"none");
+  InitializeMapHistory ();
 }
 
 BOOLEAN
@@ -646,6 +718,7 @@ Returns:
   BOOLEAN                 Delete;
   BOOLEAN                 Verbose;
   BOOLEAN                 Remap;
+  BOOLEAN                 KeepHistory;
   EFI_STATUS              Status;
   EFI_HANDLE              Handle;
   UINTN                   ShowType;
@@ -656,6 +729,8 @@ Returns:
   CHAR16                  *Useful;
   SHELL_ARG_LIST          *Item;
   SHELL_VAR_CHECK_PACKAGE ChkPck;
+  
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
 
   ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
   if (IS_OLD_SHELL) {
@@ -688,6 +763,7 @@ Returns:
   Delete    = FALSE;
   Verbose   = FALSE;
   Remap     = FALSE;
+  KeepHistory = FALSE;
   Status    = EFI_SUCCESS;
   Found     = NULL;
   ShowType  = ShowNull;
@@ -777,6 +853,16 @@ Returns:
     Remap = TRUE;
   }
 
+  if (LibCheckVarGetFlag (&ChkPck, L"-u") != NULL) {
+    if (SI->RedirArgc != 0) {
+      LibCheckVarFreeVarList (&ChkPck);
+      return EFI_REDIRECTION_NOT_ALLOWED;
+    }
+
+    Remap       = TRUE;
+    KeepHistory = TRUE;
+  }
+
   if (LibCheckVarGetFlag (&ChkPck, L"-c") != NULL) {
     ShowType |= ShowConsistMapping;
   }
@@ -843,7 +929,7 @@ Returns:
   // Process
   //
   if (Remap && !Value && !Delete) {
-    Status  = Remapping ();
+    Status  = Remapping (KeepHistory);
     Remap   = FALSE;
   }
 
@@ -870,7 +956,8 @@ Returns:
         if (EFI_ERROR (Status)) {
           goto Done;
         }
-
+        
+        RemoveHistoryMappingName (Var->Name);
         RemoveEntryList (&Found->Link);
         FreePool (Found);
       }
@@ -910,6 +997,15 @@ Returns:
       if (EFI_ERROR (Status)) {
         goto Done;
       }
+      DevicePath = DevicePathFromHandle (Handle);
+      if (DevicePath != NULL) {
+        ObtainHistoryMappingName (
+          DevicePath,
+          Name,
+          MappingNodeCustomize,
+          NULL
+          );
+      }
     } else {
       SEnvAddVarToList (
         &SEnvMap,
@@ -925,6 +1021,12 @@ Returns:
             DevicePathSize ((VOID *) Var->u.Str),
             Var->u.Str
             );
+      ObtainHistoryMappingName (
+        (EFI_DEVICE_PATH_PROTOCOL  *) Var->u.Str,
+        Name,
+        MappingNodeCustomize,
+        NULL
+        );
     }
 
     if (Found != NULL) {
@@ -1292,11 +1394,9 @@ Returns:
 {
   EFI_DEVICE_PATH_PROTOCOL  *FilePath;
   EFI_STATUS                Status;
-  EFI_FILE_HANDLE           OpenDir;
   CHAR16                    *Dir;
   CHAR16                    *CurDir;
   VARIABLE_ID               *Var;
-  EFI_FILE_INFO             *FileInfo;
   SHELL_VAR_CHECK_PACKAGE   ChkPck;
   SHELL_VAR_CHECK_CODE      RetCode;
   CHAR16                    *Useful;
@@ -1413,40 +1513,24 @@ Returns:
    Status = EFI_NOT_FOUND;
    goto Done;
   }
-  //
-  // Open the target directory
-  //
-  OpenDir = LibOpenFilePath (FilePath, EFI_FILE_MODE_READ);
 
-  if (!OpenDir) {
-    PrintToken (STRING_TOKEN (STR_SHELLENV_CD_TARGET_DIR_NOT_FOUND), HiiEnvHandle, L"cd");
-    Status = EFI_NOT_FOUND;
-    goto Done;
-  }
-  //
-  // Get information on the file path that was opened.
-  //
-  FileInfo = LibGetFileInfo (OpenDir);
-  if (FileInfo == NULL) {
-    Status = EFI_NOT_FOUND;
-    goto Done;
+  CurDir = NULL;
+  Status = CheckCdFilePath (FilePath, &CurDir);
+  switch (Status) {
+    case EFI_NOT_FOUND:
+      PrintToken (STRING_TOKEN (STR_SHELLENV_CD_TARGET_DIR_NOT_FOUND), HiiEnvHandle, L"cd");
+      break;
+    case EFI_ACCESS_DENIED:
+      PrintToken (STRING_TOKEN (STR_SHELLENV_CD_TARGET_NOT_DIR), HiiEnvHandle, L"cd");
+      break;
+    default:
+      break;
   }
-  //
-  // Verify that the file opened is a directory.
-  //
-  if (!(FileInfo->Attribute & EFI_FILE_DIRECTORY)) {
-    PrintToken (STRING_TOKEN (STR_SHELLENV_CD_TARGET_NOT_DIR), HiiEnvHandle, L"cd");
-    FreePool (FileInfo);
-    OpenDir->Close (OpenDir);
+  if (EFI_ERROR (Status)) {
     Status = EFI_NOT_FOUND;
     goto Done;
   }
 
-  FreePool (FileInfo);
-
-  CurDir = SEnvFileHandleToFileName (OpenDir);
-  OpenDir->Close (OpenDir);
-
   //
   // If we have a new path, update the device
   //
@@ -2122,20 +2206,22 @@ CheckMediaChange (
     if (!EFI_ERROR (Status)) {
       if (!BlkIo->Media->LogicalPartition) {
         Buffer = AllocatePool (BlkIo->Media->BlockSize);
-        BlkIo->ReadBlocks (
+        Status = BlkIo->ReadBlocks (
+                    BlkIo,
+                    BlkIo->Media->MediaId,
+                    0,
+                    BlkIo->Media->BlockSize,
+                    Buffer
+                    );
+        FreePool (Buffer);
+        if (EFI_ERROR (Status)) {
+          BS->ReinstallProtocolInterface (
+                ProtBlkIo->Handles[Index],
+                &gEfiBlockIoProtocolGuid,
                 BlkIo,
-                BlkIo->Media->MediaId,
-                0,
-                BlkIo->Media->BlockSize,
-                Buffer
+                BlkIo
                 );
-        FreePool (Buffer);
-        BS->ReinstallProtocolInterface (
-              ProtBlkIo->Handles[Index],
-              &gEfiBlockIoProtocolGuid,
-              BlkIo,
-              BlkIo
-              );
+        }
       }
     }
   }
@@ -2146,7 +2232,7 @@ CheckMediaChange (
 
 EFI_STATUS
 Remapping (
-  VOID
+  BOOLEAN KeepHistory
   )
 {
   PROTOCOL_INFO             *ProtFs;
@@ -2158,16 +2244,16 @@ Remapping (
   UINTN                     MappingCount;
   MAPPING_NAME_INFO         **MappingTable;
   EFI_DEVICE_PATH_PROTOCOL  **HITable;
-  UINTN                     BlkCount;
-  UINTN                     FsntCount;
   UINTN                     MappingInfoCount;
   POOL_PRINT                Path;
+  CHAR16                    *CurDir;
+  CHAR16                    *CurDev;
+  UINTN                     CurDirSize;
+  EFI_DEVICE_PATH_PROTOCOL  *FilePath;
 
   VARIABLE_ID               *Var;
 
   HITable   = NULL;
-  BlkCount  = 0;
-  FsntCount = 0;
 
   ZeroMem (&Path, sizeof (Path));
 
@@ -2179,6 +2265,19 @@ Remapping (
   // Delete all the old mappings
   //
   AcquireLock (&SEnvLock);
+  //
+  // Save current file path first if history is kept
+  //
+  CurDir = NULL;
+  CurDev = SEnvCurDevice;
+  if (KeepHistory && CurDev != NULL) {
+    Var = SEnvMapDeviceFromName (&CurDev);
+    if (Var != NULL && Var->CurDir != NULL) {
+      CurDirSize = StrSize (Var->CurDir);
+      CurDir = AllocateZeroPool (CurDirSize);
+      StrCpy (CurDir, Var->CurDir);
+    }
+  }
   while (!IsListEmpty (&SEnvMap)) {
     Var = CR (SEnvMap.Flink, VARIABLE_ID, Link, VARIABLE_SIGNATURE);
     Status = RT->SetVariable (
@@ -2192,6 +2291,12 @@ Remapping (
     FreePool (Var);
   }
 
+  if (!KeepHistory) {
+    ClearHistoryMapping ();
+  }
+
+  InvalidMappingHistory ();
+
   SEnvLoadHandleTable ();
   SEnvLoadHandleProtocolInfo (NULL);
 
@@ -2255,57 +2360,35 @@ Remapping (
   //
   QSort (MappingTable, MappingInfoCount, sizeof (MAPPING_NAME_INFO *), CompareMappingInfo);
 
-  BlkCount  = 0;
-  FsntCount = 0;
   for (Index = 0; Index < MappingInfoCount; Index++) {
-    //
-    //  Suppose the Blkname and FSname is not too large.
-    //
-    //  the blkname and the fsname is:
-    //
-    //  fsnt0
-    //  fsnt1
-    //  fsnt2
-    //  ...
-    //  fsnt(l)
-    //  fs0  .............  blk0
-    //  fs1  .............  blk1
-    //  fs2  .............  blk2
-    //  ...
-    //  fs(m).............  blk(m)
-    //                      blk(m+1)
-    //                      ...
-    //                      blk(n)
-    //
     if (MappingTable[Index]->BlkDevice) {
-      MappingTable[Index]->BlkName = AllocateZeroPool (0x20);
-      SPrint (MappingTable[Index]->BlkName, 0x20, L"blk%x", BlkCount);
+      ObtainHistoryMappingName (
+        MappingTable[Index]->DevicePath,
+        NULL,
+        MappingNodeBlock,
+        NULL
+        );
       if (MappingTable[Index]->FSDevice) {
-        MappingTable[Index]->FSName = AllocateZeroPool (0x20);
-        SPrint (MappingTable[Index]->FSName, 0x20, L"fs%x", BlkCount);
+        ObtainHistoryMappingName (
+          MappingTable[Index]->DevicePath,
+          NULL,
+          MappingNodeBlockFs,
+          NULL
+          );
       }
-
-      BlkCount++;
     } else {
-      MappingTable[Index]->FSName = AllocateZeroPool (0x20);
-      SPrint (MappingTable[Index]->FSName, 0x20, L"fsnt%x", FsntCount);
-      FsntCount++;
+      ObtainHistoryMappingName (
+        MappingTable[Index]->DevicePath,
+        NULL,
+        MappingNodeNT,
+        NULL
+        );
     }
   }
   //
   //  Add these consist name, fs name, blk name to map name list.
   //
-  for (Index = 0; Index < MappingInfoCount; Index++) {
-    if (MappingTable[Index]->FSName != NULL) {
-      SEnvAddMappingName (MappingTable[Index]->Handle, MappingTable[Index]->FSName, FALSE);
-    }
-  }
-
-  for (Index = 0; Index < MappingInfoCount; Index++) {
-    if (MappingTable[Index]->BlkName != NULL) {
-      SEnvAddMappingName (MappingTable[Index]->Handle, MappingTable[Index]->BlkName, FALSE);
-    }
-  }
+  AddHistoryMappingNamesToVariable ();
 
   for (Index = 0; Index < MappingInfoCount; Index++) {
     if (MappingTable[Index]->ConsistMappingName != NULL && MappingTable[Index]->FSDevice) {
@@ -2343,11 +2426,37 @@ Remapping (
     (Path.len + 1) * sizeof (CHAR16),
     TRUE
     );
-
+  
+  if (!KeepHistory || CurDir == NULL) {
+    goto Done;
+  }
+  //
+  // Attempt to restore current file path
+  //
+  CurDev = SEnvCurDevice;
+  Var    = NULL;
+  if (CurDev != NULL) {
+    Var = SEnvMapDeviceFromName (&CurDev);
+  }
+  if (Var != NULL) {
+    FilePath = SEnvINameToPath (CurDir);
+    if (!FilePath) {
+      goto Done;
+    }
+    Status = CheckCdFilePath (FilePath, NULL);
+    if (!EFI_ERROR (Status)) {
+      Var->CurDir = StrDuplicate (CurDir);
+    }
+    FreePool (FilePath);
+  }
+  
 Done:
   //
   //  Free the resources.
   //
+  if (CurDir != NULL) {
+    FreePool (CurDir);
+  }
   SEnvFreeHandleTable ();
   ReleaseLock (&SEnvLock);
 
@@ -2360,14 +2469,6 @@ Done:
       FreePool (MappingTable[Index]->DevicePath);
     }
 
-    if (MappingTable[Index]->FSName != NULL) {
-      FreePool (MappingTable[Index]->FSName);
-    }
-
-    if (MappingTable[Index]->BlkName != NULL) {
-      FreePool (MappingTable[Index]->BlkName);
-    }
-
     FreePool (MappingTable[Index]);
   }
 
@@ -3045,3 +3146,264 @@ Done:
   //
   return Status;
 }
+
+STATIC
+EFI_STATUS
+CheckCdFilePath (
+  IN   EFI_DEVICE_PATH_PROTOCOL  *FilePath,
+  OUT  CHAR16                    **AbsoluteDir
+  )
+{
+  EFI_STATUS                Status;
+  EFI_FILE_HANDLE           OpenDir;
+  EFI_FILE_INFO             *FileInfo;
+
+  Status   = EFI_SUCCESS;
+  FileInfo = NULL;
+  //
+  // Open the target directory
+  //
+  OpenDir = LibOpenFilePath (FilePath, EFI_FILE_MODE_READ);
+
+  if (!OpenDir) {
+    Status = EFI_NOT_FOUND;
+    goto Done;
+  }
+  //
+  // Get information on the file path that was opened.
+  //
+  FileInfo = LibGetFileInfo (OpenDir);
+  if (FileInfo == NULL) {
+    Status = EFI_DEVICE_ERROR;
+    goto Done;
+  }
+  //
+  // Verify that the file opened is a directory.
+  //
+  if (!(FileInfo->Attribute & EFI_FILE_DIRECTORY)) {
+    Status = EFI_ACCESS_DENIED;
+    goto Done;
+  }
+
+  if (AbsoluteDir != NULL) {
+    *AbsoluteDir = SEnvFileHandleToFileName (OpenDir);
+  }
+Done:
+  if (FileInfo != NULL) {
+    FreePool (FileInfo);
+  }
+  if (OpenDir != NULL) {
+    OpenDir->Close (OpenDir);
+  }
+  return Status;
+}
+
+STATIC
+VOID
+InitializeMapHistory (
+  VOID
+  )
+{
+  InitializeListHead (&SEnvMapHistory);
+}
+
+STATIC
+VOID
+InvalidMappingHistory (
+  VOID
+  )
+{
+  EFI_LIST_ENTRY       *Head;
+  EFI_LIST_ENTRY       *Link;
+  MAPPING_HISTORY_NODE *HistoryNode;
+
+  Head = &SEnvMapHistory;
+  for (Link = Head->Flink; Link != Head; Link = Link->Flink) {
+    HistoryNode = CR (Link, MAPPING_HISTORY_NODE, Link, MAPPING_HISTORY_NODE_SIGNATURE);
+    HistoryNode->Valid = FALSE;
+  }
+}
+
+STATIC
+EFI_STATUS
+ObtainHistoryMappingName (
+  IN   EFI_DEVICE_PATH_PROTOCOL  *DevicePath,
+  IN   CHAR16                    *MappingName,
+  IN   MAPPING_NODE_TYPE         NodeType,
+  OUT  CHAR16                    **MappingNameObtained
+  )
+{
+  EFI_LIST_ENTRY       *Head;
+  EFI_LIST_ENTRY       *Link;
+  MAPPING_HISTORY_NODE *HistoryNode;
+  BOOLEAN              IsNew;
+  BOOLEAN              Found;
+  UINTN                Index;
+  UINTN                Count;
+  CHAR16               *Name;
+  CHAR16               *Prefix;
+
+  if (NodeType >= MappingNodeMax ||
+      (MappingName == NULL && NodeType == MappingNodeCustomize)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Head  = &SEnvMapHistory;
+  IsNew = TRUE;
+  Count = 0;
+
+  for (Link = Head->Flink; Link != Head; Link = Link->Flink) {
+    HistoryNode = CR (Link, MAPPING_HISTORY_NODE, Link, MAPPING_HISTORY_NODE_SIGNATURE);
+    if (MappingName != NULL &&
+        StrCmp (HistoryNode->Name, MappingName) == 0 &&
+        DevicePathCompare (DevicePath, HistoryNode->DevicePath) != 0) {
+      FreePool (HistoryNode->DevicePath);
+      HistoryNode->DevicePath = DuplicateDevicePath (DevicePath);
+    }
+    if (DevicePathCompare (DevicePath, HistoryNode->DevicePath) == 0) {
+      if (NodeType == HistoryNode->NodeType ||
+          HistoryNode->NodeType == MappingNodeCustomize) {
+        HistoryNode->Valid = TRUE;
+      }
+      if (NodeType == HistoryNode->NodeType) {
+        IsNew = FALSE;
+        if (MappingNameObtained != NULL) {
+          *MappingNameObtained = HistoryNode->Name;
+        }
+      }
+    }
+    Count++;
+  }
+  if (IsNew) {
+    if (MappingName != NULL) {
+      Name = AllocateZeroPool (StrSize (MappingName));
+      StrCpy (Name, MappingName);
+    } else {
+      switch (NodeType) {
+        case MappingNodeBlockFs:
+          Prefix = L"fs";
+          break;
+        case MappingNodeBlock:
+          Prefix = L"blk";
+          break;
+        case MappingNodeNT:
+          Prefix = L"fsnt";
+          break;
+        default:
+          Prefix = L"";
+          //
+          // Should not be here!
+          //
+          ASSERT (FALSE);
+          break;
+      }
+      Name = AllocateZeroPool (0x20);
+      for (Index = 0; Index <= Count; Index++) {
+        Found = FALSE;
+        SPrint (Name, 0x20, L"%s%x", Prefix, Index);
+        for (Link = Head->Flink; Link != Head; Link = Link->Flink) {
+          HistoryNode = CR (Link, MAPPING_HISTORY_NODE, Link, MAPPING_HISTORY_NODE_SIGNATURE);
+          if (StrnCmp (Name, HistoryNode->Name, 0x20) == 0) {
+            Found = TRUE;
+            break;
+          }
+        }
+        if (!Found) {
+          break;
+        }
+        ZeroMem (Name, 0x20);
+      }
+    }
+    HistoryNode = (MAPPING_HISTORY_NODE *) AllocateZeroPool (sizeof (MAPPING_HISTORY_NODE));
+    HistoryNode->Signature  = MAPPING_HISTORY_NODE_SIGNATURE;
+    HistoryNode->DevicePath = DuplicateDevicePath (DevicePath);
+    HistoryNode->Name       = Name;
+    HistoryNode->NodeType   = NodeType;
+    HistoryNode->Valid      = TRUE;
+    InsertTailList (Head, &HistoryNode->Link);
+    if (MappingNameObtained != NULL) {
+      *MappingNameObtained = HistoryNode->Name;
+    }
+  }
+  return EFI_SUCCESS;
+}
+
+STATIC
+VOID
+RemoveHistoryMappingName (
+  IN   CHAR16  *Name
+  )
+{
+  EFI_LIST_ENTRY       *Head;
+  EFI_LIST_ENTRY       *Link;
+  MAPPING_HISTORY_NODE *HistoryNode;
+
+  Head  = &SEnvMapHistory;
+
+  for (Link = Head->Flink; Link != Head; Link = Link->Flink) {
+    HistoryNode = CR (Link, MAPPING_HISTORY_NODE, Link, MAPPING_HISTORY_NODE_SIGNATURE);
+    if (StrCmp (HistoryNode->Name, Name) == 0) {
+      RemoveEntryList (Link);
+      FreePool (HistoryNode->Name);
+      FreePool (HistoryNode->DevicePath);
+      FreePool (HistoryNode);
+      break;
+    }
+  }
+}
+
+STATIC
+VOID
+AddHistoryMappingNamesToVariable (
+  VOID
+  )
+{
+  EFI_LIST_ENTRY       *Head;
+  EFI_LIST_ENTRY       *Link;
+  MAPPING_HISTORY_NODE *HistoryNode;
+  MAPPING_NODE_TYPE    NodeType;
+
+  Head = &SEnvMapHistory;
+
+  for (NodeType = MappingNodeBlockFs; NodeType < MappingNodeMax; NodeType++) {
+    for (Link = Head->Flink; Link != Head; Link = Link->Flink) {
+      HistoryNode = CR (Link, MAPPING_HISTORY_NODE, Link, MAPPING_HISTORY_NODE_SIGNATURE);
+      if (HistoryNode->Valid && HistoryNode->NodeType == NodeType) {
+        SEnvAddVarToList (
+          &SEnvMap,
+          HistoryNode->Name,
+          (UINT8 *) HistoryNode->DevicePath,
+          DevicePathSize (HistoryNode->DevicePath),
+          TRUE
+          );
+        RT->SetVariable (
+              HistoryNode->Name,
+              &SEnvMapId,
+              EFI_VARIABLE_BOOTSERVICE_ACCESS,
+              DevicePathSize (HistoryNode->DevicePath),
+              HistoryNode->DevicePath
+              );
+      }
+    }
+  }
+}
+
+STATIC
+VOID
+ClearHistoryMapping (
+  VOID
+  )
+{
+  EFI_LIST_ENTRY       *Head;
+  MAPPING_HISTORY_NODE *HistoryNode;
+
+  Head = &SEnvMapHistory;
+
+  while (!IsListEmpty (Head)) {
+    HistoryNode = CR (Head->Flink, MAPPING_HISTORY_NODE, Link, MAPPING_HISTORY_NODE_SIGNATURE);
+    RemoveEntryList (&HistoryNode->Link);
+    FreePool (HistoryNode->Name);
+    FreePool (HistoryNode->DevicePath);
+    FreePool (HistoryNode);
+  }
+}
\ No newline at end of file
index dd217ff..06df0df 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -50,78 +50,118 @@ struct {
   EFI_GUID                    ProtocolId;
 }
 SEnvInternalProtocolInfo[] = {
-  L"DevIo",
+  //
+  // Loaded Image
+  //
+  L"Image",
+  SEnvImage,
+  SEnvImageTok,
+  EFI_LOADED_IMAGE_PROTOCOL_GUID,
+  //
+  // Device Path
+  //
+  L"Dpath",
+  SEnvDPath,
+  SEnvDPathTok,
+  EFI_DEVICE_PATH_PROTOCOL_GUID,
+  L"ImageDpath",
+  SEnvDPath,
+  SEnvImageDPathTok,
+  EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID,
+  L"DpathUtil",
   NULL,
   NULL,
-  EFI_DEVICE_IO_PROTOCOL_GUID,
-  L"Fs",
+  EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID,
+  L"DpathToText",
   NULL,
   NULL,
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
-  L"DiskIo",
+  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID,
+  L"DpathFromText",
   NULL,
   NULL,
-  EFI_DISK_IO_PROTOCOL_GUID,
-  L"BlkIo",
-  SEnvBlkIo,
+  EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID,
+  L"PcAnsi",
   NULL,
-  EFI_BLOCK_IO_PROTOCOL_GUID,
-  L"Txtin",
   NULL,
+  DEVICE_PATH_MESSAGING_PC_ANSI,
+  L"Vt100",
   NULL,
-  EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID,
-  L"Txtout",
-  SEnvTextOut,
   NULL,
-  EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID,
-  L"Load",
+  DEVICE_PATH_MESSAGING_VT_100,
+  L"Vt100+",
   NULL,
   NULL,
-  LOAD_FILE_PROTOCOL_GUID,
-  L"Image",
-  SEnvImage,
-  SEnvImageTok,
-  EFI_LOADED_IMAGE_PROTOCOL_GUID,
-  L"UnicodeCollation",
+  DEVICE_PATH_MESSAGING_VT_100_PLUS,
+  L"VtUtf8",
   NULL,
   NULL,
-  EFI_UNICODE_COLLATION_PROTOCOL_GUID,
+  DEVICE_PATH_MESSAGING_VT_UTF8,
   //
-  //  L"LegacyBoot",          NULL,                 NULL,           EFI_LEGACY_BOOT_PROTOCOL_GUID,
+  // Driver Model
   //
-  L"SerialIo",
+  L"DriverBinding",
   NULL,
   NULL,
-  EFI_SERIAL_IO_PROTOCOL_GUID,
-  L"Pxebc",
+  EFI_DRIVER_BINDING_PROTOCOL_GUID,
+  L"PlatformOverride",
   NULL,
   NULL,
-  EFI_PXE_BASE_CODE_PROTOCOL_GUID,
-  L"Tcp",
+  EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID,
+  L"BusSpecificDriverOverride",
+  SEnvBusSpecificDriverOverride,
   NULL,
+  EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID,
+  L"Diagnostics",
   NULL,
-  EFI_TCP_PROTOCOL_GUID,
-  L"Net",
+  NULL,
+  EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID,
+  L"Diagnostics2",
   NULL,
   NULL,
-  EFI_SIMPLE_NETWORK_PROTOCOL_GUID,
+  EFI_DRIVER_DIAGNOSTICS2_PROTOCOL_GUID,
+  L"ComponentName",
+  NULL,
+  NULL,
+  EFI_COMPONENT_NAME_PROTOCOL_GUID,
+  L"ComponentName2",
+  NULL,
+  NULL,
+  EFI_COMPONENT_NAME2_PROTOCOL_GUID,
+  L"PlatformDriverConfig",
+  NULL,
+  NULL,
+  EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL_GUID,
+  L"DriverEFIVersion",
+  SEnvDriverEFIVersion,
+  SEnvDriverEFIVersionTok,
+  EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL_GUID,
   //
-  //  L"TxtOutSplit",         NULL,                 NULL,           TEXT_OUT_SPLITER_PROTOCOL,
-  //  L"ErrOutSplit",         NULL,                 NULL,           ERROR_OUT_SPLITER_PROTOCOL,
-  //  L"TxtInSplit",          NULL,                 NULL,           TEXT_IN_SPLITER_PROTOCOL,
+  // Console Support
   //
-  L"Nii",
+  L"TxtinEx",
   NULL,
   NULL,
-  EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID,
-  L"UgaDraw",
+  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID,
+  L"Txtin",
   NULL,
   NULL,
-  EFI_UGA_DRAW_PROTOCOL_GUID,
-  L"UgaIo",
+  EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID,
+  L"Txtout",
+  SEnvTextOut,
   NULL,
+  EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID,
+  L"SimplePointer",
   NULL,
-  EFI_UGA_IO_PROTOCOL_GUID,
+  NULL,
+  EFI_SIMPLE_POINTER_PROTOCOL_GUID,
+  L"AbsolutePointer",
+  NULL,
+  NULL,
+  EFI_ABSOLUTE_POINTER_PROTOCOL_GUID,
+  L"SerialIo",
+  NULL,
+  NULL,
+  EFI_SERIAL_IO_PROTOCOL_GUID,
   L"GraphicsOutput",
   SEnvGraphicsOutput,
   NULL,
@@ -138,269 +178,399 @@ SEnvInternalProtocolInfo[] = {
   NULL,
   NULL,
   EFI_EDID_OVERRIDE_PROTOCOL_GUID,
-  //
-  // just plain old protocol ids
-  //
-  L"ShellInt",
-  NULL,
-  NULL,
-  SHELL_INTERFACE_PROTOCOL,
-  L"SEnv",
-  NULL,
-  NULL,
-  ENVIRONMENT_VARIABLE_ID,
-  L"ShellProtId",
+  L"ConIn",
   NULL,
   NULL,
-  PROTOCOL_ID_ID,
-  L"ShellDevPathMap",
+  EFI_CONSOLE_IN_DEVICE_GUID,
+  L"ConOut",
   NULL,
   NULL,
-  DEVICE_PATH_MAPPING_ID,
-  L"ShellAlias",
+  EFI_CONSOLE_OUT_DEVICE_GUID,
+  L"StdErr",
   NULL,
   NULL,
-  ALIAS_ID,
+  EFI_STANDARD_ERROR_DEVICE_GUID,
   //
-  // ID guids
+  // Media Access
   //
-  L"G0",
+  L"Load",
   NULL,
   NULL,
-  {
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-    0
-  },
-  L"Efi",
+  LOAD_FILE_PROTOCOL_GUID,
+  L"Fs",
   NULL,
   NULL,
-  EFI_GLOBAL_VARIABLE_GUID,
+  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
   L"GenFileInfo",
   NULL,
   NULL,
   EFI_FILE_INFO_ID,
-  L"FileSysInfo",
-  NULL,
-  NULL,
-  EFI_FILE_SYSTEM_INFO_ID_GUID,
-  L"PcAnsi",
-  NULL,
-  NULL,
-  DEVICE_PATH_MESSAGING_PC_ANSI,
-  L"Vt100",
-  NULL,
-  NULL,
-  DEVICE_PATH_MESSAGING_VT_100,
-  L"Vt100+",
-  NULL,
-  NULL,
-  DEVICE_PATH_MESSAGING_VT_100_PLUS,
-  L"VtUtf8",
-  NULL,
-  NULL,
-  DEVICE_PATH_MESSAGING_VT_UTF8,
-  L"ESP",
-  NULL,
-  NULL,
-  EFI_PART_TYPE_EFI_SYSTEM_PART_GUID,
-  L"GPT MBR",
+  L"TapeIo",
   NULL,
   NULL,
-  EFI_PART_TYPE_LEGACY_MBR_GUID,
-  L"DriverBinding",
+  EFI_TAPE_IO_PROTOCOL_GUID,
+  L"DiskIo",
   NULL,
   NULL,
-  EFI_DRIVER_BINDING_PROTOCOL_GUID,
-  L"ComponentName",
+  EFI_DISK_IO_PROTOCOL_GUID,
+  L"BlkIo",
+  SEnvBlkIo,
   NULL,
+  EFI_BLOCK_IO_PROTOCOL_GUID,
+  L"UnicodeCollation",
   NULL,
-  EFI_COMPONENT_NAME_PROTOCOL_GUID,
-  L"Configuration",
   NULL,
+  EFI_UNICODE_COLLATION_PROTOCOL_GUID,
+  L"UnicodeCollation2",
   NULL,
-  EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID,
-  L"Diagnostics",
   NULL,
+  EFI_UNICODE_COLLATION2_PROTOCOL_GUID,
+  //
+  // PCI Bus Support
+  //
+  L"PciRootBridgeIo",
+  SEnvPciRootBridgeIo,
   NULL,
-  EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID,
-#if (PLATFORM == NT32)
-  L"WinNtThunk",
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID,
+  L"PciIo",
+  SEnvPciIo,
   NULL,
+  EFI_PCI_IO_PROTOCOL_GUID,
+  //
+  // SCSI Bus Support
+  //
+  L"ScsiPassThru",
   NULL,
-  LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID,
-  L"WinNtDriverIo",
   NULL,
+  EFI_SCSI_PASS_THRU_PROTOCOL_GUID,
+  L"ScsiIo",
   NULL,
-  LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID,
-  L"SerialPrivate",
   NULL,
+  EFI_SCSI_IO_PROTOCOL_GUID,
+  L"ExtScsiPassThru",
   NULL,
-  LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID,
-#endif
-  L"PciRootBridgeIo",
-  SEnvPciRootBridgeIo,
   NULL,
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID,
-  L"PciIo",
-  SEnvPciIo,
+  EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID,
+  //
+  // iSCSI
+  //
+  L"IScsiInitName",
   NULL,
-  EFI_PCI_IO_PROTOCOL_GUID,
-  L"IsaIo",
-  SEnvIsaIo,
   NULL,
-  EFI_ISA_IO_PROTOCOL_GUID,
+  EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID,
+  //
+  // USB Support
+  //
   L"UsbIo",
   SEnvUsbIo,
   NULL,
   EFI_USB_IO_PROTOCOL_GUID,
-  L"IsaAcpi",
-  NULL,
-  NULL,
-  EFI_ISA_ACPI_PROTOCOL_GUID,
-  L"SimplePointer",
+  L"UsbHc",
   NULL,
   NULL,
-  EFI_SIMPLE_POINTER_PROTOCOL_GUID,
-  L"ConIn",
-  NULL,
+  EFI_USB_HC_PROTOCOL_GUID,
+  L"UsbHc2",
   NULL,
-  EFI_CONSOLE_IN_DEVICE_GUID,
-  L"ConOut",
   NULL,
+  EFI_USB2_HC_PROTOCOL_GUID,
+  //
+  // Debugger Support
+  //
+  L"DebugSupport",
+  SEnvDebugSupport,
   NULL,
-  EFI_CONSOLE_OUT_DEVICE_GUID,
-  L"StdErr",
+  EFI_DEBUG_SUPPORT_PROTOCOL_GUID,
+  L"DebugPort",
   NULL,
   NULL,
-  EFI_STANDARD_ERROR_DEVICE_GUID,
+  EFI_DEBUGPORT_PROTOCOL_GUID,
+  //
+  // Decompression Algorithm
+  //
   L"Decompress",
   NULL,
   NULL,
   EFI_DECOMPRESS_PROTOCOL_GUID,
-  L"DebugPort",
+  //
+  // ACPI
+  //
+  L"AcpiTable",
   NULL,
   NULL,
-  EFI_DEBUGPORT_PROTOCOL_GUID,
-  L"DebugSupport",
-  SEnvDebugSupport,
+  EFI_ACPI_TABLE_PROTOCOL_GUID,
+  //
+  // EBC
+  //
+  L"EbcInterp",
   NULL,
-  EFI_DEBUG_SUPPORT_PROTOCOL_GUID,
-  L"ScsiPassThru",
   NULL,
+  EFI_EBC_INTERPRETER_PROTOCOL_GUID,
+  //
+  // SNP, PXE, BIS
+  //
+  L"Net",
   NULL,
-  EFI_SCSI_PASS_THRU_PROTOCOL_GUID,
-  L"ScsiIo",
   NULL,
+  EFI_SIMPLE_NETWORK_PROTOCOL_GUID,
+  L"Nii",
   NULL,
-  EFI_SCSI_IO_PROTOCOL_GUID,
-  L"BusSpecificDriverOverride",
-  SEnvBusSpecificDriverOverride,
   NULL,
-  EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID,
-
-  L"UsbHc",
+  EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID,
+  L"Pxebc",
   NULL,
   NULL,
-  EFI_USB_HC_PROTOCOL_GUID,
-
-  L"UsbHc2",
+  EFI_PXE_BASE_CODE_PROTOCOL_GUID,
+  L"PxebcCallback",
   NULL,
   NULL,
-  EFI_USB2_HC_PROTOCOL_GUID,
-
-  L"ExtScsiPassThru",
+  EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID,
+  L"Bis",
   NULL,
   NULL,
-  EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID,
-
+  EFI_BIS_PROTOCOL_GUID,
+  //
+  // Managed Network
+  //
   L"MNPSb",
   NULL,
   NULL,
   EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"MNP",
   NULL,
   NULL,
   EFI_MANAGED_NETWORK_PROTOCOL_GUID,
-
+  //
+  // ARP, DHCPv4
+  //
   L"ARPSb",
   NULL,
   NULL,
   EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"ARP",
   NULL,
   NULL,
   EFI_ARP_PROTOCOL_GUID,
-
   L"DHCPv4Sb",
   NULL,
   NULL,
   EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"DHCPv4",
   NULL,
   NULL,
   EFI_DHCP4_PROTOCOL_GUID,
-
+  //
+  // TCPv4, IPv4 and Configuration
+  //
   L"TCPv4Sb",
   NULL,
   NULL,
   EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"TCPv4",
   NULL,
   NULL,
   EFI_TCP4_PROTOCOL_GUID,
-
   L"IPv4Sb",
   NULL,
   NULL,
   EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"IPv4",
   NULL,
   NULL,
   EFI_IP4_PROTOCOL_GUID,
-
   L"IPv4Config",
   NULL,
   NULL,
   EFI_IP4_CONFIG_PROTOCOL_GUID,
-
+  //
+  // UDPv4, MTFTPv4
+  //
   L"UDPv4Sb",
   NULL,
   NULL,
   EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"UDPv4",
   NULL,
   NULL,
   EFI_UDP4_PROTOCOL_GUID,
-
   L"MTFTPv4Sb",
   NULL,
   NULL,
   EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID,
-
   L"MTFTPv4",
   NULL,
   NULL,
   EFI_MTFTP4_PROTOCOL_GUID,
-
-  L"Dpath",
-  SEnvDPath,
-  SEnvDPathTok,
-  EFI_DEVICE_PATH_PROTOCOL_GUID,
+  //
+  // Security
+  //
+  L"AuthInfo",
+  NULL,
+  NULL,
+  EFI_AUTHENTICATION_INFO_PROTOCOL_GUID,
+  L"HashSb",
+  NULL,
+  NULL,
+  EFI_HASH_SERVICE_BINDING_PROTOCOL,
+  L"Hash",
+  NULL,
+  NULL,
+  EFI_HASH_PROTOCOL_GUID,
+  //
+  // HII 
+  //
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+  L"HiiFont",
+  NULL,
+  NULL,
+  EFI_HII_FONT_PROTOCOL_GUID,
+  L"HiiString",
+  NULL,
+  NULL,
+  EFI_HII_STRING_PROTOCOL_GUID,
+  L"HiiImage",
+  NULL,
+  NULL,
+  EFI_HII_IMAGE_PROTOCOL_GUID,
+  L"HiiDatabase",
+  NULL,
+  NULL,
+  EFI_HII_DATABASE_PROTOCOL_GUID,
+  //
+  // HII Configuration Processing and Browser
+  //
+  L"HiiConfRouting",
+  NULL,
+  NULL,
+  EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID,
+  L"HiiConfAccess",
+  NULL,
+  NULL,
+  EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID,
+  L"FormBrowser2",
+  NULL,
+  NULL,
+  EFI_FORM_BROWSER2_PROTOCOL_GUID,
+#else
+  L"Hii",
+  NULL,
+  NULL,
+  EFI_HII_PROTOCOL_GUID,
+  L"FormBrowser",
+  NULL,
+  NULL,
+  EFI_FORM_BROWSER_PROTOCOL_GUID,
+  L"FormCallback",
+  NULL,
+  NULL,
+  EFI_FORM_CALLBACK_PROTOCOL_GUID,
+#endif
+  //
+  // Shell Specific
+  //
+  L"ShellInt",
+  NULL,
+  NULL,
+  SHELL_INTERFACE_PROTOCOL,
+  L"SEnv",
+  NULL,
+  NULL,
+  ENVIRONMENT_VARIABLE_ID,
+  L"ShellProtId",
+  NULL,
+  NULL,
+  PROTOCOL_ID_ID,
+  L"ShellDevPathMap",
+  NULL,
+  NULL,
+  DEVICE_PATH_MAPPING_ID,
+  L"ShellAlias",
+  NULL,
+  NULL,
+  ALIAS_ID,
+  L"G0",
+  NULL,
+  NULL,
+  {
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0
+  },
+  //
+  // Deprecated
+  //
+  L"DevIo",
+  NULL,
+  NULL,
+  EFI_DEVICE_IO_PROTOCOL_GUID,
+  L"Tcp",
+  NULL,
+  NULL,
+  EFI_TCP_PROTOCOL_GUID,
+  L"UgaDraw",
+  NULL,
+  NULL,
+  EFI_UGA_DRAW_PROTOCOL_GUID,
+  L"UgaIo",
+  NULL,
+  NULL,
+  EFI_UGA_IO_PROTOCOL_GUID,
+  L"Efi",
+  NULL,
+  NULL,
+  EFI_GLOBAL_VARIABLE_GUID,
+  L"FileSysInfo",
+  NULL,
+  NULL,
+  EFI_FILE_SYSTEM_INFO_ID_GUID,
+  L"ESP",
+  NULL,
+  NULL,
+  EFI_PART_TYPE_EFI_SYSTEM_PART_GUID,
+  L"GPT MBR",
+  NULL,
+  NULL,
+  EFI_PART_TYPE_LEGACY_MBR_GUID,
+  L"Configuration",
+  NULL,
+  NULL,
+  EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID,
+  L"Configuration2",
+  NULL,
+  NULL,
+  EFI_DRIVER_CONFIGURATION2_PROTOCOL_GUID,
+  L"IsaIo",
+  SEnvIsaIo,
+  NULL,
+  EFI_ISA_IO_PROTOCOL_GUID,
+  L"IsaAcpi",
+  NULL,
+  NULL,
+  EFI_ISA_ACPI_PROTOCOL_GUID,
+  //
+  // NT32
+  //
+#if (PLATFORM == NT32)
+  L"WinNtThunk",
+  NULL,
+  NULL,
+  LOCAL_EFI_WIN_NT_THUNK_PROTOCOL_GUID,
+  L"WinNtDriverIo",
+  NULL,
+  NULL,
+  LOCAL_EFI_WIN_NT_BUS_DRIVER_IO_PROTOCOL_GUID,
+  L"SerialPrivate",
+  NULL,
+  NULL,
+  LOCAL_EFI_WIN_NT_SERIAL_PORT_GUID,
+#endif
 
   L"Unknown Device",
   NULL,
@@ -1021,20 +1191,24 @@ GetDriverName (
       //
       // Make sure the interface has been implemented
       //
+      SupportedLanguage = NULL;
       if ((ComponentName != NULL) && (ComponentName->GetDriverName != NULL)) {
+        SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
         Status = ComponentName->GetDriverName (
                                   ComponentName,
-                                  Language,
+                                  SupportedLanguage,
                                   DriverName
                                   );
       } else if ((ComponentName2 != NULL) && (ComponentName2->GetDriverName != NULL)) {
-        SupportedLanguage = LibConvertComponentName2SupportLanguage (ComponentName2, Language);
+        SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
         Status = ComponentName2->GetDriverName (
                                    ComponentName2,
                                    SupportedLanguage,
                                    DriverName
                                    );
-        FreePool(SupportedLanguage);
+      }
+      if (SupportedLanguage != NULL) {
+        FreePool (SupportedLanguage);
       }
     }
   }
@@ -1116,6 +1290,18 @@ SEnvGetDeviceName (
       *ConfigurationStatus = EFI_SUCCESS;
     }
 
+    Status = BS->OpenProtocol (
+                  DriverBindingHandleBuffer[HandleIndex],
+                  &gEfiDriverConfiguration2ProtocolGuid,
+                  NULL,
+                  NULL,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
+    if (!EFI_ERROR (Status)) {
+      *ConfigurationStatus = EFI_SUCCESS;
+    }
+
     Status = BS->OpenProtocol (
                   DriverBindingHandleBuffer[HandleIndex],
                   &gEfiDriverDiagnosticsProtocolGuid,
@@ -1128,6 +1314,18 @@ SEnvGetDeviceName (
       *DiagnosticsStatus = EFI_SUCCESS;
     }
 
+    Status = BS->OpenProtocol (
+                  DriverBindingHandleBuffer[HandleIndex],
+                  &gEfiDriverDiagnostics2ProtocolGuid,
+                  NULL,
+                  NULL,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                  );
+    if (!EFI_ERROR (Status)) {
+      *DiagnosticsStatus = EFI_SUCCESS;
+    }
+
     Status = LibGetComponentNameProtocol (
                DriverBindingHandleBuffer[HandleIndex], 
                &ComponentName,
@@ -1139,16 +1337,18 @@ SEnvGetDeviceName (
     //
     // 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,
-                                Language,
+                                SupportedLanguage,
                                 &ControllerName
                                 );
     } else if ((ComponentName2 != NULL) && (ComponentName2->GetControllerName != NULL)) {
-      SupportedLanguage = LibConvertComponentName2SupportLanguage (ComponentName2, Language);
+      SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
       Status = ComponentName2->GetControllerName (
                                  ComponentName2,
                                  DeviceHandle,
@@ -1156,10 +1356,12 @@ SEnvGetDeviceName (
                                  SupportedLanguage,
                                  &ControllerName
                                  );
-      FreePool(SupportedLanguage);
     } else {
       Status = EFI_UNSUPPORTED;
     }
+    if (SupportedLanguage != NULL) {
+      FreePool (SupportedLanguage);
+    }
 
     if (EFI_ERROR (Status)) {
       continue;
@@ -1222,6 +1424,18 @@ SEnvGetDeviceName (
             *ConfigurationStatus = EFI_SUCCESS;
           }
 
+          Status = BS->OpenProtocol (
+                        ParentDriverBindingHandleBuffer[ParentDriverIndex],
+                        &gEfiDriverConfiguration2ProtocolGuid,
+                        NULL,
+                        NULL,
+                        NULL,
+                        EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                        );
+          if (!EFI_ERROR (Status)) {
+            *ConfigurationStatus = EFI_SUCCESS;
+          }
+
           Status = BS->OpenProtocol (
                         ParentDriverBindingHandleBuffer[ParentDriverIndex],
                         &gEfiDriverDiagnosticsProtocolGuid,
@@ -1234,6 +1448,18 @@ SEnvGetDeviceName (
             *DiagnosticsStatus = EFI_SUCCESS;
           }
 
+          Status = BS->OpenProtocol (
+                        ParentDriverBindingHandleBuffer[ParentDriverIndex],
+                        &gEfiDriverDiagnostics2ProtocolGuid,
+                        NULL,
+                        NULL,
+                        NULL,
+                        EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                        );
+          if (!EFI_ERROR (Status)) {
+            *DiagnosticsStatus = EFI_SUCCESS;
+          }
+
           Status = LibGetComponentNameProtocol (
                      ParentDriverBindingHandleBuffer[ParentDriverIndex], 
                      &ComponentName,
@@ -1245,16 +1471,18 @@ SEnvGetDeviceName (
           //
           // 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,
-                                      Language,
+                                      SupportedLanguage,
                                       &ControllerName
                                       );
           } else if ((ComponentName2 != NULL) && (ComponentName2->GetControllerName != NULL)) {
-            SupportedLanguage = LibConvertComponentName2SupportLanguage (ComponentName2, Language);
+            SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
             Status = ComponentName2->GetControllerName (
                                        ComponentName2,
                                        ParentControllerHandleBuffer[HandleIndex],
@@ -1262,10 +1490,12 @@ SEnvGetDeviceName (
                                        SupportedLanguage,
                                        &ControllerName
                                        );
-            FreePool(SupportedLanguage);
           } else {
             Status = EFI_UNSUPPORTED;
           }
+          if (SupportedLanguage != NULL) {
+            FreePool (SupportedLanguage);
+          }
 
           if (EFI_ERROR (Status)) {
             continue;
@@ -1595,21 +1825,41 @@ Returns:
 
   DiagnosticsStatus = BS->OpenProtocol (
                             Handle,
-                            &gEfiDriverDiagnosticsProtocolGuid,
+                            &gEfiDriverDiagnostics2ProtocolGuid,
                             NULL,
                             NULL,
                             NULL,
                             EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                             );
+  if (EFI_ERROR (DiagnosticsStatus)) {
+    DiagnosticsStatus = BS->OpenProtocol (
+                              Handle,
+                              &gEfiDriverDiagnosticsProtocolGuid,
+                              NULL,
+                              NULL,
+                              NULL,
+                              EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                              );
+  }
 
   ConfigurationStatus = BS->OpenProtocol (
                               Handle,
-                              &gEfiDriverConfigurationProtocolGuid,
+                              &gEfiDriverConfiguration2ProtocolGuid,
                               NULL,
                               NULL,
                               NULL,
                               EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                               );
+  if (EFI_ERROR (DiagnosticsStatus)) {
+    ConfigurationStatus = BS->OpenProtocol (
+                                Handle,
+                                &gEfiDriverConfigurationProtocolGuid,
+                                NULL,
+                                NULL,
+                                NULL,
+                                EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+                                );
+  }
 
   NumberOfChildren        = 0;
   ControllerHandleBuffer  = NULL;
@@ -1939,7 +2189,7 @@ Returns:
   ArgVar      = 0;
   ByProtocol  = FALSE;
   Status      = EFI_SUCCESS;
-  Language    = LibGetVariable (VarLanguage, &gEfiGlobalVariableGuid);
+  Language    = LibGetVariableLang ();
   ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
 
   if (!EFI_PROPER_VERSION (1, 10)) {
index 7523690..4338a21 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -1033,6 +1033,12 @@ SEnvDPathTok (
   );
 VOID
 EFIAPI
+SEnvImageDPathTok (
+  IN EFI_HANDLE   h,
+  IN VOID         *Interface
+  );
+VOID
+EFIAPI
 SEnvDebugSupport (
   EFI_HANDLE,
   VOID *
@@ -2053,4 +2059,18 @@ SEnvGraphicsOutput (
   IN VOID            *Interface
   );
 
+VOID
+EFIAPI
+SEnvDriverEFIVersion (
+  IN EFI_HANDLE      h,
+  IN VOID            *Interface
+  );
+
+VOID
+EFIAPI
+SEnvDriverEFIVersionTok (
+  IN EFI_HANDLE      h,
+  IN VOID            *Interface
+  );
+
 #endif // _SHELLE_H_
index 47f9c7f..cd86769 100644 (file)
@@ -389,8 +389,15 @@ Returns:
 {
   UINTN       Size;
   VARIABLE_ID *Var;
+  UINTN       RoundUpValueSize;
 
-  Size  = sizeof (VARIABLE_ID) + StrSize (Name) + ValueSize;
+  //
+  // Variable buffer layout: VARIABLE_ID + Value + Name
+  // We need to round up the variable size to make sure Name is aligned (for IPF).
+  //
+  RoundUpValueSize = (ValueSize % 2) ? (ValueSize + 1) : ValueSize; 
+
+  Size  = sizeof (VARIABLE_ID) + StrSize (Name) + RoundUpValueSize;
   Var   = AllocateZeroPool (Size);
   if (Var == NULL) {
     return NULL;
@@ -398,7 +405,7 @@ Returns:
 
   Var->Signature  = VARIABLE_SIGNATURE;
   Var->u.Value    = ((UINT8 *) Var) + sizeof (VARIABLE_ID);
-  Var->Name       = (CHAR16 *) (Var->u.Value + ValueSize);
+  Var->Name       = (CHAR16 *) (Var->u.Value + RoundUpValueSize);
   Var->ValueSize  = ValueSize;
   CopyMem (Var->u.Value, Value, ValueSize);
   StrCpy (Var->Name, Name);
index bc7e0a5..086e5e2 100644 (file)
@@ -1,6 +1,6 @@
 /*++
 
-Copyright (c) 2005 - 2007, Intel Corporation                                                         
+Copyright (c) 2005 - 2008, 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         
@@ -125,20 +125,24 @@ _UnloadGetDriverName (
     //
     // Make sure the interface has been implemented
     //
+    SupportedLanguage = NULL;
     if ((ComponentName != NULL) && (ComponentName->GetDriverName != NULL)) {
+      SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
       Status = ComponentName->GetDriverName (
                                  ComponentName,
-                                 Language,
+                                 SupportedLanguage,
                                  DriverName
                                  );
     } else if ((ComponentName2 != NULL) && (ComponentName2->GetDriverName != NULL)) {
-      SupportedLanguage = LibConvertComponentName2SupportLanguage (ComponentName2, Language);
+      SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
       Status = ComponentName2->GetDriverName (
                                  ComponentName2,
                                  SupportedLanguage,
                                  DriverName
                                  );
-      FreePool(SupportedLanguage);
+    }
+    if (SupportedLanguage != NULL) {
+      FreePool (SupportedLanguage);
     }