Index: common/console.c =================================================================== RCS file: /src/CVS/src/sys/boot/common/console.c,v retrieving revision 1.4 diff -u -r1.4 console.c --- console.c 1998/10/31 02:53:09 1.4 +++ console.c 1999/07/14 08:35:24 @@ -36,6 +36,7 @@ static int cons_set(struct env_var *ev, int flags, void *value); static int cons_find(char *name); +static void cons_list(void); /* * Detect possible console(s) to use. The first probed console @@ -58,17 +59,14 @@ /* Now find the first working one */ 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; } /* Check to see if a console preference has already been registered */ prefconsole = getenv("console"); - if (prefconsole != NULL) - prefconsole = strdup(prefconsole); if (prefconsole != NULL) { + prefconsole = strdup(prefconsole); unsetenv("console"); /* we want to replace this */ for (cons = 0; consoles[cons] != NULL; cons++) /* look for the nominated console, use it if it's functional */ @@ -138,7 +136,16 @@ return(-1); } +static void +cons_list(void) +{ + int cons; + printf("Available consoles:\n"); + for (cons = 0; consoles[cons] != NULL; cons++) + printf(" %s\n", consoles[cons]->c_name); +} + /* * Select a console. * @@ -150,13 +157,39 @@ { int cons, active; - if ((value == NULL) || ((active = cons_find(value)) == -1)) { - if (value != NULL) - printf("no such console '%s'\n", (char *)value); - printf("Available consoles:\n"); - for (cons = 0; consoles[cons] != NULL; cons++) - printf(" %s\n", consoles[cons]->c_name); + if (value == NULL) { + cons_list(); + return(CMD_ERROR); + } else if (!strcmp(value, "probe")) { + /* reprobe all console */ + for (cons = 0; consoles[cons] != NULL; cons++) { + consoles[cons]->c_flags = 0; + consoles[cons]->c_probe(consoles[cons]); + } + /* find the first working one */ + active = -1; + for (cons = 0; consoles[cons] != NULL && active == -1; cons++) { + if (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT)) + active = cons; + } + if (active == -1) + active = 0; /* XXX */ + value = strdup(consoles[active]->c_name); + flags &= ~EV_VOLATILE; + flags |= EV_DYNAMIC; + } else if ((active = cons_find(value)) == -1) { + printf("no such console '%s'\n", (char *)value); + cons_list(); return(CMD_ERROR); + } else { + /* reprobe the specified console */ + consoles[active]->c_flags = 0; + consoles[active]->c_probe(consoles[active]); +#if 0 + /* XXX: what if it's not present?! */ + if (!(consoles[active]->c_flags & (C_PRESENTIN | C_PRESENTOUT))) + return(CMD_ERROR); +#endif } /* disable all current consoles */ Index: i386/libi386/comconsole.c =================================================================== RCS file: /src/CVS/src/sys/boot/i386/libi386/comconsole.c,v retrieving revision 1.6 diff -u -r1.6 comconsole.c --- comconsole.c 1999/01/10 14:48:05 1.6 +++ comconsole.c 1999/07/14 06:02:52 @@ -27,6 +27,7 @@ #include #include +#include #include #include "libi386.h" @@ -68,6 +69,8 @@ static int comc_ischar(void); static int comc_started; +static int comc_port; +static int comc_speed; struct console comconsole = { "comconsole", @@ -83,8 +86,32 @@ static void comc_probe(struct console *cp) { - /* XXX check the BIOS equipment list? */ - cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); + vm_offset_t p; + char *s; + u_int16_t port; + int ports; + int i; + + comc_started = 0; + s = getenv("com_port"); + if (s) + comc_port = strtol(s, NULL, 0); + else + comc_port = COMPORT; + s = getenv("com_speed"); + if (s) + comc_speed = strtol(s, NULL, 0); + else + comc_speed = COMSPEED; + + ports = (*(u_int16_t *)PTOV(0x410) >> 9) & 0x7; + for (i = 0, p = 0x400; i < ports; ++i, p += sizeof(u_int16_t)) { + port = *(u_int16_t *)PTOV(p); + if ((port != 0) && (port == comc_port)) { + cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); + return; + } + } } static int @@ -94,15 +121,15 @@ return 0; comc_started = 1; - outb(COMPORT + com_cfcr, CFCR_DLAB | COMC_FMT); - outb(COMPORT + com_dlbl, COMC_BPS(COMSPEED) & 0xff); - outb(COMPORT + com_dlbh, COMC_BPS(COMSPEED) >> 8); - outb(COMPORT + com_cfcr, COMC_FMT); - outb(COMPORT + com_mcr, MCR_RTS | MCR_DTR); + outb(comc_port + com_cfcr, CFCR_DLAB | COMC_FMT); + outb(comc_port + com_dlbl, COMC_BPS(comc_speed) & 0xff); + outb(comc_port + com_dlbh, COMC_BPS(comc_speed) >> 8); + outb(comc_port + com_cfcr, COMC_FMT); + outb(comc_port + com_mcr, MCR_RTS | MCR_DTR); do - inb(COMPORT + com_data); - while (inb(COMPORT + com_lsr) & LSR_RXRDY); + inb(comc_port + com_data); + while (inb(comc_port + com_lsr) & LSR_RXRDY); return(0); } @@ -113,8 +140,8 @@ int wait; for (wait = COMC_TXWAIT; wait > 0; wait--) - if (inb(COMPORT + com_lsr) & LSR_TXRDY) { - outb(COMPORT + com_data, c); + if (inb(comc_port + com_lsr) & LSR_TXRDY) { + outb(comc_port + com_data, c); break; } } @@ -122,11 +149,11 @@ static int comc_getchar(void) { - return(comc_ischar() ? inb(COMPORT + com_data) : -1); + return(comc_ischar() ? inb(comc_port + com_data) : -1); } static int comc_ischar(void) { - return(inb(COMPORT + com_lsr) & LSR_RXRDY); + return(inb(comc_port + com_lsr) & LSR_RXRDY); } Index: i386/libi386/vidconsole.c =================================================================== RCS file: /src/CVS/src/sys/boot/i386/libi386/vidconsole.c,v retrieving revision 1.11 diff -u -r1.11 vidconsole.c --- vidconsole.c 1999/01/04 18:45:08 1.11 +++ vidconsole.c 1999/07/14 08:22:59 @@ -35,11 +35,9 @@ #include #include "libi386.h" -#if KEYBOARD_PROBE #include static int probe_keyboard(void); -#endif static void vidc_probe(struct console *cp); static int vidc_init(int arg); static void vidc_putchar(int c); @@ -86,11 +84,7 @@ { /* look for a keyboard */ -#if KEYBOARD_PROBE - if (probe_keyboard()) -#endif - { - + if ((getenv("probe_keyboard") == NULL) || (probe_keyboard() == 0)) { cp->c_flags |= C_PRESENTIN; } @@ -514,8 +508,6 @@ return(!(v86.efl & PSL_Z)); } -#if KEYBOARD_PROBE - #define PROBE_MAXRETRY 5 #define PROBE_MAXWAIT 400 #define IO_DUMMY 0x84 @@ -624,4 +616,3 @@ return (1); } -#endif /* KEYBOARD_PROBE */