summaryrefslogtreecommitdiff
path: root/host/lib/crossystem.c
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2016-04-07 12:21:03 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-04-12 05:49:26 -0700
commitaee6bd69fefac653cfc4a5679eb387d7c3280d14 (patch)
treef2756467870078563b99904eebf32e6d93211b1f /host/lib/crossystem.c
parenteb0c8cc39bb268a7dc88ed616a564f4d46f77a2c (diff)
downloadvboot-aee6bd69fefac653cfc4a5679eb387d7c3280d14.tar.gz
Support doing battery cut-off in firmware stage.
Add a new crossystem value "battery_cutoff_request" to indicate that next reboot should cut-off battery and shutdown during firmware stage. This request is primarily for factories to ship devices in an safe state. Previously we have done same thing by running "ectool battery-cutoff" but that creates a problem which "ectool" (and the one to request for cut-off) must live in developer mode while the device must be shipped in normal mode. The mode transition was solved by setting "disable_dev_request=1", but that flag is may get lost on x86 systems (having NV storage in CMOS) when the battery is cut-off . From the experience from Ryu, such settings (dev mode transition and battery cut-off) should be done together inside firmware execution so we can create a new flag, battery_cutoff_request, to finalize device properly. BRANCH=none BUG=chromium:601705 TEST=emerge-chell depthcharge vboot_reference chromeos-bootimage crossystem battery_cutoff_request=1 # Unplug AC adapter reboot # See device rebooted and then shutdown immediately. # Press power button and system won't boot. # Attach AC adapter and now system boots. CQ-DEPEND=CL:337596,CL:338193 Change-Id: I73ccae15b337cd65786106646546c67c155b8fa6 Reviewed-on: https://chromium-review.googlesource.com/337602 Commit-Ready: Hung-Te Lin <hungte@chromium.org> Tested-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'host/lib/crossystem.c')
-rw-r--r--host/lib/crossystem.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index bcbf4dd4..7c51927e 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -551,6 +551,8 @@ int VbGetSystemPropertyInt(const char* name) {
value = VbGetNvStorage(VBNV_BOOT_ON_AC_DETECT);
} else if (!strcasecmp(name, "try_ro_sync")) {
value = VbGetNvStorage(VBNV_TRY_RO_SYNC);
+ } else if (!strcasecmp(name, "battery_cutoff_request")) {
+ value = VbGetNvStorage(VBNV_BATTERY_CUTOFF_REQUEST);
}
return value;
@@ -687,6 +689,8 @@ int VbSetSystemPropertyInt(const char* name, int value) {
return VbSetNvStorage_WithBackup(VBNV_BOOT_ON_AC_DETECT, value);
} else if (!strcasecmp(name, "try_ro_sync")) {
return VbSetNvStorage_WithBackup(VBNV_TRY_RO_SYNC, value);
+ } else if (!strcasecmp(name, "battery_cutoff_request")) {
+ return VbSetNvStorage(VBNV_BATTERY_CUTOFF_REQUEST, value);
}
return -1;