Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-31-2009, 09:17 AM   #1
Registered: Jun 2009
Location: Brighton, UK
Posts: 50

Rep: Reputation: 16
mmap to overlay VME bus into kernel space memory over a PCI?

Im trying to map the VME address space 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");

    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) );

    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?!


bus, mmap, open, pci

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
linux driver how to mmap many kernel address to user space soararing Programming 1 05-22-2008 05:32 AM
How do you MMAP PCI Configurations Space to User Space jbreaka4lyfe Linux - Kernel 0 03-03-2008 01:15 PM
DMA xmit from kernel space to pci device memory amirh Linux - Software 1 04-06-2007 04:10 PM
DMA xmit from kernel space to pci device memory amirh Linux - Newbie 0 04-06-2007 04:06 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration