diff options
author | Jett Rink <jettrink@chromium.org> | 2020-11-06 14:18:04 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-09 19:13:17 +0000 |
commit | 1b4e189e44379cf1db7639f2549441a8d678a978 (patch) | |
tree | b3e9758c6bc59808cb6e3d11bfc8b3f684795e9c | |
parent | 8141e8d7eeeb915f2b529de39570e2efc8b86466 (diff) | |
download | chrome-ec-1b4e189e44379cf1db7639f2549441a8d678a978.tar.gz |
zephyr: move from SYS_INIT to main
We are going to need to perform initialization in Zephyr's main before
we start the EC tasks or call the INIT hooks. If we rely on SYS_INIT,
all of that happens before main is called.
BRANCH=none
BUG=none
TEST=pass tasks unit tests and run on volteer
Cq-Depend: chromium:2523462
Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: Icd035695b86fc9690cea88887902be61d9b37a18
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2523380
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | zephyr/shim/include/ec_tasks.h | 12 | ||||
-rw-r--r-- | zephyr/shim/src/hooks.c | 8 | ||||
-rw-r--r-- | zephyr/shim/src/tasks.c | 6 | ||||
-rw-r--r-- | zephyr/test/tasks/main.c | 7 |
4 files changed, 19 insertions, 14 deletions
diff --git a/zephyr/shim/include/ec_tasks.h b/zephyr/shim/include/ec_tasks.h new file mode 100644 index 0000000000..0380920492 --- /dev/null +++ b/zephyr/shim/include/ec_tasks.h @@ -0,0 +1,12 @@ +/* Copyright 2020 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. + */ + +#ifndef __CROS_EC_EC_TASKS_H +#define __CROS_EC_EC_TASKS_H + +/** Starts all of the shimmed EC tasks. Requires CONFIG_SHIMMED_TASKS=y. */ +void start_ec_tasks(void); + +#endif /* __CROS_EC_EC_TASKS_H */ diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c index 04b6b59461..5011ed79ea 100644 --- a/zephyr/shim/src/hooks.c +++ b/zephyr/shim/src/hooks.c @@ -85,11 +85,3 @@ void hook_notify(enum hook_type type) for (p = hook_registry[type]; p; p = p->next) p->routine(); } - -static int run_init_hooks(const struct device *unused) -{ - ARG_UNUSED(unused); - hook_notify(HOOK_INIT); - return 0; -} -SYS_INIT(run_init_hooks, APPLICATION, 2); diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index b3450c9387..f954401a45 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -183,10 +183,8 @@ static void task_entry(void *task_contex, void *unused1, void *unused2) ctx->entry((void *)ctx->parameter); } -static int start_ec_tasks(const struct device *unused) +void start_ec_tasks(void) { - ARG_UNUSED(unused); - for (size_t i = 0; i < ARRAY_SIZE(shimmed_tasks); ++i) { struct task_ctx *const ctx = &shimmed_tasks[i]; @@ -200,6 +198,4 @@ static int start_ec_tasks(const struct device *unused) task_entry, ctx, NULL, NULL, K_PRIO_PREEMPT(TASK_ID_COUNT - i), 0, K_NO_WAIT); } - return 0; } -SYS_INIT(start_ec_tasks, APPLICATION, 10); diff --git a/zephyr/test/tasks/main.c b/zephyr/test/tasks/main.c index 0c659fd624..59eb7da64e 100644 --- a/zephyr/test/tasks/main.c +++ b/zephyr/test/tasks/main.c @@ -4,9 +4,11 @@ */ #include <kernel.h> -#include <task.h> #include <ztest.h> +#include "ec_tasks.h" +#include "task.h" + /* Second for platform/ec task API (in microseconds). */ #define TASK_SEC(s) (s * 1000 * 1000) @@ -188,6 +190,9 @@ static void test_empty_set_mask(void) void test_main(void) { + /* Manually start the EC tasks. This normally happens in main. */ + start_ec_tasks(); + ztest_test_suite(test_task_shim, ztest_unit_test(test_task_get_current), ztest_unit_test(test_timeout), |