aboutsummaryrefslogtreecommitdiff
path: root/sys/i386/isa/pccons.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386/isa/pccons.c')
-rw-r--r--sys/i386/isa/pccons.c163
1 files changed, 124 insertions, 39 deletions
diff --git a/sys/i386/isa/pccons.c b/sys/i386/isa/pccons.c
index ca474030f0f5..43fba38b1552 100644
--- a/sys/i386/isa/pccons.c
+++ b/sys/i386/isa/pccons.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)pccons.c 5.11 (Berkeley) 5/21/91
- * $Id: pccons.c,v 1.6 1993/10/16 12:50:22 rgrimes Exp $
+ * $Id: pccons.c,v 1.13.2.1 1994/05/04 05:09:30 rgrimes Exp $
*/
/*
@@ -97,15 +97,13 @@ static struct video_state {
char color; /* color or mono display */
} vs;
-int pcprobe(), pcattach();
+static int pcprobe(struct isa_device *);
+static int pcattach(struct isa_device *);
struct isa_driver pcdriver = {
pcprobe, pcattach, "pc",
};
-/* block cursor so wfj does not go blind on laptop hunting for
- the verdamnt cursor -wfj */
-#define FAT_CURSOR
#define COL 80
#define ROW 25
@@ -118,7 +116,7 @@ struct isa_driver pcdriver = {
static unsigned int addr_6845 = MONO_BASE;
u_short *Crtat = (u_short *)MONO_BUF;
-static openf;
+static int openf;
char *sgetc(int);
static char *more_chars;
@@ -133,12 +131,15 @@ static int char_count;
#define CN_TIMERVAL (hz) /* frequency at which to check cons */
#define CN_TIMO (2*60) /* intervals to allow for output char */
-int pcstart();
-int pcparam();
-int ttrstrt();
-char partab[];
+void pcstart(struct tty *);
+int pcparam(struct tty *, struct termios *);
+extern char partab[];
+static void cursor(caddr_t, int);
+static void sput(int /*u_char*/, int /*u_char*/);
+static void pc_xmode_on(void);
+static void pc_xmode_off(void);
-extern pcopen(dev_t, int, int, struct proc *);
+int pcopen(int /*dev_t*/, int, int, struct proc *);
/*
* Wait for CP to accept last CP command sent
* before setting up next command.
@@ -201,8 +202,9 @@ int kbd_response()
/*
* these are both bad jokes
*/
+int
pcprobe(dev)
-struct isa_device *dev;
+ struct isa_device *dev;
{
int again = 0;
int response;
@@ -258,8 +260,9 @@ struct isa_device *dev;
return (IO_KBDSIZE);
}
+int
pcattach(dev)
-struct isa_device *dev;
+ struct isa_device *dev;
{
u_short *cp = Crtat + (CGA_BUF-MONO_BUF)/CHR;
u_short was;
@@ -267,12 +270,14 @@ struct isa_device *dev;
if (vs.color == 0)
printf("pc%d: type monochrome\n",dev->id_unit);
else printf("pc%d: type color\n",dev->id_unit);
- cursor(0);
+ cursor(0, 0);
+ return 0;
}
/* ARGSUSED */
+int
#ifdef __STDC__
-pcopen(dev_t dev, int flag, int mode, struct proc *p)
+pcopen(int /*dev_t*/ dev, int flag, int mode, struct proc *p)
#else
pcopen(dev, flag, mode, p)
dev_t dev;
@@ -302,9 +307,10 @@ pcopen(dev, flag, mode, p)
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0)
return (EBUSY);
tp->t_state |= TS_CARR_ON;
- return ((*linesw[tp->t_line].l_open)(dev, tp));
+ return ((*linesw[tp->t_line].l_open)(dev, tp, 0));
}
+int
pcclose(dev, flag, mode, p)
dev_t dev;
int flag, mode;
@@ -316,17 +322,21 @@ pcclose(dev, flag, mode, p)
}
/*ARGSUSED*/
+int
pcread(dev, uio, flag)
dev_t dev;
struct uio *uio;
+ int flag;
{
return ((*linesw[pccons.t_line].l_read)(&pccons, uio, flag));
}
/*ARGSUSED*/
+int
pcwrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
+ int flag;
{
return ((*linesw[pccons.t_line].l_write)(&pccons, uio, flag));
}
@@ -336,8 +346,11 @@ pcwrite(dev, uio, flag)
* the console processor wants to give us a character.
* Catch the character, and see who it goes to.
*/
+void
pcrint(dev, irq, cpl)
dev_t dev;
+ int irq; /* XXX ??? */
+ int cpl;
{
int c;
char *cp;
@@ -369,9 +382,12 @@ pcrint(dev, irq, cpl)
#define CONSOLE_X_BELL _IOW('t',123,int[2])
#endif /* XSERVER */
+int
pcioctl(dev, cmd, data, flag)
dev_t dev;
+ int cmd;
caddr_t data;
+ int flag;
{
register struct tty *tp = &pccons;
register error;
@@ -411,6 +427,7 @@ int pcconsintr = 1;
* Got a console transmission interrupt -
* the console processor wants another character.
*/
+void
pcxint(dev)
dev_t dev;
{
@@ -427,6 +444,7 @@ pcxint(dev)
pcstart(&pccons);
}
+void
pcstart(tp)
register struct tty *tp;
{
@@ -460,6 +478,7 @@ out:
splx(s);
}
+void
pccnprobe(cp)
struct consdev *cp;
{
@@ -477,6 +496,7 @@ pccnprobe(cp)
}
/* ARGSUSED */
+void
pccninit(cp)
struct consdev *cp;
{
@@ -489,6 +509,7 @@ pccninit(cp)
static __color;
/* ARGSUSED */
+void
pccnputc(dev, c)
dev_t dev;
char c;
@@ -501,6 +522,7 @@ pccnputc(dev, c)
/*
* Print a character on console.
*/
+void
pcputchar(c, tp)
char c;
register struct tty *tp;
@@ -511,6 +533,7 @@ pcputchar(c, tp)
/* ARGSUSED */
+int
pccngetc(dev)
dev_t dev;
{
@@ -529,6 +552,7 @@ pccngetc(dev)
return (*cp);
}
+int
pcgetchar(tp)
register struct tty *tp;
{
@@ -546,6 +570,7 @@ pcgetchar(tp)
/*
* Set line parameters
*/
+int
pcparam(tp, t)
register struct tty *tp;
register struct termios *t;
@@ -580,8 +605,10 @@ pcpoll(onoff)
static u_short *crtat = 0;
-cursor(int a)
-{ int pos = crtat - Crtat;
+static void
+cursor(caddr_t rock, int arg2)
+{
+ int pos = crtat - Crtat;
#ifdef XSERVER /* 15 Aug 92*/
if (!pc_xmode) {
@@ -595,8 +622,8 @@ cursor(int a)
outb(addr_6845+1, 0);
outb(addr_6845, 11);
outb(addr_6845+1, 18);
-#endif FAT_CURSOR
- if (a == 0)
+#endif /* FAT_CURSOR */
+ if (rock == 0)
timeout(cursor, 0, hz/10);
#ifdef XSERVER /* 15 Aug 92*/
}
@@ -618,13 +645,29 @@ static char bgansitopc[] =
{ BG_BLACK, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE,
BG_MAGENTA, BG_CYAN, BG_LIGHTGREY};
+static void move_up(u_short *s, u_short *d, u_int len)
+{
+ s += len;
+ d += len;
+ while (len-- > 0)
+ *--d = *--s;
+}
+
+
+static void move_down(u_short *s, u_short *d, u_int len)
+{
+ while (len-- > 0)
+ *d++ = *s++;
+}
+
/*
* sput has support for emulation of the 'pc3' termcap entry.
* if ka, use kernel attributes.
*/
+static void
sput(c, ka)
-u_char c;
-u_char ka;
+ u_char c;
+ u_char ka;
{
int sc = 1; /* do scroll check */
@@ -679,7 +722,8 @@ u_char ka;
}
vs.kern_bg_at = BG_BLACK;
- fillw(((vs.bg_at|vs.fg_at)<<8)|' ', crtat, COL*ROW-cursorat);
+ fillw(((vs.bg_at|vs.fg_at)<<8)|' ', crtat,
+ COL*ROW-cursorat);
}
/* which attributes do we use? */
@@ -725,7 +769,9 @@ u_char ka;
if (vs.esc) {
if (vs.ebrac) {
switch(c) {
- int pos;
+ int pos, posy, count;
+ u_short *src, *dst;
+
case 'm':
if (!vs.cx) vs.so = 0;
else vs.so = 1;
@@ -823,18 +869,51 @@ u_char ka;
break;
case 'S': /* scroll up cx lines */
if (vs.cx <= 0) vs.cx = 1;
+ posy = (crtat - Crtat) / vs.ncol;
+ if (vs.cx > posy)
+ vs.cx = posy;
bcopy(Crtat+vs.ncol*vs.cx, Crtat, vs.ncol*(vs.nrow-vs.cx)*CHR);
- fillw((at <<8)+' ', Crtat+vs.ncol*(vs.nrow-vs.cx), vs.ncol*vs.cx);
- /* crtat -= vs.ncol*vs.cx; /* XXX */
+ fillw((at <<8)+' ',
+ (Crtat + vs.ncol * (vs.nrow - vs.cx)),
+ vs.ncol * vs.cx);
+ /* crtat -= vs.ncol*vs.cx;*/ /* XXX */
vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
break;
case 'T': /* scroll down cx lines */
if (vs.cx <= 0) vs.cx = 1;
+ posy = (crtat - Crtat) / vs.ncol;
+ if (vs.cx > vs.nrow - posy)
+ vs.cx = vs.nrow - posy;
bcopy(Crtat, Crtat+vs.ncol*vs.cx, vs.ncol*(vs.nrow-vs.cx)*CHR);
fillw((at <<8)+' ', Crtat, vs.ncol*vs.cx);
- /* crtat += vs.ncol*vs.cx; /* XXX */
+ /* crtat += vs.ncol*vs.cx;*/ /* XXX */
+ vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
+ break;
+ case 'L': /* Insert cx lines */
+ if (vs.cx <= 0) vs.cx = 1;
+ posy = (crtat - Crtat) / vs.ncol;
+ if (vs.cx > vs.nrow - posy)
+ vs.cx = vs.nrow - posy;
+ src = Crtat + posy * vs.ncol;
+ dst = src + vs.cx * vs.ncol;
+ count = vs.nrow - (posy + vs.cx);
+ move_up(src, dst, count * vs.ncol);
+ fillw((at <<8)+' ', src, vs.cx * vs.ncol);
vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
break;
+ case 'M': /* Delete cx lines */
+ if (vs.cx <= 0) vs.cx = 1;
+ posy = (crtat - Crtat) / vs.ncol;
+ if (vs.cx > vs.nrow - posy)
+ vs.cx = vs.nrow - posy;
+ dst = Crtat + posy * vs.ncol;
+ src = dst + vs.cx * vs.ncol;
+ count = vs.nrow - (posy + vs.cx);
+ move_down(src, dst, count * vs.ncol);
+ src = dst + count * vs.ncol;
+ fillw((at <<8)+' ', src, vs.cx * vs.ncol);
+ vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
+ break;
case ';': /* Switch params in cursor def */
vs.eparm = 1;
break;
@@ -926,7 +1005,7 @@ u_char ka;
crtat -= vs.ncol;
}
if (ka)
- cursor(1);
+ cursor((caddr_t)1, 0);
}
@@ -1352,7 +1431,7 @@ static Scan_def scan_codes[] =
};
-
+void
update_led()
{
int response;
@@ -1393,7 +1472,9 @@ update_led()
* noblock == 0 wait until a key is gotten. Otherwise return a
* if no characters are present 0.
*/
-char *sgetc(noblock)
+char *
+sgetc(noblock)
+ int noblock;
{
u_char dt;
unsigned key;
@@ -1482,7 +1563,7 @@ loop:
* Check for cntl-alt-esc
*/
if ((dt == 1) && ctrl_down && alt_down) {
- Debugger();
+ Debugger("manual escape to debugger");
dt |= 0x80; /* discard esc (ddb discarded ctrl-alt) */
}
#endif
@@ -1626,6 +1707,7 @@ loop:
#define del 0177
#define cntld 4
+int
getchar()
{
char thechar;
@@ -1694,6 +1776,7 @@ dprintf(flgs, fmt /*, va_alist */)
__color = 0;
}
+void
consinit() {}
/* -hv- 22-Apr-93: to make init_main more portable */
@@ -1723,30 +1806,32 @@ int pcmmap(dev_t dev, int offset, int nprot)
#include "machine/psl.h"
#include "machine/frame.h"
-pc_xmode_on ()
+static void
+pc_xmode_on (void)
{
- struct syscframe *fp;
+ struct trapframe *fp;
if (pc_xmode)
return;
pc_xmode = 1;
- fp = (struct syscframe *)curproc->p_regs;
- fp->sf_eflags |= PSL_IOPL;
+ fp = (struct trapframe *)curproc->p_regs;
+ fp->tf_eflags |= PSL_IOPL;
}
+static void
pc_xmode_off ()
{
- struct syscframe *fp;
+ struct trapframe *fp;
if (pc_xmode == 0)
return;
pc_xmode = 0;
- cursor(0);
+ cursor(0, 0);
- fp = (struct syscframe *)curproc->p_regs;
- fp->sf_eflags &= ~PSL_IOPL;
+ fp = (struct trapframe *)curproc->p_regs;
+ fp->tf_eflags &= ~PSL_IOPL;
}
#endif /* XSERVER*/