Kernel Functions for Drivers pullupmsg(9F)
NAME
pullupmsg - concatenate bytes in a message
SYNOPSIS
#include
int pullupmsg(mblkt *mp, ssizet len);
INTERFACE LEVEL
Architecture independent level 1 (DI/DKI).
PARAMETERS
mp Pointer to the message whose blocks are to be con-
catenated. mblkt is an instance of the msgb(9S)
structure.
len Number of bytes to concatenate.
DESCRIPTION
The pullupmsg() function tries to combine multiple data
blocks into a single block. pullupmsg() concatenates and
aligns the first len data bytes of the message pointed to by
mp. If len equals -1, all data are concatenated. If len
bytes of the same message type cannot be found, pullupmsg()
fails and returns 0.
RETURN VALUES
On success, 1 is returned; on failure, 0 is returned.
CONTEXT
The pullupmsg() function can be called from user, interrupt,
or kernel context.
EXAMPLES
Example 1 Using pullupmsg()
This is a driver write srv(9E) (service) routine for a dev-
ice that does not support scatter/gather DMA. For all
MDATA messages, the data will be transferred to the device
with DMA. First, try to pull up the message into one message
block with the pullupmsg() function (line 12). If success-
ful, the transfer can be accomplished in one DMA job. Other-
wise, it must be done one message block at a time (lines
19-22). After the data has been transferred to the device,
free the message and continue processing messages on the
queue.
SunOS 5.11 Last change: 16 Jan 2006 1
Kernel Functions for Drivers pullupmsg(9F)
1 xxxwsrv(q)
2 queuet *q;
3 {
4 mblkt *mp;
5 mblkt *tmp;
6 caddrt dmaaddr;
7 ssizet dmalen;
8
9 while ((mp = getq(q)) != NUL) {
10 switch (mp->bdatap->dbtype) {
11 case MDATA:
12 if (pullupmsg(mp, -1)) {
13 dmaaddr = vtop(mp->brptr);
14 dmalen = mp->bwptr - mp->brptr;
15 xxxdodma(dmaaddr, dmalen);
16 freemsg(mp);
17 break;
18 }
19 for (tmp = mp; tmp; tmp = tmp->bcont) {
20 dmaaddr = vtop(tmp->brptr);
21 dmalen = tmp->bwptr - tmp->brptr;
22 xxxdodma(dmaaddr, dmalen);
23 }
24 freemsg(mp);
25 break;
. . .
26 }
27 }
28 }
SEE ALSO
srv(9E), allocb(9F), msgpullup(9F), msgb(9S)
Writing Device Drivers
STREAMS Programming Guide
NOTES
The pullupmsg() function is not included in the DKI and will
be removed from the system in a future release. Device
driver writers are strongly encouraged to use msgpullup(9F)
instead of pullupmsg().
SunOS 5.11 Last change: 16 Jan 2006 2
|