question about tty->t_outq && clist && cblock

Matthias Apitz matthias.apitz at oclc.org
Wed May 14 10:25:08 UTC 2008


Hello,

I've some small questions about the struct 'clist', 'cblock' and 'tty'

/usr/src/sys/sys/tty.h says about 'clist'

/*
 * Clists are character lists, which is a variable length linked list
 * of cblocks, with a count of the number of characters in the list.
 */
struct clist {
        int     c_cc;           /* Number of characters in the clist. */
        int     c_cbcount;      /* Number of cblocks. */
        int     c_cbmax;        /* Max # cblocks allowed for this clist.  */
        int     c_cbreserved;   /* # cblocks reserved for this clist. */
        char    *c_cf;          /* Pointer to the first cblock. */
        char    *c_cl;          /* Pointer to the last cblock. */
};

and about 'tty'

struct tty {
        struct  clist t_rawq;           /* Device raw input queue. */
        long    t_rawcc;                /* Raw input queue statistics.  */
        struct  clist t_canq;           /* Device canonical queue. */
        long    t_cancc;                /* Canonical queue statistics.  */
        struct  clist t_outq;           /* Device output queue. */
        ...
}

and /usr/src/sys/sys/clist.h about 'cblock'

struct cblock {
        struct cblock *c_next;                  /* next cblock in queue */
        unsigned char c_quote[CBQSIZE];         /* quoted characters */
        unsigned char c_info[CBSIZE];           /* characters */
};

In the driver it seems that tty->t_outq.c_cf is pointing to the data
bytes itself which the driver should send to the device and not to
a 'cblock' (the comment in 'clist' says *c_cf; is Pointer to the first
cblock);

is this just a small error in the comment and t_outq.c_cf is really
pointing to cblock.c_info[]?

what would be the correct way to pick up the next 'cblock' in that chain
if there is already more data to deliver when for example
tty->t_outq.c_cc says 810 bytes? picking up the 4 byte pointer at
t_outq.c_cf - 20?

thanks in advance for some clarification


	matthias

-- 
Matthias Apitz
http://www.UnixArea.de/


More information about the freebsd-drivers mailing list