In message <[EMAIL PROTECTED]> "Gary T. Corcoran" writes:
: I installed FreeBSD 4.0 and I'm trying to write the attach() routine
: for my device driver, to be compiled as a loadable module.  In 4.0
: the attach routine only gets passed a dev pointer, not a PCI configuration
: pointer.  My PCI device has up to 6 I/O ranges, and I need to get the
: base addresses for those ranges.
: 
: So how does one get multiple I/O base addresses from a dev pointer
: for a PCI device in FreeBSD 4.x ?

rid = 0x10;
res1 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);
rid = 0x14;
res2 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);
rid = 0x18;
res3 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);
rid = 0x1c;
res4 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);
rid = 0x20;
res5 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);
rid = 0x24;
res6 = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE);

should do the trick.  Change SYS_RES_MEMORY to SYS_RES_IOPORT if it is 
I/O mapped rather than memory mapped.

In case it wasn't clear, the rid is the offset into the config space
where the BAR register that you want to use is.  Multiples of 4 only
need apply.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to