From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id CB395D80F81 for ; Tue, 21 May 2024 10:15:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=HvT6hTGPyFo10sA7dBuQRw0mGCm4E3IrAjs1G81FPhE=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Received-SPF:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1716286499; v=1; b=G5opXxCVLqNGLbQaeQ7GWhmZ4uOb7/1FOq66/6NWEvVWoE3H3SUKql7PUBqgUASxqVScHK3l IWZeN5Z1ZyOezHIP4y2cj6PPQg7ixALJxfUfd7DiA99npAPbHOl/7U1UwRZkI0KB22HAoNu9Yep sz2YTYMIRFkNsD68sLAum4CWs37Jkm93x6psqBHAtv6hN8tajs7Ek+4qTbjA2HutksU6JRvs1wc UNS9DP+9DllWuBJrOsApJmpLDkIlbV4z82YfafhguP2iWzMxLloUc2ldzwPSjxu2ZzmMu9KIDO1 4N9p40cMkyEII6RI4s8bHcH8JlUwZElVAiqAO0A2HWvcA== X-Received: by 127.0.0.2 with SMTP id UOy4YY7687511xZ3Q6VFYmvU; Tue, 21 May 2024 03:14:59 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.66]) by mx.groups.io with SMTP id smtpd.web11.16232.1716286497120358000 for ; Tue, 21 May 2024 03:14:57 -0700 X-Received: from BYAPR05CA0083.namprd05.prod.outlook.com (2603:10b6:a03:e0::24) by CYYPR12MB8939.namprd12.prod.outlook.com (2603:10b6:930:b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Tue, 21 May 2024 10:14:54 +0000 X-Received: from MWH0EPF000989E6.namprd02.prod.outlook.com (2603:10b6:a03:e0:cafe::49) by BYAPR05CA0083.outlook.office365.com (2603:10b6:a03:e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.16 via Frontend Transport; Tue, 21 May 2024 10:14:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C X-Received: from SATLEXMB03.amd.com (165.204.84.17) by MWH0EPF000989E6.mail.protection.outlook.com (10.167.241.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Tue, 21 May 2024 10:14:53 +0000 X-Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 21 May 2024 05:14:52 -0500 X-Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 21 May 2024 05:14:51 -0500 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 21 May 2024 05:14:50 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Paul Grimes , Abner Chang Subject: [edk2-devel] [edk2-platforms RESEND] AmdPlatformPkg: Adds SmbiosCommonDxe driver Date: Tue, 21 May 2024 15:44:38 +0530 Message-ID: <40e2c7aae8768f357f0569c63261df0fe56a1e51.1716286455.git.AbdulLateef.Attar@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: AbdulLateef.Attar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E6:EE_|CYYPR12MB8939:EE_ X-MS-Office365-Filtering-Correlation-Id: d49ac7d5-f24a-49b9-ce5f-08dc797edb5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?P7VK1TSC7X+zRqK7g7Qmikr2riFbFiLj5KMVleu4wtDirp3jSaNi5YJLZ0MN?= =?us-ascii?Q?i6R2Vz7EGHd63MZPwjSPdfOE9xILCFBDB51Jt1FaiSHQJ09iFMsHmpOnKV1f?= =?us-ascii?Q?X7BCKDWtWtXhkBxQWuGH0PAzJ5Q65445Rg2W8ToeU7xDaFfRERc6F5rRxijM?= =?us-ascii?Q?jZ16lzikt3Bq6NCj/WzZBZIl+UpZ6EB3VZPKtx3ls8BdNS8HzRIsvaLzdB0Z?= =?us-ascii?Q?NfZ/2yblf3etBsW4+rc/sBunJcEQYSaa0KzN7KEvcw3SxsuXTsn3ZbjZ4Prb?= =?us-ascii?Q?gYP/sbmBOGhw7+C78XzW9Uxq7kBpkYTu9OcvOT6ewA4E9Dy3LGaO3+uK4VlI?= =?us-ascii?Q?dx3IMTUOdqGOpUaJgNrH535pY/ggL+w+rstO5oKusCxSpkDCoRu4V9VSGOqX?= =?us-ascii?Q?4KguQrk8Uow7qvD/uc4nSuox9ulfnXTHXNPNLk8/zrMXCVJGcGAbWZEZdRYN?= =?us-ascii?Q?ywHRKYNclJUZl5fSSzTwYn+V0YvS9Ew2huoYtZ3s/pnm3qSTycbkagXOKkaN?= =?us-ascii?Q?bP2CMAIj84XkTBAco/KhhJAufx0ClZvuAk4O5KqY/zJiJ7zqld3Bx6oVOK8u?= =?us-ascii?Q?4opOGcYhId31hz9Bs/MBA3dB805K+TfHTn3QG0bMR57/+zKJ5pT2Dddo1Olv?= =?us-ascii?Q?hUeYghbdANedEkCvluUzo/sow/tEDdw482dM1jaM596JEu/a4La0eF9iEt1y?= =?us-ascii?Q?VC7uLuUKmTvjbruBBMQzBnjR1mw/a5dx4kiLyL+BhLoaa5YrU/xBtODCpheR?= =?us-ascii?Q?ZHNVUOEGA+UnsOuFu/czI6z4/UPX98qBWWgLehFXFO/tDBqvWKulBnomlBBi?= =?us-ascii?Q?UWjuilEQJc5uGQrIZZaELw3DJ2zMu2AXOygxDM9BWGvmd2TTPoBvRjqoakkj?= =?us-ascii?Q?GnnbFCBNqFX/FWbqTzWjH9fCX5pVrX7h3/Q580Lbb4Wkqfb9pHKMlWXQ+C4o?= =?us-ascii?Q?ABX1l0VfSSQUrHo8mGEo0y1AMjP0oDFAxbqJUsSL++QbaFHi3oTvh73/m9hZ?= =?us-ascii?Q?ruaybOHsIPGhP1Eut7ADYDqFYsjF8h7qA9EqRln47GJ6uDwK9BhjTjM5i9Rt?= =?us-ascii?Q?P1YWSxd1k06jmxPUbwFD2XD139hx1JU1L+VvBPaIqlqQS4QzqDNysBuvtcuT?= =?us-ascii?Q?/YqZhCWYO7oMgQypKkhTIqR6MzXT2Ive375OOeuJiq1MeDBQ1qpr+y0agK6g?= =?us-ascii?Q?gaYEmiD6CAq9IKEjplFRmxVPeEbfAF2o2MVF+PzgIjH9RB9CC9Mvn+ZMaI7Z?= =?us-ascii?Q?P8lE07SJLPFLibDqk+H2RbFP+RtYxnH0wTMirHCXmWbg3RWbWrweGqtjzUCX?= =?us-ascii?Q?DVfT6ZJEA91zwT9mO18INdndH+H9AochXE7+DSZcZ/FhYur1XAN6xuXe7/Hv?= =?us-ascii?Q?g3JpF5l4m78HnwENyow8KirXsWSx?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2024 10:14:53.1559 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d49ac7d5-f24a-49b9-ce5f-08dc797edb5d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8939 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Tue, 21 May 2024 03:14:57 -0700 Resent-From: AbdulLateef.Attar@amd.com Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 8cRXfNpyHEVEgAk5eM6oMI9Dx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=G5opXxCV; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io Adds SMBIOS common driver which generates various tables for AMD platforms. Cc: Paul Grimes Reviewed-by: Abner Chang Signed-off-by: Abdul Lateef Attar --- .../AMD/AmdPlatformPkg/AmdPlatformPkg.dec | 61 +++++ .../AMD/AmdPlatformPkg/AmdPlatformPkg.dsc | 3 +- .../SmbiosCommonDxe/DefaultLomDevicePath.c | 130 ++++++++++ .../Universal/SmbiosCommonDxe/SmbiosCommon.h | 210 ++++++++++++++++ .../SmbiosCommonDxe/SmbiosCommonDxe.inf | 76 ++++++ .../SmbiosCommonDxe/SmbiosCommonEntryPoint.c | 148 +++++++++++ .../Type11OemStringsFunction.c | 91 +++++++ .../Type12SystemCfgOptionsFunction.c | 90 +++++++ .../Type13BiosLanguageInfoFunction.c | 146 +++++++++++ .../Type38IpmiDeviceInformation.c | 70 ++++++ .../Type41OnboardDevExtInfoFunction.c | 237 ++++++++++++++++++ .../Type8PortConnectorInfoFunction.c | 133 ++++++++++ .../Type9SystemSlotInfoFunction.c | 94 +++++++ 13 files changed, 1488 insertions(+), 1 deletion(-) create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/D= efaultLomDevicePath.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/S= mbiosCommon.h create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/S= mbiosCommonDxe.inf create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/S= mbiosCommonEntryPoint.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype11OemStringsFunction.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype12SystemCfgOptionsFunction.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype13BiosLanguageInfoFunction.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype38IpmiDeviceInformation.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype41OnboardDevExtInfoFunction.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype8PortConnectorInfoFunction.c create mode 100644 Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/T= ype9SystemSlotInfoFunction.c diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec b/Platform/AMD/= AmdPlatformPkg/AmdPlatformPkg.dec index 83f57f6d0a..106820dc85 100644 --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec @@ -42,3 +42,64 @@ # 3 - BT # 4 - SSIF gAmdPlatformPkgTokenSpaceGuid.PcdIpmiInterfaceType|0|UINT8|0x00020001 + + # + # This PCD is mapped to AMD SMBIOS type 8 record structure + # + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType8Number|0|UINT8|0x00020002 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType8|{0x0}|SMBIOS_PORT_CONNEC= TOR_RECORD_ARRAY|0x00020003 { + + Pcd/SmbiosPcd.h + + AmdPlatformPkg/AmdPlatformPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + } + + # + # This PCD is mapped to AMD SMBIOS type 41 record structure + # + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType41Number|0|UINT8|0x0002000= 4 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType41|{0x0}|SMBIOS_ONBOARD_DE= V_EXT_INFO_ARRAY|0x00020005 { + + Pcd/SmbiosPcd.h + + AmdPlatformPkg/AmdPlatformPkg.dec + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + } + + # + # These PCDs are mapped to AMD SMBIOS type 9 record structure + # + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1|{0x0= }|MISC_SLOT_CHARACTERISTICS1|0x00020009 { + + IndustryStandard/SmBios.h + } + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Char= acteristicsUnknown|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Prov= ides50Volts|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Prov= ides33Volts|1 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Shar= edSlot|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.PcCa= rd16Supported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Card= BusSupported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Zoom= VideoSupported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.Mode= mRingResumeSupported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2|{0x0= }|MISC_SLOT_CHARACTERISTICS2|0x0002000A { + + IndustryStandard/SmBios.h + } + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.PmeS= ignalSupported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.HotP= lugDevicesSupported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Smbu= sSignalSupported|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Bifu= rcationSupported|1 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Asyn= cSurpriseRemoval|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Flex= busSlotCxl10Capable|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Flex= busSlotCxl20Capable|0 + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Rese= rved|0 + +[PcdsDynamic, PcdsDynamicEx] + # SMBIOS + gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStringsCount|0|UINT8|0x0003000= 1 + gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStrings|NULL|VOID*|0x00030002 + gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptionsCount|0|UINT8|0x0= 0030003 + gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptions|NULL|VOID*|0x000= 30004 diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc b/Platform/AMD/= AmdPlatformPkg/AmdPlatformPkg.dsc index 99dd5b341f..d11d3594e3 100644 --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc @@ -71,4 +71,5 @@ AmdPlatformPkg/Universal/HiiConfigRouting/AmdConfigRouting.inf AmdPlatformPkg/Universal/LogoDxe/JpegLogoDxe.inf = # Server platform JPEG logo driver AmdPlatformPkg/Universal/LogoDxe/LogoDxe.inf = # Server platfrom Bitmap logo driver - AmdPlatformPkg/Universal/LogoDxe/S3LogoDxe.inf \ No newline at end of file + AmdPlatformPkg/Universal/LogoDxe/S3LogoDxe.inf + AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommonDxe.inf diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/DefaultL= omDevicePath.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Defa= ultLomDevicePath.c new file mode 100644 index 0000000000..92c7aa5e07 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/DefaultLomDevic= ePath.c @@ -0,0 +1,130 @@ +/** @file + This file contains the implementation of the DefaultLomDevicePath protoc= ol. + The DefaultLomDevicePath protocol is used to identify the default LOM de= vice + path for the system. The protocol is installed by the SmbiosCommonDxe dr= iver + and is used by the BDS to identify the default LOM device path for the s= ystem. + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "SmbiosCommon.h" +#include +#include + +EFI_HANDLE mBoardBdsHandle =3D NULL; +BOARD_BDS_BOOT_FROM_DEVICE_PATH_PROTOCOL mBootDevicePathProtocol; + +/** + Find the Lan-On-Motherboard device path. Installs BOARD_BDS_BOOT_FROM_DE= VICE_PATH_PROTOCOL + with the LOM device path protocol + + @retval EFI NOT_FOUND LOM device path is not found + @retval EFI_SUCCESS LOM device path found +**/ +EFI_STATUS +EFIAPI +InstallLomDevicePath ( + ) +{ + SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD *DevExtInfoRecord; + EFI_STATUS Status; + EFI_HANDLE *PciHandles; + UINTN PciHandlesSize; + UINTN Index; + EFI_PCI_IO_PROTOCOL *PciProtocol; + PCI_IO_DEVICE *PciIoDevice; + UINT8 NumberOfDevices; + UINT8 DevIdx; + UINTN SegmentNumber; + UINTN BusNumber; + UINTN DeviceNumber; + UINTN FunctionNumber; + + NumberOfDevices =3D PcdGet8 (PcdAmdSmbiosType41Number); + DevExtInfoRecord =3D (SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD *)PcdGetPtr (Pc= dAmdSmbiosType41); + + // No device entries found + if (NumberOfDevices =3D=3D 0) { + DEBUG ((DEBUG_INFO, "No onboard devices found.\n")); + return EFI_NOT_FOUND; + } + + // search through present on board devices, look for onboard ethernet + for (DevIdx =3D 0; DevIdx < NumberOfDevices; DevIdx++) { + if (AsciiStrCmp (DevExtInfoRecord->RefDesignationStr, "Onboard Etherne= t") =3D=3D 0) { + break; + } + + DevExtInfoRecord++; + } + + // edge case, no Onboard Ethernet designator + if (AsciiStrCmp (DevExtInfoRecord->RefDesignationStr, "Onboard Ethernet"= ) !=3D 0) { + DEBUG ((DEBUG_INFO, "No Onboard ethernet SMBIOS designator found!\n"))= ; + return EFI_NOT_FOUND; + } + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiPciIoProtocolGuid, + NULL, + &PciHandlesSize, + &PciHandles + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "Can't locate gEfiPciIoProtocolGuid Protocol: Stat= us =3D %r\n\n", Status)); + return Status; + } + + for (Index =3D 0; Index < PciHandlesSize; Index++) { + Status =3D gBS->HandleProtocol ( + PciHandles[Index], + &gEfiPciIoProtocolGuid, + (VOID **)&PciProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "ERROR - Status =3D %r when locating PciIoProtoc= ol\n", Status)); + continue; + } + + PciIoDevice =3D PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciProtocol); + Status =3D PciIoDevice->PciIo.GetLocation (&PciIoDevice->PciIo, &= SegmentNumber, &BusNumber, &DeviceNumber, &FunctionNumber); + + if ((PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegmentNumber, BusNumb= er, DeviceNumber, FunctionNumber, 2)) =3D=3D DevExtInfoRecord->DeviceId) && + (PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegmentNumber, BusNumb= er, DeviceNumber, FunctionNumber, 0)) =3D=3D DevExtInfoRecord->VendorId)) + { + // Making Lan0 default for systems with two LANs + if (FunctionNumber =3D=3D 0) { + DEBUG ((DEBUG_INFO, "Found Onboard Device with DeviceID=3D0x%X, Ve= ndorID=3D0x%X\n", DevExtInfoRecord->DeviceId, DevExtInfoRecord->VendorId)); + Status =3D EFI_SUCCESS; + // install device path protocol here + mBootDevicePathProtocol.Device =3D PciIoDevice= ->DevicePath; + mBootDevicePathProtocol.IpmiBootDeviceSelectorType =3D IPMI_BOOT_D= EVICE_SELECTOR_PXE; + Status =3D gBS->Instal= lProtocolInterface ( + &mBoar= dBdsHandle, + &gBoar= dBdsBootFromDevicePathProtocolGuid, + EFI_NA= TIVE_INTERFACE, + &mBoot= DevicePathProtocol + ); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "BoardBdsBootFromDevicePathProtocol installe= d successfully\n")); + } + + break; + } + } + } + + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCo= mmon.h b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommon= .h new file mode 100644 index 0000000000..770053e42b --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommon.h @@ -0,0 +1,210 @@ +/** @file + AMD Smbios common header file. + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SMBIOS_COMMON_DRIVER_H_ +#define SMBIOS_COMMON_DRIVER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + Add an SMBIOS record. + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + @param[out] SmbiosHandle A unique handle will be assigned to th= e SMBIOS record. + @param[in] Record The data for the fixed portion of the = SMBIOS record. The format of the record is + determined by EFI_SMBIOS_TABLE_HEADER.Type= . The size of the formatted area is defined + by EFI_SMBIOS_TABLE_HEADER.Length and eith= er followed by a double-null (0x0000) or + a set of null terminated strings and a nul= l. + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system= resources. + +**/ +EFI_STATUS +AddCommonSmbiosRecord ( + IN EFI_SMBIOS_PROTOCOL *Smbios, + OUT EFI_SMBIOS_HANDLE *SmbiosHandle, + IN EFI_SMBIOS_TABLE_HEADER *Record + ); + +/** + This function gets the Bus, Device and Segment number of a PCI device wh= en Vendor ID, Device ID and instance + are provided. + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + @param[in] VendorId Vendor ID of the PCI device to be= provided. + @param[in] DeviceId Device ID of the PCI device to be= provided + @param[out] Instance Instance of the PCI device. If m= ore than one devices with same vendor + and device ID is present, instance nu= mber is used. + @param[out] Segment Segment number of the PCI device= is assigned. + @param[out] Bus Bus number of the PCI device is = assigned. + @param[out] Device Device number of the PCI device = is assigned. + @param[out] Functions Bits 0-7 of the Functions variab= le correspond to respective function numbers. + @param[out] DeviceFound Set to 1 if the device is found. + + @retval EFI_SUCCESS All parameters were valid. +**/ +EFI_STATUS +EFIAPI +GetBusDeviceInfo ( + IN UINT16 *VendorId, + IN UINT16 *DeviceId, + IN UINT8 *Instance, + OUT UINT16 *Segment, + OUT UINT8 *Bus, + OUT UINT8 *Device, + OUT UINT8 *Functions, + OUT UINT8 *DeviceFound + ); + +/** + PciEnumerationComplete Protocol notification event handler. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. +**/ +VOID +EFIAPI +OnPciEnumerationComplete ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +/** + This function updates IPMI Device information changes to the contents of= the + Table Type 38. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_UNSUPPORTED Unexpected RecordType value. +**/ +EFI_STATUS +EFIAPI +IpmiDeviceInformation ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + This function checks for system slot info and adds smbios record (Type 9= ). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. + +**/ +EFI_STATUS +EFIAPI +SystemSlotInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + This function adds port connector information smbios record (Type 8). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +PortConnectorInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + This function adds OEM strings smbios record (Type 11). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +OemStringsFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + This function adds System Configuration Options record (Type 12). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +SystemCfgOptionsFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + This function adds bios language information smbios record (Type 13). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. + @retval EFI_NOT_FOUND Not able to locate PlatformLanguage. + +**/ +EFI_STATUS +EFIAPI +BiosLanguageInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + This function adds onboard devices extended information smbios record (T= ype 41). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +OnboardDevExtInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +/** + Find the Lan-On-Motherboard device path. Installs BOARD_BDS_BOOT_FROM_DE= VICE_PATH_PROTOCOL + with the LOM device path protocol + + @retval EFI NOT_FOUND LOM device path is not found + @retval EFI_SUCCESS LOM device path found +**/ +EFI_STATUS +EFIAPI +InstallLomDevicePath ( + ); + +typedef +EFI_STATUS +(EFIAPI EFI_COMMON_SMBIOS_DATA_FUNCTION)( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +typedef struct { + EFI_COMMON_SMBIOS_DATA_FUNCTION *Function; +} EFI_COMMON_SMBIOS_DATA; +#endif // SMBIOS_COMMON_DRIVER_H_ diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCo= mmonDxe.inf b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosC= ommonDxe.inf new file mode 100644 index 0000000000..fc407c3bec --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommonDxe= .inf @@ -0,0 +1,76 @@ +## @file +# AMD common SMBIOS DXE library Description File +# +# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reser= ved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SmbiosCommonDxe + FILE_GUID =3D 2546E2B4-8629-47C3-A294-91E244936CBE + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D SmbiosCommonEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + SmbiosCommon.h + SmbiosCommonEntryPoint.c + Type38IpmiDeviceInformation.c + Type9SystemSlotInfoFunction.c + Type8PortConnectorInfoFunction.c + Type11OemStringsFunction.c + Type12SystemCfgOptionsFunction.c + Type13BiosLanguageInfoFunction.c + Type41OnboardDevExtInfoFunction.c + DefaultLomDevicePath.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + AmdPlatformPkg/AmdPlatformPkg.dec + BoardModulePkg/BoardModulePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + DevicePathLib + HobLib + MemoryAllocationLib + PcdLib + UefiDriverEntryPoint + UefiLib + PlatformSocLib + +[Protocols] + gEfiSmbiosProtocolGuid ## PROTOCOL ALWAYS_CONSUMED + gEfiPciEnumerationCompleteProtocolGuid ## CONSUMES + gEfiPciIoProtocolGuid ## CONSUMES + gBoardBdsBootFromDevicePathProtocolGuid ## PRODUCES + +[Pcd] + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType8 ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType8Number ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1 ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2 ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType41 ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType41Number ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdIpmiInterfaceType ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStringsCount ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStrings ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptionsCount ##= CONSUMES + gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptions ##= CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes ##= CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang ##= CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsIoBaseAddress ##= CONSUMES + +[Depex] + gEfiSmbiosProtocolGuid diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCo= mmonEntryPoint.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Sm= biosCommonEntryPoint.c new file mode 100644 index 0000000000..eaa66be454 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommonEnt= ryPoint.c @@ -0,0 +1,148 @@ +/** @file + AMD Smbios Common DXE entry point. + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include "SmbiosCommon.h" + +EFI_COMMON_SMBIOS_DATA mSmbiosCommonDataFuncTable[] =3D { + { &IpmiDeviceInformation }, + { &SystemSlotInfoFunction }, + { &PortConnectorInfoFunction }, + { &OemStringsFunction }, + { &SystemCfgOptionsFunction }, + { &BiosLanguageInfoFunction } +}; + +/** + Add an SMBIOS record. + + @param Smbios The EFI_SMBIOS_PROTOCOL instance. + @param SmbiosHandle A unique handle will be assigned to the SM= BIOS record. + @param Record The data for the fixed portion of the SMBI= OS record. The format of the record is + determined by EFI_SMBIOS_TABLE_HEADER.Type= . The size of the formatted area is defined + by EFI_SMBIOS_TABLE_HEADER.Length and eith= er followed by a double-null (0x0000) or + a set of null terminated strings and a nul= l. + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system= resources. + +**/ +EFI_STATUS +AddCommonSmbiosRecord ( + IN EFI_SMBIOS_PROTOCOL *Smbios, + OUT EFI_SMBIOS_HANDLE *SmbiosHandle, + IN EFI_SMBIOS_TABLE_HEADER *Record + ) +{ + *SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; + return Smbios->Add ( + Smbios, + NULL, + SmbiosHandle, + Record + ); +} + +/** + PciEnumerationComplete Protocol notification event handler. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. +**/ +VOID +EFIAPI +OnPciEnumerationComplete ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS EfiStatus; + EFI_SMBIOS_PROTOCOL *Smbios; + + EfiStatus =3D gBS->LocateProtocol ( + &gEfiSmbiosProtocolGuid, + NULL, + (VOID **)&Smbios + ); + if (EFI_ERROR (EfiStatus)) { + DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiSta= tus)); + } + + // Install Type 41 when PCI enumeration is complete + EfiStatus =3D OnboardDevExtInfoFunction (Smbios); + if (EFI_ERROR (EfiStatus)) { + DEBUG (( + DEBUG_ERROR, + "Skip installing SMBIOS Table 41, ReturnStatus=3D%r\n", + EfiStatus + )); + } + + EfiStatus =3D InstallLomDevicePath (); +} + +/** + EFI driver entry point. This driver parses mSmbiosCommonDataFuncTable + structure and generates common platform smbios records. + + @param ImageHandle Handle for the image of this driver + @param SystemTable Pointer to the EFI System Table + + @retval EFI_SUCCESS The data was successfully stored. + +**/ +EFI_STATUS +EFIAPI +SmbiosCommonEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + UINTN Index; + EFI_STATUS EfiStatus; + EFI_SMBIOS_PROTOCOL *Smbios; + EFI_EVENT ProtocolNotifyEvent; + VOID *Registration; + + DEBUG ((DEBUG_INFO, "%a: Entry.\n", __func__)); + + EfiStatus =3D gBS->LocateProtocol ( + &gEfiSmbiosProtocolGuid, + NULL, + (VOID **)&Smbios + ); + if (EFI_ERROR (EfiStatus)) { + DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiSta= tus)); + return EfiStatus; + } + + ProtocolNotifyEvent =3D EfiCreateProtocolNotifyEvent ( + &gEfiPciEnumerationCompleteProtocolGuid, + TPL_CALLBACK, + OnPciEnumerationComplete, + NULL, + &Registration + ); + if (ProtocolNotifyEvent =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Could not create PCI enumeration complete event\= n")); + } + + for (Index =3D 0; Index < sizeof (mSmbiosCommonDataFuncTable)/sizeof (mS= mbiosCommonDataFuncTable[0]); ++Index) { + EfiStatus =3D (*mSmbiosCommonDataFuncTable[Index].Function)(Smbios); + if (EFI_ERROR (EfiStatus)) { + // Continue installing remaining tables if one table fails. + DEBUG (( + DEBUG_ERROR, + "Skip installing SMBIOS Table Index=3D%d, ReturnStatus=3D%r\n", + Index, + EfiStatus + )); + continue; + } + } + + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type11Oe= mStringsFunction.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/= Type11OemStringsFunction.c new file mode 100644 index 0000000000..53e7a57355 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type11OemString= sFunction.c @@ -0,0 +1,91 @@ +/** @file + AMD SMBIOS Type 11 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include "SmbiosCommon.h" + +/** + This function adds OEM strings smbios record (Type 11). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +OemStringsFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE11 *SmbiosRecord; + UINT8 OemStrCount; + UINTN OemStrLen; + UINTN OemStrListSize; + CHAR8 *OemStrPtr; + UINT8 Idx; + UINTN StringOffset; + + Status =3D EFI_SUCCESS; + SmbiosRecord =3D NULL; + OemStrListSize =3D 0; + + if (Smbios =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // Get number of OEM strings + OemStrCount =3D PcdGet8 (PcdType11OemStringsCount); + + // Calculate size of all OEM Strings + OemStrPtr =3D (CHAR8 *)PcdGetPtr (PcdType11OemStrings); + for (Idx =3D 0; Idx < OemStrCount; Idx++) { + OemStrLen =3D AsciiStrSize (OemStrPtr); + OemStrPtr +=3D OemStrLen; + OemStrListSize +=3D OemStrLen; + } + + // Allocate memory for Type11 record + SmbiosRecord =3D AllocateZeroPool ( + sizeof (SMBIOS_TABLE_TYPE11) + OemStrListSize + 1 + ); + + if (SmbiosRecord =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + SmbiosRecord->Hdr.Type =3D SMBIOS_TYPE_OEM_STRINGS; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE11); + SmbiosRecord->Hdr.Handle =3D 0; + SmbiosRecord->StringCount =3D OemStrCount; + + StringOffset =3D SmbiosRecord->Hdr.Length; + + // Append strings at the end + OemStrPtr =3D (CHAR8 *)PcdGetPtr (PcdType11OemStrings); + for (Idx =3D 0; Idx < OemStrCount; Idx++) { + OemStrLen =3D AsciiStrSize (OemStrPtr); + CopyMem ( + (UINT8 *)SmbiosRecord + StringOffset, + OemStrPtr, + OemStrLen + ); + OemStrPtr +=3D OemStrLen; + StringOffset +=3D OemStrLen; + } + + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + + FreePool (SmbiosRecord); + + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type12Sy= stemCfgOptionsFunction.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosComm= onDxe/Type12SystemCfgOptionsFunction.c new file mode 100644 index 0000000000..befb122372 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type12SystemCfg= OptionsFunction.c @@ -0,0 +1,90 @@ +/** @file + AMD SMBIOS Type 12 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include "SmbiosCommon.h" + +/** + This function adds System Configuration Options record (Type 12). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +SystemCfgOptionsFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE12 *SmbiosRecord; + UINT8 SystemCfgOptionsCount; + UINTN SystemCfgOptionsLen; + UINTN SystemCfgOptionsListSize; + CHAR8 *SystemCfgOptionsPtr; + UINT8 Idx; + UINTN StringOffset; + + Status =3D EFI_SUCCESS; + SmbiosRecord =3D NULL; + SystemCfgOptionsListSize =3D 0; + + if (Smbios =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // Get number of System Configuration Options + SystemCfgOptionsCount =3D PcdGet8 (PcdType12SystemCfgOptionsCount); + + // Calculate size of all Strings + SystemCfgOptionsPtr =3D (CHAR8 *)PcdGetPtr (PcdType12SystemCfgOptions); + for (Idx =3D 0; Idx < SystemCfgOptionsCount; Idx++) { + SystemCfgOptionsLen =3D AsciiStrSize (SystemCfgOptionsPtr); + SystemCfgOptionsPtr +=3D SystemCfgOptionsLen; + SystemCfgOptionsListSize +=3D SystemCfgOptionsLen; + } + + // Allocate memory for Type12 record + SmbiosRecord =3D AllocateZeroPool ( + sizeof (SMBIOS_TABLE_TYPE12) + SystemCfgOptionsListSize= + 1 + ); + + if (SmbiosRecord =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + SmbiosRecord->Hdr.Type =3D SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE12); + SmbiosRecord->Hdr.Handle =3D 0; + SmbiosRecord->StringCount =3D SystemCfgOptionsCount; + + StringOffset =3D SmbiosRecord->Hdr.Length; + + // Append strings at the end + SystemCfgOptionsPtr =3D (CHAR8 *)PcdGetPtr (PcdType12SystemCfgOptions); + for (Idx =3D 0; Idx < SystemCfgOptionsCount; Idx++) { + SystemCfgOptionsLen =3D AsciiStrSize (SystemCfgOptionsPtr); + CopyMem ( + (UINT8 *)SmbiosRecord + StringOffset, + SystemCfgOptionsPtr, + SystemCfgOptionsLen + ); + SystemCfgOptionsPtr +=3D SystemCfgOptionsLen; + StringOffset +=3D SystemCfgOptionsLen; + } + + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + FreePool (SmbiosRecord); + + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type13Bi= osLanguageInfoFunction.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosComm= onDxe/Type13BiosLanguageInfoFunction.c new file mode 100644 index 0000000000..7d3ada2769 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type13BiosLangu= ageInfoFunction.c @@ -0,0 +1,146 @@ +/** @file + AMD SMBIOS Type 13 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include "SmbiosCommon.h" + +/** + This function adds bios language information smbios record (Type 13). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. + @retval EFI_NOT_FOUND Not able to locate PlatformLanguage. + +**/ +EFI_STATUS +EFIAPI +BiosLanguageInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE13 *SmbiosRecord; + UINTN TotalSize; + UINTN StringOffset; + UINTN VarSize; + UINTN Idx; + UINT8 NumSupportedLang; + UINT8 CurrLangIdx; + CHAR8 *CurrLang; + CHAR8 *SupportedLang; + CHAR8 *LangStr; + + if (Smbios =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + CurrLang =3D NULL; + SupportedLang =3D NULL; + + // Get the current language. + Status =3D GetEfiGlobalVariable2 ( + L"PlatformLang", + (void **)&CurrLang, + &VarSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get PlatformLang: %r\n", Status)); + + VarSize =3D AsciiStrSize ( + (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang) + ); + CurrLang =3D AllocateCopyPool ( + VarSize, + (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang) + ); + ASSERT (CurrLang !=3D NULL); + } + + // Get the list of supported languages. + Status =3D GetEfiGlobalVariable2 ( + L"PlatformLangCodes", + (void **)&SupportedLang, + &VarSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to get PlatformLangCodes: %r\n", Status))= ; + + VarSize =3D AsciiStrSize ( + (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCode= s) + ); + SupportedLang =3D AllocateCopyPool ( + VarSize, + (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLa= ngCodes) + ); + ASSERT (SupportedLang !=3D NULL); + } + + // Calculate number of supported languages and index of current language= in list. + CurrLangIdx =3D 0; + NumSupportedLang =3D 0; + LangStr =3D SupportedLang; + + for (Idx =3D 0; Idx < VarSize; Idx++) { + if ((SupportedLang[Idx] =3D=3D ';') || (SupportedLang[Idx] =3D=3D '\0'= )) { + // Found a language string, increment the language count. + NumSupportedLang++; + + // Replace string separator with null termination. + SupportedLang[Idx] =3D '\0'; + if (!AsciiStrCmp (LangStr, CurrLang)) { + CurrLangIdx =3D NumSupportedLang; + } + + // Point LangStr to next string in list. + LangStr =3D &SupportedLang[Idx + 1]; + } + } + + if (CurrLangIdx =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "Failed to locate PlatformLang in PlatformLangCod= e.\n")); + Status =3D EFI_NOT_FOUND; + } else { + // Calculate record size and allocate memory for smbios record. + TotalSize =3D sizeof (SMBIOS_TABLE_TYPE13) + VarSize + 1; + + SmbiosRecord =3D AllocateZeroPool (TotalSize); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + } else { + // Fill record data and strings. + SmbiosRecord->Hdr.Type =3D SMBIOS_TYPE_BIOS_LANGUAGE_INF= ORMATION; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE13); + SmbiosRecord->Hdr.Handle =3D 0; + SmbiosRecord->InstallableLanguages =3D NumSupportedLang; + SmbiosRecord->Flags =3D 1; // Abbreviated Format. + SmbiosRecord->CurrentLanguages =3D CurrLangIdx; + + // Add strings to bottom of data block + StringOffset =3D SmbiosRecord->Hdr.Length; + CopyMem ((UINT8 *)SmbiosRecord + StringOffset, SupportedLang, VarSiz= e); + + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + FreePool (SmbiosRecord); + } + } + + if (CurrLang !=3D NULL) { + FreePool (CurrLang); + } + + if (SupportedLang !=3D NULL) { + FreePool (SupportedLang); + } + + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type38Ip= miDeviceInformation.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonD= xe/Type38IpmiDeviceInformation.c new file mode 100644 index 0000000000..e2ad2ddb3d --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type38IpmiDevic= eInformation.c @@ -0,0 +1,70 @@ +/** @file + AMD SMBIOS Type 38 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include "SmbiosCommon.h" + +/** + This function updates IPMI Device information changes to the contents of= the + Table Type 38. + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL protocol instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_UNSUPPORTED Unexpected RecordType value. +**/ +EFI_STATUS +EFIAPI +IpmiDeviceInformation ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE38 *SmbiosRecord; + + // + // Two zeros following the last string. + // + SmbiosRecord =3D AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE38) + 1 + 1)= ; + if (SmbiosRecord =3D=3D NULL) { + ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES); + return EFI_OUT_OF_RESOURCES; + } + + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_IPMI_DEVICE_INFORMATION; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE38); + SmbiosRecord->Hdr.Handle =3D 0; + + switch (FixedPcdGet8 (PcdIpmiInterfaceType)) { + case IPMIDeviceInfoInterfaceTypeKCS: + SmbiosRecord->InterfaceType =3D IPMIDeviceInfoInterfaceT= ypeKCS; + SmbiosRecord->IPMISpecificationRevision =3D 0x20; // IPMI v2.0 + SmbiosRecord->I2CSlaveAddress =3D 0x00; // not used in KCS= interface + SmbiosRecord->NVStorageDeviceAddress =3D 0xFF; + // KCS port number base and set LSB bit 1 to mark IO ADDRESS space + SmbiosRecord->BaseAddress =3D FixedPcdGet16 (P= cdIpmiKcsIoBaseAddress) | 0x1; + SmbiosRecord->BaseAddressModifier_InterruptInfo =3D 0x00; + SmbiosRecord->InterruptNumber =3D 0x00; + // + // Now we have got the full smbios record, + // call smbios protocol to add this record. + // + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + break; + default: + // Do not add table + Status =3D EFI_UNSUPPORTED; + break; + } + + FreePool (SmbiosRecord); + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type41On= boardDevExtInfoFunction.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCom= monDxe/Type41OnboardDevExtInfoFunction.c new file mode 100644 index 0000000000..cbd4c75eaf --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type41OnboardDe= vExtInfoFunction.c @@ -0,0 +1,237 @@ +/** @file + AMD SMBIOS Type 41 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reser= ved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +#include "SmbiosCommon.h" + +#define MSR_MMIO_CFG_BASE 0xC0010058ul // MMIO Configuration = Base Address Register + +/** + This function adds onboard devices extended information smbios record (T= ype 41). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +OnboardDevExtInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE41 *SmbiosRecord; + SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD *DevExtInfoRecord; + UINT8 DevIdx; + UINT8 Idx; + UINT8 NumberOfDevices; + UINTN StringOffset; + CHAR8 *RefDesStr; + UINTN RefDesStrLen; + UINT16 SegmentNum; + UINT8 BusNum; + UINT8 DevNum; + UINT8 Functions; + UINT8 DeviceFound; + + if (Smbios =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // Get the total number of onboard devices. + NumberOfDevices =3D PcdGet8 (PcdAmdSmbiosType41Number); + DEBUG ((DEBUG_INFO, "%a: Total number of AMD SMBIOS type41 PCD structure= %d.\n", __func__, NumberOfDevices)); + DevExtInfoRecord =3D (SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD *)PcdGetPtr (Pc= dAmdSmbiosType41); + + // No device entries found + if (NumberOfDevices =3D=3D 0) { + DEBUG ((DEBUG_INFO, "No onboard devices found.\n")); + return EFI_NOT_FOUND; + } + + // Generate type41 smbios record for each device and add it to Smbios ta= ble. + for (DevIdx =3D 0; DevIdx < NumberOfDevices; DevIdx++) { + DEBUG ((DEBUG_MANAGEABILITY, "Device number %d:\n", DevIdx)); + // Check whether reference designation strings are present. + if (DevExtInfoRecord->ReferenceDesignation !=3D 0) { + RefDesStr =3D DevExtInfoRecord->RefDesignationStr; + RefDesStrLen =3D AsciiStrLen (RefDesStr) + 1; + } else { + RefDesStr =3D NULL; + RefDesStrLen =3D 1; + } + + DEBUG ((DEBUG_MANAGEABILITY, " - ReferenceDesignation =3D %d\n", DevEx= tInfoRecord->ReferenceDesignation)); + DEBUG ((DEBUG_MANAGEABILITY, " - DeviceType =3D %d\n", DevExtInfoRecor= d->DeviceType)); + DEBUG ((DEBUG_MANAGEABILITY, " - DeviceEnabled =3D %d\n", DevExtInfoRe= cord->DeviceEnabled)); + DEBUG ((DEBUG_MANAGEABILITY, " - DeviceTypeInstance =3D %d\n", DevExtI= nfoRecord->DeviceTypeInstance)); + DEBUG ((DEBUG_MANAGEABILITY, " - VendorId =3D %x\n", DevExtInfoRecord-= >VendorId)); + DEBUG ((DEBUG_MANAGEABILITY, " - DeviceId =3D %x\n", DevExtInfoRecord-= >DeviceId)); + DEBUG ((DEBUG_MANAGEABILITY, " - RefDesignationStr =3D %a\n", DevExtIn= foRecord->RefDesignationStr)); + + Status =3D GetBusDeviceInfo ( + &DevExtInfoRecord->VendorId, + &DevExtInfoRecord->DeviceId, + &DevExtInfoRecord->DeviceTypeInstance, + &SegmentNum, + &BusNum, + &DevNum, + &Functions, + &DeviceFound + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Could not get SBDF details for idx %d\n", DevI= dx)); + continue; + } + + // Device not present + if (DeviceFound =3D=3D 0) { + Status =3D EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "No onboard device found matching VendorId: %x DeviceId: %x\n", + DevExtInfoRecord->VendorId, + DevExtInfoRecord->DeviceId + )); + continue; + } + + // Create one record for each function in a multi-function device + for (Idx =3D 0; Idx <=3D 7; Idx++) { + if ((Functions >> Idx) & 0x1) { + SmbiosRecord =3D NULL; + SmbiosRecord =3D AllocateZeroPool ( + sizeof (SMBIOS_TABLE_TYPE41) + RefDesStrLen + 1 + ); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + return Status; + } else { + SmbiosRecord->Hdr.Type =3D SMBIOS_TYPE_ONBOARD_DEVIC= ES_EXTENDED_INFORMATION; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE= 41); + SmbiosRecord->Hdr.Handle =3D 0; + SmbiosRecord->ReferenceDesignation =3D DevExtInfoRecord->Referen= ceDesignation; + SmbiosRecord->DeviceType =3D (DevExtInfoRecord->Device= Enabled << 7) | DevExtInfoRecord->DeviceType; + SmbiosRecord->DeviceTypeInstance =3D DevExtInfoRecord->DeviceT= ypeInstance; + SmbiosRecord->SegmentGroupNum =3D SegmentNum; + SmbiosRecord->BusNum =3D BusNum; + SmbiosRecord->DevFuncNum =3D (DevNum << 3) + Idx; + + // Add strings to bottom of data block + StringOffset =3D SmbiosRecord->Hdr.Length; + CopyMem ( + (UINT8 *)SmbiosRecord + StringOffset, + RefDesStr, + RefDesStrLen + ); + StringOffset +=3D RefDesStrLen; + + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + FreePool (SmbiosRecord); + } + } + } + + DevExtInfoRecord++; + } + + return Status; +} + +/** + This function gets the Bus, Device and Segment number of a PCI device wh= en Vendor ID, Device ID and instance + are provided. + + @param[in] VendorId Vendor ID of the PCI device to be provided. + @param[in] DeviceId Device ID of the PCI device to be provided + @param[in] Instance Instance of the PCI device. If more than one= devices with same vendor + and device ID is present, instance number is= used. + @param[out] Segment Segment number of the PCI device is assigned= . + @param[out] Bus Bus number of the PCI device is assigned. + @param[out] Device Device number of the PCI device is assigned. + @param[out] Functions Bits 0-7 of the Functions variable correspon= d to respective function numbers. + @param[out] DeviceFound Set to 1 if the device is found. + + @retval EFI_SUCCESS All parameters were valid. +**/ +EFI_STATUS +EFIAPI +GetBusDeviceInfo ( + IN UINT16 *VendorId, + IN UINT16 *DeviceId, + IN UINT8 *Instance, + OUT UINT16 *Segment, + OUT UINT8 *Bus, + OUT UINT8 *Device, + OUT UINT8 *Functions, + OUT UINT8 *DeviceFound + ) +{ + UINT16 SegIdx; + UINT8 BusIdx; + UINT16 BusIdx16; + UINT8 DevIdx; + UINT8 FuncIdx; + UINT8 InstanceCount; + UINT16 MaxSegments; + UINT8 BusRangeIdentifier; + + InstanceCount =3D *Instance; + *DeviceFound =3D 0; + + BusRangeIdentifier =3D (AsmReadMsr64 (MSR_MMIO_CFG_BASE) >> 2) & 0xF; + if ( BusRangeIdentifier <=3D 0x8 ) { + MaxSegments =3D 1; + } else if ((BusRangeIdentifier >=3D 0x9) && (BusRangeIdentifier <=3D 0xF= )) { + MaxSegments =3D 1 << (BusRangeIdentifier - 0x8); + } + + for (SegIdx =3D 0; SegIdx < MaxSegments; SegIdx++ ) { + for (BusIdx16 =3D 0; BusIdx16 <=3D 255; BusIdx16++) { + BusIdx =3D (UINT8)BusIdx16; + for (DevIdx =3D 0; DevIdx < 32; DevIdx++) { + if ((PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegIdx, BusIdx, De= vIdx, 0, 2)) =3D=3D *DeviceId) && + (PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegIdx, BusIdx, De= vIdx, 0, 0)) =3D=3D *VendorId)) + { + *DeviceFound =3D 1; + *Functions =3D 0; + if (InstanceCount > 1) { + *DeviceFound =3D 0; + InstanceCount--; + continue; + } else { + *Bus =3D BusIdx; + *Device =3D DevIdx; + *Segment =3D SegIdx; + *Functions |=3D 1; + for (FuncIdx =3D 1; FuncIdx < 8; FuncIdx++) { + if ((PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegIdx, BusI= dx, DevIdx, FuncIdx, 2)) =3D=3D *DeviceId) && + (PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegIdx, BusI= dx, DevIdx, FuncIdx, 0)) =3D=3D *VendorId)) + { + *Functions |=3D (1 << FuncIdx); + } + } + + return EFI_SUCCESS; + } + } + } + + if (BusIdx =3D=3D 255) { + break; + } + } + } + + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type8Por= tConnectorInfoFunction.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosComm= onDxe/Type8PortConnectorInfoFunction.c new file mode 100644 index 0000000000..844529d1f0 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type8PortConnec= torInfoFunction.c @@ -0,0 +1,133 @@ +/** @file + AMD SMBIOS Type 8 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +#include "SmbiosCommon.h" + +/** + This function adds port connector information smbios record (Type 8). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. +**/ +EFI_STATUS +EFIAPI +PortConnectorInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE8 *SmbiosRecord; + SMBIOS_PORT_CONNECTOR_RECORD *PortConnRecord; + UINT8 PortIdx; + UINT8 NumberOfPortConnector; + UINTN StringOffset; + CHAR8 *IntPortConDesStr; + UINTN IntPortConDesStrLen; + CHAR8 *ExtPortConDesStr; + UINTN ExtPortConDesStrLen; + + if (Smbios =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // Get the total number of port connectors. + NumberOfPortConnector =3D PcdGet8 (PcdAmdSmbiosType8Number); + DEBUG ((DEBUG_INFO, "%a: Total number of AMD SMBIOS type8 PCD structure = %d.\n", __func__, NumberOfPortConnector)); + PortConnRecord =3D (SMBIOS_PORT_CONNECTOR_RECORD *)PcdGetPtr (PcdAmdSmbi= osType8); + + if (NumberOfPortConnector =3D=3D 0) { + DEBUG ((DEBUG_INFO, "No port connectors found.\n")); + return EFI_NOT_FOUND; + } + + // Generate type8 smbios record for each connector and add it to Smbios = table. + for (PortIdx =3D 0; PortIdx < NumberOfPortConnector; PortIdx++) { + DEBUG ((DEBUG_MANAGEABILITY, "Port %d:\n", PortIdx)); + // Check whether Port connector designator strings are present or not. + if (PortConnRecord->Type8Data.InternalReferenceDesignator !=3D 0) { + IntPortConDesStr =3D PortConnRecord->DesinatorStr.IntDesignatorSt= r; + IntPortConDesStrLen =3D AsciiStrLen (IntPortConDesStr) + 1; + DEBUG ((DEBUG_MANAGEABILITY, "-- DesinatorStr.IntDesignatorStr =3D %= a\n", IntPortConDesStr)); + } else { + IntPortConDesStr =3D NULL; + IntPortConDesStrLen =3D 0; + } + + if (PortConnRecord->Type8Data.ExternalReferenceDesignator !=3D 0) { + ExtPortConDesStr =3D PortConnRecord->DesinatorStr.ExtDesignatorSt= r; + ExtPortConDesStrLen =3D AsciiStrLen (ExtPortConDesStr) + 1; + DEBUG ((DEBUG_MANAGEABILITY, "-- DesinatorStr.ExtDesignatorStr =3D %= a\n", ExtPortConDesStr)); + } else { + ExtPortConDesStr =3D NULL; + ExtPortConDesStrLen =3D 0; + } + + SmbiosRecord =3D NULL; + SmbiosRecord =3D AllocateZeroPool ( + sizeof (SMBIOS_TABLE_TYPE8) + IntPortConDesStrLen + E= xtPortConDesStrLen + 1 + ); + + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + return Status; + } else { + SmbiosRecord->Hdr.Type =3D SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE8); + SmbiosRecord->Hdr.Handle =3D 0; + + SmbiosRecord->InternalReferenceDesignator =3D + PortConnRecord->Type8Data.InternalReferenceDesignator; + SmbiosRecord->InternalConnectorType =3D + PortConnRecord->Type8Data.InternalConnectorType; + SmbiosRecord->ExternalReferenceDesignator =3D + PortConnRecord->Type8Data.ExternalReferenceDesignator; + SmbiosRecord->ExternalConnectorType =3D + PortConnRecord->Type8Data.ExternalConnectorType; + SmbiosRecord->PortType =3D + PortConnRecord->Type8Data.PortType; + DEBUG ((DEBUG_MANAGEABILITY, " - InternalReferenceDesignator =3D %d\= n", SmbiosRecord->InternalReferenceDesignator)); + DEBUG ((DEBUG_MANAGEABILITY, " - InternalConnectorType =3D %d\n", Sm= biosRecord->InternalConnectorType)); + DEBUG ((DEBUG_MANAGEABILITY, " - ExternalReferenceDesignator =3D %d\= n", SmbiosRecord->ExternalReferenceDesignator)); + DEBUG ((DEBUG_MANAGEABILITY, " - ExternalConnectorType =3D %d\n", Sm= biosRecord->ExternalConnectorType)); + DEBUG ((DEBUG_MANAGEABILITY, " - PortType =3D %d\n", SmbiosRecord->P= ortType)); + + // Add strings to bottom of data block + StringOffset =3D SmbiosRecord->Hdr.Length; + if (IntPortConDesStr !=3D NULL) { + CopyMem ( + (UINT8 *)SmbiosRecord + StringOffset, + IntPortConDesStr, + IntPortConDesStrLen + ); + StringOffset +=3D IntPortConDesStrLen; + } + + if (ExtPortConDesStr !=3D NULL) { + CopyMem ( + (UINT8 *)SmbiosRecord + StringOffset, + ExtPortConDesStr, + ExtPortConDesStrLen + ); + } + + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + FreePool (SmbiosRecord); + } + + PortConnRecord++; + } + + return Status; +} diff --git a/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type9Sys= temSlotInfoFunction.c b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonD= xe/Type9SystemSlotInfoFunction.c new file mode 100644 index 0000000000..568f44b427 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Universal/SmbiosCommonDxe/Type9SystemSlot= InfoFunction.c @@ -0,0 +1,94 @@ +/** @file + AMD SMBIOS Type 9 Record + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +#include "SmbiosCommon.h" +#include + +/** + This function checks for system slot info and adds smbios record (Type 9= ). + + @param[in] Smbios The EFI_SMBIOS_PROTOCOL instance. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_OUT_OF_RESOURCES Resource not available. + +**/ +EFI_STATUS +EFIAPI +SystemSlotInfoFunction ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE9 *SmbiosRecord; + UINTN SystemSlotCount; + SMBIOS_TABLE_TYPE9 *SystemSlotInfo; + UINTN Index; + CHAR8 SlotDesignationStr[SMBIOS_STRING_MAX_LENGTH= ]; + SMBIOS_TABLE_TYPE9_EXTENDED SmbiosRecordExtended; + UINTN SlotDesStrLen; + UINTN TotalSize; + + if (Smbios =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + SystemSlotInfo =3D NULL; + SystemSlotCount =3D 0; + // Invoke GetSystemSlotInfo function to get the number of system slots. + Status =3D GetSystemSlotInfo (&SystemSlotInfo, &SystemSlotCount); + if (EFI_ERROR (Status)) { + return Status; + } + + for (Index =3D 0; Index < SystemSlotCount; Index++) { + SlotDesStrLen =3D AsciiSPrint ( + SlotDesignationStr, + SMBIOS_STRING_MAX_LENGTH, + "PCIE-%d", + SystemSlotInfo[Index].SlotID + ); + // Two zeros following the last string. + TotalSize =3D sizeof (SMBIOS_TABLE_TYPE9) + sizeof (SMBIOS_TABLE_TY= PE9_EXTENDED) + SlotDesStrLen + 2; + SmbiosRecord =3D NULL; + SmbiosRecord =3D AllocateZeroPool (TotalSize); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + } else { + CopyMem (SmbiosRecord, &SystemSlotInfo[Index], sizeof (SMBIOS_TABLE_= TYPE9)); + SmbiosRecord->Hdr.Type =3D SMBIOS_TYPE_SYSTEM_SLOTS; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE= 9) + sizeof (SMBIOS_TABLE_TYPE9_EXTENDED); + SmbiosRecord->Hdr.Handle =3D 0; + SmbiosRecord->SlotDesignation =3D 1; + SmbiosRecordExtended.SlotHeight =3D SlotHeightUnknown; + SmbiosRecordExtended.SlotPitch =3D 0; + SmbiosRecordExtended.SlotPhysicalWidth =3D SmbiosRecord->SlotDataBus= Width; + CopyMem (&SmbiosRecord->SlotCharacteristics1, PcdGetPtr (PcdAmdSmbio= sType9SlotCharacteristics1), sizeof (MISC_SLOT_CHARACTERISTICS1)); + CopyMem (&SmbiosRecord->SlotCharacteristics2, PcdGetPtr (PcdAmdSmbio= sType9SlotCharacteristics2), sizeof (MISC_SLOT_CHARACTERISTICS2)); + CopyMem ((UINT8 *)SmbiosRecord->PeerGroups + SmbiosRecord->PeerGroup= ingCount * sizeof (SmbiosRecord->PeerGroups), (UINT8 *)&SmbiosRecordExtende= d, sizeof (SMBIOS_TABLE_TYPE9_EXTENDED)); + CopyMem ((UINT8 *)SmbiosRecord + SmbiosRecord->Hdr.Length, SlotDesig= nationStr, SlotDesStrLen); + Status =3D AddCommonSmbiosRecord ( + Smbios, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)SmbiosRecord + ); + if (EFI_ERROR (Status)) { + FreePool (SmbiosRecord); + break; + } + + if (SmbiosRecord !=3D NULL) { + FreePool (SmbiosRecord); + } + } + } + + FreePool (SystemSlotInfo); + return EFI_SUCCESS; +} --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119101): https://edk2.groups.io/g/devel/message/119101 Mute This Topic: https://groups.io/mt/106220534/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-