From patchwork Mon Apr 27 09:48:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1277487 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=bOVJjG94; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499g3X5wtQz9sSb for ; Mon, 27 Apr 2020 19:49:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78F9D81E17; Mon, 27 Apr 2020 11:49:08 +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="bOVJjG94"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1739E81E17; Mon, 27 Apr 2020 11:49:05 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (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 8C80481E0F for ; Mon, 27 Apr 2020 11:48:59 +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-pf1-x444.google.com with SMTP id x2so5056142pfx.7 for ; Mon, 27 Apr 2020 02:48:59 -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=1AJJ39U2dw9tuHLdawUPeZ1CileDSxT+tov7QocSd6Y=; b=bOVJjG946JXdWW+1qTxuKPbefRVIpS1wjuCtt7YTBaVhY2nClK/x1T+TRbsLxevghU ZQi/VFj1NmWt3p5Q2P2/Mnr4KVPkweovUGox28MEnhKznwrAs4pFOSttrs9uLxfj1anF 90PLlaI8tPCW3Ujmasy+P5lC7RKWRUUA2G8gvbbHKSD80xEessbqP8Yn581fihWwf0x5 e2RpoxsihwYK5cUhxBx+gTirNSFXkQBVtBfuZ8I8zH7oAasqNMeUoVIsm0szn1Es5ApU LzILdC+MRQHHY8kqXQJrot70I3wirX2UC3HJSJuwM2yFnyQ5c6KABKL7SXcykcuT2lna KNpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1AJJ39U2dw9tuHLdawUPeZ1CileDSxT+tov7QocSd6Y=; b=e0ld+o686BAoXM6hx5ONgc/Qnbx1oH2ucTnDSzxIEqQowXBgjC/wFWuX/lhBZrzmdF Tq7x3LBb3E+eHKHu0Sv9VlZNV2RQxnQbIWpiIQR1KhPLlQyMg+MeF8bYIDykW8xcguhg uUerwT/uLjxnoezc8blRkLv2rJ5doRmx3X57Zfm4Q7T6ZMibLMAEfsVlOKdUaNrLKtA7 vrSwLXsl1rPr1pP7NieMrnDxSkOYwME2Y0zv5huDJZjrI0oYEgcXV0fWUSk1TTQf6fto yBW1LQ2VM5G8KmNrxGehPLDXgAFpKRM1hgkKl7o7Ua6+90zYfjPprZ1eKHZD0GoJLIsn fypw== X-Gm-Message-State: AGi0PubGvAZxan2m5lW02Ra2Jm049taFYvOG81Ai8C/wXXOU3D02uhVx EweUztoXXNZ14s9lBTW7IL/6mg== X-Google-Smtp-Source: APiQypK3sT0Ydj8RteqstqXpOMP2uOO8QW+lHdzRWk62btvmd+3ViM38MvwagHCnR7UJLvgFL4JYxw== X-Received: by 2002:a63:350:: with SMTP id 77mr23197177pgd.325.1587980937753; Mon, 27 Apr 2020 02:48:57 -0700 (PDT) Received: from localhost.localdomain (p73a21dd7.tkyea130.ap.so-net.ne.jp. [115.162.29.215]) by smtp.gmail.com with ESMTPSA id 3sm12491031pfo.27.2020.04.27.02.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 02:48:57 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Cc: sughosh.ganu@linaro.org, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH 01/10] efi_loader: disk: add efi_disk_is_system_part() Date: Mon, 27 Apr 2020 18:48:20 +0900 Message-Id: <20200427094829.1140-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200427094829.1140-1-takahiro.akashi@linaro.org> References: <20200427094829.1140-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean This function will check if a given handle to device is a EFI system partition. It will be utilised in implementing capsule-on-disk feature. Signed-off-by: AKASHI Takahiro --- include/efi_loader.h | 2 ++ lib/efi_loader/efi_disk.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index b7bccf50b30c..d4510462d616 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -393,6 +393,8 @@ efi_status_t efi_disk_register(void); int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, const char *if_typename, int diskid, const char *pdevname); +/* Check if it is EFI system partition */ +bool efi_disk_is_system_part(efi_handle_t handle); /* Called by bootefi to make GOP (graphical) interface available */ efi_status_t efi_gop_register(void); /* Called by bootefi to make the network interface available */ diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index fd3df80b0b96..9f58a8642c85 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -588,3 +588,25 @@ efi_status_t efi_disk_register(void) return EFI_SUCCESS; } + +bool efi_disk_is_system_part(efi_handle_t handle) +{ + struct efi_handler *handler; + struct efi_disk_obj *diskobj; + disk_partition_t info; + efi_status_t ret; + int r; + + /* check if this is a block device */ + ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); + if (ret != EFI_SUCCESS) + return false; + + diskobj = container_of(handle, struct efi_disk_obj, header); + + r = part_get_info(diskobj->desc, diskobj->part, &info); + if (r) + return false; + + return info.bootable & PART_EFI_SYSTEM_PARTITION; +}