From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0142e58505=abner.chang@hpe.com) Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by groups.io with SMTP; Mon, 26 Aug 2019 23:31:07 -0700 Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7R6V6Td022411 for ; Tue, 27 Aug 2019 06:31:06 GMT Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) by mx0b-002e3701.pphosted.com with ESMTP id 2umwhhgqdv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 27 Aug 2019 06:31:06 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2354.austin.hpe.com (Postfix) with ESMTP id 17C5DB4 for ; Tue, 27 Aug 2019 06:30:42 +0000 (UTC) Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.44]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 2C10C3F; Tue, 27 Aug 2019 06:30:40 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com Subject: [edk2-staging/RISC-V PATCH v1 10/14]: RiscVPkg/SmbiosDxe: RISC-V platform generic SMBIOS DXE driver Date: Tue, 27 Aug 2019 14:00:28 +0800 Message-Id: <1566885632-5747-10-git-send-email-abner.chang@hpe.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1566885632-5747-1-git-send-email-abner.chang@hpe.com> References: <1566885632-5747-1-git-send-email-abner.chang@hpe.com> X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-26_08:2019-08-26,2019-08-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=1 impostorscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1906280000 definitions=main-1908270072 RISC-V generic SMBIOS DXE driver for building up SMBIOS type 4, type 7 and type 44 records. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Abner Chang --- RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.c | 343 +++++++++++++++++++++ RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.h | 38 +++ RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf | 63 ++++ RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.uni | Bin 0 -> 1542 bytes .../Universal/SmbiosDxe/RiscVSmbiosDxeExtra.uni | Bin 0 -> 1438 bytes 5 files changed, 444 insertions(+) create mode 100644 RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.c create mode 100644 RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.h create mode 100644 RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf create mode 100644 RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.uni create mode 100644 RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxeExtra.uni diff --git a/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.c b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.c new file mode 100644 index 0000000..b59af1a --- /dev/null +++ b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.c @@ -0,0 +1,343 @@ +/** @file + RISC-V generic SMBIOS DXE driver to build up SMBIOS type 4, type 7 and type 44 records. + + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. 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 + 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. + +**/ + +#include "RiscVSmbiosDxe.h" + +#define RISCV_SMBIOS_DEBUG_INFO 1 + +EFI_SMBIOS_PROTOCOL *Smbios; + +/** + This function builds SMBIOS type 7 record according to + the given RISC_V_PROCESSOR_TYPE7_DATA_HOB. + + @param Type4DataHob Pointer to RISC_V_PROCESSOR_TYPE4_DATA_HOB + @param Type7DataHob Pointer to RISC_V_PROCESSOR_TYPE7_DATA_HOB + @param SmbiosHandle Pointer to SMBIOS_HANDLE + + @retval EFI_STATUS + +**/ +static +EFI_STATUS +BuildSmbiosType7 ( + IN RISC_V_PROCESSOR_TYPE4_DATA_HOB *Type4DataHob, + IN RISC_V_PROCESSOR_TYPE7_DATA_HOB *Type7DataHob, + OUT SMBIOS_HANDLE *SmbiosHandle +) +{ + EFI_STATUS Status; + SMBIOS_HANDLE Handle; + + if (!CompareGuid (&Type4DataHob->PrcessorGuid, &Type7DataHob->PrcessorGuid) || + Type4DataHob->ProcessorUid != Type7DataHob->ProcessorUid) { + return EFI_INVALID_PARAMETER; + } + Handle = SMBIOS_HANDLE_PI_RESERVED; + Type7DataHob->SmbiosType7Cache.Hdr.Type = SMBIOS_TYPE_CACHE_INFORMATION; + Type7DataHob->SmbiosType7Cache.Hdr.Length = sizeof(SMBIOS_TABLE_TYPE7); + Type7DataHob->SmbiosType7Cache.Hdr.Handle = 0; + Status = Smbios->Add (Smbios, NULL, &Handle, &Type7DataHob->SmbiosType7Cache.Hdr); + if (EFI_ERROR(Status)) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: Fail to add SMBIOS Type 7\n")); + return Status; + } + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: SMBIOS Type 7 was added. SMBIOS Handle: 0x%x\n", Handle)); +#if RISCV_SMBIOS_DEBUG_INFO + DEBUG ((EFI_D_INFO, " Cache belone to processor GUID: %g\n", &Type7DataHob->PrcessorGuid)); + DEBUG ((EFI_D_INFO, " Cache belone processor UID: %d\n", Type7DataHob->ProcessorUid)); + DEBUG ((EFI_D_INFO, " ==============================\n")); + DEBUG ((EFI_D_INFO, " Socket Designation: %d\n", Type7DataHob->SmbiosType7Cache.SocketDesignation)); + DEBUG ((EFI_D_INFO, " Cache Configuration: 0x%x\n", Type7DataHob->SmbiosType7Cache.CacheConfiguration)); + DEBUG ((EFI_D_INFO, " Maximum Cache Size: 0x%x\n", Type7DataHob->SmbiosType7Cache.MaximumCacheSize)); + DEBUG ((EFI_D_INFO, " Installed Size: 0x%x\n", Type7DataHob->SmbiosType7Cache.InstalledSize)); + DEBUG ((EFI_D_INFO, " Supported SRAM Type: 0x%x\n", Type7DataHob->SmbiosType7Cache.SupportedSRAMType)); + DEBUG ((EFI_D_INFO, " Current SRAMT ype: 0x%x\n", Type7DataHob->SmbiosType7Cache.CurrentSRAMType)); + DEBUG ((EFI_D_INFO, " Cache Speed: 0x%x\n", Type7DataHob->SmbiosType7Cache.CacheSpeed)); + DEBUG ((EFI_D_INFO, " Error Correction Type: 0x%x\n", Type7DataHob->SmbiosType7Cache.ErrorCorrectionType)); + DEBUG ((EFI_D_INFO, " System Cache Type: 0x%x\n", Type7DataHob->SmbiosType7Cache.SystemCacheType)); + DEBUG ((EFI_D_INFO, " Associativity: 0x%x\n", Type7DataHob->SmbiosType7Cache.Associativity)); +#endif + + *SmbiosHandle = Handle; + return EFI_SUCCESS; +} + +/** + This function builds SMBIOS type 4 record according to + the given RISC_V_PROCESSOR_TYPE4_DATA_HOB. + + @param Type4DataHob Pointer to RISC_V_PROCESSOR_TYPE4_DATA_HOB + @param SmbiosHandle Pointer to SMBIOS_HANDLE + + @retval EFI_STATUS + +**/ +static +EFI_STATUS +BuildSmbiosType4 ( + IN RISC_V_PROCESSOR_TYPE4_DATA_HOB *Type4DataHob, + OUT SMBIOS_HANDLE *SmbiosHandle + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + RISC_V_PROCESSOR_TYPE7_DATA_HOB *Type7HobData; + SMBIOS_HANDLE Cache; + SMBIOS_HANDLE Processor; + EFI_STATUS Status; + + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: Building Type 4.\n")); + DEBUG ((EFI_D_INFO, " Processor GUID: %g\n", &Type4DataHob->PrcessorGuid)); + DEBUG ((EFI_D_INFO, " Processor UUID: %d\n", Type4DataHob->ProcessorUid)); + + Type4DataHob->SmbiosType4Processor.L1CacheHandle = RISC_V_CACHE_INFO_NOT_PROVIDED; + Type4DataHob->SmbiosType4Processor.L2CacheHandle = RISC_V_CACHE_INFO_NOT_PROVIDED; + Type4DataHob->SmbiosType4Processor.L3CacheHandle = RISC_V_CACHE_INFO_NOT_PROVIDED; + GuidHob = (EFI_HOB_GUID_TYPE *)GetFirstGuidHob ((EFI_GUID *)PcdGetPtr(PcdProcessorSmbiosType7GuidHobGuid)); + if (GuidHob == NULL) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: No RISC-V SMBIOS Type7 data HOB found.\n")); + return EFI_NOT_FOUND; + } + // + // Go through each RISC_V_PROCESSOR_TYPE4_DATA_HOB for multiple processors. + // + do { + Type7HobData = (RISC_V_PROCESSOR_TYPE7_DATA_HOB *)GET_GUID_HOB_DATA (GuidHob); + Status = BuildSmbiosType7 (Type4DataHob, Type7HobData, &Cache); + if (EFI_ERROR (Status)) { + return Status; + } + if ((Type7HobData->SmbiosType7Cache.SystemCacheType & RISC_V_CACHE_CONFIGURATION_CACHE_LEVEL_MASK) == + RISC_V_CACHE_CONFIGURATION_CACHE_LEVEL_1) { + Type4DataHob->SmbiosType4Processor.L1CacheHandle = Cache; + } else if ((Type7HobData->SmbiosType7Cache.SystemCacheType & RISC_V_CACHE_CONFIGURATION_CACHE_LEVEL_MASK) == + RISC_V_CACHE_CONFIGURATION_CACHE_LEVEL_2) { + Type4DataHob->SmbiosType4Processor.L2CacheHandle = Cache; + } else if ((Type7HobData->SmbiosType7Cache.SystemCacheType & RISC_V_CACHE_CONFIGURATION_CACHE_LEVEL_MASK) == + RISC_V_CACHE_CONFIGURATION_CACHE_LEVEL_3) { + Type4DataHob->SmbiosType4Processor.L3CacheHandle = Cache; + } else { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: Improper cache level of SMBIOS handle %d\n", Cache)); + } + GuidHob = GetNextGuidHob((EFI_GUID *)PcdGetPtr(PcdProcessorSmbiosType7GuidHobGuid), GET_NEXT_HOB(GuidHob)); + } while (GuidHob != NULL); + + // + // Build SMBIOS Type 4 record + // + Processor = SMBIOS_HANDLE_PI_RESERVED; + Type4DataHob->SmbiosType4Processor.Hdr.Type = SMBIOS_TYPE_PROCESSOR_INFORMATION; + Type4DataHob->SmbiosType4Processor.Hdr.Length = sizeof(SMBIOS_TABLE_TYPE4); + Type4DataHob->SmbiosType4Processor.Hdr.Handle = 0; + Status = Smbios->Add (Smbios, NULL, &Processor, &Type4DataHob->SmbiosType4Processor.Hdr); + if (EFI_ERROR(Status)) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: Fail to add SMBIOS Type 4\n")); + return Status; + } + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: SMBIOS Type 4 was added. SMBIOS Handle: 0x%x\n", Processor)); +#if RISCV_SMBIOS_DEBUG_INFO + DEBUG ((EFI_D_INFO, " Socket StringID: %d\n", Type4DataHob->SmbiosType4Processor.Socket)); + DEBUG ((EFI_D_INFO, " Processor Type: 0x%x\n", Type4DataHob->SmbiosType4Processor.ProcessorType)); + DEBUG ((EFI_D_INFO, " Processor Family: 0x%x\n", Type4DataHob->SmbiosType4Processor.ProcessorFamily)); + DEBUG ((EFI_D_INFO, " Processor Manufacture StringID: %d\n", Type4DataHob->SmbiosType4Processor.ProcessorManufacture)); + DEBUG ((EFI_D_INFO, " Processor Id: 0x%x:0x%x\n", \ + Type4DataHob->SmbiosType4Processor.ProcessorId.Signature, Type4DataHob->SmbiosType4Processor.ProcessorId.FeatureFlags)); + DEBUG ((EFI_D_INFO, " Processor Version StringID: %d\n", Type4DataHob->SmbiosType4Processor.ProcessorVersion)); + DEBUG ((EFI_D_INFO, " Voltage: 0x%x\n", Type4DataHob->SmbiosType4Processor.Voltage)); + DEBUG ((EFI_D_INFO, " External Clock: 0x%x\n", Type4DataHob->SmbiosType4Processor.ExternalClock)); + DEBUG ((EFI_D_INFO, " Max Speed: 0x%x\n", Type4DataHob->SmbiosType4Processor.MaxSpeed)); + DEBUG ((EFI_D_INFO, " Current Speed: 0x%x\n", Type4DataHob->SmbiosType4Processor.CurrentSpeed)); + DEBUG ((EFI_D_INFO, " Status: 0x%x\n", Type4DataHob->SmbiosType4Processor.Status)); + DEBUG ((EFI_D_INFO, " ProcessorUpgrade: 0x%x\n", Type4DataHob->SmbiosType4Processor.ProcessorUpgrade)); + DEBUG ((EFI_D_INFO, " L1 Cache Handle: 0x%x\n", Type4DataHob->SmbiosType4Processor.L1CacheHandle)); + DEBUG ((EFI_D_INFO, " L2 Cache Handle: 0x%x\n",Type4DataHob->SmbiosType4Processor.L2CacheHandle)); + DEBUG ((EFI_D_INFO, " L3 Cache Handle: 0x%x\n", Type4DataHob->SmbiosType4Processor.L3CacheHandle)); + DEBUG ((EFI_D_INFO, " Serial Number StringID: %d\n", Type4DataHob->SmbiosType4Processor.SerialNumber)); + DEBUG ((EFI_D_INFO, " Asset Tag StringID: %d\n", Type4DataHob->SmbiosType4Processor.AssetTag)); + DEBUG ((EFI_D_INFO, " Part Number StringID: %d\n", Type4DataHob->SmbiosType4Processor.PartNumber)); + DEBUG ((EFI_D_INFO, " Core Count: %d\n", Type4DataHob->SmbiosType4Processor.CoreCount)); + DEBUG ((EFI_D_INFO, " Enabled CoreCount: %d\n", Type4DataHob->SmbiosType4Processor.EnabledCoreCount)); + DEBUG ((EFI_D_INFO, " Thread Count: %d\n", Type4DataHob->SmbiosType4Processor.ThreadCount)); + DEBUG ((EFI_D_INFO, " Processor Characteristics: 0x%x\n", Type4DataHob->SmbiosType4Processor.ProcessorCharacteristics)); + DEBUG ((EFI_D_INFO, " Processor Family2: 0x%x\n", Type4DataHob->SmbiosType4Processor.ProcessorFamily2)); + DEBUG ((EFI_D_INFO, " Core Count 2: %d\n", Type4DataHob->SmbiosType4Processor.CoreCount2)); + DEBUG ((EFI_D_INFO, " Enabled CoreCount : %d\n", Type4DataHob->SmbiosType4Processor.EnabledCoreCount2)); + DEBUG ((EFI_D_INFO, " Thread Count 2: %d\n", Type4DataHob->SmbiosType4Processor.ThreadCount2)); +#endif + + *SmbiosHandle = Processor; + return EFI_SUCCESS; +} + +/** + This function builds SMBIOS type 44 record according.. + + @param Type4DataHob Pointer to RISC_V_PROCESSOR_TYPE4_DATA_HOB + @param Type4Handle SMBIOS handle of type 4 + + @retval EFI_STATUS + +**/ +EFI_STATUS +BuildSmbiosType44 ( + IN RISC_V_PROCESSOR_TYPE4_DATA_HOB *Type4DataHob, + IN SMBIOS_HANDLE Type4Handle + ) +{ + EFI_HOB_GUID_TYPE *GuidHob; + RISC_V_PROCESSOR_SPECIFIC_DATA_HOB *ProcessorSpecificData; + SMBIOS_HANDLE RiscVType44; + SMBIOS_TABLE_TYPE44 *Type44Ptr; + EFI_STATUS Status; + + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: Building Type 44 for...\n")); +#if RISCV_SMBIOS_DEBUG_INFO + DEBUG ((EFI_D_INFO, " Processor GUID: %g\n", &Type4DataHob->PrcessorGuid)); + DEBUG ((EFI_D_INFO, " Processor UUID: %d\n", Type4DataHob->ProcessorUid)); +#endif + + GuidHob = (EFI_HOB_GUID_TYPE *)GetFirstGuidHob ((EFI_GUID *)PcdGetPtr(PcdProcessorSpecificDataGuidHobGuid)); + if (GuidHob == NULL) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: No RISC_V_PROCESSOR_SPECIFIC_DATA_HOB found.\n")); + return EFI_NOT_FOUND; + } + // + // Go through each RISC_V_PROCESSOR_SPECIFIC_DATA_HOB for multiple cores. + // + do { + ProcessorSpecificData = (RISC_V_PROCESSOR_SPECIFIC_DATA_HOB *)GET_GUID_HOB_DATA (GuidHob); + if (!CompareGuid (&ProcessorSpecificData->ParentPrcessorGuid, &Type4DataHob->PrcessorGuid) || + ProcessorSpecificData->ParentProcessorUid != Type4DataHob->ProcessorUid) { + GuidHob = GetNextGuidHob((EFI_GUID *)PcdGetPtr(PcdProcessorSpecificDataGuidHobGuid), GET_NEXT_HOB(GuidHob)); + if (GuidHob == NULL) { + break; + } + continue; + } + +#if RISCV_SMBIOS_DEBUG_INFO + DEBUG ((EFI_D_INFO, "[ ================================\n")); + DEBUG ((EFI_D_INFO, "[ Core GUID: %g\n", &ProcessorSpecificData->CoreGuid)); +#endif + + Type44Ptr = AllocateZeroPool(sizeof(SMBIOS_TABLE_TYPE44) + sizeof(SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA)); + if (Type44Ptr == NULL) { + return EFI_NOT_FOUND; + } + Type44Ptr->Hdr.Type = SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION; + Type44Ptr->Hdr.Handle = 0; + Type44Ptr->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE44) + sizeof(SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA); + Type44Ptr->RefHandle = Type4Handle; + Type44Ptr->ProcessorSpecificBlock.Length = sizeof(RISC_V_PROCESSOR_SPECIFIC_DATA_HOB); + Type44Ptr->ProcessorSpecificBlock.ProcessorArchType = Type4DataHob->SmbiosType4Processor.ProcessorFamily2 - + ProcessorFamilyRiscvRV32 + \ + ProcessorSpecificBlockArchTypeRiscVRV32; + CopyMem ((VOID *)(Type44Ptr + 1), (VOID *)&ProcessorSpecificData->ProcessorSpecificData, sizeof (SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA)); + +#if RISCV_SMBIOS_DEBUG_INFO + DEBUG ((EFI_D_INFO, "[ Core type: %d\n", Type44Ptr->ProcessorSpecificBlock.ProcessorArchType)); + DEBUG ((EFI_D_INFO, " HartId = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->HartId.Value64_L)); + DEBUG ((EFI_D_INFO, " Is Boot Hart? = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->BootHartId)); + DEBUG ((EFI_D_INFO, " PrivilegeModeSupported = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->PrivilegeModeSupported)); + DEBUG ((EFI_D_INFO, " MModeExcepDelegation = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->MModeExcepDelegation.Value64_L)); + DEBUG ((EFI_D_INFO, " MModeInterruptDelegation = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->MModeInterruptDelegation.Value64_L)); + DEBUG ((EFI_D_INFO, " HartXlen = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->HartXlen)); + DEBUG ((EFI_D_INFO, " MachineModeXlen = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->MachineModeXlen)); + DEBUG ((EFI_D_INFO, " SupervisorModeXlen = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->SupervisorModeXlen)); + DEBUG ((EFI_D_INFO, " UserModeXlen = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->UserModeXlen)); + DEBUG ((EFI_D_INFO, " InstSetSupported = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->InstSetSupported)); + DEBUG ((EFI_D_INFO, " MachineVendorId = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->MachineVendorId.Value64_L)); + DEBUG ((EFI_D_INFO, " MachineArchId = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->MachineArchId.Value64_L)); + DEBUG ((EFI_D_INFO, " MachineImplId = 0x%x\n", ((SMBIOS_RISC_V_PROCESSOR_SPECIFIC_DATA *)(Type44Ptr + 1))->MachineImplId.Value64_L)); +#endif + + // + // Add to SMBIOS table. + // + RiscVType44 = SMBIOS_HANDLE_PI_RESERVED; + Status = Smbios->Add (Smbios, NULL, &RiscVType44, &Type44Ptr->Hdr); + if (EFI_ERROR(Status)) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: Fail to add SMBIOS Type 44\n")); + return Status; + } + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: SMBIOS Type 44 was added. SMBIOS Handle: 0x%x\n", RiscVType44)); + + GuidHob = GetNextGuidHob((EFI_GUID *)PcdGetPtr(PcdProcessorSpecificDataGuidHobGuid), GET_NEXT_HOB(GuidHob)); + } while (GuidHob != NULL); + return EFI_SUCCESS; +} + +/** + Entry point of RISC-V SMBIOS builder. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS Thread can be successfully created + @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure + @retval EFI_DEVICE_ERROR Cannot create the thread + +**/ +EFI_STATUS +EFIAPI +RiscVSmbiosBuilderEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HOB_GUID_TYPE *GuidHob; + RISC_V_PROCESSOR_TYPE4_DATA_HOB *Type4HobData; + SMBIOS_HANDLE Processor; + + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: %a entry\n", __FUNCTION__)); + + Status = gBS->LocateProtocol ( + &gEfiSmbiosProtocolGuid, + NULL, + (VOID **)&Smbios + ); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: Locate SMBIOS Protocol fail\n")); + return Status; + } + GuidHob = (EFI_HOB_GUID_TYPE *)GetFirstGuidHob ((EFI_GUID *)PcdGetPtr(PcdProcessorSmbiosType4GuidHobGuid)); + if (GuidHob == NULL) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: No RISC-V SMBIOS information found.\n")); + return EFI_NOT_FOUND; + } + Type4HobData = (RISC_V_PROCESSOR_TYPE4_DATA_HOB *)GET_GUID_HOB_DATA (GuidHob); + Status = EFI_NOT_FOUND; + // + // Go through each RISC_V_PROCESSOR_TYPE4_DATA_HOB for multiple processors. + // + do { + Status = BuildSmbiosType4 (Type4HobData, &Processor); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: No RISC-V SMBIOS type 4 created.\n")); + ASSERT (FALSE); + } + Status = BuildSmbiosType44 (Type4HobData, Processor); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "[RISC-V SMBIOS Builder]: No RISC-V SMBIOS type 44 found.\n")); + ASSERT (FALSE); + } + + GuidHob = GetNextGuidHob((EFI_GUID *)PcdGetPtr(PcdProcessorSmbiosType4GuidHobGuid), GET_NEXT_HOB(GuidHob)); + } while (GuidHob != NULL); + DEBUG ((EFI_D_INFO, "[RISC-V SMBIOS Builder]: %a exit\n", __FUNCTION__)); + return Status; +} + diff --git a/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.h b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.h new file mode 100644 index 0000000..9f7577f --- /dev/null +++ b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.h @@ -0,0 +1,38 @@ +/** @file + RISC-V SMBIOS Builder DXE module header file. + + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. 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 + 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. + +**/ + +#ifndef _RISC_V_SMBIOS_DXE_H_ +#define _RISC_V_SMBIOS_DXE_H_ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#endif + diff --git a/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf new file mode 100644 index 0000000..5624226 --- /dev/null +++ b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.inf @@ -0,0 +1,63 @@ +## @file +# RISC-V SMBIOS DXE module. +# +# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. 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 +# 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. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RiscVSmbiosDxe + MODULE_UNI_FILE = RiscVSmbiosDxe.uni + FILE_GUID = 5FC01647-AADD-42E1-AD99-DF4CB89F5A92 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RiscVSmbiosBuilderEntry + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RiscVPkg/RiscVPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + CpuLib + DebugLib + DxeServicesTableLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + HobLib + +[Sources] + RiscVSmbiosDxe.c + RiscVSmbiosDxe.h + +[Protocols] + gEfiSmbiosProtocolGuid # Consumed + +[Guids] + + +[Pcd] + +[FixedPcd] + gUefiRiscVPkgTokenSpaceGuid.PcdProcessorSmbiosGuidHobGuid + gUefiRiscVPkgTokenSpaceGuid.PcdProcessorSmbiosType4GuidHobGuid + gUefiRiscVPkgTokenSpaceGuid.PcdProcessorSmbiosType7GuidHobGuid + gUefiRiscVPkgTokenSpaceGuid.PcdProcessorSpecificDataGuidHobGuid + +[Depex] + gEfiSmbiosProtocolGuid + +[UserExtensions.TianoCore."ExtraFiles"] + RiscVSmbiosDxeExtra.uni diff --git a/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.uni b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxe.uni new file mode 100644 index 0000000000000000000000000000000000000000..e35ce629d3c92f24ef55f9ac136059716f2a81bb GIT binary patch literal 1542 zcmb7^TW`}q6ok(+68~Y9z5r?yK$Q>(A(GZW1k_gIPh&L zTh?8I4~z`g+A~^n*lK?5Ppjvk$F5(>#9Q%e^<*94nzo!C+K5u?zPSqRrB+hHDZ(-rC*9w(3kfkbXIY7E~T&1 zKVzmmBdPulYFE|o&XjK6f*Se$XY8T$K$=!t&MMbdoW%>zNM)h2qi}rgUN>pyoKS1W z{eqDZ$cY{7%rs%S;IBQYTPZmlp(`PiVtY&3wvY6?xT;K5oif@b*9NpA_j+I_)Dh$I zq-3biq09Y=K=hqCrlp)#*`OA$SR2$G@2j`JrS6n@vBn-T*eR%7RrD{^@0pQu-Q8#%rQAhipEo=;dlxSfGD|U!xp9?mRUP~-DPIna z>EGMrPkE0@|IT2F;TXUc*%^xDmz-_mR*If~eS4gy?!!45Go)1hDJKr#lF|koa`1?e zPxKSAW9gYvc;4ua^@-jA75j<~OuCP{pE>LArd;Q)Xo{L_y#AZ||0}PRggfsd<*m}~ a2zKb_`OM2hdU`ph{;KH}E;zS(kG}wCE9rRv literal 0 HcmV?d00001 diff --git a/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxeExtra.uni b/RiscVPkg/Universal/SmbiosDxe/RiscVSmbiosDxeExtra.uni new file mode 100644 index 0000000000000000000000000000000000000000..ccfdb2aa9e6bb05715d27beb7c5d1edec7aca7cf GIT binary patch literal 1438 zcmZ{kTW=FV42AuS#D5s2FM!$vcmp9s(kwKhO`=@5JXN`nbVY93q%Gmc1K;uPWR(J1 z?Tp9cIX?E-^ZQrLY8LpP@dbNlGfQn@-|VqHLaV)=wXARFc4nVg_3g?UXgWv%>DKM1 zoXA*T+S(>I0wJ}Z=%#*R$6jhHo7LY*)6!N@MgF=X`%-dp|q38*G9-0sSfS zOM7lF?3JA&Ux0A$oOf>1#lytDGiL55DZFI1ajY%&!J3SB{0mrYY>6ZmilA#%<~lnI zW--sbi+hHh&S!phisc(}(6hJy;6H$K>JiKD8k7u9OHg74c36mu_)f4`!bE%fB3l8? z2v+i!A}v5G^P~85TDhJet(=)M8}W5oHzUm*zixJ9V@Bz2IT7zIGRb`{opnSJGg+oE zNnKVZ)>KMBlSj~?8k(#xkGPav?>!e2#=oOYVIxFg<@u7YEo((RhG+DvdkHoue9qX( z??|kFVD*sIac1&t?y(ws{4-+6b0AJ-1qSd{NgI3Z9iaNivn%_|b6w?Z#*NkUH zXwh8>7JWzVAgQ7?R+#$*dWE^+Yxy`ma0~Vsuj18lk6PF9BxY^&El`Egaqm4=;x3(h z4zQAqyyjN#vDL}1%pchib9HV~c*&zk?8^bCL~oIcE_EfJP5Le7EzZGTuA1wmJ2_O2 z-W$DF%H4I5-7YA-Lj>1gcR(G2pJ3C5