console.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
#include <stand.h>
#include <string.h>
#include "bootstrap.h"
/*
* Core console support
*/
static int cons_check(const char *string);
static int cons_change(const char *string);
/*
* Detect possible console(s) to use. If preferred console(s) have been
* specified, mark them as active. Else, mark the first probed console
* as active. Also create the console variable.
*/
void
cons_probe(void)
{
int cons;
int active;
char *prefconsole;
/* We want a callback to install the new value when this var changes. */
/* Do all console probes */
}
/* Now find the first working one */
active = -1;
}
/* Force a console even if all probes failed */
if (active == -1)
active = 0;
/* Check to see if a console preference has already been registered */
if (prefconsole != NULL)
if (prefconsole != NULL) {
} else {
}
printf("Consoles: ");
printf("\n");
if (prefconsole != NULL) {
}
}
void
{
int cons;
if (raw == 0)
else
}
}
int
getchar(void)
{
int cons;
int rv;
/* Loop forever polling all active consoles */
for(;;)
(C_PRESENTIN | C_ACTIVEIN) &&
return(rv);
}
int
ischar(void)
{
int cons;
(C_PRESENTIN | C_ACTIVEIN) &&
return(1);
return(0);
}
void
putchar(int c)
{
int cons;
/* Expand newlines if not in raw mode */
(C_PRESENTOUT | C_ACTIVEOUT)) {
}
}
/*
* Find the console with the specified name.
*/
static int
{
int cons;
return (cons);
return (-1);
}
/*
* Select one or more consoles.
*/
static int
{
int ret;
/*
* Return CMD_OK instead of CMD_ERROR to prevent forth syntax error,
* which would prevent it processing any further loader.conf entries.
*/
return (CMD_OK);
}
return (ret);
return (CMD_OK);
}
/*
* Check that at least one the consoles listed in *string is valid
*/
static int
cons_check(const char *string)
{
if (*curpos != '\0') {
if (cons == -1) {
failed++;
} else {
found++;
}
}
}
if (found == 0)
printf("no valid consoles!\n");
printf("Available consoles:\n");
}
return (found);
}
/*
* Activate all the valid consoles listed in *string and disable all others.
*/
static int
cons_change(const char *string)
{
/* Disable all consoles */
}
/* Enable selected consoles */
active = 0;
if (*curpos == '\0')
continue;
if (cons >= 0) {
(C_PRESENTIN | C_PRESENTOUT)) {
active++;
continue;
}
if (active != 0) {
/* If no consoles have initialised we wouldn't see this. */
}
}
}
if (active == 0) {
/* All requested consoles failed to initialise, try to recover. */
(C_PRESENTIN | C_PRESENTOUT)) ==
(C_PRESENTIN | C_PRESENTOUT))
active++;
}
if (active == 0)
return (CMD_ERROR); /* Recovery failed. */
}
return (CMD_OK);
}
/*
* Change the twiddle divisor.
*
* The user can set the twiddle_divisor variable to directly control how fast
* the progress twiddle spins, useful for folks with slow serial consoles. The
* code to monitor changes to the variable and propagate them to the twiddle
* routines has to live somewhere. Twiddling is console-related so it's here.
*/
static int
{
char * eptr;
return (CMD_ERROR);
}
return(CMD_OK);
}