2 * Video spigot capture driver.
4 * Copyright (c) 1995, Jim Lowe. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 2.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * This is the minimum driver code required to make a spigot work.
27 * Unfortunatly, I can't include a real driver since the information
28 * on the spigot is under non-disclosure. You can pick up a library
29 * that will work with this driver from
30 * ftp://ftp.cs.uwm.edu/pub/FreeBSD-UWM. The library contains the
31 * source that I can release as well as several object modules and
32 * functions that allows one to read spigot data. See the code for
33 * spigot_grab.c that is included with the library data.
35 * The vendor will not allow me to release the spigot library code.
36 * Please don't ask me for it.
38 * To use this driver you will need the spigot library. The library is
41 * ftp.cs.uwm.edu://pub/FreeBSD-UWM/spigot/spigot.tar.gz
43 * Version 1.7, December 1995.
52 error "Can only have 1 spigot configured."
55 #include "opt_spigot.h"
57 #include <sys/param.h>
58 #include <sys/systm.h>
61 #include <sys/kernel.h>
64 #include <sys/mutex.h>
66 #include <sys/signalvar.h>
68 #include <machine/frame.h>
69 #include <machine/md_var.h>
70 #include <machine/spigot.h>
71 #include <machine/psl.h>
73 #include <i386/isa/isa_device.h>
75 static struct spigot_softc {
81 } spigot_softc[NSPIGOT];
87 #define UNIT(dev) minor(dev)
89 static int spigot_probe(struct isa_device *id);
90 static int spigot_attach(struct isa_device *id);
92 struct isa_driver spigotdriver = {
98 COMPAT_ISA_DRIVER(spigot, spigotdriver);
100 static d_open_t spigot_open;
101 static d_close_t spigot_close;
102 static d_read_t spigot_read;
103 static d_write_t spigot_write;
104 static d_ioctl_t spigot_ioctl;
105 static d_mmap_t spigot_mmap;
107 #define CDEV_MAJOR 11
108 static struct cdevsw spigot_cdevsw = {
109 /* open */ spigot_open,
110 /* close */ spigot_close,
111 /* read */ spigot_read,
112 /* write */ spigot_write,
113 /* ioctl */ spigot_ioctl,
115 /* mmap */ spigot_mmap,
116 /* strategy */ nostrategy,
118 /* maj */ CDEV_MAJOR,
124 static ointhand2_t spigintr;
127 spigot_probe(struct isa_device *devp)
130 struct spigot_softc *ss=(struct spigot_softc *)&spigot_softc[devp->id_unit];
134 cdevsw_add(&spigot_cdevsw);
140 if(devp->id_iobase != 0xad6 || inb(0xad9) == 0xff)
141 status = 0; /* not found */
143 status = 1; /* found */
151 spigot_attach(struct isa_device *devp)
154 struct spigot_softc *ss= &spigot_softc[unit = devp->id_unit];
156 devp->id_ointr = spigintr;
157 ss->maddr = kvtop(devp->id_maddr);
158 ss->irq = devp->id_irq;
159 make_dev(&spigot_cdevsw, unit, 0, 0, 0644, "spigot%d", unit);
164 spigot_open(dev_t dev, int flags, int fmt, struct proc *p)
167 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
169 if((ss->flags & ALIVE) == 0)
175 #if !defined(SPIGOT_UNSECURE)
177 * Don't allow open() unless the process has sufficient privileges,
178 * since mapping the i/o page and granting i/o privilege would
179 * require sufficient privilege soon and nothing much can be done
197 spigot_close(dev_t dev, int flags, int fmt, struct proc *p)
199 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
211 spigot_write(dev_t dev, struct uio *uio, int ioflag)
217 spigot_read(dev_t dev, struct uio *uio, int ioflag)
224 spigot_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
227 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
228 struct spigot_info *info;
230 if(!data) return(EINVAL);
234 ss->signal_num = *((int *)data);
236 case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */
237 #if !defined(SPIGOT_UNSECURE)
244 p->p_md.md_regs->tf_eflags |= PSL_IOPL;
246 case SPIGOT_IOPL_OFF: /* deny access to the IO PAGE */
247 p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
249 case SPIGOT_GET_INFO:
250 info = (struct spigot_info *)data;
251 info->maddr = ss->maddr;
262 * Interrupt procedure.
263 * Just call a user level interrupt routine.
268 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[unit];
270 if(ss->p && ss->signal_num) {
272 psignal(ss->p, ss->signal_num);
278 spigot_mmap(dev_t dev, vm_offset_t offset, int nprot)
280 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0];
283 printf("spigot mmap failed, offset = 0x%x != 0x0\n", offset);
287 if(nprot & PROT_EXEC)
290 return i386_btop(ss->maddr);