1994-10-01 17:59:42 +00:00
|
|
|
/*
|
|
|
|
* CORTEX-I Frame Grabber driver V1.0
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994, Paul S. LaFollette, Jr. This software may be used,
|
|
|
|
* modified, copied, distributed, and sold, in both source and binary form
|
|
|
|
* provided that the above copyright and these terms are retained. Under
|
|
|
|
* no circumstances is the author responsible for the proper functioning
|
|
|
|
* of this software, nor does the author assume any responsibility
|
|
|
|
* for damages incurred with its use.
|
|
|
|
*
|
1999-04-28 10:54:24 +00:00
|
|
|
* $Id: ctx.c,v 1.29 1998/12/09 02:56:48 eivind Exp $
|
1994-10-01 17:59:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Device Driver for CORTEX-I Frame Grabber
|
|
|
|
* Made by ImageNation Corporation
|
|
|
|
* 1200 N.E. Keyues Road
|
|
|
|
* Vancouver, WA 98684 (206) 944-9131
|
|
|
|
* (I have no ties to this company, just thought you might want
|
|
|
|
* to know how to get in touch with them.)
|
|
|
|
*
|
|
|
|
* In order to understand this device, you really need to consult the
|
|
|
|
* manual which ImageNation provides when you buy the board. (And
|
|
|
|
* what a pleasure it is to buy something for a PC and actually get
|
|
|
|
* programming information along with it.) I will limit myself here to
|
|
|
|
* a few comments which are specific to this driver. See also the file
|
|
|
|
* ctxreg.h for definitions of registers and control bits.
|
|
|
|
*
|
|
|
|
* 1. Although the hardware supports low resolution (256 x 256)
|
|
|
|
* acqusition and display, I have not implemented access to
|
|
|
|
* these modes in this driver. There are some fairly quirky
|
|
|
|
* aspects to the way this board works in low resolution mode,
|
|
|
|
* and I don't want to deal with them. Maybe later.
|
|
|
|
*
|
|
|
|
* 2. Choosing the base address for the video memory: This is set
|
|
|
|
* using a combination of hardware and software, using the left
|
|
|
|
* most dip switch on the board, and the AB_SELECT bit of control
|
|
|
|
* port 1, according to the chart below:
|
|
|
|
*
|
|
|
|
* Left DIP switch || DOWN | UP |
|
|
|
|
* =================================================
|
|
|
|
* AB_SELECT = 0 || 0xA0000 | 0xB0000 |
|
|
|
|
* -------------------------------------------------
|
|
|
|
* AB_SELECT = 1 || 0xD0000 | 0xE0000 |
|
|
|
|
* ------------------------------------------------
|
|
|
|
*
|
|
|
|
* When the RAM_ENABLE bit of control port 1 is clear (0), the
|
|
|
|
* video ram is disconnected from the computer bus. This makes
|
|
|
|
* it possible, in principle, to share memory space with other
|
|
|
|
* devices (such as VGA) which can also disconnect themselves
|
|
|
|
* from the bus. It also means that multiple CORTEX-I boards
|
|
|
|
* can share the same video memory space. Disconnecting from the
|
|
|
|
* bus does not affect the video display of the video ram contents,
|
|
|
|
* so that one needs only set the RAM_ENABLE bit when actually
|
|
|
|
* reading or writing to memory. The cost of this is low,
|
|
|
|
* the benefits to me are great (I need more than one board
|
|
|
|
* in my machine, and 0xE0000 is the only address choice that
|
|
|
|
* doesn't conflict with anything) so I adopt this strategy here.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-01 17:59:42 +00:00
|
|
|
* XXX-Note... this driver has only been tested for the
|
|
|
|
* XXX base = 0xE0000 case!
|
|
|
|
*
|
|
|
|
* 3) There is a deficiency in the documentation from ImageNation, I
|
|
|
|
* think. In order to successfully load the lookup table, it is
|
|
|
|
* necessary to clear SEE_STORED_VIDEO in control port 0 as well as
|
|
|
|
* setting LUT_LOAD_ENABLE in control port 1.
|
|
|
|
*
|
|
|
|
* 4) This driver accesses video memory through read or write operations.
|
|
|
|
* Other functionality is provided through ioctl's, manifest
|
|
|
|
* constants for which are defined in ioctl_ctx.h. The ioctl's
|
|
|
|
* include:
|
|
|
|
* CTX_LIVE Display live video
|
|
|
|
* CTX_GRAB Grab a frame of video data
|
|
|
|
* CTX_H_ORGANIZE Set things up so that sequential read
|
|
|
|
* operations access horizontal lines of
|
|
|
|
* pixels.
|
|
|
|
* CTX_V_ORGANIZE Set things up so that sequential read
|
|
|
|
* operations access vertical lines of
|
|
|
|
* pixels.
|
|
|
|
* CTX_SET_LUT Set the lookup table from an array
|
|
|
|
* of 256 unsigned chars passed as the
|
|
|
|
* third parameter to ioctl.
|
|
|
|
* CTX_GET_LUT Return the current lookup table to
|
|
|
|
* the application as an array of 256
|
|
|
|
* unsigned chars. Again the third
|
|
|
|
* parameter to the ioctl call.
|
|
|
|
*
|
|
|
|
* Thus,
|
|
|
|
* ioctl(fi, CTX_H_ORGANIZE, 0);
|
|
|
|
* lseek(fi, y*512, SEEK_SET);
|
|
|
|
* read(fi, buffer, 512);
|
|
|
|
*
|
|
|
|
* will fill buffer with 512 pixels (unsigned chars) which represent
|
|
|
|
* the y-th horizontal line of the image.
|
|
|
|
* Similarly,
|
|
|
|
* ioctl(fi, CTX_V_ORGANIZE, 0:
|
|
|
|
* lseek(fi, x*512+y, SEEK_SET);
|
|
|
|
* read(fi, buffer, 10);
|
|
|
|
*
|
|
|
|
* will read 10 a vertical line of 10 pixels starting at (x,y).
|
|
|
|
*
|
|
|
|
* Obviously, this sort of ugliness needs to be hidden away from
|
|
|
|
* the casual user, with an appropriate set of higher level
|
|
|
|
* functions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ctx.h"
|
|
|
|
#if NCTX > 0
|
|
|
|
|
1998-01-24 02:54:56 +00:00
|
|
|
#include "opt_devfs.h"
|
|
|
|
|
1994-10-01 17:59:42 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1995-12-06 23:44:23 +00:00
|
|
|
#include <sys/conf.h>
|
1994-10-01 17:59:42 +00:00
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
1995-12-08 11:19:42 +00:00
|
|
|
#ifdef DEVFS
|
|
|
|
#include <sys/devfsext.h>
|
|
|
|
#endif /*DEVFS*/
|
1994-10-01 17:59:42 +00:00
|
|
|
|
1994-10-21 01:19:28 +00:00
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
#include <i386/isa/ctxreg.h>
|
1994-10-01 17:59:42 +00:00
|
|
|
#include <machine/ioctl_ctx.h>
|
1996-06-25 20:31:01 +00:00
|
|
|
#include <machine/md_var.h>
|
1994-10-01 17:59:42 +00:00
|
|
|
|
1996-11-11 17:11:08 +00:00
|
|
|
static int waitvb(int port);
|
1994-10-01 17:59:42 +00:00
|
|
|
|
|
|
|
/* state flags */
|
|
|
|
#define OPEN (0x01) /* device is open */
|
|
|
|
|
|
|
|
#define UNIT(x) ((x) & 0x07)
|
|
|
|
|
1995-12-15 00:54:32 +00:00
|
|
|
static int ctxprobe __P((struct isa_device *devp));
|
|
|
|
static int ctxattach __P((struct isa_device *devp));
|
1994-10-01 17:59:42 +00:00
|
|
|
struct isa_driver ctxdriver = {ctxprobe, ctxattach, "ctx"};
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static d_open_t ctxopen;
|
|
|
|
static d_close_t ctxclose;
|
|
|
|
static d_read_t ctxread;
|
|
|
|
static d_write_t ctxwrite;
|
|
|
|
static d_ioctl_t ctxioctl;
|
|
|
|
#define CDEV_MAJOR 40
|
|
|
|
|
1995-12-08 23:23:00 +00:00
|
|
|
static struct cdevsw ctx_cdevsw =
|
1995-12-08 11:19:42 +00:00
|
|
|
{ ctxopen, ctxclose, ctxread, ctxwrite, /*40*/
|
|
|
|
ctxioctl, nostop, nullreset, nodevtotty,/* cortex */
|
|
|
|
seltrue, nommap, NULL, "ctx", NULL, -1 };
|
|
|
|
|
|
|
|
|
1994-10-01 17:59:42 +00:00
|
|
|
#define LUTSIZE 256 /* buffer size for Look Up Table (LUT) */
|
|
|
|
#define PAGESIZE 65536 /* size of one video page, 1/4 of the screen */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Per unit shadow registers (because the dumb hardware is RO)
|
|
|
|
*/
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
static struct ctx_soft_registers {
|
1994-10-01 17:59:42 +00:00
|
|
|
u_char *lutp;
|
|
|
|
u_char cp0;
|
|
|
|
u_char cp1;
|
|
|
|
u_char flag;
|
1996-11-11 17:11:08 +00:00
|
|
|
int iobase;
|
1994-10-01 17:59:42 +00:00
|
|
|
caddr_t maddr;
|
|
|
|
int msize;
|
1995-12-08 11:19:42 +00:00
|
|
|
void *devfs_token;
|
1994-10-01 17:59:42 +00:00
|
|
|
} ctx_sr[NCTX];
|
|
|
|
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
1994-10-01 17:59:42 +00:00
|
|
|
ctxprobe(struct isa_device * devp)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (inb(devp->id_iobase) == 0xff) /* 0xff only if board absent */
|
|
|
|
status = 0;
|
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
|
|
|
else {
|
|
|
|
status = 1; /*XXX uses only one port? */
|
|
|
|
}
|
1994-10-01 17:59:42 +00:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
1994-10-01 17:59:42 +00:00
|
|
|
ctxattach(struct isa_device * devp)
|
|
|
|
{
|
|
|
|
struct ctx_soft_registers *sr;
|
|
|
|
|
|
|
|
sr = &(ctx_sr[devp->id_unit]);
|
|
|
|
sr->cp0 = 0; /* zero out the shadow registers */
|
|
|
|
sr->cp1 = 0; /* and the open flag. wait for */
|
|
|
|
sr->flag = 0; /* open to malloc the LUT space */
|
|
|
|
sr->iobase = devp->id_iobase;
|
|
|
|
sr->maddr = devp->id_maddr;
|
|
|
|
sr->msize = devp->id_msize;
|
1995-12-08 11:19:42 +00:00
|
|
|
#ifdef DEVFS
|
1996-03-28 14:29:52 +00:00
|
|
|
sr->devfs_token =
|
|
|
|
devfs_add_devswf(&ctx_cdevsw, 0, DV_CHR, 0, 0, 0600,
|
|
|
|
"ctx%d", devp->id_unit);
|
1995-12-08 11:19:42 +00:00
|
|
|
#endif /* DEVFS */
|
1998-12-09 02:56:48 +00:00
|
|
|
return (1);
|
1994-10-01 17:59:42 +00:00
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-09-08 11:09:15 +00:00
|
|
|
ctxopen(dev_t dev, int flags, int fmt, struct proc *p)
|
1994-10-01 17:59:42 +00:00
|
|
|
{
|
|
|
|
struct ctx_soft_registers *sr;
|
|
|
|
u_char unit;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
unit = UNIT(minor(dev));
|
|
|
|
|
|
|
|
/* minor number out of range? */
|
|
|
|
|
|
|
|
if (unit >= NCTX)
|
|
|
|
return (ENXIO);
|
|
|
|
sr = &(ctx_sr[unit]);
|
|
|
|
|
|
|
|
if (sr->flag != 0) /* someone has already opened us */
|
|
|
|
return (EBUSY);
|
|
|
|
|
|
|
|
/* get space for the LUT buffer */
|
|
|
|
|
|
|
|
sr->lutp = malloc(LUTSIZE, M_DEVBUF, M_WAITOK);
|
|
|
|
if (sr->lutp == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
|
|
|
|
sr->flag = OPEN;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Set up the shadow registers. We don't actually write these
|
|
|
|
values to the control ports until after we finish loading the
|
|
|
|
lookup table.
|
|
|
|
*/
|
|
|
|
sr->cp0 |= SEE_STORED_VIDEO;
|
|
|
|
if ((kvtop(sr->maddr) == 0xB0000) || (kvtop(sr->maddr) == 0xE0000))
|
|
|
|
sr->cp1 |= AB_SELECT; /* map to B or E if necessary */
|
|
|
|
/* but don't enable RAM */
|
|
|
|
/*
|
|
|
|
Set up the lookup table initially so that it is transparent.
|
|
|
|
*/
|
|
|
|
|
|
|
|
outb(sr->iobase + ctx_cp0, (u_char) 0);
|
|
|
|
outb(sr->iobase + ctx_cp1, (u_char) (LUT_LOAD_ENABLE | BLANK_DISPLAY));
|
|
|
|
for (i = 0; i < LUTSIZE; i++) {
|
|
|
|
outb(sr->iobase + ctx_lutaddr, (u_char) i);
|
|
|
|
sr->lutp[i] = (u_char) i;
|
|
|
|
outb(sr->iobase + ctx_lutdata, (u_char) sr->lutp[i]);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
Disable LUT loading, and push the data in the shadow
|
|
|
|
registers into the control ports.
|
|
|
|
*/
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
outb(sr->iobase + ctx_cp1, sr->cp1);
|
|
|
|
return (0); /* successful open. All ready to go. */
|
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-09-08 11:09:15 +00:00
|
|
|
ctxclose(dev_t dev, int flags, int fmt, struct proc *p)
|
1994-10-01 17:59:42 +00:00
|
|
|
{
|
|
|
|
int unit;
|
|
|
|
|
|
|
|
unit = UNIT(minor(dev));
|
|
|
|
ctx_sr[unit].flag = 0;
|
|
|
|
free(ctx_sr[unit].lutp, M_DEVBUF);
|
|
|
|
ctx_sr[unit].lutp = NULL;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-09-08 11:09:15 +00:00
|
|
|
ctxwrite(dev_t dev, struct uio * uio, int ioflag)
|
1994-10-01 17:59:42 +00:00
|
|
|
{
|
|
|
|
int unit, status = 0;
|
|
|
|
int page, count, offset;
|
|
|
|
struct ctx_soft_registers *sr;
|
|
|
|
|
|
|
|
unit = UNIT(minor(dev));
|
|
|
|
sr = &(ctx_sr[unit]);
|
|
|
|
|
1998-06-14 10:52:52 +00:00
|
|
|
if (uio->uio_offset < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
if (uio->uio_offset >= 4 * PAGESIZE)
|
|
|
|
page = 4; /* EOF */
|
|
|
|
else
|
|
|
|
page = (u_int)uio->uio_offset / PAGESIZE;
|
|
|
|
offset = (u_int)uio->uio_offset % PAGESIZE;
|
1994-10-01 17:59:42 +00:00
|
|
|
count = min(uio->uio_resid, PAGESIZE - offset);
|
|
|
|
while ((page >= 0) && (page <= 3) && (count > 0)) {
|
|
|
|
sr->cp0 &= ~3;
|
|
|
|
sr->cp0 |= page;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Before doing the uiomove, we need to "connect" the frame buffer
|
|
|
|
ram to the machine bus. This is done here so that we can have
|
|
|
|
several different boards installed, all sharing the same memory
|
|
|
|
space... each board is only "connected" to the bus when its memory
|
|
|
|
is actually being read or written. All my instincts tell me that
|
|
|
|
I should disable interrupts here, so I have done so.
|
|
|
|
*/
|
|
|
|
|
|
|
|
disable_intr();
|
|
|
|
sr->cp1 |= RAM_ENABLE;
|
|
|
|
outb(sr->iobase + ctx_cp1, sr->cp1);
|
|
|
|
status = uiomove(sr->maddr + offset, count, uio);
|
|
|
|
sr->cp1 &= ~RAM_ENABLE;
|
|
|
|
outb(sr->iobase + ctx_cp1, sr->cp1);
|
|
|
|
enable_intr();
|
|
|
|
|
1998-06-14 10:52:52 +00:00
|
|
|
page = (u_int)uio->uio_offset / PAGESIZE;
|
|
|
|
offset = (u_int)uio->uio_offset % PAGESIZE;
|
1994-10-01 17:59:42 +00:00
|
|
|
count = min(uio->uio_resid, PAGESIZE - offset);
|
|
|
|
}
|
|
|
|
if (uio->uio_resid > 0)
|
|
|
|
return (ENOSPC);
|
|
|
|
else
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-09-08 11:09:15 +00:00
|
|
|
ctxread(dev_t dev, struct uio * uio, int ioflag)
|
1994-10-01 17:59:42 +00:00
|
|
|
{
|
|
|
|
int unit, status = 0;
|
|
|
|
int page, count, offset;
|
|
|
|
struct ctx_soft_registers *sr;
|
|
|
|
|
|
|
|
unit = UNIT(minor(dev));
|
|
|
|
sr = &(ctx_sr[unit]);
|
|
|
|
|
1998-06-14 10:52:52 +00:00
|
|
|
if (uio->uio_offset < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
if (uio->uio_offset >= 4 * PAGESIZE)
|
|
|
|
page = 4; /* EOF */
|
|
|
|
else
|
|
|
|
page = (u_int)uio->uio_offset / PAGESIZE;
|
|
|
|
offset = (u_int)uio->uio_offset % PAGESIZE;
|
1994-10-01 17:59:42 +00:00
|
|
|
count = min(uio->uio_resid, PAGESIZE - offset);
|
|
|
|
while ((page >= 0) && (page <= 3) && (count > 0)) {
|
|
|
|
sr->cp0 &= ~3;
|
|
|
|
sr->cp0 |= page;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
/*
|
|
|
|
Before doing the uiomove, we need to "connect" the frame buffer
|
|
|
|
ram to the machine bus. This is done here so that we can have
|
|
|
|
several different boards installed, all sharing the same memory
|
|
|
|
space... each board is only "connected" to the bus when its memory
|
|
|
|
is actually being read or written. All my instincts tell me that
|
|
|
|
I should disable interrupts here, so I have done so.
|
|
|
|
*/
|
|
|
|
disable_intr();
|
|
|
|
sr->cp1 |= RAM_ENABLE;
|
|
|
|
outb(sr->iobase + ctx_cp1, sr->cp1);
|
|
|
|
status = uiomove(sr->maddr + offset, count, uio);
|
|
|
|
sr->cp1 &= ~RAM_ENABLE;
|
|
|
|
outb(sr->iobase + ctx_cp1, sr->cp1);
|
|
|
|
enable_intr();
|
|
|
|
|
1998-06-14 10:52:52 +00:00
|
|
|
page = (u_int)uio->uio_offset / PAGESIZE;
|
|
|
|
offset = (u_int)uio->uio_offset % PAGESIZE;
|
1994-10-01 17:59:42 +00:00
|
|
|
count = min(uio->uio_resid, PAGESIZE - offset);
|
|
|
|
}
|
|
|
|
if (uio->uio_resid > 0)
|
|
|
|
return (ENOSPC);
|
|
|
|
else
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1998-06-07 17:13:14 +00:00
|
|
|
ctxioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
|
1994-10-01 17:59:42 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int unit, i;
|
|
|
|
struct ctx_soft_registers *sr;
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
unit = UNIT(minor(dev));
|
|
|
|
sr = &(ctx_sr[unit]);
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case CTX_LIVE:
|
|
|
|
sr->cp0 &= ~SEE_STORED_VIDEO;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
break;
|
|
|
|
case CTX_GRAB:
|
|
|
|
sr->cp0 &= ~SEE_STORED_VIDEO;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
sr->cp0 |= ACQUIRE;
|
|
|
|
if (waitvb(sr->iobase)) /* wait for vert blank to start
|
|
|
|
* acquire */
|
|
|
|
error = ENODEV;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
if (waitvb(sr->iobase)) /* wait for two more to finish acquire */
|
|
|
|
error = ENODEV;
|
|
|
|
if (waitvb(sr->iobase))
|
|
|
|
error = ENODEV;
|
|
|
|
sr->cp0 &= ~ACQUIRE; /* turn off acquire and turn on
|
|
|
|
* display */
|
|
|
|
sr->cp0 |= SEE_STORED_VIDEO;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
break;
|
|
|
|
case CTX_H_ORGANIZE:
|
|
|
|
sr->cp0 &= ~PAGE_ROTATE;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
break;
|
|
|
|
case CTX_V_ORGANIZE:
|
|
|
|
sr->cp0 |= PAGE_ROTATE;
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0);
|
|
|
|
break;
|
|
|
|
case CTX_SET_LUT:
|
|
|
|
bcopy((u_char *) data, sr->lutp, LUTSIZE);
|
|
|
|
outb(sr->iobase + ctx_cp0, (u_char) 0);
|
|
|
|
outb(sr->iobase + ctx_cp1, (u_char) (LUT_LOAD_ENABLE | BLANK_DISPLAY));
|
|
|
|
for (i = 0; i < LUTSIZE; i++) {
|
|
|
|
outb(sr->iobase + ctx_lutaddr, i);
|
|
|
|
outb(sr->iobase + ctx_lutdata, sr->lutp[i]);
|
|
|
|
}
|
|
|
|
outb(sr->iobase + ctx_cp0, sr->cp0); /* restore control
|
|
|
|
* registers */
|
|
|
|
outb(sr->iobase + ctx_cp1, sr->cp1);
|
|
|
|
break;
|
|
|
|
case CTX_GET_LUT:
|
|
|
|
bcopy(sr->lutp, (u_char *) data, LUTSIZE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1995-12-10 13:40:44 +00:00
|
|
|
static int
|
1996-11-11 17:11:08 +00:00
|
|
|
waitvb(int port)
|
1994-10-01 17:59:42 +00:00
|
|
|
{ /* wait for a vertical blank, */
|
|
|
|
if (inb(port) == 0xff) /* 0xff means no board present */
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
while ((inb(port) & VERTICAL_BLANK) != 0) {
|
|
|
|
}
|
|
|
|
while ((inb(port) & VERTICAL_BLANK) == 0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
1999-04-28 10:54:24 +00:00
|
|
|
static int ctx_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
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static void
|
|
|
|
ctx_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( ! ctx_devsw_installed ) {
|
1995-11-29 10:49:16 +00:00
|
|
|
dev = makedev(CDEV_MAJOR,0);
|
|
|
|
cdevsw_add(&dev,&ctx_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
|
|
|
ctx_devsw_installed = 1;
|
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(ctxdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,ctx_drvinit,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
|
|
|
|
1994-10-01 17:59:42 +00:00
|
|
|
#endif /* NCTX > 0 */
|