1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright 2021 Google LLC
3 # Written by Simon Glass <sjg@chromium.org>
6 # Support for a collection of entries from other parts of an image
8 from collections import OrderedDict
11 from binman.entry import Entry
12 from dtoc import fdt_util
14 class Entry_collection(Entry):
15 """An entry which contains a collection of other entries
17 Properties / Entry arguments:
18 - content: List of phandles to entries to include
20 This allows reusing the contents of other entries. The contents of the
21 listed entries are combined to form this entry. This serves as a useful
22 base class for entry types which need to process data from elsewhere in
23 the image, not necessarily child entries.
25 def __init__(self, section, etype, node):
26 super().__init__(section, etype, node)
27 self.content = fdt_util.GetPhandleList(self._node, 'content')
29 self.Raise("Collection must have a 'content' property")
31 def GetContents(self):
32 """Get the contents of this entry
35 bytes content of the entry
37 # Join up all the data
38 self.Info('Getting content')
40 for entry_phandle in self.content:
41 entry_data = self.section.GetContentsByPhandle(entry_phandle, self)
42 if entry_data is None:
43 # Data not available yet
47 self.Info('Returning contents size %x' % len(data))
51 def ObtainContents(self):
52 data = self.GetContents()
55 self.SetContents(data)
58 def ProcessContents(self):
59 # The blob may have changed due to WriteSymbols()
60 data = self.GetContents()
61 return self.ProcessContentsUpdate(data)