diff options
author | Simon Glass <sjg@chromium.org> | 2020-12-30 19:47:49 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-21 23:59:44 +0000 |
commit | 2547bf1c0c076e88db58baf5a2ae083d9bfd2eb9 (patch) | |
tree | 954a7de7701d2fe8cca9f322ca556ec2a100c21f /zephyr | |
parent | 51dfc5be5bcbe5fc1445f90ce6c4bd3b51040f0e (diff) | |
download | chrome-ec-2547bf1c0c076e88db58baf5a2ae083d9bfd2eb9.tar.gz |
reland: zephyr: Update hooks shim to match ECOS
At present the hooks declaration in Zephyr doesn't use const but does
use static. This makes it incompatible with ECOS, even if it might be
more strictly correct.
Update the hook to fix this so that we can build the missing USB code.
Typically Zephyr would put const data in the rodata section but that is
write-protected with native_posix. So force it into .data instead.
BUG=b:175434113
BRANCH=none
TEST=make BOARD=volteer
build zephyr on volteer
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2611895
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I470c9a6b2f905be9f512b0d555f33f0998412975
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2617377
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/shim/include/zephyr_hooks_shim.h | 10 | ||||
-rw-r--r-- | zephyr/shim/src/hooks.c | 13 |
2 files changed, 16 insertions, 7 deletions
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h index 3bb0854b21..e19f311af5 100644 --- a/zephyr/shim/include/zephyr_hooks_shim.h +++ b/zephyr/shim/include/zephyr_hooks_shim.h @@ -25,21 +25,25 @@ struct deferred_data { /** * See include/hooks.h for documentation. */ -int hook_call_deferred(struct deferred_data *data, int us); +int hook_call_deferred(const struct deferred_data *data, int us); /** * Runtime helper to setup deferred data. * * @param data The struct deferred_data. */ -void zephyr_shim_setup_deferred(struct deferred_data *data); +void zephyr_shim_setup_deferred(const struct deferred_data *data); /** * See include/hooks.h for documentation. + * + * Typically Zephyr would put const data in the rodata section but that is + * write-protected with native_posix. So force it into .data instead. */ #define DECLARE_DEFERRED(routine) _DECLARE_DEFERRED(routine) #define _DECLARE_DEFERRED(_routine) \ - static __maybe_unused struct deferred_data _routine##_data = { \ + __maybe_unused const struct deferred_data _routine##_data \ + __attribute__((section(".data.hooks"))) = { \ .routine = _routine, \ }; \ static int _setup_deferred_##_routine(const struct device *unused) \ diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c index 5011ed79ea..e4b1ea8791 100644 --- a/zephyr/shim/src/hooks.c +++ b/zephyr/shim/src/hooks.c @@ -42,17 +42,22 @@ static int init_deferred_work_queue(const struct device *unused) } SYS_INIT(init_deferred_work_queue, APPLICATION, 0); -void zephyr_shim_setup_deferred(struct deferred_data *data) +void zephyr_shim_setup_deferred(const struct deferred_data *data) { - k_delayed_work_init(&data->delayed_work, deferred_work_queue_handler); + struct deferred_data *non_const = (struct deferred_data *)data; + + k_delayed_work_init(&non_const->delayed_work, + deferred_work_queue_handler); } -int hook_call_deferred(struct deferred_data *data, int us) +int hook_call_deferred(const struct deferred_data *data, int us) { + struct deferred_data *non_const = (struct deferred_data *)data; int rv; rv = k_delayed_work_submit_to_queue(&deferred_work_queue, - &data->delayed_work, K_USEC(us)); + &non_const->delayed_work, + K_USEC(us)); if (rv < 0) cprints(CC_HOOK, "Warning: deferred call not submitted."); return rv; |