mirror of
https://github.com/erichelgeson/BlueSCSI.git
synced 2024-12-22 12:30:12 +00:00
alternative sector size supported
this let's .BIN files get used at the very least, maybe more depending on how some of the other optical formats look reverted a small SCSI phase change that causes problems
This commit is contained in:
parent
30b794e03d
commit
3a3d68cf99
@ -215,8 +215,9 @@ bool VerifyISOPVD(SCSI_DEVICE *dev, unsigned sector_size, bool mode2)
|
||||
bool hddimageOpen(SCSI_DEVICE *dev, FsFile *file,int id,int lun,int blocksize)
|
||||
{
|
||||
dev->m_fileSize= 0;
|
||||
dev->m_offset = 0;
|
||||
dev->m_sector_offset = 0;
|
||||
dev->m_blocksize = blocksize;
|
||||
dev->m_rawblocksize = blocksize;
|
||||
dev->m_file = file;
|
||||
if(!dev->m_file->isOpen()) { goto failed; }
|
||||
|
||||
@ -229,25 +230,25 @@ bool hddimageOpen(SCSI_DEVICE *dev, FsFile *file,int id,int lun,int blocksize)
|
||||
|
||||
if(dev->m_type == SCSI_DEVICE_OPTICAL) {
|
||||
LOG_FILE.print(" CDROM");
|
||||
dev->m_blocksize = CDROM_COMMON_SECTORSIZE;
|
||||
|
||||
// Borrowed from PCEM
|
||||
if(VerifyISOPVD(dev, CDROM_COMMON_SECTORSIZE, false)) {
|
||||
dev->m_blocksize = CDROM_COMMON_SECTORSIZE;
|
||||
dev->m_mode2 = false;
|
||||
} else if(VerifyISOPVD(dev, CDROM_RAW_SECTORSIZE, false)) {
|
||||
dev->m_blocksize = CDROM_RAW_SECTORSIZE;
|
||||
dev->m_rawblocksize = CDROM_COMMON_SECTORSIZE;
|
||||
dev->m_mode2 = false;
|
||||
} else if(VerifyISOPVD(dev, CDROM_RAW_SECTORSIZE, false)) {
|
||||
dev->m_rawblocksize = CDROM_RAW_SECTORSIZE;
|
||||
dev->m_mode2 = false;
|
||||
dev->m_raw = true;
|
||||
dev->m_offset = 16;
|
||||
dev->m_sector_offset = 16;
|
||||
} else if(VerifyISOPVD(dev, 2336, true)) {
|
||||
dev->m_blocksize = 2336;
|
||||
dev->m_rawblocksize = 2336;
|
||||
dev->m_mode2 = true;
|
||||
} else if(VerifyISOPVD(dev, CDROM_RAW_SECTORSIZE, true)) {
|
||||
dev->m_blocksize = CDROM_RAW_SECTORSIZE;
|
||||
dev->m_rawblocksize = CDROM_RAW_SECTORSIZE;
|
||||
dev->m_mode2 = true;
|
||||
dev->m_raw = true;
|
||||
dev->m_offset = 16;
|
||||
dev->m_sector_offset = 24;
|
||||
} else {
|
||||
// Last ditch effort
|
||||
// size must be less than 700MB
|
||||
@ -282,7 +283,7 @@ bool hddimageOpen(SCSI_DEVICE *dev, FsFile *file,int id,int lun,int blocksize)
|
||||
|
||||
if(dev->m_type == SCSI_DEVICE_OPTICAL) {
|
||||
LOG_FILE.print(" MODE2:");LOG_FILE.print(dev->m_mode2);
|
||||
LOG_FILE.print(" BlockSize:");LOG_FILE.println(dev->m_blocksize);
|
||||
LOG_FILE.print(" BlockSize:");LOG_FILE.println(dev->m_rawblocksize);
|
||||
}
|
||||
return true; // File opened
|
||||
|
||||
@ -927,7 +928,7 @@ void writeDataPhaseSD(SCSI_DEVICE *dev, uint32_t adds, uint32_t len)
|
||||
LOG (" DI(SD) ");
|
||||
SCSI_PHASE_CHANGE(SCSI_PHASE_DATAIN);
|
||||
//Bus settle delay 400ns, file.seek() measured at over 1000ns.
|
||||
uint64_t pos = (uint64_t)adds * dev->m_blocksize;
|
||||
uint64_t pos = (uint64_t)adds * dev->m_rawblocksize;
|
||||
dev->m_file->seekSet(pos);
|
||||
#ifdef XCVR
|
||||
TRANSCEIVER_IO_SET(vTR_DBP,TR_OUTPUT)
|
||||
@ -937,10 +938,10 @@ void writeDataPhaseSD(SCSI_DEVICE *dev, uint32_t adds, uint32_t len)
|
||||
for(uint32_t i = 0; i < len; i++) {
|
||||
// Asynchronous reads will make it faster ...
|
||||
m_resetJmp = false;
|
||||
dev->m_file->read(m_buf, dev->m_blocksize);
|
||||
dev->m_file->read(m_buf, dev->m_rawblocksize);
|
||||
enableResetJmp();
|
||||
|
||||
writeDataLoop(dev->m_blocksize, m_buf);
|
||||
writeDataLoop(dev->m_blocksize, &m_buf[dev->m_sector_offset]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1073,11 +1074,12 @@ void loop()
|
||||
m_lun = 0xff;
|
||||
SCSI_DEVICE *dev = (SCSI_DEVICE *)0; // HDD image for current SCSI-ID, LUN
|
||||
|
||||
do {} while( !SCSI_IN(vBSY) || SCSI_IN(vRST));
|
||||
do {} while( SCSI_IN(vBSY) || !SCSI_IN(vSEL) || SCSI_IN(vRST));
|
||||
//do {} while( !SCSI_IN(vBSY) || SCSI_IN(vRST));
|
||||
// We're in ARBITRATION
|
||||
//LOG(" A:"); LOGHEX(readIO()); LOG(" ");
|
||||
|
||||
do {} while( SCSI_IN(vBSY) || !SCSI_IN(vSEL) || SCSI_IN(vRST));
|
||||
//do {} while( SCSI_IN(vBSY) || !SCSI_IN(vSEL) || SCSI_IN(vRST));
|
||||
//LOG(" S:"); LOGHEX(readIO()); LOG(" ");
|
||||
// We're in SELECTION
|
||||
|
||||
@ -1368,6 +1370,7 @@ byte onReadCapacity(SCSI_DEVICE *dev, const byte *cdb)
|
||||
(byte)(dev->m_blocksize >> 8),
|
||||
(byte)(dev->m_blocksize)
|
||||
};
|
||||
|
||||
writeDataPhase(sizeof(buf), buf);
|
||||
return SCSI_STATUS_GOOD;
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ enum SCSI_DEVICE_TYPE
|
||||
// Put DB and DP in output mode
|
||||
#define SCSI_DB_OUTPUT() { PBREG->CRL=(PBREG->CRL &0xfffffff0)|DB_MODE_OUT; PBREG->CRH = 0x11111111*DB_MODE_OUT; }
|
||||
// Put DB and DP in input mode
|
||||
#define SCSI_DB_INPUT() { PBREG->CRL=(PBREG->CRL &0xfffffff0)|DB_MODE_IN ; PBREG->CRH = (uint32_t)0x11111111*DB_MODE_IN; }
|
||||
#define SCSI_DB_INPUT() { PBREG->CRL=(PBREG->CRL &0xfffffff0)|DB_MODE_IN ; PBREG->CRH = (uint32_t)(0x11111111*DB_MODE_IN); }
|
||||
|
||||
// HDDiamge file
|
||||
#define HDIMG_ID_POS 2 // Position to embed ID number
|
||||
@ -314,7 +314,7 @@ typedef __attribute__((aligned(4))) struct _SCSI_DEVICE
|
||||
FsFile *m_file; // File object
|
||||
uint64_t m_fileSize; // File size
|
||||
uint16_t m_blocksize; // SCSI BLOCK size
|
||||
uint16_t m_rawblocksize;
|
||||
uint16_t m_rawblocksize; // OPTICAL raw sector size
|
||||
uint8_t m_type; // SCSI device type
|
||||
uint32_t m_blockcount; // blockcount
|
||||
bool m_raw; // Raw disk
|
||||
@ -322,7 +322,7 @@ typedef __attribute__((aligned(4))) struct _SCSI_DEVICE
|
||||
uint8_t m_senseKey; // Sense key
|
||||
uint16_t m_additional_sense_code; // ASC/ASCQ
|
||||
bool m_mode2; // MODE2 CDROM
|
||||
uint8_t m_offset; // ISO offset for missing sync header
|
||||
uint8_t m_sector_offset; // optical sector offset for missing sync header
|
||||
} SCSI_DEVICE;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user