1994-04-21 14:16:55 +00:00
|
|
|
|
/*-
|
|
|
|
|
* Copyright (c) 1994 S<EFBFBD>ren Schmidt
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1994-09-29 08:24:45 +00:00
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
|
* in this position and unchanged.
|
1994-04-21 14:16:55 +00:00
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software withough specific prior written permission
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*
|
1997-09-03 19:08:05 +00:00
|
|
|
|
* $Id: pcaudio.c,v 1.34 1997/02/22 09:36:58 peter Exp $
|
1994-04-21 14:16:55 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "pca.h"
|
|
|
|
|
#if NPCA > 0
|
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <sys/param.h>
|
1994-08-22 11:11:05 +00:00
|
|
|
|
#include <sys/systm.h>
|
1995-11-16 09:56:02 +00:00
|
|
|
|
#include <sys/conf.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <sys/uio.h>
|
1996-10-25 16:09:31 +00:00
|
|
|
|
#include <sys/fcntl.h>
|
1994-09-29 08:24:45 +00:00
|
|
|
|
#include <sys/proc.h>
|
1995-12-08 11:19:42 +00:00
|
|
|
|
#include <sys/kernel.h>
|
1997-09-03 19:08:05 +00:00
|
|
|
|
#include <sys/filio.h>
|
1994-11-06 00:46:21 +00:00
|
|
|
|
|
|
|
|
|
#include <machine/clock.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <machine/pcaudioio.h>
|
1994-11-06 00:46:21 +00:00
|
|
|
|
|
1994-08-13 03:50:34 +00:00
|
|
|
|
#include <i386/isa/isa.h>
|
|
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
|
#include <i386/isa/timerreg.h>
|
1994-11-06 00:46:21 +00:00
|
|
|
|
|
1996-09-13 06:29:30 +00:00
|
|
|
|
#define DSP_ULAW_NOT_WANTED
|
1994-08-22 11:11:05 +00:00
|
|
|
|
#include <i386/isa/sound/ulaw.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
|
|
1995-11-30 05:59:09 +00:00
|
|
|
|
#ifdef DEVFS
|
|
|
|
|
#include <sys/devfsext.h>
|
|
|
|
|
#endif /* DEVFS */
|
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
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
#define BUF_SIZE 8192
|
|
|
|
|
#define SAMPLE_RATE 8000
|
|
|
|
|
#define INTERRUPT_RATE 16000
|
|
|
|
|
|
|
|
|
|
static struct pca_status {
|
|
|
|
|
char open; /* device open */
|
|
|
|
|
char queries; /* did others try opening */
|
1997-09-03 19:08:05 +00:00
|
|
|
|
unsigned char *buf[3]; /* triple buffering */
|
1994-04-21 14:16:55 +00:00
|
|
|
|
unsigned char *buffer; /* current buffer ptr */
|
1997-09-03 19:08:05 +00:00
|
|
|
|
unsigned in_use[3]; /* buffers fill */
|
1994-04-21 14:16:55 +00:00
|
|
|
|
unsigned index; /* index in current buffer */
|
|
|
|
|
unsigned counter; /* sample counter */
|
|
|
|
|
unsigned scale; /* sample counter scale */
|
|
|
|
|
unsigned sample_rate; /* sample rate */
|
|
|
|
|
unsigned processed; /* samples processed */
|
|
|
|
|
unsigned volume; /* volume for pc-speaker */
|
|
|
|
|
char encoding; /* Ulaw, Alaw or linear */
|
|
|
|
|
char current; /* current buffer */
|
|
|
|
|
unsigned char oldval; /* old timer port value */
|
|
|
|
|
char timer_on; /* is playback running */
|
1994-09-29 21:11:29 +00:00
|
|
|
|
struct selinfo wsel; /* select status */
|
1997-09-03 19:08:05 +00:00
|
|
|
|
char non_block; /* set non-block on write status */
|
1994-04-21 14:16:55 +00:00
|
|
|
|
} pca_status;
|
|
|
|
|
|
|
|
|
|
static char buffer1[BUF_SIZE];
|
|
|
|
|
static char buffer2[BUF_SIZE];
|
1997-09-03 19:08:05 +00:00
|
|
|
|
static char buffer3[BUF_SIZE];
|
1994-04-21 14:16:55 +00:00
|
|
|
|
static char volume_table[256];
|
|
|
|
|
|
1996-03-28 14:29:52 +00:00
|
|
|
|
#ifdef DEVFS
|
1995-12-08 11:19:42 +00:00
|
|
|
|
static void *pca_devfs_token;
|
|
|
|
|
static void *pcac_devfs_token;
|
1996-03-28 14:29:52 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
static int pca_sleep = 0;
|
|
|
|
|
static int pca_initialized = 0;
|
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static void pcaintr(struct clockframe *frame);
|
1995-12-10 13:40:44 +00:00
|
|
|
|
static int pcaprobe(struct isa_device *dvp);
|
|
|
|
|
static int pcaattach(struct isa_device *dvp);
|
1994-04-21 14:16:55 +00:00
|
|
|
|
|
|
|
|
|
struct isa_driver pcadriver = {
|
|
|
|
|
pcaprobe, pcaattach, "pca",
|
|
|
|
|
};
|
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
|
static d_open_t pcaopen;
|
|
|
|
|
static d_close_t pcaclose;
|
|
|
|
|
static d_write_t pcawrite;
|
|
|
|
|
static d_ioctl_t pcaioctl;
|
|
|
|
|
static d_select_t pcaselect;
|
|
|
|
|
|
|
|
|
|
#define CDEV_MAJOR 24
|
1995-12-08 23:23:00 +00:00
|
|
|
|
static struct cdevsw pca_cdevsw =
|
1995-12-08 11:19:42 +00:00
|
|
|
|
{ pcaopen, pcaclose, noread, pcawrite, /*24*/
|
|
|
|
|
pcaioctl, nostop, nullreset, nodevtotty,/* pcaudio */
|
|
|
|
|
pcaselect, nommap, NULL, "pca", NULL, -1 };
|
|
|
|
|
|
1995-12-15 00:54:32 +00:00
|
|
|
|
static void pca_continue __P((void));
|
|
|
|
|
static void pca_init __P((void));
|
|
|
|
|
static void pca_pause __P((void));
|
1994-04-21 14:16:55 +00:00
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static inline void
|
|
|
|
|
conv(const void *table, void *buff, unsigned long n)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
1994-05-02 09:40:12 +00:00
|
|
|
|
__asm__("1:\tmovb (%2), %3\n"
|
|
|
|
|
"\txlatb\n"
|
|
|
|
|
"\tmovb %3, (%2)\n"
|
|
|
|
|
"\tinc %2\n"
|
|
|
|
|
"\tdec %1\n"
|
|
|
|
|
"\tjnz 1b\n"
|
1994-04-21 14:16:55 +00:00
|
|
|
|
:
|
1994-05-02 09:40:12 +00:00
|
|
|
|
:"b" ((long)table), "c" (n), "D" ((long)buff), "a" ((char)n)
|
|
|
|
|
:"bx","cx","di","ax");
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
|
static void
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_volume(int volume)
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
for (i=0; i<256; i++) {
|
1997-09-03 19:08:05 +00:00
|
|
|
|
j = ((i-128)*volume)/25;
|
|
|
|
|
/* XXX
|
1994-05-02 09:40:12 +00:00
|
|
|
|
j = ((i-128)*volume)/100;
|
1997-09-03 19:08:05 +00:00
|
|
|
|
*/
|
1994-04-21 14:16:55 +00:00
|
|
|
|
if (j<-128)
|
|
|
|
|
j = -128;
|
|
|
|
|
if (j>127)
|
|
|
|
|
j = 127;
|
|
|
|
|
volume_table[i] = (((255-(j + 128))/4)+1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
1996-10-25 16:09:31 +00:00
|
|
|
|
pca_init(void)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
|
|
|
|
pca_status.open = 0;
|
|
|
|
|
pca_status.queries = 0;
|
|
|
|
|
pca_status.timer_on = 0;
|
|
|
|
|
pca_status.buf[0] = (unsigned char *)&buffer1[0];
|
|
|
|
|
pca_status.buf[1] = (unsigned char *)&buffer2[0];
|
1997-09-03 19:08:05 +00:00
|
|
|
|
pca_status.buf[2] = (unsigned char *)&buffer3[0];
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.buffer = pca_status.buf[0];
|
1997-09-03 19:08:05 +00:00
|
|
|
|
pca_status.in_use[0] = pca_status.in_use[1] = pca_status.in_use[3] = 0;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.current = 0;
|
|
|
|
|
pca_status.sample_rate = SAMPLE_RATE;
|
|
|
|
|
pca_status.scale = (pca_status.sample_rate << 8) / INTERRUPT_RATE;
|
|
|
|
|
pca_status.encoding = AUDIO_ENCODING_ULAW;
|
|
|
|
|
pca_status.volume = 100;
|
|
|
|
|
|
|
|
|
|
pca_volume(pca_status.volume);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
|
static int
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_start(void)
|
|
|
|
|
{
|
1996-06-09 14:23:13 +00:00
|
|
|
|
int x = splhigh();
|
|
|
|
|
int rv = 0;
|
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
/* use the first buffer */
|
|
|
|
|
pca_status.current = 0;
|
|
|
|
|
pca_status.index = 0;
|
|
|
|
|
pca_status.counter = 0;
|
|
|
|
|
pca_status.buffer = pca_status.buf[pca_status.current];
|
1994-05-02 09:40:12 +00:00
|
|
|
|
pca_status.oldval = inb(IO_PPI) | 0x03;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
/* acquire the timers */
|
1996-06-09 14:23:13 +00:00
|
|
|
|
if (acquire_timer2(TIMER_LSB|TIMER_ONESHOT))
|
|
|
|
|
rv = -1;
|
|
|
|
|
else if (acquire_timer0(INTERRUPT_RATE, pcaintr)) {
|
1994-04-21 14:16:55 +00:00
|
|
|
|
release_timer2();
|
1996-06-09 14:23:13 +00:00
|
|
|
|
rv = -1;
|
|
|
|
|
} else
|
|
|
|
|
pca_status.timer_on = 1;
|
|
|
|
|
|
|
|
|
|
splx(x);
|
|
|
|
|
return rv;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
|
static void
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_stop(void)
|
|
|
|
|
{
|
1996-06-09 14:23:13 +00:00
|
|
|
|
int x = splhigh();
|
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
/* release the timers */
|
|
|
|
|
release_timer0();
|
|
|
|
|
release_timer2();
|
|
|
|
|
/* reset the buffer */
|
1997-09-03 19:08:05 +00:00
|
|
|
|
pca_status.in_use[0] = pca_status.in_use[1] = pca_status.in_use[2] = 0;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
pca_status.index = 0;
|
|
|
|
|
pca_status.counter = 0;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.current = 0;
|
|
|
|
|
pca_status.buffer = pca_status.buf[pca_status.current];
|
|
|
|
|
pca_status.timer_on = 0;
|
1996-06-09 14:23:13 +00:00
|
|
|
|
splx(x);
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
|
static void
|
1996-10-25 16:09:31 +00:00
|
|
|
|
pca_pause(void)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
1996-06-09 14:23:13 +00:00
|
|
|
|
int x = splhigh();
|
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
release_timer0();
|
1995-05-30 08:16:23 +00:00
|
|
|
|
release_timer2();
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.timer_on = 0;
|
1996-06-09 14:23:13 +00:00
|
|
|
|
splx(x);
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
|
static void
|
1996-10-25 16:09:31 +00:00
|
|
|
|
pca_continue(void)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
1996-06-09 14:23:13 +00:00
|
|
|
|
int x = splhigh();
|
|
|
|
|
|
1994-05-02 09:40:12 +00:00
|
|
|
|
pca_status.oldval = inb(IO_PPI) | 0x03;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
acquire_timer2(TIMER_LSB|TIMER_ONESHOT);
|
|
|
|
|
acquire_timer0(INTERRUPT_RATE, pcaintr);
|
|
|
|
|
pca_status.timer_on = 1;
|
1996-06-09 14:23:13 +00:00
|
|
|
|
splx(x);
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-11-06 00:46:21 +00:00
|
|
|
|
static int
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_wait(void)
|
|
|
|
|
{
|
1996-06-09 14:23:13 +00:00
|
|
|
|
int error, x;
|
|
|
|
|
|
|
|
|
|
if (!pca_status.timer_on)
|
|
|
|
|
return 0;
|
1994-11-06 00:46:21 +00:00
|
|
|
|
|
1997-09-03 19:08:05 +00:00
|
|
|
|
while (pca_status.in_use[0] || pca_status.in_use[1] || pca_status.in_use[2]) {
|
1996-06-09 14:23:13 +00:00
|
|
|
|
x = spltty();
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_sleep = 1;
|
1994-11-06 00:46:21 +00:00
|
|
|
|
error = tsleep(&pca_sleep, PZERO|PCATCH, "pca_drain", 0);
|
|
|
|
|
pca_sleep = 0;
|
1996-06-09 14:23:13 +00:00
|
|
|
|
splx(x);
|
1994-11-06 00:46:21 +00:00
|
|
|
|
if (error != 0 && error != ERESTART) {
|
|
|
|
|
pca_stop();
|
|
|
|
|
return error;
|
|
|
|
|
}
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
1994-11-06 00:46:21 +00:00
|
|
|
|
return 0;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
|
static int
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pcaprobe(struct isa_device *dvp)
|
|
|
|
|
{
|
|
|
|
|
return(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
|
static int
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pcaattach(struct isa_device *dvp)
|
|
|
|
|
{
|
1995-03-30 14:33:03 +00:00
|
|
|
|
printf("pca%d: PC speaker audio driver\n", dvp->id_unit);
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_init();
|
1995-09-03 05:43:50 +00:00
|
|
|
|
#ifdef DEVFS
|
1996-03-28 14:29:52 +00:00
|
|
|
|
pca_devfs_token =
|
|
|
|
|
devfs_add_devswf(&pca_cdevsw, 0, DV_CHR, 0, 0, 0600, "pcaudio");
|
|
|
|
|
pcac_devfs_token =
|
|
|
|
|
devfs_add_devswf(&pca_cdevsw, 128, DV_CHR, 0, 0, 0600,
|
|
|
|
|
"pcaudioctl");
|
1995-09-03 05:43:50 +00:00
|
|
|
|
#endif /*DEVFS*/
|
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
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static int
|
1995-09-08 11:09:15 +00:00
|
|
|
|
pcaopen(dev_t dev, int flags, int fmt, struct proc *p)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
|
|
|
|
/* audioctl device can always be opened */
|
|
|
|
|
if (minor(dev) == 128)
|
|
|
|
|
return 0;
|
|
|
|
|
if (minor(dev) > 0)
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
|
|
if (!pca_initialized) {
|
|
|
|
|
pca_init();
|
|
|
|
|
pca_initialized = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* audio device can only be open by one process */
|
|
|
|
|
if (pca_status.open) {
|
|
|
|
|
pca_status.queries = 1;
|
|
|
|
|
return EBUSY;
|
|
|
|
|
}
|
|
|
|
|
pca_status.buffer = pca_status.buf[0];
|
1997-09-03 19:08:05 +00:00
|
|
|
|
pca_status.in_use[0] = pca_status.in_use[1] = pca_status.in_use[2] = 0;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.timer_on = 0;
|
|
|
|
|
pca_status.open = 1;
|
|
|
|
|
pca_status.processed = 0;
|
1997-09-03 19:08:05 +00:00
|
|
|
|
pca_status.non_block = 0; /* block on write */
|
1994-04-21 14:16:55 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static int
|
1995-09-08 11:09:15 +00:00
|
|
|
|
pcaclose(dev_t dev, int flags, int fmt, struct proc *p)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
|
|
|
|
/* audioctl device can always be closed */
|
|
|
|
|
if (minor(dev) == 128)
|
|
|
|
|
return 0;
|
|
|
|
|
if (minor(dev) > 0)
|
|
|
|
|
return ENXIO;
|
|
|
|
|
/* audio device close drains all output and restores timers */
|
|
|
|
|
pca_wait();
|
1995-05-30 08:16:23 +00:00
|
|
|
|
pca_stop();
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.open = 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static int
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pcawrite(dev_t dev, struct uio *uio, int flag)
|
|
|
|
|
{
|
1996-06-09 14:23:13 +00:00
|
|
|
|
int count, error, which, x;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
|
|
|
|
|
/* only audio device can be written */
|
|
|
|
|
if (minor(dev) > 0)
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
|
|
while ((count = min(BUF_SIZE, uio->uio_resid)) > 0) {
|
1997-09-03 19:08:05 +00:00
|
|
|
|
if (pca_status.in_use[0] && pca_status.in_use[1] && pca_status.in_use[2]) {
|
|
|
|
|
if(pca_status.non_block)
|
|
|
|
|
return EWOULDBLOCK;
|
1996-06-09 14:23:13 +00:00
|
|
|
|
x = spltty();
|
1994-09-29 08:24:45 +00:00
|
|
|
|
pca_sleep = 1;
|
1994-11-06 00:46:21 +00:00
|
|
|
|
error = tsleep(&pca_sleep, PZERO|PCATCH, "pca_wait", 0);
|
|
|
|
|
pca_sleep = 0;
|
1996-06-09 14:23:13 +00:00
|
|
|
|
splx(x);
|
1994-11-06 00:46:21 +00:00
|
|
|
|
if (error != 0 && error != ERESTART) {
|
|
|
|
|
pca_stop();
|
|
|
|
|
return error;
|
|
|
|
|
}
|
1994-09-29 08:24:45 +00:00
|
|
|
|
}
|
1997-09-03 19:08:05 +00:00
|
|
|
|
if(!pca_status.in_use[0])
|
|
|
|
|
which = 0;
|
|
|
|
|
else if(!pca_status.in_use[1])
|
|
|
|
|
which = 1;
|
|
|
|
|
else which = 2;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
if (count && !pca_status.in_use[which]) {
|
|
|
|
|
uiomove(pca_status.buf[which], count, uio);
|
|
|
|
|
pca_status.processed += count;
|
|
|
|
|
switch (pca_status.encoding) {
|
|
|
|
|
case AUDIO_ENCODING_ULAW:
|
1994-05-02 09:40:12 +00:00
|
|
|
|
conv(ulaw_dsp, pca_status.buf[which], count);
|
1994-04-21 14:16:55 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AUDIO_ENCODING_ALAW:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AUDIO_ENCODING_RAW:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
pca_status.in_use[which] = count;
|
|
|
|
|
if (!pca_status.timer_on)
|
1995-05-30 08:16:23 +00:00
|
|
|
|
if (pca_start())
|
1994-04-21 14:16:55 +00:00
|
|
|
|
return EBUSY;
|
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
}
|
1994-04-21 14:16:55 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static int
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pcaioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
|
|
|
|
|
{
|
1994-09-29 08:24:45 +00:00
|
|
|
|
audio_info_t *auptr;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
|
|
|
|
|
switch(cmd) {
|
|
|
|
|
|
|
|
|
|
case AUDIO_GETINFO:
|
|
|
|
|
auptr = (audio_info_t *)data;
|
|
|
|
|
auptr->play.sample_rate = pca_status.sample_rate;
|
|
|
|
|
auptr->play.channels = 1;
|
|
|
|
|
auptr->play.precision = 8;
|
|
|
|
|
auptr->play.encoding = pca_status.encoding;
|
|
|
|
|
|
|
|
|
|
auptr->play.gain = pca_status.volume;
|
|
|
|
|
auptr->play.port = 0;
|
|
|
|
|
|
|
|
|
|
auptr->play.samples = pca_status.processed;
|
|
|
|
|
auptr->play.eof = 0;
|
|
|
|
|
auptr->play.pause = !pca_status.timer_on;
|
|
|
|
|
auptr->play.error = 0;
|
|
|
|
|
auptr->play.waiting = pca_status.queries;
|
|
|
|
|
|
|
|
|
|
auptr->play.open = pca_status.open;
|
|
|
|
|
auptr->play.active = pca_status.timer_on;
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case AUDIO_SETINFO:
|
|
|
|
|
auptr = (audio_info_t *)data;
|
|
|
|
|
if (auptr->play.sample_rate != (unsigned int)~0) {
|
|
|
|
|
pca_status.sample_rate = auptr->play.sample_rate;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
pca_status.scale =
|
1994-04-21 14:16:55 +00:00
|
|
|
|
(pca_status.sample_rate << 8) / INTERRUPT_RATE;
|
|
|
|
|
}
|
|
|
|
|
if (auptr->play.encoding != (unsigned int)~0) {
|
|
|
|
|
pca_status.encoding = auptr->play.encoding;
|
|
|
|
|
}
|
|
|
|
|
if (auptr->play.gain != (unsigned int)~0) {
|
|
|
|
|
pca_status.volume = auptr->play.gain;
|
|
|
|
|
pca_volume(pca_status.volume);
|
|
|
|
|
}
|
|
|
|
|
if (auptr->play.pause != (unsigned char)~0) {
|
|
|
|
|
if (auptr->play.pause)
|
|
|
|
|
pca_pause();
|
|
|
|
|
else
|
|
|
|
|
pca_continue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
case AUDIO_DRAIN:
|
1996-07-17 20:18:56 +00:00
|
|
|
|
case AUDIO_COMPAT_DRAIN:
|
1994-11-06 00:46:21 +00:00
|
|
|
|
return pca_wait();
|
1994-04-21 14:16:55 +00:00
|
|
|
|
|
|
|
|
|
case AUDIO_FLUSH:
|
1996-07-17 20:18:56 +00:00
|
|
|
|
case AUDIO_COMPAT_FLUSH:
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_stop();
|
|
|
|
|
return 0;
|
1997-09-03 19:08:05 +00:00
|
|
|
|
case FIONBIO:
|
|
|
|
|
pca_status.non_block = (char)(*(int *)data);
|
|
|
|
|
return 0;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
return ENXIO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static void
|
1994-11-06 00:46:21 +00:00
|
|
|
|
pcaintr(struct clockframe *frame)
|
1994-04-21 14:16:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (pca_status.index < pca_status.in_use[pca_status.current]) {
|
1994-05-02 09:40:12 +00:00
|
|
|
|
disable_intr();
|
|
|
|
|
__asm__("outb %0,$0x61\n"
|
|
|
|
|
"andb $0xFE,%0\n"
|
|
|
|
|
"outb %0,$0x61"
|
1994-04-21 14:16:55 +00:00
|
|
|
|
: : "a" ((char)pca_status.oldval) );
|
1994-05-02 09:40:12 +00:00
|
|
|
|
__asm__("xlatb\n"
|
|
|
|
|
"outb %0,$0x42"
|
1994-04-21 14:16:55 +00:00
|
|
|
|
: : "a" ((char)pca_status.buffer[pca_status.index]),
|
|
|
|
|
"b" ((long)volume_table) );
|
1994-05-02 09:40:12 +00:00
|
|
|
|
enable_intr();
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.counter += pca_status.scale;
|
|
|
|
|
pca_status.index = (pca_status.counter >> 8);
|
|
|
|
|
}
|
1994-09-29 08:24:45 +00:00
|
|
|
|
if (pca_status.index >= pca_status.in_use[pca_status.current]) {
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.index = pca_status.counter = 0;
|
|
|
|
|
pca_status.in_use[pca_status.current] = 0;
|
1997-09-03 19:08:05 +00:00
|
|
|
|
pca_status.current++;
|
|
|
|
|
if(pca_status.current > 2) pca_status.current = 0;
|
1994-04-21 14:16:55 +00:00
|
|
|
|
pca_status.buffer = pca_status.buf[pca_status.current];
|
1996-06-09 14:23:13 +00:00
|
|
|
|
if (pca_sleep)
|
1994-11-06 00:46:21 +00:00
|
|
|
|
wakeup(&pca_sleep);
|
1994-09-29 21:11:29 +00:00
|
|
|
|
if (pca_status.wsel.si_pid) {
|
|
|
|
|
selwakeup((struct selinfo *)&pca_status.wsel.si_pid);
|
|
|
|
|
pca_status.wsel.si_pid = 0;
|
|
|
|
|
pca_status.wsel.si_flags = 0;
|
1994-09-29 08:24:45 +00:00
|
|
|
|
}
|
1994-04-21 14:16:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-09-29 08:24:45 +00:00
|
|
|
|
|
1996-10-25 16:09:31 +00:00
|
|
|
|
static int
|
1994-09-29 08:24:45 +00:00
|
|
|
|
pcaselect(dev_t dev, int rw, struct proc *p)
|
|
|
|
|
{
|
|
|
|
|
int s = spltty();
|
|
|
|
|
struct proc *p1;
|
|
|
|
|
|
|
|
|
|
switch (rw) {
|
|
|
|
|
|
|
|
|
|
case FWRITE:
|
1997-09-03 19:08:05 +00:00
|
|
|
|
if (!pca_status.in_use[0] || !pca_status.in_use[1] || !pca_status.in_use[2]) {
|
1994-09-29 08:24:45 +00:00
|
|
|
|
splx(s);
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
1994-09-29 21:11:29 +00:00
|
|
|
|
if (pca_status.wsel.si_pid && (p1=pfind(pca_status.wsel.si_pid))
|
1994-09-29 08:24:45 +00:00
|
|
|
|
&& p1->p_wchan == (caddr_t)&selwait)
|
1994-09-29 21:11:29 +00:00
|
|
|
|
pca_status.wsel.si_flags = SI_COLL;
|
1994-09-29 08:24:45 +00:00
|
|
|
|
else
|
1994-09-29 21:11:29 +00:00
|
|
|
|
pca_status.wsel.si_pid = p->p_pid;
|
1994-09-29 08:24:45 +00:00
|
|
|
|
splx(s);
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
splx(s);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
return(0);
|
1994-09-29 08:24:45 +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
|
|
|
|
|
|
|
|
|
static pca_devsw_installed = 0;
|
|
|
|
|
|
1995-11-29 10:49:16 +00:00
|
|
|
|
static void pca_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( ! pca_devsw_installed ) {
|
1995-12-08 11:19:42 +00:00
|
|
|
|
dev = makedev(CDEV_MAJOR, 0);
|
|
|
|
|
cdevsw_add(&dev,&pca_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
|
|
|
|
pca_devsw_installed = 1;
|
1995-11-29 10:49:16 +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(pcadev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,pca_drvinit,NULL)
|
|
|
|
|
|
|
|
|
|
|
1994-04-21 14:16:55 +00:00
|
|
|
|
#endif
|