FreeBSD kernel kern code
kern_cons.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_syscons.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/conf.h>
#include <sys/cons.h>
#include <sys/fcntl.h>
#include <sys/kbio.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/msgbuf.h>
#include <sys/namei.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/reboot.h>
#include <sys/sysctl.h>
#include <sys/sbuf.h>
#include <sys/tty.h>
#include <sys/uio.h>
#include <sys/vnode.h>
#include <ddb/ddb.h>
#include <dev/kbd/kbdreg.h>
#include <machine/cpu.h>
#include <machine/clock.h>
Include dependency graph for kern_cons.c:

Go to the source code of this file.

Data Structures

struct  cn_device
 

Macros

#define CNDEVPATHMAX   32
 
#define CNDEVTAB_SIZE   4
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_TTYCONS, "tty console", "tty console handling")
 
static STAILQ_HEAD (cn_device)
 
void cninit (void)
 
void cninit_finish ()
 
int cnadd (struct consdev *cn)
 
void cnremove (struct consdev *cn)
 
void cnselect (struct consdev *cn)
 
void cnavailable (struct consdev *cn, int available)
 
int cnunavailable (void)
 
static int sysctl_kern_console (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, OID_AUTO, console, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_NEEDGIANT, 0, 0, sysctl_kern_console, "A", "Console device control")
 
void cngrab ()
 
void cnungrab ()
 
void cnresume ()
 
int cngetc (void)
 
int cncheckc (void)
 
void cngets (char *cp, size_t size, int visible)
 
void cnputc (int c)
 
void cnputsn (const char *p, size_t n)
 
void cnputs (const char *p)
 
 SYSCTL_UINT (_kern, OID_AUTO, consmsgbuf_size, CTLFLAG_RWTUN, &consmsgbuf_size, 0, "Console tty buffer size")
 
int constty_set (struct tty *tp)
 
int constty_clear (struct tty *tp)
 
 SYSCTL_INT (_kern, OID_AUTO, constty_wakeups_per_second, CTLFLAG_RW, &constty_wakeups_per_second, 0, "Times per second to check for pending console tty messages")
 
static void constty_timeout (void *arg)
 
int sysbeep (int pitch __unused, sbintime_t duration __unused)
 
 SYSCTL_STRING (_kern, OID_AUTO, vty, CTLFLAG_RDTUN|CTLFLAG_NOFETCH, vty_name, 0, "Console vty driver")
 
int vty_enabled (unsigned vty)
 
void vty_set_preferred (unsigned vty)
 

Variables

static struct cn_device cn_devtab [CNDEVTAB_SIZE]
 
static unsigned int consmsgbuf_size = 65536
 
static int constty_wakeups_per_second = 15
 
static unsigned vty_prefer
 
static char vty_name [16]
 

Macro Definition Documentation

◆ CNDEVPATHMAX

#define CNDEVPATHMAX   32

Definition at line 85 of file kern_cons.c.

◆ CNDEVTAB_SIZE

#define CNDEVTAB_SIZE   4

Definition at line 86 of file kern_cons.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cnadd()

int cnadd ( struct consdev *  cn)

Definition at line 208 of file kern_cons.c.

References cn_devtab, cnavailable(), CNDEVTAB_SIZE, printf(), and ttyconsdev_select().

Referenced by cninit(), sysctl_kern_console(), and termcn_cnregister().

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

◆ cnavailable()

void cnavailable ( struct consdev *  cn,
int  available 
)

Definition at line 289 of file kern_cons.c.

References cn_devtab, and CNDEVTAB_SIZE.

Referenced by cnadd().

Here is the caller graph for this function:

◆ cncheckc()

int cncheckc ( void  )

Definition at line 432 of file kern_cons.c.

References kdb_active.

Referenced by cngetc(), dumpsys_cb_dumpdata(), and shutdown_panic().

Here is the caller graph for this function:

◆ cngetc()

int cngetc ( void  )

Definition at line 418 of file kern_cons.c.

References cncheckc().

Referenced by cngets(), cnputc(), shutdown_halt(), and shutdown_panic().

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

◆ cngets()

void cngets ( char *  cp,
size_t  size,
int  visible 
)

Definition at line 452 of file kern_cons.c.

References cngetc(), cngrab(), cnputc(), cnputs(), and cnungrab().

Referenced by parse_dir_ask().

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

◆ cngrab()

void cngrab ( )

Definition at line 376 of file kern_cons.c.

References kdb_active.

Referenced by cngets(), cnputc(), kdb_trap(), kern_reboot(), and vpanic().

Here is the caller graph for this function:

◆ cninit()

void cninit ( void  )

Definition at line 133 of file kern_cons.c.

References boothowto, cnadd(), cnremove(), and cnselect().

Here is the call graph for this function:

◆ cninit_finish()

void cninit_finish ( )

Definition at line 201 of file kern_cons.c.

◆ cnputc()

void cnputc ( int  c)

Definition at line 499 of file kern_cons.c.

References cngetc(), cngrab(), cnputc(), cnungrab(), and kdb_active.

Referenced by cngets(), cnputc(), cnputsn(), constty_clear(), prf_putchar(), and putchar().

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

