1 /*
2  * Copyright (c) 2024 EPAM Systems
3  * Copyright (c) 2024 Renesas Electronics Corporation
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*
8  * Overriding Zephyr resource_table and set correct vring 0 and vring 1 addresses
9  * to match the work behaviour of master device. According to the commit:
10  * 25ec73986b (lib: open-amp: add helper to add resource table in project)
11  * vring RX and TX addresses should be allocated by master processor.
12  * Current Master Sample implementation expects slave to provide valid
13  * rsc_table so update vring addresses here.
14  *
15  * Dependencies:
16  *   to be compliant with Linux kernel OS the resource table must be linked in a
17  *   specific section named ".resource_table".
18  */
19 
20 #include <zephyr/kernel.h>
21 #include <resource_table.h>
22 
23 #define __resource Z_GENERIC_SECTION(.resource_table)
24 
25 static struct fw_resource_table __resource resource_table = {
26 	.ver = 1,
27 	.num = RSC_TABLE_NUM_ENTRY,
28 	.reserved = {0, 0},
29 	/* Offset */
30 	{
31 		offsetof(struct fw_resource_table, vdev),
32 	},
33 	/* Virtio device entry */
34 	{
35 		RSC_VDEV,
36 		VIRTIO_ID_RPMSG,
37 		0,
38 		RPMSG_IPU_C0_FEATURES,
39 		0,
40 		0,
41 		0,
42 		VRING_COUNT,
43 		{0, 0},
44 	},
45 	/* Vring rsc entry - part of vdev rsc entry */
46 	.vring0 = {VRING_TX_ADDR_A55, VRING_ALIGNMENT, RSC_TABLE_NUM_RPMSG_BUFF, VRING0_ID, 0},
47 	.vring1 = {VRING_RX_ADDR_A55, VRING_ALIGNMENT, RSC_TABLE_NUM_RPMSG_BUFF, VRING1_ID, 0},
48 };
49 
rsc_table_get(void ** table_ptr,int * length)50 void rsc_table_get(void **table_ptr, int *length)
51 {
52 	*table_ptr = (void *)&resource_table;
53 	*length = sizeof(resource_table);
54 }
55