1# SPDX-License-Identifier: GPL-2.0+ 2# Copyright (c) 2018 Google, Inc 3# Written by Simon Glass <sjg@chromium.org> 4# 5 6from binman.entry import Entry 7from dtoc import fdt_util 8from patman import tools 9 10class 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 super().__init__(section, etype, node) 26 27 def ReadNode(self): 28 super().ReadNode() 29 if self.size is None: 30 self.Raise("'fill' entry must have a size property") 31 self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0) 32 33 def ObtainContents(self): 34 self.SetContents(tools.GetBytes(self.fill_value, self.size)) 35 return True 36