FreeBSD/sys/boot/common/console.c
/*
 * 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.
 */
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.
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;
    env_setenv("twiddle_divisor", EV_VOLATILE, "1", twiddle_set, env_nounset);
    for (cons = 0; consoles[cons] != NULL; cons++) {
	consoles[cons]->c_flags = 0;
 	consoles[cons]->c_probe(consoles[cons]);
    }
    active = -1;
    for (cons = 0; consoles[cons] != NULL && active == -1; cons++) {
	consoles[cons]->c_flags = 0;
 	consoles[cons]->c_probe(consoles[cons]);
	if (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT))
	    active = cons;
    }
    if (active == -1)
	active = 0;
    prefconsole = getenv("console");
    if (prefconsole != NULL)
	prefconsole = strdup(prefconsole);
    if (prefconsole != NULL) {
	unsetenv("console");		
	cons_change(prefconsole);
    } else {
	consoles[active]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
	consoles[active]->c_init(0);
	prefconsole = strdup(consoles[active]->c_name);
    }
    printf("Consoles: ");
    for (cons = 0; consoles[cons] != NULL; cons++)
	if (consoles[cons]->c_flags & (C_ACTIVEIN | C_ACTIVEOUT))
	    printf("%s  ", consoles[cons]->c_desc);
    printf("\n");
    if (prefconsole != NULL) {
	env_setenv("console", EV_VOLATILE, prefconsole, cons_set,
	    env_nounset);
	free(prefconsole);
    }
}
void cons_probe ( void ) { int cons ; int active ; char * prefconsole ; env_setenv ( " " , EV_VOLATILE , " " , twiddle_set , env_nounset ) ; for ( cons = 0 ; consoles [ cons ] != NULL ; cons ++ ) { consoles [ cons ] -> c_flags = 0 ; consoles [ cons ] -> c_probe ( consoles [ cons ] ) ; } active = -1 ; for ( cons = 0 ; consoles [ cons ] != NULL && active == -1 ; cons ++ ) { consoles [ cons ] -> c_flags = 0 ; consoles [ cons ] -> c_probe ( consoles [ cons ] ) ; if ( consoles [ cons ] -> c_flags == ( C_PRESENTIN | C_PRESENTOUT ) ) active = cons ; } if ( active == -1 ) active = 0 ; prefconsole = getenv ( " " ) ; if ( prefconsole != NULL ) prefconsole = strdup ( prefconsole ) ; if ( prefconsole != NULL ) { unsetenv ( " " ) ; cons_change ( prefconsole ) ; } else { consoles [ active ] -> c_flags |= C_ACTIVEIN | C_ACTIVEOUT ; consoles [ active ] -> c_init ( 0 ) ; prefconsole = strdup ( consoles [ active ] -> c_name ) ; } printf ( " " ) ; for ( cons = 0 ; consoles [ cons ] != NULL ; cons ++ ) if ( consoles [ cons ] -> c_flags & ( C_ACTIVEIN | C_ACTIVEOUT ) ) printf ( " " , consoles [ cons ] -> c_desc ) ; printf ( " \n " ) ; if ( prefconsole != NULL ) { env_setenv ( " " , EV_VOLATILE , prefconsole , cons_set , env_nounset ) ; free ( prefconsole ) ; } }
Detect possible console(s) to use.
Detect possible console ( s ) to use .
/* We want a callback to install the new value when this var changes. */ /* Do all console probes */ /* Now find the first working one */ /* Force a console even if all probes failed */ /* Check to see if a console preference has already been registered */ /* we want to replace this */