faft: Move all constants of verified boot out to a module

It slims the FAFTSequence class and makes other non-FAFT tests reuse these
vboot constants.

BUG=chromium-os:32147
TEST=run the following tests passed:
run_remote_tests.sh --board link --remote dut control.faft_lv2
run_remote_tests.sh --board link --remote dut control.faft_lv3

Change-Id: I524d1ff2046e1e1826359c939f2d918426707141
Reviewed-on: https://gerrit.chromium.org/gerrit/34739
Reviewed-by: Mike Truty <truty@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Brian Harring <ferringb@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index 60e0f48..044d172 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -15,6 +15,7 @@
 
 from autotest_lib.client.bin import utils
 from autotest_lib.client.common_lib import error
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faft_client_attribute import FAFTClientAttribute
 from autotest_lib.server.cros.servo_test import ServoTest
 from autotest_lib.site_utils import lab_test
@@ -120,111 +121,6 @@
     CHROMEOS_MAGIC = "CHROMEOS"
     CORRUPTED_MAGIC = "CORRUPTD"
 
-    # Recovery reason codes, copied from:
-    #     vboot_reference/firmware/lib/vboot_nvstorage.h
-    #     vboot_reference/firmware/lib/vboot_struct.h
-    RECOVERY_REASON = {
-        # Recovery not requested
-        'NOT_REQUESTED':      '0',   # 0x00
-        # Recovery requested from legacy utility
-        'LEGACY':             '1',   # 0x01
-        # User manually requested recovery via recovery button
-        'RO_MANUAL':          '2',   # 0x02
-        # RW firmware failed signature check
-        'RO_INVALID_RW':      '3',   # 0x03
-        # S3 resume failed
-        'RO_S3_RESUME':       '4',   # 0x04
-        # TPM error in read-only firmware
-        'RO_TPM_ERROR':       '5',   # 0x05
-        # Shared data error in read-only firmware
-        'RO_SHARED_DATA':     '6',   # 0x06
-        # Test error from S3Resume()
-        'RO_TEST_S3':         '7',   # 0x07
-        # Test error from LoadFirmwareSetup()
-        'RO_TEST_LFS':        '8',   # 0x08
-        # Test error from LoadFirmware()
-        'RO_TEST_LF':         '9',   # 0x09
-        # RW firmware failed signature check
-        'RW_NOT_DONE':        '16',  # 0x10
-        'RW_DEV_MISMATCH':    '17',  # 0x11
-        'RW_REC_MISMATCH':    '18',  # 0x12
-        'RW_VERIFY_KEYBLOCK': '19',  # 0x13
-        'RW_KEY_ROLLBACK':    '20',  # 0x14
-        'RW_DATA_KEY_PARSE':  '21',  # 0x15
-        'RW_VERIFY_PREAMBLE': '22',  # 0x16
-        'RW_FW_ROLLBACK':     '23',  # 0x17
-        'RW_HEADER_VALID':    '24',  # 0x18
-        'RW_GET_FW_BODY':     '25',  # 0x19
-        'RW_HASH_WRONG_SIZE': '26',  # 0x1A
-        'RW_VERIFY_BODY':     '27',  # 0x1B
-        'RW_VALID':           '28',  # 0x1C
-        # Read-only normal path requested by firmware preamble, but
-        # unsupported by firmware.
-        'RW_NO_RO_NORMAL':    '29',  # 0x1D
-        # Firmware boot failure outside of verified boot
-        'RO_FIRMWARE':        '32',  # 0x20
-        # Recovery mode TPM initialization requires a system reboot.
-        # The system was already in recovery mode for some other reason
-        # when this happened.
-        'RO_TPM_REBOOT':      '33',  # 0x21
-        # Unspecified/unknown error in read-only firmware
-        'RO_UNSPECIFIED':     '63',  # 0x3F
-        # User manually requested recovery by pressing a key at developer
-        # warning screen.
-        'RW_DEV_SCREEN':      '65',  # 0x41
-        # No OS kernel detected
-        'RW_NO_OS':           '66',  # 0x42
-        # OS kernel failed signature check
-        'RW_INVALID_OS':      '67',  # 0x43
-        # TPM error in rewritable firmware
-        'RW_TPM_ERROR':       '68',  # 0x44
-        # RW firmware in dev mode, but dev switch is off.
-        'RW_DEV_MISMATCH':    '69',  # 0x45
-        # Shared data error in rewritable firmware
-        'RW_SHARED_DATA':     '70',  # 0x46
-        # Test error from LoadKernel()
-        'RW_TEST_LK':         '71',  # 0x47
-        # No bootable disk found
-        'RW_NO_DISK':         '72',  # 0x48
-        # Unspecified/unknown error in rewritable firmware
-        'RW_UNSPECIFIED':     '127', # 0x7F
-        # DM-verity error
-        'KE_DM_VERITY':       '129', # 0x81
-        # Unspecified/unknown error in kernel
-        'KE_UNSPECIFIED':     '191', # 0xBF
-        # Recovery mode test from user-mode
-        'US_TEST':            '193', # 0xC1
-        # Unspecified/unknown error in user-mode
-        'US_UNSPECIFIED':     '255', # 0xFF
-    }
-
-    # GBB flags
-    GBB_FLAG_DEV_SCREEN_SHORT_DELAY    = 0x00000001
-    GBB_FLAG_LOAD_OPTION_ROMS          = 0x00000002
-    GBB_FLAG_ENABLE_ALTERNATE_OS       = 0x00000004
-    GBB_FLAG_FORCE_DEV_SWITCH_ON       = 0x00000008
-    GBB_FLAG_FORCE_DEV_BOOT_USB        = 0x00000010
-    GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK = 0x00000020
-    GBB_FLAG_ENTER_TRIGGERS_TONORM     = 0x00000040
-
-    # VbSharedData flags
-    # Copied from vboot_reference/firmware/include/vboot_struct.h
-    VDAT_FLAG_FWB_TRIED                = 0x00000001
-    VDAT_FLAG_KERNEL_KEY_VERIFIED      = 0x00000002
-    VDAT_FLAG_LF_DEV_SWITCH_ON         = 0x00000004
-    VDAT_FLAG_LF_USE_RO_NORMAL         = 0x00000008
-    VDAT_FLAG_BOOT_DEV_SWITCH_ON       = 0x00000010
-    VDAT_FLAG_BOOT_REC_SWITCH_ON       = 0x00000020
-    VDAT_FLAG_BOOT_FIRMWARE_WP_ENABLED = 0x00000040
-    VDAT_FLAG_BOOT_S3_RESUME           = 0x00000100
-    VDAT_FLAG_BOOT_RO_NORMAL_SUPPORT   = 0x00000200
-    VDAT_FLAG_HONOR_VIRT_DEV_SWITCH    = 0x00000400
-    VDAT_FLAG_EC_SOFTWARE_SYNC         = 0x00000800
-    VDAT_FLAG_EC_SLOW_UPDATE           = 0x00001000
-
-    # Firmware preamble flags
-    PREAMBLE_USE_RO_NORMAL             = 0x00000001
-
     _faft_template = {}
     _faft_sequence = ()
 
