1 /* 2 * Copyright (c) 2024 EPAM Systems 3 * Copyright (c) 2024 Renesas Electronics Corporation 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 #define VDEV_ID 0xFF 18 #define VRING0_ID 0 19 #define VRING1_ID 1 20 21 #define VRING_COUNT 2 22 #define RPMSG_IPU_C0_FEATURES 1 23 24 #define R_VRING_TX DT_NODELABEL(vring_ctrl0) 25 #define R_VRING_RX DT_NODELABEL(vring_ctrl1) 26 #define VRING_TX_ADDR_CM33 DT_REG_ADDR(R_VRING_TX) 27 #define VRING_RX_ADDR_CM33 DT_REG_ADDR(R_VRING_RX) 28 29 /* 30 * Macro to convert across CM33/CM33_FPU and A55 address spaces 31 * This macro are designed to convert CM33 addresses to A55 addresses 32 * in secure and non-secure space. According to Table 5.2 of HW Manual. 33 */ 34 #ifndef _ASMLANGUAGE 35 36 #define CM33_ADDRESS_OFFSET_SECURE (0x30000000) 37 #define CM33_ADDRESS_OFFSET_NONSECURE (0x20000000) 38 #define CM33_TO_A55_ADDR_S(x) ((x) - CM33_ADDRESS_OFFSET_SECURE) 39 #define CM33_TO_A55_ADDR_NS(x) ((x) - CM33_ADDRESS_OFFSET_NONSECURE) 40 41 #endif 42 /* End of convert macro */ 43 44 #define VRING_TX_ADDR_A55 CM33_TO_A55_ADDR_NS(VRING_TX_ADDR_CM33) 45 #define VRING_RX_ADDR_A55 CM33_TO_A55_ADDR_NS(VRING_RX_ADDR_CM33) 46 #define VRING_ALIGNMENT (0x100U) 47 48 #define RSC_TABLE_NUM_RPMSG_BUFF 512 49 50 enum rsc_table_entries { 51 RSC_TABLE_VDEV_ENTRY, 52 RSC_TABLE_NUM_ENTRY 53 }; 54 55 struct fw_resource_table { 56 unsigned int ver; 57 unsigned int num; 58 unsigned int reserved[2]; 59 unsigned int offset[RSC_TABLE_NUM_ENTRY]; 60 61 struct fw_rsc_vdev vdev; 62 struct fw_rsc_vdev_vring vring0; 63 struct fw_rsc_vdev_vring vring1; 64 } METAL_PACKED_END; 65 66 void rsc_table_get(void **table_ptr, int *length); 67 rsc_table_to_vdev(void * rsc_table)68static inline struct fw_rsc_vdev *rsc_table_to_vdev(void *rsc_table) 69 { 70 return &((struct fw_resource_table *)rsc_table)->vdev; 71 } 72 rsc_table_get_vring0(void * rsc_table)73static inline struct fw_rsc_vdev_vring *rsc_table_get_vring0(void *rsc_table) 74 { 75 return &((struct fw_resource_table *)rsc_table)->vring0; 76 } 77 rsc_table_get_vring1(void * rsc_table)78static inline struct fw_rsc_vdev_vring *rsc_table_get_vring1(void *rsc_table) 79 { 80 return &((struct fw_resource_table *)rsc_table)->vring1; 81 } 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif 88