FreeBSD kernel kern code
tty_inq.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/tty.h>
#include <sys/uio.h>
#include <vm/uma.h>
Include dependency graph for tty_inq.c:

Go to the source code of this file.

Data Structures

struct  ttyinq_block
 

Macros

#define TTYINQ_QUOTESIZE   (TTYINQ_DATASIZE / BMSIZE)
 
#define BMSIZE   32
 
#define GETBIT(tib, boff)    ((tib)->tib_quotes[(boff) / BMSIZE] & (1 << ((boff) % BMSIZE)))
 
#define SETBIT(tib, boff)    ((tib)->tib_quotes[(boff) / BMSIZE] |= (1 << ((boff) % BMSIZE)))
 
#define CLRBIT(tib, boff)    ((tib)->tib_quotes[(boff) / BMSIZE] &= ~(1 << ((boff) % BMSIZE)))
 
#define TTYINQ_INSERT_TAIL(ti, tib)
 
#define TTYINQ_REMOVE_HEAD(ti)
 
#define TTYINQ_RECYCLE(ti, tib)
 
#define CORRECT_BLOCK(t)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_INT (_kern, OID_AUTO, tty_inq_flush_secure, CTLFLAG_RW, &ttyinq_flush_secure, 0, "Zero buffers while flushing")
 
int ttyinq_setsize (struct ttyinq *ti, struct tty *tp, size_t size)
 
void ttyinq_free (struct ttyinq *ti)
 
int ttyinq_read_uio (struct ttyinq *ti, struct tty *tp, struct uio *uio, size_t rlen, size_t flen)
 
static __inline void ttyinq_set_quotes (struct ttyinq_block *tib, size_t offset, size_t length, int value)
 
size_t ttyinq_write (struct ttyinq *ti, const void *buf, size_t nbytes, int quote)
 
int ttyinq_write_nofrag (struct ttyinq *ti, const void *buf, size_t nbytes, int quote)
 
void ttyinq_canonicalize (struct ttyinq *ti)
 
size_t ttyinq_findchar (struct ttyinq *ti, const char *breakc, size_t maxlen, char *lastc)
 
void ttyinq_flush (struct ttyinq *ti)
 
int ttyinq_peekchar (struct ttyinq *ti, char *c, int *quote)
 
void ttyinq_unputchar (struct ttyinq *ti)
 
void ttyinq_reprintpos_set (struct ttyinq *ti)
 
void ttyinq_reprintpos_reset (struct ttyinq *ti)
 
static void ttyinq_line_iterate (struct ttyinq *ti, ttyinq_line_iterator_t *iterator, void *data, unsigned int offset, struct ttyinq_block *tib)
 
void ttyinq_line_iterate_from_linestart (struct ttyinq *ti, ttyinq_line_iterator_t *iterator, void *data)
 
void ttyinq_line_iterate_from_reprintpos (struct ttyinq *ti, ttyinq_line_iterator_t *iterator, void *data)
 
static void ttyinq_startup (void *dummy)
 
 SYSINIT (ttyinq, SI_SUB_DRIVERS, SI_ORDER_FIRST, ttyinq_startup, NULL)
 

Variables

static int ttyinq_flush_secure = 1
 
static uma_zone_t ttyinq_zone
 

Macro Definition Documentation

◆ BMSIZE

#define BMSIZE   32

Definition at line 71 of file tty_inq.c.

◆ CLRBIT

#define CLRBIT (   tib,
  boff 
)     ((tib)->tib_quotes[(boff) / BMSIZE] &= ~(1 << ((boff) % BMSIZE)))

Definition at line 76 of file tty_inq.c.

◆ CORRECT_BLOCK

#define CORRECT_BLOCK (   t)
Value:
do { \
if (t <= TTYINQ_DATASIZE) \
t = 0; \
else \
t -= TTYINQ_DATASIZE; \
} while (0)

◆ GETBIT

#define GETBIT (   tib,
  boff 
)     ((tib)->tib_quotes[(boff) / BMSIZE] & (1 << ((boff) % BMSIZE)))

Definition at line 72 of file tty_inq.c.

◆ SETBIT

