1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
5 # Entry-type module for sections, which are entries which can contain other
9 from entry import Entry
15 class Entry_section(Entry):
16 """Entry that contains other entries
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
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.
33 def __init__(self, section, etype, node):
34 Entry.__init__(self, section, etype, node)
35 self._section = bsection.Section(node.name, section, node,
39 return self._section.GetFdtSet()
41 def ProcessFdt(self, fdt):
42 return self._section.ProcessFdt(fdt)
44 def ExpandEntries(self):
45 Entry.ExpandEntries(self)
46 self._section.ExpandEntries()
48 def AddMissingProperties(self):
49 Entry.AddMissingProperties(self)
50 self._section.AddMissingProperties()
52 def ObtainContents(self):
53 return self._section.GetEntryContents()
56 return self._section.GetData()
59 """Handle entries that want to set the offset/size of other entries
61 This calls each entry's GetOffsets() method. If it returns a list
62 of entries to update, it updates them.
64 self._section.GetEntryOffsets()
67 def Pack(self, offset):
68 """Pack all entries into the section"""
69 self._section.PackEntries()
70 if self._section._offset is None:
71 self._section.SetOffset(offset)
72 self.size = self._section.GetSize()
73 return super(Entry_section, self).Pack(offset)
75 def SetImagePos(self, image_pos):
76 Entry.SetImagePos(self, image_pos)
77 self._section.SetImagePos(image_pos + self.offset)
79 def WriteSymbols(self, section):
80 """Write symbol values into binary files for access at run time"""
81 self._section.WriteSymbols()
83 def SetCalculatedProperties(self):
84 Entry.SetCalculatedProperties(self)
85 self._section.SetCalculatedProperties()
87 def ProcessContents(self):
88 self._section.ProcessEntryContents()
89 super(Entry_section, self).ProcessContents()
91 def CheckOffset(self):
92 self._section.CheckEntries()
94 def WriteMap(self, fd, indent):
95 """Write a map of the section to a .map file
98 fd: File to write the map to
100 self._section.WriteMap(fd, indent)
102 def GetEntries(self):
103 return self._section.GetEntries()
105 def ExpandToLimit(self, limit):
106 super(Entry_section, self).ExpandToLimit(limit)
107 self._section.ExpandSize(self.size)