summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-05-26 17:42:32 -0700
committerGerrit <chrome-bot@google.com>2012-07-03 13:24:28 -0700
commit9a4205faf3a378987cf534018e30be3892fcce26 (patch)
tree7069ffb7ce22c3e802ad873668549c3801d9f5fb
parent24acac67a3ee3038145ff329a85c83fcf37ce84e (diff)
downloadchrome-ec-9a4205faf3a378987cf534018e30be3892fcce26.tar.gz
Add host_command_process() to process a command immediately
Rather than go through the task queue, host_command_process() processes the command immediately, has all of its required state passed in, allowing the caller complete control of the buffers. BUG=chrome-os-partner:10533 TEST=manual: build and boot on link, see that messages are stil processed build and boot on snow, which uses this new command See that the SPI keyboard works now Change-Id: Ib7587de10c42caf01bc95bb4d515fd0afc3da7d8 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/25983 Reviewed-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r--common/host_command.c31
-rw-r--r--include/host_command.h13
2 files changed, 33 insertions, 11 deletions
diff --git a/common/host_command.c b/common/host_command.c
index 4de9f36404..cc7de1e473 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -132,25 +132,34 @@ static const struct host_command *find_host_command(int command)
}
-/* Handle a LPC command */
-static void command_process(int slot)
+enum ec_status host_command_process(int slot, int command, uint8_t *data,
+ int *response_size)
{
- int command = host_command[slot];
- uint8_t *data = host_get_buffer(slot);
const struct host_command *cmd = find_host_command(command);
+ enum ec_status res = EC_RES_INVALID_COMMAND;
CPRINTF("[hostcmd%d 0x%02x]\n", slot, command);
- if (cmd) {
- int size = 0;
- int res = cmd->handler(data, &size);
+ *response_size = 0;
+ if (cmd)
+ res = cmd->handler(data, response_size);
- host_send_response(slot, res, data, size);
- } else {
- host_send_response(slot, EC_RES_INVALID_COMMAND, data, 0);
- }
+ return res;
}
+/* Handle a host command */
+static void command_process(int slot)
+{
+ int size;
+ int res;
+
+ CPRINTF("[hostcmd%d 0x%02x]\n", slot, host_command[slot]);
+
+ res = host_command_process(slot, host_command[slot],
+ host_get_buffer(slot), &size);
+
+ host_send_response(slot, res, host_get_buffer(slot), size);
+}
/*****************************************************************************/
/* Initialization / task */
diff --git a/include/host_command.h b/include/host_command.h
index ea31bdcc41..69facb6268 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -21,6 +21,19 @@ struct host_command {
int (*handler)(uint8_t *data, int *response_size);
};
+/**
+ * Process a host command and return its response
+ *
+ * @param slot is 0 for kernel-originated commands,
+ * 1 for usermode-originated commands.
+ * @param command The command code
+ * @param data Buffer holding the command, and used for the
+ * response payload.
+ * @param response_size Returns the size of the response
+ * @return resulting status
+ */
+enum ec_status host_command_process(int slot, int command, uint8_t *data,
+ int *response_size);
/* Called by LPC module when a command is written to one of the
command slots (0=kernel, 1=user). */