1 CB_OPS(9S)                Data Structures for Drivers               CB_OPS(9S)
   2 
   3 NAME
   4      cb_ops - character/block entry points structure
   5 
   6 SYNOPSIS
   7      #include <sys/conf.h>
   8      #include <sys/ddi.h>
   9      #include <sys/sunddi.h>
  10 
  11 INTERFACE LEVEL
  12      Solaris DDI specific (Solaris DDI)
  13 
  14 DESCRIPTION
  15      The cb_ops structure contains all entry points for drivers that support
  16      both character and block entry points.  All leaf device drivers that
  17      support direct user process access to a device should declare a cb_ops
  18      structure.
  19 
  20      All drivers that safely allow multiple threads of execution in the driver
  21      at the same time must set the D_MP flag in the cb_flag field.  See
  22      open(9E).
  23 
  24      If the driver properly handles 64-bit offsets, it should also set the
  25      D_64BIT flag in the cb_flag field.  This specifies that the driver will
  26      use the uio_loffset field of the uio(9S) structure.
  27 
  28      If the driver returns EINTR from open(9E), it should also set the
  29      D_OPEN_RETURNS_EINTR flag in the cb_flag field.  This lets the framework
  30      know that it is safe for the driver to return EINTR when waiting, to
  31      provide exclusion for a last-reference close(9E) call to complete before
  32      calling open(9E).
  33 
  34      The mt-streams(9F) function describes other flags that can be set in the
  35      cb_flag field.
  36 
  37      The cb_rev is the cb_ops structure revision number.  This field must be
  38      set to CB_REV.
  39 
  40      Non-STREAMS drivers should set cb_str to NULL.
  41 
  42      The following DDI/DKI or DKI-only or DDI-only functions are provided in
  43      the character/block driver operations structure.
  44 
  45      block/char    Function    Description
  46      b/c           XXopen      DDI/DKI
  47      b/c           XXclose     DDI/DKI
  48      b             XXstrategy  DDI/DKI
  49      b             XXprint     DDI/DKI
  50      b             XXdump      DDI(Sun)
  51      c             XXread      DDI/DKI
  52      c             XXwrite     DDI/DKI
  53      c             XXioctl     DDI/DKI
  54      c             XXdevmap    DDI(Sun)
  55      c             XXmmap      DKI
  56      c             XXsegmap    DKI
  57      c             XXchpoll    DDI/DKI
  58      c             XXprop_op   DDI(Sun)
  59      c             XXaread     DDI(Sun)
  60      c             XXawrite    DDI(Sun)
  61 
  62 STRUCTURE MEMBERS
  63        int  (*cb_open)(dev_t *devp, int flag, int otyp, cred_t *credp);
  64        int  (*cb_close)(dev_t dev, int flag, int otyp, cred_t *credp);
  65        int  (*cb_strategy)(struct buf *bp);
  66        int  (*cb_print)(dev_t dev, char *str);
  67        int  (*cb_dump)(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
  68        int  (*cb_read)(dev_t dev, struct uio *uiop, cred_t *credp);
  69        int  (*cb_write)(dev_t dev, struct uio *uiop, cred_t *credp);
  70        int  (*cb_ioctl)(dev_t dev, int cmd, intptr_t arg, int mode,
  71               cred_t *credp, int *rvalp);
  72        int  (*cb_devmap)(dev_t dev, devmap_cookie_t dhp, offset_t off,
  73               size_t len, size_t *maplen, uint_t model);
  74        int  (*cb_mmap)(dev_t dev, off_t off, int prot);
  75        int  (*cb_segmap)(dev_t dev, off_t off, struct as *asp,
  76               caddr_t *addrp, off_t len, unsigned int prot,
  77               unsigned int maxprot, unsigned int flags, cred_t *credp);
  78        int  (*cb_chpoll)(dev_t dev, short events, int anyyet,
  79               short *reventsp, struct pollhead **phpp);
  80        int  (*cb_prop_op)(dev_t dev, dev_info_t *dip,
  81               ddi_prop_op_t prop_op, int mod_flags,
  82               char *name, caddr_t valuep, int *length);
  83        struct streamtab *cb_str;   /* streams information */
  84        int  cb_flag;
  85        int  cb_rev;
  86        int  (*cb_aread)(dev_t dev, struct aio_req *aio, cred_t *credp);
  87        int  (*cb_awrite)(dev_t dev, struct aio_req *aio, cred_t *credp);
  88 
  89 SEE ALSO
  90      aread(9E), awrite(9E), chpoll(9E), close(9E), dump(9E), ioctl(9E),
  91      mmap(9E), open(9E), print(9E), prop_op(9E), read(9E), segmap(9E),
  92      strategy(9E), write(9E), nochpoll(9F), nodev(9F), nulldev(9F),
  93      dev_ops(9S), qinit(9S)
  94 
  95      Writing Device Drivers.
  96 
  97      STREAMS Programming Guide.
  98 
  99 illumos                          July 9, 2018                          illumos