mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-18 02:33:21 +09:00
c6bd6e235a
At present the Entry constructor sets up the object and then immediately reads its device-tree node to obtain its properties. This breaks a convention that constructors should not do any processing. A consequence is that we must pass all arguments to the constructor and cannot have the node-reading proceed in a different way unless we pass flags to that constructor. We already have a 'test' flag in a few cases, and now need to control whether the 'orig_offset' and 'orig_size' properties are set or not. Adjust the code to require a separate call to ReadNode() after construction. The Image class remains as it was. Signed-off-by: Simon Glass <sjg@chromium.org>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# SPDX-License-Identifier: GPL-2.0+
|
|
# Copyright (c) 2018 Google, Inc
|
|
# Written by Simon Glass <sjg@chromium.org>
|
|
#
|
|
|
|
from entry import Entry
|
|
import fdt_util
|
|
import tools
|
|
|
|
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):
|
|
Entry.__init__(self, section, etype, node)
|
|
|
|
def ReadNode(self):
|
|
Entry.ReadNode(self)
|
|
if self.size is None:
|
|
self.Raise("'fill' entry must have a size property")
|
|
self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
|
|
|
|
def ObtainContents(self):
|
|
self.SetContents(tools.GetBytes(self.fill_value, self.size))
|
|
return True
|