2018-07-18 04:25:40 +09:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
|
|
|
# Copyright (c) 2018 Google, Inc
|
|
|
|
# Written by Simon Glass <sjg@chromium.org>
|
|
|
|
#
|
|
|
|
|
2020-04-18 09:09:03 +09:00
|
|
|
from binman.entry import Entry
|
|
|
|
from dtoc import fdt_util
|
2020-04-18 09:09:04 +09:00
|
|
|
from patman import tools
|
2018-07-18 04:25:40 +09:00
|
|
|
|
|
|
|
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):
|
2020-07-10 09:39:35 +09:00
|
|
|
super().__init__(section, etype, node)
|
2019-07-21 03:23:45 +09:00
|
|
|
|
|
|
|
def ReadNode(self):
|
2020-07-10 09:39:35 +09:00
|
|
|
super().ReadNode()
|
2018-09-14 19:57:08 +09:00
|
|
|
if self.size is None:
|
2018-07-18 04:25:40 +09:00
|
|
|
self.Raise("'fill' entry must have a size property")
|
|
|
|
self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
|
|
|
|
|
|
|
|
def ObtainContents(self):
|
2019-05-15 06:53:47 +09:00
|
|
|
self.SetContents(tools.GetBytes(self.fill_value, self.size))
|
2018-07-18 04:25:40 +09:00
|
|
|
return True
|