Subject: Re: Parameter passing in the kernel
To: None <firstname.lastname@example.org>
From: Jason R Thorpe <email@example.com>
Date: 06/18/2001 16:00:31
On Mon, Jun 18, 2001 at 10:47:54PM -0000, firstname.lastname@example.org wrote:
> With the layered device driver structure that is used extensively in
> NetBSD to provide machine, bus and in some cases chip independence we
> often find the following paradigm:
> static void
> xx_bus_attach (struct device *self, _ATTACH_ARGS_)
> struct xx_softc *xx = (struct xx_softc *xx)self;
> xx->xx_DATA1 = _DATA1_;
> xx->xx_DATA2 = _DATA2_;
> xx->xx_DATA3 = _DATA3_;
> xxattach (xx, _ATTACH_ARGS_);
> Once device properties are added to the kernel, this will
> all change. You can read about device properties in the
> tech-kern archives.
Uh, I don't think so.
The code actually usually looks like this:
xx_bus_attach (struct device *self, _ATTACH_ARGS_)
struct xx_softc *xx = (struct xx_softc *xx)self;
xx->xx_DATA1 = _DATA1_;
xx->xx_DATA2 = _DATA2_;
xx->xx_DATA3 = _DATA3_;
Note that _DATA1_, _DATA2_, and _DATA3_ are generally derived in some
bus-specific way, but once derived, are bus-independent. This is the
case with e.g. the DMA tag, the space tags, the space handles, etc.
Especially with the space *handles*, a bus-specific call is sometimes
required (c.f. PCI).
Getting the DMA tag might be appropriate for properties, but the space
tag fetching might have to be encapsulated inside a bus-specific call.
-- Jason R. Thorpe <email@example.com>