ipc: backends: rpmsg: initialize shared memory to zero
Added a code for initializing shared memory to zero. This operation normalizes the memory state so that the IPC service is no longer prone to reading status bits from the previous reset session. Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This commit is contained in:
parent
92d8329d5b
commit
33408fa7af
|
@ -12,4 +12,13 @@ config IPC_SERVICE_BACKEND_RPMSG_WQ_STACK_SIZE
|
|||
prevent notifying service users about received data from the system
|
||||
work queue. Size is the same for all instances.
|
||||
|
||||
config IPC_SERVICE_BACKEND_RPMSG_SHMEM_RESET
|
||||
bool "Reset shared memory state"
|
||||
help
|
||||
Some platforms retain the memory content upon reset. This is
|
||||
problematic because the backend expects a zero-ed memory to be
|
||||
able to correctly setup instances and endpoints at init time.
|
||||
When this parameter is set to 'y' the status region of the shared
|
||||
memory is reset on kernel initialization.
|
||||
|
||||
endif # IP_SERVICE_BACKEND_RPMSG
|
||||
|
|
|
@ -508,3 +508,24 @@ static int backend_init(const struct device *instance)
|
|||
&backend_ops);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(DEFINE_BACKEND_DEVICE)
|
||||
|
||||
#define BACKEND_CONFIG_INIT(n) &backend_config_##n,
|
||||
|
||||
#if defined(CONFIG_IPC_SERVICE_BACKEND_RPMSG_SHMEM_RESET)
|
||||
static int shared_memory_prepare(const struct device *arg)
|
||||
{
|
||||
static const struct backend_config_t *config[] = {
|
||||
DT_INST_FOREACH_STATUS_OKAY(BACKEND_CONFIG_INIT)
|
||||
};
|
||||
|
||||
for (int i = 0; i < DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT); i++) {
|
||||
if (config[i]->role == ROLE_HOST) {
|
||||
memset((void *) config[i]->shm_addr, 0, VDEV_STATUS_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(shared_memory_prepare, PRE_KERNEL_1, 1);
|
||||
#endif /* CONFIG_IPC_SERVICE_BACKEND_RPMSG_SHMEM_RESET */
|
||||
|
|
Loading…
Reference in a new issue