1139825Simp/*- 24Srgrimes * Copyright (c) 1988 University of Utah. 34Srgrimes * Copyright (c) 1991 The Regents of the University of California. 44Srgrimes * All rights reserved. 54Srgrimes * 64Srgrimes * This code is derived from software contributed to Berkeley by 74Srgrimes * the Systems Programming Group of the University of Utah Computer 84Srgrimes * Science Department. 94Srgrimes * 104Srgrimes * Redistribution and use in source and binary forms, with or without 114Srgrimes * modification, are permitted provided that the following conditions 124Srgrimes * are met: 134Srgrimes * 1. Redistributions of source code must retain the above copyright 144Srgrimes * notice, this list of conditions and the following disclaimer. 154Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 164Srgrimes * notice, this list of conditions and the following disclaimer in the 174Srgrimes * documentation and/or other materials provided with the distribution. 184Srgrimes * 4. Neither the name of the University nor the names of its contributors 194Srgrimes * may be used to endorse or promote products derived from this software 204Srgrimes * without specific prior written permission. 214Srgrimes * 224Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 234Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 244Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 254Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 264Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 274Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 284Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 294Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 304Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 314Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 324Srgrimes * SUCH DAMAGE. 334Srgrimes * 34620Srgrimes * from: @(#)cons.h 7.2 (Berkeley) 5/9/91 3550477Speter * $FreeBSD$ 364Srgrimes */ 374Srgrimes 38718Swollman#ifndef _MACHINE_CONS_H_ 3924493Sbde#define _MACHINE_CONS_H_ 404Srgrimes 418023Sbdestruct consdev; 42179246Sedstruct tty; 43179246Sed 4492719Salfredtypedef void cn_probe_t(struct consdev *); 4592719Salfredtypedef void cn_init_t(struct consdev *); 4692719Salfredtypedef void cn_term_t(struct consdev *); 47228631Savgtypedef void cn_grab_t(struct consdev *); 48228631Savgtypedef void cn_ungrab_t(struct consdev *); 49111194Sphktypedef int cn_getc_t(struct consdev *); 50111194Sphktypedef void cn_putc_t(struct consdev *, int); 518023Sbde 52196506Sedstruct consdev_ops { 538023Sbde cn_probe_t *cn_probe; 548023Sbde /* probe hardware and fill in consdev info */ 558023Sbde cn_init_t *cn_init; 568023Sbde /* turn on as console */ 5748104Syokota cn_term_t *cn_term; 5848104Syokota /* turn off as console */ 598023Sbde cn_getc_t *cn_getc; 608023Sbde /* kernel getchar interface */ 618023Sbde cn_putc_t *cn_putc; 628023Sbde /* kernel putchar interface */ 63228631Savg cn_grab_t *cn_grab; 64228631Savg /* grab console for exclusive kernel use */ 65228631Savg cn_ungrab_t *cn_ungrab; 66228631Savg /* ungrab console */ 67196506Sed}; 68196506Sed 69196506Sedstruct consdev { 70196506Sed const struct consdev_ops *cn_ops; 71196506Sed /* console device operations. */ 724Srgrimes short cn_pri; /* pecking order; the higher the better */ 73111194Sphk void *cn_arg; /* drivers method argument */ 74121182Srwatson int cn_flags; /* capabilities of this console */ 75120455Sphk char cn_name[SPECNAMELEN + 1]; /* console (device) name */ 764Srgrimes}; 774Srgrimes 784Srgrimes/* values for cn_pri - reflect our policy for console selection */ 794Srgrimes#define CN_DEAD 0 /* device doesn't exist */ 80120541Sjake#define CN_LOW 1 /* device is a last restort only */ 81120541Sjake#define CN_NORMAL 2 /* device exists but is nothing special */ 82120541Sjake#define CN_INTERNAL 3 /* "internal" bit-mapped display */ 83120541Sjake#define CN_REMOTE 4 /* serial interface with remote bit set */ 844Srgrimes 85121182Srwatson/* Values for cn_flags. */ 86121182Srwatson#define CN_FLAG_NODEBUG 0x00000001 /* Not supported with debugger. */ 87125467Skan#define CN_FLAG_NOAVAIL 0x00000002 /* Temporarily not available. */ 88121182Srwatson 89228638Savg/* Visibility of characters in cngets() */ 90228638Savg#define GETS_NOECHO 0 /* Disable echoing of characters. */ 91228638Savg#define GETS_ECHO 1 /* Enable echoing of characters. */ 92228638Savg#define GETS_ECHOPASS 2 /* Print a * for every character. */ 93228638Savg 9455205Speter#ifdef _KERNEL 95718Swollman 96179246Sedextern struct msgbuf consmsgbuf; /* Message buffer for constty. */ 97179246Sedextern struct tty *constty; /* Temporary virtual console. */ 98179246Sed 99196506Sed#define CONSOLE_DEVICE(name, ops, arg) \ 100196506Sed static struct consdev name = { \ 101196506Sed .cn_ops = &ops, \ 102196506Sed .cn_arg = (arg), \ 10348104Syokota }; \ 104196506Sed DATA_SET(cons_set, name) 10542373Syokota 106196506Sed#define CONSOLE_DRIVER(name) \ 107196506Sed static const struct consdev_ops name##_consdev_ops = { \ 108158945Sphk .cn_probe = name##_cnprobe, \ 109158945Sphk .cn_init = name##_cninit, \ 110158945Sphk .cn_term = name##_cnterm, \ 111158945Sphk .cn_getc = name##_cngetc, \ 112158945Sphk .cn_putc = name##_cnputc, \ 113228631Savg .cn_grab = name##_cngrab, \ 114228631Savg .cn_ungrab = name##_cnungrab, \ 115158945Sphk }; \ 116196506Sed CONSOLE_DEVICE(name##_consdev, name##_consdev_ops, NULL) 117158945Sphk 11824493Sbde/* Other kernel entry points. */ 11985373Sjlemonvoid cninit(void); 12087620Sguidovoid cninit_finish(void); 12185373Sjlemonint cnadd(struct consdev *); 122125467Skanvoid cnavailable(struct consdev *, int); 12385373Sjlemonvoid cnremove(struct consdev *); 12485373Sjlemonvoid cnselect(struct consdev *); 125228631Savgvoid cngrab(void); 126228631Savgvoid cnungrab(void); 12785373Sjlemonint cncheckc(void); 12885373Sjlemonint cngetc(void); 129228633Savgvoid cngets(char *, size_t, int); 13085373Sjlemonvoid cnputc(int); 131163858Sjbvoid cnputs(char *); 132125487Skanint cnunavailable(void); 133179246Sedvoid constty_set(struct tty *tp); 134179246Sedvoid constty_clear(void); 135718Swollman 136268366Sray/* sc(4) / vt(4) coexistence shim */ 137268366Sray#define VTY_SC 0x01 138268366Sray#define VTY_VT 0x02 139268366Srayint vty_enabled(unsigned int); 140270988Semastevoid vty_set_preferred(unsigned int); 141268366Sray 14255205Speter#endif /* _KERNEL */ 143804Swollman 14424493Sbde#endif /* !_MACHINE_CONS_H_ */ 145