2018-06-02 00:38:16 +09:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
|
|
|
# Copyright (c) 2018 Google, Inc
|
|
|
|
# Written by Simon Glass <sjg@chromium.org>
|
|
|
|
#
|
|
|
|
# Entry-type module for sections, which are entries which can contain other
|
|
|
|
# entries.
|
|
|
|
#
|
|
|
|
|
|
|
|
from entry import Entry
|
|
|
|
import fdt_util
|
|
|
|
import tools
|
|
|
|
|
|
|
|
import bsection
|
|
|
|
|
|
|
|
class Entry_section(Entry):
|
2018-07-18 04:25:35 +09:00
|
|
|
"""Entry that contains other entries
|
|
|
|
|
|
|
|
Properties / Entry arguments: (see binman README for more information)
|
|
|
|
- size: Size of section in bytes
|
|
|
|
- align-size: Align size to a particular power of two
|
|
|
|
- pad-before: Add padding before the entry
|
|
|
|
- pad-after: Add padding after the entry
|
|
|
|
- pad-byte: Pad byte to use when padding
|
|
|
|
- sort-by-offset: Reorder the entries by offset
|
|
|
|
- end-at-4gb: Used to build an x86 ROM which ends at 4GB (2^32)
|
|
|
|
- name-prefix: Adds a prefix to the name of every entry in the section
|
|
|
|
when writing out the map
|
|
|
|
|
|
|
|
A section is an entry which can contain other entries, thus allowing
|
|
|
|
hierarchical images to be created. See 'Sections and hierarchical images'
|
|
|
|
in the binman README for more information.
|
|
|
|
"""
|
2018-07-18 04:25:38 +09:00
|
|
|
def __init__(self, section, etype, node):
|
|
|
|
Entry.__init__(self, section, etype, node)
|
2018-09-14 19:57:33 +09:00
|
|
|
self._section = bsection.Section(node.name, section, node,
|
|
|
|
section._image)
|
2018-06-02 00:38:16 +09:00
|
|
|
|
2018-09-14 19:57:24 +09:00
|
|
|
def GetFdtSet(self):
|
|
|
|
return self._section.GetFdtSet()
|
|
|
|
|
2018-07-07 01:27:40 +09:00
|
|
|
def ProcessFdt(self, fdt):
|
|
|
|
return self._section.ProcessFdt(fdt)
|
|
|
|
|
2018-09-14 19:57:29 +09:00
|
|
|
def ExpandEntries(self):
|
|
|
|
Entry.ExpandEntries(self)
|
|
|
|
self._section.ExpandEntries()
|
|
|
|
|
2018-07-07 01:27:41 +09:00
|
|
|
def AddMissingProperties(self):
|
|
|
|
Entry.AddMissingProperties(self)
|
|
|
|
self._section.AddMissingProperties()
|
|
|
|
|
2018-06-02 00:38:16 +09:00
|
|
|
def ObtainContents(self):
|
2018-07-07 01:27:17 +09:00
|
|
|
return self._section.GetEntryContents()
|
2018-06-02 00:38:16 +09:00
|
|
|
|
|
|
|
def GetData(self):
|
|
|
|
return self._section.GetData()
|
|
|
|
|
2018-08-02 06:22:37 +09:00
|
|
|
def GetOffsets(self):
|
|
|
|
"""Handle entries that want to set the offset/size of other entries
|
2018-06-02 00:38:16 +09:00
|
|
|
|
2018-08-02 06:22:37 +09:00
|
|
|
This calls each entry's GetOffsets() method. If it returns a list
|
2018-06-02 00:38:16 +09:00
|
|
|
of entries to update, it updates them.
|
|
|
|
"""
|
2018-08-02 06:22:37 +09:00
|
|
|
self._section.GetEntryOffsets()
|
2018-06-02 00:38:16 +09:00
|
|
|
return {}
|
|
|
|
|
2019-07-09 05:25:37 +09:00
|
|
|
def ResetForPack(self):
|
|
|
|
"""Reset offset/size fields so that packing can be done again"""
|
|
|
|
self._section.ResetForPack()
|
|
|
|
Entry.ResetForPack(self)
|
|
|
|
|
2018-08-02 06:22:37 +09:00
|
|
|
def Pack(self, offset):
|
2018-06-02 00:38:16 +09:00
|
|
|
"""Pack all entries into the section"""
|
|
|
|
self._section.PackEntries()
|
2019-04-26 12:58:39 +09:00
|
|
|
if self._section._offset is None:
|
|
|
|
self._section.SetOffset(offset)
|
2018-07-18 04:25:28 +09:00
|
|
|
self.size = self._section.GetSize()
|
2018-08-02 06:22:37 +09:00
|
|
|
return super(Entry_section, self).Pack(offset)
|
2018-06-02 00:38:16 +09:00
|
|
|
|
2018-08-02 06:22:42 +09:00
|
|
|
def SetImagePos(self, image_pos):
|
|
|
|
Entry.SetImagePos(self, image_pos)
|
|
|
|
self._section.SetImagePos(image_pos + self.offset)
|
|
|
|
|
2018-06-02 00:38:16 +09:00
|
|
|
def WriteSymbols(self, section):
|
|
|
|
"""Write symbol values into binary files for access at run time"""
|
|
|
|
self._section.WriteSymbols()
|
|
|
|
|
2018-07-07 01:27:41 +09:00
|
|
|
def SetCalculatedProperties(self):
|
|
|
|
Entry.SetCalculatedProperties(self)
|
|
|
|
self._section.SetCalculatedProperties()
|
|
|
|
|
2018-06-02 00:38:16 +09:00
|
|
|
def ProcessContents(self):
|
2019-07-09 05:25:35 +09:00
|
|
|
sizes_ok = self._section.ProcessEntryContents()
|
|
|
|
sizes_ok_base = super(Entry_section, self).ProcessContents()
|
|
|
|
return sizes_ok and sizes_ok_base
|
2018-06-02 00:38:16 +09:00
|
|
|
|
2018-08-02 06:22:37 +09:00
|
|
|
def CheckOffset(self):
|
2018-06-02 00:38:16 +09:00
|
|
|
self._section.CheckEntries()
|
2018-06-02 00:38:20 +09:00
|
|
|
|
|
|
|
def WriteMap(self, fd, indent):
|
|
|
|
"""Write a map of the section to a .map file
|
|
|
|
|
|
|
|
Args:
|
|
|
|
fd: File to write the map to
|
|
|
|
"""
|
2018-07-18 04:25:28 +09:00
|
|
|
self._section.WriteMap(fd, indent)
|
2018-07-18 04:25:38 +09:00
|
|
|
|
|
|
|
def GetEntries(self):
|
|
|
|
return self._section.GetEntries()
|
2018-09-14 19:57:29 +09:00
|
|
|
|
|
|
|
def ExpandToLimit(self, limit):
|
|
|
|
super(Entry_section, self).ExpandToLimit(limit)
|
|
|
|
self._section.ExpandSize(self.size)
|