summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2014-12-12 09:40:42 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-02 03:19:48 +0000
commit43c6f1f06daadac27edc6e1c15ce9c9fa46271e4 (patch)
treec4ab0abb45a4334de91330cdc5970ade22ba1a67
parent9cb62174782f792b439b726f7d05613ea43ebc24 (diff)
downloadvboot-firmware-gnawty-5216.239.B.tar.gz
CHERRY-PICK: vboot: Handle GBB_FLAG_DISABLE_LID_SHUTDOWNfirmware-gnawty-5216.239.B
Handle GBB_FLAG_DISABLE_LID_SHUTDOWN to disable lid-triggered system shutdown. BUG=none BRANCH=Gnawty TEST=Manual on Gnawty, with corresponding depthcharge change. Set GBB flag 0x1000 and disable powerd launch on boot. Close lid and issue 'reboot' command over ssh. Verify system reboots successfully into OS. Original Change-Id: Id2731508296a5ba9229f969f8224565d64f3d4a3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/234995 Reviewed-by: Randall Spangler <rspangler@chromium.org> Change-Id: Ibe0eec0d3235d325063b72c8bfd5ad7e010c4871 Reviewed-on: https://chromium-review.googlesource.com/263202 Reviewed-by: Shawn N <shawnn@chromium.org> Tested-by: T.H. Lin <T.H_Lin@quantatw.com> Commit-Queue: Shawn N <shawnn@chromium.org> (cherry picked from commit 894ad82932bb1b867b57578ff5a143a813d00d40) Reviewed-on: https://chromium-review.googlesource.com/274260 Tested-by: Katherine Hsieh <Katherine.Hsieh@quantatw.com> Commit-Queue: Katherine Hsieh <Katherine.Hsieh@quantatw.com>
-rw-r--r--firmware/include/vboot_api.h17
-rw-r--r--firmware/lib/vboot_api_kernel.c25
2 files changed, 35 insertions, 7 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 0ae6c76b..9e1668cf 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -804,9 +804,9 @@ VbError_t VbExProtectFlash(enum VbProtectFlash_t region);
/**
* Check if the firmware needs to shut down the system.
*
- * Returns 1 if a shutdown is being requested (for example, the user has
- * pressed the power button or closed the lid), or 0 if a shutdown is not being
- * requested.
+ * Returns a non-zero VB_SHUTDOWN_REQUEST mask indicating the reason(s) for
+ * shutdown if a shutdown is being requested (see VB_SHUTDOWN_REQUEST_*), or 0
+ * if a shutdown is not being requested.
*
* NOTE: When we're displaying a screen, pressing the power button should shut
* down the computer. We need a way to break out of our control loop so this
@@ -814,6 +814,17 @@ VbError_t VbExProtectFlash(enum VbProtectFlash_t region);
*/
uint32_t VbExIsShutdownRequested(void);
+/*
+ * Shutdown requested for a reason which is not defined among other
+ * VB_SHUTDOWN_REQUEST_* values. This must be defined as 1 for backward
+ * compatibility with old versions of the API.
+ */
+#define VB_SHUTDOWN_REQUEST_OTHER 0x00000001
+/* Shutdown requested due to a lid switch being closed. */
+#define VB_SHUTDOWN_REQUEST_LID_CLOSED 0x00000002
+/* Shutdown requested due to a power button being pressed. */
+#define VB_SHUTDOWN_REQUEST_POWER_BUTTON 0x00000004
+
/**
* Expose the BIOS' built-in decompression routine to the vboot wrapper. The
* caller must know how large the uncompressed data will be and must manage
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 18d00ae7..55042804 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -42,6 +42,23 @@ static void VbSetRecoveryRequest(uint32_t recovery_request)
}
/**
+ * Checks GBB flags against VbExIsShutdownRequested() shutdown request to
+ * determine if a shutdown is required.
+ *
+ * Returns true if a shutdown is required and false if no shutdown is required.
+ */
+static int VbWantShutdown(uint32_t gbb_flags)
+{
+ uint32_t shutdown_request = VbExIsShutdownRequested();
+
+ /* If desired, ignore shutdown request due to lid closure. */
+ if (gbb_flags & GBB_FLAG_DISABLE_LID_SHUTDOWN)
+ shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED;
+
+ return !!shutdown_request;
+}
+
+/**
* Attempt loading a kernel from the specified type(s) of disks.
*
* If successful, sets p->disk_handle to the disk for the kernel and returns
@@ -138,7 +155,7 @@ int VbUserConfirms(VbCommonParams *cparams, int space_means_no)
/* Await further instructions */
while (1) {
- if (VbExIsShutdownRequested())
+ if (VbWantShutdown(cparams->gbb->flags))
return -1;
key = VbExKeyboardRead();
switch (key) {
@@ -203,7 +220,7 @@ VbError_t VbBootDeveloper(VbCommonParams *cparams, LoadKernelParams *p)
do {
uint32_t key;
- if (VbExIsShutdownRequested()) {
+ if (VbWantShutdown(gbb->flags)) {
VBDEBUG(("VbBootDeveloper() - shutdown requested!\n"));
VbAudioClose(audio);
return VBERROR_SHUTDOWN_REQUESTED;
@@ -457,7 +474,7 @@ VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p)
for (i = 0; i < REC_DISK_DELAY; i += REC_KEY_DELAY) {
VbCheckDisplayKey(cparams, VbExKeyboardRead(),
&vnc);
- if (VbExIsShutdownRequested())
+ if (VbWantShutdown(cparams->gbb->flags))
return VBERROR_SHUTDOWN_REQUESTED;
VbExSleepMs(REC_KEY_DELAY);
}
@@ -536,7 +553,7 @@ VbError_t VbBootRecovery(VbCommonParams *cparams, LoadKernelParams *p)
} else {
VbCheckDisplayKey(cparams, key, &vnc);
}
- if (VbExIsShutdownRequested())
+ if (VbWantShutdown(cparams->gbb->flags))
return VBERROR_SHUTDOWN_REQUESTED;
VbExSleepMs(REC_KEY_DELAY);
}