--- Gnu-Mach/linux/src/drivers/block/ide-cd.c 2020/09/02 04:41:40 1.1 +++ Gnu-Mach/linux/src/drivers/block/ide-cd.c 2020/09/02 04:49:03 1.1.1.3 @@ -153,6 +153,10 @@ /***************************************************************************/ +#ifdef MACH +#include +#endif + #include #include #include @@ -626,7 +630,7 @@ static void cdrom_queue_request_sense (i pc->c[0] = REQUEST_SENSE; pc->c[4] = len; - pc->buffer = (char *)reqbuf; + pc->buffer = (unsigned char *)reqbuf; pc->buflen = len; pc->sense_data = (struct atapi_request_sense *)failed_command; @@ -645,7 +649,7 @@ static void cdrom_end_request (int uptod { struct request *rq = HWGROUP(drive)->rq; - if (rq->cmd == REQUEST_SENSE_COMMAND && uptodate) { + if (rq->cmd == REQUEST_SENSE_COMMAND && uptodate && !rq->quiet) { struct packet_command *pc = (struct packet_command *) rq->buffer; cdrom_analyze_sense_data (drive, @@ -723,16 +727,18 @@ static int cdrom_decode_status (ide_driv because workman constantly polls the drive with this command, and we don't want to uselessly fill up the syslog. */ - if (pc->c[0] != SCMD_READ_SUBCHANNEL) + if (pc->c[0] != SCMD_READ_SUBCHANNEL && !rq->quiet) printk ("%s : tray open or drive not ready\n", drive->name); } else if (sense_key == UNIT_ATTENTION) { /* Check for media change. */ cdrom_saw_media_change (drive); - printk ("%s: media changed\n", drive->name); + if (!rq->quiet) + printk ("%s: media changed\n", drive->name); } else { /* Otherwise, print an error. */ - ide_dump_status (drive, "packet command error", + if (!rq->quiet) + ide_dump_status (drive, "packet command error", stat); } @@ -764,7 +770,8 @@ static int cdrom_decode_status (ide_driv cdrom_saw_media_change (drive); /* Fail the request. */ - printk ("%s : tray open\n", drive->name); + if (!rq->quiet) + printk ("%s : tray open\n", drive->name); cdrom_end_request (0, drive); } else if (sense_key == UNIT_ATTENTION) { /* Media change. */ @@ -779,7 +786,8 @@ static int cdrom_decode_status (ide_driv sense_key == DATA_PROTECT) { /* No point in retrying after an illegal request or data protect error.*/ - ide_dump_status (drive, "command error", stat); + if (!rq->quiet) + ide_dump_status (drive, "command error", stat); cdrom_end_request (0, drive); } else if ((err & ~ABRT_ERR) != 0) { /* Go to the default handler @@ -844,7 +852,7 @@ static int cdrom_start_packet_command (i HANDLER is the interrupt handler to call when the command completes or there's data ready. */ static int cdrom_transfer_packet_command (ide_drive_t *drive, - char *cmd_buf, int cmd_len, + unsigned char *cmd_buf, int cmd_len, ide_handler_t *handler) { if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) { @@ -1379,9 +1387,19 @@ static void cdrom_do_packet_command (ide cdrom_start_packet_command (drive, len, cdrom_do_pc_continuation); } - /* Sleep for TIME jiffies. Not to be called from an interrupt handler. */ +#ifdef MACH +static +void cdrom_sleep (int time) +{ + int xxx; + + assert_wait ((event_t) &xxx, TRUE); + thread_set_timeout (time); + schedule (); +} +#else static void cdrom_sleep (int time) { @@ -1389,9 +1407,10 @@ void cdrom_sleep (int time) current->timeout = jiffies + time; schedule (); } +#endif static -int cdrom_queue_packet_command (ide_drive_t *drive, struct packet_command *pc) +int cdrom_queue_packet_command (ide_drive_t *drive, struct packet_command *pc, int quiet) { struct atapi_request_sense my_reqbuf; int retries = 10; @@ -1408,6 +1427,7 @@ int cdrom_queue_packet_command (ide_driv ide_init_drive_cmd (&req); req.cmd = PACKET_COMMAND; req.buffer = (char *)pc; + req.quiet = quiet; (void) ide_do_drive_cmd (drive, &req, ide_wait); if (pc->stat != 0) { @@ -1548,7 +1568,7 @@ cdrom_check_status (ide_drive_t *drive, pc.c[7] = CDROM_STATE_FLAGS (drive)->sanyo_slot % 3; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 1); } @@ -1573,7 +1593,7 @@ cdrom_lockdoor (ide_drive_t *drive, int pc.c[0] = ALLOW_MEDIUM_REMOVAL; pc.c[4] = (lockflag != 0); - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 0); } if (stat == 0) @@ -1607,7 +1627,7 @@ cdrom_eject (ide_drive_t *drive, int eje pc.c[0] = START_STOP; pc.c[4] = 2 + (ejectflag != 0); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1622,7 +1642,7 @@ cdrom_pause (ide_drive_t *drive, int pau pc.c[0] = SCMD_PAUSE_RESUME; pc.c[8] = !pauseflag; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1638,7 +1658,7 @@ cdrom_startstop (ide_drive_t *drive, int pc.c[0] = START_STOP; pc.c[1] = 1; pc.c[4] = startflag; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1658,10 +1678,10 @@ cdrom_read_capacity (ide_drive_t *drive, pc.sense_data = reqbuf; pc.c[0] = READ_CAPACITY; - pc.buffer = (char *)&capbuf; + pc.buffer = (unsigned char *)&capbuf; pc.buflen = sizeof (capbuf); - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 1); if (stat == 0) *capacity = ntohl (capbuf.lba); @@ -1679,7 +1699,7 @@ cdrom_read_tocentry (ide_drive_t *drive, memset (&pc, 0, sizeof (pc)); pc.sense_data = reqbuf; - pc.buffer = buf; + pc.buffer = (unsigned char *)buf; pc.buflen = buflen; pc.c[0] = SCMD_READ_TOC; pc.c[6] = trackno; @@ -1687,7 +1707,7 @@ cdrom_read_tocentry (ide_drive_t *drive, pc.c[8] = (buflen & 0xff); pc.c[9] = (format << 6); if (msf_flag) pc.c[1] = 2; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 1); } @@ -1811,7 +1831,7 @@ cdrom_read_subchannel (ide_drive_t *driv memset (&pc, 0, sizeof (pc)); pc.sense_data = reqbuf; - pc.buffer = buf; + pc.buffer = (unsigned char *) buf; pc.buflen = buflen; pc.c[0] = SCMD_READ_SUBCHANNEL; pc.c[1] = 2; /* MSF addressing */ @@ -1819,7 +1839,7 @@ cdrom_read_subchannel (ide_drive_t *driv pc.c[3] = format, pc.c[7] = (buflen >> 8); pc.c[8] = (buflen & 0xff); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1834,13 +1854,13 @@ cdrom_mode_sense (ide_drive_t *drive, in memset (&pc, 0, sizeof (pc)); pc.sense_data = reqbuf; - pc.buffer = buf; + pc.buffer = (unsigned char *)buf; pc.buflen = buflen; pc.c[0] = MODE_SENSE_10; pc.c[2] = pageno | (modeflag << 6); pc.c[7] = (buflen >> 8); pc.c[8] = (buflen & 0xff); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1853,14 +1873,14 @@ cdrom_mode_select (ide_drive_t *drive, i memset (&pc, 0, sizeof (pc)); pc.sense_data = reqbuf; - pc.buffer = buf; + pc.buffer = (unsigned char *)buf; pc.buflen = - buflen; pc.c[0] = MODE_SELECT_10; pc.c[1] = 0x10; pc.c[2] = pageno; pc.c[7] = (buflen >> 8); pc.c[8] = (buflen & 0xff); - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1888,7 +1908,7 @@ cdrom_play_lba_range_1 (ide_drive_t *dri } #endif /* not STANDARD_ATAPI */ - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } @@ -1969,7 +1989,7 @@ cdrom_read_block (ide_drive_t *drive, in memset (&pc, 0, sizeof (pc)); pc.sense_data = reqbuf; - pc.buffer = buf; + pc.buffer = (unsigned char *)buf; pc.buflen = buflen; #if ! STANDARD_ATAPI @@ -1989,7 +2009,7 @@ cdrom_read_block (ide_drive_t *drive, in else pc.c[9] = 0x10; - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 0); #if ! STANDARD_ATAPI /* If the drive doesn't recognize the READ CD opcode, retry the command @@ -2044,7 +2064,7 @@ cdrom_load_unload (ide_drive_t *drive, i pc.c[0] = LOAD_UNLOAD; pc.c[4] = 2 + (slot >= 0); pc.c[8] = slot; - return cdrom_queue_packet_command (drive, &pc); + return cdrom_queue_packet_command (drive, &pc, 0); } } @@ -2560,7 +2580,7 @@ int ide_cdrom_ioctl (ide_drive_t *drive, pc.buffer = buf; } - stat = cdrom_queue_packet_command (drive, &pc); + stat = cdrom_queue_packet_command (drive, &pc, 0); if (len > 0) memcpy_tofs ((void *)arg, buf, len); @@ -2623,6 +2643,10 @@ int ide_cdrom_open (struct inode *ip, st if (stat == 0 || my_reqbuf.sense_key == UNIT_ATTENTION) { (void) cdrom_lockdoor (drive, 1, &my_reqbuf); (void) cdrom_read_toc (drive, &my_reqbuf); + } else { + /* Otherwise return as missing */ + --drive->usage; + return -ENXIO; } } @@ -2696,9 +2720,12 @@ void ide_cdrom_setup (ide_drive_t *drive CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 0; if (drive->id != NULL) { - if (strcmp (drive->id->model, "V003S0DS") == 0 && - drive->id->fw_rev[4] == '1' && - drive->id->fw_rev[6] <= '2') { + const char *model = (const char *)drive->id->model; + const char *fw_rev = (const char *)drive->id->fw_rev; + + if (strcmp (model, "V003S0DS") == 0 && + fw_rev[4] == '1' && + fw_rev[6] <= '2') { /* Vertos 300. Some versions of this drive like to talk BCD. */ CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 1; @@ -2707,27 +2734,27 @@ void ide_cdrom_setup (ide_drive_t *drive CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1; } - else if (strcmp (drive->id->model, "V006E0DS") == 0 && - drive->id->fw_rev[4] == '1' && - drive->id->fw_rev[6] <= '2') { + else if (strcmp (model, "V006E0DS") == 0 && + fw_rev[4] == '1' && + fw_rev[6] <= '2') { /* Vertos 600 ESD. */ CDROM_CONFIG_FLAGS (drive)->toctracks_as_bcd = 1; } - else if (strcmp (drive->id->model, "GCD-R580B") == 0) + else if (strcmp (model, "GCD-R580B") == 0) drive->cdrom_info.max_sectors = 124; - else if (strcmp (drive->id->model, + else if (strcmp (model, "NEC CD-ROM DRIVE:260") == 0 && - strcmp (drive->id->fw_rev, "1.01") == 0) { + strcmp (fw_rev, "1.01") == 0) { /* Old NEC260 (not R). */ CDROM_CONFIG_FLAGS (drive)->tocaddr_as_bcd = 1; CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1; CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1; } - else if (strcmp (drive->id->model, "WEARNES CDD-120") == 0 && - strcmp (drive->id->fw_rev, "A1.1") == 0) { + else if (strcmp (model, "WEARNES CDD-120") == 0 && + strcmp (fw_rev, "A1.1") == 0) { /* Wearnes */ CDROM_CONFIG_FLAGS (drive)->playmsf_as_bcd = 1; CDROM_CONFIG_FLAGS (drive)->subchan_as_bcd = 1; @@ -2735,9 +2762,9 @@ void ide_cdrom_setup (ide_drive_t *drive /* Sanyo 3 CD changer uses a non-standard command for CD changing */ - else if ((strcmp(drive->id->model, "CD-ROM CDR-C3 G") == 0) || - (strcmp(drive->id->model, "CD-ROM CDR-C3G") == 0) || - (strcmp(drive->id->model, "CD-ROM CDR_C36") == 0)) { + else if ((strcmp(model, "CD-ROM CDR-C3 G") == 0) || + (strcmp(model, "CD-ROM CDR-C3G") == 0) || + (strcmp(model, "CD-ROM CDR_C36") == 0)) { /* uses CD in slot 0 when value is set to 3 */ CDROM_STATE_FLAGS (drive)->sanyo_slot = 3; }