Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 04 Mar 2000 11:05:18 -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:  <200003041905.LAA04384@mass.cdrom.com>
In-Reply-To: Your message of "Sat, 04 Mar 2000 15:02:45 %2B0530." <38C0D83D.5A21@procsys.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Hi,
> 
> I didn't find the make_dev() function in FreeBSD 3.4 version. Is there
> any equivalent function to mak_edev ()
> in 3.4 ?

Use the cdevsw_add() function in the example below.  But remember that 
you're not writing for 3.4, you're writing for 4.0.

> Does the make_dev () creates an inode also for the device ?

No.

> Regards,
> Nandan
> 
> >Mike Smith wrote:
> > 
> > > 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
> 

-- 
\\ 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?200003041905.LAA04384>