From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.91]) by mx.groups.io with SMTP id smtpd.web09.5424.1622023966465712956 for ; Wed, 26 May 2021 03:12:46 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=vlAJJURC; spf=pass (domain: os.amperecomputing.com, ip: 40.107.93.91, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bHir+3iC+R6K3bNuWW3Flbz/umcfn+e8mi7yQG2iMjq0pnTKEdbd2sRCPPTu7oX2uyVzNvf7RQScCfF8sDsPXQeOoATcMofuGn89884tsCKPeJ9NvoeLNVyCm/kz42yOpcu26kPsZP+N4UyOtHBBZpM+3PdfxfRxdKBCU+wp8LwD10un/daKmr5Wz4CtVrSznaYZlJwBrmruflHRvg0admAZiqX0nJky5nn30Ex4zGFokkh1tXSea3wCRUgzso1gxcoN1Fq0OvUmZSlbzYVct65eDbl/cXoNRCbP3J4c/4qzc2+WCcc7rqJ9a+Wrbq6aYHOnfpcRjeh1vEkfnN4lgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/YT5tZbd3+1yCMNM/DcS8jzALy4fNB5tt+zgviscwKU=; b=AS/H+cuG0cDC0nmSTVxg2Aj6JguoLTe/kdmJI25Labf4mTTEvv6j1kPBUNazvyA0kbnsz6L+UAvLrKqD6dItL+v03LlvIf08Zei4HA6EJXflf8CIcEe21GuJ2EgWsXuSScEwkB5s/BHZeX46C7gNxjPqVYIvRNpG4xlkRc/4LT9RYHV/AoTMtrs0zA92ZQgec97YDMMIHp3XZJz/oaTQljkuJd8cPmFL8gcwAamrSfw7HA34e0mAMKhWuRoW/mGuZE+WNk6OB8tKavnooKnTBSVcciX9p4zrHxEuHY6jJFNXDs054TsWzz+gvkJELQDX0RxYi9VNYmBvB8kmBgVVbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/YT5tZbd3+1yCMNM/DcS8jzALy4fNB5tt+zgviscwKU=; b=vlAJJURC6soawFioqpqmaOwcQqL05cP4+bvklsotJz1wvo0hVOxeEJjU7Xy/Z/UYchwIjy1mnjVyIVMSb+3WwdRB32hbyPvG5fRPy1XYonfY8hd+o6B1BSiQIAFuqbojYKNRC/zYs04wp25tOvv+vIRawrH0VUf7W3H7yq7pVjs= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) by DM5PR0101MB3067.prod.exchangelabs.com (2603:10b6:4:31::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Wed, 26 May 2021 10:12:45 +0000 Received: from DM6PR01MB5849.prod.exchangelabs.com ([fe80::60d2:86dd:1f1c:51dd]) by DM6PR01MB5849.prod.exchangelabs.com ([fe80::60d2:86dd:1f1c:51dd%7]) with mapi id 15.20.4173.020; Wed, 26 May 2021 10:12:45 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: Nhi Pham , Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v2 30/32] AmpereSiliconPkg: Implement PlatformBootManagerLib for LinuxBoot Date: Wed, 26 May 2021 17:07:22 +0700 Message-ID: <20210526100724.5359-32-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210526100724.5359-1-nhi@os.amperecomputing.com> References: <20210526100724.5359-1-nhi@os.amperecomputing.com> X-Originating-IP: [118.69.219.201] X-ClientProxiedBy: HKAPR04CA0008.apcprd04.prod.outlook.com (2603:1096:203:d0::18) To DM6PR01MB5849.prod.exchangelabs.com (2603:10b6:5:205::20) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (118.69.219.201) by HKAPR04CA0008.apcprd04.prod.outlook.com (2603:1096:203:d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Wed, 26 May 2021 10:12:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b9dce33-a9b9-4d7a-e35c-08d9202ece67 X-MS-TrafficTypeDiagnostic: DM5PR0101MB3067: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3nuQ4fwjiWnYpa/9yF4lcqo1Xn3kErttUa/6fHgLsY16rF7zOTu2J1CYmn/QJLq1MSnZtEnkvLp5CexzQZW7ldZLk7zvoI7mvLdm+0LA1jLW4/1c1YFeD4mwG6A9fsCcSMdYYuINF/2J7ru9pdbHLfAbCyut2rEXGoJBDhx4uQIEyN6CLW8RrNOpcf9Y75Cy5NmO3yc0FI5KXjO2UDx6jZ2YaO1OVTUrogbTSSjSGJRtyAA46FtYRjT+LCWvD4NQr+TdAdEsT3CmBXNpR9tseGeXo3H83AhpP5BHNHGC9MK74gv3P5NlX3RU8E/PkO7Y8+CH7tfJq7yAHLTlKae6dKCO1y9MbOIF2uEytZagitwQLSoyGveVnOo0CeLDiFIfosb1oZNzrUXZR2sNt3Q7GQT+dBzG/Zi411AKGQLpWT09/xMPs1p0HTUcUDYkAgbu4Sz7kL3IdYCCvL1v3x7zM1y75taraZ3MMh28bTO+yx5WUpXR7q6Fh0JO353R5kpJKdkraLiFq1yxmcW+W3OUW5ZpChEOMUutf+inKbyQxF9k9oTCJ4wB9Cy3vaDz6TT8SsbNrQG9Q9ebOsctqrtKDZyPBpUHHtPczyemoEnQjCzlah6kBYRXawlbwNI1YVOC4RJ4D/0l1tyJ3RCJLMy0PoBiPfbbZcvubPNvRn2odrqTYtKf6vNbMOeKfiPj6uDI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR01MB5849.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39840400004)(346002)(136003)(376002)(366004)(4326008)(26005)(6666004)(1076003)(2616005)(38350700002)(6506007)(83380400001)(86362001)(2906002)(6486002)(8676002)(956004)(52116002)(8936002)(186003)(54906003)(66556008)(6916009)(66476007)(6512007)(66946007)(38100700002)(5660300002)(16526019)(478600001)(316002)(69590400013);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?R1jtCdnMHVgZVDUCyx9/YYfEynB+dzql7ySjEMhg4az1joRiEST7/zx/8skr?= =?us-ascii?Q?rL6ry6UzCTmMOAo/YmX7cXGCY4Y68XGGEBmzncva7c7qbkrTDug8qVuFAGPT?= =?us-ascii?Q?momSnEHC4unNMad6hoF0S7+r2EmPPSlBVCt9T+f6x3xBtsa6GjB7XO9TKu7r?= =?us-ascii?Q?L26db48y2YHcJZdElgo/KIE3pPAW0oY6qG6B53NpRlVJRh7gIKAVBUODGexJ?= =?us-ascii?Q?Qiu/WSDv+Y2p0edbwsCwR3SXkhHnziEkpAwtl62x/bwj0ftCacrnrejUXobw?= =?us-ascii?Q?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InNB0W6a6tA?= =?us-ascii?Q?KTSWSjwmvsyEDLB/6XM+YIaJjU2Ge76jDG5cgUiwpjjOxSCDhnfNRQfCS9mh?= =?us-ascii?Q?fVP1hboC11AfGiHCPlJGKMMyYPavC0Lq5F1tdp0F/YzioMXIlCOlroRMlyLQ?= =?us-ascii?Q?0UTIBhRn9TSH6/DmdMnTFaVc?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b9dce33-a9b9-4d7a-e35c-08d9202ece67 X-MS-Exchange-CrossTenant-AuthSource: DM6PR01MB5849.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2021 10:12:45.4614 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R2AwEtkGf2hOqYOx8F0SNMnWFJQiXfmbFMdKP0R4GOSKGLZbseY1ekaP1OzPGBJel9JP56Nu2FOX9oa3Zddp/50J8lGf0TrDP0KZ9DoJqJI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0101MB3067 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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. 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/LinuxBootB= ootManagerLib.inf | 54 ++++++ Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/LinuxBootB= m.c | 173 ++++++++++++++++++++ 2 files changed, 227 insertions(+) diff --git a/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLi= b/LinuxBootBootManagerLib.inf b/Silicon/Ampere/AmpereSiliconPkg/Library/Lin= uxBootBootManagerLib/LinuxBootBootManagerLib.inf new file mode 100644 index 000000000000..cb4ade210117 --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/Linux= BootBootManagerLib.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 =3D 0x00010005 + BASE_NAME =3D LinuxBootBootManagerLib + FILE_GUID =3D 1FA91547-DB23-4F6A-8AF8-3B9782A7F917 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformBootManagerLib|DXE_DRIVER + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/LinuxBootBootManagerLi= b/LinuxBootBm.c b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootMana= gerLib/LinuxBootBm.c new file mode 100644 index 000000000000..2d0f087477d6 --- /dev/null +++ b/Silicon/Ampere/AmpereSiliconPkg/Library/LinuxBootBootManagerLib/Linux= BootBm.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 fi= le. +// GUID: D834A5AD-459C-4AED-B0D0-8CBCB28838D7 +EFI_GUID mLinuxBootFileGuid =3D { 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 =3D gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **)&LoadedImage + ); + ASSERT_EFI_ERROR (Status); + + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + DevicePath =3D DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (DevicePath !=3D NULL); + DevicePath =3D AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *)&FileNode + ); + ASSERT (DevicePath !=3D NULL); + + Status =3D EfiBootManagerInitializeLoadOption ( + &NewOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + Attributes, + Description, + DevicePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + FreePool (DevicePath); + + BootOptions =3D EfiBootManagerGetLoadOptions ( + &BootOptionCount, + LoadOptionTypeBoot + ); + + OptionIndex =3D EfiBootManagerFindLoadOption ( + &NewOption, + BootOptions, + BootOptionCount + ); + + if (OptionIndex =3D=3D -1) { + Status =3D 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; +} --=20 2.17.1