FreeBSD kernel kern code
tty_ttydisc.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/filio.h>
#include <sys/kernel.h>
#include <sys/signal.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/ttycom.h>
#include <sys/ttydefaults.h>
#include <sys/uio.h>
#include <sys/vnode.h>
Include dependency graph for tty_ttydisc.c:

Go to the source code of this file.

Data Structures

struct  ttydisc_recalc_length
 

Macros

#define CMP_CC(v, c)
 
#define CMP_FLAG(field, opt)   (tp->t_termios.c_ ## field ## flag & (opt))
 
#define CTAB   '\t'
 
#define CNL   '\n'
 
#define CCR   '\r'
 
#define CTL_VALID(c)   ((c) == 0x7f || (unsigned char)(c) < 0x20)
 
#define CTL_ECHO(c, q)
 
#define CTL_PRINT(c, q)
 
#define CTL_WHITE(c)   ((c) == ' ' || (c) == CTAB)
 
#define CTL_ALNUM(c)
 
#define TTY_STACKBUF   256
 
#define BREAK_ADD(c)
 
#define PRINT_NORMAL()   ttyoutq_write_nofrag(&tp->t_outq, &c, 1)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 SYSCTL_ULONG (_kern, OID_AUTO, tty_nin, CTLFLAG_RD,&tty_nin, 0,"Total amount of bytes received")
 
 SYSCTL_ULONG (_kern, OID_AUTO, tty_nout, CTLFLAG_RD,&tty_nout, 0,"Total amount of bytes transmitted")
 
void ttydisc_open (struct tty *tp)
 
void ttydisc_close (struct tty *tp)
 
static int ttydisc_read_canonical (struct tty *tp, struct uio *uio, int ioflag)
 
static int ttydisc_read_raw_no_timer (struct tty *tp, struct uio *uio, int ioflag)
 
static int ttydisc_read_raw_read_timer (struct tty *tp, struct uio *uio, int ioflag, int oresid)
 
static int ttydisc_read_raw_interbyte_timer (struct tty *tp, struct uio *uio, int ioflag)
 
int ttydisc_read (struct tty *tp, struct uio *uio, int ioflag)
 
static __inline unsigned int ttydisc_findchar (const char *obstart, unsigned int oblen)
 
static int ttydisc_write_oproc (struct tty *tp, char c)
 
int ttydisc_write (struct tty *tp, struct uio *uio, int ioflag)
 
void ttydisc_optimize (struct tty *tp)
 
void ttydisc_modem (struct tty *tp, int open)
 
static int ttydisc_echo_force (struct tty *tp, char c, int quote)
 
static int ttydisc_echo (struct tty *tp, char c, int quote)
 
static void ttydisc_reprint_char (void *d, char c, int quote)
 
static void ttydisc_reprint (struct tty *tp)
 
static void ttydisc_recalc_charlength (void *d, char c, int quote)
 
static unsigned int ttydisc_recalc_linelength (struct tty *tp)
 
static int ttydisc_rubchar (struct tty *tp)
 
static void ttydisc_rubword (struct tty *tp)
 
int ttydisc_rint (struct tty *tp, char c, int flags)
 
size_t ttydisc_rint_simple (struct tty *tp, const void *buf, size_t len)
 
size_t ttydisc_rint_bypass (struct tty *tp, const void *buf, size_t len)
 
void ttydisc_rint_done (struct tty *tp)
 
size_t ttydisc_rint_poll (struct tty *tp)
 
static void ttydisc_wakeup_watermark (struct tty *tp)
 
size_t ttydisc_getc (struct tty *tp, void *buf, size_t len)
 
int ttydisc_getc_uio (struct tty *tp, struct uio *uio)
 
size_t ttydisc_getc_poll (struct tty *tp)
 
int tty_putchar (struct tty *tp, char c)
 

Variables

static unsigned long tty_nin = 0
 
static unsigned long tty_nout = 0
 

Macro Definition Documentation

#define BREAK_ADD (   c)
Value:
do { \
if (tp->t_termios.c_cc[c] != _POSIX_VDISABLE) \
breakc[n++] = tp->t_termios.c_cc[c]; \
} while (0)

Referenced by ttydisc_read_canonical().

#define CCR   '\r'

Definition at line 66 of file tty_ttydisc.c.

Referenced by ttydisc_rint(), and ttydisc_write_oproc().

