Daniel Corbe wrote: > I found my problem, it was with the way I was declaring modldrv, I had > the last struct member set to NULL instead of a valid and initialized > dev_ops struct. > > So now the driver loads without crashing the kernel. > > # add_drv -m '* 0644 root sys' testdriver > devfsadm: driver failed to attach: testdriver > Warning: Driver (testdriver) successfully added to system but failed > to attach > > It looks as if my attach procedure isn't even being called. > > Your driver is for a pseudo device? If so, you need a driver.conf file. Otherwise, the system loads your driver, decides there are no devices that the driver drives, and then unloads it. See pseudo(4) and driver.conf(4) for a description of the driver.conf file (yours should be something like testdriver.conf. Also, you'll need to rem_drv before add_drv again.
max > /* Attach and detatch a device */ > > int testdriver_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) > > { > > int result = DDI_FAILURE; > > cmn_err(CE_WARN, "ATTACHING!!"); > > ddi_create_minor_node(dip, "testdriver", S_IFCHR, 1, NULL, 0); > > result = DDI_SUCCESS; > > return(result); > > } > > > and these are the relevant structs > > > > /* Character device specific stuff */ > > static struct cb_ops cb_testdriver_ops = > > { > > nodev, > /* cb_open */ > > nodev, > /* cb_close */ > > nodev, > /* cb_strategy */ > > nodev, > /* cb_print */ > > nodev, > /* cb_dump */ > > nodev, > /* cb_read */ > > nodev, > /* cb_write */ > > nodev, > /* cb_ioctl */ > > nodev, > /* cb_devmap */ > > nodev, > /* cb_mmap */ > > nodev, > /* cb_segmap */ > > nochpoll, > /* cb_chpoll */ > > ddi_prop_op, /* cb_prop_op */ > > &testdriver_strtab, /* cb_stream */ > > (D_NEW | D_MP | D_MTPERMOD) /* cb_flag */ > > }; > > > static struct dev_ops testdriver_ops = > > { > > DEVO_REV, /* devo_rev */ > > 0 , /* devo_refcnt */ > > nodev, > /* devo_getinfo */ > > nodev, > /* devo_identify */ > > nodev, > /* devo_probe */ > > testdriver_attach, /* devo_attach */ > > testdriver_detach, /* devo_detach */ > > nodev, > /* devo_reset */ > > &cb_testdriver_ops, /* devo_cb_ops */ > > (struct bus_ops *)NULL /* devo_bus_ops */ > > }; > > > /* Module specific (kernel linkage for the kernel*/ > > static struct modldrv modldrv = > > { > > &mod_driverops, > > "testdriver" , > > &testdriver_ops > > }; > > > static struct modlinkage modlinkage = > > { > > MODREV_1, > > &modldrv, > > NULL > > }; > > > > SO what am I doing wrong now? > > > -Daniel > > > > > On 9/11/07, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>* > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: > > Garrett D'Amore wrote: > > On Tue, 2007-09-11 at 17:47 +0200, [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> wrote: > > > >> Garrett D'Amore wrote: > >> > >>> On Tue, 2007-09-11 at 10:22 -0400, Daniel Corbe wrote: > >>> > >>> > >>>> You guys are extremely patient with answering these > questions, thank > >>>> you. > >>>> > >>>> > >>>> I've run into another issue. > >>>> > >>>> > >>>> Running add_drv causes my system to reboot. I assume it's > something > >>>> I'm doing wrong. I figured it had something to do with > either the > >>>> attach or getinfo procedures in my driver, and in fact the > getinfo > >>>> procedure is using an uninitialized pointer. > >>>> > >>>> > >>> I don't think getinfo() is the problem... its more likely to be > >>> attach(). (getinfo() is normally only called as part of Dynamic > >>> Reconfiguration operation, IIRC.) > >>> > >>> -- Garrett > >>> > >>> > >> Actually, getinfo() is called twice on open(2). Try > >> > >> # dtrace -n 'pts_devinfo:entry{stack();}' > >> > >> and then open a new terminal window. The pts_devinfo() routine > is the > >> getinfo for the pseudo terminal slave > >> driver (also a streams driver). > >> > > > > Is that true for all drivers, or just clone devices? I confess > I've not > > looked at getinfo() much lately.. most of the NIC drivers these days > > don't need a getinfo(), since they use qassociate() to provide the > > mapping between dev_info_t and streams. > > > > -- Garrett > > > Yes. True for all drivers that use cb_ops. See getinfo(9e) and > ddi_no_info(9f). And > I thought pts was cloned, but glancing at the source code, I guess > not!? > > max > > > > > _______________________________________________ driver-discuss mailing list driver-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/driver-discuss