esballoc(D3DK) —
.IX \f4esballoc\fP(D3DK)
NAME
esballoc − allocate a message block using an externally-supplied buffer
SYNOPSIS
#include <sys/types.h>
#include <sys/stream.h>
mblk_t ∗esballoc(uchar_t ∗base, int size, int pri, frtn_t ∗fr_rtnp);
ARGUMENTS
baseAddress of driver-supplied data buffer.
sizeNumber of bytes in data buffer.
priPriority of allocation request (used to allocate the message and data blocks.) Valid values are BPRI_LO, BPRI_MED, BPRI_HI, and BPRI_CONSOLE.
fr_rtnpPointer to the free-routine data structure.
DESCRIPTION
esballoc creates a STREAMS message and attaches a driver-supplied data buffer in place of a STREAMS data buffer. It allocates a message and data block header only. The driver-supplied data buffer, pointed to by base, is used as the data buffer for the message.
When freeb(D3DK) is called to free the message, on the last reference to the message, the driver’s free-routine, specified by the free_func field in the free_rtn(D4DK) structure, is called with one argument, specified by the free_arg field, to free the data buffer.
Instead of requiring a specific number of arguments, the free_arg field is defined of type char ∗. This way, the driver can pass a pointer to a structure if more than one argument is needed.
When the free_func function runs, interrupts from all STREAMS devices will be blocked. It has no user context and may not call any routine that sleeps. The function may not access any dynamically allocated data structures that might no longer exist when it runs.
RETURN VALUE
On success, a pointer to the newly allocated message block is returned. On failure, NULL is returned.
LEVEL
Base or Interrupt.
NOTES
Does not sleep.
Driver-defined basic locks, read/write locks, and sleep locks may be held across calls to this function.
SEE ALSO
allocb(D3DK), freeb(D3DK), free_rtn(D4DK)
DDI/DKI — STREAMS