Added Adaptec AHA-1640 MCA SCSI adapter for IBM PS/2 Model 50+ only at the moment.

This commit is contained in:
TC1995
2017-05-14 16:46:15 +02:00
parent 5ba88cba30
commit bcc505e4b8
4 changed files with 152 additions and 19 deletions

View File

@@ -35,6 +35,7 @@ static SCSI_CARD scsi_cards[] = {
{ "None", "none", NULL },
{ "Adaptec AHA-1540B", "aha1540b", &aha1540b_device },
{ "Adaptec AHA-1542CF", "aha1542cf", &aha1542cf_device },
{ "Adaptec AHA-1640", "aha1640", &aha1640_device },
{ "BusLogic BT-542B", "bt542b", &buslogic_device },
{ "BusLogic BT-958D PCI", "bt958d", &buslogic_pci_device },
{ "", "", NULL }

View File

@@ -176,7 +176,6 @@ static uint16_t aha_ports[] = {
0x0130, 0x0134, 0x0000, 0x0000
};
/*
* Write data to the BIOS space.
*
@@ -258,7 +257,7 @@ aha_patch(uint8_t *romptr, uint16_t ioaddr)
/* Initialize AHA-154xNN-specific stuff. */
static void
aha154x_bios(uint16_t ioaddr, uint32_t memaddr, aha_info *aha)
aha154x_bios(uint16_t ioaddr, uint32_t memaddr, aha_info *aha, int irq, int dma)
{
uint32_t bios_size;
uint32_t bios_addr;
@@ -388,10 +387,11 @@ again:
/* Initialize the on-board EEPROM. */
memset(aha_eep, 0x00, EEP_SIZE);
aha_eep[0] = 7; /* SCSI ID 7 */
aha_eep[1] = 15-9; /* IRQ15 */
aha_eep[1] |= (6<<4); /* DMA6 */
aha_eep[2] = (EE2_HABIOS | /* BIOS Space Reserved */
EE2_SEEKRET); /* Immediate return on seek */
aha_eep[0] |= (0x10 | 0x20 | 0x40);
aha_eep[1] = irq-9; /* IRQ15 */
aha_eep[1] |= (dma<<4); /* DMA6 */
aha_eep[2] = (EE2_DYNSCAN | /* BIOS Space Reserved */
EE2_EXT1G | EE2_RMVOK); /* Immediate return on seek */
aha_eep[3] = SPEED_50; /* speed 5.0 MB/s */
aha_eep[6] = (EE6_TERM | /* host term enable */
EE6_RSTBUS); /* reset SCSI bus on boot */
@@ -843,6 +843,7 @@ typedef struct {
mem_mapping_t mmio_mapping;
aha_info aha;
int chip;
uint8_t pos_regs[8];
} aha_t;
#pragma pack(pop)
@@ -855,7 +856,8 @@ static aha_t *ResetDev;
enum {
CHIP_AHA154XB,
CHIP_AHA154XCF
CHIP_AHA154XCF,
CHIP_AHA1640
};
@@ -2175,6 +2177,32 @@ aha_cmd_cb(void *priv)
AHA_Callback += 50 * SCSI_TIME;
}
uint8_t aha_mca_read(int port, void *p)
{
aha_t *dev = (aha_t *)p;
return dev->pos_regs[port & 7];
}
static uint16_t aha_mca_addr[6] = {0x130, 0x134, 0x230, 0x234, 0x330, 0x334};
void aha_mca_write(int port, uint8_t val, void *p)
{
aha_t *dev = (aha_t *)p;
uint16_t addr;
if (port < 0x102)
return;
addr = aha_mca_addr[dev->pos_regs[4] & 7];
if ((dev->pos_regs[2] & 1) && !(val & 1))
io_removehandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev);
if (!(dev->pos_regs[2] & 1) && (val & 1))
io_sethandler(addr, 0x0004, aha_read, aha_readw, NULL, aha_write, aha_writew, NULL, dev);
dev->pos_regs[port & 7] = val;
}
static void *
aha_init(int chip, int has_bios)
@@ -2222,6 +2250,14 @@ aha_init(int chip, int has_bios)
}
}
if (dev->chip == CHIP_AHA1640)
{
pclog("Aha1640 initialized\n");
mca_add(aha_mca_read, aha_mca_write, dev);
dev->pos_regs[0] = 0x1F;
dev->pos_regs[1] = 0x0F;
}
timer_add(aha_reset_poll, &ResetCB, &ResetCB, dev);
timer_add(aha_cmd_cb, &AHA_Callback, &AHA_Callback, dev);
@@ -2231,7 +2267,7 @@ aha_init(int chip, int has_bios)
if (bios) {
/* Perform AHA-154xNN-specific initialization. */
aha154x_bios(dev->Base, bios_addr, &dev->aha);
aha154x_bios(dev->Base, bios_addr, &dev->aha, dev->Irq, dev->DmaChannel);
}
return(dev);
@@ -2251,6 +2287,12 @@ aha_154xCF_init(void)
return(aha_init(CHIP_AHA154XCF, 1));
}
static void *
aha_1640_init(void)
{
return(aha_init(CHIP_AHA1640, 1));
}
static void
aha_close(void *priv)
@@ -2359,6 +2401,77 @@ static device_config_t aha_154XCF_config[] = {
}
};
static device_config_t aha_1640_config[] = {
{
"addr", "Address", CONFIG_SELECTION, "", 0x330,
{
{
"0x330", 0x330
},
{
"0x334", 0x334
},
{
"0x230", 0x230
},
{
"0x234", 0x234
},
{
"0x130", 0x130
},
{
"0x134", 0x134
},
{
""
}
},
},
{
"irq", "IRQ", CONFIG_SELECTION, "", 10,
{
{
"IRQ 10", 10
},
{
"IRQ 11", 11
},
{
"IRQ 12", 12
},
{
"IRQ 14", 14
},
{
"IRQ 15", 15
},
{
""
}
},
},
{
"dma", "DMA channel", CONFIG_SELECTION, "", 6,
{
{
"DMA 5", 5
},
{
"DMA 6", 6
},
{
"DMA 7", 7
},
{
""
}
},
},
{
"", "", -1
}
};
device_t aha1540b_device = {
"Adaptec AHA-1540B",
@@ -2383,3 +2496,15 @@ device_t aha1542cf_device = {
NULL,
aha_154XCF_config
};
device_t aha1640_device = {
"Adaptec AHA-1640",
DEVICE_MCA,
aha_1640_init,
aha_close,
NULL,
NULL,
NULL,
NULL,
aha_1640_config
};

View File

@@ -12,6 +12,7 @@ typedef struct {
extern device_t aha1540b_device;
extern device_t aha1542cf_device;
extern device_t aha1640_device;
#endif /*SCSI_AHA154X_H*/

View File

@@ -1192,6 +1192,7 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
int c = 0;
int d = 0;
LPTSTR lptsTemp;
device_t *scsi_dev;
switch (message)
{
@@ -1210,21 +1211,26 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR
break;
}
settings_scsi_to_list[c] = d;
settings_scsi_to_list[c] = d;
if (scsi_card_available(c))
{
if (c == 0)
scsi_dev = scsi_card_getdevice(c);
if (!scsi_dev || (scsi_dev->flags & DEVICE_MCA) == (models[temp_model].flags & MODEL_MCA))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152));
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152));
}
else
{
mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
settings_list_to_scsi[d] = c;
d++;
}
else
{
mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
settings_list_to_scsi[d] = c;
d++;
}
c++;