dvd-2.2.13-5.diff
上传用户:aoeyumen
上传日期:2007-01-06
资源大小:3329k
文件大小:291k
- + /* See if there is a padding record at the end that needs to be removed */
- + if (good_sectors > SCpnt->request.nr_sectors)
- + good_sectors -= 2;
- };
- - };
- - scsi_free(SCpnt->buffer, SCpnt->sglist_len); /* Free list of scatter-gather pointers */
- - if(SCpnt->request.sector % 4) good_sectors -= 2;
- - /* See if there is a padding record at the end that needs to be removed */
- - if(good_sectors > SCpnt->request.nr_sectors)
- - good_sectors -= 2;
- - };
-
- #ifdef DEBUG
- - printk("(%x %x %x) ",SCpnt->request.bh, SCpnt->request.nr_sectors,
- + printk("(%x %x %x) ", SCpnt->request.bh, SCpnt->request.nr_sectors,
- good_sectors);
- #endif
- - if (SCpnt->request.nr_sectors > this_count)
- - {
- + if (SCpnt->request.nr_sectors > this_count) {
- SCpnt->request.errors = 0;
- if (!SCpnt->request.bh)
- - panic("sr.c: linked page request (%lx %x)",
- - SCpnt->request.sector, this_count);
- - }
- -
- - SCpnt = end_scsi_request(SCpnt, 1, good_sectors); /* All done */
- - if (result == 0)
- - {
- - requeue_sr_request(SCpnt);
- - return;
- - }
- - }
- -
- - if (good_sectors == 0) {
- - /* We only come through here if no sectors were read successfully. */
- -
- - /* Free up any indirection buffers we allocated for DMA purposes. */
- - if (SCpnt->use_sg) {
- - struct scatterlist * sgpnt;
- - int i;
- - sgpnt = (struct scatterlist *) SCpnt->buffer;
- - for(i=0; i<SCpnt->use_sg; i++) {
- - if (sgpnt[i].alt_address) {
- - scsi_free(sgpnt[i].address, sgpnt[i].length);
- - }
- - }
- - scsi_free(SCpnt->buffer, SCpnt->sglist_len); /* Free list of scatter-gather pointers */
- - } else {
- - if (SCpnt->buffer != SCpnt->request.buffer)
- - scsi_free(SCpnt->buffer, SCpnt->bufflen);
- + panic("sr.c: linked page request (%lx %x)",
- + SCpnt->request.sector, this_count);
- + }
- + SCpnt = end_scsi_request(SCpnt, 1, good_sectors); /* All done */
- + if (result == 0) {
- + requeue_sr_request(SCpnt);
- + return;
- + }
- }
- + if (good_sectors == 0) {
- + /* We only come through here if no sectors were read successfully. */
-
- - }
- + /* Free up any indirection buffers we allocated for DMA purposes. */
- + if (SCpnt->use_sg) {
- + struct scatterlist *sgpnt;
- + int i;
- + sgpnt = (struct scatterlist *) SCpnt->buffer;
- + for (i = 0; i < SCpnt->use_sg; i++) {
- + if (sgpnt[i].alt_address) {
- + scsi_free(sgpnt[i].address, sgpnt[i].length);
- + }
- + }
- + scsi_free(SCpnt->buffer, SCpnt->sglist_len); /* Free list of scatter-gather pointers */
- + } else {
- + if (SCpnt->buffer != SCpnt->request.buffer)
- + scsi_free(SCpnt->buffer, SCpnt->bufflen);
- + }
-
- + }
- if (driver_byte(result) != 0) {
- if ((SCpnt->sense_buffer[0] & 0x7f) == 0x70) {
- if ((SCpnt->sense_buffer[2] & 0xf) == UNIT_ATTENTION) {
- /* detected disc change. set a bit and quietly refuse
- - * further access. */
- + * further access. */
-
- scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->changed = 1;
- SCpnt = end_scsi_request(SCpnt, 0, this_count);
- @@ -309,10 +314,9 @@
- return;
- }
- }
- -
- if (SCpnt->sense_buffer[2] == ILLEGAL_REQUEST) {
- printk("sr%d: CD-ROM error: ",
- - DEVICE_NR(SCpnt->request.rq_dev));
- + DEVICE_NR(SCpnt->request.rq_dev));
- print_sense("sr", SCpnt);
- printk("command was: ");
- print_command(SCpnt->cmnd);
- @@ -323,95 +327,87 @@
- return;
- } else {
- SCpnt = end_scsi_request(SCpnt, 0, this_count);
- - requeue_sr_request(SCpnt); /* Do next request */
- + requeue_sr_request(SCpnt); /* Do next request */
- return;
- }
-
- }
- -
- if (SCpnt->sense_buffer[2] == NOT_READY) {
- printk(KERN_INFO "sr%d: CD-ROM not ready. Make sure you have a disc in the drive.n",
- - DEVICE_NR(SCpnt->request.rq_dev));
- + DEVICE_NR(SCpnt->request.rq_dev));
- SCpnt = end_scsi_request(SCpnt, 0, this_count);
- - requeue_sr_request(SCpnt); /* Do next request */
- + requeue_sr_request(SCpnt); /* Do next request */
- return;
- }
- -
- if (SCpnt->sense_buffer[2] == MEDIUM_ERROR) {
- - printk("scsi%d: MEDIUM ERROR on "
- - "channel %d, id %d, lun %d, CDB: ",
- - SCpnt->host->host_no, (int) SCpnt->channel,
- - (int) SCpnt->target, (int) SCpnt->lun);
- - print_command(SCpnt->cmnd);
- - print_sense("sr", SCpnt);
- - SCpnt = end_scsi_request(SCpnt, 0, block_sectors);
- - requeue_sr_request(SCpnt);
- - return;
- + printk("scsi%d: MEDIUM ERROR on "
- + "channel %d, id %d, lun %d, CDB: ",
- + SCpnt->host->host_no, (int) SCpnt->channel,
- + (int) SCpnt->target, (int) SCpnt->lun);
- + print_command(SCpnt->cmnd);
- + print_sense("sr", SCpnt);
- + SCpnt = end_scsi_request(SCpnt, 0, block_sectors);
- + requeue_sr_request(SCpnt);
- + return;
- }
- -
- if (SCpnt->sense_buffer[2] == VOLUME_OVERFLOW) {
- - printk("scsi%d: VOLUME OVERFLOW on "
- - "channel %d, id %d, lun %d, CDB: ",
- - SCpnt->host->host_no, (int) SCpnt->channel,
- - (int) SCpnt->target, (int) SCpnt->lun);
- - print_command(SCpnt->cmnd);
- - print_sense("sr", SCpnt);
- - SCpnt = end_scsi_request(SCpnt, 0, block_sectors);
- - requeue_sr_request(SCpnt);
- - return;
- + printk("scsi%d: VOLUME OVERFLOW on "
- + "channel %d, id %d, lun %d, CDB: ",
- + SCpnt->host->host_no, (int) SCpnt->channel,
- + (int) SCpnt->target, (int) SCpnt->lun);
- + print_command(SCpnt->cmnd);
- + print_sense("sr", SCpnt);
- + SCpnt = end_scsi_request(SCpnt, 0, block_sectors);
- + requeue_sr_request(SCpnt);
- + return;
- }
- - }
- -
- + }
- /* We only get this far if we have an error we have not recognized */
- - if(result) {
- - printk("SCSI CD error : host %d id %d lun %d return code = %03xn",
- - scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->host->host_no,
- - scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->id,
- - scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->lun,
- - result);
- -
- - if (status_byte(result) == CHECK_CONDITION)
- - print_sense("sr", SCpnt);
- -
- - SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.current_nr_sectors);
- - requeue_sr_request(SCpnt);
- - }
- + if (result) {
- + printk("SCSI CD error : host %d id %d lun %d return code = %03xn",
- + scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->host->host_no,
- + scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->id,
- + scsi_CDs[DEVICE_NR(SCpnt->request.rq_dev)].device->lun,
- + result);
- +
- + if (status_byte(result) == CHECK_CONDITION)
- + print_sense("sr", SCpnt);
- +
- + SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.current_nr_sectors);
- + requeue_sr_request(SCpnt);
- + }
- }
-
- static int sr_open(struct cdrom_device_info *cdi, int purpose)
- {
- - check_disk_change(cdi->dev);
- + check_disk_change(cdi->dev);
-
- - if( MINOR(cdi->dev) >= sr_template.dev_max
- - || !scsi_CDs[MINOR(cdi->dev)].device)
- - {
- - return -ENXIO; /* No such device */
- - }
- -
- - /*
- - * If the device is in error recovery, wait until it is done.
- - * If the device is offline, then disallow any access to it.
- - */
- - if( !scsi_block_when_processing_errors(scsi_CDs[MINOR(cdi->dev)].device) )
- - {
- - return -ENXIO;
- - }
- -
- - scsi_CDs[MINOR(cdi->dev)].device->access_count++;
- - if (scsi_CDs[MINOR(cdi->dev)].device->host->hostt->module)
- - __MOD_INC_USE_COUNT(scsi_CDs[MINOR(cdi->dev)].device->host->hostt->module);
- - if(sr_template.module)
- - __MOD_INC_USE_COUNT(sr_template.module);
- -
- - /* If this device did not have media in the drive at boot time, then
- - * we would have been unable to get the sector size. Check to see if
- - * this is the case, and try again.
- - */
- + if (MINOR(cdi->dev) >= sr_template.dev_max
- + || !scsi_CDs[MINOR(cdi->dev)].device) {
- + return -ENXIO; /* No such device */
- + }
- + /*
- + * If the device is in error recovery, wait until it is done.
- + * If the device is offline, then disallow any access to it.
- + */
- + if (!scsi_block_when_processing_errors(scsi_CDs[MINOR(cdi->dev)].device)) {
- + return -ENXIO;
- + }
- + scsi_CDs[MINOR(cdi->dev)].device->access_count++;
- + if (scsi_CDs[MINOR(cdi->dev)].device->host->hostt->module)
- + __MOD_INC_USE_COUNT(scsi_CDs[MINOR(cdi->dev)].device->host->hostt->module);
- + if (sr_template.module)
- + __MOD_INC_USE_COUNT(sr_template.module);
- +
- + /* If this device did not have media in the drive at boot time, then
- + * we would have been unable to get the sector size. Check to see if
- + * this is the case, and try again.
- + */
-
- - if(scsi_CDs[MINOR(cdi->dev)].needs_sector_size)
- - get_sectorsize(MINOR(cdi->dev));
- + if (scsi_CDs[MINOR(cdi->dev)].needs_sector_size)
- + get_sectorsize(MINOR(cdi->dev));
-
- - return 0;
- + return 0;
- }
-
- /*
- @@ -420,111 +416,106 @@
- * translate them to SCSI commands.
- */
-
- -static void do_sr_request (void)
- +static void do_sr_request(void)
- {
- - Scsi_Cmnd * SCpnt = NULL;
- - struct request * req = NULL;
- - Scsi_Device * SDev;
- - int flag = 0;
- -
- - while (1==1){
- - if (CURRENT != NULL && CURRENT->rq_status == RQ_INACTIVE) {
- - return;
- - };
- + Scsi_Cmnd *SCpnt = NULL;
- + struct request *req = NULL;
- + Scsi_Device *SDev;
- + int flag = 0;
-
- - INIT_SCSI_REQUEST;
- + while (1 == 1) {
- + if (CURRENT != NULL && CURRENT->rq_status == RQ_INACTIVE) {
- + return;
- + };
-
- - SDev = scsi_CDs[DEVICE_NR(CURRENT->rq_dev)].device;
- + INIT_SCSI_REQUEST;
-
- - /*
- - * If the host for this device is in error recovery mode, don't
- - * do anything at all here. When the host leaves error recovery
- - * mode, it will automatically restart things and start queueing
- - * commands again.
- - */
- - if( SDev->host->in_recovery )
- - {
- - return;
- - }
- + SDev = scsi_CDs[DEVICE_NR(CURRENT->rq_dev)].device;
-
- - /*
- - * I am not sure where the best place to do this is. We need
- - * to hook in a place where we are likely to come if in user
- - * space.
- - */
- - if( SDev->was_reset )
- - {
- - /*
- - * We need to relock the door, but we might
- - * be in an interrupt handler. Only do this
- - * from user space, since we do not want to
- - * sleep from an interrupt.
- - */
- - if( SDev->removable && !in_interrupt() )
- - {
- - spin_unlock_irq(&io_request_lock); /* FIXME!!!! */
- - scsi_ioctl(SDev, SCSI_IOCTL_DOORLOCK, 0);
- - spin_lock_irq(&io_request_lock); /* FIXME!!!! */
- - /* scsi_ioctl may allow CURRENT to change, so start over. */
- - SDev->was_reset = 0;
- - continue;
- - }
- - SDev->was_reset = 0;
- - }
- -
- - /* we do lazy blocksize switching (when reading XA sectors,
- - * see CDROMREADMODE2 ioctl) */
- - if (scsi_CDs[DEVICE_NR(CURRENT->rq_dev)].sector_size > 2048) {
- - if (!in_interrupt())
- - sr_set_blocklength(DEVICE_NR(CURRENT->rq_dev),2048);
- + /*
- + * If the host for this device is in error recovery mode, don't
- + * do anything at all here. When the host leaves error recovery
- + * mode, it will automatically restart things and start queueing
- + * commands again.
- + */
- + if (SDev->host->in_recovery) {
- + return;
- + }
- + /*
- + * I am not sure where the best place to do this is. We need
- + * to hook in a place where we are likely to come if in user
- + * space.
- + */
- + if (SDev->was_reset) {
- + /*
- + * We need to relock the door, but we might
- + * be in an interrupt handler. Only do this
- + * from user space, since we do not want to
- + * sleep from an interrupt.
- + */
- + if (SDev->removable && !in_interrupt()) {
- + spin_unlock_irq(&io_request_lock); /* FIXME!!!! */
- + scsi_ioctl(SDev, SCSI_IOCTL_DOORLOCK, 0);
- + spin_lock_irq(&io_request_lock); /* FIXME!!!! */
- + /* scsi_ioctl may allow CURRENT to change, so start over. */
- + SDev->was_reset = 0;
- + continue;
- + }
- + SDev->was_reset = 0;
- + }
- + /* we do lazy blocksize switching (when reading XA sectors,
- + * see CDROMREADMODE2 ioctl) */
- + if (scsi_CDs[DEVICE_NR(CURRENT->rq_dev)].sector_size > 2048) {
- + if (!in_interrupt())
- + sr_set_blocklength(DEVICE_NR(CURRENT->rq_dev), 2048);
- #if 1
- - else
- - printk("sr: can't switch blocksize: in interruptn");
- + else
- + printk("sr: can't switch blocksize: in interruptn");
- #endif
- - }
- -
- - if (flag++ == 0)
- - SCpnt = scsi_allocate_device(&CURRENT,
- - scsi_CDs[DEVICE_NR(CURRENT->rq_dev)].device, 0);
- - else SCpnt = NULL;
- -
- - /* This is a performance enhancement. We dig down into the request list and
- - * try to find a queueable request (i.e. device not busy, and host able to
- - * accept another command. If we find one, then we queue it. This can
- - * make a big difference on systems with more than one disk drive. We want
- - * to have the interrupts off when monkeying with the request list, because
- - * otherwise the kernel might try to slip in a request in between somewhere. */
- -
- - if (!SCpnt && sr_template.nr_dev > 1){
- - struct request *req1;
- - req1 = NULL;
- - req = CURRENT;
- - while(req){
- - SCpnt = scsi_request_queueable(req,
- - scsi_CDs[DEVICE_NR(req->rq_dev)].device);
- - if(SCpnt) break;
- - req1 = req;
- - req = req->next;
- - }
- - if (SCpnt && req->rq_status == RQ_INACTIVE) {
- - if (req == CURRENT)
- - CURRENT = CURRENT->next;
- + }
- + if (flag++ == 0)
- + SCpnt = scsi_allocate_device(&CURRENT,
- + scsi_CDs[DEVICE_NR(CURRENT->rq_dev)].device, 0);
- else
- - req1->next = req->next;
- - }
- - }
- + SCpnt = NULL;
-
- - if (!SCpnt)
- - return; /* Could not find anything to do */
- + /* This is a performance enhancement. We dig down into the request list and
- + * try to find a queueable request (i.e. device not busy, and host able to
- + * accept another command. If we find one, then we queue it. This can
- + * make a big difference on systems with more than one disk drive. We want
- + * to have the interrupts off when monkeying with the request list, because
- + * otherwise the kernel might try to slip in a request in between somewhere. */
- +
- + if (!SCpnt && sr_template.nr_dev > 1) {
- + struct request *req1;
- + req1 = NULL;
- + req = CURRENT;
- + while (req) {
- + SCpnt = scsi_request_queueable(req,
- + scsi_CDs[DEVICE_NR(req->rq_dev)].device);
- + if (SCpnt)
- + break;
- + req1 = req;
- + req = req->next;
- + }
- + if (SCpnt && req->rq_status == RQ_INACTIVE) {
- + if (req == CURRENT)
- + CURRENT = CURRENT->next;
- + else
- + req1->next = req->next;
- + }
- + }
- + if (!SCpnt)
- + return; /* Could not find anything to do */
-
- - wake_up(&wait_for_request);
- + wake_up(&wait_for_request);
-
- - /* Queue command */
- - requeue_sr_request(SCpnt);
- - } /* While */
- + /* Queue command */
- + requeue_sr_request(SCpnt);
- + } /* While */
- }
-
- -void requeue_sr_request (Scsi_Cmnd * SCpnt)
- +void requeue_sr_request(Scsi_Cmnd * SCpnt)
- {
- unsigned int dev, block, realcount;
- unsigned char cmd[10], *buffer, tries;
- @@ -532,244 +523,234 @@
-
- tries = 2;
-
- - repeat:
- - if(!SCpnt || SCpnt->request.rq_status == RQ_INACTIVE) {
- +repeat:
- + if (!SCpnt || SCpnt->request.rq_status == RQ_INACTIVE) {
- do_sr_request();
- return;
- }
- -
- - dev = MINOR(SCpnt->request.rq_dev);
- + dev = MINOR(SCpnt->request.rq_dev);
- block = SCpnt->request.sector;
- buffer = NULL;
- this_count = 0;
-
- if (dev >= sr_template.nr_dev) {
- - /* printk("CD-ROM request error: invalid device.n"); */
- + /* printk("CD-ROM request error: invalid device.n"); */
- SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- tries = 2;
- goto repeat;
- }
- -
- if (!scsi_CDs[dev].use) {
- - /* printk("CD-ROM request error: device marked not in use.n"); */
- + /* printk("CD-ROM request error: device marked not in use.n"); */
- + SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- + tries = 2;
- + goto repeat;
- + }
- + if (!scsi_CDs[dev].device->online) {
- SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- tries = 2;
- goto repeat;
- }
- -
- - if( !scsi_CDs[dev].device->online )
- - {
- - SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- - tries = 2;
- - goto repeat;
- - }
- -
- if (scsi_CDs[dev].device->changed) {
- - /*
- - * quietly refuse to do anything to a changed disc
- - * until the changed bit has been reset
- - */
- - /* printk("CD-ROM has been changed. Prohibiting further I/O.n"); */
- + /*
- + * quietly refuse to do anything to a changed disc
- + * until the changed bit has been reset
- + */
- + /* printk("CD-ROM has been changed. Prohibiting further I/O.n"); */
- SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- tries = 2;
- goto repeat;
- }
- -
- - switch (SCpnt->request.cmd)
- - {
- - case WRITE:
- - SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- - goto repeat;
- - break;
- - case READ :
- - cmd[0] = READ_6;
- - break;
- - default :
- - panic ("Unknown sr command %dn", SCpnt->request.cmd);
- - }
- + switch (SCpnt->request.cmd) {
- + case WRITE:
- + SCpnt = end_scsi_request(SCpnt, 0, SCpnt->request.nr_sectors);
- + goto repeat;
- + break;
- + case READ:
- + cmd[0] = READ_6;
- + break;
- + default:
- + panic("Unknown sr command %dn", SCpnt->request.cmd);
- + }
-
- cmd[1] = (SCpnt->lun << 5) & 0xe0;
-
- - /*
- - * Now do the grungy work of figuring out which sectors we need, and
- - * where in memory we are going to put them.
- - *
- - * The variables we need are:
- - *
- - * this_count= number of 512 byte sectors being read
- - * block = starting cdrom sector to read.
- - * realcount = # of cdrom sectors to read
- - *
- - * The major difference between a scsi disk and a scsi cdrom
- - * is that we will always use scatter-gather if we can, because we can
- - * work around the fact that the buffer cache has a block size of 1024,
- - * and we have 2048 byte sectors. This code should work for buffers that
- - * are any multiple of 512 bytes long.
- - */
- + /*
- + * Now do the grungy work of figuring out which sectors we need, and
- + * where in memory we are going to put them.
- + *
- + * The variables we need are:
- + *
- + * this_count= number of 512 byte sectors being read
- + * block = starting cdrom sector to read.
- + * realcount = # of cdrom sectors to read
- + *
- + * The major difference between a scsi disk and a scsi cdrom
- + * is that we will always use scatter-gather if we can, because we can
- + * work around the fact that the buffer cache has a block size of 1024,
- + * and we have 2048 byte sectors. This code should work for buffers that
- + * are any multiple of 512 bytes long.
- + */
-
- SCpnt->use_sg = 0;
-
- if (SCpnt->host->sg_tablesize > 0 &&
- (!scsi_need_isa_buffer ||
- - scsi_dma_free_sectors >= 10)) {
- - struct buffer_head * bh;
- - struct scatterlist * sgpnt;
- - int count, this_count_max;
- - bh = SCpnt->request.bh;
- - this_count = 0;
- - count = 0;
- - this_count_max = (scsi_CDs[dev].ten ? 0xffff : 0xff) << 4;
- - /* Calculate how many links we can use. First see if we need
- - * a padding record at the start */
- - this_count = SCpnt->request.sector % 4;
- - if(this_count) count++;
- - while(bh && count < SCpnt->host->sg_tablesize) {
- - if ((this_count + (bh->b_size >> 9)) > this_count_max) break;
- - this_count += (bh->b_size >> 9);
- - count++;
- - bh = bh->b_reqnext;
- - };
- - /* Fix up in case of an odd record at the end */
- - end_rec = 0;
- - if(this_count % 4) {
- - if (count < SCpnt->host->sg_tablesize) {
- - count++;
- - end_rec = (4 - (this_count % 4)) << 9;
- - this_count += 4 - (this_count % 4);
- - } else {
- - count--;
- - this_count -= (this_count % 4);
- - };
- - };
- - SCpnt->use_sg = count; /* Number of chains */
- - /* scsi_malloc can only allocate in chunks of 512 bytes */
- - count = (SCpnt->use_sg * sizeof(struct scatterlist) + 511) & ~511;
- -
- - SCpnt->sglist_len = count;
- - sgpnt = (struct scatterlist * ) scsi_malloc(count);
- - if (!sgpnt) {
- - printk("Warning - running *really* short on DMA buffersn");
- - SCpnt->use_sg = 0; /* No memory left - bail out */
- - } else {
- - buffer = (unsigned char *) sgpnt;
- - count = 0;
- - bh = SCpnt->request.bh;
- - if(SCpnt->request.sector % 4) {
- - sgpnt[count].length = (SCpnt->request.sector % 4) << 9;
- - sgpnt[count].address = (char *) scsi_malloc(sgpnt[count].length);
- - if(!sgpnt[count].address) panic("SCSI DMA pool exhausted.");
- - sgpnt[count].alt_address = sgpnt[count].address; /* Flag to delete
- - if needed */
- - count++;
- - };
- - for(bh = SCpnt->request.bh; count < SCpnt->use_sg;
- - count++, bh = bh->b_reqnext) {
- - if (bh) { /* Need a placeholder at the end of the record? */
- - sgpnt[count].address = bh->b_data;
- - sgpnt[count].length = bh->b_size;
- - sgpnt[count].alt_address = NULL;
- - } else {
- - sgpnt[count].address = (char *) scsi_malloc(end_rec);
- - if(!sgpnt[count].address) panic("SCSI DMA pool exhausted.");
- - sgpnt[count].length = end_rec;
- - sgpnt[count].alt_address = sgpnt[count].address;
- - if (count+1 != SCpnt->use_sg) panic("Bad sr request list");
- - break;
- + scsi_dma_free_sectors >= 10)) {
- + struct buffer_head *bh;
- + struct scatterlist *sgpnt;
- + int count, this_count_max;
- + bh = SCpnt->request.bh;
- + this_count = 0;
- + count = 0;
- + this_count_max = (scsi_CDs[dev].ten ? 0xffff : 0xff) << 4;
- + /* Calculate how many links we can use. First see if we need
- + * a padding record at the start */
- + this_count = SCpnt->request.sector % 4;
- + if (this_count)
- + count++;
- + while (bh && count < SCpnt->host->sg_tablesize) {
- + if ((this_count + (bh->b_size >> 9)) > this_count_max)
- + break;
- + this_count += (bh->b_size >> 9);
- + count++;
- + bh = bh->b_reqnext;
- };
- - if (virt_to_phys(sgpnt[count].address) + sgpnt[count].length - 1 >
- - ISA_DMA_THRESHOLD && SCpnt->host->unchecked_isa_dma) {
- - sgpnt[count].alt_address = sgpnt[count].address;
- - /* We try to avoid exhausting the DMA pool, since it is easier
- - * to control usage here. In other places we might have a more
- - * pressing need, and we would be screwed if we ran out */
- - if(scsi_dma_free_sectors < (sgpnt[count].length >> 9) + 5) {
- - sgpnt[count].address = NULL;
- - } else {
- - sgpnt[count].address = (char *) scsi_malloc(sgpnt[count].length);
- - };
- - /* If we start running low on DMA buffers, we abort the scatter-gather
- - * operation, and free all of the memory we have allocated. We want to
- - * ensure that all scsi operations are able to do at least a non-scatter/gather
- - * operation */
- - if(sgpnt[count].address == NULL){ /* Out of dma memory */
- - printk("Warning: Running low on SCSI DMA buffersn");
- - /* Try switching back to a non scatter-gather operation. */
- - while(--count >= 0){
- - if(sgpnt[count].alt_address)
- - scsi_free(sgpnt[count].address, sgpnt[count].length);
- + /* Fix up in case of an odd record at the end */
- + end_rec = 0;
- + if (this_count % 4) {
- + if (count < SCpnt->host->sg_tablesize) {
- + count++;
- + end_rec = (4 - (this_count % 4)) << 9;
- + this_count += 4 - (this_count % 4);
- + } else {
- + count--;
- + this_count -= (this_count % 4);
- };
- - SCpnt->use_sg = 0;
- - scsi_free(buffer, SCpnt->sglist_len);
- - break;
- - }; /* if address == NULL */
- - }; /* if need DMA fixup */
- - }; /* for loop to fill list */
- + };
- + SCpnt->use_sg = count; /* Number of chains */
- + /* scsi_malloc can only allocate in chunks of 512 bytes */
- + count = (SCpnt->use_sg * sizeof(struct scatterlist) + 511) & ~511;
- +
- + SCpnt->sglist_len = count;
- + sgpnt = (struct scatterlist *) scsi_malloc(count);
- + if (!sgpnt) {
- + printk("Warning - running *really* short on DMA buffersn");
- + SCpnt->use_sg = 0; /* No memory left - bail out */
- + } else {
- + buffer = (unsigned char *) sgpnt;
- + count = 0;
- + bh = SCpnt->request.bh;
- + if (SCpnt->request.sector % 4) {
- + sgpnt[count].length = (SCpnt->request.sector % 4) << 9;
- + sgpnt[count].address = (char *) scsi_malloc(sgpnt[count].length);
- + if (!sgpnt[count].address)
- + panic("SCSI DMA pool exhausted.");
- + sgpnt[count].alt_address = sgpnt[count].address; /* Flag to delete
- + if needed */
- + count++;
- + };
- + for (bh = SCpnt->request.bh; count < SCpnt->use_sg;
- + count++, bh = bh->b_reqnext) {
- + if (bh) { /* Need a placeholder at the end of the record? */
- + sgpnt[count].address = bh->b_data;
- + sgpnt[count].length = bh->b_size;
- + sgpnt[count].alt_address = NULL;
- + } else {
- + sgpnt[count].address = (char *) scsi_malloc(end_rec);
- + if (!sgpnt[count].address)
- + panic("SCSI DMA pool exhausted.");
- + sgpnt[count].length = end_rec;
- + sgpnt[count].alt_address = sgpnt[count].address;
- + if (count + 1 != SCpnt->use_sg)
- + panic("Bad sr request list");
- + break;
- + };
- + if (virt_to_phys(sgpnt[count].address) + sgpnt[count].length - 1 >
- + ISA_DMA_THRESHOLD && SCpnt->host->unchecked_isa_dma) {
- + sgpnt[count].alt_address = sgpnt[count].address;
- + /* We try to avoid exhausting the DMA pool, since it is easier
- + * to control usage here. In other places we might have a more
- + * pressing need, and we would be screwed if we ran out */
- + if (scsi_dma_free_sectors < (sgpnt[count].length >> 9) + 5) {
- + sgpnt[count].address = NULL;
- + } else {
- + sgpnt[count].address = (char *) scsi_malloc(sgpnt[count].length);
- + };
- + /* If we start running low on DMA buffers, we abort the scatter-gather
- + * operation, and free all of the memory we have allocated. We want to
- + * ensure that all scsi operations are able to do at least a non-scatter/gather
- + * operation */
- + if (sgpnt[count].address == NULL) { /* Out of dma memory */
- + printk("Warning: Running low on SCSI DMA buffersn");
- + /* Try switching back to a non scatter-gather operation. */
- + while (--count >= 0) {
- + if (sgpnt[count].alt_address)
- + scsi_free(sgpnt[count].address, sgpnt[count].length);
- + };
- + SCpnt->use_sg = 0;
- + scsi_free(buffer, SCpnt->sglist_len);
- + break;
- + }; /* if address == NULL */
- + }; /* if need DMA fixup */
- + }; /* for loop to fill list */
- #ifdef DEBUG
- - printk("SR: %d %d %d %d %d *** ",SCpnt->use_sg, SCpnt->request.sector,
- - this_count,
- - SCpnt->request.current_nr_sectors,
- - SCpnt->request.nr_sectors);
- - for(count=0; count<SCpnt->use_sg; count++)
- - printk("SGlist: %d %x %x %xn", count,
- - sgpnt[count].address,
- - sgpnt[count].alt_address,
- - sgpnt[count].length);
- + printk("SR: %d %d %d %d %d *** ", SCpnt->use_sg, SCpnt->request.sector,
- + this_count,
- + SCpnt->request.current_nr_sectors,
- + SCpnt->request.nr_sectors);
- + for (count = 0; count < SCpnt->use_sg; count++)
- + printk("SGlist: %d %x %x %xn", count,
- + sgpnt[count].address,
- + sgpnt[count].alt_address,
- + sgpnt[count].length);
- #endif
- - }; /* Able to allocate scatter-gather list */
- + }; /* Able to allocate scatter-gather list */
- };
-
- - if (SCpnt->use_sg == 0){
- - /* We cannot use scatter-gather. Do this the old fashion way */
- - if (!SCpnt->request.bh)
- - this_count = SCpnt->request.nr_sectors;
- - else
- - this_count = (SCpnt->request.bh->b_size >> 9);
- + if (SCpnt->use_sg == 0) {
- + /* We cannot use scatter-gather. Do this the old fashion way */
- + if (!SCpnt->request.bh)
- + this_count = SCpnt->request.nr_sectors;
- + else
- + this_count = (SCpnt->request.bh->b_size >> 9);
-
- - start = block % 4;
- - if (start)
- - {
- - this_count = ((this_count > 4 - start) ?
- - (4 - start) : (this_count));
- - buffer = (unsigned char *) scsi_malloc(2048);
- - }
- - else if (this_count < 4)
- - {
- - buffer = (unsigned char *) scsi_malloc(2048);
- - }
- - else
- - {
- - this_count -= this_count % 4;
- - buffer = (unsigned char *) SCpnt->request.buffer;
- - if (virt_to_phys(buffer) + (this_count << 9) > ISA_DMA_THRESHOLD &&
- - SCpnt->host->unchecked_isa_dma)
- - buffer = (unsigned char *) scsi_malloc(this_count << 9);
- - }
- + start = block % 4;
- + if (start) {
- + this_count = ((this_count > 4 - start) ?
- + (4 - start) : (this_count));
- + buffer = (unsigned char *) scsi_malloc(2048);
- + } else if (this_count < 4) {
- + buffer = (unsigned char *) scsi_malloc(2048);
- + } else {
- + this_count -= this_count % 4;
- + buffer = (unsigned char *) SCpnt->request.buffer;
- + if (virt_to_phys(buffer) + (this_count << 9) > ISA_DMA_THRESHOLD &&
- + SCpnt->host->unchecked_isa_dma)
- + buffer = (unsigned char *) scsi_malloc(this_count << 9);
- + }
- };
-
- if (scsi_CDs[dev].sector_size == 2048)
- - block = block >> 2; /* These are the sectors that the cdrom uses */
- + block = block >> 2; /* These are the sectors that the cdrom uses */
- else
- - block = block & 0xfffffffc;
- + block = block & 0xfffffffc;
-
- realcount = (this_count + 3) / 4;
-
- - if (scsi_CDs[dev].sector_size == 512) realcount = realcount << 2;
- + if (scsi_CDs[dev].sector_size == 512)
- + realcount = realcount << 2;
-
- - /*
- - * Note: The scsi standard says that READ_6 is *optional*, while
- - * READ_10 is mandatory. Thus there is no point in using
- - * READ_6.
- - */
- - if (scsi_CDs[dev].ten)
- -
- - {
- - if (realcount > 0xffff)
- - {
- + /*
- + * Note: The scsi standard says that READ_6 is *optional*, while
- + * READ_10 is mandatory. Thus there is no point in using
- + * READ_6.
- + */
- + if (scsi_CDs[dev].ten) {
- + if (realcount > 0xffff) {
- realcount = 0xffff;
- this_count = realcount * (scsi_CDs[dev].sector_size >> 9);
- - }
- -
- - cmd[0] += READ_10 - READ_6 ;
- + }
- + cmd[0] += READ_10 - READ_6;
- cmd[2] = (unsigned char) (block >> 24) & 0xff;
- cmd[3] = (unsigned char) (block >> 16) & 0xff;
- cmd[4] = (unsigned char) (block >> 8) & 0xff;
- @@ -777,164 +758,174 @@
- cmd[6] = cmd[9] = 0;
- cmd[7] = (unsigned char) (realcount >> 8) & 0xff;
- cmd[8] = (unsigned char) realcount & 0xff;
- - }
- - else
- - {
- - if (realcount > 0xff)
- - {
- - realcount = 0xff;
- - this_count = realcount * (scsi_CDs[dev].sector_size >> 9);
- + } else {
- + if (realcount > 0xff) {
- + realcount = 0xff;
- + this_count = realcount * (scsi_CDs[dev].sector_size >> 9);
- + }
- + cmd[1] |= (unsigned char) ((block >> 16) & 0x1f);
- + cmd[2] = (unsigned char) ((block >> 8) & 0xff);
- + cmd[3] = (unsigned char) block & 0xff;
- + cmd[4] = (unsigned char) realcount;
- + cmd[5] = 0;
- }
-
- - cmd[1] |= (unsigned char) ((block >> 16) & 0x1f);
- - cmd[2] = (unsigned char) ((block >> 8) & 0xff);
- - cmd[3] = (unsigned char) block & 0xff;
- - cmd[4] = (unsigned char) realcount;
- - cmd[5] = 0;
- - }
- -
- #ifdef DEBUG
- - {
- - int i;
- - printk("ReadCD: %d %d %d %dn",block, realcount, buffer, this_count);
- - printk("Use sg: %dn", SCpnt->use_sg);
- - printk("Dumping command: ");
- - for(i=0; i<12; i++) printk("%2.2x ", cmd[i]);
- - printk("n");
- - };
- + {
- + int i;
- + printk("ReadCD: %d %d %d %dn", block, realcount, buffer, this_count);
- + printk("Use sg: %dn", SCpnt->use_sg);
- + printk("Dumping command: ");
- + for (i = 0; i < 12; i++)
- + printk("%2.2x ", cmd[i]);
- + printk("n");
- + };
- #endif
-
- - /* Some dumb host adapters can speed transfers by knowing the
- - * minimum transfersize in advance.
- - *
- - * We shouldn't disconnect in the middle of a sector, but the cdrom
- - * sector size can be larger than the size of a buffer and the
- - * transfer may be split to the size of a buffer. So it's safe to
- - * assume that we can at least transfer the minimum of the buffer
- - * size (1024) and the sector size between each connect / disconnect.
- - */
- + /* Some dumb host adapters can speed transfers by knowing the
- + * minimum transfersize in advance.
- + *
- + * We shouldn't disconnect in the middle of a sector, but the cdrom
- + * sector size can be larger than the size of a buffer and the
- + * transfer may be split to the size of a buffer. So it's safe to
- + * assume that we can at least transfer the minimum of the buffer
- + * size (1024) and the sector size between each connect / disconnect.
- + */
-
- - SCpnt->transfersize = (scsi_CDs[dev].sector_size > 1024) ?
- - 1024 : scsi_CDs[dev].sector_size;
- + SCpnt->transfersize = (scsi_CDs[dev].sector_size > 1024) ?
- + 1024 : scsi_CDs[dev].sector_size;
-
- SCpnt->this_count = this_count;
- - scsi_do_cmd (SCpnt, (void *) cmd, buffer,
- - realcount * scsi_CDs[dev].sector_size,
- - rw_intr, SR_TIMEOUT, MAX_RETRIES);
- + scsi_do_cmd(SCpnt, (void *) cmd, buffer,
- + realcount * scsi_CDs[dev].sector_size,
- + rw_intr, SR_TIMEOUT, MAX_RETRIES);
- }
-
- -static int sr_detect(Scsi_Device * SDp){
- +static int sr_detect(Scsi_Device * SDp)
- +{
-
- - if(SDp->type != TYPE_ROM && SDp->type != TYPE_WORM) return 0;
- + if (SDp->type != TYPE_ROM && SDp->type != TYPE_WORM)
- + return 0;
-
- - printk("Detected scsi CD-ROM sr%d at scsi%d, channel %d, id %d, lun %dn",
- - sr_template.dev_noticed++,
- - SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);
- + printk("Detected scsi CD-ROM sr%d at scsi%d, channel %d, id %d, lun %dn",
- + sr_template.dev_noticed++,
- + SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);
-
- - return 1;
- + return 1;
- }
-
- -static int sr_attach(Scsi_Device * SDp){
- - Scsi_CD * cpnt;
- - int i;
- -
- - if(SDp->type != TYPE_ROM && SDp->type != TYPE_WORM) return 1;
- -
- - if (sr_template.nr_dev >= sr_template.dev_max)
- - {
- - SDp->attached--;
- - return 1;
- - }
- +static int sr_attach(Scsi_Device * SDp)
- +{
- + Scsi_CD *cpnt;
- + int i;
-
- - for(cpnt = scsi_CDs, i=0; i<sr_template.dev_max; i++, cpnt++)
- - if(!cpnt->device) break;
- + if (SDp->type != TYPE_ROM && SDp->type != TYPE_WORM)
- + return 1;
-
- - if(i >= sr_template.dev_max) panic ("scsi_devices corrupt (sr)");
- + if (sr_template.nr_dev >= sr_template.dev_max) {
- + SDp->attached--;
- + return 1;
- + }
- + for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
- + if (!cpnt->device)
- + break;
- +
- + if (i >= sr_template.dev_max)
- + panic("scsi_devices corrupt (sr)");
-
- - SDp->scsi_request_fn = do_sr_request;
- - scsi_CDs[i].device = SDp;
- + SDp->scsi_request_fn = do_sr_request;
- + scsi_CDs[i].device = SDp;
-
- - sr_template.nr_dev++;
- - if(sr_template.nr_dev > sr_template.dev_max)
- - panic ("scsi_devices corrupt (sr)");
- - return 0;
- + sr_template.nr_dev++;
- + if (sr_template.nr_dev > sr_template.dev_max)
- + panic("scsi_devices corrupt (sr)");
- + return 0;
- }
-
-
- -static void sr_init_done (Scsi_Cmnd * SCpnt)
- +static void sr_init_done(Scsi_Cmnd * SCpnt)
- {
- - struct request * req;
- + struct request *req;
-
- - req = &SCpnt->request;
- - req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
- + req = &SCpnt->request;
- + req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
-
- - if (req->sem != NULL) {
- - up(req->sem);
- - }
- + if (req->sem != NULL) {
- + up(req->sem);
- + }
- }
-
- -void get_sectorsize(int i){
- - unsigned char cmd[10];
- - unsigned char *buffer;
- - int the_result, retries;
- - Scsi_Cmnd * SCpnt;
- - unsigned long flags;
- -
- - buffer = (unsigned char *) scsi_malloc(512);
- - SCpnt = scsi_allocate_device(NULL, scsi_CDs[i].device, 1);
- -
- - retries = 3;
- - do {
- - cmd[0] = READ_CAPACITY;
- - cmd[1] = (scsi_CDs[i].device->lun << 5) & 0xe0;
- - memset ((void *) &cmd[2], 0, 8);
- - SCpnt->request.rq_status = RQ_SCSI_BUSY; /* Mark as really busy */
- - SCpnt->cmd_len = 0;
- +void get_sectorsize(int i)
- +{
- + unsigned char cmd[10];
- + unsigned char *buffer;
- + int the_result, retries;
- + Scsi_Cmnd *SCpnt;
- + unsigned long flags;
- +
- + spin_lock_irq(&io_request_lock);
- + buffer = (unsigned char *) scsi_malloc(512);
- + SCpnt = scsi_allocate_device(NULL, scsi_CDs[i].device, 1);
- + spin_unlock_irq(&io_request_lock);
- +
- + retries = 3;
- + do {
- + cmd[0] = READ_CAPACITY;
- + cmd[1] = (scsi_CDs[i].device->lun << 5) & 0xe0;
- + memset((void *) &cmd[2], 0, 8);
- + SCpnt->request.rq_status = RQ_SCSI_BUSY; /* Mark as really busy */
- + SCpnt->cmd_len = 0;
- +
- + memset(buffer, 0, 8);
- +
- + /* Do the command and wait.. */
- + {
- + struct semaphore sem = MUTEX_LOCKED;
- + SCpnt->request.sem = &sem;
- + spin_lock_irqsave(&io_request_lock, flags);
- + scsi_do_cmd (SCpnt,
- + (void *) cmd, (void *) buffer,
- + 512, sr_init_done, SR_TIMEOUT,
- + MAX_RETRIES);
- + spin_unlock_irqrestore(&io_request_lock, flags);
- + down(&sem);
- + }
-
- - memset(buffer, 0, 8);
- + the_result = SCpnt->result;
- + retries--;
-
- - /* Do the command and wait.. */
- - {
- - struct semaphore sem = MUTEX_LOCKED;
- - SCpnt->request.sem = &sem;
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_do_cmd (SCpnt,
- - (void *) cmd, (void *) buffer,
- - 512, sr_init_done, SR_TIMEOUT,
- - MAX_RETRIES);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - down(&sem);
- - }
- -
- - the_result = SCpnt->result;
- - retries--;
- -
- - } while(the_result && retries);
- -
- -
- - wake_up(&SCpnt->device->device_wait);
- - scsi_release_command(SCpnt);
- - SCpnt = NULL;
- -
- - if (the_result) {
- - scsi_CDs[i].capacity = 0x1fffff;
- - scsi_CDs[i].sector_size = 2048; /* A guess, just in case */
- - scsi_CDs[i].needs_sector_size = 1;
- - } else {
- - scsi_CDs[i].capacity = 1 + ((buffer[0] << 24) |
- - (buffer[1] << 16) |
- - (buffer[2] << 8) |
- - buffer[3]);
- - scsi_CDs[i].sector_size = (buffer[4] << 24) |
- - (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
- - switch (scsi_CDs[i].sector_size) {
- - /*
- - * HP 4020i CD-Recorder reports 2340 byte sectors
- - * Philips CD-Writers report 2352 byte sectors
- - *
- - * Use 2k sectors for them..
- - */
- - case 0: case 2340: case 2352:
- + } while (the_result && retries);
- +
- +
- + wake_up(&SCpnt->device->device_wait);
- + scsi_release_command(SCpnt);
- + SCpnt = NULL;
- +
- + if (the_result) {
- + scsi_CDs[i].capacity = 0x1fffff;
- + scsi_CDs[i].sector_size = 2048; /* A guess, just in case */
- + scsi_CDs[i].needs_sector_size = 1;
- + } else {
- +#if 0
- + if (cdrom_get_last_written(MKDEV(MAJOR_NR, i),
- + (long *) &scsi_CDs[i].capacity))
- +#endif
- + scsi_CDs[i].capacity = 1 + ((buffer[0] << 24) |
- + (buffer[1] << 16) |
- + (buffer[2] << 8) |
- + buffer[3]);
- + scsi_CDs[i].sector_size = (buffer[4] << 24) |
- + (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
- + switch (scsi_CDs[i].sector_size) {
- + /*
- + * HP 4020i CD-Recorder reports 2340 byte sectors
- + * Philips CD-Writers report 2352 byte sectors
- + *
- + * Use 2k sectors for them..
- + */
- + case 0:
- + case 2340:
- + case 2352:
- scsi_CDs[i].sector_size = 2048;
- /* fall through */
- case 2048:
- @@ -943,229 +934,334 @@
- case 512:
- break;
- default:
- - printk ("sr%d: unsupported sector size %d.n",
- - i, scsi_CDs[i].sector_size);
- + printk("sr%d: unsupported sector size %d.n",
- + i, scsi_CDs[i].sector_size);
- scsi_CDs[i].capacity = 0;
- scsi_CDs[i].needs_sector_size = 1;
- - }
- + }
-
- - /*
- - * Add this so that we have the ability to correctly gauge
- - * what the device is capable of.
- - */
- - scsi_CDs[i].needs_sector_size = 0;
- - sr_sizes[i] = scsi_CDs[i].capacity >> (BLOCK_SIZE_BITS - 9);
- - };
- - scsi_free(buffer, 512);
- + /*
- + * Add this so that we have the ability to correctly gauge
- + * what the device is capable of.
- + */
- + scsi_CDs[i].needs_sector_size = 0;
- + sr_sizes[i] = scsi_CDs[i].capacity >> (BLOCK_SIZE_BITS - 9);
- + };
- + scsi_free(buffer, 512);
- }
-
- -void get_capabilities(int i){
- - unsigned char cmd[6];
- - unsigned char *buffer;
- - int rc,n;
- -
- - static char *loadmech[] = {
- - "caddy",
- - "tray",
- - "pop-up",
- - "",
- - "changer",
- - "changer",
- - "",
- - ""
- - };
- -
- - buffer = (unsigned char *) scsi_malloc(512);
- - cmd[0] = MODE_SENSE;
- - cmd[1] = (scsi_CDs[i].device->lun << 5) & 0xe0;
- - cmd[2] = 0x2a;
- - cmd[4] = 128;
- - cmd[3] = cmd[5] = 0;
- - rc = sr_do_ioctl(i, cmd, buffer, 128, 1);
- -
- - if (-EINVAL == rc) {
- - /* failed, drive has'nt this mode page */
- - scsi_CDs[i].cdi.speed = 1;
- - /* disable speed select, drive probably can't do this either */
- - scsi_CDs[i].cdi.mask |= CDC_SELECT_SPEED;
- - } else {
- - n = buffer[3]+4;
- - scsi_CDs[i].cdi.speed = ((buffer[n+8] << 8) + buffer[n+9])/176;
- - scsi_CDs[i].readcd_known = 1;
- - scsi_CDs[i].readcd_cdda = buffer[n+5] & 0x01;
- - /* print some capability bits */
- - printk("sr%i: scsi3-mmc drive: %dx/%dx %s%s%s%s%sn",i,
- - ((buffer[n+14] << 8) + buffer[n+15])/176,
- - scsi_CDs[i].cdi.speed,
- - buffer[n+3]&0x01 ? "writer " : "", /* CD Writer */
- - buffer[n+2]&0x02 ? "cd/rw " : "", /* can read rewriteable */
- - buffer[n+4]&0x20 ? "xa/form2 " : "", /* can read xa/from2 */
- - buffer[n+5]&0x01 ? "cdda " : "", /* can read audio data */
- - loadmech[buffer[n+6]>>5]);
- - if ((buffer[n+6] >> 5) == 0)
- +void get_capabilities(int i)
- +{
- + unsigned char cmd[6];
- + unsigned char *buffer;
- + int rc, n;
- +
- + static char *loadmech[] =
- + {
- + "caddy",
- + "tray",
- + "pop-up",
- + "",
- + "changer",
- + "cartridge changer",
- + "",
- + ""
- + };
- +
- + spin_lock_irq(&io_request_lock);
- + buffer = (unsigned char *) scsi_malloc(512);
- + spin_unlock_irq(&io_request_lock);
- + cmd[0] = MODE_SENSE;
- + cmd[1] = (scsi_CDs[i].device->lun << 5) & 0xe0;
- + cmd[2] = 0x2a;
- + cmd[4] = 128;
- + cmd[3] = cmd[5] = 0;
- + rc = sr_do_ioctl(i, cmd, buffer, 128, 1);
- +
- + if (-EINVAL == rc) {
- + /* failed, drive has'nt this mode page */
- + scsi_CDs[i].cdi.speed = 1;
- + /* disable speed select, drive probably can't do this either */
- + scsi_CDs[i].cdi.mask |= CDC_SELECT_SPEED;
- + scsi_free(buffer, 512);
- + return;
- + }
- + n = buffer[3] + 4;
- + scsi_CDs[i].cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
- + scsi_CDs[i].readcd_known = 1;
- + scsi_CDs[i].readcd_cdda = buffer[n + 5] & 0x01;
- + /* print some capability bits */
- + printk("sr%i: scsi3-mmc drive: %dx/%dx %s%s%s%s%sn", i,
- + ((buffer[n + 14] << 8) + buffer[n + 15]) / 176,
- + scsi_CDs[i].cdi.speed,
- + buffer[n + 3] & 0x01 ? "writer " : "", /* CD Writer */
- + buffer[n + 2] & 0x02 ? "cd/rw " : "", /* can read rewriteable */
- + buffer[n + 4] & 0x20 ? "xa/form2 " : "", /* can read xa/from2 */
- + buffer[n + 5] & 0x01 ? "cdda " : "", /* can read audio data */
- + loadmech[buffer[n + 6] >> 5]);
- + if ((buffer[n + 6] >> 5) == 0)
- /* caddy drives can't close tray... */
- - scsi_CDs[i].cdi.mask |= CDC_CLOSE_TRAY;
- - }
- - scsi_free(buffer, 512);
- + scsi_CDs[i].cdi.mask |= CDC_CLOSE_TRAY;
- + if ((buffer[n + 2] & 0x8) == 0)
- + /* not a DVD drive */
- + scsi_CDs[i].cdi.mask |= CDC_DVD;
- + if ((buffer[n + 3] & 0x20) == 0)
- + /* can't write DVD-RAM media */
- + scsi_CDs[i].cdi.mask |= CDC_DVD_RAM;
- + if ((buffer[n + 3] & 0x10) == 0)
- + /* can't write DVD-R media */
- + scsi_CDs[i].cdi.mask |= CDC_DVD_R;
- + if ((buffer[n + 3] & 0x2) == 0)
- + /* can't write CD-RW media */
- + scsi_CDs[i].cdi.mask |= CDC_CD_RW;
- + if ((buffer[n + 3] & 0x1) == 0)
- + /* can't write CD-R media */
- + scsi_CDs[i].cdi.mask |= CDC_CD_R;
- + if ((buffer[n+6] & 0x8) == 0)
- + /* can't eject */
- + scsi_CDs[i].cdi.mask |= CDC_OPEN_TRAY;
- +
- + if ((buffer[n+6] >> 5) == mechtype_individual_changer ||
- + (buffer[n+6] >> 5) == mechtype_cartridge_changer)
- + scsi_CDs[i].cdi.capacity =
- + cdrom_number_of_slots(&(scsi_CDs[i].cdi));
- + if (scsi_CDs[i].cdi.capacity <= 1)
- + /* not a changer */
- + scsi_CDs[i].cdi.mask |= CDC_SELECT_DISC;
- + /*else I don't think it can close its tray
- + scsi_CDs[i].cdi.mask |= CDC_CLOSE_TRAY; */
- +
- +
- + scsi_free(buffer, 512);
- +}
- +
- +/*
- + * sr_packet() is the entry point for the generic commands generated
- + * by the Uniform CD-ROM layer.
- + */
- +static int sr_packet(struct cdrom_device_info *cdi, struct cdrom_generic_command *cgc)
- +{
- + Scsi_Cmnd *SCpnt;
- + Scsi_Device *device = scsi_CDs[MINOR(cdi->dev)].device;
- + unsigned char *buffer = cgc->buffer;
- + unsigned long flags;
- + int buflen;
- + int stat;
- +
- + /* get the device */
- + SCpnt = scsi_allocate_device(NULL, device, 1);
- + if (SCpnt == NULL)
- + return -ENODEV; /* this just doesn't seem right /axboe */
- +
- + /* use buffer for ISA DMA */
- + buflen = (cgc->buflen + 511) & ~511;
- + if (cgc->buffer && SCpnt->host->unchecked_isa_dma &&
- + (virt_to_phys(cgc->buffer) + cgc->buflen - 1 > ISA_DMA_THRESHOLD)) {
- + spin_lock_irq(&io_request_lock);
- + buffer = scsi_malloc(buflen);
- + spin_unlock_irq(&io_request_lock);
- + if (buffer == NULL) {
- + printk("sr: SCSI DMA pool exhausted.");
- + return -ENOMEM;
- + }
- + memcpy(buffer, cgc->buffer, cgc->buflen);
- + }
- +
- + /* set the LUN */
- + cgc->cmd[1] |= device->lun << 5;
- +
- + /* do the locking and issue the command */
- + SCpnt->request.rq_dev = cdi->dev;
- + /* scsi_do_cmd sets the command length */
- + SCpnt->cmd_len = 0;
- +
- + {
- + struct semaphore sem = MUTEX_LOCKED;
- + SCpnt->request.sem = &sem;
- + spin_lock_irqsave(&io_request_lock, flags);
- + scsi_do_cmd(SCpnt, (void *)cgc->cmd, (void *) buffer,
- + cgc->buflen, sr_init_done, SR_TIMEOUT,
- + MAX_RETRIES);
- + spin_unlock_irqrestore(&io_request_lock, flags);
- + down(&sem);
- + }
- +
- + stat = SCpnt->result;
- +
- + /* release */
- + SCpnt->request.rq_dev = MKDEV(0, 0);
- + scsi_release_command(SCpnt);
- + SCpnt = NULL;
- +
- + /* write DMA buffer back if used */
- + if (buffer && (buffer != cgc->buffer)) {
- + memcpy(cgc->buffer, buffer, cgc->buflen);
- + scsi_free(buffer, buflen);
- + }
- +
- + return stat;
- }
-
- static int sr_registered = 0;
-
- static int sr_init()
- {
- - int i;
- + int i;
-
- - if(sr_template.dev_noticed == 0) return 0;
- + if (sr_template.dev_noticed == 0)
- + return 0;
-
- - if(!sr_registered) {
- - if (register_blkdev(MAJOR_NR,"sr",&cdrom_fops)) {
- - printk("Unable to get major %d for SCSI-CDn",MAJOR_NR);
- - return 1;
- + if (!sr_registered) {
- + if (register_blkdev(MAJOR_NR, "sr", &cdrom_fops)) {
- + printk("Unable to get major %d for SCSI-CDn", MAJOR_NR);
- + return 1;
- + }
- + sr_registered++;
- }
- - sr_registered++;
- - }
- + if (scsi_CDs)
- + return 0;
- + sr_template.dev_max =
- + sr_template.dev_noticed + SR_EXTRA_DEVS;
- + scsi_CDs = (Scsi_CD *) scsi_init_malloc(sr_template.dev_max * sizeof(Scsi_CD), GFP_ATOMIC);
- + memset(scsi_CDs, 0, sr_template.dev_max * sizeof(Scsi_CD));
-
- + sr_sizes = (int *) scsi_init_malloc(sr_template.dev_max * sizeof(int), GFP_ATOMIC);
- + memset(sr_sizes, 0, sr_template.dev_max * sizeof(int));
-
- - if (scsi_CDs) return 0;
- - sr_template.dev_max =
- - sr_template.dev_noticed + SR_EXTRA_DEVS;
- - scsi_CDs = (Scsi_CD *) scsi_init_malloc(sr_template.dev_max * sizeof(Scsi_CD), GFP_ATOMIC);
- - memset(scsi_CDs, 0, sr_template.dev_max * sizeof(Scsi_CD));
- + sr_blocksizes = (int *) scsi_init_malloc(sr_template.dev_max *
- + sizeof(int), GFP_ATOMIC);
-
- - sr_sizes = (int *) scsi_init_malloc(sr_template.dev_max * sizeof(int), GFP_ATOMIC);
- - memset(sr_sizes, 0, sr_template.dev_max * sizeof(int));
- -
- - sr_blocksizes = (int *) scsi_init_malloc(sr_template.dev_max *
- - sizeof(int), GFP_ATOMIC);
- -
- - /*
- - * These are good guesses for the time being.
- - */
- - for(i=0;i<sr_template.dev_max;i++) sr_blocksizes[i] = 2048;
- - blksize_size[MAJOR_NR] = sr_blocksizes;
- - return 0;
- + /*
- + * These are good guesses for the time being.
- + */
- + for (i = 0; i < sr_template.dev_max; i++)
- + sr_blocksizes[i] = 2048;
- + blksize_size[MAJOR_NR] = sr_blocksizes;
- + return 0;
- }
-
- void sr_finish()
- {
- - int i;
- - char name[6];
- + int i;
- + char name[6];
-
- - blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
- - blk_size[MAJOR_NR] = sr_sizes;
- + blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
- + blk_size[MAJOR_NR] = sr_sizes;
-
- - for (i = 0; i < sr_template.nr_dev; ++i)
- - {
- - /* If we have already seen this, then skip it. Comes up
- - * with loadable modules. */
- - if (scsi_CDs[i].capacity) continue;
- - scsi_CDs[i].capacity = 0x1fffff;
- - scsi_CDs[i].sector_size = 2048; /* A guess, just in case */
- - scsi_CDs[i].needs_sector_size = 1;
- - scsi_CDs[i].device->changed = 1; /* force recheck CD type */
- + for (i = 0; i < sr_template.nr_dev; ++i) {
- + /* If we have already seen this, then skip it. Comes up
- + * with loadable modules. */
- + if (scsi_CDs[i].capacity)
- + continue;
- + scsi_CDs[i].capacity = 0x1fffff;
- + scsi_CDs[i].sector_size = 2048; /* A guess, just in case */
- + scsi_CDs[i].needs_sector_size = 1;
- + scsi_CDs[i].device->changed = 1; /* force recheck CD type */
- #if 0
- - /* seems better to leave this for later */
- - get_sectorsize(i);
- - printk("Scd sectorsize = %d bytes.n", scsi_CDs[i].sector_size);
- + /* seems better to leave this for later */
- + get_sectorsize(i);
- + printk("Scd sectorsize = %d bytes.n", scsi_CDs[i].sector_size);
- #endif
- - scsi_CDs[i].use = 1;
- - scsi_CDs[i].ten = 1;
- - scsi_CDs[i].remap = 1;
- - scsi_CDs[i].readcd_known = 0;
- - scsi_CDs[i].readcd_cdda = 0;
- - sr_sizes[i] = scsi_CDs[i].capacity >> (BLOCK_SIZE_BITS - 9);
- -
- - scsi_CDs[i].cdi.ops = &sr_dops;
- - scsi_CDs[i].cdi.handle = &scsi_CDs[i];
- - scsi_CDs[i].cdi.dev = MKDEV(MAJOR_NR,i);
- - scsi_CDs[i].cdi.mask = 0;
- - scsi_CDs[i].cdi.capacity = 1;
- - get_capabilities(i);
- - sr_vendor_init(i);
- -
- - sprintf(name, "sr%d", i);
- - strcpy(scsi_CDs[i].cdi.name, name);
- - register_cdrom(&scsi_CDs[i].cdi);
- - }
- -
- -
- - /* If our host adapter is capable of scatter-gather, then we increase
- - * the read-ahead to 16 blocks (32 sectors). If not, we use
- - * a two block (4 sector) read ahead. */
- - if(scsi_CDs[0].device && scsi_CDs[0].device->host->sg_tablesize)
- - read_ahead[MAJOR_NR] = 32; /* 32 sector read-ahead. Always removable. */
- - else
- - read_ahead[MAJOR_NR] = 4; /* 4 sector read-ahead */
- + scsi_CDs[i].use = 1;
- + scsi_CDs[i].ten = 1;
- + scsi_CDs[i].remap = 1;
- + scsi_CDs[i].readcd_known = 0;
- + scsi_CDs[i].readcd_cdda = 0;
- + sr_sizes[i] = scsi_CDs[i].capacity >> (BLOCK_SIZE_BITS - 9);
- +
- + scsi_CDs[i].cdi.ops = &sr_dops;
- + scsi_CDs[i].cdi.handle = &scsi_CDs[i];
- + scsi_CDs[i].cdi.dev = MKDEV(MAJOR_NR, i);
- + scsi_CDs[i].cdi.mask = 0;
- + scsi_CDs[i].cdi.capacity = 1;
- + get_capabilities(i);
- + sr_vendor_init(i);
- +
- + sprintf(name, "sr%d", i);
- + strcpy(scsi_CDs[i].cdi.name, name);
- + register_cdrom(&scsi_CDs[i].cdi);
- + }
-
- - return;
- +
- + /* If our host adapter is capable of scatter-gather, then we increase
- + * the read-ahead to 16 blocks (32 sectors). If not, we use
- + * a two block (4 sector) read ahead. */
- + if (scsi_CDs[0].device && scsi_CDs[0].device->host->sg_tablesize)
- + read_ahead[MAJOR_NR] = 32; /* 32 sector read-ahead. Always removable. */
- + else
- + read_ahead[MAJOR_NR] = 4; /* 4 sector read-ahead */
- +
- + return;
- }
-
- static void sr_detach(Scsi_Device * SDp)
- {
- - Scsi_CD * cpnt;
- - int i;
- + Scsi_CD *cpnt;
- + int i;
-
- - for(cpnt = scsi_CDs, i=0; i<sr_template.dev_max; i++, cpnt++)
- - if(cpnt->device == SDp) {
- - kdev_t devi = MKDEV(MAJOR_NR, i);
- - struct super_block * sb = get_super(devi);
- -
- - /*
- - * Since the cdrom is read-only, no need to sync the device.
- - * We should be kind to our buffer cache, however.
- - */
- - if (sb) invalidate_inodes(sb);
- - invalidate_buffers(devi);
- -
- - /*
- - * Reset things back to a sane state so that one can re-load a new
- - * driver (perhaps the same one).
- - */
- - unregister_cdrom(&(cpnt->cdi));
- - cpnt->device = NULL;
- - cpnt->capacity = 0;
- - SDp->attached--;
- - sr_template.nr_dev--;
- - sr_template.dev_noticed--;
- - sr_sizes[i] = 0;
- - return;
- - }
- - return;
- + for (cpnt = scsi_CDs, i = 0; i < sr_template.dev_max; i++, cpnt++)
- + if (cpnt->device == SDp) {
- + kdev_t devi = MKDEV(MAJOR_NR, i);
- + struct super_block *sb = get_super(devi);
- +
- + /*
- + * Since the cdrom is read-only, no need to sync the device.
- + * We should be kind to our buffer cache, however.
- + */
- + if (sb)
- + invalidate_inodes(sb);
- + invalidate_buffers(devi);
- +
- + /*
- + * Reset things back to a sane state so that one can re-load a new
- + * driver (perhaps the same one).
- + */
- + unregister_cdrom(&(cpnt->cdi));
- + cpnt->device = NULL;
- + cpnt->capacity = 0;
- + SDp->attached--;
- + sr_template.nr_dev--;
- + sr_template.dev_noticed--;
- + sr_sizes[i] = 0;
- + return;
- + }
- + return;
- }
-
-
- #ifdef MODULE
-
- -int init_module(void) {
- - sr_template.module = &__this_module;
- - return scsi_register_module(MODULE_SCSI_DEV, &sr_template);
- +int init_module(void)
- +{
- + sr_template.module = &__this_module;
- + return scsi_register_module(MODULE_SCSI_DEV, &sr_template);
- }
-
- -void cleanup_module( void)
- +void cleanup_module(void)
- {
- - scsi_unregister_module(MODULE_SCSI_DEV, &sr_template);
- - unregister_blkdev(MAJOR_NR, "sr");
- - sr_registered--;
- - if(scsi_CDs != NULL) {
- - scsi_init_free((char *) scsi_CDs,
- - (sr_template.dev_noticed + SR_EXTRA_DEVS)
- - * sizeof(Scsi_CD));
- -
- - scsi_init_free((char *) sr_sizes, sr_template.dev_max * sizeof(int));
- - sr_sizes = NULL;
- -
- - scsi_init_free((char *) sr_blocksizes, sr_template.dev_max * sizeof(int));
- - sr_blocksizes = NULL;
- - }
- -
- - blksize_size[MAJOR_NR] = NULL;
- - blk_dev[MAJOR_NR].request_fn = NULL;
- - blk_size[MAJOR_NR] = NULL;
- - read_ahead[MAJOR_NR] = 0;
- + scsi_unregister_module(MODULE_SCSI_DEV, &sr_template);
- + unregister_blkdev(MAJOR_NR, "sr");
- + sr_registered--;
- + if (scsi_CDs != NULL) {
- + scsi_init_free((char *) scsi_CDs,
- + (sr_template.dev_noticed + SR_EXTRA_DEVS)
- + * sizeof(Scsi_CD));
- +
- + scsi_init_free((char *) sr_sizes, sr_template.dev_max * sizeof(int));
- + sr_sizes = NULL;
-
- - sr_template.dev_max = 0;
- + scsi_init_free((char *) sr_blocksizes, sr_template.dev_max * sizeof(int));
- + sr_blocksizes = NULL;
- + }
- + blksize_size[MAJOR_NR] = NULL;
- + blk_dev[MAJOR_NR].request_fn = NULL;
- + blk_size[MAJOR_NR] = NULL;
- + read_ahead[MAJOR_NR] = 0;
- +
- + sr_template.dev_max = 0;
- }
- -#endif /* MODULE */
- +
- +#endif /* MODULE */
-
- /*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- diff -ur --exclude-from /home/axboe/cdrom/exclude-from linux-2.2.13/drivers/scsi/sr_ioctl.c linux/drivers/scsi/sr_ioctl.c
- --- linux-2.2.13/drivers/scsi/sr_ioctl.c Thu Sep 9 12:27:30 1999
- +++ linux/drivers/scsi/sr_ioctl.c Sun Oct 31 13:40:08 1999
- @@ -18,9 +18,6 @@
- # define DEBUG
- #endif
-
- -/* for now we borrow the "operation not supported" from the network folks */
- -#define EDRIVE_CANT_DO_THIS EOPNOTSUPP
- -
- /* The sr_is_xa() seems to trigger firmware bugs with some drives :-(
- * It is off by default and can be turned on with this module parameter */
- static int xa_test = 0;
- @@ -38,6 +35,12 @@
-
- req = &SCpnt->request;
- req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
- +
- + if (SCpnt->buffer && req->buffer && SCpnt->buffer != req->buffer) {
- + memcpy(req->buffer, SCpnt->buffer, SCpnt->bufflen);
- + scsi_free(SCpnt->buffer, (SCpnt->bufflen + 511) & ~511);
- + SCpnt->buffer = req->buffer;
- + }
-
- if (req->sem != NULL) {
- up(req->sem);
- @@ -54,12 +57,26 @@
- Scsi_Device * SDev;
- int result, err = 0, retries = 0;
- unsigned long flags;
- + char * bounce_buffer;
-
- spin_lock_irqsave(&io_request_lock, flags);
- SDev = scsi_CDs[target].device;
- SCpnt = scsi_allocate_device(NULL, scsi_CDs[target].device, 1);
- spin_unlock_irqrestore(&io_request_lock, flags);
-
- + /* use ISA DMA buffer if necessary */
- + SCpnt->request.buffer=buffer;
- + if (buffer && SCpnt->host->unchecked_isa_dma &&
- + (virt_to_phys(buffer) + buflength - 1 > ISA_DMA_THRESHOLD)) {
- + bounce_buffer = (char *)scsi_malloc((buflength + 511) & ~511);
- + if (bounce_buffer == NULL) {
- + printk("SCSI DMA pool exhausted.");
- + return -ENOMEM;
- + }
- + memcpy(bounce_buffer, (char *)buffer, buflength);
- + buffer = bounce_buffer;
- + }
- +
- retry:
- if( !scsi_block_when_processing_errors(SDev) )
- return -ENODEV;
- @@ -74,7 +91,7 @@
- down(&sem);
- SCpnt->request.sem = NULL;
- }
- -
- +
- result = SCpnt->result;
-
- /* Minimal error checking. Ignore cases we know about, and report the rest. */
- @@ -159,7 +176,7 @@
- {
- u_char sr_cmd[10];
-
- - sr_cmd[0] = TEST_UNIT_READY;
- + sr_cmd[0] = GPCMD_TEST_UNIT_READY;
- sr_cmd[1] = ((scsi_CDs[minor].device -> lun) << 5);
- sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
- return sr_do_ioctl(minor, sr_cmd, NULL, 255, 1);
- @@ -169,7 +186,7 @@
- {
- u_char sr_cmd[10];
-
- - sr_cmd[0] = START_STOP;
- + sr_cmd[0] = GPCMD_START_STOP_UNIT;
- sr_cmd[1] = ((scsi_CDs[MINOR(cdi->dev)].device -> lun) << 5);
- sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0;
- sr_cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */;
- @@ -239,11 +256,10 @@
- int sr_get_mcn(struct cdrom_device_info *cdi,struct cdrom_mcn *mcn)
- {
- u_char sr_cmd[10];
- - char * buffer;
- + char buffer[32];
- int result;
- - unsigned long flags;
-
- - sr_cmd[0] = SCMD_READ_SUBCHANNEL;
- + sr_cmd[0] = GPCMD_READ_SUBCHANNEL;
- sr_cmd[1] = ((scsi_CDs[MINOR(cdi->dev)].device->lun) << 5);
- sr_cmd[2] = 0x40; /* I do want the subchannel info */
- sr_cmd[3] = 0x02; /* Give me medium catalog number info */
- @@ -253,20 +269,11 @@
- sr_cmd[8] = 24;
- sr_cmd[9] = 0;
-
- - spin_lock_irqsave(&io_request_lock, flags);
- - buffer = (unsigned char*) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!buffer) return -ENOMEM;
- -
- result = sr_do_ioctl(MINOR(cdi->dev), sr_cmd, buffer, 24, 0);
-
- memcpy (mcn->medium_catalog_number, buffer + 9, 13);
- mcn->medium_catalog_number[13] = 0;
-
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- -
- return result;
- }
-
- @@ -286,7 +293,7 @@
- speed *= 177; /* Nx to kbyte/s */
-
- memset(sr_cmd,0,12);
- - sr_cmd[0] = 0xbb; /* SET CD SPEED */
- + sr_cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */
- sr_cmd[1] = (scsi_CDs[MINOR(cdi->dev)].device->lun) << 5;
- sr_cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */
- sr_cmd[3] = speed & 0xff; /* LSB */
- @@ -299,105 +306,22 @@
- /* ----------------------------------------------------------------------- */
- /* this is called by the generic cdrom driver. arg is a _kernel_ pointer, */
- /* becauce the generic cdrom driver does the user access stuff for us. */
- +/* only cdromreadtochdr and cdromreadtocentry are left - for use with the */
- +/* sr_disk_status interface for the generic cdrom driver. */
-
- int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void* arg)
- {
- u_char sr_cmd[10];
- - int result, target;
- -
- - target = MINOR(cdi->dev);
- + int result, target = MINOR(cdi->dev);
- + unsigned char buffer[32];
-
- switch (cmd)
- {
- - /* Sun-compatible */
- - case CDROMPAUSE:
- -
- - sr_cmd[0] = SCMD_PAUSE_RESUME;
- - sr_cmd[1] = scsi_CDs[target].device->lun << 5;
- - sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = 0;
- - sr_cmd[5] = sr_cmd[6] = sr_cmd[7] = 0;
- - sr_cmd[8] = 0;
- - sr_cmd[9] = 0;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- -
- - case CDROMRESUME:
- -
- - sr_cmd[0] = SCMD_PAUSE_RESUME;
- - sr_cmd[1] = scsi_CDs[target].device->lun << 5;
- - sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = 0;
- - sr_cmd[5] = sr_cmd[6] = sr_cmd[7] = 0;
- - sr_cmd[8] = 1;
- - sr_cmd[9] = 0;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- -
- - case CDROMPLAYMSF:
- - {
- - struct cdrom_msf* msf = (struct cdrom_msf*)arg;
- -
- - sr_cmd[0] = SCMD_PLAYAUDIO_MSF;
- - sr_cmd[1] = scsi_CDs[target].device->lun << 5;
- - sr_cmd[2] = 0;
- - sr_cmd[3] = msf->cdmsf_min0;
- - sr_cmd[4] = msf->cdmsf_sec0;
- - sr_cmd[5] = msf->cdmsf_frame0;
- - sr_cmd[6] = msf->cdmsf_min1;
- - sr_cmd[7] = msf->cdmsf_sec1;
- - sr_cmd[8] = msf->cdmsf_frame1;
- - sr_cmd[9] = 0;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- - }
- -
- - case CDROMPLAYBLK:
- - {
- - struct cdrom_blk* blk = (struct cdrom_blk*)arg;
- -
- - sr_cmd[0] = SCMD_PLAYAUDIO10;
- - sr_cmd[1] = scsi_CDs[target].device->lun << 5;
- - sr_cmd[2] = blk->from >> 24;
- - sr_cmd[3] = blk->from >> 16;
- - sr_cmd[4] = blk->from >> 8;
- - sr_cmd[5] = blk->from;
- - sr_cmd[6] = 0;
- - sr_cmd[7] = blk->len >> 8;
- - sr_cmd[8] = blk->len;
- - sr_cmd[9] = 0;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- - }
- -
- - case CDROMPLAYTRKIND:
- - {
- - struct cdrom_ti* ti = (struct cdrom_ti*)arg;
- -
- - sr_cmd[0] = SCMD_PLAYAUDIO_TI;
- - sr_cmd[1] = scsi_CDs[target].device->lun << 5;
- - sr_cmd[2] = 0;
- - sr_cmd[3] = 0;
- - sr_cmd[4] = ti->cdti_trk0;
- - sr_cmd[5] = ti->cdti_ind0;
- - sr_cmd[6] = 0;
- - sr_cmd[7] = ti->cdti_trk1;
- - sr_cmd[8] = ti->cdti_ind1;
- - sr_cmd[9] = 0;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- - }
- -
- case CDROMREADTOCHDR:
- {
- struct cdrom_tochdr* tochdr = (struct cdrom_tochdr*)arg;
- - char * buffer;
- - unsigned long flags;
-
- - sr_cmd[0] = SCMD_READ_TOC;
- + sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
- sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5);
- sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
- sr_cmd[6] = 0;
- @@ -405,29 +329,19 @@
- sr_cmd[8] = 12; /* LSB of length */
- sr_cmd[9] = 0;
-
- - spin_lock_irqsave(&io_request_lock, flags);
- - buffer = (unsigned char *) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!buffer) return -ENOMEM;
- -
- result = sr_do_ioctl(target, sr_cmd, buffer, 12, 1);
-
- tochdr->cdth_trk0 = buffer[2];
- tochdr->cdth_trk1 = buffer[3];
-
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- break;
- }
-
- case CDROMREADTOCENTRY:
- {
- struct cdrom_tocentry* tocentry = (struct cdrom_tocentry*)arg;
- - unsigned char * buffer;
- - unsigned long flags;
-
- - sr_cmd[0] = SCMD_READ_TOC;
- + sr_cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
- sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5) |
- (tocentry->cdte_format == CDROM_MSF ? 0x02 : 0);
- sr_cmd[2] = sr_cmd[3] = sr_cmd[4] = sr_cmd[5] = 0;
- @@ -436,11 +350,6 @@
- sr_cmd[8] = 12; /* LSB of length */
- sr_cmd[9] = 0;
-
- - spin_lock_irqsave(&io_request_lock, flags);
- - buffer = (unsigned char *) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!buffer) return -ENOMEM;
- -
- result = sr_do_ioctl (target, sr_cmd, buffer, 12, 0);
-
- tocentry->cdte_ctrl = buffer[5] & 0xf;
- @@ -454,187 +363,9 @@
- tocentry->cdte_addr.lba = (((((buffer[8] << 8) + buffer[9]) << 8)
- + buffer[10]) << 8) + buffer[11];
-
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- break;
- }
- -
- - case CDROMSTOP:
- - sr_cmd[0] = START_STOP;
- - sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5) | 1;
- - sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0;
- - sr_cmd[4] = 0;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- -
- - case CDROMSTART:
- - sr_cmd[0] = START_STOP;
- - sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5) | 1;
- - sr_cmd[2] = sr_cmd[3] = sr_cmd[5] = 0;
- - sr_cmd[4] = 1;
- -
- - result = sr_do_ioctl(target, sr_cmd, NULL, 255, 0);
- - break;
- -
- - case CDROMVOLCTRL:
- - {
- - char * buffer, * mask;
- - struct cdrom_volctrl* volctrl = (struct cdrom_volctrl*)arg;
- - unsigned long flags;
- -
- - /* First we get the current params so we can just twiddle the volume */
- -
- - sr_cmd[0] = MODE_SENSE;
- - sr_cmd[1] = (scsi_CDs[target].device -> lun) << 5;
- - sr_cmd[2] = 0xe; /* Want mode page 0xe, CDROM audio params */
- - sr_cmd[3] = 0;
- - sr_cmd[4] = 28;
- - sr_cmd[5] = 0;
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - buffer = (unsigned char *) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!buffer) return -ENOMEM;
- -
- - if ((result = sr_do_ioctl (target, sr_cmd, buffer, 28, 0))) {
- - printk ("Hosed while obtaining audio mode pagen");
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - break;
- - }
- -
- - sr_cmd[0] = MODE_SENSE;
- - sr_cmd[1] = (scsi_CDs[target].device -> lun) << 5;
- - sr_cmd[2] = 0x4e; /* Want the mask for mode page 0xe */
- - sr_cmd[3] = 0;
- - sr_cmd[4] = 28;
- - sr_cmd[5] = 0;
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - mask = (unsigned char *) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!mask) {
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - result = -ENOMEM;
- - break;
- - };
- -
- - if ((result = sr_do_ioctl (target, sr_cmd, mask, 28, 0))) {
- - printk ("Hosed while obtaining mask for audio mode pagen");
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - scsi_free(mask, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - break;
- - }
- -
- - /* Now mask and substitute our own volume and reuse the rest */
- - buffer[0] = 0; /* Clear reserved field */
- -
- - buffer[21] = volctrl->channel0 & mask[21];
- - buffer[23] = volctrl->channel1 & mask[23];
- - buffer[25] = volctrl->channel2 & mask[25];
- - buffer[27] = volctrl->channel3 & mask[27];
- -
- - sr_cmd[0] = MODE_SELECT;
- - sr_cmd[1] = ((scsi_CDs[target].device -> lun) << 5) | 0x10; /* Params are SCSI-2 */
- - sr_cmd[2] = sr_cmd[3] = 0;
- - sr_cmd[4] = 28;
- - sr_cmd[5] = 0;
- -
- - result = sr_do_ioctl (target, sr_cmd, buffer, 28, 0);
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - scsi_free(mask, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - break;
- - }
- -
- - case CDROMVOLREAD:
- - {
- - char * buffer;
- - struct cdrom_volctrl* volctrl = (struct cdrom_volctrl*)arg;
- - unsigned long flags;
- -
- - /* Get the current params */
- -
- - sr_cmd[0] = MODE_SENSE;
- - sr_cmd[1] = (scsi_CDs[target].device -> lun) << 5;
- - sr_cmd[2] = 0xe; /* Want mode page 0xe, CDROM audio params */
- - sr_cmd[3] = 0;
- - sr_cmd[4] = 28;
- - sr_cmd[5] = 0;
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - buffer = (unsigned char *) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!buffer) return -ENOMEM;
- -
- - if ((result = sr_do_ioctl (target, sr_cmd, buffer, 28, 0))) {
- - printk ("(CDROMVOLREAD) Hosed while obtaining audio mode pagen");
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - break;
- - }
-
- - volctrl->channel0 = buffer[21];
- - volctrl->channel1 = buffer[23];
- - volctrl->channel2 = buffer[25];
- - volctrl->channel3 = buffer[27];
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - break;
- - }
- -
- - case CDROMSUBCHNL:
- - {
- - struct cdrom_subchnl* subchnl = (struct cdrom_subchnl*)arg;
- - char * buffer;
- - unsigned long flags;
- -
- - sr_cmd[0] = SCMD_READ_SUBCHANNEL;
- - sr_cmd[1] = ((scsi_CDs[target].device->lun) << 5) | 0x02; /* MSF format */
- - sr_cmd[2] = 0x40; /* I do want the subchannel info */
- - sr_cmd[3] = 0x01; /* Give me current position info */
- - sr_cmd[4] = sr_cmd[5] = 0;
- - sr_cmd[6] = 0;
- - sr_cmd[7] = 0;
- - sr_cmd[8] = 16;
- - sr_cmd[9] = 0;
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - buffer = (unsigned char *) scsi_malloc(512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if(!buffer) return -ENOMEM;
- -
- - result = sr_do_ioctl(target, sr_cmd, buffer, 16, 0);
- -
- - subchnl->cdsc_audiostatus = buffer[1];
- - subchnl->cdsc_format = CDROM_MSF;
- - subchnl->cdsc_ctrl = buffer[5] & 0xf;
- - subchnl->cdsc_trk = buffer[6];
- - subchnl->cdsc_ind = buffer[7];
- -
- - subchnl->cdsc_reladdr.msf.minute = buffer[13];
- - subchnl->cdsc_reladdr.msf.second = buffer[14];
- - subchnl->cdsc_reladdr.msf.frame = buffer[15];
- - subchnl->cdsc_absaddr.msf.minute = buffer[9];
- - subchnl->cdsc_absaddr.msf.second = buffer[10];
- - subchnl->cdsc_absaddr.msf.frame = buffer[11];
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(buffer, 512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - break;
- - }
- default:
- return -EINVAL;
- }
- @@ -672,7 +403,7 @@
- #endif
-
- memset(cmd,0,12);
- - cmd[0] = 0xbe /* READ_CD */;
- + cmd[0] = GPCMD_READ_CD; /* READ_CD */
- cmd[1] = (scsi_CDs[minor].device->lun << 5) | ((format & 7) << 2);
- cmd[2] = (unsigned char)(lba >> 24) & 0xff;
- cmd[3] = (unsigned char)(lba >> 16) & 0xff;
- @@ -718,7 +449,7 @@
- #endif
-
- memset(cmd,0,12);
- - cmd[0] = READ_10;
- + cmd[0] = GPCMD_READ_10;
- cmd[1] = (scsi_CDs[minor].device->lun << 5);
- cmd[2] = (unsigned char)(lba >> 24) & 0xff;
- cmd[3] = (unsigned char)(lba >> 16) & 0xff;
- @@ -768,131 +499,7 @@
- int sr_dev_ioctl(struct cdrom_device_info *cdi,
- unsigned int cmd, unsigned long arg)
- {
- - int target, err;
- -
- - target = MINOR(cdi->dev);
- -
- - switch (cmd) {
- - case CDROMREADMODE1:
- - case CDROMREADMODE2:
- - case CDROMREADRAW:
- - {
- - unsigned char *raw;
- - struct cdrom_msf msf;
- - int lba, rc;
- - int blocksize = 2048;
- - unsigned long flags;
- -
- - switch (cmd) {
- - case CDROMREADMODE2: blocksize = CD_FRAMESIZE_RAW0; break; /* 2336 */
- - case CDROMREADRAW: blocksize = CD_FRAMESIZE_RAW; break; /* 2352 */
- - }
- -
- - if (copy_from_user(&msf,(void*)arg,sizeof(msf)))
- - return -EFAULT;
- - spin_lock_irqsave(&io_request_lock, flags);
- - raw = scsi_malloc(2048+512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if (!(raw))
- - return -ENOMEM;
- -
- - lba = (((msf.cdmsf_min0 * CD_SECS) + msf.cdmsf_sec0)
- - * CD_FRAMES + msf.cdmsf_frame0) - CD_MSF_OFFSET;
- - if (lba < 0 || lba >= scsi_CDs[target].capacity)
- - return -EINVAL;
- -
- - rc = sr_read_sector(target, lba, blocksize, raw);
- - if (!rc)
- - if (copy_to_user((void*)arg, raw, blocksize))
- - rc = -EFAULT;
- -
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(raw,2048+512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - return rc;
- - }
- - case CDROMREADAUDIO:
- - {
- - unsigned char *raw;
- - int lba, rc=0;
- - struct cdrom_read_audio ra;
- - unsigned long flags;
- -
- - if (!scsi_CDs[target].readcd_known || !scsi_CDs[target].readcd_cdda)
- - return -EINVAL; /* -EDRIVE_DOES_NOT_SUPPORT_THIS ? */
- -
- - if (copy_from_user(&ra,(void*)arg,sizeof(ra)))
- - return -EFAULT;
- -
- - if (ra.addr_format == CDROM_LBA)
- - lba = ra.addr.lba;
- - else
- - lba = (((ra.addr.msf.minute * CD_SECS) + ra.addr.msf.second)
- - * CD_FRAMES + ra.addr.msf.frame) - CD_MSF_OFFSET;
- -
- - if (lba < 0 || lba >= scsi_CDs[target].capacity)
- - return -EINVAL;
- - spin_lock_irqsave(&io_request_lock, flags);
- - raw = scsi_malloc(2048+512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - if (!(raw))
- - return -ENOMEM;
- -
- - while (ra.nframes > 0) {
- - rc = sr_read_cd(target, raw, lba, 1, CD_FRAMESIZE_RAW);
- - if (!rc)
- - if (copy_to_user(ra.buf, raw, CD_FRAMESIZE_RAW))
- - rc = -EFAULT;
- - if (rc)
- - break;
- -
- - ra.buf += CD_FRAMESIZE_RAW;
- - ra.nframes -= 1;
- - lba++;
- - }
- - spin_lock_irqsave(&io_request_lock, flags);
- - scsi_free(raw,2048+512);
- - spin_unlock_irqrestore(&io_request_lock, flags);
- - return rc;
- - }
- - case BLKRAGET:
- - if (!arg)
- - return -EINVAL;
- - err = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
- - if (err)
- - return err;
- - put_user(read_ahead[MAJOR(cdi->dev)], (long *) arg);
- - return 0;
- -
- - case BLKRASET:
- - if(!capable(CAP_SYS_ADMIN))
- - return -EACCES;
- - if(!(cdi->dev))
- - return -EINVAL;
- - if(arg > 0xff)
- - return -EINVAL;
- - read_ahead[MAJOR(cdi->dev)] = arg;
- - return 0;
- -
- - case BLKSSZGET:
- - /* Block size of media */
- - return put_user(blksize_size[MAJOR(cdi->dev)][MINOR(cdi->dev)],
- - (int *)arg);
- -
- - RO_IOCTLS(cdi->dev,arg);
- -
- - case BLKFLSBUF:
- - if(!capable(CAP_SYS_ADMIN))
- - return -EACCES;
- - if(!(cdi->dev))
- - return -EINVAL;
- - fsync_dev(cdi->dev);
- - invalidate_buffers(cdi->dev);
- - return 0;
- -
- - default:
- - return scsi_ioctl(scsi_CDs[target].device,cmd,(void *) arg);
- - }
- + return scsi_ioctl(scsi_CDs[MINOR(cdi->dev)].device,cmd,(void *) arg);
- }
-
- /*
- diff -ur --exclude-from /home/axboe/cdrom/exclude-from linux-2.2.13/drivers/scsi/sr_vendor.c linux/drivers/scsi/sr_vendor.c
- --- linux-2.2.13/drivers/scsi/sr_vendor.c Wed May 12 13:57:12 1999
- +++ linux/drivers/scsi/sr_vendor.c Sun Oct 31 13:28:08 1999
- @@ -60,8 +60,7 @@
-
- #define VENDOR_ID (scsi_CDs[minor].vendor)
-
- -void
- -sr_vendor_init(int minor)
- +void sr_vendor_init(int minor)
- {
- #ifndef CONFIG_BLK_DEV_SR_VENDOR
- VENDOR_ID = VENDOR_SCSI3;
- @@ -104,8 +103,7 @@
- /* small handy function for switching block length using MODE SELECT,
- * used by sr_read_sector() */
-
- -int
- -sr_set_blocklength(int minor, int blocklength)
- +int sr_set_blocklength(int minor, int blocklength)
- {
- unsigned char *buffer; /* the buffer for the ioctl */
- unsigned char cmd[12]; /* the scsi-command */
- @@ -160,7 +158,9 @@
- if (scsi_CDs[minor].cdi.mask & CDC_MULTI_SESSION)
- return 0;
-
- + spin_lock_irq(&io_request_lock);
- buffer = (unsigned char *) scsi_malloc(512);
- + spin_unlock_irq(&io_request_lock);
- if(!buffer) return -ENOMEM;
-
- sector = 0; /* the multisession sector offset goes here */
- diff -ur --exclude-from /home/axboe/cdrom/exclude-from linux-2.2.13/fs/isofs/inode.c linux/fs/isofs/inode.c
- --- linux-2.2.13/fs/isofs/inode.c Fri Nov 5 15:15:40 1999
- +++ linux/fs/isofs/inode.c Sun Oct 31 13:23:55 1999
- @@ -411,7 +411,7 @@
- struct inode inode_fake;
- struct file_operations *fops;
- extern struct file_operations * get_blkfops(unsigned int);
- - int i;
- + int i, session = 0;
-
- vol_desc_start=0;
- fops = get_blkfops(MAJOR(dev));
- @@ -424,6 +424,27 @@
- mm_segment_t old_fs=get_fs();
- inode_fake.i_rdev=dev;
- ms_info.addr_format=CDROM_LBA;
- + /* If a minor device was explicitly opened, set session to the
- + * minor number. For instance, if /dev/hdc1 is mounted, session
- + * 1 on the CD-ROM is selected. CD_PART_MAX gives access to
- + * a max of 64 sessions on IDE. SCSI drives must still use
- + * the session option to mount.
- + */
- + if ((MINOR(dev) % CD_PART_MAX) && (MAJOR(dev) != SCSI_CDROM_MAJOR))
- + session = MINOR(dev) % CD_PART_MAX;
- + if (session > 0 && session <= CD_PART_MAX) {
- + struct cdrom_tocentry entry;
- + entry.cdte_track=session;
- + entry.cdte_format=CDROM_LBA;
- + set_fs(KERNEL_DS);
- + i=get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
- + NULL, CDROMREADTOCENTRY, (unsigned long) &entry);
- + set_fs(old_fs);
- + if(!i) printk(KERN_ERR"Session %d start %d type %dn",session,entry.cdte_addr.lba,entry.cdte_ctrl&CDROM_DATA_TRACK);
- + if(i || (entry.cdte_ctrl & CDROM_DATA_TRACK) != 4)
- + printk(KERN_ERR"Invalid session number or type of trackn");
- + else return entry.cdte_addr.lba;
- + }
- set_fs(KERNEL_DS);
- i=get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
- NULL,
- diff -ur --exclude-from /home/axboe/cdrom/exclude-from linux-2.2.13/include/linux/cdrom.h linux/include/linux/cdrom.h
- --- linux-2.2.13/include/linux/cdrom.h Mon Mar 22 03:37:56 1999
- +++ linux/include/linux/cdrom.h Sun Oct 31 16:05:05 1999
- @@ -11,6 +11,8 @@
- #ifndef _LINUX_CDROM_H
- #define _LINUX_CDROM_H
-
- +#include <linux/types.h>
- +
- /*******************************************************
- * As of Linux 2.1.x, all Linux CD-ROM application programs will use this
- * (and only this) include file. It is my hope to provide Linux with
- @@ -94,16 +96,26 @@
- #define CDROMPLAYBLK 0x5317 /* (struct cdrom_blk) */
-
- /*
- - * These ioctls are used only used in optcd.c
- + * These ioctls are only used in optcd.c
- */
- #define CDROMREADALL 0x5318 /* read all 2646 bytes */
- -#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
- +
- +/*
- + * These ioctls are (now) only in ide-cd.c for controlling
- + * drive spindown time. They should be implemented in the
- + * Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
- + * GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
- + * -Erik
- + */
- +#define CDROMGETSPINDOWN 0x531d
- +#define CDROMSETSPINDOWN 0x531e
-
- /*
- * These ioctls are implemented through the uniform CD-ROM driver
- * They _will_ be adopted by all CD-ROM drivers, when all the CD-ROM
- * drivers are eventually ported to the uniform CD-ROM driver interface.
- */
- +#define CDROMCLOSETRAY 0x5319 /* pendant of CDROMEJECT */
- #define CDROM_SET_OPTIONS 0x5320 /* Set behavior options */
- #define CDROM_CLEAR_OPTIONS 0x5321 /* Clear behavior options */
- #define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */
- @@ -119,6 +131,15 @@
- /* This ioctl is only used by sbpcd at the moment */
- #define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
-
- +/* DVD-ROM Specific ioctls */
- +#define DVD_READ_STRUCT 0x5390 /* Read structure */
- +#define DVD_WRITE_STRUCT 0x5391 /* Write structure */
- +#define DVD_AUTH 0x5392 /* Authentication */
- +
- +#define CDROM_SEND_PACKET 0x5393 /* send a packet to the drive */
- +#define CDROM_NEXT_WRITABLE 0x5394 /* get next writable block */
- +#define CDROM_LAST_WRITTEN 0x5395 /* get last block written on disc */
- +
- /*******************************************************
- * CDROM IOCTL structures
- *******************************************************/
- @@ -126,9 +147,9 @@
- /* Address in MSF format */
- struct cdrom_msf0
- {
- - u_char minute;
- - u_char second;
- - u_char frame;
- + __u8 minute;
- + __u8 second;
- + __u8 frame;
- };
-
- /* Address in either MSF or logical format */
- @@ -141,48 +162,48 @@
- /* This struct is used by the CDROMPLAYMSF ioctl */
- struct cdrom_msf
- {
- - u_char cdmsf_min0; /* start minute */
- - u_char cdmsf_sec0; /* start second */
- - u_char cdmsf_frame0; /* start frame */
- - u_char cdmsf_min1; /* end minute */
- - u_char cdmsf_sec1; /* end second */
- - u_char cdmsf_frame1; /* end frame */
- + __u8 cdmsf_min0; /* start minute */
- + __u8 cdmsf_sec0; /* start second */
- + __u8 cdmsf_frame0; /* start frame */
- + __u8 cdmsf_min1; /* end minute */
- + __u8 cdmsf_sec1; /* end second */
- + __u8 cdmsf_frame1; /* end frame */
- };
-
- /* This struct is used by the CDROMPLAYTRKIND ioctl */
- struct cdrom_ti
- {
- - u_char cdti_trk0; /* start track */
- - u_char cdti_ind0; /* start index */
- - u_char cdti_trk1; /* end track */
- - u_char cdti_ind1; /* end index */
- + __u8 cdti_trk0; /* start track */
- + __u8 cdti_ind0; /* start index */
- + __u8 cdti_trk1; /* end track */
- + __u8 cdti_ind1; /* end index */
- };
-
- /* This struct is used by the CDROMREADTOCHDR ioctl */
- struct cdrom_tochdr
- {
- - u_char cdth_trk0; /* start track */
- - u_char cdth_trk1; /* end track */
- + __u8 cdth_trk0; /* start track */
- + __u8 cdth_trk1; /* end track */
- };
-
- /* This struct is used by the CDROMVOLCTRL and CDROMVOLREAD ioctls */
- struct cdrom_volctrl
- {
- - u_char channel0;
- - u_char channel1;
- - u_char channel2;
- - u_char channel3;
- + __u8 channel0;
- + __u8 channel1;
- + __u8 channel2;
- + __u8 channel3;
- };
-
- /* This struct is used by the CDROMSUBCHNL ioctl */
- struct cdrom_subchnl
- {
- - u_char cdsc_format;
- - u_char cdsc_audiostatus;
- - u_char cdsc_adr: 4;
- - u_char cdsc_ctrl: 4;
- - u_char cdsc_trk;
- - u_char cdsc_ind;
- + __u8 cdsc_format;
- + __u8 cdsc_audiostatus;
- + __u8 cdsc_adr: 4;
- + __u8 cdsc_ctrl: 4;
- + __u8 cdsc_trk;
- + __u8 cdsc_ind;
- union cdrom_addr cdsc_absaddr;
- union cdrom_addr cdsc_reladdr;
- };
- @@ -191,12 +212,12 @@
- /* This struct is used by the CDROMREADTOCENTRY ioctl */
- struct cdrom_tocentry
- {
- - u_char cdte_track;
- - u_char cdte_adr :4;
- - u_char cdte_ctrl :4;
- - u_char cdte_format;
- + __u8 cdte_track;
- + __u8 cdte_adr :4;
- + __u8 cdte_ctrl :4;
- + __u8 cdte_format;
- union cdrom_addr cdte_addr;
- - u_char cdte_datamode;
- + __u8 cdte_datamode;
- };
-
- /* This struct is used by the CDROMREADMODE1, and CDROMREADMODE2 ioctls */
- @@ -211,9 +232,9 @@
- struct cdrom_read_audio
- {
- union cdrom_addr addr; /* frame address */
- - u_char addr_format; /* CDROM_LBA or CDROM_MSF */
- + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
- int nframes; /* number of 2352-byte-frames to read at once */
- - u_char *buf; /* frame buffer (size: nframes*2352 bytes) */
- + __u8 *buf; /* frame buffer (size: nframes*2352 bytes) */
- };
-
- /* This struct is used with the CDROMMULTISESSION ioctl */
- @@ -222,8 +243,8 @@
- union cdrom_addr addr; /* frame address: start-of-last-session
- (not the new "frame 16"!). Only valid
- if the "xa_flag" is true. */
- - u_char xa_flag; /* 1: "is XA disk" */
- - u_char addr_format; /* CDROM_LBA or CDROM_MSF */
- + __u8 xa_flag; /* 1: "is XA disk" */
- + __u8 addr_format; /* CDROM_LBA or CDROM_MSF */
- };
-
- /* This struct is used with the CDROM_GET_MCN ioctl.
- @@ -233,7 +254,7 @@
- */
- struct cdrom_mcn
- {
- - u_char medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
- + __u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
- };
-
- /* This is used by the CDROMPLAYBLK ioctl */
- @@ -243,6 +264,18 @@
- unsigned short len;
- };
-
- +#define CDROM_PACKET_SIZE 12
- +
- +/* for CDROM_PACKET_COMMAND ioctl */
- +struct cdrom_generic_command
- +{
- + unsigned char cmd[CDROM_PACKET_SIZE];
- + unsigned char *buffer;
- + unsigned int buflen;
- + int stat;
- + void *reserved[4];
- +};
- +
-
- /*
- * A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
- @@ -321,14 +354,6 @@
- #define CDROM_AUDIO_ERROR 0x14 /* audio play stopped due to error */
- #define CDROM_AUDIO_NO_STATUS 0x15 /* no current audio status to return */
-
- -/* CD-ROM-specific SCSI command opcodes */
- -#define SCMD_READ_TOC 0x43 /* read table of contents */
- -#define SCMD_PLAYAUDIO_MSF 0x47 /* play data at time offset */
- -#define SCMD_PLAYAUDIO_TI 0x48 /* play data at track/index */
- -#define SCMD_PAUSE_RESUME 0x4B /* pause/resume audio */
- -#define SCMD_READ_SUBCHANNEL 0x42 /* read SC info on playing disc */
- -#define SCMD_PLAYAUDIO10 0x45 /* play data at logical block */
- -
- /* capability flags used with the uniform CD-ROM driver */
- #define CDC_CLOSE_TRAY 0x1 /* caddy systems _can't_ close */
- #define CDC_OPEN_TRAY 0x2 /* but _can_ eject. */
- @@ -342,6 +367,12 @@
- #define CDC_RESET 0x200 /* hard reset device */
- #define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */
- #define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */
- +#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */
- +#define CDC_CD_R 0x2000 /* drive is a CD-R */
- +#define CDC_CD_RW 0x4000 /* drive is a CD-RW */
- +#define CDC_DVD 0x8000 /* drive is a DVD */
- +#define CDC_DVD_R 0x10000 /* drive can write DVD-R */
- +#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */
-
- /* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
- #define CDS_NO_INFO 0 /* if not implemented */
- @@ -370,7 +401,269 @@
- #define CDSL_NONE ((int) (~0U>>1)-1)
- #define CDSL_CURRENT ((int) (~0U>>1))
-
- +/* For partition based multisession access. IDE can handle 64 partitions
- + * per drive - SCSI CD-ROM's use minors to differentiate between the
- + * various drives, so we can't do multisessions the same way there.
- + * Use the -o session=x option to mount on them.
- + */
- +#define CD_PART_MAX 64
- +#define CD_PART_MASK (CD_PART_MAX - 1)
- +
- +/*********************************************************************
- + * Generic Packet commands, MMC commands, and such
- + *********************************************************************/
- +
- + /* The generic packet command opcodes for CD/DVD Logical Units,
- + * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
- +#define GPCMD_BLANK 0xa1
- +#define GPCMD_CLOSE_TRACK 0x5b
- +#define GPCMD_FLUSH_CACHE 0x35
- +#define GPCMD_FORMAT_UNIT 0x04
- +#define GPCMD_GET_CONFIGURATION 0x46
- +#define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a
- +#define GPCMD_GET_PERFORMANCE 0xac
- +#define GPCMD_INQUIRY 0x12
- +#define GPCMD_LOAD_UNLOAD 0xa6
- +#define GPCMD_MECHANISM_STATUS 0xbd
- +#define GPCMD_MODE_SELECT_10 0x55
- +#define GPCMD_MODE_SENSE_10 0x5a
- +#define GPCMD_PAUSE_RESUME 0x4b
- +#define GPCMD_PLAY_AUDIO_10 0x45
- +#define GPCMD_PLAY_AUDIO_MSF 0x47
- +#define GPCMD_PLAY_CD 0xbc
- +#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
- +#define GPCMD_READ_10 0x28
- +#define GPCMD_READ_12 0xa8
- +#define GPCMD_READ_CDVD_CAPACITY 0x25
- +#define GPCMD_READ_CD 0xbe
- +#define GPCMD_READ_CD_MSF 0xb9
- +#define GPCMD_READ_DISC_INFO 0x51
- +#define GPCMD_READ_DVD_STRUCTURE 0xad
- +#define GPCMD_READ_FORMAT_CAPACITIES 0x23
- +#define GPCMD_READ_HEADER 0x44
- +#define GPCMD_READ_TRACK_RZONE_INFO 0x52
- +#define GPCMD_READ_SUBCHANNEL 0x42
- +#define GPCMD_READ_TOC_PMA_ATIP 0x43
- +#define GPCMD_REPAIR_RZONE_TRACK 0x58
- +#define GPCMD_REPORT_KEY 0xa4
- +#define GPCMD_REQUEST_SENSE 0x03
- +#define GPCMD_RESERVE_RZONE_TRACK 0x53
- +#define GPCMD_SCAN 0xba
- +#define GPCMD_SEEK 0x2b
- +#define GPCMD_SEND_DVD_STRUCTURE 0xad
- +#define GPCMD_SEND_EVENT 0xa2
- +#define GPCMD_SEND_KEY 0xa3
- +#define GPCMD_SEND_OPC 0x54
- +#define GPCMD_SET_READ_AHEAD 0xa7
- +#define GPCMD_SET_STREAMING 0xb6
- +#define GPCMD_START_STOP_UNIT 0x1b
- +#define GPCMD_STOP_PLAY_SCAN 0x4e
- +#define GPCMD_TEST_UNIT_READY 0x00
- +#define GPCMD_VERIFY_10 0x2f
- +#define GPCMD_WRITE_10 0x2a
- +#define GPCMD_WRITE_AND_VERIFY_10 0x2e
- +/* This is listed as optional in ATAPI 2.6, but is (curiously)
- + * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
- + * Table 377 as an MMC command for SCSi devices though... Most ATAPI
- + * drives support it. */
- +#define GPCMD_SET_SPEED 0xbb
- +/* This seems to be a SCSI specific CD-ROM opcode
- + * to play data at track/index */
- +#define GPCMD_PLAYAUDIO_TI 0x48
- +
- +/* Is this really used by anything? I couldn't find these...*/
- +#if 0
- +/* MMC2/MTFuji Opcodes */
- +#define ERASE 0x2c
- +#define READ_BUFFER 0x3c
- +#endif
- +
- +
- +
- +
- +/* Mode page codes for mode sense/set */
- +#define GPMODE_R_W_ERROR_PAGE 0x01
- +#define GPMODE_WRITE_PARMS_PAGE 0x05
- +#define GPMODE_AUDIO_CTL_PAGE 0x0e
- +#define GPMODE_POWER_PAGE 0x1a
- +#define GPMODE_FAULT_FAIL_PAGE 0x1c
- +#define GPMODE_TO_PROTECT_PAGE 0x1d
- +#define GPMODE_CAPABILITIES_PAGE 0x2a
- +#define GPMODE_ALL_PAGES 0x3f
- +/* Not in Mt. Fuji, but in ATAPI 2.6 -- depricated now in favor
- + * of MODE_SENSE_POWER_PAGE */
- +#define GPMODE_CDROM_PAGE 0x0d
- +
- +
- +
- +/* DVD struct types */
- +#define DVD_STRUCT_PHYSICAL 0x00
- +#define DVD_STRUCT_COPYRIGHT 0x01
- +#define DVD_STRUCT_DISCKEY 0x02
- +#define DVD_STRUCT_BCA 0x03
- +#define DVD_STRUCT_MANUFACT 0x04
- +
- +struct dvd_layer {
- + __u8 book_version : 4;
- + __u8 book_type : 4;
- + __u8 min_rate : 4;
- + __u8 disc_size : 4;
- + __u8 layer_type : 4;
- + __u8 track_path : 1;
- + __u8 nlayers : 2;
- + __u8 track_density : 4;
- + __u8 linear_density : 4;
- + __u8 bca : 1;
- + __u32 start_sector;
- + __u32 end_sector;
- + __u32 end_sector_l0;
- +};
- +
- +struct dvd_physical {
- + __u8 type;
- + __u8 layer_num;
- + struct dvd_layer layer[4];
- +};
- +
- +struct dvd_copyright {
- + __u8 type;
- +
- + __u8 layer_num;
- + __u8 cpst;
- + __u8 rmi;
- +};
- +
- +struct dvd_disckey {
- + __u8 type;
- +
- + unsigned agid : 2;
- + __u8 value[2048];
- +};
- +
- +struct dvd_bca {
- + __u8 type;
- +
- + int len;
- + __u8 value[188];
- +};
- +
- +struct dvd_manufact {
- + __u8 type;
- +
- + __u8 layer_num;
- + int len;
- + __u8 value[2048];
- +};
- +
- +typedef union {
- + __u8 type;
- +
- + struct dvd_physical physical;
- + struct dvd_copyright copyright;
- + struct dvd_disckey disckey;
- + struct dvd_bca bca;
- + struct dvd_manufact manufact;
- +} dvd_struct;
- +
- +/*
- + * DVD authentication ioctl
- + */
- +
- +/* Authentication states */
- +#define DVD_LU_SEND_AGID 0
- +#define DVD_HOST_SEND_CHALLENGE 1
- +#define DVD_LU_SEND_KEY1 2
- +#define DVD_LU_SEND_CHALLENGE 3
- +#define DVD_HOST_SEND_KEY2 4
- +
- +/* Termination states */
- +#define DVD_AUTH_ESTABLISHED 5
- +#define DVD_AUTH_FAILURE 6
- +
- +/* Other functions */
- +#define DVD_LU_SEND_TITLE_KEY 7
- +#define DVD_LU_SEND_ASF 8
- +#define DVD_INVALIDATE_AGID 9
- +
- +/* State data */
- +typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */
- +typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
- +
- +struct dvd_lu_send_agid {
- + __u8 type;
- + unsigned agid : 2;
- +};
- +
- +struct dvd_host_send_challenge {
- + __u8 type;
- + unsigned agid : 2;
- +
- + dvd_challenge chal;
- +};
- +
- +struct dvd_send_key {
- + __u8 type;
- + unsigned agid : 2;
- +
- + dvd_key key;
- +};
- +
- +struct dvd_lu_send_challenge {
- + __u8 type;
- + unsigned agid : 2;
- +
- + dvd_challenge chal;
- +};
- +
- +#define DVD_CPM_NO_COPYRIGHT 0
- +#define DVD_CPM_COPYRIGHTED 1
- +
- +#define DVD_CP_SEC_NONE 0
- +#define DVD_CP_SEC_EXIST 1
- +
- +#define DVD_CGMS_UNRESTRICTED 0
- +#define DVD_CGMS_SINGLE 2
- +#define DVD_CGMS_RESTRICTED 3
- +
- +struct dvd_lu_send_title_key {
- + __u8 type;
- + unsigned agid : 2;
- +
- + dvd_key title_key;
- + int lba;
- + unsigned cpm : 1;
- + unsigned cp_sec : 1;
- + unsigned cgms : 2;
- +};
- +
- +struct dvd_lu_send_asf {
- + __u8 type;
- + unsigned agid : 2;
- +
- + unsigned asf : 1;
- +};
- +
- +typedef union {
- + __u8 type;
- +
- + struct dvd_lu_send_agid lsa;
- + struct dvd_host_send_challenge hsc;
- + struct dvd_send_key lsk;
- + struct dvd_lu_send_challenge lsc;
- + struct dvd_send_key hsk;
- + struct dvd_lu_send_title_key lstk;
- + struct dvd_lu_send_asf lsasf;
- +} dvd_authinfo;
- +
- #ifdef __KERNEL__
- +
- +struct cdrom_write_settings {
- + unsigned char fpacket; /* fixed/variable packets */
- + unsigned long packet_size; /* write out this number of packets */
- + unsigned long nwa; /* next writeable address */
- + unsigned char writeable; /* cdrom is writeable */
- +};
- +
- /* Uniform cdrom data structures for cdrom.c */
- struct cdrom_device_info {
- struct cdrom_device_ops *ops; /* link to device_ops */
- @@ -382,11 +675,14 @@
- int speed; /* maximum speed for reading data */
- int capacity; /* number of discs in jukebox */
- /* device-related storage */
- - int options : 30; /* options flags */
- - unsigned mc_flags : 2; /* media change buffer flags */
- + int options : 30; /* options flags */
- + unsigned mc_flags : 2; /* media change buffer flags */
- int use_count; /* number of times device opened */
- char name[20]; /* name of the device type */
- -
- +/* per-device flags */
- + __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */
- + __u8 reserved : 6; /* not used yet */
- + struct cdrom_write_settings write;
- };
-
- struct cdrom_device_ops {
- @@ -413,6 +709,9 @@
- /* driver specifications */
- const int capability; /* capability flags */
- int n_minors; /* number of active minor devices */
- + /* handle uniform packets for scsi type devices (scsi,atapi) */
- + int (*generic_packet) (struct cdrom_device_info *,
- + struct cdrom_generic_command *);
- };
-
- /* the general file operations structure: */
- @@ -420,6 +719,7 @@
-
- extern int register_cdrom(struct cdrom_device_info *cdi);
- extern int unregister_cdrom(struct cdrom_device_info *cdi);
- +
- typedef struct {
- int data;
- int audio;
- @@ -427,7 +727,217 @@
- int xa;
- long error;
- } tracktype;
- +
- extern void cdrom_count_tracks(struct cdrom_device_info *cdi,tracktype* tracks);
- +extern int cdrom_get_next_writable(kdev_t dev, long *next_writable);
- +extern int cdrom_get_last_written(kdev_t dev, long *last_written);
- +extern int cdrom_number_of_slots(struct cdrom_device_info *cdi);
- +extern int cdrom_select_disc(struct cdrom_device_info *cdi, int slot);
- +extern int cdrom_mode_select(struct cdrom_device_info *cdi,
- + struct cdrom_generic_command *cgc);
- +extern int cdrom_mode_sense(struct cdrom_device_info *cdi,
- + struct cdrom_generic_command *cgc,
- + int page_code, int page_control);
- +extern void init_cdrom_command(struct cdrom_generic_command *cgc,
- + void *buffer, int len);
- +
- +typedef struct {
- + __u16 disc_information_length;
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 reserved1 : 3;
- + __u8 erasable : 1;
- + __u8 border_status : 2;
- + __u8 disc_border : 2;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 disc_border : 2;
- + __u8 border_status : 2;
- + __u8 erasable : 1;
- + __u8 reserved1 : 3;
- +#else
- +#error "Please fix <asm/byteorder.h>"
- +#endif
- + __u8 n_first_track;
- + __u8 n_sessions_lsb;
- + __u8 first_track_lsb;
- + __u8 last_track_lsb;
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 did_v : 1;
- + __u8 dbc_v : 1;
- + __u8 uru : 1;
- + __u8 reserved2 : 5;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 reserved2 : 5;
- + __u8 uru : 1;
- + __u8 dbc_v : 1;
- + __u8 did_v : 1;
- +#endif
- + __u8 disc_type;
- + __u8 n_sessions_msb;
- + __u8 first_track_msb;
- + __u8 last_track_msb;
- + __u32 disc_id;
- + __u32 lead_in;
- + __u32 lead_out;
- + __u8 disc_bar_code[8];
- + __u8 reserved3;
- + __u8 n_opc;
- +} disc_information;
- +
- +typedef struct {
- + __u16 track_information_length;
- + __u8 track_lsb;
- + __u8 session_lsb;
- + __u8 reserved1;
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 reserved2 : 2;
- + __u8 damage : 1;
- + __u8 copy : 1;
- + __u8 track_mode : 4;
- + __u8 rt : 1;
- + __u8 blank : 1;
- + __u8 packet : 1;
- + __u8 fp : 1;
- + __u8 data_mode : 4;
- + __u8 reserved3 : 6;
- + __u8 lra_v : 1;
- + __u8 nwa_v : 1;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 track_mode : 4;
- + __u8 copy : 1;
- + __u8 damage : 1;
- + __u8 reserved2 : 2;
- + __u8 data_mode : 4;
- + __u8 fp : 1;
- + __u8 packet : 1;
- + __u8 blank : 1;
- + __u8 rt : 1;
- + __u8 nwa_v : 1;
- + __u8 lra_v : 1;
- + __u8 reserved3 : 6;
- +#endif
- + __u32 track_start;
- + __u32 next_writable;
- + __u32 free_blocks;
- + __u32 fixed_packet_size;
- + __u32 track_size;
- + __u32 last_rec_address;
- +} track_information;
- +
- +/* The SCSI spec says there could be 256 slots. */
- +#define CDROM_MAX_SLOTS 256
- +
- +struct cdrom_mechstat_header {
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 fault : 1;
- + __u8 changer_state : 2;
- + __u8 curslot : 5;
- + __u8 mech_state : 3;
- + __u8 door_open : 1;
- + __u8 reserved1 : 4;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 curslot : 5;
- + __u8 changer_state : 2;
- + __u8 fault : 1;
- + __u8 reserved1 : 4;
- + __u8 door_open : 1;
- + __u8 mech_state : 3;
- +#endif
- + __u8 curlba[3];
- + __u8 nslots;
- + __u8 short slot_tablelen;
- +};
- +
- +struct cdrom_slot {
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 disc_present : 1;
- + __u8 reserved1 : 6;
- + __u8 change : 1;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 change : 1;
- + __u8 reserved1 : 6;
- + __u8 disc_present : 1;
- +#endif
- + __u8 reserved2[3];
- +};
- +
- +struct cdrom_changer_info {
- + struct cdrom_mechstat_header hdr;
- + struct cdrom_slot slots[CDROM_MAX_SLOTS];
- +};
- +
- +typedef enum {
- + mechtype_caddy = 0,
- + mechtype_tray = 1,
- + mechtype_popup = 2,
- + mechtype_individual_changer = 4,
- + mechtype_cartridge_changer = 5
- +} mechtype_t;
- +
- +struct mode_page_header {
- + __u16 mode_data_length;
- + __u8 medium_type;
- + __u8 reserved1;
- + __u8 reserved2;
- + __u8 reserved3;
- + __u16 desc_length;
- +};
- +
- +typedef struct {
- + struct mode_page_header header;
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 ps : 1;
- + __u8 reserved1 : 1;
- + __u8 page_code : 6;
- + __u8 page_length;
- + __u8 reserved2 : 1;
- + __u8 bufe : 1;
- + __u8 ls_v : 1;
- + __u8 test_write : 1;
- + __u8 write_type : 4;
- + __u8 multi_session : 2; /* or border, DVD */
- + __u8 fp : 1;
- + __u8 copy : 1;
- + __u8 track_mode : 4;
- + __u8 reserved3 : 4;
- + __u8 data_block_type : 4;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 page_code : 6;
- + __u8 reserved1 : 1;
- + __u8 ps : 1;
- + __u8 page_length;
- + __u8 write_type : 4;
- + __u8 test_write : 1;
- + __u8 ls_v : 1;
- + __u8 bufe : 1;
- + __u8 reserved2 : 1;
- + __u8 track_mode : 4;
- + __u8 copy : 1;
- + __u8 fp : 1;
- + __u8 multi_session : 2; /* or border, DVD */
- + __u8 data_block_type : 4;
- + __u8 reserved3 : 4;
- +#endif
- + __u8 link_size;
- + __u8 reserved4;
- +#if defined(__BIG_ENDIAN_BITFIELD)
- + __u8 reserved5 : 2;
- + __u8 app_code : 6;
- +#elif defined(__LITTLE_ENDIAN_BITFIELD)
- + __u8 app_code : 6;
- + __u8 reserved5 : 2;
- +#endif
- + __u8 session_format;
- + __u8 reserved6;
- + __u32 packet_size;
- + __u16 audio_pause;
- + __u8 mcn[16];
- + __u8 isrc[16];
- + __u8 subhdr0;
- + __u8 subhdr1;
- + __u8 subhdr2;
- + __u8 subhdr3;
- +} write_param_page __attribute__((packed));
- +
- #endif /* End of kernel only stuff */
-
- #endif /* _LINUX_CDROM_H */
- diff -ur --exclude-from /home/axboe/cdrom/exclude-from linux-2.2.13/include/linux/sysctl.h linux/include/linux/sysctl.h
- --- linux-2.2.13/include/linux/sysctl.h Fri Nov 5 15:15:40 1999
- +++ linux/include/linux/sysctl.h Sun Oct 31 13:23:55 1999
- @@ -432,7 +432,12 @@
-
- /* /proc/sys/dev/cdrom */
- enum {
- - DEV_CDROM_INFO=1
- + DEV_CDROM_INFO=1,
- + DEV_CDROM_AUTOCLOSE=2,
- + DEV_CDROM_AUTOEJECT=3,
- + DEV_CDROM_DEBUG=4,
- + DEV_CDROM_LOCK=5,
- + DEV_CDROM_CHECK_MEDIA=6
- };
-
- #ifdef __KERNEL__