@@ -297,9 +193,9 @@
             'reboot_action': (self.sync_and_warm_reboot),
             'firmware_action': (None)
         })
-        self.clear_set_gbb_flags(self.GBB_FLAG_FORCE_DEV_SWITCH_ON |
-                                 self.GBB_FLAG_DEV_SCREEN_SHORT_DELAY,
-                                 self.GBB_FLAG_ENTER_TRIGGERS_TONORM)
+        self.clear_set_gbb_flags(vboot.GBB_FLAG_FORCE_DEV_SWITCH_ON |
+                                 vboot.GBB_FLAG_DEV_SCREEN_SHORT_DELAY,
+                                 vboot.GBB_FLAG_ENTER_TRIGGERS_TONORM)
         if self._install_image_path:
             self.install_test_image(self._install_image_path,
                                     self._firmware_update)
@@ -473,7 +369,7 @@
             {   # Step 2, expected recovery boot
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason' : self.RECOVERY_REASON['US_TEST'],
+                    'recovery_reason' : vboot.RECOVERY_REASON['US_TEST'],
                 }),
                 'userspace_action': (self.faft_client.run_shell_command,
                                      install_cmd),
@@ -508,7 +404,7 @@
                     '/usr/share/vboot/bin/set_gbb_flags.sh 0x%x' % new_flags)
             self.faft_client.reload_firmware()
             # If changing FORCE_DEV_SWITCH_ON flag, reboot to get a clear state
-            if ((gbb_flags ^ new_flags) & self.GBB_FLAG_FORCE_DEV_SWITCH_ON):
+            if ((gbb_flags ^ new_flags) & vboot.GBB_FLAG_FORCE_DEV_SWITCH_ON):
                 self.run_faft_step({
                     'firmware_action': self.wait_fw_screen_and_ctrl_d,
                 })
