mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 17:41:54 +00:00
enhance pack_firmware_image
* including fmap header in fmap areas
* initializing blobs by string value
BUG=chromium-os:15633
TEST=emerge-tegra2_{seaboard,kaen} chromeos-bios
Change-Id: Ib87a3f60fb11804888c4bc023d595629e017f589
Reviewed-on: http://gerrit.chromium.org/gerrit/1427
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
This commit is contained in:
@@ -80,7 +80,17 @@ class Entry(dict):
|
||||
raise PackError('class Entry does not implement Pack()')
|
||||
|
||||
|
||||
class EntryFmap(Entry):
|
||||
class EntryFmapArea(Entry):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
Entry._CheckFields(kwargs, ('flags',))
|
||||
super(EntryFmapArea, self).__init__(**kwargs)
|
||||
|
||||
def Pack(self, firmware_image, entries):
|
||||
pass
|
||||
|
||||
|
||||
class EntryFmap(EntryFmapArea):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
Entry._CheckFields(kwargs, ('ver_major', 'ver_minor', 'base', 'size'))
|
||||
@@ -90,9 +100,8 @@ class EntryFmap(Entry):
|
||||
# prepare header areas
|
||||
areas = []
|
||||
for e in entries:
|
||||
if isinstance(e, EntryFmapArea):
|
||||
areas.append(dict((name, e[name] if name != 'size' else e['length'])
|
||||
for name in FMAP_AREA_NAMES))
|
||||
areas.append(dict((name, e[name] if name != 'size' else e['length'])
|
||||
for name in FMAP_AREA_NAMES))
|
||||
|
||||
# prepare header
|
||||
obj = {'areas':areas}
|
||||
@@ -114,16 +123,6 @@ class EntryFmap(Entry):
|
||||
firmware_image.write(blob)
|
||||
|
||||
|
||||
class EntryFmapArea(Entry):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
Entry._CheckFields(kwargs, ('flags',))
|
||||
super(EntryFmapArea, self).__init__(**kwargs)
|
||||
|
||||
def Pack(self, firmware_image, entries):
|
||||
pass
|
||||
|
||||
|
||||
class EntryWiped(EntryFmapArea):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@@ -147,6 +146,20 @@ class EntryWiped(EntryFmapArea):
|
||||
firmware_image.write(self.wipe_value * self.length)
|
||||
|
||||
|
||||
class EntryBlobString(EntryFmapArea):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
Entry._CheckFields(kwargs, ('value',))
|
||||
super(EntryBlobString, self).__init__(**kwargs)
|
||||
|
||||
def Pack(self, firmware_image, entries):
|
||||
if len(self.value) > self.length:
|
||||
raise PackError('string too large: len(%s) > %d' %
|
||||
(self.value, self.length))
|
||||
firmware_image.seek(self.offset)
|
||||
firmware_image.write(self.value)
|
||||
|
||||
|
||||
class EntryBlob(EntryFmapArea):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user