#include #include #include #include #include #include #include #include #define PATTERN 0x55 #define MBUFSIZE (1<<20) /* static char membuf[MBUFSIZE]; */ int main(int argc, char ** argv) { u_char *mp,*rp; int fd; int error; int i, j; VME_attr memdesc = { base: 0xd00000, limit: 0xdfffff, flags: VME_AM_A24(16) | VME_USE_MAP | VME_USE_RMW }; VME_atomic_access rmw = { offset: 0, }; fd = open("/dev/vme",O_RDWR); if (fd < 0) { perror("error opening vme"); exit(0); } printf("/dev/vme opened.\n"); error = ioctl(fd, VME_SET_ATTR, &memdesc); if (error) perror("Failed VME_SET_ATTR"); error = ioctl(fd, VME_GET_ATTR, &memdesc); if (error) perror("Failed VME_GET_ATTR"); printf("memdesc: flags %x, vme_addr %x, length %x\n", memdesc.flags, memdesc.base, memdesc.limit-memdesc.base+1); mp = mmap(0, MBUFSIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if ((u_long)mp == -1) perror("Mmap failed with"); else printf("mem mapped at %p\n", mp); /* new code from testvme.c */ printf("Try to read\n"); rp=mp; for (i=0; i<0x100; i++) { j=*(rp++); printf("Read %x at %x\n",j,rp); usleep(1000); } printf("Try to write \n"); for (i=0; i