summaryrefslogtreecommitdiff
path: root/tools/binman/etype
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-17 13:25:40 -0600
committerSimon Glass <sjg@chromium.org>2018-08-01 16:30:48 -0600
commit3af8e49ceff044021725fc547b19ebac22d0b0f7 (patch)
treee0d82e9e4a9e94f1ffe36da7fa4ba78a4da213c7 /tools/binman/etype
parentec127af0429ad6f9818297f9c3ee77edb2154182 (diff)
binman: Add an entry filled with a repeating byte
It is sometimes useful to have an area of the image which is all zeroes, or all 0xff. This can often be achieved by padding the size of an an existing entry and setting the pad byte for an entry or image. But it is useful to have an explicit means of adding blocks of repeating data to the image. Add a 'fill' entry type to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/etype')
-rw-r--r--tools/binman/etype/fill.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
new file mode 100644
index 0000000000..7210a8324a
--- /dev/null
+++ b/tools/binman/etype/fill.py
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+
+from entry import Entry
+import fdt_util
+
+
+class Entry_fill(Entry):
+ """An entry which is filled to a particular byte value
+
+ Properties / Entry arguments:
+ - fill-byte: Byte to use to fill the entry
+
+ Note that the size property must be set since otherwise this entry does not
+ know how large it should be.
+
+ You can often achieve the same effect using the pad-byte property of the
+ overall image, in that the space between entries will then be padded with
+ that byte. But this entry is sometimes useful for explicitly setting the
+ byte value of a region.
+ """
+ def __init__(self, section, etype, node):
+ Entry.__init__(self, section, etype, node)
+ if not self.size:
+ self.Raise("'fill' entry must have a size property")
+ self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
+
+ def ObtainContents(self):
+ self.SetContents(chr(self.fill_value) * self.size)
+ return True