int main(int argc, const char **argv) { int mismatch = 0; uint32_t sg = 0; int max_error = 10; if (sem_init(&test_sem, 1, 0)) { fprintf(stderr, "error: failed to init test_sem\n"); exit(1); } fprintf(stderr, "testmemwrite: start %s %s\n", __DATE__, __TIME__); DmaManager *dma = platformInit(); MemwriteRequestProxy *device = new MemwriteRequestProxy(IfcNames_MemwriteRequestS2H); MemwriteIndication deviceIndication(IfcNames_MemwriteIndicationH2S); fprintf(stderr, "main::allocating memory...\n"); int dstAlloc = portalAlloc(alloc_sz, 0); unsigned int *dstBuffer = (unsigned int *)portalMmap(dstAlloc, alloc_sz); #ifdef FPGA0_CLOCK_FREQ long req_freq = FPGA0_CLOCK_FREQ, freq = 0; setClockFrequency(0, req_freq, &freq); fprintf(stderr, "Requested FCLK[0]=%ld actually %ld\n", req_freq, freq); #endif unsigned int ref_dstAlloc = dma->reference(dstAlloc); for (int i = 0; i < numWords; i++) dstBuffer[i] = 0xDEADBEEF; portalCacheFlush(dstAlloc, dstBuffer, alloc_sz, 1); fprintf(stderr, "testmemwrite: flush and invalidate complete\n"); fprintf(stderr, "testmemwrite: starting write %08x\n", numWords); portalTimerStart(0); device->startWrite(ref_dstAlloc, 0, numWords, burstLen, iterCnt); sem_wait(&test_sem); for (int i = 0; i < numWords; i++) { if (dstBuffer[i] != sg) { mismatch++; if (max_error-- > 0) fprintf(stderr, "testmemwrite: [%d] actual %08x expected %08x\n", i, dstBuffer[i], sg); } sg++; } platformStatistics(); fprintf(stderr, "testmemwrite: mismatch count %d.\n", mismatch); exit(mismatch); }
int main(int argc, const char **argv) { size_t alloc_sz = 1024*1024; MemwriteRequestProxy *device = new MemwriteRequestProxy(IfcNames_MemwriteRequestS2H); MemwriteIndication deviceIndication(IfcNames_MemwriteIndicationH2S); DmaManager *dma = platformInit(); sem_init(&done_sem, 1, 0); int dstAlloc = portalAlloc(alloc_sz, 0); unsigned int *dstBuffer = (unsigned int *)portalMmap(dstAlloc, alloc_sz); for (unsigned int i = 0; i < alloc_sz/sizeof(uint32_t); i++) dstBuffer[i] = 0xDEADBEEF; portalCacheFlush(dstAlloc, dstBuffer, alloc_sz, 1); fprintf(stderr, "parent::starting write\n"); unsigned int ref_dstAlloc = dma->reference(dstAlloc); device->startWrite(ref_dstAlloc, alloc_sz, 2 * sizeof(uint32_t)); sem_wait(&done_sem); memdump((unsigned char *)dstBuffer, 32, "MEM"); fprintf(stderr, "%s: done\n", __FUNCTION__); }