Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Nov 1998 14:39:58 -0800
From:      Mike Smith <mike@smith.net.au>
To:        "Larry S. Lile" <lile@stdio.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: PCI device question 
Message-ID:  <199811122239.OAA01264@dingo.cdrom.com>
In-Reply-To: Your message of "Thu, 12 Nov 1998 12:34:55 EST." <Pine.BSF.3.96.981112121428.25192F-100000@heathers.stdio.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> On Thu, 12 Nov 1998, Mike Smith wrote:
> 
> > > > > I already know the io-base address, dma-level, csn, pci slot, ... from
> > > > > another call.
> > > > 
> > > > That's where stuff like base address etc. are. If you have pulled out 
> > > > base address info via config read and friends then you already know. If 
> > > > you are not pulling base etc. out via config reads then you have to fix 
> > > > your driver :-)
> > > > 
> > > > Functions look like this:
> > > > int data = pci_conf_read(tag, PCI_CLASS_REG);
> > > > 
> > > > Are you using these?
> > > 
> > > No, there is a probe function in the driver kit that will find all
> > > of the adapters presumably through PIO, so I have not neede to 
> > > delve into this yet.  They then want a pointer into the right spot
> > > in memory for the config. info passed into another function.
> > 
> > Don't do this.  It's Bad and Evil and if they feel the only way to find 
> > device information is to go behind the system's back then I can't wait 
> > to hear what else they think is a "good idea".
> 
> They have written the kit so that it is OS independent, don't bust an
> artery.  They just want the config info passed to them so their half
> of the driver can make sure it is ok.  Here is their blurb about it...

You've just said "there is a probe function in the driver kit that will 
find all of the adapters presumably through PIO".  That's bad.  It 
should not do that.  Do not do that.  It has the ability to screw the 
PCI config right up.

> Now, the question was (and still is) how do I get the 64 byte
> configuration header out of FreeBSD, or how do I get a pointer to
> it?

Use pci_conf_read() like Ron told you three or four messages ago.  Pass 
the tag your attach routine was given as the tag argument, and pass the 
longword offset you want to read in as the argument, eg.

	u_int32_t	confspace[16];
	int		i;
...
	for (i = 0; i < 16; i++)
		confspace(i) = pci_conf_read(tag, i);
	
The confspace array now contains the 64-byte configuration space 
contents.

There are examples of this in almost every existing PCI driver.

-- 
\\  Sometimes you're ahead,       \\  Mike Smith
\\  sometimes you're behind.      \\  mike@smith.net.au
\\  The race is long, and in the  \\  msmith@freebsd.org
\\  end it's only with yourself.  \\  msmith@cdrom.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811122239.OAA01264>