summaryrefslogtreecommitdiff
path: root/firmware/lib/vboot_nvstorage.c
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2016-04-07 12:21:03 +0800
committerChromeOS bot <3su6n15k.default@developer.gserviceaccount.com>2016-04-13 17:26:07 +0000
commit4bc9906f35507cb332456cb69f883fad4cdfcba2 (patch)
treecb9c968aa29832ac0d137a73a48406f5d7271ef1 /firmware/lib/vboot_nvstorage.c
parent37ae160e51581fd51f84ac478645251412f5ea86 (diff)
downloadvboot-firmware-glados-7820.315.B.tar.gz
Support doing battery cut-off in firmware stage.firmware-glados-7820.Bfirmware-glados-7820.315.B
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:338288,CL:338399 Original-Change-Id: I73ccae15b337cd65786106646546c67c155b8fa6 Original-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> (cherry picked from commit aee6bd69fefac653cfc4a5679eb387d7c3280d14) Change-Id: I563602ee8437f867720942df7f658a28378579aa Reviewed-on: https://chromium-review.googlesource.com/338178 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Tested-by: Duncan Laurie <dlaurie@chromium.org> Commit-Queue: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'firmware/lib/vboot_nvstorage.c')
-rw-r--r--firmware/lib/vboot_nvstorage.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c
index d022c5d3..c131f088 100644
--- a/firmware/lib/vboot_nvstorage.c
+++ b/firmware/lib/vboot_nvstorage.c
@@ -64,6 +64,7 @@
#define MISC_UNLOCK_FASTBOOT 0x01
#define MISC_BOOT_ON_AC_DETECT 0x02
#define MISC_TRY_RO_SYNC 0x04
+#define MISC_BATTERY_CUTOFF_REQUEST 0x08
#define KERNEL_FIELD_OFFSET 11
#define CRC_OFFSET 15
@@ -231,6 +232,11 @@ int VbNvGet(VbNvContext *context, VbNvParam param, uint32_t *dest)
*dest = (raw[MISC_OFFSET] & MISC_TRY_RO_SYNC) ? 1 : 0;
return 0;
+ case VBNV_BATTERY_CUTOFF_REQUEST:
+ *dest = (raw[MISC_OFFSET] & MISC_BATTERY_CUTOFF_REQUEST)
+ ? 1 : 0;
+ return 0;
+
default:
return 1;
}
@@ -456,6 +462,13 @@ int VbNvSet(VbNvContext *context, VbNvParam param, uint32_t value)
raw[MISC_OFFSET] &= ~MISC_TRY_RO_SYNC;
break;
+ case VBNV_BATTERY_CUTOFF_REQUEST:
+ if (value)
+ raw[MISC_OFFSET] |= MISC_BATTERY_CUTOFF_REQUEST;
+ else
+ raw[MISC_OFFSET] &= ~MISC_BATTERY_CUTOFF_REQUEST;
+ break;
+
default:
return 1;
}