Subject: Re: missing cnmagic(9) support for sab(4) ?
To: None <port-sparc64@NetBSD.org>
From: Stoned Elipot <seb@ssr.univ-paris7.fr>
List: port-sparc64
Date: 06/08/2004 16:32:04
--Pd0ReVV5GZGQvF3a
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Jun 08, 2004 at 04:30:11PM +0200, Stoned Elipot wrote:
> I'd appreciate if someone could review the patch.

With the patch actually attached it may be easier :}

--Pd0ReVV5GZGQvF3a
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sab.c.diffs"

Index: sab.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/dev/sab.c,v
retrieving revision 1.16
diff -u -r1.16 sab.c
--- sab.c	21 Mar 2004 15:08:24 -0000	1.16
+++ sab.c	8 Jun 2004 09:50:09 -0000
@@ -150,7 +150,6 @@
 
 void sabtty_cnputc(struct sabtty_softc *, int);
 int sabtty_cngetc(struct sabtty_softc *);
-void sabtty_abort(struct sabtty_softc *);
 
 CFATTACH_DECL(sab, sizeof(struct sab_softc),
     sab_match, sab_attach, NULL, NULL);
@@ -171,6 +170,8 @@
 dev_type_tty(sabtty);
 dev_type_poll(sabpoll);
 
+static struct cnm_state sabtty_cnm_state;
+
 const struct cdevsw sabtty_cdevsw = {
 	sabopen, sabclose, sabread, sabwrite, sabioctl,
 	sabstop, sabtty, sabpoll, nommap, ttykqfilter, D_TTY
@@ -445,6 +446,8 @@
 			maj = cdevsw_lookup_major(&sabtty_cdevsw);
 			cn_tab->cn_dev = makedev(maj, self->dv_unit);
 			shutdownhook_establish(sabtty_shutdown, sc);
+			cn_init_magic(&sabtty_cnm_state);
+			cn_set_magic("\047\001"); /* default magic is BREAK */
 		}
 
 		if (sc->sc_flags & SABTTYF_CONS_OUT) {
@@ -498,6 +501,9 @@
 		ptr = sc->sc_rput;
 		for (i = 0; i < len; i++) {
 			*ptr++ = SAB_READ(sc, SAB_RFIFO);
+			if (i % 2 == 0) /* skip status byte */
+				cn_check_magic(sc->sc_tty->t_dev,
+					       ptr[-1], sabtty_cnm_state);
 			if (ptr == sc->sc_rend)
 				ptr = sc->sc_rbuf;
 			if (ptr == sc->sc_rget) {
@@ -522,7 +528,8 @@
 	}
 
 	if (isr1 & SAB_ISR1_BRKT)
-		sabtty_abort(sc);
+		cn_check_magic(sc->sc_tty->t_dev,
+			       CNC_BREAK, sabtty_cnm_state);
 
 	if (isr1 & (SAB_ISR1_XPR | SAB_ISR1_ALLS)) {
 		if ((SAB_READ(sc, SAB_STAR) & SAB_STAR_XFW) &&
@@ -1331,20 +1338,6 @@
 }
 
 void
-sabtty_abort(sc)
-	struct sabtty_softc *sc;
-{
-
-	if (sc->sc_flags & SABTTYF_CONS_IN) {
-#ifdef DDB
-		cn_trap();
-#else
-		callrom();
-#endif
-	}
-}
-
-void
 sabtty_shutdown(vsc)
 	void *vsc;
 {

--Pd0ReVV5GZGQvF3a--