[EMAIL PROTECTED] (Chris Hirsch ) wrote:
> Hey all...I'm trying to use memory mapping in a module for a PCI device
> and I can't figure out what I need to do.
linux-kernel is probably a better place for this sort of question.
Writing kernel code is radically different to writing application
code (e.g. no libc functions).
> My PCI device lists 0xe0801000 for the config and 0xe0802000 for the
> data.
Are they physical addresses, virtual addresses, real-mode 16:16
addresses or what?
> I want to enable interrupts for this card. The offset for the
> interupt register is 38h so I was trying to add 38 to the base and
> outl() it. That doesn't seem to work.
>
> After my rambling above I guess the question I have is what things do I
> need to do to use mmap and how exactly do I write to a mmapped device?
mmap() is a libc function; it isn't relevant to kernel code. If the
device is memory mapped, you just write to its address space.
> Can I use outl and outb? I have Linux Device Drivers but it stops short of
> doing a step by step example and uses the parallel port as a simple
> example DOH!
outl() and outb() are for writing to I/O ports. Simple devices (e.g.
the parallel port) are accessed solely using I/O ports. Memory mapped
devices are accessed primarily by reading and writing specific memory
addresses.
Some memory mapped devices use I/O ports as well (typically I/O ports
for configuration and memory mapping for raw data). However, given
that your device defines a separate address range for configuration,
it may be that it doesn't use I/O ports at all.
When dealing with memory-mapped hardware, you need to remember to
declare pointers to hardware addresses as `volatile'. Also, you
sometimes need to inhibit the asynchronous instruction scheduling used
on the more recent processors (Pentium-Pro, Pentium-II), otherwise
things don't work.
--
Glynn Clements <[EMAIL PROTECTED]>