Date: Fri, 03 Mar 2000 14:31:39 -0800 From: Mike Smith <msmith@freebsd.org> To: nanda@procsys.com Cc: freebsd-scsi@FreeBSD.ORG Subject: Re: IOCTL support in SCSI block driver Message-ID: <200003032231.OAA01856@mass.cdrom.com> In-Reply-To: Your message of "Fri, 03 Mar 2000 12:36:08 %2B0530." <38BF6460.703A@procsys.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> I am just resending the mail. After going through the code i am almost
> lost.
>
> I went through the mylex code to find how they implement the control
> interface. But i have some doubts regarding this. Mainly these doubts
> come since i am still quiete new to the FreeBSD world and don't have
> good text books regarding how to write device drivers etc.
>
> 1). In the user space how do i specify a controller to communicate with
> that ? For eg. if i want to open the device and a send an IOCTL how do
> i specify that ? In our case actual disks will be seen as part of target
> discovery done through the CAM SCSI interface.
The controller code instantiates a device for each controller. The Mylex
driver is still doing this the "old" way:
/*
* Register the control device on first attach.
*/
if (cdev_registered++ == 0)
cdevsw_add(&mlx_cdevsw);
It would be more correct for it to use:
sc->mlx_dev_t = make_dev(&mlx_cdevsw, device_get_unit(sc->mlx_dev),
0, 0, S_IRUSR|S_IRUSRW,
"mlx%d", device_get_unit(sc->mlx_dev));
and then use
destroy_dev(sc->mlx_dev_t);
in the corresponding detach method.
(makes note to self to fix Mylex driver thusly).
> 2). I found that the while registering the character device the "softc"
> structure does not come to picture at all. But later while opening the
> device the "softc" structure is obtained using "devclass_get_softc".
> How is it obtained ? If there are some documents regarding these you can
> tell me and i will go through it.
The bus code is responsible for tracking the softc structure; the minor
number for the device maps directly to the controller instance number, so
/dev/mlx0 has minor number 0, and thus you ask for the softc pointer for
instance 0 of mlx_devclass.
--
\\ Give a man a fish, and you feed him for a day. \\ Mike Smith
\\ Tell him he should learn how to fish himself, \\ msmith@freebsd.org
\\ and he'll hate you for a lifetime. \\ msmith@cdrom.com
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-scsi" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200003032231.OAA01856>
