From patchwork Thu May 12 02:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 571792 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp258469mal; Wed, 11 May 2022 19:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQf0CMDyn2a+fsrWV5D5tlw57PhVXKw0L1VqbBFxJGY1COQqrtAPFLb1/IR4Lr/bqODBbA X-Received: by 2002:a17:907:96a8:b0:6f4:45f1:6e76 with SMTP id hd40-20020a17090796a800b006f445f16e76mr28635904ejc.186.1652322597598; Wed, 11 May 2022 19:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652322597; cv=none; d=google.com; s=arc-20160816; b=g9e/dUHfZrjDyWmaL4qdaSwJdbuIaWOD80qFwGvZhktdUjpDVC6oWx53T3pTwT6Is8 uITlkfkjxF9cvukVe5xvu8e0JaAQBde6/CS2oIRllBRPNutGqu/DGNbQVpuYUhY52uc3 v59CYb/ZlR0HkdWOL6RV4j8uXZeubbrw5z7fcA3w994M6b/RtjYNLPTprJxiAy+rLsJh AWZ3Z2Rm2OIdJSvBGIhMOm1M1DjgLjT+1YrR9NVb/yYchOZSjUFDH4CYUkTBXAaQgTq1 4/OUg5UZMDbCp1IJ7960xt7AhWi2x1avEH1jQDETiA4yR2bLl+QsimPwmn3xjrlb2dc9 Hm6g== 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=h6UUKFaHkOLSlGWXFN0CEMZtf9sWvPkPw+9EWwYGpCg=; b=wIW9HQLLYAQNDlD/v1/PJvCkdMi9glNfs+76QVTwIaxPQOHTd/XMbEq2EEJCRNsSXb jpgdfPNk/4EC1+4ir6en8yrmuhY7wbv8YRPh40/IUrjmQGGtvtFkm8ZyVOB4zkck4K0E iGk9GpJ6Q0xLnR1YimdU5OTlHLxtlW7jkA2M8kD1VRbx4QAvEF0E4AbQ0TaaKTpmacEO GRl3RapqCmXQa+1n6Vj4O3tc4dAYIMIgGj8N7C5DZwrhrDRtovKFLTQ78nhUX4S2WB6m 7UOg+ccTNDS5Fhrd6kvvR63vRDCnfbGk1SbPn8PPVwMIb2qrO3aq5aSYWLFgCtdxpqn+ U+Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xO6RPoSP; 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 oz39-20020a1709077da700b006e8b1219735si4647048ejc.8.2022.05.11.19.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:29:57 -0700 (PDT) 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=xO6RPoSP; 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 BC37684372; Thu, 12 May 2022 04:29:50 +0200 (CEST) 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="xO6RPoSP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B63A18435A; Thu, 12 May 2022 04:29:48 +0200 (CEST) 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-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 77A6E8432D for ; Thu, 12 May 2022 04:29:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x52e.google.com with SMTP id v10so3336359pgl.11 for ; Wed, 11 May 2022 19:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h6UUKFaHkOLSlGWXFN0CEMZtf9sWvPkPw+9EWwYGpCg=; b=xO6RPoSPvYlUhFbX0/+E+UGw3Nr8Yq4ww4z/u+SSg1z+gjWsI2impxphR188Rul2Ih /zZDTQJ/22luDiceJ1999Q+AaKk+dJO6ZdKQtCmyOTB45alSTv/+VmAUHYmtaqUpIqO5 4XSLFwDZ2byOzcbUA/k0gYSoygZyhQR/N0rqCG8QAR/NlwYhBRLxGxRfQBB+YDPLOieh dEyUB3isSYN8ZoGpE8adtsMDBBCTpSlzmxu6awmAdSa2h+Pm53EapLhW0lqZTnTjDT0G JcOy5oFRb1HQJVWkB4WUqgKeeKcXbRWiPVDO/GsavqJiH2pbfwogVPGDOlRL9oNN6DX9 2nmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h6UUKFaHkOLSlGWXFN0CEMZtf9sWvPkPw+9EWwYGpCg=; b=JuzkUvHXf+M8loPY+WJuNuVWa13pcfSDiVChGJJY9Iedpc5zXCPDbIRHoZk92D9TEQ ohjS5X1dRXW9VYDEiPGr0LhKXTmZbpA0ecdlTW/lmawVUlFNch/3sXoivWfHye6rrhkG zJ0FZ0/StCngLFglmbqX741ARrjT1g/J+kq+OB68hQm/CuMNe+ZjSAFIGsQssWKIxN50 5ktLclaeqJuSQrVcPAF979b0IXQX+LyBevwGMLrEdcer1W/rhhIqbJDTSTPUD4gpDfhO mFTNNqdqvN7XxfCAsBB4aTrF88/y9GkYufyB9gbOQJsTBICCDGfI34VBjve6USvheLfX vCeQ== X-Gm-Message-State: AOAM5320pGAtO+sCrqfdJsA8QztleX9uTh7qlCMBgB0mcKgPP2TX0aKF wmPygRm1JWR+SbfWS1yx08IooGQo0AFrqA== X-Received: by 2002:a63:82c7:0:b0:398:2d6d:848a with SMTP id w190-20020a6382c7000000b003982d6d848amr22110645pgd.343.1652322583903; Wed, 11 May 2022 19:29:43 -0700 (PDT) Received: from localhost.localdomain (p914133-ipoe.ipoe.ocn.ne.jp. [153.243.15.132]) by smtp.gmail.com with ESMTPSA id i4-20020aa78b44000000b0050dc7628190sm2445314pfd.106.2022.05.11.19.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 19:29:43 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de Cc: mark.kettenis@xs4all.nl, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v2 1/3] efi_loader: disk: add efi_disk_is_removable() Date: Thu, 12 May 2022 11:29:01 +0900 Message-Id: <20220512022903.65346-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220512022903.65346-1-takahiro.akashi@linaro.org> References: <20220512022903.65346-1-takahiro.akashi@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.5 at phobos.denx.de X-Virus-Status: Clean This helper function will be used to determine if the device is removable media, initially for handling a short-path loading. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- include/efi_loader.h | 3 +++ lib/efi_loader/efi_disk.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index 40fbab816e2d..839184acb7ff 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -659,6 +659,9 @@ efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type, /* Call this to signal an event */ void efi_signal_event(struct efi_event *event); +/* return true if the device is removable */ +bool efi_disk_is_removable(efi_handle_t handle); + /* open file system: */ struct efi_simple_file_system_protocol *efi_simple_file_system( struct blk_desc *desc, int part, struct efi_device_path *dp); diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index f5b462fb164a..1e82f52dc070 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -73,6 +73,33 @@ static efi_status_t EFIAPI efi_disk_reset(struct efi_block_io *this, return EFI_EXIT(EFI_SUCCESS); } +/** + * efi_disk_is_removable() - check if the device is removable media + * @handle: efi object handle; + * + * Examine the device and determine if the device is a local block device + * and removable media. + * + * Return: true if removable, false otherwise + */ +bool efi_disk_is_removable(efi_handle_t handle) +{ + struct efi_handler *handler; + struct efi_block_io *io; + efi_status_t ret; + + ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); + if (ret != EFI_SUCCESS) + return false; + + io = handler->protocol_interface; + + if (!io || !io->media) + return false; + + return (bool)io->media->removable_media; +} + enum efi_disk_direction { EFI_DISK_READ, EFI_DISK_WRITE,