fill.py 1.2 KB

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