Make sure that vs.color is always initialized. Fix PR#2510.
- separate initialization code in sput() into new function pcinit(). - call pcinit() in both sput() and pcattach() if (crtat == 0).
This commit is contained in:
parent
4839f9406b
commit
6705728ce7
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pccons.c,v 1.112 1997/10/01 20:48:59 drochner Exp $ */
|
||||
/* $NetBSD: pccons.c,v 1.113 1997/10/09 02:05:01 enami Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994, 1995 Charles Hannum. All rights reserved.
|
||||
@ -130,6 +130,7 @@ struct pc_softc {
|
||||
int pcprobe __P((struct device *, void *, void *));
|
||||
void pcattach __P((struct device *, struct device *, void *));
|
||||
int pcintr __P((void *));
|
||||
void pcinit __P((void));
|
||||
|
||||
struct cfattach pc_ca = {
|
||||
sizeof(struct pc_softc), pcprobe, pcattach
|
||||
@ -519,6 +520,9 @@ pcattach(parent, self, aux)
|
||||
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);
|
||||
|
||||
@ -883,6 +887,52 @@ pcparam(tp, t)
|
||||
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)
|
||||
@ -935,49 +985,8 @@ sput(cp, n)
|
||||
return;
|
||||
#endif
|
||||
|
||||
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++))
|
||||
|
Loading…
Reference in New Issue
Block a user