comconsole.c revision 38465
138465Smsmith/*
238465Smsmith * Copyright (c) 1998 Michael Smith (msmith@freebsd.org)
338465Smsmith *
438465Smsmith * Redistribution and use in source and binary forms, with or without
538465Smsmith * modification, are permitted provided that the following conditions
638465Smsmith * are met:
738465Smsmith * 1. Redistributions of source code must retain the above copyright
838465Smsmith *    notice, this list of conditions and the following disclaimer.
938465Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1038465Smsmith *    notice, this list of conditions and the following disclaimer in the
1138465Smsmith *    documentation and/or other materials provided with the distribution.
1238465Smsmith *
1338465Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1438465Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1538465Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1638465Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1738465Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1838465Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1938465Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2038465Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2138465Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2238465Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2338465Smsmith * SUCH DAMAGE.
2438465Smsmith *
2538465Smsmith * 	From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp
2638465Smsmith *
2738465Smsmith *	$Id$
2838465Smsmith */
2938465Smsmith
3038465Smsmith#include <stand.h>
3138465Smsmith
3238465Smsmith#include "bootstrap.h"
3338465Smsmith
3438465Smsmith/* in comconsole.S */
3538465Smsmithextern void	cominit(int s);
3638465Smsmithextern void	computc(int c);
3738465Smsmithextern int	comgetc(void);
3838465Smsmithextern int	comiskey(void);
3938465Smsmith
4038465Smsmithstatic void	comc_probe(struct console *cp);
4138465Smsmithstatic int	comc_init(int arg);
4238465Smsmithstatic int	comc_in(void);
4338465Smsmith
4438465Smsmithstruct console comconsole = {
4538465Smsmith    "comconsole",
4638465Smsmith    "BIOS serial port",
4738465Smsmith    0,
4838465Smsmith    comc_probe,
4938465Smsmith    comc_init,
5038465Smsmith    computc,
5138465Smsmith    comc_in,
5238465Smsmith    comiskey
5338465Smsmith};
5438465Smsmith
5538465Smsmithstatic void
5638465Smsmithcomc_probe(struct console *cp)
5738465Smsmith{
5838465Smsmith    /* XXX check the BIOS equipment list? */
5938465Smsmith    cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT);
6038465Smsmith}
6138465Smsmith
6238465Smsmithstatic int
6338465Smsmithcomc_init(int arg)
6438465Smsmith{
6538465Smsmith    /* XXX arg is unit number, should we use variables instead? */
6638465Smsmith    cominit(arg);
6738465Smsmith    return(0);
6838465Smsmith}
6938465Smsmith
7038465Smsmithstatic int
7138465Smsmithcomc_in(void)
7238465Smsmith{
7338465Smsmith    if (comiskey()) {
7438465Smsmith	return(comgetc());
7538465Smsmith    } else {
7638465Smsmith	return(-1);
7738465Smsmith    }
7838465Smsmith}
79