diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2011-04-07 15:13:30 +0800 |
---|---|---|
committer | Che-Liang Chiou <clchiou@chromium.org> | 2011-04-07 15:13:30 +0800 |
commit | 9522b84029e48579303e9dbc287266eae93e0af9 (patch) | |
tree | 10972da3c9a31f2c9e4c6ddf06639f73543f11b1 | |
parent | 7f37edcf006636c40409dea8be11e4a378440e72 (diff) | |
download | vboot-9522b84029e48579303e9dbc287266eae93e0af9.tar.gz |
Add EntryWiped to pack_firmware_image
EntryWiped takes a byte value wipe_value of range [00:ff] as one of its
arguments that pack_firmware_image uses the value to "wipe" the entry.
R=yjlou@chromium.org
BUG=chrome-os-partner:3089
TEST=emerge-tegra2_seaboard chromeos-bios
Review URL: http://codereview.chromium.org/6799009
Change-Id: Ib2265caf5cfbd6d297465684e87f5a299cd4d043
-rwxr-xr-x | utility/pack_firmware_image | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/utility/pack_firmware_image b/utility/pack_firmware_image index 28572e07..7f0c41c5 100755 --- a/utility/pack_firmware_image +++ b/utility/pack_firmware_image @@ -124,6 +124,29 @@ class EntryFmapArea(Entry): pass +class EntryWiped(EntryFmapArea): + + def __init__(self, **kwargs): + Entry._CheckFields(kwargs, ('wipe_value',)) + super(EntryWiped, self).__init__(**kwargs) + if type(self.wipe_value) is int: + try: + self.wipe_value = chr(self.wipe_value) + except ValueError as e: + raise PackError('cannot convert wipe_value to a character: %s' % str(e)) + elif type(self.wipe_value) is str: + if len(self.wipe_value) != 1: + raise PackError('wipe_value out of range [00:ff]: %s' % + repr(self.wipe_value)) + else: + raise PackError('wipe_value is neither int nor str: %s' % + repr(self.wipe_value)) + + def Pack(self, firmware_image, entries): + firmware_image.seek(self.offset) + firmware_image.write(self.wipe_value * self.length) + + class EntryBlob(EntryFmapArea): def __init__(self, **kwargs): |