diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index a4c5b31f7..592122a6e 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.29 2018/01/24 + * Version: @(#)cdrom.c 1.0.30 2018/01/25 * * Author: Miran Grca, * @@ -2265,6 +2265,7 @@ cdrom_readtoc_fallback: len = alloc_length; } + len = MIN(len, max_len); cdrom_set_buf_len(id, BufLen, &len); cdrom_data_command_finish(id, len, len, len, 0); @@ -2652,44 +2653,6 @@ void cdrom_pio_request(uint8_t id, uint8_t out) } } -/* 0 = Continue transfer; 1 = Continue transfer, IRQ; -1 = Terminate transfer; -2 = Terminate transfer with error */ -int cdrom_mode_select_return(uint8_t id, int ret) -{ - switch(ret) { - case 0: - /* Invalid field in parameter list. */ - case -6: - /* Attempted to write to a non-existent CD-ROM drive (should never occur, but you never know). */ - cdrom_invalid_field_pl(id); - cdrom_buf_free(id); - return -2; - case 1: - /* Successful, more data needed. */ - if (cdrom[id].pos >= (cdrom[id].packet_len + 2)) { - cdrom[id].pos = 0; - cdrom_command_write(id); - return 1; - } - return 0; - case 2: - /* Successful, more data needed, second byte not yet processed. */ - return 0; - case -3: - /* Not initialized. */ - case -4: - /* Unknown phase. */ - cdrom_illegal_opcode(id); - cdrom_buf_free(id); - return -2; - case -5: - /* Command terminated successfully. */ - cdrom_buf_free(id); - return -1; - default: - return -15; - } -} - void cdrom_phase_callback(uint8_t id); int cdrom_read_from_ide_dma(uint8_t channel) diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index f0cfcd3a9..0e346c255 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -6,7 +6,7 @@ * * Emulation of SCSI fixed and removable disks. * - * Version: @(#)scsi_disk.c 1.0.15 2018/01/24 + * Version: @(#)scsi_disk.c 1.0.16 2018/01/25 * * Author: Miran Grca, * @@ -485,12 +485,6 @@ static void scsi_hd_command_read_dma(uint8_t id) } -static void scsi_hd_command_write(uint8_t id) -{ - shdc[id].packet_status = CDROM_PHASE_DATA_OUT; - scsi_hd_command_common(id); -} - static void scsi_hd_command_write_dma(uint8_t id) { shdc[id].packet_status = CDROM_PHASE_DATA_OUT_DMA; @@ -1454,44 +1448,6 @@ atapi_out: } -/* 0 = Continue transfer; 1 = Continue transfer, IRQ; -1 = Terminate transfer; -2 = Terminate transfer with error */ -int scsi_hd_mode_select_return(uint8_t id, int ret) -{ - switch(ret) - { - case 0: - /* Invalid field in parameter list. */ - case -6: - /* Attempted to write to a non-existent SCSI HDD drive (should never occur, but you never know). */ - scsi_hd_invalid_field_pl(id); - return -2; - case 1: - /* Successful, more data needed. */ - if (shdc[id].pos >= (shdc[id].packet_len + 2)) - { - shdc[id].pos = 0; - scsi_hd_command_write(id); - return 1; - } - return 0; - case 2: - /* Successful, more data needed, second byte not yet processed. */ - return 0; - case -3: - /* Not initialized. */ - case -4: - /* Unknown phase. */ - scsi_hd_illegal_opcode(id); - return -2; - case -5: - /* Command terminated successfully. */ - /* scsi_hd_command_complete(id); */ - return -1; - default: - return -15; - } -} - void scsi_hd_phase_data_in(uint8_t id) { uint8_t *hdbufferb = SCSIDevices[hdd[id].scsi_id][hdd[id].scsi_lun].CmdBuffer;