diff options
author | Santosh Jha | 2019-10-02 11:25:48 -0500 |
---|---|---|
committer | Santosh Jha | 2019-10-23 14:12:54 -0500 |
commit | 06be0f34a7d4572e244b14489d524e25482da508 (patch) | |
tree | 5f66f8865dab0def7d11513912f33771fab6afbe | |
parent | d8a41ef5a91133330684aba8f4cf205fa4973759 (diff) | |
download | ipc-lld-06be0f34a7d4572e244b14489d524e25482da508.tar.gz ipc-lld-06be0f34a7d4572e244b14489d524e25482da508.tar.xz ipc-lld-06be0f34a7d4572e244b14489d524e25482da508.zip |
Addressed KW and MisraC issues
Signed-off-by: Santosh Jha <sjha@ti.com>
-rw-r--r-- | examples/common/j721e/ipc_override.cfg | 5 | ||||
-rw-r--r-- | examples/common/j721e/linker_c7x_c7x_1_sysbios.lds | 2 | ||||
-rw-r--r-- | examples/common/src/ipc_rsctable.h | 136 | ||||
-rw-r--r-- | examples/common/src/ipc_setup.h | 10 | ||||
-rw-r--r-- | examples/common/src/ipc_testsetup.c | 149 | ||||
-rw-r--r-- | include/ipc_config.h | 6 | ||||
-rw-r--r-- | include/ipc_mp.h | 4 | ||||
-rw-r--r-- | include/ipc_types.h | 10 | ||||
-rw-r--r-- | include/ipc_virtio.h | 2 | ||||
-rw-r--r-- | ipc.h | 10 | ||||
-rw-r--r-- | soc/V0/ipc_soc.c | 64 | ||||
-rw-r--r-- | soc/V1/ipc_soc.c | 383 | ||||
-rw-r--r-- | soc/V1/ipc_soc.h | 100 | ||||
-rw-r--r-- | soc/ipc_soc.h | 8 | ||||
-rwxr-xr-x | src/ipc_api.c | 777 | ||||
-rw-r--r-- | src/ipc_mailbox.c | 320 | ||||
-rw-r--r-- | src/ipc_mailbox.h | 11 | ||||
-rw-r--r-- | src/ipc_mp.c | 22 | ||||
-rw-r--r-- | src/ipc_priv.h | 9 | ||||
-rwxr-xr-x | src/ipc_utils.c | 6 | ||||
-rw-r--r-- | src/ipc_utils.h | 19 | ||||
-rw-r--r-- | src/ipc_virtio.c | 213 | ||||
-rw-r--r-- | src/ipc_virtioPrivate.h | 10 | ||||
-rwxr-xr-x | src/ipc_vring.h | 12 |
24 files changed, 1156 insertions, 1132 deletions
diff --git a/examples/common/j721e/ipc_override.cfg b/examples/common/j721e/ipc_override.cfg index af83291..a80c2e9 100644 --- a/examples/common/j721e/ipc_override.cfg +++ b/examples/common/j721e/ipc_override.cfg | |||
@@ -32,19 +32,17 @@ | |||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | 33 | */ |
34 | var SysMin = xdc.module('xdc.runtime.SysMin'); | 34 | var SysMin = xdc.module('xdc.runtime.SysMin'); |
35 | var SysStd = xdc.useModule('xdc.runtime.SysStd'); | ||
36 | var System = xdc.module('xdc.runtime.System'); | 35 | var System = xdc.module('xdc.runtime.System'); |
37 | var coreId = java.lang.System.getenv("CORE"); | 36 | var coreId = java.lang.System.getenv("CORE"); |
38 | 37 | ||
39 | if(1) //(coreId == "mpu1_0") | 38 | if(1) //(coreId == "mpu1_0") |
40 | { | 39 | { |
41 | System.SupportProxy = SysMin; | ||
42 | SysMin.bufSize = 0x80000; | 40 | SysMin.bufSize = 0x80000; |
43 | } | 41 | } |
44 | else | 42 | else |
45 | { | 43 | { |
44 | var SysStd = xdc.useModule('xdc.runtime.SysStd'); | ||
46 | System.SupportProxy = SysStd; | 45 | System.SupportProxy = SysStd; |
47 | //SysMin.bufSize = 0x80000; | ||
48 | } | 46 | } |
49 | 47 | ||
50 | 48 | ||
@@ -55,7 +53,6 @@ if(coreId=="mcu1_0" || coreId=="mcu1_1" || coreId=="mcu2_0" || coreId=="mcu2_1" | |||
55 | Idle.addFunc('&sysIdleLoop'); | 53 | Idle.addFunc('&sysIdleLoop'); |
56 | 54 | ||
57 | } | 55 | } |
58 | var coreId = java.lang.System.getenv("CORE"); | ||
59 | if(coreId=="c7x_1" || coreId=="c66xdsp_1" || coreId =="c66xdsp_2") | 56 | if(coreId=="c7x_1" || coreId=="c66xdsp_1" || coreId =="c66xdsp_2") |
60 | { | 57 | { |
61 | /* Idle function */ | 58 | /* Idle function */ |
diff --git a/examples/common/j721e/linker_c7x_c7x_1_sysbios.lds b/examples/common/j721e/linker_c7x_c7x_1_sysbios.lds index f5aff7f..f00d4cd 100644 --- a/examples/common/j721e/linker_c7x_c7x_1_sysbios.lds +++ b/examples/common/j721e/linker_c7x_c7x_1_sysbios.lds | |||
@@ -102,7 +102,7 @@ SECTIONS | |||
102 | 102 | ||
103 | .cinit > C7X_DDR_SPACE /* could be part of const */ | 103 | .cinit > C7X_DDR_SPACE /* could be part of const */ |
104 | .init_array > C7X_DDR_SPACE /* C++ initializations */ | 104 | .init_array > C7X_DDR_SPACE /* C++ initializations */ |
105 | .stack > C7X_DDR_SPACE | 105 | .stack > C7X_DDR_SPACE ALIGN(0x2000) |
106 | .args > C7X_DDR_SPACE | 106 | .args > C7X_DDR_SPACE |
107 | .cio > C7X_DDR_SPACE | 107 | .cio > C7X_DDR_SPACE |
108 | .const > C7X_DDR_SPACE | 108 | .const > C7X_DDR_SPACE |
diff --git a/examples/common/src/ipc_rsctable.h b/examples/common/src/ipc_rsctable.h index 174e077..ea53f85 100644 --- a/examples/common/src/ipc_rsctable.h +++ b/examples/common/src/ipc_rsctable.h | |||
@@ -48,73 +48,73 @@ extern "C" { | |||
48 | 48 | ||
49 | #include <ti/drv/ipc/include/ipc_rsctypes.h> | 49 | #include <ti/drv/ipc/include/ipc_rsctypes.h> |
50 | 50 | ||
51 | #define R5F_MEM_RPMSG_VRING0 0xA0000000 | 51 | #define R5F_MEM_RPMSG_VRING0 0xA0000000U |
52 | #define R5F_MEM_RPMSG_VRING1 0xA0010000 | 52 | #define R5F_MEM_RPMSG_VRING1 0xA0010000U |
53 | #define MCU1_0_R5F_MEM_RPMSG_VRING0 0xA0000000 | 53 | #define MCU1_0_R5F_MEM_RPMSG_VRING0 0xA0000000U |
54 | #define MCU1_0_R5F_MEM_RPMSG_VRING1 0xA0010000 | 54 | #define MCU1_0_R5F_MEM_RPMSG_VRING1 0xA0010000U |
55 | #define MCU1_1_R5F_MEM_RPMSG_VRING0 0xA1000000 | 55 | #define MCU1_1_R5F_MEM_RPMSG_VRING0 0xA1000000U |
56 | #define MCU1_1_R5F_MEM_RPMSG_VRING1 0xA1010000 | 56 | #define MCU1_1_R5F_MEM_RPMSG_VRING1 0xA1010000U |
57 | #define MCU2_0_R5F_MEM_RPMSG_VRING0 0xA2000000 | 57 | #define MCU2_0_R5F_MEM_RPMSG_VRING0 0xA2000000U |
58 | #define MCU2_0_R5F_MEM_RPMSG_VRING1 0xA2010000 | 58 | #define MCU2_0_R5F_MEM_RPMSG_VRING1 0xA2010000U |
59 | #define MCU2_1_R5F_MEM_RPMSG_VRING0 0xA3000000 | 59 | #define MCU2_1_R5F_MEM_RPMSG_VRING0 0xA3000000U |
60 | #define MCU2_1_R5F_MEM_RPMSG_VRING1 0xA3010000 | 60 | #define MCU2_1_R5F_MEM_RPMSG_VRING1 0xA3010000U |
61 | #define MCU3_0_R5F_MEM_RPMSG_VRING0 0xA4000000 | 61 | #define MCU3_0_R5F_MEM_RPMSG_VRING0 0xA4000000U |
62 | #define MCU3_0_R5F_MEM_RPMSG_VRING1 0xA4010000 | 62 | #define MCU3_0_R5F_MEM_RPMSG_VRING1 0xA4010000U |
63 | #define MCU3_1_R5F_MEM_RPMSG_VRING0 0xA5000000 | 63 | #define MCU3_1_R5F_MEM_RPMSG_VRING0 0xA5000000U |
64 | #define MCU3_1_R5F_MEM_RPMSG_VRING1 0xA5010000 | 64 | #define MCU3_1_R5F_MEM_RPMSG_VRING1 0xA5010000U |
65 | #define C66X_1_MEM_RPMSG_VRING0 0xA7000000 /* Different than expected for caching */ | 65 | #define C66X_1_MEM_RPMSG_VRING0 0xA7000000U /* Different than expected for caching */ |
66 | #define C66X_1_MEM_RPMSG_VRING1 0xA7010000 | 66 | #define C66X_1_MEM_RPMSG_VRING1 0xA7010000U |
67 | #define C66X_2_MEM_RPMSG_VRING0 0xA6000000 /* Different than expected for caching */ | 67 | #define C66X_2_MEM_RPMSG_VRING0 0xA6000000U /* Different than expected for caching */ |
68 | #define C66X_2_MEM_RPMSG_VRING1 0xA6010000 | 68 | #define C66X_2_MEM_RPMSG_VRING1 0xA6010000U |
69 | #define C7X_1_MEM_RPMSG_VRING0 0xA8000000 | 69 | #define C7X_1_MEM_RPMSG_VRING0 0xA8000000U |
70 | #define C7X_1_MEM_RPMSG_VRING1 0xA8010000 | 70 | #define C7X_1_MEM_RPMSG_VRING1 0xA8010000U |
71 | 71 | ||
72 | #define SZ_1M 0x00100000 | 72 | #define SZ_1M 0x00100000U |
73 | 73 | ||
74 | #define R5F_MEM_IPC_VRING_SIZE SZ_1M | 74 | #define R5F_MEM_IPC_VRING_SIZE SZ_1M |
75 | 75 | ||
76 | #define R5F_NUM_ENTRIES 2 | 76 | #define R5F_NUM_ENTRIES 2U |
77 | 77 | ||
78 | /* | 78 | /* |
79 | * Assign fixed RAM addresses to facilitate a fixed MMU table. | 79 | * Assign fixed RAM addresses to facilitate a fixed MMU table. |
80 | * PHYS_MEM_IPC_VRING & PHYS_MEM_IPC_DATA MUST be together. | 80 | * PHYS_MEM_IPC_VRING & PHYS_MEM_IPC_DATA MUST be together. |
81 | */ | 81 | */ |
82 | /* See CMA BASE addresses in Linux side: arch/arm/mach-omap2/remoteproc.c */ | 82 | /* See CMA BASE addresses in Linux side: arch/arm/mach-omap2/remoteproc.c */ |
83 | #define PHYS_MEM_IPC_VRING 0xA0000000 | 83 | #define PHYS_MEM_IPC_VRING 0xA0000000U |
84 | #define MCU1_0_PHYS_MEM_IPC_VRING 0xA0000000 | 84 | #define MCU1_0_PHYS_MEM_IPC_VRING 0xA0000000U |
85 | #define MCU1_1_PHYS_MEM_IPC_VRING 0xA1000000 | 85 | #define MCU1_1_PHYS_MEM_IPC_VRING 0xA1000000U |
86 | #define MCU2_0_PHYS_MEM_IPC_VRING 0xA2000000 | 86 | #define MCU2_0_PHYS_MEM_IPC_VRING 0xA2000000U |
87 | #define MCU2_1_PHYS_MEM_IPC_VRING 0xA3000000 | 87 | #define MCU2_1_PHYS_MEM_IPC_VRING 0xA3000000U |
88 | #define MCU3_0_PHYS_MEM_IPC_VRING 0xA4000000 | 88 | #define MCU3_0_PHYS_MEM_IPC_VRING 0xA4000000U |
89 | #define MCU3_1_PHYS_MEM_IPC_VRING 0xA5000000 | 89 | #define MCU3_1_PHYS_MEM_IPC_VRING 0xA5000000U |
90 | #define C66X_1_PHYS_MEM_IPC_VRING 0xA7000000 /* Different than expected for caching purpose */ | 90 | #define C66X_1_PHYS_MEM_IPC_VRING 0xA7000000U /* Different than expected for caching purpose */ |
91 | #define C66X_2_PHYS_MEM_IPC_VRING 0xA6000000 /* Different than expected for caching purpose */ | 91 | #define C66X_2_PHYS_MEM_IPC_VRING 0xA6000000U /* Different than expected for caching purpose */ |
92 | #define C7X_1_PHYS_MEM_IPC_VRING 0xA8000000 | 92 | #define C7X_1_PHYS_MEM_IPC_VRING 0xA8000000U |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * Sizes of the virtqueues (expressed in number of buffers supported, | 95 | * Sizes of the virtqueues (expressed in number of buffers supported, |
96 | * and must be power of 2) | 96 | * and must be power of 2) |
97 | */ | 97 | */ |
98 | #define R5F_RPMSG_VQ0_SIZE 256 | 98 | #define R5F_RPMSG_VQ0_SIZE 256U |
99 | #define R5F_RPMSG_VQ1_SIZE 256 | 99 | #define R5F_RPMSG_VQ1_SIZE 256U |
100 | #define C66_RPMSG_VQ0_SIZE 256 | 100 | #define C66_RPMSG_VQ0_SIZE 256U |
101 | #define C66_RPMSG_VQ1_SIZE 256 | 101 | #define C66_RPMSG_VQ1_SIZE 256U |
102 | #define C7X_RPMSG_VQ0_SIZE 256 | 102 | #define C7X_RPMSG_VQ0_SIZE 256U |
103 | #define C7X_RPMSG_VQ1_SIZE 256 | 103 | #define C7X_RPMSG_VQ1_SIZE 256U |
104 | 104 | ||
105 | /* flip up bits whose indices represent features we support */ | 105 | /* flip up bits whose indices represent features we support */ |
106 | #define RPMSG_R5F_C0_FEATURES 1 | 106 | #define RPMSG_R5F_C0_FEATURES 1U |
107 | #define RPMSG_C66_DSP_FEATURES 1 | 107 | #define RPMSG_C66_DSP_FEATURES 1U |
108 | #define RPMSG_C7X_DSP_FEATURES 1 | 108 | #define RPMSG_C7X_DSP_FEATURES 1U |
109 | 109 | ||
110 | extern char xdc_runtime_SysMin_Module_State_0_outbuf__A; | 110 | extern char xdc_runtime_SysMin_Module_State_0_outbuf__A; |
111 | #define TRACEBUFADDR ((uintptr_t)&xdc_runtime_SysMin_Module_State_0_outbuf__A) | 111 | #define TRACEBUFADDR ((uintptr_t)&xdc_runtime_SysMin_Module_State_0_outbuf__A) |
112 | 112 | ||
113 | const Ipc_ResourceTable ti_ipc_remoteproc_ResourceTable __attribute__ ((section (".resource_table"), aligned (4096))) = | 113 | const Ipc_ResourceTable ti_ipc_remoteproc_ResourceTable __attribute__ ((section (".resource_table"), aligned (4096))) = |
114 | { | 114 | { |
115 | 1, /* we're the first version that implements this */ | 115 | 1U, /* we're the first version that implements this */ |
116 | NUM_ENTRIES, /* number of entries in the table */ | 116 | NUM_ENTRIES, /* number of entries in the table */ |
117 | 0, 0, /* reserved, must be zero */ | 117 | 0U, 0U, /* reserved, must be zero */ |
118 | 118 | ||
119 | /* offsets to entries */ | 119 | /* offsets to entries */ |
120 | { | 120 | { |
@@ -124,47 +124,47 @@ const Ipc_ResourceTable ti_ipc_remoteproc_ResourceTable __attribute__ ((section | |||
124 | 124 | ||
125 | /* rpmsg vdev entry */ | 125 | /* rpmsg vdev entry */ |
126 | { | 126 | { |
127 | TYPE_VDEV, VIRTIO_ID_RPMSG, 0, | 127 | TYPE_VDEV, VIRTIO_ID_RPMSG, 0U, |
128 | #if defined (BUILD_C66X_1) || defined (BUILD_C66X_2) | 128 | #if defined (BUILD_C66X_1) || defined (BUILD_C66X_2) |
129 | RPMSG_C66_DSP_FEATURES, 0, 0, 0, 2, { 0, 0 }, | 129 | RPMSG_C66_DSP_FEATURES, 0U, 0U, 0U, 2U, { 0U, 0U }, |
130 | #elif defined (BUILD_C7X_1) | 130 | #elif defined (BUILD_C7X_1) |
131 | RPMSG_C7X_DSP_FEATURES, 0, 0, 0, 2, { 0, 0 }, | 131 | RPMSG_C7X_DSP_FEATURES, 0U, 0U, 0U, 2U, { 0U, 0U }, |
132 | #else | 132 | #else |
133 | RPMSG_R5F_C0_FEATURES, 0, 0, 0, 2, { 0, 0 }, | 133 | RPMSG_R5F_C0_FEATURES, 0U, 0U, 0U, 2U, { 0U, 0U }, |
134 | #endif | 134 | #endif |
135 | /* no config data */ | 135 | /* no config data */ |
136 | }, | 136 | }, |
137 | /* the two vrings */ | 137 | /* the two vrings */ |
138 | #if defined (BUILD_MCU1_0) | 138 | #if defined (BUILD_MCU1_0) |
139 | { MCU1_0_R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 139 | { MCU1_0_R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
140 | { MCU1_0_R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 140 | { MCU1_0_R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
141 | #elif defined (BUILD_MCU1_1) | 141 | #elif defined (BUILD_MCU1_1) |
142 | { MCU1_1_R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 142 | { MCU1_1_R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
143 | { MCU1_1_R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 143 | { MCU1_1_R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
144 | #elif defined (BUILD_MCU2_0) | 144 | #elif defined (BUILD_MCU2_0) |
145 | { MCU2_0_R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 145 | { MCU2_0_R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
146 | { MCU2_0_R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 146 | { MCU2_0_R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
147 | #elif defined (BUILD_MCU2_1) | 147 | #elif defined (BUILD_MCU2_1) |
148 | { MCU2_1_R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 148 | { MCU2_1_R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
149 | { MCU2_1_R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 149 | { MCU2_1_R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
150 | #elif defined (BUILD_MCU3_0) | 150 | #elif defined (BUILD_MCU3_0) |
151 | { MCU3_0_R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 151 | { MCU3_0_R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
152 | { MCU3_0_R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 152 | { MCU3_0_R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
153 | #elif defined (BUILD_MCU3_1) | 153 | #elif defined (BUILD_MCU3_1) |
154 | { MCU3_1_R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 154 | { MCU3_1_R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
155 | { MCU3_1_R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 155 | { MCU3_1_R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
156 | #elif defined (BUILD_C66X_1) | 156 | #elif defined (BUILD_C66X_1) |
157 | { C66X_1_MEM_RPMSG_VRING0, 4096, C66_RPMSG_VQ0_SIZE, 1, 0 }, | 157 | { C66X_1_MEM_RPMSG_VRING0, 4096U, C66_RPMSG_VQ0_SIZE, 1U, 0U }, |
158 | { C66X_1_MEM_RPMSG_VRING1, 4096, C66_RPMSG_VQ1_SIZE, 2, 0 }, | 158 | { C66X_1_MEM_RPMSG_VRING1, 4096U, C66_RPMSG_VQ1_SIZE, 2U, 0U }, |
159 | #elif defined (BUILD_C66X_2) | 159 | #elif defined (BUILD_C66X_2) |
160 | { C66X_2_MEM_RPMSG_VRING0, 4096, C66_RPMSG_VQ0_SIZE, 1, 0 }, | 160 | { C66X_2_MEM_RPMSG_VRING0, 4096U, C66_RPMSG_VQ0_SIZE, 1U, 0U }, |
161 | { C66X_2_MEM_RPMSG_VRING1, 4096, C66_RPMSG_VQ1_SIZE, 2, 0 }, | 161 | { C66X_2_MEM_RPMSG_VRING1, 4096U, C66_RPMSG_VQ1_SIZE, 2U, 0U }, |
162 | #elif defined (BUILD_C7X_1) | 162 | #elif defined (BUILD_C7X_1) |
163 | { C7X_1_MEM_RPMSG_VRING0, 4096, C7X_RPMSG_VQ0_SIZE, 1, 0 }, | 163 | { C7X_1_MEM_RPMSG_VRING0, 4096U, C7X_RPMSG_VQ0_SIZE, 1U, 0U }, |
164 | { C7X_1_MEM_RPMSG_VRING1, 4096, C7X_RPMSG_VQ1_SIZE, 2, 0 }, | 164 | { C7X_1_MEM_RPMSG_VRING1, 4096U, C7X_RPMSG_VQ1_SIZE, 2U, 0U }, |
165 | #else | 165 | #else |
166 | { R5F_MEM_RPMSG_VRING0, 4096, R5F_RPMSG_VQ0_SIZE, 1, 0 }, | 166 | { R5F_MEM_RPMSG_VRING0, 4096U, R5F_RPMSG_VQ0_SIZE, 1U, 0U }, |
167 | { R5F_MEM_RPMSG_VRING1, 4096, R5F_RPMSG_VQ1_SIZE, 2, 0 }, | 167 | { R5F_MEM_RPMSG_VRING1, 4096U, R5F_RPMSG_VQ1_SIZE, 2U, 0U }, |
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | { | 170 | { |
diff --git a/examples/common/src/ipc_setup.h b/examples/common/src/ipc_setup.h index 32ff915..b8eeecc 100644 --- a/examples/common/src/ipc_setup.h +++ b/examples/common/src/ipc_setup.h | |||
@@ -45,16 +45,16 @@ extern "C" { | |||
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | /* this should be >= RPMessage_getObjMemRequired() */ | 47 | /* this should be >= RPMessage_getObjMemRequired() */ |
48 | #define IPC_RPMESSAGE_OBJ_SIZE 256 | 48 | #define IPC_RPMESSAGE_OBJ_SIZE 256U |
49 | 49 | ||
50 | #define RPMSG_DATA_SIZE (256*512 + IPC_RPMESSAGE_OBJ_SIZE) | 50 | #define RPMSG_DATA_SIZE (256U*512U + IPC_RPMESSAGE_OBJ_SIZE) |
51 | #define VQ_BUF_SIZE 2048 | 51 | #define VQ_BUF_SIZE 2048U |
52 | 52 | ||
53 | /* Same Start Address using for Maxwell & J721E device */ | 53 | /* Same Start Address using for Maxwell & J721E device */ |
54 | #ifdef SOC_AM65XX | 54 | #ifdef SOC_AM65XX |
55 | #define VRING_BASE_ADDRESS 0xA2000000 | 55 | #define VRING_BASE_ADDRESS 0xA2000000U |
56 | #else | 56 | #else |
57 | #define VRING_BASE_ADDRESS 0xAA000000 | 57 | #define VRING_BASE_ADDRESS 0xAA000000U |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | int32_t Ipc_echo_test(void); | 60 | int32_t Ipc_echo_test(void); |
diff --git a/examples/common/src/ipc_testsetup.c b/examples/common/src/ipc_testsetup.c index f4ceb76..ffc452c 100644 --- a/examples/common/src/ipc_testsetup.c +++ b/examples/common/src/ipc_testsetup.c | |||
@@ -44,6 +44,7 @@ | |||
44 | 44 | ||
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | #include <stdint.h> | 46 | #include <stdint.h> |
47 | #include <string.h> | ||
47 | 48 | ||
48 | /* XDCtools Header files */ | 49 | /* XDCtools Header files */ |
49 | #include <xdc/std.h> | 50 | #include <xdc/std.h> |
@@ -67,10 +68,10 @@ | |||
67 | #endif | 68 | #endif |
68 | #endif | 69 | #endif |
69 | 70 | ||
70 | #define MSGSIZE 256 | 71 | #define MSGSIZE 256U |
71 | #define SERVICE "ti.ipc4.ping-pong" | 72 | #define SERVICE "ti.ipc4.ping-pong" |
72 | #define ENDPT1 13 | 73 | #define ENDPT1 13U |
73 | #define NUMMSGS 10 /* number of message sent per task */ | 74 | #define NUMMSGS 10000 /* number of message sent per task */ |
74 | //#define NUMMSGS 1000000 /* number of message sent per task */ | 75 | //#define NUMMSGS 1000000 /* number of message sent per task */ |
75 | 76 | ||
76 | extern uint8_t *pCntrlBuf; | 77 | extern uint8_t *pCntrlBuf; |
@@ -132,7 +133,7 @@ void rpmsg_responderFxn(UArg arg0, UArg arg1) | |||
132 | int32_t n; | 133 | int32_t n; |
133 | int32_t status = 0; | 134 | int32_t status = 0; |
134 | void *buf; | 135 | void *buf; |
135 | 136 | ||
136 | uint32_t bufSize = rpmsgDataSize; | 137 | uint32_t bufSize = rpmsgDataSize; |
137 | char str[MSGSIZE]; | 138 | char str[MSGSIZE]; |
138 | 139 | ||
@@ -140,7 +141,7 @@ void rpmsg_responderFxn(UArg arg0, UArg arg1) | |||
140 | if(buf == NULL) | 141 | if(buf == NULL) |
141 | { | 142 | { |
142 | System_printf("RecvTask: buffer allocation failed\n"); | 143 | System_printf("RecvTask: buffer allocation failed\n"); |
143 | return; | 144 | return; |
144 | } | 145 | } |
145 | 146 | ||
146 | RPMessageParams_init(¶ms); | 147 | RPMessageParams_init(¶ms); |
@@ -162,53 +163,64 @@ void rpmsg_responderFxn(UArg arg0, UArg arg1) | |||
162 | status = RPMessage_announce(RPMESSAGE_ALL, myEndPt, SERVICE); | 163 | status = RPMessage_announce(RPMESSAGE_ALL, myEndPt, SERVICE); |
163 | if(status != IPC_SOK) | 164 | if(status != IPC_SOK) |
164 | { | 165 | { |
165 | System_printf("RecvTask: RPMessage_announce() failed\n"); | 166 | System_printf("RecvTask: RPMessage_announce() failed\n"); |
166 | return; | 167 | return; |
167 | } | 168 | } |
168 | 169 | ||
169 | while(!g_exitRespTsk) | 170 | while(!g_exitRespTsk) |
170 | { | 171 | { |
171 | status = RPMessage_recv(handle, (Ptr)str, &len, &remoteEndPt, &remoteProcId, | 172 | status = RPMessage_recv(handle, (Ptr)str, &len, &remoteEndPt, &remoteProcId, |
172 | IPC_RPMESSAGE_TIMEOUT_FOREVER); | 173 | IPC_RPMESSAGE_TIMEOUT_FOREVER); |
173 | if(status != IPC_SOK) | 174 | if(status != IPC_SOK) |
174 | { | 175 | { |
175 | System_printf("RecvTask: failed with code %d\n", status); | 176 | System_printf("RecvTask: failed with code %d\n", status); |
176 | } | 177 | } |
177 | else | 178 | else |
178 | { | 179 | { |
179 | /* NULL terminated string */ | 180 | /* NULL terminated string */ |
180 | str[len] = '\0'; | 181 | str[len] = '\0'; |
181 | #ifdef DEBUG_PRINT | 182 | #ifdef DEBUG_PRINT |
182 | System_printf("RecvTask: Revcvd msg \"%s\" len %d from %s\n", | 183 | System_printf("RecvTask: Revcvd msg \"%s\" len %d from %s\n", |
183 | str, len, Ipc_mpGetName(remoteProcId)); | 184 | str, len, Ipc_mpGetName(remoteProcId)); |
184 | #endif | 185 | #endif |
185 | } | 186 | } |
186 | 187 | ||
187 | status = sscanf(str, "ping %d", &n); | 188 | status = sscanf(str, "ping %d", &n); |
188 | if(status == 1) | 189 | if(status == 1) |
189 | { | 190 | { |
190 | len = snprintf(str, MSGSIZE-1, "pong %d", n); | 191 | memset(str, 0, MSGSIZE); |
191 | } | 192 | len = snprintf(str, 255, "pong %d", n); |
193 | if(len > 255) | ||
194 | { | ||
195 | System_printf("RecvTask: snprintf failed, len %d\n", len); | ||
196 | len = 255; | ||
197 | } | ||
198 | str[len++] = '\0'; | ||
199 | } | ||
192 | else | 200 | else |
193 | { | 201 | { |
194 | /* If this is not ping/pong message, just print the message */ | 202 | /* If this is not ping/pong message, just print the message */ |
195 | System_printf("%s <--> %s : %s recvd\n", | 203 | System_printf("%s <--> %s : %s recvd\n", |
196 | Ipc_mpGetSelfName(), | 204 | Ipc_mpGetSelfName(), |
197 | Ipc_mpGetName(remoteProcId), | 205 | Ipc_mpGetName(remoteProcId), |
198 | str); | 206 | str); |
199 | } | 207 | } |
200 | #ifdef DEBUG_PRINT | 208 | #ifdef DEBUG_PRINT |
201 | System_printf("RecvTask: Sending msg \"%s\" len %d from %s to %s\n", | 209 | System_printf("RecvTask: Sending msg \"%s\" len %d from %s to %s\n", |
202 | str, len, Ipc_mpGetSelfName(), | 210 | str, len, Ipc_mpGetSelfName(), |
203 | Ipc_mpGetName(remoteProcId)); | 211 | Ipc_mpGetName(remoteProcId)); |
204 | #endif | 212 | #endif |
205 | status = RPMessage_send(handle, remoteProcId, remoteEndPt, myEndPt, str, len); | 213 | status = RPMessage_send(handle, remoteProcId, remoteEndPt, myEndPt, str, len); |
206 | if (status != IPC_SOK) | 214 | if (status != IPC_SOK) |
207 | { | 215 | { |
208 | System_printf("RecvTask: RPMessage_send " | 216 | System_printf("RecvTask: Sending msg \"%s\" len %d from %s to %s failed!!!\n", |
209 | " failed status %d procId %d\n", status, remoteProcId); | 217 | str, len, Ipc_mpGetSelfName(), |
210 | } | 218 | Ipc_mpGetName(remoteProcId)); |
219 | } | ||
211 | } | 220 | } |
221 | |||
222 | System_printf("%s responder task exiting ...\n", | ||
223 | Ipc_mpGetSelfName()); | ||
212 | } | 224 | } |
213 | 225 | ||
214 | void rpmsg_senderFxn(UArg arg0, UArg arg1) | 226 | void rpmsg_senderFxn(UArg arg0, UArg arg1) |
@@ -227,7 +239,7 @@ void rpmsg_senderFxn(UArg arg0, UArg arg1) | |||
227 | 239 | ||
228 | uint32_t cntPing = 0; | 240 | uint32_t cntPing = 0; |
229 | uint32_t cntPong = 0; | 241 | uint32_t cntPong = 0; |
230 | 242 | ||
231 | buf1 = &pSendTaskBuf[rpmsgDataSize * arg1]; | 243 | buf1 = &pSendTaskBuf[rpmsgDataSize * arg1]; |
232 | dstProc = arg0; | 244 | dstProc = arg0; |
233 | 245 | ||
@@ -240,49 +252,60 @@ void rpmsg_senderFxn(UArg arg0, UArg arg1) | |||
240 | if(!handle) | 252 | if(!handle) |
241 | { | 253 | { |
242 | System_printf("SendTas %d: Failed to create message endpoint\n", | 254 | System_printf("SendTas %d: Failed to create message endpoint\n", |
243 | dstProc); | 255 | dstProc); |
244 | return; | 256 | return; |
245 | } | 257 | } |
246 | 258 | ||
247 | status = RPMessage_getRemoteEndPt(dstProc, SERVICE, &remoteProcId, | 259 | status = RPMessage_getRemoteEndPt(dstProc, SERVICE, &remoteProcId, |
248 | &remoteEndPt, BIOS_WAIT_FOREVER); | 260 | &remoteEndPt, BIOS_WAIT_FOREVER); |
249 | if(dstProc != remoteProcId) | 261 | if(dstProc != remoteProcId) |
250 | { | 262 | { |
251 | System_printf("SendTask%d: RPMessage_getRemoteEndPt() malfunctioned, status %d\n", | 263 | System_printf("SendTask%d: RPMessage_getRemoteEndPt() malfunctioned, status %d\n", |
252 | dstProc, status); | 264 | dstProc, status); |
253 | return; | 265 | return; |
254 | } | 266 | } |
255 | 267 | ||
256 | for (i = 0; i < NUMMSGS; i++) | 268 | for (i = 0; i < NUMMSGS; i++) |
257 | { | 269 | { |
258 | /* Send data to remote endPt: */ | 270 | /* Send data to remote endPt: */ |
259 | len = snprintf(buf, MSGSIZE-1, "ping %d", i); | 271 | memset(buf, 0, 256); |
260 | buf[len++] = '\0'; | 272 | len = snprintf(buf, 255, "ping %d", i); |
273 | if(len > 255) | ||
274 | { | ||
275 | System_printf("SendTask%d: snprintf failed, len %d\n", dstProc, len); | ||
276 | len = 255; | ||
277 | } | ||
278 | buf[len++] = '\0'; | ||
261 | 279 | ||
262 | #ifdef DEBUG_PRINT | 280 | #ifdef DEBUG_PRINT |
263 | System_printf("SendTask%d: Sending \"%s\" from %s to %s...\n", dstProc, | 281 | System_printf("SendTask%d: Sending \"%s\" from %s to %s...\n", dstProc, |
264 | buf, Ipc_mpGetSelfName(), | 282 | buf, Ipc_mpGetSelfName(), |
265 | Ipc_mpGetName(dstProc)); | 283 | Ipc_mpGetName(dstProc)); |
266 | #endif | 284 | #endif |
267 | /* Increase the Ping Counter */ | 285 | /* Increase the Ping Counter */ |
268 | cntPing++; | 286 | cntPing++; |
269 | 287 | ||
270 | status = RPMessage_send(handle, dstProc, ENDPT1, myEndPt, (Ptr)buf, len); | 288 | status = RPMessage_send(handle, dstProc, ENDPT1, myEndPt, (Ptr)buf, len); |
271 | if (status != IPC_SOK) | 289 | if (status != IPC_SOK) |
272 | { | 290 | { |
273 | System_printf("SendTask%d: rpmsg_senderFxn: RPMessage_send " | 291 | System_printf("SendTask%d: RPMessage_send Failed Msg-> \"%s\" from %s to %s...\n", |
274 | " failed status %d\n", dstProc, status); | 292 | dstProc, |
275 | } | 293 | buf, Ipc_mpGetSelfName(), |
294 | Ipc_mpGetName(dstProc)); | ||
295 | break; | ||
296 | } | ||
297 | |||
276 | 298 | ||
277 | /* wait a for a response message: */ | 299 | /* wait a for a response message: */ |
278 | status = RPMessage_recv(handle, (Ptr)buf, &len, &remoteEndPt, | 300 | status = RPMessage_recv(handle, (Ptr)buf, &len, &remoteEndPt, |
279 | &remoteProcId, IPC_RPMESSAGE_TIMEOUT_FOREVER); | 301 | &remoteProcId, IPC_RPMESSAGE_TIMEOUT_FOREVER); |
280 | 302 | ||
281 | if(status != IPC_SOK) | 303 | if(status != IPC_SOK) |
282 | { | 304 | { |
283 | System_printf("SendTask%d: RPMessage_recv failed with code %d\n", | 305 | System_printf("SendTask%d: RPMessage_recv failed with code %d\n", |
284 | dstProc, status); | 306 | dstProc, status); |
285 | } | 307 | break; |
308 | } | ||
286 | 309 | ||
287 | /* Make it NULL terminated string */ | 310 | /* Make it NULL terminated string */ |
288 | if(len >= MSGSIZE) | 311 | if(len >= MSGSIZE) |
@@ -294,22 +317,22 @@ void rpmsg_senderFxn(UArg arg0, UArg arg1) | |||
294 | buf[len] = '\0'; | 317 | buf[len] = '\0'; |
295 | } | 318 | } |
296 | #ifdef DEBUG_PRINT | 319 | #ifdef DEBUG_PRINT |
297 | System_printf("SendTask%d: Received \"%s\" len %d from %s endPt %d \n", | 320 | System_printf("SendTask%d: Received \"%s\" len %d from %s endPt %d \n", |
298 | dstProc, buf, len, Ipc_mpGetName(remoteProcId), | 321 | dstProc, buf, len, Ipc_mpGetName(remoteProcId), |
299 | remoteEndPt); | 322 | remoteEndPt); |
300 | #endif | 323 | #endif |
301 | cntPong++; | 324 | cntPong++; |
302 | if(i%50 == 0) | 325 | if((i+1)%50 == 0) |
303 | { | 326 | { |
304 | System_printf("%s <--> %s, ping/pong iteration %d ...\n", | 327 | //System_printf("%s <--> %s, ping/pong iteration %d ...\n", |
305 | Ipc_mpGetSelfName(), Ipc_mpGetName(dstProc), i); | 328 | // Ipc_mpGetSelfName(), Ipc_mpGetName(dstProc), i); |
306 | } | 329 | } |
307 | } | 330 | } |
308 | 331 | ||
309 | System_printf("%s <--> %s, Ping- %d, pong - %d completed\n", | 332 | System_printf("%s <--> %s, Ping- %d, pong - %d completed\n", |
310 | Ipc_mpGetSelfName(), | 333 | Ipc_mpGetSelfName(), |
311 | Ipc_mpGetName(dstProc), | 334 | Ipc_mpGetName(dstProc), |
312 | cntPing, cntPong); | 335 | cntPing, cntPong); |
313 | 336 | ||
314 | /* Delete the RPMesg object now */ | 337 | /* Delete the RPMesg object now */ |
315 | RPMessage_delete(&handle); | 338 | RPMessage_delete(&handle); |
@@ -334,15 +357,15 @@ void rpmsg_vdevMonitorFxn(UArg arg0, UArg arg1) | |||
334 | status = Ipc_lateVirtioCreate(IPC_MPU1_0); | 357 | status = Ipc_lateVirtioCreate(IPC_MPU1_0); |
335 | if(status != IPC_SOK) | 358 | if(status != IPC_SOK) |
336 | { | 359 | { |
337 | System_printf("%s: Ipc_lateVirtioCreate failed\n", __func__); | 360 | System_printf("%s: Ipc_lateVirtioCreate failed\n", __func__); |
338 | return; | 361 | return; |
339 | } | 362 | } |
340 | 363 | ||
341 | status = RPMessage_lateInit(IPC_MPU1_0); | 364 | status = RPMessage_lateInit(IPC_MPU1_0); |
342 | if(status != IPC_SOK) | 365 | if(status != IPC_SOK) |
343 | { | 366 | { |
344 | System_printf("%s: RPMessage_lateInit failed\n", __func__); | 367 | System_printf("%s: RPMessage_lateInit failed\n", __func__); |
345 | return; | 368 | return; |
346 | } | 369 | } |
347 | 370 | ||
348 | status = RPMessage_announce(IPC_MPU1_0, RecvEndPt, SERVICE); | 371 | status = RPMessage_announce(IPC_MPU1_0, RecvEndPt, SERVICE); |
@@ -366,7 +389,7 @@ int32_t Ipc_echo_test(void) | |||
366 | Ipc_mpSetConfig(selfProcId, numProc, pRemoteProcArray); | 389 | Ipc_mpSetConfig(selfProcId, numProc, pRemoteProcArray); |
367 | 390 | ||
368 | System_printf("IPC_echo_test (core : %s) .....\r\n%s\r\n", | 391 | System_printf("IPC_echo_test (core : %s) .....\r\n%s\r\n", |
369 | Ipc_mpGetSelfName(), IPC_DRV_VERSION_STR); | 392 | Ipc_mpGetSelfName(), IPC_DRV_VERSION_STR); |
370 | 393 | ||
371 | Ipc_init(NULL); | 394 | Ipc_init(NULL); |
372 | 395 | ||
@@ -385,7 +408,7 @@ int32_t Ipc_echo_test(void) | |||
385 | { | 408 | { |
386 | while(!Ipc_isRemoteReady(pRemoteProcArray[t])) | 409 | while(!Ipc_isRemoteReady(pRemoteProcArray[t])) |
387 | { | 410 | { |
388 | // Task_sleep(100); | 411 | // Task_sleep(100); |
389 | } | 412 | } |
390 | } | 413 | } |
391 | //System_printf("Linux VDEV ready now .....\n"); | 414 | //System_printf("Linux VDEV ready now .....\n"); |
@@ -427,11 +450,11 @@ int32_t Ipc_echo_test(void) | |||
427 | for(t = 0; t < numProc; t++, index++) | 450 | for(t = 0; t < numProc; t++, index++) |
428 | { | 451 | { |
429 | #if !defined(BUILD_MPU1_0) && defined(A72_LINUX_OS) | 452 | #if !defined(BUILD_MPU1_0) && defined(A72_LINUX_OS) |
430 | /* Linux does not have a responder func running */ | 453 | /* Linux does not have a responder func running */ |
431 | if(pRemoteProcArray[t] == IPC_MPU1_0) | 454 | if(pRemoteProcArray[t] == IPC_MPU1_0) |
432 | continue; | 455 | continue; |
433 | #endif | 456 | #endif |
434 | /* send messages to peer(s) on ENDPT1 */ | 457 | /* send messages to peer(s) on ENDPT1 */ |
435 | Task_Params_init(¶ms); | 458 | Task_Params_init(¶ms); |
436 | params.priority = 3; | 459 | params.priority = 3; |
437 | params.stack = &pTaskBuf[index * IPC_TASK_STACKSIZE]; | 460 | params.stack = &pTaskBuf[index * IPC_TASK_STACKSIZE]; |
@@ -439,7 +462,7 @@ int32_t Ipc_echo_test(void) | |||
439 | params.arg0 = pRemoteProcArray[t]; | 462 | params.arg0 = pRemoteProcArray[t]; |
440 | params.arg1 = t; | 463 | params.arg1 = t; |
441 | Task_create(rpmsg_senderFxn, ¶ms, NULL); | 464 | Task_create(rpmsg_senderFxn, ¶ms, NULL); |
442 | 465 | ||
443 | } | 466 | } |
444 | 467 | ||
445 | #if !defined(BUILD_MPU1_0) && defined(A72_LINUX_OS) && defined(A72_LINUX_OS_IPC_ATTACH) | 468 | #if !defined(BUILD_MPU1_0) && defined(A72_LINUX_OS) && defined(A72_LINUX_OS_IPC_ATTACH) |
diff --git a/include/ipc_config.h b/include/ipc_config.h index 6d8c7c6..60d532c 100644 --- a/include/ipc_config.h +++ b/include/ipc_config.h | |||
@@ -71,12 +71,12 @@ extern "C" { | |||
71 | * \brief Size of VRing. There are 256 buffer of 512 bytes | 71 | * \brief Size of VRing. There are 256 buffer of 512 bytes |
72 | * Allocate same amount for book keeping. | 72 | * Allocate same amount for book keeping. |
73 | */ | 73 | */ |
74 | #define IPC_VRING_SIZE (0x20000) | 74 | #define IPC_VRING_SIZE (0x20000U) |
75 | 75 | ||
76 | #ifdef BUILD_C7X_1 | 76 | #ifdef BUILD_C7X_1 |
77 | #define IPC_TASK_STACKSIZE 0x4000 | 77 | #define IPC_TASK_STACKSIZE 0x4000U |
78 | #else | 78 | #else |
79 | #define IPC_TASK_STACKSIZE 0x2000 | 79 | #define IPC_TASK_STACKSIZE 0x2000U |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | #ifdef IPC_SUPPORT_SCICLIENT | 82 | #ifdef IPC_SUPPORT_SCICLIENT |
diff --git a/include/ipc_mp.h b/include/ipc_mp.h index fffa2de..7985d5a 100644 --- a/include/ipc_mp.h +++ b/include/ipc_mp.h | |||
@@ -65,7 +65,7 @@ extern "C" { | |||
65 | /** | 65 | /** |
66 | * \brief Invalid processor id. | 66 | * \brief Invalid processor id. |
67 | */ | 67 | */ |
68 | #define IPC_MP_INVALID_ID (0xFFFFFFFF) | 68 | #define IPC_MP_INVALID_ID (0xFFFFFFFFU) |
69 | 69 | ||
70 | /* ========================================================================== */ | 70 | /* ========================================================================== */ |
71 | /* Structure Declarations */ | 71 | /* Structure Declarations */ |
@@ -141,7 +141,7 @@ const char* Ipc_mpGetSelfName(void); | |||
141 | * \brief Returns procId of the given index | 141 | * \brief Returns procId of the given index |
142 | * | 142 | * |
143 | */ | 143 | */ |
144 | uint32_t Ipc_mpGetRemoteProcId(uint32_t index); | 144 | uint32_t Ipc_mpGetRemoteProcId(uint32_t coreIndex); |
145 | 145 | ||
146 | /* ========================================================================== */ | 146 | /* ========================================================================== */ |
147 | /* Static Function Definitions */ | 147 | /* Static Function Definitions */ |
diff --git a/include/ipc_types.h b/include/ipc_types.h index b23ebd3..71ad09f 100644 --- a/include/ipc_types.h +++ b/include/ipc_types.h | |||
@@ -90,7 +90,7 @@ extern "C" { | |||
90 | #define IPC_E_UNBLOCKED (-50) | 90 | #define IPC_E_UNBLOCKED (-50) |
91 | 91 | ||
92 | /** \brief Macro used to specify that interrupt number is invalid. */ | 92 | /** \brief Macro used to specify that interrupt number is invalid. */ |
93 | #define IPC_INTR_INVALID ((uint32_t) 0xFFFF0000) | 93 | #define IPC_INTR_INVALID (0xFFFF0000U) |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * \brief Timeout foreever for IPC Recv | 96 | * \brief Timeout foreever for IPC Recv |
@@ -100,17 +100,17 @@ extern "C" { | |||
100 | /** | 100 | /** |
101 | * \brief RPMessage Endpoint any available | 101 | * \brief RPMessage Endpoint any available |
102 | */ | 102 | */ |
103 | #define RPMESSAGE_ANY (0xFFFFFFFF) | 103 | #define RPMESSAGE_ANY (0xFFFFFFFFU) |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * \brief RPMessage type | 106 | * \brief RPMessage type |
107 | */ | 107 | */ |
108 | #define RPMESSAGE_ALL (0xFFFFFFFF) | 108 | #define RPMESSAGE_ALL (0xFFFFFFFFU) |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * \brief Mailbox interrupt router configuration | 111 | * \brief Mailbox interrupt router configuration |
112 | */ | 112 | */ |
113 | typedef struct Ipc_MbConfig | 113 | typedef struct Ipc_MbConfig_s |
114 | { | 114 | { |
115 | uint32_t priority; | 115 | uint32_t priority; |
116 | uint32_t eventId; | 116 | uint32_t eventId; |
@@ -318,7 +318,7 @@ typedef void (*Ipc_NewMsgReceivedFxn)(uint32_t srcEndPt, uint32_t procId); | |||
318 | /** | 318 | /** |
319 | * \brief IPC driver OSAL function pointers. | 319 | * \brief IPC driver OSAL function pointers. |
320 | */ | 320 | */ |
321 | typedef struct | 321 | typedef struct Ipc_OsalPrms_s |
322 | { | 322 | { |
323 | Ipc_OsalDisableAllIntrFxn disableAllIntr; | 323 | Ipc_OsalDisableAllIntrFxn disableAllIntr; |
324 | /**< OSAL all interrupt disable function pointer */ | 324 | /**< OSAL all interrupt disable function pointer */ |
diff --git a/include/ipc_virtio.h b/include/ipc_virtio.h index ce3453a..c1850e9 100644 --- a/include/ipc_virtio.h +++ b/include/ipc_virtio.h | |||
@@ -59,7 +59,7 @@ extern "C" { | |||
59 | * \brief Parameter structure for creating VirtIO table for each core | 59 | * \brief Parameter structure for creating VirtIO table for each core |
60 | * combinations. | 60 | * combinations. |
61 | */ | 61 | */ |
62 | typedef struct | 62 | typedef struct Ipc_VirtIoParams_s |
63 | { | 63 | { |
64 | void *vqObjBaseAddr; | 64 | void *vqObjBaseAddr; |
65 | /**< Base address for storing VQ Object */ | 65 | /**< Base address for storing VQ Object */ |
@@ -82,7 +82,7 @@ extern "C" { | |||
82 | /** | 82 | /** |
83 | * \brief RPMessage_Handle type | 83 | * \brief RPMessage_Handle type |
84 | */ | 84 | */ |
85 | typedef struct RPMessage_Object *RPMessage_Handle; | 85 | typedef struct RPMessage_Object_s* RPMessage_Handle; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * \brief RPMessage_Callback | 88 | * \brief RPMessage_Callback |
@@ -94,8 +94,8 @@ typedef struct RPMessage_Object *RPMessage_Handle; | |||
94 | * \param src [IN] source | 94 | * \param src [IN] source |
95 | * | 95 | * |
96 | */ | 96 | */ |
97 | typedef void (*RPMessage_Callback)(RPMessage_Handle, void*, void*, | 97 | typedef void (*RPMessage_Callback)(RPMessage_Handle handle, void* arg, void* data, |
98 | uint16_t, uint32_t); | 98 | uint16_t len, uint32_t src); |
99 | 99 | ||
100 | 100 | ||
101 | /* ========================================================================== */ | 101 | /* ========================================================================== */ |
@@ -106,7 +106,7 @@ typedef void (*RPMessage_Callback)(RPMessage_Handle, void*, void*, | |||
106 | * \brief IPC initialization parameters. | 106 | * \brief IPC initialization parameters. |
107 | * | 107 | * |
108 | */ | 108 | */ |
109 | typedef struct | 109 | typedef struct Ipc_InitPrms_s |
110 | { | 110 | { |
111 | uint32_t instId; | 111 | uint32_t instId; |
112 | /**< [IN] Ipc_InstanceId. Only 1 instance is supported in this | 112 | /**< [IN] Ipc_InstanceId. Only 1 instance is supported in this |
@@ -138,7 +138,7 @@ typedef struct | |||
138 | /** | 138 | /** |
139 | * \brief Parameter structure for creating RPMessage endpoints | 139 | * \brief Parameter structure for creating RPMessage endpoints |
140 | */ | 140 | */ |
141 | typedef struct | 141 | typedef struct RPMessage_Params_s |
142 | { | 142 | { |
143 | uint32_t requestedEndpt; | 143 | uint32_t requestedEndpt; |
144 | /**< Requested Endpoint - Any or next available */ | 144 | /**< Requested Endpoint - Any or next available */ |
diff --git a/soc/V0/ipc_soc.c b/soc/V0/ipc_soc.c index 47954a7..9dca964 100644 --- a/soc/V0/ipc_soc.c +++ b/soc/V0/ipc_soc.c | |||
@@ -49,18 +49,18 @@ | |||
49 | 49 | ||
50 | #include <ti/drv/sciclient/sciclient.h> | 50 | #include <ti/drv/sciclient/sciclient.h> |
51 | 51 | ||
52 | #define NAVSS_INTRTR_INPUT_MAILBOX0_USER0 (436) | 52 | #define NAVSS_INTRTR_INPUT_MAILBOX0_USER0 (436U) |
53 | #define NAVSS_INTRTR_INPUT_MAILBOX1_USER0 (432) | 53 | #define NAVSS_INTRTR_INPUT_MAILBOX1_USER0 (432U) |
54 | #define NAVSS_INTRTR_INPUT_MAILBOX2_USER0 (428) | 54 | #define NAVSS_INTRTR_INPUT_MAILBOX2_USER0 (428U) |
55 | #define NAVSS_INTRTR_INPUT_MAILBOX3_USER0 (424) | 55 | #define NAVSS_INTRTR_INPUT_MAILBOX3_USER0 (424U) |
56 | #define NAVSS_INTRTR_INPUT_MAILBOX4_USER0 (420) | 56 | #define NAVSS_INTRTR_INPUT_MAILBOX4_USER0 (420U) |
57 | #define NAVSS_INTRTR_INPUT_MAILBOX5_USER0 (416) | 57 | #define NAVSS_INTRTR_INPUT_MAILBOX5_USER0 (416U) |
58 | #define NAVSS_INTRTR_INPUT_MAILBOX6_USER0 (412) | 58 | #define NAVSS_INTRTR_INPUT_MAILBOX6_USER0 (412U) |
59 | #define NAVSS_INTRTR_INPUT_MAILBOX7_USER0 (408) | 59 | #define NAVSS_INTRTR_INPUT_MAILBOX7_USER0 (408U) |
60 | #define NAVSS_INTRTR_INPUT_MAILBOX8_USER0 (404) | 60 | #define NAVSS_INTRTR_INPUT_MAILBOX8_USER0 (404U) |
61 | #define NAVSS_INTRTR_INPUT_MAILBOX9_USER0 (400) | 61 | #define NAVSS_INTRTR_INPUT_MAILBOX9_USER0 (400U) |
62 | #define NAVSS_INTRTR_INPUT_MAILBOX10_USER0 (396) | 62 | #define NAVSS_INTRTR_INPUT_MAILBOX10_USER0 (396U) |
63 | #define NAVSS_INTRTR_INPUT_MAILBOX11_USER0 (392) | 63 | #define NAVSS_INTRTR_INPUT_MAILBOX11_USER0 (392U) |
64 | 64 | ||
65 | /* Maxwell CSL does not have Mailbox base address */ | 65 | /* Maxwell CSL does not have Mailbox base address */ |
66 | #define CSL_NAVSS_MAIN_MAILBOX_REGS_0_BASE (0x31F80000U) | 66 | #define CSL_NAVSS_MAIN_MAILBOX_REGS_0_BASE (0x31F80000U) |
@@ -127,27 +127,27 @@ static Ipc_MailboxInfo g_IPC_MailboxInfo[IPC_MAX_PROCS][IPC_MAX_PROCS] = | |||
127 | { | 127 | { |
128 | /* Host Processor - A53-vm0 */ | 128 | /* Host Processor - A53-vm0 */ |
129 | { | 129 | { |
130 | { { -1, -1, 0}, { -1, -1, 0} }, /* Self - A53-vm0 */ | 130 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0U} }, /* Self - A53-vm0 */ |
131 | { { 0, 0, 0}, { 0, 1, 1} }, /* mcu-r5f0 */ | 131 | { { 0U, 0U, 0U}, { 0U, 1U, 1U} }, /* mcu-r5f0 */ |
132 | { { 1, 0, 0}, { 1, 1, 1} }, /* mcu-r5f1 */ | 132 | { { 1U, 0U, 0U}, { 1U, 1U, 1U} }, /* mcu-r5f1 */ |
133 | }, | 133 | }, |
134 | /* Host Processor - mcu1_0 */ | 134 | /* Host Processor - mcu1_0 */ |
135 | { | 135 | { |
136 | { { 0, 1, 1 }, { 0, 0, 0} }, /* A53-vm0 */ | 136 | { { 0U, 1U, 1U }, { 0U, 0U, 0U} }, /* A53-vm0 */ |
137 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - mcu-r5f0 */ | 137 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - mcu-r5f0 */ |
138 | { { 2, 0, 0 }, { 2, 1, 1} }, /* mcu-r5f1 */ | 138 | { { 2U, 0U, 0U }, { 2U, 1U, 1U} }, /* mcu-r5f1 */ |
139 | }, | 139 | }, |
140 | /* Host Processor - mcu1_1 */ | 140 | /* Host Processor - mcu1_1 */ |
141 | { | 141 | { |
142 | { { 1, 1, 1 }, { 1, 0, 0} }, /* A53-vm0 */ | 142 | { { 1U, 1U, 1U }, { 1U, 0U, 0U} }, /* A53-vm0 */ |
143 | { { 2, 1, 1 }, { 2, 0, 0} }, /* mcu-r5f0 */ | 143 | { { 2U, 1U, 1U }, { 2U, 0U, 0U} }, /* mcu-r5f0 */ |
144 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - mcu-r5f1 */ | 144 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - mcu-r5f1 */ |
145 | } | 145 | } |
146 | }; | 146 | }; |
147 | 147 | ||
148 | 148 | ||
149 | int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, | 149 | int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, |
150 | int32_t *clusterId, int32_t *userId, uint32_t *queueId) | 150 | uint32_t *clusterId, uint32_t *userId, uint32_t *queueId) |
151 | { | 151 | { |
152 | int32_t retVal = -1; | 152 | int32_t retVal = -1; |
153 | 153 | ||
@@ -166,7 +166,7 @@ int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, | |||
166 | } | 166 | } |
167 | 167 | ||
168 | int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, | 168 | int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, |
169 | int32_t *clusterId, int32_t *userId, uint32_t *queueId) | 169 | uint32_t *clusterId, uint32_t *userId, uint32_t *queueId) |
170 | { | 170 | { |
171 | int32_t retVal = -1; | 171 | int32_t retVal = -1; |
172 | 172 | ||
@@ -187,7 +187,7 @@ int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, | |||
187 | 187 | ||
188 | uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId) | 188 | uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId) |
189 | { | 189 | { |
190 | uint32_t baseAddr = 0x00000000; | 190 | uint32_t baseAddr = 0x00000000U; |
191 | 191 | ||
192 | if( custerId < IPC_MAX_PROCS) | 192 | if( custerId < IPC_MAX_PROCS) |
193 | { | 193 | { |
@@ -201,8 +201,10 @@ uint32_t Ipc_getNavss512MailboxInputIntr(int32_t clusterId, int32_t userId) | |||
201 | { | 201 | { |
202 | uint32_t mailboxIntrNum = 0; | 202 | uint32_t mailboxIntrNum = 0; |
203 | 203 | ||
204 | if(clusterId >= 0 && clusterId < IPC_MAILBOX_CLUSTER_CNT && | 204 | if( (clusterId != MAILBOX_CLUSTER_INVALID) && |
205 | userId >= 0 && userId < IPC_MAILBOX_USER_CNT) | 205 | (clusterId < IPC_MAILBOX_CLUSTER_CNT) && |
206 | (userId != MAILBOX_USER_INVALID) && | ||
207 | (userId < IPC_MAILBOX_USER_CNT)) | ||
206 | { | 208 | { |
207 | mailboxIntrNum = g_Navss512MbInput[clusterId] + userId; | 209 | mailboxIntrNum = g_Navss512MbInput[clusterId] + userId; |
208 | } | 210 | } |
@@ -241,7 +243,7 @@ int32_t Ipc_setCoreEventId(uint32_t selfId, Ipc_MbConfig* cfg, uint32_t intrCnt) | |||
241 | } | 243 | } |
242 | 244 | ||
243 | 245 | ||
244 | int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, int32_t clusterId, int32_t userId, | 246 | int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, uint32_t clusterId, uint32_t userId, |
245 | Ipc_MbConfig* cfg, uint32_t cnt) | 247 | Ipc_MbConfig* cfg, uint32_t cnt) |
246 | { | 248 | { |
247 | int32_t retVal = IPC_SOK; | 249 | int32_t retVal = IPC_SOK; |
@@ -335,8 +337,8 @@ const uint16_t map_host_id[] = | |||
335 | TISCI_HOST_ID_R5_2 | 337 | TISCI_HOST_ID_R5_2 |
336 | }; | 338 | }; |
337 | 339 | ||
338 | int32_t Ipc_sciclientIrqRelease(uint16_t coreId, int32_t clusterId, | 340 | int32_t Ipc_sciclientIrqRelease(uint16_t coreId, uint32_t clusterId, |
339 | int32_t userId, uint32_t intNumber) | 341 | uint32_t userId, uint32_t intNumber) |
340 | { | 342 | { |
341 | int32_t retVal = IPC_SOK; | 343 | int32_t retVal = IPC_SOK; |
342 | struct tisci_msg_rm_irq_set_req rmIrqReq; | 344 | struct tisci_msg_rm_irq_set_req rmIrqReq; |
@@ -365,8 +367,8 @@ int32_t Ipc_sciclientIrqRelease(uint16_t coreId, int32_t clusterId, | |||
365 | } | 367 | } |
366 | 368 | ||
367 | 369 | ||
368 | int32_t Ipc_sciclientIrqSet(uint16_t coreId, int32_t clusterId, | 370 | int32_t Ipc_sciclientIrqSet(uint16_t coreId, uint32_t clusterId, |
369 | int32_t userId, uint32_t intNumber) | 371 | uint32_t userId, uint32_t intNumber) |
370 | { | 372 | { |
371 | int32_t retVal = IPC_SOK; | 373 | int32_t retVal = IPC_SOK; |
372 | struct tisci_msg_rm_irq_set_req rmIrqReq; | 374 | struct tisci_msg_rm_irq_set_req rmIrqReq; |
diff --git a/soc/V1/ipc_soc.c b/soc/V1/ipc_soc.c index a3c00eb..42deb30 100644 --- a/soc/V1/ipc_soc.c +++ b/soc/V1/ipc_soc.c | |||
@@ -51,18 +51,18 @@ | |||
51 | #include <ti/drv/sciclient/sciclient.h> | 51 | #include <ti/drv/sciclient/sciclient.h> |
52 | //#include <ti/drv/sciclient/soc/V1/sciclient_fmwMsgParams.h> | 52 | //#include <ti/drv/sciclient/soc/V1/sciclient_fmwMsgParams.h> |
53 | 53 | ||
54 | #define NAVSS_INTRTR_INPUT_MAILBOX0_USER0 (436) | 54 | #define NAVSS_INTRTR_INPUT_MAILBOX0_USER0 (436U) |
55 | #define NAVSS_INTRTR_INPUT_MAILBOX1_USER0 (432) | 55 | #define NAVSS_INTRTR_INPUT_MAILBOX1_USER0 (432U) |
56 | #define NAVSS_INTRTR_INPUT_MAILBOX2_USER0 (428) | 56 | #define NAVSS_INTRTR_INPUT_MAILBOX2_USER0 (428U) |
57 | #define NAVSS_INTRTR_INPUT_MAILBOX3_USER0 (424) | 57 | #define NAVSS_INTRTR_INPUT_MAILBOX3_USER0 (424U) |
58 | #define NAVSS_INTRTR_INPUT_MAILBOX4_USER0 (420) | 58 | #define NAVSS_INTRTR_INPUT_MAILBOX4_USER0 (420U) |
59 | #define NAVSS_INTRTR_INPUT_MAILBOX5_USER0 (416) | 59 | #define NAVSS_INTRTR_INPUT_MAILBOX5_USER0 (416U) |
60 | #define NAVSS_INTRTR_INPUT_MAILBOX6_USER0 (412) | 60 | #define NAVSS_INTRTR_INPUT_MAILBOX6_USER0 (412U) |
61 | #define NAVSS_INTRTR_INPUT_MAILBOX7_USER0 (408) | 61 | #define NAVSS_INTRTR_INPUT_MAILBOX7_USER0 (408U) |
62 | #define NAVSS_INTRTR_INPUT_MAILBOX8_USER0 (404) | 62 | #define NAVSS_INTRTR_INPUT_MAILBOX8_USER0 (404U) |
63 | #define NAVSS_INTRTR_INPUT_MAILBOX9_USER0 (400) | 63 | #define NAVSS_INTRTR_INPUT_MAILBOX9_USER0 (400U) |
64 | #define NAVSS_INTRTR_INPUT_MAILBOX10_USER0 (396) | 64 | #define NAVSS_INTRTR_INPUT_MAILBOX10_USER0 (396U) |
65 | #define NAVSS_INTRTR_INPUT_MAILBOX11_USER0 (392) | 65 | #define NAVSS_INTRTR_INPUT_MAILBOX11_USER0 (392U) |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * \brief Main NavSS512 - Mailbox input line | 68 | * \brief Main NavSS512 - Mailbox input line |
@@ -122,163 +122,166 @@ static Ipc_MailboxInfo g_IPC_MailboxInfo[IPC_MAX_PROCS][IPC_MAX_PROCS] = | |||
122 | { | 122 | { |
123 | /* Host Processor - A72-vm0 */ | 123 | /* Host Processor - A72-vm0 */ |
124 | { | 124 | { |
125 | { { -1, -1, 0}, { -1, -1, 0} }, /* Self - A72-vm0 */ | 125 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0xFFU} }, /* Self - A72-vm0 */ |
126 | { { 0, 0, 0}, { 0, 0, 1} }, /* mcu-r5f0 */ | 126 | { { 0U, 0U, 0U}, { 0U, 0U, 1U} }, /* mcu-r5f0 */ |
127 | { { 0, 0, 2}, { 0, 0, 3} }, /* mcu-r5f1 */ | 127 | { { 0U, 0U, 2U}, { 0U, 0U, 3U} }, /* mcu-r5f1 */ |
128 | { { 1, 0, 0}, { 1, 0, 1} }, /* main-r5f0 */ | 128 | { { 1U, 0U, 0U}, { 1U, 0U, 1U} }, /* main-r5f0 */ |
129 | { { 1, 0, 2}, { 1, 0, 3} }, /* main-r5f1 */ | 129 | { { 1U, 0U, 2U}, { 1U, 0U, 3U} }, /* main-r5f1 */ |
130 | { { 2, 0, 0}, { 2, 0, 1} }, /* main-r5f2 */ | 130 | { { 2U, 0U, 0U}, { 2U, 0U, 1U} }, /* main-r5f2 */ |
131 | { { 2, 0, 2}, { 2, 0, 3} }, /* main-r5f3 */ | 131 | { { 2U, 0U, 2U}, { 2U, 0U, 3U} }, /* main-r5f3 */ |
132 | { { 3, 0, 0}, { 3, 0, 1} }, /* C66x-0 */ | 132 | { { 3U, 0U, 0U}, { 3U, 0U, 1U} }, /* C66x-0 */ |
133 | { { 3, 0, 2}, { 3, 0, 3} }, /* C66x-1 */ | 133 | { { 3U, 0U, 2U}, { 3U, 0U, 3U} }, /* C66x-1 */ |
134 | { { 4, 0, 0}, { 4, 0, 1} }, /* C7x-1 */ | 134 | { { 4U, 0U, 0U}, { 4U, 0U, 1U} }, /* C7x-1 */ |
135 | { { 0, 0, 10}, { 0, 0, 11} } /* A72-vm1 */ | 135 | { { 0U, 0U, 10U}, { 0U, 0U, 11U} } /* A72-vm1 */ |
136 | }, | 136 | }, |
137 | /* Host Processor - mcu1_0 */ | 137 | /* Host Processor - mcu1_0 */ |
138 | { | 138 | { |
139 | { { 0, 1, 1 }, { 0, 1, 0} }, /* A72-vm0 */ | 139 | { { 0U, 1U, 1U }, { 0U, 1U, 0U} }, /* A72-vm0 */ |
140 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - mcu-r5f0 */ | 140 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - mcu-r5f0 */ |
141 | { { 0, 1, 4 }, { 0, 1, 5} }, /* mcu-r5f1 */ | 141 | { { 0U, 1U, 4U }, { 0U, 1U, 5U} }, /* mcu-r5f1 */ |
142 | { { 7, 0, 0 }, { 5, -1, 2} }, /* main-r5f0 */ | 142 | { { 7U, 0U, 0U }, { 5U, 0xFFU, 2U} }, /* main-r5f0 */ |
143 | { { 7, 0, 1 }, { 5, -1, 10} }, /* main-r5f1 */ | 143 | { { 7U, 0U, 1U }, { 5U, 0xFFU, 10U} }, /* main-r5f1 */ |
144 | { { 7, 0, 2 }, { 6, -1, 2} }, /* main-r5f2 */ | 144 | { { 7U, 0U, 2U }, { 6U, 0xFFU, 2U} }, /* main-r5f2 */ |
145 | { { 7, 0, 3 }, { 6, -1, 10} }, /* main-r5f3 */ | 145 | { { 7U, 0U, 3U }, { 6U, 0xFFU, 10U} }, /* main-r5f3 */ |
146 | { { 7, 1, 4 }, { 8, -1, 4} }, /* C66x-0 */ | 146 | { { 7U, 1U, 4U }, { 8U, 0xFFU, 4U} }, /* C66x-0 */ |
147 | { { 7, 1, 5 }, { 8, -1, 12} }, /* C66x-1 */ | 147 | { { 7U, 1U, 5U }, { 8U, 0xFFU, 12U} }, /* C66x-1 */ |
148 | { { 7, 1, 6 }, { 9, -1, 4} }, /* C7x-1 */ | 148 | { { 7U, 1U, 6U }, { 9U, 0xFFU, 4U} }, /* C7x-1 */ |
149 | { { 0, 1, 7 }, { 0, 1, 6} } /* A72-vm1 */ | 149 | { { 0U, 1U, 7U }, { 0U, 1U, 6U} } /* A72-vm1 */ |
150 | }, | 150 | }, |
151 | /* Host Processor - mcu1_1 */ | 151 | /* Host Processor - mcu1_1 */ |
152 | { | 152 | { |
153 | { { 0, 2, 3 }, { 0, 2, 2} }, /* A72-vm0 */ | 153 | { { 0U, 2U, 3U }, { 0U, 2U, 2U} }, /* A72-vm0 */ |
154 | { { 0, 2, 5 }, { 0, 2, 4} }, /* mcu-r5f0 */ | 154 | { { 0U, 2U, 5U }, { 0U, 2U, 4U} }, /* mcu-r5f0 */ |
155 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - mcu-r5f1 */ | 155 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - mcu-r5f1 */ |
156 | { { 7, 2, 8 }, { 5, -1, 3} }, /* main-r5f0 */ | 156 | { { 7U, 2U, 8U }, { 5U, 0xFFU, 3U} }, /* main-r5f0 */ |
157 | { { 7, 2, 9 }, { 5, -1, 11} }, /* main-r5f1 */ | 157 | { { 7U, 2U, 9U }, { 5U, 0xFFU, 11U} }, /* main-r5f1 */ |
158 | { { 7, 2, 10 }, { 6, -1, 3} }, /* main-r5f2 */ | 158 | { { 7U, 2U, 10U }, { 6U, 0xFFU, 3U} }, /* main-r5f2 */ |
159 | { { 7, 2, 11 }, { 6, -1, 11} }, /* main-r5f3 */ | 159 | { { 7U, 2U, 11U }, { 6U, 0xFFU, 11U} }, /* main-r5f3 */ |
160 | { { 7, 3, 12 }, { 8, -1, 5} }, /* C66x-0 */ | 160 | { { 7U, 3U, 12U }, { 8U, 0xFFU, 5U} }, /* C66x-0 */ |
161 | { { 7, 3, 13 }, { 8, -1, 13} }, /* C66x-1 */ | 161 | { { 7U, 3U, 13U }, { 8U, 0xFFU, 13U} }, /* C66x-1 */ |
162 | { { 7, 3, 14 }, { 9, -1, 5} }, /* C7x-1 */ | 162 | { { 7U, 3U, 14U }, { 9U, 0xFFU, 5U} }, /* C7x-1 */ |
163 | { { 0, 2, 9 }, { 0, 2, 8} } /* A72-vm1 */ | 163 | { { 0U, 2U, 9U }, { 0U, 2U, 8U} } /* A72-vm1 */ |
164 | }, | 164 | }, |
165 | /* Host Processor - mcu2_0 */ | 165 | /* Host Processor - mcu2_0 */ |
166 | { | 166 | { |
167 | { { 1, 1, 1}, { 1, 1, 0} }, /* A72-vm0 */ | 167 | { { 1U, 1U, 1U}, { 1U, 1U, 0U} }, /* A72-vm0 */ |
168 | { { 5, 0, 2}, { 7, -1, 0} }, /* mcu-r5f0 */ | 168 | { { 5U, 0U, 2U}, { 7U, 0xFFU, 0U} }, /* mcu-r5f0 */ |
169 | { { 5, 0, 3}, { 7, -1, 8} }, /* mcu-r5f1 */ | 169 | { { 5U, 0U, 3U}, { 7U, 0xFFU, 8U} }, /* mcu-r5f1 */ |
170 | { { -1, -1, 0}, { -1, -1, 0} }, /* Self - main-r5f0 */ | 170 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0U} }, /* Self - main-r5f0 */ |
171 | { { 1, 1, 4}, { 1, 1, 5} }, /* main-r5f1 */ | 171 | { { 1U, 1U, 4U}, { 1U, 1U, 5U} }, /* main-r5f1 */ |
172 | { { 5, 0, 0}, { 6, -1, 0} }, /* main-r5f2 */ | 172 | { { 5U, 0U, 0U}, { 6U, 0xFFU, 0U} }, /* main-r5f2 */ |
173 | { { 5, 0, 1}, { 6, -1, 8} }, /* main-r5f3 */ | 173 | { { 5U, 0U, 1U}, { 6U, 0xFFU, 8U} }, /* main-r5f3 */ |
174 | { { 5, 1, 4}, { 8, -1, 0} }, /* C66x-0 */ | 174 | { { 5U, 1U, 4U}, { 8U, 0xFFU, 0U} }, /* C66x-0 */ |
175 | { { 5, 1, 5}, { 8, -1, 8} }, /* C66x-1 */ | 175 | { { 5U, 1U, 5U}, { 8U, 0xFFU, 8U} }, /* C66x-1 */ |
176 | { { 5, 1, 6}, { 9, -1, 0} }, /* C7x-1 */ | 176 | { { 5U, 1U, 6U}, { 9U, 0xFFU, 0U} }, /* C7x-1 */ |
177 | { { 1, 1, 7}, { 1, 1, 6} } /* A72-vm1 */ | 177 | { { 1U, 1U, 7U}, { 1U, 1U, 6U} } /* A72-vm1 */ |
178 | }, | 178 | }, |
179 | /* Host Processor - mcu2_1 */ | 179 | /* Host Processor - mcu2_1 */ |
180 | { | 180 | { |
181 | { { 1, 2, 3 }, { 1, 2, 2} }, /* A72-vm0 */ | 181 | { { 1U, 2U, 3U }, { 1U, 2U, 2U} }, /* A72-vm0 */ |
182 | { { 5, 2, 10 }, { 7, -1, 1} }, /* mcu-r5f0 */ | 182 | { { 5U, 2U, 10U }, { 7U, 0xFFU, 1U} }, /* mcu-r5f0 */ |
183 | { { 5, 2, 11 }, { 7, -1, 9} }, /* mcu-r5f1 */ | 183 | { { 5U, 2U, 11U }, { 7U, 0xFFU, 9U} }, /* mcu-r5f1 */ |
184 | { { 1, 2, 5 }, { 1, 2, 4} }, /* main-r5f0 */ | 184 | { { 1U, 2U, 5U }, { 1U, 2U, 4U} }, /* main-r5f0 */ |
185 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - main-r5f1 */ | 185 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - main-r5f1 */ |
186 | { { 5, 2, 8 }, { 6, -1, 1} }, /* main-r5f2 */ | 186 | { { 5U, 2U, 8U }, { 6U, 0xFFU, 1U} }, /* main-r5f2 */ |
187 | { { 5, 2, 9 }, { 6, -1, 9} }, /* main-r5f3 */ | 187 | { { 5U, 2U, 9U }, { 6U, 0xFFU, 9U} }, /* main-r5f3 */ |
188 | { { 5, 3, 12 }, { 8, -1, 1} }, /* C66x-0 */ | 188 | { { 5U, 3U, 12U }, { 8U, 0xFFU, 1U} }, /* C66x-0 */ |
189 | { { 5, 3, 13 }, { 8, -1, 9} }, /* C66x-1 */ | 189 | { { 5U, 3U, 13U }, { 8U, 0xFFU, 9U} }, /* C66x-1 */ |
190 | { { 5, 3, 14 }, { 9, -1, 1} }, /* C7x-1 */ | 190 | { { 5U, 3U, 14U }, { 9U, 0xFFU, 1U} }, /* C7x-1 */ |
191 | { { 0, 2, 9 }, { 0, 2, 8} } /* A72-vm1 */ | 191 | { { 0U, 2U, 9U }, { 0U, 2U, 8U} } /* A72-vm1 */ |
192 | }, | 192 | }, |
193 | /* Host Processor - mcu3_0 */ | 193 | /* Host Processor - mcu3_0 */ |
194 | { | 194 | { |
195 | { { 2, 1, 1 }, { 2, 1, 0} }, /* A72-vm0 */ | 195 | { { 2U, 1U, 1U }, { 2U, 1U, 0U} }, /* A72-vm0 */ |
196 | { { 6, 0, 2 }, { 7, -1, 2} }, /* mcu-r5f0 */ | 196 | { { 6U, 0U, 2U }, { 7U, 0xFFU, 2U} }, /* mcu-r5f0 */ |
197 | { { 6, 0, 3 }, { 7, -1, 10} }, /* mcu-r5f1 */ | 197 | { { 6U, 0U, 3U }, { 7U, 0xFFU, 10U} }, /* mcu-r5f1 */ |
198 | { { 6, 0, 0 }, { 5, -1, 0} }, /* main-r5f0 */ | 198 | { { 6U, 0U, 0U }, { 5U, 0xFFU, 0U} }, /* main-r5f0 */ |
199 | { { 6, 0, 1 }, { 5, -1, 8} }, /* main-r5f1 */ | 199 | { { 6U, 0U, 1U }, { 5U, 0xFFU, 8U} }, /* main-r5f1 */ |
200 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - main-r5f2 */ | 200 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - main-r5f2 */ |
201 | { { 2, 1, 4 }, { 2, 1, 5} }, /* main-r5f3 */ | 201 | { { 2U, 1U, 4U }, { 2U, 1U, 5U} }, /* main-r5f3 */ |
202 | { { 6, 1, 4 }, { 8, -1, 2} }, /* C66x-0 */ | 202 | { { 6U, 1U, 4U }, { 8U, 0xFFU, 2U} }, /* C66x-0 */ |
203 | { { 6, 1, 5 }, { 8, -1, 10} }, /* C66x-1 */ | 203 | { { 6U, 1U, 5U }, { 8U, 0xFFU, 10U} }, /* C66x-1 */ |
204 | { { 6, 1, 6 }, { 9, -1, 2} }, /* C7x-1 */ | 204 | { { 6U, 1U, 6U }, { 9U, 0xFFU, 2U} }, /* C7x-1 */ |
205 | { { 2, 1, 7 }, { 2, 1, 6} } /* A72-vm1 */ | 205 | { { 2U, 1U, 7U }, { 2U, 1U, 6U} } /* A72-vm1 */ |
206 | }, | 206 | }, |
207 | /* Host Processor - mcu3_1 */ | 207 | /* Host Processor - mcu3_1 */ |
208 | { | 208 | { |
209 | { { 2, 2, 3 }, { 2, 2, 2} }, /* A72-vm0 */ | 209 | { { 2U, 2U, 3U }, { 2U, 2U, 2U} }, /* A72-vm0 */ |
210 | { { 6, 2, 10 }, { 7, -1, 3} }, /* mcu-r5f0 */ | 210 | { { 6U, 2U, 10U }, { 7U, 0xFFU, 3U} }, /* mcu-r5f0 */ |
211 | { { 6, 2, 11 }, { 7, -1, 11} }, /* mcu-r5f1 */ | 211 | { { 6U, 2U, 11U }, { 7U, 0xFFU, 11U} }, /* mcu-r5f1 */ |
212 | { { 6, 2, 8 }, { 5, -1, 1} }, /* main-r5f0 */ | 212 | { { 6U, 2U, 8U }, { 5U, 0xFFU, 1U} }, /* main-r5f0 */ |
213 | { { 6, 2, 9 }, { 5, -1, 9} }, /* main-r5f1 */ | 213 | { { 6U, 2U, 9U }, { 5U, 0xFFU, 9U} }, /* main-r5f1 */ |
214 | { { 2, 2, 5 }, { 2, 2, 4} }, /* main-r5f2 */ | 214 | { { 2U, 2U, 5U }, { 2U, 2U, 4U} }, /* main-r5f2 */ |
215 | { { -1, -1, 0 }, { -1, -1, 0} }, /* Self - main-r5f3 */ | 215 | { { 0xFFU, 0xFFU, 0U }, { 0xFFU, 0xFFU, 0U} }, /* Self - main-r5f3 */ |
216 | { { 6, 3, 12 }, { 8, -1, 3} }, /* C66x-0 */ | 216 | { { 6U, 3U, 12U }, { 8U, 0xFFU, 3U} }, /* C66x-0 */ |
217 | { { 6, 3, 13 }, { 8, -1, 11} }, /* C66x-1 */ | 217 | { { 6U, 3U, 13U }, { 8U, 0xFFU, 11U} }, /* C66x-1 */ |
218 | { { 6, 3, 14 }, { 9, -1, 3} }, /* C7x-1 */ | 218 | { { 6U, 3U, 14U }, { 9U, 0xFFU, 3U} }, /* C7x-1 */ |
219 | { { 2, 2, 9 }, { 2, 2, 8} } /* A72-vm1 */ | 219 | { { 2U, 2U, 9U }, { 2U, 2U, 8U} } /* A72-vm1 */ |
220 | }, | 220 | }, |
221 | /* Host Processor - c66xdsp_1 */ | 221 | /* Host Processor - c66xdsp_1 */ |
222 | { | 222 | { |
223 | { { 3, 1, 1}, { 3, 1, 0} }, /* A72-vm0 */ | 223 | { { 3U, 1U, 1U}, { 3U, 1U, 0U} }, /* A72-vm0 */ |
224 | { { 8, 1, 4}, { 7, -1, 4} }, /* mcu-r5f0 */ | 224 | { { 8U, 1U, 4U}, { 7U, 0xFFU, 4U} }, /* mcu-r5f0 */ |
225 | { { 8, 1, 5}, { 7, -1, 12} }, /* mcu-r5f1 */ | 225 | { { 8U, 1U, 5U}, { 7U, 0xFFU, 12U} }, /* mcu-r5f1 */ |
226 | { { 8, 0, 0}, { 5, -1, 4} }, /* main-r5f0 */ | 226 | { { 8U, 0U, 0U}, { 5U, 0xFFU, 4U} }, /* main-r5f0 */ |
227 | { { 8, 0, 1}, { 5, -1, 12} }, /* main-r5f1 */ | 227 | { { 8U, 0U, 1U}, { 5U, 0xFFU, 12U} }, /* main-r5f1 */ |
228 | { { 8, 0, 2}, { 6, -1, 4} }, /* main-r5f2 */ | 228 | { { 8U, 0U, 2U}, { 6U, 0xFFU, 4U} }, /* main-r5f2 */ |
229 | { { 8, 0, 3}, { 6, -1, 12} }, /* main-r5f3 */ | 229 | { { 8U, 0U, 3U}, { 6U, 0xFFU, 12U} }, /* main-r5f3 */ |
230 | { { -1, -1, 0}, { -1, -1, 0} }, /* Self - C66x-0 */ | 230 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0U} }, /* Self - C66x-0 */ |
231 | { { 3, 1, 4}, { 3, 1, 5} }, /* C66x-1 */ | 231 | { { 3U, 1U, 4U}, { 3U, 1U, 5U} }, /* C66x-1 */ |
232 | { { 8, 1, 6}, { 9, -1, 6} }, /* C7x-1 */ | 232 | { { 8U, 1U, 6U}, { 9U, 0xFFU, 6U} }, /* C7x-1 */ |
233 | { { 3, 1, 7}, { 3, 1, 6} } /* A72-vm1 */ | 233 | { { 3U, 1U, 7U}, { 3U, 1U, 6U} } /* A72-vm1 */ |
234 | }, | 234 | }, |
235 | /* Host Processor - c66xdsp_2 */ | 235 | /* Host Processor - c66xdsp_2 */ |
236 | { | 236 | { |
237 | { { 3, 2, 3}, { 3, 2, 2} }, /* A72-vm0 */ | 237 | { { 3U, 2U, 3U}, { 3U, 2U, 2U} }, /* A72-vm0 */ |
238 | { { 8, 3, 12}, { 7, -1, 5} }, /* mcu-r5f0 */ | 238 | { { 8U, 3U, 12U}, { 7U, 0xFFU, 5U} }, /* mcu-r5f0 */ |
239 | { { 8, 3, 13}, { 7, -1, 13} }, /* mcu-r5f1 */ | 239 | { { 8U, 3U, 13U}, { 7U, 0xFFU, 13U} }, /* mcu-r5f1 */ |
240 | { { 8, 2, 8}, { 5, -1, 5} }, /* main-r5f0 */ | 240 | { { 8U, 2U, 8U}, { 5U, 0xFFU, 5U} }, /* main-r5f0 */ |
241 | { { 8, 2, 9}, { 5, -1, 13} }, /* main-r5f1 */ | 241 | { { 8U, 2U, 9U}, { 5U, 0xFFU, 13U} }, /* main-r5f1 */ |
242 | { { 8, 2, 10}, { 6, -1, 5} }, /* main-r5f2 */ | 242 | { { 8U, 2U, 10U}, { 6U, 0xFFU, 5U} }, /* main-r5f2 */ |
243 | { { 8, 2, 11}, { 6, -1, 13} }, /* main-r5f3 */ | 243 | { { 8U, 2U, 11U}, { 6U, 0xFFU, 13U} }, /* main-r5f3 */ |
244 | { { 3, 2, 5}, { 3, 2, 4} }, /* C66x-0 */ | 244 | { { 3U, 2U, 5U}, { 3U, 2U, 4U} }, /* C66x-0 */ |
245 | { { -1, -1, 0}, { -1, -1, 0} }, /* Self - C66x-1 */ | 245 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0U} }, /* Self - C66x-1 */ |
246 | { { 8, 3, 14}, { 9, -1, 7} }, /* C7x-1 */ | 246 | { { 8U, 3U, 14U}, { 9U, 0xFFU, 7U} }, /* C7x-1 */ |
247 | { { 3, 2, 9}, { 3, 2, 8} } /* A72-vm1 */ | 247 | { { 3U, 2U, 9U}, { 3U, 2U, 8U} } /* A72-vm1 */ |
248 | }, | 248 | }, |
249 | /* Host Processor - c7x_1 */ | 249 | /* Host Processor - c7x_1 */ |
250 | { | 250 | { |
251 | { { 4, 1, 1}, { 4, 1, 0} }, /* A72-vm0 */ | 251 | { { 4U, 1U, 1U}, { 4U, 1U, 0U} }, /* A72-vm0 */ |
252 | { { 9, 1, 4}, { 7, -1, 6} }, /* mcu-r5f0 */ | 252 | { { 9U, 1U, 4U}, { 7U, 0xFFU, 6U} }, /* mcu-r5f0 */ |
253 | { { 9, 1, 5}, { 7, -1, 14} }, /* mcu-r5f1 */ | 253 | { { 9U, 1U, 5U}, { 7U, 0xFFU, 14U} }, /* mcu-r5f1 */ |
254 | { { 9, 0, 0}, { 5, -1, 6} }, /* main-r5f0 */ | 254 | { { 9U, 0U, 0U}, { 5U, 0xFFU, 6U} }, /* main-r5f0 */ |
255 | { { 9, 0, 1}, { 5, -1, 14} }, /* main-r5f1 */ | 255 | { { 9U, 0U, 1U}, { 5U, 0xFFU, 14U} }, /* main-r5f1 */ |
256 | { { 9, 0, 2}, { 6, -1, 6} }, /* main-r5f2 */ | 256 | { { 9U, 0U, 2U}, { 6U, 0xFFU, 6U} }, /* main-r5f2 */ |
257 | { { 9, 0, 3}, { 6, -1, 14} }, /* main-r5f3 */ | 257 | { { 9U, 0U, 3U}, { 6U, 0xFFU, 14U} }, /* main-r5f3 */ |
258 | { { 9, 1, 6}, { 8, -1, 6} }, /* C66x-0 */ | 258 | { { 9U, 1U, 6U}, { 8U, 0xFFU, 6U} }, /* C66x-0 */ |
259 | { { 9, 1, 7}, { 8, -1, 14} }, /* C66x-1 */ | 259 | { { 9U, 1U, 7U}, { 8U, 0xFFU, 14U} }, /* C66x-1 */ |
260 | { { -1, -1, 0}, { -1, -1, 0} }, /* Self - C7x-1 */ | 260 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0U} }, /* Self - C7x-1 */ |
261 | { { 4, 1, 7}, { 4, 1, 6} } /* A72-vm1 */ | 261 | { { 4U, 1U, 7U}, { 4U, 1U, 6U} } /* A72-vm1 */ |
262 | }, | 262 | }, |
263 | /* Host Processor - A72-vm1 */ | 263 | /* Host Processor - A72-vm1 */ |
264 | { | 264 | { |
265 | { { 0, 3, 11}, { 0, 3, 10} }, /* A72-vm0 */ | 265 | { { 0U, 3U, 11U}, { 0U, 3U, 10U} }, /* A72-vm0 */ |
266 | { { 3, 3, 6}, { 3, 3, 7} }, /* C66x-0 */ | 266 | { { 3U, 3U, 6U}, { 3U, 3U, 7U} }, /* C66x-0 */ |
267 | { { 3, 3, 8}, { 3, 3, 9} }, /* C66x-1 */ | 267 | { { 3U, 3U, 8U}, { 3U, 3U, 9U} }, /* C66x-1 */ |
268 | { { 1, 3, 6}, { 1, 3, 7} }, /* main-r5f0 */ | 268 | { { 1U, 3U, 6U}, { 1U, 3U, 7U} }, /* main-r5f0 */ |
269 | { { 1, 3, 8}, { 1, 3, 9} }, /* main-r5f1 */ | 269 | { { 1U, 3U, 8U}, { 1U, 3U, 9U} }, /* main-r5f1 */ |
270 | { { 2, 3, 6}, { 2, 3, 7} }, /* main-r5f2 */ | 270 | { { 2U, 3U, 6U}, { 2U, 3U, 7U} }, /* main-r5f2 */ |
271 | { { 2, 3, 8}, { 2, 3, 9} }, /* main-r5f3 */ | 271 | { { 2U, 3U, 8U}, { 2U, 3U, 9U} }, /* main-r5f3 */ |
272 | { { 0, 3, 6}, { 0, 3, 7} }, /* mcu-r5f0 */ | 272 | { { 0U, 3U, 6U}, { 0U, 3U, 7U} }, /* mcu-r5f0 */ |
273 | { { 0, 3, 8}, { 0, 3, 9} }, /* mcu-r5f1 */ | 273 | { { 0U, 3U, 8U}, { 0U, 3U, 9U} }, /* mcu-r5f1 */ |
274 | { { 4, 3, 6}, { 4, 3, 7} }, /* C7x-1 */ | 274 | { { 4U, 3U, 6U}, { 4U, 3U, 7U} }, /* C7x-1 */ |
275 | { { -1, -1, 0}, { -1, -1, 0} } /* Self - A72-vm1 */ | 275 | { { 0xFFU, 0xFFU, 0U}, { 0xFFU, 0xFFU, 0U} } /* Self - A72-vm1 */ |
276 | } | 276 | } |
277 | }; | 277 | }; |
278 | 278 | ||
279 | uint32_t Ipc_getNavss512MailboxInputIntr(uint32_t clusterId, uint32_t userId); | ||
280 | int32_t Ipc_setCoreEventId(uint32_t selfId, Ipc_MbConfig* cfg, uint32_t intrCnt); | ||
281 | |||
279 | 282 | ||
280 | int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, | 283 | int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, |
281 | int32_t *clusterId, int32_t *userId, uint32_t *queueId) | 284 | uint32_t *clusterId, uint32_t *userId, uint32_t *queueId) |
282 | { | 285 | { |
283 | int32_t retVal = -1; | 286 | int32_t retVal = -1; |
284 | 287 | ||
@@ -297,7 +300,7 @@ int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, | |||
297 | } | 300 | } |
298 | 301 | ||
299 | int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, | 302 | int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, |
300 | int32_t *clusterId, int32_t *userId, uint32_t *queueId) | 303 | uint32_t *clusterId, uint32_t *userId, uint32_t *queueId) |
301 | { | 304 | { |
302 | int32_t retVal = -1; | 305 | int32_t retVal = -1; |
303 | 306 | ||
@@ -318,7 +321,7 @@ int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, | |||
318 | 321 | ||
319 | uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId) | 322 | uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId) |
320 | { | 323 | { |
321 | uint32_t baseAddr = 0x00000000; | 324 | uint32_t baseAddr = 0x00000000U; |
322 | 325 | ||
323 | if( custerId < IPC_MAX_PROCS) | 326 | if( custerId < IPC_MAX_PROCS) |
324 | { | 327 | { |
@@ -328,12 +331,14 @@ uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId) | |||
328 | return baseAddr; | 331 | return baseAddr; |
329 | } | 332 | } |
330 | 333 | ||
331 | uint32_t Ipc_getNavss512MailboxInputIntr(int32_t clusterId, int32_t userId) | 334 | uint32_t Ipc_getNavss512MailboxInputIntr(uint32_t clusterId, uint32_t userId) |
332 | { | 335 | { |
333 | uint32_t mailboxIntrNum = 0; | 336 | uint32_t mailboxIntrNum = 0U; |
334 | 337 | ||
335 | if(clusterId >= 0 && clusterId < IPC_MAILBOX_CLUSTER_CNT && | 338 | if( (clusterId != MAILBOX_CLUSTER_INVALID) && |
336 | userId >= 0 && userId < IPC_MAILBOX_USER_CNT) | 339 | (clusterId < IPC_MAILBOX_CLUSTER_CNT) && |
340 | (userId != MAILBOX_USER_INVALID) && | ||
341 | (userId < IPC_MAILBOX_USER_CNT)) | ||
337 | { | 342 | { |
338 | mailboxIntrNum = g_Navss512MbInput[clusterId] + userId; | 343 | mailboxIntrNum = g_Navss512MbInput[clusterId] + userId; |
339 | } | 344 | } |
@@ -388,6 +393,8 @@ int32_t Ipc_setCoreEventId(uint32_t selfId, Ipc_MbConfig* cfg, uint32_t intrCnt) | |||
388 | outIntrBaseNum = NAVSS512_C7X1_INPUT_MAILBOX_OFFSET; | 393 | outIntrBaseNum = NAVSS512_C7X1_INPUT_MAILBOX_OFFSET; |
389 | vimEventBaseNum = C7X1_MBINTR_OFFSET; | 394 | vimEventBaseNum = C7X1_MBINTR_OFFSET; |
390 | break; | 395 | break; |
396 | default: | ||
397 | break; | ||
391 | } | 398 | } |
392 | cfg->outputIntrNum = outIntrBaseNum + intrCnt; | 399 | cfg->outputIntrNum = outIntrBaseNum + intrCnt; |
393 | cfg->eventId = vimEventBaseNum + intrCnt; | 400 | cfg->eventId = vimEventBaseNum + intrCnt; |
@@ -396,8 +403,8 @@ int32_t Ipc_setCoreEventId(uint32_t selfId, Ipc_MbConfig* cfg, uint32_t intrCnt) | |||
396 | } | 403 | } |
397 | 404 | ||
398 | 405 | ||
399 | int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, int32_t clusterId, int32_t userId, | 406 | int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, uint32_t clusterId, |
400 | Ipc_MbConfig* cfg, uint32_t cnt) | 407 | uint32_t userId, Ipc_MbConfig* cfg, uint32_t cnt) |
401 | { | 408 | { |
402 | int32_t retVal = IPC_SOK; | 409 | int32_t retVal = IPC_SOK; |
403 | uint32_t mailboxIntrNum = 0; | 410 | uint32_t mailboxIntrNum = 0; |
@@ -407,49 +414,47 @@ int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, int32_t clusterId, int32_t | |||
407 | 414 | ||
408 | cfg->inputIntrNum = mailboxIntrNum; | 415 | cfg->inputIntrNum = mailboxIntrNum; |
409 | cfg->priority = 1U; | 416 | cfg->priority = 1U; |
410 | Ipc_setCoreEventId(selfId, cfg, cnt); | 417 | retVal = Ipc_setCoreEventId(selfId, cfg, cnt); |
411 | 418 | ||
412 | return retVal; | 419 | return retVal; |
413 | } | 420 | } |
414 | 421 | ||
415 | const char* Ipc_getCoreName(uint32_t procId) | 422 | const char* Ipc_getCoreName(uint32_t procId) |
416 | { | 423 | { |
417 | if(procId < IPC_MAX_PROCS) | 424 | char* p = (void*)0; |
418 | return g_Ipc_mp_procInfo[procId].name; | 425 | uint32_t id = procId; |
419 | else | 426 | |
420 | return (const char*)NULL; | 427 | if(id < IPC_MAX_PROCS) |
428 | { | ||
429 | p = g_Ipc_mp_procInfo[id].name; | ||
430 | } | ||
431 | return p; | ||
421 | } | 432 | } |
422 | 433 | ||
423 | #if defined(BUILD_C66X_1) || defined(BUILD_C66X_2) | 434 | #if defined(BUILD_C66X_1) || defined(BUILD_C66X_2) |
424 | void Ipc_configC66xIntrRouter(uint32_t input) | 435 | void Ipc_configC66xIntrRouter(uint32_t input) |
425 | { | 436 | { |
426 | static bool firstTime = TRUE; | ||
427 | volatile uint32_t *intr_router = (volatile uint32_t *)IPC_C66X_INTR_VA_BASE; | 437 | volatile uint32_t *intr_router = (volatile uint32_t *)IPC_C66X_INTR_VA_BASE; |
428 | uint32_t inputBase = 0; | 438 | volatile uint32_t *RAT = (volatile uint32_t *)IPC_C66X_RAT_BASE; |
429 | uint32_t outputBase = 0; | 439 | uint32_t inputBase = 0U; |
430 | uint32_t mbIntrBase = 0; | 440 | uint32_t outputBase = 0U; |
431 | uint32_t outputPin = 0; | 441 | uint32_t mbIntrBase = 0U; |
432 | uint32_t inputPin = 0; | 442 | uint32_t outputPin = 0U; |
443 | uint32_t inputPin = 0U; | ||
433 | 444 | ||
434 | if(TRUE == firstTime) | 445 | /* program virtual address to REGION_BASE */ |
435 | { | 446 | RAT[1] = (int)intr_router; |
436 | /* Configure RAT to access C66x Interrupt Router */ | ||
437 | volatile uint32_t *RAT = (volatile uint32_t *)IPC_C66X_RAT_BASE; | ||
438 | 447 | ||
439 | /* program virtual address to REGION_BASE */ | 448 | /* program C66_1/2 INTR_ROUTER physical addr to REGION_TRANS_L */ |
440 | RAT[1] = (int)intr_router; | ||
441 | |||
442 | /* program C66_1/2 INTR_ROUTER physical addr to REGION_TRANS_L */ | ||
443 | #ifdef BUILD_C66X_1 | 449 | #ifdef BUILD_C66X_1 |
444 | RAT[2] = IPC_C66X_1_INTR_PA_BASE; | 450 | RAT[2] = IPC_C66X_1_INTR_PA_BASE; |
445 | #endif | 451 | #endif |
446 | #ifdef BUILD_C66X_2 | 452 | #ifdef BUILD_C66X_2 |
447 | RAT[2] = IPC_C66X_2_INTR_PA_BASE; | 453 | RAT[2] = IPC_C66X_2_INTR_PA_BASE; |
448 | #endif | 454 | #endif |
449 | 455 | ||
450 | /* enable region and set size to 512 B */ | 456 | /* enable region and set size to 512 B */ |
451 | RAT[0] = 0x80000009; | 457 | RAT[0] = 0x80000009U; |
452 | } | ||
453 | 458 | ||
454 | #ifdef BUILD_C66X_1 | 459 | #ifdef BUILD_C66X_1 |
455 | inputBase = C66X1_MBINTR_INPUT_BASE; | 460 | inputBase = C66X1_MBINTR_INPUT_BASE; |
@@ -488,7 +493,7 @@ void Ipc_configClecRouter(uint32_t corePackEvent) | |||
488 | cfgClec.secureClaimEnable = FALSE; | 493 | cfgClec.secureClaimEnable = FALSE; |
489 | cfgClec.evtSendEnable = TRUE; | 494 | cfgClec.evtSendEnable = TRUE; |
490 | cfgClec.rtMap = CSL_CLEC_RTMAP_CPU_ALL; | 495 | cfgClec.rtMap = CSL_CLEC_RTMAP_CPU_ALL; |
491 | cfgClec.extEvtNum = 0; | 496 | cfgClec.extEvtNum = 0U; |
492 | cfgClec.c7xEvtNum = corePackEvent; | 497 | cfgClec.c7xEvtNum = corePackEvent; |
493 | CSL_clecConfigEvent(clecBaseAddr, input, &cfgClec); | 498 | CSL_clecConfigEvent(clecBaseAddr, input, &cfgClec); |
494 | } | 499 | } |
@@ -497,7 +502,7 @@ void Ipc_configClecRouter(uint32_t corePackEvent) | |||
497 | #ifdef IPC_SUPPORT_SCICLIENT | 502 | #ifdef IPC_SUPPORT_SCICLIENT |
498 | 503 | ||
499 | /* Indexed list of dst ids */ | 504 | /* Indexed list of dst ids */ |
500 | const int32_t map_dst_id[] = | 505 | const uint8_t map_dst_id[] = |
501 | { | 506 | { |
502 | TISCI_DEV_COMPUTE_CLUSTER0_GIC500SS, | 507 | TISCI_DEV_COMPUTE_CLUSTER0_GIC500SS, |
503 | TISCI_DEV_MCU_R5FSS0_CORE0, | 508 | TISCI_DEV_MCU_R5FSS0_CORE0, |
@@ -544,8 +549,8 @@ const uint16_t map_host_id[] = | |||
544 | }; | 549 | }; |
545 | 550 | ||
546 | 551 | ||
547 | int32_t Ipc_sciclientIrqRelease(uint16_t coreId, int32_t clusterId, | 552 | int32_t Ipc_sciclientIrqRelease(uint16_t coreId, uint32_t clusterId, |
548 | int32_t userId, uint32_t intNumber) | 553 | uint32_t userId, uint32_t intNumber) |
549 | { | 554 | { |
550 | int32_t retVal = IPC_SOK; | 555 | int32_t retVal = IPC_SOK; |
551 | struct tisci_msg_rm_irq_release_req rmIrqRel; | 556 | struct tisci_msg_rm_irq_release_req rmIrqRel; |
@@ -559,26 +564,22 @@ int32_t Ipc_sciclientIrqRelease(uint16_t coreId, int32_t clusterId, | |||
559 | TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID | | 564 | TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID | |
560 | TISCI_MSG_VALUE_RM_SECONDARY_HOST_VALID; | 565 | TISCI_MSG_VALUE_RM_SECONDARY_HOST_VALID; |
561 | rmIrqRel.src_id = map_src_id[clusterId]; | 566 | rmIrqRel.src_id = map_src_id[clusterId]; |
562 | rmIrqRel.src_index = userId; | 567 | rmIrqRel.src_index = (uint16_t)userId; |
563 | rmIrqRel.dst_id = map_dst_id[coreId]; | 568 | rmIrqRel.dst_id = (uint16_t)map_dst_id[coreId]; |
564 | #if defined(BUILD_C7X_1) | 569 | #if defined(BUILD_C7X_1) |
565 | rmIrqRel.dst_host_irq = intNumber + IPC_C7X_COMPUTE_CLUSTER_OFFSET; | 570 | rmIrqRel.dst_host_irq = (uint16_t)(intNumber + IPC_C7X_COMPUTE_CLUSTER_OFFSET); |
566 | #else | 571 | #else |
567 | rmIrqRel.dst_host_irq = intNumber; | 572 | rmIrqRel.dst_host_irq = (uint16_t)intNumber; |
568 | #endif | 573 | #endif |
569 | rmIrqRel.secondary_host = map_host_id[coreId]; | 574 | rmIrqRel.secondary_host = (uint8_t)map_host_id[coreId]; |
570 | 575 | ||
571 | if(IPC_SOK == retVal) | 576 | retVal = Sciclient_rmIrqRelease(&rmIrqRel, IPC_SCICLIENT_TIMEOUT); |
572 | { | ||
573 | retVal = Sciclient_rmIrqRelease( | ||
574 | &rmIrqRel, IPC_SCICLIENT_TIMEOUT); | ||
575 | } | ||
576 | 577 | ||
577 | return retVal; | 578 | return retVal; |
578 | } | 579 | } |
579 | 580 | ||
580 | int32_t Ipc_sciclientIrqSet(uint16_t coreId, int32_t clusterId, | 581 | int32_t Ipc_sciclientIrqSet(uint16_t coreId, uint32_t clusterId, |
581 | int32_t userId, uint32_t intNumber) | 582 | uint32_t userId, uint32_t intNumber) |
582 | { | 583 | { |
583 | int32_t retVal = IPC_SOK; | 584 | int32_t retVal = IPC_SOK; |
584 | struct tisci_msg_rm_irq_set_req rmIrqReq; | 585 | struct tisci_msg_rm_irq_set_req rmIrqReq; |
@@ -593,21 +594,17 @@ int32_t Ipc_sciclientIrqSet(uint16_t coreId, int32_t clusterId, | |||
593 | TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID | | 594 | TISCI_MSG_VALUE_RM_DST_HOST_IRQ_VALID | |
594 | TISCI_MSG_VALUE_RM_SECONDARY_HOST_VALID; | 595 | TISCI_MSG_VALUE_RM_SECONDARY_HOST_VALID; |
595 | rmIrqReq.src_id = map_src_id[clusterId]; | 596 | rmIrqReq.src_id = map_src_id[clusterId]; |
596 | rmIrqReq.src_index = userId; | 597 | rmIrqReq.src_index = (uint16_t)userId; |
597 | rmIrqReq.dst_id = map_dst_id[coreId]; | 598 | rmIrqReq.dst_id = (uint16_t)map_dst_id[coreId]; |
598 | #if defined(BUILD_C7X_1) | 599 | #if defined(BUILD_C7X_1) |
599 | rmIrqReq.dst_host_irq = intNumber + IPC_C7X_COMPUTE_CLUSTER_OFFSET; | 600 | rmIrqReq.dst_host_irq = (uint16_t)(intNumber + IPC_C7X_COMPUTE_CLUSTER_OFFSET); |
600 | #else | 601 | #else |
601 | rmIrqReq.dst_host_irq = intNumber; | 602 | rmIrqReq.dst_host_irq = (uint16_t)intNumber; |
602 | #endif | 603 | #endif |
603 | rmIrqReq.secondary_host = map_host_id[coreId]; | 604 | rmIrqReq.secondary_host = (uint8_t)map_host_id[coreId]; |
604 | 605 | ||
605 | if(IPC_SOK == retVal) | 606 | /* Config event */ |
606 | { | 607 | retVal = Sciclient_rmIrqSet(&rmIrqReq, &rmIrqResp, IPC_SCICLIENT_TIMEOUT); |
607 | /* Config event */ | ||
608 | retVal = Sciclient_rmIrqSet( | ||
609 | &rmIrqReq, &rmIrqResp, IPC_SCICLIENT_TIMEOUT); | ||
610 | } | ||
611 | 608 | ||
612 | return retVal; | 609 | return retVal; |
613 | } | 610 | } |
diff --git a/soc/V1/ipc_soc.h b/soc/V1/ipc_soc.h index 16e8268..352bbbb 100644 --- a/soc/V1/ipc_soc.h +++ b/soc/V1/ipc_soc.h | |||
@@ -57,7 +57,7 @@ extern "C" { | |||
57 | * \brief VRing Buffer Size required for all core | 57 | * \brief VRing Buffer Size required for all core |
58 | * combinations. | 58 | * combinations. |
59 | */ | 59 | */ |
60 | #define IPC_VRING_BUFFER_SIZE (0x1C00000) | 60 | #define IPC_VRING_BUFFER_SIZE (0x1C00000U) |
61 | 61 | ||
62 | /* | 62 | /* |
63 | * For VLAB toolbox 0.14.5.snapshot2 onward, | 63 | * For VLAB toolbox 0.14.5.snapshot2 onward, |
@@ -67,75 +67,75 @@ extern "C" { | |||
67 | #define SUPPORT_C66X_BIT0 | 67 | #define SUPPORT_C66X_BIT0 |
68 | 68 | ||
69 | /** \brief Core definitions */ | 69 | /** \brief Core definitions */ |
70 | #define IPC_MPU1_0 (0) /**< ARM A72 - VM0 */ | 70 | #define IPC_MPU1_0 (0U) /**< ARM A72 - VM0 */ |
71 | #define IPC_MCU1_0 (1) /**< ARM MCU R5F - core0 */ | 71 | #define IPC_MCU1_0 (1U) /**< ARM MCU R5F - core0 */ |
72 | #define IPC_MCU1_1 (2) /**< ARM MCU R5F - core1 */ | 72 | #define IPC_MCU1_1 (2U) /**< ARM MCU R5F - core1 */ |
73 | #define IPC_MCU2_0 (3) /**< ARM Main R5F - core0 */ | 73 | #define IPC_MCU2_0 (3U) /**< ARM Main R5F - core0 */ |
74 | #define IPC_MCU2_1 (4) /**< ARM Main R5F - core1 */ | 74 | #define IPC_MCU2_1 (4U) /**< ARM Main R5F - core1 */ |
75 | #define IPC_MCU3_0 (5) /**< ARM Main R5F - core2 */ | 75 | #define IPC_MCU3_0 (5U) /**< ARM Main R5F - core2 */ |
76 | #define IPC_MCU3_1 (6) /**< ARM Main R5F - core3 */ | 76 | #define IPC_MCU3_1 (6U) /**< ARM Main R5F - core3 */ |
77 | #define IPC_C66X_1 (7) /**< DSP C66x - core0 */ | 77 | #define IPC_C66X_1 (7U) /**< DSP C66x - core0 */ |
78 | #define IPC_C66X_2 (8) /**< DSP C66x - core1 */ | 78 | #define IPC_C66X_2 (8U) /**< DSP C66x - core1 */ |
79 | #define IPC_C7X_1 (9) /**< DSP C7x - core0 */ | 79 | #define IPC_C7X_1 (9U) /**< DSP C7x - core0 */ |
80 | #define IPC_MPU1_1 (10) /**< ARM A72 - VM1 */ | 80 | #define IPC_MPU1_1 (10U) /**< ARM A72 - VM1 */ |
81 | #define IPC_MAX_PROCS (11) /**< Maximum Processors */ | 81 | #define IPC_MAX_PROCS (11U) /**< Maximum Processors */ |
82 | 82 | ||
83 | #define IPC_MAILBOX_CLUSTER_CNT (12) | 83 | #define IPC_MAILBOX_CLUSTER_CNT (12U) |
84 | #define IPC_MAILBOX_USER_CNT (4) | 84 | #define IPC_MAILBOX_USER_CNT (4U) |
85 | #define MAIN_NAVSS_MAILBOX_INPUTINTR_MAX (440) | 85 | #define MAIN_NAVSS_MAILBOX_INPUTINTR_MAX (440U) |
86 | #define MAIN_NAVSS_MAILBOX_OUTPUTINTR_MAX (512) | 86 | #define MAIN_NAVSS_MAILBOX_OUTPUTINTR_MAX (512U) |
87 | 87 | ||
88 | /* Refer to J7ES interrupt mapping table */ | 88 | /* Refer to J7ES interrupt mapping table */ |
89 | #define NAVSS512_MPU1_0_INPUT_MAILBOX_OFFSET (182) | 89 | #define NAVSS512_MPU1_0_INPUT_MAILBOX_OFFSET (182U) |
90 | #define NAVSS512_MCU1R5F0_INPUT_MAILBOX_OFFSET (400) | 90 | #define NAVSS512_MCU1R5F0_INPUT_MAILBOX_OFFSET (400U) |
91 | #define NAVSS512_MCU1R5F1_INPUT_MAILBOX_OFFSET (404) | 91 | #define NAVSS512_MCU1R5F1_INPUT_MAILBOX_OFFSET (404U) |
92 | #define NAVSS512_MCU2R5F0_INPUT_MAILBOX_OFFSET (216) | 92 | #define NAVSS512_MCU2R5F0_INPUT_MAILBOX_OFFSET (216U) |
93 | #define NAVSS512_MCU2R5F1_INPUT_MAILBOX_OFFSET (248) | 93 | #define NAVSS512_MCU2R5F1_INPUT_MAILBOX_OFFSET (248U) |
94 | #define NAVSS512_MCU3R5F0_INPUT_MAILBOX_OFFSET (280) | 94 | #define NAVSS512_MCU3R5F0_INPUT_MAILBOX_OFFSET (280U) |
95 | #define NAVSS512_MCU3R5F1_INPUT_MAILBOX_OFFSET (312) | 95 | #define NAVSS512_MCU3R5F1_INPUT_MAILBOX_OFFSET (312U) |
96 | #define NAVSS512_C66X1_INPUT_MAILBOX_OFFSET (344) /* C66x_intrRouter_0 : 96 */ | 96 | #define NAVSS512_C66X1_INPUT_MAILBOX_OFFSET (344U) /* C66x_intrRouter_0 : 96 */ |
97 | #define NAVSS512_C66X2_INPUT_MAILBOX_OFFSET (376) /* C66x_intrRouter_1 : 96 */ | 97 | #define NAVSS512_C66X2_INPUT_MAILBOX_OFFSET (376U) /* C66x_intrRouter_1 : 96 */ |
98 | #define NAVSS512_C7X1_INPUT_MAILBOX_OFFSET (188) | 98 | #define NAVSS512_C7X1_INPUT_MAILBOX_OFFSET (188U) |
99 | 99 | ||
100 | #define IPC_MCU_NAVSS0_INTR0_CFG_BASE (CSL_NAVSS_MAIN_INTR_ROUTER_CFG_REGS_0_BASE) | 100 | #define IPC_MCU_NAVSS0_INTR0_CFG_BASE (CSL_NAVSS_MAIN_INTR_ROUTER_CFG_REGS_0_BASE) |
101 | 101 | ||
102 | /* Could not find the RAT address in CSL */ | 102 | /* Could not find the RAT address in CSL */ |
103 | #define IPC_C66X_RAT_BASE (0x07ff0030) | 103 | #define IPC_C66X_RAT_BASE (0x07ff0030U) |
104 | 104 | ||
105 | /* Virtual Address used for C66x to access j7_c66_interrupt_router */ | 105 | /* Virtual Address used for C66x to access j7_c66_interrupt_router */ |
106 | #define IPC_C66X_INTR_VA_BASE (0x18000000) | 106 | #define IPC_C66X_INTR_VA_BASE (0x18000000U) |
107 | 107 | ||
108 | /* C66x_1/2 intr_router phy address */ | 108 | /* C66x_1/2 intr_router phy address */ |
109 | #define IPC_C66X_1_INTR_PA_BASE (CSL_C66SS0_INTROUTER0_INTR_ROUTER_CFG_BASE) | 109 | #define IPC_C66X_1_INTR_PA_BASE (CSL_C66SS0_INTROUTER0_INTR_ROUTER_CFG_BASE) |
110 | #define IPC_C66X_2_INTR_PA_BASE (CSL_C66SS1_INTROUTER0_INTR_ROUTER_CFG_BASE) | 110 | #define IPC_C66X_2_INTR_PA_BASE (CSL_C66SS1_INTROUTER0_INTR_ROUTER_CFG_BASE) |
111 | 111 | ||
112 | /* CPU local interrupt Number */ | 112 | /* CPU local interrupt Number */ |
113 | #define MPU1_0_MBINTR_OFFSET (726) | 113 | #define MPU1_0_MBINTR_OFFSET (726U) |
114 | #define MCU1R5F0_MBINTR_OFFSET (376) | 114 | #define MCU1R5F0_MBINTR_OFFSET (376U) |
115 | #define MCU1R5F1_MBINTR_OFFSET (380) | 115 | #define MCU1R5F1_MBINTR_OFFSET (380U) |
116 | #define MCU2R5F0_MBINTR_OFFSET (248) | 116 | #define MCU2R5F0_MBINTR_OFFSET (248U) |
117 | #define MCU2R5F1_MBINTR_OFFSET (248) | 117 | #define MCU2R5F1_MBINTR_OFFSET (248U) |
118 | #define MCU3R5F0_MBINTR_OFFSET (248) | 118 | #define MCU3R5F0_MBINTR_OFFSET (248U) |
119 | #define MCU3R5F1_MBINTR_OFFSET (248) | 119 | #define MCU3R5F1_MBINTR_OFFSET (248U) |
120 | 120 | ||
121 | /* C66x Corepack Event */ | 121 | /* C66x Corepack Event */ |
122 | #define C66X1_MBINTR_OFFSET (84) | 122 | #define C66X1_MBINTR_OFFSET (84U) |
123 | #define C66X2_MBINTR_OFFSET (84) | 123 | #define C66X2_MBINTR_OFFSET (84U) |
124 | 124 | ||
125 | #define C7X1_MBINTR_OFFSET (51) | 125 | #define C7X1_MBINTR_OFFSET (51U) |
126 | #define IPC_C7X_COMPUTE_CLUSTER_OFFSET (CSLR_COMPUTE_CLUSTER0_GIC500SS_SPI_NAVSS0_INTR_ROUTER_0_OUTL_INTR_128) | 126 | #define IPC_C7X_COMPUTE_CLUSTER_OFFSET (CSLR_COMPUTE_CLUSTER0_GIC500SS_SPI_NAVSS0_INTR_ROUTER_0_OUTL_INTR_128) |
127 | 127 | ||
128 | #define C66X1_MBINTR_INPUT_BASE (74) | 128 | #define C66X1_MBINTR_INPUT_BASE (74U) |
129 | #define C66X2_MBINTR_INPUT_BASE (74) | 129 | #define C66X2_MBINTR_INPUT_BASE (74U) |
130 | 130 | ||
131 | /* Input to C66x Interrupt Router */ | 131 | /* Input to C66x Interrupt Router */ |
132 | #define C66X1_MBINTR_OUTPUT_BASE (96) | 132 | #define C66X1_MBINTR_OUTPUT_BASE (96U) |
133 | #define C66X2_MBINTR_OUTPUT_BASE (96) | 133 | #define C66X2_MBINTR_OUTPUT_BASE (96U) |
134 | 134 | ||
135 | #ifdef IPC_SUPPORT_SCICLIENT | 135 | #ifdef IPC_SUPPORT_SCICLIENT |
136 | #define C7X1_MBINTR_OUTPUT_BASE (1715) | 136 | #define C7X1_MBINTR_OUTPUT_BASE (1715U) |
137 | #else | 137 | #else |
138 | #define C7X1_MBINTR_OUTPUT_BASE (1724) | 138 | #define C7X1_MBINTR_OUTPUT_BASE (1724U) |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | #define C7X_CLEC_BASE_ADDR (CSL_COMPUTE_CLUSTER0_CLEC_REGS_BASE) | 141 | #define C7X_CLEC_BASE_ADDR (CSL_COMPUTE_CLUSTER0_CLEC_REGS_BASE) |
@@ -174,10 +174,10 @@ void Ipc_configClecRouter(uint32_t coreEvent); | |||
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | #ifdef IPC_SUPPORT_SCICLIENT | 176 | #ifdef IPC_SUPPORT_SCICLIENT |
177 | int32_t Ipc_sciclientIrqRelease(uint16_t remoteId, int32_t clusterId, | 177 | int32_t Ipc_sciclientIrqRelease(uint16_t remoteId, uint32_t clusterId, |
178 | int32_t userId, uint32_t intNumber); | 178 | uint32_t userId, uint32_t intNumber); |
179 | int32_t Ipc_sciclientIrqSet(uint16_t remoteId, int32_t clusterId, int32_t userId, | 179 | int32_t Ipc_sciclientIrqSet(uint16_t remoteId, uint32_t clusterId, |
180 | uint32_t intNumber); | 180 | uint32_t userId, uint32_t intNumber); |
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | /* ========================================================================== */ | 183 | /* ========================================================================== */ |
diff --git a/soc/ipc_soc.h b/soc/ipc_soc.h index 406e621..0dcfb91 100644 --- a/soc/ipc_soc.h +++ b/soc/ipc_soc.h | |||
@@ -62,11 +62,11 @@ extern "C" { | |||
62 | /* Function Declarations */ | 62 | /* Function Declarations */ |
63 | /* ========================================================================== */ | 63 | /* ========================================================================== */ |
64 | int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, | 64 | int32_t Ipc_getMailboxInfoTx(uint32_t selfId, uint32_t remoteId, |
65 | int32_t *clusterId, int32_t *userId, uint32_t *queueId); | 65 | uint32_t *clusterId, uint32_t *userId, uint32_t *queueId); |
66 | int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, | 66 | int32_t Ipc_getMailboxInfoRx(uint32_t selfId, uint32_t remoteId, |
67 | int32_t *clusterId, int32_t *userId, uint32_t *queueId); | 67 | uint32_t *clusterId, uint32_t *userId, uint32_t *queueId); |
68 | int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, int32_t clusterId, int32_t userId, | 68 | int32_t Ipc_getMailboxIntrRouterCfg(uint32_t selfId, uint32_t clusterId, |
69 | Ipc_MbConfig* cfg, uint32_t cnt); | 69 | uint32_t userId, Ipc_MbConfig* cfg, uint32_t cnt); |
70 | uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId); | 70 | uint32_t Ipc_getMailboxBaseAddr(uint32_t custerId); |
71 | const char* Ipc_getCoreName(uint32_t procId); | 71 | const char* Ipc_getCoreName(uint32_t procId); |
72 | 72 | ||
diff --git a/src/ipc_api.c b/src/ipc_api.c index d624422..b9de032 100755 --- a/src/ipc_api.c +++ b/src/ipc_api.c | |||
@@ -60,25 +60,20 @@ | |||
60 | /* ========================================================================== */ | 60 | /* ========================================================================== */ |
61 | #define MAXCALLBACKS IPC_MAX_PROCS | 61 | #define MAXCALLBACKS IPC_MAX_PROCS |
62 | 62 | ||
63 | #define MSGBUFFERSIZE 512 | 63 | #define MSGBUFFERSIZE 512U |
64 | #define SERVICENAMELEN 32 | 64 | #define SERVICENAMELEN 32U |
65 | #define HEAPALIGNMENT 8 | 65 | #define HEAPALIGNMENT 8U |
66 | 66 | ||
67 | typedef struct RPMessage_Object* RPMessage_EndptPool[MAXENDPOINTS]; | 67 | typedef struct RPMessage_Object* RPMessage_EndptPool[MAXENDPOINTS]; |
68 | #define RPMessage_lookupEndpt(p, e) (((RPMessage_Object**)(p))[(e)]) | ||
69 | #define RPMessage_assignEndpt(p, e, obj) (((RPMessage_Object**)(p))[(e)] = (obj)) | ||
70 | 68 | ||
71 | /* ========================================================================== */ | 69 | /* ========================================================================== */ |
72 | /* Structure Declarations */ | 70 | /* Structure Declarations */ |
73 | /* ========================================================================== */ | 71 | /* ========================================================================== */ |
74 | 72 | ||
75 | #define CNTRLMSG_ANNOUNCE (0x00000000) | 73 | #define CNTRLMSG_ANNOUNCE (0x00000000U) |
76 | |||
77 | #define is_aligned(POINTER, BYTE_COUNT) \ | ||
78 | (((uintptr_t)(const void *)(POINTER)) % (BYTE_COUNT) == 0) | ||
79 | 74 | ||
80 | /* Message Header: Must match mp_msg_hdr in virtio_rp_msg.h on Linux side. */ | 75 | /* Message Header: Must match mp_msg_hdr in virtio_rp_msg.h on Linux side. */ |
81 | typedef struct RPMessage_MsgHeader | 76 | typedef struct RPMessage_MsgHeader_s |
82 | { | 77 | { |
83 | uint32_t srcAddr; /* source endpoint addr */ | 78 | uint32_t srcAddr; /* source endpoint addr */ |
84 | uint32_t dstAddr; /* destination endpoint addr */ | 79 | uint32_t dstAddr; /* destination endpoint addr */ |
@@ -86,16 +81,17 @@ typedef struct RPMessage_MsgHeader | |||
86 | uint16_t dataLen; /* data length */ | 81 | uint16_t dataLen; /* data length */ |
87 | uint16_t flags; /* bitmask of different flags */ | 82 | uint16_t flags; /* bitmask of different flags */ |
88 | uint8_t payload[]; /* Data payload */ | 83 | uint8_t payload[]; /* Data payload */ |
89 | } RPMessage_MsgHeader; | 84 | }RPMessage_MsgHeader; |
85 | |||
90 | 86 | ||
91 | /* common fields of a control message */ | 87 | /* common fields of a control message */ |
92 | typedef struct RPMessage_CntrlMsg | 88 | typedef struct RPMessage_CntrlMsg_s |
93 | { | 89 | { |
94 | uint32_t type; | 90 | uint32_t type; |
95 | } RPMessage_CntrlMsg; | 91 | }RPMessage_CntrlMsg; |
96 | 92 | ||
97 | /* announcement message */ | 93 | /* announcement message */ |
98 | typedef struct RPMessage_Announcement | 94 | typedef struct RPMessage_Announcement_s |
99 | { | 95 | { |
100 | char name[SERVICENAMELEN]; | 96 | char name[SERVICENAMELEN]; |
101 | uint32_t endPt; | 97 | uint32_t endPt; |
@@ -104,7 +100,7 @@ typedef struct RPMessage_Announcement | |||
104 | 100 | ||
105 | 101 | ||
106 | /* list element for the announcedEndpts list */ | 102 | /* list element for the announcedEndpts list */ |
107 | typedef struct RPMessage_NameEntry | 103 | typedef struct RPMessage_NameEntry_s |
108 | { | 104 | { |
109 | IpcUtils_QElem elem; | 105 | IpcUtils_QElem elem; |
110 | uint32_t procId; | 106 | uint32_t procId; |
@@ -114,7 +110,7 @@ typedef struct RPMessage_NameEntry | |||
114 | 110 | ||
115 | 111 | ||
116 | /* list element for the waitingTasks list */ | 112 | /* list element for the waitingTasks list */ |
117 | typedef struct RPMessage_Waiter | 113 | typedef struct RPMessage_Waiter_s |
118 | { | 114 | { |
119 | IpcUtils_QElem elem; | 115 | IpcUtils_QElem elem; |
120 | void *semHandle; | 116 | void *semHandle; |
@@ -125,7 +121,7 @@ typedef struct RPMessage_Waiter | |||
125 | /** | 121 | /** |
126 | * \brief Element to hold payload copied onto receiver's queue. | 122 | * \brief Element to hold payload copied onto receiver's queue. |
127 | */ | 123 | */ |
128 | typedef struct | 124 | typedef struct RPMessage_MsgElem_s |
129 | { | 125 | { |
130 | IpcUtils_QElem elem; /**< Allow list linking. */ | 126 | IpcUtils_QElem elem; /**< Allow list linking. */ |
131 | uint32_t len; /**< Length of data */ | 127 | uint32_t len; /**< Length of data */ |
@@ -135,14 +131,14 @@ typedef struct | |||
135 | } RPMessage_MsgElem; | 131 | } RPMessage_MsgElem; |
136 | 132 | ||
137 | /* The RPMessage Object */ | 133 | /* The RPMessage Object */ |
138 | typedef struct RPMessage_Object | 134 | typedef struct RPMessage_Object_s |
139 | { | 135 | { |
140 | uint32_t endPt; /**< Unique id (procId | queueIndex) */ | 136 | uint32_t endPt; /**< Unique id (procId | queueIndex) */ |
141 | void *semHandle; /**< I/O Completion */ | 137 | void *semHandle; /**< I/O Completion */ |
142 | RPMessage_Callback cb; /**< RPMessage Callback */ | 138 | RPMessage_Callback cb; /**< RPMessage Callback */ |
143 | void* arg; /**< Callback argument */ | 139 | void* arg; /**< Callback argument */ |
144 | IpcUtils_QHandle queue; /**< Queue of pending messages */ | 140 | IpcUtils_QHandle queue; /**< Queue of pending messages */ |
145 | bool unblocked; /**< Use with signal to unblock _receive() */ | 141 | uint8_t unblocked; /**< Use with signal to unblock _receive() */ |
146 | IpcUtils_HeapParams heapParams; /* Save the heapBuf params to delete Heap */ | 142 | IpcUtils_HeapParams heapParams; /* Save the heapBuf params to delete Heap */ |
147 | IpcUtils_HeapHandle heap; /* Heap from which to allocate free messages */ | 143 | IpcUtils_HeapHandle heap; /* Heap from which to allocate free messages */ |
148 | RPMessage_EndptPool *pool; /**< track associated pool for cleanup */ | 144 | RPMessage_EndptPool *pool; /**< track associated pool for cleanup */ |
@@ -154,7 +150,7 @@ typedef struct RPMessage_Object | |||
154 | * \brief This struct is used as private data supplied to the VQ | 150 | * \brief This struct is used as private data supplied to the VQ |
155 | * callback function. It is also passed to the SWI | 151 | * callback function. It is also passed to the SWI |
156 | * functions through arg0. */ | 152 | * functions through arg0. */ |
157 | typedef struct RPMessage_CallbackData_e | 153 | typedef struct RPMessage_CallbackData_s |
158 | { | 154 | { |
159 | Virtio_Handle vq; | 155 | Virtio_Handle vq; |
160 | RPMessage_EndptPool *pool; | 156 | RPMessage_EndptPool *pool; |
@@ -164,7 +160,7 @@ typedef struct RPMessage_CallbackData_e | |||
164 | /** | 160 | /** |
165 | * \brief Module_State | 161 | * \brief Module_State |
166 | */ | 162 | */ |
167 | typedef struct | 163 | typedef struct RPMessage_Module_s |
168 | { | 164 | { |
169 | /* Instance gate: */ | 165 | /* Instance gate: */ |
170 | Ipc_OsalHIsrGateHandle gateSwi; | 166 | Ipc_OsalHIsrGateHandle gateSwi; |
@@ -217,12 +213,44 @@ static RPMessage_Object* RPMessage_rawCreate(RPMessage_Params *params, | |||
217 | 213 | ||
218 | static RPMessage_Module module; | 214 | static RPMessage_Module module; |
219 | 215 | ||
220 | static Ipc_Object_t gIpcObject; | 216 | static Ipc_Object gIpcObject; |
221 | /**< IPC Object */ | 217 | /**< IPC Object */ |
222 | /* ========================================================================== */ | 218 | /* ========================================================================== */ |
223 | /* Function Definitions */ | 219 | /* Function Definitions */ |
224 | /* ========================================================================== */ | 220 | /* ========================================================================== */ |
225 | 221 | ||
222 | RPMessage_Object* RPMessage_lookupEndpt(void* p, uint32_t e); | ||
223 | void RPMessage_assignEndpt(void* p, uint32_t e, RPMessage_Object* obj); | ||
224 | void UNUSED(const uint32_t* x); | ||
225 | uint8_t is_aligned(const void* ptr, uint32_t byteCnt); | ||
226 | RPMessage_Object* RPMessage_allocObject(void); | ||
227 | |||
228 | |||
229 | inline RPMessage_Object* RPMessage_lookupEndpt(void* p, uint32_t e) | ||
230 | { | ||
231 | return (((RPMessage_Object**)(p))[(e)]); | ||
232 | } | ||
233 | |||
234 | inline void RPMessage_assignEndpt(void* p, uint32_t e, RPMessage_Object* obj) | ||
235 | { | ||
236 | (((RPMessage_Object**)(p))[(e)] = (obj)); | ||
237 | } | ||
238 | |||
239 | inline void UNUSED(const uint32_t* x) | ||
240 | { | ||
241 | (void)(x); | ||
242 | } | ||
243 | |||
244 | inline uint8_t is_aligned(const void* ptr, uint32_t byteCnt) | ||
245 | { | ||
246 | uint8_t retVal; | ||
247 | uint32_t bufAddr = (uint32_t)(uintptr_t)ptr; | ||
248 | retVal = (0 == (bufAddr%byteCnt)) ? TRUE : FALSE; | ||
249 | return retVal; | ||
250 | } | ||
251 | |||
252 | |||
253 | |||
226 | int32_t RPMessageParams_init(RPMessage_Params *params) | 254 | int32_t RPMessageParams_init(RPMessage_Params *params) |
227 | { | 255 | { |
228 | int32_t retVal = IPC_SOK; | 256 | int32_t retVal = IPC_SOK; |
@@ -236,7 +264,7 @@ int32_t RPMessageParams_init(RPMessage_Params *params) | |||
236 | params->requestedEndpt = RPMESSAGE_ANY; | 264 | params->requestedEndpt = RPMESSAGE_ANY; |
237 | params->numBufs = RPMessage_Buffer_Count_Default; | 265 | params->numBufs = RPMessage_Buffer_Count_Default; |
238 | params->stackBuffer = NULL; | 266 | params->stackBuffer = NULL; |
239 | params->stackSize = 0; | 267 | params->stackSize = 0U; |
240 | } | 268 | } |
241 | 269 | ||
242 | return (retVal); | 270 | return (retVal); |
@@ -247,7 +275,7 @@ uint32_t RPMessage_getMessageBufferSize(void) | |||
247 | return MSGBUFFERSIZE; | 275 | return MSGBUFFERSIZE; |
248 | } | 276 | } |
249 | 277 | ||
250 | uint32_t RPMessage_getObjMemRequired() | 278 | uint32_t RPMessage_getObjMemRequired(void) |
251 | { | 279 | { |
252 | uint32_t objSize = sizeof(RPMessage_Object); | 280 | uint32_t objSize = sizeof(RPMessage_Object); |
253 | objSize = ((objSize + HEAPALIGNMENT-1) & ~(HEAPALIGNMENT-1)); | 281 | objSize = ((objSize + HEAPALIGNMENT-1) & ~(HEAPALIGNMENT-1)); |
@@ -255,13 +283,14 @@ uint32_t RPMessage_getObjMemRequired() | |||
255 | } | 283 | } |
256 | 284 | ||
257 | 285 | ||
258 | RPMessage_Object* RPMessage_allocObject() | 286 | RPMessage_Object* RPMessage_allocObject(void) |
259 | { | 287 | { |
260 | RPMessage_Object* obj = NULL; | 288 | RPMessage_Object* obj = NULL; |
261 | 289 | ||
262 | if(module.objArry != NULL) | 290 | if(module.objArry != NULL) |
263 | { | 291 | { |
264 | obj = (RPMessage_Object*)&(module.objArry[module.objCnt++]); | 292 | obj = (RPMessage_Object*)&(module.objArry[module.objCnt]); |
293 | module.objCnt++; | ||
265 | } | 294 | } |
266 | 295 | ||
267 | return obj; | 296 | return obj; |
@@ -292,48 +321,15 @@ static int32_t RPMessage_enqueMsg(RPMessage_EndptPool *pool, RPMessage_MsgHeader | |||
292 | } | 321 | } |
293 | } | 322 | } |
294 | 323 | ||
295 | if (obj == NULL) | 324 | if (NULL != obj) |
296 | { | ||
297 | return -1; | ||
298 | } | ||
299 | |||
300 | if(obj->recv_buffer) | ||
301 | { | ||
302 | memcpy(obj->recv_buffer, msg->payload, msg->dataLen); | ||
303 | obj->recv_buffer = NULL; | ||
304 | obj->payload.len = msg->dataLen; | ||
305 | obj->payload.src = msg->srcAddr; | ||
306 | obj->payload.procId = msg->srcProcId; | ||
307 | |||
308 | if (NULL != gIpcObject.initPrms.newMsgFxn) | ||
309 | { | ||
310 | gIpcObject.initPrms.newMsgFxn(msg->srcAddr, msg->srcProcId); | ||
311 | } | ||
312 | |||
313 | if (NULL != pOsalPrms->unlockMutex) | ||
314 | { | ||
315 | pOsalPrms->unlockMutex(obj->semHandle); | ||
316 | } | ||
317 | } | ||
318 | else | ||
319 | { | 325 | { |
320 | /* Allocate a buffer to copy the payload: */ | 326 | if(NULL != obj->recv_buffer) |
321 | size = msg->dataLen + sizeof(RPMessage_MsgElem); | ||
322 | |||
323 | /* HeapBuf_alloc() is non-blocking, so needs protection: */ | ||
324 | key = pOsalPrms->disableAllIntr(); | ||
325 | payload = (RPMessage_MsgElem *)IpcUtils_HeapAlloc(&obj->heap, size, 0); | ||
326 | |||
327 | if (payload != NULL) | ||
328 | { | 327 | { |
329 | memcpy(payload->data, msg->payload, msg->dataLen); | 328 | memcpy(obj->recv_buffer, msg->payload, msg->dataLen); |
330 | payload->len = msg->dataLen; | 329 | obj->recv_buffer = NULL; |
331 | payload->src = msg->srcAddr; | 330 | obj->payload.len = msg->dataLen; |
332 | payload->procId = msg->srcProcId; | 331 | obj->payload.src = msg->srcAddr; |
333 | 332 | obj->payload.procId = msg->srcProcId; | |
334 | IpcUtils_Qput(&obj->queue, &payload->elem, (void *)payload); | ||
335 | |||
336 | pOsalPrms->restoreAllIntr(key); | ||
337 | 333 | ||
338 | if (NULL != gIpcObject.initPrms.newMsgFxn) | 334 | if (NULL != gIpcObject.initPrms.newMsgFxn) |
339 | { | 335 | { |
@@ -347,8 +343,39 @@ static int32_t RPMessage_enqueMsg(RPMessage_EndptPool *pool, RPMessage_MsgHeader | |||
347 | } | 343 | } |
348 | else | 344 | else |
349 | { | 345 | { |
350 | pOsalPrms->restoreAllIntr(key); | 346 | /* Allocate a buffer to copy the payload: */ |
351 | status = -1; | 347 | size = msg->dataLen + sizeof(RPMessage_MsgElem); |
348 | |||
349 | /* HeapBuf_alloc() is non-blocking, so needs protection: */ | ||
350 | key = pOsalPrms->disableAllIntr(); | ||
351 | payload = (RPMessage_MsgElem *)IpcUtils_HeapAlloc(&obj->heap, size, 0); | ||
352 | |||
353 | if (payload != NULL) | ||
354 | { | ||
355 | memcpy(payload->data, msg->payload, msg->dataLen); | ||
356 | payload->len = msg->dataLen; | ||
357 | payload->src = msg->srcAddr; | ||
358 | payload->procId = msg->srcProcId; | ||
359 | |||
360 | IpcUtils_Qput(&obj->queue, &payload->elem, (void *)payload); | ||
361 | |||
362 | pOsalPrms->restoreAllIntr(key); | ||
363 | |||
364 | if (NULL != gIpcObject.initPrms.newMsgFxn) | ||
365 | { | ||
366 | gIpcObject.initPrms.newMsgFxn(msg->srcAddr, msg->srcProcId); | ||
367 | } | ||
368 | |||
369 | if (NULL != pOsalPrms->unlockMutex) | ||
370 | { | ||
371 | pOsalPrms->unlockMutex(obj->semHandle); | ||
372 | } | ||
373 | } | ||
374 | else | ||
375 | { | ||
376 | pOsalPrms->restoreAllIntr(key); | ||
377 | status = IPC_EFAIL; | ||
378 | } | ||
352 | } | 379 | } |
353 | } | 380 | } |
354 | 381 | ||
@@ -364,7 +391,7 @@ static void RPMessage_swiLinuxFxn(uintptr_t arg0, uintptr_t arg1) | |||
364 | RPMessage_MsgHeader *msg; | 391 | RPMessage_MsgHeader *msg; |
365 | Int16 token; | 392 | Int16 token; |
366 | int32_t len; | 393 | int32_t len; |
367 | bool usedBufAdded = false; | 394 | uint8_t usedBufAdded = FALSE; |
368 | 395 | ||
369 | /* Process all available buffers: */ | 396 | /* Process all available buffers: */ |
370 | while ((token = Virtio_getAvailBuf(cbdata->vq, (void **)&msg, &len)) >= 0) | 397 | while ((token = Virtio_getAvailBuf(cbdata->vq, (void **)&msg, &len)) >= 0) |
@@ -373,10 +400,10 @@ static void RPMessage_swiLinuxFxn(uintptr_t arg0, uintptr_t arg1) | |||
373 | RPMessage_enqueMsg(cbdata->pool, msg); | 400 | RPMessage_enqueMsg(cbdata->pool, msg); |
374 | 401 | ||
375 | Virtio_addUsedBuf(cbdata->vq, token, MSGBUFFERSIZE); | 402 | Virtio_addUsedBuf(cbdata->vq, token, MSGBUFFERSIZE); |
376 | usedBufAdded = true; | 403 | usedBufAdded = TRUE; |
377 | } | 404 | } |
378 | 405 | ||
379 | if (usedBufAdded) | 406 | if (TRUE == usedBufAdded) |
380 | { | 407 | { |
381 | /* Tell host we've processed the buffers: */ | 408 | /* Tell host we've processed the buffers: */ |
382 | Virtio_kick(cbdata->vq); | 409 | Virtio_kick(cbdata->vq); |
@@ -390,7 +417,6 @@ static void RPMessage_swiFxn(uintptr_t arg0, uintptr_t arg1) | |||
390 | { | 417 | { |
391 | RPMessage_CallbackData *cbdata = (RPMessage_CallbackData*)arg0; | 418 | RPMessage_CallbackData *cbdata = (RPMessage_CallbackData*)arg0; |
392 | RPMessage_MsgHeader *msg; | 419 | RPMessage_MsgHeader *msg; |
393 | bool usedBufAdded = false; | ||
394 | 420 | ||
395 | /* Process all available buffers: */ | 421 | /* Process all available buffers: */ |
396 | while ((msg = (RPMessage_MsgHeader *) Virtio_getUsedBuf(cbdata->vq)) != NULL) | 422 | while ((msg = (RPMessage_MsgHeader *) Virtio_getUsedBuf(cbdata->vq)) != NULL) |
@@ -399,13 +425,6 @@ static void RPMessage_swiFxn(uintptr_t arg0, uintptr_t arg1) | |||
399 | RPMessage_enqueMsg(cbdata->pool, msg); | 425 | RPMessage_enqueMsg(cbdata->pool, msg); |
400 | 426 | ||
401 | Virtio_addAvailBuf(cbdata->vq, msg); | 427 | Virtio_addAvailBuf(cbdata->vq, msg); |
402 | usedBufAdded = false; | ||
403 | } | ||
404 | |||
405 | if (usedBufAdded) | ||
406 | { | ||
407 | /* Tell host we've processed the buffers: */ | ||
408 | Virtio_kick(cbdata->vq); | ||
409 | } | 428 | } |
410 | } | 429 | } |
411 | 430 | ||
@@ -416,7 +435,7 @@ static void virtio_callback(uint32_t* priv) | |||
416 | { | 435 | { |
417 | RPMessage_CallbackData *cbdata = (RPMessage_CallbackData*)priv; | 436 | RPMessage_CallbackData *cbdata = (RPMessage_CallbackData*)priv; |
418 | 437 | ||
419 | if (cbdata) | 438 | if (NULL != cbdata) |
420 | { | 439 | { |
421 | gIpcObject.initPrms.osalPrms.postHIsr(&cbdata->swi); | 440 | gIpcObject.initPrms.osalPrms.postHIsr(&cbdata->swi); |
422 | } | 441 | } |
@@ -433,7 +452,7 @@ int32_t RPMessage_announce(uint32_t remoteProcId, uint32_t endPt, const char* na | |||
433 | Virtio_Handle vq; | 452 | Virtio_Handle vq; |
434 | uint32_t c; | 453 | uint32_t c; |
435 | uint32_t procId; | 454 | uint32_t procId; |
436 | int32_t status = IPC_EFAIL; | 455 | int32_t status = IPC_SOK; |
437 | uint32_t namelen; | 456 | uint32_t namelen; |
438 | 457 | ||
439 | #if DEBUG_PRINT | 458 | #if DEBUG_PRINT |
@@ -444,46 +463,47 @@ int32_t RPMessage_announce(uint32_t remoteProcId, uint32_t endPt, const char* na | |||
444 | namelen = strlen(name); | 463 | namelen = strlen(name); |
445 | if(namelen >= SERVICENAMELEN || namelen == 0) | 464 | if(namelen >= SERVICENAMELEN || namelen == 0) |
446 | { | 465 | { |
447 | return IPC_EFAIL; | 466 | status = IPC_EFAIL; |
448 | } | 467 | } |
449 | 468 | ||
450 | msg.ctrl.type = CNTRLMSG_ANNOUNCE; | 469 | if(IPC_EFAIL != status) |
451 | msg.endPt = endPt; | ||
452 | strncpy(msg.name, name, SERVICENAMELEN-1); | ||
453 | msg.name[SERVICENAMELEN-1] = '\0'; | ||
454 | |||
455 | if(remoteProcId == RPMESSAGE_ALL) | ||
456 | { | 470 | { |
457 | for(c = 0; c < module.numCallbacks; c++) | 471 | msg.ctrl.type = CNTRLMSG_ANNOUNCE; |
472 | msg.endPt = endPt; | ||
473 | strncpy(msg.name, name, SERVICENAMELEN-1); | ||
474 | msg.name[SERVICENAMELEN-1] = '\0'; | ||
475 | |||
476 | if(remoteProcId == RPMESSAGE_ALL) | ||
458 | { | 477 | { |
459 | /* Find callback for RX VQs that have matching pool. */ | 478 | for(c = 0; c < module.numCallbacks; c++) |
460 | if(module.VQ_callbacks[c].pool == pool) | ||
461 | { | 479 | { |
462 | vq = module.VQ_callbacks[c].vq; | 480 | /* Find callback for RX VQs that have matching pool. */ |
463 | procId = Virtio_getProcId(vq); | 481 | if(module.VQ_callbacks[c].pool == pool) |
482 | { | ||
483 | vq = module.VQ_callbacks[c].vq; | ||
484 | procId = Virtio_getProcId(vq); | ||
464 | #if DEBUG_PRINT | 485 | #if DEBUG_PRINT |
465 | SystemP_printf("RPMessage_announce.....c%d ProcId %d\n", c, procId); | 486 | SystemP_printf("RPMessage_announce.....c%d ProcId %d\n", c, procId); |
466 | #endif | 487 | #endif |
467 | status = RPMessage_send(NULL, procId, IPC_CTRL_ENDPOINT_ID, | 488 | status = RPMessage_send(NULL, procId, IPC_CTRL_ENDPOINT_ID, |
468 | IPC_CTRL_ENDPOINT_ID, | 489 | IPC_CTRL_ENDPOINT_ID, &msg, sizeof(msg)); |
469 | &msg, sizeof(msg)); | 490 | if (status != IPC_SOK) |
470 | if (status != IPC_SOK) | 491 | { |
471 | { | 492 | SystemP_printf("RPMessage_announce.....failed to send c %d (%s)\n", c, Ipc_mpGetName(procId)); |
472 | SystemP_printf("RPMessage_announce.....failed to send c %d (%s)\n", c, Ipc_mpGetName(procId)); | 493 | /* even if failed to annouce to one CPU continue to other CPUs */ |
473 | /* even if failed to annouce to one CPU continue to other CPUs */ | 494 | continue; |
474 | continue; | 495 | } |
475 | } | 496 | } |
476 | } | 497 | } |
477 | } | 498 | } |
478 | } | 499 | else |
479 | else | ||
480 | { | ||
481 | status = RPMessage_send(NULL, remoteProcId, IPC_CTRL_ENDPOINT_ID, | ||
482 | IPC_CTRL_ENDPOINT_ID, | ||
483 | &msg, sizeof(msg)); | ||
484 | if (status != IPC_SOK) | ||
485 | { | 500 | { |
486 | SystemP_printf("RPMessage_announce.....failed to send\n"); | 501 | status = RPMessage_send(NULL, remoteProcId, IPC_CTRL_ENDPOINT_ID, |
502 | IPC_CTRL_ENDPOINT_ID, &msg, sizeof(msg)); | ||
503 | if (status != IPC_SOK) | ||
504 | { | ||
505 | SystemP_printf("RPMessage_announce.....failed to send\n"); | ||
506 | } | ||
487 | } | 507 | } |
488 | } | 508 | } |
489 | 509 | ||
@@ -525,50 +545,56 @@ static void RPMessage_processAnnounceMsg(RPMessage_Announcement *amsg, uint32_t | |||
525 | 545 | ||
526 | /* Save the annoucement for future calls to */ | 546 | /* Save the annoucement for future calls to */ |
527 | /* RPMessage_peerIsReady(). */ | 547 | /* RPMessage_peerIsReady(). */ |
528 | p = &module.nameEntry[module.nameEntryCnt++]; | 548 | if(module.nameEntryCnt == IPC_MAX_PROCS-1) |
529 | if(p == NULL) | ||
530 | { | 549 | { |
531 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); | 550 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); |
532 | SystemP_printf("RPMessage_processAnnounceMsg : failed to alloc nameEntry\n"); | 551 | SystemP_printf("RPMessage_processAnnounceMsg : all remote core done\n"); |
533 | return; | 552 | rtnVal = IPC_EFAIL; |
534 | } | 553 | } |
535 | p->endPt = amsg->endPt; | 554 | |
536 | p->procId = procId; | 555 | if(rtnVal != IPC_EFAIL) |
537 | strncpy(p->name, amsg->name, SERVICENAMELEN); | ||
538 | p->name[SERVICENAMELEN-1] = '\0'; | ||
539 | |||
540 | /* No interrupt / SWI protection, required here again. | ||
541 | We are already in SWI protected region */ | ||
542 | IpcUtils_Qput(&module.announcedEndpts, &p->elem, (void *)p); | ||
543 | |||
544 | /* Wakeup all the tasks that are waiting on the */ | ||
545 | /* announced name. */ | ||
546 | if (!IpcUtils_QisEmpty(&module.waitingTasks)) | ||
547 | { | 556 | { |
557 | p = &module.nameEntry[module.nameEntryCnt]; | ||
558 | p->endPt = amsg->endPt; | ||
559 | p->procId = procId; | ||
560 | strncpy(p->name, amsg->name, SERVICENAMELEN-1); | ||
561 | p->name[SERVICENAMELEN-1] = '\0'; | ||
562 | module.nameEntryCnt++; | ||
563 | |||
548 | /* No interrupt / SWI protection, required here again. | 564 | /* No interrupt / SWI protection, required here again. |
549 | We are already in SWI protected region */ | 565 | We are already in SWI protected region */ |
550 | elem = head = (IpcUtils_QElem *) IpcUtils_QgetHeadNode(&module.waitingTasks); | 566 | IpcUtils_Qput(&module.announcedEndpts, &p->elem, (void *)p); |
551 | do | 567 | |
568 | /* Wakeup all the tasks that are waiting on the */ | ||
569 | /* announced name. */ | ||
570 | if (!IpcUtils_QisEmpty(&module.waitingTasks)) | ||
552 | { | 571 | { |
553 | w = (RPMessage_Waiter*)elem; | 572 | /* No interrupt / SWI protection, required here again. |
554 | if(strncmp(w->name, amsg->name, SERVICENAMELEN) == 0 && | 573 | We are already in SWI protected region */ |
555 | (w->procId == procId || w->procId == RPMESSAGE_ANY)) | 574 | elem = head = (IpcUtils_QElem *) IpcUtils_QgetHeadNode(&module.waitingTasks); |
575 | do | ||
556 | { | 576 | { |
557 | /* Update the waiter's entry with actual */ | 577 | w = (RPMessage_Waiter*)elem; |
558 | /* announcement values. */ | 578 | if( (NULL != w) && |
559 | w->procId = procId; | 579 | (strncmp(w->name, amsg->name, SERVICENAMELEN-1) == 0) && |
560 | w->endPt = amsg->endPt; | 580 | (w->procId == procId || w->procId == RPMESSAGE_ANY)) |
581 | { | ||
582 | /* Update the waiter's entry with actual */ | ||
583 | /* announcement values. */ | ||
584 | w->procId = procId; | ||
585 | w->endPt = amsg->endPt; | ||
561 | #if DEBUG_PRINT | 586 | #if DEBUG_PRINT |
562 | SystemP_printf("RPMessage_processAnnounceMsg :Semphore Handle 0x%x\n", | 587 | SystemP_printf("RPMessage_processAnnounceMsg :Semphore Handle 0x%x\n", |
563 | (uint32_t)w->semHandle); | 588 | (uint32_t)w->semHandle); |
564 | #endif | 589 | #endif |
565 | 590 | ||
566 | pOsalPrms->unlockMutex(w->semHandle); | 591 | pOsalPrms->unlockMutex(w->semHandle); |
567 | } | 592 | } |
568 | elem = (IpcUtils_QElem *) IpcUtils_Qnext(elem); | 593 | elem = (IpcUtils_QElem *) IpcUtils_Qnext(elem); |
569 | } while (elem != head); | 594 | } while (elem != head); |
595 | } | ||
596 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); | ||
570 | } | 597 | } |
571 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); | ||
572 | } | 598 | } |
573 | } | 599 | } |
574 | 600 | ||
@@ -579,23 +605,24 @@ static void RPMessage_processAnnounceMsg(RPMessage_Announcement *amsg, uint32_t | |||
579 | * received. | 605 | * received. |
580 | * non-blocking query - must be protected by caller | 606 | * non-blocking query - must be protected by caller |
581 | */ | 607 | */ |
582 | static bool RPMessage_lookupName(uint32_t procId, const char* name, uint32_t *remoteProcId, | 608 | static uint8_t RPMessage_lookupName(uint32_t procId, const char* name, uint32_t *remoteProcId, |
583 | uint32_t *remoteEndPt) | 609 | uint32_t *remoteEndPt) |
584 | { | 610 | { |
585 | bool found = false; | 611 | uint8_t found = FALSE; |
586 | RPMessage_NameEntry *p; | 612 | RPMessage_NameEntry *p; |
587 | IpcUtils_QElem *elem, *head; | 613 | IpcUtils_QElem *elem, *head; |
588 | 614 | ||
589 | if (!IpcUtils_QisEmpty(&module.announcedEndpts)) | 615 | if (FALSE == IpcUtils_QisEmpty(&module.announcedEndpts)) |
590 | { | 616 | { |
591 | elem = head = (IpcUtils_QElem *) IpcUtils_QgetHeadNode(&module.announcedEndpts); | 617 | elem = head = (IpcUtils_QElem *) IpcUtils_QgetHeadNode(&module.announcedEndpts); |
592 | do | 618 | do |
593 | { | 619 | { |
594 | p = (RPMessage_NameEntry*)elem; | 620 | p = (RPMessage_NameEntry*)elem; |
595 | if(strncmp(p->name, name, SERVICENAMELEN) == 0 && | 621 | if( (NULL != p) && |
596 | (p->procId == procId || procId == RPMESSAGE_ANY)) | 622 | (strncmp(p->name, name, SERVICENAMELEN) == 0) && |
623 | (p->procId == procId || procId == RPMESSAGE_ANY)) | ||
597 | { | 624 | { |
598 | found = true; | 625 | found = TRUE; |
599 | *remoteEndPt = p->endPt; | 626 | *remoteEndPt = p->endPt; |
600 | *remoteProcId = p->procId; | 627 | *remoteProcId = p->procId; |
601 | #if DEBUG_PRINT | 628 | #if DEBUG_PRINT |
@@ -617,12 +644,12 @@ int32_t RPMessage_getRemoteEndPt(uint32_t selfProcId, const char* name, uint32_t | |||
617 | uint32_t *remoteEndPt, uint32_t timeout) | 644 | uint32_t *remoteEndPt, uint32_t timeout) |
618 | { | 645 | { |
619 | int32_t key; | 646 | int32_t key; |
620 | bool lookupStatus; | 647 | uint8_t lookupStatus = FALSE; |
621 | int32_t rtnVal = IPC_SOK; | 648 | int32_t rtnVal = IPC_SOK; |
622 | void *semHandle; | 649 | void *semHandle; |
623 | RPMessage_Waiter taskWaiter; | 650 | RPMessage_Waiter taskWaiter; |
624 | uint32_t namelen; | 651 | uint32_t namelen; |
625 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; | 652 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; |
626 | 653 | ||
627 | namelen = strlen(name); | 654 | namelen = strlen(name); |
628 | if ((namelen >= SERVICENAMELEN || namelen == 0)) | 655 | if ((namelen >= SERVICENAMELEN || namelen == 0)) |
@@ -661,14 +688,14 @@ int32_t RPMessage_getRemoteEndPt(uint32_t selfProcId, const char* name, uint32_t | |||
661 | key = pOsalPrms->disableAllIntr(); | 688 | key = pOsalPrms->disableAllIntr(); |
662 | lookupStatus = RPMessage_lookupName(selfProcId, name, | 689 | lookupStatus = RPMessage_lookupName(selfProcId, name, |
663 | remoteProcId, remoteEndPt); | 690 | remoteProcId, remoteEndPt); |
664 | if(!lookupStatus) | 691 | if(FALSE == lookupStatus) |
665 | { | 692 | { |
666 | IpcUtils_Qput(&module.waitingTasks, &taskWaiter.elem, | 693 | IpcUtils_Qput(&module.waitingTasks, &taskWaiter.elem, |
667 | (void *)&taskWaiter); | 694 | (void *)&taskWaiter); |
668 | } | 695 | } |
669 | pOsalPrms->restoreAllIntr(key); | 696 | pOsalPrms->restoreAllIntr(key); |
670 | 697 | ||
671 | if(!lookupStatus) | 698 | if(FALSE == lookupStatus) |
672 | { | 699 | { |
673 | rtnVal = pOsalPrms->lockMutex(semHandle, timeout); | 700 | rtnVal = pOsalPrms->lockMutex(semHandle, timeout); |
674 | if(rtnVal == IPC_SOK) | 701 | if(rtnVal == IPC_SOK) |
@@ -710,7 +737,7 @@ static void RPMessage_checkForMessages(RPMessage_EndptPool *pool) | |||
710 | /* Find callback for RX VQs that have matching pool. */ | 737 | /* Find callback for RX VQs that have matching pool. */ |
711 | if(module.VQ_callbacks[c].pool == pool) | 738 | if(module.VQ_callbacks[c].pool == pool) |
712 | { | 739 | { |
713 | if(Virtio_isReady(module.VQ_callbacks[c].vq)) | 740 | if(TRUE == Virtio_isReady(module.VQ_callbacks[c].vq)) |
714 | { | 741 | { |
715 | key = gIpcObject.initPrms.osalPrms.lockHIsrGate(module.gateSwi); | 742 | key = gIpcObject.initPrms.osalPrms.lockHIsrGate(module.gateSwi); |
716 | RPMessage_swiFxn((uintptr_t)&module.VQ_callbacks[c], 0); | 743 | RPMessage_swiFxn((uintptr_t)&module.VQ_callbacks[c], 0); |
@@ -734,11 +761,13 @@ static void RPMessage_ctrlMsgTask(uint32_t* arg0, uint32_t* arg1) | |||
734 | RPMessage_Object *obj = (RPMessage_Object *)arg0; | 761 | RPMessage_Object *obj = (RPMessage_Object *)arg0; |
735 | uint32_t remoteEndpoint; | 762 | uint32_t remoteEndpoint; |
736 | uint32_t remoteProcId; | 763 | uint32_t remoteProcId; |
737 | uint32_t status; | 764 | int32_t status; |
738 | uint16_t len = MSGBUFFERSIZE; | 765 | uint16_t len = MSGBUFFERSIZE; |
739 | uint32_t buffer[MSGBUFFERSIZE/sizeof(uint32_t)]; /* alignment */ | 766 | uint32_t buffer[MSGBUFFERSIZE/sizeof(uint32_t)]; /* alignment */ |
740 | RPMessage_Announcement *amsg = (RPMessage_Announcement*)&buffer; | 767 | RPMessage_Announcement *amsg = (RPMessage_Announcement*)&buffer; |
741 | 768 | ||
769 | UNUSED(arg1); | ||
770 | |||
742 | while(1) | 771 | while(1) |
743 | { | 772 | { |
744 | status = RPMessage_recv((RPMessage_Handle)obj, (void*)amsg, &len, | 773 | status = RPMessage_recv((RPMessage_Handle)obj, (void*)amsg, &len, |
@@ -749,7 +778,7 @@ static void RPMessage_ctrlMsgTask(uint32_t* arg0, uint32_t* arg1) | |||
749 | SystemP_printf("RPMessage_recv failed with code %d for endPt %d\n" | 778 | SystemP_printf("RPMessage_recv failed with code %d for endPt %d\n" |
750 | "RPMessage_ctrlMsgTask terminating early", | 779 | "RPMessage_ctrlMsgTask terminating early", |
751 | status, obj->endPt); | 780 | status, obj->endPt); |
752 | return; | 781 | break; |
753 | } | 782 | } |
754 | 783 | ||
755 | if(amsg->ctrl.type == CNTRLMSG_ANNOUNCE) | 784 | if(amsg->ctrl.type == CNTRLMSG_ANNOUNCE) |
@@ -788,21 +817,22 @@ static int32_t RPMessage_startCtrlMsgTask(RPMessage_Params *params) | |||
788 | */ | 817 | */ |
789 | params->requestedEndpt = IPC_CTRL_ENDPOINT_ID; | 818 | params->requestedEndpt = IPC_CTRL_ENDPOINT_ID; |
790 | obj = RPMessage_rawCreate(params, &module.globalPool, &myEndpoint); | 819 | obj = RPMessage_rawCreate(params, &module.globalPool, &myEndpoint); |
791 | if(!obj) | 820 | if(NULL != obj) |
792 | { | 821 | { |
793 | SystemP_printf("Failed to create control endpoint.\n"); | 822 | TaskP_Params_init(&tparams); |
794 | retVal = IPC_EFAIL; | 823 | tparams.priority = 10; |
795 | return retVal; | 824 | tparams.arg0 = (uint32_t*)obj; |
825 | tparams.stacksize = params->stackSize; | ||
826 | tparams.stack = params->stackBuffer; | ||
827 | tskHandle = TaskP_create((void *) RPMessage_ctrlMsgTask, &tparams); | ||
828 | if(tskHandle == NULL) | ||
829 | { | ||
830 | retVal = IPC_EFAIL; | ||
831 | } | ||
796 | } | 832 | } |
797 | 833 | else | |
798 | TaskP_Params_init(&tparams); | ||
799 | tparams.priority = 10; | ||
800 | tparams.arg0 = (uint32_t*)obj; | ||
801 | tparams.stacksize = params->stackSize; | ||
802 | tparams.stack = params->stackBuffer; | ||
803 | tskHandle = TaskP_create((void *) RPMessage_ctrlMsgTask, &tparams); | ||
804 | if(tskHandle == NULL) | ||
805 | { | 834 | { |
835 | SystemP_printf("Failed to create control endpoint.\n"); | ||
806 | retVal = IPC_EFAIL; | 836 | retVal = IPC_EFAIL; |
807 | } | 837 | } |
808 | 838 | ||
@@ -817,108 +847,100 @@ static RPMessage_Object* RPMessage_rawCreate( | |||
817 | uint32_t *endPt) | 847 | uint32_t *endPt) |
818 | { | 848 | { |
819 | RPMessage_Object *obj = NULL; | 849 | RPMessage_Object *obj = NULL; |
820 | bool found = false; | 850 | uint8_t found = FALSE; |
821 | int32_t i, rtnVal; | 851 | int32_t i; |
822 | uint16_t queueIndex = 0; | 852 | uint16_t queueIndex = 0; |
823 | int32_t key; | 853 | int32_t key; |
824 | uint32_t objSize = RPMessage_getObjMemRequired(); | 854 | uint32_t objSize = RPMessage_getObjMemRequired(); |
825 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; | 855 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; |
856 | int32_t status = IPC_SOK; | ||
826 | 857 | ||
827 | /* Returning NULL, here Fix ME TBD | 858 | /* Returning NULL, here Fix ME TBD |
828 | This function error checks would require an overhaul */ | 859 | This function error checks would require an overhaul */ |
829 | if (NULL != pOsalPrms) | 860 | if ( (NULL == pOsalPrms) || |
830 | { | 861 | (NULL == pOsalPrms->lockHIsrGate) || |
831 | if ((NULL == pOsalPrms->lockHIsrGate) || | 862 | (NULL == pOsalPrms->unLockHIsrGate)) |
832 | (NULL == pOsalPrms->unLockHIsrGate)) | ||
833 | { | ||
834 | return NULL; | ||
835 | } | ||
836 | } | ||
837 | else | ||
838 | { | 863 | { |
839 | return NULL; | 864 | status = IPC_EFAIL; |
840 | } | 865 | } |
841 | key = pOsalPrms->lockHIsrGate(module.gateSwi); | ||
842 | 866 | ||
843 | /* Allocate the endPt */ | 867 | if(IPC_SOK == status) |
844 | if (params->requestedEndpt == RPMESSAGE_ANY) | ||
845 | { | 868 | { |
846 | /* Search the array for a free slot above reserved: */ | 869 | key = pOsalPrms->lockHIsrGate(module.gateSwi); |
847 | for (i = RPMessage_MAX_RESERVED_ENDPOINT + 1; | 870 | |
848 | (i < MAXENDPOINTS) && (found == false); i++) | 871 | /* Allocate the endPt */ |
872 | if (params->requestedEndpt == RPMESSAGE_ANY) | ||
849 | { | 873 | { |
850 | if (RPMessage_lookupEndpt(pool, i) == NULL) | 874 | /* Search the array for a free slot above reserved: */ |
875 | for (i = RPMessage_MAX_RESERVED_ENDPOINT + 1; | ||
876 | (i < MAXENDPOINTS) && (found == 0U); i++) | ||
851 | { | 877 | { |
852 | queueIndex = i; | 878 | if (RPMessage_lookupEndpt(pool, i) == NULL) |
853 | found = true; | 879 | { |
854 | break; | 880 | queueIndex = i; |
881 | found = TRUE; | ||
882 | break; | ||
883 | } | ||
884 | } | ||
885 | } | ||
886 | else if (params->requestedEndpt <= RPMessage_MAX_RESERVED_ENDPOINT) | ||
887 | { | ||
888 | if (RPMessage_lookupEndpt(pool, params->requestedEndpt) == NULL) | ||
889 | { | ||
890 | queueIndex = params->requestedEndpt; | ||
891 | found = TRUE; | ||
855 | } | 892 | } |
856 | } | 893 | } |
857 | } | ||
858 | else if (params->requestedEndpt <= RPMessage_MAX_RESERVED_ENDPOINT) | ||
859 | { | ||
860 | if (RPMessage_lookupEndpt(pool, params->requestedEndpt) == NULL) | ||
861 | { | ||
862 | queueIndex = params->requestedEndpt; | ||
863 | found = true; | ||
864 | } | ||
865 | } | 894 | } |
866 | 895 | ||
867 | if (!found) | 896 | if ((FALSE == found) || |
897 | (params->numBufs < 1) || | ||
898 | (params->bufSize < ((params->numBufs * MSGBUFFERSIZE) + objSize))) | ||
868 | { | 899 | { |
869 | return NULL; | 900 | status = IPC_EFAIL; |
870 | } | 901 | } |
871 | 902 | ||
872 | if (params->numBufs < 1) | 903 | if(IPC_SOK == status) |
873 | { | 904 | { |
874 | return NULL; | 905 | obj = (RPMessage_Object *) params->buf; |
875 | } | 906 | if (NULL != obj) |
907 | { | ||
908 | obj->heapParams.blockSize = MSGBUFFERSIZE; | ||
909 | obj->heapParams.numBlocks = params->numBufs; | ||
910 | obj->heapParams.buf = (void*)((uintptr_t)params->buf + objSize); | ||
911 | obj->heapParams.bufSize = params->bufSize - objSize ; | ||
912 | obj->heapParams.align = HEAPALIGNMENT; | ||
913 | status = IpcUtils_HeapCreate(&obj->heap, &obj->heapParams); | ||
914 | if (IPC_SOK == status) | ||
915 | { | ||
916 | /* Allocate a semaphore to signal when messages received: */ | ||
917 | if (NULL != pOsalPrms->createMutex) | ||
918 | { | ||
919 | obj->semHandle = pOsalPrms->createMutex(); | ||
920 | } | ||
876 | 921 | ||
877 | /* Check if memory provided is big enough */ | 922 | /* Create our queue of to be received messages: */ |
878 | if(params->bufSize < ((params->numBufs * MSGBUFFERSIZE) + objSize)) | 923 | IpcUtils_Qcreate(&obj->queue); |
879 | { | ||
880 | return NULL; | ||
881 | } | ||
882 | 924 | ||
883 | obj = (RPMessage_Object *) params->buf; | 925 | /* Store our endPt, and object: */ |
884 | if (obj == NULL) | 926 | obj->endPt = queueIndex; |
885 | { | 927 | RPMessage_assignEndpt(pool, queueIndex, obj); |
886 | return NULL; | ||
887 | } | ||
888 | 928 | ||
889 | obj->heapParams.blockSize = MSGBUFFERSIZE; | 929 | /* See RPMessage_unblock() */ |
890 | obj->heapParams.numBlocks = params->numBufs; | 930 | obj->unblocked = FALSE; |
891 | obj->heapParams.buf = (void*)((uintptr_t)params->buf + objSize); | 931 | obj->pool = pool; |
892 | obj->heapParams.bufSize = params->bufSize - objSize ; | 932 | obj->recv_buffer = NULL; |
893 | obj->heapParams.align = HEAPALIGNMENT; | 933 | *endPt = queueIndex; |
894 | rtnVal = IpcUtils_HeapCreate(&obj->heap, &obj->heapParams); | 934 | } |
895 | if (IPC_SOK != rtnVal) | 935 | else |
896 | { | 936 | { |
897 | /* failed to create heap Fix ME*/ | 937 | obj = NULL; |
898 | return NULL; | 938 | } |
899 | } | ||
900 | 939 | ||
901 | /* Allocate a semaphore to signal when messages received: */ | 940 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); |
902 | if (NULL != pOsalPrms->createMutex) | 941 | } |
903 | { | ||
904 | obj->semHandle = pOsalPrms->createMutex(); | ||
905 | } | 942 | } |
906 | 943 | ||
907 | /* Create our queue of to be received messages: */ | ||
908 | IpcUtils_Qcreate(&obj->queue); | ||
909 | |||
910 | /* Store our endPt, and object: */ | ||
911 | obj->endPt = queueIndex; | ||
912 | RPMessage_assignEndpt(pool, queueIndex, obj); | ||
913 | |||
914 | /* See RPMessage_unblock() */ | ||
915 | obj->unblocked = false; | ||
916 | obj->pool = pool; | ||
917 | obj->recv_buffer = NULL; | ||
918 | *endPt = queueIndex; | ||
919 | |||
920 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); | ||
921 | |||
922 | return (obj); | 944 | return (obj); |
923 | } | 945 | } |
924 | 946 | ||
@@ -929,31 +951,34 @@ int32_t RPMessage_lateInit(uint32_t proc) | |||
929 | int32_t retVal = IPC_SOK; | 951 | int32_t retVal = IPC_SOK; |
930 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; | 952 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; |
931 | 953 | ||
932 | if(VirtioIPC_getVirtQueues(VIRTIOIPC_RPMSG, proc, 0, &tx_vqId, &rx_vqId)) | 954 | if(TRUE == VirtioIPC_getVirtQueues(VIRTIOIPC_RPMSG, proc, 0, &tx_vqId, &rx_vqId)) |
933 | { | 955 | { |
934 | uintptr_t arg0; | 956 | uintptr_t arg0; |
935 | c = module.numCallbacks++; | 957 | c = module.numCallbacks; |
958 | module.numCallbacks++; | ||
936 | 959 | ||
937 | /* setup the receiving path */ | 960 | /* setup the receiving path */ |
938 | module.VQ_callbacks[c].pool = &module.globalPool; | 961 | module.VQ_callbacks[c].pool = &module.globalPool; |
939 | module.VQ_callbacks[c].vq = Virtio_getHandle(proc, VIRTIO_RX); | 962 | module.VQ_callbacks[c].vq = Virtio_getHandle(proc, VIRTIO_RX); |
940 | 963 | ||
941 | arg0 = (uintptr_t)&module.VQ_callbacks[c]; | 964 | arg0 = (uintptr_t)&module.VQ_callbacks[c]; |
942 | if (Virtio_isRemoteLinux(proc)) | 965 | if (TRUE == Virtio_isRemoteLinux(proc)) |
943 | { | 966 | { |
944 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, | 967 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, |
945 | &RPMessage_swiLinuxFxn, (void *)arg0); | 968 | &RPMessage_swiLinuxFxn, (void *)arg0); |
946 | } | 969 | } |
947 | else | 970 | else |
948 | { | 971 | { |
949 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, | 972 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, |
950 | &RPMessage_swiFxn, (void *)arg0); | 973 | &RPMessage_swiFxn, (void *)arg0); |
951 | } | 974 | } |
952 | Virtio_setCallback(proc, virtio_callback, (uint32_t *)&module.VQ_callbacks[c]); | 975 | Virtio_setCallback(proc, virtio_callback, (uint32_t *)&module.VQ_callbacks[c]); |
953 | 976 | ||
954 | /* setup the sending path */ | 977 | /* setup the sending path */ |
955 | module.tx_VQs[proc] = Virtio_getHandle(proc, VIRTIO_TX); | 978 | module.tx_VQs[proc] = Virtio_getHandle(proc, VIRTIO_TX); |
956 | } else { | 979 | } |
980 | else | ||
981 | { | ||
957 | retVal = IPC_EFAIL; | 982 | retVal = IPC_EFAIL; |
958 | } | 983 | } |
959 | 984 | ||
@@ -976,82 +1001,82 @@ int32_t RPMessage_init(RPMessage_Params *params) | |||
976 | int32_t retVal = IPC_SOK; | 1001 | int32_t retVal = IPC_SOK; |
977 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; | 1002 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; |
978 | 1003 | ||
979 | if(!is_aligned(params->buf,HEAPALIGNMENT)) | ||
980 | { | ||
981 | SystemP_printf("RPMessage_init : Memory alignment failed\n"); | ||
982 | return IPC_EFAIL; | ||
983 | } | ||
984 | |||
985 | /* Clear module state */ | 1004 | /* Clear module state */ |
986 | memset(&module, 0, sizeof(module)); | 1005 | memset(&module, 0, sizeof(module)); |
987 | 1006 | ||
988 | /* Gate to protect module object and lists: */ | 1007 | /* Gate to protect module object and lists: */ |
989 | if ((NULL != pOsalPrms->createHIsrGate) && (NULL != pOsalPrms->createHIsr)) | 1008 | if ((1U == is_aligned(params->buf,HEAPALIGNMENT)) && |
1009 | (NULL != pOsalPrms->createHIsrGate) && | ||
1010 | (NULL != pOsalPrms->createHIsr)) | ||
990 | { | 1011 | { |
991 | module.gateSwi = pOsalPrms->createHIsrGate(); | 1012 | module.gateSwi = pOsalPrms->createHIsrGate(); |
992 | } | 1013 | } |
993 | else | 1014 | else |
994 | { | 1015 | { |
995 | retVal = IPC_EFAIL; | 1016 | retVal = IPC_EFAIL; |
1017 | SystemP_printf("RPMessage_init : Memory misalignment or invalid HIstGate fxn\n"); | ||
996 | } | 1018 | } |
997 | 1019 | ||
998 | IpcUtils_Qcreate(&module.announcedEndpts); | 1020 | if( retVal != IPC_EFAIL) |
999 | IpcUtils_Qcreate(&module.waitingTasks); | 1021 | { |
1022 | IpcUtils_Qcreate(&module.announcedEndpts); | ||
1023 | IpcUtils_Qcreate(&module.waitingTasks); | ||
1000 | 1024 | ||
1001 | #ifndef IPC_EXCLUDE_CTRL_TASKS | 1025 | #ifndef IPC_EXCLUDE_CTRL_TASKS |
1002 | /* Call startCtrlMsgTask() before setting the VQ | 1026 | /* Call startCtrlMsgTask() before setting the VQ |
1003 | * callbacks to avoid dropping control messages. | 1027 | * callbacks to avoid dropping control messages. |
1004 | */ | 1028 | */ |
1005 | retVal = RPMessage_startCtrlMsgTask(params); | 1029 | retVal = RPMessage_startCtrlMsgTask(params); |
1006 | #endif /* IPC_EXCLUDE_CTRL_TASKS */ | 1030 | #endif /* IPC_EXCLUDE_CTRL_TASKS */ |
1007 | 1031 | ||
1008 | /* Connect to the VQs by setting the VQ callbacks and | 1032 | /* Connect to the VQs by setting the VQ callbacks and |
1009 | * creating the assocated SWIs. Once the callbacks | 1033 | * creating the assocated SWIs. Once the callbacks |
1010 | * are installed is it possilbe to drop messages if | 1034 | * are installed is it possilbe to drop messages if |
1011 | * the dest endpoint has not yet been created. | 1035 | * the dest endpoint has not yet been created. |
1012 | */ | 1036 | */ |
1013 | for(p = 0; ((p < /* Ipc_mp_getNumProcessors() */ IPC_MAX_PROCS) && | 1037 | for(p = 0; ((p < IPC_MAX_PROCS) && (IPC_SOK == retVal)); p++) |
1014 | (IPC_SOK == retVal)); p++) | ||
1015 | { | ||
1016 | if(VirtioIPC_getVirtQueues(VIRTIOIPC_RPMSG, p, 0, &tx_vqId, &rx_vqId)) | ||
1017 | { | 1038 | { |
1018 | uintptr_t arg0; | 1039 | if(TRUE == VirtioIPC_getVirtQueues(VIRTIOIPC_RPMSG, p, 0, &tx_vqId, &rx_vqId)) |
1019 | c = module.numCallbacks++; | 1040 | { |
1041 | uintptr_t arg0; | ||
1042 | c = module.numCallbacks; | ||
1043 | module.numCallbacks++; | ||
1020 | 1044 | ||
1021 | /* setup the receiving path */ | 1045 | /* setup the receiving path */ |
1022 | module.VQ_callbacks[c].pool = &module.globalPool; | 1046 | module.VQ_callbacks[c].pool = &module.globalPool; |
1023 | module.VQ_callbacks[c].vq = Virtio_getHandle(p, VIRTIO_RX); | 1047 | module.VQ_callbacks[c].vq = Virtio_getHandle(p, VIRTIO_RX); |
1024 | 1048 | ||
1025 | arg0 = (uintptr_t)&module.VQ_callbacks[c]; | 1049 | arg0 = (uintptr_t)&module.VQ_callbacks[c]; |
1026 | if (Virtio_isRemoteLinux(p)) | 1050 | if (TRUE == Virtio_isRemoteLinux(p)) |
1027 | { | 1051 | { |
1028 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, | 1052 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, |
1029 | &RPMessage_swiLinuxFxn, (void *)arg0); | 1053 | &RPMessage_swiLinuxFxn, (void *)arg0); |
1054 | } | ||
1055 | else | ||
1056 | { | ||
1057 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, | ||
1058 | &RPMessage_swiFxn, (void *)arg0); | ||
1059 | } | ||
1060 | Virtio_setCallback(p, virtio_callback, (uint32_t *)&module.VQ_callbacks[c]); | ||
1061 | |||
1062 | /* setup the sending path */ | ||
1063 | module.tx_VQs[p] = Virtio_getHandle(p, VIRTIO_TX); | ||
1030 | } | 1064 | } |
1031 | else | 1065 | else |
1032 | { | 1066 | { |
1033 | pOsalPrms->createHIsr(&module.VQ_callbacks[c].swi, | 1067 | module.tx_VQs[p] = NULL; |
1034 | &RPMessage_swiFxn, (void *)arg0); | ||
1035 | } | 1068 | } |
1036 | Virtio_setCallback(p, virtio_callback, (uint32_t *)&module.VQ_callbacks[c]); | ||
1037 | |||
1038 | /* setup the sending path */ | ||
1039 | module.tx_VQs[p] = Virtio_getHandle(p, VIRTIO_TX); | ||
1040 | } | ||
1041 | else | ||
1042 | { | ||
1043 | module.tx_VQs[p] = NULL; | ||
1044 | } | 1069 | } |
1045 | } | ||
1046 | 1070 | ||
1047 | #ifndef IPC_EXCLUDE_CTRL_TASKS | 1071 | #ifndef IPC_EXCLUDE_CTRL_TASKS |
1048 | /* | 1072 | /* |
1049 | * At this point, the control end point would not have been created. | 1073 | * At this point, the control end point would not have been created. |
1050 | * Let apps, decide when to process pending messages | 1074 | * Let apps, decide when to process pending messages |
1051 | */ | 1075 | */ |
1052 | RPMessage_checkForMessages(&module.globalPool); | 1076 | RPMessage_checkForMessages(&module.globalPool); |
1053 | 1077 | ||
1054 | #endif /* IPC_EXCLUDE_CTRL_TASKS */ | 1078 | #endif /* IPC_EXCLUDE_CTRL_TASKS */ |
1079 | } | ||
1055 | 1080 | ||
1056 | return retVal; | 1081 | return retVal; |
1057 | } | 1082 | } |
@@ -1071,13 +1096,14 @@ RPMessage_Handle RPMessage_create(RPMessage_Params *params, uint32_t *endPt) | |||
1071 | RPMessageParams_init(params); | 1096 | RPMessageParams_init(params); |
1072 | } | 1097 | } |
1073 | 1098 | ||
1074 | if(!is_aligned(params->buf,HEAPALIGNMENT)) | 1099 | if( 0U == is_aligned(params->buf,HEAPALIGNMENT)) |
1075 | { | 1100 | { |
1076 | SystemP_printf("RPMessage_create : Memory alignment failed\n"); | 1101 | SystemP_printf("RPMessage_create : Memory alignment failed\n"); |
1077 | return (RPMessage_Handle)NULL; | ||
1078 | } | 1102 | } |
1079 | 1103 | else | |
1080 | obj = RPMessage_rawCreate(params, &module.globalPool, endPt); | 1104 | { |
1105 | obj = RPMessage_rawCreate(params, &module.globalPool, endPt); | ||
1106 | } | ||
1081 | 1107 | ||
1082 | return (RPMessage_Handle)obj; | 1108 | return (RPMessage_Handle)obj; |
1083 | } | 1109 | } |
@@ -1136,10 +1162,13 @@ int32_t RPMessage_delete(RPMessage_Handle *handlePtr) | |||
1136 | key = gIpcObject.initPrms.osalPrms.disableAllIntr(); | 1162 | key = gIpcObject.initPrms.osalPrms.disableAllIntr(); |
1137 | 1163 | ||
1138 | /* Free/discard all queued message buffers: */ | 1164 | /* Free/discard all queued message buffers: */ |
1139 | while (!IpcUtils_QisEmpty(&obj->queue)) | 1165 | while (0U == IpcUtils_QisEmpty(&obj->queue)) |
1140 | { | 1166 | { |
1141 | payload = (RPMessage_MsgElem *)IpcUtils_QgetHead(&obj->queue); | 1167 | payload = (RPMessage_MsgElem *)IpcUtils_QgetHead(&obj->queue); |
1142 | IpcUtils_HeapFree(&obj->heap, (void *)payload, MSGBUFFERSIZE); | 1168 | if(NULL != payload) |
1169 | { | ||
1170 | IpcUtils_HeapFree(&obj->heap, (void *)payload, MSGBUFFERSIZE); | ||
1171 | } | ||
1143 | } | 1172 | } |
1144 | 1173 | ||
1145 | gIpcObject.initPrms.osalPrms.restoreAllIntr(key); | 1174 | gIpcObject.initPrms.osalPrms.restoreAllIntr(key); |
@@ -1164,7 +1193,7 @@ int32_t RPMessage_recv(RPMessage_Handle handle, void* data, uint16_t *len, | |||
1164 | int32_t status = IPC_SOK; | 1193 | int32_t status = IPC_SOK; |
1165 | RPMessage_Object *obj = (RPMessage_Object *)handle; | 1194 | RPMessage_Object *obj = (RPMessage_Object *)handle; |
1166 | int32_t semStatus; | 1195 | int32_t semStatus; |
1167 | bool skiplist = false; | 1196 | uint8_t skiplist = FALSE; |
1168 | RPMessage_MsgElem *payload; | 1197 | RPMessage_MsgElem *payload; |
1169 | uint32_t key; | 1198 | uint32_t key; |
1170 | /* Fix ME TBD, skipping the null tests, as this function check's/error | 1199 | /* Fix ME TBD, skipping the null tests, as this function check's/error |
@@ -1172,10 +1201,10 @@ int32_t RPMessage_recv(RPMessage_Handle handle, void* data, uint16_t *len, | |||
1172 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; | 1201 | Ipc_OsalPrms *pOsalPrms = &gIpcObject.initPrms.osalPrms; |
1173 | 1202 | ||
1174 | key = pOsalPrms->lockHIsrGate(module.gateSwi); | 1203 | key = pOsalPrms->lockHIsrGate(module.gateSwi); |
1175 | if (IpcUtils_QisEmpty(&obj->queue)) | 1204 | if (TRUE == IpcUtils_QisEmpty(&obj->queue)) |
1176 | { | 1205 | { |
1177 | obj->recv_buffer = data; | 1206 | obj->recv_buffer = data; |
1178 | skiplist = true; | 1207 | skiplist = TRUE; |
1179 | } | 1208 | } |
1180 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); | 1209 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); |
1181 | 1210 | ||
@@ -1187,11 +1216,11 @@ int32_t RPMessage_recv(RPMessage_Handle handle, void* data, uint16_t *len, | |||
1187 | { | 1216 | { |
1188 | status = IPC_ETIMEOUT; | 1217 | status = IPC_ETIMEOUT; |
1189 | } | 1218 | } |
1190 | else if (obj->unblocked) | 1219 | else if (TRUE == obj->unblocked) |
1191 | { | 1220 | { |
1192 | status = IPC_E_UNBLOCKED; | 1221 | status = IPC_E_UNBLOCKED; |
1193 | } | 1222 | } |
1194 | else if(skiplist) | 1223 | else if(TRUE == skiplist) |
1195 | { | 1224 | { |
1196 | *len = obj->payload.len; | 1225 | *len = obj->payload.len; |
1197 | *rplyEndPt = obj->payload.src; | 1226 | *rplyEndPt = obj->payload.src; |
@@ -1202,21 +1231,23 @@ int32_t RPMessage_recv(RPMessage_Handle handle, void* data, uint16_t *len, | |||
1202 | key = gIpcObject.initPrms.osalPrms.disableAllIntr(); | 1231 | key = gIpcObject.initPrms.osalPrms.disableAllIntr(); |
1203 | 1232 | ||
1204 | payload = (RPMessage_MsgElem *)IpcUtils_QgetHead(&obj->queue); | 1233 | payload = (RPMessage_MsgElem *)IpcUtils_QgetHead(&obj->queue); |
1205 | if (payload == (RPMessage_MsgElem *)&obj->queue) | 1234 | if ( (NULL == payload) || |
1235 | (payload == (RPMessage_MsgElem *)&obj->queue)) | ||
1206 | { | 1236 | { |
1207 | return IPC_EFAIL; | 1237 | status = IPC_EFAIL; |
1208 | } | 1238 | } |
1209 | 1239 | ||
1210 | /* Now, copy payload to client and free our internal msg */ | 1240 | if(status != IPC_EFAIL) |
1211 | memcpy(data, payload->data, payload->len); | 1241 | { |
1212 | *len = payload->len; | 1242 | /* Now, copy payload to client and free our internal msg */ |
1213 | *rplyEndPt = payload->src; | 1243 | memcpy(data, payload->data, payload->len); |
1214 | *rplyProcId = payload->procId; | 1244 | *len = payload->len; |
1215 | 1245 | *rplyEndPt = payload->src; | |
1216 | IpcUtils_HeapFree(&obj->heap, (void *)payload, | 1246 | *rplyProcId = payload->procId; |
1217 | (payload->len + sizeof(RPMessage_MsgElem))); | 1247 | IpcUtils_HeapFree(&obj->heap, (void *)payload, |
1218 | 1248 | (payload->len + sizeof(RPMessage_MsgElem))); | |
1219 | gIpcObject.initPrms.osalPrms.restoreAllIntr(key); | 1249 | gIpcObject.initPrms.osalPrms.restoreAllIntr(key); |
1250 | } | ||
1220 | } | 1251 | } |
1221 | 1252 | ||
1222 | return (status); | 1253 | return (status); |
@@ -1307,32 +1338,35 @@ static int32_t RPMessage_rawSend(Virtio_Handle vq, | |||
1307 | if(!msg) | 1338 | if(!msg) |
1308 | { | 1339 | { |
1309 | SystemP_printf("RPMessage_rawSend ...NULL MsgHdr\n"); | 1340 | SystemP_printf("RPMessage_rawSend ...NULL MsgHdr\n"); |
1310 | return IPC_EFAIL; | 1341 | status = IPC_EFAIL; |
1311 | } | 1342 | } |
1312 | if(length < bufSize) | 1343 | if(length < bufSize) |
1313 | { | 1344 | { |
1314 | SystemP_printf("RPMessage_rawSend ...length %d, reqrd %d\n", length, bufSize); | 1345 | SystemP_printf("RPMessage_rawSend ...length %d, reqrd %d\n", length, bufSize); |
1315 | return IPC_EFAIL; | 1346 | status = IPC_EFAIL; |
1316 | } | 1347 | } |
1317 | if (token >= 0) | 1348 | if(status != IPC_EFAIL) |
1318 | { | 1349 | { |
1319 | /* Copy the payload and set message header: */ | 1350 | if (token >= 0) |
1320 | memcpy(msg->payload, data, len); | 1351 | { |
1321 | msg->dataLen = len; | 1352 | /* Copy the payload and set message header: */ |
1322 | msg->dstAddr = dstEndPt; | 1353 | memcpy(msg->payload, data, len); |
1323 | msg->srcAddr = srcEndPt; | 1354 | msg->dataLen = len; |
1324 | msg->flags = 0; | 1355 | msg->dstAddr = dstEndPt; |
1325 | msg->srcProcId = Ipc_mpGetSelfId(); | 1356 | msg->srcAddr = srcEndPt; |
1357 | msg->flags = 0; | ||
1358 | msg->srcProcId = Ipc_mpGetSelfId(); | ||
1326 | 1359 | ||
1327 | key = pOsalPrms->lockHIsrGate(module.gateSwi); | 1360 | key = pOsalPrms->lockHIsrGate(module.gateSwi); |
1328 | Virtio_addUsedBuf(vq, token, bufSize); | 1361 | Virtio_addUsedBuf(vq, token, bufSize); |
1329 | Virtio_kick(vq); | 1362 | Virtio_kick(vq); |
1330 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); | 1363 | pOsalPrms->unLockHIsrGate(module.gateSwi, key); |
1331 | } | 1364 | } |
1332 | else | 1365 | else |
1333 | { | 1366 | { |
1334 | SystemP_printf("RPMessage_rawSend ...Invalid token %d\n", token); | 1367 | SystemP_printf("RPMessage_rawSend ...Invalid token %d\n", token); |
1335 | status = IPC_EFAIL; | 1368 | status = IPC_EFAIL; |
1369 | } | ||
1336 | } | 1370 | } |
1337 | 1371 | ||
1338 | return (status); | 1372 | return (status); |
@@ -1346,27 +1380,34 @@ int32_t RPMessage_send(RPMessage_Handle handle, uint32_t procId, uint32_t dstEnd | |||
1346 | { | 1380 | { |
1347 | Virtio_Handle vq; | 1381 | Virtio_Handle vq; |
1348 | uint32_t endPt; | 1382 | uint32_t endPt; |
1383 | int32_t status = IPC_SOK; | ||
1349 | 1384 | ||
1350 | if(procId >= IPC_MAX_PROCS) | 1385 | if(procId >= IPC_MAX_PROCS) |
1351 | { | 1386 | { |
1352 | return IPC_EFAIL; | 1387 | status = IPC_EFAIL; |
1353 | } | 1388 | } |
1354 | 1389 | ||
1355 | if(procId == Ipc_mpGetSelfId()) | 1390 | if(procId == Ipc_mpGetSelfId()) |
1356 | { | 1391 | { |
1357 | return IPC_EFAIL; | 1392 | status = IPC_EFAIL; |
1358 | } | 1393 | } |
1359 | 1394 | ||
1360 | vq = module.tx_VQs[procId]; | 1395 | if(status != IPC_EFAIL) |
1361 | if(vq == NULL) | ||
1362 | { | 1396 | { |
1363 | SystemP_printf("RPMessage_send ...NULL vq\n"); | 1397 | vq = module.tx_VQs[procId]; |
1364 | return IPC_EFAIL; | 1398 | if(NULL == vq) |
1399 | { | ||
1400 | SystemP_printf("RPMessage_send ...NULL vq\n"); | ||
1401 | status = IPC_EFAIL; | ||
1402 | } | ||
1403 | else | ||
1404 | { | ||
1405 | endPt = (handle == NULL) ? srcEndPt : handle->endPt; | ||
1406 | status = RPMessage_rawSend(vq, dstEndPt, endPt, data, len); | ||
1407 | } | ||
1365 | } | 1408 | } |
1366 | 1409 | ||
1367 | endPt = (handle == NULL) ? srcEndPt : handle->endPt; | 1410 | return status; |
1368 | |||
1369 | return RPMessage_rawSend(vq, dstEndPt, endPt, data, len); | ||
1370 | } | 1411 | } |
1371 | 1412 | ||
1372 | 1413 | ||
@@ -1378,7 +1419,7 @@ void RPMessage_unblock(RPMessage_Handle handle) | |||
1378 | RPMessage_Object *obj = (RPMessage_Object *)handle; | 1419 | RPMessage_Object *obj = (RPMessage_Object *)handle; |
1379 | 1420 | ||
1380 | /* Set instance to 'unblocked' state, and post */ | 1421 | /* Set instance to 'unblocked' state, and post */ |
1381 | obj->unblocked = true; | 1422 | obj->unblocked = TRUE; |
1382 | 1423 | ||
1383 | if (NULL != gIpcObject.initPrms.osalPrms.unlockMutex) | 1424 | if (NULL != gIpcObject.initPrms.osalPrms.unlockMutex) |
1384 | { | 1425 | { |
@@ -1404,7 +1445,7 @@ void IpcInitPrms_init(uint32_t instId, Ipc_InitPrms *initPrms) | |||
1404 | } | 1445 | } |
1405 | #endif /* IPC_EXCLUDE_INIT_PARAMS_INIT */ | 1446 | #endif /* IPC_EXCLUDE_INIT_PARAMS_INIT */ |
1406 | 1447 | ||
1407 | Ipc_Object_t *getIpcObjInst(uint32_t instId) | 1448 | Ipc_Object *getIpcObjInst(uint32_t instId) |
1408 | { | 1449 | { |
1409 | return &gIpcObject; | 1450 | return &gIpcObject; |
1410 | } | 1451 | } |
diff --git a/src/ipc_mailbox.c b/src/ipc_mailbox.c index cef092c..1a5776d 100644 --- a/src/ipc_mailbox.c +++ b/src/ipc_mailbox.c | |||
@@ -58,15 +58,15 @@ | |||
58 | 58 | ||
59 | /* Fix Me, need not be 256, can be max remote proc / max proc, i.e. 1 as | 59 | /* Fix Me, need not be 256, can be max remote proc / max proc, i.e. 1 as |
60 | structure which uses this is instantiated max proc times. */ | 60 | structure which uses this is instantiated max proc times. */ |
61 | #define IPC_MBOX_MAXFIFO_CNT 256 | 61 | #define IPC_MBOX_MAXFIFO_CNT 16U |
62 | /* Fix Me, need not be 256, can be max remote proc / max proc */ | 62 | /* Fix Me, need not be 256, can be max remote proc / max proc */ |
63 | #define IPC_MBOX_MAXDATA 256 | 63 | #define IPC_MBOX_MAXDATA 8U |
64 | 64 | ||
65 | /* ========================================================================== */ | 65 | /* ========================================================================== */ |
66 | /* Local Types */ | 66 | /* Local Types */ |
67 | /* ========================================================================== */ | 67 | /* ========================================================================== */ |
68 | 68 | ||
69 | typedef struct Ipc_MailboxFifo | 69 | typedef struct Ipc_MailboxFifo_s |
70 | { | 70 | { |
71 | int32_t cfgNdx; | 71 | int32_t cfgNdx; |
72 | Mailbox_hwiCallback func; | 72 | Mailbox_hwiCallback func; |
@@ -75,7 +75,7 @@ typedef struct Ipc_MailboxFifo | |||
75 | } Ipc_MailboxFifo; | 75 | } Ipc_MailboxFifo; |
76 | 76 | ||
77 | /* mboxData */ | 77 | /* mboxData */ |
78 | typedef struct Ipc_MailboxData | 78 | typedef struct Ipc_MailboxData_s |
79 | { | 79 | { |
80 | uint32_t baseAddr; | 80 | uint32_t baseAddr; |
81 | uint32_t fifoCnt; | 81 | uint32_t fifoCnt; |
@@ -89,7 +89,7 @@ typedef struct Ipc_MailboxData | |||
89 | /* ========================================================================== */ | 89 | /* ========================================================================== */ |
90 | /* Globals */ | 90 | /* Globals */ |
91 | /* ========================================================================== */ | 91 | /* ========================================================================== */ |
92 | uint32_t g_ipc_mBoxCnt = 0; | 92 | uint32_t g_ipc_mBoxCnt = 0U; |
93 | Ipc_MailboxData g_ipc_mBoxData[IPC_MBOX_MAXDATA]; | 93 | Ipc_MailboxData g_ipc_mBoxData[IPC_MBOX_MAXDATA]; |
94 | /** | 94 | /** |
95 | * \brief Maps mBoxData allocated to a given Remote Processor | 95 | * \brief Maps mBoxData allocated to a given Remote Processor |
@@ -113,18 +113,18 @@ void Ipc_mailboxInternalCallback(uintptr_t mboxNdx); | |||
113 | #ifndef IPC_EXCLUDE_POLLED_RX | 113 | #ifndef IPC_EXCLUDE_POLLED_RX |
114 | #define IPC_POLL_TIMER 10 | 114 | #define IPC_POLL_TIMER 10 |
115 | 115 | ||
116 | uint32_t g_pollTaskExit = false; | 116 | uint32_t g_pollTaskExit = FALSE; |
117 | TaskP_Handle g_pollTask = NULL; | 117 | TaskP_Handle g_pollTask = NULL; |
118 | 118 | ||
119 | void Mailbox_Poll_Task(void* argNotUsed) | 119 | void Mailbox_Poll_Task(void* argNotUsed) |
120 | { | 120 | { |
121 | uint32_t n = 0; | 121 | uint32_t n = 0U; |
122 | uint32_t cnt = 0; | 122 | uint32_t cnt = 0U; |
123 | uint32_t msg[4]; | 123 | uint32_t msg[4]; |
124 | Ipc_MailboxData *mbox = NULL; | 124 | Ipc_MailboxData *mbox = NULL; |
125 | Ipc_MailboxFifo *fifo = NULL; | 125 | Ipc_MailboxFifo *fifo = NULL; |
126 | 126 | ||
127 | while(!g_pollTaskExit) | 127 | while(FALSE == g_pollTaskExit) |
128 | { | 128 | { |
129 | for(n = 0; n < g_ipc_mBoxCnt; n++) | 129 | for(n = 0; n < g_ipc_mBoxCnt; n++) |
130 | { | 130 | { |
@@ -156,10 +156,10 @@ void Mailbox_Poll_Task(void* argNotUsed) | |||
156 | 156 | ||
157 | void Mailbox_Poll_TaskExit() | 157 | void Mailbox_Poll_TaskExit() |
158 | { | 158 | { |
159 | g_pollTaskExit = true; | 159 | g_pollTaskExit = TRUE; |
160 | } | 160 | } |
161 | 161 | ||
162 | #if defined(BUILD_C7X_1) && defined(MAILBOX_INTERRUPT_MODE) | 162 | #if defined(BUILD_C7X_1) && !defined(MAILBOX_INTERRUPT_MODE) |
163 | static uint8_t g_pollTaskStack[IPC_TASK_STACKSIZE] | 163 | static uint8_t g_pollTaskStack[IPC_TASK_STACKSIZE] |
164 | __attribute__ ((section(".bss:taskStackSection"))) | 164 | __attribute__ ((section(".bss:taskStackSection"))) |
165 | __attribute__ ((aligned(8192))) | 165 | __attribute__ ((aligned(8192))) |
@@ -172,7 +172,7 @@ void StartmailboxPollingTask() | |||
172 | 172 | ||
173 | TaskP_Params_init(¶m); | 173 | TaskP_Params_init(¶m); |
174 | param.priority = 2; | 174 | param.priority = 2; |
175 | #if defined(BUILD_C7X_1) && defined(MAILBOX_INTERRUPT_MODE) | 175 | #if defined(BUILD_C7X_1) && !defined(MAILBOX_INTERRUPT_MODE) |
176 | param.stack = g_pollTaskStack; | 176 | param.stack = g_pollTaskStack; |
177 | #endif | 177 | #endif |
178 | param.stacksize = IPC_TASK_STACKSIZE; | 178 | param.stacksize = IPC_TASK_STACKSIZE; |
@@ -224,68 +224,22 @@ uint32_t Ipc_mailboxClear(uint32_t baseAddr, uint32_t queueId) | |||
224 | } | 224 | } |
225 | 225 | ||
226 | /** | 226 | /** |
227 | * Adding these two functions as workaround for C7x release build. | ||
228 | * The workaround will be removed when pdk/c7x compiler start using | ||
229 | * cgt_c7000_1.1.0 compiler which fixes the load error | ||
230 | * */ | ||
231 | #ifdef BUILD_C7X_1 | ||
232 | #ifdef __cplusplus | ||
233 | #pragma FUNCTION_OPTIONS("--opt_level=off") | ||
234 | #else | ||
235 | #pragma FUNCTION_OPTIONS(Ipc_MailboxWriteMessage, "--opt_level=off") | ||
236 | #endif | ||
237 | #endif | ||
238 | void Ipc_MailboxWriteMessage(uint32_t baseAddr, uint32_t queueId, uint32_t msg) | ||
239 | { | ||
240 | /* Write mailbox message */ | ||
241 | HW_WR_REG32(baseAddr + MAILBOX_MESSAGE(queueId), msg); | ||
242 | } | ||
243 | |||
244 | #ifdef BUILD_C7X_1 | ||
245 | #ifdef __cplusplus | ||
246 | #pragma FUNCTION_OPTIONS("--opt_level=off") | ||
247 | #else | ||
248 | #pragma FUNCTION_OPTIONS(Ipc_MailboxSendMessage, "--opt_level=off") | ||
249 | #endif | ||
250 | #endif | ||
251 | uint32_t Ipc_MailboxSendMessage(uint32_t baseAddr, uint32_t queueId, uint32_t msg) | ||
252 | { | ||
253 | uint32_t fifoFull; | ||
254 | uint32_t retval; | ||
255 | |||
256 | /* Read the FIFO Status */ | ||
257 | fifoFull = HW_RD_REG32(baseAddr + MAILBOX_FIFOSTATUS(queueId)); | ||
258 | if (fifoFull == 0U) | ||
259 | { | ||
260 | /* FIFO not full write msg */ | ||
261 | Ipc_MailboxWriteMessage(baseAddr, queueId, msg); | ||
262 | retval = MESSAGE_VALID; | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | retval = MESSAGE_INVALID; | ||
267 | } | ||
268 | |||
269 | return retval; | ||
270 | } | ||
271 | /* ------------ End of workaround ------------*/ | ||
272 | |||
273 | /** | ||
274 | * \brief Send interrupt to the remote processor | 227 | * \brief Send interrupt to the remote processor |
275 | */ | 228 | */ |
276 | int32_t Ipc_mailboxSend(uint32_t selfId, uint32_t remoteProcId, uint32_t val, | 229 | int32_t Ipc_mailboxSend(uint32_t selfId, uint32_t remoteProcId, uint32_t val, |
277 | uint32_t timeoutCnt) | 230 | uint32_t timeoutCnt) |
278 | { | 231 | { |
279 | int32_t status = 0; | 232 | int32_t status = 0; |
280 | int32_t clusterId; | 233 | uint32_t clusterId; |
281 | int32_t userId; | 234 | uint32_t userId; |
282 | uint32_t queueId; | 235 | uint32_t queueId; |
283 | uint32_t baseAddr; | 236 | uint32_t baseAddr; |
237 | uint32_t cnt = timeoutCnt; | ||
284 | 238 | ||
285 | #ifndef IPC_ONE_CONTEXT_FOR_HISRGATE_HWIGATE | 239 | #ifndef IPC_ONE_CONTEXT_FOR_HISRGATE_HWIGATE |
286 | Ipc_Object_t *pObj = NULL; | 240 | Ipc_Object *pObj = NULL; |
287 | Ipc_OsalPrms *pOsal = NULL; | 241 | Ipc_OsalPrms *pOsal = NULL; |
288 | uintptr_t key = 0U; | 242 | uintptr_t key = 0U; |
289 | 243 | ||
290 | pObj = getIpcObjInst(0U); | 244 | pObj = getIpcObjInst(0U); |
291 | pOsal = &pObj->initPrms.osalPrms; | 245 | pOsal = &pObj->initPrms.osalPrms; |
@@ -294,9 +248,9 @@ int32_t Ipc_mailboxSend(uint32_t selfId, uint32_t remoteProcId, uint32_t val, | |||
294 | Ipc_getMailboxInfoTx(selfId, remoteProcId, | 248 | Ipc_getMailboxInfoTx(selfId, remoteProcId, |
295 | &clusterId, &userId, &queueId); | 249 | &clusterId, &userId, &queueId); |
296 | 250 | ||
297 | if( (clusterId > -1) && (queueId < 16) ) | 251 | if( (clusterId != MAILBOX_CLUSTER_INVALID) && (queueId < 16) ) |
298 | { | 252 | { |
299 | int32_t retVal; | 253 | uint32_t retVal; |
300 | 254 | ||
301 | baseAddr = Ipc_getMailboxBaseAddr(clusterId); | 255 | baseAddr = Ipc_getMailboxBaseAddr(clusterId); |
302 | 256 | ||
@@ -315,10 +269,9 @@ int32_t Ipc_mailboxSend(uint32_t selfId, uint32_t remoteProcId, uint32_t val, | |||
315 | 269 | ||
316 | do | 270 | do |
317 | { | 271 | { |
318 | retVal = Ipc_MailboxSendMessage(baseAddr, queueId, val); | 272 | retVal = MailboxSendMessage(baseAddr, queueId, val); |
319 | 273 | cnt--; | |
320 | timeoutCnt--; | 274 | } while( (cnt != 0U) && (retVal == MESSAGE_INVALID)); |
321 | } while(timeoutCnt != 0 && retVal == MESSAGE_INVALID); | ||
322 | 275 | ||
323 | if(MESSAGE_INVALID == retVal) | 276 | if(MESSAGE_INVALID == retVal) |
324 | { | 277 | { |
@@ -349,17 +302,17 @@ int32_t Ipc_mailboxSend(uint32_t selfId, uint32_t remoteProcId, uint32_t val, | |||
349 | int32_t Ipc_mailboxRegister(uint16_t selfId, uint16_t remoteProcId, | 302 | int32_t Ipc_mailboxRegister(uint16_t selfId, uint16_t remoteProcId, |
350 | Mailbox_hwiCallback func, uint32_t arg) | 303 | Mailbox_hwiCallback func, uint32_t arg) |
351 | { | 304 | { |
352 | int32_t retVal = 0; | 305 | int32_t retVal = IPC_SOK; |
353 | int32_t clusterId; | 306 | uint32_t clusterId; |
354 | int32_t userId; | 307 | uint32_t userId; |
355 | uint32_t queueId; | 308 | uint32_t queueId; |
356 | uint32_t baseAddr; | 309 | uint32_t baseAddr; |
357 | uint32_t n; | 310 | uint32_t n; |
358 | Ipc_MailboxData *mbox = NULL; | 311 | Ipc_MailboxData *mbox = NULL; |
359 | #ifndef IPC_EXCLUDE_INTERRUPT_REG | 312 | #ifndef IPC_EXCLUDE_INTERRUPT_REG |
360 | uintptr_t key = 0U; | 313 | uintptr_t key = 0U; |
361 | Ipc_Object_t *pObj = NULL; | 314 | Ipc_Object *pObj = NULL; |
362 | Ipc_OsalPrms *pOsal = NULL; | 315 | Ipc_OsalPrms *pOsal = NULL; |
363 | 316 | ||
364 | pObj = getIpcObjInst(0U); | 317 | pObj = getIpcObjInst(0U); |
365 | pOsal = &pObj->initPrms.osalPrms; | 318 | pOsal = &pObj->initPrms.osalPrms; |
@@ -368,125 +321,129 @@ int32_t Ipc_mailboxRegister(uint16_t selfId, uint16_t remoteProcId, | |||
368 | Ipc_getMailboxInfoRx(selfId, remoteProcId, | 321 | Ipc_getMailboxInfoRx(selfId, remoteProcId, |
369 | &clusterId, &userId, &queueId); | 322 | &clusterId, &userId, &queueId); |
370 | 323 | ||
371 | if( (clusterId > -1) && (IPC_MAX_PROCS > remoteProcId)) | 324 | if( (clusterId != MAILBOX_CLUSTER_INVALID) && (IPC_MAX_PROCS > remoteProcId)) |
372 | { | 325 | { |
373 | baseAddr = Ipc_getMailboxBaseAddr(clusterId); | 326 | baseAddr = Ipc_getMailboxBaseAddr(clusterId); |
374 | } | 327 | } |
375 | else | 328 | else |
376 | { | 329 | { |
377 | SystemP_printf("Ipc_Mailbox_register : failed Invalid cluster..\n"); | 330 | SystemP_printf("Ipc_Mailbox_register : failed Invalid cluster..\n"); |
378 | return retVal; | 331 | retVal = IPC_EFAIL; |
379 | } | 332 | } |
380 | 333 | ||
381 | for(n = 0; n < g_ipc_mBoxCnt; n++) | 334 | if(retVal == IPC_SOK) |
382 | { | 335 | { |
383 | if(baseAddr == g_ipc_mBoxData[n].baseAddr && userId == g_ipc_mBoxData[n].userId) | 336 | for(n = 0; n < g_ipc_mBoxCnt; n++) |
384 | break; | 337 | { |
385 | } | 338 | if(baseAddr == g_ipc_mBoxData[n].baseAddr && userId == g_ipc_mBoxData[n].userId) |
339 | break; | ||
340 | } | ||
386 | 341 | ||
387 | /* Get the MailBox Data */ | 342 | /* Get the MailBox Data */ |
388 | mbox = &g_ipc_mBoxData[n]; | 343 | mbox = &g_ipc_mBoxData[n]; |
389 | 344 | ||
390 | if(n == g_ipc_mBoxCnt) | 345 | if(n == g_ipc_mBoxCnt) |
391 | { | 346 | { |
392 | /* Could not find one, this is new entry */ | 347 | /* Could not find one, this is new entry */ |
393 | mbox->baseAddr = baseAddr; | 348 | mbox->baseAddr = baseAddr; |
394 | mbox->fifoCnt = 0; | 349 | mbox->fifoCnt = 0; |
395 | mbox->userId = userId; | 350 | mbox->userId = userId; |
396 | 351 | ||
397 | #ifndef IPC_EXCLUDE_INTERRUPT_REG | 352 | #ifndef IPC_EXCLUDE_INTERRUPT_REG |
398 | /* Disable global interrupts */ | 353 | /* Disable global interrupts */ |
399 | if (NULL != pOsal->disableAllIntr) | 354 | if (NULL != pOsal->disableAllIntr) |
400 | { | 355 | { |
401 | key = pOsal->disableAllIntr(); | 356 | key = pOsal->disableAllIntr(); |
402 | } | 357 | } |
403 | 358 | ||
404 | /* Clear Mailbox cluster queue */ | 359 | /* Clear Mailbox cluster queue */ |
405 | Ipc_mailboxClear(baseAddr, queueId); | 360 | Ipc_mailboxClear(baseAddr, queueId); |
406 | 361 | ||
407 | /* Restore global interrupts */ | 362 | /* Restore global interrupts */ |
408 | if (NULL != pOsal->restoreAllIntr) | 363 | if (NULL != pOsal->restoreAllIntr) |
409 | { | 364 | { |
410 | pOsal->restoreAllIntr(key); | 365 | pOsal->restoreAllIntr(key); |
411 | } | 366 | } |
412 | 367 | ||
413 | #ifdef MAILBOX_INTERRUPT_MODE | 368 | #ifdef MAILBOX_INTERRUPT_MODE |
414 | { | 369 | { |
415 | Ipc_MbConfig cfg; | 370 | Ipc_MbConfig cfg; |
416 | 371 | ||
417 | MailboxClrNewMsgStatus(baseAddr, userId, queueId); | 372 | MailboxClrNewMsgStatus(baseAddr, userId, queueId); |
418 | 373 | ||
419 | /* Get the Interrupt Configuration */ | 374 | /* Get the Interrupt Configuration */ |
420 | Ipc_getMailboxIntrRouterCfg(selfId, clusterId, userId, &cfg, g_ipc_mBoxCnt); | 375 | Ipc_getMailboxIntrRouterCfg(selfId, clusterId, userId, &cfg, g_ipc_mBoxCnt); |
421 | 376 | ||
422 | #ifdef IPC_SUPPORT_SCICLIENT | 377 | #ifdef IPC_SUPPORT_SCICLIENT |
423 | { | ||
424 | /* Release the resource first */ | ||
425 | retVal = Ipc_sciclientIrqRelease(selfId, clusterId, userId, cfg.eventId); | ||
426 | |||
427 | uint32_t timeout_cnt = 10; | ||
428 | do | ||
429 | { | 378 | { |
430 | retVal = Ipc_sciclientIrqSet(selfId, clusterId, userId, cfg.eventId); | 379 | /* Release the resource first */ |
431 | if(retVal != 0) | 380 | retVal = Ipc_sciclientIrqRelease(selfId, clusterId, userId, cfg.eventId); |
381 | |||
382 | uint32_t timeout_cnt = 10; | ||
383 | do | ||
384 | { | ||
385 | retVal = Ipc_sciclientIrqSet(selfId, clusterId, userId, cfg.eventId); | ||
386 | if(retVal != 0) | ||
387 | { | ||
388 | SystemP_printf("Failed to register irq through sciclient...%x\n", retVal); | ||
389 | } | ||
390 | timeout_cnt--; | ||
391 | }while((retVal != 0) && (timeout_cnt > 0)); | ||
392 | |||
393 | if(timeout_cnt == 0) | ||
432 | { | 394 | { |
433 | SystemP_printf("Failed to register irq through sciclient...%x\n", retVal); | 395 | retVal = IPC_EFAIL; |
434 | } | 396 | } |
435 | }while(retVal != 0 && timeout_cnt > 0); | ||
436 | |||
437 | if(timeout_cnt == 0) | ||
438 | { | ||
439 | return IPC_EFAIL; | ||
440 | } | 397 | } |
441 | } | ||
442 | #endif | 398 | #endif |
443 | /* Register Mailbox interrupt now... */ | 399 | /* Register Mailbox interrupt now... */ |
444 | if (NULL != pOsal->registerIntr) | 400 | if ( (retVal == IPC_SOK) && |
445 | { | 401 | (NULL != pOsal->registerIntr)) |
446 | pObj->interruptHandle = pOsal->registerIntr( | 402 | { |
447 | &cfg, | 403 | pObj->interruptHandle = pOsal->registerIntr( |
448 | Ipc_mailboxInternalCallback, | 404 | &cfg,Ipc_mailboxInternalCallback, |
449 | (uintptr_t)mbox); | 405 | (uintptr_t)mbox); |
450 | } | 406 | } |
451 | 407 | ||
452 | } | 408 | } |
453 | #endif /* MAILBOX_INTERRUPT_MODE */ | 409 | #endif /* MAILBOX_INTERRUPT_MODE */ |
454 | #endif /* IPC_EXCLUDE_INTERRUPT_REG */ | 410 | #endif /* IPC_EXCLUDE_INTERRUPT_REG */ |
455 | 411 | ||
456 | #ifndef IPC_EXCLUDE_POLLED_RX | 412 | #ifndef IPC_EXCLUDE_POLLED_RX |
457 | #ifndef MAILBOX_INTERRUPT_MODE | 413 | #ifndef MAILBOX_INTERRUPT_MODE |
458 | { | ||
459 | /* Mailbox interrupt is not supported currently */ | ||
460 | if(g_pollTask == NULL) | ||
461 | { | 414 | { |
462 | StartmailboxPollingTask(); | 415 | /* Mailbox interrupt is not supported currently */ |
416 | if(g_pollTask == NULL) | ||
417 | { | ||
418 | StartmailboxPollingTask(); | ||
419 | } | ||
463 | } | 420 | } |
464 | } | ||
465 | #endif /* MAILBOX_INTERRUPT_MODE */ | 421 | #endif /* MAILBOX_INTERRUPT_MODE */ |
466 | #endif /* IPC_EXCLUDE_POLLED_RX */ | 422 | #endif /* IPC_EXCLUDE_POLLED_RX */ |
467 | 423 | ||
468 | g_ipc_mBoxCnt++; | 424 | g_ipc_mBoxCnt++; |
469 | } | 425 | } |
470 | 426 | ||
471 | /* Add the fifo data for the remoteProcId. */ | 427 | /* Add the fifo data for the remoteProcId. */ |
472 | mbox->fifoTable[mbox->fifoCnt].cfgNdx = n; | 428 | mbox->fifoTable[mbox->fifoCnt].cfgNdx = n; |
473 | mbox->fifoTable[mbox->fifoCnt].func = func; | 429 | mbox->fifoTable[mbox->fifoCnt].func = func; |
474 | mbox->fifoTable[mbox->fifoCnt].arg = arg; | 430 | mbox->fifoTable[mbox->fifoCnt].arg = arg; |
475 | mbox->fifoTable[mbox->fifoCnt].queueId = queueId; | 431 | mbox->fifoTable[mbox->fifoCnt].queueId = queueId; |
476 | gIpcRProcIdToMBoxDataMap[remoteProcId] = (uintptr_t)mbox; | 432 | gIpcRProcIdToMBoxDataMap[remoteProcId] = (uintptr_t)mbox; |
477 | 433 | ||
478 | mbox->fifoCnt++; | 434 | mbox->fifoCnt++; |
479 | 435 | ||
480 | #ifdef DEBUG_PRINT | 436 | #ifdef DEBUG_PRINT |
481 | SystemP_printf("Ipc_MB(%d): Self %d Remote %d (c%d,u%d,q%d) arg %d,total %d\n", | 437 | SystemP_printf("Ipc_MB(%d): Self %d Remote %d (c%d,u%d,q%d) arg %d,total %d\n", |
482 | mbox->fifoCnt, selfId, remoteProcId, clusterId, userId, queueId, arg, | 438 | mbox->fifoCnt, selfId, remoteProcId, clusterId, userId, queueId, arg, |
483 | g_ipc_mBoxCnt); | 439 | g_ipc_mBoxCnt); |
484 | #endif | 440 | #endif |
485 | 441 | ||
486 | #ifndef IPC_EXCLUDE_INTERRUPT_REG | 442 | #ifndef IPC_EXCLUDE_INTERRUPT_REG |
487 | /* enable the mailbox interrupt */ | 443 | /* enable the mailbox interrupt */ |
488 | Ipc_mailboxEnable(baseAddr, userId, queueId); | 444 | Ipc_mailboxEnable(baseAddr, userId, queueId); |
489 | #endif /* IPC_EXCLUDE_INTERRUPT_REG */ | 445 | #endif /* IPC_EXCLUDE_INTERRUPT_REG */ |
446 | } | ||
490 | 447 | ||
491 | return retVal; | 448 | return retVal; |
492 | } | 449 | } |
@@ -519,53 +476,46 @@ void Ipc_mailboxInternalCallback(uintptr_t arg) | |||
519 | Ipc_MailboxFifo *fifo; | 476 | Ipc_MailboxFifo *fifo; |
520 | 477 | ||
521 | mbox = (Ipc_MailboxData *)arg; | 478 | mbox = (Ipc_MailboxData *)arg; |
522 | if(mbox == NULL) | 479 | if(mbox != NULL) |
523 | { | ||
524 | return; | ||
525 | } | ||
526 | |||
527 | mbox->intCnt++; | ||
528 | |||
529 | for(n = 0; n < mbox->fifoCnt; n++) | ||
530 | { | 480 | { |
531 | fifo = &mbox->fifoTable[n]; | 481 | mbox->intCnt++; |
532 | 482 | ||
533 | if(MailboxGetRawNewMsgStatus(mbox->baseAddr, mbox->userId, fifo->queueId)) | 483 | for(n = 0; n < mbox->fifoCnt; n++) |
534 | { | 484 | { |
535 | if( MailboxGetMessageCount(mbox->baseAddr, fifo->queueId) != 0) | 485 | fifo = &mbox->fifoTable[n]; |
536 | { | ||
537 | /* Get the message from Mailbox fifo */ | ||
538 | MailboxGetMessage(mbox->baseAddr, fifo->queueId, msg); | ||
539 | |||
540 | |||
541 | /* Clear new message status of Mailbox */ | ||
542 | MailboxClrNewMsgStatus(mbox->baseAddr, mbox->userId, | ||
543 | fifo->queueId); | ||
544 | 486 | ||
545 | /* Call the function with arg */ | 487 | if(0U != MailboxGetRawNewMsgStatus(mbox->baseAddr, mbox->userId, fifo->queueId)) |
546 | (mbox->fifoTable[n].func)(msg, fifo->arg); | ||
547 | |||
548 | } | ||
549 | else | ||
550 | { | 488 | { |
551 | /* Clear new message status of Mailbox */ | 489 | if( MailboxGetMessageCount(mbox->baseAddr, fifo->queueId) > 0U) |
552 | MailboxClrNewMsgStatus(mbox->baseAddr, mbox->userId, fifo->queueId); | 490 | { |
553 | } | 491 | /* Get the message from Mailbox fifo */ |
492 | MailboxGetMessage(mbox->baseAddr, fifo->queueId, msg); | ||
554 | 493 | ||
555 | MailboxWriteEOI(mbox->baseAddr, mbox->userId); | 494 | /* Clear new message status of Mailbox */ |
495 | MailboxClrNewMsgStatus(mbox->baseAddr, mbox->userId, | ||
496 | fifo->queueId); | ||
556 | 497 | ||
498 | /* Call the function with arg */ | ||
499 | (mbox->fifoTable[n].func)(msg, fifo->arg); | ||
500 | } | ||
501 | else | ||
502 | { | ||
503 | /* Clear new message status of Mailbox */ | ||
504 | MailboxClrNewMsgStatus(mbox->baseAddr, mbox->userId, fifo->queueId); | ||
505 | } | ||
506 | } | ||
507 | } | ||
508 | if(n == mbox->fifoCnt) | ||
509 | { | ||
510 | mbox->noMsgCnt++; | ||
557 | } | 511 | } |
558 | } | ||
559 | if(n == mbox->fifoCnt) | ||
560 | { | ||
561 | mbox->noMsgCnt++; | ||
562 | } | 512 | } |
563 | } | 513 | } |
564 | 514 | ||
565 | void Ipc_mailboxEnableNewMsgInt(uint16_t selfId, uint16_t remoteProcId) | 515 | void Ipc_mailboxEnableNewMsgInt(uint16_t selfId, uint16_t remoteProcId) |
566 | { | 516 | { |
567 | int32_t clusterId; | 517 | uint32_t clusterId; |
568 | int32_t userId; | 518 | uint32_t userId; |
569 | uint32_t queueId; | 519 | uint32_t queueId; |
570 | uint32_t baseAddr; | 520 | uint32_t baseAddr; |
571 | 521 | ||
@@ -582,8 +532,8 @@ void Ipc_mailboxEnableNewMsgInt(uint16_t selfId, uint16_t remoteProcId) | |||
582 | 532 | ||
583 | void Ipc_mailboxDisableNewMsgInt(uint16_t selfId, uint16_t remoteProcId) | 533 | void Ipc_mailboxDisableNewMsgInt(uint16_t selfId, uint16_t remoteProcId) |
584 | { | 534 | { |
585 | int32_t clusterId; | 535 | uint32_t clusterId; |
586 | int32_t userId; | 536 | uint32_t userId; |
587 | uint32_t queueId; | 537 | uint32_t queueId; |
588 | uint32_t baseAddr; | 538 | uint32_t baseAddr; |
589 | 539 | ||
diff --git a/src/ipc_mailbox.h b/src/ipc_mailbox.h index 647ee63..9929d81 100644 --- a/src/ipc_mailbox.h +++ b/src/ipc_mailbox.h | |||
@@ -54,7 +54,8 @@ extern "C" { | |||
54 | /* Macros & Typedefs */ | 54 | /* Macros & Typedefs */ |
55 | /* ========================================================================== */ | 55 | /* ========================================================================== */ |
56 | 56 | ||
57 | 57 | #define MAILBOX_CLUSTER_INVALID (0xFFU) | |
58 | #define MAILBOX_USER_INVALID (0xFFU) | ||
58 | 59 | ||
59 | /* ========================================================================== */ | 60 | /* ========================================================================== */ |
60 | /* Structure Declarations */ | 61 | /* Structure Declarations */ |
@@ -63,14 +64,14 @@ extern "C" { | |||
63 | /** | 64 | /** |
64 | * \brief Mailbox entry for all transmit and receive | 65 | * \brief Mailbox entry for all transmit and receive |
65 | */ | 66 | */ |
66 | typedef struct Ipc_MailboxEntry | 67 | typedef struct Ipc_MailboxEntry_s |
67 | { | 68 | { |
68 | int32_t cluster; | 69 | uint32_t cluster; |
69 | int32_t user; | 70 | uint32_t user; |
70 | uint32_t fifo; | 71 | uint32_t fifo; |
71 | } Ipc_MailboxEntry; | 72 | } Ipc_MailboxEntry; |
72 | 73 | ||
73 | typedef struct Ipc_MailboxInfo | 74 | typedef struct Ipc_MailboxInfo_s |
74 | { | 75 | { |
75 | Ipc_MailboxEntry rx; | 76 | Ipc_MailboxEntry rx; |
76 | Ipc_MailboxEntry tx; | 77 | Ipc_MailboxEntry tx; |
diff --git a/src/ipc_mp.c b/src/ipc_mp.c index 3564e9c..334daca 100644 --- a/src/ipc_mp.c +++ b/src/ipc_mp.c | |||
@@ -51,7 +51,7 @@ | |||
51 | /* Macros & Typedefs */ | 51 | /* Macros & Typedefs */ |
52 | /* ========================================================================== */ | 52 | /* ========================================================================== */ |
53 | 53 | ||
54 | typedef struct Ipc_MpConfig | 54 | typedef struct Ipc_MpConfig_s |
55 | { | 55 | { |
56 | uint32_t selfProcId; | 56 | uint32_t selfProcId; |
57 | /**< own processor id */ | 57 | /**< own processor id */ |
@@ -75,7 +75,7 @@ int32_t Ipc_mpSetConfig(uint32_t selfId, uint16_t numProc, uint32_t procArry[IPC | |||
75 | uint32_t i = 0; | 75 | uint32_t i = 0; |
76 | uint32_t id; | 76 | uint32_t id; |
77 | 77 | ||
78 | if(selfId >= IPC_MAX_PROCS || numProc > IPC_MAX_PROCS) | 78 | if( (selfId >= IPC_MAX_PROCS) || (numProc > IPC_MAX_PROCS) ) |
79 | { | 79 | { |
80 | retVal = IPC_EINVALID_PARAMS; | 80 | retVal = IPC_EINVALID_PARAMS; |
81 | } | 81 | } |
@@ -102,11 +102,11 @@ int32_t Ipc_mpSetConfig(uint32_t selfId, uint16_t numProc, uint32_t procArry[IPC | |||
102 | 102 | ||
103 | uint32_t Ipc_mpGetId(const char* name) | 103 | uint32_t Ipc_mpGetId(const char* name) |
104 | { | 104 | { |
105 | int32_t procId = IPC_MP_INVALID_ID; | 105 | uint32_t procId = IPC_MP_INVALID_ID; |
106 | uint16_t i = 0; | 106 | uint16_t i = 0; |
107 | Ipc_MpConfig *pMpCfg = &g_ipcMpConfig; | 107 | Ipc_MpConfig *pMpCfg = &g_ipcMpConfig; |
108 | 108 | ||
109 | if(NULL == name || strlen(name) == 0) | 109 | if( (NULL == name) || (strlen(name) == 0U) ) |
110 | { | 110 | { |
111 | /* Invalid parameter */ | 111 | /* Invalid parameter */ |
112 | 112 | ||
@@ -116,7 +116,7 @@ uint32_t Ipc_mpGetId(const char* name) | |||
116 | for(i = 0; i < pMpCfg->numProcessors; i++) | 116 | for(i = 0; i < pMpCfg->numProcessors; i++) |
117 | { | 117 | { |
118 | if ((pMpCfg->procInfo[i].name != NULL) && | 118 | if ((pMpCfg->procInfo[i].name != NULL) && |
119 | (strcmp(name, pMpCfg->procInfo[i].name) == 0)) | 119 | (strncmp(name, pMpCfg->procInfo[i].name, IPC_MAX_PROC_NAMELEN) == 0U)) |
120 | { | 120 | { |
121 | procId = pMpCfg->procInfo[i].procId; | 121 | procId = pMpCfg->procInfo[i].procId; |
122 | } | 122 | } |
@@ -157,7 +157,7 @@ const char* Ipc_mpGetName(uint32_t id) | |||
157 | return (const char*)name; | 157 | return (const char*)name; |
158 | } | 158 | } |
159 | 159 | ||
160 | const char* Ipc_mpGetSelfName() | 160 | const char* Ipc_mpGetSelfName(void) |
161 | { | 161 | { |
162 | Ipc_MpConfig *pMpCfg = &g_ipcMpConfig; | 162 | Ipc_MpConfig *pMpCfg = &g_ipcMpConfig; |
163 | return (const char*)pMpCfg->name; | 163 | return (const char*)pMpCfg->name; |
@@ -173,14 +173,14 @@ uint32_t Ipc_mpGetSelfId(void) | |||
173 | return g_ipcMpConfig.selfProcId; | 173 | return g_ipcMpConfig.selfProcId; |
174 | } | 174 | } |
175 | 175 | ||
176 | uint32_t Ipc_mpGetRemoteProcId(uint32_t index) | 176 | uint32_t Ipc_mpGetRemoteProcId(uint32_t coreIndex) |
177 | { | 177 | { |
178 | uint32_t remoteId = 0xFF; | 178 | uint32_t remoteId = 0xFFU; |
179 | Ipc_MpConfig *pMpCfg = &g_ipcMpConfig; | 179 | Ipc_MpConfig *pMpCfg = &g_ipcMpConfig; |
180 | 180 | ||
181 | if(index < g_ipcMpConfig.numProcessors) | 181 | if(coreIndex < g_ipcMpConfig.numProcessors) |
182 | { | 182 | { |
183 | remoteId = pMpCfg->procInfo[index].procId; | 183 | remoteId = pMpCfg->procInfo[coreIndex].procId; |
184 | } | 184 | } |
185 | 185 | ||
186 | return remoteId; | 186 | return remoteId; |
diff --git a/src/ipc_priv.h b/src/ipc_priv.h index 1aab3dd..c90d723 100644 --- a/src/ipc_priv.h +++ b/src/ipc_priv.h | |||
@@ -77,7 +77,8 @@ extern "C" { | |||
77 | /** | 77 | /** |
78 | * \brief This structure is for proc info | 78 | * \brief This structure is for proc info |
79 | */ | 79 | */ |
80 | typedef struct { | 80 | typedef struct Ipc_ProcInfo_s |
81 | { | ||
81 | uint32_t procId; | 82 | uint32_t procId; |
82 | /**< unique processor id */ | 83 | /**< unique processor id */ |
83 | 84 | ||
@@ -88,7 +89,7 @@ typedef struct { | |||
88 | /** | 89 | /** |
89 | * \brief Instance specific parameter, only 1 instance supported | 90 | * \brief Instance specific parameter, only 1 instance supported |
90 | */ | 91 | */ |
91 | typedef struct Ipc_Object | 92 | typedef struct Ipc_Object_s |
92 | { | 93 | { |
93 | uint32_t instId; | 94 | uint32_t instId; |
94 | /**< Instance ID */ | 95 | /**< Instance ID */ |
@@ -96,7 +97,7 @@ typedef struct Ipc_Object | |||
96 | /**< Initialization parameters */ | 97 | /**< Initialization parameters */ |
97 | void *interruptHandle; | 98 | void *interruptHandle; |
98 | /**< Interrupt handler handle */ | 99 | /**< Interrupt handler handle */ |
99 | } Ipc_Object_t; | 100 | } Ipc_Object; |
100 | 101 | ||
101 | /* ========================================================================== */ | 102 | /* ========================================================================== */ |
102 | /* Structure Declarations */ | 103 | /* Structure Declarations */ |
@@ -108,7 +109,7 @@ typedef struct Ipc_Object | |||
108 | /* Function Declarations */ | 109 | /* Function Declarations */ |
109 | /* ========================================================================== */ | 110 | /* ========================================================================== */ |
110 | 111 | ||
111 | Ipc_Object_t *getIpcObjInst(uint32_t instId); | 112 | Ipc_Object *getIpcObjInst(uint32_t instId); |
112 | 113 | ||
113 | /* ========================================================================== */ | 114 | /* ========================================================================== */ |
114 | /* Static Function Definitions */ | 115 | /* Static Function Definitions */ |
diff --git a/src/ipc_utils.c b/src/ipc_utils.c index e555492..1f49883 100755 --- a/src/ipc_utils.c +++ b/src/ipc_utils.c | |||
@@ -59,7 +59,7 @@ | |||
59 | 59 | ||
60 | /** \brief Utils Object | 60 | /** \brief Utils Object |
61 | */ | 61 | */ |
62 | typedef struct | 62 | typedef struct Ipc_UtilsObj_s |
63 | { | 63 | { |
64 | uint32_t state; | 64 | uint32_t state; |
65 | /**< State indicator */ | 65 | /**< State indicator */ |
@@ -109,9 +109,9 @@ void* IpcUtils_QgetHead(IpcUtils_QHandle *handle) | |||
109 | return (rtnVal); | 109 | return (rtnVal); |
110 | } | 110 | } |
111 | 111 | ||
112 | bool IpcUtils_QisEmpty(IpcUtils_QHandle *handle) | 112 | uint8_t IpcUtils_QisEmpty(IpcUtils_QHandle *handle) |
113 | { | 113 | { |
114 | bool rtnVal = FALSE; | 114 | uint8_t rtnVal = 0U; |
115 | if (handle->next == handle) | 115 | if (handle->next == handle) |
116 | { | 116 | { |
117 | rtnVal = TRUE; | 117 | rtnVal = TRUE; |
diff --git a/src/ipc_utils.h b/src/ipc_utils.h index d500080..d61a81e 100644 --- a/src/ipc_utils.h +++ b/src/ipc_utils.h | |||
@@ -56,11 +56,11 @@ extern "C" { | |||
56 | /* ========================================================================== */ | 56 | /* ========================================================================== */ |
57 | 57 | ||
58 | /** \brief Queue Element type */ | 58 | /** \brief Queue Element type */ |
59 | typedef struct IpcUtils_QElem | 59 | typedef struct IpcUtils_QElem_s |
60 | { | 60 | { |
61 | struct IpcUtils_QElem *next; | 61 | struct IpcUtils_QElem_s *next; |
62 | /**< Next Node */ | 62 | /**< Next Node */ |
63 | struct IpcUtils_QElem *prev; | 63 | struct IpcUtils_QElem_s *prev; |
64 | /**< Next Node */ | 64 | /**< Next Node */ |
65 | void *pData; | 65 | void *pData; |
66 | /**< Pointer to data */ | 66 | /**< Pointer to data */ |
@@ -115,6 +115,17 @@ typedef IpcUtils_HeapElem IpcUtils_HeapHandle; | |||
115 | int32_t IpcUtils_Init(Ipc_OsalPrms *pOsalInit); | 115 | int32_t IpcUtils_Init(Ipc_OsalPrms *pOsalInit); |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * \brief IpcUtils_DeInit | ||
119 | * | ||
120 | * DeInitializes the IPC utilites. | ||
121 | * | ||
122 | * \param None | ||
123 | * | ||
124 | * \return IPC_SOK | ||
125 | */ | ||
126 | int32_t IpcUtils_DeInit(void); | ||
127 | |||
128 | /** | ||
118 | * \brief IpcUtils_QgetHead | 129 | * \brief IpcUtils_QgetHead |
119 | * | 130 | * |
120 | * Returns the head node of the queue | 131 | * Returns the head node of the queue |
@@ -133,7 +144,7 @@ void* IpcUtils_QgetHead(IpcUtils_QHandle *handle); | |||
133 | * | 144 | * |
134 | * \return TRUE in case queue is empty FALSE otherwise | 145 | * \return TRUE in case queue is empty FALSE otherwise |
135 | */ | 146 | */ |
136 | bool IpcUtils_QisEmpty(IpcUtils_QHandle *handle); | 147 | uint8_t IpcUtils_QisEmpty(IpcUtils_QHandle *handle); |
137 | 148 | ||
138 | /** | 149 | /** |
139 | * \brief IpcUtils_Qput | 150 | * \brief IpcUtils_Qput |
diff --git a/src/ipc_virtio.c b/src/ipc_virtio.c index 068c800..6b4a52e 100644 --- a/src/ipc_virtio.c +++ b/src/ipc_virtio.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #define IPC_VRING_ALIGNMENT (0x1000) | 54 | #define IPC_VRING_ALIGNMENT (0x1000) |
55 | #define IPC_VRING_BUF_CNT (256) | 55 | #define IPC_VRING_BUF_CNT (256) |
56 | 56 | ||
57 | typedef struct Ipc_VirtioInfo | 57 | typedef struct Ipc_VirtioInfo_s |
58 | { | 58 | { |
59 | uint32_t daTx; /* Buffer for TX to remote core */ | 59 | uint32_t daTx; /* Buffer for TX to remote core */ |
60 | uint32_t daRx; /* Buffer for RX from remote core */ | 60 | uint32_t daRx; /* Buffer for RX from remote core */ |
@@ -67,7 +67,7 @@ typedef struct Ipc_VirtioInfo | |||
67 | uint32_t rxNotifyId; /* Notify Id for RX */ | 67 | uint32_t rxNotifyId; /* Notify Id for RX */ |
68 | } Ipc_VirtioInfo; | 68 | } Ipc_VirtioInfo; |
69 | 69 | ||
70 | typedef struct Ipc_NotifyIdEntry | 70 | typedef struct Ipc_NotifyIdEntry_s |
71 | { | 71 | { |
72 | int32_t txNotifyId; | 72 | int32_t txNotifyId; |
73 | int32_t rxNotifyId; | 73 | int32_t rxNotifyId; |
@@ -102,7 +102,7 @@ int32_t virtio_cnt = 0; | |||
102 | * RPMSG_IPC_MEM = (RP_MSG_BUFS_SPACE + 2 * RP_MSG_RING_SIZE) | 102 | * RPMSG_IPC_MEM = (RP_MSG_BUFS_SPACE + 2 * RP_MSG_RING_SIZE) |
103 | */ | 103 | */ |
104 | 104 | ||
105 | typedef struct Virtio_Object | 105 | typedef struct Virtio_Object_s |
106 | { | 106 | { |
107 | uint16_t id; | 107 | uint16_t id; |
108 | /**< Id for this VirtQueue_Object */ | 108 | /**< Id for this VirtQueue_Object */ |
@@ -113,7 +113,7 @@ typedef struct Virtio_Object | |||
113 | uint32_t* callback_priv; | 113 | uint32_t* callback_priv; |
114 | /**< The private data to pass to the callback (can be NULL) */ | 114 | /**< The private data to pass to the callback (can be NULL) */ |
115 | 115 | ||
116 | struct vring vring; | 116 | struct VRing vring; |
117 | /**< Shared state */ | 117 | /**< Shared state */ |
118 | 118 | ||
119 | uint16_t last_avail_idx; | 119 | uint16_t last_avail_idx; |
@@ -149,19 +149,19 @@ typedef struct Virtio_Object | |||
149 | /** | 149 | /** |
150 | * \brief Vring parameter | 150 | * \brief Vring parameter |
151 | */ | 151 | */ |
152 | typedef struct Vring_Params | 152 | typedef struct Vring_Params_s |
153 | { | 153 | { |
154 | uint32_t num; | 154 | uint32_t num; |
155 | uint32_t addr; | 155 | uint32_t addr; |
156 | uint32_t align; | 156 | uint32_t align; |
157 | } Vring_Params; | 157 | } Vring_Params; |
158 | 158 | ||
159 | static struct Virtio_Object *queueRegistry[MAX_VIRTQUEUES]; | 159 | static Virtio_Object *queueRegistry[MAX_VIRTQUEUES]; |
160 | static uint32_t queueCnt; | 160 | static uint32_t queueCnt; |
161 | 161 | ||
162 | /* Application provides the memory for storing local Virtio */ | 162 | /* Application provides the memory for storing local Virtio */ |
163 | static void* vqBaseAddr = NULL; | 163 | static void* vqBaseAddr = NULL; |
164 | static uint32_t vqSizeLeft = 0; | 164 | static uint32_t vqSizeLeft = 0U; |
165 | static void* rscTable = NULL; | 165 | static void* rscTable = NULL; |
166 | 166 | ||
167 | void* Ipc_allocVirtio() | 167 | void* Ipc_allocVirtio() |
@@ -222,16 +222,16 @@ uint8_t Virtio_isRemoteLinux(uint16_t procId) | |||
222 | */ | 222 | */ |
223 | uint8_t Ipc_isRemoteReady(uint16_t procId) | 223 | uint8_t Ipc_isRemoteReady(uint16_t procId) |
224 | { | 224 | { |
225 | uint8_t retVal = 1; | 225 | uint8_t retVal = TRUE; |
226 | Ipc_ResourceTable *rsc = NULL; | 226 | Ipc_ResourceTable *rsc = NULL; |
227 | 227 | ||
228 | if(Virtio_isRemoteLinux(procId)) | 228 | if(TRUE == Virtio_isRemoteLinux(procId)) |
229 | { | 229 | { |
230 | rsc = (Ipc_ResourceTable*)rscTable; | 230 | rsc = (Ipc_ResourceTable*)rscTable; |
231 | CacheP_Inv(rsc, sizeof(Ipc_ResourceTable)); | 231 | CacheP_Inv(rsc, sizeof(Ipc_ResourceTable)); |
232 | if(rsc->rpmsg_vdev.status != 0x7) | 232 | if(rsc->rpmsg_vdev.status != 0x7U) |
233 | { | 233 | { |
234 | retVal = 0; | 234 | retVal = FALSE; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | 237 | ||
@@ -245,28 +245,25 @@ int32_t Ipc_initVirtIO(Ipc_VirtIoParams *vqParam) | |||
245 | { | 245 | { |
246 | int32_t retVal = IPC_SOK; | 246 | int32_t retVal = IPC_SOK; |
247 | 247 | ||
248 | if(vqParam == NULL) | 248 | if( (vqParam == NULL) || |
249 | (vqParam->vringBufSize < IPC_VRING_BUFFER_SIZE)) | ||
249 | { | 250 | { |
250 | SystemP_printf("Ipc_initVirtIO : Null Memory, Failed\n"); | 251 | SystemP_printf("Ipc_initVirtIO : Invalid Memory, Failed\n"); |
251 | return IPC_EFAIL; | 252 | retVal = IPC_EFAIL; |
252 | } | 253 | } |
253 | 254 | ||
254 | if(vqParam->vringBufSize < IPC_VRING_BUFFER_SIZE) | 255 | if(retVal == IPC_SOK) |
255 | { | 256 | { |
256 | SystemP_printf("Failed : Not enough memory for VRing, required size 0x%X\n", | 257 | /* Initialize the global queue registry */ |
257 | IPC_VRING_BUFFER_SIZE); | 258 | memset(queueRegistry, 0, sizeof(queueRegistry)); |
258 | return IPC_EFAIL; | 259 | queueCnt = 0; |
259 | } | ||
260 | 260 | ||
261 | /* Initialize the global queue registry */ | 261 | vqBaseAddr = (void*)vqParam->vqObjBaseAddr; |
262 | memset(queueRegistry, 0, sizeof(queueRegistry)); | 262 | vqSizeLeft = vqParam->vqBufSize; |
263 | queueCnt = 0; | ||
264 | 263 | ||
265 | vqBaseAddr = (void*)vqParam->vqObjBaseAddr; | 264 | /* Initialize the shared page table and VRing */ |
266 | vqSizeLeft = vqParam->vqBufSize; | 265 | retVal = VirtioIPC_init(vqParam); |
267 | 266 | } | |
268 | /* Initialize the shared page table and VRing */ | ||
269 | retVal = VirtioIPC_init(vqParam); | ||
270 | 267 | ||
271 | return retVal; | 268 | return retVal; |
272 | } | 269 | } |
@@ -310,9 +307,9 @@ static inline uint32_t mapVAtoPA(void * va) | |||
310 | /** | 307 | /** |
311 | * \brief Check the vq status | 308 | * \brief Check the vq status |
312 | */ | 309 | */ |
313 | bool Virtio_isReady(Virtio_Handle vq) | 310 | uint8_t Virtio_isReady(Virtio_Handle vq) |
314 | { | 311 | { |
315 | return (bool)(vq->status); | 312 | return (uint8_t)(vq->status); |
316 | } | 313 | } |
317 | 314 | ||
318 | /** | 315 | /** |
@@ -331,13 +328,12 @@ void Virtio_kick(Virtio_Handle vq) | |||
331 | uint32_t selfId = Ipc_mpGetSelfId(); | 328 | uint32_t selfId = Ipc_mpGetSelfId(); |
332 | 329 | ||
333 | /* For now, simply interrupt remote processor */ | 330 | /* For now, simply interrupt remote processor */ |
334 | if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) | 331 | if (0 == (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) |
335 | { | ||
336 | return; | ||
337 | } | ||
338 | |||
339 | if (Ipc_mailboxSend(selfId, vq->procId, vq->id, vq->timeoutCnt) != IPC_SOK) | ||
340 | { | 332 | { |
333 | if (IPC_SOK != Ipc_mailboxSend(selfId, vq->procId, vq->id, vq->timeoutCnt)) | ||
334 | { | ||
335 | SystemP_printf("Virtio_kick: Ipc_mailboxSend failed\n"); | ||
336 | } | ||
341 | } | 337 | } |
342 | } | 338 | } |
343 | 339 | ||
@@ -348,10 +344,6 @@ int32_t Virtio_addUsedBuf(Virtio_Handle vq, int16_t head, int32_t len) | |||
348 | { | 344 | { |
349 | struct vring_used_elem *used; | 345 | struct vring_used_elem *used; |
350 | 346 | ||
351 | if ((head > vq->vring.num) || (head < 0)) | ||
352 | { | ||
353 | } | ||
354 | |||
355 | /* | 347 | /* |
356 | * The virtqueue contains a ring of used buffers. Get a pointer to the | 348 | * The virtqueue contains a ring of used buffers. Get a pointer to the |
357 | * next entry in that used ring. | 349 | * next entry in that used ring. |
@@ -372,7 +364,8 @@ void Virtio_addAvailBuf(Virtio_Handle vq, void *buf) | |||
372 | { | 364 | { |
373 | uint16_t avail; | 365 | uint16_t avail; |
374 | 366 | ||
375 | avail = vq->vring.avail->idx++ % vq->vring.num; | 367 | avail = vq->vring.avail->idx % vq->vring.num; |
368 | vq->vring.avail->idx++; | ||
376 | 369 | ||
377 | vq->vring.desc[avail].addr = mapVAtoPA(buf); | 370 | vq->vring.desc[avail].addr = mapVAtoPA(buf); |
378 | vq->vring.desc[avail].len = RP_MSG_BUF_SIZE; | 371 | vq->vring.desc[avail].len = RP_MSG_BUF_SIZE; |
@@ -386,18 +379,16 @@ void Virtio_addAvailBuf(Virtio_Handle vq, void *buf) | |||
386 | void *Virtio_getUsedBuf(Virtio_Handle vq) | 379 | void *Virtio_getUsedBuf(Virtio_Handle vq) |
387 | { | 380 | { |
388 | uint16_t head; | 381 | uint16_t head; |
389 | void *buf; | 382 | void *buf = NULL; |
390 | 383 | ||
391 | /* There's nothing available? */ | 384 | /* There's nothing available? */ |
392 | if (vq->last_used_idx == vq->vring.used->idx) | 385 | if (vq->last_used_idx != vq->vring.used->idx) |
393 | { | 386 | { |
394 | return (NULL); | 387 | head = vq->vring.used->ring[vq->last_used_idx % vq->vring.num].id; |
395 | } | 388 | vq->last_used_idx++; |
396 | |||
397 | head = vq->vring.used->ring[vq->last_used_idx % vq->vring.num].id; | ||
398 | vq->last_used_idx++; | ||
399 | 389 | ||
400 | buf = mapPAtoVA(vq->vring.desc[head].addr); | 390 | buf = mapPAtoVA(vq->vring.desc[head].addr); |
391 | } | ||
401 | 392 | ||
402 | return (buf); | 393 | return (buf); |
403 | } | 394 | } |
@@ -408,26 +399,30 @@ void *Virtio_getUsedBuf(Virtio_Handle vq) | |||
408 | int16_t Virtio_getAvailBuf(Virtio_Handle vq, void **buf, int32_t *len) | 399 | int16_t Virtio_getAvailBuf(Virtio_Handle vq, void **buf, int32_t *len) |
409 | { | 400 | { |
410 | uint16_t head; | 401 | uint16_t head; |
402 | int16_t retVal; | ||
411 | 403 | ||
412 | /* There's nothing available? */ | 404 | /* There's nothing available? */ |
413 | if (vq->last_avail_idx == vq->vring.avail->idx) | 405 | if (vq->last_avail_idx == vq->vring.avail->idx) |
414 | { | 406 | { |
415 | /* We need to know about added buffers */ | 407 | /* We need to know about added buffers */ |
416 | vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY; | 408 | vq->vring.used->flags &= (uint16_t)~VRING_USED_F_NO_NOTIFY; |
417 | 409 | retVal = -1; | |
418 | return (-1); | 410 | } |
411 | else | ||
412 | { | ||
413 | /* | ||
414 | * Grab the next descriptor number they're advertising, and increment | ||
415 | * the index we've seen. | ||
416 | */ | ||
417 | head = vq->vring.avail->ring[vq->last_avail_idx % vq->vring.num]; | ||
418 | vq->last_avail_idx++; | ||
419 | |||
420 | *buf = mapPAtoVA(vq->vring.desc[head].addr); | ||
421 | *len = (int32_t)vq->vring.desc[head].len; | ||
422 | retVal = (int16_t)head; | ||
419 | } | 423 | } |
420 | 424 | ||
421 | /* | 425 | return (retVal); |
422 | * Grab the next descriptor number they're advertising, and increment | ||
423 | * the index we've seen. | ||
424 | */ | ||
425 | head = vq->vring.avail->ring[vq->last_avail_idx++ % vq->vring.num]; | ||
426 | |||
427 | *buf = mapPAtoVA(vq->vring.desc[head].addr); | ||
428 | *len = vq->vring.desc[head].len; | ||
429 | |||
430 | return (head); | ||
431 | } | 426 | } |
432 | 427 | ||
433 | 428 | ||
@@ -442,9 +437,9 @@ void Virtio_disableCallback(Virtio_Handle vq) | |||
442 | /** | 437 | /** |
443 | * \brief Virtio_enableCallback | 438 | * \brief Virtio_enableCallback |
444 | */ | 439 | */ |
445 | bool Virtio_enableCallback(Virtio_Handle vq) | 440 | uint8_t Virtio_enableCallback(Virtio_Handle vq) |
446 | { | 441 | { |
447 | return (false); | 442 | return (0U); |
448 | } | 443 | } |
449 | 444 | ||
450 | 445 | ||
@@ -480,41 +475,42 @@ void Virtio_isr(uint32_t* msg, uint32_t priv) | |||
480 | { | 475 | { |
481 | int32_t retVal; | 476 | int32_t retVal; |
482 | Virtio_Object *vq = (Virtio_Object *)Ipc_allocVirtio(); | 477 | Virtio_Object *vq = (Virtio_Object *)Ipc_allocVirtio(); |
483 | if (!vq) | 478 | if (NULL != vq) |
484 | { | ||
485 | return (NULL); | ||
486 | } | ||
487 | |||
488 | vq->callback = callback; | ||
489 | vq->id = vqId; | ||
490 | vq->procId = procId; | ||
491 | vq->status = status; | ||
492 | vq->last_avail_idx = 0; | ||
493 | vq->last_used_idx = 0; | ||
494 | vq->direction = direction; | ||
495 | vq->timeoutCnt = timeoutCnt; | ||
496 | |||
497 | vring_init(&(vq->vring), params->num, (void*)(uintptr_t)params->addr, params->align); | ||
498 | |||
499 | /* Each processor clears only its TX vq memory. */ | ||
500 | if (direction == VIRTIO_TX) | ||
501 | { | 479 | { |
502 | memset((void*)(uintptr_t)params->addr, 0, vring_size(params->num, params->align)); | 480 | vq->callback = callback; |
503 | /* Don't trigger a mailbox message every time remote rpoc */ | 481 | vq->id = vqId; |
504 | /* makes another buffer available. */ | 482 | vq->procId = procId; |
505 | vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY; | 483 | vq->status = status; |
506 | } | 484 | vq->last_avail_idx = 0; |
485 | vq->last_used_idx = 0; | ||
486 | vq->direction = direction; | ||
487 | vq->timeoutCnt = timeoutCnt; | ||
488 | |||
489 | vring_init(&(vq->vring), params->num, (void*)(uintptr_t)params->addr, params->align); | ||
490 | |||
491 | /* Each processor clears only its TX vq memory. */ | ||
492 | if (direction == VIRTIO_TX) | ||
493 | { | ||
494 | memset((void*)(uintptr_t)params->addr, 0, vring_size(params->num, params->align)); | ||
495 | /* Don't trigger a mailbox message every time remote rpoc */ | ||
496 | /* makes another buffer available. */ | ||
497 | vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY; | ||
498 | } | ||
507 | 499 | ||
508 | queueRegistry[queueCnt++] = vq; | 500 | queueRegistry[queueCnt] = vq; |
501 | queueCnt++; | ||
509 | 502 | ||
510 | if (direction == VIRTIO_RX) | 503 | if (direction == VIRTIO_RX) |
511 | { | ||
512 | uint32_t selfId = Ipc_mpGetSelfId(); | ||
513 | retVal = Ipc_mailboxRegister(selfId, procId, Virtio_isr, procId); | ||
514 | if (retVal != IPC_SOK) | ||
515 | { | 504 | { |
505 | uint32_t selfId = Ipc_mpGetSelfId(); | ||
506 | retVal = Ipc_mailboxRegister(selfId, procId, Virtio_isr, procId); | ||
507 | if (retVal != IPC_SOK) | ||
508 | { | ||
509 | SystemP_printf("Virtio_create : Failed to register mailbox\n"); | ||
510 | } | ||
516 | } | 511 | } |
517 | } | 512 | } |
513 | |||
518 | return (vq); | 514 | return (vq); |
519 | } | 515 | } |
520 | 516 | ||
@@ -548,7 +544,7 @@ int32_t Virtio_setCallback(uint32_t procId, Virtio_callback callback, uint32_t* | |||
548 | int32_t status = 1; | 544 | int32_t status = 1; |
549 | Virtio_Object *vq = Virtio_getHandle(procId, VIRTIO_RX); | 545 | Virtio_Object *vq = Virtio_getHandle(procId, VIRTIO_RX); |
550 | 546 | ||
551 | if (vq) | 547 | if (NULL != vq) |
552 | { | 548 | { |
553 | vq->callback = callback; | 549 | vq->callback = callback; |
554 | vq->callback_priv = priv; | 550 | vq->callback_priv = priv; |
@@ -570,9 +566,11 @@ void Virtio_prime(Virtio_Object *vq, uint32_t addr, uint32_t num) | |||
570 | uint32_t buf; | 566 | uint32_t buf; |
571 | 567 | ||
572 | /* Add buffers to the vring's available ring. */ | 568 | /* Add buffers to the vring's available ring. */ |
573 | for (i = 0, buf = addr; i<num; i++, buf += RP_MSG_BUF_SIZE) | 569 | buf = addr; |
570 | for (i = 0; i < num; i++) | ||
574 | { | 571 | { |
575 | Virtio_addAvailBuf(vq, (void *)(uintptr_t)buf); | 572 | Virtio_addAvailBuf(vq, (void *)(uintptr_t)buf); |
573 | buf += RP_MSG_BUF_SIZE; | ||
576 | } | 574 | } |
577 | } | 575 | } |
578 | 576 | ||
@@ -601,23 +599,26 @@ static uint32_t g_vqItemCnt = 0; | |||
601 | * Look up the VirtQueues by procId. | 599 | * Look up the VirtQueues by procId. |
602 | * Rank is 0 for primary VQs. | 600 | * Rank is 0 for primary VQs. |
603 | */ | 601 | */ |
604 | bool VirtioIPC_getVirtQueues(uint32_t type, uint32_t procId, uint32_t rank, | 602 | uint8_t VirtioIPC_getVirtQueues(uint32_t type, uint32_t procId, uint32_t rank, |
605 | uint32_t *tx_vqId, uint32_t *rx_vqId) | 603 | uint32_t *tx_vqId, uint32_t *rx_vqId) |
606 | { | 604 | { |
607 | int32_t i; | 605 | int32_t i; |
606 | uint8_t retVal = FALSE; | ||
608 | 607 | ||
609 | for (i= 0; i<g_vqItemCnt; i++) | 608 | for (i = 0; i < g_vqItemCnt; i++) |
610 | { | 609 | { |
611 | if (type == g_vqTable[i].virtioId && | 610 | if ((type == g_vqTable[i].virtioId) && |
612 | rank == g_vqTable[i].rank && | 611 | (rank == g_vqTable[i].rank) && |
613 | procId == g_vqTable[i].procId) | 612 | (procId == g_vqTable[i].procId)) |
614 | { | 613 | { |
615 | *tx_vqId = g_vqTable[i].tx_vqId; | 614 | *tx_vqId = g_vqTable[i].tx_vqId; |
616 | *rx_vqId = g_vqTable[i].rx_vqId; | 615 | *rx_vqId = g_vqTable[i].rx_vqId; |
617 | return true; | 616 | retVal = TRUE; |
617 | break; | ||
618 | } | 618 | } |
619 | } | 619 | } |
620 | return false; | 620 | |
621 | return retVal; | ||
621 | } | 622 | } |
622 | 623 | ||
623 | /** | 624 | /** |
@@ -678,9 +679,9 @@ int32_t VirtioIPC_createVirtioCorePair(Ipc_VirtioInfo* vqInfo, uint32_t timeoutC | |||
678 | return retVal; | 679 | return retVal; |
679 | } | 680 | } |
680 | 681 | ||
681 | bool Ipc_isRemoteVirtioCreated(uint32_t remoteId) | 682 | uint8_t Ipc_isRemoteVirtioCreated(uint32_t remoteId) |
682 | { | 683 | { |
683 | bool vqCreated = FALSE; | 684 | uint8_t vqCreated = FALSE; |
684 | uint32_t index = 0; | 685 | uint32_t index = 0; |
685 | 686 | ||
686 | for(index = 0; index < g_vqItemCnt; index++) | 687 | for(index = 0; index < g_vqItemCnt; index++) |
@@ -737,7 +738,7 @@ void Ipc_updateVirtioInfo(uint32_t numProc, void *baseAddr, uint32_t vrBufSize, | |||
737 | /* If remote core is Linux, and vdev is ready | 738 | /* If remote core is Linux, and vdev is ready |
738 | * update the address | 739 | * update the address |
739 | */ | 740 | */ |
740 | if(Virtio_isRemoteLinux(info->remoteId)) | 741 | if(TRUE == Virtio_isRemoteLinux(info->remoteId)) |
741 | { | 742 | { |
742 | Ipc_ResourceTable *rsc = (Ipc_ResourceTable*)rscTable; | 743 | Ipc_ResourceTable *rsc = (Ipc_ResourceTable*)rscTable; |
743 | info->daTx = rsc->rpmsg_vring0.da; | 744 | info->daTx = rsc->rpmsg_vring0.da; |
@@ -777,7 +778,7 @@ int32_t VirtioIPC_init(Ipc_VirtIoParams *vqParams) | |||
777 | continue; | 778 | continue; |
778 | } | 779 | } |
779 | 780 | ||
780 | if(!Ipc_isRemoteReady(procId)) | 781 | if(FALSE == Ipc_isRemoteReady(procId)) |
781 | { | 782 | { |
782 | /* Linux on A72 is not ready, go to next core | 783 | /* Linux on A72 is not ready, go to next core |
783 | * Virtio is not created at this moment, it must be | 784 | * Virtio is not created at this moment, it must be |
@@ -812,7 +813,7 @@ int32_t Ipc_lateVirtioCreate(uint16_t procId) | |||
812 | Ipc_VirtioInfo vqInfo; | 813 | Ipc_VirtioInfo vqInfo; |
813 | uint32_t vrBufSize = IPC_VRING_SIZE; | 814 | uint32_t vrBufSize = IPC_VRING_SIZE; |
814 | 815 | ||
815 | if(Ipc_isRemoteReady(procId)) | 816 | if(TRUE == Ipc_isRemoteReady(procId)) |
816 | { | 817 | { |
817 | /* Initialize the structure */ | 818 | /* Initialize the structure */ |
818 | memset(&vqInfo, 0, sizeof(Ipc_VirtioInfo)); | 819 | memset(&vqInfo, 0, sizeof(Ipc_VirtioInfo)); |
diff --git a/src/ipc_virtioPrivate.h b/src/ipc_virtioPrivate.h index 09bca82..0403aa7 100644 --- a/src/ipc_virtioPrivate.h +++ b/src/ipc_virtioPrivate.h | |||
@@ -59,19 +59,19 @@ extern "C" { | |||
59 | /** | 59 | /** |
60 | * \brief Enumeration for Virtio direction | 60 | * \brief Enumeration for Virtio direction |
61 | */ | 61 | */ |
62 | typedef enum VIRTIO_DIR | 62 | typedef enum VIRTIO_DIR_e |
63 | { | 63 | { |
64 | VIRTIO_TX, | 64 | VIRTIO_TX, |
65 | VIRTIO_RX | 65 | VIRTIO_RX |
66 | } VIRTIO_DIR; | 66 | } VIRTIO_DIR; |
67 | 67 | ||
68 | typedef struct Virtio_Object *Virtio_Handle; | 68 | typedef struct Virtio_Object_s* Virtio_Handle; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * @brief Signature of a callback function that can be registered | 71 | * @brief Signature of a callback function that can be registered |
72 | * with the Virtio | 72 | * with the Virtio |
73 | */ | 73 | */ |
74 | typedef void (*Virtio_callback)(uint32_t*); | 74 | typedef void (*Virtio_callback)(uint32_t* arg); |
75 | 75 | ||
76 | /* ========================================================================== */ | 76 | /* ========================================================================== */ |
77 | /* Structure Declarations */ | 77 | /* Structure Declarations */ |
@@ -161,7 +161,7 @@ uint32_t Virtio_getProcId(Virtio_Handle vq); | |||
161 | * | 161 | * |
162 | * \sa VirtioIPC_getVirtQueues | 162 | * \sa VirtioIPC_getVirtQueues |
163 | */ | 163 | */ |
164 | bool VirtioIPC_getVirtQueues(uint32_t type, uint32_t procId, uint32_t rank, | 164 | uint8_t VirtioIPC_getVirtQueues(uint32_t type, uint32_t procId, uint32_t rank, |
165 | uint32_t *tx_vqId, uint32_t *rx_vqId); | 165 | uint32_t *tx_vqId, uint32_t *rx_vqId); |
166 | 166 | ||
167 | /** | 167 | /** |
@@ -211,7 +211,7 @@ int32_t VirtioIPC_init(Ipc_VirtIoParams* vqInfo); | |||
211 | * | 211 | * |
212 | * \sa Virtio_isReady | 212 | * \sa Virtio_isReady |
213 | */ | 213 | */ |
214 | bool Virtio_isReady(Virtio_Handle vq); | 214 | uint8_t Virtio_isReady(Virtio_Handle vq); |
215 | 215 | ||
216 | 216 | ||
217 | /* | 217 | /* |
diff --git a/src/ipc_vring.h b/src/ipc_vring.h index 45fc33e..c5e5489 100755 --- a/src/ipc_vring.h +++ b/src/ipc_vring.h | |||
@@ -83,26 +83,26 @@ extern "C" { | |||
83 | /** | 83 | /** |
84 | * \brief This marks a buffer as continuing via the next field. | 84 | * \brief This marks a buffer as continuing via the next field. |
85 | */ | 85 | */ |
86 | #define VRING_DESC_F_NEXT 1 | 86 | #define VRING_DESC_F_NEXT 1U |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * \brief This marks a buffer as write-only (otherwise read-only). | 89 | * \brief This marks a buffer as write-only (otherwise read-only). |
90 | */ | 90 | */ |
91 | #define VRING_DESC_F_WRITE 2 | 91 | #define VRING_DESC_F_WRITE 2U |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * \brief The Host uses this in used->flags to advise the Guest: don't kick | 94 | * \brief The Host uses this in used->flags to advise the Guest: don't kick |
95 | * me when you add a buffer. It's unreliable, so it's simply an | 95 | * me when you add a buffer. It's unreliable, so it's simply an |
96 | * optimization. Guest will still kick if it's out of buffers. | 96 | * optimization. Guest will still kick if it's out of buffers. |
97 | */ | 97 | */ |
98 | #define VRING_USED_F_NO_NOTIFY 1 | 98 | #define VRING_USED_F_NO_NOTIFY 1U |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * \brief The Guest uses this in avail->flags to advise the Host: don't | 101 | * \brief The Guest uses this in avail->flags to advise the Host: don't |
102 | * interrupt me when you consume a buffer. It's unreliable, so it's | 102 | * interrupt me when you consume a buffer. It's unreliable, so it's |
103 | * simply an optimization. | 103 | * simply an optimization. |
104 | */ | 104 | */ |
105 | #define VRING_AVAIL_F_NO_INTERRUPT 1 | 105 | #define VRING_AVAIL_F_NO_INTERRUPT 1U |
106 | 106 | ||
107 | 107 | ||
108 | /* ========================================================================== */ | 108 | /* ========================================================================== */ |
@@ -165,7 +165,7 @@ struct vring_used | |||
165 | struct vring_used_elem ring[256]; | 165 | struct vring_used_elem ring[256]; |
166 | }; | 166 | }; |
167 | 167 | ||
168 | struct vring | 168 | struct VRing |
169 | { | 169 | { |
170 | uint32_t num; | 170 | uint32_t num; |
171 | struct vring_desc *desc; | 171 | struct vring_desc *desc; |
@@ -183,7 +183,7 @@ struct vring | |||
183 | /* Static Function Definitions */ | 183 | /* Static Function Definitions */ |
184 | /* ========================================================================== */ | 184 | /* ========================================================================== */ |
185 | 185 | ||
186 | static inline void vring_init(struct vring *vr, uint32_t num, void *p, | 186 | static inline void vring_init(struct VRing *vr, uint32_t num, void *p, |
187 | uint32_t pagesize) | 187 | uint32_t pagesize) |
188 | { | 188 | { |
189 | vr->num = num; | 189 | vr->num = num; |