Reimplemented the READ SUBCHANNEL command for both ATAPI and SCSI.
This commit is contained in:
@@ -529,6 +529,21 @@ static void ioctl_read_capacity(uint8_t *b)
|
||||
ioctl_close();
|
||||
}
|
||||
|
||||
static void ioctl_read_subchannel(uint8_t *in_cdb, uint8_t *b)
|
||||
{
|
||||
const UCHAR cdb[12];
|
||||
UCHAR buf[24];
|
||||
|
||||
ioctl_open(0);
|
||||
|
||||
memcpy(cdb, in_cdb, 12);
|
||||
SCSICommand(cdb, buf, 24);
|
||||
|
||||
memcpy(b, buf, 24);
|
||||
|
||||
ioctl_close();
|
||||
}
|
||||
|
||||
static void ioctl_read_header(uint8_t *in_cdb, uint8_t *b)
|
||||
{
|
||||
const UCHAR cdb[12];
|
||||
@@ -1054,6 +1069,7 @@ static CDROM ioctl_cdrom=
|
||||
ioctl_readtoc_raw,
|
||||
ioctl_getcurrentsubchannel,
|
||||
ioctl_read_capacity,
|
||||
ioctl_read_subchannel,
|
||||
ioctl_read_header,
|
||||
ioctl_read_disc_information,
|
||||
ioctl_read_track_information,
|
||||
|
@@ -18,6 +18,8 @@ void iso_close(void);
|
||||
static FILE* iso_image;
|
||||
static int iso_changed = 0;
|
||||
|
||||
static uint32_t lba = 0;
|
||||
|
||||
static uint32_t iso_cd_pos = 0, iso_cd_end = 0;
|
||||
|
||||
void iso_audio_callback(int16_t *output, int len)
|
||||
@@ -64,6 +66,7 @@ static void iso_stop(void)
|
||||
static void iso_seek(uint32_t pos)
|
||||
{
|
||||
// pclog("iso_seek stub\n");
|
||||
lba = pos;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,10 +116,41 @@ static int iso_medium_changed(void)
|
||||
|
||||
static uint8_t iso_getcurrentsubchannel(uint8_t *b, int msf)
|
||||
{
|
||||
// pclog("iso_getcurrentsubchannel stub\n");
|
||||
long size;
|
||||
int pos=0;
|
||||
if (strlen(iso_path) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
b[pos++]=0;
|
||||
b[pos++]=0;
|
||||
b[pos++]=0;
|
||||
|
||||
int32_t temp = lba;
|
||||
if (msf)
|
||||
{
|
||||
memset(&(b[pos]), 0, 8);
|
||||
lba_to_msf(&(b[pos]), temp);
|
||||
pos += 4;
|
||||
lba_to_msf(&(b[pos]), temp);
|
||||
pos += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
b[pos++] = temp >> 24;
|
||||
b[pos++] = temp >> 16;
|
||||
b[pos++] = temp >> 8;
|
||||
b[pos++] = temp;
|
||||
b[pos++] = temp >> 24;
|
||||
b[pos++] = temp >> 16;
|
||||
b[pos++] = temp >> 8;
|
||||
b[pos++] = temp;
|
||||
}
|
||||
|
||||
return 0x13;
|
||||
}
|
||||
|
||||
static void iso_eject(void)
|
||||
{
|
||||
// pclog("iso_eject stub\n");
|
||||
@@ -418,6 +452,7 @@ static CDROM iso_cdrom =
|
||||
iso_getcurrentsubchannel,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
iso_sector_data_type,
|
||||
|
@@ -134,6 +134,7 @@ static CDROM null_cdrom =
|
||||
null_getcurrentsubchannel,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
null_sector_data_type,
|
||||
|
@@ -11,6 +11,7 @@ typedef struct CDROM
|
||||
int (*readtoc_raw)(uint8_t *b, int msf, int maxlen);
|
||||
uint8_t (*getcurrentsubchannel)(uint8_t *b, int msf);
|
||||
void (*read_capacity)(uint8_t *b);
|
||||
void (*read_subchannel)(uint8_t *in_cdb, uint8_t *b);
|
||||
void (*read_header)(uint8_t *in_cdb, uint8_t *b);
|
||||
void (*read_disc_information)(uint8_t *b);
|
||||
int (*read_track_information)(uint8_t *in_cdb, uint8_t *b);
|
||||
|
40
src/ide.c
40
src/ide.c
@@ -2577,26 +2577,54 @@ static void atapicommand(int ide_board)
|
||||
break;
|
||||
|
||||
case GPCMD_READ_SUBCHANNEL:
|
||||
temp=idebufferb[2]&0x40;
|
||||
if (idebufferb[3]!=1)
|
||||
if (idebufferb[3] > 3)
|
||||
{
|
||||
// pclog("Read subchannel check condition %02X\n",idebufferb[3]);
|
||||
atapi_invalid_field(ide);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(idebufferb[3])
|
||||
{
|
||||
case 0:
|
||||
alloc_length = 4;
|
||||
break;
|
||||
case 1:
|
||||
alloc_length = 16;
|
||||
break;
|
||||
default:
|
||||
alloc_length = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cdrom->read_subchannel)
|
||||
{
|
||||
cdrom->read_subchannel(idebufferb, idebufferb);
|
||||
len = alloc_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = idebufferb[3] & 3;
|
||||
temp |= (idebufferb[2] & 0x40);
|
||||
memset(idebufferb, 24, 0);
|
||||
pos = 0;
|
||||
idebufferb[pos++]=0;
|
||||
idebufferb[pos++]=0; /*Audio status*/
|
||||
idebufferb[pos++]=0; idebufferb[pos++]=0; /*Subchannel length*/
|
||||
idebufferb[pos++]=1; /*Format code*/
|
||||
idebufferb[pos++]=temp & 3; /*Format code*/
|
||||
if ((temp & 3) == 1)
|
||||
{
|
||||
idebufferb[1]=cdrom->getcurrentsubchannel(&idebufferb[5],msf);
|
||||
// pclog("Read subchannel complete - audio status %02X\n",idebufferb[1]);
|
||||
len=16;
|
||||
if (!temp)
|
||||
}
|
||||
if (!(temp & 0x40) || ((temp & 3) == 0))
|
||||
{
|
||||
len=4;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = alloc_length;
|
||||
}
|
||||
}
|
||||
ide->packetstatus = ATAPI_STATUS_DATA;
|
||||
ide->cylinder=len;
|
||||
ide->secount=2;
|
||||
|
@@ -1120,8 +1120,7 @@ SCSIOut:
|
||||
break;
|
||||
|
||||
case GPCMD_READ_SUBCHANNEL:
|
||||
Temp = cdb[2] & 0x40;
|
||||
if (cdb[3] != 1)
|
||||
if (cdb[3] > 3)
|
||||
{
|
||||
SCSIStatus = SCSI_STATUS_CHECK_CONDITION;
|
||||
SCSISenseCodeError(SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET, 0x00);
|
||||
@@ -1129,15 +1128,45 @@ SCSIOut:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(cdb[3])
|
||||
{
|
||||
case 0:
|
||||
alloc_length = 4;
|
||||
break;
|
||||
case 1:
|
||||
alloc_length = 16;
|
||||
break;
|
||||
default:
|
||||
alloc_length = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cdrom->read_subchannel)
|
||||
{
|
||||
cdrom->read_subchannel(cdb, cmdbuffer);
|
||||
len = alloc_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(cmdbuffer, 24, 0);
|
||||
pos = 0;
|
||||
cmdbuffer[pos++]=0;
|
||||
cmdbuffer[pos++]=0; /*Audio status*/
|
||||
cmdbuffer[pos++]=0; cmdbuffer[pos++]=0; /*Subchannel length*/
|
||||
cmdbuffer[pos++] = 1; /*Format code*/
|
||||
cmdbuffer[1] = cdrom->getcurrentsubchannel(&cmdbuffer[5], msf);
|
||||
len = 16;
|
||||
if (!Temp)
|
||||
cmdbuffer[pos++]=cdb[3]; /*Format code*/
|
||||
if (!(cdb[2] & 0x40) || (cdb[3] == 0))
|
||||
{
|
||||
len = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = alloc_length;
|
||||
}
|
||||
if (cdb[3] == 1)
|
||||
{
|
||||
cmdbuffer[1]=cdrom->getcurrentsubchannel(&cmdbuffer[5],msf);
|
||||
}
|
||||
}
|
||||
|
||||
SCSIPhase = SCSI_PHASE_DATAIN;
|
||||
SCSIStatus = SCSI_STATUS_OK;
|
||||
|
Reference in New Issue
Block a user