PCI and Resouce question

Cole cole at opteqint.net
Wed Mar 17 10:18:19 UTC 2010


Hi.

Sorry if this is not the correct list, I have tried posting to
freebsd-hackers, and didnt get a response. Maybe im being stupid and
not connecting something, or just not understanding, in which case
sorry again.

What im trying to achieve is writing to a few registers/memory
addresses for the memory location of BAR 0 for a pci card. I do not
want to modify the drivers source code, since it might become
unavailable sometime in the future. So what im looking to do is write
another kernel module, that can obtain the cards device_t structure,
as well as the resource structure of the card. My aim is to obtain the
resource structure so that I can then obtain the bus_tag and
bus_handle, and use those to write to the BAR 0 memory space.

My understanding is that I would use pci_find_device to obtain the
device_t, then I think I can use bus_alloc_resource_any to obtain the
resource, I see there used to be a bus_get_resource, but the man page
for that no longer seems to exist, and references to it seem to have
been removed. If there is another way or better way of doing this,
please let me know. Also im not familiar with the specifics of
bus_alloc_resouce_any, and I dont know if calling this function from
another kernel module will give me the already allocated memory for
this pci card, or will it create a new one and assign it to the BAR 0
register on the card?

I also know I can get the softc structure from the device_t, but I
dont wish to use that, as it might change without my knowledge,
especially if the driver becomes closed in the future.

I dont really do a lot of driver development, or this sort of
programming, so any help would be appreciated, and once again, im
sorry if this is all basic stuff and im not understanding something,
or if im posting to the wrong list.

Regards
/Cole


More information about the freebsd-arch mailing list