blob: 54d08561c497d0bd1b26351c59f8c2f46a4242e3 [file] [log] [blame]
Randall Spangler54218662011-02-07 11:20:20 -08001/* 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
3 * found in the LICENSE file.
4 */
5
6#include <stdio.h>
7#include <string.h>
Vadim Bendebury20084232011-03-15 09:29:48 -07008#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11#include <ctype.h>
Randall Spangler54218662011-02-07 11:20:20 -080012
13#include "host_common.h"
14
15#include "crossystem.h"
Randall Spanglereb591952011-04-07 10:02:00 -070016#include "crossystem_arch.h"
Randall Spangler54218662011-02-07 11:20:20 -080017#include "utility.h"
18#include "vboot_common.h"
Randall Spanglere73302c2011-02-18 14:53:01 -080019#include "vboot_nvstorage.h"
Randall Spanglerf4ba19d2011-03-17 16:10:21 -070020#include "vboot_struct.h"
Randall Spangler54218662011-02-07 11:20:20 -080021
Randall Spangler196e1772011-03-10 11:31:06 -080022/* Filename for kernel command line */
23#define KERNEL_CMDLINE_PATH "/proc/cmdline"
24
Randall Spanglerf4ba19d2011-03-17 16:10:21 -070025/* Fields that GetVdatString() can get */
26typedef enum VdatStringField {
Randall Spangler71415712011-03-21 11:04:50 -070027 VDAT_STRING_TIMERS = 0, /* Timer values */
28 VDAT_STRING_LOAD_FIRMWARE_DEBUG, /* LoadFirmware() debug information */
29 VDAT_STRING_LOAD_KERNEL_DEBUG /* LoadKernel() debug information */
Randall Spanglerf4ba19d2011-03-17 16:10:21 -070030} VdatStringField;
31
32
33/* Fields that GetVdatInt() can get */
34typedef enum VdatIntField {
Randall Spanglercabe6b32011-03-18 12:44:27 -070035 VDAT_INT_FLAGS = 0, /* Flags */
36 VDAT_INT_FW_VERSION_TPM, /* Current firmware version in TPM */
37 VDAT_INT_KERNEL_VERSION_TPM, /* Current kernel version in TPM */
38 VDAT_INT_TRIED_FIRMWARE_B, /* Tried firmware B due to fwb_tries */
Randall Spangler7adcc602011-06-24 16:11:45 -070039 VDAT_INT_KERNEL_KEY_VERIFIED, /* Kernel key verified using
Randall Spanglercabe6b32011-03-18 12:44:27 -070040 * signature, not just hash */
Randall Spangler7adcc602011-06-24 16:11:45 -070041 VDAT_INT_RECOVERY_REASON /* Recovery reason for current boot */
Randall Spanglerf4ba19d2011-03-17 16:10:21 -070042} VdatIntField;
43
44
Randall Spanglerd7728232011-04-08 14:04:21 -070045/* Masks for kern_nv usage by kernel */
46#define KERN_NV_FWUPDATE_TRIES_MASK 0x0000000F
47
48
Randall Spanglerc80fe652011-02-17 11:06:47 -080049/* Return true if the FWID starts with the specified string. */
Randall Spanglereb591952011-04-07 10:02:00 -070050int FwidStartsWith(const char *start) {
Randall Spanglerc80fe652011-02-17 11:06:47 -080051 char fwid[128];
52 if (!VbGetSystemPropertyString("fwid", fwid, sizeof(fwid)))
53 return 0;
54
55 return 0 == strncmp(fwid, start, strlen(start));
56}
57
58
Randall Spangler0f8ffb12011-02-25 09:50:54 -080059int VbGetNvStorage(VbNvParam param) {
Randall Spangler0f8ffb12011-02-25 09:50:54 -080060 VbNvContext vnc;
Randall Spangler0f8ffb12011-02-25 09:50:54 -080061 uint32_t value;
62 int retval;
63
Randall Spangler0f8ffb12011-02-25 09:50:54 -080064 /* TODO: locking around NV access */
Randall Spanglereb591952011-04-07 10:02:00 -070065
66 if (0 != VbReadNvStorage(&vnc))
Randall Spangler0f8ffb12011-02-25 09:50:54 -080067 return -1;
Randall Spangler0f8ffb12011-02-25 09:50:54 -080068 if (0 != VbNvSetup(&vnc))
69 return -1;
70 retval = VbNvGet(&vnc, param, &value);
71 if (0 != VbNvTeardown(&vnc))
72 return -1;
73 if (0 != retval)
74 return -1;
75
76 /* TODO: If vnc.raw_changed, attempt to reopen NVRAM for write and
77 * save the new defaults. If we're able to, log. */
78 /* TODO: release lock */
79
80 return (int)value;
81}
82
83
Randall Spangler0f8ffb12011-02-25 09:50:54 -080084int VbSetNvStorage(VbNvParam param, int value) {
Randall Spangler0f8ffb12011-02-25 09:50:54 -080085 VbNvContext vnc;
Randall Spangler0f8ffb12011-02-25 09:50:54 -080086 int retval = -1;
87 int i;
88
Randall Spanglereb591952011-04-07 10:02:00 -070089 if (0 != VbReadNvStorage(&vnc))
Randall Spangler0f8ffb12011-02-25 09:50:54 -080090 return -1;
Randall Spangler0f8ffb12011-02-25 09:50:54 -080091
92 if (0 != VbNvSetup(&vnc))
93 goto VbSetNvCleanup;
94 i = VbNvSet(&vnc, param, (uint32_t)value);
95 if (0 != VbNvTeardown(&vnc))
96 goto VbSetNvCleanup;
97 if (0 != i)
98 goto VbSetNvCleanup;
99
100 if (vnc.raw_changed) {
Randall Spanglerd7728232011-04-08 14:04:21 -0700101 if (0 != VbWriteNvStorage(&vnc))
Randall Spangler0f8ffb12011-02-25 09:50:54 -0800102 goto VbSetNvCleanup;
103 }
104
105 /* Success */
106 retval = 0;
107
108VbSetNvCleanup:
Randall Spangler0f8ffb12011-02-25 09:50:54 -0800109 /* TODO: release lock */
110 return retval;
111}
112
113
Randall Spangler196e1772011-03-10 11:31:06 -0800114/* Determine whether OS-level debugging should be allowed. Passed the
115 * destination and its size. Returns 1 if yes, 0 if no, -1 if error. */
116int VbGetCrosDebug(void) {
117 FILE* f = NULL;
118 char buf[4096] = "";
Randall Spangler196e1772011-03-10 11:31:06 -0800119 char *t, *saveptr;
120
Randall Spanglereb591952011-04-07 10:02:00 -0700121 /* Try reading firmware type. */
122 if (VbGetArchPropertyString("mainfw_type", buf, sizeof(buf))) {
123 if (0 == strcmp(buf, "recovery"))
124 return 0; /* Recovery mode never allows debug. */
125 else if (0 == strcmp(buf, "developer"))
126 return 1; /* Developer firmware always allows debug. */
127 }
Randall Spangler196e1772011-03-10 11:31:06 -0800128
129 /* Normal new firmware, older ChromeOS firmware, or non-Chrome firmware.
Randall Spangler227f7922011-03-11 13:34:56 -0800130 * For all these cases, check /proc/cmdline for cros_[no]debug. */
Randall Spangler196e1772011-03-10 11:31:06 -0800131 f = fopen(KERNEL_CMDLINE_PATH, "rt");
132 if (f) {
133 if (NULL == fgets(buf, sizeof(buf), f))
134 *buf = 0;
135 fclose(f);
136 }
137 for (t = strtok_r(buf, " ", &saveptr); t; t=strtok_r(NULL, " ", &saveptr)) {
138 if (0 == strcmp(t, "cros_debug"))
139 return 1;
Randall Spangler227f7922011-03-11 13:34:56 -0800140 else if (0 == strcmp(t, "cros_nodebug"))
141 return 0;
Randall Spangler196e1772011-03-10 11:31:06 -0800142 }
143
144 /* Normal new firmware or older Chrome OS firmware allows debug if the
145 * dev switch is on. */
Randall Spanglereb591952011-04-07 10:02:00 -0700146 if (1 == VbGetSystemPropertyInt("devsw_boot"))
Randall Spangler196e1772011-03-10 11:31:06 -0800147 return 1;
148
149 /* All other cases disallow debug. */
150 return 0;
151}
152
Randall Spanglerb47ed5a2011-02-23 13:05:40 -0800153
Randall Spangler71415712011-03-21 11:04:50 -0700154char* GetVdatLoadFirmwareDebug(char* dest, int size,
155 const VbSharedDataHeader* sh) {
156 snprintf(dest, size,
157 "Check A result=%d\n"
158 "Check B result=%d\n"
159 "Firmware index booted=0x%02x\n"
160 "TPM combined version at start=0x%08x\n"
161 "Lowest combined version from firmware=0x%08x\n",
162 sh->check_fw_a_result,
163 sh->check_fw_b_result,
164 sh->firmware_index,
165 sh->fw_version_tpm_start,
166 sh->fw_version_lowest);
167 return dest;
168}
169
170
171#define TRUNCATED "\n(truncated)\n"
172
173char* GetVdatLoadKernelDebug(char* dest, int size,
174 const VbSharedDataHeader* sh) {
175 int used = 0;
176 int first_call_tracked = 0;
177 int call;
178
179 /* Make sure we have space for truncation warning */
180 if (size < strlen(TRUNCATED) + 1)
181 return NULL;
182 size -= strlen(TRUNCATED) + 1;
183
184 used += snprintf(
185 dest + used, size - used,
186 "Calls to LoadKernel()=%d\n",
187 sh->lk_call_count);
188 if (used > size)
189 goto LoadKernelDebugExit;
190
191 /* Report on the last calls */
192 if (sh->lk_call_count > VBSD_MAX_KERNEL_CALLS)
193 first_call_tracked = sh->lk_call_count - VBSD_MAX_KERNEL_CALLS;
194 for (call = first_call_tracked; call < sh->lk_call_count; call++) {
195 const VbSharedDataKernelCall* shc =
196 sh->lk_calls + (call & (VBSD_MAX_KERNEL_CALLS - 1));
197 int first_part_tracked = 0;
198 int part;
199
200 used += snprintf(
201 dest + used, size - used,
202 "Call %d:\n"
203 " Boot flags=0x%02x\n"
204 " Boot mode=%d\n"
205 " Test error=%d\n"
206 " Return code=%d\n"
207 " Debug flags=0x%02x\n"
208 " Drive sectors=%" PRIu64 "\n"
209 " Sector size=%d\n"
210 " Check result=%d\n"
211 " Kernel partitions found=%d\n",
212 call + 1,
213 shc->boot_flags,
214 shc->boot_mode,
215 shc->test_error_num,
216 shc->return_code,
217 shc->flags,
218 shc->sector_count,
219 shc->sector_size,
220 shc->check_result,
221 shc->kernel_parts_found);
222 if (used > size)
223 goto LoadKernelDebugExit;
224
225 /* If we found too many partitions, only prints ones where the
226 * structure has info. */
227 if (shc->kernel_parts_found > VBSD_MAX_KERNEL_PARTS)
228 first_part_tracked = shc->kernel_parts_found - VBSD_MAX_KERNEL_PARTS;
229
230 /* Report on the partitions checked */
231 for (part = first_part_tracked; part < shc->kernel_parts_found; part++) {
232 const VbSharedDataKernelPart* shp =
233 shc->parts + (part & (VBSD_MAX_KERNEL_PARTS - 1));
234
235 used += snprintf(
236 dest + used, size - used,
237 " Kernel %d:\n"
238 " GPT index=%d\n"
239 " Start sector=%" PRIu64 "\n"
240 " Sector count=%" PRIu64 "\n"
241 " Combined version=0x%08x\n"
242 " Check result=%d\n"
243 " Debug flags=0x%02x\n",
244 part + 1,
245 shp->gpt_index,
246 shp->sector_start,
247 shp->sector_count,
248 shp->combined_version,
249 shp->check_result,
250 shp->flags);
251 if (used > size)
252 goto LoadKernelDebugExit;
253 }
254 }
255
256LoadKernelDebugExit:
257
258 /* Warn if data was truncated; we left space for this above. */
259 if (used > size)
260 strcat(dest, TRUNCATED);
261
262 return dest;
263}
264
265
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700266char* GetVdatString(char* dest, int size, VdatStringField field)
267{
Randall Spanglereb591952011-04-07 10:02:00 -0700268 VbSharedDataHeader* sh = VbSharedDataRead();
Randall Spangler71415712011-03-21 11:04:50 -0700269 char* value = dest;
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700270
Randall Spanglereb591952011-04-07 10:02:00 -0700271 if (!sh)
272 return NULL;
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700273
274 switch (field) {
275 case VDAT_STRING_TIMERS:
276 snprintf(dest, size,
277 "LFS=%" PRIu64 ",%" PRIu64
278 " LF=%" PRIu64 ",%" PRIu64
279 " LK=%" PRIu64 ",%" PRIu64,
280 sh->timer_load_firmware_start_enter,
281 sh->timer_load_firmware_start_exit,
282 sh->timer_load_firmware_enter,
283 sh->timer_load_firmware_exit,
284 sh->timer_load_kernel_enter,
285 sh->timer_load_kernel_exit);
286 break;
287
288 case VDAT_STRING_LOAD_FIRMWARE_DEBUG:
Randall Spangler71415712011-03-21 11:04:50 -0700289 value = GetVdatLoadFirmwareDebug(dest, size, sh);
290 break;
291
292 case VDAT_STRING_LOAD_KERNEL_DEBUG:
293 value = GetVdatLoadKernelDebug(dest, size, sh);
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700294 break;
295
296 default:
Randall Spanglereb591952011-04-07 10:02:00 -0700297 value = NULL;
298 break;
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700299 }
300
Randall Spanglereb591952011-04-07 10:02:00 -0700301 Free(sh);
Randall Spangler71415712011-03-21 11:04:50 -0700302 return value;
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700303}
304
305
306int GetVdatInt(VdatIntField field) {
Randall Spanglereb591952011-04-07 10:02:00 -0700307 VbSharedDataHeader* sh = VbSharedDataRead();
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700308 int value = -1;
309
Randall Spanglereb591952011-04-07 10:02:00 -0700310 if (!sh)
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700311 return -1;
312
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700313 switch (field) {
314 case VDAT_INT_FLAGS:
315 value = (int)sh->flags;
316 break;
Randall Spangler5ac39bf2011-03-17 17:58:56 -0700317 case VDAT_INT_FW_VERSION_TPM:
318 value = (int)sh->fw_version_tpm;
319 break;
320 case VDAT_INT_KERNEL_VERSION_TPM:
321 value = (int)sh->kernel_version_tpm;
322 break;
Randall Spanglercabe6b32011-03-18 12:44:27 -0700323 case VDAT_INT_TRIED_FIRMWARE_B:
324 value = (sh->flags & VBSD_FWB_TRIED ? 1 : 0);
325 break;
326 case VDAT_INT_KERNEL_KEY_VERIFIED:
327 value = (sh->flags & VBSD_KERNEL_KEY_VERIFIED ? 1 : 0);
328 break;
Randall Spangler7adcc602011-06-24 16:11:45 -0700329 case VDAT_INT_RECOVERY_REASON:
330 /* Field added in struct version 2 */
331 if (sh->struct_version >= 2)
332 value = sh->recovery_reason;
333 break;
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700334 }
335
Randall Spanglereb591952011-04-07 10:02:00 -0700336 Free(sh);
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700337 return value;
338}
339
340
Randall Spangler54218662011-02-07 11:20:20 -0800341int VbGetSystemPropertyInt(const char* name) {
Randall Spanglerc80fe652011-02-17 11:06:47 -0800342 int value = -1;
Randall Spangler54218662011-02-07 11:20:20 -0800343
Randall Spanglereb591952011-04-07 10:02:00 -0700344 /* Check architecture-dependent properties first */
345 value = VbGetArchPropertyInt(name);
346 if (-1 != value)
347 return value;
348
349 /* NV storage values */
Randall Spanglercabe6b32011-03-18 12:44:27 -0700350 else if (!strcasecmp(name,"kern_nv")) {
Randall Spangler618d17d2011-03-01 10:33:11 -0800351 value = VbGetNvStorage(VBNV_KERNEL_FIELD);
Randall Spanglerb4167142011-03-01 13:04:22 -0800352 } else if (!strcasecmp(name,"nvram_cleared")) {
353 value = VbGetNvStorage(VBNV_KERNEL_SETTINGS_RESET);
Randall Spanglerb17e8d32011-03-15 09:50:38 -0700354 } else if (!strcasecmp(name,"vbtest_errfunc")) {
355 value = VbGetNvStorage(VBNV_TEST_ERROR_FUNC);
356 } else if (!strcasecmp(name,"vbtest_errno")) {
357 value = VbGetNvStorage(VBNV_TEST_ERROR_NUM);
Randall Spanglereb591952011-04-07 10:02:00 -0700358 } else if (!strcasecmp(name,"recovery_request")) {
Randall Spangler0f8ffb12011-02-25 09:50:54 -0800359 value = VbGetNvStorage(VBNV_RECOVERY_REQUEST);
Randall Spanglere73302c2011-02-18 14:53:01 -0800360 } else if (!strcasecmp(name,"dbg_reset")) {
Randall Spangler0f8ffb12011-02-25 09:50:54 -0800361 value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE);
Randall Spanglere73302c2011-02-18 14:53:01 -0800362 } else if (!strcasecmp(name,"fwb_tries")) {
Randall Spangler0f8ffb12011-02-25 09:50:54 -0800363 value = VbGetNvStorage(VBNV_TRY_B_COUNT);
Randall Spanglerd7728232011-04-08 14:04:21 -0700364 } else if (!strcasecmp(name,"fwupdate_tries")) {
365 value = VbGetNvStorage(VBNV_KERNEL_FIELD);
366 if (value != -1)
367 value &= KERN_NV_FWUPDATE_TRIES_MASK;
Randall Spangler44a12762011-04-12 13:16:40 -0700368 } else if (!strcasecmp(name,"loc_idx")) {
369 value = VbGetNvStorage(VBNV_LOCALIZATION_INDEX);
Randall Spanglere73302c2011-02-18 14:53:01 -0800370 }
Randall Spanglerb47ed5a2011-02-23 13:05:40 -0800371 /* Other parameters */
Randall Spanglereb591952011-04-07 10:02:00 -0700372 else if (!strcasecmp(name,"cros_debug")) {
Randall Spangler196e1772011-03-10 11:31:06 -0800373 value = VbGetCrosDebug();
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700374 } else if (!strcasecmp(name,"vdat_flags")) {
375 value = GetVdatInt(VDAT_INT_FLAGS);
Randall Spangler5ac39bf2011-03-17 17:58:56 -0700376 } else if (!strcasecmp(name,"tpm_fwver")) {
377 value = GetVdatInt(VDAT_INT_FW_VERSION_TPM);
378 } else if (!strcasecmp(name,"tpm_kernver")) {
379 value = GetVdatInt(VDAT_INT_KERNEL_VERSION_TPM);
Randall Spanglercabe6b32011-03-18 12:44:27 -0700380 } else if (!strcasecmp(name,"tried_fwb")) {
381 value = GetVdatInt(VDAT_INT_TRIED_FIRMWARE_B);
Randall Spangler7adcc602011-06-24 16:11:45 -0700382 } else if (!strcasecmp(name,"recovery_reason")) {
383 value = GetVdatInt(VDAT_INT_RECOVERY_REASON);
Randall Spanglerb47ed5a2011-02-23 13:05:40 -0800384 }
Randall Spangler54218662011-02-07 11:20:20 -0800385
Randall Spanglerc80fe652011-02-17 11:06:47 -0800386 return value;
Randall Spangler54218662011-02-07 11:20:20 -0800387}
388
Randall Spangler54218662011-02-07 11:20:20 -0800389
Randall Spanglereb591952011-04-07 10:02:00 -0700390const char* VbGetSystemPropertyString(const char* name, char* dest, int size) {
391 /* Check architecture-dependent properties first */
392 if (VbGetArchPropertyString(name, dest, size))
393 return dest;
394
395 if (!strcasecmp(name,"kernkey_vfy")) {
Randall Spanglercabe6b32011-03-18 12:44:27 -0700396 switch(GetVdatInt(VDAT_INT_KERNEL_KEY_VERIFIED)) {
Randall Spangler17260282011-02-25 12:06:26 -0800397 case 0:
398 return "hash";
399 case 1:
400 return "sig";
401 default:
402 return NULL;
403 }
Randall Spanglerf4ba19d2011-03-17 16:10:21 -0700404 } else if (!strcasecmp(name, "vdat_timers")) {
405 return GetVdatString(dest, size, VDAT_STRING_TIMERS);
406 } else if (!strcasecmp(name, "vdat_lfdebug")) {
407 return GetVdatString(dest, size, VDAT_STRING_LOAD_FIRMWARE_DEBUG);
Randall Spangler71415712011-03-21 11:04:50 -0700408 } else if (!strcasecmp(name, "vdat_lkdebug")) {
409 return GetVdatString(dest, size, VDAT_STRING_LOAD_KERNEL_DEBUG);
Randall Spanglereb591952011-04-07 10:02:00 -0700410 }
411
412 return NULL;
Randall Spangler54218662011-02-07 11:20:20 -0800413}
414
415
Randall Spangler54218662011-02-07 11:20:20 -0800416int VbSetSystemPropertyInt(const char* name, int value) {
Randall Spanglereb591952011-04-07 10:02:00 -0700417 /* Check architecture-dependent properties first */
Randall Spanglerd7728232011-04-08 14:04:21 -0700418
Randall Spanglereb591952011-04-07 10:02:00 -0700419 if (0 == VbSetArchPropertyInt(name, value))
420 return 0;
Randall Spangler54218662011-02-07 11:20:20 -0800421
Randall Spanglereb591952011-04-07 10:02:00 -0700422 /* NV storage values */
Randall Spanglerb4167142011-03-01 13:04:22 -0800423 if (!strcasecmp(name,"nvram_cleared")) {
424 /* Can only clear this flag; it's set inside the NV storage library. */
425 return VbSetNvStorage(VBNV_KERNEL_SETTINGS_RESET, 0);
426 } else if (!strcasecmp(name,"kern_nv")) {
Randall Spangler618d17d2011-03-01 10:33:11 -0800427 return VbSetNvStorage(VBNV_KERNEL_FIELD, value);
Randall Spanglerb17e8d32011-03-15 09:50:38 -0700428 } else if (!strcasecmp(name,"vbtest_errfunc")) {
429 return VbSetNvStorage(VBNV_TEST_ERROR_FUNC, value);
430 } else if (!strcasecmp(name,"vbtest_errno")) {
431 return VbSetNvStorage(VBNV_TEST_ERROR_NUM, value);
Randall Spanglereb591952011-04-07 10:02:00 -0700432 } else if (!strcasecmp(name,"recovery_request")) {
433 return VbSetNvStorage(VBNV_RECOVERY_REQUEST, value);
Randall Spanglere73302c2011-02-18 14:53:01 -0800434 } else if (!strcasecmp(name,"dbg_reset")) {
Randall Spanglereb591952011-04-07 10:02:00 -0700435 return VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value);
Randall Spanglere73302c2011-02-18 14:53:01 -0800436 } else if (!strcasecmp(name,"fwb_tries")) {
Randall Spanglereb591952011-04-07 10:02:00 -0700437 return VbSetNvStorage(VBNV_TRY_B_COUNT, value);
Randall Spanglerd7728232011-04-08 14:04:21 -0700438 } else if (!strcasecmp(name,"fwupdate_tries")) {
439 int kern_nv = VbGetNvStorage(VBNV_KERNEL_FIELD);
440 if (kern_nv == -1)
441 return -1;
442 kern_nv &= ~KERN_NV_FWUPDATE_TRIES_MASK;
443 kern_nv |= (value & KERN_NV_FWUPDATE_TRIES_MASK);
444 return VbSetNvStorage(VBNV_KERNEL_FIELD, kern_nv);
Randall Spangler44a12762011-04-12 13:16:40 -0700445 } else if (!strcasecmp(name,"loc_idx")) {
446 return VbSetNvStorage(VBNV_LOCALIZATION_INDEX, value);
Randall Spanglere73302c2011-02-18 14:53:01 -0800447 }
448
Randall Spangler54218662011-02-07 11:20:20 -0800449 return -1;
450}
451
452
Randall Spangler54218662011-02-07 11:20:20 -0800453int VbSetSystemPropertyString(const char* name, const char* value) {
Randall Spanglereb591952011-04-07 10:02:00 -0700454 /* Chain to architecture-dependent properties */
455 return VbSetArchPropertyString(name, value);
Randall Spangler54218662011-02-07 11:20:20 -0800456}