summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2011-04-08 14:04:21 -0700
committerRandall Spangler <rspangler@chromium.org>2011-04-08 14:04:21 -0700
commitd7728233dd7b3d772ce840c5477bcacc536ceb5d (patch)
treed7f05af88e209149b979b96016a304c732b70f14
parent824906b9dbd7d5c883949acf404a008fe17b1da7 (diff)
downloadvboot-d7728233dd7b3d772ce840c5477bcacc536ceb5d.tar.gz
Add crossystem fwupdate_tries and fix nv storage writes
Change-Id: I1835f4867de80aa3764e4a4c6d90b3fde2dc4308 R=reinauer@chromium.org BUG=chromium_os:13672 TEST=manual crossystem kern_nv=3 crossystem fwupdate_tries # should print 3 crossystem fwupdate_tries=15 crossystem kern_nv # should print 0x0000000F crossystem kern_nv=0 crossystem fwupdate_tries # should print 0 Review URL: http://codereview.chromium.org/6813056
-rw-r--r--host/lib/crossystem.c18
-rw-r--r--utility/crossystem_main.c1
2 files changed, 18 insertions, 1 deletions
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 2e29d04d..1c3fcc25 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -41,6 +41,10 @@ typedef enum VdatIntField {
} VdatIntField;
+/* Masks for kern_nv usage by kernel */
+#define KERN_NV_FWUPDATE_TRIES_MASK 0x0000000F
+
+
/* Return true if the FWID starts with the specified string. */
int FwidStartsWith(const char *start) {
char fwid[128];
@@ -93,7 +97,7 @@ int VbSetNvStorage(VbNvParam param, int value) {
goto VbSetNvCleanup;
if (vnc.raw_changed) {
- if (0 != VbReadNvStorage(&vnc))
+ if (0 != VbWriteNvStorage(&vnc))
goto VbSetNvCleanup;
}
@@ -351,6 +355,10 @@ int VbGetSystemPropertyInt(const char* name) {
value = VbGetNvStorage(VBNV_DEBUG_RESET_MODE);
} else if (!strcasecmp(name,"fwb_tries")) {
value = VbGetNvStorage(VBNV_TRY_B_COUNT);
+ } else if (!strcasecmp(name,"fwupdate_tries")) {
+ value = VbGetNvStorage(VBNV_KERNEL_FIELD);
+ if (value != -1)
+ value &= KERN_NV_FWUPDATE_TRIES_MASK;
}
/* Other parameters */
else if (!strcasecmp(name,"cros_debug")) {
@@ -397,6 +405,7 @@ const char* VbGetSystemPropertyString(const char* name, char* dest, int size) {
int VbSetSystemPropertyInt(const char* name, int value) {
/* Check architecture-dependent properties first */
+
if (0 == VbSetArchPropertyInt(name, value))
return 0;
@@ -416,6 +425,13 @@ int VbSetSystemPropertyInt(const char* name, int value) {
return VbSetNvStorage(VBNV_DEBUG_RESET_MODE, value);
} else if (!strcasecmp(name,"fwb_tries")) {
return VbSetNvStorage(VBNV_TRY_B_COUNT, value);
+ } else if (!strcasecmp(name,"fwupdate_tries")) {
+ int kern_nv = VbGetNvStorage(VBNV_KERNEL_FIELD);
+ if (kern_nv == -1)
+ return -1;
+ kern_nv &= ~KERN_NV_FWUPDATE_TRIES_MASK;
+ kern_nv |= (value & KERN_NV_FWUPDATE_TRIES_MASK);
+ return VbSetNvStorage(VBNV_KERNEL_FIELD, kern_nv);
}
return -1;
diff --git a/utility/crossystem_main.c b/utility/crossystem_main.c
index 133ab007..0d44b99a 100644
--- a/utility/crossystem_main.c
+++ b/utility/crossystem_main.c
@@ -62,6 +62,7 @@ const Param sys_param_list[] = {
{"recovery_request", CAN_WRITE, "Recovery mode request (writable)"},
{"dbg_reset", CAN_WRITE, "Debug reset mode request (writable)"},
{"fwb_tries", CAN_WRITE, "Try firmware B count (writable)"},
+ {"fwupdate_tries", CAN_WRITE, "Times to try OS firmware update (writable)"},
{"vbtest_errfunc", CAN_WRITE, "Verified boot test error function (writable)"},
{"vbtest_errno", CAN_WRITE, "Verified boot test error number (writable)"},
/* Fields not shown in a print-all list */