Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jan 2000 02:59:22 +0100
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        Jeroen Ruigrok/Asmodai <asmodai@wxs.nl>
Cc:        =?iso-8859-1?Q?Joachim_J=E4ckel?= <Joachim.Jaeckel@d.kamp.net>, "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: How to write a device-driver?
Message-ID:  <20000128025921.A8066@saturn.kn-bremen.de>
In-Reply-To: <20000125185415.C290@daemon.ninth-circle.org>
References:  <388B8724.D3B9707C@d.kamp.net> <20000125185415.C290@daemon.ninth-circle.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jan 25, 2000 at 06:54:15PM +0100, Jeroen Ruigrok/Asmodai wrote:
> -On [20000124 00:00], Joachim Jäckel (Joachim.Jaeckel@d.kamp.net) wrote:

> >But how get's the zoran36067_regs structure the information from the
> >chip?
> 
> If you were using newbus (on FreeBSD 4.0) I'd say bus_space_read_#() to
> get the info in the registers our of your chip.
> 
> >If I change the content of the structure, which function would change
> >the registers on the chip accordingly? (Or is it done through the call
> >of pci_map_mem? And is everything I change to the structure
> >automatically changed on the card?)
> 
> I have to show my lack of 2.2.x and 3.x driver programming.  I am
> spoiled due to 4.x.  I think someone else needs to answer this.  Juergen
> appears to know 3.x driver programming.

Oh i'm sure there are others here that know more than me!
But since i see no other followup (huh?), here goes:

 The bus_space_* are in -stable too (and i just looked, they're
even in RELENG_2_2, went in Jan 1988, sys/i386/include/bus.h),
they are just not used by all drivers, most(?) simply are older.
(sys/pci/es1370.c is one that uses them.)  For memory mapped
registers on -stable use pci_map_mem, this maps them into memory.
then, since you're making a new driver, i'd access them thru the
bus_space_* macros too.  Whether you need a zoran36067_regs struct
to mirror the register contents depends on the card, if there are
no special restrictions on accessing registers then there's probably
no need for it.  (Or do you mean the virtual address returned by
pci_map_mem? that will point to the registers themselves, accessing
them thru the bus_space_* macros instead of `by hand' is just more
portable, and you don't have to remember the `volatile', etc...)

 The `proper' way to get the first arg (tag) to the bus_space_*
for memory mapped io on -stable seems to be something like this,

#ifdef __i386__
#define MEM_SPACE_MAPPING	I386_BUS_SPACE_MEM
#endif
#ifdef __alpha__
#define MEM_SPACE_MAPPING	ALPHA_BUS_SPACE_MEM
#endif

 the second arg is the virtual address (on -stable from
pci_map_mem), the third is the offset...

 And if you want to know things like what changed in -current in
some file when you only have the -stable version of it you can also
use cvsweb, bus.h for example would be here:

	http://www.freebsd.org/cgi-bin/cvsweb.cgi/src/sys/i386/include/bus.h

 And now i should probably convert the cascade driver to use the
bus_space_* too... :)

 (Note, most(?) of the above is only what i learned from looking
at the source myself, if i managed to talk nonsense please someone
say so...)

 HTH,
-- 
Juergen Lock <nox.foo@jelal.kn-bremen.de>
(remove dot foo from address to reply)


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?20000128025921.A8066>