Re: PCI Device Driver Development

Peter Monta (pmonta@halibut.imedia.com)
Thu, 16 Apr 1998 11:16:47 -0700


Dave Deal writes:

> ... According to the PCI
> specification I should be able to set the base address registers to
> map the card to some physical address. Is this done by the kernel's PCI
> probing or do I have to set the address when I initialize the card?

Neither; the BIOS should set them for you when it does the initial PCI scan.
After the system comes up try "more /proc/pci"---you should see a listing
of the board's base address registers. For example

Bus 0, device 14, function 0:
Bridge: Unknown vendor Unknown device (rev 2).
Vendor id=10b5. Device id=9080.
Medium devsel. Fast back-to-back capable. IRQ 9. Master Capable. Latency=32.
Non-prefetchable 32 bit memory at 0xfebffd00.
I/O at 0xdc00.
I/O at 0xd800.

shows a memory BAR 0, I/O BAR 1, and I/O BAR 2. If your device uses
the mapping from say BAR 1 for its registers, then outl(data,0xdc00+offset)
should work. (Of course the driver should read the BAR from the board
rather than hardwiring it, since the location the BIOS uses will change
as boards are added or removed.)

> If you can direct me to any source code or documentation that would
> help me solve this problem I would greatly appreciate it.

Try the PCI network card drivers or SCSI drivers for PCI probing examples;
I can send you some generic driver init code if that helps. There's also
the "Kernel Hacker's Guide" with some discussion of writing drivers.

Cheers,
Peter Monta pmonta@imedia.com
Imedia Corp.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu