o Rename methods according to "consdev style".
o Add cngrab/cnungrab methods. o Allow later console attach with termcn_cnregister(). Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
36deab7b3b
commit
5f5f17c829
@ -140,7 +140,6 @@ terminal_init(struct terminal *tm)
|
||||
mtx_init(&tm->tm_mtx, "trmlck", NULL, MTX_SPIN);
|
||||
teken_init(&tm->tm_emulator, &terminal_drawmethods, tm);
|
||||
teken_set_defattr(&tm->tm_emulator, &default_message);
|
||||
|
||||
}
|
||||
|
||||
struct terminal *
|
||||
@ -403,42 +402,90 @@ termtty_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
|
||||
* Binding with the kernel and debug console.
|
||||
*/
|
||||
|
||||
static cn_probe_t termcn_probe;
|
||||
static cn_init_t termcn_init;
|
||||
static cn_term_t termcn_term;
|
||||
static cn_getc_t termcn_getc;
|
||||
static cn_putc_t termcn_putc;
|
||||
static cn_probe_t termcn_cnprobe;
|
||||
static cn_init_t termcn_cninit;
|
||||
static cn_term_t termcn_cnterm;
|
||||
static cn_getc_t termcn_cngetc;
|
||||
static cn_putc_t termcn_cnputc;
|
||||
static cn_grab_t termcn_cngrab;
|
||||
static cn_ungrab_t termcn_cnungrab;
|
||||
|
||||
const struct consdev_ops termcn_ops = {
|
||||
.cn_probe = termcn_probe,
|
||||
.cn_init = termcn_init,
|
||||
.cn_term = termcn_term,
|
||||
.cn_getc = termcn_getc,
|
||||
.cn_putc = termcn_putc,
|
||||
const struct consdev_ops termcn_cnops = {
|
||||
.cn_probe = termcn_cnprobe,
|
||||
.cn_init = termcn_cninit,
|
||||
.cn_term = termcn_cnterm,
|
||||
.cn_getc = termcn_cngetc,
|
||||
.cn_putc = termcn_cnputc,
|
||||
.cn_grab = termcn_cngrab,
|
||||
.cn_ungrab = termcn_cnungrab,
|
||||
};
|
||||
|
||||
void
|
||||
termcn_cnregister(struct terminal *tm)
|
||||
{
|
||||
struct consdev *cp;
|
||||
|
||||
cp = tm->consdev;
|
||||
if (cp == NULL) {
|
||||
cp = malloc(sizeof(struct consdev), M_TERMINAL,
|
||||
M_WAITOK|M_ZERO);
|
||||
cp->cn_ops = &termcn_cnops;
|
||||
cp->cn_arg = tm;
|
||||
cp->cn_pri = CN_INTERNAL;
|
||||
sprintf(cp->cn_name, "ttyv0");
|
||||
|
||||
tm->tm_flags = TF_CONS;
|
||||
tm->consdev = cp;
|
||||
|
||||
terminal_init(tm);
|
||||
}
|
||||
|
||||
/* Attach terminal as console. */
|
||||
cnadd(cp);
|
||||
}
|
||||
|
||||
static void
|
||||
termcn_probe(struct consdev *cp)
|
||||
termcn_cngrab(struct consdev *cp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
termcn_cnungrab(struct consdev *cp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
termcn_cnprobe(struct consdev *cp)
|
||||
{
|
||||
struct terminal *tm = cp->cn_arg;
|
||||
|
||||
if (tm == NULL) {
|
||||
cp->cn_pri = CN_DEAD;
|
||||
return;
|
||||
}
|
||||
|
||||
tm->consdev = cp;
|
||||
terminal_init(tm);
|
||||
|
||||
tm->tm_class->tc_cnprobe(tm, cp);
|
||||
}
|
||||
|
||||
static void
|
||||
termcn_init(struct consdev *cp)
|
||||
termcn_cninit(struct consdev *cp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
termcn_term(struct consdev *cp)
|
||||
termcn_cnterm(struct consdev *cp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
termcn_getc(struct consdev *cp)
|
||||
termcn_cngetc(struct consdev *cp)
|
||||
{
|
||||
struct terminal *tm = cp->cn_arg;
|
||||
|
||||
@ -446,7 +493,7 @@ termcn_getc(struct consdev *cp)
|
||||
}
|
||||
|
||||
static void
|
||||
termcn_putc(struct consdev *cp, int c)
|
||||
termcn_cnputc(struct consdev *cp, int c)
|
||||
{
|
||||
struct terminal *tm = cp->cn_arg;
|
||||
teken_attr_t backup;
|
||||
|
@ -128,6 +128,7 @@ struct terminal {
|
||||
#define TF_MUTE 0x1 /* Drop incoming data. */
|
||||
#define TF_BELL 0x2 /* Bell needs to be sent. */
|
||||
#define TF_CONS 0x4 /* Console device (needs spinlock). */
|
||||
struct consdev *consdev;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
@ -140,8 +141,10 @@ void terminal_input_char(struct terminal *tm, term_char_t c);
|
||||
void terminal_input_raw(struct terminal *tm, char c);
|
||||
void terminal_input_special(struct terminal *tm, unsigned int k);
|
||||
|
||||
void termcn_cnregister(struct terminal *tm);
|
||||
|
||||
/* Kernel console helper interface. */
|
||||
extern const struct consdev_ops termcn_ops;
|
||||
extern const struct consdev_ops termcn_cnops;
|
||||
|
||||
#define TERMINAL_DECLARE_EARLY(name, class, softc) \
|
||||
static struct terminal name = { \
|
||||
@ -149,7 +152,7 @@ extern const struct consdev_ops termcn_ops;
|
||||
.tm_softc = softc, \
|
||||
.tm_flags = TF_CONS, \
|
||||
}; \
|
||||
CONSOLE_DEVICE(name ## _consdev, termcn_ops, &name)
|
||||
CONSOLE_DEVICE(name ## _consdev, termcn_cnops, &name)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user