From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web11.6994.1589294068256810442 for ; Tue, 12 May 2020 07:34:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=ZheAVejS; spf=pass (domain: nuviainc.com, ip: 209.85.128.66, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f66.google.com with SMTP id m12so17106365wmc.0 for ; Tue, 12 May 2020 07:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FbOo0VS+smdOPf9EUqj22/d4dehSR6xcU/V+0wH2GXs=; b=ZheAVejSQD+ynJTXXXkZNP9ZRw+hKHENo4t6FhZAD7WpfJyICAgAM1iqqgj5Zla2Xt TJ2/IQFhEx3u3NzmqH/qxh4WmfBI2oBVryRMRshctvt3283gL2uRIQdR6KZ9+SINot3F DSRnb743lAA/VKz0a59+B3hXqUCRp23WNRZlF18X9Nis2qVXR90Vni7A+iqH0B1sa3Os zn5MHunlBGgSTEPa76ulq4HiyUq/CArFU1C3aaeKtZYfp+QLNMfyntMQWw4i7PBmY+ow pTd3ZifVGVLlAOAxhnluvvye3Io2sRJcOF2XeT0aQDMu7dYNxEVF30GKRz2KF7E8YL8l 3CBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FbOo0VS+smdOPf9EUqj22/d4dehSR6xcU/V+0wH2GXs=; b=eblPSsE+wWoPHdWhRY1CQptWfyKKVEbZQgbB2MP+mQz1czrYqtTF00F8XRaECRhXxq WrrQ4VYf3GssAjlBF0uVUCujHrYpHS4DBP3Va5skpVXw7c8NsTFQPefT3dNVUEcdMFCr 2Yfzq2+eufZ2sFTnlua4dnuHJN6MmNPpE6XYsgVRCNkgT9nR/H5NOl3G9+SZMWvxjy9h bqGsmTdlsrle67fruJADRT+iWMzpYgkTfS/JimMT5Z2ZbKnrWv9TIzVKLvzhOfoU5R6d YcCp7yN4MmPi5bwvHoWZsF+H/HC0mn38qXzjBbNVN2ciY736gDHK/2RdMuGLL2LYsq96 o0pA== X-Gm-Message-State: AGi0PubBsxlsCZW6ck/C2kEXD4P2P7XcsCxFXzvZdN5kHrSnhqb13MiW N2M89xVRjGw8xs85MLSk2/3dnA== X-Google-Smtp-Source: APiQypLA5o7kliPFMq+D/Vys0Y5tAlbfV3PT3rkX6TYFLwMPngZhkhCPK0AO+0QtIaM00QQK3XsGQw== X-Received: by 2002:a05:600c:3cd:: with SMTP id z13mr18202388wmd.159.1589294066707; Tue, 12 May 2020 07:34:26 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id m3sm7507421wrn.96.2020.05.12.07.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 07:34:26 -0700 (PDT) Date: Tue, 12 May 2020 15:34:24 +0100 From: "Leif Lindholm" To: Ard Biesheuvel Cc: devel@edk2.groups.io, philmd@redhat.com Subject: Re: [PATCH edk2-platforms v2 5/7] Platform/RaspberryPi4: Register GENET platform device protocol Message-ID: <20200512143424.GH21486@vanye> References: <20200512075512.12645-1-ard.biesheuvel@arm.com> <20200512075512.12645-6-ard.biesheuvel@arm.com> MIME-Version: 1.0 In-Reply-To: <20200512075512.12645-6-ard.biesheuvel@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 12, 2020 at 09:55:10 +0200, Ard Biesheuvel wrote: > Register an event at EndOfDxe to instantiate the EFI device path protocol > with the GENET MAC address on a new handle, and install the > BcmGenetPlatformDeviceProtocol on that handle. This protocol is used to > pass platform information (GENET MAC address and register base address) > to the GENET driver, which will consume this in its implementation of the > UEFI driver model Supported/Start/Stop methods. > > Co-authored-by: Samer El-Haj-Mahmoud > Co-authored-by: Ard Biesheuvel > Co-authored-by: Andrei Warkentin > Signed-off-by: Ard Biesheuvel > --- > Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 29 ++++-- > Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 108 ++++++++++++++++++-- > 2 files changed, 117 insertions(+), 20 deletions(-) > > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > index e47f3af69199..f20f3bcc1243 100644 > --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > @@ -1,6 +1,8 @@ > #/** @file > # > -# Copyright (c) 2019, ARM Limited. All rights reserved. > +# Component description file for the RasbperryPi DXE platform config driver. > +# > +# Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. > # Copyright (c) 2018, Andrei Warkentin > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -21,7 +23,6 @@ [Defines] > # > # VALID_ARCHITECTURES = AARCH64 > # > - > [Sources] > ConfigDxe.c > ConfigDxeFormSetGuid.h > @@ -31,31 +32,36 @@ [Sources] > [Packages] > ArmPkg/ArmPkg.dec > ArmPlatformPkg/ArmPlatformPkg.dec > - MdePkg/MdePkg.dec > + EmbeddedPkg/EmbeddedPkg.dec > MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + NetworkPkg/NetworkPkg.dec > + Platform/RaspberryPi/RaspberryPi.dec > Silicon/Broadcom/Bcm27xx/Bcm27xx.dec > Silicon/Broadcom/Bcm283x/Bcm283x.dec > - Platform/RaspberryPi/RaspberryPi.dec > - EmbeddedPkg/EmbeddedPkg.dec > + Silicon/Broadcom/Drivers/Net/BcmNet.dec > > [LibraryClasses] > + AcpiLib > BaseLib > DebugLib > DxeServicesTableLib > + GpioLib > + HiiLib > + NetLib > PcdLib > UefiBootServicesTableLib > - UefiRuntimeServicesTableLib > UefiDriverEntryPoint > - HiiLib > - GpioLib > - AcpiLib > + UefiRuntimeServicesTableLib The cleanup is good, but could we separate functional and non-functional changes into separate patches? > > [Guids] > gConfigDxeFormSetGuid > + gEfiEndOfDxeEventGroupGuid > > [Protocols] > - gRaspberryPiFirmwareProtocolGuid ## CONSUMES > - gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES > + gBcmGenetPlatformDeviceProtocolGuid ## PRODUCES > + gRaspberryPiFirmwareProtocolGuid ## CONSUMES > + gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES > > [FixedPcd] > gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz > @@ -64,6 +70,7 @@ [FixedPcd] > > [Pcd] > gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress > + gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress > gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress > gRaspberryPiTokenSpaceGuid.PcdCpuClock > gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > index 00867879da20..47ca0a89a3d8 100644 > --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > @@ -1,6 +1,6 @@ > /** @file > * > - * Copyright (c) 2019, ARM Limited. All rights reserved. > + * Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. > * Copyright (c) 2018 - 2019, Andrei Warkentin > * > * SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -8,19 +8,21 @@ > **/ > > #include > +#include > +#include > +#include > +#include > #include > -#include > #include > +#include > #include > +#include > +#include > #include > +#include > #include > #include > -#include > -#include > -#include > -#include > -#include > -#include > +#include > #include > #include > #include "ConfigDxeFormSetGuid.h" > @@ -34,6 +36,8 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; > STATIC UINT32 mModelFamily = 0; > STATIC UINT32 mModelInstalledMB = 0; > > +STATIC EFI_MAC_ADDRESS MacAddress; m-prefix on global variable? / Leif > + > /* > * The GUID inside Platform/RaspberryPi/RPi3/AcpiTables/AcpiTables.inf and > * Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf _must_ match below. > @@ -47,6 +51,18 @@ typedef struct { > EFI_DEVICE_PATH_PROTOCOL End; > } HII_VENDOR_DEVICE_PATH; > > +#pragma pack (1) > +typedef struct { > + MAC_ADDR_DEVICE_PATH MacAddrDP; > + EFI_DEVICE_PATH_PROTOCOL End; > +} GENET_DEVICE_PATH; > + > +typedef struct { > + GENET_DEVICE_PATH DevicePath; > + BCM_GENET_PLATFORM_DEVICE_PROTOCOL PlatformDevice; > +} GENET_DEVICE; > +#pragma pack () > + > STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = { > { > { > @@ -69,6 +85,65 @@ STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = { > } > }; > > +STATIC GENET_DEVICE mGenetDevice = { > + { > + { > + { > + MESSAGING_DEVICE_PATH, > + MSG_MAC_ADDR_DP, > + { > + (UINT8)(sizeof (MAC_ADDR_DEVICE_PATH)), > + (UINT8)((sizeof (MAC_ADDR_DEVICE_PATH)) >> 8) > + } > + }, > + {{ 0 }}, > + NET_IFTYPE_ETHERNET > + }, > + { > + END_DEVICE_PATH_TYPE, > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > + { > + sizeof (EFI_DEVICE_PATH_PROTOCOL), > + 0 > + } > + } > + }, > + { > + GENET_BASE_ADDRESS, > + {{ 0 }} > + } > +}; > + > + > +STATIC > +VOID > +EFIAPI > +RegisterDevices ( > + EFI_EVENT Event, > + VOID *Context > + ) > +{ > + EFI_HANDLE Handle; > + EFI_STATUS Status; > + > + if (mModelFamily == 4) { > + DEBUG ((DEBUG_INFO, "GENET: MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", > + MacAddress.Addr[0], MacAddress.Addr[1], MacAddress.Addr[2], > + MacAddress.Addr[3], MacAddress.Addr[4], MacAddress.Addr[5])); > + > + CopyMem (&mGenetDevice.DevicePath.MacAddrDP.MacAddress, MacAddress.Addr, > + NET_ETHER_ADDR_LEN); > + CopyMem (&mGenetDevice.PlatformDevice.MacAddress, MacAddress.Addr, > + NET_ETHER_ADDR_LEN); > + > + Handle = NULL; > + Status = gBS->InstallMultipleProtocolInterfaces (&Handle, > + &gEfiDevicePathProtocolGuid, &mGenetDevice.DevicePath, > + &gBcmGenetPlatformDeviceProtocolGuid, &mGenetDevice.PlatformDevice, > + NULL); > + ASSERT_EFI_ERROR (Status); > + } > +} > > STATIC EFI_STATUS > InstallHiiPages ( > @@ -242,6 +317,16 @@ SetupVariables ( > PcdSet32 (PcdDisplayEnableSShot, PcdGet32 (PcdDisplayEnableSShot)); > } > > + if (mModelFamily == 4) { > + // > + // Get the MAC address from the firmware. > + // > + Status = mFwProtocol->GetMacAddress (MacAddress.Addr); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_WARN, "%a: failed to retrieve MAC address\n", __FUNCTION__)); > + } > + } > + > return EFI_SUCCESS; > } > > @@ -448,7 +533,8 @@ ConfigInitialize ( > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - EFI_STATUS Status; > + EFI_STATUS Status; > + EFI_EVENT EndOfDxeEvent; > > Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, > NULL, (VOID**)&mFwProtocol); > @@ -494,5 +580,9 @@ ConfigInitialize ( > ASSERT_EFI_ERROR (Status); > } > > + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_NOTIFY, RegisterDevices, > + NULL, &gEfiEndOfDxeEventGroupGuid, &EndOfDxeEvent); > + ASSERT_EFI_ERROR (Status); > + > return EFI_SUCCESS; > } > -- > 2.17.1 >