Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(716)

Unified Diff: saft/flashrom_handler.py

Issue 3328008: Make SAFT use layout retrieved from the BIOS image. (Closed) Base URL: http://git.chromium.org/git/firmware.git
Patch Set: Cosmetic changes before committing. Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | saft/saft_utility.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: saft/flashrom_handler.py
diff --git a/saft/flashrom_handler.py b/saft/flashrom_handler.py
index 40e24b63ec796872eecc3e86f0fe277c56a955a4..f71d0195bca35653a0c5b074670719e2d5cb4f3a 100755
--- a/saft/flashrom_handler.py
+++ b/saft/flashrom_handler.py
@@ -39,7 +39,6 @@ class FlashromHandler(object):
def __init__(self):
# make sure it does not accidentally overwrite the image.
self.fum = None
- self.bios_layout = None
self.chros_if = None
self.image = ''
self.pub_key_file = ''
@@ -77,18 +76,14 @@ class FlashromHandler(object):
if image_file:
self.image = open(image_file, 'rb').read()
+ self.fum.set_bios_layout(image_file)
else:
self.image = self.fum.read_whole()
- self.bios_layout = self.fum.detect_chromeos_layout('bios',
- len(self.image))
- self.whole_flash_layout = self.fum.detect_layout('all',
- len(self.image))
for section in self.fv_sections.itervalues():
for subsection_name in section.names():
f = open(self.chros_if.state_dir_file(subsection_name), 'wb')
- f.write(self.fum.get_section(self.image,
- self.bios_layout, subsection_name))
+ f.write(self.fum.get_section(self.image, subsection_name))
f.close()
if not self.pub_key_file:
@@ -100,8 +95,7 @@ class FlashromHandler(object):
gbb_header_format = '<4s20s2I'
pubk_header_format = '<2Q'
- gbb_section = self.fum.get_section(
- self.image, self.bios_layout, 'FV_GBB')
+ gbb_section = self.fum.get_section(self.image, 'FV_GBB')
# do some sanity checks
try:
@@ -171,14 +165,13 @@ class FlashromHandler(object):
# Get the appropriate section of the image.
subsection_name = self.fv_sections[section].body_name
- body = self.fum.get_section(self.image, self.bios_layout,
- subsection_name)
+ body = self.fum.get_section(self.image, subsection_name)
# Modify the byte in it within 5% of the section body.
index = len(body) / 20
body_list = list(body)
body_list[index] = '%c' % ((ord(body[index]) + delta) % 0x100)
- self.image = self.fum.put_section(self.image, self.bios_layout,
+ self.image = self.fum.put_section(self.image,
subsection_name, ''.join(body_list))
return subsection_name
@@ -196,15 +189,13 @@ class FlashromHandler(object):
'''Corrupt a section in the FLASHROM!!!'''
subsection_name = self.corrupt_section(section)
- self.fum.write_partial(self.image, self.bios_layout,
- (subsection_name, ))
+ self.fum.write_partial(self.image, (subsection_name, ))
def restore_firmware(self, section):
'''Restore the previously corrupted section in the FLASHROM!!!'''
subsection_name = self.restore_section(section)
- self.fum.write_partial(self.image, self.bios_layout,
- (subsection_name, ))
+ self.fum.write_partial(self.image, (subsection_name, ))
def write_whole(self):
'''Write the whole image into the flashrom.'''
@@ -212,7 +203,7 @@ class FlashromHandler(object):
if not self.image:
raise FlashromHandlerError(
'Attempt at using an uninitialized object')
- self.fum.write_partial(self.image, self.whole_flash_layout, ('all', ))
+ self.fum.write_whole(self.image)
def dump_whole(self, filename):
'''Write the whole image into a file.'''
« no previous file with comments | « no previous file | saft/saft_utility.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698