summaryrefslogtreecommitdiff
path: root/include/host_command.h
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-05-10 22:47:11 +0000
committerVincent Palatin <vpalatin@chromium.org>2012-05-14 23:33:21 +0000
commit87d3707f62c14376f9c5013e455544bf32d0fb33 (patch)
treea3f88652a3961a51299e4d71605b5e12fb772afd /include/host_command.h
parent805299d838c996c1a96b9808214d742ea28eb707 (diff)
downloadchrome-ec-87d3707f62c14376f9c5013e455544bf32d0fb33.tar.gz
Slightly update the host commands API
Preparatory work to use common host command code between ARM and x86. Every command sends back explicitly the size of the response payload. The size of the response defaults to 0 ond can be updated. Add a protocol version number returned as command 0x00 to help with backward compatibility. move a couple of function from lpc specific header to host commands to be able to implement them for the I2C link. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:9614 TEST=make BOARD=link Change-Id: I6a28edf02996ddf6b7f32a3831d07d5f0271848f
Diffstat (limited to 'include/host_command.h')
-rw-r--r--include/host_command.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/include/host_command.h b/include/host_command.h
index c00df1a93d..7bebbe5e19 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -15,8 +15,10 @@
struct host_command {
/* Command code. */
int command;
- /* Handler for the command; data points to parameters/response. */
- enum lpc_status (*handler)(uint8_t *data);
+ /* Handler for the command; data points to parameters/response.
+ * returns negative error code if case of failure (using EC_LPC_STATUS
+ * codes). sets <response_size> if it returns a payload to the host. */
+ int (*handler)(uint8_t *data, int *response_size);
};
@@ -24,6 +26,27 @@ struct host_command {
command slots (0=kernel, 1=user). */
void host_command_received(int slot, int command);
+/* Send errors or success result code to a host command,
+ * without response data.
+ * <slot> is 0 for kernel-originated commands,
+ * 1 for usermode-originated commands.
+ * <result> is the error code. */
+void host_send_result(int slot, int result);
+
+ // success results with response data
+/* Send a successful result code along with response data to a host command.
+ * <slot> is 0 for kernel-originated commands,
+ * 1 for usermode-originated commands.
+ * <data> is the buffer with the response payload.
+ * <size> is the size of the response buffer. */
+void host_send_response(int slot, const uint8_t *data, int size);
+
+/* Return a pointer to the host command data buffer. This buffer must
+ * only be accessed between a notification to host_command_received()
+ * and a subsequent call to lpc_SendHostResponse(). <slot> is 0 for
+ * kernel-originated commands, 1 for usermode-originated commands. */
+uint8_t *host_get_buffer(int slot);
+
/* Register a host command handler */
#define DECLARE_HOST_COMMAND(command, routine) \
const struct host_command __host_cmd_##command \