Commit 08723a7abbc7e28b22d18684faf5142fc6f155e8

Authored by Simon Glass
1 parent f025363543

binman: Record the parent section of each section

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 <sjg@chromium.org>

Showing 3 changed files with 9 additions and 4 deletions Side-by-side Diff

tools/binman/bsection.py
... ... @@ -24,6 +24,7 @@
24 24  
25 25 Attributes:
26 26 _node: Node object that contains the section definition in device tree
  27 + _parent_section: Parent Section object which created this Section
27 28 _size: Section size in bytes, or None if not known yet
28 29 _align_size: Section size alignment, or None
29 30 _pad_before: Number of bytes before the first entry starts. This
30 31  
31 32  
... ... @@ -46,14 +47,16 @@
46 47 section
47 48 _entries: OrderedDict() of entries
48 49 """
49   - def __init__(self, name, node, test=False):
  50 + def __init__(self, name, parent_section, node, image, test=False):
50 51 global entry
51 52 global Entry
52 53 import entry
53 54 from entry import Entry
54 55  
  56 + self._parent_section = parent_section
55 57 self._name = name
56 58 self._node = node
  59 + self._image = image
57 60 self._offset = 0
58 61 self._size = None
59 62 self._align_size = None
tools/binman/etype/section.py
... ... @@ -32,7 +32,8 @@
32 32 """
33 33 def __init__(self, section, etype, node):
34 34 Entry.__init__(self, section, etype, node)
35   - self._section = bsection.Section(node.name, node)
  35 + self._section = bsection.Section(node.name, section, node,
  36 + section._image)
36 37  
37 38 def GetFdtSet(self):
38 39 return self._section.GetFdtSet()
tools/binman/image.py
... ... @@ -42,7 +42,8 @@
42 42 self._size = None
43 43 self._filename = '%s.bin' % self._name
44 44 if test:
45   - self._section = bsection.Section('main-section', self._node, True)
  45 + self._section = bsection.Section('main-section', None, self._node,
  46 + self, True)
46 47 else:
47 48 self._ReadNode()
48 49  
... ... @@ -52,7 +53,7 @@
52 53 filename = fdt_util.GetString(self._node, 'filename')
53 54 if filename:
54 55 self._filename = filename
55   - self._section = bsection.Section('main-section', self._node)
  56 + self._section = bsection.Section('main-section', None, self._node, self)
56 57  
57 58 def GetFdtSet(self):
58 59 """Get the set of device tree files used by this image"""