@@ -756,8 +652,8 @@
             crossystem_dict['ecfw_act'] = ('RW' if twostop else 'RO')
 
         return (self.vdat_flags_checker(
-                    self.VDAT_FLAG_LF_USE_RO_NORMAL,
-                    0 if twostop else self.VDAT_FLAG_LF_USE_RO_NORMAL) and
+                    vboot.VDAT_FLAG_LF_USE_RO_NORMAL,
+                    0 if twostop else vboot.VDAT_FLAG_LF_USE_RO_NORMAL) and
                 self.crossystem_checker(crossystem_dict))
 
 
diff --git a/server/cros/vboot_constants.py b/server/cros/vboot_constants.py
new file mode 100644
index 0000000..47b5361
--- /dev/null
+++ b/server/cros/vboot_constants.py
@@ -0,0 +1,112 @@
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# The constants of verified boot.
+
+# Recovery reason codes, copied from:
+#     vboot_reference/firmware/lib/vboot_nvstorage.h
+#     vboot_reference/firmware/lib/vboot_struct.h
+RECOVERY_REASON = {
+    # Recovery not requested
+    'NOT_REQUESTED':      '0',   # 0x00
+    # Recovery requested from legacy utility
+    'LEGACY':             '1',   # 0x01
+    # User manually requested recovery via recovery button
+    'RO_MANUAL':          '2',   # 0x02
+    # RW firmware failed signature check
+    'RO_INVALID_RW':      '3',   # 0x03
+    # S3 resume failed
+    'RO_S3_RESUME':       '4',   # 0x04
+    # TPM error in read-only firmware
+    'RO_TPM_ERROR':       '5',   # 0x05
+    # Shared data error in read-only firmware
+    'RO_SHARED_DATA':     '6',   # 0x06
+    # Test error from S3Resume()
+    'RO_TEST_S3':         '7',   # 0x07
+    # Test error from LoadFirmwareSetup()
+    'RO_TEST_LFS':        '8',   # 0x08
+    # Test error from LoadFirmware()
+    'RO_TEST_LF':         '9',   # 0x09
+    # RW firmware failed signature check
+    'RW_NOT_DONE':        '16',  # 0x10
+    'RW_DEV_MISMATCH':    '17',  # 0x11
+    'RW_REC_MISMATCH':    '18',  # 0x12
+    'RW_VERIFY_KEYBLOCK': '19',  # 0x13
+    'RW_KEY_ROLLBACK':    '20',  # 0x14
+    'RW_DATA_KEY_PARSE':  '21',  # 0x15
+    'RW_VERIFY_PREAMBLE': '22',  # 0x16
+    'RW_FW_ROLLBACK':     '23',  # 0x17
+    'RW_HEADER_VALID':    '24',  # 0x18
+    'RW_GET_FW_BODY':     '25',  # 0x19
+    'RW_HASH_WRONG_SIZE': '26',  # 0x1A
+    'RW_VERIFY_BODY':     '27',  # 0x1B
+    'RW_VALID':           '28',  # 0x1C
+    # Read-only normal path requested by firmware preamble, but
+    # unsupported by firmware.
+    'RW_NO_RO_NORMAL':    '29',  # 0x1D
+    # Firmware boot failure outside of verified boot
+    'RO_FIRMWARE':        '32',  # 0x20
+    # Recovery mode TPM initialization requires a system reboot.
+    # The system was already in recovery mode for some other reason
+    # when this happened.
+    'RO_TPM_REBOOT':      '33',  # 0x21
+    # Unspecified/unknown error in read-only firmware
+    'RO_UNSPECIFIED':     '63',  # 0x3F
+    # User manually requested recovery by pressing a key at developer
+    # warning screen.
+    'RW_DEV_SCREEN':      '65',  # 0x41
+    # No OS kernel detected
+    'RW_NO_OS':           '66',  # 0x42
+    # OS kernel failed signature check
+    'RW_INVALID_OS':      '67',  # 0x43
+    # TPM error in rewritable firmware
+    'RW_TPM_ERROR':       '68',  # 0x44
+    # RW firmware in dev mode, but dev switch is off.
+    'RW_DEV_MISMATCH':    '69',  # 0x45
+    # Shared data error in rewritable firmware
+    'RW_SHARED_DATA':     '70',  # 0x46
+    # Test error from LoadKernel()
+    'RW_TEST_LK':         '71',  # 0x47
+    # No bootable disk found
+    'RW_NO_DISK':         '72',  # 0x48
+    # Unspecified/unknown error in rewritable firmware
+    'RW_UNSPECIFIED':     '127', # 0x7F
+    # DM-verity error
+    'KE_DM_VERITY':       '129', # 0x81
+    # Unspecified/unknown error in kernel
+    'KE_UNSPECIFIED':     '191', # 0xBF
+    # Recovery mode test from user-mode
+    'US_TEST':            '193', # 0xC1
+    # Unspecified/unknown error in user-mode
+    'US_UNSPECIFIED':     '255', # 0xFF
+}
+
+# GBB flags, copied from:
+#     vboot_reference/firmware/include/gbb_header.h
+GBB_FLAG_DEV_SCREEN_SHORT_DELAY    = 0x00000001
+GBB_FLAG_LOAD_OPTION_ROMS          = 0x00000002
+GBB_FLAG_ENABLE_ALTERNATE_OS       = 0x00000004
+GBB_FLAG_FORCE_DEV_SWITCH_ON       = 0x00000008
+GBB_FLAG_FORCE_DEV_BOOT_USB        = 0x00000010
+GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK = 0x00000020
+GBB_FLAG_ENTER_TRIGGERS_TONORM     = 0x00000040
+
+# VbSharedData flags, copied from:
+#     vboot_reference/firmware/include/vboot_struct.h
+VDAT_FLAG_FWB_TRIED                = 0x00000001
+VDAT_FLAG_KERNEL_KEY_VERIFIED      = 0x00000002
+VDAT_FLAG_LF_DEV_SWITCH_ON         = 0x00000004
+VDAT_FLAG_LF_USE_RO_NORMAL         = 0x00000008
+VDAT_FLAG_BOOT_DEV_SWITCH_ON       = 0x00000010
+VDAT_FLAG_BOOT_REC_SWITCH_ON       = 0x00000020
+VDAT_FLAG_BOOT_FIRMWARE_WP_ENABLED = 0x00000040
+VDAT_FLAG_BOOT_S3_RESUME           = 0x00000100
+VDAT_FLAG_BOOT_RO_NORMAL_SUPPORT   = 0x00000200
+VDAT_FLAG_HONOR_VIRT_DEV_SWITCH    = 0x00000400
+VDAT_FLAG_EC_SOFTWARE_SYNC         = 0x00000800
+VDAT_FLAG_EC_SLOW_UPDATE           = 0x00001000
+
+# Firmware preamble flags, copied from:
+#     vboot_reference/firmware/include/vboot_struct.h
+PREAMBLE_USE_RO_NORMAL             = 0x00000001
diff --git a/server/site_tests/firmware_CorruptBothFwBodyAB/firmware_CorruptBothFwBodyAB.py b/server/site_tests/firmware_CorruptBothFwBodyAB/firmware_CorruptBothFwBodyAB.py
index 3ce4568..43e644d 100644
--- a/server/site_tests/firmware_CorruptBothFwBodyAB/firmware_CorruptBothFwBodyAB.py
+++ b/server/site_tests/firmware_CorruptBothFwBodyAB/firmware_CorruptBothFwBodyAB.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -28,7 +29,7 @@
         super(firmware_CorruptBothFwBodyAB, self).setup()
         self.backup_firmware()
         if (self.faft_client.get_firmware_flags('a') &
-                self.PREAMBLE_USE_RO_NORMAL):
+                vboot.PREAMBLE_USE_RO_NORMAL):
             self.use_ro = True
             self.setup_dev_mode(dev_mode)
         else:
