From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.64.1610735228826984530 for ; Fri, 15 Jan 2021 10:27:09 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pranav.madhu@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8405C11B3; Fri, 15 Jan 2021 10:27:08 -0800 (PST) Received: from usa.arm.com (a074742.blr.arm.com [10.162.16.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 559733F719; Fri, 15 Jan 2021 10:27:07 -0800 (PST) From: "Pranav Madhu" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm Subject: [edk2-platforms][PATCH V1 03/11] Platform/ARM/SgiPkg: Add Initial SMBIOS support Date: Fri, 15 Jan 2021 23:56:40 +0530 Message-Id: <20210115182648.20938-4-pranav.madhu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210115182648.20938-1-pranav.madhu@arm.com> References: <20210115182648.20938-1-pranav.madhu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable SMBIOS provides basic hardware and firmware configuration information through table-driven data structure. This patch adds SMBIOS driver support that allows for installation of multiple SMBIOS types. Also add SMBIOS Type0 (BIOS Information) table, that include information about BIOS vendor name, version, SMBIOS version and other information related to BIOS. Signed-off-by: Pranav Madhu --- Platform/ARM/SgiPkg/SgiPlatform.dsc.inc | = 10 ++ Platform/ARM/SgiPkg/SgiPlatform.fdf | = 8 +- Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | = 56 ++++++++++ Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h | = 18 ++++ Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c | = 74 ++++++++++++++ Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type0BiosInformation.c | 1= 08 ++++++++++++++++++++ 6 files changed, 273 insertions(+), 1 deletion(-) diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc b/Platform/ARM/SgiPk= g/SgiPlatform.dsc.inc index f5c3ccd13069..806f570c637f 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc @@ -119,6 +119,10 @@ # ACPI Table Version gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20 =20 + # SMBIOS entry point version + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0304 + gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0 + # # PCIe # @@ -260,6 +264,12 @@ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf =20 + # + # SMBIOS/DMI + # + MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf + Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf + # # platform driver # diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf b/Platform/ARM/SgiPkg/Sg= iPlatform.fdf index 18fd09e5d2e2..d94e4633e36c 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.fdf +++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, ARM Limited. All rights reserved. +# Copyright (c) 2018-2021, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -109,6 +109,12 @@ READ_LOCK_STATUS =3D TRUE INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf !include $(BOARD_DXE_FV_COMPONENTS) =20 + # + # SMBIOS/DMI + # + INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf + INF Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.in= f + # Required by PCI INF ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf =20 diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.inf b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe= .inf new file mode 100644 index 000000000000..8996c521de54 --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf @@ -0,0 +1,56 @@ +## @file +# This driver installs SMBIOS information for RD Platforms +# +# Copyright (c) 2020-2021, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D SmbiosPlatformDxe + FILE_GUID =3D 86e0aa8b-4f8d-44a5-a140-1f693d529c7= 6 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + + ENTRY_POINT =3D SmbiosTableEntryPoint + +# +# The following information is for reference only and not required by th= e build +# tools. +# +# VALID_ARCHITECTURES =3D AARCH64 +# + +[Sources] + SmbiosPlatformDxe.c + Type0BiosInformation.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Platform/ARM/SgiPkg/SgiPlatform.dec + +[LibraryClasses] + ArmPlatformLib + DebugLib + HobLib + UefiDriverEntryPoint + +[Guids] + gEfiGlobalVariableGuid + gArmSgiPlatformIdDescriptorGuid + +[FixedPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision + +[Protocols] + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED + +[Guids] + +[Depex] + gEfiSmbiosProtocolGuid diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h new file mode 100644 index 000000000000..9a10bbf15e9e --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h @@ -0,0 +1,18 @@ +/** @file +* +* Copyright (c) 2020-2021, ARM Limited. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#ifndef SMBIOS_PLATFORM_DXE_H_ +#define SMBIOS_PLATFORM_DXE_H_ + +EFI_STATUS +EFIAPI +InstallBiosInformation ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + +#endif // SMBIOS_PLATFORM_DXE_H_ diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c new file mode 100644 index 000000000000..f00ef5f8c415 --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c @@ -0,0 +1,74 @@ +/** @file + Install SMBIOS information for Arm's SGI/RD platforms + + Copyright (c) 2020-2021, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include "SgiPlatform.h" +#include "SmbiosPlatformDxe.h" + +typedef EFI_STATUS (*ARM_RD_SMBIOS_TABLE_INSTALL_FPTR)(EFI_SMBIOS_PROTOC= OL *); + +STATIC +ARM_RD_SMBIOS_TABLE_INSTALL_FPTR mSmbiosTableList[] =3D { + &InstallBiosInformation, +}; + +/** + Driver entry point. Installs SMBIOS information + + @param ImageHandle Module's image handle + @param SystemTable Pointer of EFI_SYSTEM_TABLE + + @retval EFI_SUCCESS SMBIOS data successfully installed + @retval Other SMBIOS data was not installed +**/ +EFI_STATUS +EFIAPI +SmbiosTableEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_PROTOCOL *Smbios =3D NULL; + UINT8 CountFail =3D 0; + UINT8 Idx; + + /* Install SMBIOS table only for supported product. */ + if (SgiGetProductId () =3D=3D UnknownId) { + return EFI_NOT_FOUND; + } + + /* Find the SMBIOS protocol */ + Status =3D gBS->LocateProtocol ( + &gEfiSmbiosProtocolGuid, + NULL, + (VOID **)&Smbios + ); + if (EFI_ERROR (Status)) { + return Status; + } + + /* Install the tables listed in mSmbiosTableList */ + for (Idx =3D 0; Idx < ARRAY_SIZE (mSmbiosTableList); Idx++) { + Status =3D (*mSmbiosTableList[Idx]) (Smbios); + if (Status !=3D EFI_SUCCESS) { + CountFail++; + } + } + + DEBUG ((DEBUG_INFO, "Installed %d SMBIOS tables\n", + ARRAY_SIZE (mSmbiosTableList) - CountFail)); + return Status; +} diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type0BiosInfor= mation.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type0BiosInforma= tion.c new file mode 100644 index 000000000000..ef39178b595e --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type0BiosInformation.= c @@ -0,0 +1,108 @@ +/** @file + SMBIOS Type 0 (BIOS information) table for ARM RD platforms. + + Copyright (c) 2020-2021, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#define TYPE0_STRINGS \ + "ARM LTD\0" /* Vendor */ \ + "EDK II\0" /* BiosVersion */ \ + __DATE__"\0" /* BiosReleaseDate */ \ + "\0" + +/* SMBIOS Type0 structure */ +#pragma pack(1) +struct ArmRdSmbiosType0 { + SMBIOS_TABLE_TYPE0 Base; + INT8 Strings[sizeof (TYPE0_STRINGS)]; +}; +#pragma pack() + +/* BIOS information (SMBIOS 3.4 spec, section 7.1) */ +static struct ArmRdSmbiosType0 mArmRdSmbiosType0 =3D { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_BIOS_INFORMATION, // Type 0 + sizeof (SMBIOS_TABLE_TYPE0), // Length + SMBIOS_HANDLE_PI_RESERVED, // Assign an unused handle numbe= r + }, + 1, // String number of vendor name in TYPE0_STRINGS + 2, // String number of BiosVersion + 0, // Bios starting address segment + 3, // String number of BiosReleaseDate + 0, // Bios ROM size + { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics + 0, // Reserved + 0, // Unknown + 0, // BIOS Characteristics are not supported + 0, // ISA is supported + 0, // MCA is supported + 0, // EISA is supported + 1, // PCI supported + 0, // PC card (PCMCIA) is supported + 1, // Plug and Play is supported + 0, // APM is supported + 1, // BIOS upgradable + 0, // BIOS shadowing is allowed + 0, // VL-VESA is supported + 0, // ESCD support is available + 0, // Boot from CD is supported + 1, // selectable boot + }, + { // BIOSCharacteristicsExtensionBytes + ( + (1 << 0) | // ACPI Supported + (1 << 1) // Legacy USB supported + ), + ( + (1 << 3) | // Content distribution enabled + (1 << 4) // UEFI spec supported + ) + }, + 0, // SMBIOS Major Release, updated dynamically + 0, // SMBIOS Minor Release, updated dynamically + 0xFF, // Embedded Controller Firmware Major Release + 0xFF // Embedded Controller Firmware Minor Release + }, + // Text strings (unformatted area) + TYPE0_STRINGS +}; + +/** + Install SMBIOS Bios information Table + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added. + @retval EFI_ALREADY_STARTED The SmbiosHandle passed in is already in= use. +**/ +EFI_STATUS +InstallBiosInformation ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + + SmbiosHandle =3D ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType0)->Hand= le; + + /* Update firmware revision dynamicaly */ + mArmRdSmbiosType0.Base.SystemBiosMajorRelease =3D + (PcdGet32 ( PcdFirmwareRevision ) >> 16) & 0xFF; + mArmRdSmbiosType0.Base.SystemBiosMinorRelease =3D + PcdGet32 ( PcdFirmwareRevision ) & 0xFF; + + Status =3D Smbios->Add ( + Smbios, + NULL, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType0 + ); + + return Status; +} --=20 2.17.1