diff options
Diffstat (limited to 'firmware/include/vboot_nvstorage.h')
-rw-r--r-- | firmware/include/vboot_nvstorage.h | 209 |
1 files changed, 122 insertions, 87 deletions
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h index 8b41c8f1..890af4b6 100644 --- a/firmware/include/vboot_nvstorage.h +++ b/firmware/include/vboot_nvstorage.h @@ -1,10 +1,9 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2013 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. */ -/* Non-volatile storage routines for verified boot. - */ +/* Non-volatile storage routines for verified boot. */ #ifndef VBOOT_REFERENCE_NVSTORAGE_H_ #define VBOOT_REFERENCE_NVSTORAGE_H_ @@ -12,70 +11,88 @@ #define VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */ typedef struct VbNvContext { - /* Raw NV data. Caller must fill this before calling VbNvSetup(). */ - uint8_t raw[VBNV_BLOCK_SIZE]; - /* Flag indicating whether raw data has changed. Set by VbNvTeardown() if - * the raw data has changed and needs to be stored to the underlying - * non-volatile data store. */ - int raw_changed; - - /* Internal data for NV storage routines. Caller should not touch - * these fields. */ - int regenerate_crc; + /* Raw NV data. Caller must fill this before calling VbNvSetup(). */ + uint8_t raw[VBNV_BLOCK_SIZE]; + /* + * Flag indicating whether raw data has changed. Set by VbNvTeardown() + * if the raw data has changed and needs to be stored to the underlying + * non-volatile data store. + */ + int raw_changed; + /* + * Internal data for NV storage routines. Caller should not touch + * these fields. + */ + int regenerate_crc; } VbNvContext; - /* Parameter type for VbNvGet(), VbNvSet(). */ typedef enum VbNvParam { - /* Parameter values have been reset to defaults (flag for firmware). - * 0=clear; 1=set. */ - VBNV_FIRMWARE_SETTINGS_RESET = 0, - /* Parameter values have been reset to defaults (flag for kernel). - * 0=clear; 1=set. */ - VBNV_KERNEL_SETTINGS_RESET, - /* Request debug reset on next S3->S0 transition. 0=clear; 1=set. */ - VBNV_DEBUG_RESET_MODE, - /* Number of times to try booting RW firmware slot B before slot A. - * Valid range: 0-15. */ - VBNV_TRY_B_COUNT, - /* Request recovery mode on next boot; see VBNB_RECOVERY_* below for - * currently defined reason codes. 8-bit value. */ - VBNV_RECOVERY_REQUEST, - /* Localization index for screen bitmaps displayed by firmware. - * 8-bit value. */ - VBNV_LOCALIZATION_INDEX, - /* Field reserved for kernel/user-mode use; 32-bit value. */ - VBNV_KERNEL_FIELD, - /* Allow booting from USB in developer mode. 0=no, 1=yes. */ - VBNV_DEV_BOOT_USB, - /* Allow booting of legacy OSes in developer mode. 0=no, 1=yes. */ - VBNV_DEV_BOOT_LEGACY, - /* Only boot Google-signed images in developer mode. 0=no, 1=yes. */ - VBNV_DEV_BOOT_SIGNED_ONLY, - /* Set by userspace to request that RO firmware disable dev-mode on the next - * boot. This is likely only possible if the dev-switch is virtual. */ - VBNV_DISABLE_DEV_REQUEST, - /* Set and cleared by vboot to request that the video Option ROM be loaded at - * boot time, so that BIOS screens can be displayed. 0=no, 1=yes. */ - VBNV_OPROM_NEEDED, - /* Request that the firmware clear the TPM owner on the next boot. */ - VBNV_CLEAR_TPM_OWNER_REQUEST, - /* Flag that TPM owner was cleared on request. */ - VBNV_CLEAR_TPM_OWNER_DONE, - /* More details on recovery reason */ - VBNV_RECOVERY_SUBCODE, + /* + * Parameter values have been reset to defaults (flag for firmware). + * 0=clear; 1=set. + */ + VBNV_FIRMWARE_SETTINGS_RESET = 0, + /* + * Parameter values have been reset to defaults (flag for kernel). + * 0=clear; 1=set. + */ + VBNV_KERNEL_SETTINGS_RESET, + /* Request debug reset on next S3->S0 transition. 0=clear; 1=set. */ + VBNV_DEBUG_RESET_MODE, + /* + * Number of times to try booting RW firmware slot B before slot A. + * Valid range: 0-15. + */ + VBNV_TRY_B_COUNT, + /* + * Request recovery mode on next boot; see VBNB_RECOVERY_* below for + * currently defined reason codes. 8-bit value. + */ + VBNV_RECOVERY_REQUEST, + /* + * Localization index for screen bitmaps displayed by firmware. + * 8-bit value. + */ + VBNV_LOCALIZATION_INDEX, + /* Field reserved for kernel/user-mode use; 32-bit value. */ + VBNV_KERNEL_FIELD, + /* Allow booting from USB in developer mode. 0=no, 1=yes. */ + VBNV_DEV_BOOT_USB, + /* Allow booting of legacy OSes in developer mode. 0=no, 1=yes. */ + VBNV_DEV_BOOT_LEGACY, + /* Only boot Google-signed images in developer mode. 0=no, 1=yes. */ + VBNV_DEV_BOOT_SIGNED_ONLY, + /* + * Set by userspace to request that RO firmware disable dev-mode on the + * next boot. This is likely only possible if the dev-switch is + * virtual. + */ + VBNV_DISABLE_DEV_REQUEST, + /* + * Set and cleared by vboot to request that the video Option ROM be + * loaded at boot time, so that BIOS screens can be displayed. 0=no, + * 1=yes. + */ + VBNV_OPROM_NEEDED, + /* Request that the firmware clear the TPM owner on the next boot. */ + VBNV_CLEAR_TPM_OWNER_REQUEST, + /* Flag that TPM owner was cleared on request. */ + VBNV_CLEAR_TPM_OWNER_DONE, + /* More details on recovery reason */ + VBNV_RECOVERY_SUBCODE, } VbNvParam; - /* Recovery reason codes for VBNV_RECOVERY_REQUEST */ /* Recovery not requested. */ #define VBNV_RECOVERY_NOT_REQUESTED 0x00 -/* Recovery requested from legacy utility. (Prior to the NV storage - * spec, recovery mode was a single bitfield; this value is reserved - * so that scripts which wrote 1 to the recovery field are - * distinguishable from scripts whch use the recovery reasons listed - * here. */ +/* + * Recovery requested from legacy utility. (Prior to the NV storage spec, + * recovery mode was a single bitfield; this value is reserved so that scripts + * which wrote 1 to the recovery field are distinguishable from scripts whch + * use the recovery reasons listed here. + */ #define VBNV_RECOVERY_LEGACY 0x01 /* User manually requested recovery via recovery button */ #define VBNV_RECOVERY_RO_MANUAL 0x02 @@ -93,17 +110,23 @@ typedef enum VbNvParam { #define VBNV_RECOVERY_RO_TEST_LFS 0x08 /* Test error from LoadFirmware() */ #define VBNV_RECOVERY_RO_TEST_LF 0x09 -/* RW firmware failed signature check (neither RW firmware slot was valid). +/* + * RW firmware failed signature check (neither RW firmware slot was valid). * Recovery reason is VBNV_RECOVERY_RO_INVALID_RW_CHECK_MIN + the check value * for the slot which came closest to validating; see VBSD_LF_CHECK_* in - * vboot_struct.h. */ + * vboot_struct.h. + */ #define VBNV_RECOVERY_RO_INVALID_RW_CHECK_MIN 0x10 #define VBNV_RECOVERY_RO_INVALID_RW_CHECK_MAX 0x1F -/* Firmware boot failure outside of verified boot (RAM init, missing SSD, - * etc.). */ +/* + * Firmware boot failure outside of verified boot (RAM init, missing SSD, + * etc.). + */ #define VBNV_RECOVERY_RO_FIRMWARE 0x20 -/* Recovery mode TPM initialization requires a system reboot. The system was - * already in recovery mode for some other reason when this happened. */ +/* + * Recovery mode TPM initialization requires a system reboot. The system was + * already in recovery mode for some other reason when this happened. + */ #define VBNV_RECOVERY_RO_TPM_REBOOT 0x21 /* EC software sync - other error */ #define VBNV_RECOVERY_EC_SOFTWARE_SYNC 0x22 @@ -121,8 +144,10 @@ typedef enum VbNvParam { #define VBNV_RECOVERY_EC_PROTECT 0x28 /* Unspecified/unknown error in read-only firmware */ #define VBNV_RECOVERY_RO_UNSPECIFIED 0x3F -/* User manually requested recovery by pressing a key at developer - * warning screen */ +/* + * User manually requested recovery by pressing a key at developer + * warning screen + */ #define VBNV_RECOVERY_RW_DEV_SCREEN 0x41 /* No OS kernel detected */ #define VBNV_RECOVERY_RW_NO_OS 0x42 @@ -175,10 +200,11 @@ typedef enum VbNvParam { /* Unspecified/unknown error in user-mode */ #define VBNV_RECOVERY_US_UNSPECIFIED 0xFF - -/* Initialize the NV storage library. This must be called before any - * other functions in this library. Returns 0 if success, non-zero if - * error. +/** + * Initialize the NV storage library. + * + * This must be called before any other functions in this library. Returns 0 + * if success, non-zero if error. * * Proper calling procedure: * 1) Allocate a context struct. @@ -187,14 +213,17 @@ typedef enum VbNvParam { * 3) Read underlying storage and fill in context->raw. * 4) Call VbNvSetup(). * - * If you have access to global variables, you may want to wrap all - * that in your own VbNvOpen() function. We don't do that in here - * because there are no global variables in UEFI BIOS during the PEI - * phase (that's also why we have to pass around a context pointer). */ -int VbNvSetup(VbNvContext* context); + * If you have access to global variables, you may want to wrap all that in + * your own VbNvOpen() function. We don't do that in here because there are no + * global variables in UEFI BIOS during the PEI phase (that's also why we have + * to pass around a context pointer). + */ +int VbNvSetup(VbNvContext *context); -/* Clean up and flush changes back to the raw data. This must be - * called after other functions in this library. Returns 0 if +/** + * Clean up and flush changes back to the raw data. + * + * This must be called after other functions in this library. Returns 0 if * success, non-zero if error. * * Proper calling procedure: @@ -204,20 +233,26 @@ int VbNvSetup(VbNvContext* context); * 4) Free the context struct. * * If you have access to global variables, you may want to wrap this - * in your own VbNvClose() function. */ -int VbNvTeardown(VbNvContext* context); + * in your own VbNvClose() function. + */ +int VbNvTeardown(VbNvContext *context); -/* Read a NV storage parameter into *dest. Returns 0 if success, - * non-zero if error. +/** + * Read a NV storage parameter into *dest. * - * This may only be called between VbNvSetup() and VbNvTeardown(). */ -int VbNvGet(VbNvContext* context, VbNvParam param, uint32_t* dest); - -/* Set a NV storage param to a new value. Returns 0 if success, - * non-zero if error. + * Returns 0 if success, non-zero if error. * - * This may only be called between VbNvSetup() and VbNvTeardown(). */ -int VbNvSet(VbNvContext* context, VbNvParam param, uint32_t value); + * This may only be called between VbNvSetup() and VbNvTeardown(). + */ +int VbNvGet(VbNvContext *context, VbNvParam param, uint32_t *dest); +/** + * Set a NV storage param to a new value. + * + * Returns 0 if success, non-zero if error. + * + * This may only be called between VbNvSetup() and VbNvTeardown(). + */ +int VbNvSet(VbNvContext *context, VbNvParam param, uint32_t value); #endif /* VBOOT_REFERENCE_NVSTORAGE_H_ */ |