summaryrefslogtreecommitdiff
path: root/common/extension.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2018-05-18 15:24:25 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-23 20:35:12 -0700
commit57ed31bcc5af3d79a24dfc1937560c922685d280 (patch)
tree7e3c06a0b2733fc94c46801e76c91a334967a702 /common/extension.c
parentf07e300fe457575394c21d040cfc80e6dc2829f0 (diff)
downloadchrome-ec-57ed31bcc5af3d79a24dfc1937560c922685d280.tar.gz
cr50: pass params to vendor commands as struct
This makes it easier to add params or flags for vendor commands without changing all of the command handlers. It also reduces code size by 56 bytes. For now, existing command handlers continue to use DECLARE_VENDOR_COMMAND(). Added DECLARE_VENDOR_COMMAND_P() for handlers which take the params struct directly. The CCD command will be the first user of that, since it will have different rules for 'open' based on where the command comes from. No change to existing command behavior. BUG=b:79983505 BRANCH=cr50 TEST=gsctool -I still works Change-Id: I7ed288a9c45e381162e246b50ae88cf76e67490d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1069538 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'common/extension.c')
-rw-r--r--common/extension.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/common/extension.c b/common/extension.c
index d75bbbe4f3..fecb61ec9e 100644
--- a/common/extension.c
+++ b/common/extension.c
@@ -11,11 +11,7 @@
#define CPRINTS(format, args...) cprints(CC_EXTENSION, format, ## args)
-uint32_t extension_route_command(uint16_t command_code,
- void *buffer,
- size_t in_size,
- size_t *out_size,
- uint32_t flags)
+uint32_t extension_route_command(struct vendor_cmd_params *p)
{
struct extension_command *cmd_p;
struct extension_command *end_p;
@@ -27,8 +23,8 @@ uint32_t extension_route_command(uint16_t command_code,
#endif
/* Filter commands from USB */
- if (flags & VENDOR_CMD_FROM_USB) {
- switch (command_code) {
+ if (p->flags & VENDOR_CMD_FROM_USB) {
+ switch (p->code) {
#ifdef CR50_DEV
case VENDOR_CC_IMMEDIATE_RESET:
case VENDOR_CC_INVALIDATE_INACTIVE_RW:
@@ -54,7 +50,7 @@ uint32_t extension_route_command(uint16_t command_code,
* Cr50 firmware.
*/
if (board_id_is_mismatched()) {
- switch (command_code) {
+ switch (p->code) {
case EXTENSION_FW_UPGRADE:
case VENDOR_CC_REPORT_TPM_STATE:
case VENDOR_CC_TURN_UPDATE_ON:
@@ -71,15 +67,14 @@ uint32_t extension_route_command(uint16_t command_code,
cmd_p = (struct extension_command *)&__extension_cmds;
end_p = (struct extension_command *)&__extension_cmds_end;
while (cmd_p != end_p) {
- if (cmd_p->command_code == command_code)
- return cmd_p->handler(command_code, buffer,
- in_size, out_size);
+ if (cmd_p->command_code == p->code)
+ return cmd_p->handler(p);
cmd_p++;
}
ignore_cmd:
/* Command not found or not allowed */
- CPRINTS("%s: ignore %d: %s", __func__, command_code, why_ignore);
- *out_size = 0;
+ CPRINTS("%s: ignore %d: %s", __func__, p->code, why_ignore);
+ p->out_size = 0;
return VENDOR_RC_NO_SUCH_COMMAND;
}