diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-05-12 10:43:34 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-14 19:51:36 +0000 |
commit | 675f3a1a481aae3247e2d2af3e603b149cdaf4aa (patch) | |
tree | 628415b8ee391f3988920bbd561a91932cf6527b | |
parent | 4be909bf3b6e4cf1b131a8da8f023cd01f9df641 (diff) | |
download | chrome-ec-675f3a1a481aae3247e2d2af3e603b149cdaf4aa.tar.gz |
rollback: create private header file for use by unit tests
Expose definitions that we want to use in unit tests, but are internal
details that should not be used by other EC code using the rollback
functionality.
BRANCH=none
BUG=none
TEST=b:151105339
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ib81251cce63e0a8b929b6e7a8e1fc1ec4a664f5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2197619
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | common/rollback.c | 17 | ||||
-rw-r--r-- | common/rollback_private.h | 33 |
2 files changed, 35 insertions, 15 deletions
diff --git a/common/rollback.c b/common/rollback.c index 95fa86f9fd..b448f0514f 100644 --- a/common/rollback.c +++ b/common/rollback.c @@ -17,6 +17,7 @@ #include "mpu.h" #endif #include "rollback.h" +#include "rollback_private.h" #include "sha256.h" #include "system.h" #include "task.h" @@ -29,20 +30,6 @@ /* Number of rollback regions */ #define ROLLBACK_REGIONS 2 -/* - * Note: Do not change this structure without also updating - * common/firmware_image.S .image.ROLLBACK section. - */ -struct rollback_data { - int32_t id; /* Incrementing number to indicate which region to use. */ - int32_t rollback_min_version; -#ifdef CONFIG_ROLLBACK_SECRET_SIZE - uint8_t secret[CONFIG_ROLLBACK_SECRET_SIZE]; -#endif - /* cookie must always be last, as it validates the rest of the data. */ - uint32_t cookie; -}; - static int get_rollback_offset(int region) { #ifdef CONFIG_FLASH_MULTIPLE_REGION @@ -103,7 +90,7 @@ static void clear_rollback(struct rollback_data *data) #endif } -static int read_rollback(int region, struct rollback_data *data) +int read_rollback(int region, struct rollback_data *data) { int offset; int ret = EC_SUCCESS; diff --git a/common/rollback_private.h b/common/rollback_private.h new file mode 100644 index 0000000000..c757882f4f --- /dev/null +++ b/common/rollback_private.h @@ -0,0 +1,33 @@ +/* Copyright 2020 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. + */ + +/** Internal header file for rollback. + * + * EC code should not normally include this. These are exposed so they can be + * used by unit test code. + */ + +#ifndef __CROS_EC_ROLLBACK_PRIVATE_H +#define __CROS_EC_ROLLBACK_PRIVATE_H + +#include "config.h" + +/* + * Note: Do not change this structure without also updating + * common/firmware_image.S .image.ROLLBACK section. + */ +struct rollback_data { + int32_t id; /* Incrementing number to indicate which region to use. */ + int32_t rollback_min_version; +#ifdef CONFIG_ROLLBACK_SECRET_SIZE + uint8_t secret[CONFIG_ROLLBACK_SECRET_SIZE]; +#endif + /* cookie must always be last, as it validates the rest of the data. */ + uint32_t cookie; +}; + +int read_rollback(int region, struct rollback_data *data); + +#endif /* __CROS_EC_ROLLBACK_PRIVATE_H */ |