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

Side by Side Diff: utility/pack_firmware_image

Issue 6799009: Add EntryWiped to pack_firmware_image (Closed) Base URL: ssh://gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python2.6 1 #!/usr/bin/env python2.6
2 2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import os 7 import os
8 import re 8 import re
9 import struct 9 import struct
10 import subprocess 10 import subprocess
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 class EntryFmapArea(Entry): 117 class EntryFmapArea(Entry):
118 118
119 def __init__(self, **kwargs): 119 def __init__(self, **kwargs):
120 Entry._CheckFields(kwargs, ('flags',)) 120 Entry._CheckFields(kwargs, ('flags',))
121 super(EntryFmapArea, self).__init__(**kwargs) 121 super(EntryFmapArea, self).__init__(**kwargs)
122 122
123 def Pack(self, firmware_image, entries): 123 def Pack(self, firmware_image, entries):
124 pass 124 pass
125 125
126 126
127 class EntryWiped(EntryFmapArea):
128
129 def __init__(self, **kwargs):
130 Entry._CheckFields(kwargs, ('wipe_value',))
131 super(EntryWiped, self).__init__(**kwargs)
132 if type(self.wipe_value) is int:
133 try:
134 self.wipe_value = chr(self.wipe_value)
135 except ValueError as e:
136 raise PackError('cannot convert wipe_value to a character: %s' % str(e))
137 elif type(self.wipe_value) is str:
138 if len(self.wipe_value) != 1:
139 raise PackError('wipe_value out of range [00:ff]: %s' %
140 repr(self.wipe_value))
141 else:
142 raise PackError('wipe_value is neither int nor str: %s' %
143 repr(self.wipe_value))
144
145 def Pack(self, firmware_image, entries):
146 firmware_image.seek(self.offset)
147 firmware_image.write(self.wipe_value * self.length)
148
149
127 class EntryBlob(EntryFmapArea): 150 class EntryBlob(EntryFmapArea):
128 151
129 def __init__(self, **kwargs): 152 def __init__(self, **kwargs):
130 Entry._CheckFields(kwargs, ('path',)) 153 Entry._CheckFields(kwargs, ('path',))
131 super(EntryBlob, self).__init__(**kwargs) 154 super(EntryBlob, self).__init__(**kwargs)
132 155
133 def Pack(self, firmware_image, entries): 156 def Pack(self, firmware_image, entries):
134 size = os.stat(self.path).st_size 157 size = os.stat(self.path).st_size
135 if size > self.length: 158 if size > self.length:
136 raise PackError('blob too large: %s: %d > %d' % 159 raise PackError('blob too large: %s: %d > %d' %
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 raise ConfigError('undefined variable: %s' % varname) 287 raise ConfigError('undefined variable: %s' % varname)
265 _Info('%s = %s' % (varname, repr(env[varname]))) 288 _Info('%s = %s' % (varname, repr(env[varname])))
266 289
267 pack_firmware_image(env['ENTRIES'], env['OUTPUT'], env['SIZE']) 290 pack_firmware_image(env['ENTRIES'], env['OUTPUT'], env['SIZE'])
268 291
269 sys.exit(0) 292 sys.exit(0)
270 293
271 294
272 if __name__ == '__main__': 295 if __name__ == '__main__':
273 main() 296 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698