diff options
author | Randall Spangler <rspangler@chromium.org> | 2018-05-18 14:27:42 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-22 21:57:12 -0700 |
commit | 9df26ce0f2a97bbc58b1807483fd22005e253b0f (patch) | |
tree | 651d4ff123841cdc0630b423e91e61395f894b68 /include | |
parent | 4ec57f14091c42e2f9502d1c17146a06fa105a88 (diff) | |
download | chrome-ec-9df26ce0f2a97bbc58b1807483fd22005e253b0f.tar.gz |
cr50: Refactor tracking vendor command origin
Added flags parameter to extension_route_command(). The caller now
specifies whether the command comes from the USB interface or the AP.
Moved USB-specific shuffling of response to embed result code into
usb_upgrade.c, so extension_route_command() can be more generic.
No change to permissions/behavior for existing commands.
ccd_command_wrapper() still sends vendor commands as if they come from
the AP. That's fixed in the next CL.
Reduces code size by 128 bytes
BUG=b:79983505
BRANCH=cr50
TEST=manual
Build with DEBUG_EXTENSION defined, to turn on printing each command
'ccd lock' comes from AP and works
From host, 'gscutil -I' comes from USB and fails
From AP, 'gscutil -t -I' comes from AP and works
Change-Id: I7136bb54073de9c5951a174c308151b1871c56f3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1068101
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/extension.h | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/include/extension.h b/include/extension.h index e5f183eb49..bec6bf3ffd 100644 --- a/include/extension.h +++ b/include/extension.h @@ -12,6 +12,16 @@ #include "common.h" #include "tpm_vendor_cmds.h" +/* Flags for vendor or extension commands */ +enum vendor_cmd_flags { + /* + * Command is coming from the USB interface (either via the vendor + * command endpoint or the console). If this flag is not present, + * the command is coming from the AP. + */ + VENDOR_CMD_FROM_USB = (1 << 0), +}; + /* * Type of function handling extension commands. * @@ -35,19 +45,17 @@ typedef enum vendor_cmd_rc (*extension_handler)(enum vendor_cmd_cc code, * @param command_code Code associated with a extension command handler. * @param buffer Data to be processd by the handler, the same space * is used for data returned by the handler. - * @command_size Size of the input data. - * @param size On input - max size of the buffer, on output - actual number of - * data returned by the handler. A single byte return + * @param in_size Size of the input data. + * @param out_size On input: max size of the buffer. On output: actual + * number of bytes returned by the handler; a single byte * usually indicates an error and contains the error code. + * @param flags Zero or more flags from vendor_cmd_flags. */ -void usb_extension_route_command(uint16_t command_code, +uint32_t extension_route_command(uint16_t command_code, void *buffer, - size_t command_size, - size_t *size); -uint32_t tpm_extension_route_command(uint16_t command_code, - void *buffer, - size_t command_size, - size_t *size); + size_t in_size, + size_t *out_size, + uint32_t flags); /* Pointer table */ struct extension_command { |