From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 29 09:47:13 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 25D6516A4CE for ; Fri, 29 Apr 2005 09:47:13 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2CFF843D2D for ; Fri, 29 Apr 2005 09:47:12 +0000 (GMT) (envelope-from dipjyoti.saikia@gmail.com) Received: by zproxy.gmail.com with SMTP id 34so1297381nzf for ; Fri, 29 Apr 2005 02:47:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ukGoX2Eex7njPEG7EpdXOZviV+IGyvcpsD1oBSoH8YmPy4I34TmG0Z0KA7MDf4jQuVypcuZWmePy7zvpJg7v4b2UkybtISxr4hZNkV1xzIjLy2fI5EsFjgQ2RbzbVsWcKpElbCQeN2NNhMU2fXAe5uWun/fRrQyGrgiaWBophC4= Received: by 10.36.8.17 with SMTP id 17mr168981nzh; Fri, 29 Apr 2005 02:47:11 -0700 (PDT) Received: by 10.36.75.15 with HTTP; Fri, 29 Apr 2005 02:47:11 -0700 (PDT) Message-ID: Date: Fri, 29 Apr 2005 15:17:11 +0530 From: Dipjyoti Saikia To: Cole In-Reply-To: <000901c54c19$3dba2570$4206000a@deadmind> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <000901c54c19$3dba2570$4206000a@deadmind> cc: freebsd-hackers@freebsd.org Subject: Re: PCI Programming X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dipjyoti Saikia List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2005 09:47:13 -0000 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(); =20 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 wrote: > Hey >=20 > 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. >=20 > Heres the function up to the point where im getting stuck. >=20 > int FindDevice( void ) > { >=20 > static struct pci_dev *pciptr; > int pci_info_index =3D 0; > U16 wDev; > unsigned int tmp_addr; >=20 > /*-----------------------------------------*/ > #ifdef CONFIG_PCI // find the specified device and its configuration > if( pcibios_present() ){ >=20 > pci_for_each_dev( pciptr ){ > if ((pciptr->vendor =3D=3D VENDOR_ID) && \ > (pciptr->device =3D=3D DEVICE_ID) && \ > (pciptr->subsystem_vendor =3D=3D SUBSYSTEM_VID) && \ > (pciptr->subsystem_device =3D=3D SUBSYSTEM_DID) && \ > (PCI_FUNC(pciptr->devfn) =3D=3D 0) ) > { > DevExtension[pci_info_index].wBus=3D pciptr->bus->numb= er; > DevExtension[pci_info_index].wDevFunc=3D pciptr->devfn= ; > DevExtension[pci_info_index].wCard =3D pci_info_index; > tmp_addr =3D pci_resource_start( pciptr, 4 ); > DevExtension[pci_info_index].func0_bar =3D (tmp_addr &= ~0x03); >=20 > now the function im getting stuck at, is the "tmp_addr =3D pci_resource_s= tart(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. >=20 > If anyone has any sample code or anything that I could read to proceed an= y further, it would be greatly appreciated. >=20 > Regards > /Cole >=20 > _______________________________________________ > 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= " >