]> git.ipfire.org Git - thirdparty/u-boot.git/blob - tools/binman/etype/section.py
f5b2ed67cf8fa46706b541da48b0bbcc69525e82
[thirdparty/u-boot.git] / tools / binman / etype / section.py
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5 # Entry-type module for sections, which are entries which can contain other
6 # entries.
7 #
8
9 from entry import Entry
10 import fdt_util
11 import tools
12
13 import bsection
14
15 class Entry_section(Entry):
16 """Entry that contains other entries
17
18 Properties / Entry arguments: (see binman README for more information)
19 - size: Size of section in bytes
20 - align-size: Align size to a particular power of two
21 - pad-before: Add padding before the entry
22 - pad-after: Add padding after the entry
23 - pad-byte: Pad byte to use when padding
24 - sort-by-offset: Reorder the entries by offset
25 - end-at-4gb: Used to build an x86 ROM which ends at 4GB (2^32)
26 - name-prefix: Adds a prefix to the name of every entry in the section
27 when writing out the map
28
29 A section is an entry which can contain other entries, thus allowing
30 hierarchical images to be created. See 'Sections and hierarchical images'
31 in the binman README for more information.
32 """
33 def __init__(self, section, etype, node):
34 Entry.__init__(self, section, etype, node)
35 self._section = bsection.Section(node.name, node)
36
37 def ProcessFdt(self, fdt):
38 return self._section.ProcessFdt(fdt)
39
40 def AddMissingProperties(self):
41 Entry.AddMissingProperties(self)
42 self._section.AddMissingProperties()
43
44 def ObtainContents(self):
45 return self._section.GetEntryContents()
46
47 def GetData(self):
48 return self._section.GetData()
49
50 def GetOffsets(self):
51 """Handle entries that want to set the offset/size of other entries
52
53 This calls each entry's GetOffsets() method. If it returns a list
54 of entries to update, it updates them.
55 """
56 self._section.GetEntryOffsets()
57 return {}
58
59 def Pack(self, offset):
60 """Pack all entries into the section"""
61 self._section.PackEntries()
62 self._section.SetOffset(offset)
63 self.size = self._section.GetSize()
64 return super(Entry_section, self).Pack(offset)
65
66 def SetImagePos(self, image_pos):
67 Entry.SetImagePos(self, image_pos)
68 self._section.SetImagePos(image_pos + self.offset)
69
70 def WriteSymbols(self, section):
71 """Write symbol values into binary files for access at run time"""
72 self._section.WriteSymbols()
73
74 def SetCalculatedProperties(self):
75 Entry.SetCalculatedProperties(self)
76 self._section.SetCalculatedProperties()
77
78 def ProcessContents(self):
79 self._section.ProcessEntryContents()
80 super(Entry_section, self).ProcessContents()
81
82 def CheckOffset(self):
83 self._section.CheckEntries()
84
85 def WriteMap(self, fd, indent):
86 """Write a map of the section to a .map file
87
88 Args:
89 fd: File to write the map to
90 """
91 self._section.WriteMap(fd, indent)
92
93 def GetEntries(self):
94 return self._section.GetEntries()