Return to BSD News archive
Newsgroups: comp.os.386bsd.development Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!uunet!emba-news.uvm.edu!wollman From: wollman@UVM.EDU (Garrett Wollman) Subject: Re: interim release. Message-ID: <1993Jul24.210540.3314@emba.uvm.edu> Sender: news@emba.uvm.edu Organization: University of Vermont, EMBA Computer Facility References: <JKH.93Jul17212255@whisker.lotus.ie> <CAEwsw.2xz@veda.is> <1993Jul21.053444.19280@cm.cf.ac.uk> Date: Sat, 24 Jul 1993 21:05:40 GMT Lines: 388 In article <1993Jul21.053444.19280@cm.cf.ac.uk> paul@myrddin.isl.cf.ac.uk (Paul) writes: >This will be a complete new tree with >all of the previous patchkit and a load more fixes applied, it should be >very stable and has all the newest utils as well. Unfortunately, this really screws people like me who have made major modifications to their kernels. (Well, it's not as much a problem for me as it used to be, but it's about to become more so...) The nice thing about the patchkit was that it could be applied to modified kernels with still some expectation of success. Right now I'm using CVS, but not everybody has the time or the disk space to set it up and get things working and merged properly. As an unrelated gift to the world, here's a patch to spkr.c to make it work somewhat better and more cooperatively in the BSD kernel structure... =================================================================== RCS file: /usr/space/CVSROOT/kernel/i386/isa/spkr.c,v retrieving revision 1.1.2.1 diff -c -r1.1.2.1 spkr.c *** 1.1.2.1 1993/07/11 05:57:17 --- spkr.c 1993/07/21 02:08:03 *************** *** 1,4 **** --- 1,5 ---- /* + * $Id: spkr.c,v 1.4 1993/07/21 02:08:17 wollman Exp $ * spkr.c -- device driver for console speaker on 80386 * * v1.1 by Eric S. Raymond (esr@snark.thyrsus.com) Feb 1990 *************** *** 11,22 **** #if NSPEAKER > 0 ! #include "param.h" #include "kernel.h" #include "errno.h" #include "buf.h" #include "uio.h" #include "spkr.h" /**************** MACHINE DEPENDENT PART STARTS HERE ************************* * --- 12,24 ---- #if NSPEAKER > 0 ! #include "systm.h" #include "kernel.h" #include "errno.h" #include "buf.h" #include "uio.h" #include "spkr.h" + #include "machine/cpufunc.h" /**************** MACHINE DEPENDENT PART STARTS HERE ************************* * *************** *** 57,75 **** */ #define TIMER_CLK 1193180L /* corresponds to 18.2 MHz tick rate */ ! static int endtone() ! /* turn off the speaker, ending current tone */ ! { ! wakeup((caddr_t)endtone); ! outb(PPI, inb(PPI) & ~PPI_SPKR); ! } ! static void tone(hz, ticks) /* emit tone of frequency hz for given number of ticks */ unsigned int hz, ticks; { unsigned int divisor = TIMER_CLK / hz; int sps; #ifdef DEBUG printf("tone: hz=%d ticks=%d\n", hz, ticks); --- 59,73 ---- */ #define TIMER_CLK 1193180L /* corresponds to 18.2 MHz tick rate */ ! static char endtone; ! static int tone(hz, ticks) /* emit tone of frequency hz for given number of ticks */ unsigned int hz, ticks; { unsigned int divisor = TIMER_CLK / hz; int sps; + int rv; #ifdef DEBUG printf("tone: hz=%d ticks=%d\n", hz, ticks); *************** *** 90,109 **** * This is so other processes can execute while the tone is being * emitted. */ ! timeout((caddr_t)endtone, (caddr_t)NULL, ticks); ! sleep((caddr_t)endtone, PZERO - 1); } ! static int endrest() ! /* end a rest */ ! { ! wakeup((caddr_t)endrest); ! } ! static void rest(ticks) /* rest for given number of ticks */ int ticks; { /* * Set timeout to endrest function, then give up the timeslice. * This is so other processes can execute while the rest is being --- 88,106 ---- * This is so other processes can execute while the tone is being * emitted. */ ! rv = tsleep((caddr_t)&endtone, (PZERO - 1) | PCATCH, "spkrio", ticks); ! outb(PPI, inb(PPI) & ~PPI_SPKR); ! /* return (rv == EWOULDBLOCK) ? 0 : rv;*/ ! return 0; } ! char endrest; ! static int rest(ticks) /* rest for given number of ticks */ int ticks; { + int rv; /* * Set timeout to endrest function, then give up the timeslice. * This is so other processes can execute while the rest is being *************** *** 112,119 **** #ifdef DEBUG printf("rest: %d\n", ticks); #endif /* DEBUG */ ! timeout((caddr_t)endrest, (caddr_t)NULL, ticks); ! sleep((caddr_t)endrest, PZERO - 1); } /**************** PLAY STRING INTERPRETER BEGINS HERE ********************** --- 109,117 ---- #ifdef DEBUG printf("rest: %d\n", ticks); #endif /* DEBUG */ ! rv = tsleep((caddr_t)&endrest, PZERO | PCATCH, "spkrio", ticks); ! /* return (rv == EWOULDBLOCK) ? 0 : rv;*/ ! return 0; } /**************** PLAY STRING INTERPRETER BEGINS HERE ********************** *************** *** 188,198 **** octprefix = TRUE; /* act as though there was an initial O(n) */ } ! static void playtone(pitch, value, sustain) /* play tone of proper duration for current rhythm signature */ int pitch, value, sustain; { register int sound, silence, snum = 1, sdenom = 1; /* this weirdness avoids floating-point arithmetic */ for (; sustain; sustain--) --- 186,197 ---- octprefix = TRUE; /* act as though there was an initial O(n) */ } ! static int playtone(pitch, value, sustain) /* play tone of proper duration for current rhythm signature */ int pitch, value, sustain; { register int sound, silence, snum = 1, sdenom = 1; + int rv; /* this weirdness avoids floating-point arithmetic */ for (; sustain; sustain--) *************** *** 214,223 **** pitch, sound, silence); #endif /* DEBUG */ ! tone(pitchtab[pitch], sound); if (fill != LEGATO) rest(silence); } } static int abs(n) --- 213,224 ---- pitch, sound, silence); #endif /* DEBUG */ ! rv = tone(pitchtab[pitch], sound); ! if(rv) return rv; if (fill != LEGATO) rest(silence); } + return 0; } static int abs(n) *************** *** 229,240 **** return(n); } ! static void playstring(cp, slen) /* interpret and play an item from a notation string */ char *cp; size_t slen; { int pitch, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE; #define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \ {v = v * 10 + (*++cp - '0'); slen--;} --- 230,242 ---- return(n); } ! static int playstring(cp, slen) /* interpret and play an item from a notation string */ char *cp; size_t slen; { int pitch, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE; + int rv; #define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \ {v = v * 10 + (*++cp - '0'); slen--;} *************** *** 303,309 **** } /* time to emit the actual tone */ ! playtone(pitch, timeval, sustain); break; case 'O': --- 305,312 ---- } /* time to emit the actual tone */ ! rv = playtone(pitch, timeval, sustain); ! if(rv) return rv; break; case 'O': *************** *** 347,353 **** slen--; sustain++; } ! playtone(pitch - 1, value, sustain); break; case 'L': --- 350,357 ---- slen--; sustain++; } ! rv = playtone(pitch - 1, value, sustain); ! if(rv) return rv; break; case 'L': *************** *** 367,373 **** slen--; sustain++; } ! playtone(-1, timeval, sustain); break; case 'T': --- 371,378 ---- slen--; sustain++; } ! rv = playtone(-1, timeval, sustain); ! if(rv) return rv; break; case 'T': *************** *** 399,404 **** --- 404,410 ---- break; } } + return 0; } /******************* UNIX DRIVER HOOKS BEGIN HERE ************************** *************** *** 450,456 **** cp = spkr_inbuf->b_un.b_addr; error = uiomove(cp, n, uio); if (!error) ! playstring(cp, n); return(error); } } --- 456,462 ---- cp = spkr_inbuf->b_un.b_addr; error = uiomove(cp, n, uio); if (!error) ! error = playstring(cp, n); return(error); } } *************** *** 466,474 **** return(ENXIO); else { ! endtone(); ! brelse(spkr_inbuf); ! spkr_active = 0; } return(0); } --- 472,480 ---- return(ENXIO); else { ! wakeup((caddr_t)&endtone); ! brelse(spkr_inbuf); ! spkr_active = 0; } return(0); } *************** *** 489,497 **** tone_t *tp = (tone_t *)cmdarg; if (tp->frequency == 0) ! rest(tp->duration); else ! tone(tp->frequency, tp->duration); } else if (cmd == SPKRTUNE) { --- 495,503 ---- tone_t *tp = (tone_t *)cmdarg; if (tp->frequency == 0) ! return rest(tp->duration); else ! return tone(tp->frequency, tp->duration); } else if (cmd == SPKRTUNE) { *************** *** 506,514 **** if (ttp.duration == 0) break; if (ttp.frequency == 0) ! rest(ttp.duration); else ! tone(ttp.frequency, ttp.duration); } } else --- 512,520 ---- if (ttp.duration == 0) break; if (ttp.frequency == 0) ! return rest(ttp.duration); else ! return tone(ttp.frequency, ttp.duration); } } else -- Garrett A. Wollman | Shashish is simple, it's discreet, it's brief. ... wollman@emba.uvm.edu | Shashish is the bonding of hearts in spite of distance. uvm-gen!wollman | It is a bond more powerful than absence. We like people UVM disagrees. | who like Shashish. - Claude McKenzie + Florent Vollant