Subject: PROM console, cngetc()
To: None <port-sun3@sun-lamp.cs.berkeley.edu>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: port-sun3
Date: 03/03/1994 13:43:59
Here are changes to make the kernel console input function work.
(In case the kernel calls cngetc() as it does in boot -a mode.)
I also increased the polling rate a to 10 Hz (it was really slow).

My 3/60 does not like having NMI turned off for very long or
it gets a "Watchdog Reset!" when NMI is turned back on.
These changes take care of that problem too.

Of course, this hack can go away when the zs driver is ready.
(hopefully soon...)


*** arch/sun3/dev/prom.c.orig	Tue Mar  1 06:21:45 1994
--- arch/sun3/dev/prom.c	Thu Mar  3 12:52:50 1994
***************
*** 99,105 ****
      result = (*linesw[tp->t_line].l_open)(dev, tp);
      if (result)
  	return result;
!     timeout((timeout_t) promreceive, (caddr_t) tp, hz/2);
      return 0;
  }
  
--- 99,105 ----
      result = (*linesw[tp->t_line].l_open)(dev, tp);
      if (result)
  	return result;
!     timeout((timeout_t) promreceive, (caddr_t) tp, hz/10);
      return 0;
  }
  
***************
*** 216,221 ****
--- 216,222 ----
      tp->t_cflag = t->c_cflag;
      return 0;
  }
+ 
  static void promreceive(arg)
       caddr_t arg;
  {
***************
*** 224,255 ****
  
      tp = (struct tty *) arg;
      
-     s = spltty();
      if (tp->t_state & TS_ISOPEN) {
! 	if ((tp->t_state & TS_BUSY) == 0) {
! 	    extern unsigned int orig_nmi_vector;
! 	    extern int nmi_intr();
! 	    
! 	    set_clk_mode(0,IREG_CLOCK_ENAB_7|IREG_CLOCK_ENAB_5,0);
! 	    isr_add_custom(7, orig_nmi_vector);
! 	    set_clk_mode(IREG_CLOCK_ENAB_7,0,1);
! 	    c = mon_may_getchar();
! 	    set_clk_mode(0,IREG_CLOCK_ENAB_7|IREG_CLOCK_ENAB_5,0);
! 	    isr_add_custom(7, nmi_intr);
! 	    set_clk_mode(IREG_CLOCK_ENAB_5,0,1);
! 	    if (c != -1) {
! 		(*linesw[tp->t_line].l_rint)(c, tp);
! 	    }
! 	}
! 	timeout((timeout_t) promreceive, (caddr_t) tp, hz/3);
      }
!     else {
!     }
!     splx(s);
  }
  
  
- 
  /* prom console support */
  
  promcnprobe(cp)
--- 225,240 ----
  
      tp = (struct tty *) arg;
      
      if (tp->t_state & TS_ISOPEN) {
! 	s = spltty();
! 	while ((c = mon_may_getchar()) >= 0)
! 	    (*linesw[tp->t_line].l_rint)(c, tp);
! 	splx(s);
      }
!     timeout((timeout_t) promreceive, (caddr_t) tp, hz/10);
  }
  
  
  /* prom console support */
  
  promcnprobe(cp)
***************
*** 275,284 ****
      mon_printf("prom console initialized\n");
  }
  
  promcngetc(dev)
       dev_t dev;
  {
!     mon_printf("not sure how to do promcngetc() yet\n");
  }
  
  /*
--- 260,281 ----
      mon_printf("prom console initialized\n");
  }
  
+ /*
+  * Console kernel input chararcter routine.
+  */
  promcngetc(dev)
       dev_t dev;
  {
!     int c, s;
! 
!     s = splhigh();
!     do c = mon_may_getchar();
!     while (c < 0);
!     splx(s);
! 
!     if (c == '\r')
! 	c = '\n';
!     return (c);
  }
  
  /*

*** arch/sun3/sun3autoconf.c.orig	Tue Mar  1 06:21:49 1994
--- arch/sun3/sun3autoconf.c	Thu Mar  3 11:03:57 1994
***************
*** 89,101 ****
  void configure()
  {
      int root_found;
  
      boothowto = RB_SINGLE;
      isr_init();
      root_found = config_rootfound("mainbus", NULL);
      if (!root_found)
  	panic("configure: autoconfig failed, no device tree root found");
      isr_add(7, nmi_intr, 0);
      isr_cleanup();
  }
  
--- 89,108 ----
  void configure()
  {
      int root_found;
+     extern unsigned int orig_nmi_vector;
  
      boothowto = RB_SINGLE;
      isr_init();
      root_found = config_rootfound("mainbus", NULL);
      if (!root_found)
  	panic("configure: autoconfig failed, no device tree root found");
+ #if 1
+     /* XXX - Let the PROM handle this for now. -gwr */
+     isr_add_custom(7, orig_nmi_vector);
+ #else
+     /* XXX - Let the PROM handle this for now. -gwr */
      isr_add(7, nmi_intr, 0);
+ #endif
      isr_cleanup();
  }
  


------------------------------------------------------------------------------