DECchip 21040 emulation (only tested on Linux)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
extern const device_t dec_tulip_device;
|
||||
extern const device_t dec_tulip_21140_device;
|
||||
extern const device_t dec_tulip_21140_vpc_device;
|
||||
extern const device_t dec_tulip_21040_device;
|
||||
|
@@ -323,6 +323,9 @@ struct TULIPState {
|
||||
uint32_t mii_word;
|
||||
uint32_t mii_bitcnt;
|
||||
|
||||
/* 21040 ROM read address. */
|
||||
uint32_t rom_read_addr;
|
||||
|
||||
uint32_t current_rx_desc;
|
||||
uint32_t current_tx_desc;
|
||||
|
||||
@@ -666,6 +669,9 @@ tulip_mii(TULIPState *s)
|
||||
static uint32_t
|
||||
tulip_csr9_read(TULIPState *s)
|
||||
{
|
||||
if (s->device_info->local == 3) {
|
||||
return ((uint8_t*)nmc93cxx_eeprom_data(s->eeprom))[s->rom_read_addr++];
|
||||
}
|
||||
if (s->csr[9] & CSR9_SR) {
|
||||
if (nmc93cxx_eeprom_read(s->eeprom)) {
|
||||
s->csr[9] |= CSR9_SR_DO;
|
||||
@@ -698,6 +704,10 @@ tulip_read(uint32_t addr, void *opaque)
|
||||
break;
|
||||
|
||||
case CSR(12):
|
||||
if (s->device_info->local == 3) {
|
||||
data = 0;
|
||||
break;
|
||||
}
|
||||
/* Fake autocompletion complete until we have PHY emulation */
|
||||
data = 5 << CSR12_ANS_SHIFT;
|
||||
break;
|
||||
@@ -884,9 +894,11 @@ tulip_reset(void *priv)
|
||||
s->csr[13] = 0xffff0000;
|
||||
s->csr[14] = 0xffffffff;
|
||||
s->csr[15] = 0x8ff00000;
|
||||
if (s->device_info->local != 3) {
|
||||
s->subsys_id = eeprom_data[1];
|
||||
s->subsys_ven_id = eeprom_data[0];
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tulip_write(uint32_t addr, uint32_t data, void *opaque)
|
||||
@@ -955,12 +967,16 @@ tulip_write(uint32_t addr, uint32_t data, void *opaque)
|
||||
break;
|
||||
|
||||
case CSR(9):
|
||||
if (s->device_info->local != 3) {
|
||||
tulip_csr9_write(s, s->csr[9], data);
|
||||
/* don't clear MII read data */
|
||||
s->csr[9] &= CSR9_MDI;
|
||||
s->csr[9] |= (data & ~CSR9_MDI);
|
||||
tulip_mii(s);
|
||||
s->old_csr9 = s->csr[9];
|
||||
} else {
|
||||
s->rom_read_addr = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case CSR(10):
|
||||
@@ -978,6 +994,11 @@ tulip_write(uint32_t addr, uint32_t data, void *opaque)
|
||||
|
||||
case CSR(13):
|
||||
s->csr[13] = data;
|
||||
if (s->device_info->local == 3 && (data & 0x4)) {
|
||||
s->csr[13] = 0x8f01;
|
||||
s->csr[14] = 0xfffd;
|
||||
s->csr[15] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case CSR(14):
|
||||
@@ -1141,7 +1162,9 @@ tulip_pci_read(UNUSED(int func), int addr, void *priv)
|
||||
ret = 0x10;
|
||||
break;
|
||||
case 0x02:
|
||||
if (s->device_info->local)
|
||||
if (s->device_info->local == 3)
|
||||
ret = 0x02;
|
||||
else if (s->device_info->local)
|
||||
ret = 0x09;
|
||||
else
|
||||
ret = 0x19;
|
||||
@@ -1229,6 +1252,7 @@ tulip_pci_read(UNUSED(int func), int addr, void *priv)
|
||||
break;
|
||||
case 0x3E:
|
||||
case 0x3F:
|
||||
case 0x41:
|
||||
ret = s->pci_conf[addr & 0xff];
|
||||
break;
|
||||
}
|
||||
@@ -1319,6 +1343,7 @@ tulip_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv)
|
||||
return;
|
||||
case 0x3E:
|
||||
case 0x3F:
|
||||
case 0x41:
|
||||
s->pci_conf[addr & 0xff] = val;
|
||||
return;
|
||||
}
|
||||
@@ -1336,7 +1361,7 @@ nic_init(const device_t *info)
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
if (info->local) {
|
||||
if (info->local && info->local != 3) {
|
||||
s->bios_addr = 0xD0000;
|
||||
s->has_bios = device_get_config_int("bios");
|
||||
} else {
|
||||
@@ -1349,6 +1374,7 @@ nic_init(const device_t *info)
|
||||
|
||||
s->device_info = info;
|
||||
|
||||
if (info->local != 3) {
|
||||
/*Subsystem Vendor ID*/
|
||||
s->eeprom_data[0] = info->local ? 0x25 : 0x11;
|
||||
s->eeprom_data[1] = 0x10;
|
||||
@@ -1481,6 +1507,27 @@ nic_init(const device_t *info)
|
||||
|
||||
s->eeprom_data[126] = tulip_srom_crc(s->eeprom_data) & 0xff;
|
||||
s->eeprom_data[127] = tulip_srom_crc(s->eeprom_data) >> 8;
|
||||
} else {
|
||||
/* 21040 is supposed to only have MAC address in its serial ROM if Linux is correct. */
|
||||
memset(s->eeprom_data, 0, sizeof(s->eeprom_data));
|
||||
s->eeprom_data[0] = 0x00;
|
||||
s->eeprom_data[1] = 0x00;
|
||||
s->eeprom_data[2] = 0xF8;
|
||||
if (mac & 0xff000000) {
|
||||
/* Generate new local MAC. */
|
||||
s->eeprom_data[3] = random_generate();
|
||||
s->eeprom_data[4] = random_generate();
|
||||
s->eeprom_data[5] = random_generate();
|
||||
mac = (((int) s->eeprom_data[3]) << 16);
|
||||
mac |= (((int) s->eeprom_data[4]) << 8);
|
||||
mac |= ((int) s->eeprom_data[5]);
|
||||
device_set_config_mac("mac", mac);
|
||||
} else {
|
||||
s->eeprom_data[3] = (mac >> 16) & 0xff;
|
||||
s->eeprom_data[4] = (mac >> 8) & 0xff;
|
||||
s->eeprom_data[5] = (mac & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
params.nwords = 64;
|
||||
params.default_content = (uint16_t *) s->eeprom_data;
|
||||
@@ -1592,3 +1639,17 @@ const device_t dec_tulip_21140_vpc_device = {
|
||||
.force_redraw = NULL,
|
||||
.config = dec_tulip_21140_config
|
||||
};
|
||||
|
||||
const device_t dec_tulip_21040_device = {
|
||||
.name = "DEC DE-435 EtherWorks Turbo (DECchip 21040 \"Tulip\")",
|
||||
.internal_name = "dec_21040_tulip",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 3,
|
||||
.init = nic_init,
|
||||
.close = nic_close,
|
||||
.reset = tulip_reset,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = dec_tulip_21143_config
|
||||
};
|
||||
|
@@ -136,6 +136,7 @@ static const device_t *net_cards[] = {
|
||||
&rtl8139c_plus_device,
|
||||
&dec_tulip_21140_device,
|
||||
&dec_tulip_21140_vpc_device,
|
||||
&dec_tulip_21040_device,
|
||||
&pcnet_am79c960_vlb_device,
|
||||
NULL
|
||||
};
|
||||
|
Reference in New Issue
Block a user