Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Dec 2002 10:58:27 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 22216 for review
Message-ID:  <200212121858.gBCIwRn3062973@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=22216

Change 22216 by marcel@marcel_nfs on 2002/12/12 10:57:56

	o  CONS_DRIVER cannot have init and term NULL pointers. This
	   fixes the hang when you try to make sio the console.
	o  Get/set baudrate. If MD code has returned 0 as the baudrate,
	   we read the current baudrate from the device; otherwise we
	   set the baudrate on the device. This has been copied from
	   the original code. It probably should go to siocninit...
	o  Copy initialization stuff over from the original probe code
	   and put it in siocninit.
	
	This brings the hackery closer to development, but still no
	console though...

Affected files ...

.. //depot/projects/ia64/sys/dev/sio/sio_cons.c#2 edit

Differences ...

==== //depot/projects/ia64/sys/dev/sio/sio_cons.c#2 (text+ko) ====

@@ -80,39 +80,83 @@
 struct com_s sio_console;
 
 static cn_probe_t siocnprobe;
+static cn_init_t siocninit;
+static cn_term_t siocnterm;
+static cn_getc_t siocngetc;
 static cn_checkc_t siocncheckc;
-static cn_getc_t siocngetc;
 static cn_putc_t siocnputc;
 
-CONS_DRIVER(sio, siocnprobe, NULL, NULL, siocngetc, siocncheckc, siocnputc,
-    NULL);
+CONS_DRIVER(sio, siocnprobe, siocninit, siocnterm, siocngetc, siocncheckc,
+	siocnputc, NULL);
 
 static void
 siocnprobe(struct consdev *cp)
 {
 	struct sio_consdata cd;
+	u_int divisor;
+	u_char cfcr;
 
 	bzero(&sio_console, sizeof(sio_console));
 
-	if (sio_get_console(&cd) != 0) {
-		cp->cn_pri = CN_DEAD;
+	cp->cn_pri = CN_DEAD;
+
+	if (sio_get_console(&cd) != 0)
 		return;
+
+	sio_console.bst = cd.type;
+	sio_console.bsh = cd.addr;
+	sio_console.rclk = cd.rclk;
+
+	cfcr = sio_getreg(&sio_console, com_cfcr);
+	sio_setreg(&sio_console, com_cfcr, CFCR_DLAB | cfcr);
+	if (cd.baud != 0) {
+		divisor = siodivisor(cd.rclk, cd.baud);
+		sio_setreg(&sio_console, com_dlbl, divisor & 0xff);
+		sio_setreg(&sio_console, com_dlbh, divisor >> 8);
+	} else {
+		divisor = sio_getreg(&sio_console, com_dlbh);
+		divisor = (divisor << 8) | sio_getreg(&sio_console, com_dlbl);
+		/* XXX there should be more sanity checking. */
+		cd.baud = (divisor != 0)
+		    ? cd.rclk / (16UL * divisor) : CONSPEED;
 	}
+	sio_setreg(&sio_console, com_cfcr, cfcr);
 
 	cp->cn_dev = makedev(28, 0);
 	cp->cn_pri = (boothowto & RB_SERIAL) ? CN_REMOTE : CN_NORMAL;
+}
+
+static void
+siocninit(struct consdev *cp)
+{
+	u_char mcr;
 
-	sio_console.bst = (cd.type == SYS_RES_IOPORT)
-	    ? IA64_BUS_SPACE_IO : IA64_BUS_SPACE_MEM;
-	sio_console.bsh = cd.addr;
+	sio_setreg(&sio_console, com_ier, 0);
+	sio_setreg(&sio_console, com_cfcr, CFCR_8BITS);
+	mcr = sio_getreg(&sio_console, com_mcr);
+	sio_setreg(&sio_console, com_mcr,
+	    (mcr & MCR_IENABLE) | MCR_DTR | MCR_RTS);
+	(void)sio_getreg(&sio_console, com_iir);
+	sio_console.is_console = 1;
+}
+
+static void
+siocnterm(struct consdev *cp)
+{
+
+	sio_console.is_console = 0;
 }
 
 static void
 siocnputc(dev_t dev, int c)
 {
-	int s;
+	int s, to;
 
 	s = spltty();
+	to = 100000;
+	while ((sio_getreg(&sio_console, com_lsr) & (LSR_TSRE | LSR_TXRDY))
+	    != (LSR_TSRE | LSR_TXRDY) && --to != 0)
+		;
 	sio_setreg(&sio_console, com_data, c);
 	/* XXX bus_space_barrier */
 	splx(s);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212121858.gBCIwRn3062973>