MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers        scsiallocconsistentbuf(9F)



NAME
     scsiallocconsistentbuf - allocate an I/O buffer for  SCSI
     DMA

SYNOPSIS
     #include 



     struct buf *scsiallocconsistentbuf(structscsiaddress*ap,
          struct buf *bp, sizet datalen, uintt bflags,
          int (*callback)(caddrt), caddrt arg);


INTERFACE LEVEL
     Solaris DI specific (Solaris DI).

PARAMETERS
     ap          Pointer to the scsiaddress(9S) structure.


     bp          Pointer to the buf(9S) structure.


     datalen     Number of bytes for the data buffer.


     bflags      Flags setting for the allocated  buffer  header.
                 This should either be BREAD or BWRITE.


     callback    A pointer to a callback function,  NULFUNC  or
                 SLEPFUNC.


     arg         The callback function argument.


DESCRIPTION
     The scsiallocconsistentbuf() function returns allocates a
     buffer  header  and  the  associated  data buffer for direct
     memory access (DMA) transfer. This buffer is allocated  from
     the  iobp  space, which is considered consistent memory. For
     more     details,     see     ddidmamemalloc(9F)      and
     ddidmasync(9F).


     For buffers allocated via  scsiallocconsistentbuf(),  and
     marked  with  the PKTCONSISTENT flag via scsiinitpkt(9F),
     the HBA driver must ensure that the data  transfer  for  the
     command is correctly synchronized before the target driver's
     command completion callback is performed.



SunOS 5.11          Last change: 16 Jan 2006                    1






Kernel Functions for Drivers        scsiallocconsistentbuf(9F)



     If bp is NUL, a new buffer header will be  allocated  using
     getrbuf(9F).  In  addition,  if  datalen  is non-zero, a new
     buffer will be allocated using ddidmamemalloc(9F).


     callback indicates what the  allocator  routines  should  do
     when direct memory access (DMA) resources are not available;
     the valid values are:

     NULFUNC       Do not wait for  resources.  Return  a  NUL
                     pointer.


     SLEPFUNC      Wait indefinitely for resources.


     Other Values    callback points to a function that is called
                     when  resources  may become available. call-
                     back must return either 0  (indicating  that
                     it   attempted  to  allocate  resources  but
                     failed to do so), in which case  it  is  put
                     back  on a list to be called again later, or
                     1 indicating either  success  in  allocating
                     resources  or  indicating  that it no longer
                     cares for a retry. The last argument arg  is
                     supplied to the callback function when it is
                     invoked.


RETURN VALUES
     The scsiallocconsistentbuf() function returns  a  pointer
     to  a  buf(9S)  structure  on  success.  It  returns NUL if
     resources  are  not  available  even  if  waitfunc  was  not
     SLEPFUNC.

CONTEXT
     If callback is SLEPFUNC, then this routine may  be  called
     only  from  user-level  code.  Otherwise,  it  may be called
     fromuser, interrupt, or kernel context. The  callback  func-
     tion may not block or call routines that block.

EXAMPLES
     Example 1 Allocate a request sense  packet  with  consistent
     DMA resources attached.

          bp = scsiallocconsistentbuf(&devp->sdaddress, NUL,
                SENSELENGTH, BREAD, SLEPFUNC, NUL);
           rqpkt = scsiinitpkt(&devp->sdaddress,
                NUL, bp, CDBGROUP0, 1, 0,
                PKTCONSISTENT, SLEPFUNC, NUL);





SunOS 5.11          Last change: 16 Jan 2006                    2






Kernel Functions for Drivers        scsiallocconsistentbuf(9F)



     Example 2 Allocate an inquiry  packet  with  consistent  DMA
     resources attached.

           bp = scsiallocconsistentbuf(&devp->sdaddress, NUL,
                SUNINQSIZE, BREAD, canwait, NUL);
           if (bp) {
            pkt = scsiinitpkt(&devp->sdaddress, NUL, bp,
                 CDBGROUP0, 1, PLEN, PKTCONSISTENT,
                 canwait, NUL);
           }


SEE ALSO
     ddidmamemalloc(9F),    ddidmasync(9F),     getrbuf(9F),
     scsidestroypkt(9F),                     scsiinitpkt(9F),
     scsifreeconsistentbuf(9F), buf(9S), scsiaddress(9S)


     Writing Device Drivers




































SunOS 5.11          Last change: 16 Jan 2006                    3



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™