From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 083C282104 for ; Sun, 11 Dec 2016 22:19:16 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 11 Dec 2016 22:19:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,334,1477983600"; d="scan'208";a="911156370" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 11 Dec 2016 22:19:15 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 11 Dec 2016 22:19:14 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.97]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.9]) with mapi id 14.03.0248.002; Mon, 12 Dec 2016 14:19:12 +0800 From: "Wei, David" To: "Guo, Mang" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue Thread-Index: AdJR+FW5v7ZFagDAS+6QOdZJXzK5CwCRzynA Date: Mon, 12 Dec 2016 06:19:12 +0000 Message-ID: <89954A0B46707A448411A627AD4EEE3468EDC573@SHSMSX101.ccr.corp.intel.com> References: <22D2C85ED001C54AA20BFE3B0E4751D14FAFC9D7@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <22D2C85ED001C54AA20BFE3B0E4751D14FAFC9D7@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2Q2YjlhNzMtZGVmMS00OTE4LWIwNmItMzUxM2I4MTBmNWU5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ik5NVUVreUt5QkFhbG5Id2lCa1lCT01zUVc4U1FNTzNzOUREWml4MlJVelU9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2016 06:19:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: David Wei Thanks, David Wei =20 -----Original Message----- From: Guo, Mang=20 Sent: Friday, December 09, 2016 4:44 PM To: edk2-devel@lists.01.org Cc: Wei, David Subject: [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg:= Fixed Turbot 2 frontpage issue frontpage show blank on Turbot 2 due to some SMBIOS data missing. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang --- .../MiscBaseBoardManufacturerFunction.c | 566 ++++++++------- .../SmBiosMiscDxe/MiscSystemManufacturerFunction.c | 758 +++++++++++------= ---- Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf | 291 ++++---- 3 files changed, 856 insertions(+), 759 deletions(-) diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunct= ion.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c index 0102310..b2c12fd 100644 --- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c +++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c @@ -1,244 +1,322 @@ -/*++ - -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 - This program and the accompanying materials are licensed and made availa= ble under - the terms and conditions of the BSD License that accompanies this distri= bution. =20 - The full text of the license may be found at = =20 - http://opensource.org/licenses/bsd-license.php. = =20 - = =20 - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 - = =20 - - -Module Name: - - MiscBaseBoardManufacturerFunction.c - -Abstract: - - BaseBoard manufacturer information boot time changes. - SMBIOS type 2. - ---*/ - - -#include "CommonHeader.h" -#include "MiscSubclassDriver.h" -#include -#include "Library/DebugLib.h" -#include -#include - - -extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; - -/** - This function makes boot time changes to the contents of the - MiscBaseBoardManufacturer (Type 2). - - @param RecordData Pointer to copy of RecordData from th= e Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) -{ - CHAR8 *OptionalStrStart; - UINTN ManuStrLen; - UINTN ProductStrLen; - UINTN VerStrLen; - UINTN AssertTagStrLen; - UINTN SerialNumStrLen; - UINTN ChassisStrLen; - EFI_STATUS Status; - EFI_STRING Manufacturer; - EFI_STRING Product; - EFI_STRING Version; - EFI_STRING SerialNumber; - EFI_STRING AssertTag; - EFI_STRING Chassis; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE2 *SmbiosRecord; - EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData; - - CHAR16 *MacStr;=20 - EFI_HANDLE *Handles; - UINTN BufferSize; - CHAR16 Buffer[40]; - - ForType2InputData =3D (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData; - - // - // First check for invalid parameters. - // - if (RecordData =3D=3D NULL || mPlatformInfo =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { - UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER)= , Buffer, NULL); - } - TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER); - Manufacturer =3D SmbiosMiscGetString (TokenToGet); - ManuStrLen =3D StrLen(Manufacturer); - if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { - UnicodeSPrint (Buffer, sizeof (Buffer),L"MinnowBoard Turbot"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME1= ), Buffer, NULL); - } - TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME1); - Product =3D SmbiosMiscGetString (TokenToGet); - ProductStrLen =3D StrLen(Product); - if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION); - Version =3D SmbiosMiscGetString (TokenToGet); - VerStrLen =3D StrLen(Version); - if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - =20 - // - //Get handle infomation - // - BufferSize =3D 0; - Handles =3D NULL; - Status =3D gBS->LocateHandle ( - ByProtocol,=20 - &gEfiSimpleNetworkProtocolGuid, - NULL, - &BufferSize, - Handles - ); - - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - Handles =3D AllocateZeroPool(BufferSize); - if (Handles =3D=3D NULL) { - return (EFI_OUT_OF_RESOURCES); - } - Status =3D gBS->LocateHandle( - ByProtocol, - &gEfiSimpleNetworkProtocolGuid, - NULL, - &BufferSize, - Handles - ); - } - =20 - // - //Get the MAC string - // - Status =3D NetLibGetMacString ( - *Handles, - NULL, - &MacStr - ); - if (EFI_ERROR (Status)) {=09 - return Status; - } - SerialNumber =3D MacStr; =20 - SerialNumStrLen =3D StrLen(SerialNumber); - if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - DEBUG ((EFI_D_ERROR, "MAC Address: %S\n", MacStr));=20 - =20 - TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG); - AssertTag =3D SmbiosMiscGetString (TokenToGet); - AssertTagStrLen =3D StrLen(AssertTag); - if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION); - Chassis =3D SmbiosMiscGetString (TokenToGet); - ChassisStrLen =3D StrLen(Chassis); - if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - - // - // Two zeros following the last string. - // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen += 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStr= Len + 1 + ChassisStrLen +1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + Pro= ductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 = + ChassisStrLen +1 + 1); - - SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION; - SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE2); - - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle =3D 0; - - // - // Manu will be the 1st optional string following the formatted structur= e. - // - SmbiosRecord->Manufacturer =3D 1; - - // - // ProductName will be the 2st optional string following the formatted s= tructure. - // - SmbiosRecord->ProductName =3D 2; - - // - // Version will be the 3rd optional string following the formatted struc= ture. - // - SmbiosRecord->Version =3D 3; - - // - // SerialNumber will be the 4th optional string following the formatted = structure. - // - SmbiosRecord->SerialNumber =3D 4; - - // - // AssertTag will be the 5th optional string following the formatted str= ucture. - // - SmbiosRecord->AssetTag =3D 5; - - // - // LocationInChassis will be the 6th optional string following the forma= tted structure. - // - SmbiosRecord->LocationInChassis =3D 6; - SmbiosRecord->FeatureFlag =3D (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2Inp= utData->BaseBoardFeatureFlags)); - SmbiosRecord->ChassisHandle =3D 0; - SmbiosRecord->BoardType =3D (UINT8)ForType2InputData->BaseBoardType= ; - SmbiosRecord->NumberOfContainedObjectHandles =3D 0; - - OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - - // - // Since we fill NumberOfContainedObjectHandles =3D 0 for simple, just a= fter this filed to fill string - // - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + P= roductStrLen + 1 + VerStrLen + 1); - UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + Prod= uctStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); - UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1); - - // - // Now we have got the full smbios record, call smbios protocol to add t= his record. - // - SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; - Status =3D Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); - - FreePool(SmbiosRecord); - return Status; -} +/*++ + +Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + 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 IMP= LIED. + + + +Module Name: + + MiscBaseBoardManufacturerFunction.c + +Abstract: + + BaseBoard manufacturer information boot time changes. + SMBIOS type 2. + +--*/ + + +#include "CommonHeader.h" +#include "MiscSubclassDriver.h" +#include +#include "Library/DebugLib.h" +#include +#include + +extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; +static EFI_SMBIOS_HANDLE mSmbiosHandleType2; + +EFI_STATUS +EFIAPI +UpdateBaseBoardManuCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_HANDLE *Handles; + UINTN BufferSize; + CHAR16 *MacStr; + EFI_SMBIOS_PROTOCOL *Smbios; + UINTN SerialNumberOffset; + CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH]; + + gBS->CloseEvent (Event); // Unload this event. + + DEBUG ((EFI_D_INFO, "Executing UpdateBaseBoardManuCallback.\n")); + + // + //Get handle infomation + // + BufferSize =3D 0; + Handles =3D NULL; + Status =3D gBS->LocateHandle ( + ByProtocol, + &gEfiSimpleNetworkProtocolGuid, + NULL, + &BufferSize, + Handles + ); + + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + Handles =3D AllocateZeroPool(BufferSize); + if (Handles =3D=3D NULL) { + return (EFI_OUT_OF_RESOURCES); + } + Status =3D gBS->LocateHandle( + ByProtocol, + &gEfiSimpleNetworkProtocolGuid, + NULL, + &BufferSize, + Handles + ); + } + + // + //Get the MAC string + // + Status =3D NetLibGetMacString ( + *Handles, + NULL, + &MacStr + ); + if (EFI_ERROR (Status)) { + return Status; + } + + ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH); + UnicodeStrToAsciiStr (MacStr, AsciiData); + + Status =3D gBS->LocateProtocol ( + &gEfiSmbiosProtocolGuid, + NULL, + (VOID *) &Smbios + ); + ASSERT_EFI_ERROR (Status); + + SerialNumberOffset =3D 4; + Status =3D Smbios->UpdateString ( + Smbios, + &mSmbiosHandleType2, + &SerialNumberOffset, + AsciiData + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + return EFI_SUCCESS; +} + + +/** + This function makes boot time changes to the contents of the + MiscBaseBoardManufacturer (Type 2). + + @param RecordData Pointer to copy of RecordData from th= e Data Table. + + @retval EFI_SUCCESS All parameters were valid. + @retval EFI_UNSUPPORTED Unexpected RecordType value. + @retval EFI_INVALID_PARAMETER Invalid parameter was found. + +**/ +MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) +{ + CHAR8 *OptionalStrStart; + UINTN ManuStrLen; + UINTN ProductStrLen; + UINTN VerStrLen; + UINTN AssertTagStrLen; + UINTN SerialNumStrLen; + UINTN ChassisStrLen; + EFI_STATUS Status; + EFI_STRING Manufacturer; + EFI_STRING Product; + EFI_STRING Version; + EFI_STRING SerialNumber; + EFI_STRING AssertTag; + EFI_STRING Chassis; + STRING_REF TokenToGet; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE2 *SmbiosRecord; + EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData; + VOID *UpdateBaseBoardManuCallbackNotifyReg= ; + EFI_EVENT UpdateBaseBoardManuCallbackEvent; + CHAR16 *MacStr; + CHAR16 Buffer[40]; + static BOOLEAN CallbackIsInstalledT2 =3D FALSE; + + ForType2InputData =3D (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData; + + // + // First check for invalid parameters. + // + if (RecordData =3D=3D NULL || mPlatformInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { + UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER)= , Buffer, NULL); + } + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER); + Manufacturer =3D SmbiosMiscGetString (TokenToGet); + ManuStrLen =3D StrLen(Manufacturer); + if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { + UnicodeSPrint (Buffer, sizeof (Buffer),L"MinnowBoard Turbot"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME1= ), Buffer, NULL); + } + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME1); + Product =3D SmbiosMiscGetString (TokenToGet); + ProductStrLen =3D StrLen(Product); + if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION); + Version =3D SmbiosMiscGetString (TokenToGet); + VerStrLen =3D StrLen(Version); + if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + MacStr =3D L"00000000"; + SerialNumber =3D MacStr; + SerialNumStrLen =3D StrLen(SerialNumber); + if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + DEBUG ((EFI_D_ERROR, "MAC Address: %S\n", MacStr)); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG); + AssertTag =3D SmbiosMiscGetString (TokenToGet); + AssertTagStrLen =3D StrLen(AssertTag); + if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION); + Chassis =3D SmbiosMiscGetString (TokenToGet); + ChassisStrLen =3D StrLen(Chassis); + if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + + // + // Two zeros following the last string. + // + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen += 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStr= Len + 1 + ChassisStrLen +1 + 1); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + Pro= ductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 = + ChassisStrLen +1 + 1); + + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE2); + + // + // Make handle chosen by smbios protocol.add automatically. + // + SmbiosRecord->Hdr.Handle =3D 0; + + // + // Manu will be the 1st optional string following the formatted structur= e. + // + SmbiosRecord->Manufacturer =3D 1; + + // + // ProductName will be the 2st optional string following the formatted s= tructure. + // + SmbiosRecord->ProductName =3D 2; + + // + // Version will be the 3rd optional string following the formatted struc= ture. + // + SmbiosRecord->Version =3D 3; + + // + // SerialNumber will be the 4th optional string following the formatted = structure. + // + SmbiosRecord->SerialNumber =3D 4; + + // + // AssertTag will be the 5th optional string following the formatted str= ucture. + // + SmbiosRecord->AssetTag =3D 5; + + // + // LocationInChassis will be the 6th optional string following the forma= tted structure. + // + SmbiosRecord->LocationInChassis =3D 6; + SmbiosRecord->FeatureFlag =3D (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2Inp= utData->BaseBoardFeatureFlags)); + SmbiosRecord->ChassisHandle =3D 0; + SmbiosRecord->BoardType =3D (UINT8)ForType2InputData->BaseBoardType= ; + SmbiosRecord->NumberOfContainedObjectHandles =3D 0; + + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + + // + // Since we fill NumberOfContainedObjectHandles =3D 0 for simple, just a= fter this filed to fill string + // + UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); + UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1); + UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1); + UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + P= roductStrLen + 1 + VerStrLen + 1); + UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + Prod= uctStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); + UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1); + + // + // Now we have got the full smbios record, call smbios protocol to add t= his record. + // + SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; + Status =3D Smbios-> Add( + Smbios, + NULL, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord + ); + + FreePool(SmbiosRecord); + + // + // gEfiSimpleNetworkProtocolGuid is ready + // + if (CallbackIsInstalledT2 =3D=3D FALSE) { + CallbackIsInstalledT2 =3D TRUE; // Prevent more than 1 callba= ck. + DEBUG ((EFI_D_INFO, "Create Smbios T2 callback.\n")); + + mSmbiosHandleType2 =3D SmbiosHandle; + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (EFI_EVENT_NOTIFY)UpdateBaseBoardManuCallback, + RecordData, + &UpdateBaseBoardManuCallbackEvent + ); + + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + + } + + Status =3D gBS->RegisterProtocolNotify ( + &gEfiSimpleNetworkProtocolGuid, + UpdateBaseBoardManuCallbackEvent, + &UpdateBaseBoardManuCallbackNotifyReg + ); + + return Status; + } + return EFI_SUCCESS; +} + diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction= .c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c index 420c8c3..1d47e4a 100644 --- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c +++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c @@ -1,370 +1,388 @@ -/*++ - -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 - This program and the accompanying materials are licensed and made availa= ble under - the terms and conditions of the BSD License that accompanies this distri= bution. =20 - The full text of the license may be found at = =20 - http://opensource.org/licenses/bsd-license.php. = =20 - = =20 - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 - = =20 - - -Module Name: - - MiscSystemManufacturerFunction.c - -Abstract: - - This driver parses the mMiscSubclassDataTable structure and reports - any generated data. - ---*/ - - -#include "CommonHeader.h" -#include "MiscSubclassDriver.h" -#include -#include -#include "Library/DebugLib.h" -#include -#include - - -extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; - - -/** - - Publish the smbios type 1. - - @param Event Event whose notification function is being invoked (gE= fiDxeSmmReadyToLockProtocolGuid). - @param Context Pointer to the notification functions context, which i= s implementation dependent. - - @retval None - -**/ -EFI_STATUS -EFIAPI -AddSmbiosManuCallback ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - - CHAR8 *OptionalStrStart; - UINTN ManuStrLen; - UINTN VerStrLen; - UINTN PdNameStrLen; - UINTN SerialNumStrLen; - UINTN SkuNumberStrLen; - UINTN FamilyNameStrLen; - EFI_STATUS Status; - EFI_STRING Manufacturer; - EFI_STRING ProductName; - EFI_STRING Version; - EFI_STRING SerialNumber; - EFI_STRING SkuNumber; - EFI_STRING FamilyName; - STRING_REF TokenToGet; - EFI_SMBIOS_HANDLE SmbiosHandle; - SMBIOS_TABLE_TYPE1 *SmbiosRecord; - EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData; - EFI_SMBIOS_PROTOCOL *Smbios; - CHAR16 Buffer[40]; - =20 - CHAR16 *MacStr;=20 - EFI_HANDLE *Handles; - UINTN BufferSize; - CHAR16 PlatformNameBuffer[40]; - - ForType1InputData =3D (EFI_MISC_SYSTEM_MANUFACTURER *)Context; - - // - // First check for invalid parameters. - // - if (Context =3D=3D NULL || mPlatformInfo =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID *) = &Smbios); - ASSERT_EFI_ERROR (Status); - - - if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { - // Detect the board is Turbot board platform - UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L= "Minnowboard Turbot "); - } else { - UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L= "Minnowboard Max "); - } - - // - // Silicon Steppings - // - switch (PchStepping()) { - case PchA0: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"A0 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n")); - break; - case PchA1: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"A1 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n")); - break; - case PchB0: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B0 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n")); - break; - case PchB1: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B1 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n")); - break; - case PchB2: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B2 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n")); - break; - case PchB3: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B3 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n")); - break; - case PchC0: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"C0 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n")); - break; - case PchD0: - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"D0 PLATFORM"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); - UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); - DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n")); - break; - default: - DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n")); - break; - } - - if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { - UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI"); - HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Bu= ffer, NULL); - } - TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER); - Manufacturer =3D SmbiosMiscGetString (TokenToGet); - ManuStrLen =3D StrLen(Manufacturer); - if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME); - ProductName =3D SmbiosMiscGetString (TokenToGet); - PdNameStrLen =3D StrLen(ProductName); - if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_VERSION); - Version =3D SmbiosMiscGetString (TokenToGet); - VerStrLen =3D StrLen(Version); - if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - //Get handle infomation - // - BufferSize =3D 0; - Handles =3D NULL; - Status =3D gBS->LocateHandle ( - ByProtocol,=20 - &gEfiSimpleNetworkProtocolGuid, - NULL, - &BufferSize, - Handles - ); - - if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { - Handles =3D AllocateZeroPool(BufferSize); - if (Handles =3D=3D NULL) { - return (EFI_OUT_OF_RESOURCES); - } - Status =3D gBS->LocateHandle( - ByProtocol, - &gEfiSimpleNetworkProtocolGuid, - NULL, - &BufferSize, - Handles - ); - } - =20 - // - //Get the MAC string - // - Status =3D NetLibGetMacString ( - *Handles, - NULL, - &MacStr - ); - if (EFI_ERROR (Status)) {=09 - return Status; - } - SerialNumber =3D MacStr;=20 - SerialNumStrLen =3D StrLen(SerialNumber); - if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER); - SkuNumber =3D SmbiosMiscGetString (TokenToGet); - SkuNumberStrLen =3D StrLen(SkuNumber); - if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1); - FamilyName =3D SmbiosMiscGetString (TokenToGet); - FamilyNameStrLen =3D StrLen(FamilyName); - if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) { - return EFI_UNSUPPORTED; - } - - // - // Two zeros following the last string. - // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen += 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrL= en + 1 + FamilyNameStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdN= ameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 += FamilyNameStrLen + 1 + 1); - - SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_SYSTEM_INFORMATION; - SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE1); - - // - // Make handle chosen by smbios protocol.add automatically. - // - SmbiosRecord->Hdr.Handle =3D 0; - - // - // Manu will be the 1st optional string following the formatted structur= e. - // - SmbiosRecord->Manufacturer =3D 1; - - // - // ProductName will be the 2nd optional string following the formatted s= tructure. - // - SmbiosRecord->ProductName =3D 2; - - // - // Version will be the 3rd optional string following the formatted struc= ture. - // - SmbiosRecord->Version =3D 3; - - // - // Version will be the 4th optional string following the formatted struc= ture. - // - SmbiosRecord->SerialNumber =3D 4; - - SmbiosRecord->SKUNumber=3D 5; - SmbiosRecord->Family=3D 6; - - // - // Unique UUID - // - ForType1InputData->SystemUuid.Data1 =3D PcdGet32 (PcdProductSerialNumber= ); - ForType1InputData->SystemUuid.Data4[0] =3D PcdGet8 (PcdEmmcManufacturerI= d); - - CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,= 16); - - SmbiosRecord->WakeUpType =3D (UINT8)ForType1InputData->SystemWakeupType; - - OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdName= StrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + P= dNameStrLen + 1 + VerStrLen + 1); - - UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNa= meStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); - UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdN= ameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1); - - // - // Now we have got the full smbios record, call smbios protocol to add t= his record. - // - SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; - Status =3D Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); - FreePool(SmbiosRecord); - return Status; -} - -/** - This function makes boot time changes to the contents of the - MiscSystemManufacturer (Type 1). - - @param RecordData Pointer to copy of RecordData from th= e Data Table. - - @retval EFI_SUCCESS All parameters were valid. - @retval EFI_UNSUPPORTED Unexpected RecordType value. - @retval EFI_INVALID_PARAMETER Invalid parameter was found. - -**/ -MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer) -{ - EFI_STATUS Status; - static BOOLEAN CallbackIsInstalledManu =3D FALSE; - VOID *AddSmbiosManuCallbackNotifyReg; - EFI_EVENT AddSmbiosManuCallbackEvent; - - - if (CallbackIsInstalledManu =3D=3D FALSE) { - CallbackIsInstalledManu =3D TRUE; // Prevent more than 1 callb= ack. - DEBUG ((EFI_D_INFO, "Create Smbios Manu callback.\n")); - - // - // gEfiDxeSmmReadyToLockProtocolGuid is ready - // - Status =3D gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - (EFI_EVENT_NOTIFY)AddSmbiosManuCallback, - RecordData, - &AddSmbiosManuCallbackEvent - ); - - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - return Status; - - } - - Status =3D gBS->RegisterProtocolNotify ( - &gEfiDxeSmmReadyToLockProtocolGuid, - AddSmbiosManuCallbackEvent, - &AddSmbiosManuCallbackNotifyReg - ); - - return Status; - } - - return EFI_SUCCESS; - -} +/*++ + +Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made availa= ble under + the terms and conditions of the BSD License that accompanies this distri= bution. + 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 IMP= LIED. + + + +Module Name: + + MiscSystemManufacturerFunction.c + +Abstract: + + This driver parses the mMiscSubclassDataTable structure and reports + any generated data. + +--*/ + + +#include "CommonHeader.h" +#include "MiscSubclassDriver.h" +#include +#include +#include "Library/DebugLib.h" +#include +#include + + +extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; +static EFI_SMBIOS_HANDLE mSmbiosHandleType1; + + +EFI_STATUS +EFIAPI +UpdateSmbiosManuCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_HANDLE *Handles; + UINTN BufferSize; + CHAR16 *MacStr; + EFI_SMBIOS_PROTOCOL *Smbios; + UINTN SerialNumberOffset; + CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH]; + + gBS->CloseEvent (Event); // Unload this event. + + DEBUG ((EFI_D_INFO, "Executing UpdateSmbiosManuCallback.\n")); + + // + //Get handle infomation + // + BufferSize =3D 0; + Handles =3D NULL; + Status =3D gBS->LocateHandle ( + ByProtocol, + &gEfiSimpleNetworkProtocolGuid, + NULL, + &BufferSize, + Handles + ); + + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + Handles =3D AllocateZeroPool(BufferSize); + if (Handles =3D=3D NULL) { + return (EFI_OUT_OF_RESOURCES); + } + Status =3D gBS->LocateHandle( + ByProtocol, + &gEfiSimpleNetworkProtocolGuid, + NULL, + &BufferSize, + Handles + ); + } + + // + //Get the MAC string + // + Status =3D NetLibGetMacString ( + *Handles, + NULL, + &MacStr + ); + if (EFI_ERROR (Status)) { + return Status; + } + + ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH); + UnicodeStrToAsciiStr (MacStr, AsciiData); + + Status =3D gBS->LocateProtocol ( + &gEfiSmbiosProtocolGuid, + NULL, + (VOID *) &Smbios + ); + ASSERT_EFI_ERROR (Status); + + SerialNumberOffset =3D 4; + Status =3D Smbios->UpdateString ( + Smbios, + &mSmbiosHandleType1, + &SerialNumberOffset, + AsciiData + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + return EFI_SUCCESS; +} + + +/** + + Publish the smbios type 1. + + @param Event Event whose notification function is being invoked (gE= fiDxeSmmReadyToLockProtocolGuid). + @param Context Pointer to the notification functions context, which i= s implementation dependent. + + @retval None + +**/ +MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer) +{ + + CHAR8 *OptionalStrStart; + UINTN ManuStrLen; + UINTN VerStrLen; + UINTN PdNameStrLen; + UINTN SerialNumStrLen; + UINTN SkuNumberStrLen; + UINTN FamilyNameStrLen; + EFI_STATUS Status; + EFI_STRING Manufacturer; + EFI_STRING ProductName; + EFI_STRING Version; + EFI_STRING SerialNumber; + EFI_STRING SkuNumber; + EFI_STRING FamilyName; + STRING_REF TokenToGet; + EFI_SMBIOS_HANDLE SmbiosHandle; + SMBIOS_TABLE_TYPE1 *SmbiosRecord; + EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData; + CHAR16 Buffer[40]; + CHAR16 *MacStr; + CHAR16 PlatformNameBuffer[40]; + VOID *UpdateSmbiosManuCallbackNotifyReg; + EFI_EVENT UpdateSmbiosManuCallbackEvent; + static BOOLEAN CallbackIsInstalledT1 =3D FALSE; + + ForType1InputData =3D (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData; + // + // First check for invalid parameters. + // + if (RecordData =3D=3D NULL || mPlatformInfo =3D=3D NULL) { + DEBUG ((EFI_D_INFO, "MISC_SMBIOS_TABLE_FUNCTION error.\n")); + return EFI_INVALID_PARAMETER; + } + + if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { + // + // Detect the board is Turbot board platform + // + UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L= "Minnowboard Turbot "); + } else { + UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L= "Minnowboard Max "); + } + + // + // Silicon Steppings + // + switch (PchStepping()) { + case PchA0: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"A0 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n")); + break; + case PchA1: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"A1 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n")); + break; + case PchB0: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B0 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n")); + break; + case PchB1: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B1 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n")); + break; + case PchB2: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B2 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n")); + break; + case PchB3: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"B3 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n")); + break; + case PchC0: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"C0 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n")); + break; + case PchD0: + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, = L"D0 PLATFORM"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), = Buffer, NULL); + UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffe= r, NULL); + DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n")); + break; + default: + DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n")); + break; + } + + if (BOARD_ID_MINNOW2_TURBOT =3D=3D mPlatformInfo->BoardId) { + UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI"); + HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Bu= ffer, NULL); + } + TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER); + Manufacturer =3D SmbiosMiscGetString (TokenToGet); + ManuStrLen =3D StrLen(Manufacturer); + if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME); + ProductName =3D SmbiosMiscGetString (TokenToGet); + PdNameStrLen =3D StrLen(ProductName); + if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_VERSION); + Version =3D SmbiosMiscGetString (TokenToGet); + VerStrLen =3D StrLen(Version); + if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + MacStr =3D L"00000000"; + SerialNumber =3D MacStr; + SerialNumStrLen =3D StrLen(SerialNumber); + if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER); + SkuNumber =3D SmbiosMiscGetString (TokenToGet); + SkuNumberStrLen =3D StrLen(SkuNumber); + if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1); + FamilyName =3D SmbiosMiscGetString (TokenToGet); + FamilyNameStrLen =3D StrLen(FamilyName); + if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + // + // Two zeros following the last string. + // + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen += 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrL= en + 1 + FamilyNameStrLen + 1 + 1); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdN= ameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 += FamilyNameStrLen + 1 + 1); + + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_SYSTEM_INFORMATION; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE1); + + // + // Make handle chosen by smbios protocol.add automatically. + // + SmbiosRecord->Hdr.Handle =3D 0; + + // + // Manu will be the 1st optional string following the formatted structur= e. + // + SmbiosRecord->Manufacturer =3D 1; + + // + // ProductName will be the 2nd optional string following the formatted s= tructure. + // + SmbiosRecord->ProductName =3D 2; + + // + // Version will be the 3rd optional string following the formatted struc= ture. + // + SmbiosRecord->Version =3D 3; + + // + // Version will be the 4th optional string following the formatted struc= ture. + // + SmbiosRecord->SerialNumber =3D 4; + + SmbiosRecord->SKUNumber=3D 5; + SmbiosRecord->Family=3D 6; + + // + // Unique UUID + // + ForType1InputData->SystemUuid.Data1 =3D PcdGet32 (PcdProductSerialNumber= ); + ForType1InputData->SystemUuid.Data4[0] =3D PcdGet8 (PcdEmmcManufacturerI= d); + + CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,= 16); + + SmbiosRecord->WakeUpType =3D (UINT8)ForType1InputData->SystemWakeupType; + + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); + UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1); + UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdName= StrLen + 1); + UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + P= dNameStrLen + 1 + VerStrLen + 1); + + UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNa= meStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); + UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdN= ameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1); + + // + // Now we have got the full smbios record, call smbios protocol to add t= his record. + // + SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; + Status =3D Smbios-> Add( + Smbios, + NULL, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord + ); + FreePool(SmbiosRecord); + + // + // gEfiSimpleNetworkProtocolGuid is ready + // + if (CallbackIsInstalledT1 =3D=3D FALSE) { + CallbackIsInstalledT1 =3D TRUE; // Prevent more than 1 callba= ck. + DEBUG ((EFI_D_INFO, "Create Smbios Type1 callback.\n")); + + mSmbiosHandleType1 =3D SmbiosHandle; + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (EFI_EVENT_NOTIFY)UpdateSmbiosManuCallback, + RecordData, + &UpdateSmbiosManuCallbackEvent + ); + + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR (Status)) { + return Status; + + } + + Status =3D gBS->RegisterProtocolNotify ( + &gEfiSimpleNetworkProtocolGuid, + UpdateSmbiosManuCallbackEvent, + &UpdateSmbiosManuCallbackNotifyReg + ); + return Status; + } + + return EFI_SUCCESS; +} + diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf b/Vlv2TbltDe= vicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf index 332d237..f88dcbe 100644 --- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf +++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf @@ -1,145 +1,146 @@ -## @file -# Component name for module MiscSubclass -# -# FIX ME! -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
-# = =20 -# This program and the accompanying materials are licensed and made availa= ble under -# the terms and conditions of the BSD License that accompanies this distri= bution. =20 -# The full text of the license may be found at = =20 -# http://opensource.org/licenses/bsd-license.php. = =20 -# = =20 -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 -# = =20 -# -# -# -## - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D MiscSubclass - FILE_GUID =3D 4EFFB560-B28B-4e57-9DAD-4344E32EA3BA - MODULE_TYPE =3D DXE_DRIVER - VERSION_STRING =3D 1.0 - ENTRY_POINT =3D MiscSubclassDriverEntryPoint - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC -# - -[Sources] - MiscBaseBoardManufacturer.uni - MiscBaseBoardManufacturerData.c - MiscBaseBoardManufacturerFunction.c - MiscBiosVendor.uni - MiscBiosVendorData.c - MiscBiosVendorFunction.c - MiscBootInformationData.c - MiscBootInformationFunction.c - MiscChassisManufacturer.uni - MiscChassisManufacturerData.c - MiscChassisManufacturerFunction.c - MiscNumberOfInstallableLanguagesData.c - MiscNumberOfInstallableLanguagesFunction.c - MiscOemString.uni - MiscOemStringData.c - MiscOemStringFunction.c - MiscOnboardDevice.uni - MiscOnboardDeviceData.c - MiscOnboardDeviceFunction.c - MiscPortInternalConnectorDesignator.uni - MiscPortInternalConnectorDesignatorData.c - MiscPortInternalConnectorDesignatorFunction.c - MiscResetCapabilitiesData.c - MiscResetCapabilitiesFunction.c - MiscSystemLanguageString.uni - MiscSystemLanguageStringData.c - MiscSystemLanguageStringFunction.c - MiscSystemManufacturer.uni - MiscSystemManufacturerData.c - MiscSystemManufacturerFunction.c - MiscSystemOptionString.uni - MiscSystemOptionStringData.c - MiscSystemOptionStringFunction.c - MiscSystemSlotDesignation.uni - MiscSystemSlotDesignationData.c - MiscSystemSlotDesignationFunction.c - MiscSubclassDriver.h - MiscSubclassDriver.uni - MiscSubclassDriverDataTable.c - MiscSubclassDriverEntryPoint.c - CommonHeader.h - MiscOemType0x90Function.c - MiscOemType0x90Data.c - MiscOemType0x90.uni - MiscProcessorInformation.uni - MiscProcessorInformationData.c - MiscProcessorInformationFunction.c - MiscProcessorCache.uni - MiscProcessorCacheData.c - MiscProcessorCacheFunction.c - MiscPhysicalArray.uni - MiscPhysicalArrayData.c - MiscPhysicalArrayFunction.c - MiscMemoryDevice.uni - MiscMemoryDeviceData.c - MiscMemoryDeviceFunction.c - -[Packages] - MdeModulePkg/MdeModulePkg.dec - Vlv2TbltDevicePkg/PlatformPkg.dec - MdePkg/MdePkg.dec - IntelFrameworkPkg/IntelFrameworkPkg.dec - Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec - -[LibraryClasses] - HiiLib - DevicePathLib - UefiBootServicesTableLib - UefiRuntimeServicesTableLib - UefiDriverEntryPoint - BaseMemoryLib - DebugLib - BaseLib - MemoryAllocationLib - PcdLib - UefiLib - BiosIdLib - PrintLib - CpuIA32Lib - PchPlatformLib - I2cLib - NetLib - HobLib - =20 -[Guids] - gEfiProcessorSubClassGuid - gEfiCacheSubClassGuid - gEfiNormalSetupGuid - gEfiPlatformInfoGuid - gEfiVlv2VariableGuid - -[Protocols] - gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiDataHubProtocolGuid - gEfiMpServiceProtocolGuid - gMemInfoProtocolGuid - gEfiTdtOperationProtocolGuid - gDxePchPlatformPolicyProtocolGuid - gEfiSpiProtocolGuid - gEfiSimpleNetworkProtocolGuid - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString - gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString - gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang - gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId - gEfiVLVTokenSpaceGuid.PcdProductSerialNumber - -[Depex] - gEfiSmbiosProtocolGuid AND gMemInfoProtocolGuid AND gEfiMpServiceProtocol= Guid AND gEfiSimpleNetworkProtocolGuid +## @file +# Component name for module MiscSubclass +# +# FIX ME! +# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials are licensed and made availa= ble under +# the terms and conditions of the BSD License that accompanies this distri= bution. +# 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 IMP= LIED. +# +# +# +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D MiscSubclass + FILE_GUID =3D 4EFFB560-B28B-4e57-9DAD-4344E32EA3BA + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D MiscSubclassDriverEntryPoint + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 IPF EBC +# + +[Sources] + MiscBaseBoardManufacturer.uni + MiscBaseBoardManufacturerData.c + MiscBaseBoardManufacturerFunction.c + MiscBiosVendor.uni + MiscBiosVendorData.c + MiscBiosVendorFunction.c + MiscBootInformationData.c + MiscBootInformationFunction.c + MiscChassisManufacturer.uni + MiscChassisManufacturerData.c + MiscChassisManufacturerFunction.c + MiscNumberOfInstallableLanguagesData.c + MiscNumberOfInstallableLanguagesFunction.c + MiscOemString.uni + MiscOemStringData.c + MiscOemStringFunction.c + MiscOnboardDevice.uni + MiscOnboardDeviceData.c + MiscOnboardDeviceFunction.c + MiscPortInternalConnectorDesignator.uni + MiscPortInternalConnectorDesignatorData.c + MiscPortInternalConnectorDesignatorFunction.c + MiscResetCapabilitiesData.c + MiscResetCapabilitiesFunction.c + MiscSystemLanguageString.uni + MiscSystemLanguageStringData.c + MiscSystemLanguageStringFunction.c + MiscSystemManufacturer.uni + MiscSystemManufacturerData.c + MiscSystemManufacturerFunction.c + MiscSystemOptionString.uni + MiscSystemOptionStringData.c + MiscSystemOptionStringFunction.c + MiscSystemSlotDesignation.uni + MiscSystemSlotDesignationData.c + MiscSystemSlotDesignationFunction.c + MiscSubclassDriver.h + MiscSubclassDriver.uni + MiscSubclassDriverDataTable.c + MiscSubclassDriverEntryPoint.c + CommonHeader.h + MiscOemType0x90Function.c + MiscOemType0x90Data.c + MiscOemType0x90.uni + MiscProcessorInformation.uni + MiscProcessorInformationData.c + MiscProcessorInformationFunction.c + MiscProcessorCache.uni + MiscProcessorCacheData.c + MiscProcessorCacheFunction.c + MiscPhysicalArray.uni + MiscPhysicalArrayData.c + MiscPhysicalArrayFunction.c + MiscMemoryDevice.uni + MiscMemoryDeviceData.c + MiscMemoryDeviceFunction.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + Vlv2TbltDevicePkg/PlatformPkg.dec + MdePkg/MdePkg.dec + IntelFrameworkPkg/IntelFrameworkPkg.dec + Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec + +[LibraryClasses] + HiiLib + DevicePathLib + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + UefiDriverEntryPoint + BaseMemoryLib + DebugLib + BaseLib + MemoryAllocationLib + PcdLib + UefiLib + BiosIdLib + PrintLib + CpuIA32Lib + PchPlatformLib + I2cLib + NetLib + HobLib + +[Guids] + gEfiProcessorSubClassGuid + gEfiCacheSubClassGuid + gEfiNormalSetupGuid + gEfiPlatformInfoGuid + gEfiVlv2VariableGuid + +[Protocols] + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiDataHubProtocolGuid + gEfiMpServiceProtocolGuid + gMemInfoProtocolGuid + gEfiTdtOperationProtocolGuid + gDxePchPlatformPolicyProtocolGuid + gEfiSpiProtocolGuid + gEfiSimpleNetworkProtocolGuid + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString + gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang + gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId + gEfiVLVTokenSpaceGuid.PcdProductSerialNumber + +[Depex] + gEfiSmbiosProtocolGuid AND gMemInfoProtocolGuid AND gEfiMpServiceProtocol= Guid + --=20 2.10.1.windows.1