diff options
author | Nicolas Boichat <drinkcat@google.com> | 2017-03-16 10:24:37 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-03-31 22:33:33 -0700 |
commit | 871bf8da2cf5fa9bcfe8771b96af4b55c2503616 (patch) | |
tree | 2ef82237fbbeb488cd297010f56b3abf8c1ba5d0 /common/keyboard_mkbp.c | |
parent | 24fd8060fd27f0306d5d3f91faa09d28ed892772 (diff) | |
download | chrome-ec-871bf8da2cf5fa9bcfe8771b96af4b55c2503616.tar.gz |
system: Add support for emulated sysrq
On keyboard-less design, we will implement a special debug mode,
based on button sequences, to transmit sysrq events to the AP.
This implements the new MKBP event to send sysrq, and a console
command to test it. Later CL will implement debug mode itself.
BRANCH=none
BUG=b:35775099
TEST=sysrq available in EC console
TEST=sysrq h => help message in AP console
TEST=sysrq b => AP reboots
Change-Id: I71d3f77497baf8cc7fac65cd040ce20513b507bc
Reviewed-on: https://chromium-review.googlesource.com/456520
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/keyboard_mkbp.c')
-rw-r--r-- | common/keyboard_mkbp.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index 277e63dc03..e592addf2f 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -90,6 +90,7 @@ static int get_data_size(enum ec_mkbp_event e) case EC_MKBP_EVENT_HOST_EVENT: case EC_MKBP_EVENT_BUTTON: case EC_MKBP_EVENT_SWITCH: + case EC_MKBP_EVENT_SYSRQ: return sizeof(uint32_t); default: /* For unknown types, say it's 0. */ @@ -258,6 +259,15 @@ void keyboard_update_button(enum keyboard_button_type button, int is_pressed) (const uint8_t *)&mkbp_button_state); } +#ifdef CONFIG_EMULATED_SYSRQ +void send_sysrq(uint8_t key) +{ + uint32_t value = key; + + mkbp_fifo_add(EC_MKBP_EVENT_SYSRQ, (const uint8_t *)&value); +} +#endif + #ifdef CONFIG_POWER_BUTTON /** * Handle power button changing state. @@ -325,6 +335,14 @@ static int switch_get_next_event(uint8_t *out) } DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_SWITCH, switch_get_next_event); +#ifdef CONFIG_EMULATED_SYSRQ +static int sysrq_get_next_event(uint8_t *out) +{ + return get_next_event(out, EC_MKBP_EVENT_SYSRQ); +} +DECLARE_EVENT_SOURCE(EC_MKBP_EVENT_SYSRQ, sysrq_get_next_event); +#endif + void keyboard_send_battery_key(void) { uint8_t state[KEYBOARD_COLS]; |