From patchwork Fri Sep 14 10:57:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 969750 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42BY9X2Lt5z9sBx for ; Fri, 14 Sep 2018 21:25:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EFD4AC22019; Fri, 14 Sep 2018 11:15:38 +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=RCVD_IN_MSPIKE_H2 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 5086DC22079; Fri, 14 Sep 2018 11:05:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 326ABC22051; Fri, 14 Sep 2018 10:59:05 +0000 (UTC) Received: from mail-vk1-f201.google.com (mail-vk1-f201.google.com [209.85.221.201]) by lists.denx.de (Postfix) with ESMTPS id 10114C21FF3 for ; Fri, 14 Sep 2018 10:58:49 +0000 (UTC) Received: by mail-vk1-f201.google.com with SMTP id w73-v6so1315667vkd.9 for ; Fri, 14 Sep 2018 03:58:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FXVZUv3xJotebZy9kTcdK2IOYOO5eJ51vtRjvpIGsC8=; b=h63pgYbEGxdTg8NZ+jyZ6nu0GUGdJtZPmCWbTBVfVC0HiuISYywB4eV23BNBPSYldR jGLAqW63RLuammG6lJpeJGSPcq3OnxAGV9rn3CaVi5jzSorXdnsePZgl6NHSiZSkLNWn iD5EIamu08d+RwHZEjqbUq+zqiaGSkuqGRQ1/9VRrANPiqqg4lHbsCNy2iqoIlpez+3J SUT5RTIdLInvVT6E2eqNQM1F4m4tuZD1AnnkPFZ8DJgBpgR17voEPqSIi+ueu89//ElQ aA/kOP2DVVWqGi194npHJqT7OT0FsR1kaQXW7JZBvy4Qz7KFxm7mhKcPdrC1wBxicdHn uwwA== X-Gm-Message-State: APzg51B/h6OdtM6UC5t6R8azK5k+mKuEZygNj59qRI+8YYYQya/x1GnG /+3jEEdnm799DL4JlAJDNcavp+c= X-Google-Smtp-Source: ANB0VdbPfjWJDskbP0r6YIruIUjjKGw2LPrF40JkDW2M25gQU+IS49FHArpoyNZOGCVtH4I6ayfRGJ4= X-Received: by 2002:a67:4bcd:: with SMTP id f74-v6mr2034449vsg.45.1536922728195; Fri, 14 Sep 2018 03:58:48 -0700 (PDT) Date: Fri, 14 Sep 2018 04:57:33 -0600 In-Reply-To: <20180914105736.162666-1-sjg@chromium.org> Message-Id: <20180914105736.162666-29-sjg@chromium.org> Mime-Version: 1.0 References: <20180914105736.162666-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH 28/31] binman: Record the parent section of each section 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" At present sections have no record of their parent so it is not possible to traverse up the tree to the root and figure out the position of a section within the image. Change the constructor to record this information. Signed-off-by: Simon Glass --- tools/binman/bsection.py | 5 ++++- tools/binman/etype/section.py | 3 ++- tools/binman/image.py | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py index 650e9ba353f..e4c1900b17f 100644 --- a/tools/binman/bsection.py +++ b/tools/binman/bsection.py @@ -24,6 +24,7 @@ class Section(object): Attributes: _node: Node object that contains the section definition in device tree + _parent_section: Parent Section object which created this Section _size: Section size in bytes, or None if not known yet _align_size: Section size alignment, or None _pad_before: Number of bytes before the first entry starts. This @@ -46,14 +47,16 @@ class Section(object): section _entries: OrderedDict() of entries """ - def __init__(self, name, node, test=False): + def __init__(self, name, parent_section, node, image, test=False): global entry global Entry import entry from entry import Entry + self._parent_section = parent_section self._name = name self._node = node + self._image = image self._offset = 0 self._size = None self._align_size = None diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 005a9f9cb2e..7f1b4136049 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -32,7 +32,8 @@ class Entry_section(Entry): """ def __init__(self, section, etype, node): Entry.__init__(self, section, etype, node) - self._section = bsection.Section(node.name, node) + self._section = bsection.Section(node.name, section, node, + section._image) def GetFdtSet(self): return self._section.GetFdtSet() diff --git a/tools/binman/image.py b/tools/binman/image.py index 4b922b51c42..e113a60ac9a 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -42,7 +42,8 @@ class Image: self._size = None self._filename = '%s.bin' % self._name if test: - self._section = bsection.Section('main-section', self._node, True) + self._section = bsection.Section('main-section', None, self._node, + self, True) else: self._ReadNode() @@ -52,7 +53,7 @@ class Image: filename = fdt_util.GetString(self._node, 'filename') if filename: self._filename = filename - self._section = bsection.Section('main-section', self._node) + self._section = bsection.Section('main-section', None, self._node, self) def GetFdtSet(self): """Get the set of device tree files used by this image"""