Ported over the CD-ROM, Iomega ZIP, and RTC fixes from PCem and disabled Iomega ZIP logging.

This commit is contained in:
OBattler
2018-02-27 23:55:28 +01:00
parent 8b3d51d3b7
commit ffc7ee4ccd
6 changed files with 51 additions and 55 deletions

View File

@@ -9,7 +9,7 @@
* Implementation of the Iomega ZIP drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage.
*
* Version: @(#)zip.c 1.0.5 2018/02/15
* Version: @(#)zip.c 1.0.6 2018/02/27
*
* Author: Miran Grca, <mgrca8@gmail.com>
*
@@ -455,7 +455,6 @@ static const mode_sense_pages_t zip_250_mode_sense_pages_changeable =
static mode_sense_pages_t zip_mode_sense_pages_saved[ZIP_NUM];
#define ENABLE_ZIP_LOG 1
#ifdef ENABLE_ZIP_LOG
int zip_do_log = ENABLE_ZIP_LOG;
#endif
@@ -903,14 +902,18 @@ uint32_t zip_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type, ui
void zip_update_request_length(uint8_t id, int len, int block_len)
{
uint32_t bt;
if (!zip[id].request_length)
zip[id].max_transfer_len = 65534;
else
zip[id].max_transfer_len = zip[id].request_length;
/* For media access commands, make sure the requested DRQ length matches the block length. */
switch (zip[id].current_cdb[0]) {
case 0x08:
case 0x28:
case 0xa8:
if (zip[id].request_length < block_len)
zip[id].request_length = block_len;
if (zip[id].max_transfer_len < block_len)
zip[id].max_transfer_len = block_len;
bt = (zip[id].requested_blocks * block_len);
if (len > bt)
len = bt;
@@ -919,11 +922,11 @@ void zip_update_request_length(uint8_t id, int len, int block_len)
break;
}
/* If the DRQ length is odd, and the total remaining length is bigger, make sure it's even. */
if ((zip[id].request_length & 1) && (zip[id].request_length < len))
zip[id].request_length &= 0xfffe;
if ((zip[id].max_transfer_len & 1) && (zip[id].max_transfer_len < len))
zip[id].max_transfer_len &= 0xfffe;
/* If the DRQ length is smaller or equal in size to the total remaining length, set it to that. */
if (len <= zip[id].request_length)
zip[id].request_length = len;
if (len <= zip[id].max_transfer_len)
zip[id].max_transfer_len = len;
return;
}
@@ -982,13 +985,6 @@ static void zip_command_write_dma(uint8_t id)
zip_command_common(id);
}
static int zip_request_length_is_zero(uint8_t id)
{
if ((zip[id].request_length == 0) && (zip_drives[id].bus_type < ZIP_BUS_SCSI))
return 1;
return 0;
}
/* id = Current ZIP device ID;
len = Total transfer length;
block_len = Length of a single block (why does it matter?!);
@@ -1003,7 +999,7 @@ static void zip_data_command_finish(uint8_t id, int len, int block_len, int allo
len = alloc_len;
}
}
if (zip_request_length_is_zero(id) || (len == 0) || (zip_current_mode(id) == 0)) {
if ((len == 0) || (zip_current_mode(id) == 0)) {
if (zip_drives[id].bus_type != ZIP_BUS_SCSI) {
zip[id].packet_len = 0;
}
@@ -2194,8 +2190,8 @@ void zip_pio_request(uint8_t id, uint8_t out)
/* If less than (packet length) bytes are remaining, update packet length
accordingly. */
if ((zip[id].packet_len - zip[id].pos) < (zip[id].request_length))
zip[id].request_length = zip[id].packet_len - zip[id].pos;
if ((zip[id].packet_len - zip[id].pos) < (zip[id].max_transfer_len))
zip[id].max_transfer_len = zip[id].packet_len - zip[id].pos;
old_pos = zip[id].pos;
zip[id].packet_status = out ? ZIP_PHASE_DATA_OUT : ZIP_PHASE_DATA_IN;
@@ -2263,7 +2259,7 @@ int zip_read_from_dma(uint8_t id)
in_data_length = *BufLen;
zip_log("ZIP %i: SCSI Input data length: %i\n", id, in_data_length);
} else {
in_data_length = zip[id].request_length;
in_data_length = zip[id].max_transfer_len;
zip_log("ZIP %i: ATAPI Input data length: %i\n", id, in_data_length);
}
@@ -2453,7 +2449,7 @@ uint32_t zip_read(uint8_t channel, int length)
}
if (zip[id].packet_status == ZIP_PHASE_DATA_IN) {
if ((zip[id].request_pos >= zip[id].request_length) || (zip[id].pos >= zip[id].packet_len)) {
if ((zip[id].request_pos >= zip[id].max_transfer_len) || (zip[id].pos >= zip[id].packet_len)) {
/* Time for a DRQ. */
// zip_log("ZIP %i: Issuing read callback\n", id);
zip_pio_request(id, 0);
@@ -2509,7 +2505,7 @@ void zip_write(uint8_t channel, uint32_t val, int length)
}
if (zip[id].packet_status == ZIP_PHASE_DATA_OUT) {
if ((zip[id].request_pos >= zip[id].request_length) || (zip[id].pos >= zip[id].packet_len)) {
if ((zip[id].request_pos >= zip[id].max_transfer_len) || (zip[id].pos >= zip[id].packet_len)) {
/* Time for a DRQ. */
zip_pio_request(id, 1);
}