cdvdgigaherz: Remove unused code/macros/variables/etc

The SPTI code is unused, and it's simpler to just use the Windows
ioctls/API if they work (only raw disk sector reading is an issue and
the SPTI workaround is already in place).
This commit is contained in:
Jonathan Li 2016-09-18 23:20:07 +01:00
parent 52fbfdc5ab
commit 60da39712c
4 changed files with 1 additions and 265 deletions

View File

@ -13,16 +13,10 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CDVD.h"
#include "resource.h"
#include "Shlwapi.h"
#include <cstdio>
#include "svnrev.h"
#include <assert.h>
void (*newDiscCB)();
HANDLE hThread_keepAlive = nullptr;
@ -579,7 +573,6 @@ void CALLBACK CDVDnewDiskCB(void (*callback)())
newDiscCB=callback;
}
void configure();
void CALLBACK CDVDconfigure()
{
configure();

View File

@ -139,8 +139,6 @@ public:
extern Source *src;
int FindDiskType();
void configure();
extern char source_drive;

View File

@ -27,255 +27,6 @@
#include <cstddef>
#include <cstdlib>
template<class T>
bool ApiErrorCheck(T t,T okValue,bool cmpEq)
{
bool cond=(t==okValue);
if(!cmpEq) cond=!cond;
if(!cond)
{
static char buff[1024];
DWORD ec = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,ec,0,buff,1023,NULL);
MessageBoxEx(0,buff,"ERROR?!",MB_OK,0);
}
return cond;
}
#if FALSE
typedef struct {
SCSI_PASS_THROUGH_DIRECT spt;
ULONG Filler;
UCHAR ucSenseBuf[32];
} SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptIOCTL; // global read bufs
char szBuf[1024];
PSCSI_ADDRESS pSA;
DWORD SendIoCtlScsiCommand(HANDLE hDevice, u8 direction,
u8 cdbLength, u8* cdb,
u32 dataLength, void* dataBuffer
)
{
DWORD dwRet;
memset(szBuf,0,1024);
pSA=(PSCSI_ADDRESS)szBuf;
pSA->Length=sizeof(SCSI_ADDRESS);
if(!DeviceIoControl(hDevice,IOCTL_SCSI_GET_ADDRESS,NULL,
0,pSA,sizeof(SCSI_ADDRESS),
&dwRet,NULL))
{
return -1;
}
memset(&sptIOCTL,0,sizeof(sptIOCTL));
sptIOCTL.spt.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptIOCTL.spt.TimeOutValue = 60;
sptIOCTL.spt.SenseInfoLength = 14;
sptIOCTL.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, ucSenseBuf);
sptIOCTL.spt.PathId = pSA->PortNumber;
sptIOCTL.spt.TargetId = pSA->TargetId;
sptIOCTL.spt.Lun = pSA->Lun;
sptIOCTL.spt.DataIn = (direction>0)?SCSI_IOCTL_DATA_IN:((direction<0)?SCSI_IOCTL_DATA_OUT:SCSI_IOCTL_DATA_UNSPECIFIED);
sptIOCTL.spt.DataTransferLength = dataLength;
sptIOCTL.spt.DataBuffer = dataBuffer;
sptIOCTL.spt.CdbLength = cdbLength;
memcpy(sptIOCTL.spt.Cdb,cdb,cdbLength);
DWORD code = DeviceIoControl(hDevice,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sptIOCTL,sizeof(sptIOCTL),
&sptIOCTL,sizeof(sptIOCTL),
&dwRet,NULL);
ApiErrorCheck<DWORD>(code,0,false);
return code;
}
//0x00 = PHYSICAL STRUCTURE
DWORD ScsiReadStructure(HANDLE hDevice, u32 layer, u32 format, u32 buffer_length, void* buffer)
{
u8 cdb[12]={0};
cdb[0] = 0xAD;
/*
cdb[2] = (unsigned char)((addr >> 24) & 0xFF);
cdb[3] = (unsigned char)((addr >> 16) & 0xFF);
cdb[4] = (unsigned char)((addr >> 8) & 0xFF);
cdb[5] = (unsigned char)(addr & 0xFF);
*/
cdb[6] = layer;
cdb[7] = format;
cdb[8] = (unsigned char)((buffer_length>>8) & 0xFF);
cdb[9] = (unsigned char)((buffer_length) & 0xFF);
return SendIoCtlScsiCommand(hDevice, 1, 12, cdb, buffer_length, buffer);
}
DWORD ScsiReadBE_2(HANDLE hDevice, u32 addr, u32 count, u8* buffer)
{
u8 cdb[12]={0};
cdb[0] = 0xBE;
cdb[2] = (unsigned char)((addr >> 24) & 0xFF);
cdb[3] = (unsigned char)((addr >> 16) & 0xFF);
cdb[4] = (unsigned char)((addr >> 8) & 0xFF);
cdb[5] = (unsigned char)(addr & 0xFF);
cdb[8] = count;
cdb[9] = 0xF8;
cdb[10] = 0x2;
return SendIoCtlScsiCommand(hDevice, 1, 12, cdb, 2352, buffer);
}
DWORD ScsiRead10(HANDLE hDevice, u32 addr, u32 count, u8* buffer)
{
u8 cdb[10]={0};
cdb[0] = 0x28;
//cdb[1] = lun<<5;
cdb[2] = (unsigned char)((addr >> 24) & 0xFF);
cdb[3] = (unsigned char)((addr >> 16) & 0xFF);
cdb[4] = (unsigned char)((addr >> 8) & 0xFF);
cdb[5] = (unsigned char)(addr & 0xFF);
cdb[8] = count;
return SendIoCtlScsiCommand(hDevice, 1, 10, cdb, 2352, buffer);
}
DWORD ScsiReadTOC(HANDLE hDevice, u32 addr, u8* buffer, bool use_msf)
{
u8 cdb[12]={0};
cdb[0] = 0x43;
cdb[7] = 0x03;
cdb[8] = 0x24;
if(use_msf) cdb[1]=2;
return SendIoCtlScsiCommand(hDevice, 1, 10, cdb, 2352, buffer);
}
s32 IOCtlSrc::GetSectorCount()
{
DWORD size;
LARGE_INTEGER li;
int plain_sectors = 0;
if(GetFileSizeEx(device,&li))
{
return li.QuadPart / 2048;
}
GET_LENGTH_INFORMATION info;
if(DeviceIoControl(device, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &size, NULL))
{
return info.Length.QuadPart / 2048;
}
CDROM_READ_TOC_EX tocrq={0};
tocrq.Format = CDROM_READ_TOC_EX_FORMAT_FULL_TOC;
tocrq.Msf=1;
tocrq.SessionTrack=1;
CDROM_TOC_FULL_TOC_DATA *ftd=(CDROM_TOC_FULL_TOC_DATA*)sectorbuffer;
if(DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),ftd, 2048, &size, NULL))
{
for(int i=0;i<101;i++)
{
if(ftd->Descriptors[i].Point==0xa2)
{
if(ftd->Descriptors[i].SessionNumber==ftd->LastCompleteSession)
{
int min=ftd->Descriptors[i].Msf[0];
int sec=ftd->Descriptors[i].Msf[1];
int frm=ftd->Descriptors[i].Msf[2];
return MSF_TO_LBA(min,sec,frm);
}
}
}
}
int sectors1=-1;
if(ScsiReadStructure(device,0,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
{
if(dld.ld.EndLayerZeroSector>0) // OTP?
{
sectors1 = dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
}
else //PTP or single layer
{
sectors1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
}
if(ScsiReadStructure(device,1,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
{
// PTP second layer
//sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
if(dld.ld.EndLayerZeroSector>0) // OTP?
{
sectors1 += dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
}
else //PTP
{
sectors1 += dld.ld.EndDataSector - dld.ld.StartingDataSector;
}
}
return sectors1;
}
return -1;
}
s32 IOCtlSrc::GetLayerBreakAddress()
{
DWORD size;
if(ScsiReadStructure(device,0,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
{
if(dld.ld.EndLayerZeroSector>0) // OTP?
{
return dld.ld.EndLayerZeroSector - dld.ld.StartingDataSector;
}
else //PTP or single layer
{
u32 s1 = dld.ld.EndDataSector - dld.ld.StartingDataSector;
if(ScsiReadStructure(device,1,DvdPhysicalDescriptor, sizeof(dld), &dld)!=0)
{
//PTP
return s1;
}
// single layer
return 0;
}
}
return -1;
}
#endif
#define RETURN(v) {OpenOK=v; return;}
s32 IOCtlSrc::Reopen()
{
if(device!=INVALID_HANDLE_VALUE)
@ -352,7 +103,6 @@ struct mycrap
DVD_READ_STRUCTURE dvdrs;
mycrap dld;
DISK_GEOMETRY dg;
CDROM_READ_TOC_EX tocrq={0};
s32 IOCtlSrc::GetSectorCount()

View File

@ -143,11 +143,6 @@ char* path[] = {
int n,s;
#define SET_CHECK(idc,value) SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,((value)==0)?BST_UNCHECKED:BST_CHECKED,0)
#define HANDLE_CHECK(idc,hvar) case idc: hvar=hvar?0:1; SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,(hvar==1)?BST_CHECKED:BST_UNCHECKED,0); break
#define HANDLE_CHECKNB(idc,hvar)case idc: hvar=hvar?0:1; SendMessage(GetDlgItem(hWnd,idc),BM_SETCHECK,(hvar==1)?BST_CHECKED:BST_UNCHECKED,0)
#define ENABLE_CONTROL(idc,value) EnableWindow(GetDlgItem(hWnd,idc),value)
BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
int wmId,wmEvent;