1pullupmsg(9F)            Kernel Functions for Drivers            pullupmsg(9F)
2
3
4

NAME

6       pullupmsg - concatenate bytes in a message
7

SYNOPSIS

9       #include <sys/stream.h>
10
11
12
13       int pullupmsg(mblk_t *mp, ssize_t len);
14
15

INTERFACE LEVEL

17       Architecture independent level 1 (DDI/DKI).
18

PARAMETERS

20       mp     Pointer  to  the  message  whose  blocks are to be concatenated.
21              mblk_t is an instance of the msgb(9S) structure.
22
23
24       len    Number of bytes to concatenate.
25
26

DESCRIPTION

28       The pullupmsg() function tries to combine multiple data blocks  into  a
29       single  block.  pullupmsg()  concatenates and aligns the first len data
30       bytes of the message pointed to by mp. If len equals -1, all  data  are
31       concatenated.  If  len  bytes of the same message type cannot be found,
32       pullupmsg() fails and returns 0.
33

RETURN VALUES

35       On success, 1 is returned; on failure, 0 is returned.
36

CONTEXT

38       The pullupmsg() function can be called from user, interrupt, or  kernel
39       context.
40

EXAMPLES

42       Example 1 Using pullupmsg()
43
44
45       This is a driver write srv(9E) (service) routine for a device that does
46       not support scatter/gather DMA. For all  M_DATA messages, the data will
47       be  transferred  to the device with DMA. First, try to pull up the mes‐
48       sage into one message block with the pullupmsg() function (line 12). If
49       successful, the transfer can be accomplished in one DMA job. Otherwise,
50       it must be done one message block at a time (lines  19-22).  After  the
51       data  has been transferred to the device, free the message and continue
52       processing messages on the queue.
53
54
55
56          1 xxxwsrv(q)
57          2    queue_t *q;
58          3 {
59          4       mblk_t *mp;
60          5       mblk_t *tmp;
61          6       caddr_t dma_addr;
62          7     ssize_t dma_len;
63          8
64          9       while ((mp = getq(q)) != NULL) {
65         10               switch (mp->b_datap->db_type) {
66         11             case M_DATA:
67         12                      if (pullupmsg(mp, -1)) {
68         13                            dma_addr = vtop(mp->b_rptr);
69         14                              dma_len = mp->b_wptr - mp->b_rptr;
70         15                              xxx_do_dma(dma_addr, dma_len);
71         16                              freemsg(mp);
72         17                              break;
73         18                      }
74         19                      for (tmp = mp; tmp; tmp = tmp->b_cont) {
75         20                            dma_addr = vtop(tmp->b_rptr);
76         21                            dma_len = tmp->b_wptr - tmp->b_rptr;
77         22                            xxx_do_dma(dma_addr, dma_len);
78         23                    }
79         24                      freemsg(mp);
80         25                      break;
81                    . . .
82         26                }
83         27       }
84         28 }
85
86

SEE ALSO

88       srv(9E), allocb(9F), msgpullup(9F), msgb(9S)
89
90
91       Writing Device Drivers
92
93
94       STREAMS Programming Guide
95

NOTES

97       The pullupmsg() function is not included in the DKI and will be removed
98       from the system in a future release. Device driver writers are strongly
99       encouraged to use msgpullup(9F) instead of pullupmsg().
100
101
102
103SunOS 5.11                        16 Jan 2006                    pullupmsg(9F)
Impressum