From: kjb=732293@cs.vu.nl (Kees J Bot)
Newsgroups: comp.os.minix
Subject: Re: [VMD] RS232 FIFO's
Date: Fri, 20 Oct 2000 20:51:20 +0200
Organization: One Minix-vmd system, it works!
Lines: 91
Message-ID: <874qs8.5d.ln@jetsam.cs.vu.nl>
References: <slrn8urqr3.cil.pino+comp_os_minix@mud.stack.nl> <8spdfi$pku@cs.vu.nl>
NNTP-Posting-Host: jetsam.cs.vu.nl
Path: news.adfa.edu.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!skywalker.ou.edu!leto.backbone.ou.edu!hammer.uoregon.edu!newsflash.concordia.ca!sunqbc.risq.qc.ca!isdnet!newsfeeds.belnet.be!news.belnet.be!newsfeed1.news.nl.uu.net!sun4nl!star.cs.vu.nl!not-for-mail
Xref: news.adfa.edu.au comp.os.minix:35948

In article <8spdfi$pku@cs.vu.nl>, Philip Homburg  <philip@cs.vu.nl> wrote:
>In article <slrn8urqr3.cil.pino+comp_os_minix@mud.stack.nl>,
>Martijn van Buul <pino+comp_os_minix@dohd.org> wrote:
>
>>                                                    If this could
>>be configured differently for each port, this would be great.
>
>Add an extra field to the env_parse format string, and make some changes
>to the detection code in rs_init. Should not be very difficult.

Especially if use the diff below as a guide (don't try to patch, do it
by hand.)  My COM3 freezes up totally on a hangup when used as a 16550,
so I added a third parameter to the SERIALn variables that selects the
chip type.  Use SERIALn=::0 to force your line to be a 8250.
-- 
Kees J. Bot, Systems Programmer, Sciences dept., Vrije Universiteit Amsterdam
_._. .._ _   ._ ._.. ___ _. __.   _ .... .   _.. ___ _ _ . _..   ._.. .. _. .
--- /save/vmd/pch-1999-11-19/src/sys/kernel/ibm/rs232.c	Thu Jan 14 09:06:54 1999
+++ /usr/src/sys/kernel/ibm/rs232.c	Sat Sep 23 13:07:30 2000
@@ -581,7 +572,7 @@
 rs_conf_t *rcp;
 {
 	long v;
-	static char rc_fmt[] = "x:d";
+	static char rc_fmt[] = "x:d:d";
 
 	/* The default settings may be overridden from the environment. */
 	serial->rs_mode= rcp->rc_mode;
@@ -602,6 +593,10 @@
 						(long) NR_IRQ_VECTORS - 1);
 	serial->rs_irq= v;
 
+	v= RST_UNKNOWN;
+	(void) env_parse(rcp->rc_envvar, rc_fmt, 2, &v, RST_8250, RST_16550A);
+	serial->rs_type= v;
+
 	/* Don't let a disabled line be recognized in the interrupt handler. */
 	if (serial->rs_mode == RSM_DISABLED)
 		serial->rs_irq= IRQ_OFF;
@@ -1079,7 +1074,6 @@
 
   rs = rs_addr(serial_line) = &rs_lines[serial_line];
 
-  rs->rs_type= RST_UNKNOWN;
   rs->rs_out_fifo_sz= 1;		/* Old UARTS buffer 1 byte */
 
   /* Set up input queue. */
@@ -1121,26 +1115,27 @@
 	return;
   }
   id= id >> 6;
-  switch(id)
-  {
-  case 0:	rs->rs_type= RST_16450; break;		/* or 8250 */
-  case 1:	break;					/* unknown */
-  case 2:	rs->rs_type= RST_16550;	break;
-  case 3:	rs->rs_type= RST_16550A;
-		rs->rs_out_fifo_sz= RS_16550A_FIFO_SIZE;
+  if (rs->rs_type == RST_UNKNOWN) {
+	switch(id)
+	{
+	case 0:	scratch= in_byte(rs->rs_scr);
+		out_byte(rs->rs_scr, 0xa5);
+		res1= in_byte(rs->rs_scr);
+		out_byte(rs->rs_scr, 0x5a);
+		res2= in_byte(rs->rs_scr);
+		out_byte(rs->rs_scr, scratch);
+		rs->rs_type= res1!=0xa5 || res2!=0x5a ? RST_8250 : RST_16450;
+		break;
+	case 1:	break;					/* unknown */
+	case 2:	rs->rs_type= RST_16550;	break;
+	case 3:	rs->rs_type= RST_16550A;
 		break;
+	}
   }
 
-  if (rs->rs_type == RST_16450)
+  if (rs->rs_type == RST_16550A)
   {
-  	scratch= in_byte(rs->rs_scr);
-  	out_byte(rs->rs_scr, 0xa5);
-  	res1= in_byte(rs->rs_scr);
-  	out_byte(rs->rs_scr, 0x5a);
-  	res2= in_byte(rs->rs_scr);
-  	out_byte(rs->rs_scr, scratch);
-  	if (res1 != 0xa5 || res2 != 0x5a)
-  		rs->rs_type= RST_8250;
+	rs->rs_out_fifo_sz= RS_16550A_FIFO_SIZE;
   }
 
   if (debug) {
