Accessing PCI registers in user space

From: Joe Mulligan (joem_at_foresightimaging.com)
Date: 08/25/04


Date: 25 Aug 2004 07:04:18 -0700

I'm a kernel newbie with a problem that I know has been answered
before, but none of the solutions that I found through net/docs
research seem to work.
I'm porting software for a PCI card (AMCC 5935 based). What I'm
trying to do is map the board's register region into user space so it
can be accessed via a pointer. Please, no lectures about how
unportable this is, I'm dealing with a large library that insists on
using pointers on X86 based systems.

I retrieve the physical addresses from the pci config space. If I
access the registers in the driver via io_remap_nocache then
readl/writel then all is fine. If I pass the physical addresses back
up to user space then attempt to map via mmap() then I get a good
virtual address that doesn't point to the registers. I have a scope
on the board so I've confirmed that this is the case. Im assuming
that there may be some caching going on.

I've seen articles that recommend opening /dev/mem and mapping the
registers using that file descriptor, but I get the same results. I've
based my device mmap on the code from the Rubini/Corbet book. I've
been trying for 2 days now with various combinations of
io_remap_nocache/virt_to_phys and remap_page_range calls with no luck.
I've also tried various flags to the vma page protection (page_pcd,
page_pwt) also with no luck.
I'm using the 2.4 kernel with a Red Hat distro.
Could someone please post the proper sequence, including flags to
accomplish this ?

Any help would be greatly appreciated.

Thank you,
joem@foresightimaging.com
Could some



Relevant Pages

  • Re: How to access PCI memory mapped location from user space?
    ... I have a PCI ... I can access the registers in the driver through ... Now I am writing a user space diagnostic program for the PCI ...
    (comp.os.linux.development.system)
  • Re: User space access in kernel
    ... > of registers available for passing arguments. ... Linux uses the FASTCALL model for passing syscall ... > kernel can get all those datas is by copying them from user space. ...
    (comp.os.linux.development.system)
  • Re: Accessing PCI registers in user space
    ... > trying to do is map the board's register region into user space so it ... > registers using that file descriptor, but I get the same results. ... Problems like this are often caused by caching issues. ...
    (comp.os.linux.development.system)
  • Re: How to access PCI memory mapped location from user space?
    ... > I am relatively new to linux user space programming. ... I have a PCI ... I can access the registers in the driver through ... Now I am writing a user space diagnostic program for the PCI ...
    (comp.os.linux.development.system)