From 86941b9bdc3cb04656cda89c03e3a06dee42859e Mon Sep 17 00:00:00 2001 From: niklas Date: Thu, 18 Apr 1996 17:48:27 +0000 Subject: [PATCH] Merge of NetBSD 960317 --- sys/arch/i386/isa/pcvt/pcvt_conf.h | 16 ++----- sys/arch/i386/isa/pcvt/pcvt_drv.c | 46 ++++++++++++------- sys/arch/i386/isa/pcvt/pcvt_ext.c | 14 +++--- sys/arch/i386/isa/pcvt/pcvt_hdr.h | 10 ++--- sys/arch/i386/isa/pcvt/pcvt_ioctl.h | 4 +- sys/arch/i386/isa/pcvt/pcvt_kbd.c | 63 +++++++++++++++----------- sys/arch/i386/isa/pcvt/pcvt_kbd.h | 4 +- sys/arch/i386/isa/pcvt/pcvt_sup.c | 69 +++++++++++------------------ sys/arch/i386/isa/pcvt/pcvt_vtf.c | 18 +------- 9 files changed, 114 insertions(+), 130 deletions(-) diff --git a/sys/arch/i386/isa/pcvt/pcvt_conf.h b/sys/arch/i386/isa/pcvt/pcvt_conf.h index 7a21fb3c8e3..54500d8155b 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_conf.h +++ b/sys/arch/i386/isa/pcvt/pcvt_conf.h @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_conf.h,v 1.3 1996/04/18 17:48:27 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -85,7 +87,7 @@ #endif #ifdef NetBSD1_1 -#define PCVT_NETBSD 110 +#define PCVT_NETBSD (110 + (NetBSD1_1 - 1)) #endif /*--------------------------------------------------------------------------- @@ -105,8 +107,6 @@ * * options "PCVT_NSCREENS=x" * options "PCVT_SCANSET=x" - * options "PCVT_UPDATEFAST=x" - * options "PCVT_UPDATESLOW=x" * options "PCVT_SYSBEEPF=x" * * which are always numeric! @@ -334,16 +334,6 @@ # define PCVT_BACKUP_FONTS 1 #endif -#ifndef PCVT_UPDATEFAST /* this is the rate at which the cursor */ -# define PCVT_UPDATEFAST (hz/10) /* gets updated with it's new position */ -#endif /* see: async_update() in pcvt_sup.c */ - -#ifndef PCVT_UPDATESLOW /* this is the rate at which the cursor */ -# define PCVT_UPDATESLOW 3 /* position display and the system load */ -#endif /* (or the keyboard scancode display) */ - /* is updated. the relation is: */ - /* PCVT_UPDATEFAST/PCVT_UPDATESLOW */ - #ifndef PCVT_SYSBEEPF /* timer chip value to be used for the */ # define PCVT_SYSBEEPF 1193182 /* sysbeep frequency value. */ #endif /* this should really go somewhere else,*/ diff --git a/sys/arch/i386/isa/pcvt/pcvt_drv.c b/sys/arch/i386/isa/pcvt/pcvt_drv.c index 9644eb909d9..671749e0ed3 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_drv.c +++ b/sys/arch/i386/isa/pcvt/pcvt_drv.c @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_drv.c,v 1.9 1996/04/18 17:48:28 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -327,7 +329,7 @@ pcattach(struct isa_device *dev) vs[i].vs_tty = &pccons[i]; #endif /* !PCVT_NETBSD && !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200) */ - async_update(UPDATE_START); /* start asynchronous updates */ + async_update(); #if PCVT_FREEBSD > 205 /* mark the device busy now if we are the console */ @@ -341,6 +343,16 @@ pcattach(struct isa_device *dev) #if PCVT_NETBSD > 101 sc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_TTY, pcintr, (void *)0, sc->sc_dev.dv_xname); + +#if PCVT_NETBSD > 110 + /* + * Look for children of the keyboard controller. + * XXX Really should decouple keyboard controller + * from the console code. + */ + while (config_found(self, NULL, NULL)) + /* will break when no more children */ ; +#endif /* PVCT_NETBSD > 110 */ #else /* PCVT_NETBSD > 100 */ vthand.ih_fun = pcrint; vthand.ih_arg = 0; @@ -947,7 +959,6 @@ extern void ttrstrt(); void pcstart(register struct tty *tp) { - register struct clist *rbp; int s, len; u_char buf[PCVT_PCBURST]; @@ -956,41 +967,42 @@ pcstart(register struct tty *tp) if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; + if (tp->t_outq.c_cc == 0 && + tp->t_wsel.si_pid == 0) + { + async_update(); + goto low; + } + tp->t_state |= TS_BUSY; splx(s); - async_update(UPDATE_KERN); - /* * We need to do this outside spl since it could be fairly * expensive and we don't want our serial ports to overflow. */ - rbp = &tp->t_outq; - - while (len = q_to_b(rbp, buf, PCVT_PCBURST)) + while (len = q_to_b(&tp->t_outq, buf, PCVT_PCBURST)) sput(&buf[0], 0, len, minor(tp->t_dev)); s = spltty(); tp->t_state &= ~TS_BUSY; - if (rbp->c_cc) - { - tp->t_state |= TS_TIMEOUT; - timeout(ttrstrt, tp, 1); - } + tp->t_state |= TS_TIMEOUT; + timeout(ttrstrt, tp, 1); #if PCVT_FREEBSD >= 210 && !defined(TS_ASLEEP) ttwakeup(tp); #else - if (rbp->c_cc <= tp->t_lowat) + if (tp->t_outq.c_cc <= tp->t_lowat) { +low: if (tp->t_state&TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; - wakeup((caddr_t)rbp); + wakeup((caddr_t)&tp->t_outq); } selwakeup(&tp->t_wsel); } @@ -1178,7 +1190,7 @@ pccnputc(Dev_t dev, U_char c) sput((char *) &c, 1, 1, 0); - async_update(UPDATE_KERN); + async_update(); #if ((PCVT_NETBSD && (PCVT_NETBSD <= 101)) || \ (PCVT_FREEBSD && (PCVT_FREEBSD <= 205))) @@ -1200,7 +1212,7 @@ pccngetc(Dev_t dev) s = spltty(); /* block pcrint while we poll */ cp = sgetc(0); splx(s); - async_update(UPDATE_KERN); + async_update(); #if ! (PCVT_FREEBSD >= 201) /* this belongs to cons.c */ @@ -1286,7 +1298,7 @@ getchar(void) sput(">", 1, 1, 0); - async_update(UPDATE_KERN); + async_update(); thechar = *(sgetc(0)); diff --git a/sys/arch/i386/isa/pcvt/pcvt_ext.c b/sys/arch/i386/isa/pcvt/pcvt_ext.c index 4b031d60b2b..1d47179b38e 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_ext.c +++ b/sys/arch/i386/isa/pcvt/pcvt_ext.c @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_ext.c,v 1.3 1996/04/18 17:48:29 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -2196,8 +2198,6 @@ switch_screen(int n, int oldgrafx, int newgrafx) if((saved_scrnsv_tmo = scrnsv_timeout)) pcvt_set_scrnsv_tmo(0); /* screensaver off */ #endif /* PCVT_SCREENSAVER */ - - async_update(UPDATE_STOP); /* status display off */ } if(!oldgrafx) @@ -2265,9 +2265,6 @@ switch_screen(int n, int oldgrafx, int newgrafx) outb(addr_6845, CRTC_CUREND); /* select low register */ outb(addr_6845+1, vsp->cursor_end); } - - /* make status display happy */ - async_update(UPDATE_START); } if(!newgrafx) @@ -2759,10 +2756,13 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if(suser(p->p_ucred, &p->p_acflag) != 0) return (EPERM); +#if (PCVT_NETBSD <= 100) || defined(COMPAT_10) || defined(COMPAT_11) + /* This is done by i386_iopl(3) now. */ #if PCVT_NETBSD || (PCVT_FREEBSD && PCVT_FREEBSD > 102) fp->tf_eflags |= PSL_IOPL; #else fp->sf_eflags |= PSL_IOPL; +#endif #endif return 0; @@ -2772,6 +2772,8 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) /* abandon IO access permission */ { +#if (PCVT_NETBSD <= 100) || defined(COMPAT_10) || defined(COMPAT_11) + /* This is done by i386_iopl(3) now. */ #if PCVT_NETBSD > 9 || PCVT_FREEBSD >= 200 struct trapframe *fp = (struct trapframe *)p->p_md.md_regs; fp->tf_eflags &= ~PSL_IOPL; @@ -2782,7 +2784,7 @@ usl_vt_ioctl(Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) struct syscframe *fp = (struct syscframe *)p->p_regs; fp->sf_eflags &= ~PSL_IOPL; #endif - +#endif return 0; } diff --git a/sys/arch/i386/isa/pcvt/pcvt_hdr.h b/sys/arch/i386/isa/pcvt/pcvt_hdr.h index b3e427ee037..0427ebabefd 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_hdr.h +++ b/sys/arch/i386/isa/pcvt/pcvt_hdr.h @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_hdr.h,v 1.6 1996/04/18 17:48:31 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -693,12 +695,6 @@ in the config file" #define SYS_FKL 0 /* in hp mode, sys-fkls are active */ #define USR_FKL 1 /* in hp mode, user-fkls are active */ -/* arguments to async_update() */ - -#define UPDATE_START 0 /* do cursor update and requeue */ -#define UPDATE_STOP 1 /* suspend cursor updates */ -#define UPDATE_KERN 2 /* do cursor updates for kernel output */ - /* variables */ #ifdef EXTERN @@ -1260,7 +1256,7 @@ void pcvt_set_scrnsv_tmo ( int ); void vga_move_charset ( unsigned n, unsigned char *b, int save_it); #endif /* XSERVER */ -void async_update ( int arg ); +void async_update ( void ); void clr_parms ( struct video_state *svsp ); void cons_highlight ( void ); void cons_normal ( void ); diff --git a/sys/arch/i386/isa/pcvt/pcvt_ioctl.h b/sys/arch/i386/isa/pcvt/pcvt_ioctl.h index a3e7d413406..932c1f908c2 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_ioctl.h +++ b/sys/arch/i386/isa/pcvt/pcvt_ioctl.h @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_ioctl.h,v 1.3 1996/04/18 17:48:32 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -427,8 +429,6 @@ struct pcvtinfo { /* compile time option values */ u_int opsysrel; /* Release */ u_int nscreens; /* PCVT_NSCREENS */ u_int scanset; /* PCVT_SCANSET */ - u_int updatefast; /* PCVT_UPDATEFAST */ - u_int updateslow; /* PCVT_UPDATESLOW */ u_int sysbeepf; /* PCVT_SYSBEEPF */ u_int pcburst; /* PCVT_PCBURST */ u_int kbd_fifo_sz; /* PCVT_KBD_FIFO_SZ */ diff --git a/sys/arch/i386/isa/pcvt/pcvt_kbd.c b/sys/arch/i386/isa/pcvt/pcvt_kbd.c index 61773c803ba..e2512494b38 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/arch/i386/isa/pcvt/pcvt_kbd.c @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_kbd.c,v 1.4 1996/04/18 17:48:33 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -268,16 +270,40 @@ settpmrate(int rate) /*---------------------------------------------------------------------------* * Pass command to keyboard controller (8042) *---------------------------------------------------------------------------*/ +static inline int +kbd_wait_output() +{ + u_int i; + + for (i = 100000; i; i--) + if ((inb(CONTROLLER_CTRL) & STATUS_INPBF) == 0) { + PCVT_KBD_DELAY(); + return 1; + } + return 0; +} + +static inline int +kbd_wait_input() +{ + u_int i; + + for (i = 100000; i; i--) + if ((inb(CONTROLLER_CTRL) & STATUS_OUTPBF) != 0) { + PCVT_KBD_DELAY(); + return 1; + } + return 0; +} + static int kbc_8042cmd(int val) { - unsigned timeo; - timeo = 100000; /* > 100 msec */ - while (inb(CONTROLLER_CTRL) & STATUS_INPBF) - if (--timeo == 0) - return (-1); + if (!kbd_wait_output()) + return (-1); outb(CONTROLLER_CTRL, val); + return (0); } @@ -287,12 +313,9 @@ kbc_8042cmd(int val) int kbd_cmd(int val) { - unsigned timeo; - timeo = 100000; /* > 100 msec */ - while (inb(CONTROLLER_CTRL) & STATUS_INPBF) - if (--timeo == 0) - return (-1); + if (!kbd_wait_output()) + return (-1); outb(CONTROLLER_DATA, val); #if PCVT_SHOWKEYS @@ -310,14 +333,9 @@ int kbd_response(void) { u_char ch; - unsigned timeo; - - timeo = 500000; /* > 500 msec (KEYB_R_SELFOK requires 87) */ - while (!(inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) - if (--timeo == 0) - return (-1); - PCVT_KBD_DELAY(); /* 7 us delay */ + if (!kbd_wait_input()) + return (-1); ch = inb(CONTROLLER_DATA); #if PCVT_SHOWKEYS @@ -336,7 +354,7 @@ kbd_setmode(int mode) #if PCVT_SCANSET > 1 /* switch only if we are running */ /* keyboard scancode 2 */ - int cmd, timeo = 10000; + int cmd; #if PCVT_USEKBDSEC cmd = COMMAND_SYSFLG | COMMAND_IRQEN; @@ -348,15 +366,8 @@ kbd_setmode(int mode) cmd |= COMMAND_PCSCAN; /* yes, setup command */ kbc_8042cmd(CONTR_WRITE); + kbc_cmd(cmd); - while (inb(CONTROLLER_CTRL) & STATUS_INPBF) - { - if (--timeo == 0) - break; - } - - outb(CONTROLLER_DATA, cmd); - #endif /* PCVT_SCANSET > 1 */ if(mode == K_RAW) diff --git a/sys/arch/i386/isa/pcvt/pcvt_kbd.h b/sys/arch/i386/isa/pcvt/pcvt_kbd.h index 2af508d6042..d0621422114 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_kbd.h +++ b/sys/arch/i386/isa/pcvt/pcvt_kbd.h @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_kbd.h,v 1.2 1996/04/18 17:48:35 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -220,7 +222,7 @@ static Keycap_def key2ascii[] = /* 6*/ KBD_ASCII, I, {S,1,C "5"}, {S,1,C "%"}, {S,1,C "5"}, DFAULT, DFAULT, DFAULT, DFAULT, /* 7*/ KBD_ASCII, I, {S,1,C "6"}, {S,1,C "^"}, {S,1,C "\036"}, DFAULT, DFAULT, DFAULT, DFAULT, /* 8*/ KBD_ASCII, I, {S,1,C "7"}, {S,1,C "&"}, {S,1,C "7"}, DFAULT, DFAULT, DFAULT, DFAULT, -/* 9*/ KBD_ASCII, I, {S,1,C "8"}, {S,1,C "*"}, {S,1,C "9"}, DFAULT, DFAULT, DFAULT, DFAULT, +/* 9*/ KBD_ASCII, I, {S,1,C "8"}, {S,1,C "*"}, {S,1,C "8"}, DFAULT, DFAULT, DFAULT, DFAULT, /* 10*/ KBD_ASCII, I, {S,1,C "9"}, {S,1,C "("}, {S,1,C "9"}, DFAULT, DFAULT, DFAULT, DFAULT, /* 11*/ KBD_ASCII, I, {S,1,C "0"}, {S,1,C ")"}, {S,1,C "0"}, DFAULT, DFAULT, DFAULT, DFAULT, /* 12*/ KBD_ASCII, I, {S,1,C "-"}, {S,1,C "_"}, {S,1,C "\037"}, DFAULT, DFAULT, DFAULT, DFAULT, diff --git a/sys/arch/i386/isa/pcvt/pcvt_sup.c b/sys/arch/i386/isa/pcvt/pcvt_sup.c index af96e7b3cc1..97c6583a1ac 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_sup.c +++ b/sys/arch/i386/isa/pcvt/pcvt_sup.c @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_sup.c,v 1.2 1996/04/18 17:48:36 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -265,8 +267,6 @@ vgapcvtinfo(struct pcvtinfo *data) data->nscreens = PCVT_NSCREENS; data->scanset = PCVT_SCANSET; - data->updatefast= PCVT_UPDATEFAST; - data->updateslow= PCVT_UPDATESLOW; data->sysbeepf = PCVT_SYSBEEPF; #if PCVT_NETBSD || PCVT_FREEBSD >= 200 @@ -865,42 +865,30 @@ vgapaletteio(unsigned idx, struct rgb *val, int writeit) * * update asynchronous: cursor, cursor pos displ, sys load, keyb scan * - * arg is: - * UPDATE_START = 0 = do update; requeue - * UPDATE_STOP = 1 = suspend updates - * UPDATE_KERN = 2 = do update for kernel printfs - * *---------------------------------------------------------------------------*/ void -async_update(int arg) +async_update() { + static int lastadr = 0; static int lastpos = 0; - static int counter = PCVT_UPDATESLOW; -#ifdef XSERVER - /* need a method to suspend the updates */ + /* first check if update is possible */ - if(arg == UPDATE_STOP) - { - untimeout((TIMEOUT_FUNC_T)async_update, UPDATE_START); + if(vsp->vt_status & VT_GRAFX) return; - } -#endif /* XSERVER */ - - /* first check if update is possible */ if(chargen_access) /* does someone load characters? */ - goto async_update_exit; /* yes, do not update anything */ + return; /* yes, do not update anything */ #if PCVT_SCREENSAVER - if(reset_screen_saver && (counter == PCVT_UPDATESLOW)) + if(reset_screen_saver) { pcvt_scrnsv_reset(); /* yes, do it */ reset_screen_saver = 0; /* re-init */ } else if(scrnsv_active) /* is the screen not blanked? */ { - goto async_update_exit; /* do not update anything */ + return; /* do not update anything */ } #endif /* PCVT_SCREENSAVER */ @@ -908,22 +896,26 @@ async_update(int arg) /* this takes place on EVERY virtual screen (if not in X mode etc...)*/ /*-------------------------------------------------------------------*/ - if ( cursor_pos_valid && - (lastpos != (vsp->Crtat + vsp->cur_offset - Crtat))) + if (cursor_pos_valid) { - lastpos = vsp->Crtat + vsp->cur_offset - Crtat; - outb(addr_6845, CRTC_CURSORH); /* high register */ - outb(addr_6845+1, ((lastpos) >> 8)); - outb(addr_6845, CRTC_CURSORL); /* low register */ - outb(addr_6845+1, (lastpos)); - } - - if (arg == UPDATE_KERN) /* Magic arg: for kernel printfs */ - return; + if (lastadr != (vsp->Crtat - Crtat)) + { + lastadr = vsp->Crtat - Crtat; + outb(addr_6845, CRTC_STARTADRH); /* high register */ + outb(addr_6845+1, ((lastadr) >> 8)); + outb(addr_6845, CRTC_STARTADRL); /* low register */ + outb(addr_6845+1, (lastadr)); + } - if(--counter) /* below is possible update */ - goto async_update_exit; /* just now and then ..... */ - counter = PCVT_UPDATESLOW; /* caution, see screensaver above !! */ + if (lastpos != (lastadr + vsp->cur_offset)) + { + lastpos = lastadr + vsp->cur_offset; + outb(addr_6845, CRTC_CURSORH); /* high register */ + outb(addr_6845+1, ((lastpos) >> 8)); + outb(addr_6845, CRTC_CURSORL); /* low register */ + outb(addr_6845+1, (lastpos)); + } + } /*-------------------------------------------------------------------*/ /* this takes place ONLY on screen 0 if in HP mode, labels on, !X */ @@ -1054,13 +1046,6 @@ async_update(int arg) *(p + LABEL_ROWH) = (user_attr | (((vsp->row+1)/10) + '0')); *(p + LABEL_ROWL) = (user_attr | (((vsp->row+1)%10) + '0')); } - -async_update_exit: - - if(arg == UPDATE_START) - { - timeout((TIMEOUT_FUNC_T)async_update, UPDATE_START, PCVT_UPDATEFAST); - } } /*---------------------------------------------------------------------------* diff --git a/sys/arch/i386/isa/pcvt/pcvt_vtf.c b/sys/arch/i386/isa/pcvt/pcvt_vtf.c index 25c8c18240f..6e2056de9d8 100644 --- a/sys/arch/i386/isa/pcvt/pcvt_vtf.c +++ b/sys/arch/i386/isa/pcvt/pcvt_vtf.c @@ -1,3 +1,5 @@ +/* $OpenBSD: pcvt_vtf.c,v 1.2 1996/04/18 17:48:37 niklas Exp $ */ + /* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * @@ -2009,14 +2011,6 @@ roll_up(struct video_state *svsp, int n) { svsp->Crtat += n * svsp->maxcol; } - - if(vsp == svsp && !(vsp->vt_status & VT_GRAFX)) - { - outb(addr_6845, CRTC_STARTADRH); - outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8); - outb(addr_6845, CRTC_STARTADRL); - outb(addr_6845+1, (svsp->Crtat - Crtat)); - } } else #endif @@ -2071,14 +2065,6 @@ roll_down(struct video_state *svsp, int n) { svsp->Crtat -= n * svsp->maxcol; } - - if(vsp == svsp && !(vsp->vt_status & VT_GRAFX)) - { - outb(addr_6845, CRTC_STARTADRH); - outb(addr_6845+1, (svsp->Crtat - Crtat) >> 8); - outb(addr_6845, CRTC_STARTADRL); - outb(addr_6845+1, (svsp->Crtat - Crtat)); - } } else #endif -- 2.20.1