#define SETBIT (   tib,
  boff 
)     ((tib)->tib_quotes[(boff) / BMSIZE] |= (1 << ((boff) % BMSIZE)))

Definition at line 74 of file tty_inq.c.

◆ TTYINQ_INSERT_TAIL

#define TTYINQ_INSERT_TAIL (   ti,
  tib 
)
Value:
do { \
if (ti->ti_end == 0) { \
tib->tib_prev = NULL; \
tib->tib_next = ti->ti_firstblock; \
ti->ti_firstblock = tib; \
} else { \
tib->tib_prev = ti->ti_lastblock; \
tib->tib_next = ti->ti_lastblock->tib_next; \
ti->ti_lastblock->tib_next = tib; \
} \
if (tib->tib_next != NULL) \
tib->tib_next->tib_prev = tib; \
ti->ti_nblocks++; \
} while (0)

Definition at line 88 of file tty_inq.c.

◆ TTYINQ_QUOTESIZE

#define TTYINQ_QUOTESIZE   (TTYINQ_DATASIZE / BMSIZE)

Definition at line 70 of file tty_inq.c.

◆ TTYINQ_RECYCLE

#define TTYINQ_RECYCLE (   ti,
  tib 
)
Value:
do { \
if (ti->ti_quota <= ti->ti_nblocks) \
uma_zfree(ttyinq_zone, tib); \
} while (0)
static uma_zone_t ttyinq_zone
Definition: tty_inq.c:86
#define TTYINQ_INSERT_TAIL(ti, tib)
Definition: tty_inq.c:88

Definition at line 110 of file tty_inq.c.

◆ TTYINQ_REMOVE_HEAD

#define TTYINQ_REMOVE_HEAD (   ti)
Value:
do { \
ti->ti_firstblock = ti->ti_firstblock->tib_next; \
if (ti->ti_firstblock != NULL) \
ti->ti_firstblock->tib_prev = NULL; \
ti->ti_nblocks--; \
} while (0)

Definition at line 103 of file tty_inq.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ SYSCTL_INT()

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
tty_inq_flush_secure  ,
CTLFLAG_RW  ,
ttyinq_flush_secure,
,
"Zero buffers while flushing"   
)

◆ SYSINIT()

SYSINIT ( ttyinq  ,
SI_SUB_DRIVERS  ,
SI_ORDER_FIRST  ,
ttyinq_startup  ,
NULL   
)

◆ ttyinq_canonicalize()

void ttyinq_canonicalize ( struct ttyinq *  ti)

Definition at line 344 of file tty_inq.c.

Referenced by tty_generic_ioctl(), ttydisc_rint(), and ttydisc_rint_bypass().

Here is the caller graph for this function:

◆ ttyinq_findchar()

size_t ttyinq_findchar ( struct ttyinq *  ti,
const char *  breakc,
size_t  maxlen,
char *  lastc 
)

Definition at line 352 of file tty_inq.c.

References GETBIT, and ttyinq_block::tib_data.

Referenced by ttydisc_read_canonical().

Here is the caller graph for this function:

◆ ttyinq_flush()

void ttyinq_flush ( struct ttyinq *  ti)

Definition at line 378 of file tty_inq.c.

References ttyinq_block::tib_data, ttyinq_block::tib_next, and ttyinq_flush_secure.

Referenced by tty_flush(), and ttyinq_free().

Here is the caller graph for this function:

◆ ttyinq_free()

void ttyinq_free ( struct ttyinq *  ti)

Definition at line 150 of file tty_inq.c.

References ttyinq_flush(), TTYINQ_REMOVE_HEAD, and ttyinq_zone.

Referenced by tty_dealloc(), and ttydev_leave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ttyinq_line_iterate()

static void ttyinq_line_iterate ( struct ttyinq *  ti,
ttyinq_line_iterator_t *  iterator,
void *  data,
unsigned int  offset,
struct ttyinq_block tib 
)
static

Definition at line 446 of file tty_inq.c.

References data, GETBIT, ttyinq_block::tib_data, and ttyinq_block::tib_next.

Referenced by ttyinq_line_iterate_from_linestart(), and ttyinq_line_iterate_from_reprintpos().

Here is the caller graph for this function:

◆ ttyinq_line_iterate_from_linestart()

