Renamed Adaptec 154x adapter source to Buslogic as now it emulates the Buslogic BT-540B SCSI adapter.
Moved CD-ROM read data buffer declaration and definitions to SCSI source files and headers, but still applying to IDE when needed. SCSI Read commands now return the correct sectors on callback. DMA bug fixes.
This commit is contained in:
@@ -4,13 +4,13 @@ CC = gcc.exe
|
||||
WINDRES = windres.exe
|
||||
CFLAGS = -O3 -march=native -mtune=native -fbranch-probabilities -fvpt -fpeel-loops -ftracer -fomit-frame-pointer -ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse -mstackrealign
|
||||
DFLAGS = -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign
|
||||
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o acerm3a.o aha154x.o ali1429.o amstrad.o cdrom-ioctl.o cdrom-iso.o \
|
||||
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o acerm3a.o ali1429.o amstrad.o buslogic.o cdrom-ioctl.o cdrom-iso.o \
|
||||
cdrom-null.o codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86.o compaq.o config.o cpu.o dac.o \
|
||||
device.o disc.o disc_86f.o disc_fdi.o disc_imd.o disc_img.o disc_random.o disc_td0.o dma.o fdc.o fdc37c665.o fdc37c932fr.o fdd.o fdi2raw.o gameport.o headland.o i430hx.o i430lx.o i430fx.o \
|
||||
i430nx.o i430vx.o i440fx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \
|
||||
keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o lpt.o mcr.o mem.o memregs.o model.o mouse.o mouse_ps2.o \
|
||||
mouse_serial.o ne2000.o neat.o nethandler.o nmi.o nvr.o olivetti_m24.o opti495.o pc.o pc87306.o pci.o pic.o piix.o pit.o ppi.o ps1.o rom.o rtc.o \
|
||||
scat.o scattergather.o scsi.o scsi_cdrom.o serial.o sis496.o sis85c471.o sio.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o \
|
||||
scat.o scsi.o scsi_cdrom.o serial.o sis496.o sis85c471.o sio.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o \
|
||||
sound_dbopl.o sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
|
||||
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o \
|
||||
soundopenal.o tandy_eeprom.o tandy_rom.o timer.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
|
||||
|
@@ -4,13 +4,13 @@ CC = gcc.exe
|
||||
WINDRES = windres.exe
|
||||
CFLAGS = -O3 -march=native -mtune=native -fbranch-probabilities -fvpt -fpeel-loops -ftracer -fomit-frame-pointer -ffast-math -msse -msse2 -msse3 -mssse3 -mfpmath=sse -mstackrealign
|
||||
DFLAGS = -O3 -fomit-frame-pointer -msse2
|
||||
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o acerm3a.o aha154x.o ali1429.o amstrad.o cdrom-ioctl.o cdrom-iso.o \
|
||||
OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o acerm3a.o ali1429.o amstrad.o buslogic.o cdrom-ioctl.o cdrom-iso.o \
|
||||
cdrom-null.o codegen.o codegen_ops.o codegen_timing_486.o codegen_timing_686.o codegen_timing_pentium.o codegen_timing_winchip.o codegen_x86-64.o compaq.o config.o cpu.o dac.o \
|
||||
device.o disc.o disc_86f.o disc_fdi.o disc_imd.o disc_img.o disc_random.o disc_td0.o dma.o fdc.o fdc37c665.o fdc37c932fr.o fdd.o fdi2raw.o gameport.o headland.o i430hx.o i430lx.o i430fx.o \
|
||||
i430nx.o i430vx.o i440fx.o ide.o intel.o intel_flash.o io.o jim.o joystick_ch_flightstick_pro.o joystick_standard.o joystick_sw_pad.o joystick_tm_fcs.o keyboard.o keyboard_amstrad.o keyboard_at.o \
|
||||
keyboard_olim24.o keyboard_pcjr.o keyboard_xt.o lpt.o mcr.o mem.o memregs.o model.o mouse.o mouse_ps2.o \
|
||||
mouse_serial.o ne2000.o neat.o nethandler.o nmi.o nvr.o olivetti_m24.o opti495.o pc.o pc87306.o pci.o pic.o piix.o pit.o ppi.o ps1.o rom.o rtc.o \
|
||||
scat.o scattergather.o scsi.o scsi_cdrom.o serial.o sis496.o sis85c471.o sio.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o \
|
||||
scat.o scsi.o scsi_cdrom.o serial.o sis496.o sis85c471.o sio.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o \
|
||||
sound_dbopl.o sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
|
||||
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o \
|
||||
soundopenal.o tandy_eeprom.o tandy_rom.o timer.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
|
||||
|
1302
src/aha154x.c
1302
src/aha154x.c
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
extern void AdaptecInit();
|
1573
src/buslogic.c
Normal file
1573
src/buslogic.c
Normal file
File diff suppressed because it is too large
Load Diff
1
src/buslogic.h
Normal file
1
src/buslogic.h
Normal file
@@ -0,0 +1 @@
|
||||
extern device_t BuslogicDevice;
|
12
src/dma.c
12
src/dma.c
@@ -565,9 +565,9 @@ int dma_channel_write(int channel, uint16_t val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t PageLengthReadWrite(uint32_t PhysAddress, size_t TotalSize)
|
||||
static uint32_t PageLengthReadWrite(uint32_t PhysAddress, uint32_t TotalSize)
|
||||
{
|
||||
size_t LengthSize;
|
||||
uint32_t LengthSize;
|
||||
uint32_t Page;
|
||||
|
||||
Page = PhysAddress & 4095;
|
||||
@@ -579,20 +579,20 @@ static size_t PageLengthReadWrite(uint32_t PhysAddress, size_t TotalSize)
|
||||
}
|
||||
|
||||
//DMA Bus Master Page Read/Write
|
||||
void DMAPageRead(uint32_t PhysAddress, void *DataRead, size_t TotalSize)
|
||||
void DMAPageRead(uint32_t PhysAddress, void *DataRead, uint32_t TotalSize)
|
||||
{
|
||||
uint32_t PageLen = PageLengthReadWrite(PhysAddress, TotalSize);
|
||||
memcpy(DataRead, &ram[PhysAddress], PageLen);
|
||||
DataRead -= PageLen;
|
||||
PageLen -= TotalSize;
|
||||
TotalSize += PageLen;
|
||||
}
|
||||
|
||||
void DMAPageWrite(uint32_t PhysAddress, const void *DataWrite, size_t TotalSize)
|
||||
void DMAPageWrite(uint32_t PhysAddress, const void *DataWrite, uint32_t TotalSize)
|
||||
{
|
||||
uint32_t PageLen = PageLengthReadWrite(PhysAddress, TotalSize);
|
||||
memcpy(&ram[PhysAddress], DataWrite, PageLen);
|
||||
DataWrite -= PageLen;
|
||||
PageLen -= TotalSize;
|
||||
TotalSize += PageLen;
|
||||
}
|
||||
|
||||
int dma_mode(int channel)
|
||||
|
@@ -19,5 +19,5 @@ void writedma2(uint8_t temp);
|
||||
int dma_channel_read(int channel);
|
||||
int dma_channel_write(int channel, uint16_t val);
|
||||
|
||||
void DMAPageRead(uint32_t PhysAddress, void *DataRead, size_t TotalSize);
|
||||
void DMAPageWrite(uint32_t PhysAddress, const void *DataWrite, size_t TotalSize);
|
||||
void DMAPageRead(uint32_t PhysAddress, void *DataRead, uint32_t TotalSize);
|
||||
void DMAPageWrite(uint32_t PhysAddress, const void *DataWrite, uint32_t TotalSize);
|
@@ -345,7 +345,7 @@ int driveempty[4];
|
||||
#define PCJR (romset == ROM_IBMPCJR)
|
||||
#define AMIBIOS (romset==ROM_AMI386SX || romset==ROM_AMI486 || romset == ROM_WIN486)
|
||||
|
||||
int GAMEBLASTER, GUS, SSI2001, voodoo_enabled, aha154x_enabled;
|
||||
int GAMEBLASTER, GUS, SSI2001, voodoo_enabled, buslogic_enabled;
|
||||
extern int AMSTRAD, AT, is286, is386, PCI, TANDY;
|
||||
|
||||
enum
|
||||
|
368
src/ide.c
368
src/ide.c
@@ -125,7 +125,6 @@ typedef struct IDE
|
||||
int spt,hpc;
|
||||
int tracks;
|
||||
int packetstatus;
|
||||
int cdpos,cdlen;
|
||||
uint8_t asc;
|
||||
int reset;
|
||||
FILE *hdfile;
|
||||
@@ -167,49 +166,6 @@ int ide_ter_enabled = 0;
|
||||
|
||||
uint8_t getstat(IDE *ide) { return ide->atastat; }
|
||||
|
||||
#define MSFtoLBA(m,s,f) ((((m*60)+s)*75)+f)
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t user_data[2048];
|
||||
uint8_t ecc[288];
|
||||
} m1_data_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t sub_header[8];
|
||||
uint8_t user_data[2328];
|
||||
} m2_data_t;
|
||||
|
||||
typedef union __attribute__((packed))
|
||||
{
|
||||
m1_data_t m1_data;
|
||||
m2_data_t m2_data;
|
||||
uint8_t raw_data[2352];
|
||||
} sector_data_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t sync[12];
|
||||
uint8_t header[4];
|
||||
sector_data_t data;
|
||||
uint8_t c2[296];
|
||||
uint8_t subchannel_raw[96];
|
||||
uint8_t subchannel_q[16];
|
||||
uint8_t subchannel_rw[96];
|
||||
} cdrom_sector_t;
|
||||
|
||||
typedef union __attribute__((packed))
|
||||
{
|
||||
cdrom_sector_t cdrom_sector;
|
||||
uint8_t buffer[2856];
|
||||
} sector_buffer_t;
|
||||
|
||||
sector_buffer_t cdrom_sector_buffer;
|
||||
|
||||
int cdrom_sector_type, cdrom_sector_flags;
|
||||
int cdrom_sector_size, cdrom_sector_ismsf;
|
||||
|
||||
int image_is_hdi(const char *s)
|
||||
{
|
||||
int i, len;
|
||||
@@ -1907,266 +1863,6 @@ static void atapi_sense_clear(int command, int ignore_ua)
|
||||
}
|
||||
}
|
||||
|
||||
static int cdrom_add_error_and_subchannel(uint8_t *b, int real_sector_type)
|
||||
{
|
||||
if ((cdrom_sector_flags & 0x06) == 0x02)
|
||||
{
|
||||
/* Add error flags. */
|
||||
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.c2, 294);
|
||||
cdrom_sector_size += 294;
|
||||
}
|
||||
else if ((cdrom_sector_flags & 0x06) == 0x04)
|
||||
{
|
||||
/* Add error flags. */
|
||||
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.c2, 296);
|
||||
cdrom_sector_size += 296;
|
||||
}
|
||||
else if ((cdrom_sector_flags & 0x06) == 0x06)
|
||||
{
|
||||
// pclog("Invalid error flags\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if (real_sector_type == 1)
|
||||
{ */
|
||||
if ((cdrom_sector_flags & 0x700) == 0x100)
|
||||
{
|
||||
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.subchannel_raw, 96);
|
||||
cdrom_sector_size += 96;
|
||||
}
|
||||
else if ((cdrom_sector_flags & 0x700) == 0x200)
|
||||
{
|
||||
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.subchannel_q, 16);
|
||||
cdrom_sector_size += 16;
|
||||
}
|
||||
else if ((cdrom_sector_flags & 0x700) == 0x400)
|
||||
{
|
||||
memcpy(b + cdrom_sector_size, cdrom_sector_buffer.cdrom_sector.subchannel_rw, 96);
|
||||
cdrom_sector_size += 96;
|
||||
}
|
||||
else if (((cdrom_sector_flags & 0x700) == 0x300) || ((cdrom_sector_flags & 0x700) > 0x400))
|
||||
{
|
||||
// pclog("Invalid subchannel data flags\n");
|
||||
return 0;
|
||||
}
|
||||
// }
|
||||
|
||||
// pclog("CD-ROM sector size after processing: %i (%i, %i) [%04X]\n", cdrom_sector_size, cdrom_sector_type, real_sector_type, cdrom_sector_flags);
|
||||
|
||||
return cdrom_sector_size;
|
||||
}
|
||||
|
||||
static int cdrom_LBAtoMSF_accurate(IDE *ide)
|
||||
{
|
||||
int temp_pos;
|
||||
int m, s, f;
|
||||
|
||||
temp_pos = ide->cdpos + 150;
|
||||
f = temp_pos % 75;
|
||||
temp_pos -= f;
|
||||
temp_pos /= 75;
|
||||
s = temp_pos % 60;
|
||||
temp_pos -= s;
|
||||
temp_pos /= 60;
|
||||
m = temp_pos;
|
||||
|
||||
return ((m << 16) | (s << 8) | f);
|
||||
}
|
||||
|
||||
static int cdrom_read_data(IDE *ide, uint8_t *buffer)
|
||||
{
|
||||
int real_sector_type;
|
||||
uint8_t *b;
|
||||
uint8_t *temp_b;
|
||||
int is_audio;
|
||||
int real_pos;
|
||||
|
||||
b = temp_b = buffer;
|
||||
|
||||
if (cdrom_sector_ismsf)
|
||||
{
|
||||
real_pos = cdrom_LBAtoMSF_accurate(ide);
|
||||
}
|
||||
else
|
||||
{
|
||||
real_pos = ide->cdpos;
|
||||
}
|
||||
|
||||
memset(cdrom_sector_buffer.buffer, 0, 2856);
|
||||
|
||||
// is_audio = cdrom->is_track_audio(real_pos, cdrom_sector_ismsf);
|
||||
real_sector_type = cdrom->sector_data_type(real_pos, cdrom_sector_ismsf);
|
||||
// pclog("Sector type: %i\n", real_sector_type);
|
||||
|
||||
if ((cdrom_sector_type > 0) && (cdrom_sector_type < 6))
|
||||
{
|
||||
if (real_sector_type != cdrom_sector_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (cdrom_sector_type == 6)
|
||||
{
|
||||
/* READ (6), READ (10), READ (12) */
|
||||
if ((real_sector_type != 2) && (real_sector_type != 4))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cdrom_sector_flags & 0xf0)) /* 0x00 and 0x08 are illegal modes */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cdrom->readsector_raw(cdrom_sector_buffer.buffer, real_pos, cdrom_sector_ismsf);
|
||||
|
||||
if (real_sector_type == 1)
|
||||
{
|
||||
memcpy(b, cdrom_sector_buffer.buffer, 2352);
|
||||
cdrom_sector_size = 2352;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((cdrom_sector_flags & 0x18) == 0x08) /* EDC/ECC without user data is an illegal mode */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cdrom_sector_size = 0;
|
||||
|
||||
if (cdrom_sector_flags & 0x80) /* Sync */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.sync, 12);
|
||||
cdrom_sector_size += 12;
|
||||
temp_b += 12;
|
||||
}
|
||||
if (cdrom_sector_flags & 0x20) /* Header */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.header, 4);
|
||||
cdrom_sector_size += 4;
|
||||
temp_b += 4;
|
||||
}
|
||||
|
||||
if (real_sector_type == 2)
|
||||
{
|
||||
/* Mode 1 sector, expected type is 1 type. */
|
||||
if (cdrom_sector_flags & 0x40) /* Sub-header */
|
||||
{
|
||||
if (!(cdrom_sector_flags & 0x10)) /* No user data */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m1_data.user_data, 8);
|
||||
cdrom_sector_size += 8;
|
||||
temp_b += 8;
|
||||
}
|
||||
}
|
||||
if (cdrom_sector_flags & 0x10) /* User data */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m1_data.user_data, 2048);
|
||||
cdrom_sector_size += 2048;
|
||||
temp_b += 2048;
|
||||
}
|
||||
if (cdrom_sector_flags & 0x08) /* EDC/ECC */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m1_data.ecc, 288);
|
||||
cdrom_sector_size += 288;
|
||||
temp_b += 288;
|
||||
}
|
||||
}
|
||||
else if (real_sector_type == 3)
|
||||
{
|
||||
/* Mode 2 sector, non-XA mode. */
|
||||
if (cdrom_sector_flags & 0x40) /* Sub-header */
|
||||
{
|
||||
if (!(cdrom_sector_flags & 0x10)) /* No user data */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.sub_header, 8);
|
||||
cdrom_sector_size += 8;
|
||||
temp_b += 8;
|
||||
}
|
||||
}
|
||||
if (cdrom_sector_flags & 0x10) /* User data */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.sub_header, 2328);
|
||||
cdrom_sector_size += 8;
|
||||
temp_b += 8;
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.user_data, 2328);
|
||||
cdrom_sector_size += 2328;
|
||||
temp_b += 2328;
|
||||
}
|
||||
}
|
||||
else if (real_sector_type == 4)
|
||||
{
|
||||
/* Mode 2 sector, XA Form 1 mode */
|
||||
if ((cdrom_sector_flags & 0xf0) == 0x30)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (((cdrom_sector_flags & 0xf8) >= 0xa8) && ((cdrom_sector_flags & 0xf8) <= 0xd8))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (cdrom_sector_flags & 0x40) /* Sub-header */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.sub_header, 8);
|
||||
cdrom_sector_size += 8;
|
||||
temp_b += 8;
|
||||
}
|
||||
if (cdrom_sector_flags & 0x10) /* User data */
|
||||
{
|
||||
if ((cdrom_sector_flags & 0xf0) == 0x10)
|
||||
{
|
||||
/* The data is alone, include sub-header. */
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.sub_header, 8);
|
||||
cdrom_sector_size += 8;
|
||||
temp_b += 8;
|
||||
}
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.user_data, 2040);
|
||||
cdrom_sector_size += 2040;
|
||||
temp_b += 2040;
|
||||
}
|
||||
if (cdrom_sector_flags & 0x08) /* EDC/ECC */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.user_data + 2040, 288);
|
||||
cdrom_sector_size += 288;
|
||||
temp_b += 288;
|
||||
}
|
||||
}
|
||||
else if (real_sector_type == 5)
|
||||
{
|
||||
/* Mode 2 sector, XA Form 2 mode */
|
||||
if ((cdrom_sector_flags & 0xf0) == 0x30)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (((cdrom_sector_flags & 0xf8) >= 0xa8) || ((cdrom_sector_flags & 0xf8) <= 0xd8))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/* Mode 2 sector, XA Form 1 mode */
|
||||
if (cdrom_sector_flags & 0x40) /* Sub-header */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.sub_header, 8);
|
||||
cdrom_sector_size += 8;
|
||||
temp_b += 8;
|
||||
}
|
||||
if (cdrom_sector_flags & 0x10) /* User data */
|
||||
{
|
||||
memcpy(temp_b, cdrom_sector_buffer.cdrom_sector.data.m2_data.user_data, 2328);
|
||||
cdrom_sector_size += 2328;
|
||||
temp_b += 2328;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// pclog("CD-ROM sector size: %i (%i, %i) [%04X]\n", cdrom_sector_size, cdrom_sector_type, real_sector_type, cdrom_sector_flags);
|
||||
return cdrom_add_error_and_subchannel(b, real_sector_type);
|
||||
}
|
||||
|
||||
static void atapicommand(int ide_board)
|
||||
{
|
||||
IDE *ide = &ide_drives[cur_ide[ide_board]];
|
||||
@@ -2202,7 +1898,7 @@ static void atapicommand(int ide_board)
|
||||
#endif
|
||||
|
||||
msf=idebufferb[1]&2;
|
||||
ide->cdlen=0;
|
||||
SectorLen=0;
|
||||
|
||||
if (cdrom->medium_changed())
|
||||
{
|
||||
@@ -2412,18 +2108,18 @@ static void atapicommand(int ide_board)
|
||||
// pclog("Read CD : start LBA %02X%02X%02X%02X Length %02X%02X%02X Flags %02X\n",idebufferb[2],idebufferb[3],idebufferb[4],idebufferb[5],idebufferb[6],idebufferb[7],idebufferb[8],idebufferb[9]);
|
||||
if (idebufferb[0] == GPCMD_READ_CD_MSF)
|
||||
{
|
||||
ide->cdpos=MSFtoLBA(idebufferb[3],idebufferb[4],idebufferb[5]);
|
||||
ide->cdlen=MSFtoLBA(idebufferb[6],idebufferb[7],idebufferb[8]);
|
||||
SectorLBA=MSFtoLBA(idebufferb[3],idebufferb[4],idebufferb[5]);
|
||||
SectorLen=MSFtoLBA(idebufferb[6],idebufferb[7],idebufferb[8]);
|
||||
|
||||
ide->cdlen -= ide->cdpos;
|
||||
ide->cdlen++;
|
||||
SectorLen -= SectorLBA;
|
||||
SectorLen++;
|
||||
|
||||
cdrom_sector_ismsf = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ide->cdlen=(idebufferb[6]<<16)|(idebufferb[7]<<8)|idebufferb[8];
|
||||
ide->cdpos=(idebufferb[2]<<24)|(idebufferb[3]<<16)|(idebufferb[4]<<8)|idebufferb[5];
|
||||
SectorLen=(idebufferb[6]<<16)|(idebufferb[7]<<8)|idebufferb[8];
|
||||
SectorLBA=(idebufferb[2]<<24)|(idebufferb[3]<<16)|(idebufferb[4]<<8)|idebufferb[5];
|
||||
|
||||
cdrom_sector_ismsf = 0;
|
||||
}
|
||||
@@ -2431,7 +2127,7 @@ static void atapicommand(int ide_board)
|
||||
cdrom_sector_type = (idebufferb[1] >> 2) & 7;
|
||||
cdrom_sector_flags = idebufferb[9] || (((uint32_t) idebufferb[10]) << 8);
|
||||
|
||||
if (ide->cdpos > (cdrom->size() - 1))
|
||||
if (SectorLBA > (cdrom->size() - 1))
|
||||
{
|
||||
pclog("Trying to read beyond the end of disc\n");
|
||||
ide->atastat = READY_STAT | ERR_STAT; /*CHECK CONDITION*/
|
||||
@@ -2446,7 +2142,7 @@ static void atapicommand(int ide_board)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = cdrom_read_data(ide, idebufferb);
|
||||
ret = cdrom_read_data(idebufferb);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
@@ -2466,9 +2162,9 @@ static void atapicommand(int ide_board)
|
||||
readflash=1;
|
||||
#endif
|
||||
|
||||
ide->cdpos++;
|
||||
ide->cdlen--;
|
||||
if (ide->cdlen >= 0)
|
||||
SectorLBA++;
|
||||
SectorLen--;
|
||||
if (SectorLen >= 0)
|
||||
ide->packetstatus = ATAPI_STATUS_READCD;
|
||||
else
|
||||
ide->packetstatus = ATAPI_STATUS_DATA;
|
||||
@@ -2487,21 +2183,21 @@ static void atapicommand(int ide_board)
|
||||
|
||||
if (idebufferb[0] == GPCMD_READ_6)
|
||||
{
|
||||
ide->cdlen=idebufferb[4];
|
||||
ide->cdpos=((((uint32_t) idebufferb[1]) & 0x1f)<<16)|(((uint32_t) idebufferb[2])<<8)|((uint32_t) idebufferb[3]);
|
||||
SectorLen=idebufferb[4];
|
||||
SectorLBA=((((uint32_t) idebufferb[1]) & 0x1f)<<16)|(((uint32_t) idebufferb[2])<<8)|((uint32_t) idebufferb[3]);
|
||||
}
|
||||
else if (idebufferb[0] == GPCMD_READ_10)
|
||||
{
|
||||
ide->cdlen=(idebufferb[7]<<8)|idebufferb[8];
|
||||
ide->cdpos=(idebufferb[2]<<24)|(idebufferb[3]<<16)|(idebufferb[4]<<8)|idebufferb[5];
|
||||
SectorLen=(idebufferb[7]<<8)|idebufferb[8];
|
||||
SectorLBA=(idebufferb[2]<<24)|(idebufferb[3]<<16)|(idebufferb[4]<<8)|idebufferb[5];
|
||||
}
|
||||
else
|
||||
{
|
||||
ide->cdlen=(((uint32_t) idebufferb[6])<<24)|(((uint32_t) idebufferb[7])<<16)|(((uint32_t) idebufferb[8])<<8)|((uint32_t) idebufferb[9]);
|
||||
ide->cdpos=(((uint32_t) idebufferb[2])<<24)|(((uint32_t) idebufferb[3])<<16)|(((uint32_t) idebufferb[4])<<8)|((uint32_t) idebufferb[5]);
|
||||
SectorLen=(((uint32_t) idebufferb[6])<<24)|(((uint32_t) idebufferb[7])<<16)|(((uint32_t) idebufferb[8])<<8)|((uint32_t) idebufferb[9]);
|
||||
SectorLBA=(((uint32_t) idebufferb[2])<<24)|(((uint32_t) idebufferb[3])<<16)|(((uint32_t) idebufferb[4])<<8)|((uint32_t) idebufferb[5]);
|
||||
}
|
||||
|
||||
if (ide->cdpos > (cdrom->size() - 1))
|
||||
if (SectorLBA > (cdrom->size() - 1))
|
||||
{
|
||||
pclog("Trying to read beyond the end of disc\n");
|
||||
ide->atastat = READY_STAT | ERR_STAT; /*CHECK CONDITION*/
|
||||
@@ -2516,7 +2212,7 @@ static void atapicommand(int ide_board)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ide->cdlen)
|
||||
if (!SectorLen)
|
||||
{
|
||||
// pclog("All done - callback set\n");
|
||||
ide->packetstatus = ATAPI_STATUS_COMPLETE;
|
||||
@@ -2527,7 +2223,7 @@ static void atapicommand(int ide_board)
|
||||
cdrom_sector_type = 6;
|
||||
cdrom_sector_flags = 0x10;
|
||||
|
||||
ret = cdrom_read_data(ide, idebufferb);
|
||||
ret = cdrom_read_data(idebufferb);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
@@ -2544,9 +2240,9 @@ static void atapicommand(int ide_board)
|
||||
#ifndef RPCEMU_IDE
|
||||
readflash=1;
|
||||
#endif
|
||||
ide->cdpos++;
|
||||
ide->cdlen--;
|
||||
if (ide->cdlen >= 0)
|
||||
SectorLBA++;
|
||||
SectorLen--;
|
||||
if (SectorLen >= 0)
|
||||
ide->packetstatus = ATAPI_STATUS_READCD;
|
||||
else
|
||||
ide->packetstatus = ATAPI_STATUS_DATA;
|
||||
@@ -2564,15 +2260,15 @@ static void atapicommand(int ide_board)
|
||||
}
|
||||
else
|
||||
{
|
||||
ide->cdlen=(idebufferb[7]<<8)|idebufferb[8];
|
||||
ide->cdpos=(idebufferb[2]<<24)|(idebufferb[3]<<16)|(idebufferb[4]<<8)|idebufferb[5];
|
||||
SectorLen=(idebufferb[7]<<8)|idebufferb[8];
|
||||
SectorLBA=(idebufferb[2]<<24)|(idebufferb[3]<<16)|(idebufferb[4]<<8)|idebufferb[5];
|
||||
if (msf)
|
||||
{
|
||||
real_pos = cdrom_LBAtoMSF_accurate(ide);
|
||||
}
|
||||
else
|
||||
{
|
||||
real_pos = ide->cdpos;
|
||||
real_pos = SectorLBA;
|
||||
}
|
||||
idebufferb[4] = (real_pos >> 24);
|
||||
idebufferb[5] = ((real_pos >> 16) & 0xff);
|
||||
@@ -3200,24 +2896,24 @@ static void callreadcd(IDE *ide)
|
||||
int ret;
|
||||
|
||||
ide_irq_lower(ide);
|
||||
if (ide->cdlen<=0)
|
||||
if (SectorLen<=0)
|
||||
{
|
||||
// pclog("All done - callback set\n");
|
||||
ide->packetstatus = ATAPI_STATUS_COMPLETE;
|
||||
idecallback[ide->board]=20*IDE_TIME;
|
||||
return;
|
||||
}
|
||||
// pclog("Continue readcd! %i blocks left\n",ide->cdlen);
|
||||
// pclog("Continue readcd! %i blocks left\n",SectorLen);
|
||||
ide->atastat = BUSY_STAT;
|
||||
|
||||
ret = cdrom_read_data(ide, (uint8_t *) ide->buffer);
|
||||
ret = cdrom_read_data((uint8_t *) ide->buffer);
|
||||
|
||||
#ifndef RPCEMU_IDE
|
||||
readflash=1;
|
||||
#endif
|
||||
|
||||
ide->cdpos++;
|
||||
ide->cdlen--;
|
||||
SectorLBA++;
|
||||
SectorLen--;
|
||||
ide->packetstatus = ATAPI_STATUS_READCD;
|
||||
ide->cylinder=cdrom_sector_size;
|
||||
ide->secount=2;
|
||||
|
20
src/pc.c
20
src/pc.c
@@ -23,7 +23,7 @@
|
||||
#include "fdd.h"
|
||||
#include "gameport.h"
|
||||
#include "sound_gus.h"
|
||||
#include "aha154x.h"
|
||||
#include "buslogic.h"
|
||||
#include "cdrom.h"
|
||||
#include "scsi.h"
|
||||
#include "ide.h"
|
||||
@@ -292,10 +292,10 @@ void initpc(int argc, char *argv[])
|
||||
loadnvr();
|
||||
sound_init();
|
||||
resetide();
|
||||
if (aha154x_enabled)
|
||||
if (buslogic_enabled)
|
||||
{
|
||||
SCSIReset(&ScsiDrives[scsi_cdrom_id], scsi_cdrom_id);
|
||||
AdaptecInit(scsi_cdrom_id);
|
||||
SCSIReset(scsi_cdrom_id);
|
||||
device_add(&BuslogicDevice);
|
||||
}
|
||||
|
||||
if ((cdrom_drive == -1) || (cdrom_drive == 0))
|
||||
@@ -419,11 +419,11 @@ void resetpchard()
|
||||
|
||||
resetide();
|
||||
|
||||
if (aha154x_enabled)
|
||||
if (buslogic_enabled)
|
||||
{
|
||||
SCSIReset(&ScsiDrives[scsi_cdrom_id], scsi_cdrom_id);
|
||||
AdaptecInit(scsi_cdrom_id);
|
||||
}
|
||||
SCSIReset(scsi_cdrom_id);
|
||||
device_add(&BuslogicDevice);
|
||||
}
|
||||
|
||||
loadnvr();
|
||||
|
||||
@@ -626,7 +626,7 @@ void loadconfig(char *fn)
|
||||
GUS = config_get_int(NULL, "gus", 0);
|
||||
SSI2001 = config_get_int(NULL, "ssi2001", 0);
|
||||
voodoo_enabled = config_get_int(NULL, "voodoo", 0);
|
||||
aha154x_enabled = config_get_int(NULL, "aha154x", 0);
|
||||
buslogic_enabled = config_get_int(NULL, "buslogic", 0);
|
||||
|
||||
scsi_base = config_get_int(NULL, "scsi_base", 0x330);
|
||||
scsi_irq = config_get_int(NULL, "scsi_irq", 11);
|
||||
@@ -814,7 +814,7 @@ void saveconfig()
|
||||
config_set_int(NULL, "gus", GUS);
|
||||
config_set_int(NULL, "ssi2001", SSI2001);
|
||||
config_set_int(NULL, "voodoo", voodoo_enabled);
|
||||
config_set_int(NULL, "aha154x", aha154x_enabled);
|
||||
config_set_int(NULL, "buslogic", buslogic_enabled);
|
||||
|
||||
config_set_int(NULL, "scsi_base", scsi_base);
|
||||
config_set_int(NULL, "scsi_irq", scsi_irq);
|
||||
|
149
src/scsi.c
149
src/scsi.c
@@ -1,4 +1,4 @@
|
||||
/* Copyright holders: SA1988
|
||||
/* Copyright holders: SA1988, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*SCSI layer emulation*/
|
||||
@@ -11,98 +11,101 @@
|
||||
#include "cdrom.h"
|
||||
#include "scsi.h"
|
||||
|
||||
int ScsiCallback[7] = {0,0,0,0,0,0,0};
|
||||
#include "timer.h"
|
||||
|
||||
int SCSICallback[7] = {0,0,0,0,0,0,0};
|
||||
uint8_t scsi_cdrom_id = 3; /*common setting*/
|
||||
|
||||
void SCSIQueryResidual(SCSI *Scsi, uint32_t *Residual)
|
||||
//Get the transfer length of the command
|
||||
void SCSIGetLength(uint8_t id, int *datalen)
|
||||
{
|
||||
*Residual = ScsiStatus == SCSI_STATUS_OK ? 0 : Scsi->SegmentData.Length;
|
||||
*datalen = SCSIDevices[id].CmdBufferLength;
|
||||
}
|
||||
|
||||
static uint32_t SCSICopyFromBuffer(uint32_t OffDst, SGBUF *SegmentBuffer,
|
||||
uint32_t Copy)
|
||||
//Execute SCSI command
|
||||
void SCSIExecCommand(uint8_t id, uint8_t *cdb)
|
||||
{
|
||||
const SGSEG *SegmentArray = SegmentBuffer->SegmentPtr;
|
||||
unsigned SegmentNum = SegmentBuffer->SegmentNum;
|
||||
uint32_t Copied = 0;
|
||||
SCSICDROM_Command(id, cdb);
|
||||
}
|
||||
|
||||
//Read pending data from the resulting SCSI command
|
||||
void SCSIReadData(uint8_t id, uint8_t *cdb, uint8_t *data, int datalen)
|
||||
{
|
||||
SCSICDROM_ReadData(id, cdb, data, datalen);
|
||||
}
|
||||
|
||||
//Write pending data to the resulting SCSI command
|
||||
void SCSIWriteData(uint8_t id, uint8_t *cdb, uint8_t *data, int datalen)
|
||||
{
|
||||
SCSICDROM_WriteData(id, cdb, data, datalen);
|
||||
}
|
||||
|
||||
/////
|
||||
void SCSIDMAResetPosition(uint8_t Id)
|
||||
{
|
||||
//Reset position in memory after reaching the
|
||||
SCSIDevices[Id].pos = 0;
|
||||
}
|
||||
|
||||
//Read data from buffer with given position in buffer memory
|
||||
void SCSIRead(uint8_t Id, uint32_t len_size)
|
||||
{
|
||||
if (!len_size) //If there's no data, don't try to do anything.
|
||||
return;
|
||||
|
||||
SGBUF SegmentBuffer2;
|
||||
SegmentBufferInit(&SegmentBuffer2, SegmentArray, SegmentNum);
|
||||
|
||||
SegmentBufferAdvance(&SegmentBuffer2, OffDst);
|
||||
Copied = SegmentBufferCopy(&SegmentBuffer2, SegmentBuffer, Copy);
|
||||
|
||||
return Copied;
|
||||
}
|
||||
|
||||
static uint32_t SCSICopyToBuffer(uint32_t OffSrc, SGBUF *SegmentBuffer,
|
||||
uint32_t Copy)
|
||||
{
|
||||
const SGSEG *SegmentArray = SegmentBuffer->SegmentPtr;
|
||||
unsigned SegmentNum = SegmentBuffer->SegmentNum;
|
||||
uint32_t Copied = 0;
|
||||
int c;
|
||||
|
||||
SGBUF SegmentBuffer2;
|
||||
SegmentBufferInit(&SegmentBuffer2, SegmentArray, SegmentNum);
|
||||
|
||||
SegmentBufferAdvance(&SegmentBuffer2, OffSrc);
|
||||
Copied = SegmentBufferCopy(&SegmentBuffer2, SegmentBuffer, Copy);
|
||||
|
||||
return Copied;
|
||||
}
|
||||
|
||||
void SCSIWriteTransfer(SCSI *Scsi, uint8_t Id)
|
||||
{
|
||||
if ((Scsi->BufferPosition >= prefix_len + 4) && (page_flags[page_current] & PAGE_CHANGEABLE))
|
||||
for (c = 0; c <= len_size; c++) //Count as many bytes as the length of the buffer is requested
|
||||
{
|
||||
mode_pages_in[page_current][Scsi->BufferPosition - prefix_len - 4] = Scsi->SegmentData.Address[Scsi->BufferPosition - 2];
|
||||
mode_pages_in[page_current][Scsi->BufferPosition - prefix_len - 3] = Scsi->SegmentData.Address[Scsi->BufferPosition - 1];
|
||||
memcpy(SCSIDevices[Id].CmdBuffer, SCSIDevices[Id].CmdBuffer + SCSIDevices[Id].pos, len_size);
|
||||
SCSIDevices[Id].pos = c;
|
||||
|
||||
//pclog("SCSI Read: position at %i\n", SCSIDevices[Id].pos);
|
||||
}
|
||||
SGBUF SegmentBuffer;
|
||||
SCSICopyToBuffer(Scsi->SegmentData.Length, &SegmentBuffer, 1);
|
||||
pfnIoRequestCopyToBuffer(0, &SegmentBuffer, Scsi->SegmentData.Length);
|
||||
}
|
||||
|
||||
void SCSIReadTransfer(SCSI *Scsi, uint8_t Id)
|
||||
//Write data to buffer with given position in buffer memory
|
||||
void SCSIWrite(uint8_t Id, uint32_t len_size)
|
||||
{
|
||||
SCSICDROM_ReadCallback(Scsi, Id);
|
||||
if (!len_size) //If there's no data, don't try to do anything.
|
||||
return;
|
||||
|
||||
SGBUF SegmentBuffer;
|
||||
SCSICopyFromBuffer(Scsi->SegmentData.Length, &SegmentBuffer, 1);
|
||||
pfnIoRequestCopyFromBuffer(0, &SegmentBuffer, Scsi->SegmentData.Length);
|
||||
}
|
||||
int c;
|
||||
|
||||
for (c = 0; c <= len_size; c++) //Count as many bytes as the length of the buffer is requested
|
||||
{
|
||||
memcpy(SCSIDevices[Id].CmdBuffer + SCSIDevices[Id].pos, SCSIDevices[Id].CmdBuffer, len_size);
|
||||
SCSIDevices[Id].pos = c;
|
||||
|
||||
//Mode Sense/Select stuff
|
||||
if ((SCSIDevices[Id].pos >= prefix_len+4) && (page_flags[page_current] & PAGE_CHANGEABLE))
|
||||
{
|
||||
mode_pages_in[page_current][SCSIDevices[Id].pos - prefix_len - 4] = SCSIDevices[Id].CmdBuffer[SCSIDevices[Id].pos - 2];
|
||||
mode_pages_in[page_current][SCSIDevices[Id].pos - prefix_len - 3] = SCSIDevices[Id].CmdBuffer[SCSIDevices[Id].pos - 1];
|
||||
}
|
||||
|
||||
void SCSISendCommand(SCSI *Scsi, uint8_t Id, uint8_t *Cdb, uint8_t CdbLength, uint32_t DataBufferLength, uint8_t *SenseBufferPointer, uint8_t SenseBufferLength)
|
||||
//pclog("SCSI Write: position at %i\n", SCSIDevices[Id].pos);
|
||||
}
|
||||
}
|
||||
/////
|
||||
|
||||
//Initialization function for the SCSI layer
|
||||
void SCSIReset(uint8_t Id)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < CdbLength; i++)
|
||||
pclog("Cdb[%d]=0x%02X\n", i, Cdb[i]);
|
||||
|
||||
Scsi->CdbLength = CdbLength;
|
||||
|
||||
pclog("SCSI CD-ROM in ID %d\n", Id);
|
||||
SCSICDROM_RunCommand(Scsi, Id, Cdb, SenseBufferLength, SenseBufferPointer, DataBufferLength);
|
||||
}
|
||||
|
||||
void SCSIReset(SCSI *Scsi, uint8_t Id)
|
||||
{
|
||||
page_flags[GPMODE_CDROM_AUDIO_PAGE] &= 0xFD; /* Clear changed flag for CDROM AUDIO mode page. */
|
||||
memset(mode_pages_in[GPMODE_CDROM_AUDIO_PAGE], 0, 256); /* Clear the page itself. */
|
||||
|
||||
if (scsi_cdrom_enabled)
|
||||
|
||||
if (cdrom_enabled && scsi_cdrom_enabled)
|
||||
{
|
||||
if (cdrom_enabled)
|
||||
{
|
||||
Scsi->LunType = SCSI_CDROM;
|
||||
}
|
||||
SCSICallback[Id]=0;
|
||||
SCSIDevices[Id].LunType = SCSI_CDROM;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scsi->LunType = SCSI_NONE;
|
||||
}
|
||||
|
||||
pfnIoRequestCopyFromBuffer = SCSICopyFromBuffer;
|
||||
pfnIoRequestCopyToBuffer = SCSICopyToBuffer;
|
||||
|
||||
SCSIDevices[Id].LunType = SCSI_NONE;
|
||||
}
|
||||
|
||||
page_flags[GPMODE_CDROM_AUDIO_PAGE] &= ~PAGE_CHANGED;
|
||||
}
|
||||
|
||||
SCSISense.UnitAttention = 0;
|
||||
}
|
||||
|
127
src/scsi.h
127
src/scsi.h
@@ -4,7 +4,11 @@
|
||||
#ifndef __SCSI_H__
|
||||
#define __SCSI_H__
|
||||
|
||||
#include "scattergather.h"
|
||||
//#include "scattergather.h"
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
#define SCSI_TIME (5 * 100 * (1 << TIMER_SHIFT))
|
||||
|
||||
/* SCSI Commands */
|
||||
#define GPCMD_TEST_UNIT_READY 0x00
|
||||
@@ -138,6 +142,8 @@
|
||||
#define MMC_PROFILE_HDDVD_RW_DL 0x005A
|
||||
#define MMC_PROFILE_INVALID 0xFFFF
|
||||
|
||||
#define WRITEDATA 0x10
|
||||
#define READDATA 8
|
||||
#define NONDATA 4
|
||||
#define CHECK_READY 2
|
||||
#define ALLOW_UA 1
|
||||
@@ -162,8 +168,12 @@ extern uint8_t page_current;
|
||||
uint32_t DataLength;
|
||||
uint32_t DataPointer;
|
||||
|
||||
extern uint8_t ScsiStatus;
|
||||
extern int ScsiCallback[7];
|
||||
int SectorLBA;
|
||||
int SectorLen;
|
||||
|
||||
extern uint8_t SCSIStatus;
|
||||
extern uint8_t SCSIPhase;
|
||||
extern int SCSICallback[7];
|
||||
extern uint8_t scsi_cdrom_id;
|
||||
|
||||
struct
|
||||
@@ -181,52 +191,81 @@ extern int prev_status;
|
||||
#define SCSI_HDD 1 /*not present yet*/
|
||||
#define SCSI_CDROM 2
|
||||
|
||||
// extern sector_buffer_t cdrom_sector_buffer;
|
||||
#define MSFtoLBA(m,s,f) ((((m*60)+s)*75)+f)
|
||||
|
||||
// extern int cdrom_sector_type, cdrom_sector_flags;
|
||||
// extern int cdrom_sector_size, cdrom_sector_ismsf;
|
||||
|
||||
typedef struct SCSI
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t Cdb[32];
|
||||
uint8_t CdbLength;
|
||||
SGBUF SegmentBuffer;
|
||||
int SectorLen;
|
||||
int SectorLba;
|
||||
int BufferLength;
|
||||
int BufferPosition;
|
||||
SGSEG SegmentData;
|
||||
uint8_t user_data[2048];
|
||||
uint8_t ecc[288];
|
||||
} m1_data_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t sub_header[8];
|
||||
uint8_t user_data[2328];
|
||||
} m2_data_t;
|
||||
|
||||
typedef union __attribute__((packed))
|
||||
{
|
||||
m1_data_t m1_data;
|
||||
m2_data_t m2_data;
|
||||
uint8_t raw_data[2352];
|
||||
} sector_data_t;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint8_t sync[12];
|
||||
uint8_t header[4];
|
||||
sector_data_t data;
|
||||
uint8_t c2[296];
|
||||
uint8_t subchannel_raw[96];
|
||||
uint8_t subchannel_q[16];
|
||||
uint8_t subchannel_rw[96];
|
||||
} cdrom_sector_t;
|
||||
|
||||
typedef union __attribute__((packed))
|
||||
{
|
||||
cdrom_sector_t cdrom_sector;
|
||||
uint8_t buffer[2856];
|
||||
} sector_buffer_t;
|
||||
|
||||
extern sector_buffer_t cdrom_sector_buffer;
|
||||
|
||||
extern int cdrom_sector_type, cdrom_sector_flags;
|
||||
extern int cdrom_sector_size, cdrom_sector_ismsf;
|
||||
|
||||
#define SCSI_PHASE_DATAOUT ( 0 )
|
||||
#define SCSI_PHASE_DATAIN ( 1 )
|
||||
#define SCSI_PHASE_COMMAND ( 2 )
|
||||
#define SCSI_PHASE_STATUS ( 3 )
|
||||
#define SCSI_PHASE_MESSAGE_OUT ( 6 )
|
||||
#define SCSI_PHASE_MESSAGE_IN ( 7 )
|
||||
#define SCSI_PHASE_BUS_FREE ( 8 )
|
||||
#define SCSI_PHASE_SELECT ( 9 )
|
||||
|
||||
#define BUFFER_LEN 262144
|
||||
|
||||
struct
|
||||
{
|
||||
uint32_t buffer_size;
|
||||
uint32_t pos;
|
||||
uint8_t *Cdb;
|
||||
uint8_t CmdBuffer[BUFFER_LEN];
|
||||
uint32_t CmdBufferLength;
|
||||
int LunType;
|
||||
uint8_t PacketStatus;
|
||||
int ReadCDCallback;
|
||||
int RequestSenseEnabled;
|
||||
void *p;
|
||||
} SCSI;
|
||||
uint32_t InitLength;
|
||||
} SCSIDevices[7];
|
||||
|
||||
SCSI ScsiDrives[7];
|
||||
extern void SCSIReset(uint8_t Id);
|
||||
|
||||
void SCSIQueryResidual(SCSI *Scsi, uint32_t *Residual);
|
||||
uint32_t SCSICDROMModeSense(uint8_t *buf, uint32_t pos, uint8_t type);
|
||||
uint8_t SCSICDROMSetProfile(uint8_t *buf, uint8_t *index, uint16_t profile);
|
||||
int SCSICDROMReadDVDStructure(int format, const uint8_t *packet, uint8_t *buf);
|
||||
uint32_t SCSICDROMEventStatus(uint8_t *buffer);
|
||||
void SCSICDROM_Insert();
|
||||
|
||||
void SCSISendCommand(SCSI *Scsi, uint8_t Id, uint8_t *Cdb, uint8_t CdbLength,
|
||||
uint32_t DataBufferLength, uint8_t *SenseBufferPointer,
|
||||
uint8_t SenseBufferLength);
|
||||
|
||||
uint32_t (*pfnIoRequestCopyFromBuffer)(uint32_t OffDst, SGBUF *SegmentBuffer,
|
||||
uint32_t Copy);
|
||||
uint32_t (*pfnIoRequestCopyToBuffer)(uint32_t OffSrc, SGBUF *SegmentBuffer,
|
||||
uint32_t Copy);
|
||||
void SCSIReadTransfer(SCSI *Scsi, uint8_t Id);
|
||||
void SCSIWriteTransfer(SCSI *Scsi, uint8_t Id);
|
||||
|
||||
extern void SCSIReset(SCSI *Scsi, uint8_t Id);
|
||||
|
||||
extern uint32_t SCSICDROMModeSense(uint8_t *buf, uint32_t pos, uint8_t type);
|
||||
extern uint8_t SCSICDROMSetProfile(uint8_t *buf, uint8_t *index, uint16_t profile);
|
||||
extern int SCSICDROMReadDVDStructure(int format, const uint8_t *packet, uint8_t *buf);
|
||||
extern uint32_t SCSICDROMEventStatus(uint8_t *buffer);
|
||||
|
||||
extern void SCSICDROM_ReadyHandler(int IsReady);
|
||||
extern void SCSICDROM_Insert();
|
||||
// extern int cdrom_add_error_and_subchannel(uint8_t *b, int real_sector_type);
|
||||
int cdrom_add_error_and_subchannel(uint8_t *b, int real_sector_type);
|
||||
int cdrom_LBAtoMSF_accurate();
|
||||
int cdrom_read_data(uint8_t *buffer);
|
||||
|
||||
#endif
|
2082
src/scsi_cdrom.c
2082
src/scsi_cdrom.c
File diff suppressed because it is too large
Load Diff
@@ -626,7 +626,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
|
||||
if (scsi_cdrom_enabled)
|
||||
CheckMenuItem(menu, IDM_CDROM_SCSI, MF_CHECKED);
|
||||
|
||||
if (aha154x_enabled)
|
||||
if (buslogic_enabled)
|
||||
CheckMenuItem(menu, IDM_SCSI_ENABLED, MF_CHECKED);
|
||||
|
||||
CheckMenuItem(menu, IDM_SCSI_BASE130, MF_UNCHECKED);
|
||||
@@ -1429,8 +1429,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||
}
|
||||
pause = 1;
|
||||
Sleep(100);
|
||||
aha154x_enabled ^= 1;
|
||||
CheckMenuItem(hmenu, IDM_SCSI_ENABLED, aha154x_enabled ? MF_CHECKED : MF_UNCHECKED);
|
||||
buslogic_enabled ^= 1;
|
||||
CheckMenuItem(hmenu, IDM_SCSI_ENABLED, buslogic_enabled ? MF_CHECKED : MF_UNCHECKED);
|
||||
saveconfig();
|
||||
resetpchard();
|
||||
pause = 0;
|
||||
|
Reference in New Issue
Block a user