1 AWRITE(9E)                    Driver Entry Points                   AWRITE(9E)
   2 
   3 
   4 
   5 NAME
   6        awrite - asynchronous write to a device
   7 
   8 SYNOPSIS
   9        #include <sys/uio.h>
  10        #include <sys/aio_req.h>
  11        #include <sys/cred.h>
  12        #include <sys/ddi.h>
  13        #include <sys/sunddi.h>
  14 
  15        int prefixawrite(dev_t dev, struct aio_req *aio_reqp,
  16             cred_t *cred_p);
  17 
  18 
  19 INTERFACE LEVEL
  20        Solaris DDI specific (Solaris DDI). This entry point is optional.
  21        Drivers that do not support an awrite() entry point should use
  22        nodev(9F)
  23 
  24 PARAMETERS
  25        dev
  26                    Device number.
  27 
  28 
  29        aio_reqp
  30                    Pointer to the aio_req(9S) structure that describes where
  31                    the data is stored.
  32 
  33 
  34        cred_p
  35                    Pointer to the credential structure.
  36 
  37 
  38 DESCRIPTION
  39        The driver's awrite() routine is called to perform an asynchronous
  40        write.  getminor(9F) can be used to access the minor number component
  41        of the dev argument. awrite() may use the credential structure pointed
  42        to by cred_p to check for superuser access by calling drv_priv(9F).
  43        The awrite() routine may also examine the uio(9S) structure through the
  44        aio_req structure pointer, aio_reqp. awrite() must call aphysio(9F)
  45        with the aio_req pointer and a pointer to the driver's strategy(9E)
  46        routine.
  47 
  48 
  49        No fields of the uio(9S) structure pointed to by aio_req, other than
  50        uio_offset or uio_loffset, may be modified for non-seekable devices.
  51 
  52 RETURN VALUES
  53        The awrite() routine should return  0 for success, or the appropriate
  54        error number.
  55 
  56 CONTEXT
  57        This function is called from user context only.
  58 
  59 EXAMPLES
  60        Example 1 Using the awrite() routine:
  61 
  62 
  63        The following is an example of an awrite() routine:
  64 
  65 
  66          static int
  67          xxawrite(dev_t dev, struct aio_req *aio, cred_t *cred_p)
  68          {
  69                  int instance;
  70                  struct xxstate *xsp;
  71 
  72                  instance = getminor(dev);
  73                  xsp = ddi_get_soft_state(statep, instance);
  74                  /*Verify soft state structure has been allocated */
  75                  if (xsp == NULL)
  76                           return (ENXIO);
  77                  return (aphysio(xxstrategy, anocancel, dev, B_WRITE, \
  78                  xxminphys, aio));
  79          }
  80 
  81 
  82 SEE ALSO
  83        write(2), aiowrite(3C), aread(9E), read(9E), strategy(9E), write(9E),
  84        anocancel(9F), aphysio(9F), ddi_get_soft_state(9F), drv_priv(9F),
  85        getminor(9F), minphys(9F), nodev(9F), aio_req(9S), cb_ops(9S), uio(9S)
  86 
  87 
  88        Writing Device Drivers
  89 
  90 BUGS
  91        There is no way other than calling aphysio(9F) to accomplish an
  92        asynchronous write.
  93 
  94 
  95 
  96                                February 15, 2020                    AWRITE(9E)