Writing Device Drivers

Special Issues With SCSI HBA Drivers

SCSI HBA drivers usually do not have a cb_ops(9S) structure, so to enable hotplugging, a minimal cb_ops(9S) structure must be created and exported in the dev_ops(9S).

 /*
      * autoconfiguration routines.
      */ 
     static struct dev_ops xx_dev_ops = {
             ....
             &xx_cb_ops,             /* devo_cb_ops */
             ....
     };
     static struct cb_ops xx_cb_ops = {
     nodev,                  /* open */
      nodev,                  /* close */
      nodev,                  /* strategy */
      nodev,                  /* print */
      nodev,                  /* dump */
      nodev,                  /* read */
      nodev,                  /* write */
      nodev,                  /* ioctl */
      nodev,                  /* devmap */
      nodev,                  /* mmap */
      nodev,                  /* segmap */
      nochpoll,               /* poll */
      nodev,                  /* cb_prop_op */
      0,                      /* streamtab  */
      D_MP | D_HOTPLUG,        /* Driver compatibility flag */
      CB_REV,                 /* cb_rev */
      nodev,                  /* async I/O read entry point */
      nodev                   /* async I/O write entry point */
     };

The DDI_DETACH and DDI_SUSPEND/RESUME requirements are very similar to those of leaf drivers described above.