Merge tag 'dm-pull-9jul19-take2' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
[oweals/u-boot.git] / tools / binman / etype / fill.py
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5
6 from entry import Entry
7 import fdt_util
8 import tools
9
10 class Entry_fill(Entry):
11     """An entry which is filled to a particular byte value
12
13     Properties / Entry arguments:
14         - fill-byte: Byte to use to fill the entry
15
16     Note that the size property must be set since otherwise this entry does not
17     know how large it should be.
18
19     You can often achieve the same effect using the pad-byte property of the
20     overall image, in that the space between entries will then be padded with
21     that byte. But this entry is sometimes useful for explicitly setting the
22     byte value of a region.
23     """
24     def __init__(self, section, etype, node):
25         Entry.__init__(self, section, etype, node)
26         if self.size is None:
27             self.Raise("'fill' entry must have a size property")
28         self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
29
30     def ObtainContents(self):
31         self.SetContents(tools.GetBytes(self.fill_value, self.size))
32         return True