1995-08-18 11:26:35 +00:00
|
|
|
/*
|
|
|
|
* IDE CD-ROM driver for FreeBSD.
|
|
|
|
* Supports ATAPI-compatible drives.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Cronyx Ltd.
|
|
|
|
* Author Serge Vakulenko, <vak@cronyx.ru>
|
|
|
|
*
|
|
|
|
* This software is distributed with NO WARRANTIES, not even the implied
|
|
|
|
* warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* Authors grant any other persons or organisations permission to use
|
|
|
|
* or modify this software as long as this message is kept with the software,
|
|
|
|
* all derivative works or modified versions.
|
|
|
|
*
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
* Version 1.9, Mon Oct 9 20:27:42 MSK 1995
|
1995-08-18 11:26:35 +00:00
|
|
|
*/
|
|
|
|
|
1995-09-07 08:20:18 +00:00
|
|
|
#include "wdc.h"
|
1995-08-18 11:26:35 +00:00
|
|
|
#include "wcd.h"
|
|
|
|
#if NWCD > 0 && NWDC > 0 && defined (ATAPI)
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/devconf.h>
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/cdio.h>
|
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
|
|
|
#include <sys/conf.h>
|
1995-11-29 10:49:16 +00:00
|
|
|
#ifdef DEVFS
|
|
|
|
#include <sys/devfsext.h>
|
|
|
|
#endif /*DEVFS*/
|
1995-12-08 11:19:42 +00:00
|
|
|
#include <i386/include/cpufunc.h>
|
|
|
|
#include <i386/isa/atapi.h>
|
|
|
|
|
|
|
|
static d_open_t wcdropen;
|
|
|
|
static d_open_t wcdbopen;
|
|
|
|
static d_close_t wcdrclose;
|
|
|
|
static d_close_t wcdbclose;
|
|
|
|
static d_ioctl_t wcdioctl;
|
|
|
|
static d_strategy_t wcdstrategy;
|
|
|
|
|
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
|
|
|
#define CDEV_MAJOR 69
|
|
|
|
#define BDEV_MAJOR 19
|
1995-12-08 11:19:42 +00:00
|
|
|
extern struct cdevsw wcd_cdevsw;
|
1995-12-08 23:23:00 +00:00
|
|
|
static struct bdevsw wcd_bdevsw =
|
1995-12-08 11:19:42 +00:00
|
|
|
{ wcdbopen, wcdbclose, wcdstrategy, wcdioctl, /*19*/
|
1995-12-10 19:44:58 +00:00
|
|
|
nodump, nopsize, 0, "wcd", &wcd_cdevsw, -1 };
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1995-12-08 23:23:00 +00:00
|
|
|
static struct cdevsw wcd_cdevsw =
|
1995-12-08 11:19:42 +00:00
|
|
|
{ wcdropen, wcdrclose, rawread, nowrite, /*69*/
|
|
|
|
wcdioctl, nostop, nullreset, nodevtotty,/* atapi */
|
|
|
|
seltrue, nommap, wcdstrategy, "wcd",
|
|
|
|
&wcd_bdevsw, -1 };
|
|
|
|
|
1995-12-29 22:17:12 +00:00
|
|
|
#ifndef ATAPI_STATIC
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
int wcdattach(struct atapi*, int, struct atapi_params*, int, struct kern_devconf*);
|
1995-10-29 16:10:06 +00:00
|
|
|
|
1995-09-30 00:11:19 +00:00
|
|
|
#define NUNIT (NWDC*2) /* Max. number of devices */
|
|
|
|
#define UNIT(d) ((minor(d) >> 3) & 3) /* Unit part of minor device number */
|
|
|
|
#define SECSIZE 2048 /* CD-ROM sector size in bytes */
|
1995-08-18 11:26:35 +00:00
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
#define F_BOPEN 0x0001 /* The block device is opened */
|
1995-09-30 00:11:19 +00:00
|
|
|
#define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
#define F_DEBUG 0x0004 /* Print debug info */
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disc table of contents.
|
|
|
|
*/
|
|
|
|
#define MAXTRK 99
|
|
|
|
struct toc {
|
|
|
|
struct ioc_toc_header hdr;
|
|
|
|
struct cd_toc_entry tab[MAXTRK+1]; /* One extra for the leadout */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Volume size info.
|
|
|
|
*/
|
|
|
|
struct volinfo {
|
|
|
|
u_long volsize; /* Volume size in blocks */
|
|
|
|
u_long blksize; /* Block size in bytes */
|
|
|
|
} info;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Current subchannel status.
|
|
|
|
*/
|
|
|
|
struct subchan {
|
|
|
|
u_char void0;
|
|
|
|
u_char audio_status;
|
|
|
|
u_short data_length;
|
|
|
|
u_char data_format;
|
|
|
|
u_char control;
|
|
|
|
u_char track;
|
|
|
|
u_char indx;
|
|
|
|
u_long abslba;
|
|
|
|
u_long rellba;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Audio Control Parameters Page
|
|
|
|
*/
|
|
|
|
struct audiopage {
|
|
|
|
/* Mode data header */
|
|
|
|
u_short data_length;
|
|
|
|
u_char medium_type;
|
|
|
|
u_char reserved1[5];
|
|
|
|
|
|
|
|
/* Audio control page */
|
|
|
|
u_char page_code;
|
|
|
|
#define AUDIO_PAGE 0x0e
|
|
|
|
#define AUDIO_PAGE_MASK 0x4e /* changeable values */
|
|
|
|
u_char param_len;
|
|
|
|
u_char flags;
|
|
|
|
#define CD_PA_SOTC 0x02 /* mandatory */
|
|
|
|
#define CD_PA_IMMED 0x04 /* always 1 */
|
|
|
|
u_char reserved3[3];
|
|
|
|
u_short lb_per_sec;
|
|
|
|
struct port_control {
|
|
|
|
u_char channels : 4;
|
|
|
|
#define CHANNEL_0 1 /* mandatory */
|
|
|
|
#define CHANNEL_1 2 /* mandatory */
|
|
|
|
#define CHANNEL_2 4 /* optional */
|
|
|
|
#define CHANNEL_3 8 /* optional */
|
|
|
|
u_char volume;
|
|
|
|
} port[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CD-ROM Capabilities and Mechanical Status Page
|
|
|
|
*/
|
|
|
|
struct cappage {
|
|
|
|
/* Mode data header */
|
|
|
|
u_short data_length;
|
|
|
|
u_char medium_type;
|
|
|
|
#define MDT_UNKNOWN 0x00
|
|
|
|
#define MDT_DATA_120 0x01
|
|
|
|
#define MDT_AUDIO_120 0x02
|
|
|
|
#define MDT_COMB_120 0x03
|
|
|
|
#define MDT_PHOTO_120 0x04
|
|
|
|
#define MDT_DATA_80 0x05
|
|
|
|
#define MDT_AUDIO_80 0x06
|
|
|
|
#define MDT_COMB_80 0x07
|
|
|
|
#define MDT_PHOTO_80 0x08
|
|
|
|
#define MDT_NO_DISC 0x70
|
|
|
|
#define MDT_DOOR_OPEN 0x71
|
|
|
|
#define MDT_FMT_ERROR 0x72
|
|
|
|
u_char reserved1[5];
|
|
|
|
|
|
|
|
/* Capabilities page */
|
|
|
|
u_char page_code;
|
|
|
|
#define CAP_PAGE 0x2a
|
|
|
|
u_char param_len;
|
|
|
|
u_char reserved2[2];
|
|
|
|
|
|
|
|
u_char audio_play : 1; /* audio play supported */
|
|
|
|
u_char composite : 1; /* composite audio/video supported */
|
|
|
|
u_char dport1 : 1; /* digital audio on port 1 */
|
|
|
|
u_char dport2 : 1; /* digital audio on port 2 */
|
|
|
|
u_char mode2_form1 : 1; /* mode 2 form 1 (XA) read */
|
|
|
|
u_char mode2_form2 : 1; /* mode 2 form 2 format */
|
|
|
|
u_char multisession : 1; /* multi-session photo-CD */
|
|
|
|
u_char : 1;
|
|
|
|
u_char cd_da : 1; /* audio-CD read supported */
|
|
|
|
u_char cd_da_stream : 1; /* CD-DA streaming */
|
|
|
|
u_char rw : 1; /* combined R-W subchannels */
|
|
|
|
u_char rw_corr : 1; /* R-W subchannel data corrected */
|
|
|
|
u_char c2 : 1; /* C2 error pointers supported */
|
|
|
|
u_char isrc : 1; /* can return the ISRC info */
|
|
|
|
u_char upc : 1; /* can return the catalog number UPC */
|
|
|
|
u_char : 1;
|
|
|
|
u_char lock : 1; /* could be locked */
|
|
|
|
u_char locked : 1; /* current lock state */
|
|
|
|
u_char prevent : 1; /* prevent jumper installed */
|
|
|
|
u_char eject : 1; /* can eject */
|
|
|
|
u_char : 1;
|
|
|
|
u_char mech : 3; /* loading mechanism type */
|
|
|
|
#define MECH_CADDY 0
|
|
|
|
#define MECH_TRAY 1
|
|
|
|
#define MECH_POPUP 2
|
|
|
|
#define MECH_CHANGER 4
|
|
|
|
#define MECH_CARTRIDGE 5
|
|
|
|
u_char sep_vol : 1; /* independent volume of channels */
|
|
|
|
u_char sep_mute : 1; /* independent mute of channels */
|
|
|
|
u_char : 6;
|
|
|
|
|
|
|
|
u_short max_speed; /* max raw data rate in bytes/1000 */
|
|
|
|
u_short max_vol_levels; /* number of discrete volume levels */
|
|
|
|
u_short buf_size; /* internal buffer size in bytes/1024 */
|
|
|
|
u_short cur_speed; /* current data rate in bytes/1000 */
|
1995-09-30 00:11:19 +00:00
|
|
|
|
|
|
|
/* Digital drive output format description (optional?) */
|
|
|
|
u_char reserved3;
|
|
|
|
u_char bckf : 1; /* data valid on failing edge of BCK */
|
|
|
|
u_char rch : 1; /* high LRCK indicates left channel */
|
|
|
|
u_char lsbf : 1; /* set if LSB first */
|
|
|
|
u_char dlen: 2;
|
|
|
|
#define DLEN_32 0 /* 32 BCKs */
|
|
|
|
#define DLEN_16 1 /* 16 BCKs */
|
|
|
|
#define DLEN_24 2 /* 24 BCKs */
|
|
|
|
#define DLEN_24_I2S 3 /* 24 BCKs (I2S) */
|
|
|
|
u_char : 3;
|
|
|
|
u_char reserved4[2];
|
1995-08-18 11:26:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wcd {
|
|
|
|
struct atapi *ata; /* Controller structure */
|
|
|
|
int unit; /* IDE bus drive unit */
|
|
|
|
int lun; /* Logical device unit */
|
|
|
|
int flags; /* Device state flags */
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
int refcnt; /* The number of raw opens */
|
1995-08-18 11:26:35 +00:00
|
|
|
struct buf queue; /* Queue of i/o requests */
|
|
|
|
struct atapi_params *param; /* Drive parameters table */
|
|
|
|
struct toc toc; /* Table of disc contents */
|
|
|
|
struct volinfo info; /* Volume size info */
|
|
|
|
struct audiopage au; /* Audio page info */
|
|
|
|
struct cappage cap; /* Capabilities page info */
|
|
|
|
struct audiopage aumask; /* Audio page mask */
|
|
|
|
struct subchan subchan; /* Subchannel info */
|
|
|
|
struct kern_devconf cf; /* Driver configuration info */
|
|
|
|
char description[80]; /* Device description */
|
1995-12-08 11:19:42 +00:00
|
|
|
#ifdef DEVFS
|
|
|
|
void *ra_devfs_token;
|
|
|
|
void *rc_devfs_token;
|
|
|
|
void *a_devfs_token;
|
|
|
|
void *c_devfs_token;
|
|
|
|
#endif
|
1995-08-18 11:26:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct wcd *wcdtab[NUNIT]; /* Drive info by unit number */
|
|
|
|
static int wcdnlun = 0; /* Number of configured drives */
|
|
|
|
|
|
|
|
static void wcd_start (struct wcd *t);
|
|
|
|
static void wcd_done (struct wcd *t, struct buf *bp, int resid,
|
|
|
|
struct atapires result);
|
|
|
|
static void wcd_error (struct wcd *t, struct atapires result);
|
|
|
|
static int wcd_read_toc (struct wcd *t);
|
|
|
|
static int wcd_request_wait (struct wcd *t, u_char cmd, u_char a1, u_char a2,
|
|
|
|
u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8,
|
|
|
|
u_char a9, char *addr, int count);
|
1995-11-20 12:42:39 +00:00
|
|
|
static int wcd_externalize (struct kern_devconf*, struct sysctl_req *);
|
1995-08-18 11:26:35 +00:00
|
|
|
static int wcd_goaway (struct kern_devconf *kdc, int force);
|
|
|
|
static void wcd_describe (struct wcd *t);
|
1995-10-29 16:10:06 +00:00
|
|
|
static int wcd_open(dev_t dev, int rawflag);
|
1995-08-18 11:26:35 +00:00
|
|
|
static int wcd_setchan (struct wcd *t,
|
|
|
|
u_char c0, u_char c1, u_char c2, u_char c3);
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
static int wcd_eject (struct wcd *t);
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
static struct kern_devconf cftemplate = {
|
|
|
|
0, 0, 0, "wcd", 0, { MDDT_DISK, 0 },
|
|
|
|
wcd_externalize, 0, wcd_goaway, DISK_EXTERNALLEN,
|
|
|
|
0, 0, DC_IDLE, "ATAPI compact disc",
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump the array in hexadecimal format for debugging purposes.
|
|
|
|
*/
|
|
|
|
static void wcd_dump (int lun, char *label, void *data, int len)
|
|
|
|
{
|
|
|
|
u_char *p = data;
|
|
|
|
|
|
|
|
printf ("wcd%d: %s %x", lun, label, *p++);
|
|
|
|
while (--len > 0)
|
|
|
|
printf ("-%x", *p++);
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
|
1995-11-20 12:42:39 +00:00
|
|
|
static int wcd_externalize (struct kern_devconf *kdc, struct sysctl_req *req)
|
1995-08-18 11:26:35 +00:00
|
|
|
{
|
1995-11-20 12:42:39 +00:00
|
|
|
return disk_externalize (wcdtab[kdc->kdc_unit]->unit, req);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wcd_goaway (struct kern_devconf *kdc, int force)
|
|
|
|
{
|
|
|
|
dev_detach (kdc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-12-29 22:17:12 +00:00
|
|
|
#ifndef ATAPI_STATIC
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
int
|
1995-10-28 15:39:31 +00:00
|
|
|
wcdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug,
|
1995-08-18 11:26:35 +00:00
|
|
|
struct kern_devconf *parent)
|
|
|
|
{
|
|
|
|
struct wcd *t;
|
|
|
|
struct atapires result;
|
1995-12-08 11:19:42 +00:00
|
|
|
int lun;
|
|
|
|
char name[32];
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
if (wcdnlun >= NUNIT) {
|
|
|
|
printf ("wcd: too many units\n");
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return (0);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
1995-10-28 17:45:04 +00:00
|
|
|
if (!atapi_request_immediate) {
|
|
|
|
printf("wcd: configuration error, ATAPI core code not present!\n");
|
|
|
|
printf("wcd: check `options ATAPI_STATIC' in your kernel config file!\n");
|
|
|
|
return (0);
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
t = malloc (sizeof (struct wcd), M_TEMP, M_NOWAIT);
|
|
|
|
if (! t) {
|
|
|
|
printf ("wcd: out of memory\n");
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return (0);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
wcdtab[wcdnlun] = t;
|
|
|
|
bzero (t, sizeof (struct wcd));
|
|
|
|
t->ata = ata;
|
|
|
|
t->unit = unit;
|
1995-12-08 11:19:42 +00:00
|
|
|
lun = t->lun = wcdnlun++;
|
1995-08-18 11:26:35 +00:00
|
|
|
t->param = ap;
|
|
|
|
t->flags = F_MEDIA_CHANGED;
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
t->refcnt = 0;
|
1995-08-18 11:26:35 +00:00
|
|
|
if (debug) {
|
|
|
|
t->flags |= F_DEBUG;
|
|
|
|
/* Print params. */
|
|
|
|
wcd_dump (t->lun, "info", ap, sizeof *ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get drive capabilities. */
|
|
|
|
result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE,
|
|
|
|
0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8, sizeof (t->cap),
|
|
|
|
0, 0, 0, 0, 0, 0, 0, (char*) &t->cap, sizeof (t->cap));
|
|
|
|
|
1995-09-30 00:11:19 +00:00
|
|
|
/* Do it twice to avoid the stale media changed state. */
|
|
|
|
if (result.code == RES_ERR &&
|
|
|
|
(result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)
|
1995-09-09 11:41:04 +00:00
|
|
|
result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE,
|
|
|
|
0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8,
|
|
|
|
sizeof (t->cap), 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
(char*) &t->cap, sizeof (t->cap));
|
1995-09-30 00:11:19 +00:00
|
|
|
|
|
|
|
/* Some drives have shorter capabilities page. */
|
|
|
|
if (result.code == RES_UNDERRUN)
|
|
|
|
result.code = 0;
|
|
|
|
|
1995-08-18 11:26:35 +00:00
|
|
|
if (result.code == 0) {
|
|
|
|
wcd_describe (t);
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
wcd_dump (t->lun, "cap", &t->cap, sizeof t->cap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register driver */
|
|
|
|
t->cf = cftemplate;
|
|
|
|
t->cf.kdc_unit = t->lun;
|
|
|
|
t->cf.kdc_parent = parent;
|
|
|
|
t->cf.kdc_description = t->description;
|
|
|
|
strcpy (t->description, cftemplate.kdc_description);
|
|
|
|
strcat (t->description, ": ");
|
|
|
|
strncpy (t->description + strlen(t->description),
|
|
|
|
ap->model, sizeof(ap->model));
|
|
|
|
dev_attach (&t->cf);
|
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
|
|
|
#ifdef DEVFS
|
|
|
|
#define WDC_UID 0
|
|
|
|
#define WDC_GID 13
|
|
|
|
sprintf(name, "rwcd%da",lun);
|
|
|
|
t->ra_devfs_token = devfs_add_devsw(
|
|
|
|
"/", name, &wcd_cdevsw, (lun * 8),
|
|
|
|
DV_CHR, WDC_UID, WDC_GID, 0600);
|
|
|
|
|
|
|
|
sprintf(name, "rwcd%dc",lun);
|
|
|
|
t->rc_devfs_token = devfs_add_devsw(
|
|
|
|
"/", name, &wcd_cdevsw, (lun * 8) + RAW_PART,
|
|
|
|
DV_CHR, WDC_UID, WDC_GID, 0600);
|
|
|
|
|
|
|
|
sprintf(name, "wcd%da",lun);
|
|
|
|
t->a_devfs_token = devfs_add_devsw(
|
|
|
|
"/", name, &wcd_bdevsw, (lun * 8),
|
|
|
|
DV_BLK, WDC_UID, WDC_GID, 0600);
|
|
|
|
|
|
|
|
sprintf(name, "wcd%dc",lun);
|
|
|
|
t->c_devfs_token = devfs_add_devsw(
|
|
|
|
"/", name, &wcd_bdevsw, (lun * 8) + RAW_PART,
|
|
|
|
DV_BLK, WDC_UID, WDC_GID, 0600);
|
|
|
|
#endif
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return (1);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wcd_describe (struct wcd *t)
|
|
|
|
{
|
|
|
|
char *m;
|
|
|
|
|
|
|
|
t->cap.max_speed = ntohs (t->cap.max_speed);
|
|
|
|
t->cap.max_vol_levels = ntohs (t->cap.max_vol_levels);
|
|
|
|
t->cap.buf_size = ntohs (t->cap.buf_size);
|
|
|
|
t->cap.cur_speed = ntohs (t->cap.cur_speed);
|
|
|
|
|
|
|
|
printf ("wcd%d: ", t->lun);
|
|
|
|
if (t->cap.cur_speed != t->cap.max_speed)
|
|
|
|
printf ("%d/", t->cap.cur_speed * 1000 / 1024);
|
1995-09-30 00:11:19 +00:00
|
|
|
printf ("%dKb/sec", t->cap.max_speed * 1000 / 1024);
|
1995-08-18 11:26:35 +00:00
|
|
|
if (t->cap.buf_size)
|
|
|
|
printf (", %dKb cache", t->cap.buf_size);
|
|
|
|
|
|
|
|
if (t->cap.audio_play)
|
|
|
|
printf (", audio play");
|
|
|
|
if (t->cap.max_vol_levels)
|
|
|
|
printf (", %d volume levels", t->cap.max_vol_levels);
|
|
|
|
|
|
|
|
switch (t->cap.mech) {
|
|
|
|
default: m = 0; break;
|
|
|
|
case MECH_CADDY: m = "caddy"; break;
|
|
|
|
case MECH_TRAY: m = "tray"; break;
|
|
|
|
case MECH_POPUP: m = "popup"; break;
|
|
|
|
case MECH_CHANGER: m = "changer"; break;
|
|
|
|
case MECH_CARTRIDGE: m = "cartridge"; break;
|
|
|
|
}
|
|
|
|
if (m)
|
|
|
|
printf (", %s%s", t->cap.eject ? "ejectable " : "", m);
|
|
|
|
else if (t->cap.eject)
|
|
|
|
printf (", eject");
|
|
|
|
printf ("\n");
|
|
|
|
|
|
|
|
printf ("wcd%d: ", t->lun);
|
|
|
|
switch (t->cap.medium_type) {
|
|
|
|
case MDT_UNKNOWN: printf ("medium type unknown"); break;
|
|
|
|
case MDT_DATA_120: printf ("120mm data disc loaded"); break;
|
|
|
|
case MDT_AUDIO_120: printf ("120mm audio disc loaded"); break;
|
|
|
|
case MDT_COMB_120: printf ("120mm data/audio disc loaded"); break;
|
|
|
|
case MDT_PHOTO_120: printf ("120mm photo disc loaded"); break;
|
|
|
|
case MDT_DATA_80: printf ("80mm data disc loaded"); break;
|
|
|
|
case MDT_AUDIO_80: printf ("80mm audio disc loaded"); break;
|
|
|
|
case MDT_COMB_80: printf ("80mm data/audio disc loaded"); break;
|
|
|
|
case MDT_PHOTO_80: printf ("80mm photo disc loaded"); break;
|
|
|
|
case MDT_NO_DISC: printf ("no disc inside"); break;
|
|
|
|
case MDT_DOOR_OPEN: printf ("door open"); break;
|
|
|
|
case MDT_FMT_ERROR: printf ("medium format error"); break;
|
|
|
|
default: printf ("medium type=0x%x", t->cap.medium_type); break;
|
|
|
|
}
|
|
|
|
if (t->cap.lock)
|
|
|
|
printf (t->cap.locked ? ", locked" : ", unlocked");
|
|
|
|
if (t->cap.prevent)
|
|
|
|
printf (", lock protected");
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
|
1995-10-28 15:39:31 +00:00
|
|
|
static int
|
|
|
|
wcd_open (dev_t dev, int rawflag)
|
1995-08-18 11:26:35 +00:00
|
|
|
{
|
|
|
|
int lun = UNIT(dev);
|
|
|
|
struct wcd *t;
|
|
|
|
struct atapires result;
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
/* Check that the device number is legal
|
|
|
|
* and the ATAPI driver is loaded. */
|
|
|
|
if (lun >= wcdnlun || ! atapi_request_immediate)
|
1995-08-18 11:26:35 +00:00
|
|
|
return (ENXIO);
|
|
|
|
t = wcdtab[lun];
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
/* On the first open, read the table of contents. */
|
|
|
|
if (! (t->flags & F_BOPEN) && ! t->refcnt) {
|
|
|
|
/* Read table of contents. */
|
|
|
|
if (wcd_read_toc (t) < 0)
|
|
|
|
return (EIO);
|
1995-08-18 11:26:35 +00:00
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
/* Lock the media. */
|
|
|
|
wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
if (rawflag)
|
|
|
|
++t->refcnt;
|
|
|
|
else
|
|
|
|
t->flags |= F_BOPEN;
|
|
|
|
return (0);
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
int wcdbopen (dev_t dev, int flags, int fmt, struct proc *p)
|
|
|
|
{
|
|
|
|
return wcd_open (dev, 0);
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
int wcdropen (dev_t dev, int flags, int fmt, struct proc *p)
|
|
|
|
{
|
|
|
|
return wcd_open (dev, 1);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close the device. Only called if we are the LAST
|
|
|
|
* occurence of an open device.
|
|
|
|
*/
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
int wcdbclose (dev_t dev, int flags, int fmt, struct proc *p)
|
1995-08-18 11:26:35 +00:00
|
|
|
{
|
|
|
|
int lun = UNIT(dev);
|
|
|
|
struct wcd *t = wcdtab[lun];
|
|
|
|
|
|
|
|
/* If we were the last open of the entire device, release it. */
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
if (! t->refcnt)
|
|
|
|
wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
t->flags &= ~F_BOPEN;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int wcdrclose (dev_t dev, int flags, int fmt, struct proc *p)
|
|
|
|
{
|
|
|
|
int lun = UNIT(dev);
|
|
|
|
struct wcd *t = wcdtab[lun];
|
|
|
|
|
|
|
|
/* If we were the last open of the entire device, release it. */
|
|
|
|
if (! (t->flags & F_BOPEN) && t->refcnt == 1)
|
|
|
|
wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
--t->refcnt;
|
1995-08-18 11:26:35 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actually translate the requested transfer into one the physical driver can
|
|
|
|
* understand. The transfer is described by a buf and will include only one
|
|
|
|
* physical transfer.
|
|
|
|
*/
|
1995-09-08 19:57:13 +00:00
|
|
|
void wcdstrategy (struct buf *bp)
|
1995-08-18 11:26:35 +00:00
|
|
|
{
|
|
|
|
int lun = UNIT(bp->b_dev);
|
|
|
|
struct wcd *t = wcdtab[lun];
|
|
|
|
int x;
|
|
|
|
|
|
|
|
/* Can't ever write to a CD. */
|
|
|
|
if (! (bp->b_flags & B_READ)) {
|
|
|
|
bp->b_error = EROFS;
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
biodone (bp);
|
1995-09-08 19:57:13 +00:00
|
|
|
return;
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If it's a null transfer, return immediatly. */
|
|
|
|
if (bp->b_bcount == 0) {
|
|
|
|
bp->b_resid = 0;
|
|
|
|
biodone (bp);
|
1995-09-08 19:57:13 +00:00
|
|
|
return;
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Process transfer request. */
|
|
|
|
bp->b_pblkno = bp->b_blkno;
|
|
|
|
bp->b_resid = bp->b_bcount;
|
|
|
|
x = splbio();
|
|
|
|
|
|
|
|
/* Place it in the queue of disk activities for this disk. */
|
|
|
|
disksort (&t->queue, bp);
|
|
|
|
|
|
|
|
/* Tell the device to get going on the transfer if it's
|
|
|
|
* not doing anything, otherwise just wait for completion. */
|
|
|
|
wcd_start (t);
|
|
|
|
splx(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look to see if there is a buf waiting for the device
|
|
|
|
* and that the device is not already busy. If both are true,
|
|
|
|
* It dequeues the buf and creates an ATAPI command to perform the
|
|
|
|
* transfer in the buf.
|
|
|
|
* The bufs are queued by the strategy routine (wcdstrategy).
|
|
|
|
* Must be called at the correct (splbio) level.
|
|
|
|
*/
|
|
|
|
static void wcd_start (struct wcd *t)
|
|
|
|
{
|
|
|
|
struct buf *bp = t->queue.b_actf;
|
|
|
|
u_long blkno, nblk;
|
|
|
|
|
|
|
|
/* See if there is a buf to do and we are not already doing one. */
|
|
|
|
if (! bp)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Unqueue the request. */
|
|
|
|
t->queue.b_actf = bp->b_actf;
|
|
|
|
|
|
|
|
/* Should reject all queued entries if media have changed. */
|
|
|
|
if (t->flags & F_MEDIA_CHANGED) {
|
|
|
|
bp->b_error = EIO;
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
biodone (bp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a buf, now we should make a command
|
|
|
|
* First, translate the block to absolute and put it in terms of the
|
|
|
|
* logical blocksize of the device.
|
|
|
|
* What if something asks for 512 bytes not on a 2k boundary? */
|
|
|
|
blkno = bp->b_blkno / (SECSIZE / 512);
|
|
|
|
nblk = (bp->b_bcount + (SECSIZE - 1)) / SECSIZE;
|
|
|
|
|
|
|
|
atapi_request_callback (t->ata, t->unit, ATAPI_READ_BIG, 0,
|
|
|
|
blkno>>24, blkno>>16, blkno>>8, blkno, 0, nblk>>8, nblk, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, (u_char*) bp->b_un.b_addr, bp->b_bcount,
|
|
|
|
wcd_done, t, bp);
|
|
|
|
t->cf.kdc_state = DC_BUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wcd_done (struct wcd *t, struct buf *bp, int resid,
|
|
|
|
struct atapires result)
|
|
|
|
{
|
|
|
|
if (result.code) {
|
|
|
|
wcd_error (t, result);
|
|
|
|
bp->b_error = EIO;
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
} else
|
|
|
|
bp->b_resid = resid;
|
|
|
|
biodone (bp);
|
|
|
|
t->cf.kdc_state = DC_IDLE;
|
|
|
|
wcd_start (t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wcd_error (struct wcd *t, struct atapires result)
|
|
|
|
{
|
|
|
|
if (result.code != RES_ERR)
|
|
|
|
return;
|
1995-09-30 00:11:19 +00:00
|
|
|
switch (result.error & AER_SKEY) {
|
1995-08-18 11:26:35 +00:00
|
|
|
case AER_SK_NOT_READY:
|
1995-09-30 00:11:19 +00:00
|
|
|
if (result.error & ~AER_SKEY) {
|
|
|
|
/* Audio disc. */
|
|
|
|
printf ("wcd%d: cannot read audio disc\n", t->lun);
|
|
|
|
return;
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
/* Tray open. */
|
|
|
|
if (! (t->flags & F_MEDIA_CHANGED))
|
|
|
|
printf ("wcd%d: tray open\n", t->lun);
|
|
|
|
t->flags |= F_MEDIA_CHANGED;
|
1995-09-30 00:11:19 +00:00
|
|
|
return;
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
case AER_SK_UNIT_ATTENTION:
|
|
|
|
/* Media changed. */
|
|
|
|
if (! (t->flags & F_MEDIA_CHANGED))
|
|
|
|
printf ("wcd%d: media changed\n", t->lun);
|
|
|
|
t->flags |= F_MEDIA_CHANGED;
|
1995-09-30 00:11:19 +00:00
|
|
|
return;
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
case AER_SK_ILLEGAL_REQUEST:
|
|
|
|
/* Unknown command or invalid command arguments. */
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
printf ("wcd%d: invalid command\n", t->lun);
|
1995-09-30 00:11:19 +00:00
|
|
|
return;
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
1995-09-30 00:11:19 +00:00
|
|
|
printf ("wcd%d: i/o error, status=%b, error=%b\n", t->lun,
|
|
|
|
result.status, ARS_BITS, result.error, AER_BITS);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wcd_request_wait (struct wcd *t, u_char cmd, u_char a1, u_char a2,
|
|
|
|
u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8,
|
|
|
|
u_char a9, char *addr, int count)
|
|
|
|
{
|
|
|
|
struct atapires result;
|
|
|
|
|
|
|
|
t->cf.kdc_state = DC_BUSY;
|
|
|
|
result = atapi_request_wait (t->ata, t->unit, cmd,
|
|
|
|
a1, a2, a3, a4, a5, a6, a7, a8, a9, 0, 0, 0, 0, 0, 0,
|
|
|
|
addr, count);
|
|
|
|
t->cf.kdc_state = DC_IDLE;
|
|
|
|
if (result.code) {
|
|
|
|
wcd_error (t, result);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void lba2msf (int lba, u_char *m, u_char *s, u_char *f)
|
|
|
|
{
|
|
|
|
lba += 150; /* offset of first logical frame */
|
|
|
|
lba &= 0xffffff; /* negative lbas use only 24 bits */
|
|
|
|
*m = lba / (60 * 75);
|
|
|
|
lba %= (60 * 75);
|
|
|
|
*s = lba / 75;
|
|
|
|
*f = lba % 75;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform special action on behalf of the user.
|
|
|
|
* Knows about the internals of this device
|
|
|
|
*/
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
int wcdioctl (dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p)
|
1995-08-18 11:26:35 +00:00
|
|
|
{
|
|
|
|
int lun = UNIT(dev);
|
|
|
|
struct wcd *t = wcdtab[lun];
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
struct atapires result;
|
1995-08-18 11:26:35 +00:00
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if (t->flags & F_MEDIA_CHANGED)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case CDIOCSETDEBUG:
|
|
|
|
case CDIOCCLRDEBUG:
|
|
|
|
case CDIOCRESET:
|
|
|
|
/* These ops are media change transparent. */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Read table of contents. */
|
|
|
|
wcd_read_toc (t);
|
|
|
|
|
|
|
|
/* Lock the media. */
|
|
|
|
wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
switch (cmd) {
|
|
|
|
default:
|
|
|
|
return (ENOTTY);
|
|
|
|
|
|
|
|
case CDIOCSETDEBUG:
|
1995-09-30 00:11:19 +00:00
|
|
|
if (p->p_cred->pc_ucred->cr_uid)
|
|
|
|
return (EPERM);
|
1995-08-18 11:26:35 +00:00
|
|
|
t->flags |= F_DEBUG;
|
|
|
|
atapi_debug (t->ata, 1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case CDIOCCLRDEBUG:
|
1995-09-30 00:11:19 +00:00
|
|
|
if (p->p_cred->pc_ucred->cr_uid)
|
|
|
|
return (EPERM);
|
1995-08-18 11:26:35 +00:00
|
|
|
t->flags &= ~F_DEBUG;
|
|
|
|
atapi_debug (t->ata, 0);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case CDIOCRESUME:
|
|
|
|
return wcd_request_wait (t, ATAPI_PAUSE,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCPAUSE:
|
|
|
|
return wcd_request_wait (t, ATAPI_PAUSE,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCSTART:
|
|
|
|
return wcd_request_wait (t, ATAPI_START_STOP,
|
|
|
|
1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCSTOP:
|
|
|
|
return wcd_request_wait (t, ATAPI_START_STOP,
|
|
|
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCALLOW:
|
|
|
|
return wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCPREVENT:
|
|
|
|
return wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCRESET:
|
1995-09-30 00:11:19 +00:00
|
|
|
if (p->p_cred->pc_ucred->cr_uid)
|
|
|
|
return (EPERM);
|
1995-08-18 11:26:35 +00:00
|
|
|
return wcd_request_wait (t, ATAPI_TEST_UNIT_READY,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCEJECT:
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
/* Don't allow eject if the device is opened
|
|
|
|
* by somebody (not us) in block mode. */
|
|
|
|
if ((t->flags & F_BOPEN) && t->refcnt)
|
|
|
|
return (EBUSY);
|
|
|
|
return wcd_eject (t);
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
case CDIOREADTOCHEADER:
|
1995-09-30 00:11:19 +00:00
|
|
|
if (! t->toc.hdr.ending_track)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return (EIO);
|
1995-08-18 11:26:35 +00:00
|
|
|
bcopy (&t->toc.hdr, addr, sizeof t->toc.hdr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CDIOREADTOCENTRYS: {
|
|
|
|
struct ioc_read_toc_entry *te =
|
|
|
|
(struct ioc_read_toc_entry*) addr;
|
|
|
|
struct toc *toc = &t->toc;
|
|
|
|
struct toc buf;
|
|
|
|
u_long len;
|
1996-01-30 11:32:20 +00:00
|
|
|
u_char starting_track = te->starting_track;
|
1995-08-18 11:26:35 +00:00
|
|
|
|
1995-09-30 00:11:19 +00:00
|
|
|
if (! t->toc.hdr.ending_track)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return (EIO);
|
1995-08-18 11:26:35 +00:00
|
|
|
|
1996-01-30 12:07:15 +00:00
|
|
|
if ( te->data_len < sizeof(toc->tab[0])
|
1996-01-30 11:32:20 +00:00
|
|
|
|| (te->data_len % sizeof(toc->tab[0])) != 0
|
|
|
|
)
|
|
|
|
return EINVAL;
|
|
|
|
if (te->address_format != CD_MSF_FORMAT &&
|
|
|
|
te->address_format != CD_LBA_FORMAT)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if (starting_track == 0)
|
|
|
|
starting_track = toc->hdr.starting_track;
|
|
|
|
else if (starting_track == 170) /* Handle leadout request */
|
|
|
|
starting_track = toc->hdr.ending_track + 1;
|
|
|
|
else if (starting_track < toc->hdr.starting_track ||
|
|
|
|
starting_track > toc->hdr.ending_track + 1)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
len = ((toc->hdr.ending_track + 1 - starting_track) + 1) *
|
1995-08-18 11:26:35 +00:00
|
|
|
sizeof(toc->tab[0]);
|
|
|
|
if (te->data_len < len)
|
|
|
|
len = te->data_len;
|
|
|
|
|
|
|
|
/* Convert to MSF format, if needed. */
|
|
|
|
if (te->address_format == CD_MSF_FORMAT) {
|
|
|
|
struct cd_toc_entry *e;
|
|
|
|
|
|
|
|
buf = t->toc;
|
|
|
|
toc = &buf;
|
1996-01-30 11:32:20 +00:00
|
|
|
e = toc->tab + (toc->hdr.ending_track + 1 -
|
|
|
|
toc->hdr.starting_track) + 1;
|
1995-08-18 11:26:35 +00:00
|
|
|
while (--e >= toc->tab)
|
|
|
|
lba2msf (e->addr.lba, &e->addr.msf.minute,
|
|
|
|
&e->addr.msf.second, &e->addr.msf.frame);
|
|
|
|
}
|
1996-01-30 11:32:20 +00:00
|
|
|
return copyout (toc->tab + starting_track -
|
|
|
|
toc->hdr.starting_track, te->data, len);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
case CDIOCREADSUBCHANNEL: {
|
|
|
|
struct ioc_read_subchannel *args =
|
|
|
|
(struct ioc_read_subchannel*) addr;
|
|
|
|
struct cd_sub_channel_info data;
|
|
|
|
u_long len = args->data_len;
|
|
|
|
int abslba, rellba;
|
|
|
|
|
|
|
|
if (len > sizeof(data) ||
|
|
|
|
len < sizeof(struct cd_sub_channel_header))
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
if (wcd_request_wait (t, ATAPI_READ_SUBCHANNEL, 0, 0x40, 1, 0,
|
|
|
|
0, 0, sizeof (t->subchan) >> 8, sizeof (t->subchan),
|
|
|
|
0, (char*)&t->subchan, sizeof (t->subchan)) != 0)
|
|
|
|
return (EIO);
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
wcd_dump (t->lun, "subchan", &t->subchan, sizeof t->subchan);
|
|
|
|
|
|
|
|
abslba = ntohl (t->subchan.abslba);
|
|
|
|
rellba = ntohl (t->subchan.rellba);
|
|
|
|
if (args->address_format == CD_MSF_FORMAT) {
|
|
|
|
lba2msf (abslba,
|
|
|
|
&data.what.position.absaddr.msf.minute,
|
|
|
|
&data.what.position.absaddr.msf.second,
|
|
|
|
&data.what.position.absaddr.msf.frame);
|
|
|
|
lba2msf (rellba,
|
|
|
|
&data.what.position.reladdr.msf.minute,
|
|
|
|
&data.what.position.reladdr.msf.second,
|
|
|
|
&data.what.position.reladdr.msf.frame);
|
|
|
|
} else {
|
|
|
|
data.what.position.absaddr.lba = abslba;
|
|
|
|
data.what.position.reladdr.lba = rellba;
|
|
|
|
}
|
|
|
|
data.header.audio_status = t->subchan.audio_status;
|
|
|
|
data.what.position.control = t->subchan.control & 0xf;
|
|
|
|
data.what.position.track_number = t->subchan.track;
|
|
|
|
data.what.position.index_number = t->subchan.indx;
|
|
|
|
|
1996-01-30 11:32:20 +00:00
|
|
|
return copyout (&data, args->data, len);
|
1995-08-18 11:26:35 +00:00
|
|
|
}
|
|
|
|
case CDIOCPLAYMSF: {
|
|
|
|
struct ioc_play_msf *args = (struct ioc_play_msf*) addr;
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return wcd_request_wait (t, ATAPI_PLAY_MSF, 0, 0,
|
1995-08-18 11:26:35 +00:00
|
|
|
args->start_m, args->start_s, args->start_f,
|
|
|
|
args->end_m, args->end_s, args->end_f, 0, 0, 0);
|
|
|
|
}
|
|
|
|
case CDIOCPLAYBLOCKS: {
|
|
|
|
struct ioc_play_blocks *args = (struct ioc_play_blocks*) addr;
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return wcd_request_wait (t, ATAPI_PLAY_BIG, 0,
|
1995-08-18 11:26:35 +00:00
|
|
|
args->blk >> 24 & 0xff, args->blk >> 16 & 0xff,
|
|
|
|
args->blk >> 8 & 0xff, args->blk & 0xff,
|
|
|
|
args->len >> 24 & 0xff, args->len >> 16 & 0xff,
|
|
|
|
args->len >> 8 & 0xff, args->len & 0xff, 0, 0);
|
|
|
|
}
|
|
|
|
case CDIOCPLAYTRACKS: {
|
|
|
|
struct ioc_play_track *args = (struct ioc_play_track*) addr;
|
|
|
|
u_long start, len;
|
|
|
|
int t1, t2;
|
|
|
|
|
1995-09-30 00:11:19 +00:00
|
|
|
if (! t->toc.hdr.ending_track)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return (EIO);
|
1995-09-30 00:11:19 +00:00
|
|
|
|
1995-08-18 11:26:35 +00:00
|
|
|
/* Ignore index fields,
|
|
|
|
* play from start_track to end_track inclusive. */
|
|
|
|
if (args->end_track < t->toc.hdr.ending_track+1)
|
|
|
|
++args->end_track;
|
|
|
|
if (args->end_track > t->toc.hdr.ending_track+1)
|
|
|
|
args->end_track = t->toc.hdr.ending_track+1;
|
|
|
|
t1 = args->start_track - t->toc.hdr.starting_track;
|
|
|
|
t2 = args->end_track - t->toc.hdr.starting_track;
|
|
|
|
if (t1 < 0 || t2 < 0)
|
|
|
|
return (EINVAL);
|
|
|
|
start = t->toc.tab[t1].addr.lba;
|
|
|
|
len = t->toc.tab[t2].addr.lba - start;
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
return wcd_request_wait (t, ATAPI_PLAY_BIG, 0,
|
1995-08-18 11:26:35 +00:00
|
|
|
start >> 24 & 0xff, start >> 16 & 0xff,
|
|
|
|
start >> 8 & 0xff, start & 0xff,
|
|
|
|
len >> 24 & 0xff, len >> 16 & 0xff,
|
|
|
|
len >> 8 & 0xff, len & 0xff, 0, 0);
|
|
|
|
}
|
|
|
|
case CDIOCGETVOL: {
|
|
|
|
struct ioc_vol *arg = (struct ioc_vol*) addr;
|
|
|
|
|
|
|
|
error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE,
|
|
|
|
0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0,
|
|
|
|
(char*) &t->au, sizeof (t->au));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
wcd_dump (t->lun, "au", &t->au, sizeof t->au);
|
|
|
|
if (t->au.page_code != AUDIO_PAGE)
|
|
|
|
return (EIO);
|
|
|
|
arg->vol[0] = t->au.port[0].volume;
|
|
|
|
arg->vol[1] = t->au.port[1].volume;
|
|
|
|
arg->vol[2] = t->au.port[2].volume;
|
|
|
|
arg->vol[3] = t->au.port[3].volume;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CDIOCSETVOL: {
|
|
|
|
struct ioc_vol *arg = (struct ioc_vol*) addr;
|
|
|
|
|
|
|
|
error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE,
|
|
|
|
0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0,
|
|
|
|
(char*) &t->au, sizeof (t->au));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
wcd_dump (t->lun, "au", &t->au, sizeof t->au);
|
|
|
|
if (t->au.page_code != AUDIO_PAGE)
|
|
|
|
return (EIO);
|
|
|
|
|
|
|
|
error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0,
|
|
|
|
AUDIO_PAGE_MASK, 0, 0, 0, 0, sizeof (t->aumask) >> 8,
|
|
|
|
sizeof (t->aumask), 0, (char*) &t->aumask,
|
|
|
|
sizeof (t->aumask));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
wcd_dump (t->lun, "mask", &t->aumask, sizeof t->aumask);
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
/* Sony-55E requires the data length field to be zeroed. */
|
|
|
|
t->au.data_length = 0;
|
|
|
|
|
1995-08-18 11:26:35 +00:00
|
|
|
t->au.port[0].channels = CHANNEL_0;
|
|
|
|
t->au.port[1].channels = CHANNEL_1;
|
|
|
|
t->au.port[0].volume = arg->vol[0] & t->aumask.port[0].volume;
|
|
|
|
t->au.port[1].volume = arg->vol[1] & t->aumask.port[1].volume;
|
|
|
|
t->au.port[2].volume = arg->vol[2] & t->aumask.port[2].volume;
|
|
|
|
t->au.port[3].volume = arg->vol[3] & t->aumask.port[3].volume;
|
|
|
|
return wcd_request_wait (t, ATAPI_MODE_SELECT_BIG, 0x10,
|
|
|
|
0, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au),
|
|
|
|
0, (char*) &t->au, - sizeof (t->au));
|
|
|
|
}
|
|
|
|
case CDIOCSETPATCH: {
|
|
|
|
struct ioc_patch *arg = (struct ioc_patch*) addr;
|
|
|
|
|
|
|
|
return wcd_setchan (t, arg->patch[0], arg->patch[1],
|
|
|
|
arg->patch[2], arg->patch[3]);
|
|
|
|
}
|
|
|
|
case CDIOCSETMONO:
|
|
|
|
return wcd_setchan (t, CHANNEL_0 | CHANNEL_1,
|
|
|
|
CHANNEL_0 | CHANNEL_1, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCSETSTERIO:
|
|
|
|
return wcd_setchan (t, CHANNEL_0, CHANNEL_1, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCSETMUTE:
|
|
|
|
return wcd_setchan (t, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCSETLEFT:
|
|
|
|
return wcd_setchan (t, CHANNEL_0, CHANNEL_0, 0, 0);
|
|
|
|
|
|
|
|
case CDIOCSETRIGHT:
|
|
|
|
return wcd_setchan (t, CHANNEL_1, CHANNEL_1, 0, 0);
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the entire TOC for the disc into our internal buffer.
|
|
|
|
*/
|
|
|
|
static int wcd_read_toc (struct wcd *t)
|
|
|
|
{
|
|
|
|
int ntracks, len, i;
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
struct atapires result;
|
|
|
|
|
|
|
|
bzero (&t->toc, sizeof (t->toc));
|
|
|
|
bzero (&t->info, sizeof (t->info));
|
|
|
|
|
|
|
|
/* Check for the media.
|
|
|
|
* Do it twice to avoid the stale media changed state. */
|
|
|
|
result = atapi_request_wait (t->ata, t->unit, ATAPI_TEST_UNIT_READY,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
if (result.code == RES_ERR &&
|
|
|
|
(result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) {
|
|
|
|
t->flags |= F_MEDIA_CHANGED;
|
|
|
|
result = atapi_request_wait (t->ata, t->unit,
|
|
|
|
ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
if (result.code) {
|
|
|
|
wcd_error (t, result);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
t->flags &= ~F_MEDIA_CHANGED;
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
/* First read just the header, so we know how long the TOC is. */
|
|
|
|
len = sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry);
|
|
|
|
if (wcd_request_wait (t, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0,
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
len >> 8, len & 0xff, 0, (char*)&t->toc, len) != 0) {
|
|
|
|
err: bzero (&t->toc, sizeof (t->toc));
|
|
|
|
return (0);
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
ntracks = t->toc.hdr.ending_track - t->toc.hdr.starting_track + 1;
|
|
|
|
if (ntracks <= 0)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
goto err;
|
1995-08-18 11:26:35 +00:00
|
|
|
if (ntracks > MAXTRK)
|
|
|
|
ntracks = MAXTRK;
|
|
|
|
|
|
|
|
/* Now read the whole schmeer. */
|
|
|
|
len = sizeof(struct ioc_toc_header) +
|
|
|
|
(ntracks+1) * sizeof(struct cd_toc_entry);
|
|
|
|
if (wcd_request_wait (t, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0,
|
|
|
|
len >> 8, len & 0xff, 0, (char*)&t->toc, len) & 0xff)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
goto err;
|
1995-08-18 11:26:35 +00:00
|
|
|
|
|
|
|
t->toc.hdr.len = ntohs (t->toc.hdr.len);
|
|
|
|
for (i=0; i<=ntracks; i++)
|
|
|
|
t->toc.tab[i].addr.lba = ntohl (t->toc.tab[i].addr.lba);
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
|
|
|
|
/* Decrement the total length of the disc.
|
|
|
|
* Some drives (e.g. Sony-55E) have this value too big. */
|
|
|
|
--t->toc.tab[ntracks].addr.lba;
|
|
|
|
|
|
|
|
/* Read disc capacity. */
|
|
|
|
if (wcd_request_wait (t, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, sizeof(t->info), 0, (char*)&t->info, sizeof(t->info)) != 0)
|
|
|
|
bzero (&t->info, sizeof (t->info));
|
|
|
|
t->info.volsize = ntohl (t->info.volsize);
|
|
|
|
t->info.blksize = ntohl (t->info.blksize);
|
|
|
|
|
|
|
|
/* Print the disc description string on every disc change.
|
|
|
|
* It would help to track the history of disc changes. */
|
|
|
|
if (t->info.volsize && t->toc.hdr.ending_track &&
|
|
|
|
(t->flags & F_MEDIA_CHANGED) && (t->flags & F_DEBUG)) {
|
|
|
|
printf ("wcd%d: ", t->lun);
|
|
|
|
if (t->toc.tab[0].control & 4)
|
|
|
|
printf ("%ldMB ", t->info.volsize / 512);
|
|
|
|
else
|
|
|
|
printf ("%ld:%ld audio ", t->info.volsize/75/60,
|
|
|
|
t->info.volsize/75%60);
|
|
|
|
printf ("(%ld sectors), %d tracks\n", t->info.volsize,
|
|
|
|
t->toc.hdr.ending_track - t->toc.hdr.starting_track + 1);
|
|
|
|
}
|
1995-08-18 11:26:35 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the audio channel masks.
|
|
|
|
*/
|
|
|
|
static int wcd_setchan (struct wcd *t,
|
|
|
|
u_char c0, u_char c1, u_char c2, u_char c3)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = wcd_request_wait (t, ATAPI_MODE_SENSE, 0, AUDIO_PAGE,
|
|
|
|
0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au), 0,
|
|
|
|
(char*) &t->au, sizeof (t->au));
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (t->flags & F_DEBUG)
|
|
|
|
wcd_dump (t->lun, "au", &t->au, sizeof t->au);
|
|
|
|
if (t->au.page_code != AUDIO_PAGE)
|
|
|
|
return (EIO);
|
|
|
|
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
/* Sony-55E requires the data length field to be zeroed. */
|
|
|
|
t->au.data_length = 0;
|
|
|
|
|
1995-08-18 11:26:35 +00:00
|
|
|
t->au.port[0].channels = c0;
|
|
|
|
t->au.port[1].channels = c1;
|
|
|
|
t->au.port[2].channels = c2;
|
|
|
|
t->au.port[3].channels = c3;
|
|
|
|
return wcd_request_wait (t, ATAPI_MODE_SELECT_BIG, 0x10,
|
|
|
|
0, 0, 0, 0, 0, sizeof (t->au) >> 8, sizeof (t->au),
|
|
|
|
0, (char*) &t->au, - sizeof (t->au));
|
|
|
|
}
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
|
|
|
|
static int wcd_eject (struct wcd *t)
|
|
|
|
{
|
|
|
|
struct atapires result;
|
|
|
|
|
|
|
|
/* Try to stop the disc. */
|
|
|
|
t->cf.kdc_state = DC_BUSY;
|
|
|
|
result = atapi_request_wait (t->ata, t->unit, ATAPI_START_STOP,
|
|
|
|
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
t->cf.kdc_state = DC_IDLE;
|
|
|
|
|
|
|
|
if (result.code == RES_ERR &&
|
|
|
|
((result.error & AER_SKEY) == AER_SK_NOT_READY ||
|
|
|
|
(result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) {
|
|
|
|
/*
|
|
|
|
* The disc was unloaded.
|
|
|
|
* Load it (close tray).
|
|
|
|
* Read the table of contents.
|
|
|
|
*/
|
|
|
|
int err = wcd_request_wait (t, ATAPI_START_STOP,
|
|
|
|
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
|
|
|
|
/* Read table of contents. */
|
|
|
|
wcd_read_toc (t);
|
|
|
|
|
|
|
|
/* Lock the media. */
|
|
|
|
wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.code) {
|
|
|
|
wcd_error (t, result);
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Give it some time to stop spinning. */
|
|
|
|
tsleep ((caddr_t)&lbolt, PRIBIO, "wcdej1", 0);
|
|
|
|
tsleep ((caddr_t)&lbolt, PRIBIO, "wcdej2", 0);
|
|
|
|
|
|
|
|
/* Unlock. */
|
|
|
|
wcd_request_wait (t, ATAPI_PREVENT_ALLOW,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
/* Eject. */
|
|
|
|
t->flags |= F_MEDIA_CHANGED;
|
|
|
|
return wcd_request_wait (t, ATAPI_START_STOP,
|
|
|
|
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WCD_MODULE
|
|
|
|
/*
|
|
|
|
* Loadable ATAPI CD-ROM driver stubs.
|
|
|
|
*/
|
|
|
|
#include <sys/exec.h>
|
|
|
|
#include <sys/sysent.h>
|
|
|
|
#include <sys/lkm.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Construct lkm_dev structures (see lkm.h).
|
|
|
|
* Our bdevsw/cdevsw slot numbers are 19/69.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
MOD_DEV(wcd, LM_DT_BLOCK, BDEV_MAJOR, &wcd_bdevsw);
|
|
|
|
MOD_DEV(rwcd, LM_DT_CHAR, CDEV_MAJOR, &wcd_cdevsw);
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function called when loading the driver.
|
|
|
|
*/
|
|
|
|
int wcd_load (struct lkm_table *lkmtp, int cmd)
|
|
|
|
{
|
|
|
|
struct atapi *ata;
|
|
|
|
int n, u;
|
|
|
|
|
|
|
|
if (! atapi_start)
|
|
|
|
/* No ATAPI driver available. */
|
|
|
|
return EPROTONOSUPPORT;
|
|
|
|
n = 0;
|
|
|
|
for (ata=atapi_tab; ata<atapi_tab+2; ++ata)
|
|
|
|
if (ata->port)
|
|
|
|
for (u=0; u<2; ++u)
|
|
|
|
/* Probing controller ata->ctrlr, unit u. */
|
|
|
|
if (ata->params[u] && ! ata->attached[u] &&
|
|
|
|
wcdattach (ata, u, ata->params[u],
|
|
|
|
ata->debug, ata->parent) >= 0)
|
|
|
|
{
|
|
|
|
/* Drive found. */
|
|
|
|
ata->attached[u] = 1;
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
if (! n)
|
|
|
|
/* No IDE CD-ROMs found. */
|
|
|
|
return ENXIO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function called when unloading the driver.
|
|
|
|
*/
|
|
|
|
int wcd_unload (struct lkm_table *lkmtp, int cmd)
|
|
|
|
{
|
|
|
|
struct wcd **t;
|
|
|
|
|
|
|
|
for (t=wcdtab; t<wcdtab+wcdnlun; ++t)
|
|
|
|
if (((*t)->flags & F_BOPEN) || (*t)->refcnt)
|
|
|
|
/* The device is opened, cannot unload the driver. */
|
|
|
|
return EBUSY;
|
|
|
|
for (t=wcdtab; t<wcdtab+wcdnlun; ++t) {
|
|
|
|
(*t)->ata->attached[(*t)->unit] = 0;
|
|
|
|
free (*t, M_TEMP);
|
|
|
|
}
|
|
|
|
wcdnlun = 0;
|
|
|
|
bzero (wcdtab, sizeof(wcdtab));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dispatcher function for the module (load/unload/stat).
|
|
|
|
*/
|
1995-10-28 17:45:04 +00:00
|
|
|
int wcd_mod (struct lkm_table *lkmtp, int cmd, int ver)
|
Latest fixes from Serge:
I tried to solve the problem of IDE probing compatibility in this version.
When compiled without an ATAPI option, the wd driver is
fully backward compatible with 2.0.5. With ATAPI option,
the wdprobe becomes strictly weaker. That is, if wdprobe works
without ATAPI option, it will always work with it too.
Another problem was with the CD-ROM drive attached as a slave
in the IDE bus, where there is no master. All IDE CD-ROM
drives are shipped in slave configuration, and most users
just plug them in, never thinking about jumpers.
It works fine with ms-dos and ms-windows, and this
version of the driver supports it as well.
The eject op can now load disks. Just repeat it twice,
and the disk will be ejected and then loaded back.
The disc cannot be ejected if it is mounted.
Submitted by: Serge Vakulenko, <vak@cronyx.ru>
1995-10-14 15:41:10 +00:00
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (ver != LKM_VERSION)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if (cmd == LKM_E_LOAD)
|
|
|
|
err = wcd_load (lkmtp, cmd);
|
|
|
|
else if (cmd == LKM_E_UNLOAD)
|
|
|
|
err = wcd_unload (lkmtp, cmd);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* Register the cdevsw entry. */
|
|
|
|
lkmtp->private.lkm_dev = &rwcd_module;
|
|
|
|
err = lkmdispatch (lkmtp, cmd);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/* Register the bdevsw entry. */
|
|
|
|
lkmtp->private.lkm_dev = &wcd_module;
|
|
|
|
return lkmdispatch (lkmtp, cmd);
|
|
|
|
}
|
|
|
|
#endif /* WCD_MODULE */
|
|
|
|
|
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 wcd_devsw_installed = 0;
|
|
|
|
|
1995-11-29 10:49:16 +00:00
|
|
|
static void wcd_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( ! wcd_devsw_installed ) {
|
1995-12-08 11:19:42 +00:00
|
|
|
dev = makedev(CDEV_MAJOR, 0);
|
|
|
|
cdevsw_add(&dev,&wcd_cdevsw, NULL);
|
|
|
|
dev = makedev(BDEV_MAJOR, 0);
|
|
|
|
bdevsw_add(&dev,&wcd_bdevsw, 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
|
|
|
wcd_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(wcddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wcd_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
|
|
|
|
1995-08-18 11:26:35 +00:00
|
|
|
#endif /* NWCD && NWDC && ATAPI */
|