diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2020-04-22 18:35:44 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2020-05-14 18:38:39 +0000 |
commit | ca83aee50469799a9b70b03ef6bd3fc1e86d6c38 (patch) | |
tree | 0ad6a589a259294c0f3cd341b3b5a027810a5a97 /chip/g/usb_spi.h | |
parent | 69a887265d737c628a3c55a03b923917cf1b471e (diff) | |
download | chrome-ec-stabilize-13099.101.B-cr50_stab.tar.gz |
usb_spi: refactor to allow use in different contextsstabilize-quickfix-13099.93.B-cr50_stabstabilize-13099.94.B-cr50_stabstabilize-13099.90.B-cr50_stabstabilize-13099.85.B-cr50_stabstabilize-13099.73.B-cr50_stabstabilize-13099.72.B-cr50_stabstabilize-13099.70.B-cr50_stabstabilize-13099.118.B-cr50_stabstabilize-13099.110.B-cr50_stabstabilize-13099.101.B-cr50_stabrelease-R84-13099.B-cr50_stab
The code which allows to read a section of AP or EC flash and
calculate the section's SHA256 sum does not allow calculating the sum
over multiple non-adjacent flash areas.
This patch changes the implementation to allow calculations over more
than one region. Initialization, calculation and reporting of the
result become three separate API entries.
The loop counting the number of the read flash chunks, is being
simplified, a watchdog kick added to the brief loop interruptions, as
it turns out that sleeping alone is not enough to prevent watchdog
expiration when calculating hash over large SPI flash ranges.
Also simplified prototypes for usb_spi_board_enable() and
usb_spi_board_disable().
BUG=b:153764696
TEST=created an RO descriptor for the Atlas DUT and verified that
'gsctool -O' succeeds.
Cq-Depend: chrome-internal:2939596
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Change-Id: Iec7b8634c7c80ebc7600c5b708879eb322bc7fec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2163569
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'chip/g/usb_spi.h')
-rw-r--r-- | chip/g/usb_spi.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/chip/g/usb_spi.h b/chip/g/usb_spi.h index cedfe78485..0c2707df4f 100644 --- a/chip/g/usb_spi.h +++ b/chip/g/usb_spi.h @@ -8,6 +8,7 @@ /* USB SPI driver for Chrome EC */ #include "compile_time_macros.h" +#include "cryptoc/sha256.h" #include "hooks.h" #include "queue.h" #include "queue_policies.h" @@ -239,7 +240,11 @@ int usb_spi_interface(struct usb_spi_config const *config, * usb_spi_board_enable should return EC_SUCCESS on success or an error * otherwise. */ -int usb_spi_board_enable(struct usb_spi_config const *config); -void usb_spi_board_disable(struct usb_spi_config const *config); +int usb_spi_board_enable(int host); +void usb_spi_board_disable(void); + +int usb_spi_sha256_start(HASH_CTX *ctx); +int usb_spi_sha256_update(HASH_CTX *ctx, uint32_t offset, uint32_t size); +void usb_spi_sha256_final(HASH_CTX *ctx, void *digest, size_t digest_size); #endif /* __CROS_EC_USB_SPI_H */ |