More ide and scsi updates

This commit is contained in:
Dimitris Panokostas 2020-07-04 14:28:20 +02:00
parent 10b51595b0
commit e4f2c8d187
2 changed files with 159 additions and 72 deletions

View file

@ -91,6 +91,38 @@ void ata_parse_identity(uae_u8 *out, struct uaedev_config_info *uci, bool *lba,
}
}
bool ata_get_identity(struct ini_data *ini, uae_u8 *out, bool overwrite)
{
#ifdef AMIBERRY
return false;
#else
if (!out)
return false;
if (overwrite) {
uae_u8 *out2;
int len;
if (!ini_getdata(ini, _T("IDENTITY"), _T("DATA"), &out2, &len))
return false;
if (len == 512) {
memcpy(out, out2, 512);
}
xfree(out2);
}
int v;
if (ini_getval(ini, _T("IDENTITY"), _T("multiple_mode"), &v)) {
if (v) {
out[59 * 2 + 1] |= 1;
out[47 * 2 + 0] = 0;
out[47 * 2 + 1] = v;
} else {
out[59 * 2 + 1] &= ~1;
}
}
return true;
#endif
}
uae_u16 adide_decode_word(uae_u16 w)
{
uae_u16 o = 0;
@ -219,7 +251,7 @@ static void ql(uae_u8 *d, int o)
d[o + 7] = t;
}
static void ata_byteswapidentity(uae_u8 *d)
void ata_byteswapidentity(uae_u8 *d)
{
for (int i = 0; i < 512; i += 2)
{
@ -444,6 +476,31 @@ static void ide_identity_buffer(struct ide_hdf *ide)
if (!device_type)
device_type = 5; // CD
if (ata_get_identity(ide->hdhfd.hfd.geometry, ide->secbuf, true)) {
//if (ini_getval(ide->hdhfd.hfd.geometry, _T("IDENTITY"), _T("atapi"), &v)) {
// ide->atapi = v != 0;
// if (ide->atapi) {
// ide->atapi_device_type = 0;
// ini_getval(ide->hdhfd.hfd.geometry, _T("IDENTITY"), _T("atapi_type"), &ide->atapi_device_type);
// if (!ide->atapi_device_type)
// ide->atapi_device_type = 5;
// }
//}
if (!ide->byteswap) {
ata_byteswapidentity(ide->secbuf);
}
} else if (ide->hdhfd.hfd.ci.loadidentity && (ide->hdhfd.hfd.identity[0] || ide->hdhfd.hfd.identity[1])) {
memcpy(ide->secbuf, ide->hdhfd.hfd.identity, 512);
if (!ide->byteswap) {
ata_byteswapidentity(ide->secbuf);
}
real = true;
} else {
pw(ide, 0, atapi ? 0x80c0 | (device_type << 8) : (cf ? 0x848a : (1 << 6)));
pw(ide, 1, ide->hdhfd.cyls_def);
pw(ide, 2, 0xc837);
@ -502,9 +559,13 @@ static void ide_identity_buffer(struct ide_hdf *ide)
}
}
}
ata_get_identity(ide->hdhfd.hfd.geometry, ide->secbuf, false);
}
if (!real) {
v = ide->multiple_mode;
pwor(ide, 59, v > 0 ? 0x100 : 0);
}
if (!atapi && cf) {
pw(ide, 0, 0x848a);
} else if (!atapi && !cf) {
@ -521,6 +582,14 @@ static void ide_identify_drive (struct ide_hdf *ide)
ide_data_ready (ide);
ide->direction = 0;
ide_identity_buffer(ide);
if (ide->adide) {
for (int i = 0; i < 256; i++) {
uae_u16 w = (ide->secbuf[i * 2 + 0] << 8) | (ide->secbuf[i * 2 + 1] << 0);
uae_u16 we = adide_decode_word(w);
ide->secbuf[i * 2 + 0] = we >> 8;
ide->secbuf[i * 2 + 1] = we >> 0;
}
}
}
static void set_signature (struct ide_hdf *ide)
@ -550,6 +619,11 @@ static void reset_device (struct ide_hdf *ide, bool both)
set_signature (ide->pair);
}
void ide_reset_device(struct ide_hdf* ide)
{
reset_device(ide, true);
}
static void ide_execute_drive_diagnostics (struct ide_hdf *ide, bool irq)
{
reset_device (ide, irq);
@ -616,9 +690,11 @@ static void ide_set_features (struct ide_hdf *ide)
{
// 8-bit mode
case 1:
ide->mode_8bit = true;
ide_interrupt(ide);
break;
case 0x81:
ide->mode_8bit = false;
ide_interrupt(ide);
break;
// write cache
@ -1181,6 +1257,10 @@ uae_u16 ide_get_data(struct ide_hdf *ide)
{
return ide_get_data_2(ide, 1);
}
uae_u8 ide_get_data_8bit(struct ide_hdf *ide)
{
return (uae_u8)ide_get_data_2(ide, 0);
}
static void ide_put_data_2(struct ide_hdf *ide, uae_u16 v, int bussize)
{
@ -1225,6 +1305,10 @@ void ide_put_data(struct ide_hdf *ide, uae_u16 v)
{
ide_put_data_2(ide, v, 1);
}
void ide_put_data_8bit(struct ide_hdf *ide, uae_u8 v)
{
ide_put_data_2(ide, v, 0);
}
uae_u32 ide_read_reg (struct ide_hdf *ide, int ide_reg)
{
@ -1545,6 +1629,7 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct
ide->lba = true;
ide->uae_unitnum = ci->uae_unitnum;
gui_flicker_led (LED_HD, ide->uae_unitnum, -1);
ide->cd_unit_num = -1;
ide->media_type = ci->controller_media_type;
ide->ata_level = ci->unit_feature_level;
if (!ide->ata_level && (ide->hdhfd.size >= 4 * (uae_u64)0x40000000 || ide->media_type))

View file

@ -1450,8 +1450,8 @@ static void supra_do_dma(struct soft_scsi *ncr)
}
}
uae_u8 aic_bget_dma(struct soft_scsi *scsi, bool *phaseerr);
void aic_bput_dma(struct soft_scsi *scsi, uae_u8 v, bool *phaseerr);
static uae_u8 aic_bget_dma(struct soft_scsi *scsi, bool *phaseerr);
static void aic_bput_dma(struct soft_scsi *scsi, uae_u8 v, bool *phaseerr);
static void hardframe_do_dma(struct soft_scsi *ncr)
{
@ -1596,7 +1596,7 @@ static uae_u8 aic_bget_reg(struct soft_scsi *scsi)
return scsi->aic_reg & 15;
}
uae_u8 aic_bget_dma(struct soft_scsi *scsi, bool *phaseerr)
static uae_u8 aic_bget_dma(struct soft_scsi *scsi, bool *phaseerr)
{
struct raw_scsi *r = &scsi->rscsi;
if (!scsi->dma_direction)
@ -1706,7 +1706,7 @@ static void aic_bput_reg(struct soft_scsi *scsi, uae_u8 v)
scsi->aic_reg = v & 15;
}
void aic_bput_dma(struct soft_scsi *scsi, uae_u8 v, bool *phaseerr)
static void aic_bput_dma(struct soft_scsi *scsi, uae_u8 v, bool *phaseerr)
{
struct raw_scsi *r = &scsi->rscsi;
if (!scsi->dma_direction)
@ -5385,10 +5385,12 @@ uae_u8 x86_rt1000_bget(int portnum)
return v;
}
extern void x86_rt1000_bios(struct zfile*, struct romconfig *rc);
bool x86_rt1000_init(struct autoconfig_info *aci)
{
static const int parent[] = { ROMTYPE_A1060, ROMTYPE_A2088, ROMTYPE_A2088T, ROMTYPE_A2286, ROMTYPE_A2386, 0 };
aci->parent_romtype = parent;
scsi_add_reset();
if (!aci->doinit)
return true;