diff options
author | Fabio Baltieri <fabiobaltieri@google.com> | 2022-04-14 13:12:36 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-04-21 20:24:54 +0000 |
commit | 33be9c52c6910c4805fb1ef67b4e1d23e81471fd (patch) | |
tree | a2f7b9cb37e2e06df48df9d46193386cd6f9759c /zephyr/shim/include | |
parent | 2fae2c312151cfb33d9a243efe12570e9b69960f (diff) | |
download | chrome-ec-33be9c52c6910c4805fb1ef67b4e1d23e81471fd.tar.gz |
zephyr: tasks: run HOSTCMD in main thread
Add an option to run the host command loop in the main thread, taking
over the entire thread and reusing its thread support code and stack.
This is still optional and automatically disabled on tests as test code
actually needs main() to run the test code itself.
The code ensures that the main thread is switched to the correct
priority for the HOSTCMD code and changes the thread name as well.
BRANCH=none
BUG=b:223044986
TEST=zmake testall
TEST=build and run on brya
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Change-Id: Ib2b3ba3d8a6fb883876ecdd432068ca3300e5344
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3593779
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim/include')
-rw-r--r-- | zephyr/shim/include/shimmed_task_id.h | 6 | ||||
-rw-r--r-- | zephyr/shim/include/zephyr_host_command.h | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h index 1c746d5fc5..69efe50f1b 100644 --- a/zephyr/shim/include/shimmed_task_id.h +++ b/zephyr/shim/include/shimmed_task_id.h @@ -100,7 +100,7 @@ enum { (CROS_EC_TASK(MOTIONSENSE, motion_sense_task, 0, \ CONFIG_TASK_MOTIONSENSE_STACK_SIZE, \ EC_TASK_MOTIONSENSE_PRIO)), ()) \ - COND_CODE_1(HAS_TASK_HOSTCMD, \ + COND_CODE_1(CONFIG_TASK_HOSTCMD_THREAD_DEDICATED, \ (CROS_EC_TASK(HOSTCMD, host_command_task, 0, \ CONFIG_TASK_HOSTCMD_STACK_SIZE, \ EC_TASK_HOSTCMD_PRIO)), ()) \ @@ -195,9 +195,11 @@ enum { #undef TASK_TEST /* - * Additional task IDs for features that runs on non shimmed threads. + * Additional task IDs for features that runs on non shimmed threads, + * task_get_current() needs to be updated to identify these ones. */ #define CROS_EC_EXTRA_TASKS(fn) \ + COND_CODE_1(CONFIG_TASK_HOSTCMD_THREAD_MAIN, (fn(HOSTCMD)), ()) \ fn(SYSWORKQ) #define EXTRA_TASK_INTERNAL_ID(name) EXTRA_TASK_##name, diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h index 138c8636c7..1f07ac34d2 100644 --- a/zephyr/shim/include/zephyr_host_command.h +++ b/zephyr/shim/include/zephyr_host_command.h @@ -11,6 +11,16 @@ #define __CROS_EC_ZEPHYR_HOST_COMMAND_H #include <init.h> +#include <stdbool.h> + +/* Initializes and runs the host command handler loop. */ +void host_command_task(void *u); + +/* Takes over the main thread and runs the host command loop. */ +void host_command_main(void); + +/* True if running in the main thread. */ +bool in_host_command_main(void); #ifdef CONFIG_PLATFORM_EC_HOSTCMD |