2023-04-29 04:52:16 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023 Google LLC
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2023-08-29 17:34:41 +08:00
|
|
|
#include <zephyr/init.h>
|
2023-04-29 04:52:16 +08:00
|
|
|
#include <zephyr/rtio/rtio.h>
|
|
|
|
#include <zephyr/sys/util.h>
|
|
|
|
#include <zephyr/app_memory/app_memdomain.h>
|
2023-05-15 21:50:28 +08:00
|
|
|
#include <zephyr/sys/iterable_sections.h>
|
2023-04-29 04:52:16 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
K_APPMEM_PARTITION_DEFINE(rtio_partition);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int rtio_init(void)
|
|
|
|
{
|
2023-05-01 06:02:39 +08:00
|
|
|
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);
|
2023-04-29 04:52:16 +08:00
|
|
|
}
|
2023-05-01 06:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2023-04-29 04:52:16 +08:00
|
|
|
}
|
|
|
|
}
|
2023-05-01 06:02:39 +08:00
|
|
|
|
2023-04-29 04:52:16 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYS_INIT(rtio_init, POST_KERNEL, 0);
|