From patchwork Thu Jan 14 03:29:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1426167 X-Patchwork-Delegate: trini@ti.com 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=85.214.62.61; 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=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=JSSuDOPc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DGVJY56QQz9sVF for ; Thu, 14 Jan 2021 14:33:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5CBEF82778; Thu, 14 Jan 2021 04:31:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JSSuDOPc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C58028270D; Thu, 14 Jan 2021 04:30:29 +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.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) (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 C06748272C for ; Thu, 14 Jan 2021 04:30:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2b.google.com with SMTP id n4so8530587iow.12 for ; Wed, 13 Jan 2021 19:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=niNa39SxGOug0BL/HjjxIVMJyI5H4I2yhndRLqxGwXw=; b=JSSuDOPcdHFGoGkfAKFwT0hFbFJojdv+ncXR07HTWK+H75mvmf02ROD/mfjDOJZuyM sLEPjjNuk9XbLRHQUXgG+pt0xluM7vnf3Zeo+tlWYdLgbsSiX2Qm9COn6+BafMTC4av+ Tuy+PJcmHxeoGdKXCUgcrtNNIZNiUM8MHfgLg= 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=niNa39SxGOug0BL/HjjxIVMJyI5H4I2yhndRLqxGwXw=; b=EIthQsO6uuHI2ivMcqQPdbTaFsqwYjE752v2B/tI1ZS8cWSf5WfOdZR1AniP62Wz92 PZnVCX0/h3ZgdeXHfEb9aKyV2fca2qCGQmzbI5FNctgaYoYxDr2JPU63V/0CaHWd/a4K pj3cJ06zMMsX3bf4mKSMeUmwDJ3Fe1IMwjP4IBSdu58ZvNriVq0gUjufY4Ln1zfG6U+O M3z0zeGcM8ZQuqH6bp8bSwdC7HjLK6U0AwjFgt8EbjDD7u7NCzuB/04ng7Z3N0TBZf1K 4g25J+0aIWHeQYvMm1bSXzQlQybx8QgXNUUYM3jO4RqSP045VFg13QXEloAZbyhEOU+2 C+Ng== X-Gm-Message-State: AOAM5312jKX2+zBWdKNvCtG1ansCemdzYpQPDJUjZ5Q5sCAHeMqq45zE 2BNQGHuDyomJQPEmRLf5uuuJKivAGs8EPSkd X-Google-Smtp-Source: ABdhPJxyJhJEGwUc84ARmmx1eBC6PbzicLVS9s8M7pTedzQm9DnHRnIUpm/NtBKKMPDjOYT1IX7MnQ== X-Received: by 2002:a05:6e02:e01:: with SMTP id a1mr4861036ilk.101.1610595020239; Wed, 13 Jan 2021 19:30:20 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id 12sm1930547ioz.41.2021.01.13.19.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 19:30:19 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Bin Meng , Michal Simek Subject: [PATCH 17/17] binman: Allow reading entries from a subnode Date: Wed, 13 Jan 2021 20:29:57 -0700 Message-Id: <20210114032957.483086-18-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog In-Reply-To: <20210114032957.483086-1-sjg@chromium.org> References: <20210114032957.483086-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean Some images may have multiple copies of the same thing, e.g. two versions of the read/write U-Boots. It is necessary to read data from one or other of these under selection of the verified-boot logic. Add a function to select the subnode to use. Signed-off-by: Simon Glass --- include/binman.h | 14 ++++++++++++++ lib/binman.c | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/binman.h b/include/binman.h index 8b89a9666d5..5958dfb4485 100644 --- a/include/binman.h +++ b/include/binman.h @@ -70,6 +70,20 @@ int binman_entry_find(const char *name, struct binman_entry *entry); */ ofnode binman_section_find_node(const char *name); +/** + * binman_select_subnode() - Select a subnode to use to find entries + * + * Normally binman selects the top-level node for future entry requests, such as + * binman_entry_find(). This function allows a subnode to be chosen instead. + * + * @name: Name of subnode, typically a section. This must be in the top-level + * binman node + * @return 0 if OK, -EINVAL if there is no /binman node, -ECHILD if multiple + * images are being used but the first image is not available, -ENOENT if + * the requested subnode cannot be found + */ +int binman_select_subnode(const char *name); + /** * binman_init() - Set up the binman symbol information * diff --git a/lib/binman.c b/lib/binman.c index b6d9dff5b7c..f415df30545 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -116,6 +116,24 @@ int binman_get_rom_offset(void) return binman->rom_offset; } +int binman_select_subnode(const char *name) +{ + ofnode node; + int ret; + + ret = find_image_node(&node); + if (ret) + return log_msg_ret("main", -ENOENT); + node = ofnode_find_subnode(node, name); + if (!ofnode_valid(node)) + return log_msg_ret("node", -ENOENT); + binman->image = node; + log_debug("binman: Selected image subnode '%s'\n", + ofnode_get_name(binman->image)); + + return 0; +} + int binman_init(void) { int ret;