#define CMP_CC (   v,
 
)
Value:
(tp->t_termios.c_cc[v] != _POSIX_VDISABLE && \
tp->t_termios.c_cc[v] == (c))

Definition at line 59 of file tty_ttydisc.c.

Referenced by ttydisc_echo_force(), ttydisc_read_canonical(), and ttydisc_rint().

#define CMP_FLAG (   field,
  opt 
)    (tp->t_termios.c_ ## field ## flag & (opt))
#define CNL   '\n'
#define CTAB   '\t'

Definition at line 64 of file tty_ttydisc.c.

Referenced by ttydisc_recalc_charlength(), ttydisc_rubchar(), and ttydisc_write_oproc().

#define CTL_ALNUM (   c)
Value:
(((c) >= '0' && (c) <= '9') || \
((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z'))

Definition at line 79 of file tty_ttydisc.c.

Referenced by ttydisc_rubword().

#define CTL_ECHO (   c,
 
)
Value:
(!(q) && ((c) == CERASE2 || (c) == CTAB || \
(c) == CNL || (c) == CCR))
#define CTAB
Definition: tty_ttydisc.c:64
#define CCR
Definition: tty_ttydisc.c:66
#define CNL
Definition: tty_ttydisc.c:65

Definition at line 71 of file tty_ttydisc.c.

Referenced by ttydisc_echo_force().

#define CTL_PRINT (   c,
 
)
Value:
((c) == 0x7f || ((unsigned char)(c) < 0x20 && \
((q) || ((c) != CTAB && (c) != CNL))))
#define CTAB
Definition: tty_ttydisc.c:64
#define CNL
Definition: tty_ttydisc.c:65

Definition at line 74 of file tty_ttydisc.c.

Referenced by ttydisc_echo_force(), ttydisc_recalc_charlength(), and ttydisc_rubchar().

#define CTL_VALID (   c)    ((c) == 0x7f || (unsigned char)(c) < 0x20)

Definition at line 69 of file tty_ttydisc.c.

Referenced by ttydisc_findchar(), and ttydisc_write_oproc().

#define CTL_WHITE (   c)    ((c) == ' ' || (c) == CTAB)

Definition at line 77 of file tty_ttydisc.c.

Referenced by ttydisc_rubword().

#define PRINT_NORMAL ( )    ttyoutq_write_nofrag(&tp->t_outq, &c, 1)

Referenced by ttydisc_write_oproc().

#define TTY_STACKBUF   256

Definition at line 82 of file tty_ttydisc.c.

Referenced by ttydisc_getc_uio(), and ttydisc_write().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
SYSCTL_ULONG ( _kern  ,
OID_AUTO  ,
tty_nin  ,
CTLFLAG_RD  ,
tty_nin,
,
"Total amount of bytes received"   
)
SYSCTL_ULONG ( _kern  ,
OID_AUTO  ,
tty_nout  ,
CTLFLAG_RD  ,
tty_nout,
,
"Total amount of bytes transmitted"   
)
int tty_putchar ( struct tty *  tp,
char  c 
)

Definition at line 1256 of file tty_ttydisc.c.

References ttydisc_echo_force(), and ttyinq_reprintpos_set().

Referenced by constty_timeout(), and putchar().

Here is the call graph for this function:

Here is the caller graph for this function:

void ttydisc_close ( struct tty *  tp)

Definition at line 91 of file tty_ttydisc.c.

References ttyinq_flush(), and ttyoutq_flush().

Referenced by ttydev_leave().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_echo ( struct tty *  tp,
char  c,
int  quote 
)
static

Definition at line 666 of file tty_ttydisc.c.

References CMP_FLAG, CNL, and ttydisc_echo_force().

Referenced by ttydisc_reprint(), ttydisc_reprint_char(), ttydisc_rint(), and ttydisc_rubchar().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_echo_force ( struct tty *  tp,
char  c,
int  quote 
)
static

Definition at line 630 of file tty_ttydisc.c.

References CMP_CC, CMP_FLAG, CTL_ECHO, CTL_PRINT, ttydisc_write_oproc(), and ttyoutq_write_nofrag().

Referenced by tty_putchar(), and ttydisc_echo().

Here is the call graph for this function:

Here is the caller graph for this function:

static __inline unsigned int ttydisc_findchar ( const char *  obstart,
unsigned int  oblen 
)
static

Definition at line 355 of file tty_ttydisc.c.

References CTL_VALID.

Referenced by ttydisc_write().

Here is the caller graph for this function:

size_t ttydisc_getc ( struct tty *  tp,
void *  buf,
size_t  len 
)

Definition at line 1167 of file tty_ttydisc.c.

References tty_nout, ttydisc_wakeup_watermark(), and ttyoutq_read().

Referenced by termtty_outwakeup(), and ttydisc_getc_uio().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t ttydisc_getc_poll ( struct tty *  tp)

Definition at line 1235 of file tty_ttydisc.c.

Referenced by pts_kqops_read_event(), ptsdev_ioctl(), ptsdev_poll(), and ptsdev_read().

Here is the caller graph for this function:

int ttydisc_getc_uio ( struct tty *  tp,
struct uio *  uio 
)

Definition at line 1190 of file tty_ttydisc.c.

References buf, tty_nout, TTY_STACKBUF, ttydisc_getc(), ttydisc_wakeup_watermark(), ttyoutq_read_uio(), and uiomove().

Referenced by ptsdev_read().

Here is the call graph for this function:

Here is the caller graph for this function:

void ttydisc_modem ( struct tty *  tp,
int  open 
)

Definition at line 595 of file tty_ttydisc.c.

References CMP_FLAG, tty_flush(), and tty_signal_sessleader().

Referenced by tty_rel_gone().

Here is the call graph for this function:

Here is the caller graph for this function:

void ttydisc_open ( struct tty *  tp)

Definition at line 85 of file tty_ttydisc.c.

References ttydisc_optimize().

Referenced by ttydev_open().

Here is the call graph for this function:

Here is the caller graph for this function:

void ttydisc_optimize ( struct tty *  tp)

Definition at line 575 of file tty_ttydisc.c.

References CMP_FLAG.

Referenced by tty_generic_ioctl(), ttydisc_open(), ttyhook_register(), and ttyhook_unregister().

Here is the caller graph for this function:

int ttydisc_read ( struct tty *  tp,
struct uio *  uio,
int  ioflag 
)

Definition at line 326 of file tty_ttydisc.c.

References CMP_FLAG, tty_hiwat_in_unblock(), ttydisc_read_canonical(), ttydisc_read_raw_interbyte_timer(), ttydisc_read_raw_no_timer(), and ttydisc_read_raw_read_timer().

Referenced by ttydev_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_read_canonical ( struct tty *  tp,
struct uio *  uio,
int  ioflag 
)
static

Definition at line 111 of file tty_ttydisc.c.

References BREAK_ADD, CMP_CC, CNL, tty_wait(), tty_wait_background(), ttyinq_findchar(), and ttyinq_read_uio().

Referenced by ttydisc_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_read_raw_interbyte_timer ( struct tty *  tp,
struct uio *  uio,
int  ioflag 
)
static

Definition at line 277 of file tty_ttydisc.c.

References tty_wait(), tty_wait_background(), ttydisc_read_raw_read_timer(), and ttyinq_read_uio().

Referenced by ttydisc_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_read_raw_no_timer ( struct tty *  tp,
struct uio *  uio,
int  ioflag 
)
static

Definition at line 184 of file tty_ttydisc.c.

References tty_wait(), tty_wait_background(), and ttyinq_read_uio().

Referenced by ttydisc_read().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_read_raw_read_timer ( struct tty *  tp,
struct uio *  uio,
int  ioflag,
int  oresid 
)
static

Definition at line 223 of file tty_ttydisc.c.

References getmicrotime(), hz, timevaladd(), timevalsub(), tty_timedwait(), tty_wait_background(), ttyinq_read_uio(), and tvtohz().

Referenced by ttydisc_read(), and ttydisc_read_raw_interbyte_timer().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ttydisc_recalc_charlength ( void *  d,
char  c,
int  quote 
)
static

Definition at line 710 of file tty_ttydisc.c.

References CMP_FLAG, CTAB, CTL_PRINT, ttydisc_recalc_length::curlen, and ttydisc_recalc_length::tp.

Referenced by ttydisc_recalc_linelength().

Here is the caller graph for this function:

static unsigned int ttydisc_recalc_linelength ( struct tty *  tp)
static

Definition at line 726 of file tty_ttydisc.c.

References ttydisc_recalc_length::curlen, ttydisc_recalc_length::tp, ttydisc_recalc_charlength(), and ttyinq_line_iterate_from_reprintpos().

Referenced by ttydisc_rubchar().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ttydisc_reprint ( struct tty *  tp)
static

Definition at line 690 of file tty_ttydisc.c.

References CNL, ttydisc_echo(), ttydisc_reprint_char(), ttyinq_line_iterate_from_linestart(), and ttyinq_reprintpos_reset().

Referenced by ttydisc_rint(), and ttydisc_rubchar().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ttydisc_reprint_char ( void *  d,
char  c,
int  quote 
)
static

Definition at line 682 of file tty_ttydisc.c.

References ttydisc_echo().

Referenced by ttydisc_reprint().

Here is the call graph for this function:

Here is the caller graph for this function:

int ttydisc_rint ( struct tty *  tp,
char  c,
int  flags 
)
size_t ttydisc_rint_bypass ( struct tty *  tp,
const void *  buf,
size_t  len 
)

Definition at line 1086 of file tty_ttydisc.c.

References tty_hiwat_in_block(), tty_nin, ttyinq_canonicalize(), and ttyinq_write().

Referenced by ttydisc_rint_simple().

Here is the call graph for this function:

Here is the caller graph for this function:

void ttydisc_rint_done ( struct tty *  tp)

Definition at line 1108 of file tty_ttydisc.c.

References tty_wakeup().

Referenced by ptsdev_write(), terminal_input_char(), terminal_input_raw(), terminal_input_special(), termteken_respond(), and tty_generic_ioctl().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t ttydisc_rint_poll ( struct tty *  tp)

Definition at line 1123 of file tty_ttydisc.c.

Referenced by pts_kqops_write_event(), and ptsdev_poll().

Here is the caller graph for this function:

size_t ttydisc_rint_simple ( struct tty *  tp,
const void *  buf,
size_t  len 
)

Definition at line 1070 of file tty_ttydisc.c.

References ttydisc_rint(), and ttydisc_rint_bypass().

Referenced by ptsdev_write(), terminal_input_char(), terminal_input_special(), and termteken_respond().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_rubchar ( struct tty *  tp)
static

Definition at line 736 of file tty_ttydisc.c.

References CMP_FLAG, CTAB, CTL_PRINT, ttydisc_echo(), ttydisc_recalc_linelength(), ttydisc_reprint(), ttyinq_peekchar(), ttyinq_unputchar(), and ttyoutq_write_nofrag().

Referenced by ttydisc_rint(), and ttydisc_rubword().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ttydisc_rubword ( struct tty *  tp)
static

Definition at line 809 of file tty_ttydisc.c.

References CMP_FLAG, CTL_ALNUM, CTL_WHITE, ttydisc_rubchar(), and ttyinq_peekchar().

Referenced by ttydisc_rint().

Here is the call graph for this function:

Here is the caller graph for this function:

static void ttydisc_wakeup_watermark ( struct tty *  tp)
static

Definition at line 1146 of file tty_ttydisc.c.

References tty_wakeup().

Referenced by ttydisc_getc(), and ttydisc_getc_uio().

Here is the call graph for this function:

Here is the caller graph for this function:

int ttydisc_write ( struct tty *  tp,
struct uio *  uio,
int  ioflag 
)

Definition at line 455 of file tty_ttydisc.c.

References CMP_FLAG, TTY_STACKBUF, tty_wait(), ttydisc_findchar(), ttydisc_write_oproc(), ttyinq_reprintpos_set(), ttyoutq_write(), and uiomove().

Referenced by ttydev_write().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ttydisc_write_oproc ( struct tty *  tp,
char  c 
)
static

Definition at line 369 of file tty_ttydisc.c.

References CCR, CMP_FLAG, CNL, CTAB, CTL_VALID, PRINT_NORMAL, ttyinq_reprintpos_set(), and ttyoutq_write_nofrag().

Referenced by ttydisc_echo_force(), and ttydisc_write().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

unsigned long tty_nin = 0
static

Definition at line 51 of file tty_ttydisc.c.

Referenced by ttydisc_rint(), and ttydisc_rint_bypass().

unsigned long tty_nout = 0
static

Definition at line 54 of file tty_ttydisc.c.

Referenced by ttydisc_getc(), and ttydisc_getc_uio().