summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGerrit <chrome-bot@google.com>2012-05-14 17:27:49 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2012-05-14 17:27:49 -0700
commitdc703b5ae48442f094dd8f3122e4507a8b043970 (patch)
tree0ad29d5aef38484722fce0afedb89cef00c847a3 /include
parente00c460c933da8926905762735d9fef70d058609 (diff)
parent87d3707f62c14376f9c5013e455544bf32d0fb33 (diff)
downloadchrome-ec-dc703b5ae48442f094dd8f3122e4507a8b043970.tar.gz
Merge "Slightly update the host commands API"
Diffstat (limited to 'include')
-rw-r--r--include/host_command.h27
-rw-r--r--include/lpc.h10
-rw-r--r--include/lpc_commands.h25
3 files changed, 50 insertions, 12 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 \
diff --git a/include/lpc.h b/include/lpc.h
index 295522ad1f..45e777689a 100644
--- a/include/lpc.h
+++ b/include/lpc.h
@@ -15,20 +15,10 @@
*/
void lpc_manual_irq(int irq_num);
-/* 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 *lpc_get_host_range(int slot);
-
/* Return a pointer to the memory-mapped buffer. This buffer is writable at
* any time, and the host can read it at any time. */
uint8_t *lpc_get_memmap_range(void);
-/* Send a result code to a host command. <slot> is 0 for kernel-originated
- * commands, 1 for usermode-originated commands. */
-void lpc_send_host_response(int slot, int result);
-
/* Return true if the TOH is still set */
int lpc_keyboard_has_char(void);
diff --git a/include/lpc_commands.h b/include/lpc_commands.h
index c7f2530df1..fd93136421 100644
--- a/include/lpc_commands.h
+++ b/include/lpc_commands.h
@@ -14,6 +14,8 @@
*/
#define SUPPORT_CHECKSUM
+/* Current version of this protocol */
+#define EC_LPC_PROTO_VERSION 0x00000002
/* I/O addresses for LPC commands */
#define EC_LPC_ADDR_KERNEL_DATA 0x62
@@ -156,6 +158,13 @@ enum host_event_code {
/*****************************************************************************/
/* General / test commands */
+/* Get protocol version, used to deal with non-backward compatible protocol
+ * changes. */
+#define EC_LPC_COMMAND_PROTO_VERSION 0x00
+struct lpc_response_proto_version {
+ uint32_t version;
+} __attribute__ ((packed));
+
/* Hello. This is a simple command to test the EC is responsive to
* commands. */
#define EC_LPC_COMMAND_HELLO 0x01
@@ -458,6 +467,22 @@ struct lpc_response_thermal_get_threshold {
#define EC_LPC_COMMAND_THERMAL_AUTO_FAN_CTRL 0x52
/*****************************************************************************/
+/* Matrix KeyBoard Protocol */
+
+/* Read key state */
+#define EC_LPC_COMMAND_MKBP_STATE 0x60
+struct lpc_response_mkbp_state {
+ uint8_t cols[32];
+} __attribute__ ((packed));
+
+/* Provide information about the matrix : number of rows and columns */
+#define EC_LPC_COMMAND_MKBP_INFO 0x61
+struct lpc_response_mkbp_info {
+ uint32_t rows;
+ uint32_t cols;
+} __attribute__ ((packed));
+
+/*****************************************************************************/
/* Host event commands */
/* Host event mask params and response structures, shared by all of the host