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>
59 #include <sys/kernel.h>
62 #include <sys/signalvar.h>
66 #include <machine/frame.h>
67 #include <machine/md_var.h>
68 #include <machine/spigot.h>
69 #include <machine/psl.h>
71 #include <i386/isa/isa_device.h>
73 static struct spigot_softc {
79 } spigot_softc[NSPIGOT];
85 #define UNIT(dev) minor(dev)
87 static int spigot_probe(struct isa_device *id);
88 static int spigot_attach(struct isa_device *id);
90 struct isa_driver spigotdriver = {
96 COMPAT_ISA_DRIVER(spigot, spigotdriver);
98 static d_open_t spigot_open;
99 static d_close_t spigot_close;
100 static d_read_t spigot_read;
101 static d_write_t spigot_write;
102 static d_ioctl_t spigot_ioctl;
103 static d_mmap_t spigot_mmap;
105 #define CDEV_MAJOR 11
106 static struct cdevsw spigot_cdevsw = {
107 /* open */ spigot_open,
108 /* close */ spigot_close,
109 /* read */ spigot_read,
110 /* write */ spigot_write,
111 /* ioctl */ spigot_ioctl,
113 /* mmap */ spigot_mmap,
114 /* strategy */ nostrategy,
116 /* maj */ CDEV_MAJOR,
123 static ointhand2_t spigintr;
126 spigot_probe(struct isa_device *devp)
129 struct spigot_softc *ss=(struct spigot_softc *)&spigot_softc[devp->id_unit];
133 cdevsw_add(&spigot_cdevsw);
139 if(devp->id_iobase != 0xad6 || inb(0xad9) == 0xff)
140 status = 0; /* not found */
142 status = 1; /* found */
150 spigot_attach(struct isa_device *devp)
153 struct spigot_softc *ss= &spigot_softc[unit = devp->id_unit];
155 devp->id_ointr = spigintr;
156 ss->maddr = kvtop(devp->id_maddr);
157 ss->irq = devp->id_irq;
158 make_dev(&spigot_cdevsw, unit, 0, 0, 0644, "spigot%d", unit);
163 spigot_open(dev_t dev, int flags, int fmt, struct proc *p)
166 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
168 if((ss->flags & ALIVE) == 0)
174 #if !defined(SPIGOT_UNSECURE)
176 * Don't allow open() unless the process has sufficient privileges,
177 * since mapping the i/o page and granting i/o privilege would
178 * require sufficient privilege soon and nothing much can be done
196 spigot_close(dev_t dev, int flags, int fmt, struct proc *p)
198 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
210 spigot_write(dev_t dev, struct uio *uio, int ioflag)
216 spigot_read(dev_t dev, struct uio *uio, int ioflag)
223 spigot_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
226 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)];
227 struct spigot_info *info;
229 if(!data) return(EINVAL);
233 ss->signal_num = *((int *)data);
235 case SPIGOT_IOPL_ON: /* allow access to the IO PAGE */
236 #if !defined(SPIGOT_UNSECURE)
243 p->p_md.md_regs->tf_eflags |= PSL_IOPL;
245 case SPIGOT_IOPL_OFF: /* deny access to the IO PAGE */
246 p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
248 case SPIGOT_GET_INFO:
249 info = (struct spigot_info *)data;
250 info->maddr = ss->maddr;
261 * Interrupt procedure.
262 * Just call a user level interrupt routine.
267 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[unit];
269 if(ss->p && ss->signal_num) {
271 psignal(ss->p, ss->signal_num);
277 spigot_mmap(dev_t dev, vm_offset_t offset, int nprot)
279 struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0];
282 printf("spigot mmap failed, offset = 0x%x != 0x0\n", offset);
286 if(nprot & PROT_EXEC)
289 return i386_btop(ss->maddr);