Part Number: AM5728
I attempted to add GateMP functionality to the IPC BIg Data Example and get a segment fault on the first GateMP_enter() call. Any suggestions are appreciated. Apparently I don't have permission to post code so I've included it inline. I apologize that it's hard to read.
/*
* ======== App_exec ========
*/
Int App_exec(Void)
{
Int status;
App_Msg * msg;
UInt32 *bigDataLocalPtr;
Int i,j;
UInt16 regionId1=1;
SharedRegion_Entry *pSrEntry;
void *sharedRegionAllocPtr=NULL;
Int pool_id;
CMEM_AllocParams cmemAttrs;
HeapMem_Handle sr1Heap;
UInt16 regionId;
UInt32 errorCount=0;
Int retVal;
bigDataLocalDesc_t bigDataLocalDesc;
SharedRegion_Config sharedRegionConfig;
SharedRegion_Entry srEntry;
HeapMem_Config HeapMemConfig;
HeapMem_Params heapMem_params;
Memory_Stats stats;
HeapMem_ExtendedStats extStats;
GateMP_Params gparams;
GateMP_Handle gateHandle;
IArg gateKey;
printf("--> App_exec-4:\n");
/* CMEM: contiguous memory manager for HLOS */
/* initialised here */
status = CMEM_init();
if (status < 0) {
printf("CMEM_init failed\n");
goto leave;
}
else {
printf("CMEM_init success\n");
}
pool_id = CMEM_getPool(BIG_DATA_POOL_SIZE);
if (pool_id < 0) {
printf("CMEM_getPool failed\n");
goto leave;
}
printf("CMEM_getPool success\n");
cmemAttrs.type = CMEM_HEAP;
cmemAttrs.flags = CMEM_CACHED;
cmemAttrs.alignment = 0;
sharedRegionAllocPtr = CMEM_allocPool(pool_id, &cmemAttrs);
if (sharedRegionAllocPtr == NULL) {
printf("CMEM_allocPool failed\n");
goto leave;
}
printf("CMEM_allocPool success: Allocated buffer %p\n", sharedRegionAllocPtr);
/* Create shared region */
SharedRegion_getConfig (&sharedRegionConfig);
status = SharedRegion_setup (&sharedRegionConfig);
if (status < 0) {
printf("SharedRegion_setup failed\n");
goto leave;
}
printf("SharedRegion_setup success\n");
/* Configure srEntry */
srEntry.base = sharedRegionAllocPtr;
srEntry.len = BIG_DATA_POOL_SIZE;
srEntry.ownerProcId = MultiProc_self();
/* Make sure this is enabled if using Cached memory */
srEntry.isValid = TRUE;
srEntry.cacheEnable = TRUE;
srEntry.createHeap = FALSE;
srEntry.cacheLineSize = 128;
srEntry.name = "SR1";
status = SharedRegion_setEntry (regionId1, &srEntry);
pSrEntry = SharedRegion_getEntryPtr(regionId1);
printf("App_taskFxn: SR_1, base 0x%x, len=%x\n", (UInt32)pSrEntry->base, pSrEntry->len);
regionId = regionId1;
/* Setup HeapMem module */
HeapMem_getConfig (&HeapMemConfig);
status = HeapMem_setup (&HeapMemConfig);
if (status < 0) {
printf("HeapMem_setup failed\n");
goto leave;
}
printf("HeapMem_setup success\n");
/* Create HeapMP at run-time:
This heap is intended to be used for big data ipc */
HeapMem_Params_init(&heapMem_params);
heapMem_params.name = "sr1HeapMem";
heapMem_params.sharedAddr = pSrEntry->base;
heapMem_params.sharedBufSize = ROUNDUP(pSrEntry->len, pSrEntry->cacheLineSize);
heapMem_params.gate = NULL;
sr1Heap = HeapMem_create(&heapMem_params);
if (!sr1Heap) {
printf("sr1Heap creation failed\n");
status = -1;
goto leave;
}
printf("HeapMem_create success\n");
HeapMem_getStats((HeapMem_Handle)sr1Heap, &stats);
printf("App_taskFxn: SR_1 heap, totalSize=%d,totalFreeSize=%d,largestFreeSize=%d\n", stats.totalSize, stats.totalFreeSize, stats.largestFreeSize);
HeapMem_getExtendedStats((HeapMem_Handle)sr1Heap, &extStats);
printf("App_taskFxn: SR_1 heap, buf=0x%p,size=%d\n", extStats.buf, extStats.size);
//==========================================
// Create GateMP object
//==========================================
GateMP_Params_init(&gparams);
gparams.localProtect = GateMP_LocalProtect_THREAD;
gparams.remoteProtect = GateMP_RemoteProtect_SYSTEM;
gparams.name = "myGate";
gparams.regionId = regionId1;
gateHandle = GateMP_create(&gparams);
printf ("GateMP created \n");
gateKey = GateMP_enter (gateHandle);
printf ("GateMP entered \n");