zephyr/lib/open-amp/resource_table.h
Alexandru Lastur ec2dd19d45 samples: openamp_rsc_table: Add the option to use predefined vring ID
Currently, Zephyr is always sending back notifications to
AP (e.g Linux in our case) on channel 0.

But this currently doesn't work if Linux uses other channel
id for communication. So, add option to use predefined
vring ID that can accomodate Linux used ID.

Signed-off-by: Alexandru Lastur <alexandru.lastur@nxp.com>
2024-10-15 13:53:42 +02:00

84 lines
1.9 KiB
C

/*
* Copyright (c) 2020 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef RESOURCE_TABLE_H__
#define RESOURCE_TABLE_H__
#include <openamp/remoteproc.h>
#include <openamp/virtio.h>
#ifdef __cplusplus
extern "C" {
#endif
#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
#define VDEV_ID 0xFF
#define VRING0_ID CONFIG_OPENAMP_RSC_TABLE_IPM_RX_ID /* (host to remote) */
#define VRING1_ID CONFIG_OPENAMP_RSC_TABLE_IPM_TX_ID /* (remote to host) */
#define VRING_COUNT 2
#define RPMSG_IPU_C0_FEATURES 1
#define VRING_RX_ADDRESS -1 /* allocated by Master processor */
#define VRING_TX_ADDRESS -1 /* allocated by Master processor */
#define VRING_BUFF_ADDRESS -1 /* allocated by Master processor */
#define VRING_ALIGNMENT 16 /* fixed to match with Linux constraint */
#endif
enum rsc_table_entries {
#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
RSC_TABLE_VDEV_ENTRY,
#endif
#if defined(CONFIG_RAM_CONSOLE)
RSC_TABLE_TRACE_ENTRY,
#endif
RSC_TABLE_NUM_ENTRY
};
struct fw_resource_table {
struct resource_table hdr;
uint32_t offset[RSC_TABLE_NUM_ENTRY];
#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
struct fw_rsc_vdev vdev;
struct fw_rsc_vdev_vring vring0;
struct fw_rsc_vdev_vring vring1;
#endif
#if defined(CONFIG_RAM_CONSOLE)
/* rpmsg trace entry */
struct fw_rsc_trace cm_trace;
#endif
} METAL_PACKED_END;
void rsc_table_get(struct fw_resource_table **table_ptr, int *length);
#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
inline struct fw_rsc_vdev *rsc_table_to_vdev(struct fw_resource_table *rsc_table)
{
return &rsc_table->vdev;
}
inline struct fw_rsc_vdev_vring *rsc_table_get_vring0(struct fw_resource_table *rsc_table)
{
return &rsc_table->vring0;
}
inline struct fw_rsc_vdev_vring *rsc_table_get_vring1(struct fw_resource_table *rsc_table)
{
return &rsc_table->vring1;
}
#endif
#ifdef __cplusplus
}
#endif
#endif