SlideShare a Scribd company logo
start_printf: dev/ic/com.c
comstart()
start_printf: dev/ic/com.c
comstart()
start_printf: dev/ic/com.c
comstart()
start_printf: dev/ic/com.c
comstart()
start_printf: dev/ic/com.c
comstart()
Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
Where comstart called?Where comstart called?Where comstart called?Where comstart called?Where comstart called?
Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
fifodone:
tp = tty_alloc();
tp->t_oproc = comstart;
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
fifodone:
tp = tty_alloc();
tp->t_oproc = comstart;
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
fifodone:
tp = tty_alloc();
tp->t_oproc = comstart;
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
fifodone:
tp = tty_alloc();
tp->t_oproc = comstart;
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
fifodone:
tp = tty_alloc();
tp->t_oproc = comstart;
com0 attached at isa0com0 attached at isa0com0 attached at isa0com0 attached at isa0com0 attached at isa0
$ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0
com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports
$ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa
attach com at isa with com_isa
file dev/isa/com_isa.c com_isa
$ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0
com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports
$ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa
attach com at isa with com_isa
file dev/isa/com_isa.c com_isa
$ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0
com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports
$ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa
attach com at isa with com_isa
file dev/isa/com_isa.c com_isa
$ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0
com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports
$ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa
attach com at isa with com_isa
file dev/isa/com_isa.c com_isa
$ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0
com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports
$ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa
attach com at isa with com_isa
file dev/isa/com_isa.c com_isa
// File: sys/dev/isa/com_isa.c
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
// -- snip --
com_attach_subr(sc);
// File: sys/dev/isa/com_isa.c
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
// -- snip --
com_attach_subr(sc);
// File: sys/dev/isa/com_isa.c
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
// -- snip --
com_attach_subr(sc);
// File: sys/dev/isa/com_isa.c
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
// -- snip --
com_attach_subr(sc);
// File: sys/dev/isa/com_isa.c
void
com_isa_attach(device_t parent, device_t self, void *aux)
{
// -- snip --
com_attach_subr(sc);
com softc has struct tty membercom softc has struct tty membercom softc has struct tty membercom softc has struct tty membercom softc has struct tty member
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
tp = tty_alloc();
tp->t_oproc = comstart;
tp->t_param = comparam;
tp->t_hwiflow = comhwiflow;
sc->sc_tty = tp;
// -- snip --
tty_attach(tp);
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
tp = tty_alloc();
tp->t_oproc = comstart;
tp->t_param = comparam;
tp->t_hwiflow = comhwiflow;
sc->sc_tty = tp;
// -- snip --
tty_attach(tp);
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
tp = tty_alloc();
tp->t_oproc = comstart;
tp->t_param = comparam;
tp->t_hwiflow = comhwiflow;
sc->sc_tty = tp;
// -- snip --
tty_attach(tp);
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
tp = tty_alloc();
tp->t_oproc = comstart;
tp->t_param = comparam;
tp->t_hwiflow = comhwiflow;
sc->sc_tty = tp;
// -- snip --
tty_attach(tp);
// File: sys/dev/ic/com.c
void
com_attach_subr(struct com_softc *sc)
{
// -- snip --
tp = tty_alloc();
tp->t_oproc = comstart;
tp->t_param = comparam;
tp->t_hwiflow = comhwiflow;
sc->sc_tty = tp;
// -- snip --
tty_attach(tp);
// File: sys/dev/ic/comvar.h
struct com_softc {
device_t sc_dev;
void *sc_si;
struct tty *sc_tty;
// File: sys/dev/ic/comvar.h
struct com_softc {
device_t sc_dev;
void *sc_si;
struct tty *sc_tty;
// File: sys/dev/ic/comvar.h
struct com_softc {
device_t sc_dev;
void *sc_si;
struct tty *sc_tty;
// File: sys/dev/ic/comvar.h
struct com_softc {
device_t sc_dev;
void *sc_si;
struct tty *sc_tty;
// File: sys/dev/ic/comvar.h
struct com_softc {
device_t sc_dev;
void *sc_si;
struct tty *sc_tty;
Maybe call tree is...Maybe call tree is...Maybe call tree is...Maybe call tree is...Maybe call tree is...
cdev_write
=> comwrite
=> ttwrite
=> ttstart
=> comstart
cdev_write
=> comwrite
=> ttwrite
=> ttstart
=> comstart
cdev_write
=> comwrite
=> ttwrite
=> ttstart
=> comstart
cdev_write
=> comwrite
=> ttwrite
=> ttstart
=> comstart
cdev_write
=> comwrite
=> ttwrite
=> ttstart
=> comstart
comwrite()comwrite()comwrite()comwrite()comwrite()
#define COM_ISALIVE(sc) ((sc)->enabled != 0 && 
device_is_active((sc)->sc_dev))
int
comwrite(dev_t dev, struct uio *uio, int flag)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(dev));
struct tty *tp = sc->sc_tty;
if (COM_ISALIVE(sc) == 0)
return (EIO);
return ((*tp->t_linesw->l_write)(tp, uio, flag));
}
#define COM_ISALIVE(sc) ((sc)->enabled != 0 && 
device_is_active((sc)->sc_dev))
int
comwrite(dev_t dev, struct uio *uio, int flag)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(dev));
struct tty *tp = sc->sc_tty;
if (COM_ISALIVE(sc) == 0)
return (EIO);
return ((*tp->t_linesw->l_write)(tp, uio, flag));
}
#define COM_ISALIVE(sc) ((sc)->enabled != 0 && 
device_is_active((sc)->sc_dev))
int
comwrite(dev_t dev, struct uio *uio, int flag)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(dev));
struct tty *tp = sc->sc_tty;
if (COM_ISALIVE(sc) == 0)
return (EIO);
return ((*tp->t_linesw->l_write)(tp, uio, flag));
}
#define COM_ISALIVE(sc) ((sc)->enabled != 0 && 
device_is_active((sc)->sc_dev))
int
comwrite(dev_t dev, struct uio *uio, int flag)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(dev));
struct tty *tp = sc->sc_tty;
if (COM_ISALIVE(sc) == 0)
return (EIO);
return ((*tp->t_linesw->l_write)(tp, uio, flag));
}
#define COM_ISALIVE(sc) ((sc)->enabled != 0 && 
device_is_active((sc)->sc_dev))
int
comwrite(dev_t dev, struct uio *uio, int flag)
{
struct com_softc *sc =
device_lookup_private(&com_cd, COMUNIT(dev));
struct tty *tp = sc->sc_tty;
if (COM_ISALIVE(sc) == 0)
return (EIO);
return ((*tp->t_linesw->l_write)(tp, uio, flag));
}
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;
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;
}
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;
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;
}
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 */
};
struct clist (figure)struct clist (figure)struct clist (figure)struct clist (figure)struct clist (figure)
comstart() #3comstart() #3comstart() #3comstart() #3comstart() #3
/* Enable transmit completion interrupts if necessary. */
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
SET(sc->sc_ier, IER_ETXRDY);
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
}
/* Output the first chunk of the contiguous buffer. */
if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) {
u_int n;
n = sc->sc_tbc;
if (n > sc->sc_fifolen)
n = sc->sc_fifolen;
CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n);
sc->sc_tbc -= n;
sc->sc_tba += n;
}
mutex_spin_exit(&sc->sc_lock);
out:
splx(s);
return;
}
/* Enable transmit completion interrupts if necessary. */
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
SET(sc->sc_ier, IER_ETXRDY);
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
}
/* Output the first chunk of the contiguous buffer. */
if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) {
u_int n;
n = sc->sc_tbc;
if (n > sc->sc_fifolen)
n = sc->sc_fifolen;
CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n);
sc->sc_tbc -= n;
sc->sc_tba += n;
}
mutex_spin_exit(&sc->sc_lock);
out:
splx(s);
return;
}
/* Enable transmit completion interrupts if necessary. */
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
SET(sc->sc_ier, IER_ETXRDY);
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
}
/* Output the first chunk of the contiguous buffer. */
if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) {
u_int n;
n = sc->sc_tbc;
if (n > sc->sc_fifolen)
n = sc->sc_fifolen;
CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n);
sc->sc_tbc -= n;
sc->sc_tba += n;
}
mutex_spin_exit(&sc->sc_lock);
out:
splx(s);
return;
}
/* Enable transmit completion interrupts if necessary. */
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
SET(sc->sc_ier, IER_ETXRDY);
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
}
/* Output the first chunk of the contiguous buffer. */
if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) {
u_int n;
n = sc->sc_tbc;
if (n > sc->sc_fifolen)
n = sc->sc_fifolen;
CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n);
sc->sc_tbc -= n;
sc->sc_tba += n;
}
mutex_spin_exit(&sc->sc_lock);
out:
splx(s);
return;
}
/* Enable transmit completion interrupts if necessary. */
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {
SET(sc->sc_ier, IER_ETXRDY);
CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier);
}
/* Output the first chunk of the contiguous buffer. */
if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) {
u_int n;
n = sc->sc_tbc;
if (n > sc->sc_fifolen)
n = sc->sc_fifolen;
CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n);
sc->sc_tbc -= n;
sc->sc_tba += n;
}
mutex_spin_exit(&sc->sc_lock);
out:
splx(s);
return;
}
clist to serial port (figure)clist to serial port (figure)clist to serial port (figure)clist to serial port (figure)clist to serial port (figure)
CSR_WRITE_*()CSR_WRITE_*()CSR_WRITE_*()CSR_WRITE_*()CSR_WRITE_*()
// arch/i386/compile/GENERIC/opt_com.h:
// /* option `COM_REGMAP' not defined */
#define CSR_WRITE_1(r, o, v) 
bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v)
#define CSR_WRITE_MULTI(r, o, p, n) 
bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n)
#define COM_REG_IER com_ier
#define COM_REG_TXDATA com_data
// arch/i386/compile/GENERIC/opt_com.h:
// /* option `COM_REGMAP' not defined */
#define CSR_WRITE_1(r, o, v) 
bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v)
#define CSR_WRITE_MULTI(r, o, p, n) 
bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n)
#define COM_REG_IER com_ier
#define COM_REG_TXDATA com_data
// arch/i386/compile/GENERIC/opt_com.h:
// /* option `COM_REGMAP' not defined */
#define CSR_WRITE_1(r, o, v) 
bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v)
#define CSR_WRITE_MULTI(r, o, p, n) 
bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n)
#define COM_REG_IER com_ier
#define COM_REG_TXDATA com_data
// arch/i386/compile/GENERIC/opt_com.h:
// /* option `COM_REGMAP' not defined */
#define CSR_WRITE_1(r, o, v) 
bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v)
#define CSR_WRITE_MULTI(r, o, p, n) 
bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n)
#define COM_REG_IER com_ier
#define COM_REG_TXDATA com_data
// arch/i386/compile/GENERIC/opt_com.h:
// /* option `COM_REGMAP' not defined */
#define CSR_WRITE_1(r, o, v) 
bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v)
#define CSR_WRITE_MULTI(r, o, p, n) 
bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n)
#define COM_REG_IER com_ier
#define COM_REG_TXDATA com_data
// com.c
// = include => dev/ic/comreg.h
// = include => dev/ic/ns16550reg.h
#define com_data 0 /* data register (R/W) */
#define com_ier 1 /* interrupt enable (W) */
// com.c
// = include => dev/ic/comreg.h
// = include => dev/ic/ns16550reg.h
#define com_data 0 /* data register (R/W) */
#define com_ier 1 /* interrupt enable (W) */
// com.c
// = include => dev/ic/comreg.h
// = include => dev/ic/ns16550reg.h
#define com_data 0 /* data register (R/W) */
#define com_ier 1 /* interrupt enable (W) */
// com.c
// = include => dev/ic/comreg.h
// = include => dev/ic/ns16550reg.h
#define com_data 0 /* data register (R/W) */
#define com_ier 1 /* interrupt enable (W) */
// com.c
// = include => dev/ic/comreg.h
// = include => dev/ic/ns16550reg.h
#define com_data 0 /* data register (R/W) */
#define com_ier 1 /* interrupt enable (W) */
The com_data address should be 0x3f8.The com_data address should be 0x3f8.The com_data address should be 0x3f8.The com_data address should be 0x3f8.The com_data address should be 0x3f8.
bus_space_map()bus_space_map()bus_space_map()bus_space_map()bus_space_map()
int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate,
int frequency, int type, tcflag_t cflag)
{
// --snip--
regs.cr_iot = iot;
regs.cr_iobase = iobase;
regs.cr_nports = COM_NPORTS;
return comcnattach1(&regs, rate, frequency, type, cflag);
// --snip--
int comcnattach1(struct com_regs *regsp, int rate, int frequency,
int type, tcflag_t cflag)
{
// --snip--
comcons_info.regs = *regsp;
res = cominit(&comcons_info.regs, rate, frequency, type,
cflag);
// --snip--
int cominit(struct com_regs *regsp, int rate, int frequency, int
type, tcflag_t cflag)
{
if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp-
>cr_nports, 0, &regsp->cr_ioh))
int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate,
int frequency, int type, tcflag_t cflag)
{
// --snip--
regs.cr_iot = iot;
regs.cr_iobase = iobase;
regs.cr_nports = COM_NPORTS;
return comcnattach1(&regs, rate, frequency, type, cflag);
// --snip--
int comcnattach1(struct com_regs *regsp, int rate, int frequency,
int type, tcflag_t cflag)
{
// --snip--
comcons_info.regs = *regsp;
res = cominit(&comcons_info.regs, rate, frequency, type,
cflag);
// --snip--
int cominit(struct com_regs *regsp, int rate, int frequency, int
type, tcflag_t cflag)
{
if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp-
>cr_nports, 0, &regsp->cr_ioh))
int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate,
int frequency, int type, tcflag_t cflag)
{
// --snip--
regs.cr_iot = iot;
regs.cr_iobase = iobase;
regs.cr_nports = COM_NPORTS;
return comcnattach1(&regs, rate, frequency, type, cflag);
// --snip--
int comcnattach1(struct com_regs *regsp, int rate, int frequency,
int type, tcflag_t cflag)
{
// --snip--
comcons_info.regs = *regsp;
res = cominit(&comcons_info.regs, rate, frequency, type,
cflag);
// --snip--
int cominit(struct com_regs *regsp, int rate, int frequency, int
type, tcflag_t cflag)
{
if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp-
>cr_nports, 0, &regsp->cr_ioh))
int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate,
int frequency, int type, tcflag_t cflag)
{
// --snip--
regs.cr_iot = iot;
regs.cr_iobase = iobase;
regs.cr_nports = COM_NPORTS;
return comcnattach1(&regs, rate, frequency, type, cflag);
// --snip--
int comcnattach1(struct com_regs *regsp, int rate, int frequency,
int type, tcflag_t cflag)
{
// --snip--
comcons_info.regs = *regsp;
res = cominit(&comcons_info.regs, rate, frequency, type,
cflag);
// --snip--
int cominit(struct com_regs *regsp, int rate, int frequency, int
type, tcflag_t cflag)
{
if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp-
>cr_nports, 0, &regsp->cr_ioh))
int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate,
int frequency, int type, tcflag_t cflag)
{
// --snip--
regs.cr_iot = iot;
regs.cr_iobase = iobase;
regs.cr_nports = COM_NPORTS;
return comcnattach1(&regs, rate, frequency, type, cflag);
// --snip--
int comcnattach1(struct com_regs *regsp, int rate, int frequency,
int type, tcflag_t cflag)
{
// --snip--
comcons_info.regs = *regsp;
res = cominit(&comcons_info.regs, rate, frequency, type,
cflag);
// --snip--
int cominit(struct com_regs *regsp, int rate, int frequency, int
type, tcflag_t cflag)
{
if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp-
>cr_nports, 0, &regsp->cr_ioh))
comcnattach() callercomcnattach() callercomcnattach() callercomcnattach() callercomcnattach() caller
void
consinit(void)
{
// --snip--
#if (NCOM > 0)
if (!strcmp(consinfo->devname, "com")) {
int addr = consinfo->addr;
int speed = consinfo->speed;
if (addr == 0)
addr = CONADDR; // <= 0x3f8
if (speed == 0)
speed = CONSPEED;
if (comcnattach(x86_bus_space_io, addr, speed,
COM_FREQ, COM_TYPE_NORMAL,
comcnmode))
panic("can't init serial console @%x",
consinfo->addr);
return;
}
#endif
void
consinit(void)
{
// --snip--
#if (NCOM > 0)
if (!strcmp(consinfo->devname, "com")) {
int addr = consinfo->addr;
int speed = consinfo->speed;
if (addr == 0)
addr = CONADDR; // <= 0x3f8
if (speed == 0)
speed = CONSPEED;
if (comcnattach(x86_bus_space_io, addr, speed,
COM_FREQ, COM_TYPE_NORMAL,
comcnmode))
panic("can't init serial console @%x",
consinfo->addr);
return;
}
#endif
void
consinit(void)
{
// --snip--
#if (NCOM > 0)
if (!strcmp(consinfo->devname, "com")) {
int addr = consinfo->addr;
int speed = consinfo->speed;
if (addr == 0)
addr = CONADDR; // <= 0x3f8
if (speed == 0)
speed = CONSPEED;
if (comcnattach(x86_bus_space_io, addr, speed,
COM_FREQ, COM_TYPE_NORMAL,
comcnmode))
panic("can't init serial console @%x",
consinfo->addr);
return;
}
#endif
void
consinit(void)
{
// --snip--
#if (NCOM > 0)
if (!strcmp(consinfo->devname, "com")) {
int addr = consinfo->addr;
int speed = consinfo->speed;
if (addr == 0)
addr = CONADDR; // <= 0x3f8
if (speed == 0)
speed = CONSPEED;
if (comcnattach(x86_bus_space_io, addr, speed,
COM_FREQ, COM_TYPE_NORMAL,
comcnmode))
panic("can't init serial console @%x",
consinfo->addr);
return;
}
#endif
void
consinit(void)
{
// --snip--
#if (NCOM > 0)
if (!strcmp(consinfo->devname, "com")) {
int addr = consinfo->addr;
int speed = consinfo->speed;
if (addr == 0)
addr = CONADDR; // <= 0x3f8
if (speed == 0)
speed = CONSPEED;
if (comcnattach(x86_bus_space_io, addr, speed,
COM_FREQ, COM_TYPE_NORMAL,
comcnmode))
panic("can't init serial console @%x",
consinfo->addr);
return;
}
#endif
bus_space_map() (figure)bus_space_map() (figure)bus_space_map() (figure)bus_space_map() (figure)bus_space_map() (figure)

More Related Content

What's hot

DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
Felipe Prado
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
akaptur
 
Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
Simonas Kareiva
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
Atsushi Tadokoro
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2
Kazuho Oku
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
hesher
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
Santosh Wadghule
 
Javascript: The Important Bits
Javascript: The Important BitsJavascript: The Important Bits
Javascript: The Important Bits
Zumba Fitness - Technology Team
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
inovex GmbH
 
Network security mannual (2)
Network security mannual (2)Network security mannual (2)
Network security mannual (2)
Vivek Kumar Sinha
 
ch8-pv1-the-virtual-filesystem
ch8-pv1-the-virtual-filesystemch8-pv1-the-virtual-filesystem
ch8-pv1-the-virtual-filesystem
yushiang fu
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
Sebastiano Armeli
 
Network security Lab manual
Network security Lab manual Network security Lab manual
Network security Lab manual
Vivek Kumar Sinha
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
Flavio Poletti
 
Exploring slides
Exploring slidesExploring slides
Exploring slides
akaptur
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl Presentation
Attila Balazs
 
Php radomize
Php radomizePhp radomize
Php radomize
do_aki
 
IT6712 lab manual
IT6712 lab manualIT6712 lab manual
IT6712 lab manual
Madhu Amarnath
 
Introduction to kotlin coroutines
Introduction to kotlin coroutinesIntroduction to kotlin coroutines
Introduction to kotlin coroutines
NAVER Engineering
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays
 

What's hot (20)

DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
Javascript: The Important Bits
Javascript: The Important BitsJavascript: The Important Bits
Javascript: The Important Bits
 
lldb – Debugger auf Abwegen
lldb – Debugger auf Abwegenlldb – Debugger auf Abwegen
lldb – Debugger auf Abwegen
 
Network security mannual (2)
Network security mannual (2)Network security mannual (2)
Network security mannual (2)
 
ch8-pv1-the-virtual-filesystem
ch8-pv1-the-virtual-filesystemch8-pv1-the-virtual-filesystem
ch8-pv1-the-virtual-filesystem
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
 
Network security Lab manual
Network security Lab manual Network security Lab manual
Network security Lab manual
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
Exploring slides
Exploring slidesExploring slides
Exploring slides
 
Barely Legal Xxx Perl Presentation
Barely Legal Xxx Perl PresentationBarely Legal Xxx Perl Presentation
Barely Legal Xxx Perl Presentation
 
Php radomize
Php radomizePhp radomize
Php radomize
 
IT6712 lab manual
IT6712 lab manualIT6712 lab manual
IT6712 lab manual
 
Introduction to kotlin coroutines
Introduction to kotlin coroutinesIntroduction to kotlin coroutines
Introduction to kotlin coroutines
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
 

Viewers also liked

Functional MCU programming #0: Development environment
Functional MCU programming #0: Development environmentFunctional MCU programming #0: Development environment
Functional MCU programming #0: Development environment
Kiwamu Okabe
 
Build OS X Apps on Travis CI
Build OS X Apps on Travis CIBuild OS X Apps on Travis CI
Build OS X Apps on Travis CI
Kiwamu Okabe
 
Play, Slick, play2-authの間で討死
Play, Slick, play2-authの間で討死Play, Slick, play2-authの間で討死
Play, Slick, play2-authの間で討死
Kiwamu Okabe
 
Functional MCU programming
Functional MCU programmingFunctional MCU programming
Functional MCU programming
Kiwamu Okabe
 
Safer IoT using functional language
Safer IoT using functional languageSafer IoT using functional language
Safer IoT using functional language
Kiwamu Okabe
 
Real-time OS system state captured by ATS language
Real-time OS system state captured by ATS languageReal-time OS system state captured by ATS language
Real-time OS system state captured by ATS language
Kiwamu Okabe
 

Viewers also liked (6)

Functional MCU programming #0: Development environment
Functional MCU programming #0: Development environmentFunctional MCU programming #0: Development environment
Functional MCU programming #0: Development environment
 
Build OS X Apps on Travis CI
Build OS X Apps on Travis CIBuild OS X Apps on Travis CI
Build OS X Apps on Travis CI
 
Play, Slick, play2-authの間で討死
Play, Slick, play2-authの間で討死Play, Slick, play2-authの間で討死
Play, Slick, play2-authの間で討死
 
Functional MCU programming
Functional MCU programmingFunctional MCU programming
Functional MCU programming
 
Safer IoT using functional language
Safer IoT using functional languageSafer IoT using functional language
Safer IoT using functional language
 
Real-time OS system state captured by ATS language
Real-time OS system state captured by ATS languageReal-time OS system state captured by ATS language
Real-time OS system state captured by ATS language
 

Similar to start_printf: dev/ic/com.c comstart()

Create an auto-extractible shell script linux
Create an auto-extractible shell script linuxCreate an auto-extractible shell script linux
Create an auto-extractible shell script linux
Thierry Gayet
 
Embedding perl
Embedding perlEmbedding perl
Embedding perl
Marian Marinov
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
Sherif Mousa
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
Emanuel Calvo
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
maheshkumar12354
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
Giovanni Bechis
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
Ahmed Mekkawy
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
Dinesh Manajipet
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers
Carlo Pescio
 
Gps c
Gps cGps c
为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?
勇浩 赖
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
PROIDEA
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
Stefan
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
CODE BLUE
 
Introduction to Kernel Programming
Introduction to Kernel ProgrammingIntroduction to Kernel Programming
Introduction to Kernel Programming
Ahmed Mekkawy
 
04 - I love my OS, he protects me (sometimes, in specific circumstances)
04 - I love my OS, he protects me (sometimes, in specific circumstances)04 - I love my OS, he protects me (sometimes, in specific circumstances)
04 - I love my OS, he protects me (sometimes, in specific circumstances)
Alexandre Moneger
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
JungMinSEO5
 
망고100 보드로 놀아보자 7
망고100 보드로 놀아보자 7망고100 보드로 놀아보자 7
망고100 보드로 놀아보자 7
종인 전
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++
Yandex
 

Similar to start_printf: dev/ic/com.c comstart() (20)

Create an auto-extractible shell script linux
Create an auto-extractible shell script linuxCreate an auto-extractible shell script linux
Create an auto-extractible shell script linux
 
Embedding perl
Embedding perlEmbedding perl
Embedding perl
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Im trying to run make qemu-nox In a putty terminal but it.pdf
Im trying to run  make qemu-nox  In a putty terminal but it.pdfIm trying to run  make qemu-nox  In a putty terminal but it.pdf
Im trying to run make qemu-nox In a putty terminal but it.pdf
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers
 
Gps c
Gps cGps c
Gps c
 
为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
 
Introduction to Kernel Programming
Introduction to Kernel ProgrammingIntroduction to Kernel Programming
Introduction to Kernel Programming
 
04 - I love my OS, he protects me (sometimes, in specific circumstances)
04 - I love my OS, he protects me (sometimes, in specific circumstances)04 - I love my OS, he protects me (sometimes, in specific circumstances)
04 - I love my OS, he protects me (sometimes, in specific circumstances)
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
망고100 보드로 놀아보자 7
망고100 보드로 놀아보자 7망고100 보드로 놀아보자 7
망고100 보드로 놀아보자 7
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++
 

Recently uploaded

Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
HarisZaheer8
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 

Recently uploaded (20)

Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
AWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptxAWS Cloud Cost Optimization Presentation.pptx
AWS Cloud Cost Optimization Presentation.pptx
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 

start_printf: dev/ic/com.c comstart()

  • 1. start_printf: dev/ic/com.c comstart() start_printf: dev/ic/com.c comstart() start_printf: dev/ic/com.c comstart() start_printf: dev/ic/com.c comstart() start_printf: dev/ic/com.c comstart() Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
  • 2. Where comstart called?Where comstart called?Where comstart called?Where comstart called?Where comstart called? Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?Who kick "tp->t_oproc"?Who kick "tp->t_oproc"? // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- fifodone: tp = tty_alloc(); tp->t_oproc = comstart; // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- fifodone: tp = tty_alloc(); tp->t_oproc = comstart; // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- fifodone: tp = tty_alloc(); tp->t_oproc = comstart; // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- fifodone: tp = tty_alloc(); tp->t_oproc = comstart; // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- fifodone: tp = tty_alloc(); tp->t_oproc = comstart;
  • 3. com0 attached at isa0com0 attached at isa0com0 attached at isa0com0 attached at isa0com0 attached at isa0 $ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0 com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports $ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa attach com at isa with com_isa file dev/isa/com_isa.c com_isa $ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0 com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports $ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa attach com at isa with com_isa file dev/isa/com_isa.c com_isa $ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0 com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports $ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa attach com at isa with com_isa file dev/isa/com_isa.c com_isa $ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0 com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports $ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa attach com at isa with com_isa file dev/isa/com_isa.c com_isa $ grep 3f8 sys/arch/i386/conf/GENERIC | grep com0 com0 at isa? port 0x3f8 irq 4 # Standard PC serial ports $ grep -B 1 dev/isa/com_isa.c sys/dev/isa/files.isa attach com at isa with com_isa file dev/isa/com_isa.c com_isa // File: sys/dev/isa/com_isa.c void com_isa_attach(device_t parent, device_t self, void *aux) { // -- snip -- com_attach_subr(sc); // File: sys/dev/isa/com_isa.c void com_isa_attach(device_t parent, device_t self, void *aux) { // -- snip -- com_attach_subr(sc); // File: sys/dev/isa/com_isa.c void com_isa_attach(device_t parent, device_t self, void *aux) { // -- snip -- com_attach_subr(sc); // File: sys/dev/isa/com_isa.c void com_isa_attach(device_t parent, device_t self, void *aux) { // -- snip -- com_attach_subr(sc); // File: sys/dev/isa/com_isa.c void com_isa_attach(device_t parent, device_t self, void *aux) { // -- snip -- com_attach_subr(sc);
  • 4. com softc has struct tty membercom softc has struct tty membercom softc has struct tty membercom softc has struct tty membercom softc has struct tty member // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- tp = tty_alloc(); tp->t_oproc = comstart; tp->t_param = comparam; tp->t_hwiflow = comhwiflow; sc->sc_tty = tp; // -- snip -- tty_attach(tp); // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- tp = tty_alloc(); tp->t_oproc = comstart; tp->t_param = comparam; tp->t_hwiflow = comhwiflow; sc->sc_tty = tp; // -- snip -- tty_attach(tp); // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- tp = tty_alloc(); tp->t_oproc = comstart; tp->t_param = comparam; tp->t_hwiflow = comhwiflow; sc->sc_tty = tp; // -- snip -- tty_attach(tp); // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- tp = tty_alloc(); tp->t_oproc = comstart; tp->t_param = comparam; tp->t_hwiflow = comhwiflow; sc->sc_tty = tp; // -- snip -- tty_attach(tp); // File: sys/dev/ic/com.c void com_attach_subr(struct com_softc *sc) { // -- snip -- tp = tty_alloc(); tp->t_oproc = comstart; tp->t_param = comparam; tp->t_hwiflow = comhwiflow; sc->sc_tty = tp; // -- snip -- tty_attach(tp); // File: sys/dev/ic/comvar.h struct com_softc { device_t sc_dev; void *sc_si; struct tty *sc_tty; // File: sys/dev/ic/comvar.h struct com_softc { device_t sc_dev; void *sc_si; struct tty *sc_tty; // File: sys/dev/ic/comvar.h struct com_softc { device_t sc_dev; void *sc_si; struct tty *sc_tty; // File: sys/dev/ic/comvar.h struct com_softc { device_t sc_dev; void *sc_si; struct tty *sc_tty; // File: sys/dev/ic/comvar.h struct com_softc { device_t sc_dev; void *sc_si; struct tty *sc_tty;
  • 5. Maybe call tree is...Maybe call tree is...Maybe call tree is...Maybe call tree is...Maybe call tree is... cdev_write => comwrite => ttwrite => ttstart => comstart cdev_write => comwrite => ttwrite => ttstart => comstart cdev_write => comwrite => ttwrite => ttstart => comstart cdev_write => comwrite => ttwrite => ttstart => comstart cdev_write => comwrite => ttwrite => ttstart => comstart
  • 6. comwrite()comwrite()comwrite()comwrite()comwrite() #define COM_ISALIVE(sc) ((sc)->enabled != 0 && device_is_active((sc)->sc_dev)) int comwrite(dev_t dev, struct uio *uio, int flag) { struct com_softc *sc = device_lookup_private(&com_cd, COMUNIT(dev)); struct tty *tp = sc->sc_tty; if (COM_ISALIVE(sc) == 0) return (EIO); return ((*tp->t_linesw->l_write)(tp, uio, flag)); } #define COM_ISALIVE(sc) ((sc)->enabled != 0 && device_is_active((sc)->sc_dev)) int comwrite(dev_t dev, struct uio *uio, int flag) { struct com_softc *sc = device_lookup_private(&com_cd, COMUNIT(dev)); struct tty *tp = sc->sc_tty; if (COM_ISALIVE(sc) == 0) return (EIO); return ((*tp->t_linesw->l_write)(tp, uio, flag)); } #define COM_ISALIVE(sc) ((sc)->enabled != 0 && device_is_active((sc)->sc_dev)) int comwrite(dev_t dev, struct uio *uio, int flag) { struct com_softc *sc = device_lookup_private(&com_cd, COMUNIT(dev)); struct tty *tp = sc->sc_tty; if (COM_ISALIVE(sc) == 0) return (EIO); return ((*tp->t_linesw->l_write)(tp, uio, flag)); } #define COM_ISALIVE(sc) ((sc)->enabled != 0 && device_is_active((sc)->sc_dev)) int comwrite(dev_t dev, struct uio *uio, int flag) { struct com_softc *sc = device_lookup_private(&com_cd, COMUNIT(dev)); struct tty *tp = sc->sc_tty; if (COM_ISALIVE(sc) == 0) return (EIO); return ((*tp->t_linesw->l_write)(tp, uio, flag)); } #define COM_ISALIVE(sc) ((sc)->enabled != 0 && device_is_active((sc)->sc_dev)) int comwrite(dev_t dev, struct uio *uio, int flag) { struct com_softc *sc = device_lookup_private(&com_cd, COMUNIT(dev)); struct tty *tp = sc->sc_tty; if (COM_ISALIVE(sc) == 0) return (EIO); return ((*tp->t_linesw->l_write)(tp, uio, flag)); }
  • 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 */ };
  • 12. struct clist (figure)struct clist (figure)struct clist (figure)struct clist (figure)struct clist (figure)
  • 13. comstart() #3comstart() #3comstart() #3comstart() #3comstart() #3 /* Enable transmit completion interrupts if necessary. */ if (!ISSET(sc->sc_ier, IER_ETXRDY)) { SET(sc->sc_ier, IER_ETXRDY); CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier); } /* Output the first chunk of the contiguous buffer. */ if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) { u_int n; n = sc->sc_tbc; if (n > sc->sc_fifolen) n = sc->sc_fifolen; CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n); sc->sc_tbc -= n; sc->sc_tba += n; } mutex_spin_exit(&sc->sc_lock); out: splx(s); return; } /* Enable transmit completion interrupts if necessary. */ if (!ISSET(sc->sc_ier, IER_ETXRDY)) { SET(sc->sc_ier, IER_ETXRDY); CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier); } /* Output the first chunk of the contiguous buffer. */ if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) { u_int n; n = sc->sc_tbc; if (n > sc->sc_fifolen) n = sc->sc_fifolen; CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n); sc->sc_tbc -= n; sc->sc_tba += n; } mutex_spin_exit(&sc->sc_lock); out: splx(s); return; } /* Enable transmit completion interrupts if necessary. */ if (!ISSET(sc->sc_ier, IER_ETXRDY)) { SET(sc->sc_ier, IER_ETXRDY); CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier); } /* Output the first chunk of the contiguous buffer. */ if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) { u_int n; n = sc->sc_tbc; if (n > sc->sc_fifolen) n = sc->sc_fifolen; CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n); sc->sc_tbc -= n; sc->sc_tba += n; } mutex_spin_exit(&sc->sc_lock); out: splx(s); return; } /* Enable transmit completion interrupts if necessary. */ if (!ISSET(sc->sc_ier, IER_ETXRDY)) { SET(sc->sc_ier, IER_ETXRDY); CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier); } /* Output the first chunk of the contiguous buffer. */ if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) { u_int n; n = sc->sc_tbc; if (n > sc->sc_fifolen) n = sc->sc_fifolen; CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n); sc->sc_tbc -= n; sc->sc_tba += n; } mutex_spin_exit(&sc->sc_lock); out: splx(s); return; } /* Enable transmit completion interrupts if necessary. */ if (!ISSET(sc->sc_ier, IER_ETXRDY)) { SET(sc->sc_ier, IER_ETXRDY); CSR_WRITE_1(regsp, COM_REG_IER, sc->sc_ier); } /* Output the first chunk of the contiguous buffer. */ if (!ISSET(sc->sc_hwflags, COM_HW_NO_TXPRELOAD)) { u_int n; n = sc->sc_tbc; if (n > sc->sc_fifolen) n = sc->sc_fifolen; CSR_WRITE_MULTI(regsp,COM_REG_TXDATA,sc->sc_tba,n); sc->sc_tbc -= n; sc->sc_tba += n; } mutex_spin_exit(&sc->sc_lock); out: splx(s); return; }
  • 14. clist to serial port (figure)clist to serial port (figure)clist to serial port (figure)clist to serial port (figure)clist to serial port (figure)
  • 15. CSR_WRITE_*()CSR_WRITE_*()CSR_WRITE_*()CSR_WRITE_*()CSR_WRITE_*() // arch/i386/compile/GENERIC/opt_com.h: // /* option `COM_REGMAP' not defined */ #define CSR_WRITE_1(r, o, v) bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v) #define CSR_WRITE_MULTI(r, o, p, n) bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n) #define COM_REG_IER com_ier #define COM_REG_TXDATA com_data // arch/i386/compile/GENERIC/opt_com.h: // /* option `COM_REGMAP' not defined */ #define CSR_WRITE_1(r, o, v) bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v) #define CSR_WRITE_MULTI(r, o, p, n) bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n) #define COM_REG_IER com_ier #define COM_REG_TXDATA com_data // arch/i386/compile/GENERIC/opt_com.h: // /* option `COM_REGMAP' not defined */ #define CSR_WRITE_1(r, o, v) bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v) #define CSR_WRITE_MULTI(r, o, p, n) bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n) #define COM_REG_IER com_ier #define COM_REG_TXDATA com_data // arch/i386/compile/GENERIC/opt_com.h: // /* option `COM_REGMAP' not defined */ #define CSR_WRITE_1(r, o, v) bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v) #define CSR_WRITE_MULTI(r, o, p, n) bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n) #define COM_REG_IER com_ier #define COM_REG_TXDATA com_data // arch/i386/compile/GENERIC/opt_com.h: // /* option `COM_REGMAP' not defined */ #define CSR_WRITE_1(r, o, v) bus_space_write_1((r)->cr_iot, (r)->cr_ioh, o, v) #define CSR_WRITE_MULTI(r, o, p, n) bus_space_write_multi_1((r)->cr_iot, (r)->cr_ioh, o, p, n) #define COM_REG_IER com_ier #define COM_REG_TXDATA com_data // com.c // = include => dev/ic/comreg.h // = include => dev/ic/ns16550reg.h #define com_data 0 /* data register (R/W) */ #define com_ier 1 /* interrupt enable (W) */ // com.c // = include => dev/ic/comreg.h // = include => dev/ic/ns16550reg.h #define com_data 0 /* data register (R/W) */ #define com_ier 1 /* interrupt enable (W) */ // com.c // = include => dev/ic/comreg.h // = include => dev/ic/ns16550reg.h #define com_data 0 /* data register (R/W) */ #define com_ier 1 /* interrupt enable (W) */ // com.c // = include => dev/ic/comreg.h // = include => dev/ic/ns16550reg.h #define com_data 0 /* data register (R/W) */ #define com_ier 1 /* interrupt enable (W) */ // com.c // = include => dev/ic/comreg.h // = include => dev/ic/ns16550reg.h #define com_data 0 /* data register (R/W) */ #define com_ier 1 /* interrupt enable (W) */ The com_data address should be 0x3f8.The com_data address should be 0x3f8.The com_data address should be 0x3f8.The com_data address should be 0x3f8.The com_data address should be 0x3f8.
  • 16. bus_space_map()bus_space_map()bus_space_map()bus_space_map()bus_space_map() int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- regs.cr_iot = iot; regs.cr_iobase = iobase; regs.cr_nports = COM_NPORTS; return comcnattach1(&regs, rate, frequency, type, cflag); // --snip-- int comcnattach1(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- comcons_info.regs = *regsp; res = cominit(&comcons_info.regs, rate, frequency, type, cflag); // --snip-- int cominit(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp- >cr_nports, 0, &regsp->cr_ioh)) int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- regs.cr_iot = iot; regs.cr_iobase = iobase; regs.cr_nports = COM_NPORTS; return comcnattach1(&regs, rate, frequency, type, cflag); // --snip-- int comcnattach1(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- comcons_info.regs = *regsp; res = cominit(&comcons_info.regs, rate, frequency, type, cflag); // --snip-- int cominit(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp- >cr_nports, 0, &regsp->cr_ioh)) int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- regs.cr_iot = iot; regs.cr_iobase = iobase; regs.cr_nports = COM_NPORTS; return comcnattach1(&regs, rate, frequency, type, cflag); // --snip-- int comcnattach1(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- comcons_info.regs = *regsp; res = cominit(&comcons_info.regs, rate, frequency, type, cflag); // --snip-- int cominit(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp- >cr_nports, 0, &regsp->cr_ioh)) int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- regs.cr_iot = iot; regs.cr_iobase = iobase; regs.cr_nports = COM_NPORTS; return comcnattach1(&regs, rate, frequency, type, cflag); // --snip-- int comcnattach1(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- comcons_info.regs = *regsp; res = cominit(&comcons_info.regs, rate, frequency, type, cflag); // --snip-- int cominit(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp- >cr_nports, 0, &regsp->cr_ioh)) int comcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- regs.cr_iot = iot; regs.cr_iobase = iobase; regs.cr_nports = COM_NPORTS; return comcnattach1(&regs, rate, frequency, type, cflag); // --snip-- int comcnattach1(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { // --snip-- comcons_info.regs = *regsp; res = cominit(&comcons_info.regs, rate, frequency, type, cflag); // --snip-- int cominit(struct com_regs *regsp, int rate, int frequency, int type, tcflag_t cflag) { if (bus_space_map(regsp->cr_iot, regsp->cr_iobase, regsp- >cr_nports, 0, &regsp->cr_ioh))
  • 17. comcnattach() callercomcnattach() callercomcnattach() callercomcnattach() callercomcnattach() caller void consinit(void) { // --snip-- #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; if (addr == 0) addr = CONADDR; // <= 0x3f8 if (speed == 0) speed = CONSPEED; if (comcnattach(x86_bus_space_io, addr, speed, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console @%x", consinfo->addr); return; } #endif void consinit(void) { // --snip-- #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; if (addr == 0) addr = CONADDR; // <= 0x3f8 if (speed == 0) speed = CONSPEED; if (comcnattach(x86_bus_space_io, addr, speed, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console @%x", consinfo->addr); return; } #endif void consinit(void) { // --snip-- #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; if (addr == 0) addr = CONADDR; // <= 0x3f8 if (speed == 0) speed = CONSPEED; if (comcnattach(x86_bus_space_io, addr, speed, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console @%x", consinfo->addr); return; } #endif void consinit(void) { // --snip-- #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; if (addr == 0) addr = CONADDR; // <= 0x3f8 if (speed == 0) speed = CONSPEED; if (comcnattach(x86_bus_space_io, addr, speed, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console @%x", consinfo->addr); return; } #endif void consinit(void) { // --snip-- #if (NCOM > 0) if (!strcmp(consinfo->devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; if (addr == 0) addr = CONADDR; // <= 0x3f8 if (speed == 0) speed = CONSPEED; if (comcnattach(x86_bus_space_io, addr, speed, COM_FREQ, COM_TYPE_NORMAL, comcnmode)) panic("can't init serial console @%x", consinfo->addr); return; } #endif
  • 18. bus_space_map() (figure)bus_space_map() (figure)bus_space_map() (figure)bus_space_map() (figure)bus_space_map() (figure)