Date: Sat, 21 Apr 2007 23:42:53 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: alfred@freebsd.org Cc: hackers@freebsd.org, bde@freebsd.org Subject: Re: serial help ? Message-ID: <20070421.234253.-937378175.imp@bsdimp.com> In-Reply-To: <20070419211021.GH69188@elvis.mu.org> References: <20070419211021.GH69188@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20070419211021.GH69188@elvis.mu.org> Alfred Perlstein <alfred@freebsd.org> writes: : : I'm working on some custom hardware and I'm getting garbled console : output. : : I noticed that siocntxwait looks like this: : : static void : siocntxwait(iobase) : Port_t iobase; : { : int timo; : : /* : * Wait for any pending transmission to finish. Required to avoid : * the UART lockup bug when the speed is changed, and for normal : * transmits. : */ : timo = 100000; : while ((inb(iobase + com_lsr) & (LSR_TSRE | LSR_TXRDY)) : != (LSR_TSRE | LSR_TXRDY) && --timo != 0) : ; : } : : Shouldn't there be some sort of DELAY in there? : : My platform has an emulated serial device in hardware, so it : may be that the loop could run a LOT faster than transmit can : happen... : : any ideas of what the DELAY should be? The inb() is assumed to provide a delay of 1us, so this has a timeout of 100ms. Even with newer PCI devices that run about 4-5 times faster, the timeout is still on the order of 20ms, which is adequate for most modern baudrates (9600 baud takes 1ms, 115200 takes 10us). Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070421.234253.-937378175.imp>