STREAMS/UX for the HP 9000 Reference Manual

154
Debugging STREAMS/UX Modules and Drivers
STREAMS/UX Debugging Tool
struct sp {
unsigned sp_state; /* Set to SPOPEN when driver opened. */
/* Cleared when driver is closed. */
queue_t *sp_rdq; /* Contains sp's read q pointer. */
mblk_t *first_mp; /* Pointer to head of message list. */
/* Messages are saved here until */
/* timeout expires. */
mblk_t *last_mp; /* Pointer to tail of message list. */
};
/* Driver state values. */
#define SPOPEN 01
static sp_put(q, mp)
queue_t *q;
mblk_t *mp;
{
struct sp *private;
unsigned int s;
/*
* Check the message type.
*/
switch (mp->b_datap->db_type) {
case M_DATA:
case M_PROTO:
case M_PCPROTO:
/* Raise the spl level to protect private structure,
* since timeout functions such as sp_timeout can
* interrupt sp_put.
*/
s = splstr();
/* Put the message at the tail of the
* private data structure queue.
*/
private = q->q_ptr;
if (!private->last_mp)
private->first_mp = mp;
else
private->last_mp->b_next = mp;
private->last_mp = mp;
splx(s);
/* Set the timeout */
timeout(sp_timeout,private,1);
break;
default:
printf(“Routine sp_put: Illegal message %x received.\n”,
mp->b_datap->db_type);
break;
}
}