@@ -79,8 +80,8 @@
                     'state_checker': (self.crossystem_checker, {
                         'mainfw_type': 'recovery',
                         'recovery_reason':
-                            (self.RECOVERY_REASON['RO_INVALID_RW'],
-                             self.RECOVERY_REASON['RW_VERIFY_BODY']),
+                            (vboot.RECOVERY_REASON['RO_INVALID_RW'],
+                             vboot.RECOVERY_REASON['RW_VERIFY_BODY']),
                     }),
                     'userspace_action': (self.faft_client.restore_firmware_body,
                                          (('a', 'b'),)),
diff --git a/server/site_tests/firmware_CorruptBothFwSigAB/firmware_CorruptBothFwSigAB.py b/server/site_tests/firmware_CorruptBothFwSigAB/firmware_CorruptBothFwSigAB.py
index 48e80c3..bd6a6a6 100644
--- a/server/site_tests/firmware_CorruptBothFwSigAB/firmware_CorruptBothFwSigAB.py
+++ b/server/site_tests/firmware_CorruptBothFwSigAB/firmware_CorruptBothFwSigAB.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -46,8 +47,8 @@
             {   # Step 2, expected recovery boot and set fwb_tries flag
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason': (self.RECOVERY_REASON['RO_INVALID_RW'],
-                            self.RECOVERY_REASON['RW_VERIFY_KEYBLOCK']),
+                    'recovery_reason': (vboot.RECOVERY_REASON['RO_INVALID_RW'],
+                            vboot.RECOVERY_REASON['RW_VERIFY_KEYBLOCK']),
                 }),
                 'userspace_action': self.faft_client.set_try_fw_b,
                 'firmware_action': None if dev_mode else
