Several CD-ROM fixes.
This commit is contained in:
@@ -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.42 2018/03/19
|
||||
* Version: @(#)cdrom.c 1.0.43 2018/03/20
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -128,7 +128,7 @@ const uint8_t cdrom_command_flags[0x100] =
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
IMPLEMENTED | CHECK_READY,
|
||||
IMPLEMENTED | CHECK_READY | ALLOW_UA, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
|
||||
IMPLEMENTED | CHECK_READY, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
|
||||
NOTE: The ATAPI reference says otherwise, but I think this is a question of
|
||||
interpreting things right - the UNIT ATTENTION condition we have here
|
||||
is a tradition from not ready to ready, by definition the drive
|
||||
@@ -449,10 +449,19 @@ void cdrom_init(int id, int cdb_len_setting)
|
||||
{
|
||||
cdrom_t *dev;
|
||||
|
||||
uint8_t *trcbuf;
|
||||
uint32_t tcap;
|
||||
|
||||
if (id >= CDROM_NUM)
|
||||
return;
|
||||
dev = cdrom[id];
|
||||
tcap = dev->cdrom_capacity;
|
||||
trcbuf = (uint8_t *) malloc(16);
|
||||
memcpy(trcbuf, dev->rcbuf, 16);
|
||||
memset(dev, 0, sizeof(cdrom_t));
|
||||
memcpy(dev->rcbuf, trcbuf, 16);
|
||||
free(trcbuf);
|
||||
dev->cdrom_capacity = tcap;
|
||||
dev->requested_blocks = 1;
|
||||
if (cdb_len_setting <= 1)
|
||||
dev->cdb_len_setting = cdb_len_setting;
|
||||
@@ -468,7 +477,6 @@ void cdrom_init(int id, int cdb_len_setting)
|
||||
cdrom_log("CD-ROM %i: Bus type %i, bus mode %i\n", id, cdrom_drives[id].bus_type, cdrom_drives[id].bus_mode);
|
||||
if (cdrom_drives[id].bus_type < CDROM_BUS_SCSI)
|
||||
cdrom_set_signature(id);
|
||||
cdrom_drives[id].max_blocks_at_once = 85;
|
||||
dev->status = READY_STAT | DSC_STAT;
|
||||
dev->pos = 0;
|
||||
dev->packet_status = 0xff;
|
||||
@@ -1236,29 +1244,29 @@ int cdrom_read_data(uint8_t id, int msf, int type, int flags, uint32_t *len)
|
||||
|
||||
int last_valid_data_pos = 0;
|
||||
|
||||
if (cdrom_drives[id].handler->pass_through) {
|
||||
cdsize = cdrom_drives[id].handler->size(id);
|
||||
cdsize = cdrom_drives[id].handler->size(id);
|
||||
|
||||
if (dev->sector_pos >= cdsize) {
|
||||
cdrom_log("CD-ROM %i: Trying to read from beyond the end of disc (%i >= %i)\n", id, dev->sector_pos, cdsize);
|
||||
cdrom_lba_out_of_range(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((dev->sector_pos + dev->sector_len - 1) >= cdsize) {
|
||||
cdrom_log("CD-ROM %i: Trying to read to beyond the end of disc (%i >= %i)\n", id, (dev->sector_pos + dev->sector_len - 1), cdsize);
|
||||
cdrom_lba_out_of_range(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cdrom_drives[id].handler->pass_through) {
|
||||
ret = cdrom_pass_through(id, len, dev->current_cdb, cdbufferb + dev->data_pos);
|
||||
dev->data_pos += *len;
|
||||
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
if (dev->sector_pos > (cdsize - 1)) {
|
||||
/* cdrom_log("CD-ROM %i: Trying to read beyond the end of disc\n", id); */
|
||||
cdrom_lba_out_of_range(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev->old_len = *len;
|
||||
} else {
|
||||
if (dev->sector_pos > (cdrom_drives[id].handler->size(id) - 1)) {
|
||||
/* cdrom_log("CD-ROM %i: Trying to read beyond the end of disc\n", id); */
|
||||
cdrom_lba_out_of_range(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev->old_len = 0;
|
||||
*len = 0;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the CD-ROM drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)cdrom.h 1.0.9 2018/03/18
|
||||
* Version: @(#)cdrom.h 1.0.10 2018/03/20
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -170,8 +170,6 @@ typedef struct {
|
||||
} cdrom_t;
|
||||
|
||||
typedef struct {
|
||||
int max_blocks_at_once;
|
||||
|
||||
CDROM *handler;
|
||||
|
||||
int host_drive;
|
||||
|
||||
@@ -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.14 2018/03/20
|
||||
* Version: @(#)zip.c 1.0.15 2018/03/20
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -654,7 +654,6 @@ void zip_init(int id, int cdb_len_setting)
|
||||
zip_log("ZIP %i: Bus type %i, bus mode %i\n", id, zip_drives[id].bus_type, zip_drives[id].bus_mode);
|
||||
if (zip_drives[id].bus_type < ZIP_BUS_SCSI)
|
||||
zip_set_signature(id);
|
||||
zip_drives[id].max_blocks_at_once = 85;
|
||||
zip[id].status = READY_STAT | DSC_STAT;
|
||||
zip[id].pos = 0;
|
||||
zip[id].packet_status = 0xff;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the Iomega ZIP drive with SCSI(-like)
|
||||
* commands, for both ATAPI and SCSI usage.
|
||||
*
|
||||
* Version: @(#)zip.h 1.0.3 2018/03/17
|
||||
* Version: @(#)zip.h 1.0.4 2018/03/20
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
@@ -122,8 +122,6 @@ typedef struct {
|
||||
} zip_t;
|
||||
|
||||
typedef struct {
|
||||
int max_blocks_at_once;
|
||||
|
||||
int host_drive;
|
||||
int prev_host_drive;
|
||||
|
||||
|
||||
10
src/pci.c
10
src/pci.c
@@ -16,6 +16,7 @@
|
||||
#include "cdrom/cdrom.h"
|
||||
#include "disk/hdc.h"
|
||||
#include "disk/hdc_ide.h"
|
||||
#include "disk/zip.h"
|
||||
|
||||
|
||||
static uint64_t pci_irq_hold[16];
|
||||
@@ -658,11 +659,18 @@ static void trc_reset(uint8_t val)
|
||||
ide_set_all_signatures();
|
||||
for (i = 0; i < CDROM_NUM; i++)
|
||||
{
|
||||
if (!cdrom_drives[i].bus_type)
|
||||
if ((cdrom_drives[i].bus_type == CDROM_BUS_ATAPI_PIO_ONLY) || (cdrom_drives[i].bus_type == CDROM_BUS_ATAPI_PIO_AND_DMA))
|
||||
{
|
||||
cdrom_reset(i);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < ZIP_NUM; i++)
|
||||
{
|
||||
if ((zip_drives[i].bus_type == ZIP_BUS_ATAPI_PIO_ONLY) || (zip_drives[i].bus_type == ZIP_BUS_ATAPI_PIO_AND_DMA))
|
||||
{
|
||||
zip_reset(i);
|
||||
}
|
||||
}
|
||||
|
||||
port_92_reset();
|
||||
keyboard_at_reset();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Implementation of the CD-ROM host drive IOCTL interface for
|
||||
* Windows using SCSI Passthrough Direct.
|
||||
*
|
||||
* Version: @(#)cdrom_ioctl.c 1.0.14 2018/03/17
|
||||
* Version: @(#)cdrom_ioctl.c 1.0.15 2018/03/20
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -1202,6 +1202,7 @@ static uint32_t ioctl_size(uint8_t id)
|
||||
{
|
||||
uint8_t capacity_buffer[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
uint32_t capacity = 0;
|
||||
|
||||
ioctl_read_capacity(id, capacity_buffer);
|
||||
capacity = ((uint32_t) capacity_buffer[0]) << 24;
|
||||
capacity |= ((uint32_t) capacity_buffer[1]) << 16;
|
||||
@@ -1260,16 +1261,22 @@ int ioctl_hopen(uint8_t id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define rcs "Read capacity: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n"
|
||||
#define drb dev->rcbuf
|
||||
|
||||
int ioctl_open(uint8_t id, char d)
|
||||
{
|
||||
cdrom_t *dev = cdrom[id];
|
||||
sprintf(cdrom_ioctl[id].ioctl_path,"\\\\.\\%c:",d);
|
||||
pclog("IOCTL path: %s\n", cdrom_ioctl[id].ioctl_path);
|
||||
dev->disc_changed = 1;
|
||||
cdrom_ioctl_windows[id].hIOCTL = CreateFile(cdrom_ioctl[id].ioctl_path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
cdrom_drives[id].handler = &ioctl_cdrom;
|
||||
dev->handler_inited=1;
|
||||
cdrom_ioctl[id].capacity_read=0; /* With this two lines, we read the READ CAPACITY command output from the host drive into our cache buffer. */
|
||||
cdrom_ioctl[id].capacity_read=0; /* With these two lines, we read the READ CAPACITY command output from the host drive into our cache buffer. */
|
||||
ioctl_read_capacity(id, NULL);
|
||||
pclog(rcs, drb[0], drb[1], drb[2], drb[3], drb[4], drb[5], drb[6], drb[7],
|
||||
drb[8], drb[9], drb[10], drb[11], drb[12], drb[13], drb[14], drb[15]);
|
||||
CloseHandle(cdrom_ioctl_windows[id].hIOCTL);
|
||||
cdrom_ioctl_windows[id].hIOCTL = NULL;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user