From nobody Mon Nov 25 12:40:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70314+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70314+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610642230; cv=none; d=zohomail.com; s=zohoarc; b=IgiRL6xWyR2JjQ0ESnIvnlxIkHvkY8czZyWQRdv5P6BRoHM/EconFbfYhry1IvHu8XFfQgU9j22B/42cZDPZOrg4t54RaDSM1IKwsedyIQhqBm/OuYLeOJIZb9ov/j8pIOjXRIYeQYckQwjsdOGOFxoSV/WGxPD1/jqnxrd2aSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610642230; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=JIHZ4VMtq1MGKFvOfjAOZxSfNq39ARyb/3cKeuLu2Ok=; b=T0KMtezOl/KdsnGd6m8gk40SXOtkAuyjnh4w80WE/7DaFJEGSLPz5IK1BlP82wQMtnam+1YiIfCuTYs98UnGB951Njub4hVUNZlFIMJDvosZxwZrZu2tYC63ewc1QDHZmh04oPbPGWqIxM3q5xE9Z1HLyJNuvFs4sTD9xbigebM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70314+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610642230614855.9886685323221; Thu, 14 Jan 2021 08:37:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4RrTYY1788612x1ZRkkPutjt; Thu, 14 Jan 2021 08:37:10 -0800 X-Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by mx.groups.io with SMTP id smtpd.web09.4103.1610642223917209768 for ; Thu, 14 Jan 2021 08:37:04 -0800 X-Received: by mail-io1-f52.google.com with SMTP id n4so12299614iow.12 for ; Thu, 14 Jan 2021 08:37:03 -0800 (PST) X-Gm-Message-State: X0KPRon4OadbJFcqFgVCzJOlx1787277AA= X-Google-Smtp-Source: ABdhPJxHzcAGRcxRF8K/Akgkbpq6EihnstZUlw8l6B8CgbkOWJEQcZ8kAhgRvMqLIw/ZZw1l6uhpYQ== X-Received: by 2002:a02:7428:: with SMTP id o40mr7051349jac.130.1610642222912; Thu, 14 Jan 2021 08:37:02 -0800 (PST) X-Received: from cube.nuviainc.com (c-174-52-16-57.hsd1.ut.comcast.net. [174.52.16.57]) by smtp.gmail.com with ESMTPSA id y5sm3711920ilj.35.2021.01.14.08.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 08:37:02 -0800 (PST) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Leif Lindholm , Ard Biesheuvel , nd@arm.com, Sami Mujawar , Liming Gao , Michael D Kinney , Zhiguang Liu Subject: [edk2-devel] [PATCH v6 19/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type13 Date: Thu, 14 Jan 2021 09:36:25 -0700 Message-Id: <20210114163628.31952-20-rebecca@nuviainc.com> In-Reply-To: <20210114163628.31952-1-rebecca@nuviainc.com> References: <20210114163628.31952-1-rebecca@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rebecca@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610642230; bh=taQP979svRK0qLBr0IHk0Wmg3W31ZbxCbpla6Bo017s=; h=Cc:Date:From:Reply-To:Subject:To; b=boAYBmm4pjPBtgZiT7jryZDNbMfBzQ9MDPNVwB2mLDYyunppPh3PZQ6/qU1buopW0Gr YE3TKz+ZA/TBLgbs7rkEZVwKKhcrbHCnLjVMyneNxdufid93lfWX4ItYKsUYysSRgQW16 3j2S9Mqxbf0NbRY2isezrIQkh7Yi82M3Ep0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This code provides information for the SMBIOS Type 13 table. Signed-off-by: Rebecca Cran Reviewed-by: Leif Lindholm --- ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInstallableLangua= gesData.c | 33 ++++ ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInstallableLangua= gesFunction.c | 166 ++++++++++++++++++++ ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInstallableLangua= ges.uni | 43 +++++ 3 files changed, 242 insertions(+) diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInsta= llableLanguagesData.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNu= mberOfInstallableLanguagesData.c new file mode 100644 index 000000000000..97d7303d1a33 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInstallableL= anguagesData.c @@ -0,0 +1,33 @@ +/** @file + This file provides Smbios Type13 Data + + Based on files under Nt32Pkg/MiscSubClassPlatformDxe/ + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "SmbiosMisc.h" + +// +// Static (possibly build generated) Bios Vendor data. +// + +SMBIOS_MISC_TABLE_DATA(SMBIOS_TABLE_TYPE13, MiscNumberOfInstallableLanguag= es) =3D +{ + { // Hdr + EFI_SMBIOS_TYPE_BIOS_LANGUAGE_INFORMATION, // Type, + 0, // Length, + 0 // Handle + }, + 0, // InstallableLang= uages + 0, // Flags + { + 0 // Reserved[15] + }, + 1 // CurrentLanguage +}; diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInsta= llableLanguagesFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/Mi= scNumberOfInstallableLanguagesFunction.c new file mode 100644 index 000000000000..19b60ed71f8c --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInstallableL= anguagesFunction.c @@ -0,0 +1,166 @@ +/** @file + Based on files under Nt32Pkg/MiscSubClassPlatformDxe/ + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SmbiosMisc.h" + +/** + Get next language from language code list (with separator ';'). + + @param LangCode Input: point to first language in the list. On + Otput: point to next language in the list, or + NULL if no more language in the list. + @param Lang The first language in the list. + +**/ +VOID +EFIAPI +GetNextLanguage ( + IN OUT CHAR8 **LangCode, + OUT CHAR8 *Lang + ) +{ + UINTN Index; + CHAR8 *StringPtr; + + if (LangCode =3D=3D NULL || *LangCode =3D=3D NULL || Lang =3D=3D NULL) { + return; + } + + Index =3D 0; + StringPtr =3D *LangCode; + while (StringPtr[Index] !=3D 0 && StringPtr[Index] !=3D ';') { + Index++; + } + + (VOID)CopyMem (Lang, StringPtr, Index); + Lang[Index] =3D 0; + + if (StringPtr[Index] =3D=3D ';') { + Index++; + } + *LangCode =3D StringPtr + Index; +} + +/** + This function returns the number of supported languages on HiiHandle. + + @param HiiHandle The HII package list handle. + + @retval The number of supported languages. + +**/ +UINT16 +EFIAPI +GetSupportedLanguageNumber ( + IN EFI_HII_HANDLE HiiHandle + ) +{ + CHAR8 *Lang; + CHAR8 *Languages; + CHAR8 *LanguageString; + UINT16 LangNumber; + + Languages =3D HiiGetSupportedLanguages (HiiHandle); + if (Languages =3D=3D NULL) { + return 0; + } + + LangNumber =3D 0; + Lang =3D AllocatePool (AsciiStrSize (Languages)); + if (Lang !=3D NULL) { + LanguageString =3D Languages; + while (*LanguageString !=3D 0) { + GetNextLanguage (&LanguageString, Lang); + LangNumber++; + } + FreePool (Lang); + } + FreePool (Languages); + return LangNumber; +} + + +/** + This function makes boot time changes to the contents of the + MiscNumberOfInstallableLanguages (Type 13) record. + + @param RecordData Pointer to SMBIOS table with default = values. + @param Smbios SMBIOS protocol. + + @retval EFI_SUCCESS The SMBIOS table was successfully add= ed. + @retval EFI_INVALID_PARAMETER Invalid parameter was found. + @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory. + +**/ +SMBIOS_MISC_TABLE_FUNCTION(MiscNumberOfInstallableLanguages) +{ + UINTN LangStrLen; + CHAR8 CurrentLang[SMBIOS_STRING_MAX_= LENGTH + 1]; + CHAR8 *OptionalStrStart; + EFI_STATUS Status; + SMBIOS_TABLE_TYPE13 *SmbiosRecord; + SMBIOS_TABLE_TYPE13 *InputData; + + InputData =3D NULL; + + // + // First check for invalid parameters. + // + if (RecordData =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + InputData =3D (SMBIOS_TABLE_TYPE13 *)RecordData; + + InputData->InstallableLanguages =3D GetSupportedLanguageNumber (mSmbiosM= iscHiiHandle); + + // + // Try to check if current langcode matches with the langcodes in instal= led languages + // + ZeroMem (CurrentLang, SMBIOS_STRING_MAX_LENGTH - 1); + (VOID)AsciiStrCpyS (CurrentLang, SMBIOS_STRING_MAX_LENGTH - 1, "en|US|is= o8859-1"); + LangStrLen =3D AsciiStrLen (CurrentLang); + + // + // Two zeros following the last string. + // + SmbiosRecord =3D AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE13) + LangSt= rLen + 1 + 1); + if (SmbiosRecord =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + (VOID)CopyMem (SmbiosRecord, InputData, sizeof (SMBIOS_TABLE_TYPE13)); + + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE13); + + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + (VOID)AsciiStrCpyS (OptionalStrStart, SMBIOS_STRING_MAX_LENGTH - 1, Curr= entLang); + // + // Now we have got the full smbios record, call smbios protocol to add t= his record. + // + Status =3D SmbiosMiscAddRecord ((UINT8*)SmbiosRecord, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Smbios Type13 Table Log Failed! %r \n= ", + __FUNCTION__, __LINE__, Status)); + } + + FreePool (SmbiosRecord); + return Status; +} diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInsta= llableLanguages.uni b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumb= erOfInstallableLanguages.uni new file mode 100644 index 000000000000..3af7a01653d8 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type13/MiscNumberOfInstallableL= anguages.uni @@ -0,0 +1,43 @@ +/** @file + Based on files under Nt32Pkg/MiscSubClassPlatformDxe/ + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +/=3D# + +/=3D# +// +// Language String (Long Format) +// +#string STR_MISC_BIOS_LANGUAGES_ENG_LONG #language en-US "en|US|is= o8859-1" +#string STR_MISC_BIOS_LANGUAGES_FRA_LONG #language en-US "fr|CA|is= o8859-1" +#string STR_MISC_BIOS_LANGUAGES_CHN_LONG #language en-US "zh|TW|un= icode" +#string STR_MISC_BIOS_LANGUAGES_JPN_LONG #language en-US "ja|JP|un= icode" +#string STR_MISC_BIOS_LANGUAGES_ITA_LONG #language en-US "it|IT|is= o8859-1" +#string STR_MISC_BIOS_LANGUAGES_SPA_LONG #language en-US "es|ES|is= o8859-1" +#string STR_MISC_BIOS_LANGUAGES_GER_LONG #language en-US "de|DE|is= o8859-1" +#string STR_MISC_BIOS_LANGUAGES_POR_LONG #language en-US "pt|PT|is= o8859-1" + + +// +// Language String (Abbreviated Format) +// +#string STR_MISC_BIOS_LANGUAGES_ENG_ABBREVIATE #language en-US "enUS" +#string STR_MISC_BIOS_LANGUAGES_FRA_ABBREVIATE #language en-US "frCA" +#string STR_MISC_BIOS_LANGUAGES_CHN_ABBREVIATE #language en-US "zhTW" +#string STR_MISC_BIOS_LANGUAGES_JPN_ABBREVIATE #language en-US "jaJP" +#string STR_MISC_BIOS_LANGUAGES_ITA_ABBREVIATE #language en-US "itIT" +#string STR_MISC_BIOS_LANGUAGES_SPA_ABBREVIATE #language en-US "esES" +#string STR_MISC_BIOS_LANGUAGES_GER_ABBREVIATE #language en-US "deDE" +#string STR_MISC_BIOS_LANGUAGES_POR_ABBREVIATE #language en-US "ptPT" + +#string STR_MISC_BIOS_LANGUAGES_SIMPLECH_ABBREVIATE #language en-US "zhC= N" +#string STR_MISC_BIOS_LANGUAGES_SIMPLECH_LONG #language en-US "zh|= CN|unicode" + + --=20 2.26.2 -=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 (#70314): https://edk2.groups.io/g/devel/message/70314 Mute This Topic: https://groups.io/mt/79679264/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-