#include #include #include #include #include #include #include #include int main(void) { int f; unsigned long int *mem,*src,*dst; int t; long int usecs; unsigned long int secs, count; double rate; struct timeval tv, tv0, tv1; printf("Opening fb0\n"); f = open("/dev/fb0", O_RDWR); if(f<0) { perror("opening fb0"); return 1; } printf("mmapping fb0\n"); mem = mmap(NULL, 0x00300000, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED,f,0); printf("mmap returned: %08x\n",(unsigned int)mem); perror("mmap"); if(mem==-1) return 1; gettimeofday(&tv, NULL); for(t=0; t<0x000c0000; t++) mem[t] = (tv.tv_usec ^ tv.tv_sec) ^ t; count = 0; gettimeofday(&tv0, NULL); for(t=0; t<10; t++) { src = mem; dst = mem+0x00040000; memcpy(dst, src, 0x00100000); count += 0x00100000; } gettimeofday(&tv1, NULL); secs = tv1.tv_sec-tv0.tv_sec; usecs = tv1.tv_usec-tv0.tv_usec; if(usecs<0) { usecs += 1000000; secs -= 1; } printf("Time elapsed: %ld secs, %ld usecs data transferred: %ld bytes\n",secs, usecs, count); rate = (double)count/((double)secs + (double)usecs/1000000.0); printf("Data rate: %5.3g MiB/s\n", rate/(1024.0*1024.0)); return 0; }