From owner-freebsd-current@FreeBSD.ORG Sun Aug 14 03:10:01 2005 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A920C16A41F for ; Sun, 14 Aug 2005 03:10:01 +0000 (GMT) (envelope-from Emanuel.strobl@gmx.net) Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 61F3A43D48 for ; Sun, 14 Aug 2005 03:09:59 +0000 (GMT) (envelope-from Emanuel.strobl@gmx.net) Received: (qmail invoked by alias); 14 Aug 2005 03:09:58 -0000 Received: from flb.schmalzbauer.de (EHLO cale.flintsbach.schmalzbauer.de) [62.245.232.135] by mail.gmx.net (mp005) with SMTP; 14 Aug 2005 05:09:58 +0200 X-Authenticated: #301138 From: Emanuel Strobl To: freebsd-current@freebsd.org Date: Sun, 14 Aug 2005 05:09:42 +0200 User-Agent: KMail/1.8.1 References: <200508140243.aa50444@nowhere.iedowse.com> In-Reply-To: <200508140243.aa50444@nowhere.iedowse.com> X-Birthday: Oct. 6th 1972 X-CelPhone: +49 (0) 173 9967781 X-Tel: +49 (0) 89 18947781 X-Country: Germany X-Address: Munich, 80686 X-OS: FreeBSD MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2456771.8rlk6FXTLq"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200508140509.53723@harrymail> X-Y-GMX-Trusted: 0 Cc: Ian Dowse , current@freebsd.org Subject: Re: Loader serial baud rate control X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Aug 2005 03:10:01 -0000 --nextPart2456771.8rlk6FXTLq Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Am Sonntag, 14. August 2005 03:43 CEST schrieb Ian Dowse: > Currently the baud rate used by the i386/amd64 loader for a serial > console is hard-coded as 9600 baud and you need to recompile the > loader to change it. Below is a patch that adds a "comconsole_speed" > loader environment variable so that the speed can be changed from > loader.conf or manually from the loader prompt. It doesn't quite > do what you want though, since the loader has already printed a > number of things by the time it reads loader.conf. Any comments? Yes :) Thanks a lot for your work! I recognized that BOOT_COMCONSOLE_SPEED in make.conf doesn't change the=20 console behaviour anymore (as with beta2 from last Thursday). I can=20 successfully set the speed in /etc/ttys, also the boot bits respect the=20 setting, but kernel console is 9600. Having a loader tunable for serial console speed was really great!!! Since it seems you're firm with the relevant bits, why doesn't setting=20 machdep.conspeed in loader.conf work? Thanks a lot, =2DHarry > > Ian > > Index: i386/libi386/comconsole.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /dump/FreeBSD-CVS/src/sys/boot/i386/libi386/comconsole.c,v > retrieving revision 1.10 > diff -u -r1.10 comconsole.c > --- i386/libi386/comconsole.c 16 Sep 2003 11:24:23 -0000 1.10 > +++ i386/libi386/comconsole.c 14 Aug 2005 01:12:52 -0000 > @@ -48,8 +48,13 @@ > static void comc_putchar(int c); > static int comc_getchar(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 =3D { > "comconsole", > @@ -72,19 +77,29 @@ > static int > comc_init(int arg) > { > + char speedbuf[16]; > + char *speedenv; > + int speed; > + > if (comc_started && arg =3D=3D 0) > return 0; > - comc_started =3D 1; > + if (!comc_started) { > + comc_curspeed =3D COMSPEED; > + speedenv =3D getenv("comconsole_speed"); > + if (speedenv !=3D NULL) { > + speed =3D comc_parsespeed(speedenv); > + if (speed > 0) > + comc_curspeed =3D speed; > + } > > - 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); > + sprintf(speedbuf, "%d", comc_curspeed); > + unsetenv("comconsole_speed"); > + env_setenv("comconsole_speed", EV_VOLATILE, speedbuf, comc_speed_set, > + env_nounset); > + } > + comc_started =3D 1; > > - do > - inb(COMPORT + com_data); > - while (inb(COMPORT + com_lsr) & LSR_RXRDY); > + comc_setup(comc_curspeed); > > return(0); > } > @@ -112,3 +127,51 @@ > { > 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 =3D=3D NULL || (speed =3D comc_parsespeed(value)) <=3D 0) { > + printf("Invalid speed\n"); > + return (CMD_ERROR); > + } > + > + if (comc_curspeed !=3D 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 =3D 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 =3D strtol(speedstr, &p, 0); > + if (p =3D=3D speedstr || *p !=3D '\0' || speed <=3D 0) > + return (-1); > + > + return (speed); > +} > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to > "freebsd-current-unsubscribe@freebsd.org" --nextPart2456771.8rlk6FXTLq Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQBC/rYBBylq0S4AzzwRAnLCAJ4uMbzCpwa3GCFUP4ZhDGjSN/UYhwCfeWyV Rc3dPgTiLKC6dKx4GJTufCs= =5Xu5 -----END PGP SIGNATURE----- --nextPart2456771.8rlk6FXTLq--