diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-02-28 13:44:03 -0800 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-02-28 13:58:34 -0800 |
commit | 4c89ccd89eea60092118e49ca6b68a04d21d8870 (patch) | |
tree | 19cbd88927df9b8839bd11a6d760ebae20241476 /include | |
parent | e632029ed045e2b4922e3131898b0137d3a79972 (diff) | |
download | chrome-ec-4c89ccd89eea60092118e49ca6b68a04d21d8870.tar.gz |
Register host commands the same clever way we do console commands
BUG=none
TEST=run assorted ectool commands
Change-Id: I830d3cbf2d1557b3ab455ec8736d3de5e5d3e697
Diffstat (limited to 'include')
-rw-r--r-- | include/flash_commands.h | 28 | ||||
-rw-r--r-- | include/host_command.h | 18 | ||||
-rw-r--r-- | include/lpc.h | 2 | ||||
-rw-r--r-- | include/pstore_commands.h | 18 | ||||
-rw-r--r-- | include/pwm_commands.h | 21 | ||||
-rw-r--r-- | include/usb_charge_commands.h | 19 |
6 files changed, 17 insertions, 89 deletions
diff --git a/include/flash_commands.h b/include/flash_commands.h deleted file mode 100644 index 9a46bef5e5..0000000000 --- a/include/flash_commands.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Flash memory commands for Chrome EC */ - -#ifndef __CROS_EC_FLASH_COMMANDS_H -#define __CROS_EC_FLASH_COMMANDS_H - -#include "common.h" -#include "lpc_commands.h" - -/* Host command handlers. */ -enum lpc_status flash_command_get_info(uint8_t *data); -enum lpc_status flash_command_read(uint8_t *data); -enum lpc_status flash_command_write(uint8_t *data); -enum lpc_status flash_command_erase(uint8_t *data); -enum lpc_status flash_command_wp_enable(uint8_t *data); -enum lpc_status flash_command_wp_get_state(uint8_t *data); -enum lpc_status flash_command_wp_set_range(uint8_t *data); -enum lpc_status flash_command_wp_get_range(uint8_t *data); -#ifdef SUPPORT_CHECKSUM -enum lpc_status flash_command_checksum(uint8_t *data); -#endif - - -#endif /* __CROS_EC_FLASH_COMMANDS_H */ diff --git a/include/host_command.h b/include/host_command.h index 9c2dda2a69..c00df1a93d 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -9,9 +9,25 @@ #define __CROS_EC_HOST_COMMAND_H #include "common.h" +#include "lpc_commands.h" + +/* Host command */ +struct host_command { + /* Command code. */ + int command; + /* Handler for the command; data points to parameters/response. */ + enum lpc_status (*handler)(uint8_t *data); +}; + /* Called by LPC module when a command is written to one of the command slots (0=kernel, 1=user). */ void host_command_received(int slot, int command); +/* Register a host command handler */ +#define DECLARE_HOST_COMMAND(command, routine) \ + const struct host_command __host_cmd_##command \ + __attribute__((section(".rodata.hcmds"))) \ + = {command, routine} + #endif /* __CROS_EC_HOST_COMMAND_H */ diff --git a/include/lpc.h b/include/lpc.h index 69968dba99..b616659300 100644 --- a/include/lpc.h +++ b/include/lpc.h @@ -10,13 +10,11 @@ #include "common.h" - /* Manually generates an IRQ to host. * Note that the irq_num == 0 would set the AH bit (Active High). */ void lpc_manual_irq(int irq_num); - /* Initializes the LPC module. */ int lpc_init(void); diff --git a/include/pstore_commands.h b/include/pstore_commands.h deleted file mode 100644 index 123d6f28f9..0000000000 --- a/include/pstore_commands.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Persistent storage commands for Chrome EC */ - -#ifndef __CROS_EC_PSTORE_COMMANDS_H -#define __CROS_EC_PSTORE_COMMANDS_H - -#include "common.h" - -/* Host command handlers. */ -enum lpc_status pstore_command_get_info(uint8_t *data); -enum lpc_status pstore_command_read(uint8_t *data); -enum lpc_status pstore_command_write(uint8_t *data); - -#endif /* __CROS_EC_PSTORE_COMMANDS_H */ diff --git a/include/pwm_commands.h b/include/pwm_commands.h deleted file mode 100644 index 8f2dbdfb0c..0000000000 --- a/include/pwm_commands.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* PWM commands for Chrome EC */ - -#ifndef __CROS_EC_PWM_COMMANDS_H -#define __CROS_EC_PWM_COMMANDS_H - -#include "common.h" -#include "lpc_commands.h" - -/* Host command handlers. */ -enum lpc_status pwm_command_get_fan_rpm(uint8_t *data); -enum lpc_status pwm_command_set_fan_target_rpm(uint8_t *data); -enum lpc_status pwm_command_get_keyboard_backlight(uint8_t *data); -enum lpc_status pwm_command_set_keyboard_backlight(uint8_t *data); - - -#endif /* __CROS_EC_PWM_COMMANDS_H */ diff --git a/include/usb_charge_commands.h b/include/usb_charge_commands.h deleted file mode 100644 index 8871fdd294..0000000000 --- a/include/usb_charge_commands.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* USB charging control commands for Chrome EC */ - -#ifndef __CROS_EC_USB_CHARGE_COMMANDS_H -#define __CROS_EC_USB_CHARGE_COMMANDS_H - -#include "common.h" - -/* Initializes the module. */ -int usb_charge_commands_init(void); - -/* Host command handlers. */ -enum lpc_status usb_charge_command_set_mode(uint8_t *data); - -#endif /* __CROS_EC_USB_CHARGE_COMMANDS_H */ |