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 9from entry import Entry 10import fdt_util 11import tools 12 13import bsection 14 15class 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, section, node, 36 section._image) 37 38 def GetFdtSet(self): 39 return self._section.GetFdtSet() 40 41 def ProcessFdt(self, fdt): 42 return self._section.ProcessFdt(fdt) 43 44 def ExpandEntries(self): 45 Entry.ExpandEntries(self) 46 self._section.ExpandEntries() 47 48 def AddMissingProperties(self): 49 Entry.AddMissingProperties(self) 50 self._section.AddMissingProperties() 51 52 def ObtainContents(self): 53 return self._section.GetEntryContents() 54 55 def GetData(self): 56 return self._section.GetData() 57 58 def GetOffsets(self): 59 """Handle entries that want to set the offset/size of other entries 60 61 This calls each entry's GetOffsets() method. If it returns a list 62 of entries to update, it updates them. 63 """ 64 self._section.GetEntryOffsets() 65 return {} 66 67 def Pack(self, offset): 68 """Pack all entries into the section""" 69 self._section.PackEntries() 70 self._section.SetOffset(offset) 71 self.size = self._section.GetSize() 72 return super(Entry_section, self).Pack(offset) 73 74 def SetImagePos(self, image_pos): 75 Entry.SetImagePos(self, image_pos) 76 self._section.SetImagePos(image_pos + self.offset) 77 78 def WriteSymbols(self, section): 79 """Write symbol values into binary files for access at run time""" 80 self._section.WriteSymbols() 81 82 def SetCalculatedProperties(self): 83 Entry.SetCalculatedProperties(self) 84 self._section.SetCalculatedProperties() 85 86 def ProcessContents(self): 87 self._section.ProcessEntryContents() 88 super(Entry_section, self).ProcessContents() 89 90 def CheckOffset(self): 91 self._section.CheckEntries() 92 93 def WriteMap(self, fd, indent): 94 """Write a map of the section to a .map file 95 96 Args: 97 fd: File to write the map to 98 """ 99 self._section.WriteMap(fd, indent) 100 101 def GetEntries(self): 102 return self._section.GetEntries() 103 104 def ExpandToLimit(self, limit): 105 super(Entry_section, self).ExpandToLimit(limit) 106 self._section.ExpandSize(self.size) 107