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->seek_pos = 0;
|
||||||
dev->cd_buflen = 0;
|
dev->cd_buflen = 0;
|
||||||
|
|
||||||
if ((dev->ops->is_empty != NULL) && dev->ops->is_empty(dev->local))
|
if (dev->ops->is_dvd(dev->local))
|
||||||
dev->cd_status = CD_STATUS_EMPTY;
|
|
||||||
else if (dev->ops->is_dvd(dev->local))
|
|
||||||
dev->cd_status = CD_STATUS_DVD;
|
dev->cd_status = CD_STATUS_DVD;
|
||||||
else
|
else
|
||||||
dev->cd_status = dev->ops->has_audio(dev->local) ? CD_STATUS_STOPPED :
|
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;
|
int ret = 0;
|
||||||
|
|
||||||
/* This entire block should be in cdrom.c/cdrom_eject(dev*) ... */
|
/* 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. */
|
/* Switch from empty to empty. Do nothing. */
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -241,7 +241,6 @@ int ide_qua_enabled = 0;
|
|||||||
static void ide_atapi_callback(ide_t *ide);
|
static void ide_atapi_callback(ide_t *ide);
|
||||||
static void ide_callback(void *priv);
|
static void ide_callback(void *priv);
|
||||||
|
|
||||||
#define ENABLE_IDE_LOG 1
|
|
||||||
#ifdef ENABLE_IDE_LOG
|
#ifdef ENABLE_IDE_LOG
|
||||||
int ide_do_log = 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.Msf = 1;
|
||||||
ioctl->cur_read_toc_ex.SessionTrack = 1;
|
ioctl->cur_read_toc_ex.SessionTrack = 1;
|
||||||
|
|
||||||
ioctl_open_handle(ioctl);
|
|
||||||
const int temp = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX,
|
const int temp = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX,
|
||||||
&ioctl->cur_read_toc_ex, 65535,
|
&ioctl->cur_read_toc_ex, 65535,
|
||||||
cur_full_toc, 65535,
|
cur_full_toc, 65535,
|
||||||
(LPDWORD) &size, NULL);
|
(LPDWORD) &size, NULL);
|
||||||
ioctl_close_handle(ioctl);
|
|
||||||
ioctl_log(ioctl->log, "temp = %i\n", temp);
|
ioctl_log(ioctl->log, "temp = %i\n", temp);
|
||||||
|
|
||||||
if (temp != 0) {
|
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.Msf = 1;
|
||||||
ioctl->cur_read_toc_ex.SessionTrack = 1;
|
ioctl->cur_read_toc_ex.SessionTrack = 1;
|
||||||
|
|
||||||
ioctl_open_handle(ioctl);
|
|
||||||
const int status = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX,
|
const int status = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX,
|
||||||
&ioctl->cur_read_toc_ex, 65535,
|
&ioctl->cur_read_toc_ex, 65535,
|
||||||
cur_full_toc, 65535,
|
cur_full_toc, 65535,
|
||||||
(LPDWORD) &size, NULL);
|
(LPDWORD) &size, NULL);
|
||||||
ioctl_close_handle(ioctl);
|
|
||||||
ioctl_log(ioctl->log, "status = %i\n", status);
|
ioctl_log(ioctl->log, "status = %i\n", status);
|
||||||
|
|
||||||
if ((status == 0) && (ioctl->tracks_num >= 1)) {
|
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;
|
int ret;
|
||||||
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
||||||
|
|
||||||
ioctl_open_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
if (ioctl->is_dvd) {
|
if (ioctl->is_dvd) {
|
||||||
int track;
|
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--)
|
for (int j = 7; j >= 0; j--)
|
||||||
buffer[2352 + (i * 8) + j] = ((buffer[sc_offs + i] >> (7 - j)) & 0x01) << 6;
|
buffer[2352 + (i * 8) + j] = ((buffer[sc_offs + i] >> (7 - j)) & 0x01) << 6;
|
||||||
|
|
||||||
ioctl_close_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
return ret;
|
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;
|
const int len = 2052;
|
||||||
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
||||||
|
|
||||||
ioctl_open_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
memset(&req, 0x00, sizeof(SCSI_PASS_THROUGH_DIRECT_BUF));
|
memset(&req, 0x00, sizeof(SCSI_PASS_THROUGH_DIRECT_BUF));
|
||||||
req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
||||||
req.spt.PathId = 0;
|
req.spt.PathId = 0;
|
||||||
@@ -650,8 +640,6 @@ ioctl_read_dvd_structure(const void *local, const uint8_t layer, const uint8_t f
|
|||||||
} else
|
} else
|
||||||
ret = ret ? (req.spt.DataTransferLength >= len) : 0;
|
ret = ret ? (req.spt.DataTransferLength >= len) : 0;
|
||||||
|
|
||||||
ioctl_close_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,8 +672,6 @@ ioctl_is_empty(const void *local)
|
|||||||
unsigned long int unused = 0;
|
unsigned long int unused = 0;
|
||||||
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
SCSI_PASS_THROUGH_DIRECT_BUF req;
|
||||||
|
|
||||||
ioctl_open_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
memset(&req, 0x00, sizeof(SCSI_PASS_THROUGH_DIRECT_BUF));
|
memset(&req, 0x00, sizeof(SCSI_PASS_THROUGH_DIRECT_BUF));
|
||||||
req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
req.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
|
||||||
req.spt.PathId = 0;
|
req.spt.PathId = 0;
|
||||||
@@ -745,8 +731,6 @@ ioctl_is_empty(const void *local)
|
|||||||
} else
|
} else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
ioctl_close_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -774,7 +758,6 @@ ioctl_load(const void *local)
|
|||||||
DeviceIoControl(ioctl->handle, IOCTL_STORAGE_LOAD_MEDIA,
|
DeviceIoControl(ioctl->handle, IOCTL_STORAGE_LOAD_MEDIA,
|
||||||
NULL, 0, NULL, 0,
|
NULL, 0, NULL, 0,
|
||||||
(LPDWORD) &size, NULL);
|
(LPDWORD) &size, NULL);
|
||||||
ioctl_close_handle((ioctl_t *) ioctl);
|
|
||||||
|
|
||||||
ioctl_read_toc((ioctl_t *) ioctl);
|
ioctl_read_toc((ioctl_t *) ioctl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#define ENABLE_SCSI_CDROM_LOG 2
|
|
||||||
#ifdef ENABLE_SCSI_CDROM_LOG
|
#ifdef ENABLE_SCSI_CDROM_LOG
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -704,8 +703,11 @@ scsi_cdrom_set_period(scsi_cdrom_t *dev)
|
|||||||
if (dev->was_cached == -1)
|
if (dev->was_cached == -1)
|
||||||
period *= (double) dev->packet_len;
|
period *= (double) dev->packet_len;
|
||||||
else {
|
else {
|
||||||
period *= ((double) dev->requested_blocks) * 2352.0;
|
const int num = (dev->drv->bus_type == CDROM_BUS_SCSI) ?
|
||||||
pclog("[%02X] Calculated period for %i * 2352 bytes\n", cmd, dev->requested_blocks);
|
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",
|
scsi_cdrom_log(dev->log, "Sector transfer period: %" PRIu64 " us\n",
|
||||||
(uint64_t) period);
|
(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,
|
scsi_cdrom_read_data(scsi_cdrom_t *dev, const int msf, const int type, const int flags,
|
||||||
const int vendor_type)
|
const int vendor_type)
|
||||||
{
|
{
|
||||||
int temp_len = 0;
|
int temp_len = 0;
|
||||||
int ret = 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)
|
if (dev->drv->cd_status == CD_STATUS_EMPTY)
|
||||||
scsi_cdrom_not_ready(dev);
|
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;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
ret = 1;
|
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,
|
ret = cdrom_readsector_raw(dev->drv, dev->buffer + dev->buffer_pos,
|
||||||
dev->sector_pos, msf, type,
|
dev->sector_pos, msf, type,
|
||||||
flags, &temp_len, vendor_type);
|
flags, &temp_len, vendor_type);
|
||||||
|
|||||||
Reference in New Issue
Block a user