summaryrefslogtreecommitdiff
path: root/firmware/lib
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib')
-rw-r--r--firmware/lib/vboot_api_kernel.c12
-rw-r--r--firmware/lib/vboot_nvstorage.c13
2 files changed, 25 insertions, 0 deletions
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index fff30561..c3362789 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -1082,6 +1082,7 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
VbError_t retval = VBERROR_SUCCESS;
LoadKernelParams p;
uint32_t tpm_status = 0;
+ uint32_t battery_cutoff = 0;
/* Start timer */
shared->timer_vb_select_and_load_kernel_enter = VbExGetTimer();
@@ -1138,6 +1139,17 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
if (retval != VBERROR_SUCCESS)
goto VbSelectAndLoadKernel_exit;
+ /* Check if we need to cut-off battery. This must be done after EC
+ * firmware updating and before kernel started. */
+ VbNvGet(&vnc, VBNV_BATTERY_CUTOFF_REQUEST, &battery_cutoff);
+ if (battery_cutoff) {
+ VBDEBUG(("Request to cut-off battery\n"));
+ VbNvSet(&vnc, VBNV_BATTERY_CUTOFF_REQUEST, 0);
+ VbExEcBatteryCutOff();
+ retval = VBERROR_SHUTDOWN_REQUESTED;
+ goto VbSelectAndLoadKernel_exit;
+ }
+
/* Read kernel version from the TPM. Ignore errors in recovery mode. */
tpm_status = RollbackKernelRead(&shared->kernel_version_tpm);
if (0 != tpm_status) {
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;
}