summaryrefslogtreecommitdiff
path: root/common/vstore.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /common/vstore.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14695.107.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'common/vstore.c')
-rw-r--r--common/vstore.c127
1 files changed, 0 insertions, 127 deletions
diff --git a/common/vstore.c b/common/vstore.c
deleted file mode 100644
index 9b4636397c..0000000000
--- a/common/vstore.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Copyright 2015 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.
- */
-
-/*
- * Temporary secure storage commands for use by the host for verified boot
- * related activities such as storing the hash of verified firmware for use
- * in suspend/resume.
- *
- * There are a configurable number of vstore slots, with all slots having
- * the same size of EC_VSTORE_SLOT_SIZE (64 bytes).
- *
- * Slots can be written once per AP power-on and will then be locked and
- * cannot be written again until it is cleared in the CHIPSET_SHUTDOWN
- * or CHIPSET_RESET hooks.
- */
-
-#include "common.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "system.h"
-#include "util.h"
-
-#define VSTORE_SYSJUMP_TAG 0x5653 /* "VS" */
-#define VSTORE_HOOK_VERSION 1
-
-struct vstore_slot {
- uint8_t locked;
- uint8_t data[EC_VSTORE_SLOT_SIZE];
-};
-
-static struct vstore_slot vstore_slots[CONFIG_VSTORE_SLOT_COUNT];
-static const int vstore_size =
- sizeof(struct vstore_slot) * CONFIG_VSTORE_SLOT_COUNT;
-BUILD_ASSERT(ARRAY_SIZE(vstore_slots) <= EC_VSTORE_SLOT_MAX);
-
-/*
- * vstore_info - Get slot count and mask of locked slots.
- */
-static enum ec_status vstore_info(struct host_cmd_handler_args *args)
-{
- struct ec_response_vstore_info *r = args->response;
- int i;
-
- r->slot_count = CONFIG_VSTORE_SLOT_COUNT;
- r->slot_locked = 0;
- for (i = 0; i < CONFIG_VSTORE_SLOT_COUNT; i++)
- if (vstore_slots[i].locked)
- r->slot_locked |= 1 << i;
-
- args->response_size = sizeof(*r);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_VSTORE_INFO, vstore_info, EC_VER_MASK(0));
-
-/*
- * vstore_read - Read slot from temporary secure storage.
- *
- * Response is EC_VSTORE_SLOT_SIZE bytes of data.
- */
-static enum ec_status vstore_read(struct host_cmd_handler_args *args)
-{
- const struct ec_params_vstore_read *p = args->params;
- struct ec_response_vstore_read *r = args->response;
-
- if (p->slot >= CONFIG_VSTORE_SLOT_COUNT)
- return EC_RES_INVALID_PARAM;
-
- memcpy(r->data, vstore_slots[p->slot].data, EC_VSTORE_SLOT_SIZE);
-
- args->response_size = sizeof(*r);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_VSTORE_READ, vstore_read, EC_VER_MASK(0));
-
-/*
- * vstore_write - Write temporary secure storage slot and lock it.
- */
-static enum ec_status vstore_write(struct host_cmd_handler_args *args)
-{
- const struct ec_params_vstore_write *p = args->params;
- struct vstore_slot *slot;
-
- if (p->slot >= CONFIG_VSTORE_SLOT_COUNT)
- return EC_RES_INVALID_PARAM;
- slot = &vstore_slots[p->slot];
-
- if (slot->locked)
- return EC_RES_ACCESS_DENIED;
- slot->locked = 1;
- memcpy(slot->data, p->data, EC_VSTORE_SLOT_SIZE);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_VSTORE_WRITE, vstore_write, EC_VER_MASK(0));
-
-static void vstore_clear_lock(void)
-{
- int i;
-
- for (i = 0; i < CONFIG_VSTORE_SLOT_COUNT; i++)
- vstore_slots[i].locked = 0;
-}
-DECLARE_HOOK(HOOK_CHIPSET_RESET, vstore_clear_lock, HOOK_PRIO_DEFAULT);
-
-static void vstore_preserve_state(void)
-{
- system_add_jump_tag(VSTORE_SYSJUMP_TAG, VSTORE_HOOK_VERSION,
- vstore_size, vstore_slots);
-}
-DECLARE_HOOK(HOOK_SYSJUMP, vstore_preserve_state, HOOK_PRIO_DEFAULT);
-
-static void vstore_init(void)
-{
- const struct vstore_slot *prev;
- int version, size;
-
- prev = (const struct vstore_slot *)system_get_jump_tag(
- VSTORE_SYSJUMP_TAG, &version, &size);
-
- if (prev && version == VSTORE_HOOK_VERSION && size == vstore_size)
- memcpy(vstore_slots, prev, vstore_size);
-}
-DECLARE_HOOK(HOOK_INIT, vstore_init, HOOK_PRIO_DEFAULT);