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 ResetForPack(self):
68 """Reset offset/size fields so that packing can be done again"""
69 self._section.ResetForPack()
70 Entry.ResetForPack(self)
72 def Pack(self, offset):
73 """Pack all entries into the section"""
74 self._section.PackEntries()
75 if self._section._offset is None:
76 self._section.SetOffset(offset)
77 self.size = self._section.GetSize()
78 return super(Entry_section, self).Pack(offset)
80 def SetImagePos(self, image_pos):
81 Entry.SetImagePos(self, image_pos)
82 self._section.SetImagePos(image_pos + self.offset)
84 def WriteSymbols(self, section):
85 """Write symbol values into binary files for access at run time"""
86 self._section.WriteSymbols()
88 def SetCalculatedProperties(self):
89 Entry.SetCalculatedProperties(self)
90 self._section.SetCalculatedProperties()
92 def ProcessContents(self):
93 sizes_ok = self._section.ProcessEntryContents()
94 sizes_ok_base = super(Entry_section, self).ProcessContents()
95 return sizes_ok and sizes_ok_base
97 def CheckOffset(self):
98 self._section.CheckEntries()
100 def WriteMap(self, fd, indent):
101 """Write a map of the section to a .map file
104 fd: File to write the map to
106 self._section.WriteMap(fd, indent)
108 def GetEntries(self):
109 return self._section.GetEntries()
111 def ExpandToLimit(self, limit):
112 super(Entry_section, self).ExpandToLimit(limit)
113 self._section.ExpandSize(self.size)
115 def ListEntries(self, entries, indent):
116 """List the files in the section"""
117 self._section.ListEntries(entries, indent)