scsi_alloc_consistent_buf(9F)
NAME
scsi_alloc_consistent_buf − allocate an I/O buffer for SCSI DMA
SYNOPSIS
#include <sys/scsi/scsi.h>
struct buf ∗scsi_alloc_consistent_buf(struct scsi_address ∗ap, struct buf ∗bp,
int datalen, ulong bflags, int (∗callback )(caddr_t) , caddr_t arg);
ARGUMENTS
ap Pointer to the scsi_address structure.
bp Pointer to the buf(9S) structure.
datalen Number of bytes for the data buffer.
bflags Flags setting for the allocated buffer header.
callback NULL_FUNC or SLEEP_FUNC.
arg callback function argument, must be set to NULL.
INTERFACE LEVEL
Solaris architecture specific (SunDDI).
DESCRIPTION
scsi_alloc_consistent_buf() 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. See ddi_iopb_alloc(9F) and ddi_dma_sync(9F) for more details. If bp is NULL, a new buffer header will be allocated using getrbuf(9F). In addition, if datalen is non-zero, a new buffer will be allocated using ddi_iopb_alloc(9F).
callback indicates what the allocator routines should do when direct memory access (DMA) resources are not available; the valid values are:
NULL_FUNC Do not wait for resources. Return a NULL pointer.
SLEEP_FUNC
Wait indefinitely for resources.
RETURN VALUES
scsi_alloc_consistent_buf() returns a pointer to a buf(9S) structure on success. It returns NULL if resources are not available.
CONTEXT
If callback is SLEEP_FUNC, then this routine may only be called from user-level code. Otherwise, it may be called from either user or interrupt level. The callback function may not block or call routines that block.
EXAMPLE
bp = scsi_alloc_consistent_buf(&devp->sd_address, NULL,
SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL);
rqpkt = scsi_init_pkt(&devp->sd_address,
NULL, bp, CDB_GROUP0, 1, 0,
PKT_CONSISTENT, SLEEP_FUNC, NULL);
SEE ALSO
ddi_dma_sync(9F), ddi_iopb_alloc(9F), getrbuf(9F), scsi_init_pkt(9F), scsi_destroy_pkt(9F), scsi_free_consistent_buf(9F), buf(9S)
SunOS 5.1 Writing Device Drivers
SunOS 5.2 — Last change: 21 Dec 1992