summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa/matcd/matcd.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1997-05-04 15:24:23 +0000
committerjoerg <joerg@FreeBSD.org>1997-05-04 15:24:23 +0000
commit8cea5b917d62db9701a7fe2a45c9032aec48325d (patch)
treea2408a8a297df1fa5ba68bcc7ee4bc36c2fc2521 /sys/i386/isa/matcd/matcd.c
parent60343a746abd65c1fe9040ea648287d56be4b871 (diff)
downloadFreeBSD-src-8cea5b917d62db9701a7fe2a45c9032aec48325d.zip
FreeBSD-src-8cea5b917d62db9701a7fe2a45c9032aec48325d.tar.gz
This mega-commit brings the following:
. It makes cd9660 root f/s working again. . It makes CD9660 a new-style option. . It adds support to mount an ISO9660 multi-session CD-ROM as the root filesystem (the last session actually, but that's what is expected behaviour). Sigh. The CDIOREADTOCENTRYS did a copyout() of its own, and thus has been unusable for me for this work. Too bad it didn't simply stuff the max 100 entries into the struct ioc_read_toc_entry, but relied on a user supplied data buffer instead. :-( I now had to reinvent the wheel, and created a CDIOREADTOCENTRY ioctl command that can be used in a kernel context. While doing this, i noticed the following bogosities in existing CD-ROM drivers: wcd: This driver is likely to be totally bogus when someone tries two succeeding CDIOREADTOCENTRYS (or now CDIOREADTOCENTRY) commands with requesting MSF format, since it apparently operates on an internal table. scd: This driver apparently returns just a single TOC entry only for the CDIOREADTOCENTRYS command. I have only been able to test the CDIOREADTOCENTRY command with the cd(4) driver. I hereby request the respective maintainers of the other CD-ROM drivers to verify my code for their driver. When it comes to merging this CD-ROM multisession stuff into RELENG_2_2 i will only consider drivers where i've got a confirmation that it actually works.
Diffstat (limited to 'sys/i386/isa/matcd/matcd.c')
-rw-r--r--sys/i386/isa/matcd/matcd.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/sys/i386/isa/matcd/matcd.c b/sys/i386/isa/matcd/matcd.c
index 945152a..0ed243f 100644
--- a/sys/i386/isa/matcd/matcd.c
+++ b/sys/i386/isa/matcd/matcd.c
@@ -76,7 +76,7 @@
Dedicated to: My family, my Grandfather,
and Max, my Golden Retriever
-Thanks to: Jordon Hubbard (jkh) for getting me ramped-up to 2.x system
+Thanks to: Jordan Hubbard (jkh) for getting me ramped-up to 2.x system
quickly enough to make the 2.1 release. He put up with
plenty of silly questions and might get the post of
ambassador some day.
@@ -337,7 +337,7 @@ static char MATCDVERSION[]="Version 1(26) 18-Oct-95";
static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank Durda IV";
/* The proceeding strings may not be changed*/
-/* $Id: matcd.c,v 1.24 1997/03/24 11:24:22 bde Exp $ */
+/* $Id: matcd.c,v 1.25 1997/04/20 18:02:40 bde Exp $ */
/*---------------------------------------------------------------------------
Include declarations
@@ -572,6 +572,9 @@ static int matcd_toc_header(int ldrive, int cdrive, int controller,
static int matcd_toc_entries(int ldrive, int cdrive,
int controller,
struct ioc_read_toc_entry *ioc_entry);
+static int matcd_toc_entry(int ldrive, int cdrive,
+ int controller,
+ struct ioc_read_toc_single_entry *ioc_entry);
static int matcd_read_subq(int ldrive, int cdrive, int controller,
struct ioc_read_subchannel * sqp);
static int matcd_igot(struct ioc_capability * sqp);
@@ -1099,6 +1102,10 @@ int matcdioctl(dev_t dev, int command, caddr_t addr,
return(matcd_toc_entries(ldrive, cdrive, controller,
(struct ioc_read_toc_entry *) addr));
+ case CDIOREADTOCENTRY:
+ return(matcd_toc_entry(ldrive, cdrive, controller,
+ (struct ioc_read_toc_single_entry *) addr));
+
case CDIOCREADSUBCHANNEL:
return(matcd_read_subq(ldrive, cdrive, controller,
(struct ioc_read_subchannel *) addr));
@@ -2503,6 +2510,73 @@ static int matcd_toc_entries(int ldrive, int cdrive, int controller,
}
/*---------------------------------------------------------------------------
+ matcd_toc_entriy - Read a single TOC entry
+---------------------------------------------------------------------------*/
+
+static int matcd_toc_entry(int ldrive, int cdrive, int controller,
+ struct ioc_read_toc_single_entry * ioc_entry)
+{
+ struct matcd_data *cd;
+ struct cd_toc_entry *from;
+ struct cd_toc_entry *to;
+ int trk,origtrk,i,z,port;
+ unsigned char cmd[MAXCMDSIZ];
+ unsigned char data[5];
+
+ cd=&matcd_data[ldrive];
+ port=cd->iobase;
+
+ if ((cd->flags & MATCDLABEL)==0)
+ return(EIO); /*Refuse after chg error*/
+
+ zero_cmd(cmd);
+ cmd[0]=READTOC;
+
+ origtrk=trk=ioc_entry->track;
+ if (trk == 0xaa)
+ /* leadout */
+ trk=cd->volinfo.trk_high-1;
+ cmd[2]=trk+1;
+ lockbus(controller, ldrive); /*Request bus*/
+ matcd_slowcmd(port,ldrive,cdrive,cmd);
+ i=waitforit(10*TICKRES,DTEN,port,"mats1");
+ matcd_pread(port, 8, data); /*Read data returned*/
+ z=get_stat(port,ldrive); /*Read status byte*/
+ if ((z & MATCD_ST_ERROR)) { /*Something went wrong*/
+ i=get_error(port, ldrive, cdrive);
+ unlockbus(controller, ldrive); /*Release bus*/
+ return(EIO);
+ }
+ unlockbus(controller, ldrive); /*Release bus*/
+
+#ifdef DEBUGIOCTL
+ printf("Track %d addr/ctrl %x m %x s %x f %x\n",data[2],
+ data[1],data[4],data[5],data[6]);
+#endif /*DEBUGIOCTL*/
+
+ ioc_entry->entry.control=data[1]; /*Track type*/
+ ioc_entry->entry.addr_type=ioc_entry->address_format;/*Type*/
+ ioc_entry->entry.track=data[2]; /*Track #, can be Out of Order*/
+ if (ioc_entry->address_format == CD_MSF_FORMAT) {
+ ioc_entry->entry.addr.msf.unused=0;
+ ioc_entry->entry.addr.msf.minute=data[4]; /*Min*/
+ ioc_entry->entry.addr.msf.second=data[5]; /*Sec*/
+ ioc_entry->entry.addr.msf.frame=data[6]; /*Frame*/
+ }
+ if (origtrk == 0xaa) {
+ /* Handle leadout */
+ ioc_entry->entry.control=data[2]; /*Copy from last valid track*/
+ ioc_entry->entry.track=0xaa; /*Lead-out*/
+ ioc_entry->entry.addr.msf.unused=0; /*Fill*/
+ ioc_entry->entry.addr.msf.minute=cd->volinfo.vol_msf[0];
+ ioc_entry->entry.addr.msf.second=cd->volinfo.vol_msf[1];
+ ioc_entry->entry.addr.msf.frame=cd->volinfo.vol_msf[2];
+ }
+ return(0);
+
+}
+
+/*---------------------------------------------------------------------------
matcd_subq - Read the Sub-Q packet - (where are we?)
This call gives a snapshot state of where the optical
OpenPOWER on IntegriCloud