int main(int argc, const char **argv) { unsigned int srcGen = 0; NandSimRequestProxy *device = 0; DmaConfigProxy *dmap = 0; NandSimIndication *deviceIndication = 0; DmaIndication *dmaIndication = 0; fprintf(stderr, "Main::%s %s\n", __DATE__, __TIME__); device = new NandSimRequestProxy(IfcNames_NandSimRequest); dmap = new DmaConfigProxy(IfcNames_DmaConfig); DmaManager *dma = new DmaManager(dmap); deviceIndication = new NandSimIndication(IfcNames_NandSimIndication); dmaIndication = new DmaIndication(dma, IfcNames_DmaIndication); fprintf(stderr, "Main::allocating memory...\n"); srcAlloc = portalAlloc(numBytes); srcBuffer = (unsigned int *)portalMmap(srcAlloc, numBytes); fprintf(stderr, "fd=%d, srcBuffer=%p\n", srcAlloc, srcBuffer); portalExec_start(); for (int i = 0; i < numBytes/sizeof(srcBuffer[0]); i++) srcBuffer[i] = srcGen++; portalDCacheFlushInval(srcAlloc, numBytes, srcBuffer); fprintf(stderr, "Main::flush and invalidate complete\n"); sleep(1); unsigned int ref_srcAlloc = dma->reference(srcAlloc); nandAlloc = portalAlloc(nandBytes); int ref_nandAlloc = dma->reference(nandAlloc); fprintf(stderr, "NAND alloc fd=%d ref=%d\n", nandAlloc, ref_nandAlloc); device->configureNand(ref_nandAlloc, nandBytes); deviceIndication->wait(); fprintf(stderr, "Main::starting write ref=%d, len=%08zx\n", ref_srcAlloc, numBytes); device->startWrite(ref_srcAlloc, 0, 0, numBytes, 16); deviceIndication->wait(); fprintf(stderr, "Main::starting read %08zx\n", numBytes); device->startRead(ref_srcAlloc, 0, 0, numBytes, 16); deviceIndication->wait(); fprintf(stderr, "Main::starting erase %08zx\n", numBytes); device->startErase(0, numBytes); deviceIndication->wait(); fprintf(stderr, "Main::starting read %08zx\n", numBytes); device->startRead(ref_srcAlloc, 0, 0, numBytes, 16); deviceIndication->wait(); return 0; }
int main(int argc, const char **argv) { unsigned int srcGen = 0; NandSimRequestProxy *device = 0; NandSimIndication *deviceIndication = 0; fprintf(stderr, "chamdoo-test\n"); fprintf(stderr, "Main::%s %s\n", __DATE__, __TIME__); device = new NandSimRequestProxy(IfcNames_NandSimRequest); deviceIndication = new NandSimIndication(IfcNames_NandSimIndication); DmaDebugRequestProxy *hostDmaDebugRequest = new DmaDebugRequestProxy(IfcNames_HostDmaDebugRequest); MMUConfigRequestProxy *dmap = new MMUConfigRequestProxy(IfcNames_HostMMUConfigRequest); DmaManager *dma = new DmaManager(hostDmaDebugRequest, dmap); DmaDebugIndication *hostDmaDebugIndication = new DmaDebugIndication(dma, IfcNames_HostDmaDebugIndication); MMUConfigIndication *hostMMUConfigIndication = new MMUConfigIndication(dma, IfcNames_HostMMUConfigIndication); fprintf(stderr, "Main::allocating memory...\n"); srcAlloc = portalAlloc(numBytes); srcBuffer = (unsigned int *)portalMmap(srcAlloc, numBytes); fprintf(stderr, "fd=%d, srcBuffer=%p\n", srcAlloc, srcBuffer); portalExec_start(); for (int i = 0; i < numBytes/sizeof(srcBuffer[0]); i++) srcBuffer[i] = srcGen++; portalDCacheFlushInval(srcAlloc, numBytes, srcBuffer); fprintf(stderr, "Main::flush and invalidate complete\n"); sleep(1); unsigned int ref_srcAlloc = dma->reference(srcAlloc); nandAlloc = portalAlloc(nandBytes); int ref_nandAlloc = dma->reference(nandAlloc); fprintf(stderr, "NAND alloc fd=%d ref=%d\n", nandAlloc, ref_nandAlloc); device->configureNand(ref_nandAlloc, nandBytes); deviceIndication->wait(); /* do tests */ 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; } fprintf(stderr, "Main::starting write ref=%d, len=%08zx (%lu)\n", ref_srcAlloc, numBytes, loop); device->startWrite(ref_srcAlloc, 0, loop, numBytes, 16); deviceIndication->wait(); loop+=numBytes; } loop = 0; while (loop < nandBytes) { int i; fprintf(stderr, "Main::starting read %08zx (%lu)\n", numBytes, loop); device->startRead(ref_srcAlloc, 0, loop, numBytes, 16); deviceIndication->wait(); for (i = 0; i < numBytes/sizeof(srcBuffer[0]); i++) { if (srcBuffer[i] != loop+i) { fprintf(stderr, "Main::mismatch [%08zx] != [%08zx]\n", loop+i, srcBuffer[i]); mismatch++; } else { match++; } } loop+=numBytes; } /* end */ fprintf(stderr, "Main::Summary: match=%lu mismatch:%lu (%lu) (%f percent)\n", match, mismatch, match+mismatch, (float)mismatch/(float)(match+mismatch)*100.0); return (mismatch > 0); }