From patchwork Sat Jul 20 18:23:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1134426 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hyf/ifwO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45rbwG2286z9s4Y for ; Sun, 21 Jul 2019 04:28:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CEEA8C21C38; Sat, 20 Jul 2019 18:25:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 58744C21DF8; Sat, 20 Jul 2019 18:25:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B0284C21C6A; Sat, 20 Jul 2019 18:25:09 +0000 (UTC) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by lists.denx.de (Postfix) with ESMTPS id 93D14C21DED for ; Sat, 20 Jul 2019 18:25:06 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id k20so65213846ios.10 for ; Sat, 20 Jul 2019 11:25:06 -0700 (PDT) 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=rtQrl3EhUCAV/mpMOH+ptuibC2JZSox+rHYbDw5/ddU=; b=Hyf/ifwOvwiqQURE/EBn0brUuRsPNIXe3v8LbuWCOuCkw7tz9oZwNjVWEh0ztQel+L 5rK6NbMDZumfrrhhONtuZwI+/gVlO97CpE0PJ7I1Mf+5dNWzp0NhASRHMJh3DGKx3SR5 +B6qzApg0/QoTkyhEkX1JAzHwV8ebU0T/Ob7A= 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=rtQrl3EhUCAV/mpMOH+ptuibC2JZSox+rHYbDw5/ddU=; b=FUywNtPTIlOZ9q+e1o0d2RCEob99+zcpsr6X//OxQDruQs0DiMvBWKbEavFQrBsBns /vCkc7xy93BVUF84FScgnuDhpU7ZY89+MVmHkq4FbGRCkIMhXhbKnFp5RpaCw4UhZ+GK gmKIG4Owh98waUDmKjASlkuKccBSNRY8M1zo4Zf7MXPZ+a/PslPxNmpGkGbqnKfJROan WFHntbcu8WwnoenDa/HOPMC21QIZ9gjI1jVTqdenYa5X91O2GUMUjjouGKLFoZ0L3frB u0TrA5gYBnChkYGac1niMXfHRM9e4JuDsojwrXovl/D2BX9BVGW4DwSaU/wb51/pAWOT 1GHw== X-Gm-Message-State: APjAAAW9kgDo3idE81q1zQc88pIhdD7NkOVAQWb4RqD5bpkgsUin4STL PVX7bL00Zxm+IbMXPxO51Zp6nE8gEJA= X-Google-Smtp-Source: APXvYqxqHeimyjQUa6VUls8wIw5p+qkb1fURGjYVxUheHZ5S0Tq1NykPcYF6It0U4EgheL1YsjSc4w== X-Received: by 2002:a5e:d507:: with SMTP id e7mr48507597iom.284.1563647105376; Sat, 20 Jul 2019 11:25:05 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id z17sm49778933iol.73.2019.07.20.11.25.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 20 Jul 2019 11:25:04 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 20 Jul 2019 12:23:32 -0600 Message-Id: <20190720182416.183626-11-sjg@chromium.org> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog In-Reply-To: <20190720182416.183626-1-sjg@chromium.org> References: <20190720182416.183626-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 10/53] binman: Adjust state.fdt_files to be keyed by entry type X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" It makes more sense to use entry type as the key for this dictionary, since the filename can in principle be anything. Make this change and also rename fdt_files and add a comment to explain it better. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/etype/blob_dtb.py | 4 +- tools/binman/etype/u_boot_dtb_with_ucode.py | 6 +-- tools/binman/state.py | 57 ++++++++++++--------- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/tools/binman/etype/blob_dtb.py b/tools/binman/etype/blob_dtb.py index b9ccf9a9540..a3b548eef20 100644 --- a/tools/binman/etype/blob_dtb.py +++ b/tools/binman/etype/blob_dtb.py @@ -23,12 +23,12 @@ class Entry_blob_dtb(Entry_blob): def ObtainContents(self): """Get the device-tree from the list held by the 'state' module""" self._filename = self.GetDefaultFilename() - self._pathname, _ = state.GetFdtContents(self._filename) + self._pathname, _ = state.GetFdtContents(self.GetFdtEtype()) return Entry_blob.ReadBlobContents(self) def ProcessContents(self): """Re-read the DTB contents so that we get any calculated properties""" - _, indata = state.GetFdtContents(self._filename) + _, indata = state.GetFdtContents(self.GetFdtEtype()) data = self.CompressData(indata) return self.ProcessContentsUpdate(data) diff --git a/tools/binman/etype/u_boot_dtb_with_ucode.py b/tools/binman/etype/u_boot_dtb_with_ucode.py index ff7f80421a3..cb6c3730d79 100644 --- a/tools/binman/etype/u_boot_dtb_with_ucode.py +++ b/tools/binman/etype/u_boot_dtb_with_ucode.py @@ -56,11 +56,11 @@ class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb): return True # Remove the microcode - fname = self.GetDefaultFilename() - fdt = state.GetFdtForEtype(fname) + etype = self.GetFdtEtype() + fdt = state.GetFdtForEtype(etype) self.ucode = fdt.GetNode('/microcode') if not self.ucode: - raise self.Raise("No /microcode node found in '%s'" % fname) + raise self.Raise("No /microcode node found in '%s'" % etype) # There's no need to collate it (move all microcode into one place) # if we only have one chunk of microcode. diff --git a/tools/binman/state.py b/tools/binman/state.py index ee11ba470e0..0278f87df22 100644 --- a/tools/binman/state.py +++ b/tools/binman/state.py @@ -11,9 +11,15 @@ import re import os import tools -# Records the device-tree files known to binman, keyed by filename (e.g. -# 'u-boot-spl.dtb') -fdt_files = {} +# Records the device-tree files known to binman, keyed by entry type (e.g. +# 'u-boot-spl-dtb'). These are the output FDT files, which can be updated by +# binman. They have been copied to .out files. +# +# key: entry type +# value: tuple: +# Fdt object +# Filename +output_fdt_files = {} # Arguments passed to binman to provide arguments to entries entry_args = {} @@ -36,36 +42,36 @@ main_dtb = None # Entry.ProcessContentsUpdate() allow_entry_expansion = True -def GetFdtForEtype(fname): - """Get the Fdt object for a particular device-tree filename +def GetFdtForEtype(etype): + """Get the Fdt object for a particular device-tree entry Binman keeps track of at least one device-tree file called u-boot.dtb but can also have others (e.g. for SPL). This function looks up the given - filename and returns the associated Fdt object. + entry and returns the associated Fdt object. Args: - fname: Filename to look up (e.g. 'u-boot.dtb'). + etype: Entry type of device tree (e.g. 'u-boot-dtb') Returns: - Fdt object associated with the filename + Fdt object associated with the entry type """ - return fdt_files[fname] + return output_fdt_files[etype][0] -def GetFdtPath(fname): +def GetFdtPath(etype): """Get the full pathname of a particular Fdt object Similar to GetFdtForEtype() but returns the pathname associated with the Fdt. Args: - fname: Filename to look up (e.g. 'u-boot.dtb'). + etype: Entry type of device tree (e.g. 'u-boot-dtb') Returns: Full path name to the associated Fdt """ - return fdt_files[fname]._fname + return output_fdt_files[etype][0]._fname -def GetFdtContents(fname='u-boot.dtb'): +def GetFdtContents(etype='u-boot-dtb'): """Looks up the FDT pathname and contents This is used to obtain the Fdt pathname and contents when needed by an @@ -73,17 +79,18 @@ def GetFdtContents(fname='u-boot.dtb'): the real dtb. Args: - fname: Filename to look up (e.g. 'u-boot.dtb'). + etype: Entry type to look up (e.g. 'u-boot.dtb'). Returns: tuple: pathname to Fdt Fdt data (as bytes) """ - if fname in fdt_files and not use_fake_dtb: - pathname = GetFdtPath(fname) - data = GetFdtForEtype(fname).GetContents() + if etype in output_fdt_files and not use_fake_dtb: + pathname = GetFdtPath(etype) + data = GetFdtForEtype(etype).GetContents() else: + fname = output_fdt_files[etype][1] pathname = tools.GetInputFilename(fname) data = tools.ReadFile(pathname) return pathname, data @@ -128,7 +135,7 @@ def Prepare(images, dtb): images: List of images being used dtb: Main dtb """ - global fdt_set, fdt_subset, fdt_files, main_dtb + global fdt_set, fdt_subset, output_fdt_files, main_dtb # Import these here in case libfdt.py is not available, in which case # the above help option still works. import fdt @@ -139,8 +146,10 @@ def Prepare(images, dtb): # since it is assumed to be the one passed in with options.dt, and # was handled just above. main_dtb = dtb - fdt_files.clear() - fdt_files['u-boot.dtb'] = dtb + output_fdt_files.clear() + output_fdt_files['u-boot-dtb'] = [dtb, 'u-boot.dtb'] + output_fdt_files['u-boot-spl-dtb'] = [dtb, 'spl/u-boot-spl.dtb'] + output_fdt_files['u-boot-tpl-dtb'] = [dtb, 'tpl/u-boot-tpl.dtb'] fdt_subset = {} if not use_fake_dtb: for image in images.values(): @@ -155,7 +164,7 @@ def Prepare(images, dtb): os.path.split(other_fname)[1]) tools.WriteFile(out_fname, tools.ReadFile(other_fname_dtb)) other_dtb = fdt.FdtScan(out_fname) - fdt_files[other_fname] = other_dtb + output_fdt_files[etype] = [other_dtb, other_fname] def GetAllFdts(): """Yield all device tree files being used by binman @@ -164,8 +173,8 @@ def GetAllFdts(): Device trees being used (U-Boot proper, SPL, TPL) """ yield main_dtb - for etype, other_fname in fdt_subset.values(): - yield fdt_files[other_fname] + for etype in fdt_subset: + yield output_fdt_files[etype][0] def GetUpdateNodes(node): """Yield all the nodes that need to be updated in all device trees @@ -182,7 +191,7 @@ def GetUpdateNodes(node): is node, SPL and TPL) """ yield node - for dtb in fdt_files.values(): + for dtb, fname in output_fdt_files.values(): if dtb != node.GetFdt(): other_node = dtb.GetNode(node.path) if other_node: