static int init_portal(struct PortalInternal *pint, void *param) { initPortalHardware(); char oldname[128]; int i; snprintf(oldname, sizeof(oldname), "/dev/portal_%d_%d", pint->fpga_tile, pint->fpga_number); //FIXME: race condition on Zynq between cat /dev/connectal and here for (i = 0; i < 5; i++) { // try old style name pint->fpga_fd = open(oldname, O_RDWR); if (pint->fpga_fd >= 0) break; // retry if EACCESS if (errno == EACCES && i != 4) { sleep(1); continue; } // else fail PORTAL_PRINTF("Failed to open %s fd=%d errno=%d:%s\n", oldname, pint->fpga_fd, errno, strerror(errno)); return -errno; } pint->map_base = (volatile unsigned int*)portalMmap(pint->fpga_fd, PORTAL_BASE_OFFSET); if (pint->map_base == MAP_FAILED) { PORTAL_PRINTF("Failed to mmap PortalHWRegs from fd=%d errno=%d\n", pint->fpga_fd, errno); return -errno; } portalPtr = &pint->map_base[PORTAL_FIFO(0)]; return 0; }
int MemServerRequestJson_handleMessage(struct PortalInternal *p, unsigned int channel, int messageFd) { static int runaway = 0; int tmp __attribute__ ((unused)); int tmpfd __attribute__ ((unused)); MemServerRequestData tempdata __attribute__ ((unused)); channel = connnectalJsonDecode(p, channel, &tempdata, MemServerRequestInfo); switch (channel) { case CHAN_NUM_MemServerRequest_addrTrans: { ((MemServerRequestCb *)p->cb)->addrTrans(p, tempdata.addrTrans.sglId, tempdata.addrTrans.offset); } break; case CHAN_NUM_MemServerRequest_setTileState: { ((MemServerRequestCb *)p->cb)->setTileState(p, tempdata.setTileState.tc); } break; case CHAN_NUM_MemServerRequest_stateDbg: { ((MemServerRequestCb *)p->cb)->stateDbg(p, tempdata.stateDbg.rc); } break; case CHAN_NUM_MemServerRequest_memoryTraffic: { ((MemServerRequestCb *)p->cb)->memoryTraffic(p, tempdata.memoryTraffic.rc); } break; default: PORTAL_PRINTF("MemServerRequestJson_handleMessage: unknown channel 0x%x\n", channel); if (runaway++ > 10) { PORTAL_PRINTF("MemServerRequestJson_handleMessage: too many bogus indications, exiting\n"); #ifndef __KERNEL__ exit(-1); #endif } return 0; } return 0; }
int DmaRequestJson_handleMessage(struct PortalInternal *p, unsigned int channel, int messageFd) { static int runaway = 0; int tmp __attribute__ ((unused)); int tmpfd __attribute__ ((unused)); DmaRequestData tempdata __attribute__ ((unused)); channel = connnectalJsonDecode(p, channel, &tempdata, DmaRequestInfo); switch (channel) { case CHAN_NUM_DmaRequest_writeRequestSize: { ((DmaRequestCb *)p->cb)->writeRequestSize(p, tempdata.writeRequestSize.burstLenBytes); } break; case CHAN_NUM_DmaRequest_readRequestSize: { ((DmaRequestCb *)p->cb)->readRequestSize(p, tempdata.readRequestSize.readRequestBytes); } break; case CHAN_NUM_DmaRequest_transferToFpga: { ((DmaRequestCb *)p->cb)->transferToFpga(p, tempdata.transferToFpga.objId, tempdata.transferToFpga.base, tempdata.transferToFpga.bytes, tempdata.transferToFpga.tag); } break; case CHAN_NUM_DmaRequest_transferFromFpga: { ((DmaRequestCb *)p->cb)->transferFromFpga(p, tempdata.transferFromFpga.objId, tempdata.transferFromFpga.base, tempdata.transferFromFpga.bytes, tempdata.transferFromFpga.tag); } break; default: PORTAL_PRINTF("DmaRequestJson_handleMessage: unknown channel 0x%x\n", channel); if (runaway++ > 10) { PORTAL_PRINTF("DmaRequestJson_handleMessage: too many bogus indications, exiting\n"); #ifndef __KERNEL__ exit(-1); #endif } return 0; } return 0; }
int MemServerIndicationJson_handleMessage(struct PortalInternal *p, unsigned int channel, int messageFd) { static int runaway = 0; int tmp __attribute__ ((unused)); int tmpfd __attribute__ ((unused)); MemServerIndicationData tempdata __attribute__ ((unused)); channel = connnectalJsonDecode(p, channel, &tempdata, MemServerIndicationInfo); switch (channel) { case CHAN_NUM_MemServerIndication_addrResponse: { ((MemServerIndicationCb *)p->cb)->addrResponse(p, tempdata.addrResponse.physAddr); } break; case CHAN_NUM_MemServerIndication_reportStateDbg: { ((MemServerIndicationCb *)p->cb)->reportStateDbg(p, tempdata.reportStateDbg.rec); } break; case CHAN_NUM_MemServerIndication_reportMemoryTraffic: { ((MemServerIndicationCb *)p->cb)->reportMemoryTraffic(p, tempdata.reportMemoryTraffic.words); } break; case CHAN_NUM_MemServerIndication_error: { ((MemServerIndicationCb *)p->cb)->error(p, tempdata.error.code, tempdata.error.sglId, tempdata.error.offset, tempdata.error.extra); } break; default: PORTAL_PRINTF("MemServerIndicationJson_handleMessage: unknown channel 0x%x\n", channel); if (runaway++ > 10) { PORTAL_PRINTF("MemServerIndicationJson_handleMessage: too many bogus indications, exiting\n"); #ifndef __KERNEL__ exit(-1); #endif } return 0; } return 0; }
int MMURequestJson_handleMessage(struct PortalInternal *p, unsigned int channel, int messageFd) { static int runaway = 0; int tmp __attribute__ ((unused)); int tmpfd __attribute__ ((unused)); MMURequestData tempdata __attribute__ ((unused)); channel = connnectalJsonDecode(p, channel, &tempdata, MMURequestInfo); switch (channel) { case CHAN_NUM_MMURequest_sglist: { ((MMURequestCb *)p->cb)->sglist(p, tempdata.sglist.sglId, tempdata.sglist.sglIndex, tempdata.sglist.addr, tempdata.sglist.len); } break; case CHAN_NUM_MMURequest_region: { ((MMURequestCb *)p->cb)->region(p, tempdata.region.sglId, tempdata.region.barr12, tempdata.region.index12, tempdata.region.barr8, tempdata.region.index8, tempdata.region.barr4, tempdata.region.index4, tempdata.region.barr0, tempdata.region.index0); } break; case CHAN_NUM_MMURequest_idRequest: { ((MMURequestCb *)p->cb)->idRequest(p, tempdata.idRequest.fd); } break; case CHAN_NUM_MMURequest_idReturn: { ((MMURequestCb *)p->cb)->idReturn(p, tempdata.idReturn.sglId); } break; case CHAN_NUM_MMURequest_setInterface: { ((MMURequestCb *)p->cb)->setInterface(p, tempdata.setInterface.interfaceId, tempdata.setInterface.sglId); } break; default: PORTAL_PRINTF("MMURequestJson_handleMessage: unknown channel 0x%x\n", channel); if (runaway++ > 10) { PORTAL_PRINTF("MMURequestJson_handleMessage: too many bogus indications, exiting\n"); #ifndef __KERNEL__ exit(-1); #endif } return 0; } return 0; }
void DmaManager_init(DmaManagerPrivate *priv, PortalInternal *sglDevice) { memset(priv, 0, sizeof(*priv)); priv->sglDevice = sglDevice; #ifndef __KERNEL__ pthread_once(&mutex_once, dmaManagerOnce); #endif initPortalMemory(); if (sem_init(&priv->sglIdSem, 0, 0)){ PORTAL_PRINTF("failed to init sglIdSem\n"); } if (sem_init(&priv->confSem, 0, 0)){ PORTAL_PRINTF("failed to init confSem\n"); } }
static int event_portal(struct PortalInternal *pint) { // handle all messasges from this portal instance volatile unsigned int *map_base = pint->map_base, len; while ((len = map_base[PORTAL_CTRL_IND_QUEUE_STATUS])) { if(trace_portal) PORTAL_PRINTF( "%s: (fpga%d) about to receive messages int=%08x en=%08x qs=%08x handler %p parent %p\n", __FUNCTION__, pint->fpga_number, 0, 0, 0, pint->handler, pint->parent); if (pint->handler) pint->handler(pint, 5/*portal number */, len /*HACK FOR ATOMICC*/); else { PORTAL_PRINTF( "%s: (fpga%d) no handler receive int=%08x en=%08x qs=%08x handler %p parent %p\n", __FUNCTION__, pint->fpga_number, 0, 0, 0, pint->handler, pint->parent); exit(-1); } } return -1; }
static void *pthread_worker(void *p) { void *rc = NULL; while (1) { #if defined(BSIM) && !defined(__KERNEL__) if (bsim_poll_interrupt()) #endif manual_event(); #ifdef __KERNEL__ msleep(10); if (kthread_should_stop()) { PORTAL_PRINTF ("pthread_worker ends\n"); break; } #else ///////////////////////// userspace version struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 10000; select(0, NULL, NULL, NULL, &timeout); #endif } #ifdef __KERNEL__ complete(&worker_completion); #endif return rc; }
int MemServerRequest_handleMessage(struct PortalInternal *p, unsigned int channel, int messageFd) { static int runaway = 0; int tmp __attribute__ ((unused)); int tmpfd __attribute__ ((unused)); MemServerRequestData tempdata __attribute__ ((unused)); volatile unsigned int* temp_working_addr = p->item->mapchannelInd(p, channel); switch (channel) { case CHAN_NUM_MemServerRequest_addrTrans: { p->item->recv(p, temp_working_addr, 2, &tmpfd); tmp = p->item->read(p, &temp_working_addr); tempdata.addrTrans.sglId = (uint32_t)(((tmp)&0xfffffffful)); tmp = p->item->read(p, &temp_working_addr); tempdata.addrTrans.offset = (uint32_t)(((tmp)&0xfffffffful));((MemServerRequestCb *)p->cb)->addrTrans(p, tempdata.addrTrans.sglId, tempdata.addrTrans.offset); } break; case CHAN_NUM_MemServerRequest_setTileState: { p->item->recv(p, temp_working_addr, 1, &tmpfd); tmp = p->item->read(p, &temp_working_addr); tempdata.setTileState.tc.state = (TileState)(((tmp)&0x3ul)); tempdata.setTileState.tc.tile = (uint8_t)(((tmp>>2)&0x3ul));((MemServerRequestCb *)p->cb)->setTileState(p, tempdata.setTileState.tc); } break; case CHAN_NUM_MemServerRequest_stateDbg: { p->item->recv(p, temp_working_addr, 1, &tmpfd); tmp = p->item->read(p, &temp_working_addr); tempdata.stateDbg.rc = (ChannelType)(((tmp)&0x1ul));((MemServerRequestCb *)p->cb)->stateDbg(p, tempdata.stateDbg.rc); } break; case CHAN_NUM_MemServerRequest_memoryTraffic: { p->item->recv(p, temp_working_addr, 1, &tmpfd); tmp = p->item->read(p, &temp_working_addr); tempdata.memoryTraffic.rc = (ChannelType)(((tmp)&0x1ul));((MemServerRequestCb *)p->cb)->memoryTraffic(p, tempdata.memoryTraffic.rc); } break; default: PORTAL_PRINTF("MemServerRequest_handleMessage: unknown channel 0x%x\n", channel); if (runaway++ > 10) { PORTAL_PRINTF("MemServerRequest_handleMessage: too many bogus indications, exiting\n"); #ifndef __KERNEL__ exit(-1); #endif } return 0; } return 0; }
int main(int argc, const char **argv) { int srcAlloc; unsigned int *srcBuffer; unsigned int ref_srcAlloc; unsigned int i; pthread_t tid = 0; init_portal_internal(&intarr[0], IfcNames_MMUIndicationH2S, 0, MMUIndication_handleMessage, &MMUIndication_cbTable, NULL, NULL, MMUIndication_reqinfo);// fpga1 init_portal_internal(&intarr[1], IfcNames_ReadTestIndicationH2S,0, ReadTestIndication_handleMessage, &ReadTestIndication_cbTable, NULL, NULL, ReadTestIndication_reqinfo); // fpga2 init_portal_internal(&intarr[2], IfcNames_MMURequestS2H, 0, NULL, NULL, NULL, NULL, MMURequest_reqinfo); // fpga3 init_portal_internal(&intarr[3], IfcNames_ReadTestRequestS2H,0, NULL, NULL, NULL, NULL, ReadTestRequest_reqinfo); // fpga4 sem_init(&test_sem, 0, 0); DmaManager_init(&priv, &intarr[2]); srcAlloc = portalAlloc(numBytes, 0); if (srcAlloc < 0){ PORTAL_PRINTF("portal alloc failed rc=%d\n", srcAlloc); return srcAlloc; } srcBuffer = (unsigned int *)portalMmap(srcAlloc, numBytes); for (i = 0; i < numBytes/sizeof(srcBuffer[0]); i++) srcBuffer[i] = i; portalCacheFlush(srcAlloc, srcBuffer, numBytes, 1); PORTAL_PRINTF( "Main: creating exec thread\n"); if(pthread_create(&tid, NULL, pthread_worker, NULL)){ PORTAL_PRINTF( "error creating exec thread\n"); return -1; } PORTAL_PRINTF( "Test 1: check for match\n"); PORTAL_PRINTF( "Main: before DmaManager_reference(%x)\n", srcAlloc); ref_srcAlloc = DmaManager_reference(&priv, srcAlloc); PORTAL_PRINTF( "Main: starting read %08x\n", numBytes); ReadTestRequest_startRead (&intarr[3], ref_srcAlloc, numBytes, burstLen, 1); PORTAL_PRINTF( "Main: waiting for semaphore1\n"); sem_wait(&test_sem); PORTAL_PRINTF( "Test 2: check that mismatch is detected\n"); srcBuffer[0] = -1; srcBuffer[numBytes/sizeof(srcBuffer[0])/2] = -1; srcBuffer[numBytes/sizeof(srcBuffer[0])-1] = -1; portalCacheFlush(srcAlloc, srcBuffer, numBytes, 1); ReadTestRequest_startRead (&intarr[3], ref_srcAlloc, numBytes, burstLen, 1); PORTAL_PRINTF( "Main: waiting for semaphore2\n"); sem_wait(&test_sem); PORTAL_PRINTF( "Main: all done\n"); #ifdef __KERNEL__ if (tid && !kthread_stop (tid)) { printk("kthread stops"); } wait_for_completion(&worker_completion); #endif #ifdef __KERNEL__ portalmem_dmabuffer_destroy(srcAlloc); #endif return 0; }
int DmaIndicationWrapperdmaError_cb ( struct PortalInternal *p, const uint32_t code, const uint32_t pointer, const uint64_t offset, const uint64_t extra ) { PORTAL_PRINTF("DmaIndication::dmaError(code=%x, pointer=%x, offset=%"PRIx64" extra=%"PRIx64"\n", code, pointer, offset, extra); }
int DmaIndicationWrapperreportStateDbg_cb ( struct PortalInternal *p, const DmaDbgRec rec ) { PORTAL_PRINTF("reportStateDbg: {x:%08x y:%08x z:%08x w:%08x}\n", rec.x,rec.y,rec.z,rec.w); sem_post(&priv.dbgSem); }
int NandCfgIndicationWrapperwriteDone_cb ( struct PortalInternal *p, const uint32_t tag ) { PORTAL_PRINTF( "cb: NandSim_writeDone(tag = %x)\n", tag); sem_post(&test_sem); }
int NandSimIndicationWrapperreadDone_cb ( struct PortalInternal *p, const uint32_t tag ) { PORTAL_PRINTF( "NandSim_readDone(tag = %x)\n", tag); sem_post(&test_sem); }
int main(int argc, const char **argv) { int srcAlloc; int nandAlloc; unsigned int *srcBuffer; unsigned int ref_srcAlloc; unsigned int ref_nandAlloc; int rc = 0, i; pthread_t tid = 0; init_portal_internal(&intarr[0], IfcNames_DmaIndication, DmaIndication_handleMessage, NULL, NULL, DmaIndication_reqinfo); // fpga1 init_portal_internal(&intarr[1], IfcNames_NandSimIndication, NandSimIndication_handleMessage, NULL, NULL, NandSimIndication_reqinfo); // fpga2 init_portal_internal(&intarr[2], IfcNames_DmaConfig, NULL, NULL, NULL, DmaConfig_reqinfo); // fpga3 init_portal_internal(&intarr[3], IfcNames_NandSimRequest, NULL, NULL, NULL, NandSimRequest_reqinfo); // fpga4 sem_init(&test_sem, 0, 0); DmaManager_init(&priv, &intarr[2]); srcAlloc = portalAlloc(alloc_sz, 0); if (rc){ PORTAL_PRINTF("portal alloc failed rc=%d\n", rc); return rc; } PORTAL_PRINTF( "Main: creating exec thread\n"); if(pthread_create(&tid, NULL, pthread_worker, NULL)){ PORTAL_PRINTF( "error creating exec thread\n"); return -1; } srcBuffer = (unsigned int *)portalMmap(srcAlloc, alloc_sz); for (i = 0; i < numWords; i++) { srcBuffer[i] = i; } PORTAL_PRINTF("Test 1: check for operations\n"); portalCacheFlush(srcAlloc, srcBuffer, alloc_sz, 1); PORTAL_PRINTF("Main: before DmaManager_reference(%u)\n", srcAlloc); ref_srcAlloc = DmaManager_reference(&priv, srcAlloc); nandAlloc = portalAlloc (nandBytes, 0); ref_nandAlloc = DmaManager_reference(&priv, nandAlloc); PORTAL_PRINTF("Main::configure NAND fd=%d ref=%d\n", nandAlloc, ref_nandAlloc); NandSimRequest_configureNand (&intarr[3], ref_nandAlloc, nandBytes); sem_wait(&test_sem); PORTAL_PRINTF( "Main::starting write - begin %08zx\n", numBytes); NandSimRequest_startWrite (&intarr[3], ref_srcAlloc, 0, 0, numBytes, 16); PORTAL_PRINTF( "Main:: wait for semaphore\n"); sem_wait(&test_sem); for (i = 0; i < numWords; i++) { srcBuffer[i] = 0; } PORTAL_PRINTF( "Main::starting read %08zx\n", numBytes); NandSimRequest_startRead (&intarr[3], ref_srcAlloc, 0, 0, numBytes, 16); sem_wait(&test_sem); PORTAL_PRINTF ("read: %u %u %u %u\n", srcBuffer[0], srcBuffer[1], srcBuffer[2], srcBuffer[3]); PORTAL_PRINTF( "Main::starting erase %08zx\n", numBytes); NandSimRequest_startErase (&intarr[3], 0, numBytes); sem_wait(&test_sem); PORTAL_PRINTF( "Main::starting read %08zx\n", numBytes); NandSimRequest_startRead (&intarr[3], ref_srcAlloc, 0, 0, numBytes, 16); sem_wait(&test_sem); PORTAL_PRINTF ("read: %u %u %u %u\n", srcBuffer[0], srcBuffer[1], srcBuffer[2], srcBuffer[3]); PORTAL_PRINTF("\n\nTest 2: check for match\n"); { unsigned long loop = 0; unsigned long match = 0, mismatch = 0; while (loop < nandBytes) { int i; for (i = 0; i < numBytes/sizeof(srcBuffer[0]); i++) { srcBuffer[i] = loop+i; } /*PORTAL_PRINTF("Main::starting write ref=%d, len=%08zx (%lu)\n", ref_srcAlloc, numBytes, loop);*/ NandSimRequest_startWrite (&intarr[3], ref_srcAlloc, 0, loop, numBytes, 16); sem_wait(&test_sem); loop+=numBytes; } loop = 0; while (loop < nandBytes) { int i; /*PORTAL_PRINTF("Main::starting read %08zx (%lu)\n", numBytes, loop);*/ NandSimRequest_startRead (&intarr[3], ref_srcAlloc, 0, loop, numBytes, 16); sem_wait(&test_sem); for (i = 0; i < numBytes/sizeof(srcBuffer[0]); i++) { if (srcBuffer[i] != loop+i) { PORTAL_PRINTF("Main::mismatch [%08zx] != [%08zx]\n", loop+i, srcBuffer[i]); mismatch++; } else { match++; } } loop+=numBytes; } PORTAL_PRINTF("Main::Summary: match=%lu mismatch:%lu (%lu) (%f percent)\n", match, mismatch, match+mismatch, (float)mismatch/(float)(match+mismatch)*100.0); } PORTAL_PRINTF( "Main: all done\n"); #ifdef __KERNEL__ if (tid && !kthread_stop (tid)) { PORTAL_PRINTF ("kthread stops\n"); } wait_for_completion(&worker_completion); #endif PORTAL_PRINTF ("Main: ends\n"); return 0; }
int MMUIndicationWrappererror_cb ( struct PortalInternal *p, const uint32_t code, const uint32_t pointer, const uint64_t offset, const uint64_t extra ) { PORTAL_PRINTF("cb: MMUIndicationWrappererror_cb\n"); }
int MMUIndicationWrapperidResponse_cb ( struct PortalInternal *p, const uint32_t sglId ) { PORTAL_PRINTF("cb: MMUIndicationWrapperidResponse_cb\n"); priv.sglId = sglId; sem_post(&priv.sglIdSem); }
int ReadTestIndicationWrapperreadDone_cb ( struct PortalInternal *p, const uint32_t mismatchCount ) { PORTAL_PRINTF( "ReadTest_readDone(mismatch = %x)\n", mismatchCount); sem_post(&test_sem); return 0; }
int MMUIndicationWrappererror_cb ( struct PortalInternal *p, const uint32_t code, const uint32_t pointer, const uint64_t offset, const uint64_t extra ) { static int maxnumber = 10; if (maxnumber-- > 0) PORTAL_PRINTF("DmaIndication::dmaError(code=%x, pointer=%x, offset=%"PRIx64" extra=%"PRIx64"\n", code, pointer, offset, extra); return 0; }
int NandSimIndicationWrapperconfigureNandDone_cb ( struct PortalInternal *p ) { PORTAL_PRINTF( "NandSim_NandDone\n"); sem_post(&test_sem); }
void init(){ if (sem_init(&mtSem, 0, 0)) PORTAL_PRINTF("MemServerIndication::init failed to init mtSem\n"); }
int DmaIndicationWrapperaddrResponse_cb ( struct PortalInternal *p, const uint64_t physAddr ) { PORTAL_PRINTF("DmaIndication_addrResponse(physAddr=%"PRIx64")\n", physAddr); }
int DmaIndicationWrapperconfigResp_cb ( struct PortalInternal *p, const uint32_t pointer ) { PORTAL_PRINTF("DmaIndication_configResp(physAddr=%x)\n", pointer); sem_post(&priv.confSem); }
int main(int argc, const char **argv) { int srcAlloc; int backAlloc; unsigned int *srcBuffer; unsigned int ref_srcAlloc; unsigned int *backBuffer; unsigned int ref_backAlloc; int rc = 0, i; pthread_t tid = 0; init_portal_internal(&intarr[2], IfcNames_BackingStoreMMURequest, NULL, NULL, NULL, NULL, MMURequest_reqinfo); // fpga3 init_portal_internal(&intarr[0], IfcNames_BackingStoreMMUIndication, MMUIndication_handleMessage, &MMUIndication_cbTable, NULL, NULL, MMUIndication_reqinfo); // fpga1 init_portal_internal(&intarr[3], IfcNames_NandCfgRequest, NULL, NULL, NULL, NULL, NandCfgRequest_reqinfo); // fpga4 init_portal_internal(&intarr[1], IfcNames_NandCfgIndication, NandCfgIndication_handleMessage, &NandCfgIndication_cbTable, NULL, NULL, NandCfgIndication_reqinfo); // fpga2 DmaManager_init(&priv, &intarr[2]); sem_init(&test_sem, 0, 0); PORTAL_PRINTF( "Main: creating exec thread - %lu\n", sizeof (unsigned int) ); if(pthread_create(&tid, NULL, pthread_worker, NULL)){ PORTAL_PRINTF( "error creating exec thread\n"); return -1; } backAlloc = portalAlloc (back_sz, 0); PORTAL_PRINTF("backAlloc=%d\n", backAlloc); ref_backAlloc = DmaManager_reference(&priv, backAlloc); PORTAL_PRINTF("ref_backAlloc=%d\n", ref_backAlloc); backBuffer = (unsigned int*)portalMmap(backAlloc, back_sz); portalCacheFlush(backAlloc, backBuffer, back_sz, 1); NandCfgRequest_configureNand (&intarr[3], ref_backAlloc, back_sz); PORTAL_PRINTF("Main::configure NAND fd=%d ref=%d\n", backAlloc, ref_backAlloc); sem_wait(&test_sem); srcAlloc = portalAlloc(back_sz, 0); srcBuffer = (unsigned int *)portalMmap(srcAlloc, back_sz); ref_srcAlloc = DmaManager_reference(&priv, srcAlloc); PORTAL_PRINTF("about to start write\n"); //write data to "flash" memory strcpy((char*)srcBuffer, "acabcabacababacababababababcacabcabacababacabababc\n012345678912"); NandCfgRequest_startWrite(&intarr[3], ref_srcAlloc, 0, 0, 1024, 8); sem_wait(&test_sem); // at this point, if we were synchronizing with the algo_exe, we // could tell it that it was OK to start searching PORTAL_PRINTF ("initialization of data in \"flash\" memory complete\n"); #ifdef __KERNEL__ if (tid && !kthread_stop (tid)) { PORTAL_PRINTF ("kthread stops\n"); } wait_for_completion(&worker_completion); msleep(20000); #else sleep(20); #endif #ifdef __KERNEL__ portalmem_dmabuffer_destroy(backAlloc); portalmem_dmabuffer_destroy(srcAlloc); #endif PORTAL_PRINTF ("Main: ends\n"); return 0; }