7. comstart() #1comstart() #1comstart() #1comstart() #1comstart() #1
void
comstart(struct tty *tp)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(tp->t_dev));
struct com_regs *regsp = &sc->sc_regs;
int s;
if (COM_ISALIVE(sc) == 0)
return;
s = spltty();
if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
goto out;
if (sc->sc_tx_stopped)
goto out;
if (!ttypull(tp))
goto out;
void
comstart(struct tty *tp)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(tp->t_dev));
struct com_regs *regsp = &sc->sc_regs;
int s;
if (COM_ISALIVE(sc) == 0)
return;
s = spltty();
if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
goto out;
if (sc->sc_tx_stopped)
goto out;
if (!ttypull(tp))
goto out;
void
comstart(struct tty *tp)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(tp->t_dev));
struct com_regs *regsp = &sc->sc_regs;
int s;
if (COM_ISALIVE(sc) == 0)
return;
s = spltty();
if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
goto out;
if (sc->sc_tx_stopped)
goto out;
if (!ttypull(tp))
goto out;
void
comstart(struct tty *tp)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(tp->t_dev));
struct com_regs *regsp = &sc->sc_regs;
int s;
if (COM_ISALIVE(sc) == 0)
return;
s = spltty();
if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
goto out;
if (sc->sc_tx_stopped)
goto out;
if (!ttypull(tp))
goto out;
void
comstart(struct tty *tp)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(tp->t_dev));
struct com_regs *regsp = &sc->sc_regs;
int s;
if (COM_ISALIVE(sc) == 0)
return;
s = spltty();
if (ISSET(tp->t_state, TS_BUSY | TS_TIMEOUT | TS_TTSTOP))
goto out;
if (sc->sc_tx_stopped)
goto out;
if (!ttypull(tp))
goto out;
8. ttypull()ttypull()ttypull()ttypull()ttypull()
/*
* Try to pull more output from the producer. Return non-zero if
* there is output ready to be sent.
*/
bool
ttypull(struct tty *tp)
{
/* XXXSMP not yet KASSERT(mutex_owned(&tty_lock)); */
if (tp->t_outq.c_cc <= tp->t_lowat) {
cv_broadcast(&tp->t_outcv);
selnotify(&tp->t_wsel, 0, NOTE_SUBMIT);
}
return tp->t_outq.c_cc != 0;
}
/*
* Try to pull more output from the producer. Return non-zero if
* there is output ready to be sent.
*/
bool
ttypull(struct tty *tp)
{
/* XXXSMP not yet KASSERT(mutex_owned(&tty_lock)); */
if (tp->t_outq.c_cc <= tp->t_lowat) {
cv_broadcast(&tp->t_outcv);
selnotify(&tp->t_wsel, 0, NOTE_SUBMIT);
}
return tp->t_outq.c_cc != 0;
}
/*
* Try to pull more output from the producer. Return non-zero if
* there is output ready to be sent.
*/
bool
ttypull(struct tty *tp)
{
/* XXXSMP not yet KASSERT(mutex_owned(&tty_lock)); */
if (tp->t_outq.c_cc <= tp->t_lowat) {
cv_broadcast(&tp->t_outcv);
selnotify(&tp->t_wsel, 0, NOTE_SUBMIT);
}
return tp->t_outq.c_cc != 0;
}
/*
* Try to pull more output from the producer. Return non-zero if
* there is output ready to be sent.
*/
bool
ttypull(struct tty *tp)
{
/* XXXSMP not yet KASSERT(mutex_owned(&tty_lock)); */
if (tp->t_outq.c_cc <= tp->t_lowat) {
cv_broadcast(&tp->t_outcv);
selnotify(&tp->t_wsel, 0, NOTE_SUBMIT);
}
return tp->t_outq.c_cc != 0;
}
/*
* Try to pull more output from the producer. Return non-zero if
* there is output ready to be sent.
*/
bool
ttypull(struct tty *tp)
{
/* XXXSMP not yet KASSERT(mutex_owned(&tty_lock)); */
if (tp->t_outq.c_cc <= tp->t_lowat) {
cv_broadcast(&tp->t_outcv);
selnotify(&tp->t_wsel, 0, NOTE_SUBMIT);
}
return tp->t_outq.c_cc != 0;
}
9. comstart() #2comstart() #2comstart() #2comstart() #2comstart() #2
/* Grab the first contiguous region of buffer space. */
{
u_char *tba;
int tbc;
tba = tp->t_outq.c_cf;
tbc = ndqb(&tp->t_outq, 0);
mutex_spin_enter(&sc->sc_lock);
sc->sc_tba = tba;
sc->sc_tbc = tbc;
}
SET(tp->t_state, TS_BUSY);
sc->sc_tx_busy = 1;
/* Grab the first contiguous region of buffer space. */
{
u_char *tba;
int tbc;
tba = tp->t_outq.c_cf;
tbc = ndqb(&tp->t_outq, 0);
mutex_spin_enter(&sc->sc_lock);
sc->sc_tba = tba;
sc->sc_tbc = tbc;
}
SET(tp->t_state, TS_BUSY);
sc->sc_tx_busy = 1;
/* Grab the first contiguous region of buffer space. */
{
u_char *tba;
int tbc;
tba = tp->t_outq.c_cf;
tbc = ndqb(&tp->t_outq, 0);
mutex_spin_enter(&sc->sc_lock);
sc->sc_tba = tba;
sc->sc_tbc = tbc;
}
SET(tp->t_state, TS_BUSY);
sc->sc_tx_busy = 1;
/* Grab the first contiguous region of buffer space. */
{
u_char *tba;
int tbc;
tba = tp->t_outq.c_cf;
tbc = ndqb(&tp->t_outq, 0);
mutex_spin_enter(&sc->sc_lock);
sc->sc_tba = tba;
sc->sc_tbc = tbc;
}
SET(tp->t_state, TS_BUSY);
sc->sc_tx_busy = 1;
/* Grab the first contiguous region of buffer space. */
{
u_char *tba;
int tbc;
tba = tp->t_outq.c_cf;
tbc = ndqb(&tp->t_outq, 0);
mutex_spin_enter(&sc->sc_lock);
sc->sc_tba = tba;
sc->sc_tbc = tbc;
}
SET(tp->t_state, TS_BUSY);
sc->sc_tx_busy = 1;
10. ndqb()ndqb()ndqb()ndqb()ndqb()
/*
* Return count of contiguous characters in clist.
* Stop counting if flag&character is non-null.
*/
int
ndqb(struct clist *clp, int flag)
{
int count = 0;
int i;
int cc;
int s;
s = spltty();
if ((cc = clp->c_cc) == 0)
goto out;
// --snip--
out:
splx(s);
return count;
}
/*
* Return count of contiguous characters in clist.
* Stop counting if flag&character is non-null.
*/
int
ndqb(struct clist *clp, int flag)
{
int count = 0;
int i;
int cc;
int s;
s = spltty();
if ((cc = clp->c_cc) == 0)
goto out;
// --snip--
out:
splx(s);
return count;
}
/*
* Return count of contiguous characters in clist.
* Stop counting if flag&character is non-null.
*/
int
ndqb(struct clist *clp, int flag)
{
int count = 0;
int i;
int cc;
int s;
s = spltty();
if ((cc = clp->c_cc) == 0)
goto out;
// --snip--
out:
splx(s);
return count;
}
/*
* Return count of contiguous characters in clist.
* Stop counting if flag&character is non-null.
*/
int
ndqb(struct clist *clp, int flag)
{
int count = 0;
int i;
int cc;
int s;
s = spltty();
if ((cc = clp->c_cc) == 0)
goto out;
// --snip--
out:
splx(s);
return count;
}
/*
* Return count of contiguous characters in clist.
* Stop counting if flag&character is non-null.
*/
int
ndqb(struct clist *clp, int flag)
{
int count = 0;
int i;
int cc;
int s;
s = spltty();
if ((cc = clp->c_cc) == 0)
goto out;
// --snip--
out:
splx(s);
return count;
}
11. struct cliststruct cliststruct cliststruct cliststruct clist
/*
* Clists are actually ring buffers. The c_cc, c_cf, c_cl fields
have
* exactly the same behaviour as in true clists.
* if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
* (but, saves memory and CPU time)
*
* *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside
tty_subr.c!!!
*/
struct clist {
u_char *c_cf; /* points to first character */
u_char *c_cl; /* points to next open character */
u_char *c_cs; /* start of ring buffer */
u_char *c_ce; /* c_ce + c_len */
u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
int c_cc; /* count of characters in queue */
int c_cn; /* total ring buffer length */
};
/*
* Clists are actually ring buffers. The c_cc, c_cf, c_cl fields
have
* exactly the same behaviour as in true clists.
* if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
* (but, saves memory and CPU time)
*
* *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside
tty_subr.c!!!
*/
struct clist {
u_char *c_cf; /* points to first character */
u_char *c_cl; /* points to next open character */
u_char *c_cs; /* start of ring buffer */
u_char *c_ce; /* c_ce + c_len */
u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
int c_cc; /* count of characters in queue */
int c_cn; /* total ring buffer length */
};
/*
* Clists are actually ring buffers. The c_cc, c_cf, c_cl fields
have
* exactly the same behaviour as in true clists.
* if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
* (but, saves memory and CPU time)
*
* *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside
tty_subr.c!!!
*/
struct clist {
u_char *c_cf; /* points to first character */
u_char *c_cl; /* points to next open character */
u_char *c_cs; /* start of ring buffer */
u_char *c_ce; /* c_ce + c_len */
u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
int c_cc; /* count of characters in queue */
int c_cn; /* total ring buffer length */
};
/*
* Clists are actually ring buffers. The c_cc, c_cf, c_cl fields
have
* exactly the same behaviour as in true clists.
* if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
* (but, saves memory and CPU time)
*
* *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside
tty_subr.c!!!
*/
struct clist {
u_char *c_cf; /* points to first character */
u_char *c_cl; /* points to next open character */
u_char *c_cs; /* start of ring buffer */
u_char *c_ce; /* c_ce + c_len */
u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
int c_cc; /* count of characters in queue */
int c_cn; /* total ring buffer length */
};
/*
* Clists are actually ring buffers. The c_cc, c_cf, c_cl fields
have
* exactly the same behaviour as in true clists.
* if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality
* (but, saves memory and CPU time)
*
* *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside
tty_subr.c!!!
*/
struct clist {
u_char *c_cf; /* points to first character */
u_char *c_cl; /* points to next open character */
u_char *c_cs; /* start of ring buffer */
u_char *c_ce; /* c_ce + c_len */
u_char *c_cq; /* N bits/bytes long, see tty_subr.c */
int c_cc; /* count of characters in queue */
int c_cn; /* total ring buffer length */
};