@@ -56,8 +57,8 @@
             {   # Step 3, still expected recovery boot and restore firmware
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason': (self.RECOVERY_REASON['RO_INVALID_RW'],
-                            self.RECOVERY_REASON['RW_VERIFY_KEYBLOCK']),
+                    'recovery_reason': (vboot.RECOVERY_REASON['RO_INVALID_RW'],
+                            vboot.RECOVERY_REASON['RW_VERIFY_KEYBLOCK']),
                 }),
                 'userspace_action': (self.faft_client.restore_firmware,
                                      (('a', 'b'),)),
diff --git a/server/site_tests/firmware_CorruptBothKernelAB/firmware_CorruptBothKernelAB.py b/server/site_tests/firmware_CorruptBothKernelAB/firmware_CorruptBothKernelAB.py
index c537153..55e924b 100644
--- a/server/site_tests/firmware_CorruptBothKernelAB/firmware_CorruptBothKernelAB.py
+++ b/server/site_tests/firmware_CorruptBothKernelAB/firmware_CorruptBothKernelAB.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -51,11 +52,11 @@
     def run_once(self, host=None, dev_mode=False):
         platform = self.faft_client.get_platform_name()
         if platform in ('Mario', 'Alex', 'ZGB'):
-            recovery_reason = self.RECOVERY_REASON['RW_NO_OS']
+            recovery_reason = vboot.RECOVERY_REASON['RW_NO_OS']
         elif platform in ('Aebl', 'Kaen'):
-            recovery_reason = self.RECOVERY_REASON['RW_INVALID_OS']
+            recovery_reason = vboot.RECOVERY_REASON['RW_INVALID_OS']
         else:
