Subject: port-i386/2510: pccons recognises color video as mono if console is COMCONSOLE.
To: None <gnats-bugs@NetBSD.ORG>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 06/03/1996 20:08:03
>Number:         2510
>Category:       port-i386
>Synopsis:       pccons recongnies color viode as mono if console is COMCONSOLE.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun  3 17:35:02 1996
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
	one of NetBSD users in japan
>Release:        1.2_ALPHA
>Environment:
System: NetBSD pavlov 1.2_ALPHA NetBSD 1.2_ALPHA (PAVLOV) #41: Mon May 27 23:07:20 JST 1996 enami@pavlov:/usr/src/sys/arch/i386/compile/PAVLOV i386


>Description:
	if COMCONSOLE is specified when build a kernel and also pccons
	has enabled, that kernel recognises video as mono even if it is
	actually a color.
>How-To-Repeat:
	Build kernel with COMCONSOLE option and pc0, and boot it.  Then
	it says 
		pc0 at isa .... : mono
>Fix:
	Some of initalizing code is called at first call of sput().  It
	is called before attaching pccons if it is console, but it never
	called before attaching if it is not console.

	So to fix a problem, make initialization code in sput into
	separate function, and then call it in attach of pccons if
	apropriciate.

	Pcvt does similar thing.

Index: pccons.c
===================================================================
RCS file: /a/cvsroot/NetBSD/sys/arch/i386/isa/pccons.c,v
retrieving revision 1.1.1.10
diff -u -r1.1.1.10 pccons.c
--- pccons.c	1996/05/15 11:55:31	1.1.1.10
+++ pccons.c	1996/05/19 08:31:48
@@ -148,6 +148,7 @@
 
 static unsigned int addr_6845 = MONO_BASE;
 
+void pcinit __P((void));
 char *sget __P((void));
 void sput __P((u_char *, int));
 void pc_xmode_on __P((void));
@@ -492,6 +493,9 @@
 	struct pc_softc *sc = (void *)self;
 	struct isa_attach_args *ia = aux;
 
+	if (crtat == 0)
+		pcinit();
+
 	printf(": %s\n", vs.color ? "color" : "mono");
 	do_async_update((void *)1);
 
@@ -846,6 +850,52 @@
 	return 0;
 }
 
+void
+pcinit()
+{
+	u_short volatile *cp;
+	u_short was;
+	unsigned cursorat;
+
+	cp = ISA_HOLE_VADDR(CGA_BUF);
+	was = *cp;
+	*cp = (u_short) 0xA55A;
+	if (*cp != 0xA55A) {
+		cp = ISA_HOLE_VADDR(MONO_BUF);
+		addr_6845 = MONO_BASE;
+		vs.color = 0;
+	} else {
+		*cp = was;
+		addr_6845 = CGA_BASE;
+		vs.color = 1;
+	}
+
+	/* Extract cursor location */
+	outb(addr_6845, 14);
+	cursorat = inb(addr_6845+1) << 8;
+	outb(addr_6845, 15);
+	cursorat |= inb(addr_6845+1);
+
+#ifdef FAT_CURSOR
+	cursor_shape = 0x0012;
+#endif
+
+	Crtat = (u_short *)cp;
+	crtat = (u_short *)(cp + cursorat);
+
+	vs.ncol = COL;
+	vs.nrow = ROW;
+	vs.nchr = COL * ROW;
+	vs.at = FG_LIGHTGREY | BG_BLACK;
+
+	if (vs.color == 0)
+		vs.so_at = FG_BLACK | BG_LIGHTGREY;
+	else
+		vs.so_at = FG_YELLOW | BG_BLACK;
+
+	fillw((vs.at << 8) | ' ', crtat, vs.nchr - cursorat);
+}
+
 #define	wrtchar(c, at) do {\
 	char *cp = (char *)crtat; *cp++ = (c); *cp = (at); crtat++; vs.col++; \
 } while (0)
@@ -874,49 +924,8 @@
 	if (pc_xmode > 0)
 		return;
 
-	if (crtat == 0) {
-		u_short volatile *cp;
-		u_short was;
-		unsigned cursorat;
-
-		cp = ISA_HOLE_VADDR(CGA_BUF);
-		was = *cp;
-		*cp = (u_short) 0xA55A;
-		if (*cp != 0xA55A) {
-			cp = ISA_HOLE_VADDR(MONO_BUF);
-			addr_6845 = MONO_BASE;
-			vs.color = 0;
-		} else {
-			*cp = was;
-			addr_6845 = CGA_BASE;
-			vs.color = 1;
-		}
-
-		/* Extract cursor location */
-		outb(addr_6845, 14);
-		cursorat = inb(addr_6845+1) << 8;
-		outb(addr_6845, 15);
-		cursorat |= inb(addr_6845+1);
-
-#ifdef FAT_CURSOR
-		cursor_shape = 0x0012;
-#endif
-
-		Crtat = (u_short *)cp;
-		crtat = (u_short *)(cp + cursorat);
-
-		vs.ncol = COL;
-		vs.nrow = ROW;
-		vs.nchr = COL * ROW;
-		vs.at = FG_LIGHTGREY | BG_BLACK;
-
-		if (vs.color == 0)
-			vs.so_at = FG_BLACK | BG_LIGHTGREY;
-		else
-			vs.so_at = FG_YELLOW | BG_BLACK;
-
-		fillw((vs.at << 8) | ' ', crtat, vs.nchr - cursorat);
-	}
+	if (crtat == 0)
+		pcinit();
 
 	while (n--) {
 		if (!(c = *cp++))
>Audit-Trail:
>Unformatted: