1993-06-12 14:58:17 +00:00
|
|
|
/*
|
1993-11-09 02:32:30 +00:00
|
|
|
* spkr.c -- device driver for console speaker
|
1993-06-12 14:58:17 +00:00
|
|
|
*
|
1993-11-09 02:32:30 +00:00
|
|
|
* v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
|
|
|
|
* modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
|
1993-10-16 13:48:52 +00:00
|
|
|
*
|
1998-06-07 17:13:14 +00:00
|
|
|
* $Id: spkr.c,v 1.33 1998/02/20 13:46:55 bde Exp $
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "speaker.h"
|
|
|
|
|
|
|
|
#if NSPEAKER > 0
|
|
|
|
|
1998-01-24 02:54:56 +00:00
|
|
|
#include "opt_devfs.h"
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/uio.h>
|
1995-12-08 11:19:42 +00:00
|
|
|
#include <sys/conf.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <i386/isa/isa.h>
|
|
|
|
#include <i386/isa/timerreg.h>
|
1995-03-16 18:17:34 +00:00
|
|
|
#include <machine/clock.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <machine/speaker.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1995-09-03 05:43:50 +00:00
|
|
|
#ifdef DEVFS
|
|
|
|
#include <sys/devfsext.h>
|
1998-02-09 06:11:36 +00:00
|
|
|
static void *devfs_token;
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
#endif
|
1995-09-03 05:43:50 +00:00
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static d_open_t spkropen;
|
|
|
|
static d_close_t spkrclose;
|
|
|
|
static d_write_t spkrwrite;
|
|
|
|
static d_ioctl_t spkrioctl;
|
|
|
|
|
|
|
|
#define CDEV_MAJOR 26
|
1995-12-08 23:23:00 +00:00
|
|
|
static struct cdevsw spkr_cdevsw =
|
1995-12-08 11:19:42 +00:00
|
|
|
{ spkropen, spkrclose, noread, spkrwrite, /*26*/
|
|
|
|
spkrioctl, nostop, nullreset, nodevtotty,/* spkr */
|
|
|
|
seltrue, nommap, NULL, "spkr", NULL, -1 };
|
1995-09-03 05:43:50 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/**************** MACHINE DEPENDENT PART STARTS HERE *************************
|
|
|
|
*
|
|
|
|
* This section defines a function tone() which causes a tone of given
|
1996-10-25 14:00:47 +00:00
|
|
|
* frequency and duration from the ISA console speaker.
|
1993-06-12 14:58:17 +00:00
|
|
|
* Another function endtone() is defined to force sound off, and there is
|
|
|
|
* also a rest() entry point to do pauses.
|
|
|
|
*
|
|
|
|
* Audible sound is generated using the Programmable Interval Timer (PIT) and
|
1996-10-25 14:00:47 +00:00
|
|
|
* Programmable Peripheral Interface (PPI) attached to the ISA speaker. The
|
1993-06-12 14:58:17 +00:00
|
|
|
* PPI controls whether sound is passed through at all; the PIT's channel 2 is
|
|
|
|
* used to generate clicks (a square wave) of whatever frequency is desired.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1996-10-25 14:00:47 +00:00
|
|
|
* PPI control values.
|
|
|
|
* XXX should be in a header and used in clock.c.
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
#define PPI_SPKR 0x03 /* turn these PPI bits on to pass sound */
|
|
|
|
|
1993-11-15 01:33:11 +00:00
|
|
|
#define SPKRPRI PSOCK
|
|
|
|
static char endtone, endrest;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1995-12-15 00:54:32 +00:00
|
|
|
static void tone __P((unsigned int thz, unsigned int ticks));
|
|
|
|
static void rest __P((int ticks));
|
|
|
|
static void playinit __P((void));
|
|
|
|
static void playtone __P((int pitch, int value, int sustain));
|
|
|
|
static int abs __P((int n));
|
|
|
|
static void playstring __P((char *cp, size_t slen));
|
|
|
|
|
1993-11-15 01:33:11 +00:00
|
|
|
/* emit tone of frequency thz for given number of ticks */
|
1996-07-20 18:48:54 +00:00
|
|
|
static void
|
|
|
|
tone(thz, ticks)
|
|
|
|
unsigned int thz, ticks;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
1995-05-05 06:15:11 +00:00
|
|
|
unsigned int divisor;
|
1994-01-25 23:04:27 +00:00
|
|
|
int sps;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1995-05-05 06:15:11 +00:00
|
|
|
if (thz <= 0)
|
|
|
|
return;
|
|
|
|
|
1996-10-25 14:00:47 +00:00
|
|
|
divisor = timer_freq / thz;
|
1995-05-05 06:15:11 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
#ifdef DEBUG
|
1993-11-15 01:33:11 +00:00
|
|
|
(void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
/* set timer to generate clicks at given frequency in Hertz */
|
1996-07-20 18:48:54 +00:00
|
|
|
sps = splclock();
|
1994-04-21 14:21:50 +00:00
|
|
|
|
1996-10-25 14:00:47 +00:00
|
|
|
if (acquire_timer2(TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT)) {
|
1994-04-21 14:21:50 +00:00
|
|
|
/* enter list of waiting procs ??? */
|
1996-07-20 18:48:54 +00:00
|
|
|
splx(sps);
|
1994-04-21 14:21:50 +00:00
|
|
|
return;
|
|
|
|
}
|
1996-07-20 18:48:54 +00:00
|
|
|
splx(sps);
|
|
|
|
disable_intr();
|
1994-04-21 14:21:50 +00:00
|
|
|
outb(TIMER_CNTR2, (divisor & 0xff)); /* send lo byte */
|
|
|
|
outb(TIMER_CNTR2, (divisor >> 8)); /* send hi byte */
|
1996-07-20 18:48:54 +00:00
|
|
|
enable_intr();
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/* turn the speaker on */
|
1994-04-21 14:21:50 +00:00
|
|
|
outb(IO_PPI, inb(IO_PPI) | PPI_SPKR);
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set timeout to endtone function, then give up the timeslice.
|
|
|
|
* This is so other processes can execute while the tone is being
|
|
|
|
* emitted.
|
|
|
|
*/
|
1995-02-03 10:19:38 +00:00
|
|
|
if (ticks > 0)
|
|
|
|
tsleep((caddr_t)&endtone, SPKRPRI | PCATCH, "spkrtn", ticks);
|
1994-04-21 14:21:50 +00:00
|
|
|
outb(IO_PPI, inb(IO_PPI) & ~PPI_SPKR);
|
1996-07-20 18:48:54 +00:00
|
|
|
sps = splclock();
|
1994-04-21 14:21:50 +00:00
|
|
|
release_timer2();
|
1996-07-20 18:48:54 +00:00
|
|
|
splx(sps);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rest for given number of ticks */
|
1996-07-20 18:48:54 +00:00
|
|
|
static void
|
|
|
|
rest(ticks)
|
|
|
|
int ticks;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Set timeout to endrest function, then give up the timeslice.
|
|
|
|
* This is so other processes can execute while the rest is being
|
|
|
|
* waited out.
|
|
|
|
*/
|
|
|
|
#ifdef DEBUG
|
1993-11-09 02:32:30 +00:00
|
|
|
(void) printf("rest: %d\n", ticks);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* DEBUG */
|
1995-02-03 10:19:38 +00:00
|
|
|
if (ticks > 0)
|
|
|
|
tsleep((caddr_t)&endrest, SPKRPRI | PCATCH, "spkrrs", ticks);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************** PLAY STRING INTERPRETER BEGINS HERE **********************
|
|
|
|
*
|
|
|
|
* Play string interpretation is modelled on IBM BASIC 2.0's PLAY statement;
|
1993-11-09 02:32:30 +00:00
|
|
|
* M[LNS] are missing; the ~ synonym and the _ slur mark and the octave-
|
|
|
|
* tracking facility are added.
|
1993-06-12 14:58:17 +00:00
|
|
|
* Requires tone(), rest(), and endtone(). String play is not interruptible
|
|
|
|
* except possibly at physical block boundaries.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef int bool;
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
|
|
|
|
#define toupper(c) ((c) - ' ' * (((c) >= 'a') && ((c) <= 'z')))
|
|
|
|
#define isdigit(c) (((c) >= '0') && ((c) <= '9'))
|
|
|
|
#define dtoi(c) ((c) - '0')
|
|
|
|
|
|
|
|
static int octave; /* currently selected octave */
|
|
|
|
static int whole; /* whole-note time at current tempo, in ticks */
|
|
|
|
static int value; /* whole divisor for note time, quarter note = 1 */
|
|
|
|
static int fill; /* controls spacing of notes */
|
|
|
|
static bool octtrack; /* octave-tracking on? */
|
|
|
|
static bool octprefix; /* override current octave-tracking state? */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Magic number avoidance...
|
|
|
|
*/
|
|
|
|
#define SECS_PER_MIN 60 /* seconds per minute */
|
|
|
|
#define WHOLE_NOTE 4 /* quarter notes per whole note */
|
|
|
|
#define MIN_VALUE 64 /* the most we can divide a note by */
|
|
|
|
#define DFLT_VALUE 4 /* default value (quarter-note) */
|
|
|
|
#define FILLTIME 8 /* for articulation, break note in parts */
|
|
|
|
#define STACCATO 6 /* 6/8 = 3/4 of note is filled */
|
|
|
|
#define NORMAL 7 /* 7/8ths of note interval is filled */
|
|
|
|
#define LEGATO 8 /* all of note interval is filled */
|
|
|
|
#define DFLT_OCTAVE 4 /* default octave */
|
|
|
|
#define MIN_TEMPO 32 /* minimum tempo */
|
|
|
|
#define DFLT_TEMPO 120 /* default tempo */
|
|
|
|
#define MAX_TEMPO 255 /* max tempo */
|
|
|
|
#define NUM_MULT 3 /* numerator of dot multiplier */
|
|
|
|
#define DENOM_MULT 2 /* denominator of dot multiplier */
|
|
|
|
|
|
|
|
/* letter to half-tone: A B C D E F G */
|
|
|
|
static int notetab[8] = {9, 11, 0, 2, 4, 5, 7};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the American Standard A440 Equal-Tempered scale with frequencies
|
|
|
|
* rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook...
|
|
|
|
* our octave 0 is standard octave 2.
|
|
|
|
*/
|
|
|
|
#define OCTAVE_NOTES 12 /* semitones per octave */
|
|
|
|
static int pitchtab[] =
|
|
|
|
{
|
|
|
|
/* C C# D D# E F F# G G# A A# B*/
|
|
|
|
/* 0 */ 65, 69, 73, 78, 82, 87, 93, 98, 103, 110, 117, 123,
|
|
|
|
/* 1 */ 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247,
|
|
|
|
/* 2 */ 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
|
|
|
|
/* 3 */ 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
|
|
|
|
/* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975,
|
|
|
|
/* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951,
|
|
|
|
/* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902,
|
|
|
|
};
|
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
static void
|
|
|
|
playinit()
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
octave = DFLT_OCTAVE;
|
1993-11-15 01:33:11 +00:00
|
|
|
whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
|
1993-06-12 14:58:17 +00:00
|
|
|
fill = NORMAL;
|
|
|
|
value = DFLT_VALUE;
|
|
|
|
octtrack = FALSE;
|
|
|
|
octprefix = TRUE; /* act as though there was an initial O(n) */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* play tone of proper duration for current rhythm signature */
|
1996-07-20 18:48:54 +00:00
|
|
|
static void
|
|
|
|
playtone(pitch, value, sustain)
|
|
|
|
int pitch, value, sustain;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
register int sound, silence, snum = 1, sdenom = 1;
|
|
|
|
|
|
|
|
/* this weirdness avoids floating-point arithmetic */
|
|
|
|
for (; sustain; sustain--)
|
|
|
|
{
|
1993-11-09 02:32:30 +00:00
|
|
|
/* See the BUGS section in the man page for discussion */
|
1993-06-12 14:58:17 +00:00
|
|
|
snum *= NUM_MULT;
|
|
|
|
sdenom *= DENOM_MULT;
|
|
|
|
}
|
|
|
|
|
1995-05-05 06:15:11 +00:00
|
|
|
if (value == 0 || sdenom == 0)
|
|
|
|
return;
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
if (pitch == -1)
|
1994-01-25 23:04:27 +00:00
|
|
|
rest(whole * snum / (value * sdenom));
|
1993-06-12 14:58:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sound = (whole * snum) / (value * sdenom)
|
|
|
|
- (whole * (FILLTIME - fill)) / (value * FILLTIME);
|
|
|
|
silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1993-11-09 02:32:30 +00:00
|
|
|
(void) printf("playtone: pitch %d for %d ticks, rest for %d ticks\n",
|
1993-06-12 14:58:17 +00:00
|
|
|
pitch, sound, silence);
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
1994-01-25 23:04:27 +00:00
|
|
|
tone(pitchtab[pitch], sound);
|
1993-06-12 14:58:17 +00:00
|
|
|
if (fill != LEGATO)
|
1994-01-25 23:04:27 +00:00
|
|
|
rest(silence);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
static int
|
|
|
|
abs(n)
|
|
|
|
int n;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
if (n < 0)
|
|
|
|
return(-n);
|
|
|
|
else
|
|
|
|
return(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* interpret and play an item from a notation string */
|
1996-07-20 18:48:54 +00:00
|
|
|
static void
|
|
|
|
playstring(cp, slen)
|
|
|
|
char *cp;
|
|
|
|
size_t slen;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
1993-11-09 02:32:30 +00:00
|
|
|
int pitch, oldfill, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \
|
|
|
|
{v = v * 10 + (*++cp - '0'); slen--;}
|
|
|
|
for (; slen--; cp++)
|
|
|
|
{
|
|
|
|
int sustain, timeval, tempo;
|
|
|
|
register char c = toupper(*cp);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1993-11-09 02:32:30 +00:00
|
|
|
(void) printf("playstring: %c (%x)\n", c, c);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
|
|
|
|
|
|
|
|
/* compute pitch */
|
|
|
|
pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES;
|
|
|
|
|
|
|
|
/* this may be followed by an accidental sign */
|
|
|
|
if (cp[1] == '#' || cp[1] == '+')
|
|
|
|
{
|
|
|
|
++pitch;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
else if (cp[1] == '-')
|
|
|
|
{
|
|
|
|
--pitch;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If octave-tracking mode is on, and there has been no octave-
|
|
|
|
* setting prefix, find the version of the current letter note
|
|
|
|
* closest to the last regardless of octave.
|
|
|
|
*/
|
|
|
|
if (octtrack && !octprefix)
|
|
|
|
{
|
|
|
|
if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch))
|
|
|
|
{
|
|
|
|
++octave;
|
|
|
|
pitch += OCTAVE_NOTES;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch))
|
|
|
|
{
|
|
|
|
--octave;
|
|
|
|
pitch -= OCTAVE_NOTES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
octprefix = FALSE;
|
|
|
|
lastpitch = pitch;
|
|
|
|
|
|
|
|
/* ...which may in turn be followed by an override time value */
|
|
|
|
GETNUM(cp, timeval);
|
|
|
|
if (timeval <= 0 || timeval > MIN_VALUE)
|
|
|
|
timeval = value;
|
|
|
|
|
|
|
|
/* ...and/or sustain dots */
|
|
|
|
for (sustain = 0; cp[1] == '.'; cp++)
|
|
|
|
{
|
|
|
|
slen--;
|
|
|
|
sustain++;
|
|
|
|
}
|
|
|
|
|
1993-11-09 02:32:30 +00:00
|
|
|
/* ...and/or a slur mark */
|
|
|
|
oldfill = fill;
|
|
|
|
if (cp[1] == '_')
|
|
|
|
{
|
|
|
|
fill = LEGATO;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/* time to emit the actual tone */
|
1994-01-25 23:04:27 +00:00
|
|
|
playtone(pitch, timeval, sustain);
|
1993-11-09 02:32:30 +00:00
|
|
|
|
|
|
|
fill = oldfill;
|
1993-06-12 14:58:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'O':
|
|
|
|
if (cp[1] == 'N' || cp[1] == 'n')
|
|
|
|
{
|
|
|
|
octprefix = octtrack = FALSE;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
else if (cp[1] == 'L' || cp[1] == 'l')
|
|
|
|
{
|
|
|
|
octtrack = TRUE;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GETNUM(cp, octave);
|
1994-10-14 16:37:58 +00:00
|
|
|
if (octave >= sizeof(pitchtab) / sizeof(pitchtab[0]) / OCTAVE_NOTES)
|
1993-06-12 14:58:17 +00:00
|
|
|
octave = DFLT_OCTAVE;
|
|
|
|
octprefix = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '>':
|
1994-10-14 16:37:58 +00:00
|
|
|
if (octave < sizeof(pitchtab) / sizeof(pitchtab[0]) / OCTAVE_NOTES - 1)
|
1993-06-12 14:58:17 +00:00
|
|
|
octave++;
|
|
|
|
octprefix = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '<':
|
|
|
|
if (octave > 0)
|
|
|
|
octave--;
|
|
|
|
octprefix = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'N':
|
|
|
|
GETNUM(cp, pitch);
|
|
|
|
for (sustain = 0; cp[1] == '.'; cp++)
|
|
|
|
{
|
|
|
|
slen--;
|
|
|
|
sustain++;
|
|
|
|
}
|
1993-11-09 02:32:30 +00:00
|
|
|
oldfill = fill;
|
|
|
|
if (cp[1] == '_')
|
|
|
|
{
|
|
|
|
fill = LEGATO;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
1994-01-25 23:04:27 +00:00
|
|
|
playtone(pitch - 1, value, sustain);
|
1993-11-09 02:32:30 +00:00
|
|
|
fill = oldfill;
|
1993-06-12 14:58:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L':
|
|
|
|
GETNUM(cp, value);
|
|
|
|
if (value <= 0 || value > MIN_VALUE)
|
|
|
|
value = DFLT_VALUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'P':
|
|
|
|
case '~':
|
|
|
|
/* this may be followed by an override time value */
|
|
|
|
GETNUM(cp, timeval);
|
|
|
|
if (timeval <= 0 || timeval > MIN_VALUE)
|
|
|
|
timeval = value;
|
|
|
|
for (sustain = 0; cp[1] == '.'; cp++)
|
|
|
|
{
|
|
|
|
slen--;
|
|
|
|
sustain++;
|
|
|
|
}
|
1994-01-25 23:04:27 +00:00
|
|
|
playtone(-1, timeval, sustain);
|
1993-06-12 14:58:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'T':
|
|
|
|
GETNUM(cp, tempo);
|
|
|
|
if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
|
|
|
|
tempo = DFLT_TEMPO;
|
1993-11-15 01:33:11 +00:00
|
|
|
whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / tempo;
|
1993-06-12 14:58:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'M':
|
|
|
|
if (cp[1] == 'N' || cp[1] == 'n')
|
|
|
|
{
|
|
|
|
fill = NORMAL;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
else if (cp[1] == 'L' || cp[1] == 'l')
|
|
|
|
{
|
|
|
|
fill = LEGATO;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
else if (cp[1] == 'S' || cp[1] == 's')
|
|
|
|
{
|
|
|
|
fill = STACCATO;
|
|
|
|
++cp;
|
|
|
|
slen--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************* UNIX DRIVER HOOKS BEGIN HERE **************************
|
|
|
|
*
|
|
|
|
* This section implements driver hooks to run playstring() and the tone(),
|
|
|
|
* endtone(), and rest() functions defined above.
|
|
|
|
*/
|
|
|
|
|
1993-11-09 02:32:30 +00:00
|
|
|
static int spkr_active = FALSE; /* exclusion flag */
|
|
|
|
static struct buf *spkr_inbuf; /* incoming buf */
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
int
|
|
|
|
spkropen(dev, flags, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flags;
|
|
|
|
int fmt;
|
|
|
|
struct proc *p;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
1993-11-09 02:32:30 +00:00
|
|
|
(void) printf("spkropen: entering with dev = %x\n", dev);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
if (minor(dev) != 0)
|
|
|
|
return(ENXIO);
|
|
|
|
else if (spkr_active)
|
|
|
|
return(EBUSY);
|
|
|
|
else
|
|
|
|
{
|
1993-11-09 02:32:30 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
(void) printf("spkropen: about to perform play initialization\n");
|
|
|
|
#endif /* DEBUG */
|
1993-06-12 14:58:17 +00:00
|
|
|
playinit();
|
|
|
|
spkr_inbuf = geteblk(DEV_BSIZE);
|
1993-11-09 02:32:30 +00:00
|
|
|
spkr_active = TRUE;
|
|
|
|
return(0);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
int
|
|
|
|
spkrwrite(dev, uio, ioflag)
|
|
|
|
dev_t dev;
|
|
|
|
struct uio *uio;
|
|
|
|
int ioflag;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("spkrwrite: entering with dev = %x, count = %d\n",
|
|
|
|
dev, uio->uio_resid);
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
if (minor(dev) != 0)
|
|
|
|
return(ENXIO);
|
1996-08-24 03:24:39 +00:00
|
|
|
else if (uio->uio_resid > (DEV_BSIZE - 1)) /* prevent system crashes */
|
1993-11-09 02:32:30 +00:00
|
|
|
return(E2BIG);
|
1993-06-12 14:58:17 +00:00
|
|
|
else
|
|
|
|
{
|
1993-11-09 02:32:30 +00:00
|
|
|
unsigned n;
|
|
|
|
char *cp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
n = uio->uio_resid;
|
1997-12-02 21:07:20 +00:00
|
|
|
cp = spkr_inbuf->b_data;
|
1996-08-24 03:24:39 +00:00
|
|
|
error = uiomove(cp, n, uio);
|
|
|
|
if (!error) {
|
|
|
|
cp[n] = '\0';
|
1994-01-25 23:04:27 +00:00
|
|
|
playstring(cp, n);
|
1996-08-24 03:24:39 +00:00
|
|
|
}
|
1993-06-12 14:58:17 +00:00
|
|
|
return(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
int
|
|
|
|
spkrclose(dev, flags, fmt, p)
|
|
|
|
dev_t dev;
|
|
|
|
int flags;
|
|
|
|
int fmt;
|
|
|
|
struct proc *p;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
1993-11-09 02:32:30 +00:00
|
|
|
(void) printf("spkrclose: entering with dev = %x\n", dev);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
if (minor(dev) != 0)
|
|
|
|
return(ENXIO);
|
|
|
|
else
|
|
|
|
{
|
1993-11-15 01:33:11 +00:00
|
|
|
wakeup((caddr_t)&endtone);
|
|
|
|
wakeup((caddr_t)&endrest);
|
1993-06-12 14:58:17 +00:00
|
|
|
brelse(spkr_inbuf);
|
1993-11-09 02:32:30 +00:00
|
|
|
spkr_active = FALSE;
|
|
|
|
return(0);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
int
|
|
|
|
spkrioctl(dev, cmd, cmdarg, flags, p)
|
|
|
|
dev_t dev;
|
1998-06-07 17:13:14 +00:00
|
|
|
u_long cmd;
|
1996-07-20 18:48:54 +00:00
|
|
|
caddr_t cmdarg;
|
|
|
|
int flags;
|
|
|
|
struct proc *p;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
1993-11-09 02:32:30 +00:00
|
|
|
(void) printf("spkrioctl: entering with dev = %x, cmd = %x\n");
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
if (minor(dev) != 0)
|
|
|
|
return(ENXIO);
|
|
|
|
else if (cmd == SPKRTONE)
|
|
|
|
{
|
|
|
|
tone_t *tp = (tone_t *)cmdarg;
|
|
|
|
|
|
|
|
if (tp->frequency == 0)
|
1994-01-25 23:04:27 +00:00
|
|
|
rest(tp->duration);
|
1993-06-12 14:58:17 +00:00
|
|
|
else
|
1994-01-25 23:04:27 +00:00
|
|
|
tone(tp->frequency, tp->duration);
|
|
|
|
return 0;
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
else if (cmd == SPKRTUNE)
|
|
|
|
{
|
|
|
|
tone_t *tp = (tone_t *)(*(caddr_t *)cmdarg);
|
|
|
|
tone_t ttp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
for (; ; tp++) {
|
|
|
|
error = copyin(tp, &ttp, sizeof(tone_t));
|
|
|
|
if (error)
|
|
|
|
return(error);
|
|
|
|
if (ttp.duration == 0)
|
|
|
|
break;
|
|
|
|
if (ttp.frequency == 0)
|
1994-01-25 23:04:27 +00:00
|
|
|
rest(ttp.duration);
|
1993-06-12 14:58:17 +00:00
|
|
|
else
|
1994-01-25 23:04:27 +00:00
|
|
|
tone(ttp.frequency, ttp.duration);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1993-11-09 02:32:30 +00:00
|
|
|
return(0);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1993-11-09 02:32:30 +00:00
|
|
|
return(EINVAL);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
|
1998-02-20 13:46:58 +00:00
|
|
|
static int spkr_devsw_installed;
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
|
1996-07-20 18:48:54 +00:00
|
|
|
static void
|
|
|
|
spkr_drvinit(void *unused)
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
{
|
1995-11-29 10:49:16 +00:00
|
|
|
dev_t dev;
|
|
|
|
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
if( ! spkr_devsw_installed ) {
|
1995-12-08 11:19:42 +00:00
|
|
|
dev = makedev(CDEV_MAJOR, 0);
|
|
|
|
cdevsw_add(&dev,&spkr_cdevsw, NULL);
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
spkr_devsw_installed = 1;
|
1995-11-29 10:49:16 +00:00
|
|
|
#ifdef DEVFS
|
1996-03-27 19:07:33 +00:00
|
|
|
devfs_token = devfs_add_devswf(&spkr_cdevsw, 0, DV_CHR,
|
|
|
|
UID_ROOT, GID_WHEEL, 0600,
|
|
|
|
"speaker");
|
1995-11-29 10:49:16 +00:00
|
|
|
#endif
|
1995-11-29 14:41:20 +00:00
|
|
|
}
|
the second set of changes in a move towards getting devices to be
totally dynamic.
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:42:06 +00:00
|
|
|
}
|
1995-11-29 10:49:16 +00:00
|
|
|
|
|
|
|
SYSINIT(spkrdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,spkr_drvinit,NULL)
|
|
|
|
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif /* NSPEAKER > 0 */
|
|
|
|
/* spkr.c ends here */
|