diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2020-11-06 14:24:04 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-09 01:48:57 +0000 |
commit | b709dc9aaffe3692dbadd3f4cc3e0891b5daf3f9 (patch) | |
tree | 99bc943315812d3400ef74f73c2bf0b5221f68e6 | |
parent | c47740eca17a2fe652b7bb13f5b2949687884e79 (diff) | |
download | chrome-ec-b709dc9aaffe3692dbadd3f4cc3e0891b5daf3f9.tar.gz |
zephyr: add stub host events implementation
Include host_command.c and host_event_commands.c so that we get some
basic definitions to get things compiling. Since we don't have
CONFIG_HOSTCMD_ESPI enabled yet, this is really just pulling in stub
definitions.
BUG=b:172678200
BRANCH=none
TEST=compiles for volteer
Cq-Depend: chromium:2523466
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: Ic293f80d30ecf9534ff935b73aa4ca42614a77be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523381
-rw-r--r-- | common/host_command.c | 61 | ||||
-rw-r--r-- | zephyr/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/Kconfig | 6 |
3 files changed, 40 insertions, 29 deletions
diff --git a/common/host_command.c b/common/host_command.c index c7fd1baa15..c5821df6d3 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -370,38 +370,41 @@ host_packet_bad: */ static const struct host_command *find_host_command(int command) { -#ifdef CONFIG_HOSTCMD_SECTION_SORTED - const struct host_command *l, *r, *m; - uint32_t num; - -/* Use binary search to locate host command handler */ - l = __hcmds; - r = __hcmds_end - 1; - - while (1) { - if (l > r) - return NULL; - - num = r - l; - m = l + (num / 2); + if (IS_ENABLED(CONFIG_ZEPHYR)) { + /* TODO(b/172678200): shim host commands for Zephyr */ + return NULL; + } else if (IS_ENABLED(CONFIG_HOSTCMD_SECTION_SORTED)) { + const struct host_command *l, *r, *m; + uint32_t num; + + /* Use binary search to locate host command handler */ + l = __hcmds; + r = __hcmds_end - 1; + + while (1) { + if (l > r) + return NULL; + + num = r - l; + m = l + (num / 2); + + if (m->command < command) + l = m + 1; + else if (m->command > command) + r = m - 1; + else + return m; + } + } else { + const struct host_command *cmd; - if (m->command < command) - l = m + 1; - else if (m->command > command) - r = m - 1; - else - return m; - } -#else - const struct host_command *cmd; + for (cmd = __hcmds; cmd < __hcmds_end; cmd++) { + if (command == cmd->command) + return cmd; + } - for (cmd = __hcmds; cmd < __hcmds_end; cmd++) { - if (command == cmd->command) - return cmd; + return NULL; } - - return NULL; -#endif } static void host_command_init(void) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 7f7d5f4308..2fc58241b6 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -36,6 +36,8 @@ add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim") zephyr_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c") zephyr_sources_ifdef(CONFIG_SHELL "${PLATFORM_EC}/common/gpio_commands.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD "${PLATFORM_EC}/common/host_command.c") +zephyr_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD "${PLATFORM_EC}/common/host_event_commands.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_I2C "${PLATFORM_EC}/common/i2c_master.c") zephyr_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042 "${PLATFORM_EC}/common/keyboard_8042.c") diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 6569450766..e675f8eeea 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -102,6 +102,12 @@ config PLATFORM_EC_HOOKS hook_call_deferred to Zephyr's work queues, and a compatible DECLARE_HOOK implementation. +config PLATFORM_EC_HOSTCMD + bool "Enable host commands shim" + default y if AP + help + Enable the host commands shim in platform/ec. + config PLATFORM_EC_LID_SWITCH bool "Enable the lid switch module" help |