From nobody Tue Feb 10 15:46:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53439+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53439+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1579780825; cv=none; d=zohomail.com; s=zohoarc; b=MUspNcZM6L5+8HcohqhzKIHVOhgjqRHNqM69mVS5LMCXoapp9wIyYLLPE6JxkRhpAxj9jqK5Nk5PjxD6e+O9cuiB65ApZfoMJs52k5Q97m6v4sY6KoLX/eB5gLqLU9b4zrfwa43mJWrscOC0w88vsE8VZJaM7ur5tX5grkREmVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579780825; 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=Y56DoZHlsw7Csw5SCuxVyaDe+CvUoJJZGoaIS1mgL/Q=; b=U89aHuLhNUhtIr0EdyMjaNanP8za+kzRWsTfvL1DfCmWu9F9Lg+9hRk6gt20mlkNCSLuu4pF1Y/mC+zVd06yQq4FI5LXSZSyKXVEvs993jolPCUmLjIl01aStCwkCpyqgn/zDbH61yPxVfkuPhpfE2MlSZdcOrPJmSAdJGtjjFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53439+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1579780825189798.2445037033212; Thu, 23 Jan 2020 04:00:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id h6SmYY1788612xrqzxsDM1Il; Thu, 23 Jan 2020 04:00:24 -0800 X-Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.groups.io with SMTP id smtpd.web09.6560.1579780823129833984 for ; Thu, 23 Jan 2020 04:00:23 -0800 X-Received: by mail-wm1-f68.google.com with SMTP id b19so2266139wmj.4 for ; Thu, 23 Jan 2020 04:00:22 -0800 (PST) X-Gm-Message-State: SaPwm4mBLhZBLjfN4iTvQV67x1787277AA= X-Google-Smtp-Source: APXvYqyjarzOKvyJOrBSUIep1i3GrFbNin2ZxF9CqUeCNC6VYAVw8QmU2xhYCbevxs6Sb29m7juWhQ== X-Received: by 2002:a1c:6588:: with SMTP id z130mr3853873wmb.0.1579780821506; Thu, 23 Jan 2020 04:00:21 -0800 (PST) X-Received: from localhost.localdomain ([84.203.95.128]) by smtp.gmail.com with ESMTPSA id t1sm2492281wma.43.2020.01.23.04.00.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jan 2020 04:00:20 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif@nuviainc.com, philmd@redhat.com, lintonrjeremy@gmail.com Subject: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/RPi: Add PlatformPcdLib to set the Genet MAC address Date: Thu, 23 Jan 2020 12:00:04 +0000 Message-Id: <20200123120007.4784-3-pete@akeo.ie> In-Reply-To: <20200123120007.4784-1-pete@akeo.ie> References: <20200123120007.4784-1-pete@akeo.ie> 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579780824; bh=fJlWroX3757fPjMv9lKLOIbCPhEDL8gjeCi+i76n0ig=; h=Cc:Date:From:Reply-To:Subject:To; b=d6DzcEPwee7s6A7eBs5z/ucPpoFYhp0raGAn81qvbLykRO+HYy7+p3vleIZaCD5ocOL pfNscMGJzTnQbT1Uy1UNlFVCX5u/rynmrme42v1q8hc1CW2TnBIzxsr7bhP2Ar/oO0Jxr 4ZoZS9AJAyFmuUnUX5oaU4ZU5SgzoZwi1Bs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The Genet driver stub used by the Raspberry Pi 4 platform is designed to set the MAC address according to a PCD. To be able to set that PCD at runtime, by using the Raspberry Pi firmware interface, that has a dedicated call to retrieve the MAC address, and satisfy driver dependencies in a generic manner, we create a new PlatformPcdLib that can be referenced by the Genet driver, to set the MAC PCD before use there. While it is currently only tailored around MAC PCD population for Genet, we do expect this PCD library to be extended in the future, to provide additional PCD facilities for other drivers. Signed-off-by: Pete Batard --- Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c | 61 ++++++= ++++++++++++++ Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf | 44 ++++++= ++++++++ 2 files changed, 105 insertions(+) diff --git a/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c b= /Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c new file mode 100644 index 000000000000..78f3679e2e48 --- /dev/null +++ b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.c @@ -0,0 +1,61 @@ +/** @file + * + * Copyright (c) 2020, Pete Batard + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +PlatformPcdLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + + // + // If Genet is in use and a MAC address PCD has not been set, do it here. + // +#if (FixedPcdGet64 (PcdBcmGenetRegistersAddress) !=3D 0) + EFI_STATUS Status; + UINT64 MacAddr; + RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; + + if (PcdGet64 (PcdBcmGenetMacAddress) =3D=3D 0) { + Status =3D gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NUL= L, + (VOID**)&mFwProtocol); + ASSERT_EFI_ERROR(Status); + + // + // Get the MAC address from the firmware + // + Status =3D mFwProtocol->GetMacAddress ((UINT8*) &MacAddr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "%a: failed to retrieve MAC address\n", __FUNCTI= ON__)); + } else { + PcdSet64 (PcdBcmGenetMacAddress, MacAddr); + } + } +#endif + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +PlatformPcdLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return EFI_SUCCESS; +} diff --git a/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf= b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf new file mode 100644 index 000000000000..a564ddfbb2a3 --- /dev/null +++ b/Platform/RaspberryPi/Library/PlatformPcdLib/PlatformPcdLib.inf @@ -0,0 +1,44 @@ +#/** @file +# +# Copyright (c) 2020, Pete Batard +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D PlatformPcdLib + FILE_GUID =3D 3B8409D7-D3C7-4006-823B-BFB184435363 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D NULL|DXE_DRIVER UEFI_APPLICATION + CONSTRUCTOR =3D PlatformPcdLibConstructor + DESTRUCTOR =3D PlatformPcdLibDestructor + +[Sources] + PlatformPcdLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + Platform/RaspberryPi/RaspberryPi.dec + Silicon/Broadcom/Drivers/Net/BcmNet.dec + +[LibraryClasses] + UefiLib + DebugLib + PrintLib + +[Protocols] + gRaspberryPiFirmwareProtocolGuid ## CONSUMES + +[Pcd] + gBcmNetTokenSpaceGuid.PcdBcmGenetMacAddress ## SOMETIMES_PRODUCES + +[FixedPcd] + gBcmNetTokenSpaceGuid.PcdBcmGenetRegistersAddress + +[Depex] + gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid + --=20 2.21.0.windows.1 -=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 (#53439): https://edk2.groups.io/g/devel/message/53439 Mute This Topic: https://groups.io/mt/70045881/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-