Date: Tue, 20 Feb 2007 11:31:18 -0500 From: John Baldwin <jhb@freebsd.org> To: freebsd-drivers@freebsd.org Cc: aji abraham <abraham_aji@yahoo.co.in> Subject: Re: Doudts in "softc" and "device_get_softc(dev)" Message-ID: <200702201131.18873.jhb@freebsd.org> In-Reply-To: <150997.27592.qm@web8315.mail.in.yahoo.com> References: <150997.27592.qm@web8315.mail.in.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 17 February 2007 04:41, aji abraham wrote: > hi > > My name is Aji Abraham, now working with device > drivers. the word > "softc" and the function "device_get_softc(dev)" > getting confuse me a > lot. am listing some query below .. pls help me .. A softc is the driver-private "instance" data for each device. The driver tells the kernel how big of a softc it wants and as a convenience the kernel will go ahead and allocate it and zero it for the driver. > Q1 In a free BSD driver Code, there are two device > depended structures > > struct xx_softc { > ....... > ...... > > > }; > > struct xx_if_softc { > ....... > ...... > > > }; > > sizeof(struct xx_softc ) is 68 > sizeof(struct xx_if_softc ) is 1186 > > And in device attach function > > xx_attach(dev){ > > struct xx_softc *sc; > struct xx_if_softc *if_sc; > > sc_if = device_get_softc(dev); > sc = device_get_softc(device_get_parent(dev)); > > sc_if-> ..... > sc-> .... > ....... > ...... > > } > > > Both allocation uses the same function. How it > possible ? It is the same function, but it is getting called with different device_t arguments, so it will return different pointers. > can we > access > all structure member ? Yes. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200702201131.18873.jhb>