SVR5
geteblk(D3)
geteblk --
get an empty buffer
Synopsis (Not in current DDI version)
#include <sys/types.h>
#include <sys/buf.h>
#include <sys/ddi.h>
buf_t *geteblk(void);
Description
geteblk retrieves a buffer [see
buf(D4)]
from the buffer cache and returns a pointer to the
buffer header.
If a buffer is not
available, geteblk sleeps until one is available.
Return values
A pointer to the buffer header structure is
returned.
Usage
When the driver
strategy(D2)
routine receives a buffer header
from the kernel, all the necessary members are already initialized.
However, when a driver allocates buffers for its own use, it
must set up some of the members before
using the buffer for an I/O request.
The following list describes the state of these members
when the buffer header is received from geteblk:
b_flags-
is set for a synchronous write transfer
from main memory to the device.
The driver must turn on B_READ flag
to transfer from the device to main memor.
The driver may also turn on
the B_ASYNC flag
and set the
b_iodone
member
for a synchronous transfer.
the user's buffer.
b_edev-
is set to NODEV and must be initialized by the driver.
b_bcount-
is set to 1024.
b_un.b_addr-
is set to the buffer's virtual address.
b_blkno-
is not initialized by geteblk,
and must be
initialized by the driver
b_blkoff-
??
b_addrtype-
is set to BA_KVIRT
b_bufsize-
is set to bsize
b_iodone-
is set to NULL
Typically,
drivers do not allocate buffers.
A buffer is
allocated by the kernel,
and the associated buffer header is used as an
argument to the driver's
strategy(D2)
routine.
However, to implement some special features,
such as
ioctl(D2)
commands that perform I/O,
the driver may need its own buffer space.
The driver can get the buffer space from the system by
using geteblk or
ngeteblk(D3).
If the driver chooses to use its own memory for the buffer,
it can allocate just a buffer header by using the
getrbuf(D3)
function.
Buffers allocated via geteblk must be freed
using either
brelse(D3)
or
biodone(D3).
Context and synchronization
User or blockable
context.
Hardware applicability
All
Version applicability
ddi:
1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp
Differences between versions
In DDI 8, use the
ngeteblk(D3)
function instead of
geteblk( ).
References
biodone(D3),
biowait(D3),
brelse(D3),
buf(D4)
ngeteblk(D3)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005