summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-07 15:48:04 -0700
committerGerrit <chrome-bot@google.com>2012-07-07 19:10:24 -0700
commit053b7b682c60eb7bcf55a079ff7afccccef82fa6 (patch)
treeb7bdc361954769143897653d3e2bd6672f037844
parentb2ac7fbbbf05fecfbabd37f6a2e4b268c9ac330f (diff)
downloadvboot-053b7b682c60eb7bcf55a079ff7afccccef82fa6.tar.gz
Stub out new vboot APIs for EC software sync
BUG=chrome-os-partner:11087 TEST=make sure it builds; APIs aren't used yet. Change-Id: If86f3465a889b8fa87cf225d2b9876fe79311327 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/26875 Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--firmware/include/vboot_api.h53
-rw-r--r--firmware/stub/vboot_api_stub.c44
2 files changed, 89 insertions, 8 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 08e61ad8..2a418ad3 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -601,6 +601,51 @@ uint32_t VbExKeyboardRead(void);
/*****************************************************************************/
+/* Embedded controller (EC) */
+
+/* This is called only if the system implements a keyboard-based (virtual)
+ * developer switch. It must return true only if the system has an embedded
+ * controller which is provably running in its RO firmware at the time the
+ * function is called. */
+int VbExTrustEC(void);
+
+/* Check if the EC is currently running rewritable code.
+ *
+ * If the EC is in RO code, sets *in_rw=0.
+ * If the EC is in RW code, sets *in_rw non-zero.
+ * If the current EC image is unknown, returns error. */
+VbError_t VbExEcRunningRW(int *in_rw);
+
+/* Request the EC jump to its rewritable code. If successful, returns
+ * when the EC has booting its RW code far enough to respond to
+ * subsequent commands. Does nothing if the EC is already in its
+ * rewritable code. */
+VbError_t VbExEcJumpToRW(void);
+
+/* Cold-reboot the EC into read-only code. This also reboots the main
+ * processor, so this function only returns if there was an error. */
+VbError_t VbExEcRebootToRO(void);
+
+/* Tell the EC to stay in RO code until it reboots. Subsequent calls to
+ * VbExEcJumpToRW() this boot will fail. Fails if the EC is not currently in
+ * RO code. */
+VbError_t VbExEcStayInRO(void);
+
+/* Read the SHA-256 hash of the rewriteable EC image. */
+VbError_t VbExEcHashRW(const uint8_t **hash, int *hash_size);
+
+/* Get the expected contents of the EC image as stored in the main firmware. */
+VbError_t VbExEcGetExpectedRW(const uint8_t **image, int *image_size);
+
+/* Update the EC rewritable image. */
+VbError_t VbExEcUpdateRW(const uint8_t *image, int image_size);
+
+/* Lock the EC code to prevent updates until the EC is rebooted.
+ * Subsequent calls to VbExEcUpdateRW() this boot will fail. */
+VbError_t VbExEcProtectRW(void);
+
+
+/*****************************************************************************/
/* Misc */
/* Checks if the firmware needs to shut down the system.
@@ -624,10 +669,4 @@ VbError_t VbExDecompress(void *inbuf, uint32_t in_size,
void *outbuf, uint32_t *out_size);
-/* This is called only if the system implements a keyboard-based (virtual)
- * developer switch. It must return true only if the system has an embedded
- * controller which is provably running in its RO firmware at the time the
- * function is called. */
-int VbExTrustEC(void);
-
#endif /* VBOOT_REFERENCE_VBOOT_API_H_ */
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index 9a13448f..6452e97d 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -145,3 +145,45 @@ VbError_t VbExDecompress(void *inbuf, uint32_t in_size,
int VbExTrustEC(void) {
return 1;
}
+
+VbError_t VbExEcRunningRW(int *in_rw) {
+ *in_rw = 0;
+ return VBERROR_SUCCESS;
+}
+
+VbError_t VbExEcJumpToRW(void) {
+ return VBERROR_SUCCESS;
+}
+
+VbError_t VbExEcRebootToRO(void) {
+ /* Nothing to reboot, so all we can do is return failure. */
+ return VBERROR_UNKNOWN;
+}
+
+VbError_t VbExEcStayInRO(void) {
+ return VBERROR_SUCCESS;
+}
+
+#define SHA256_HASH_SIZE 32
+
+VbError_t VbExEcHashRW(const uint8_t **hash, int *hash_size) {
+ static const uint8_t fake_hash[32] = {1, 2, 3, 4};
+ *hash = fake_hash;
+ *hash_size = sizeof(fake_hash);
+ return VBERROR_SUCCESS;
+}
+
+VbError_t VbExEcGetExpectedRW(const uint8_t **image, int *image_size) {
+ static const uint8_t fake_image[64] = {5, 6, 7, 8};
+ *image = fake_image;
+ *image_size = sizeof(fake_image);
+ return VBERROR_SUCCESS;
+}
+
+VbError_t VbExEcUpdateRW(const uint8_t *image, int image_size) {
+ return VBERROR_SUCCESS;
+}
+
+VbError_t VbExEcProtectRW(void) {
+ return VBERROR_SUCCESS;
+}