LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-31-2009, 10:17 AM   #1
IanVaughan
Member
 
Registered: Jun 2009
Location: Brighton, UK
Posts: 49

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


Reply

Tags
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 06:32 AM
How do you MMAP PCI Configurations Space to User Space jbreaka4lyfe Linux - Kernel 0 03-03-2008 02:15 PM
DMA xmit from kernel space to pci device memory amirh Linux - Software 1 04-06-2007 05:10 PM
DMA xmit from kernel space to pci device memory amirh Linux - Newbie 0 04-06-2007 05:06 PM


All times are GMT -5. The time now is 03:56 PM.

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