Index: sys/kern/kern_cons.c =================================================================== --- sys/kern/kern_cons.c (revision 290726) +++ sys/kern/kern_cons.c (working copy) @@ -105,11 +105,15 @@ DATA_SET(cons_set, cons_consdev); SET_DECLARE(cons_set, struct consdev); +static char preferred_console[16]; + void cninit(void) { - struct consdev *best_cn, *cn, **list; + struct consdev *best_cn, *prefered_cn, *cn, **list; + TUNABLE_STR_FETCH("console.prefer", preferred_console, sizeof(preferred_console)); + /* * Check if we should mute the console (for security reasons perhaps) * It can be changes dynamically using sysctl kern.consmute @@ -125,6 +129,7 @@ * Find the first console with the highest priority. */ best_cn = NULL; + prefered_cn = NULL; SET_FOREACH(list, cons_set) { cn = *list; cnremove(cn); @@ -134,6 +139,8 @@ cn->cn_ops->cn_probe(cn); if (cn->cn_pri == CN_DEAD) continue; + if (strcmp(preferred_console, cn->cn_name) == 0) + prefered_cn = cn; if (best_cn == NULL || cn->cn_pri > best_cn->cn_pri) best_cn = cn; if (boothowto & RB_MULTIPLE) { @@ -144,6 +151,9 @@ cnadd(cn); } } + if (prefered_cn) + best_cn = prefered_cn; + if (best_cn == NULL) return; if ((boothowto & RB_MULTIPLE) == 0) { @@ -157,6 +167,8 @@ */ cnselect(best_cn); + printf("PREFER %s\n", preferred_console); + #ifdef EARLY_PRINTF /* * Release early console. @@ -178,6 +190,7 @@ struct cn_device *cnd; int i; + STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) if (cnd->cnd_cn == cn) return (0); @@ -194,7 +207,8 @@ printf("WARNING: console at %p has no name\n", cn); } STAILQ_INSERT_TAIL(&cn_devlist, cnd, cnd_next); - if (STAILQ_FIRST(&cn_devlist) == cnd) + if ((STAILQ_FIRST(&cn_devlist) == cnd) || + (strcmp(preferred_console, cn->cn_name) == 0)) ttyconsdev_select(cnd->cnd_cn->cn_name); /* Add device to the active mask. */