From nobody Tue Apr 30 17:33:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1526951527714357.3031243605037; Mon, 21 May 2018 18:12:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 14E42203B8CEB; Mon, 21 May 2018 18:12:06 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 9ECB4203B8CE8 for ; Mon, 21 May 2018 18:12:05 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2018 18:12:05 -0700 Received: from unknown (HELO zwei4-MOBL1.ccr.corp.intel.com) ([10.239.193.66]) by orsmga001.jf.intel.com with ESMTP; 21 May 2018 18:12:04 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=david.wei@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,428,1520924400"; d="scan'208";a="57899209" From: zwei4 To: edk2-devel@lists.01.org Date: Tue, 22 May 2018 09:11:59 +0800 Message-Id: <20180522011159.16468-1-david.wei@intel.com> X-Mailer: git-send-email 2.14.1.windows.1 Subject: [edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Initialize SerialNumber of SMBIOS Type 1 Table. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Get NIC MAC address and fill it into SerialNumber field of SMBIOS Type 1 Ta= ble. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: zwei4 --- .../SmBiosMiscDxe/MiscBaseBoardManufacturer.uni | Bin 2448 -> 2430 bytes .../SmBiosMiscDxe/MiscChassisManufacturer.uni | Bin 1990 -> 1892 bytes .../SmBiosMiscDxe/MiscSystemManufacturer.uni | Bin 3406 -> 3438 bytes .../SmBiosMiscDxe/MiscSystemManufacturerFunction.c | 230 +++++++++++++++++= +--- .../Smbios/SmBiosMiscDxe/SmBiosMiscDxe.inf | 4 +- .../Common/PlatformSettings/PlatformDxe/Platform.c | 4 +- 6 files changed, 207 insertions(+), 31 deletions(-) diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscD= xe/MiscBaseBoardManufacturer.uni b/Platform/BroxtonPlatformPkg/Common/Featu= res/Smbios/SmBiosMiscDxe/MiscBaseBoardManufacturer.uni index e53c866ce87e1aeef7f60321f975f2ac2b5c809d..4bb96b13a67a808ebba0000620e= 5ad979c92d765 100644 GIT binary patch delta 96 zcmbOr{7-1Y6h@1UQ|GfxzQiWQoyw5MkiwA9P{g1#c_WMMRR910 delta 180 zcmew-G(mX66h^a+Q|Gg=3DIx@I0cus!E8oqfQYXOsH2tz)D0z(o*Dv(TL$YjU?!c>M7 ouvjIK^k>jxa0OytpcebdWgKoK>JZ^{Ga=3Ddz1|`+83CvRbMQ1@lXWXJ=3D;e1>wM g+I)sYh9ZU(pq?-WV<3raLZtwl$DqW(%fQ6|042l}VgLXD delta 203 zcmaFDcZ`2RAEVjEennQz5QcmP1%@PsR3Mqgkjan(gsBWEV6jRd>Cd3Y;0naPlW((G ePyWJcM}iJ(wn`FI-)5^cAlfwyN({UVTnqr(bS7c| diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscD= xe/MiscSystemManufacturer.uni b/Platform/BroxtonPlatformPkg/Common/Features= /Smbios/SmBiosMiscDxe/MiscSystemManufacturer.uni index da8647f6c7d31b1388c601885014a9dea40065b7..3567f72b9cfcec53748b4d5f825= 60a4a17ba9120 100644 GIT binary patch delta 167 zcmX>n^-gNS3Py{KE2pw3`!ZxQ7OMo3 a{tS8yu0ZTNIg! + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -22,7 +22,176 @@ #include #include #include +#include +#include +#include =20 +/** + Return the description for network boot device. + + @param Handle Controller handle. + + @return The description string. +**/ +CHAR16 * +GetNetworkDescription ( + IN EFI_HANDLE Handle + ) +{ + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + MAC_ADDR_DEVICE_PATH *Mac; + VLAN_DEVICE_PATH *Vlan; + EFI_DEVICE_PATH_PROTOCOL *Ip; + EFI_DEVICE_PATH_PROTOCOL *Uri; + CHAR16 *Description; + UINTN DescriptionSize; + + Status =3D gBS->OpenProtocol ( + Handle, + &gEfiLoadFileProtocolGuid, + NULL, + gImageHandle, + Handle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + Status =3D gBS->OpenProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID **) &DevicePath, + gImageHandle, + Handle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status) || (DevicePath =3D=3D NULL)) { + return NULL; + } + + // + // The PXE device path is like: + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)] + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...) + // + // The HTTP device path is like: + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)/Uri(...) + // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)/Uri(...) + // + while (!IsDevicePathEnd (DevicePath) && + ((DevicePathType (DevicePath) !=3D MESSAGING_DEVICE_PATH) || + (DevicePathSubType (DevicePath) !=3D MSG_MAC_ADDR_DP)) + ) { + DevicePath =3D NextDevicePathNode (DevicePath); + } + + if (IsDevicePathEnd (DevicePath)) { + return NULL; + } + + Mac =3D (MAC_ADDR_DEVICE_PATH *) DevicePath; + DevicePath =3D NextDevicePathNode (DevicePath); + + // + // Locate the optional Vlan node + // + if ((DevicePathType (DevicePath) =3D=3D MESSAGING_DEVICE_PATH) && + (DevicePathSubType (DevicePath) =3D=3D MSG_VLAN_DP) + ) { + Vlan =3D (VLAN_DEVICE_PATH *) DevicePath; + DevicePath =3D NextDevicePathNode (DevicePath); + } else { + Vlan =3D NULL; + } + + // + // Skip the optional Wi-Fi node + // + if ((DevicePathType (DevicePath) =3D=3D MESSAGING_DEVICE_PATH) && + (DevicePathSubType (DevicePath) =3D=3D MSG_WIFI_DP) + ) { + DevicePath =3D NextDevicePathNode (DevicePath); + } + + // + // Locate the IP node + // + if ((DevicePathType (DevicePath) =3D=3D MESSAGING_DEVICE_PATH) && + ((DevicePathSubType (DevicePath) =3D=3D MSG_IPv4_DP) || + (DevicePathSubType (DevicePath) =3D=3D MSG_IPv6_DP)) + ) { + Ip =3D DevicePath; + DevicePath =3D NextDevicePathNode (DevicePath); + } else { + Ip =3D NULL; + } + + // + // Locate the URI node + // + if ((DevicePathType (DevicePath) =3D=3D MESSAGING_DEVICE_PATH) && + (DevicePathSubType (DevicePath) =3D=3D MSG_URI_DP) + ) { + Uri =3D DevicePath; + DevicePath =3D NextDevicePathNode (DevicePath); + } else { + Uri =3D NULL; + } + + // + // Build description like below: + // "PXEv6 (MAC:112233445566 VLAN1)" + // "HTTPv4 (MAC:112233445566)" + // + DescriptionSize =3D sizeof (L"112233445566"); + Description =3D AllocatePool (DescriptionSize); + ASSERT (Description !=3D NULL); + UnicodeSPrint ( + Description, DescriptionSize, + L"%02x%02x%02x%02x%02x%02x", + Mac->MacAddress.Addr[0], Mac->MacAddress.Addr[1], Mac->MacAddress.Addr= [2], + Mac->MacAddress.Addr[3], Mac->MacAddress.Addr[4], Mac->MacAddress.Addr= [5] + ); + return Description; +} + +CHAR16 * +GetMacAddressString( + ) +{ + EFI_HANDLE *Handles; + UINTN HandleCount; + UINT8 Index; + CHAR16 *MacAddressString =3D NULL; + =20 + // + // Parse load file protocol + // + gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiLoadFileProtocolGuid, + NULL, + &HandleCount, + &Handles + ); + for (Index =3D 0; Index < HandleCount; Index++) { + + MacAddressString =3D GetNetworkDescription (Handles[Index]); + + if (MacAddressString !=3D NULL) { + break; + } + } + + if (HandleCount !=3D 0) { + FreePool (Handles); + } + + return MacAddressString; +} =20 /** Publish the smbios type 1. @@ -61,10 +230,16 @@ AddSmbiosManuCallback ( EFI_SMBIOS_PROTOCOL *Smbios; CHAR16 Buffer[40]; CHAR16 PlatformNameBuffer[40]; + CHAR16 SerialNumberBuffer[sizeof (L"112233445= 566")]; EFI_PEI_HOB_POINTERS GuidHob; GET_BOARD_NAME GetBoardNameFunc; EFI_PLATFORM_INFO_HOB *PlatformInfo =3D NULL; + CHAR16 *MacAddressString =3D NULL; + STATIC BOOLEAN mType1Installed =3D FALSE; =20 + if (mType1Installed =3D=3D TRUE) { + return; + } =20 GuidHob.Raw =3D GetHobList (); if (GuidHob.Raw !=3D NULL) { @@ -177,6 +352,11 @@ AddSmbiosManuCallback ( return; } =20 + MacAddressString =3D GetMacAddressString(); + if ( MacAddressString !=3D NULL) { + UnicodeSPrint (SerialNumberBuffer, sizeof (L"112233445566"), L"%s", Ge= tMacAddressString()); + HiiSetString (mHiiHandle, STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER)= , SerialNumberBuffer, NULL); + } TokenToGet =3D STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER); SerialNumber =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NUL= L); SerialNumStrLen =3D StrLen (SerialNumber); @@ -236,9 +416,16 @@ AddSmbiosManuCallback ( // // Unique UUID // - ForType1InputData->SystemUuid.Data1 =3D PcdGet32 (PcdProductSerialNumber= ); - ForType1InputData->SystemUuid.Data4[0] =3D PcdGet8 (PcdEmmcManufacturerI= d); - + //ForType1InputData->SystemUuid.Data1 =3D PcdGet32 (PcdProductSerialNumb= er); + //ForType1InputData->SystemUuid.Data4[0] =3D PcdGet8 (PcdEmmcManufacture= rId); + ForType1InputData->SystemUuid.Data1 =3D (UINT32)MacAddressString [0] + (= ((UINT32)MacAddressString [1]) << 16); + ForType1InputData->SystemUuid.Data2 =3D (UINT16)MacAddressString [2]; + ForType1InputData->SystemUuid.Data3 =3D (UINT16)MacAddressString [3]; + ForType1InputData->SystemUuid.Data4[0] =3D (UINT8)MacAddressString [4]; + ForType1InputData->SystemUuid.Data4[1] =3D (UINT8)(MacAddressString [4] = >> 8); + ForType1InputData->SystemUuid.Data4[2] =3D (UINT8)MacAddressString [5]; + ForType1InputData->SystemUuid.Data4[3] =3D (UINT8)(MacAddressString [5] = >> 8); + =20 CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,= 16); =20 SmbiosRecord->WakeUpType =3D (UINT8) ForType1InputData->SystemWakeupType; @@ -262,6 +449,9 @@ AddSmbiosManuCallback ( (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord ); FreePool (SmbiosRecord); + =20 + mType1Installed =3D TRUE; + =20 return; } =20 @@ -279,9 +469,8 @@ AddSmbiosManuCallback ( **/ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer) { - EFI_STATUS Status; + EFI_STATUS Status =3D EFI_SUCCESS; static BOOLEAN CallbackIsInstalledManu =3D FALSE; - VOID *AddSmbiosManuCallbackNotifyReg; EFI_EVENT AddSmbiosManuCallbackEvent; =20 =20 @@ -289,32 +478,17 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer) CallbackIsInstalledManu =3D TRUE; // Prevent more than 1 call= back. DEBUG ((EFI_D_INFO, "Create Smbios Manu callback.\n")); =20 - // - // gEfiDxeSmmReadyToLockProtocolGuid is ready - // - Status =3D gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - AddSmbiosManuCallback, - RecordData, - &AddSmbiosManuCallbackEvent - ); - - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - return Status; =20 - } =20 - Status =3D gBS->RegisterProtocolNotify ( - &gEfiDxeSmmReadyToLockProtocolGuid, - AddSmbiosManuCallbackEvent, - &AddSmbiosManuCallbackNotifyReg - ); + Status =3D EfiCreateEventReadyToBootEx ( + TPL_CALLBACK, + (EFI_EVENT_NOTIFY)AddSmbiosManuCallback, + RecordData, + &AddSmbiosManuCallbackEvent + ); =20 - return Status; } =20 - return EFI_SUCCESS; + return Status; =20 } =20 diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscD= xe/SmBiosMiscDxe.inf b/Platform/BroxtonPlatformPkg/Common/Features/Smbios/S= mBiosMiscDxe/SmBiosMiscDxe.inf index 12ffea3c90..31fd8406b2 100644 --- a/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscDxe/SmBi= osMiscDxe.inf +++ b/Platform/BroxtonPlatformPkg/Common/Features/Smbios/SmBiosMiscDxe/SmBi= osMiscDxe.inf @@ -1,7 +1,7 @@ ## @file # Component name for module MiscSubclass. # -# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -129,6 +129,8 @@ gEfiMpServiceProtocolGuid gMemInfoProtocolGuid gCpuInfoProtocolGuid + gEfiLoadFileProtocolGuid + gEfiDevicePathProtocolGuid =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDx= e/Platform.c b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/Platform= Dxe/Platform.c index b03f825f89..712d5cd14f 100644 --- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platf= orm.c +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/Platf= orm.c @@ -699,7 +699,7 @@ InitializePlatform ( EFI_HOB_GUID_TYPE *FdoEnabledGuidHob =3D NULL; EFI_PLATFORM_INFO_HOB *PlatformInfoHob; EFI_PEI_HOB_POINTERS Hob; - EFI_EVENT EfiShellEvent =3D NULL; + EFI_EVENT EfiShellEvent =3D NULL; VOID *mEfiShellProtocolRegistration; =20 mImageHandle =3D ImageHandle; @@ -916,7 +916,7 @@ InitializePlatform ( EfiShellEvent, &mEfiShellProtocolRegistration ); - } + } return EFI_SUCCESS; } =20 --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel