1 /* 2 * Copyright (c) 2020 STMicroelectronics 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef RESOURCE_TABLE_H__ 8 #define RESOURCE_TABLE_H__ 9 10 #include <openamp/remoteproc.h> 11 #include <openamp/virtio.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0) 18 19 #define VDEV_ID 0xFF 20 #define VRING0_ID CONFIG_OPENAMP_RSC_TABLE_IPM_RX_ID /* (host to remote) */ 21 #define VRING1_ID CONFIG_OPENAMP_RSC_TABLE_IPM_TX_ID /* (remote to host) */ 22 23 #define VRING_COUNT 2 24 #define RPMSG_IPU_C0_FEATURES 1 25 26 #define VRING_RX_ADDRESS -1 /* allocated by Master processor */ 27 #define VRING_TX_ADDRESS -1 /* allocated by Master processor */ 28 #define VRING_BUFF_ADDRESS -1 /* allocated by Master processor */ 29 #define VRING_ALIGNMENT 16 /* fixed to match with Linux constraint */ 30 31 #endif 32 33 enum rsc_table_entries { 34 #if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0) 35 RSC_TABLE_VDEV_ENTRY, 36 #endif 37 #if defined(CONFIG_RAM_CONSOLE) 38 RSC_TABLE_TRACE_ENTRY, 39 #endif 40 RSC_TABLE_NUM_ENTRY 41 }; 42 43 struct fw_resource_table { 44 struct resource_table hdr; 45 uint32_t offset[RSC_TABLE_NUM_ENTRY]; 46 47 #if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0) 48 struct fw_rsc_vdev vdev; 49 struct fw_rsc_vdev_vring vring0; 50 struct fw_rsc_vdev_vring vring1; 51 #endif 52 53 #if defined(CONFIG_RAM_CONSOLE) 54 /* rpmsg trace entry */ 55 struct fw_rsc_trace cm_trace; 56 #endif 57 } METAL_PACKED_END; 58 59 void rsc_table_get(struct fw_resource_table **table_ptr, int *length); 60 61 #if (CONFIG_OPENAMP_RSC_TABLE_NUM_RPMSG_BUFF > 0) 62 rsc_table_to_vdev(struct fw_resource_table * rsc_table)63inline struct fw_rsc_vdev *rsc_table_to_vdev(struct fw_resource_table *rsc_table) 64 { 65 return &rsc_table->vdev; 66 } 67 rsc_table_get_vring0(struct fw_resource_table * rsc_table)68inline struct fw_rsc_vdev_vring *rsc_table_get_vring0(struct fw_resource_table *rsc_table) 69 { 70 return &rsc_table->vring0; 71 } 72 rsc_table_get_vring1(struct fw_resource_table * rsc_table)73inline struct fw_rsc_vdev_vring *rsc_table_get_vring1(struct fw_resource_table *rsc_table) 74 { 75 return &rsc_table->vring1; 76 } 77 78 #endif 79 80 #ifdef __cplusplus 81 } 82 #endif 83 84 #endif 85