Re: PCI Programming

From: Dipjyoti Saikia (dipjyoti.saikia_at_gmail.com)
Date: 04/29/05

  • Next message: Steven Hartland: "Re: Very low disk performance Highpoint 1820a"
    Date: Fri, 29 Apr 2005 15:17:11 +0530
    To: Cole <cole@opteqint.net>
    
    

    Hi,

    The normal usage of pci_resource_start() in Linux is to get the base
    address of the BAR for further reads/writes using inb/outb etc.

    In Free BSD you can use the following :

    bus_alloc_resource();
    rman_get_bustag();
    rman_get_bushandle();

    Usually the ret value of rman_get_bushandle() gives the starting
    address of the resource (of the BAR for which you called
    bus_alloc_resource) .

    Normally we use bus_space_* api's to read/write in FreeBSD. The use of
    bus_space_ functions need us to only specify the offset rather than
    the Linux like usage
      inb(base+offset) etc.

    Thanks
    Dip

    On 4/28/05, Cole <cole@opteqint.net> wrote:
    > Hey
    >
    > Im currently trying to port some linux pci driver to FreeBSD code. But im running into a problem. Its using a function that I cant
    > seem to find the equivalent of for FreeBSD.
    >
    > Heres the function up to the point where im getting stuck.
    >
    > int FindDevice( void )
    > {
    >
    > static struct pci_dev *pciptr;
    > int pci_info_index = 0;
    > U16 wDev;
    > unsigned int tmp_addr;
    >
    > /*-----------------------------------------*/
    > #ifdef CONFIG_PCI // find the specified device and its configuration
    > if( pcibios_present() ){
    >
    > pci_for_each_dev( pciptr ){
    > if ((pciptr->vendor == VENDOR_ID) && \
    > (pciptr->device == DEVICE_ID) && \
    > (pciptr->subsystem_vendor == SUBSYSTEM_VID) && \
    > (pciptr->subsystem_device == SUBSYSTEM_DID) && \
    > (PCI_FUNC(pciptr->devfn) == 0) )
    > {
    > DevExtension[pci_info_index].wBus= pciptr->bus->number;
    > DevExtension[pci_info_index].wDevFunc= pciptr->devfn;
    > DevExtension[pci_info_index].wCard = pci_info_index;
    > tmp_addr = pci_resource_start( pciptr, 4 );
    > DevExtension[pci_info_index].func0_bar = (tmp_addr & ~0x03);
    >
    > now the function im getting stuck at, is the "tmp_addr = pci_resource_start(pciptr, 4). I was wondering if anyone knows of an
    > equivalent under FreeBSD. Or if there is a way to obtain that value with some other method in FreeBSD. I am pretty much fine up
    > until that point.
    >
    > If anyone has any sample code or anything that I could read to proceed any further, it would be greatly appreciated.
    >
    > Regards
    > /Cole
    >
    > _______________________________________________
    > freebsd-hackers@freebsd.org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    >
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Steven Hartland: "Re: Very low disk performance Highpoint 1820a"

    Relevant Pages

    • Re: FreeBSD 4.x Opteron Question
      ... the FreeBSD developers told everyone that 5.3 was da ... initially over linux not because there's a bunch of good guys on the ... My tests measure kernel performance; ... > a networking device is a key performance indicator. ...
      (freebsd-questions)
    • Re: Newbie Experience
      ... I've only been around since FreeBSD 5.4 ... FreeBSD kernel too. ... always sunshine and linux is farts. ... in the hey day of AT&T Unix I'm ...
      (freebsd-questions)
    • Re: Review of FreeBSD 5.4
      ... but not less problems compared to FreeBSD. ... If you like to have a bleeding edge system using debian --- just go ... > the linux kernel suffers. ... When the kernel suffers, everyone who uses ...
      (comp.unix.bsd.freebsd.misc)
    • Re: FreeBSD & Linux distro
      ... as a FreeBSD advocacy the tone of the article should be neutral and all ... do not like Linux and more over I have never used it in my life but I ... Statement of the type BSD appears more stable than Linux is ... fewer FreeBSD advocates make claims like that, however, is part of the ...
      (freebsd-questions)
    • Re: Compare Linux and Freebsd Redux
      ... >> Perhaps the most unsettling 'misinformation' about the FreeBSD vs. ... >> Linux situation was the spin that Linux was somehow more 'open', ... >> the official Linux tree... ... your own distribution is that the FreeBSD distribution is/was already ...
      (comp.unix.bsd.freebsd.misc)