Commit 222297ee authored by Iuliana Prodan's avatar Iuliana Prodan Committed by Benjamin Cabé
Browse files

lib: open-amp: Add base support for resource table



Introduce macros to define initialization
routines for OpenAMP resource table entries.

This will allow to extend the default OpenAMP
resource table with vendor-specific data structures.

Signed-off-by: default avatarIuliana Prodan <iuliana.prodan@nxp.com>
parent e8a70202
Loading
Loading
Loading
Loading
+1 −40
Original line number Diff line number Diff line
@@ -39,46 +39,7 @@ extern char ram_console_buf[];

#define __resource Z_GENERIC_SECTION(.resource_table)

static struct fw_resource_table __resource resource_table = {
	.hdr = {
		.ver = 1,
		.num = RSC_TABLE_NUM_ENTRY,
	},
	.offset = {

#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
		offsetof(struct fw_resource_table, vdev),
#endif

#if defined(CONFIG_RAM_CONSOLE)
		offsetof(struct fw_resource_table, cm_trace),
#endif
	},

#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
	/* Virtio device entry */
	.vdev = {
		RSC_VDEV, VIRTIO_ID_RPMSG, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
		VRING_COUNT, {0, 0},
	},

	/* Vring rsc entry - part of vdev rsc entry */
	.vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT,
		   CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF,
		   VRING0_ID, 0},
	.vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT,
		   CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF,
		   VRING1_ID, 0},
#endif

#if defined(CONFIG_RAM_CONSOLE)
	.cm_trace = {
		RSC_TRACE,
		(uint32_t)ram_console_buf, CONFIG_RAM_CONSOLE_BUFFER_SIZE, 0,
		"Zephyr_log",
	},
#endif
};
static struct fw_resource_table __resource resource_table = RESOURCE_TABLE_INIT;

void rsc_table_get(void **table_ptr, int *length)
{
+50 −0
Original line number Diff line number Diff line
@@ -56,6 +56,56 @@ struct fw_resource_table {
#endif
} METAL_PACKED_END;

#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
	#define VDEV_OFFSET	offsetof(struct fw_resource_table, vdev),
#else
	#define VDEV_OFFSET
#endif

#if defined(CONFIG_RAM_CONSOLE)
	#define CM_TRACE_OFFSET	offsetof(struct fw_resource_table, cm_trace),
#else
	#define CM_TRACE_OFFSET
#endif

#define VDEV_ENTRY_HELPER(x)							\
	.vdev = {RSC_VDEV, VIRTIO_ID_RPMSG, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,	\
		VRING_COUNT, {0, 0},},						\
	.vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT, x, VRING0_ID, 0},		\
	.vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT, x, VRING1_ID, 0},

#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)
	#define VDEV_ENTRY							\
		VDEV_ENTRY_HELPER(CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF)
#else
	#define VDEV_ENTRY
#endif

#if defined(CONFIG_RAM_CONSOLE)
	#define CM_TRACE_ENTRY							\
		.cm_trace = {							\
			RSC_TRACE,						\
			(uint32_t)ram_console_buf, CONFIG_RAM_CONSOLE_BUFFER_SIZE, 0,\
			"Zephyr_log",						\
		},
#else
	#define CM_TRACE_ENTRY
#endif

#define RESOURCE_TABLE_INIT			\
{						\
	.hdr = {				\
		.ver = 1,			\
		.num = RSC_TABLE_NUM_ENTRY,	\
	},					\
	.offset = {				\
		VDEV_OFFSET			\
		CM_TRACE_OFFSET			\
	},					\
	VDEV_ENTRY				\
	CM_TRACE_ENTRY				\
}

void rsc_table_get(void **table_ptr, int *length);

#if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0)