From owner-p4-projects Thu Dec 12 11: 3:30 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 759AD37B404; Thu, 12 Dec 2002 11:03:26 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E9FFA37B401 for ; Thu, 12 Dec 2002 11:03:25 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7428B43EC2 for ; Thu, 12 Dec 2002 11:03:25 -0800 (PST) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gBCIwSmV062976 for ; Thu, 12 Dec 2002 10:58:28 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gBCIwRn3062973 for perforce@freebsd.org; Thu, 12 Dec 2002 10:58:27 -0800 (PST) Date: Thu, 12 Dec 2002 10:58:27 -0800 (PST) Message-Id: <200212121858.gBCIwRn3062973@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar Subject: PERFORCE change 22216 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=22216 Change 22216 by marcel@marcel_nfs on 2002/12/12 10:57:56 o CONS_DRIVER cannot have init and term NULL pointers. This fixes the hang when you try to make sio the console. o Get/set baudrate. If MD code has returned 0 as the baudrate, we read the current baudrate from the device; otherwise we set the baudrate on the device. This has been copied from the original code. It probably should go to siocninit... o Copy initialization stuff over from the original probe code and put it in siocninit. This brings the hackery closer to development, but still no console though... Affected files ... .. //depot/projects/ia64/sys/dev/sio/sio_cons.c#2 edit Differences ... ==== //depot/projects/ia64/sys/dev/sio/sio_cons.c#2 (text+ko) ==== @@ -80,39 +80,83 @@ struct com_s sio_console; static cn_probe_t siocnprobe; +static cn_init_t siocninit; +static cn_term_t siocnterm; +static cn_getc_t siocngetc; static cn_checkc_t siocncheckc; -static cn_getc_t siocngetc; static cn_putc_t siocnputc; -CONS_DRIVER(sio, siocnprobe, NULL, NULL, siocngetc, siocncheckc, siocnputc, - NULL); +CONS_DRIVER(sio, siocnprobe, siocninit, siocnterm, siocngetc, siocncheckc, + siocnputc, NULL); static void siocnprobe(struct consdev *cp) { struct sio_consdata cd; + u_int divisor; + u_char cfcr; bzero(&sio_console, sizeof(sio_console)); - if (sio_get_console(&cd) != 0) { - cp->cn_pri = CN_DEAD; + cp->cn_pri = CN_DEAD; + + if (sio_get_console(&cd) != 0) return; + + sio_console.bst = cd.type; + sio_console.bsh = cd.addr; + sio_console.rclk = cd.rclk; + + cfcr = sio_getreg(&sio_console, com_cfcr); + sio_setreg(&sio_console, com_cfcr, CFCR_DLAB | cfcr); + if (cd.baud != 0) { + divisor = siodivisor(cd.rclk, cd.baud); + sio_setreg(&sio_console, com_dlbl, divisor & 0xff); + sio_setreg(&sio_console, com_dlbh, divisor >> 8); + } else { + divisor = sio_getreg(&sio_console, com_dlbh); + divisor = (divisor << 8) | sio_getreg(&sio_console, com_dlbl); + /* XXX there should be more sanity checking. */ + cd.baud = (divisor != 0) + ? cd.rclk / (16UL * divisor) : CONSPEED; } + sio_setreg(&sio_console, com_cfcr, cfcr); cp->cn_dev = makedev(28, 0); cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL; +} + +static void +siocninit(struct consdev *cp) +{ + u_char mcr; - sio_console.bst = (cd.type == SYS_RES_IOPORT) - ? IA64_BUS_SPACE_IO : IA64_BUS_SPACE_MEM; - sio_console.bsh = cd.addr; + sio_setreg(&sio_console, com_ier, 0); + sio_setreg(&sio_console, com_cfcr, CFCR_8BITS); + mcr = sio_getreg(&sio_console, com_mcr); + sio_setreg(&sio_console, com_mcr, + (mcr & MCR_IENABLE) | MCR_DTR | MCR_RTS); + (void)sio_getreg(&sio_console, com_iir); + sio_console.is_console = 1; +} + +static void +siocnterm(struct consdev *cp) +{ + + sio_console.is_console = 0; } static void siocnputc(dev_t dev, int c) { - int s; + int s, to; s = spltty(); + to = 100000; + while ((sio_getreg(&sio_console, com_lsr) & (LSR_TSRE | LSR_TXRDY)) + != (LSR_TSRE | LSR_TXRDY) && --to != 0) + ; sio_setreg(&sio_console, com_data, c); /* XXX bus_space_barrier */ splx(s); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message