From patchwork Fri Jan 12 00:19:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 762187 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2666834wrz; Thu, 11 Jan 2024 16:22:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQudKD1PN9frc2dBPKT0H3if/UiqC6JgFjAIbT18C60ft+Qs/GmMhgkjOOngCdMa+s8oe3 X-Received: by 2002:a5d:674f:0:b0:336:ee8a:a44e with SMTP id l15-20020a5d674f000000b00336ee8aa44emr257605wrw.94.1705018928562; Thu, 11 Jan 2024 16:22:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705018928; cv=none; d=google.com; s=arc-20160816; b=DWRyttxvTuW1Q1UghBI8wosQiodVwE2d+fqI4aJ3vo3H/Hxb+/zYHbjVtETJltCZo5 Gg2Md0dbuG5nyrc7ZS61KuQBEMdHal53cix6w6GShOQfy5vdA2QsPRr1/Xa//59ZZKTk UWPW2LegEkbriIC/cU+MGLyqZOi0fUQRFNlbhPSHfHYWUS6gk6Y8QWiAmRGbDfPOAlwA zCjj27pDMLvV96S6xaTQHWL8H1LglCYIBlbCsbCvcFIAeGKP+lYsTPfRJZpugi86UmPV AOEzQloM2zHkHyppYwDGXFEtSyGDvEBpE9/08GYg+p6L+Fy9n3222gBPc5gcrWx6tmV7 Pc5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ejKH3PbnB5egZiczLwA//aVuAqzhtujQe4vggYRX1f8=; fh=YtnCJplQ1DA0Rz8c1dg8CfrVxTgSI4BIXB9JUZxV1zk=; b=ztlF2ZqwURjlsmDMghGLfCs4smDmsQuWWDfM7EbU6aWoFmCRwA/nqEAzWp8so1cG6X XkeM5PPXw0m480ePFNRbl7JodynMqkv/HlZK/qyALkWOwJZXIkoixSWrf3J0o4ayv71F /b03tjFCv0t/Xdug5LMb3LPvExsKNhLFPYe6CwamUvSzK636YCGgaZAGNY1anJxInkW8 bJVJN7kWfqLdNSypdei2/ASl6OsqUHBMQr6+ZXgzV3VvF2mPSrBcM3w8r33K6HMpaQqq DPLW2P7kZ+Yup/nGOa8u+QZnZxTDbVR8qSQo2Aqz2hfsT0QGaLQyqSsw/ALA3/Ipd1YF 8WxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMrTK2ih; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id x3-20020a5d4903000000b00336633ff149si1056553wrq.944.2024.01.11.16.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 16:22:08 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMrTK2ih; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 87CD28792C; Fri, 12 Jan 2024 01:21:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fMrTK2ih"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D1CE8792C; Fri, 12 Jan 2024 01:21:32 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8B4AB878C6 for ; Fri, 12 Jan 2024 01:21:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3bbbdf0b859so6282642b6e.3 for ; Thu, 11 Jan 2024 16:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705018886; x=1705623686; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ejKH3PbnB5egZiczLwA//aVuAqzhtujQe4vggYRX1f8=; b=fMrTK2ih6uvPOR6EKprkmBA1WIEw22eR6hTua1D+YSG6Smvd58hAXz28XRCetCQhmi QJTH/+TbUTjGXCP1D3zUho9UhAvZQSRaaPpeMUDilozZj6A3iS5R/PMdwsr4WBdx0vdt OkU9n1B4Ous40Fuj9I9Nhdi4JUa85oHBmLRFNI/dRF5mD9RrXND56eJ8gFryh6IQl0JV RBoKf21BHxhmxwumgVoZAop2qEbJmTMOq2yHB45TOncwzgj1p2GucbC0R9KGIQ/hUTKs ICM/qpdl95HiiIhATV9hHKBZ+YIw0yUhoNY6mc+TpCYgy/BvX+cBZSn54Z5i8yakydrG jkig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705018886; x=1705623686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ejKH3PbnB5egZiczLwA//aVuAqzhtujQe4vggYRX1f8=; b=VlpBYt3LrSkunwxKRIkmsiNpSPoNAgdFQr+my9oV94oD/N8hkbWWj4Jdwk9ymcCgbS WJLblqsXawZdhIlknABuJ/u9FMMgp5G4XO6XhKDTghleP3Jz+Z7Kq5dktfcQQ/Iv2SsW iEXLHhP2GX2sPnzjOaJBTwG9sxiYibFz2px85kByNmHQ6UZEFHowgf0eTWLIP6nUeLAN Zr1lX8nAgjLtC3/++WSRont+ZNHEG/x3VRQm1KJKuF6WuGQIWMFuibOn3FpmEE0oDDmc Xbvo7/40KuVHMN85haM/OgM1okhiHwMTbFWa8gwP+i0KCQ1AD6TyIYAeFZu9JHpUHWn8 /7sw== X-Gm-Message-State: AOJu0Yyh/6QOu0t8h4q4IlnLiqOred4kMipPjZDSqDG0vpZkIFVmqX4K 1V46qJW6jaa6e1MoUWS6dTHgxUh4V1Df3arPtQTQZloneGE= X-Received: by 2002:a54:4503:0:b0:3bd:5a9b:f505 with SMTP id l3-20020a544503000000b003bd5a9bf505mr165249oil.65.1705018886507; Thu, 11 Jan 2024 16:21:26 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id j186-20020a638bc3000000b005c67ca3c2c2sm1838843pge.21.2024.01.11.16.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 16:21:25 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v3 1/3] efi_loader: rename check_disk_has_default_file function Date: Fri, 12 Jan 2024 09:19:21 +0900 Message-Id: <20240112001923.976414-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240112001923.976414-1-masahisa.kojima@linaro.org> References: <20240112001923.976414-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean check_disk_has_default_file() function checks if the architecture-specific default file exists in the blk device, and fills the default file device path if it exists. Rename the function name to fill_default_file_path(). Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_bootmgr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a032d3ae04..eda2619142 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -307,14 +307,14 @@ err: } /** - * check_disk_has_default_file() - load the default file + * fill_default_file_path() - fill default file device path from blk device if default file exists * * @blk: pointer to the UCLASS_BLK udevice - * @dp: pointer to default file device path + * @dp: pointer to store the default file device path * Return: status code */ -static efi_status_t check_disk_has_default_file(struct udevice *blk, - struct efi_device_path **dp) +static efi_status_t fill_default_file_path(struct udevice *blk, + struct efi_device_path **dp) { efi_status_t ret; struct udevice *partition; @@ -361,7 +361,7 @@ static efi_status_t prepare_loaded_image(u16 *label, ulong addr, ulong size, if (!ramdisk_blk) return EFI_LOAD_ERROR; - ret = check_disk_has_default_file(ramdisk_blk, dp); + ret = fill_default_file_path(ramdisk_blk, dp); if (ret != EFI_SUCCESS) { log_info("Cannot boot from downloaded image\n"); goto err; From patchwork Fri Jan 12 00:19:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 762188 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2666916wrz; Thu, 11 Jan 2024 16:22:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeyoao61qyOkMGbUKb79b24kBOkDLfKEbVhwkODu31MmcbLdkM6H1SyKl1kC0y/wRXS4Tj X-Received: by 2002:a05:600c:358a:b0:40e:43db:7174 with SMTP id p10-20020a05600c358a00b0040e43db7174mr276775wmq.27.1705018944404; Thu, 11 Jan 2024 16:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705018944; cv=none; d=google.com; s=arc-20160816; b=CQ8gEaAuQVUUew72Y59V/F7ncI9m25bxGcB5aPZ28Shh3Ia2uCrhvx6hYUcFTaI1PE fTzgY5bGPKGhwuA0C+hpcRExQqJECL2PtteO/7QL1YBO9hIJ+vfWBMSMrtMW6qGTKZM4 +HIyONBHxKjREsu0XQv3ayo27rklImUUdHrjGaJaWkVfipOBxTr7aSwMIX7DqUsu9BDp rXt2FrIGuTr2IbIY4iCBzppAG3sIyJWJBWemFDKtA0BNCdRE+A2zY4+kE33r7Incz0nc YU1hqRpfudRfn1Cfm4kK9tnpVZ0qYePbI5SIykvxbYLVoLFJ09Vn4zPl7XelgSYjZkUw e/+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=65wKEJNwvk9ZVpyhvumXc2zlAAX/IgYCkwnqilCNGvw=; fh=YtnCJplQ1DA0Rz8c1dg8CfrVxTgSI4BIXB9JUZxV1zk=; b=PfVA5revI77xBEmD+FQ4cCMCn+4yCCP8JFYYt1GXTze+AiDfB1OeNQNLH0giddGu1N LcEZN5OJC836qz4B91hXJ3apbPkm85y/n/ReoRgwiErkUWpTcKHOd9mP7ccVl2rLfx46 FpuLqjOxIjy+Q5n5UXM7pP20IEBH7+Hts1NL9pLqXlxUbCRxbdGXFZp7OV4aNAnZmy2V YDfqIm10QWn+JzycH6l/PtSbGrKI4WZxVJYO97P9e7QW5ga50FXymyAi3nHO4akWMTtT f/HCNXdYZKw+cqlqMBiOpFwyOV+jGaE5YfNEdUsrG/41vLpbk/aP8igVpQ/e7oge/Fkz miiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yZKrKpRP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id n22-20020a7bcbd6000000b0040e419b6bfdsi2483828wmi.74.2024.01.11.16.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 16:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yZKrKpRP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6C8DE87933; Fri, 12 Jan 2024 01:21:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yZKrKpRP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F6AA87227; Fri, 12 Jan 2024 01:21:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C709787956 for ; Fri, 12 Jan 2024 01:21:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d9a795cffbso4436068b3a.0 for ; Thu, 11 Jan 2024 16:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705018892; x=1705623692; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=65wKEJNwvk9ZVpyhvumXc2zlAAX/IgYCkwnqilCNGvw=; b=yZKrKpRPJDyXf0APhZ+QLU8dmu1MHS/jvibNz6ktAK/5JVZvMBVGq24tViln2csUMV 73BqZ7l0C8bPGU2x+2zt7aVwJXGHGRrFl5z4yvB1+SrJyTKrlsugNDVHoVlccHBRsSyK GFlpSNoC6FAGXrHM3I+nzBi06o40UyVscuy6AdyFfyjj0/m7QEvdQjIp6tZvJqDrAhbP vWLVo1e0wtwbT5usGgiXJdZlmF4Ddh5R6HdJSA2YlSWwF6zLoOF98R3lenKsAehruYPE MO5h5EVJl+iwBKweHeGRSW1f80lAVpkmIo23+3c8jTIXSyULhIEU1ByU+ogxSexyJijf iwTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705018892; x=1705623692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=65wKEJNwvk9ZVpyhvumXc2zlAAX/IgYCkwnqilCNGvw=; b=KzCKk50LASm33babla8AEfRxbzuduyOEtgOTEmDkiknkGxPFtZoQo8yu+msZg3dvdv gwOk7ftZcKxxNQgpW4zm1qfRMn857Jy0XBwQxVdjCWnSgPxq8C3W3tOD5l9RO4wKRN4f 5rfZKTHR/LhVkry3Jy54PTdKmvVeyfwwC91ZbubQ8tjYipkAtxLRP7XKkcjH+gTkTuk2 5BZ9W66kyeKJr/IKBJr5o8SCsxpZtNeZhoI2E5utXMkYQzJghD0f0PXfozahJLpoplmg 2wzpGYsFzvonLdZRoN559kQK7CryQIevgFDhRhMIDp5N4NskejsAQ1kulBvbH6LweaI/ LZvg== X-Gm-Message-State: AOJu0YwwqOHl5mhVn57GZbkeSRwx0MGwe/+7F1m9Coz+HXykOlOPM7qH PqFjgtF7kEiBqcOTt9B0aKCgAFKe7L9d8YBprvWdGE/Uz20= X-Received: by 2002:a05:6a00:464f:b0:6d9:acb2:29ac with SMTP id kp15-20020a056a00464f00b006d9acb229acmr176115pfb.23.1705018891720; Thu, 11 Jan 2024 16:21:31 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id t22-20020a056a00139600b006d94291679asm1821733pfg.78.2024.01.11.16.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 16:21:31 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v3 2/3] efi_loader: auto-generate boot option for each blkio device Date: Fri, 12 Jan 2024 09:19:22 +0900 Message-Id: <20240112001923.976414-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240112001923.976414-1-masahisa.kojima@linaro.org> References: <20240112001923.976414-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Current efibootmgr auto-generates the boot option for all disks and partitions installing EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, while EDK II reference implementation auto-generates the boot option for all devices installing EFI_BLOCK_IO_PROTOCOL with eliminating logical partitions. This commit modifies the efibootmgr to get aligned to EDK II. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_bootmgr.c | 101 ++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 26 deletions(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index eda2619142..c2b8da89e6 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -559,6 +559,50 @@ err: return ret; } +/** + * try_load_from_media() - load file from media + * + * @file_path: file path + * @handle_img: on return handle for the newly installed image + * + * If @file_path contains a file name, load the file. + * If @file_path does not have a file name, search the architecture-specific + * default file and load it. + * TODO: If the FilePathList[0] device does not support + * EFI_SIMPLE_FILE_SYSTEM_PROTOCOL but supports EFI_BLOCK_IO_PROTOCOL, + * call EFI_BOOT_SERVICES.ConnectController() + * TODO: FilePathList[0] device supports EFI_SIMPLE_FILE_SYSTEM_PROTOCOL + * not based on EFI_BLOCK_IO_PROTOCOL + * + * Return: status code + */ +static efi_status_t try_load_from_media(struct efi_device_path *file_path, + efi_handle_t *handle_img) +{ + efi_handle_t handle_blkdev; + efi_status_t ret = EFI_SUCCESS; + struct efi_device_path *rem, *dp = NULL; + struct efi_device_path *final_dp = file_path; + + handle_blkdev = efi_dp_find_obj(file_path, &efi_block_io_guid, &rem); + if (handle_blkdev) { + if (rem->type == DEVICE_PATH_TYPE_END) { + /* no file name present, try default file */ + ret = fill_default_file_path(handle_blkdev->dev, &dp); + if (ret != EFI_SUCCESS) + return ret; + + final_dp = dp; + } + } + + ret = EFI_CALL(efi_load_image(true, efi_root, final_dp, NULL, 0, handle_img)); + + efi_free_pool(dp); + + return ret; +} + /** * try_load_entry() - try to load image for boot option * @@ -593,7 +637,6 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, } if (lo.attributes & LOAD_OPTION_ACTIVE) { - struct efi_device_path *file_path; u32 attributes; log_debug("trying to load \"%ls\" from %pD\n", lo.label, @@ -610,10 +653,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, else ret = EFI_LOAD_ERROR; } else { - file_path = expand_media_path(lo.file_path); - ret = EFI_CALL(efi_load_image(true, efi_root, file_path, - NULL, 0, handle)); - efi_free_pool(file_path); + ret = try_load_from_media(lo.file_path, handle); } if (ret != EFI_SUCCESS) { log_warning("Loading %ls '%ls' failed\n", @@ -744,22 +784,23 @@ error: } /** - * efi_bootmgr_enumerate_boot_option() - enumerate the possible bootable media + * efi_bootmgr_enumerate_boot_options() - enumerate the possible bootable media * * @opt: pointer to the media boot option structure - * @volume_handles: pointer to the efi handles - * @count: number of efi handle + * @handles: pointer to block device handles + * @count: On entry number of handles to block devices. + * On exit number of boot options. * Return: status code */ -static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boot_option *opt, - efi_handle_t *volume_handles, - efi_status_t count) +static efi_status_t +efi_bootmgr_enumerate_boot_options(struct eficonfig_media_boot_option *opt, + efi_handle_t *handles, efi_uintn_t *count) { - u32 i; + u32 i, num = 0; struct efi_handler *handler; efi_status_t ret = EFI_SUCCESS; - for (i = 0; i < count; i++) { + for (i = 0; i < *count; i++) { u16 *p; u16 dev_name[BOOTMENU_DEVICE_NAME_MAX]; char *optional_data; @@ -767,8 +808,15 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo char buf[BOOTMENU_DEVICE_NAME_MAX]; struct efi_device_path *device_path; struct efi_device_path *short_dp; + struct efi_block_io *blkio; + + ret = efi_search_protocol(handles[i], &efi_block_io_guid, &handler); + blkio = handler->protocol_interface; - ret = efi_search_protocol(volume_handles[i], &efi_guid_device_path, &handler); + if (blkio->media->logical_partition) + continue; + + ret = efi_search_protocol(handles[i], &efi_guid_device_path, &handler); if (ret != EFI_SUCCESS) continue; ret = efi_protocol_open(handler, (void **)&device_path, @@ -776,7 +824,7 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo if (ret != EFI_SUCCESS) continue; - ret = efi_disk_get_device_name(volume_handles[i], buf, BOOTMENU_DEVICE_NAME_MAX); + ret = efi_disk_get_device_name(handles[i], buf, BOOTMENU_DEVICE_NAME_MAX); if (ret != EFI_SUCCESS) continue; @@ -800,17 +848,20 @@ static efi_status_t efi_bootmgr_enumerate_boot_option(struct eficonfig_media_boo * to store guid, instead of realloc the load_option. */ lo.optional_data = "1234567"; - opt[i].size = efi_serialize_load_option(&lo, (u8 **)&opt[i].lo); - if (!opt[i].size) { + opt[num].size = efi_serialize_load_option(&lo, (u8 **)&opt[num].lo); + if (!opt[num].size) { ret = EFI_OUT_OF_RESOURCES; goto out; } /* set the guid */ - optional_data = (char *)opt[i].lo + (opt[i].size - u16_strsize(u"1234567")); + optional_data = (char *)opt[num].lo + (opt[num].size - u16_strsize(u"1234567")); memcpy(optional_data, &efi_guid_bootmenu_auto_generated, sizeof(efi_guid_t)); + num++; } out: + *count = num; + return ret; } @@ -1039,8 +1090,7 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index) /** * efi_bootmgr_update_media_device_boot_option() - generate the media device boot option * - * This function enumerates all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL - * and generate the bootmenu entries. + * This function enumerates all BlockIo devices and add the boot option for it. * This function also provide the BOOT#### variable maintenance for * the media device entries. * - Automatically create the BOOT#### variable for the newly detected device, @@ -1056,13 +1106,13 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) u32 i; efi_status_t ret; efi_uintn_t count; - efi_handle_t *volume_handles = NULL; + efi_handle_t *handles = NULL; struct eficonfig_media_boot_option *opt = NULL; ret = efi_locate_handle_buffer_int(BY_PROTOCOL, - &efi_simple_file_system_protocol_guid, + &efi_block_io_guid, NULL, &count, - (efi_handle_t **)&volume_handles); + (efi_handle_t **)&handles); if (ret != EFI_SUCCESS) goto out; @@ -1072,8 +1122,7 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) goto out; } - /* enumerate all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */ - ret = efi_bootmgr_enumerate_boot_option(opt, volume_handles, count); + ret = efi_bootmgr_enumerate_boot_options(opt, handles, &count); if (ret != EFI_SUCCESS) goto out; @@ -1121,7 +1170,7 @@ out: free(opt[i].lo); } free(opt); - efi_free_pool(volume_handles); + efi_free_pool(handles); if (ret == EFI_NOT_FOUND) return EFI_SUCCESS; From patchwork Fri Jan 12 00:19:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 762189 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2666969wrz; Thu, 11 Jan 2024 16:22:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFepBwuOsB9Fut6DuumPHfE5mkTDUxC7k+FfXtVTnPExWHK9Intfz9ogJFCRtzufakQXhoA X-Received: by 2002:a5d:614f:0:b0:337:157:2d3e with SMTP id y15-20020a5d614f000000b0033701572d3emr95741wrt.222.1705018954776; Thu, 11 Jan 2024 16:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705018954; cv=none; d=google.com; s=arc-20160816; b=U3HMlcUHrDiPd3Wy5bzw/ReRQ7EMAGCcxpl32AOkXgiLFpNmOedC2yUy0Nyzjh6xhH SwRfzpzcXi73eh+lRwvFrNIlRV9oK/WdXYUK1wuaw+fgltWvZHKJRmbc2lTunXfkTCMV 68dlE4sPVkskHGUhYIp0nWty8G0iD++YEHCkgfgWe+/Q1usg9/9JDp4+rvxO/Da1bHjZ Q+guTf1NOnAMwrMliegHoZrnFzEG6412KLG3EXFOjSR/6kfG7YhBuoy0dvVbZU8VCav6 Y7ZIPwZS/2gM02nkWB+iHMk2SCUtdtc03Fw0Z5Ir9foIyXqgMiSP9pjR551IqN9jWkia rRxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vvsc+JgHfocrcstT4VTrcXZxfvOCdybE19o+51syb7g=; fh=YtnCJplQ1DA0Rz8c1dg8CfrVxTgSI4BIXB9JUZxV1zk=; b=pqwKn60WHSGjsVC2otv7ngdkyeLycS1wGzt7kmMudmID1g/FJSt7ipVewBTRzA2z2e XzLVQ/DcCnbipzZGaPsBWcNf9ZSqVPkxPuuK+FLhcAzQUR4sMuDdonLifkhQ3eZaKSIU piHkiL2mP8GYAcSaw8afKPqzLb2nKDnQD3Xf6XQCH7FXssCsISHNrbZLGxuHaXIsUnCo ZDERCwR26S+sMhVlOAHJfWj8kMbzWtmwph2xyVyQOt9z+xjG0zpQPcCWHjlu+YaMsV1t BHbkYY3v1P6MgE9zzMrRxHbrNBMGd2rjQW9jJMGWMij3YVcg+1pJbdCmduHB/JOomaag 077g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L+VgyGnm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u8-20020a5d6da8000000b003367bd32ff3si1092596wrs.53.2024.01.11.16.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 16:22:34 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L+VgyGnm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6A9387969; Fri, 12 Jan 2024 01:21:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="L+VgyGnm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 32EE1878B1; Fri, 12 Jan 2024 01:21:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DBA8587956 for ; Fri, 12 Jan 2024 01:21:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3bbd1f9e0b8so4852674b6e.0 for ; Thu, 11 Jan 2024 16:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705018897; x=1705623697; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vvsc+JgHfocrcstT4VTrcXZxfvOCdybE19o+51syb7g=; b=L+VgyGnmfXftJ1luXkg8io0QoGwwlioG+ut6PoMU6SOb9cMNlPrPdK+lcA3C2EXuzg gzM+rLR3e0YUSxhsAWdZQCjH9Csoda5QSBNl8Xe+VzRoUgbpsZ0IzL0HBuhoSliwFHo4 gfXZolo8mL+1qeOMGa0Sg5kDpQXqDtViPwfJ6kYtd/JUnjevVVCXTcN752wAD91rIKC4 BBVZdVdtkC+Jborb9QZiK8nn2x9VjuAzVlRdxl3AivrD0M3leH/RG2ITQl3G5G/wFyRH WH45oZvmbQZ+ZXPHYTtYi58zK87zjX19N7w9duBPpEr9YCeaYxKjdw+lvh06YcGeSARg 9bug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705018897; x=1705623697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vvsc+JgHfocrcstT4VTrcXZxfvOCdybE19o+51syb7g=; b=vXz1gWOzbXCmtarZcOnnf0EK6FN8gYUMz7xTbWgD033lF2sQI1jSTzn6Sl6yXgyQGO 69YZjY3los0FsjlwuuZwXtkVoBVg8JDTmu/QFslDQcpMEVMIXiMwlkXQ3QyGxm7UOYKE +/9xbiZdqyU0I8dPFBOYWiEj43o3wF4BsZL7wilD2qo7kKwmnyKTqSbSw+pn3v5zJj/b eFqExdqJ+X/TJpSlGfjGE0W6Qgx4jAIpKBAAi7GW8N74/gEk+G317VwZZZkqIw76JDPB Flo1RiC1KwQpU+0rSLSiVsKWXgLfRKvQIq4asEtF3en4v/LG2cwhbQn9IQ/7FlmeJj4+ 2/ig== X-Gm-Message-State: AOJu0Yyj3AJm2a2EgRkTwtcao7NjMVZbnkiZ5c6cIyxpezrt6D+UWJwH 2FpqfOSrFa5/xjnCTjGH8M8bjddO3DIv0KAKSGsqhbKmpfA= X-Received: by 2002:a05:6358:6117:b0:175:9261:c2e2 with SMTP id 23-20020a056358611700b001759261c2e2mr692565rws.51.1705018897191; Thu, 11 Jan 2024 16:21:37 -0800 (PST) Received: from localhost ([164.70.16.189]) by smtp.gmail.com with ESMTPSA id sf15-20020a17090b51cf00b0028e023be116sm332993pjb.49.2024.01.11.16.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 16:21:36 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima Subject: [PATCH v3 3/3] efi_loader: auto-generate removable media boot option first Date: Fri, 12 Jan 2024 09:19:23 +0900 Message-Id: <20240112001923.976414-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240112001923.976414-1-masahisa.kojima@linaro.org> References: <20240112001923.976414-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This commit auto-generates the boot option for removable block io devices followed by fixed block io devices. This is what EDK II reference implementation does. Signed-off-by: Masahisa Kojima --- lib/efi_loader/efi_bootmgr.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index c2b8da89e6..9befe001e7 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -787,16 +787,19 @@ error: * efi_bootmgr_enumerate_boot_options() - enumerate the possible bootable media * * @opt: pointer to the media boot option structure + * @index: index of the opt array to store the boot option * @handles: pointer to block device handles * @count: On entry number of handles to block devices. * On exit number of boot options. + * @removable: flag to parse removable only * Return: status code */ static efi_status_t efi_bootmgr_enumerate_boot_options(struct eficonfig_media_boot_option *opt, - efi_handle_t *handles, efi_uintn_t *count) + efi_uintn_t index, efi_handle_t *handles, + efi_uintn_t *count, bool removable) { - u32 i, num = 0; + u32 i, num = index; struct efi_handler *handler; efi_status_t ret = EFI_SUCCESS; @@ -816,6 +819,9 @@ efi_bootmgr_enumerate_boot_options(struct eficonfig_media_boot_option *opt, if (blkio->media->logical_partition) continue; + if (removable != (blkio->media->removable_media != 0)) + continue; + ret = efi_search_protocol(handles[i], &efi_guid_device_path, &handler); if (ret != EFI_SUCCESS) continue; @@ -857,6 +863,9 @@ efi_bootmgr_enumerate_boot_options(struct eficonfig_media_boot_option *opt, optional_data = (char *)opt[num].lo + (opt[num].size - u16_strsize(u"1234567")); memcpy(optional_data, &efi_guid_bootmenu_auto_generated, sizeof(efi_guid_t)); num++; + + if (num >= *count) + break; } out: @@ -1105,7 +1114,7 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) { u32 i; efi_status_t ret; - efi_uintn_t count; + efi_uintn_t count, num, total; efi_handle_t *handles = NULL; struct eficonfig_media_boot_option *opt = NULL; @@ -1122,22 +1131,32 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) goto out; } - ret = efi_bootmgr_enumerate_boot_options(opt, handles, &count); + /* parse removable block io followed by fixed block io */ + num = count; + ret = efi_bootmgr_enumerate_boot_options(opt, 0, handles, &num, true); if (ret != EFI_SUCCESS) goto out; + total = num; + num = count; + ret = efi_bootmgr_enumerate_boot_options(opt, total, handles, &num, false); + if (ret != EFI_SUCCESS) + goto out; + + total = num; + /* * System hardware configuration may vary depending on the user setup. * The boot option is automatically added by the bootmenu. * If the device is not attached to the system, the boot option needs * to be deleted. */ - ret = efi_bootmgr_delete_invalid_boot_option(opt, count); + ret = efi_bootmgr_delete_invalid_boot_option(opt, total); if (ret != EFI_SUCCESS) goto out; /* add non-existent boot option */ - for (i = 0; i < count; i++) { + for (i = 0; i < total; i++) { u32 boot_index; u16 var_name[9]; @@ -1166,7 +1185,7 @@ efi_status_t efi_bootmgr_update_media_device_boot_option(void) out: if (opt) { - for (i = 0; i < count; i++) + for (i = 0; i < total; i++) free(opt[i].lo); } free(opt);