◆ cnputs()

void cnputs ( const char *  p)

Definition at line 564 of file kern_cons.c.

References cnputsn().

Referenced by cngets(), and prf_putbuf().

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

◆ cnputsn()

void cnputsn ( const char *  p,
size_t  n 
)

Definition at line 539 of file kern_cons.c.

References cnputc().

Referenced by cnputs(), and sbuf_tty_drain().

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

◆ cnremove()

void cnremove ( struct consdev *  cn)

Definition at line 239 of file kern_cons.c.

References cn_devtab, CNDEVTAB_SIZE, and ttyconsdev_select().

Referenced by cninit(), and sysctl_kern_console().

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

◆ cnresume()

void cnresume ( )

Definition at line 402 of file kern_cons.c.

◆ cnselect()

void cnselect ( struct consdev *  cn)

Definition at line 272 of file kern_cons.c.

References ttyconsdev_select().

Referenced by cninit(), and sysctl_kern_console().

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

◆ cnunavailable()

int cnunavailable ( void  )

Definition at line 309 of file kern_cons.c.

◆ cnungrab()

void cnungrab ( )

Definition at line 389 of file kern_cons.c.

References kdb_active.

Referenced by cngets(), cnputc(), and kdb_trap().

Here is the caller graph for this function:

◆ constty_clear()

int constty_clear ( struct tty *  tp)

Definition at line 616 of file kern_cons.c.

References cnputc(), and msgbuf_getchar().

Referenced by constty_timeout(), tty_generic_ioctl(), and ttydev_leave().

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

◆ constty_set()

int constty_set ( struct tty *  tp)

Definition at line 577 of file kern_cons.c.

References buf, consmsgbuf_size, constty_timeout(), free(), malloc(), and msgbuf_init().

Referenced by tty_generic_ioctl().

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

◆ constty_timeout()

static void constty_timeout ( void *  arg)
static

Definition at line 640 of file kern_cons.c.

References constty_clear(), constty_timeout(), constty_wakeups_per_second, msgbuf_getchar(), and tty_putchar().

Referenced by constty_set(), and constty_timeout().

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

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_TTYCONS  ,
"tty console"  ,
"tty console handling"   
)
static

◆ STAILQ_HEAD()

static STAILQ_HEAD ( cn_device  )
static

Definition at line 88 of file kern_cons.c.

Referenced by ktls_work_thread().

Here is the caller graph for this function:

◆ sysbeep()

int sysbeep ( int pitch  __unused,
sbintime_t duration  __unused 
)

Definition at line 706 of file kern_cons.c.

◆ SYSCTL_INT()

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
constty_wakeups_per_second  ,
CTLFLAG_RW  ,
constty_wakeups_per_second,
,
"Times per second to check for pending console tty messages"   
)

◆ sysctl_kern_console()

static int sysctl_kern_console ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 319 of file kern_cons.c.

References cnadd(), CNDEVPATHMAX, cnremove(), cnselect(), sbuf_clear(), sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), sbuf_new(), sbuf_printf(), and sysctl_handle_string().

Here is the call graph for this function:

◆ SYSCTL_PROC()

SYSCTL_PROC ( _kern  ,
OID_AUTO  ,
console  ,
CTLTYPE_STRING|CTLFLAG_RW|  CTLFLAG_NEEDGIANT,
,
,
sysctl_kern_console  ,
"A"  ,
"Console device control"   
)

◆ SYSCTL_STRING()

SYSCTL_STRING ( _kern  ,
OID_AUTO  ,
vty  ,
CTLFLAG_RDTUN|  CTLFLAG_NOFETCH,
vty_name  ,
,
"Console vty driver"   
)

◆ SYSCTL_UINT()

SYSCTL_UINT ( _kern  ,
OID_AUTO  ,
consmsgbuf_size  ,
CTLFLAG_RWTUN  ,
consmsgbuf_size,
,
"Console tty buffer size"   
)

◆ vty_enabled()

int vty_enabled ( unsigned  vty)

Definition at line 723 of file kern_cons.c.

References vty_name, and vty_prefer.

◆ vty_set_preferred()

void vty_set_preferred ( unsigned  vty)

Definition at line 762 of file kern_cons.c.

References vty_prefer.

Variable Documentation

◆ cn_devtab

struct cn_device cn_devtab[CNDEVTAB_SIZE]
static

Definition at line 87 of file kern_cons.c.

Referenced by cnadd(), cnavailable(), and cnremove().

◆ consmsgbuf_size

unsigned int consmsgbuf_size = 65536
static

Definition at line 569 of file kern_cons.c.

Referenced by constty_set().

◆ constty_wakeups_per_second

int constty_wakeups_per_second = 15
static

Definition at line 634 of file kern_cons.c.

Referenced by constty_timeout().

◆ vty_name

char vty_name[16]
static

Definition at line 718 of file kern_cons.c.

Referenced by vty_enabled().

◆ vty_prefer

unsigned vty_prefer
static

Definition at line 717 of file kern_cons.c.

Referenced by vty_enabled(), and vty_set_preferred().