void ttyinq_line_iterate_from_linestart ( struct ttyinq *  ti,
ttyinq_line_iterator_t *  iterator,
void *  data 
)

Definition at line 472 of file tty_inq.c.

References data, and ttyinq_line_iterate().

Referenced by ttydisc_reprint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ttyinq_line_iterate_from_reprintpos()

void ttyinq_line_iterate_from_reprintpos ( struct ttyinq *  ti,
ttyinq_line_iterator_t *  iterator,
void *  data 
)

Definition at line 481 of file tty_inq.c.

References data, and ttyinq_line_iterate().

Referenced by ttydisc_recalc_linelength().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ttyinq_peekchar()

int ttyinq_peekchar ( struct ttyinq *  ti,
char *  c,
int *  quote 
)

Definition at line 395 of file tty_inq.c.

References GETBIT, and ttyinq_block::tib_data.

Referenced by ttydisc_rubchar(), and ttydisc_rubword().

Here is the caller graph for this function:

◆ ttyinq_read_uio()

int ttyinq_read_uio ( struct ttyinq *  ti,
struct tty *  tp,
struct uio *  uio,
size_t  rlen,
size_t  flen 
)

Definition at line 166 of file tty_inq.c.

References CORRECT_BLOCK, ttyinq_block::tib_data, TTYINQ_RECYCLE, TTYINQ_REMOVE_HEAD, and uiomove().

Referenced by ttydisc_read_canonical(), ttydisc_read_raw_interbyte_timer(), ttydisc_read_raw_no_timer(), and ttydisc_read_raw_read_timer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ttyinq_reprintpos_reset()

void ttyinq_reprintpos_reset ( struct ttyinq *  ti)

Definition at line 438 of file tty_inq.c.

Referenced by ttydisc_reprint().

Here is the caller graph for this function:

◆ ttyinq_reprintpos_set()

void ttyinq_reprintpos_set ( struct ttyinq *  ti)

Definition at line 430 of file tty_inq.c.

Referenced by tty_putstrn(), ttydisc_write(), and ttydisc_write_oproc().

Here is the caller graph for this function:

◆ ttyinq_set_quotes()

static __inline void ttyinq_set_quotes ( struct ttyinq_block tib,
size_t  offset,
size_t  length,
int  value 
)
static

Definition at line 265 of file tty_inq.c.

References CLRBIT, SETBIT, and value.

Referenced by ttyinq_write().

Here is the caller graph for this function:

◆ ttyinq_setsize()

int ttyinq_setsize ( struct ttyinq *  ti,
struct tty *  tp,
size_t  size 
)

Definition at line 118 of file tty_inq.c.

References TTYINQ_INSERT_TAIL, and ttyinq_zone.

◆ ttyinq_startup()

static void ttyinq_startup ( void *  dummy)
static

Definition at line 490 of file tty_inq.c.

References ttyinq_zone.

◆ ttyinq_unputchar()

void ttyinq_unputchar ( struct ttyinq *  ti)

Definition at line 413 of file tty_inq.c.

Referenced by ttydisc_rubchar().

Here is the caller graph for this function:

◆ ttyinq_write()

size_t ttyinq_write ( struct ttyinq *  ti,
const void *  buf,
size_t  nbytes,
int  quote 
)

Definition at line 281 of file tty_inq.c.

References buf, nbytes, ttyinq_block::tib_data, ttyinq_block::tib_next, and ttyinq_set_quotes().

Referenced by ttydisc_rint_bypass(), and ttyinq_write_nofrag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ttyinq_write_nofrag()

int ttyinq_write_nofrag ( struct ttyinq *  ti,
const void *  buf,
size_t  nbytes,
int  quote 
)

Definition at line 329 of file tty_inq.c.

References buf, nbytes, and ttyinq_write().

Referenced by ttydisc_rint().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ttyinq_flush_secure

int ttyinq_flush_secure = 1
static

Definition at line 66 of file tty_inq.c.

Referenced by ttyinq_flush().

◆ ttyinq_zone

uma_zone_t ttyinq_zone
static

Definition at line 86 of file tty_inq.c.

Referenced by ttyinq_free(), ttyinq_setsize(), and ttyinq_startup().