experchange > linux.development.system

Mark Linn (09-24-05, 11:52 PM)
Hi,

I am relatively new to linux user space programming. I have a PCI
device which has memory mapped register sets. The driver works fine on
an intel Pentium M. I can access the registers in the driver through
PCI BAR0. Now I am writing a user space diagnostic program for the PCI
device, I can access the PCI BAR0 value, how can I convert it into user
space virtual address so that I can read the registers from the user
space?

Your advice and help is greatly appreciated !!

thanks

Mark
Ulrich Eckhardt (09-25-05, 11:44 AM)
Mark Linn wrote:
> I am relatively new to linux user space programming. I have a PCI
> device which has memory mapped register sets. The driver works fine on
> an intel Pentium M. I can access the registers in the driver through
> PCI BAR0. Now I am writing a user space diagnostic program for the PCI
> device, I can access the PCI BAR0 value, how can I convert it into user
> space virtual address so that I can read the registers from the user
> space?


I found and reused such code in a video driver where you could mmap() the
framebuffer. Well, I think that was what it did, it is more than two years
ago. I found the code by looking for implementation of the mmap() handler
of struct fileops (or file_ops).

Anyhow, the code did what it should, but we removed it lateron in favor of
an ioctl() interface because we had to fiddle a few registers and could
not tolerate being preempted. I just wanted to mention that, in case you
have similar requirements.

Uli
John Fusco (09-25-05, 08:35 PM)
Mark Linn wrote:
[..]
> Your advice and help is greatly appreciated !!
> thanks
> Mark


You can usually use mmap with /dev/mem as the device and the value of
the BAR as an offset. You have to be root to use this. Otherwise you
have to write your own driver and implement the mmap routine.

John