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

Unified Diff: firmware/lib/vboot_nvstorage.c

Issue 6469059: VbNvStorage cleanup and comments (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Fixes from code review Created 9 years, 10 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 | « firmware/include/vboot_nvstorage.h ('k') | firmware/linktest/main.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: firmware/lib/vboot_nvstorage.c
diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c
index 81816ac416b0a01c1f746211f91f422dd5436d7e..6e8c1c799a61e0c1ef6741ad9d3ae2250e8bcb71 100644
--- a/firmware/lib/vboot_nvstorage.c
+++ b/firmware/lib/vboot_nvstorage.c
@@ -61,7 +61,7 @@ int VbNvSetup(VbNvContext* context) {
|| (Crc8(raw, CRC_OFFSET) != raw[CRC_OFFSET])) {
/* Data is inconsistent (bad CRC or header), so reset defaults */
- Memset(raw, 0, NV_BLOCK_SIZE);
+ Memset(raw, 0, VBNV_BLOCK_SIZE);
raw[HEADER_OFFSET] = (HEADER_SIGNATURE | HEADER_FIRMWARE_SETTINGS_RESET |
HEADER_KERNEL_SETTINGS_RESET);
@@ -153,19 +153,30 @@ int VbNvSet(VbNvContext* context, VbNvParam param, uint32_t value) {
if (value)
raw[BOOT_OFFSET] |= BOOT_DEBUG_RESET_MODE;
else
- raw[BOOT_OFFSET] &= BOOT_DEBUG_RESET_MODE;
+ raw[BOOT_OFFSET] &= ~BOOT_DEBUG_RESET_MODE;
break;
case VBNV_TRY_B_COUNT:
+ /* Clip to valid range. */
+ if (value > BOOT_TRY_B_COUNT)
+ value = BOOT_TRY_B_COUNT - 1;
+
raw[BOOT_OFFSET] &= ~BOOT_TRY_B_COUNT;
- raw[BOOT_OFFSET] |= (uint8_t)(value & BOOT_TRY_B_COUNT);
+ raw[BOOT_OFFSET] |= (uint8_t)value;
break;
case VBNV_RECOVERY_REQUEST:
+ /* Map values outside the valid range to the legacy reason, since we
+ * can't determine if we're called from kernel or user mode. */
+ if (value > 0xFF)
+ value = VBNV_RECOVERY_LEGACY;
raw[RECOVERY_OFFSET] = (uint8_t)value;
break;
case VBNV_LOCALIZATION_INDEX:
+ /* Map values outside the valid range to the default index. */
+ if (value > 0xFF)
+ value = 0;
raw[LOCALIZATION_OFFSET] = (uint8_t)value;
break;
« no previous file with comments | « firmware/include/vboot_nvstorage.h ('k') | firmware/linktest/main.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698