Subject: Re: softc
To: None <michaelv@HeadCandy.com>
From: Mike Long <mike.long@analog.com>
List: tech-kern
Date: 06/04/1996 19:23:08
>Date: Sun, 02 Jun 1996 23:30:18 -0700
>From: "Michael L. VanLoon -- HeadCandy.com" <michaelv@HeadCandy.com>

>Please help me get a better understanding: what exactly is a softc,
>and how exactly is it supposed to be allocated, filled in, and used?
>
>Is it supposed to be some place where all the state for a particular
>instance of a device resides, or something like that?  What is the
>ultimate prototype for all softc's?  Is there such a thing?

You got it right; softc structures contain state information for a
given device instance.  Each device driver defines its own softc
structure, but the first member of the structure must be a 'struct
device' or the config_*() functions will fail.  Memory for the
structure is allocated by either config_{search,scan}() or
config_attach(), depending on the state of the 'indirect' flag in the
driver's parent's cfdata (this gets a bit murky).  The config_*()
functions get the size of the driver's softc structure from its
cfattach structure.  Usually (AFAIK) the softc is filled in the
driver's attach function, not the match/attach function.

You can learn a lot about how softc structures work by looking at
/sys/sys/device.h and /sys/kern/subr_autoconf.c.

Hopefully that made some sense. :-/
-- 
Mike Long <mike.long@analog.com>     <URL:http://www.shore.net/~mikel>
VLSI Design Engineer         finger mikel@shore.net for PGP public key
Analog Devices, CPD Division          CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA       (eq (opinion 'ADI) (opinion 'mike)) -> nil