Implemented ATAPI Read CD-ROM Capacity command, fixes CD usage in OS/2.
This commit is contained in:
parent
71f47a4e07
commit
8283d3ee73
3 changed files with 40 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ typedef struct _CDROM_TOC_SESSION_DATA {
|
|||
} CDROM_TOC_SESSION_DATA, *PCDROM_TOC_SESSION_DATA;
|
||||
static ATAPI ioctl_atapi;
|
||||
|
||||
static uint32_t last_block = 0;
|
||||
static int ioctl_inited = 0;
|
||||
static char ioctl_path[8];
|
||||
static void ioctl_close(void);
|
||||
|
|
@ -383,14 +384,20 @@ static int ioctl_readtoc(unsigned char *b, unsigned char starttrack, int msf, in
|
|||
}
|
||||
}
|
||||
b[2]=toc.TrackData[c].TrackNumber;
|
||||
last_block = 0;
|
||||
for (c=d;c<=toc.LastTrack;c++)
|
||||
{
|
||||
uint32_t address;
|
||||
if ((len+8)>maxlen) break;
|
||||
// pclog("Len %i max %i Track %02X - %02X %02X %i %i %i %i %08X\n",len,maxlen,toc.TrackData[c].TrackNumber,toc.TrackData[c].Adr,toc.TrackData[c].Control,toc.TrackData[c].Address[0],toc.TrackData[c].Address[1],toc.TrackData[c].Address[2],toc.TrackData[c].Address[3],MSFtoLBA(toc.TrackData[c].Address[1],toc.TrackData[c].Address[2],toc.TrackData[c].Address[3]));
|
||||
b[len++]=0; /*Reserved*/
|
||||
b[len++]=(toc.TrackData[c].Adr<<4)|toc.TrackData[c].Control;
|
||||
b[len++]=toc.TrackData[c].TrackNumber;
|
||||
b[len++]=0; /*Reserved*/
|
||||
address = MSFtoLBA(toc.TrackData[c].Address[1],toc.TrackData[c].Address[2],toc.TrackData[c].Address[3]);
|
||||
if (address > last_block)
|
||||
last_block = address;
|
||||
|
||||
if (msf)
|
||||
{
|
||||
b[len++]=toc.TrackData[c].Address[0];
|
||||
|
|
@ -461,6 +468,15 @@ static void ioctl_readtoc_session(unsigned char *b, int msf, int maxlen)
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t ioctl_size()
|
||||
{
|
||||
unsigned char b[4096];
|
||||
|
||||
atapi->readtoc(b, 0, 0, 4096, 0);
|
||||
|
||||
return last_block;
|
||||
}
|
||||
|
||||
int ioctl_open(char d)
|
||||
{
|
||||
// char s[8];
|
||||
|
|
@ -510,6 +526,7 @@ static ATAPI ioctl_atapi=
|
|||
ioctl_eject,
|
||||
ioctl_pause,
|
||||
ioctl_resume,
|
||||
ioctl_size,
|
||||
ioctl_stop,
|
||||
ioctl_exit
|
||||
};
|
||||
|
|
|
|||
22
src/ide.c
22
src/ide.c
|
|
@ -71,6 +71,7 @@
|
|||
#define GPCMD_PREVENT_REMOVAL 0x1e
|
||||
#define GPCMD_READ_10 0x28
|
||||
#define GPCMD_READ_CD 0xbe
|
||||
#define GPCMD_READ_CDROM_CAPACITY 0x25
|
||||
#define GPCMD_READ_HEADER 0x44
|
||||
#define GPCMD_READ_SUBCHANNEL 0x42
|
||||
#define GPCMD_READ_TOC_PMA_ATIP 0x43
|
||||
|
|
@ -1553,6 +1554,7 @@ static void atapicommand(int ide_board)
|
|||
int msf;
|
||||
int pos=0;
|
||||
unsigned char temp;
|
||||
uint32_t size;
|
||||
#ifndef RPCEMU_IDE
|
||||
pclog("New ATAPI command %02X %i\n",idebufferb[0],ins);
|
||||
#endif
|
||||
|
|
@ -1957,6 +1959,26 @@ static void atapicommand(int ide_board)
|
|||
idecallback[ide_board]=50*IDE_TIME;
|
||||
break;
|
||||
|
||||
case GPCMD_READ_CDROM_CAPACITY:
|
||||
if (!atapi->ready()) { atapi_notready(ide); return; }
|
||||
size = atapi->size();
|
||||
idebufferb[0] = (size >> 24) & 0xff;
|
||||
idebufferb[1] = (size >> 16) & 0xff;
|
||||
idebufferb[2] = (size >> 8) & 0xff;
|
||||
idebufferb[3] = size & 0xff;
|
||||
idebufferb[4] = (2048 >> 24) & 0xff;
|
||||
idebufferb[5] = (2048 >> 16) & 0xff;
|
||||
idebufferb[6] = (2048 >> 8) & 0xff;
|
||||
idebufferb[7] = 2048 & 0xff;
|
||||
len=8;
|
||||
ide->packetstatus=3;
|
||||
ide->cylinder=len;
|
||||
ide->secount=2;
|
||||
ide->pos=0;
|
||||
idecallback[ide_board]=60*IDE_TIME;
|
||||
ide->packlen=len;
|
||||
break;
|
||||
|
||||
case GPCMD_SEND_DVD_STRUCTURE:
|
||||
default:
|
||||
ide->atastat = READY_STAT | ERR_STAT; /*CHECK CONDITION*/
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ typedef struct ATAPI
|
|||
void (*eject)(void);
|
||||
void (*pause)(void);
|
||||
void (*resume)(void);
|
||||
uint32_t (*size)(void);
|
||||
void (*stop)(void);
|
||||
void (*exit)(void);
|
||||
} ATAPI;
|
||||
|
|
|
|||
Loading…
Reference in a new issue