blob: caeaca8a4f52d1a0aa42148088f0f07f1133f450 [file] [log] [blame]
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -07001# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -07002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -07005"""Code to provide functions for FAFT tests.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -07006
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -07007These can be exposed via a xmlrpci server running on the DUT.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -07008"""
9
Tom Wai-Hong Tam9434b142015-08-05 02:35:49 +080010import functools, os, tempfile
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070011
Yusuf Mohsinallycd108da2013-08-12 14:06:12 -070012import common
Tom Wai-Hong Tam533eed72015-07-31 07:37:27 +080013from autotest_lib.client.cros.faft.utils import (cgpt_handler,
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +080014 os_interface,
David Sodman3ad51642015-01-22 11:15:33 -080015 firmware_check_keys,
Yusuf Mohsinallycd108da2013-08-12 14:06:12 -070016 firmware_updater,
17 flashrom_handler,
18 kernel_handler,
Vic (Chun-Ju) Yang4edbc072014-02-11 14:40:57 +080019 rootfs_handler,
Yusuf Mohsinallycd108da2013-08-12 14:06:12 -070020 saft_flashrom_util,
21 tpm_handler,
22 )
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070023
24
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +080025def allow_multiple_section_input(image_operator):
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080026 """Decorate a method to support multiple sections.
27
28 @param image_operator: Method accepting one section as its argument.
29 """
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +080030 @functools.wraps(image_operator)
31 def wrapper(self, section):
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080032 """Wrapper method to support multiple sections.
33
34 @param section: A list of sections of just a section.
35 """
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +080036 if type(section) in (tuple, list):
37 for sec in section:
38 image_operator(self, sec)
39 else:
40 image_operator(self, section)
41 return wrapper
42
43
Vic Yang13d22ec2012-06-18 15:12:47 +080044class LazyFlashromHandlerProxy:
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080045 """Proxy of FlashromHandler for lazy initialization."""
Vic Yang13d22ec2012-06-18 15:12:47 +080046 _loaded = False
47 _obj = None
48
49 def __init__(self, *args, **kargs):
50 self._args = args
51 self._kargs = kargs
52
53 def _load(self):
54 self._obj = flashrom_handler.FlashromHandler()
55 self._obj.init(*self._args, **self._kargs)
56 self._obj.new_image()
57 self._loaded = True
58
59 def __getattr__(self, name):
60 if not self._loaded:
61 self._load()
62 return getattr(self._obj, name)
63
Tom Wai-Hong Tamc1c4deb2012-07-26 14:28:11 +080064 def reload(self):
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +080065 """Reload the FlashromHandler class."""
Tom Wai-Hong Tamc1c4deb2012-07-26 14:28:11 +080066 self._loaded = False
67
Vic Yang13d22ec2012-06-18 15:12:47 +080068
Yusuf Mohsinallyf4664222013-08-14 12:59:16 -070069class RPCFunctions(object):
70 """A class which aggregates some useful functions for firmware testing.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070071
72 This class can be exposed via a XMLRPC server such that its functions can
Chun-ting Changd43aa9b2012-11-16 10:12:05 +080073 be accessed remotely. Method naming should fit the naming rule
74 '_[categories]_[method_name]' where categories contains system, ec, bios,
75 kernel, cgpt, tpm, updater, etc. Methods should be called by
76 'FAFTClient.[categories].[method_name]', because _dispatch will rename
77 this name to '_[categories]_[method_name]'.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070078
79 Attributes:
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +080080 _os_if: An object to encapsulate OS services functions.
Vic Yang59cac9c2012-05-21 15:28:42 +080081 _bios_handler: An object to automate BIOS flashrom testing.
82 _ec_handler: An object to automate EC flashrom testing.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070083 _kernel_handler: An object to provide kernel related actions.
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +080084 _log_file: Path of the log file.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070085 _tpm_handler: An object to control TPM device.
Chun-ting Changcf924e92012-10-29 13:49:01 +080086 _updater: An object to update firmware.
ctchangc7e55ea2012-08-09 16:19:14 +080087 _temp_path: Path of a temp directory.
88 _keys_path: Path of a directory, keys/, in temp directory.
89 _work_path: Path of a directory, work/, in temp directory.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070090 """
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070091 def __init__(self):
92 """Initialize the data attributes of this class."""
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070093 # TODO(waihong): Move the explicit object.init() methods to the
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +080094 # objects' constructors (OSInterface, FlashromHandler,
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -070095 # KernelHandler, and TpmHandler).
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +080096 self._os_if = os_interface.OSInterface()
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +080097 # We keep the state of FAFT test in a permanent directory over reboots.
Tom Wai-Hong Tam07278c22012-02-08 16:53:00 +080098 state_dir = '/var/tmp/faft'
Tom Wai-Hong Tam6db59cb2015-07-21 08:11:23 +080099 self._log_file = os.path.join(state_dir, 'faft_client.log')
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800100 self._os_if.init(state_dir, log_file=self._log_file)
danny chan6dc580a2015-08-08 00:14:02 +0000101 os.chdir(state_dir)
Tom Wai-Hong Tam6db59cb2015-07-21 08:11:23 +0800102
Vic Yang13d22ec2012-06-18 15:12:47 +0800103 self._bios_handler = LazyFlashromHandlerProxy(
104 saft_flashrom_util,
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800105 self._os_if,
Vic Yang59cac9c2012-05-21 15:28:42 +0800106 None,
107 '/usr/share/vboot/devkeys',
108 'bios')
Vic Yang59cac9c2012-05-21 15:28:42 +0800109
Todd Brochf2b1d012012-06-14 12:55:21 -0700110 self._ec_handler = None
Tom Wai-Hong Tam38aa5482015-08-01 05:31:07 +0800111 if self._os_if.run_shell_command_get_status('mosys ec info') == 0:
Vic Yang13d22ec2012-06-18 15:12:47 +0800112 self._ec_handler = LazyFlashromHandlerProxy(
113 saft_flashrom_util,
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800114 self._os_if,
Vic Yang13d22ec2012-06-18 15:12:47 +0800115 'ec_root_key.vpubk',
Todd Brochf2b1d012012-06-14 12:55:21 -0700116 '/usr/share/vboot/devkeys',
117 'ec')
Tom Wai-Hong Tam38aa5482015-08-01 05:31:07 +0800118 else:
119 self._os_if.log('No EC is reported by mosys.')
Todd Brochf2b1d012012-06-14 12:55:21 -0700120
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700121 self._kernel_handler = kernel_handler.KernelHandler()
Tom Wai-Hong Tam9434b142015-08-05 02:35:49 +0800122 self._kernel_handler.init(self._os_if,
123 dev_key_path='/usr/share/vboot/devkeys',
124 internal_disk=True)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700125
Tom Wai-Hong Tama0265e32015-08-06 01:50:47 +0800126 # FIXME(waihong): Add back the TPM support.
127 if not self._os_if.is_android:
128 self._tpm_handler = tpm_handler.TpmHandler()
129 self._tpm_handler.init(self._os_if)
130 else:
131 self._tpm_handler = None
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700132
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800133 self._cgpt_handler = cgpt_handler.CgptHandler(self._os_if)
Tom Wai-Hong Tam48958832011-12-30 10:16:57 +0800134
Vic (Chun-Ju) Yang4edbc072014-02-11 14:40:57 +0800135 self._rootfs_handler = rootfs_handler.RootfsHandler()
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800136 self._rootfs_handler.init(self._os_if)
Vic (Chun-Ju) Yang4edbc072014-02-11 14:40:57 +0800137
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800138 self._updater = firmware_updater.FirmwareUpdater(self._os_if)
David Sodman3ad51642015-01-22 11:15:33 -0800139 self._check_keys = firmware_check_keys.firmwareCheckKeys()
Chun-ting Changcf924e92012-10-29 13:49:01 +0800140
ctchangc7e55ea2012-08-09 16:19:14 +0800141 # Initialize temporary directory path
142 self._temp_path = '/var/tmp/faft/autest'
143 self._keys_path = os.path.join(self._temp_path, 'keys')
144 self._work_path = os.path.join(self._temp_path, 'work')
145
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800146 def _dispatch(self, method, params):
147 """This _dispatch method handles string conversion especially.
148
149 Since we turn off allow_dotted_names option. So any string conversion,
150 like str(FAFTClient.method), i.e. FAFTClient.method.__str__, failed
151 via XML RPC call.
152 """
153 is_str = method.endswith('.__str__')
154 if is_str:
155 method = method.rsplit('.', 1)[0]
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800156
157 categories = ('system', 'bios', 'ec', 'kernel',
Vic (Chun-Ju) Yang4edbc072014-02-11 14:40:57 +0800158 'tpm', 'cgpt', 'updater', 'rootfs')
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800159 try:
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800160 if method.split('.', 1)[0] in categories:
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800161 func = getattr(self, '_%s_%s' % (method.split('.', 1)[0],
162 method.split('.', 1)[1]))
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800163 else:
164 func = getattr(self, method)
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800165 except AttributeError:
166 raise Exception('method "%s" is not supported' % method)
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800167
168 if is_str:
169 return str(func)
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800170 else:
Tom Wai-Hong Tam38aa5482015-08-01 05:31:07 +0800171 self._os_if.log('Dispatching method %s with args %r' %
172 (func.__name__, params))
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800173 return func(*params)
Tom Wai-Hong Tame8f291a2011-12-08 22:03:53 +0800174
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800175 def _system_is_available(self):
Tom Wai-Hong Tambea57b32011-09-02 18:27:47 +0800176 """Function for polling the RPC server availability.
177
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800178 @return: Always True.
Tom Wai-Hong Tambea57b32011-09-02 18:27:47 +0800179 """
180 return True
181
Tom Wai-Hong Tam3dbc70a2015-08-20 06:39:08 +0800182 def _system_wait_for_client(self, timeout):
183 """Wait for the client to come back online.
184
185 @param timeout: Time in seconds to wait for the client SSH daemon to
186 come up.
187 @return: True if succeed; otherwise False.
188 """
189 return self._os_if.wait_for_device(timeout)
190
191 def _system_wait_for_client_offline(self, timeout):
192 """Wait for the client to come offline.
193
194 @param timeout: Time in seconds to wait the client to come offline.
195 @return: True if succeed; otherwise False.
196 """
197 return self._os_if.wait_for_no_device(timeout)
198
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +0800199 def _system_dump_log(self, remove_log=False):
200 """Dump the log file.
201
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800202 @param remove_log: Remove the log file after dump.
203 @return: String of the log file content.
Tom Wai-Hong Tam48ae2212013-06-26 10:37:40 +0800204 """
205 log = open(self._log_file).read()
206 if remove_log:
207 os.remove(self._log_file)
208 return log
209
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800210 def _system_run_shell_command(self, command):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700211 """Run shell command.
212
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800213 @param command: A shell command to be run.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700214 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800215 self._os_if.run_shell_command(command)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700216
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800217 def _system_run_shell_command_get_output(self, command):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700218 """Run shell command and get its console output.
219
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800220 @param command: A shell command to be run.
221 @return: A list of strings stripped of the newline characters.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700222 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800223 return self._os_if.run_shell_command_get_output(command)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700224
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800225 def _system_software_reboot(self):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700226 """Request software reboot."""
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800227 self._os_if.run_shell_command('reboot')
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700228
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800229 def _system_get_platform_name(self):
Tom Wai-Hong Tam678ab152011-12-14 15:27:24 +0800230 """Get the platform name of the current system.
231
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800232 @return: A string of the platform name.
Tom Wai-Hong Tam678ab152011-12-14 15:27:24 +0800233 """
Vic Yang2bbb8672012-11-12 12:14:53 +0800234 # 'mosys platform name' sometimes fails. Let's get the verbose output.
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800235 lines = self._os_if.run_shell_command_get_output(
Vic Yang2bbb8672012-11-12 12:14:53 +0800236 '(mosys -vvv platform name 2>&1) || echo Failed')
237 if lines[-1].strip() == 'Failed':
238 raise Exception('Failed getting platform name: ' + '\n'.join(lines))
239 return lines[-1]
Tom Wai-Hong Tam678ab152011-12-14 15:27:24 +0800240
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800241 def _system_get_crossystem_value(self, key):
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700242 """Get crossystem value of the requested key.
243
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800244 @param key: A crossystem key.
245 @return: A string of the requested crossystem value.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700246 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800247 return self._os_if.run_shell_command_get_output(
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700248 'crossystem %s' % key)[0]
249
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800250 def _system_get_root_dev(self):
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800251 """Get the name of root device without partition number.
252
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800253 @return: A string of the root device without partition number.
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800254 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800255 return self._os_if.get_root_dev()
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800256
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800257 def _system_get_root_part(self):
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800258 """Get the name of root device with partition number.
259
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800260 @return: A string of the root device with partition number.
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800261 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800262 return self._os_if.get_root_part()
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800263
Shelley Chen3edea982014-12-30 14:54:21 -0800264 def _system_set_try_fw_b(self, count=1):
265 """Set 'Try Frimware B' flag in crossystem.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700266
Shelley Chen3edea982014-12-30 14:54:21 -0800267 @param count: # times to try booting into FW B
268 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800269 self._os_if.cs.fwb_tries = count
Shelley Chen3edea982014-12-30 14:54:21 -0800270
271 def _system_set_fw_try_next(self, next, count=0):
272 """Set fw_try_next to A or B
273
274 @param next: Next FW to reboot to (A or B)
275 @param count: # of times to try booting into FW <next>
276 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800277 self._os_if.cs.fw_try_next = next
Shelley Chen3edea982014-12-30 14:54:21 -0800278 if count:
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800279 self._os_if.cs.fw_try_count = count
Daisuke Nojiri57c05982014-06-25 15:28:35 -0700280
281 def _system_get_fw_vboot2(self):
282 """Get fw_vboot2"""
Tom Wai-Hong Tam94886f92014-07-10 07:01:43 +0800283 try:
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800284 return self._os_if.cs.fw_vboot2 == '1'
285 except os_interface.OSInterfaceError:
Tom Wai-Hong Tam94886f92014-07-10 07:01:43 +0800286 return False
Daisuke Nojiri57c05982014-06-25 15:28:35 -0700287
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800288 def _system_request_recovery_boot(self):
Tom Wai-Hong Tam76c75072011-10-25 18:00:12 +0800289 """Request running in recovery mode on the restart."""
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800290 self._os_if.cs.request_recovery()
Tom Wai-Hong Tam76c75072011-10-25 18:00:12 +0800291
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800292 def _system_get_dev_boot_usb(self):
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800293 """Get dev_boot_usb value which controls developer mode boot from USB.
294
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800295 @return: True if enable, False if disable.
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800296 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800297 return self._os_if.cs.dev_boot_usb == '1'
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800298
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800299 def _system_set_dev_boot_usb(self, value):
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800300 """Set dev_boot_usb value which controls developer mode boot from USB.
301
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800302 @param value: True to enable, False to disable.
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800303 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800304 self._os_if.cs.dev_boot_usb = 1 if value else 0
Tom Wai-Hong Tam0a7b2be2012-10-15 16:44:12 +0800305
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800306 def _system_is_removable_device_boot(self):
307 """Check the current boot device is removable.
308
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800309 @return: True: if a removable device boots.
310 False: if a non-removable device boots.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800311 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800312 root_part = self._os_if.get_root_part()
313 return self._os_if.is_removable_device(root_part)
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800314
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800315 def _system_create_temp_dir(self, prefix='backup_'):
316 """Create a temporary directory and return the path."""
317 return tempfile.mkdtemp(prefix=prefix)
318
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800319 def _bios_reload(self):
320 """Reload the firmware image that may be changed."""
321 self._bios_handler.reload()
322
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800323 def _bios_get_gbb_flags(self):
Tom Wai-Hong Tam8c9eed62011-12-28 15:05:05 +0800324 """Get the GBB flags.
325
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800326 @return: An integer of the GBB flags.
Tom Wai-Hong Tam8c9eed62011-12-28 15:05:05 +0800327 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800328 return self._bios_handler.get_gbb_flags()
Tom Wai-Hong Tam8c9eed62011-12-28 15:05:05 +0800329
Tom Wai-Hong Tam0d2b8932015-08-27 06:22:50 +0800330 def _bios_set_gbb_flags(self, flags):
331 """Set the GBB flags.
332
333 @param flags: An integer of the GBB flags.
334 """
335 self._bios_handler.set_gbb_flags(flags, write_through=True)
336
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800337 def _bios_get_preamble_flags(self, section):
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800338 """Get the preamble flags of a firmware section.
339
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800340 @param section: A firmware section, either 'a' or 'b'.
341 @return: An integer of the preamble flags.
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800342 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800343 return self._bios_handler.get_section_flags(section)
344
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800345 def _bios_set_preamble_flags(self, section, flags):
Vic Yang91b73cf2012-07-31 17:18:11 +0800346 """Set the preamble flags of a firmware section.
347
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800348 @param section: A firmware section, either 'a' or 'b'.
349 @param flags: An integer of preamble flags.
Vic Yang91b73cf2012-07-31 17:18:11 +0800350 """
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800351 version = self._bios_get_version(section)
Vic Yang91b73cf2012-07-31 17:18:11 +0800352 self._bios_handler.set_section_version(section, version, flags,
353 write_through=True)
354
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800355 def _bios_get_body_sha(self, section):
Tom Wai-Hong Tam4e10b9f2012-09-06 16:23:02 +0800356 """Get SHA1 hash of BIOS RW firmware section.
357
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800358 @param section: A firmware section, either 'a' or 'b'.
359 @param flags: An integer of preamble flags.
Tom Wai-Hong Tam4e10b9f2012-09-06 16:23:02 +0800360 """
361 return self._bios_handler.get_section_sha(section)
362
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800363 def _bios_get_sig_sha(self, section):
ctchang38ae4922012-09-03 17:01:16 +0800364 """Get SHA1 hash of firmware vblock in section."""
365 return self._bios_handler.get_section_sig_sha(section)
366
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +0800367 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800368 def _bios_corrupt_sig(self, section):
Tom Wai-Hong Tam9aea8212011-12-12 15:08:45 +0800369 """Corrupt the requested firmware section signature.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700370
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800371 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700372 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800373 self._bios_handler.corrupt_firmware(section)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700374
Tom Wai-Hong Tam0e680af2011-10-26 14:32:55 +0800375 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800376 def _bios_restore_sig(self, section):
Tom Wai-Hong Tam9aea8212011-12-12 15:08:45 +0800377 """Restore the previously corrupted firmware section signature.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700378
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800379 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700380 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800381 self._bios_handler.restore_firmware(section)
Tom Wai-Hong Tamb8a58ef2011-10-11 23:53:10 -0700382
Tom Wai-Hong Tamcfda61f2011-11-02 17:41:01 +0800383 @allow_multiple_section_input
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800384 def _bios_corrupt_body(self, section):
385 """Corrupt the requested firmware section body.
386
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800387 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800388 """
389 self._bios_handler.corrupt_firmware_body(section)
390
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800391 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800392 def _bios_restore_body(self, section):
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800393 """Restore the previously corrupted firmware section body.
394
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800395 @param section: A firmware section, either 'a' or 'b'.
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800396 """
Vic Yang59cac9c2012-05-21 15:28:42 +0800397 self._bios_handler.restore_firmware_body(section)
Tom Wai-Hong Tam81f70002011-12-13 12:29:46 +0800398
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800399 def __bios_modify_version(self, section, delta):
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800400 """Modify firmware version for the requested section, by adding delta.
401
402 The passed in delta, a positive or a negative number, is added to the
403 original firmware version.
404 """
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800405 original_version = self._bios_get_version(section)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800406 new_version = original_version + delta
Vic Yang59cac9c2012-05-21 15:28:42 +0800407 flags = self._bios_handler.get_section_flags(section)
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800408 self._os_if.log(
danny chan6dc580a2015-08-08 00:14:02 +0000409 'Setting firmware section %s version from %d to %d' % (
410 section, original_version, new_version))
Vic Yang59cac9c2012-05-21 15:28:42 +0800411 self._bios_handler.set_section_version(section, new_version, flags,
412 write_through=True)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800413
414 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800415 def _bios_move_version_backward(self, section):
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800416 """Decrement firmware version for the requested section."""
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800417 self.__bios_modify_version(section, -1)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800418
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800419 @allow_multiple_section_input
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800420 def _bios_move_version_forward(self, section):
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800421 """Increase firmware version for the requested section."""
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800422 self.__bios_modify_version(section, 1)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800423
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800424 def _bios_get_version(self, section):
425 """Retrieve firmware version of a section."""
426 return self._bios_handler.get_section_version(section)
427
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800428 def _bios_get_datakey_version(self, section):
ctchangc7e55ea2012-08-09 16:19:14 +0800429 """Return firmware data key version."""
430 return self._bios_handler.get_section_datakey_version(section)
431
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800432 def _bios_get_kernel_subkey_version(self, section):
ctchangc7e55ea2012-08-09 16:19:14 +0800433 """Return kernel subkey version."""
434 return self._bios_handler.get_section_kernel_subkey_version(section)
Tom Wai-Hong Tam46d03b12012-02-08 12:02:17 +0800435
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800436 def _bios_dump_whole(self, bios_path):
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800437 """Dump the current BIOS firmware to a file, specified by bios_path.
438
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800439 @param bios_path: The path of the BIOS image to be written.
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800440 """
441 self._bios_handler.dump_whole(bios_path)
442
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800443 def _bios_write_whole(self, bios_path):
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800444 """Write the firmware from bios_path to the current system.
445
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800446 @param bios_path: The path of the source BIOS image.
Tom Wai-Hong Tamb63bc742012-08-30 20:41:30 +0800447 """
448 self._bios_handler.new_image(bios_path)
449 self._bios_handler.write_whole()
450
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800451 def _ec_get_version(self):
452 """Get EC version via mosys.
453
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800454 @return: A string of the EC version.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800455 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800456 return self._os_if.run_shell_command_get_output(
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800457 'mosys ec info | sed "s/.*| //"')[0]
458
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800459 def _ec_get_firmware_sha(self):
460 """Get SHA1 hash of EC RW firmware section."""
461 return self._ec_handler.get_section_sha('rw')
462
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800463 @allow_multiple_section_input
464 def _ec_corrupt_sig(self, section):
465 """Corrupt the requested EC section signature.
466
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800467 @param section: A EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800468 """
469 self._ec_handler.corrupt_firmware(section, corrupt_all=True)
470
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800471 @allow_multiple_section_input
472 def _ec_restore_sig(self, section):
473 """Restore the previously corrupted EC section signature.
474
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800475 @param section: An EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800476 """
477 self._ec_handler.restore_firmware(section, restore_all=True)
478
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800479 @allow_multiple_section_input
480 def _ec_corrupt_body(self, section):
481 """Corrupt the requested EC section body.
482
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800483 @param section: An EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800484 """
485 self._ec_handler.corrupt_firmware_body(section, corrupt_all=True)
486
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800487 @allow_multiple_section_input
488 def _ec_restore_body(self, section):
489 """Restore the previously corrupted EC section body.
490
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800491 @param section: An EC section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800492 """
493 self._ec_handler.restore_firmware_body(section, restore_all=True)
494
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800495 def _ec_dump_firmware(self, ec_path):
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800496 """Dump the current EC firmware to a file, specified by ec_path.
497
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800498 @param ec_path: The path of the EC image to be written.
Tom Wai-Hong Tam23870e02012-08-24 16:15:34 +0800499 """
500 self._ec_handler.dump_whole(ec_path)
501
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800502 def _ec_set_write_protect(self, enable):
Tom Wai-Hong Tam44204b32012-11-20 13:55:40 +0800503 """Enable write protect of the EC flash chip.
504
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800505 @param enable: True if activating EC write protect. Otherwise, False.
Tom Wai-Hong Tam44204b32012-11-20 13:55:40 +0800506 """
Tom Wai-Hong Tam44204b32012-11-20 13:55:40 +0800507 if enable:
508 self._ec_handler.enable_write_protect()
509 else:
510 self._ec_handler.disable_write_protect()
511
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800512 @allow_multiple_section_input
513 def _kernel_corrupt_sig(self, section):
514 """Corrupt the requested kernel section.
515
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800516 @param section: A kernel section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800517 """
518 self._kernel_handler.corrupt_kernel(section)
519
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800520 @allow_multiple_section_input
521 def _kernel_restore_sig(self, section):
522 """Restore the requested kernel section (previously corrupted).
523
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800524 @param section: A kernel section, either 'a' or 'b'.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800525 """
526 self._kernel_handler.restore_kernel(section)
527
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800528 def __kernel_modify_version(self, section, delta):
529 """Modify kernel version for the requested section, by adding delta.
530
531 The passed in delta, a positive or a negative number, is added to the
532 original kernel version.
533 """
534 original_version = self._kernel_handler.get_version(section)
535 new_version = original_version + delta
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800536 self._os_if.log(
danny chan6dc580a2015-08-08 00:14:02 +0000537 'Setting kernel section %s version from %d to %d' % (
538 section, original_version, new_version))
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800539 self._kernel_handler.set_version(section, new_version)
540
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800541 @allow_multiple_section_input
542 def _kernel_move_version_backward(self, section):
543 """Decrement kernel version for the requested section."""
544 self.__kernel_modify_version(section, -1)
545
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800546 @allow_multiple_section_input
547 def _kernel_move_version_forward(self, section):
548 """Increase kernel version for the requested section."""
549 self.__kernel_modify_version(section, 1)
550
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800551 def _kernel_get_version(self, section):
552 """Return kernel version."""
553 return self._kernel_handler.get_version(section)
554
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800555 def _kernel_get_datakey_version(self, section):
556 """Return kernel datakey version."""
557 return self._kernel_handler.get_datakey_version(section)
558
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800559 def _kernel_diff_a_b(self):
560 """Compare kernel A with B.
561
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800562 @return: True: if kernel A is different with B.
563 False: if kernel A is the same as B.
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800564 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800565 rootdev = self._os_if.get_root_dev()
566 kernel_a = self._os_if.join_part(rootdev, '2')
567 kernel_b = self._os_if.join_part(rootdev, '4')
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800568
569 # The signature (some kind of hash) for the kernel body is stored in
570 # the beginning. So compare the first 64KB (including header, preamble,
571 # and signature) should be enough to check them identical.
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800572 header_a = self._os_if.read_partition(kernel_a, 0x10000)
573 header_b = self._os_if.read_partition(kernel_b, 0x10000)
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800574
575 return header_a != header_b
576
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800577 def _kernel_resign_with_keys(self, section, key_path=None):
578 """Resign kernel with temporary key."""
579 self._kernel_handler.resign_kernel(section, key_path)
580
Vic (Chun-Ju) Yang33ef9e02014-02-07 14:30:19 +0800581 def _kernel_dump(self, section, kernel_path):
582 """Dump the specified kernel to a file.
583
584 @param section: The kernel to dump. May be A or B.
585 @param kernel_path: The path to the kernel image to be written.
586 """
587 self._kernel_handler.dump_kernel(section, kernel_path)
588
589 def _kernel_write(self, section, kernel_path):
590 """Write a kernel image to the specified section.
591
592 @param section: The kernel to dump. May be A or B.
593 @param kernel_path: The path to the kernel image.
594 """
595 self._kernel_handler.write_kernel(section, kernel_path)
596
597 def _kernel_get_sha(self, section):
598 """Return the SHA1 hash of the specified kernel section."""
599 return self._kernel_handler.get_sha(section)
600
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800601 def _tpm_get_firmware_version(self):
602 """Retrieve tpm firmware body version."""
603 return self._tpm_handler.get_fw_version()
604
Tom Wai-Hong Tamc1a569f2012-12-04 15:07:25 +0800605 def _tpm_get_firmware_datakey_version(self):
606 """Retrieve tpm firmware data key version."""
607 return self._tpm_handler.get_fw_body_version()
608
Vic (Chun-Ju) Yang93932842014-02-07 20:01:28 +0800609 def _cgpt_get_attributes(self):
610 """Get kernel attributes."""
611 rootdev = self._system_get_root_dev()
612 self._cgpt_handler.read_device_info(rootdev)
613 return {'A': self._cgpt_handler.get_partition(rootdev, 'KERN-A'),
614 'B': self._cgpt_handler.get_partition(rootdev, 'KERN-B')}
615
616 def _cgpt_set_attributes(self, attributes):
617 """Set kernel attributes."""
618 rootdev = self._system_get_root_dev()
619 allowed = ['priority', 'tries', 'successful']
620 for p in ('A', 'B'):
621 if p not in attributes:
622 continue
623 attr = dict()
624 for k in allowed:
625 if k in attributes[p]:
626 attr[k] = attributes[p][k]
627 if attr:
628 self._cgpt_handler.set_partition(rootdev, 'KERN-%s' % p, attr)
629
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800630 def _updater_setup(self, shellball=None):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800631 """Setup the updater.
632
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800633 @param shellball: Path of provided shellball. Use default shellball
634 if None,
Chun-ting Changcf924e92012-10-29 13:49:01 +0800635 """
Tom Wai-Hong Tamba5e3e52015-08-01 05:54:00 +0800636 self._updater.setup(self._os_if, shellball)
Chun-ting Changcf924e92012-10-29 13:49:01 +0800637
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800638 def _updater_cleanup(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800639 self._updater.cleanup_temp_dir()
640
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800641 def _updater_get_fwid(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800642 """Retrieve shellball's fwid.
643
644 This method should be called after updater_setup.
645
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800646 @return: Shellball's fwid.
Chun-ting Changcf924e92012-10-29 13:49:01 +0800647 """
648 return self._updater.retrieve_fwid()
649
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800650 def _updater_resign_firmware(self, version):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800651 """Resign firmware with version.
652
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800653 @param version: new version number.
Chun-ting Changcf924e92012-10-29 13:49:01 +0800654 """
655 self._updater.resign_firmware(version)
656
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800657 def _updater_repack_shellball(self, append):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800658 """Repack shellball with new fwid.
659
Tom Wai-Hong Tam144202a2013-07-18 13:59:29 +0800660 @param append: use for new fwid naming.
Chun-ting Changcf924e92012-10-29 13:49:01 +0800661 """
662 self._updater.repack_shellball(append)
663
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800664 def _updater_run_autoupdate(self, append):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800665 """Run chromeos-firmwareupdate with autoupdate mode."""
666 options = ['--noupdate_ec', '--nocheck_rw_compatible']
667 self._updater.run_firmwareupdate(mode='autoupdate',
668 updater_append=append,
669 options=options)
670
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800671 def _updater_run_factory_install(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800672 """Run chromeos-firmwareupdate with factory_install mode."""
673 options = ['--noupdate_ec']
674 self._updater.run_firmwareupdate(mode='factory_install',
675 options=options)
676
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800677 def _updater_run_bootok(self, append):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800678 """Run chromeos-firmwareupdate with bootok mode."""
679 self._updater.run_firmwareupdate(mode='bootok',
680 updater_append=append)
681
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800682 def _updater_run_recovery(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800683 """Run chromeos-firmwareupdate with recovery mode."""
684 options = ['--noupdate_ec', '--nocheck_rw_compatible']
685 self._updater.run_firmwareupdate(mode='recovery',
686 options=options)
687
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800688 def _updater_get_temp_path(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800689 """Get updater's temp directory path."""
690 return self._updater.get_temp_path()
691
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800692 def _updater_get_keys_path(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800693 """Get updater's keys directory path."""
694 return self._updater.get_keys_path()
695
Chun-ting Changd43aa9b2012-11-16 10:12:05 +0800696 def _updater_get_work_path(self):
Chun-ting Changcf924e92012-10-29 13:49:01 +0800697 """Get updater's work directory path."""
698 return self._updater.get_work_path()
699
Vic (Chun-Ju) Yang4edbc072014-02-11 14:40:57 +0800700 def _rootfs_verify_rootfs(self, section):
701 """Verifies the integrity of the root FS.
702
703 @param section: The rootfs to verify. May be A or B.
704 """
705 return self._rootfs_handler.verify_rootfs(section)
706
David Sodman3ad51642015-01-22 11:15:33 -0800707 def _system_check_keys(self, expected_sequence):
708 """Check the keys sequence was as expected.
709
710 @param expected_sequence: A list of expected key sequences.
711 """
712 return self._check_keys.check_keys(expected_sequence)
713
Tom Wai-Hong Tambea57b32011-09-02 18:27:47 +0800714 def cleanup(self):
715 """Cleanup for the RPC server. Currently nothing."""
716 pass