fill.py 1.1 KB

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