summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2022-09-14 12:15:29 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-05 01:51:14 +0000
commitfc456da1d13fa0791528d18cb4982f50257f3c57 (patch)
treea3b472155abdbaa028586b19a159214de03d95ef
parent5473aa650018ad48c57086e10249b9568106e7b6 (diff)
downloadchrome-ec-fc456da1d13fa0791528d18cb4982f50257f3c57.tar.gz
gsctool: adjust CCD info v1 capabilities representation
The gsctool utility expects the 64 capabilities values to be represented as two u32 quantities in big endian format, where each two bits represent current and default states for various capabilities. Ti50 represents the same values as single u64 little endian values. This patch modifies the cpabilities values to match expectations in case ccd_info structure is of version 1. BUG=b:244750201 TEST=capalbilities display on the Ti50 console and in gsctool output are the same in both cases when CCD is opened and locked: localhost # ./gsctool -a -I State: Opened Password: None Flags: 000000 Capabilities, current and default: UartGscRxAPTx Y Always UartGscTxAPRx Y Always UartGscRxECTx Y Always UartGscTxECRx Y IfOpened UartGscRxFpmcuTx Y Always UartGscTxFpmcuRx Y IfOpened FlashAP Y IfOpened FlashEC Y IfOpened OverrideWP Y IfOpened RebootECAP Y IfOpened GscFullConsole Y IfOpened UnlockNoReboot Y Always UnlockNoShortPP Y Always OpenNoTPMWipe Y IfOpened OpenNoLongPP Y IfOpened RemoveBatteryBypassPP Y Always I2C Y IfOpened FlashRead Y Always OpenNoDevMode Y Always OpenFromUSB Y Always OverrideBatt Y IfOpened BootUnverifiedRo Y Default CCD caps bitmap: 0x3fffff Capabilities are default. localhost # ./gsctool -a -I State: Locked Password: None Flags: 000000 Capabilities, current and default: UartGscRxAPTx Y Always UartGscTxAPRx Y Always UartGscRxECTx Y Always UartGscTxECRx - IfOpened UartGscRxFpmcuTx Y Always UartGscTxFpmcuRx - IfOpened FlashAP - IfOpened FlashEC - IfOpened OverrideWP - IfOpened RebootECAP - IfOpened GscFullConsole - IfOpened UnlockNoReboot Y Always UnlockNoShortPP Y Always OpenNoTPMWipe - IfOpened OpenNoLongPP - IfOpened RemoveBatteryBypassPP Y Always I2C - IfOpened FlashRead Y Always OpenNoDevMode Y Always OpenFromUSB Y Always OverrideBatt - IfOpened BootUnverifiedRo - Default CCD caps bitmap: 0xe9817 Capabilities are default. Signed-off-by: Vadim Bendebury <vbendeb@google.com> Change-Id: I41e0ea22265cdb5aaaff33be4ba79030e402ee1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3895514 Reviewed-by: Mary Ruthven <mruthven@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> (cherry picked from commit eb3cedf0d8d6ab7fc638f40e30b20d37acdb6df9) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3929216 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Tested-by: Mary Ruthven <mruthven@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Mary Ruthven <mruthven@chromium.org> (cherry picked from commit 7dcbb31861abefc4b7523970879b1a740f2f8e8b) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3935297
-rw-r--r--extra/usb_updater/gsctool.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c
index c2e189dea4..ff4857de1d 100644
--- a/extra/usb_updater/gsctool.c
+++ b/extra/usb_updater/gsctool.c
@@ -2283,6 +2283,18 @@ static void print_ccd_info(void *response, size_t response_size)
(uint8_t *)response +
sizeof(struct ccd_info_response_header),
sizeof(ccd_info));
+ /*
+ * V1 CCD info structure has the capabilities bitmaps
+ * represented as a single little endian u64, whereas this
+ * utility expects it to be two big endian u32s. This function
+ * fixes the V1 representation.
+ */
+ for (i = 0; i < ARRAY_SIZE(ccd_info.ccd_caps_current); i++) {
+ ccd_info.ccd_caps_current[i] =
+ htobe32(ccd_info.ccd_caps_current[i]);
+ ccd_info.ccd_caps_defaults[i] =
+ htobe32(ccd_info.ccd_caps_defaults[i]);
+ }
} else if (response_size == CCD_INFO_V0_SIZE) {
ccd_info_version = 0; /* Default, Cr50 case. */
memcpy(&ccd_info, response, sizeof(ccd_info));