diff options
author | Rob Barnes <robbarnes@google.com> | 2023-02-01 10:46:58 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-15 15:58:52 +0000 |
commit | a4b1da633cca2333820cd053055b259d3929bda5 (patch) | |
tree | 239f1513372b9b46c0b7e4fd266e4c2742ba40df | |
parent | 70e826325a4f54f666a0bad67e7a410f9dbb11d1 (diff) | |
download | chrome-ec-a4b1da633cca2333820cd053055b259d3929bda5.tar.gz |
tasks: Add local get_syswork_thread method
Add local get_sysworkq_thread method. Also add HAS_TASK_SYSWORKQ.
This just cleansup the handling of the syswork task id.
BUG=b:267470086
BRANCH=None
TEST=Unit tests
Change-Id: Ic665d33aa524edd5ab9902e5591bfa4b1a5263b0
Signed-off-by: Rob Barnes <robbarnes@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4214558
Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
-rw-r--r-- | zephyr/shim/include/shimmed_tasks.h | 1 | ||||
-rw-r--r-- | zephyr/shim/src/tasks.c | 9 | ||||
-rw-r--r-- | zephyr/test/tasks/extra_tasks.c | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/zephyr/shim/include/shimmed_tasks.h b/zephyr/shim/include/shimmed_tasks.h index cf579f1ed9..ea44d2a113 100644 --- a/zephyr/shim/include/shimmed_tasks.h +++ b/zephyr/shim/include/shimmed_tasks.h @@ -49,5 +49,6 @@ /* These non-shimmed (extra) tasks are always present */ #define HAS_TASK_IDLE 1 +#define HAS_TASK_SYSWORKQ 1 #endif /* __CROS_EC_SHIMMED_TASKS_H */ diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index 84384a27ea..62bca4ed60 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -89,9 +89,14 @@ test_export_static k_tid_t get_idle_thread(void) return NULL; } +test_export_static k_tid_t get_sysworkq_thread(void) +{ + return &k_sys_work_q.thread; +} + task_id_t task_get_current(void) { - if (in_deferred_context()) { + if (get_sysworkq_thread() == k_current_get()) { return TASK_ID_SYSWORKQ; } @@ -364,5 +369,5 @@ inline bool in_deferred_context(void) /* * Deferred calls run in the sysworkq. */ - return (k_current_get() == &k_sys_work_q.thread); + return (k_current_get() == get_sysworkq_thread()); } diff --git a/zephyr/test/tasks/extra_tasks.c b/zephyr/test/tasks/extra_tasks.c index 98aa300b17..6069741001 100644 --- a/zephyr/test/tasks/extra_tasks.c +++ b/zephyr/test/tasks/extra_tasks.c @@ -9,6 +9,7 @@ #include <zephyr/kernel/thread.h> #include <zephyr/ztest.h> +k_tid_t get_sysworkq_thread(void); k_tid_t get_idle_thread(void); /* Utility functions for finding a Zephyr thread by name */ @@ -49,6 +50,7 @@ ZTEST_USER(extra_tasks, test_sysworkq_thread_mapping) sysworkq_thread = find_thread_by_name("sysworkq"); zassert_not_null(sysworkq_thread); + zassert_equal(sysworkq_thread, get_sysworkq_thread()); } ZTEST_USER(extra_tasks, test_idle_thread_mapping) |