summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/tirtos/HwiP_tirtos.c')
-rw-r--r--src/tirtos/HwiP_tirtos.c87
1 files changed, 51 insertions, 36 deletions
diff --git a/src/tirtos/HwiP_tirtos.c b/src/tirtos/HwiP_tirtos.c
index ca03e4b..4faaa74 100644
--- a/src/tirtos/HwiP_tirtos.c
+++ b/src/tirtos/HwiP_tirtos.c
@@ -38,6 +38,7 @@
38#include <stdint.h> 38#include <stdint.h>
39#include <stdbool.h> 39#include <stdbool.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h>
41 42
42#include <xdc/std.h> 43#include <xdc/std.h>
43#include <xdc/runtime/Error.h> 44#include <xdc/runtime/Error.h>
@@ -70,8 +71,8 @@
70 71
71#include <ti/osal/src/tirtos/tirtos_config.h> 72#include <ti/osal/src/tirtos/tirtos_config.h>
72 73
73extern void _DebugP_assert(int32_t expression, const char *file, int32_t line); 74extern void Osal_DebugP_assert(int32_t expression, const char *file, int32_t line);
74#define HWIPOSAL_Assert(expression) (_DebugP_assert((expression), \ 75#define HWIPOSAL_Assert(expression) (Osal_DebugP_assert((int32_t)((expression)?1:0),\
75 __FILE__, __LINE__)) 76 __FILE__, __LINE__))
76 77
77extern uint32_t gOsalHwiAllocCnt, gOsalHwiPeak; 78extern uint32_t gOsalHwiAllocCnt, gOsalHwiPeak;
@@ -85,7 +86,7 @@ typedef struct HwiP_tiRtos_s {
85} HwiP_tiRtos; 86} HwiP_tiRtos;
86 87
87/* global pool of statically allocated semaphore pools */ 88/* global pool of statically allocated semaphore pools */
88static HwiP_tiRtos gOsalHwiPTiRtosPool[OSAL_TIRTOS_CONFIGNUM_HWI] = {{0}}; 89static HwiP_tiRtos gOsalHwiPTiRtosPool[OSAL_TIRTOS_CONFIGNUM_HWI];
89 90
90/* 91/*
91 * Dummy function to check size during compile time 92 * Dummy function to check size during compile time
@@ -101,7 +102,7 @@ void HwiP_compileTime_SizeChk(void)
101/* TI compiler */ 102/* TI compiler */
102#pragma diag_suppress 179 103#pragma diag_suppress 179
103#endif 104#endif
104 OSAL_COMPILE_TIME_SIZE_CHECK (sizeof(HwiP_tiRtos) < OSAL_TIRTOS_HWIP_SIZE_BYTES); 105 OSAL_COMPILE_TIME_SIZE_CHECK ((uint32_t)sizeof(HwiP_tiRtos),OSAL_TIRTOS_HWIP_SIZE_BYTES);
105#if defined(__GNUC__) && !defined(__ti__) 106#if defined(__GNUC__) && !defined(__ti__)
106#pragma GCC diagnostic pop 107#pragma GCC diagnostic pop
107#endif 108#endif
@@ -119,9 +120,9 @@ void HwiP_clearInterrupt(int32_t interruptNum)
119 * ======== HwiP_create ======== 120 * ======== HwiP_create ========
120 */ 121 */
121HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn, 122HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
122 HwiP_Params *params) 123 const HwiP_Params *params)
123{ 124{
124 HwiP_tiRtos *handle = (HwiP_tiRtos *) NULL; 125 HwiP_tiRtos *handle = NULL_PTR;
125 Hwi_Params hwiParams; 126 Hwi_Params hwiParams;
126 Error_Block eb; 127 Error_Block eb;
127 uint32_t i; 128 uint32_t i;
@@ -133,7 +134,7 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
133 /* Check if user has specified any memory block to be used, which gets 134 /* Check if user has specified any memory block to be used, which gets
134 * the precedence over the internal static memory block 135 * the precedence over the internal static memory block
135 */ 136 */
136 if (gOsal_HwAttrs.extHwiPBlock.base != (uintptr_t)NULL) 137 if (gOsal_HwAttrs.extHwiPBlock.base != (uintptr_t)0U)
137 { 138 {
138 /* pick up the external memory block configured */ 139 /* pick up the external memory block configured */
139 hwiPool = (HwiP_tiRtos *) gOsal_HwAttrs.extHwiPBlock.base; 140 hwiPool = (HwiP_tiRtos *) gOsal_HwAttrs.extHwiPBlock.base;
@@ -145,12 +146,17 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
145 /* Pick up the internal static memory block */ 146 /* Pick up the internal static memory block */
146 hwiPool = (HwiP_tiRtos *) &gOsalHwiPTiRtosPool[0]; 147 hwiPool = (HwiP_tiRtos *) &gOsalHwiPTiRtosPool[0];
147 maxHwi = OSAL_TIRTOS_CONFIGNUM_HWI; 148 maxHwi = OSAL_TIRTOS_CONFIGNUM_HWI;
149
150 if(gOsalHwiAllocCnt==0U)
151 {
152 (void)memset((void *)gOsalHwiPTiRtosPool,0,sizeof(gOsalHwiPTiRtosPool));
153 }
148 } 154 }
149 155
150 /* Grab the memory */ 156 /* Grab the memory */
151 key = HwiP_disable(); 157 key = HwiP_disable();
152 158
153 for (i = 0; i < maxHwi; i++) 159 for (i = 0U; i < maxHwi; i++)
154 { 160 {
155 if (hwiPool[i].used == FALSE) 161 if (hwiPool[i].used == FALSE)
156 { 162 {
@@ -172,14 +178,14 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
172 handle = (HwiP_tiRtos *) &hwiPool[i]; 178 handle = (HwiP_tiRtos *) &hwiPool[i];
173 } 179 }
174 180
175 if (handle != NULL) 181 if (handle != NULL_PTR)
176 { 182 {
177 /* Initialize the error */ 183 /* Initialize the error */
178 Error_init(&eb); 184 Error_init(&eb);
179 185
180 if (params == NULL) 186 if (params == NULL_PTR)
181 { 187 {
182 Hwi_construct(&handle->hwi, interruptNum, (Hwi_FuncPtr)hwiFxn, NULL, &eb); 188 Hwi_construct(&handle->hwi, interruptNum, (Hwi_FuncPtr)hwiFxn, NULL_PTR, &eb);
183 } 189 }
184 else 190 else
185 { 191 {
@@ -187,7 +193,7 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
187 hwiParams.instance->name = params->name; 193 hwiParams.instance->name = params->name;
188 hwiParams.arg = (xdc_UArg)(params->arg); 194 hwiParams.arg = (xdc_UArg)(params->arg);
189 195
190 if (params->priority==0) 196 if (params->priority==0U)
191 { 197 {
192 /* A priority of 0 is invalid for many targets. -1 forces 198 /* A priority of 0 is invalid for many targets. -1 forces
193 sysbios to assign a default priority */ 199 sysbios to assign a default priority */
@@ -195,10 +201,10 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
195 } 201 }
196 else 202 else
197 { 203 {
198 hwiParams.priority = (int)params->priority; 204 hwiParams.priority = (int32_t)params->priority;
199 } 205 }
200 206
201 hwiParams.eventId = (int)params->evtId; 207 hwiParams.eventId = (int32_t)params->evtId;
202 if (params->enableIntr == TRUE) 208 if (params->enableIntr == TRUE)
203 { 209 {
204 hwiParams.enableInt = TRUE; 210 hwiParams.enableInt = TRUE;
@@ -237,9 +243,9 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
237#endif 243#endif
238#if defined (__TI_ARM_V7R4__) 244#if defined (__TI_ARM_V7R4__)
239 /* Set the trigger type */ 245 /* Set the trigger type */
240 if ((params->triggerSensitivity == OSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL) || 246 if ((params->triggerSensitivity == (uint32_t)OSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL) ||
241 (params->triggerSensitivity == OSAL_ARM_GIC_TRIG_TYPE_LEVEL) || 247 (params->triggerSensitivity == (uint32_t)OSAL_ARM_GIC_TRIG_TYPE_LEVEL) ||
242 (params->triggerSensitivity == OSAL_ARM_GIC_TRIG_TYPE_LOW_LEVEL)) 248 (params->triggerSensitivity == (uint32_t)OSAL_ARM_GIC_TRIG_TYPE_LOW_LEVEL))
243 { 249 {
244 hwiParams.triggerType = Hwi_TriggerType_LEVEL; 250 hwiParams.triggerType = Hwi_TriggerType_LEVEL;
245 } 251 }
@@ -251,11 +257,11 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
251 Hwi_construct(&handle->hwi, interruptNum, (Hwi_FuncPtr)hwiFxn, 257 Hwi_construct(&handle->hwi, interruptNum, (Hwi_FuncPtr)hwiFxn,
252 &hwiParams, &eb); 258 &hwiParams, &eb);
253 259
254 if (Error_check(&eb)) 260 if (Error_check(&eb)>0U)
255 { 261 {
256 /* Free the allocated memory and return null */ 262 /* Free the allocated memory and return null */
257 handle->used = FALSE; 263 handle->used = FALSE;
258 handle = (HwiP_tiRtos *) NULL; 264 handle = NULL_PTR;
259 } 265 }
260 } 266 }
261 } 267 }
@@ -268,22 +274,31 @@ HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn,
268 */ 274 */
269HwiP_Status HwiP_delete(HwiP_Handle handle) 275HwiP_Status HwiP_delete(HwiP_Handle handle)
270{ 276{
271 HWIPOSAL_Assert((handle == NULL)); 277 HWIPOSAL_Assert((handle == NULL_PTR));
272 278
273 uintptr_t key; 279 uintptr_t key;
280 HwiP_Status ret;
281
274 HwiP_tiRtos *hwi = (HwiP_tiRtos *)handle; 282 HwiP_tiRtos *hwi = (HwiP_tiRtos *)handle;
275 283
276 Hwi_destruct(&hwi->hwi); 284 if(hwi!=NULL_PTR) {
277 key = HwiP_disable(); 285 Hwi_destruct(&hwi->hwi);
278 hwi->used = FALSE; 286 key = HwiP_disable();
279 /* Found the osal hwi object to delete */ 287 hwi->used = FALSE;
280 if (gOsalHwiAllocCnt > 0U) 288 /* Found the osal hwi object to delete */
281 { 289 if (gOsalHwiAllocCnt > 0U)
290 {
282 gOsalHwiAllocCnt--; 291 gOsalHwiAllocCnt--;
283 } 292 }
284 293
285 HwiP_restore(key); 294 HwiP_restore(key);
286 return (HwiP_OK); 295 ret = HwiP_OK;
296 }
297 else
298 {
299 ret = HwiP_FAILURE;
300 }
301 return (ret);
287} 302}
288 303
289/* 304/*
@@ -303,7 +318,7 @@ uintptr_t HwiP_disable(void)
303 */ 318 */
304void HwiP_disableInterrupt(int32_t interruptNum) 319void HwiP_disableInterrupt(int32_t interruptNum)
305{ 320{
306 Hwi_disableInterrupt((uint32_t)interruptNum); 321 (void)Hwi_disableInterrupt((uint32_t)interruptNum);
307} 322}
308 323
309/* 324/*
@@ -311,7 +326,7 @@ void HwiP_disableInterrupt(int32_t interruptNum)
311 */ 326 */
312void HwiP_enableInterrupt(int32_t interruptNum) 327void HwiP_enableInterrupt(int32_t interruptNum)
313{ 328{
314 Hwi_enableInterrupt((uint32_t)interruptNum); 329 (void)Hwi_enableInterrupt((uint32_t)interruptNum);
315} 330}
316 331
317/* 332/*
@@ -319,13 +334,13 @@ void HwiP_enableInterrupt(int32_t interruptNum)
319 */ 334 */
320void HwiP_Params_init(HwiP_Params *params) 335void HwiP_Params_init(HwiP_Params *params)
321{ 336{
322 params->name = NULL; 337 params->name = NULL_PTR;
323 params->arg = 0; 338 params->arg = 0;
324 params->priority = HWIP_USE_DEFAULT_PRIORITY; 339 params->priority = HWIP_USE_DEFAULT_PRIORITY;
325 params->evtId = 0; 340 params->evtId = 0;
326 params->enableIntr = TRUE; 341 params->enableIntr = TRUE;
327#if defined (__ARM_ARCH_7A__) || defined(__aarch64__) || defined (__TI_ARM_V7R4__) || defined(gnu_targets_arm_A15F) || defined(gnu_targets_arm_A9F) 342#if defined (__ARM_ARCH_7A__) || defined(__aarch64__) || defined (__TI_ARM_V7R4__) || defined(gnu_targets_arm_A15F) || defined(gnu_targets_arm_A9F)
328 params->triggerSensitivity = OSAL_ARM_GIC_TRIG_TYPE_LEVEL; 343 params->triggerSensitivity = (uint32_t)OSAL_ARM_GIC_TRIG_TYPE_LEVEL;
329#endif 344#endif
330 345
331#if defined(__GNUC__) && !defined(__ti__) 346#if defined(__GNUC__) && !defined(__ti__)
@@ -333,7 +348,7 @@ void HwiP_Params_init(HwiP_Params *params)
333#pragma GCC diagnostic ignored "-Wunused-variable" 348#pragma GCC diagnostic ignored "-Wunused-variable"
334#endif 349#endif
335 350
336 OSAL_COMPILE_TIME_SIZE_CHECK (sizeof(HwiP_tiRtos) < OSAL_TIRTOS_HWIP_SIZE_BYTES); 351 OSAL_COMPILE_TIME_SIZE_CHECK ((uint32_t)sizeof(HwiP_tiRtos),OSAL_TIRTOS_HWIP_SIZE_BYTES);
337 352
338#if defined(__GNUC__) && !defined(__ti__) 353#if defined(__GNUC__) && !defined(__ti__)
339#pragma GCC diagnostic pop 354#pragma GCC diagnostic pop
@@ -360,5 +375,5 @@ int32_t HwiP_post(uint32_t interruptNum)
360 */ 375 */
361void HwiP_restore(uintptr_t key) 376void HwiP_restore(uintptr_t key)
362{ 377{
363 Hwi_restore(key); 378 (void)Hwi_restore((uint32_t)key);
364} 379}