summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-11-29 01:07:59 +0000
committerjkh <jkh@FreeBSD.org>1995-11-29 01:07:59 +0000
commit8b518c54b47f7a852f4e88e1174e3dc3edc4bca1 (patch)
tree1edc6902afaa1aa0384c0537aa6ab3d68b13456c /sys/i386
parent072ed4b1b938c9263f06b0b51f077d17ec0363be (diff)
downloadFreeBSD-src-8b518c54b47f7a852f4e88e1174e3dc3edc4bca1.zip
FreeBSD-src-8b518c54b47f7a852f4e88e1174e3dc3edc4bca1.tar.gz
A batch of Jim Lowe's patches:
o Add signed/unsigned functionality to the matrox meteor device driver. o Apply a few fixes to the sound driver. o Add a ``SPIGOT_UNSECURE'' compile time definition so, if one defines SPIGOT_UNSECURE in their conf file, then they can use the spigot w/o root. There is a warning that this allows users access to the IO page which is probably not secure. Submitted by: james
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/conf/LINT9
-rw-r--r--sys/i386/conf/NOTES9
-rw-r--r--sys/i386/include/ioctl_meteor.h3
-rw-r--r--sys/i386/isa/sound/audio.c30
-rw-r--r--sys/i386/isa/sound/dmabuf.c10
-rw-r--r--sys/i386/isa/sound/gus_wave.c74
-rw-r--r--sys/i386/isa/sound/soundcard.c7
-rw-r--r--sys/i386/isa/spigot.c4
8 files changed, 122 insertions, 24 deletions
diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT
index 628b0c4..a532668 100644
--- a/sys/i386/conf/LINT
+++ b/sys/i386/conf/LINT
@@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
-# $Id: LINT,v 1.213 1995/11/09 22:47:05 gibbs Exp $
+# $Id: LINT,v 1.214 1995/11/21 02:50:08 peter Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@@ -710,7 +710,12 @@ device pca0 at isa? port IO_TIMER1 tty
# The irq values may only be 10, 11, or 15
# I/O memory is an 8kb region. Possible values are:
# 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff
-# Note that the start address must be on an even boundary.
+# The start address must be on an even boundary.
+# Add the following option if you want to allow non-root users to be able
+# to access the spigot. This option is not secure because it allows users
+# direct access to the I/O page.
+# options SPIGOT_UNSECURE
+#
# Notes on the Digiboard driver:
#
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index 628b0c4..a532668 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
-# $Id: LINT,v 1.213 1995/11/09 22:47:05 gibbs Exp $
+# $Id: LINT,v 1.214 1995/11/21 02:50:08 peter Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@@ -710,7 +710,12 @@ device pca0 at isa? port IO_TIMER1 tty
# The irq values may only be 10, 11, or 15
# I/O memory is an 8kb region. Possible values are:
# 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff
-# Note that the start address must be on an even boundary.
+# The start address must be on an even boundary.
+# Add the following option if you want to allow non-root users to be able
+# to access the spigot. This option is not secure because it allows users
+# direct access to the I/O page.
+# options SPIGOT_UNSECURE
+#
# Notes on the Digiboard driver:
#
diff --git a/sys/i386/include/ioctl_meteor.h b/sys/i386/include/ioctl_meteor.h
index e1fed36..c6fd9a3 100644
--- a/sys/i386/include/ioctl_meteor.h
+++ b/sys/i386/include/ioctl_meteor.h
@@ -113,8 +113,9 @@ struct meteor_counts {
/* internally stored in 32 bits */
#define METEOR_GEO_YUV_PACKED 0x40000 /* 4-2-2 YUV 16 bits packed */
#define METEOR_GEO_YUV_PLANER 0x80000 /* 4-2-2 YUV 16 bits planer */
+#define METEOR_GEO_UNSIGNED 0x400000 /* unsigned uv outputs */
- /* following structure is used to coordinate the syncronous */
+ /* following structure is used to coordinate the synchronous */
struct meteor_mem {
/* kernel write only */
diff --git a/sys/i386/isa/sound/audio.c b/sys/i386/isa/sound/audio.c
index 005915b..770babc 100644
--- a/sys/i386/isa/sound/audio.c
+++ b/sys/i386/isa/sound/audio.c
@@ -227,10 +227,16 @@ audio_write (int dev, struct fileinfo *file, snd_rw_buf * buf, int count)
/* Handle nonblocking mode */
#if defined(__FreeBSD__)
if (dev_nblock[dev] && wr_buff_no[dev] == RET_ERROR (EWOULDBLOCK))
+ return wr_buff_no[dev]; /*
+ * XXX Return error, write() will
+ * supply # of accepted bytes.
+ * In fact, in FreeBSD the check
+ * above should not be needed
+ */
#else
if (dev_nblock[dev] && wr_buff_no[dev] == RET_ERROR (EAGAIN))
-#endif
return p; /* No more space. Return # of accepted bytes */
+#endif
return wr_buff_no[dev];
}
wr_buff_ptr[dev] = 0;
@@ -317,10 +323,16 @@ audio_read (int dev, struct fileinfo *file, snd_rw_buf * buf, int count)
#if defined(__FreeBSD__)
if (dev_nblock[dev] && buff_no == RET_ERROR (EWOULDBLOCK))
+ return buff_no; /*
+ * XXX Return error, read() will supply
+ * # of bytes actually read. In fact,
+ * in FreeBSD the check above should not
+ * be needed
+ */
#else
if (dev_nblock[dev] && buff_no == RET_ERROR (EAGAIN))
-#endif
return p;
+#endif
return buff_no;
}
@@ -449,6 +461,20 @@ audio_ioctl (int dev, struct fileinfo *file,
return 0;
break;
+#ifdef __FreeBSD__
+ case FIONBIO: /* XXX Is this the same in Linux? */
+ if (*(int *)arg)
+ dev_nblock[dev] = 1;
+ else
+ dev_nblock[dev] = 0;
+ return 0;
+ break;
+
+ case FIOASYNC:
+ return 0; /* XXX Useful for ampling input notification? */
+ break;
+#endif
+
default:
return DMAbuf_ioctl (dev, cmd, arg, 0);
}
diff --git a/sys/i386/isa/sound/dmabuf.c b/sys/i386/isa/sound/dmabuf.c
index f696de7..d748005 100644
--- a/sys/i386/isa/sound/dmabuf.c
+++ b/sys/i386/isa/sound/dmabuf.c
@@ -527,7 +527,7 @@ space_in_queue (int dev)
int len, max, tmp;
struct dma_buffparms *dmap = audio_devs[dev]->dmap;
- if (dmap->qlen == dmap->nbufs) /* No space at all */
+ if (dmap->qlen >= dmap->nbufs) /* No space at all */
return 0;
/*
@@ -587,7 +587,7 @@ DMAbuf_getwrbuffer (int dev, char **buf, int *size, int dontblock)
}
- if (dontblock)
+ if (dontblock && !space_in_queue (dev)) /* XXX */
#if defined(__FreeBSD__)
return RET_ERROR (EWOULDBLOCK);
#else
@@ -961,9 +961,9 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait
if (dmap->dma_mode != DMODE_INPUT)
return 0;
+ DISABLE_INTR (flags);
if (!dmap->qlen)
{
- DISABLE_INTR (flags);
#if defined(__FreeBSD__)
selrecord(wait, &selinfo[dev]);
#else
@@ -973,6 +973,7 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait
RESTORE_INTR (flags);
return 0;
}
+ RESTORE_INTR (flags);
return 1;
break;
@@ -983,9 +984,9 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait
if (dmap->dma_mode == DMODE_NONE)
return 1;
+ DISABLE_INTR (flags);
if (!space_in_queue (dev))
{
- DISABLE_INTR (flags);
#if defined(__FreeBSD__)
selrecord(wait, &selinfo[dev]);
#else
@@ -995,6 +996,7 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait
RESTORE_INTR (flags);
return 0;
}
+ RESTORE_INTR (flags);
return 1;
break;
diff --git a/sys/i386/isa/sound/gus_wave.c b/sys/i386/isa/sound/gus_wave.c
index ecc266d..eb7227a 100644
--- a/sys/i386/isa/sound/gus_wave.c
+++ b/sys/i386/isa/sound/gus_wave.c
@@ -131,6 +131,10 @@ static unsigned long pcm_current_buf;
static int pcm_current_count;
static int pcm_current_intrflag;
+#if defined(__FreeBSD__)
+static char *gus_copy_buf;
+#endif
+
struct voice_info voices[32];
static int freq_div_table[] =
@@ -2003,11 +2007,13 @@ static int
gus_sampling_open (int dev, int mode)
{
int dev_flag;
+ int init_flag;
#ifdef GUS_NO_DMA
printk ("GUS: DMA mode not enabled. Device not supported\n");
return RET_ERROR (ENXIO);
#endif
dev_flag = 0;
+ init_flag = (gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum] == 0);
if(mode & OPEN_WRITE)
{
if (gus_busy[gus_devnum])
@@ -2029,18 +2035,20 @@ gus_sampling_open (int dev, int mode)
}
}
- if(gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum] == 0)
- gus_initialize ();
+ if(init_flag)
+ {
+ gus_initialize ();
- active_device = 0;
+ active_device = 0;
- gus_reset ();
- reset_sample_memory ();
- gus_select_max_voices (14);
+ gus_reset ();
+ reset_sample_memory ();
+ gus_select_max_voices (14);
- pcm_active = 0;
- dma_active = 0;
- pcm_opened = 1;
+ pcm_active = 0;
+ dma_active = 0;
+ pcm_opened = 1;
+ }
if (mode & OPEN_READ)
{
recording_active = 1;
@@ -2055,7 +2063,7 @@ static void
gus_sampling_close (int dev)
{
gus_busy[dev] = 0;
- if (gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum]) {
+ if (gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum] == 0) {
active_device = 0;
gus_reset();
pcm_opened = 0;
@@ -2392,6 +2400,47 @@ gus_copy_from_user (int dev, char *localbuf, int localoffs,
COPY_FROM_USER (&localbuf[localoffs], userbuf, useroffs, len);
}
else if (gus_sampling_bits == 8)
+#if defined(__FreeBSD__)
+ {
+ char *in_left = gus_copy_buf;
+ char *in_right = in_left + 1;
+ char *out_left = localbuf + (localoffs / 2);
+ char *out_right = out_left + pcm_bsize;
+ int i;
+
+ COPY_FROM_USER (gus_copy_buf, userbuf, useroffs, len);
+
+ len /= 2;
+
+ for (i = 0; i < len; i++)
+ {
+ *out_left++ = *in_left++;
+ in_left++;
+ *out_right++ = *in_right++;
+ in_right++;
+ }
+ }
+ else
+ {
+ short *in_left = (short *)gus_copy_buf;
+ short *in_right = in_left + 1;
+ short *out_left = (short *)localbuf + (localoffs / 4);
+ short *out_right = out_left + (pcm_bsize / 2);
+ int i;
+
+ COPY_FROM_USER (gus_copy_buf, userbuf, useroffs, len);
+
+ len /= 4;
+
+ for (i = 0; i < len; i++)
+ {
+ *out_left++ = *in_left++;
+ in_left++;
+ *out_right++ = *in_right++;
+ in_right++;
+ }
+ }
+#else
{
int in_left = useroffs;
int in_right = useroffs + 1;
@@ -2439,6 +2488,7 @@ gus_copy_from_user (int dev, char *localbuf, int localoffs,
#endif
}
}
+#endif
}
static struct audio_operations gus_sampling_operations =
@@ -3055,6 +3105,10 @@ gus_wave_init (long mem_start, int irq, int dma, int dma_read)
synth_devs[num_synths++] = &guswave_operations;
}
+#if defined(__FreeBSD__)
+ PERMANENT_MALLOC (char *, gus_copy_buf, DSP_BUFFSIZE, mem_start);
+#endif
+
PERMANENT_MALLOC (struct patch_info *, samples,
(MAX_SAMPLE + 1) * sizeof (*samples), mem_start);
diff --git a/sys/i386/isa/sound/soundcard.c b/sys/i386/isa/sound/soundcard.c
index 8542e0a..d417c30 100644
--- a/sys/i386/isa/sound/soundcard.c
+++ b/sys/i386/isa/sound/soundcard.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: soundcard.c,v 1.30 1995/11/04 13:24:48 bde Exp $
+ * $Id: soundcard.c,v 1.31 1995/11/28 09:43:45 julian Exp $
*/
#include "sound_config.h"
@@ -53,7 +53,10 @@ u_int snd7_imask;
u_int snd8_imask;
u_int snd9_imask;
-#define FIX_RETURN(ret) {if ((ret)<0) return -(ret); else return 0;}
+#define FIX_RETURN(ret) { \
+ int tmp_ret = (ret); \
+ if (tmp_ret<0) return -tmp_ret; else return 0; \
+ }
static int timer_running = 0;
diff --git a/sys/i386/isa/spigot.c b/sys/i386/isa/spigot.c
index d8c8ff1..093c30e 100644
--- a/sys/i386/isa/spigot.c
+++ b/sys/i386/isa/spigot.c
@@ -40,7 +40,7 @@
*
* ftp.cs.uwm.edu://pub/FreeBSD/spigot/spigot.tar.gz
*
- * Version 1.5, August 30, 1995.
+ * Version 1.6, Novemeber 21, 1995.
*
*/
@@ -225,9 +225,11 @@ struct spigot_info *info;
ss->signal_num = *((int *)data);
break;
case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */
+#if !defined(SPIGOT_UNSECURE)
error = suser(p->p_ucred, &p->p_acflag);
if (error != 0)
return error;
+#endif
fp=(struct trapframe *)p->p_md.md_regs;
fp->tf_eflags |= PSL_IOPL;
break;
OpenPOWER on IntegriCloud