binman: Enhance the map and fdt-update output
[platform/kernel/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     def __init__(self, image, etype, node):
17         Entry.__init__(self, image, etype, node)
18         self._section = bsection.Section(node.name, node)
19
20     def ProcessFdt(self, fdt):
21         return self._section.ProcessFdt(fdt)
22
23     def AddMissingProperties(self):
24         Entry.AddMissingProperties(self)
25         self._section.AddMissingProperties()
26
27     def ObtainContents(self):
28         return self._section.GetEntryContents()
29
30     def GetData(self):
31         return self._section.GetData()
32
33     def GetOffsets(self):
34         """Handle entries that want to set the offset/size of other entries
35
36         This calls each entry's GetOffsets() method. If it returns a list
37         of entries to update, it updates them.
38         """
39         self._section.GetEntryOffsets()
40         return {}
41
42     def Pack(self, offset):
43         """Pack all entries into the section"""
44         self._section.PackEntries()
45         self._section.SetOffset(offset)
46         self.size = self._section.GetSize()
47         return super(Entry_section, self).Pack(offset)
48
49     def WriteSymbols(self, section):
50         """Write symbol values into binary files for access at run time"""
51         self._section.WriteSymbols()
52
53     def SetCalculatedProperties(self):
54         Entry.SetCalculatedProperties(self)
55         self._section.SetCalculatedProperties()
56
57     def ProcessContents(self):
58         self._section.ProcessEntryContents()
59         super(Entry_section, self).ProcessContents()
60
61     def CheckOffset(self):
62         self._section.CheckEntries()
63
64     def WriteMap(self, fd, indent):
65         """Write a map of the section to a .map file
66
67         Args:
68             fd: File to write the map to
69         """
70         self._section.WriteMap(fd, indent)