I'm trying to map a VME address space through a PCI bus into user space so I can perform regular read/writes on the memory. I have done this with another PCI device like this :-
unsigned long *mapArea(unsigned int barAddr, unsigned int mapSize, int *fd)
{
unsigned long *mem;
*fd = open("/dev/mem", O_RDWR);
if ( *fd<0 ) {
printf("Cannot open /dev/vme_mem\n");
exit(-1);
}
unsigned long *mem = (unsigned long*) mmap ( 0, mapSize, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, *fd, barAddr);
if ( (mem == NULL) || (mem == (unsigned long*)-1) ) {
printf ( "Cannot map memory, error is %s\n", strerror(errno) );
exit(-1);
}
return mem;
}
volatile unsigned long *bar = (volatile unsigned long *)mapArea(barAddr, mapSize, &fd);
And then "bar" can be used normally for read/writes.
So to VME, and with a Tundra Universe II PCI-VME Bridge chip :-
Should I open "/dev/vme_m0" Where do I map my BAR from? the lspci -vv : "Region 1: Memory at 80020000"
Also the addresses within the VME BUS are offset by 0x20000000, so how does that work wrt accessing/mapping it?!
(Using Linux 2.6.18-128.el5 #1 SMP) (Need new tag "vme"!)