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

Side by Side Diff: firmware/lib/vboot_nvstorage.c

Issue 6596081: Add crossystem support for nvram_cleared and kern_nv (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Fix try B count mask Created 9 years, 9 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 | « firmware/lib/vboot_firmware.c ('k') | host/lib/crossystem.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* Non-volatile storage routines. 6 /* Non-volatile storage routines.
7 */ 7 */
8 8
9 #include "utility.h" 9 #include "utility.h"
10 #include "vboot_common.h" 10 #include "vboot_common.h"
11 #include "vboot_nvstorage.h" 11 #include "vboot_nvstorage.h"
12 12
13 /* Constants for NV storage. We use this rather than structs and 13 /* Constants for NV storage. We use this rather than structs and
14 * bitfields so the data format is consistent across platforms and 14 * bitfields so the data format is consistent across platforms and
15 * compilers. */ 15 * compilers. */
16 #define HEADER_OFFSET 0 16 #define HEADER_OFFSET 0
17 #define HEADER_MASK 0xC0 17 #define HEADER_MASK 0xC0
18 #define HEADER_SIGNATURE 0x40 18 #define HEADER_SIGNATURE 0x40
19 #define HEADER_FIRMWARE_SETTINGS_RESET 0x20 19 #define HEADER_FIRMWARE_SETTINGS_RESET 0x20
20 #define HEADER_KERNEL_SETTINGS_RESET 0x10 20 #define HEADER_KERNEL_SETTINGS_RESET 0x10
21 21
22 #define BOOT_OFFSET 1 22 #define BOOT_OFFSET 1
23 #define BOOT_DEBUG_RESET_MODE 0x80 23 #define BOOT_DEBUG_RESET_MODE 0x80
24 #define BOOT_TRY_B_COUNT 0x0F 24 #define BOOT_TRY_B_COUNT_MASK 0x0F
25 25
26 #define RECOVERY_OFFSET 2 26 #define RECOVERY_OFFSET 2
27 #define LOCALIZATION_OFFSET 3 27 #define LOCALIZATION_OFFSET 3
28 28
29 #define FIRMWARE_FLAGS_OFFSET 5 29 #define FIRMWARE_FLAGS_OFFSET 5
30 #define FIRMWARE_TRIED_FIRMWARE_B 0x80 30 #define FIRMWARE_TRIED_FIRMWARE_B 0x80
31 #define FIRMWARE_FW_VERIFIED_KERNEL_KEY 0x40 31 #define FIRMWARE_FW_VERIFIED_KERNEL_KEY 0x40
32 32
33 #define KERNEL_FIELD_OFFSET 11 33 #define KERNEL_FIELD_OFFSET 11
34 #define CRC_OFFSET 15 34 #define CRC_OFFSET 15
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 case VBNV_KERNEL_SETTINGS_RESET: 101 case VBNV_KERNEL_SETTINGS_RESET:
102 *dest = (raw[HEADER_OFFSET] & HEADER_KERNEL_SETTINGS_RESET ? 1 : 0); 102 *dest = (raw[HEADER_OFFSET] & HEADER_KERNEL_SETTINGS_RESET ? 1 : 0);
103 return 0; 103 return 0;
104 104
105 case VBNV_DEBUG_RESET_MODE: 105 case VBNV_DEBUG_RESET_MODE:
106 *dest = (raw[BOOT_OFFSET] & BOOT_DEBUG_RESET_MODE ? 1 : 0); 106 *dest = (raw[BOOT_OFFSET] & BOOT_DEBUG_RESET_MODE ? 1 : 0);
107 return 0; 107 return 0;
108 108
109 case VBNV_TRY_B_COUNT: 109 case VBNV_TRY_B_COUNT:
110 *dest = raw[BOOT_OFFSET] & BOOT_TRY_B_COUNT; 110 *dest = raw[BOOT_OFFSET] & BOOT_TRY_B_COUNT_MASK;
111 return 0; 111 return 0;
112 112
113 case VBNV_RECOVERY_REQUEST: 113 case VBNV_RECOVERY_REQUEST:
114 *dest = raw[RECOVERY_OFFSET]; 114 *dest = raw[RECOVERY_OFFSET];
115 return 0; 115 return 0;
116 116
117 case VBNV_LOCALIZATION_INDEX: 117 case VBNV_LOCALIZATION_INDEX:
118 *dest = raw[LOCALIZATION_OFFSET]; 118 *dest = raw[LOCALIZATION_OFFSET];
119 return 0; 119 return 0;
120 120
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 case VBNV_DEBUG_RESET_MODE: 166 case VBNV_DEBUG_RESET_MODE:
167 if (value) 167 if (value)
168 raw[BOOT_OFFSET] |= BOOT_DEBUG_RESET_MODE; 168 raw[BOOT_OFFSET] |= BOOT_DEBUG_RESET_MODE;
169 else 169 else
170 raw[BOOT_OFFSET] &= ~BOOT_DEBUG_RESET_MODE; 170 raw[BOOT_OFFSET] &= ~BOOT_DEBUG_RESET_MODE;
171 break; 171 break;
172 172
173 case VBNV_TRY_B_COUNT: 173 case VBNV_TRY_B_COUNT:
174 /* Clip to valid range. */ 174 /* Clip to valid range. */
175 if (value > BOOT_TRY_B_COUNT) 175 if (value > BOOT_TRY_B_COUNT_MASK)
176 value = BOOT_TRY_B_COUNT - 1; 176 value = BOOT_TRY_B_COUNT_MASK;
177 177
178 raw[BOOT_OFFSET] &= ~BOOT_TRY_B_COUNT; 178 raw[BOOT_OFFSET] &= ~BOOT_TRY_B_COUNT_MASK;
179 raw[BOOT_OFFSET] |= (uint8_t)value; 179 raw[BOOT_OFFSET] |= (uint8_t)value;
180 break; 180 break;
181 181
182 case VBNV_RECOVERY_REQUEST: 182 case VBNV_RECOVERY_REQUEST:
183 /* Map values outside the valid range to the legacy reason, since we 183 /* Map values outside the valid range to the legacy reason, since we
184 * can't determine if we're called from kernel or user mode. */ 184 * can't determine if we're called from kernel or user mode. */
185 if (value > 0xFF) 185 if (value > 0xFF)
186 value = VBNV_RECOVERY_LEGACY; 186 value = VBNV_RECOVERY_LEGACY;
187 raw[RECOVERY_OFFSET] = (uint8_t)value; 187 raw[RECOVERY_OFFSET] = (uint8_t)value;
188 break; 188 break;
(...skipping 27 matching lines...) Expand all
216 break; 216 break;
217 217
218 default: 218 default:
219 return 1; 219 return 1;
220 } 220 }
221 221
222 /* Need to regenerate CRC, since the value changed. */ 222 /* Need to regenerate CRC, since the value changed. */
223 context->regenerate_crc = 1; 223 context->regenerate_crc = 1;
224 return 0; 224 return 0;
225 } 225 }
OLDNEW
« no previous file with comments | « firmware/lib/vboot_firmware.c ('k') | host/lib/crossystem.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698