From owner-freebsd-hackers Thu Feb 28 22:34:51 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from zibbi.icomtek.csir.co.za (zibbi.icomtek.csir.co.za [146.64.24.58]) by hub.freebsd.org (Postfix) with ESMTP id CDCCD37B402 for ; Thu, 28 Feb 2002 22:34:42 -0800 (PST) Received: (from jhay@localhost) by zibbi.icomtek.csir.co.za (8.11.6/8.11.6) id g216YCQ20870; Fri, 1 Mar 2002 08:34:12 +0200 (SAT) (envelope-from jhay) From: John Hay Message-Id: <200203010634.g216YCQ20870@zibbi.icomtek.csir.co.za> Subject: Re: arbitrary serial speeds In-Reply-To: from Julian Elischer at "Feb 28, 2002 10:00:06 am" To: julian@elischer.org (Julian Elischer) Date: Fri, 1 Mar 2002 08:34:12 +0200 (SAT) Cc: lvd@mndmttr.nl (Luuk van Dijk), freebsd-hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Don't the stuff I committed to current do what you guys want? I'm planning to MFC it, but haven't asked Bruce yet. I'll need it before I MFC the puc driver. John -- John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org > I had changes to do this > BDE refused to commit them. > > > On Thu, 28 Feb 2002, Luuk van Dijk wrote: > > > This is a multi-part message in MIME format. > > --------------17932B47B695003DFEDACE26 > > Content-Type: text/plain; charset=us-ascii > > Content-Transfer-Encoding: 7bit > > > > L.S. > > > > for a project in which I communicate with embedded controllers in cars I > > need to read and write serial data at weird speeds of 5 and 10400 baud. > > > > the beauty of the freebsd interface to the serial ports is that the > > speed > > can be specified as an integer, i.e. not neccesarily as some predefined > > constant > > like B9600, but in src/sys/isa/sio.c the supplied value is looked up in > > a table, > > so using an arbitrary baudrate like 5 will return EINVAL. > > > > (On linux there is an ugly way to set these weird baud rates by setting > > the > > baudrate to 38400, and using a special syscall to tell the kernel to use > > some other divisor of 115200 to generate the uart speed. needless to > > say, I prefer > > the hygiene commonly observed in bsd's api's) > > > > an easy way would be to add my special baudrates to the table > > 'comspeedtab' > > that maps speed to divisor, but it is even more flexible to calculate > > the divisor > > on the spot, with the same macro COMBRD() as used in the initializer of > > 'comspeedtab'; > > note that this macro will automatically round to the next higher > > baudrate that is > > a divisor of 115200. > > > > The attached patch contains the neccesary changes. It works well for > > me, > > but who knows what I broke.... > > > > As far as I can tell, this renders the comspeedtab table, as well as the > > routine ttspeedtab in kern/tty.c superfluous, but as I'm not sure I > > haven't > > included their removal in the patch. > > > > Whoever maintains isa/sio.c, feel free to use this. I'd be very happy > > if > > in future versions of FreeBSD I could use baudrates of 5 and 10400 > > (actually the > > latter is rounded to 10475 == 115200/11, but that's good enough for me), > > without > > recompiling. > > > > Regards, > > Luuk van Dijk > > > > ___________________________________________________ > > Mind over Matter lvd at mndmttr.nl > > The Netherlands tel +31 6 224 97 227 > > ___________________________________________________ > > --------------17932B47B695003DFEDACE26 > > Content-Type: text/plain; charset=us-ascii; > > name="freebsd-src-sys-isa-sio-arbitrary-speed.patch" > > Content-Transfer-Encoding: 7bit > > Content-Disposition: inline; > > filename="freebsd-src-sys-isa-sio-arbitrary-speed.patch" > > > > --- isa.org/sio.c Wed Feb 6 23:58:00 2002 > > +++ isa/sio.c Thu Feb 7 00:08:25 2002 > > @@ -2153,7 +2153,7 @@ > > t->c_ispeed = t->c_ospeed; > > > > /* check requested parameters */ > > - divisor = ttspeedtab(t->c_ospeed, comspeedtab); > > + divisor = (t->c_ospeed) ? COMBRD(t->c_ospeed) : 0; /* was ttspeedtab(t->c_ospeed, comspeedtab); lvd */ > > if (divisor < 0 || (divisor > 0 && t->c_ispeed != t->c_ospeed)) > > return (EINVAL); > > > > @@ -2794,7 +2794,7 @@ > > * data input register. This also reduces the effects of the > > * UMC8669F bug. > > */ > > - divisor = ttspeedtab(speed, comspeedtab); > > + divisor = (speed) ? COMBRD(speed) : 0; /* was ttspeedtab(speed, comspeedtab); lvd */ > > dlbl = divisor & 0xFF; > > if (sp->dlbl != dlbl) > > outb(iobase + com_dlbl, dlbl); > > > > --------------17932B47B695003DFEDACE26-- > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-hackers" in the body of the message > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message