-            recovery_reason = self.RECOVERY_REASON['RW_NO_DISK']
+            recovery_reason = vboot.RECOVERY_REASON['RW_NO_DISK']
 
         self.register_faft_sequence((
             {   # Step 1, corrupt kernel A and B
diff --git a/server/site_tests/firmware_CorruptFwBodyA/firmware_CorruptFwBodyA.py b/server/site_tests/firmware_CorruptFwBodyA/firmware_CorruptFwBodyA.py
index 64a0c28..a938259 100644
--- a/server/site_tests/firmware_CorruptFwBodyA/firmware_CorruptFwBodyA.py
+++ b/server/site_tests/firmware_CorruptFwBodyA/firmware_CorruptFwBodyA.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -33,7 +34,7 @@
 
     def run_once(self, host=None):
         if (self.faft_client.get_firmware_flags('a') &
-                self.PREAMBLE_USE_RO_NORMAL):
+                vboot.PREAMBLE_USE_RO_NORMAL):
             # USE_RO_NORMAL flag is ON. Firmware body corruption doesn't
             # hurt the booting results.
             logging.info('The firmware USE_RO_NORMAL flag is enabled.')
diff --git a/server/site_tests/firmware_CorruptFwBodyB/firmware_CorruptFwBodyB.py b/server/site_tests/firmware_CorruptFwBodyB/firmware_CorruptFwBodyB.py
index 2ad23fb..ff595b5 100644
--- a/server/site_tests/firmware_CorruptFwBodyB/firmware_CorruptFwBodyB.py
+++ b/server/site_tests/firmware_CorruptFwBodyB/firmware_CorruptFwBodyB.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -31,7 +32,7 @@
 
     def run_once(self, host=None):
         RO_enabled = (self.faft_client.get_firmware_flags('b') &
-                      self.PREAMBLE_USE_RO_NORMAL)
+                      vboot.PREAMBLE_USE_RO_NORMAL)
         self.register_faft_sequence((
             {   # Step 1, corrupt firmware body B
                 'state_checker': (self.crossystem_checker, {
diff --git a/server/site_tests/firmware_DevFwNormalBoot/firmware_DevFwNormalBoot.py b/server/site_tests/firmware_DevFwNormalBoot/firmware_DevFwNormalBoot.py
index d0499ef..9de0101 100644
--- a/server/site_tests/firmware_DevFwNormalBoot/firmware_DevFwNormalBoot.py
+++ b/server/site_tests/firmware_DevFwNormalBoot/firmware_DevFwNormalBoot.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -64,7 +65,7 @@
                         'devsw_boot': '0',
                         'mainfw_type': 'recovery',
                         'recovery_reason' :
-                                self.RECOVERY_REASON['RO_INVALID_RW'],
+                                vboot.RECOVERY_REASON['RO_INVALID_RW'],
                     }),
                     'userspace_action': self.restore_fw_b_and_enable_devsw,
                 },
diff --git a/server/site_tests/firmware_DevScreenTimeout/firmware_DevScreenTimeout.py b/server/site_tests/firmware_DevScreenTimeout/firmware_DevScreenTimeout.py
index e696800..d7aaeb1 100644
--- a/server/site_tests/firmware_DevScreenTimeout/firmware_DevScreenTimeout.py
+++ b/server/site_tests/firmware_DevScreenTimeout/firmware_DevScreenTimeout.py
@@ -6,6 +6,7 @@
 import time
 
 from autotest_lib.client.common_lib import error
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -86,7 +87,7 @@
         # This test is run on developer mode only.
         self.setup_dev_mode(dev_mode=True)
         # Clear the short delay flag to verify the release behavior.
-        self.clear_set_gbb_flags(self.GBB_FLAG_DEV_SCREEN_SHORT_DELAY, 0)
+        self.clear_set_gbb_flags(vboot.GBB_FLAG_DEV_SCREEN_SHORT_DELAY, 0)
 
 
     def run_once(self, host=None):
diff --git a/server/site_tests/firmware_DevTriggerRecovery/firmware_DevTriggerRecovery.py b/server/site_tests/firmware_DevTriggerRecovery/firmware_DevTriggerRecovery.py
index 0bd0e22..1c4bd74 100644
--- a/server/site_tests/firmware_DevTriggerRecovery/firmware_DevTriggerRecovery.py
+++ b/server/site_tests/firmware_DevTriggerRecovery/firmware_DevTriggerRecovery.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -99,7 +100,7 @@
                 'state_checker': (self.crossystem_checker, {
                     'devsw_boot': '1',
                     'mainfw_type': 'recovery',
-                    'recovery_reason' : self.RECOVERY_REASON['RW_DEV_SCREEN'],
+                    'recovery_reason' : vboot.RECOVERY_REASON['RW_DEV_SCREEN'],
                 }),
                 'userspace_action': self.servo.disable_development_mode,
             },
diff --git a/server/site_tests/firmware_ECWriteProtect/firmware_ECWriteProtect.py b/server/site_tests/firmware_ECWriteProtect/firmware_ECWriteProtect.py
index 9970009..5a3ab51 100644
--- a/server/site_tests/firmware_ECWriteProtect/firmware_ECWriteProtect.py
+++ b/server/site_tests/firmware_ECWriteProtect/firmware_ECWriteProtect.py
@@ -5,6 +5,7 @@
 import logging
 
 from autotest_lib.client.common_lib import error
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -54,7 +55,7 @@
 
     def run_once(self, host=None):
         flags = self.faft_client.get_firmware_flags('a')
-        if flags & self.PREAMBLE_USE_RO_NORMAL == 0:
+        if flags & vboot.PREAMBLE_USE_RO_NORMAL == 0:
             logging.info('The firmware USE_RO_NORMAL flag is disabled.')
             return
 
@@ -84,7 +85,7 @@
                                               twostop=True) and
                                           self.write_protect_checker()),
                 'userspace_action': (self.faft_client.set_firmware_flags,
-                                     ('a', self.PREAMBLE_USE_RO_NORMAL)),
+                                     ('a', vboot.PREAMBLE_USE_RO_NORMAL)),
                 'reboot_action': (self.set_EC_write_protect_and_reboot, False),
             },
             {   # Step 5, expected EC RO boot.
diff --git a/server/site_tests/firmware_InvalidUSB/firmware_InvalidUSB.py b/server/site_tests/firmware_InvalidUSB/firmware_InvalidUSB.py
index cd3d9ba..63f1a57 100644
--- a/server/site_tests/firmware_InvalidUSB/firmware_InvalidUSB.py
+++ b/server/site_tests/firmware_InvalidUSB/firmware_InvalidUSB.py
@@ -6,6 +6,7 @@
 import time
 
 from autotest_lib.client.common_lib import error
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -75,7 +76,7 @@
             {   # Step 2, expected to boot the restored USB image and reboot.
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason' : self.RECOVERY_REASON['US_TEST'],
+                    'recovery_reason' : vboot.RECOVERY_REASON['US_TEST'],
                 }),
             },
             {   # Step 3, expected to normal boot and done.
diff --git a/server/site_tests/firmware_RONormalBoot/firmware_RONormalBoot.py b/server/site_tests/firmware_RONormalBoot/firmware_RONormalBoot.py
index c70e0e1..72fd7ac 100644
--- a/server/site_tests/firmware_RONormalBoot/firmware_RONormalBoot.py
+++ b/server/site_tests/firmware_RONormalBoot/firmware_RONormalBoot.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -35,15 +36,15 @@
 
     def run_once(self, host=None):
         flags = self.faft_client.get_firmware_flags('a')
-        if flags & self.PREAMBLE_USE_RO_NORMAL == 0:
+        if flags & vboot.PREAMBLE_USE_RO_NORMAL == 0:
             logging.info('The firmware USE_RO_NORMAL flag is disabled.')
             return
 
         self.register_faft_sequence((
             {   # Step 1, disable the RO normal boot flag
                 'state_checker': (self.ro_normal_checker, 'A'),
-                'userspace_action': (self.faft_client.set_firmware_flags,
-                                    ('a', flags ^ self.PREAMBLE_USE_RO_NORMAL)),
+                'userspace_action': (self.faft_client.set_firmware_flags, ('a',
+                                     flags ^ vboot.PREAMBLE_USE_RO_NORMAL)),
             },
             {   # Step 2, expected TwoStop boot, restore the original flags
                 'state_checker': (lambda: self.ro_normal_checker('A',
diff --git a/server/site_tests/firmware_RecoveryButton/firmware_RecoveryButton.py b/server/site_tests/firmware_RecoveryButton/firmware_RecoveryButton.py
index 2245d1e..adde983 100644
--- a/server/site_tests/firmware_RecoveryButton/firmware_RecoveryButton.py
+++ b/server/site_tests/firmware_RecoveryButton/firmware_RecoveryButton.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -69,7 +70,7 @@
             {   # Step 2, expected recovery boot and reboot
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason' : self.RECOVERY_REASON['RO_MANUAL'],
+                    'recovery_reason' : vboot.RECOVERY_REASON['RO_MANUAL'],
                 }),
             },
             {   # Step 3, expected normal boot
diff --git a/server/site_tests/firmware_RollbackFirmware/firmware_RollbackFirmware.py b/server/site_tests/firmware_RollbackFirmware/firmware_RollbackFirmware.py
index 367f8ba..add55cd 100644
--- a/server/site_tests/firmware_RollbackFirmware/firmware_RollbackFirmware.py
+++ b/server/site_tests/firmware_RollbackFirmware/firmware_RollbackFirmware.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -23,7 +24,7 @@
         self.assert_test_image_in_usb_disk()
         self.setup_dev_mode(dev_mode)
         self.servo.set('usb_mux_sel1', 'dut_sees_usbkey')
-        self.clear_set_gbb_flags(self.GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK, 0)
+        self.clear_set_gbb_flags(vboot.GBB_FLAG_DISABLE_FW_ROLLBACK_CHECK, 0)
 
 
     def cleanup(self):
@@ -34,9 +35,9 @@
     def run_once(self, host=None, dev_mode=False):
         # Recovery reason RW_FW_ROLLBACK available after Alex/ZGB.
         if self.faft_client.get_platform_name() in ('Mario', 'Alex', 'ZGB'):
-            recovery_reason = self.RECOVERY_REASON['RO_INVALID_RW']
+            recovery_reason = vboot.RECOVERY_REASON['RO_INVALID_RW']
         else:
-            recovery_reason = self.RECOVERY_REASON['RW_FW_ROLLBACK']
+            recovery_reason = vboot.RECOVERY_REASON['RW_FW_ROLLBACK']
 
         self.register_faft_sequence((
             {   # Step 1, rollbacks firmware A.
diff --git a/server/site_tests/firmware_RollbackKernel/firmware_RollbackKernel.py b/server/site_tests/firmware_RollbackKernel/firmware_RollbackKernel.py
index c197ad4..b98906a 100644
--- a/server/site_tests/firmware_RollbackKernel/firmware_RollbackKernel.py
+++ b/server/site_tests/firmware_RollbackKernel/firmware_RollbackKernel.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -51,11 +52,11 @@
     def run_once(self, host=None, dev_mode=False):
         # Historical reason that the old models use a different value.
         if self.faft_client.get_platform_name() in ('Mario', 'Alex', 'ZGB'):
-            recovery_reason = self.RECOVERY_REASON['RW_NO_OS']
+            recovery_reason = vboot.RECOVERY_REASON['RW_NO_OS']
         else:
             # TODO(waihong): Should be RW_INVALID_OS but the current vboot
             # implementation overwrites it with RW_NO_DISK.
-            recovery_reason = self.RECOVERY_REASON['RW_NO_DISK']
+            recovery_reason = vboot.RECOVERY_REASON['RW_NO_DISK']
 
         if dev_mode:
             faft_sequence = (
diff --git a/server/site_tests/firmware_SoftwareSync/firmware_SoftwareSync.py b/server/site_tests/firmware_SoftwareSync/firmware_SoftwareSync.py
index 0116309..a26b2a1 100644
--- a/server/site_tests/firmware_SoftwareSync/firmware_SoftwareSync.py
+++ b/server/site_tests/firmware_SoftwareSync/firmware_SoftwareSync.py
@@ -4,6 +4,7 @@
 
 import logging
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -17,8 +18,8 @@
     def ensure_rw(self):
         """Ensure firmware A is not in RO-normal mode."""
         flags = self.faft_client.get_firmware_flags('a')
-        if flags & self.PREAMBLE_USE_RO_NORMAL:
-            flags = flags ^ self.PREAMBLE_USE_RO_NORMAL
+        if flags & vboot.PREAMBLE_USE_RO_NORMAL:
+            flags = flags ^ vboot.PREAMBLE_USE_RO_NORMAL
             self.run_faft_step({
                 'userspace_action': (self.faft_client.set_firmware_flags,
                     ('a', flags))
diff --git a/server/site_tests/firmware_UpdateECBin/firmware_UpdateECBin.py b/server/site_tests/firmware_UpdateECBin/firmware_UpdateECBin.py
index be93644..d4043e4 100644
--- a/server/site_tests/firmware_UpdateECBin/firmware_UpdateECBin.py
+++ b/server/site_tests/firmware_UpdateECBin/firmware_UpdateECBin.py
@@ -6,6 +6,7 @@
 import logging, os
 
 from autotest_lib.client.common_lib import error, utils
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -83,7 +84,7 @@
             return
 
         flags = self.faft_client.get_firmware_flags('a')
-        if flags & self.PREAMBLE_USE_RO_NORMAL == 0:
+        if flags & vboot.PREAMBLE_USE_RO_NORMAL == 0:
             logging.info('The firmware USE_RO_NORMAL flag is disabled.')
             return
 
diff --git a/server/site_tests/firmware_UserRequestRecovery/firmware_UserRequestRecovery.py b/server/site_tests/firmware_UserRequestRecovery/firmware_UserRequestRecovery.py
index 5a7c26b..7dacffd 100644
--- a/server/site_tests/firmware_UserRequestRecovery/firmware_UserRequestRecovery.py
+++ b/server/site_tests/firmware_UserRequestRecovery/firmware_UserRequestRecovery.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+from autotest_lib.server.cros import vboot_constants as vboot
 from autotest_lib.server.cros.faftsequence import FAFTSequence
 
 
@@ -67,7 +68,7 @@
             {   # Step 2, expected recovery boot, request recovery again
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason' : self.RECOVERY_REASON['US_TEST'],
+                    'recovery_reason' : vboot.RECOVERY_REASON['US_TEST'],
                 }),
                 'userspace_action': self.faft_client.request_recovery_boot,
                 'firmware_action': None if dev_mode else
@@ -76,7 +77,7 @@
             {   # Step 3, expected recovery boot
                 'state_checker': (self.crossystem_checker, {
                     'mainfw_type': 'recovery',
-                    'recovery_reason' : self.RECOVERY_REASON['US_TEST'],
+                    'recovery_reason' : vboot.RECOVERY_REASON['US_TEST'],
                 }),
             },
             {   # Step 4, expected normal boot