diff options
| author | Simon Glass <[email protected]> | 2019-07-20 12:24:04 -0600 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2019-07-29 09:38:06 -0600 |
| commit | a9cd39ef751efdd05a3a5ccae13e28d8a993292d (patch) | |
| tree | f40b538b4be83f3c0a8a8ad6b829c7a55ee40f7e /tools/binman/etype/section.py | |
| parent | 17a7421ff417f21d0e3e151c992d7188ded3c0d3 (diff) | |
binman: Update Entry.ReadEntry() to work through classes
At present we simply extract the data directly from entries using the
image_pos information. This happens to work on current entry types, but
cannot work if the entry type encodes the data in some way. Update the
ReadData() method to provide the data by calling a new ReadChildData()
method in the parent. This allows the entry_Section class, or possibly
any other container class, to return the correct data in all cases.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'tools/binman/etype/section.py')
| -rw-r--r-- | tools/binman/etype/section.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 3ce013d5029..855e291bc43 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -17,6 +17,7 @@ import sys from entry import Entry import fdt_util import tools +import tout class Entry_section(Entry): @@ -488,3 +489,34 @@ class Entry_section(Entry): they appear in the device tree """ return self._sort + + def ReadData(self, decomp=True): + tout.Info("ReadData path='%s'" % self.GetPath()) + parent_data = self.section.ReadData(True) + tout.Info('%s: Reading data from offset %#x-%#x, size %#x' % + (self.GetPath(), self.offset, self.offset + self.size, + self.size)) + data = parent_data[self.offset:self.offset + self.size] + return data + + def ReadChildData(self, child, decomp=True): + """Read the data for a particular child entry + + Args: + child: Child entry to read data for + decomp: True to return uncompressed data, False to leave the data + compressed if it is compressed + + Returns: + Data contents of entry + """ + parent_data = self.ReadData(True) + data = parent_data[child.offset:child.offset + child.size] + if decomp: + indata = data + data = tools.Decompress(indata, child.compress) + if child.uncomp_size: + tout.Info("%s: Decompressing data size %#x with algo '%s' to data size %#x" % + (child.GetPath(), len(indata), child.compress, + len(data))) + return data |
