zephyr/subsys/rtio/rtio_init.c
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00

33 lines
713 B
C

/*
* Copyright (c) 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/rtio/rtio.h>
#include <zephyr/sys/util.h>
#include <zephyr/app_memory/app_memdomain.h>
#include <zephyr/sys/iterable_sections.h>
#ifdef CONFIG_USERSPACE
K_APPMEM_PARTITION_DEFINE(rtio_partition);
#endif
int rtio_init(void)
{
STRUCT_SECTION_FOREACH(rtio_sqe_pool, sqe_pool) {
for (int i = 0; i < sqe_pool->pool_size; i++) {
rtio_mpsc_push(&sqe_pool->free_q, &sqe_pool->pool[i].q);
}
}
STRUCT_SECTION_FOREACH(rtio_cqe_pool, cqe_pool) {
for (int i = 0; i < cqe_pool->pool_size; i++) {
rtio_mpsc_push(&cqe_pool->free_q, &cqe_pool->pool[i].q);
}
}
return 0;
}
SYS_INIT(rtio_init, POST_KERNEL, 0);