FreeBSD/sys/boot/common/console.c
/*
 * Activate all the valid consoles listed in *string and disable all others.
 */
Activate all the valid consoles listed in *string and disable all others.
Activate all the valid consoles listed in * string and disable all others .
static int
cons_change(const char *string)
{
    int		cons, active;
    char	*curpos, *dup, *next;
    for (cons = 0; consoles[cons] != NULL; cons++) {
	consoles[cons]->c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT);
    }
    dup = next = strdup(string);
    active = 0;
    while (next != NULL) {
	curpos = strsep(&next, " ,");
	if (*curpos == '\0')
		continue;
	cons = cons_find(curpos);
	if (cons >= 0) {
	    consoles[cons]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
	    consoles[cons]->c_init(0);
	    if ((consoles[cons]->c_flags & (C_PRESENTIN | C_PRESENTOUT)) ==
		(C_PRESENTIN | C_PRESENTOUT)) {
		active++;
		continue;
	    }
	    if (active != 0) {
		printf("console %s failed to initialize\n", consoles[cons]->c_name);
	    }
	}
    }
    free(dup);
    if (active == 0) {
	for (cons = 0; consoles[cons] != NULL; cons++) {
	    consoles[cons]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT;
	    consoles[cons]->c_init(0);
	    if ((consoles[cons]->c_flags &
		(C_PRESENTIN | C_PRESENTOUT)) ==
		(C_PRESENTIN | C_PRESENTOUT))
		active++;
	}
	if (active == 0)
	    return (CMD_ERROR); 
    }
    return (CMD_OK);
}
static int cons_change ( const char * string ) { int cons , active ; char * curpos , * dup , * next ; for ( cons = 0 ; consoles [ cons ] != NULL ; cons ++ ) { consoles [ cons ] -> c_flags &= ~ ( C_ACTIVEIN | C_ACTIVEOUT ) ; } dup = next = strdup ( string ) ; active = 0 ; while ( next != NULL ) { curpos = strsep ( & next , " " ) ; if ( * curpos == ' \0 ' ) continue ; cons = cons_find ( curpos ) ; if ( cons >= 0 ) { consoles [ cons ] -> c_flags |= C_ACTIVEIN | C_ACTIVEOUT ; consoles [ cons ] -> c_init ( 0 ) ; if ( ( consoles [ cons ] -> c_flags & ( C_PRESENTIN | C_PRESENTOUT ) ) == ( C_PRESENTIN | C_PRESENTOUT ) ) { active ++ ; continue ; } if ( active != 0 ) { printf ( " \n " , consoles [ cons ] -> c_name ) ; } } } free ( dup ) ; if ( active == 0 ) { for ( cons = 0 ; consoles [ cons ] != NULL ; cons ++ ) { consoles [ cons ] -> c_flags |= C_ACTIVEIN | C_ACTIVEOUT ; consoles [ cons ] -> c_init ( 0 ) ; if ( ( consoles [ cons ] -> c_flags & ( C_PRESENTIN | C_PRESENTOUT ) ) == ( C_PRESENTIN | C_PRESENTOUT ) ) active ++ ; } if ( active == 0 ) return ( CMD_ERROR ) ; } return ( CMD_OK ) ; }
Activate all the valid consoles listed in *string and disable all others.
Activate all the valid consoles listed in * string and disable all others .
/* Disable all consoles */ /* Enable selected consoles */ /* If no consoles have initialised we wouldn't see this. */ /* All requested consoles failed to initialise, try to recover. */ /* Recovery failed. */