From 8dfab1b8fdd700cfd416fbc2813272e44bf0709d Mon Sep 17 00:00:00 2001 From: William Nesheim Date: Fri, 10 May 1991 03:36:04 -0800 Subject: [PATCH] interim version, changes for net2 tape SCCS-vsn: sys/i386/isa/clock.c 5.5 SCCS-vsn: sys/i386/isa/fd.c 5.5 SCCS-vsn: sys/i386/isa/fdreg.h 1.2 SCCS-vsn: sys/i386/isa/isa.c 1.5 SCCS-vsn: sys/i386/isa/isa.h 5.7 SCCS-vsn: sys/i386/isa/npx.c 1.4 SCCS-vsn: sys/i386/isa/rtc.h 1.2 SCCS-vsn: sys/i386/isa/wt.c 1.4 SCCS-vsn: sys/i386/isa/wtreg.h 1.2 SCCS-vsn: sys/i386/isa/pccons.c 5.7 --- usr/src/sys/i386/isa/clock.c | 106 ++++++++++++---- usr/src/sys/i386/isa/fd.c | 31 ++--- usr/src/sys/i386/isa/fdreg.h | 2 +- usr/src/sys/i386/isa/isa.c | 7 +- usr/src/sys/i386/isa/isa.h | 16 +-- usr/src/sys/i386/isa/npx.c | 71 +++++++---- usr/src/sys/i386/isa/pccons.c | 226 ++++++++++++++++++++-------------- usr/src/sys/i386/isa/rtc.h | 34 ++++- usr/src/sys/i386/isa/wt.c | 64 +++++----- usr/src/sys/i386/isa/wtreg.h | 2 +- 10 files changed, 361 insertions(+), 198 deletions(-) diff --git a/usr/src/sys/i386/isa/clock.c b/usr/src/sys/i386/isa/clock.c index fa140324d0..c541886ba7 100644 --- a/usr/src/sys/i386/isa/clock.c +++ b/usr/src/sys/i386/isa/clock.c @@ -9,7 +9,7 @@ * * %sccs.include.386.c% * - * @(#)clock.c 5.4 (Berkeley) %G% + * @(#)clock.c 5.5 (Berkeley) %G% */ /* @@ -19,20 +19,61 @@ #include "time.h" #include "kernel.h" #include "machine/segments.h" -#include "machine/isa/icu.h" -#include "machine/isa/isa.h" +#include "i386/isa/icu.h" +#include "i386/isa/isa.h" +#include "i386/isa/rtc.h" #define DAYST 119 #define DAYEN 303 startrtclock() { + int s; /* initialize 8253 clock */ outb (IO_TIMER1+3, 0x36); outb (IO_TIMER1, 1193182/hz); outb (IO_TIMER1, (1193182/hz)/256); + +#ifdef notdef + /* NMI fail safe 1/4 sec */ + /* initialize 8253 clock */ + outb(0x461,0); + outb (IO_TIMER2+3, 0x30); + outb (IO_TIMER2, 298300*40); + outb (IO_TIMER2, (298300*40)/256); + outb(0x461,4); +printf("armed "); +#endif + + /* initialize brain-dead battery powered clock */ + outb (IO_RTC, RTC_STATUSA); + outb (IO_RTC+1, 0x26); + outb (IO_RTC, RTC_STATUSB); + outb (IO_RTC+1, 2); + + /*outb (IO_RTC, RTC_STATUSD); + if((inb(IO_RTC+1) & 0x80) == 0) + printf("rtc lost power\n"); + outb (IO_RTC, RTC_STATUSD); + outb (IO_RTC+1, 0x80);*/ + + outb (IO_RTC, RTC_DIAG); + if (s = inb (IO_RTC+1)) + printf("RTC BIOS diagnostic error %b\n", s, RTCDG_BITS); + outb (IO_RTC, RTC_DIAG); + outb (IO_RTC+1, 0); } +#ifdef ARGOx +reprimefailsafe(){ + outb(0x461,0); + outb (IO_TIMER2+3, 0x30); + outb (IO_TIMER2, 298300*40); + outb (IO_TIMER2, (298300*40)/256); + outb(0x461,4); +} +#endif + /* convert 2 digit BCD number */ bcd(i) int i; @@ -50,8 +91,8 @@ int y; ret = 0; y = y - 70; for(i=0;i= DAYST) && ( yd <= DAYEN)) { - sec -= 3600; + sec -= 60*60; } +#endif sec += tz.tz_minuteswest * 60; time.tv_sec = sec; @@ -136,16 +190,26 @@ test_inittodr(base) } #endif +#ifdef notdef /* * retreve a value from realtime clock */ u_char rtcin(n) { u_char val; + /*outb(IO_RTC, RTC_STATUSA); + do val = inb(IO_RTC+1) ; while (val&0x80);*/ + outb(IO_RTC,n); + DELAY(100); + if (inb(IO_RTC) != n) { + outb(IO_RTC,n); + DELAY(100); + } do val = inb(IO_RTC+1) ; while (val != inb(IO_RTC+1)); return (val); } +#endif /* * Restart the clock. @@ -154,7 +218,7 @@ resettodr() { } -#define V(s) V/**/s +#define V(s) __CONCAT(V, s) extern V(clk)(); enablertclock() { INTREN(IRQ0); diff --git a/usr/src/sys/i386/isa/fd.c b/usr/src/sys/i386/isa/fd.c index cec6aae5bd..2bb8a0b617 100644 --- a/usr/src/sys/i386/isa/fd.c +++ b/usr/src/sys/i386/isa/fd.c @@ -9,7 +9,7 @@ * * %sccs.include.386.c% * - * @(#)fd.c 5.4 (Berkeley) %G% + * @(#)fd.c 5.5 (Berkeley) %G% */ /****************************************************************************/ @@ -20,17 +20,13 @@ #include "systm.h" #include "conf.h" #include "file.h" -#include "dir.h" -#include "user.h" #include "ioctl.h" #include "disk.h" #include "buf.h" -#include "vm.h" #include "uio.h" -#include "machine/pte.h" -#include "machine/isa/isa_device.h" -#include "machine/isa/fdreg.h" -#include "icu.h" +#include "i386/isa/isa_device.h" +#include "i386/isa/fdreg.h" +#include "i386/isa/icu.h" #define FDUNIT(s) ((s)&1) #define FDTYPE(s) (((s)>>1)&7) @@ -273,7 +269,7 @@ check_fdc() /****************************************************************************/ /* fdopen/fdclose */ /****************************************************************************/ -fdopen(dev, flags) +Fdopen(dev, flags) dev_t dev; int flags; { @@ -292,7 +288,7 @@ fdopen(dev, flags) return 0; } -fdclose(dev) +fdclose(dev, flags) dev_t dev; { } @@ -362,7 +358,7 @@ printf("Seek %d %d\n", bp->b_cylin, dp->b_step); out_fdc(15); /* Seek function */ out_fdc(unit); /* Drive number */ out_fdc(bp->b_cylin * dp->b_step); - } else fdintr(0); + } else fdintr(0xff); } splx(s); } @@ -392,8 +388,7 @@ int x; /****************************************************************************/ /* fdintr */ /****************************************************************************/ -fdintr(vec) -int vec; +fdintr(unit) { register struct buf *dp,*bp; struct buf *dpother; @@ -402,7 +397,7 @@ int vec; struct fd_type *ft; #ifdef FDTEST - printf("state %d, vec %d, dr %d|",fd_state,vec,fd_drive); + printf("state %d, unit %d, dr %d|",fd_state,unit,fd_drive); #endif dp = &fd_unit[fd_drive].head; @@ -413,7 +408,7 @@ int vec; switch (fd_state) { case 1 : /* SEEK DONE, START DMA */ /* Make sure seek really happened*/ - if (vec) { + if (unit != 0xff) { out_fdc(0x8); i = in_fdc(); cyl = in_fdc(); @@ -504,7 +499,7 @@ printf("Seek|"); out_fdc(fd_drive);/* Drive number */ out_fdc(bp->b_cylin * dp->b_step); break; - } else fdintr(0); + } else fdintr(0xff); } break; case 3: @@ -561,7 +556,7 @@ retry: case 4: fd_retry++; fd_state = 5; - fdintr(0); + fdintr(0xff); return; case 5: case 6: case 7: break; @@ -574,7 +569,7 @@ retry: } fd_state = 1; fd_retry++; - fdintr(0); + fdintr(0xff); } badtrans(dp,bp) diff --git a/usr/src/sys/i386/isa/fdreg.h b/usr/src/sys/i386/isa/fdreg.h index 6855959d67..14e06174cd 100644 --- a/usr/src/sys/i386/isa/fdreg.h +++ b/usr/src/sys/i386/isa/fdreg.h @@ -1,6 +1,6 @@ /* * AT floppy controller registers and bitfields - * @(#)fdreg.h 1.1 (Berkeley) %G% + * @(#)fdreg.h 1.2 (Berkeley) %G% */ /* uses NEC765 controller */ diff --git a/usr/src/sys/i386/isa/isa.c b/usr/src/sys/i386/isa/isa.c index 7715e8823c..504be83e59 100644 --- a/usr/src/sys/i386/isa/isa.c +++ b/usr/src/sys/i386/isa/isa.c @@ -7,7 +7,7 @@ * * %sccs.include.redist% * - * @(#)isa.c 1.4 (Berkeley) %G% + * @(#)isa.c 1.5 (Berkeley) %G% */ /* @@ -18,7 +18,6 @@ #include "systm.h" #include "conf.h" #include "file.h" -#include "user.h" #include "buf.h" #include "uio.h" #include "syslog.h" @@ -87,7 +86,7 @@ config_isadev(isdp, mp) } else return(0); } -#define IDTVEC(name) X/**/name +#define IDTVEC(name) __CONCAT(X,name) /* default interrupt vector table */ extern IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3), IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7), @@ -186,7 +185,7 @@ int nbytes; if (raw) phys = (unsigned long) bounce; else phys = addr; /* translate to physical */ - phys = phys - sbase; + phys = pmap_extract(pmap_kernel(), (vm_offset_t)phys); outb(0x4,phys & 0xFF); outb(0x4,(phys>>8) & 0xFF); outb(0x81,(phys>>16) & 0xFF); diff --git a/usr/src/sys/i386/isa/isa.h b/usr/src/sys/i386/isa/isa.h index 836a8dc1dd..494141186a 100644 --- a/usr/src/sys/i386/isa/isa.h +++ b/usr/src/sys/i386/isa/isa.h @@ -5,9 +5,9 @@ * This code is derived from software contributed to Berkeley by * William Jolitz. * - * %sccs.include.noredist.c% + * %sccs.include.redist.c% * - * @(#)isa.h 5.6 (Berkeley) %G% + * @(#)isa.h 5.7 (Berkeley) %G% */ /* @@ -83,8 +83,9 @@ void outb(); */ #ifndef IOM_BEGIN -#define IOM_BEGIN 0xa0000 /* Start of I/O Memory "hole" */ -#define IOM_END 0xFFFFF /* End of I/O Memory "hole" */ +#define IOM_BEGIN 0x0a0000 /* Start of I/O Memory "hole" */ +#define IOM_END 0x100000 /* End of I/O Memory "hole" */ +#define IOM_SIZE (IOM_END - IOM_BEGIN) #endif IOM_BEGIN /* @@ -92,9 +93,10 @@ void outb(); */ #ifndef RAM_BEGIN -#define RAM_BEGIN 0x000000 /* Start of RAM Memory */ -#define RAM_END 0xFFFFFF /* End of RAM Memory */ -#endif IOM_BEGIN +#define RAM_BEGIN 0x0000000 /* Start of RAM Memory */ +#define RAM_END 0x1000000 /* End of RAM Memory */ +#define RAM_SIZE (RAM_END - RAM_BEGIN) +#endif RAM_BEGIN /* * Oddball Physical Memory Addresses diff --git a/usr/src/sys/i386/isa/npx.c b/usr/src/sys/i386/isa/npx.c index 3c817ae23c..dde98012da 100644 --- a/usr/src/sys/i386/isa/npx.c +++ b/usr/src/sys/i386/isa/npx.c @@ -1,6 +1,6 @@ /* * Copyright (c) 1990 W. Jolitz - * @(#)npx.c 1.3 (Berkeley) %G% + * @(#)npx.c 1.4 (Berkeley) %G% */ #include "npx.h" #if NNPX > 0 @@ -9,12 +9,12 @@ #include "systm.h" #include "conf.h" #include "file.h" -#include "dir.h" -#include "user.h" -#include "ioctl.h" -#include "vm.h" +#include "proc.h" +#include "machine/pcb.h" #include "machine/pte.h" -#include "machine/isa/isa_device.h" +#include "ioctl.h" +#include "machine/specialreg.h" +#include "i386/isa/isa_device.h" #include "icu.h" /* * 387 and 287 Numeric Coprocessor Extension (NPX) Driver. @@ -25,9 +25,11 @@ struct isa_driver npxdriver = { npxprobe, npxattach, "npx", }; -struct proc *npxproc; /* process who owns device, otherwise zero */ +static struct proc *npxproc; /* process who owns device, otherwise zero */ extern struct user npxutl; /* owners user structure */ extern struct pte Npxmap[]; /* kernel ptes mapping owner's user structure */ +static npxexists; +extern long npx0mask; /* * Probe routine - look device, otherwise set emulator bit @@ -74,6 +76,8 @@ npxattach(dvp) npxinit(0x262); /* check for ET bit to decide 387/287 */ /*outb(0xb1,0); /* reset processor */ + npxexists++; + npx0mask = dvp->id_irq; } /* @@ -81,20 +85,35 @@ npxattach(dvp) */ npxinit(control) { - asm (" fninit"); + if (npxexists == 0) return; + + + load_cr0(rcr0() & ~CR0_EM); /* stop emulating */ +#ifdef INTEL_COMPAT + asm (" finit"); asm(" fldcw %0" : : "g" (control)); + asm(" fnsave %0 " : : "g" + (((struct pcb *)curproc->p_addr)->pcb_savefpu) ); +#else + asm("fninit"); + asm("fnsave %0" : : "g" + (((struct pcb *)curproc->p_addr)->pcb_savefpu) ); +#endif + load_cr0(rcr0() | CR0_EM); /* start emulating */ } +#ifdef notyet /* * Load floating point context and record ownership to suite */ npxload() { if (npxproc) panic ("npxload"); - npxproc = u.u_procp; + npxproc = curproc; uaccess(npxproc, Npxmap, &npxutl); - asm(" frstor %0 " : : "g" (u.u_pcb.pcb_savefpu) ); + asm(" frstor %0 " : : "g" + (((struct pcb *)curproc->p_addr)->pcb_savefpu) ); } /* @@ -107,14 +126,19 @@ npxunload() { npxproc = 0 ; } +#endif /* * Record information needed in processing an exception and clear status word */ -npxexcept() { +npxintr() { + + outb(0xf0,0); /* reset processor */ /* save state in appropriate user structure */ - if (npxproc == 0) panic ("npxexcept"); - asm (" fsave %0 " : : "g" (npxutl.u_pcb.pcb_savefpu) ); + if (npxproc == 0 || npxexists == 0) panic ("npxintr"); +#ifdef notyet + asm (" fnsave %0 " : : "g" (npxutl.u_pcb.pcb_savefpu) ); +#endif /* * encode the appropriate u_code for detailed information @@ -128,17 +152,22 @@ npxexcept() { asm (" fnclex"); } -/* - * Catch AT/386 interrupt used to signal exception, and simulate trap() - */ -npxintr() { - outb(0xf0,0); - pg("npxintr"); -} - /* * Implement device not available (DNA) exception */ npxdna() { + + if (npxexists == 0) return(0); + if (!(((struct pcb *) curproc->p_addr)->pcb_flags & FP_WASUSED) + ||(((struct pcb *) curproc->p_addr)->pcb_flags & FP_NEEDSRESTORE)) { + load_cr0(rcr0() & ~CR0_EM); /* stop emulating */ + asm(" frstor %0 " : : "g" (((struct pcb *) curproc->p_addr)->pcb_savefpu) ); + ((struct pcb *) curproc->p_addr)->pcb_flags |= FP_WASUSED | FP_NEEDSSAVE; + ((struct pcb *) curproc->p_addr)->pcb_flags &= ~FP_NEEDSRESTORE; + npxproc = curproc; + + return(1); + } + return (0); } #endif diff --git a/usr/src/sys/i386/isa/pccons.c b/usr/src/sys/i386/isa/pccons.c index 848b5b38d0..8cdd8a871f 100644 --- a/usr/src/sys/i386/isa/pccons.c +++ b/usr/src/sys/i386/isa/pccons.c @@ -5,11 +5,9 @@ * This code is derived from software contributed to Berkeley by * William Jolitz. * - * Added support for ibmpc term type and improved keyboard support. -Don Ahn + * %sccs.include.redist.c% * - * %sccs.include.386.c% - * - * @(#)pccons.c 5.6 (Berkeley) %G% + * @(#)pccons.c 5.7 (Berkeley) %G% */ /* @@ -17,18 +15,17 @@ */ #include "param.h" #include "conf.h" -#include "dir.h" #include "ioctl.h" -#include "user.h" #include "proc.h" +#include "user.h" #include "tty.h" #include "uio.h" -#include "machine/isa/isa_device.h" +#include "i386/isa/isa_device.h" #include "callout.h" #include "systm.h" #include "kernel.h" #include "syslog.h" -#include "icu.h" +#include "i386/isa/icu.h" struct tty cons; @@ -51,41 +48,20 @@ struct isa_driver cndriver = { #define ROW 25 #define CHR 2 #define MONO_BASE 0x3B4 -#define MONO_BUF 0xB0000 +#define MONO_BUF 0xfe0B0000 #define CGA_BASE 0x3D4 -#define CGA_BUF 0xB8000 +#define CGA_BUF 0xfe0B8000 #define IOPHYSMEM 0xA0000 u_char color = 0xe ; static unsigned int addr_6845 = MONO_BASE; u_short *Crtat = (u_short *)MONO_BUF; - -/* - * We check the console periodically to make sure - * that it hasn't wedged. Unfortunately, if an XOFF - * is typed on the console, that can't be distinguished - * from more catastrophic failure. - */ -#define CN_TIMERVAL (hz) /* frequency at which to check cons */ -#define CN_TIMO (2*60) /* intervals to allow for output char */ +static openf; int cnstart(); +int cnparam(); int ttrstrt(); char partab[]; - -/* - * Wait for CP to accept last CP command sent - * before setting up next command. - */ -#define waitforlast(timo) { \ - if (cnlast) { \ - (timo) = 10000; \ - do \ - uncache((char *)&cnlast->cp_unit); \ - while ((cnlast->cp_unit&CPTAKE) == 0 && --(timo)); \ - } \ -} - u_char inb(); cnprobe(dev) @@ -110,7 +86,7 @@ struct isa_device *dev; } } /* pick up keyboard reset return code */ - while((c=inb(0x60))!=0xAA)nullop(); + while((c=inb(0x60))!=0xAA); return 1; } @@ -131,50 +107,64 @@ struct isa_device *dev; printf(""); else printf(""); *Crtat = was; + cursor(); } -/*ARGSUSED*/ -cnopen(dev, flag) +/* ARGSUSED */ +#ifdef __STDC__ +cnopen(dev_t dev, int flag, int mode, struct proc *p) +#else +cnopen(dev, flag, mode, p) dev_t dev; + int flag, mode; + struct proc *p; +#endif { register struct tty *tp; - int unit = minor(dev); tp = &cons; - if (tp->t_state&TS_XCLUDE && u.u_uid != 0) - return (EBUSY); tp->t_oproc = cnstart; - if ((tp->t_state&TS_ISOPEN) == 0) { + tp->t_param = cnparam; + tp->t_dev = dev; + openf++; + if ((tp->t_state & TS_ISOPEN) == 0) { + tp->t_state |= TS_WOPEN; ttychars(tp); - tp->t_state = TS_ISOPEN|TS_CARR_ON; - tp->t_flags = EVENP|ECHO|XTABS|CRMOD; - splnone(); - } + tp->t_iflag = TTYDEF_IFLAG; + tp->t_oflag = TTYDEF_OFLAG; + tp->t_cflag = TTYDEF_CFLAG; + tp->t_lflag = TTYDEF_LFLAG; + tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + cnparam(tp, &tp->t_termios); + ttsetwater(tp); + } 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)); } - -cnclose(dev) +cnclose(dev, flag) dev_t dev; { (*linesw[cons.t_line].l_close)(&cons); ttyclose(&cons); + return(0); } /*ARGSUSED*/ -cnread(dev, uio) +cnread(dev, uio, flag) dev_t dev; struct uio *uio; { - return ((*linesw[cons.t_line].l_read)(&cons, uio)); + return ((*linesw[cons.t_line].l_read)(&cons, uio, flag)); } /*ARGSUSED*/ -cnwrite(dev, uio) +cnwrite(dev, uio, flag) dev_t dev; struct uio *uio; { - return ((*linesw[cons.t_line].l_write)(&cons, uio)); + return ((*linesw[cons.t_line].l_write)(&cons, uio, flag)); } /* @@ -198,24 +188,23 @@ cnrint(dev, irq, cpl) (*linesw[cons.t_line].l_rint)(c&0xff, &cons); } -cnioctl(dev, cmd, addr, flag) +cnioctl(dev, cmd, data, flag) dev_t dev; - caddr_t addr; + caddr_t data; { register struct tty *tp = &cons; register error; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr); + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag); + if (error >= 0) + return (error); + error = ttioctl(tp, cmd, data, flag); if (error >= 0) - return error; - if ((error = ttioctl(tp, cmd, addr, flag)) < 0) - error = ENOTTY; - else if (cmd == TIOCSETP || cmd == TIOCSETN) - cnparams(tp); - return (error); + return (error); + return (ENOTTY); } -int consintr = 1; +extern int consintr ; /* * Got a console transmission interrupt - * the console processor wants another character. @@ -244,7 +233,8 @@ cnstart(tp) s = spltty(); if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) goto out; - if (tp->t_outq.c_cc <= TTLOWAT(tp)) { + do { + if (tp->t_outq.c_cc <= tp->t_lowat) { if (tp->t_state&TS_ASLEEP) { tp->t_state &= ~TS_ASLEEP; wakeup((caddr_t)&tp->t_outq); @@ -255,31 +245,28 @@ cnstart(tp) tp->t_state &= ~TS_WCOLL; } } - while (tp->t_outq.c_cc != 0) { - c = getc(&tp->t_outq) & 0xff; - if ((tp->t_flags & (RAW|LITOUT)) == 0) { - if (c > 0177) - { - timeout(ttrstrt, (caddr_t)tp, (c&0177)); - tp->t_state |= TS_TIMEOUT; - break; - } - c &= 0177; - } - splx(s); - sput(c,0x7); - s = spltty(); - } + if (tp->t_outq.c_cc == 0) + goto out; + c = getc(&tp->t_outq); + splx(s); + sput(c,0x7); + s = spltty(); + } while(1); out: splx(s); } +static __color; + cnputc(c) char c; -{ +{ int clr; + clr = __color; + if (clr == 0) clr = 0x30; + else clr |= 0x60; if (c == '\n') - sput('\r',0x3); - sput(c, 0x3); + sput('\r',clr); + sput(c, clr); } /* @@ -317,9 +304,17 @@ cngetchar(tp) /* * Set line parameters */ -cnparams(tp) +cnparam(tp, t) register struct tty *tp; + register struct termios *t; { + register int cflag = t->c_cflag; + /* and copy to tty */ + tp->t_ispeed = t->c_ispeed; + tp->t_ospeed = t->c_ospeed; + tp->t_cflag = cflag; + + return(0); } #ifdef KDB @@ -334,14 +329,17 @@ cnpoll(onoff) extern int hz; +static beeping; sysbeepstop() { /* disable counter 2 */ outb(0x61,inb(0x61)&0xFC); + beeping = 0; } sysbeep() { + /* enable counter 2 */ outb(0x61,inb(0x61)|3); /* set command for counter 2, 2 byte write */ @@ -349,7 +347,8 @@ sysbeep() /* send 0x637 for 750 HZ */ outb(0x42,0x37); outb(0x42,0x06); - timeout(sysbeepstop,0,hz/4); + if(!beeping)timeout(sysbeepstop,0,hz/4); + beeping = 1; } /* cursor() sets an offset (0-1999) into the 80x25 text area */ @@ -365,8 +364,16 @@ cursor() outb(addr_6845+1,pos >> 8); outb(addr_6845,15); outb(addr_6845+1,pos&0xff); + timeout(cursor,0,hz/10); } +u_char shfts, ctls, alts, caps, num, stp, scroll; + +/* + * Compensate for abysmally stupid frame buffer aribitration with macro + */ +#define wrtchar(c) { do *crtat = (c); while ((c) != *crtat); crtat++; row++; } + /* sput has support for emulation of the 'ibmpc' termcap entry. */ /* This is a bare-bones implementation of a bare-bones entry */ /* One modification: Change li#24 to li#25 to reflect 25 lines */ @@ -411,8 +418,8 @@ u_char c, ca; case '\t': do { - *crtat++ = (ca<<8)| ' '; row++ ; - } while (row %8); + wrtchar((ca<<8)| ' '); + } while (row % 8); break; case '\010': @@ -455,7 +462,8 @@ u_char c, ca; esc = 0; ebrac = 0; eparm = 0; break; case 'K': /* Clear to EOL */ - fillw((bg_at<<8)+' ', crtat, COL-row); + fillw((bg_at<<8)+' ', crtat, + COL-(crtat-Crtat)%COL); esc = 0; ebrac = 0; eparm = 0; break; case 'H': /* Cursor move */ @@ -496,16 +504,14 @@ u_char c, ca; esc = 0; ebrac = 0; eparm = 0; } } else { - if (c == 7) { + if (c == 7) sysbeep(); - } /* Print only printables */ else /*if (c >= ' ') */ { - while(inb(0x3da)&1)nullop(); if (so) { - *crtat++ = (so_at<<8)| c; row++ ; + wrtchar((so_at<<8)| c); } else { - *crtat++ = (ca<<8)| c; row++ ; + wrtchar((ca<<8)| c); } if (row >= COL) row = 0; break ; @@ -513,13 +519,13 @@ u_char c, ca; } } if (crtat >= Crtat+COL*(ROW)) { /* scroll check */ + if (openf) do sgetc(1); while (scroll); bcopy(Crtat+COL,Crtat,COL*(ROW-1)*CHR); - fillw ((bg_at<<8)+' ', Crtat+COL*(ROW-1),COL) ; + fillw ((bg_at<<8) + ' ', Crtat+COL*(ROW-1),COL) ; crtat -= COL ; } } - #define L 0x0001 /* locking function */ #define SHF 0x0002 /* keyboard shift */ #define ALT 0x0004 /* alternate shift -- alternate chars */ @@ -531,7 +537,7 @@ u_char c, ca; #define FUNC 0x0100 /* function key */ #define SCROLL 0x0200 /* scroll lock key */ -unsigned __debug = 0; +unsigned __debug = 0xffe; u_short action[] = { 0, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, /* scan 0- 7 */ ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, /* scan 8-15 */ @@ -541,7 +547,7 @@ ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, /* scan 32-39 */ ASCII, ASCII, SHF , ASCII, ASCII, ASCII, ASCII, ASCII, /* scan 40-47 */ ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, SHF, ASCII, /* scan 48-55 */ ALT, ASCII, CPS , FUNC , FUNC , FUNC , FUNC , FUNC , /* scan 56-63 */ -FUNC , FUNC , FUNC , FUNC , FUNC , NUM, STP, ASCII, /* scan 64-71 */ +FUNC , FUNC , FUNC , FUNC , FUNC , NUM, SCROLL, ASCII, /* scan 64-71 */ ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, /* scan 72-79 */ ASCII, ASCII, ASCII, ASCII, 0, 0, 0, 0, /* scan 80-87 */ 0,0,0,0,0,0,0,0, @@ -609,7 +615,6 @@ struct key { }; #endif -u_char shfts, ctls, alts, caps, num, stp, scroll; #define KBSTAT 0x64 /* kbd status port */ #define KBS_INP_BUF_FUL 0x02 /* kbd char ready */ @@ -740,3 +745,36 @@ getchar() } /*}*/ } + +#include "machine/dbg.h" +#include "machine/stdarg.h" +static nrow; + +void +#ifdef __STDC__ +dprintf(unsigned flgs, const char *fmt, ...) +#else +dprintf(flgs, fmt /*, va_alist */) + char *fmt; + unsigned flgs; +#endif +{ extern unsigned __debug; + va_list ap; + + if((flgs&__debug) > DPAUSE) { + __color = ffs(flgs&__debug)+1; + va_start(ap,fmt); + kprintf(fmt, 1, (struct tty *)0, ap); + va_end(ap); + if (flgs&DPAUSE || nrow%24 == 23) { + int x; + x = splhigh(); + if (nrow%24 == 23) nrow = 0; + sgetc(0); + splx(x); + } + } + __color = 0; +} + +consinit() {} diff --git a/usr/src/sys/i386/isa/rtc.h b/usr/src/sys/i386/isa/rtc.h index f6c6c46852..9e163ee252 100644 --- a/usr/src/sys/i386/isa/rtc.h +++ b/usr/src/sys/i386/isa/rtc.h @@ -1,5 +1,16 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * %sccs.include.redist.c% + * + * @(#)rtc.h 1.2 (Berkeley) %G% + */ + /* - * @(#)rtc.h 1.1 (Berkeley) %G% * RTC Register locations */ @@ -14,8 +25,29 @@ #define RTC_MONTH 0x08 /* month of year */ #define RTC_YEAR 0x09 /* month of year */ #define RTC_STATUSA 0x0a /* status register A */ +#define RTCSA_TUP 0x80 /* time update, don't look now */ + +#define RTC_STATUSB 0x0b /* status register B */ + +#define RTC_INTR 0x0c /* status register C (R) interrupt source */ +#define RTCIR_UPDATE 0x10 /* update intr */ +#define RTCIR_ALARM 0x20 /* alarm intr */ +#define RTCIR_PERIOD 0x40 /* periodic intr */ +#define RTCIR_INT 0x80 /* interrupt output signal */ + +#define RTC_STATUSD 0x0d /* status register D (R) Lost Power */ +#define RTCSD_PWR 0x80 /* clock lost power */ + +#define RTC_DIAG 0x0e /* status register E - bios diagnostic */ +#define RTCDG_BITS "\020\010clock battery\007ROM cksum\006config unit\005memory size\004fixed disk\003invalid time" + +#define RTC_RESET 0x0f /* status register F - reset code byte */ +#define RTCRS_RST 0x00 /* normal reset */ +#define RTCRS_LOAD 0x04 /* load system */ #define RTC_BASELO 0x15 /* low byte of basemem size */ #define RTC_BASEHI 0x16 /* high byte of basemem size */ #define RTC_EXTLO 0x17 /* low byte of extended mem size */ #define RTC_EXTHI 0x18 /* low byte of extended mem size */ + +#define RTC_CENTURY 0x32 /* current century - please increment in Dec99*/ diff --git a/usr/src/sys/i386/isa/wt.c b/usr/src/sys/i386/isa/wt.c index 30de876972..4540473e7b 100644 --- a/usr/src/sys/i386/isa/wt.c +++ b/usr/src/sys/i386/isa/wt.c @@ -5,7 +5,7 @@ * Copyright (c) 1989 Carnegie-Mellon University * All rights reserved. The CMU software License Agreement specifies * the terms and conditions for use and redistribution. - * @(#)wt.c 1.3 (Berkeley) %G% + * @(#)wt.c 1.4 (Berkeley) 1/18/91 */ /* * HISTORY @@ -35,16 +35,15 @@ * Support Bell Tech QIC-02 and WANGTEK QIC-36 or QIC-02 */ -#include +/*#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include */ +#include "sys/param.h" +#include "sys/buf.h" +#include "sys/file.h" +#include "sys/proc.h" +#include "sys/user.h" +#include "i386/isa/wtreg.h" #ifdef ORC unsigned wtport = 0x288; /* base I/O port of controller */ @@ -173,7 +172,6 @@ char isrlock; /* isr() flag */ struct proc * Hogproc; /* no Hogproc on Microport */ #define ftoseg(x) ((unsigned) (x >> 16)) -#define seterror(err) u.u_error = err struct wtstatus { ushort wt_err; /* code for error encountered */ @@ -242,6 +240,7 @@ register struct buf *bp; { unsigned ucnt1, ucnt2, finished; unsigned long adr1, adr2; + int bad; adr1 = kvtop(bp->b_un.b_addr); #ifdef DEBUG @@ -273,7 +272,7 @@ register struct buf *bp; Hogproc = myproc; } if (bp->b_flags & B_READ) { - int bad = 0; + bad = 0; /* For now, we assume that all data will be copied out */ /* If read command outstanding, just skip down */ @@ -358,10 +357,11 @@ errxit: bp->b_flags |= B_ERROR; /* All writes and/or copyins were fine! */ else finished = bp->b_bcount; - pollrdy(); + bad = pollrdy(); } endio: + if(bad == EIO) bad = 0; wterror.wt_err = 0; if (exflag && wtsense((bp->b_flags & B_READ) ? TP_WRP : 0)) { if ((wterror.wt_err & TP_ST0) @@ -385,6 +385,10 @@ errxit: bp->b_flags |= B_ERROR; } } + if(bad) { + bp->b_flags |= B_ERROR; + bp->b_error = bad; + } bp->b_resid = bp->b_bcount - finished; xit: biodone(bp); @@ -440,7 +444,6 @@ wtread(dev, uio) struct uio *uio; { if (wtflags & TPSESS) { - seterror(EIO); return(EIO); } physio(wtrawio, &rwtbuf, dev, B_READ, wt_minphys, uio); @@ -454,7 +457,6 @@ wtwrite(dev, uio) struct uio *uio; { if (wtflags & TPSESS) { - seterror(EIO); return(EIO); } physio(wtrawio, &rwtbuf, dev, B_WRITE, wt_minphys, uio); @@ -477,11 +479,11 @@ int mode; if ((qicmd((int)arg) == ERROR) || (rdyexc(HZ) == ERROR)) { wtsense(0); - seterror(EIO); + return(EIO); } - return; + return(0); } - seterror(EINVAL); + return(EINVAL); } /* @@ -499,15 +501,12 @@ int dev, flag; printf("wtopen ...\n"); #endif if (!pageaddr) { - nodev(); return(ENXIO); } if (wtflags & (TPINUSE)) { - seterror(ENXIO); return(ENXIO); } if (wtflags & (TPDEAD)) { - seterror(EIO); return(EIO); } /* If a rewind from the last session is going on, wait */ @@ -521,14 +520,12 @@ int dev, flag; * This allows multiple volumes. */ if (wtflags & TPSTART) { if (t_reset() != SUCCESS) { - nodev(); return(ENXIO); } #ifdef DEBUG debug("reset done. calling wtsense\n"); #endif if (wtsense(TP_WRP) == ERROR) { - seterror(EIO); return (EIO); } #ifdef DEBUG @@ -543,7 +540,7 @@ int dev, flag; if (flag & FWRITE) wtflags |= TPWRITE; rwtbuf.b_flags = 0; - myproc = u.u_procp; /* for comparison */ + myproc = curproc; /* for comparison */ switch(TP_DENS(dev)) { case 0: cmds(0x28); @@ -737,7 +734,7 @@ wtwind() { rwind(); /* actually start rewind */ } -wtintr(vec) { +wtintr(unit) { if (wtflags & (TPWO|TPRO)) { isrlock = 1; @@ -791,13 +788,20 @@ pollrdy() debug("Pollrdy\n"); #endif sps = splbio(); - while (wtio) - sleep(&wci, WTPRI); + while (wtio) { + int error; + + if (error = tsleep((caddr_t)&wci, WTPRI | PCATCH, + "wtpoll", 0)) { + splx(sps); + return(error); + } + } splx(sps); #ifdef DEBUG debug("Finish poll, wci %d exflag %d\n", wci, exflag); #endif - return exflag; + return (EIO); } wtdma() /* start up i/o operation, called from dma() in wtlib1.s */ @@ -1109,8 +1113,8 @@ wtdump() { } -#include "machine/isa/isa_device.h" -#include "machine/isa/icu.h" +#include "i386/isa/isa_device.h" +#include "i386/isa/icu.h" int wtprobe(), wtattach(); struct isa_driver wtdriver = { diff --git a/usr/src/sys/i386/isa/wtreg.h b/usr/src/sys/i386/isa/wtreg.h index 71be3da85f..efaa879c27 100644 --- a/usr/src/sys/i386/isa/wtreg.h +++ b/usr/src/sys/i386/isa/wtreg.h @@ -3,7 +3,7 @@ * Copyright (c) 1989 Carnegie-Mellon University * All rights reserved. The CMU software License Agreement specifies * the terms and conditions for use and redistribution. - * @(#)wtreg.h 1.1 (Berkeley) %G% + * @(#)wtreg.h 1.1 (Berkeley) 11/8/90 */ /* * HISTORY -- 2.20.1