Fixed ATAPI transfer split by sectors and improved the performance of IOCTL by making it no longer constantly open and close the handle.
This commit is contained in:
@@ -2822,9 +2822,7 @@ cdrom_update_status(cdrom_t *dev)
|
||||
dev->seek_pos = 0;
|
||||
dev->cd_buflen = 0;
|
||||
|
||||
if ((dev->ops->is_empty != NULL) && dev->ops->is_empty(dev->local))
|
||||
dev->cd_status = CD_STATUS_EMPTY;
|
||||
else if (dev->ops->is_dvd(dev->local))
|
||||
if (dev->ops->is_dvd(dev->local))
|
||||
dev->cd_status = CD_STATUS_DVD;
|
||||
else
|
||||
dev->cd_status = dev->ops->has_audio(dev->local) ? CD_STATUS_STOPPED :
|
||||
@@ -3048,7 +3046,7 @@ cdrom_is_empty(const uint8_t id)
|
||||
int ret = 0;
|
||||
|
||||
/* This entire block should be in cdrom.c/cdrom_eject(dev*) ... */
|
||||
if (strlen(dev->image_path) == 0)
|
||||
if ((strlen(dev->image_path) == 0) || (dev->cd_status == CD_STATUS_EMPTY))
|
||||
/* Switch from empty to empty. Do nothing. */
|
||||
ret = 1;
|
||||
|
||||
|
||||
@@ -241,7 +241,6 @@ int ide_qua_enabled = 0;
|
||||
static void ide_atapi_callback(ide_t *ide);
|
||||
static void ide_callback(void *priv);
|
||||
|
||||
#define ENABLE_IDE_LOG 1
|
||||
#ifdef ENABLE_IDE_LOG
|
||||
int ide_do_log = ENABLE_IDE_LOG;
|
||||
|
||||
|
||||
@@ -124,12 +124,10 @@ ioctl_read_normal_toc(ioctl_t *ioctl, uint8_t *toc_buf)
|
||||
ioctl->cur_read_toc_ex.Msf = 1;
|
||||
ioctl->cur_read_toc_ex.SessionTrack = 1;
|
||||
|
||||
ioctl_open_handle(ioctl);
|
||||
const int temp = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX,
|
||||
&ioctl->cur_read_toc_ex, 65535,
|
||||
cur_full_toc, 65535,
|
||||
(LPDWORD) &size, NULL);
|
||||
ioctl_close_handle(ioctl);
|
||||
ioctl_log(ioctl->log, "temp = %i\n", temp);
|
||||
|
||||
if (temp != 0) {
|
||||
@@ -178,12 +176,10 @@ ioctl_read_raw_toc(ioctl_t *ioctl)
|
||||
ioctl->cur_read_toc_ex.Msf = 1;
|
||||
ioctl->cur_read_toc_ex.SessionTrack = 1;
|
||||
|
||||
ioctl_open_handle(ioctl);
|
||||
const int status = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX,
|
||||
&ioctl->cur_read_toc_ex, 65535,
|
||||
cur_full_toc, 65535,
|
||||
(LPDWORD) &size, NULL);
|
||||
ioctl_close_handle(ioctl);
|
||||
ioctl_log(ioctl->log, "status = %i\n", status);
|
||||
|
||||
if ((status == 0) && (ioctl->tracks_num >= 1)) {
|
||||
@@ -384,8 +380,6 @@ ioctl_read_sector(const void *local, uint8_t *buffer, uint32_t const sector)
|
||||
int ret;
|
||||
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
||||
|
||||
ioctl_open_handle((ioctl_t *) ioctl);
|
||||
|
||||
if (ioctl->is_dvd) {
|
||||
int track;
|
||||
|
||||
@@ -517,8 +511,6 @@ ioctl_read_sector(const void *local, uint8_t *buffer, uint32_t const sector)
|
||||
for (int j = 7; j >= 0; j--)
|
||||
buffer[2352 + (i * 8) + j] = ((buffer[sc_offs + i] >> (7 - j)) & 0x01) << 6;
|
||||
|
||||
ioctl_close_handle((ioctl_t *) ioctl);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -587,8 +579,6 @@ ioctl_read_dvd_structure(const void *local, const uint8_t layer, const uint8_t f
|
||||
const int len = 2052;
|
||||
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
||||
|
||||
ioctl_open_handle((ioctl_t *) ioctl);
|
||||
|
||||
memset(&req, 0x00, sizeof(SCSI_PASS_THROUGH_DIRECT_BUF));
|
||||
req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
||||
req.spt.PathId = 0;
|
||||
@@ -650,8 +640,6 @@ ioctl_read_dvd_structure(const void *local, const uint8_t layer, const uint8_t f
|
||||
} else
|
||||
ret = ret ? (req.spt.DataTransferLength >= len) : 0;
|
||||
|
||||
ioctl_close_handle((ioctl_t *) ioctl);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -684,8 +672,6 @@ ioctl_is_empty(const void *local)
|
||||
unsigned long int unused = 0;
|
||||
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
||||
|
||||
ioctl_open_handle((ioctl_t *) ioctl);
|
||||
|
||||
memset(&req, 0x00, sizeof(SCSI_PASS_THROUGH_DIRECT_BUF));
|
||||
req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
||||
req.spt.PathId = 0;
|
||||
@@ -745,8 +731,6 @@ ioctl_is_empty(const void *local)
|
||||
} else
|
||||
ret = 0;
|
||||
|
||||
ioctl_close_handle((ioctl_t *) ioctl);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -774,7 +758,6 @@ ioctl_load(const void *local)
|
||||
DeviceIoControl(ioctl->handle, IOCTL_STORAGE_LOAD_MEDIA,
|
||||
NULL, 0, NULL, 0,
|
||||
(LPDWORD) &size, NULL);
|
||||
ioctl_close_handle((ioctl_t *) ioctl);
|
||||
|
||||
ioctl_read_toc((ioctl_t *) ioctl);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#define ENABLE_SCSI_CDROM_LOG 2
|
||||
#ifdef ENABLE_SCSI_CDROM_LOG
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@@ -704,8 +703,11 @@ scsi_cdrom_set_period(scsi_cdrom_t *dev)
|
||||
if (dev->was_cached == -1)
|
||||
period *= (double) dev->packet_len;
|
||||
else {
|
||||
period *= ((double) dev->requested_blocks) * 2352.0;
|
||||
pclog("[%02X] Calculated period for %i * 2352 bytes\n", cmd, dev->requested_blocks);
|
||||
const int num = (dev->drv->bus_type == CDROM_BUS_SCSI) ?
|
||||
dev->requested_blocks : 1;
|
||||
|
||||
period *= ((double) num) * 2352.0;
|
||||
pclog("[%02X] Calculated period for %i * 2352 bytes\n", cmd, num);
|
||||
}
|
||||
scsi_cdrom_log(dev->log, "Sector transfer period: %" PRIu64 " us\n",
|
||||
(uint64_t) period);
|
||||
@@ -1041,8 +1043,10 @@ static int
|
||||
scsi_cdrom_read_data(scsi_cdrom_t *dev, const int msf, const int type, const int flags,
|
||||
const int vendor_type)
|
||||
{
|
||||
int temp_len = 0;
|
||||
int ret = 0;
|
||||
int temp_len = 0;
|
||||
int ret = 0;
|
||||
const int num = (dev->drv->bus_type == CDROM_BUS_SCSI) ?
|
||||
dev->requested_blocks : 1;
|
||||
|
||||
if (dev->drv->cd_status == CD_STATUS_EMPTY)
|
||||
scsi_cdrom_not_ready(dev);
|
||||
@@ -1051,7 +1055,7 @@ scsi_cdrom_read_data(scsi_cdrom_t *dev, const int msf, const int type, const int
|
||||
ret = -1;
|
||||
} else {
|
||||
ret = 1;
|
||||
for (int i = 0; (i < dev->requested_blocks) && (ret > 0); i++) {
|
||||
for (int i = 0; (i < num) && (ret > 0); i++) {
|
||||
ret = cdrom_readsector_raw(dev->drv, dev->buffer + dev->buffer_pos,
|
||||
dev->sector_pos, msf, type,
|
||||
flags, &temp_len, vendor_type);
|
||||
|
||||
Reference in New Issue
Block a user