static int wsdisplay_emul_match __P((struct device *, struct cfdata *, void *));
static int wsdisplay_emul_match __P((struct device *, void *, void *));
struct wsscreen *wsscreen_attach __P((struct wsdisplay_softc *, int,				      const char *,				      const struct wsscreen_descr *, void *,				      int, int, long));void wsscreen_detach __P((struct wsscreen *));static const struct wsscreen_descr *wsdisplay_screentype_pick __P((const struct wsscreen_list *, const char *));int wsdisplay_addscreen __P((struct wsdisplay_softc *, int, const char *, const char *));static void wsdisplay_shutdownhook __P((void *));static void wsdisplay_addscreen_print __P((struct wsdisplay_softc *, int, int));static void wsdisplay_closescreen __P((struct wsdisplay_softc *,				       struct wsscreen *));int wsdisplay_delscreen __P((struct wsdisplay_softc *, int, int));#define WSDISPLAY_MAXSCREEN 8struct wsdisplay_softc {	struct device sc_dv;	const struct wsdisplay_accessops *sc_accessops;	void	*sc_accesscookie;	const struct wsscreen_list *sc_scrdata;	struct wsscreen *sc_scr[WSDISPLAY_MAXSCREEN];	int sc_focusidx;	struct wsscreen *sc_focus;	int	sc_isconsole;	int sc_flags;#define SC_SWITCHPENDING 1	int sc_screenwanted, sc_oldscreen; /* valid with SC_SWITCHPENDING */#if NWSKBD > 0	struct wsmux_softc *sc_muxdv;#ifdef WSDISPLAY_COMPAT_RAWKBD	int sc_rawkbd;#endif#endif /* NWSKBD > 0 */};extern struct cfdriver wsdisplay_cd;/* Autoconfiguration definitions. */static int wsdisplay_emul_match __P((struct device *, struct cfdata *,	    void *));static void wsdisplay_emul_attach __P((struct device *, struct device *,	    void *));static int wsdisplay_noemul_match __P((struct device *, struct cfdata *,	    void *));static void wsdisplay_noemul_attach __P((struct device *, struct device *,	    void *));struct cfdriver wsdisplay_cd = {	NULL, "wsdisplay", DV_TTY};struct cfattach wsdisplay_emul_ca = {	sizeof (struct wsdisplay_softc),	(cfmatch_t)wsdisplay_emul_match,	wsdisplay_emul_attach,}; struct cfattach wsdisplay_noemul_ca = {	sizeof (struct wsdisplay_softc),	(cfmatch_t)wsdisplay_noemul_match,	wsdisplay_noemul_attach,}; /* Exported tty- and cdevsw-related functions. */cdev_decl(wsdisplay);static void wsdisplaystart __P((struct tty *));static int wsdisplayparam __P((struct tty *, struct termios *));/* Internal macros, functions, and variables. */#define	SET(t, f)	(t) |= (f)#define	CLR(t, f)	(t) &= ~(f)#define	ISSET(t, f)	((t) & (f))#define	WSDISPLAYUNIT(dev)	(minor(dev) >> 8)#define	WSDISPLAYSCREEN(dev)	(minor(dev) & 0xff)#define ISWSDISPLAYCTL(dev)	(WSDISPLAYSCREEN(dev) == 255)#define WSDISPLAYMINOR(unit, screen)	(((unit) << 8) | (screen))#define	WSSCREEN_HAS_EMULATOR(scr)	((scr)->scr_dconf->wsemul != NULL)#define	WSSCREEN_HAS_TTY(scr)	((scr)->scr_tty != NULL)static void wsdisplay_common_attach __P((struct wsdisplay_softc *sc,	    int console, const struct wsscreen_list *,	    const struct wsdisplay_accessops *accessops,	    void *accesscookie));#ifdef WSDISPLAY_COMPAT_RAWKBDint wsdisplay_update_rawkbd __P((struct wsdisplay_softc *,				 struct wsscreen *));#endifstatic int wsdisplay_console_initted;static struct wsdisplay_softc *wsdisplay_console_device;static struct wsscreen_internal wsdisplay_console_conf;static int wsdisplay_getc_dummy __P((dev_t));static void wsdisplay_pollc __P((dev_t, int));static int wsdisplay_cons_pollmode;static void (*wsdisplay_cons_kbd_pollc) __P((dev_t, int));static struct consdev wsdisplay_cons = {	NULL, NULL, wsdisplay_getc_dummy, wsdisplay_cnputc,	wsdisplay_pollc, NODEV, CN_NORMAL};#ifndef WSDISPLAY_DEFAULTSCREENS# define WSDISPLAY_DEFAULTSCREENS	0#endifint wsdisplay_defaultscreens = WSDISPLAY_DEFAULTSCREENS;int wsdisplay_switch1 __P((void *, int, int));int wsdisplay_switch2 __P((void *, int, int));int wsdisplay_switch3 __P((void *, int, int));int wsdisplay_clearonclose;struct wsscreen *wsscreen_attach(sc, console, emul, type, cookie, ccol, crow, defattr)	struct wsdisplay_softc *sc;	int console;	const char *emul;	const struct wsscreen_descr *type;	void *cookie;	int ccol, crow;	long defattr;{	struct wsscreen_internal *dconf;	struct wsscreen *scr;	scr = malloc(sizeof(struct wsscreen), M_DEVBUF, M_WAITOK);	if (!scr)		return (NULL);	if (console) {		dconf = &wsdisplay_console_conf;		/*		 * If there's an emulation, tell it about the callback argument.		 * The other stuff is already there.		 */		if (dconf->wsemul != NULL)			(*dconf->wsemul->attach)(1, 0, 0, 0, 0, scr, 0);	} else { /* not console */		dconf = malloc(sizeof(struct wsscreen_internal),			       M_DEVBUF, M_NOWAIT);		dconf->emulops = type->textops;		dconf->emulcookie = cookie;		if (dconf->emulops) {			dconf->wsemul = wsemul_pick(emul);			if (dconf->wsemul == NULL) {				free(dconf, M_DEVBUF);				free(scr, M_DEVBUF);				return (NULL);			}			dconf->wsemulcookie =			  (*dconf->wsemul->attach)(0, type, cookie,						   ccol, crow, scr, defattr);		} else			dconf->wsemul = NULL;		dconf->scrdata = type;	}	scr->scr_dconf = dconf;	scr->scr_tty = ttymalloc();	tty_attach(scr->scr_tty);	scr->scr_hold_screen = 0;	if (WSSCREEN_HAS_EMULATOR(scr))		scr->scr_flags = 0;	else		scr->scr_flags = SCR_GRAPHICS;	scr->scr_syncops = 0;	scr->sc = sc;#ifdef WSDISPLAY_COMPAT_RAWKBD	scr->scr_rawkbd = 0;#endif	return (scr);}