+#if defined(KDB) || defined(GENERIC)
+cngetc()
+{
+ register int c, s;
+
+ s = spl8(); /* block cnrint while we poll */
+ c = cngetchar((struct tty *)0);
+ if (c == '\r')
+ c = '\n';
+ splx(s);
+ return (c);
+}
+
+cngetchar(tp)
+ register struct tty *tp;
+{
+ register timo, unit;
+ register struct cpdcb_i *current;
+ char c;
+
+ /* tp == 0 only in system error messages */
+ if (tp == 0) {
+ current = &consin[CPCONS];
+ unit = CPCONS;
+ if (lasthdr == 0) /* not done anything yet */
+ lasthdr = (struct cphdr *)current;
+ } else {
+ current = &consin[minor(tp->t_dev)];
+ unit = minor(tp->t_dev);
+ }
+ timo = 10000;
+ uncache((char *)&lasthdr->cp_unit);
+ while ((lasthdr->cp_unit&CPTAKE) == 0 && --timo)
+ uncache(&lasthdr->cp_unit);
+ current->cp_hdr.cp_unit = unit; /* Resets done bit */
+ current->cp_hdr.cp_comm = CPREAD;
+ current->cp_hdr.cp_count = 1;
+ mtpr(CPMDCB, current);
+ while ((current->cp_hdr.cp_unit & CPDONE) == 0)
+ uncache(¤t->cp_hdr.cp_unit);
+ uncache(¤t->cpi_buf[0]);
+ c = current->cpi_buf[0] & 0x7f;
+ lasthdr = (struct cphdr *)current;
+ return (c);
+}
+#endif
+