From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.web12.5701.1623109812788847873 for ; Mon, 07 Jun 2021 16:50:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=lTpPltoj; spf=pass (domain: nuviainc.com, ip: 209.85.221.47, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f47.google.com with SMTP id l2so19506209wrw.6 for ; Mon, 07 Jun 2021 16:50:12 -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; bh=TyGuprQYtCmTqaoVPpwyPAbCCYK8fCVJnUT8e2TXyR4=; b=lTpPltojmlQeI0czAqM/hGVw30VSLJ1oaNo+khOVBkr5+vX3O6ZBL9N4rrt4eivfcB 7Yt4aJa84rRfr8JZH/nm36EveUo9VMlzoW/W6ac9JdplOw0MIzjxdBtUkRG+RENzwxK9 W1JX6zRlay+ivsaOHDwtsHwVmqqhV7uerximdjiPCxFnxhMJDImA4DcWOHpWgDRxOTrz 7Fkp30dD9ry4JYl85rfV9LDoDqCNnv38BRJjBive32lvXX+4aPyiTLt/TzPZuWeqn2Fi rw2dcjwVxocATouMmIiPbJCaCdm+q+PwPW9Zqh2ioYGgZpDM37ai1+Wo0EDFON5FtHRl iXfg== 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; bh=TyGuprQYtCmTqaoVPpwyPAbCCYK8fCVJnUT8e2TXyR4=; b=FO5vskUVUOtEX7aIs3Cp0v9qKJ78QrMSxaA+IOc3cxTTP47YUE1u4m1FIMkxikiQ2d RyNr1cQK4Oxg46heksrYGiTQ2h6mAZeS5fCmq0G5PA/gP9cGxhyATs4LHmGupsx0Zo3e hJC6uTp3p8CE/4Ypd/OhUWoYDuWeWnC4Xwy/h+LtYOHx95Btc2JWw33Lj5n1s8zZJr/w zjSjlpNdaH8yhaLR+hs8J6jwp3MVrJXQ+IbSPxJbQfaABt7x2wqh/2V9uvm2/Y8oYo+D 2MNEMM3Ctp+pTejmvHyRoygSA1DfgT4xs3rRnQC8VHTd/kGxAvNkNOlua/xfw11Gp7bh IfVg== X-Gm-Message-State: AOAM530gPKMKZBRCOxbpedWzhqf2Mi0EgOGnCx387iR7oK9Z3MqZpMT/ 0qnf0a+aucAwVuLJjh0HIJcqqg== X-Google-Smtp-Source: ABdhPJyfiPqd9O/MWkUGQUY3m4juxNthZ4LyoruVrP4F4HXDCWESL7Yp92aJz4Ye8yzo8L/mkES23g== X-Received: by 2002:a5d:64af:: with SMTP id m15mr1998885wrp.364.1623109811093; Mon, 07 Jun 2021 16:50:11 -0700 (PDT) Return-Path: Received: from leviathan (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id r7sm1243164wma.9.2021.06.07.16.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 16:50:10 -0700 (PDT) Date: Tue, 8 Jun 2021 00:50:09 +0100 From: "Leif Lindholm" To: Nhi Pham Cc: devel@edk2.groups.io, Thang Nguyen , Chuong Tran , Phong Vo , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: Re: [edk2-platforms][PATCH v2 30/32] AmpereSiliconPkg: Implement PlatformBootManagerLib for LinuxBoot Message-ID: <20210607235009.ov6smeyzmotarrnz@leviathan> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> <20210526100724.5359-32-nhi@os.amperecomputing.com> MIME-Version: 1.0 In-Reply-To: <20210526100724.5359-32-nhi@os.amperecomputing.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, May 26, 2021 at 17:07:22 +0700, Nhi Pham wrote: > The PlatformBootManagerLib library derived from > ArmPkg/Library/PlatformBootManagerLib. > > This implementation registers only a common GUID for LinuxBoot Payload > ("D834A5AD-459C-4AED-B0D0-8CBCB28838D7") as a active boot option. This > allows BDS to jump to the LinuxBoot Shell immediately without entering > the UiApp Setup Screen or UEFI Shell. This driver does not look spectacularly platform specific to me, although the GUID handling could posibly do with some additional engineering if this was to be shared with others. Would you consider submitting it for ArmPkg for now? (Unless it's something for MinPlatformPkg?) / Leif > Cc: Thang Nguyen > Cc: Chuong Tran > Cc: Phong Vo > Cc: Leif Lindholm > Cc: Michael D Kinney > Cc: Ard Biesheuvel > Cc: Nate DeSimone > > Signed-off-by: Nhi Pham > --- > Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBootManagerLib.inf | 54 ++++++ > Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBm.c | 173 ++++++++++++++++++++ > 2 files changed, 227 insertions(+) > > diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBootManagerLib.inf b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBootManagerLib.inf > new file mode 100644 > index 000000000000..cb4ade210117 > --- /dev/null > +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBootManagerLib.inf > @@ -0,0 +1,54 @@ > +## @file > +# Implementation for PlatformBootManagerLib library class interfaces. > +# > +# Copyright (C) 2015-2016, Red Hat, Inc. > +# Copyright (c) 2014, ARM Ltd. All rights reserved.
> +# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
> +# Copyright (c) 2016, Linaro Ltd. All rights reserved.
> +# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = LinuxBootBootManagerLib > + FILE_GUID = 1FA91547-DB23-4F6A-8AF8-3B9782A7F917 > + MODULE_TYPE = DXE_DRIVER > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER > + > +# > +# The following information is for reference only and not required by the build tools. > +# > +# VALID_ARCHITECTURES = ARM AARCH64 > +# > + > +[Sources] > + LinuxBootBm.c > + > +[Packages] > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + ShellPkg/ShellPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + MemoryAllocationLib > + PrintLib > + UefiBootManagerLib > + UefiBootServicesTableLib > + UefiLib > + UefiRuntimeServicesTableLib > + > +[Pcd] > + > +[Guids] > + gEfiEndOfDxeEventGroupGuid > + gUefiShellFileGuid > + > +[Protocols] > + gEfiLoadedImageProtocolGuid > diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBm.c b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBm.c > new file mode 100644 > index 000000000000..2d0f087477d6 > --- /dev/null > +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootBm.c > @@ -0,0 +1,173 @@ > +/** @file > + Implementation for PlatformBootManagerLib library class interfaces. > + > + Copyright (C) 2015-2016, Red Hat, Inc. > + Copyright (c) 2014 - 2019, ARM Ltd. All rights reserved.
> + Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
> + Copyright (c) 2016, Linaro Ltd. All rights reserved.
> + Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +// This GUID must match the FILE_GUID in the LinuxBootPkg/LinuxBoot.inf file. > +// GUID: D834A5AD-459C-4AED-B0D0-8CBCB28838D7 > +EFI_GUID mLinuxBootFileGuid = { 0xD834A5AD, 0x459C, 0x4AED, { 0xB0, 0xD0, 0x8C, 0xBC, 0xB2, 0x88, 0x38, 0xD7 } }; > + > +STATIC > +VOID > +RegisterFvBootOption ( > + CONST EFI_GUID *FileGuid, > + CHAR16 *Description, > + UINT32 Attributes > + ) > +{ > + EFI_STATUS Status; > + INTN OptionIndex; > + EFI_BOOT_MANAGER_LOAD_OPTION NewOption; > + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > + UINTN BootOptionCount; > + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; > + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > + > + Status = gBS->HandleProtocol ( > + gImageHandle, > + &gEfiLoadedImageProtocolGuid, > + (VOID **)&LoadedImage > + ); > + ASSERT_EFI_ERROR (Status); > + > + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); > + DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); > + ASSERT (DevicePath != NULL); > + DevicePath = AppendDevicePathNode ( > + DevicePath, > + (EFI_DEVICE_PATH_PROTOCOL *)&FileNode > + ); > + ASSERT (DevicePath != NULL); > + > + Status = EfiBootManagerInitializeLoadOption ( > + &NewOption, > + LoadOptionNumberUnassigned, > + LoadOptionTypeBoot, > + Attributes, > + Description, > + DevicePath, > + NULL, > + 0 > + ); > + ASSERT_EFI_ERROR (Status); > + FreePool (DevicePath); > + > + BootOptions = EfiBootManagerGetLoadOptions ( > + &BootOptionCount, > + LoadOptionTypeBoot > + ); > + > + OptionIndex = EfiBootManagerFindLoadOption ( > + &NewOption, > + BootOptions, > + BootOptionCount > + ); > + > + if (OptionIndex == -1) { > + Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN); > + ASSERT_EFI_ERROR (Status); > + } > + EfiBootManagerFreeLoadOption (&NewOption); > + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); > +} > + > +/** > + Do the platform specific action before the console is connected. > + > + Such as: > + Update console variable; > + Register new Driver#### or Boot####; > + Signal ReadyToLock event. > +**/ > +VOID > +EFIAPI > +PlatformBootManagerBeforeConsole ( > + VOID > + ) > +{ > + // > + // Signal EndOfDxe PI Event > + // > + EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid); > +} > + > +/** > + Do the platform specific action after the console is connected. > + > + Such as: > + Dynamically switch output mode; > + Signal console ready platform customized event; > + Run diagnostics like memory testing; > + Connect certain devices; > + Dispatch additional option roms. > +**/ > +VOID > +EFIAPI > +PlatformBootManagerAfterConsole ( > + VOID > + ) > +{ > + // > + // Register LinuxBoot > + // > + RegisterFvBootOption ( > + &mLinuxBootFileGuid, > + L"LinuxBoot", > + LOAD_OPTION_ACTIVE > + ); > +} > + > +/** > + This function is called each second during the boot manager waits the > + timeout. > + > + @param TimeoutRemain The remaining timeout. > +**/ > +VOID > +EFIAPI > +PlatformBootManagerWaitCallback ( > + UINT16 TimeoutRemain > + ) > +{ > + return; > +} > + > +/** > + The function is called when no boot option could be launched, > + including platform recovery options and options pointing to applications > + built into firmware volumes. > + > + If this function returns, BDS attempts to enter an infinite loop. > +**/ > +VOID > +EFIAPI > +PlatformBootManagerUnableToBoot ( > + VOID > + ) > +{ > + return; > +} > -- > 2.17.1 >