Subject: FIX! Re: Upgraded to 3.0.1 -> no console
To: None <netbsd-help@netbsd.org, port-alpha@netbsd.org,>
From: Dieter <netbsd@sopwith.solgatos.com>
List: netbsd-help
Date: 08/12/2006 17:19:12
Dave Barnes was kind enough to email me a diff to fix
the rs-232 ports.  Patch wasn't quite smart enough to
automatically apply it to 3.0.1, but with a bit of hand
editing the console is working again.  Thanks, Dave!

Here is a patch for 3.0.1.


===================================================================
RCS file: arch/alpha/pci/RCS/sio_pic.c,v
retrieving revision 1.1
diff -u -r1.1 arch/alpha/pci/sio_pic.c
--- arch/alpha/pci/sio_pic.c	2006/08/12 22:39:31	1.1
+++ arch/alpha/pci/sio_pic.c	2006/08/12 22:48:16
@@ -121,8 +121,15 @@
  * If prom console is broken, must remember the initial interrupt
  * settings and enforce them.  WHEE!
  */
-u_int8_t initial_ocw1[2];
-u_int8_t initial_elcr[2];
+#define    INITIALLY_ENABLED(irq)                        \
+    ((initial_ocw1[(irq) / 8] & (1 << ((irq) % 8))) == 0)
+#define    INITIALLY_LEVEL_TRIGGERED(irq)                    \
+    ((initial_elcr[(irq) / 8] & (1 << ((irq) % 8))) != 0)
+ u_int8_t initial_ocw1[2];
+ u_int8_t initial_elcr[2];
+#else
+#define    INITIALLY_ENABLED(irq)        ((irq) == 2 ? 1 : 0)
+#define    INITIALLY_LEVEL_TRIGGERED(irq)    0
 #endif
 
 void		sio_setirqstat __P((int, int, int));
@@ -384,7 +391,9 @@
 			 * IRQs 0, 1, 8, and 13 must always be
 			 * edge-triggered.
 			 */
-			sio_setirqstat(i, 0, IST_EDGE);
+		        if (INITIALLY_LEVEL_TRIGGERED(i))
+		            printf("sio_intr_setup: %d level-triggered\n",i);
+		        sio_setirqstat(i, INITIALLY_ENABLED(i), IST_EDGE);
 			alpha_shared_intr_set_dfltsharetype(sio_intr, i,
 			    IST_EDGE);
 			specific_eoi(i);
@@ -405,9 +414,12 @@
 			 * Otherwise, disable the IRQ and set its
 			 * type to (effectively) "unknown."
 			 */
-			sio_setirqstat(i, 0, IST_NONE);
-			alpha_shared_intr_set_dfltsharetype(sio_intr, i,
-			    IST_NONE);
+		         sio_setirqstat(i, INITIALLY_ENABLED(i),
+			     INITIALLY_LEVEL_TRIGGERED(i) ?
+			     IST_LEVEL : IST_NONE);
+			 alpha_shared_intr_set_dfltsharetype(sio_intr, i,
+			     INITIALLY_LEVEL_TRIGGERED(i) ?
+	       		     IST_LEVEL : IST_NONE);
 			specific_eoi(i);
 			break;
 		}
@@ -519,10 +531,11 @@
 			break;
 
 		default:
-			ist = IST_NONE;
+		        ist = INITIALLY_LEVEL_TRIGGERED(irq) ?
+		            IST_LEVEL : IST_NONE;
 			break;
 		}
-		sio_setirqstat(irq, 0, ist);
+		sio_setirqstat(irq, INITIALLY_ENABLED(irq), ist);
 		alpha_shared_intr_set_dfltsharetype(sio_intr, irq, ist);
 
 		/* Release our SCB vector. */