From 49945a6a88c130c8807b65a17b31ace6f2eec4e4 Mon Sep 17 00:00:00 2001 From: Jack Rosenthal Date: Mon, 27 Jun 2022 15:18:05 -0600 Subject: include/vboot.h: Format with clang-format BUG=b:236386294 BRANCH=none TEST=none Change-Id: I427a43cbfa7022c80b4cf4d4314f3048e00e2833 Signed-off-by: Jack Rosenthal Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730453 Reviewed-by: Jeremy Bettis --- include/vboot.h | 67 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'include/vboot.h') diff --git a/include/vboot.h b/include/vboot.h index 52ccae6e90..2df76b9e03 100644 --- a/include/vboot.h +++ b/include/vboot.h @@ -31,7 +31,6 @@ int vb21_is_packed_key_valid(const struct vb21_packed_key *key); int vb21_is_signature_valid(const struct vb21_signature *sig, const struct vb21_packed_key *key); - /** * Returns the public key in RO that was used to sign RW. * @@ -58,8 +57,8 @@ int vboot_is_padding_valid(const uint8_t *data, uint32_t start, uint32_t end); * @param sig Signature of * @return EC_SUCCESS or EC_ERROR_* */ -int vboot_verify(const uint8_t *data, int len, - const struct rsa_public_key *key, const uint8_t *sig); +int vboot_verify(const uint8_t *data, int len, const struct rsa_public_key *key, + const uint8_t *sig); /** * Entry point of EC EFS @@ -100,19 +99,19 @@ __override_proto void board_enable_packet_mode(bool enable); void packet_mode_interrupt(enum gpio_signal signal); /* Maximum number of times EC retries packet transmission before giving up. */ -#define CR50_COMM_MAX_RETRY 5 +#define CR50_COMM_MAX_RETRY 5 /* EC's timeout for packet transmission to Cr50. */ -#define CR50_COMM_TIMEOUT (50 * MSEC) +#define CR50_COMM_TIMEOUT (50 * MSEC) /* Preamble character repeated before the packet header starts. */ -#define CR50_COMM_PREAMBLE 0xec +#define CR50_COMM_PREAMBLE 0xec /* Magic characters used to identify ec-cr50-comm packets */ -#define CR50_PACKET_MAGIC 0x4345 /* 'EC' in little endian */ +#define CR50_PACKET_MAGIC 0x4345 /* 'EC' in little endian */ /* version of struct cr50_comm_request */ -#define CR50_COMM_PACKET_VERSION (0 << 4 | 0 << 0) /* 0.0 */ +#define CR50_COMM_PACKET_VERSION (0 << 4 | 0 << 0) /* 0.0 */ /** * EC-Cr50 data frame looks like the following: @@ -125,11 +124,11 @@ void packet_mode_interrupt(enum gpio_signal signal); */ struct cr50_comm_request { /* Header */ - uint16_t magic; /* CR50_PACKET_MAGIC */ - uint8_t struct_version; /* version of this struct msb:lsb=major:minor */ - uint8_t crc; /* checksum computed from all bytes after crc */ - uint16_t type; /* CR50_CMD_* */ - uint8_t size; /* Payload size. Be easy on Cr50 buffer. */ + uint16_t magic; /* CR50_PACKET_MAGIC */ + uint8_t struct_version; /* version of this struct msb:lsb=major:minor */ + uint8_t crc; /* checksum computed from all bytes after crc */ + uint16_t type; /* CR50_CMD_* */ + uint8_t size; /* Payload size. Be easy on Cr50 buffer. */ /* Payload */ uint8_t data[]; } __packed; @@ -138,33 +137,33 @@ struct cr50_comm_response { uint16_t error; } __packed; -#define CR50_COMM_MAX_REQUEST_SIZE (sizeof(struct cr50_comm_request) \ - + UINT8_MAX) -#define CR50_UART_RX_BUFFER_SIZE 32 /* TODO: Get from Cr50 header */ +#define CR50_COMM_MAX_REQUEST_SIZE \ + (sizeof(struct cr50_comm_request) + UINT8_MAX) +#define CR50_UART_RX_BUFFER_SIZE 32 /* TODO: Get from Cr50 header */ /* commands */ enum cr50_comm_cmd { - CR50_COMM_CMD_HELLO = 0x0000, - CR50_COMM_CMD_SET_BOOT_MODE = 0x0001, - CR50_COMM_CMD_VERIFY_HASH = 0x0002, - CR50_COMM_CMD_LIMIT = 0xffff, + CR50_COMM_CMD_HELLO = 0x0000, + CR50_COMM_CMD_SET_BOOT_MODE = 0x0001, + CR50_COMM_CMD_VERIFY_HASH = 0x0002, + CR50_COMM_CMD_LIMIT = 0xffff, } __packed; BUILD_ASSERT(sizeof(enum cr50_comm_cmd) == sizeof(uint16_t)); -#define CR50_COMM_ERR_PREFIX 0xec +#define CR50_COMM_ERR_PREFIX 0xec /* return code */ enum cr50_comm_err { - CR50_COMM_SUCCESS = 0xec00, - CR50_COMM_ERR_UNKNOWN = 0xec01, - CR50_COMM_ERR_MAGIC = 0xec02, - CR50_COMM_ERR_CRC = 0xec03, - CR50_COMM_ERR_SIZE = 0xec04, - CR50_COMM_ERR_TIMEOUT = 0xec05, /* Generated by EC */ - CR50_COMM_ERR_UNDEFINED_CMD = 0xec06, - CR50_COMM_ERR_BAD_PAYLOAD = 0xec07, - CR50_COMM_ERR_STRUCT_VERSION = 0xec08, - CR50_COMM_ERR_NVMEM = 0xec09, + CR50_COMM_SUCCESS = 0xec00, + CR50_COMM_ERR_UNKNOWN = 0xec01, + CR50_COMM_ERR_MAGIC = 0xec02, + CR50_COMM_ERR_CRC = 0xec03, + CR50_COMM_ERR_SIZE = 0xec04, + CR50_COMM_ERR_TIMEOUT = 0xec05, /* Generated by EC */ + CR50_COMM_ERR_UNDEFINED_CMD = 0xec06, + CR50_COMM_ERR_BAD_PAYLOAD = 0xec07, + CR50_COMM_ERR_STRUCT_VERSION = 0xec08, + CR50_COMM_ERR_NVMEM = 0xec09, } __packed; BUILD_ASSERT(sizeof(enum cr50_comm_err) == sizeof(uint16_t)); @@ -173,8 +172,8 @@ BUILD_ASSERT(sizeof(enum cr50_comm_err) == sizeof(uint16_t)); * BIT(0) : RECOVERY flag */ enum boot_mode { - BOOT_MODE_NORMAL = 0x00, - BOOT_MODE_NO_BOOT = 0x01, + BOOT_MODE_NORMAL = 0x00, + BOOT_MODE_NO_BOOT = 0x01, } __packed; BUILD_ASSERT(sizeof(enum boot_mode) == sizeof(uint8_t)); @@ -187,4 +186,4 @@ BUILD_ASSERT(sizeof(enum boot_mode) == sizeof(uint8_t)); */ __override_proto bool vboot_allow_usb_pd(void); -#endif /* __CROS_EC_INCLUDE_VBOOT_H */ +#endif /* __CROS_EC_INCLUDE_VBOOT_H */ -- cgit v1.2.1 From 84ce87820dfd04af120f3bca4f884e7b10f39831 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 26 Aug 2022 16:56:48 -0600 Subject: zephyr: Add new test for vboot efs2 This covers the cases in vboot_main. Next is to move the next level down and emulate the communication with the cr50 as well. Add new test hooks to vboot/efs2.c, and the flash emul. BRANCH=None BUG=None TEST=./twister Signed-off-by: Jeremy Bettis Change-Id: Icca8dde3731a91645eabbf2bc547c84a51cb1474 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3858041 Tested-by: Jeremy Bettis Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis Reviewed-by: Simon Glass --- include/vboot.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/vboot.h') diff --git a/include/vboot.h b/include/vboot.h index 2df76b9e03..ce6a2388c0 100644 --- a/include/vboot.h +++ b/include/vboot.h @@ -186,4 +186,11 @@ BUILD_ASSERT(sizeof(enum boot_mode) == sizeof(uint8_t)); */ __override_proto bool vboot_allow_usb_pd(void); +#ifdef TEST_BUILD +/** + * Set the vboot_allow_usb_pd flag to false. + */ +__test_only void vboot_disable_pd(void); +#endif + #endif /* __CROS_EC_INCLUDE_VBOOT_H */ -- cgit v1.2.1 From 71b2ef709dcb14260f5fdaa3ab4ced005a29fb46 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 12 Sep 2022 14:54:36 -0400 Subject: Update license boilerplate text in source code files Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis Reviewed-by: Jack Rosenthal --- include/vboot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/vboot.h') diff --git a/include/vboot.h b/include/vboot.h index ce6a2388c0..55359e8044 100644 --- a/include/vboot.h +++ b/include/vboot.h @@ -1,4 +1,4 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. +/* Copyright 2017 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -- cgit v1.2.1