]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
ShellPkg: Improved Smbios Type 9 table changes in PrintInfo.c
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / SmbiosView / PrintInfo.c
index 0ab9f5063a8db56d345e54a295d38145dc45105a..bf5306205b8c8c8900b29fb46e23fdb59fe5a59e 100644 (file)
@@ -2,6 +2,7 @@
   Module for clarifying the content of the smbios structure element information.\r
 \r
   Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>\r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
   (C) Copyright 2015-2019 Hewlett Packard Enterprise Development LP<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -597,8 +598,9 @@ SmbiosPrintStructure (
     //\r
     case 9:\r
     {\r
-      MISC_SLOT_PEER_GROUP  *PeerGroupPtr;\r
-      UINT8                 PeerGroupCount;\r
+      MISC_SLOT_PEER_GROUP         *PeerGroupPtr;\r
+      SMBIOS_TABLE_TYPE9_EXTENDED  *Type9ExtendedStruct;\r
+      UINT8                        PeerGroupCount;\r
 \r
       PRINT_PENDING_STRING (Struct, Type9, SlotDesignation);\r
       DisplaySystemSlotType (Struct->Type9->SlotType, Option);\r
@@ -636,9 +638,12 @@ SmbiosPrintStructure (
             ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_DATA_BUS_WIDTH), gShellDebug1HiiHandle, PeerGroupPtr[Index].DataBusWidth);\r
           }\r
 \r
-          DisplaySystemSlotHeight (Struct->Type9->SlotHeight, Option);\r
-          DisplaySystemSlotPhysicalWidth (Struct->Type9->SlotPhysicalWidth, Option);\r
-          DisplaySystemSlotInformation (Struct->Type9->SlotInformation, Option);\r
+          // Since PeerGroups has a variable number of entries, new fields added after PeerGroups are defined in\r
+          // a extended structure. Those fields can be referenced using SMBIOS_TABLE_TYPE9_EXTENDED structure.\r
+          Type9ExtendedStruct = (SMBIOS_TABLE_TYPE9_EXTENDED *)((UINT8 *)PeerGroupPtr + (PeerGroupCount * sizeof (MISC_SLOT_PEER_GROUP)));\r
+          DisplaySystemSlotHeight (Type9ExtendedStruct->SlotHeight, Option);\r
+          DisplaySystemSlotPhysicalWidth (Type9ExtendedStruct->SlotPhysicalWidth, Option);\r
+          DisplaySystemSlotInformation (Type9ExtendedStruct->SlotInformation, Option);\r
         }\r
       }\r
 \r