From owner-p4-projects@FreeBSD.ORG Tue Sep 13 09:47:38 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D0FB316A421; Tue, 13 Sep 2005 09:47:37 +0000 (GMT) X-Original-To: perforce@freebsd.org 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 A646B16A41F for ; Tue, 13 Sep 2005 09:47:37 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 61F5943D46 for ; Tue, 13 Sep 2005 09:47:37 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j8D9lbxn037637 for ; Tue, 13 Sep 2005 09:47:37 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j8D9lb8Q037633 for perforce@freebsd.org; Tue, 13 Sep 2005 09:47:37 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 13 Sep 2005 09:47:37 GMT Message-Id: <200509130947.j8D9lb8Q037633@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 83530 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Sep 2005 09:47:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=83530 Change 83530 by rwatson@rwatson_zoo on 2005/09/13 09:47:19 Integrate netsmp from FreeBSD CVS - Loop back fifofs fixes, merge fifofs comments. Affected files ... .. //depot/projects/netsmp/src/sys/boot/pc98/Makefile.inc#2 integrate .. //depot/projects/netsmp/src/sys/boot/pc98/libpc98/comconsole.c#2 integrate .. //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#9 integrate Differences ... ==== //depot/projects/netsmp/src/sys/boot/pc98/Makefile.inc#2 (text+ko) ==== @@ -1,11 +1,12 @@ # Common defines for all of /sys/boot/pc98/ # -# $FreeBSD: src/sys/boot/pc98/Makefile.inc,v 1.5 2004/02/09 16:01:44 nyan Exp $ +# $FreeBSD: src/sys/boot/pc98/Makefile.inc,v 1.6 2005/09/13 08:27:38 nyan Exp $ BINDIR?= /boot LOADER_ADDRESS?=0x100000 -CFLAGS+= -ffreestanding -mpreferred-stack-boundary=2 +CFLAGS+= -ffreestanding -mpreferred-stack-boundary=2 \ + -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 LDFLAGS+= -nostdlib # BTX components ==== //depot/projects/netsmp/src/sys/boot/pc98/libpc98/comconsole.c#2 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/boot/pc98/libpc98/comconsole.c,v 1.6 2005/05/08 14:17:28 nyan Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/pc98/libpc98/comconsole.c,v 1.7 2005/09/13 08:29:03 nyan Exp $"); #include #include @@ -35,6 +35,7 @@ #define COMC_FMT 0x3 /* 8N1 */ #define COMC_TXWAIT 0x40000 /* transmit timeout */ #define COMC_BPS(x) (115200 / (x)) /* speed to DLAB divisor */ +#define COMC_DIV2BPS(x) (115200 / (x)) /* DLAB divisor to speed */ #ifndef COMPORT #define COMPORT 0x238 @@ -47,9 +48,15 @@ static int comc_init(int arg); static void comc_putchar(int c); static int comc_getchar(void); +static int comc_getspeed(void); static int comc_ischar(void); +static int comc_parsespeed(const char *string); +static void comc_setup(int speed); +static int comc_speed_set(struct env_var *ev, int flags, + const void *value); static int comc_started; +static int comc_curspeed; struct console comconsole = { "comconsole", @@ -65,8 +72,36 @@ static void comc_probe(struct console *cp) { + char speedbuf[16]; + char *cons, *speedenv; + int speed; + /* XXX check the BIOS equipment list? */ cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); + + if (comc_curspeed == 0) { + comc_curspeed = COMSPEED; + /* + * Assume that the speed was set by an earlier boot loader if + * comconsole is already the preferred console. + */ + cons = getenv("console"); + if ((cons != NULL && strcmp(cons, comconsole.c_name) == 0) || + getenv("boot_multicons") != NULL) { + comc_curspeed = comc_getspeed(); + } + speedenv = getenv("comconsole_speed"); + if (speedenv != NULL) { + speed = comc_parsespeed(speedenv); + if (speed > 0) + comc_curspeed = speed; + } + + sprintf(speedbuf, "%d", comc_curspeed); + unsetenv("comconsole_speed"); + env_setenv("comconsole_speed", EV_VOLATILE, speedbuf, comc_speed_set, + env_nounset); + } } static int @@ -76,15 +111,7 @@ 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); - - do - inb(COMPORT + com_data); - while (inb(COMPORT + com_lsr) & LSR_RXRDY); + comc_setup(comc_curspeed); return(0); } @@ -112,3 +139,75 @@ { return(inb(COMPORT + com_lsr) & LSR_RXRDY); } + +static int +comc_speed_set(struct env_var *ev, int flags, const void *value) +{ + int speed; + + if (value == NULL || (speed = comc_parsespeed(value)) <= 0) { + printf("Invalid speed\n"); + return (CMD_ERROR); + } + + if (comc_started && comc_curspeed != speed) + comc_setup(speed); + + env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); + + return (CMD_OK); +} + +static void +comc_setup(int speed) +{ + + comc_curspeed = speed; + + outb(COMPORT + com_cfcr, CFCR_DLAB | COMC_FMT); + outb(COMPORT + com_dlbl, COMC_BPS(speed) & 0xff); + outb(COMPORT + com_dlbh, COMC_BPS(speed) >> 8); + outb(COMPORT + com_cfcr, COMC_FMT); + outb(COMPORT + com_mcr, MCR_RTS | MCR_DTR); + + do + inb(COMPORT + com_data); + while (inb(COMPORT + com_lsr) & LSR_RXRDY); +} + +static int +comc_parsespeed(const char *speedstr) +{ + char *p; + int speed; + + speed = strtol(speedstr, &p, 0); + if (p == speedstr || *p != '\0' || speed <= 0) + return (-1); + + return (speed); +} + +static int +comc_getspeed(void) +{ + u_int divisor; + u_char dlbh; + u_char dlbl; + u_char cfcr; + + cfcr = inb(COMPORT + com_cfcr); + outb(COMPORT + com_cfcr, CFCR_DLAB | cfcr); + + dlbl = inb(COMPORT + com_dlbl); + dlbh = inb(COMPORT + com_dlbh); + + outb(COMPORT + com_cfcr, cfcr); + + divisor = dlbh << 8 | dlbl; + + /* XXX there should be more sanity checking. */ + if (divisor == 0) + return (COMSPEED); + return (COMC_DIV2BPS(divisor)); +} ==== //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#9 (text+ko) ==== @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 - * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c,v 1.120 2005/09/12 18:07:49 rwatson Exp $ + * $FreeBSD: src/sys/fs/fifofs/fifo_vnops.c,v 1.122 2005/09/13 09:23:22 rwatson Exp $ */ #include @@ -334,6 +334,12 @@ return (0); } +/* + * Currently fifo_kqfilter() isn't reachable beause vop_kqfilter() is only + * called for open files, in which case the fifo code has redirected the + * caller to fifo_kqfilter_f() via the file descriptor operations vector. + * This implementation should be garbage collected. + */ /* ARGSUSED */ static int fifo_kqfilter(ap) @@ -589,6 +595,12 @@ return (error); } +/* + * Because fifos are now a file descriptor layer object, EVFILT_VNODE is not + * implemented. Likely, fifo_kqfilter() should be removed, and + * fifo_kqfilter_f() should know how to forward the request to the underling + * vnode using f_vnode in the file descriptor here. + */ static int fifo_kqfilter_f(struct file *fp, struct knote *kn) {