dp8390: Eliminate CS line handler; use separate read and write handlers instead (nw)

This commit is contained in:
AJR 2020-06-04 13:09:08 -04:00
parent 8a017c1bc8
commit 754a13530c
7 changed files with 60 additions and 87 deletions

View File

@ -110,8 +110,7 @@ void el2_3c503_device::dack_w(int line, uint8_t data) {
uint8_t el2_3c503_device::el2_3c503_loport_r(offs_t offset) { uint8_t el2_3c503_device::el2_3c503_loport_r(offs_t offset) {
switch((m_regs.ctrl >> 2) & 3) { switch((m_regs.ctrl >> 2) & 3) {
case 0: case 0:
m_dp8390->dp8390_cs(CLEAR_LINE); return m_dp8390->cs_read(offset);
return m_dp8390->dp8390_r(offset);
case 1: case 1:
return m_prom[offset]; return m_prom[offset];
case 2: case 2:
@ -125,8 +124,7 @@ uint8_t el2_3c503_device::el2_3c503_loport_r(offs_t offset) {
void el2_3c503_device::el2_3c503_loport_w(offs_t offset, uint8_t data) { void el2_3c503_device::el2_3c503_loport_w(offs_t offset, uint8_t data) {
switch((m_regs.ctrl >> 2) & 3) { switch((m_regs.ctrl >> 2) & 3) {
case 0: case 0:
m_dp8390->dp8390_cs(CLEAR_LINE); return m_dp8390->cs_write(offset, data);
return m_dp8390->dp8390_w(offset, data);
case 1: case 1:
case 2: case 2:
logerror("3c503: invalid attempt to write to prom\n"); logerror("3c503: invalid attempt to write to prom\n");

View File

@ -41,13 +41,11 @@ void ne1000_device::device_reset() {
uint8_t ne1000_device::ne1000_port_r(offs_t offset) { uint8_t ne1000_device::ne1000_port_r(offs_t offset) {
if(offset < 16) { if(offset < 16) {
m_dp8390->dp8390_cs(CLEAR_LINE); return m_dp8390->cs_read(offset);
return m_dp8390->dp8390_r(offset);
} }
switch(offset) { switch(offset) {
case 16: case 16:
m_dp8390->dp8390_cs(ASSERT_LINE); return m_dp8390->remote_read();
return m_dp8390->dp8390_r(offset);
case 31: case 31:
m_dp8390->dp8390_reset(CLEAR_LINE); m_dp8390->dp8390_reset(CLEAR_LINE);
return 0; return 0;
@ -59,14 +57,12 @@ uint8_t ne1000_device::ne1000_port_r(offs_t offset) {
void ne1000_device::ne1000_port_w(offs_t offset, uint8_t data) { void ne1000_device::ne1000_port_w(offs_t offset, uint8_t data) {
if(offset < 16) { if(offset < 16) {
m_dp8390->dp8390_cs(CLEAR_LINE); m_dp8390->cs_write(offset, data);
m_dp8390->dp8390_w(offset, data);
return; return;
} }
switch(offset) { switch(offset) {
case 16: case 16:
m_dp8390->dp8390_cs(ASSERT_LINE); m_dp8390->remote_write(data);
m_dp8390->dp8390_w(offset, data);
return; return;
case 31: case 31:
m_dp8390->dp8390_reset(ASSERT_LINE); m_dp8390->dp8390_reset(ASSERT_LINE);

View File

@ -42,15 +42,13 @@ void ne2000_device::device_reset() {
READ16_MEMBER(ne2000_device::ne2000_port_r) { READ16_MEMBER(ne2000_device::ne2000_port_r) {
offset <<= 1; offset <<= 1;
if(offset < 16) { if(offset < 16) {
m_dp8390->dp8390_cs(CLEAR_LINE); return m_dp8390->cs_read(offset) |
return m_dp8390->dp8390_r(offset) | m_dp8390->cs_read(offset+1) << 8;
m_dp8390->dp8390_r(offset+1) << 8;
} }
if(mem_mask == 0xff00) offset++; if(mem_mask == 0xff00) offset++;
switch(offset) { switch(offset) {
case 16: case 16:
m_dp8390->dp8390_cs(ASSERT_LINE); return m_dp8390->remote_read();
return m_dp8390->dp8390_r(offset);
case 31: case 31:
m_dp8390->dp8390_reset(CLEAR_LINE); m_dp8390->dp8390_reset(CLEAR_LINE);
return 0; return 0;
@ -63,20 +61,18 @@ READ16_MEMBER(ne2000_device::ne2000_port_r) {
WRITE16_MEMBER(ne2000_device::ne2000_port_w) { WRITE16_MEMBER(ne2000_device::ne2000_port_w) {
offset <<= 1; offset <<= 1;
if(offset < 16) { if(offset < 16) {
m_dp8390->dp8390_cs(CLEAR_LINE);
if(mem_mask == 0xff00) { if(mem_mask == 0xff00) {
data >>= 8; data >>= 8;
offset++; offset++;
} }
m_dp8390->dp8390_w(offset, data & 0xff); m_dp8390->cs_write(offset, data & 0xff);
if(mem_mask == 0xffff) m_dp8390->dp8390_w(offset+1, data>>8); if(mem_mask == 0xffff) m_dp8390->cs_write(offset+1, data>>8);
return; return;
} }
if(mem_mask == 0xff00) offset++; if(mem_mask == 0xff00) offset++;
switch(offset) { switch(offset) {
case 16: case 16:
m_dp8390->dp8390_cs(ASSERT_LINE); m_dp8390->remote_write(data);
m_dp8390->dp8390_w(offset, data);
return; return;
case 31: case 31:
m_dp8390->dp8390_reset(ASSERT_LINE); m_dp8390->dp8390_reset(ASSERT_LINE);

View File

@ -124,7 +124,6 @@ void nubus_mac8390_device::device_start()
void nubus_mac8390_device::device_reset() void nubus_mac8390_device::device_reset()
{ {
m_dp83902->dp8390_reset(0); m_dp83902->dp8390_reset(0);
m_dp83902->dp8390_cs(0);
memcpy(m_prom, m_dp83902->get_mac(), 6); memcpy(m_prom, m_dp83902->get_mac(), 6);
} }
@ -145,13 +144,11 @@ WRITE32_MEMBER( nubus_mac8390_device::en_w )
if (mem_mask == 0xff000000) if (mem_mask == 0xff000000)
{ {
// printf("%02x to 8390 @ %x\n", data>>24, 0xf-offset); // printf("%02x to 8390 @ %x\n", data>>24, 0xf-offset);
m_dp83902->dp8390_w(0xf-offset, data>>24); m_dp83902->cs_write(0xf-offset, data>>24);
} }
else if (mem_mask == 0xffff0000) else if (mem_mask == 0xffff0000)
{ {
m_dp83902->dp8390_cs(1); m_dp83902->remote_write(data>>16);
m_dp83902->dp8390_w(0xf-offset, data>>16);
m_dp83902->dp8390_cs(0);
} }
else else
{ {
@ -163,13 +160,11 @@ READ32_MEMBER( nubus_mac8390_device::en_r )
{ {
if (mem_mask == 0xff000000) if (mem_mask == 0xff000000)
{ {
return (m_dp83902->dp8390_r(0xf-offset)<<24); return (m_dp83902->cs_read(0xf-offset)<<24);
} }
else if (mem_mask == 0xffff0000) else if (mem_mask == 0xffff0000)
{ {
m_dp83902->dp8390_cs(1); return (m_dp83902->remote_read()<<16);
return (m_dp83902->dp8390_r(0xf-offset)<<16);
m_dp83902->dp8390_cs(0);
} }
else else
{ {

View File

@ -62,17 +62,15 @@ READ16_MEMBER(x68k_neptune_device::x68k_neptune_port_r)
return 0xffff; return 0xffff;
if(offset < 0x100+16) if(offset < 0x100+16)
{ {
m_dp8390->dp8390_cs(CLEAR_LINE); return (m_dp8390->cs_read(offset) << 8)|
return (m_dp8390->dp8390_r(offset) << 8)| m_dp8390->cs_read(offset+1);
m_dp8390->dp8390_r(offset+1);
} }
//if(mem_mask == 0x00ff) offset++; //if(mem_mask == 0x00ff) offset++;
switch(offset) switch(offset)
{ {
case 0x100+16: case 0x100+16:
m_dp8390->dp8390_cs(ASSERT_LINE); data = m_dp8390->remote_read();
data = m_dp8390->dp8390_r(offset); data = swapendian_int16(data);
data = ((data & 0x00ff) << 8) | ((data & 0xff00) >> 8);
return data; return data;
case 0x100+31: case 0x100+31:
m_dp8390->dp8390_reset(CLEAR_LINE); m_dp8390->dp8390_reset(CLEAR_LINE);
@ -89,23 +87,20 @@ WRITE16_MEMBER(x68k_neptune_device::x68k_neptune_port_w)
return; return;
if(offset < 0x100+16) if(offset < 0x100+16)
{ {
m_dp8390->dp8390_cs(CLEAR_LINE);
if(mem_mask == 0x00ff) if(mem_mask == 0x00ff)
{ {
data <<= 8; data <<= 8;
offset++; offset++;
} }
m_dp8390->dp8390_w(offset, data>>8); m_dp8390->cs_write(offset, data>>8);
if(mem_mask == 0xffff) m_dp8390->dp8390_w(offset+1, data & 0xff); if(mem_mask == 0xffff) m_dp8390->cs_write(offset+1, data & 0xff);
return; return;
} }
//if(mem_mask == 0x00ff) offset++; //if(mem_mask == 0x00ff) offset++;
switch(offset) switch(offset)
{ {
case 0x100+16: case 0x100+16:
m_dp8390->dp8390_cs(ASSERT_LINE); m_dp8390->remote_write(swapendian_int16(data));
data = ((data & 0x00ff) << 8) | ((data & 0xff00) >> 8);
m_dp8390->dp8390_w(offset, data);
return; return;
case 0x100+31: case 0x100+31:
m_dp8390->dp8390_reset(ASSERT_LINE); m_dp8390->dp8390_reset(ASSERT_LINE);

View File

@ -28,7 +28,6 @@ dp8390_device::dp8390_device(const machine_config &mconfig, device_type type, co
, m_mem_read_cb(*this) , m_mem_read_cb(*this)
, m_mem_write_cb(*this) , m_mem_write_cb(*this)
, m_reset(0) , m_reset(0)
, m_cs(false)
, m_rdma_active(0) , m_rdma_active(0)
{ {
} }
@ -172,33 +171,29 @@ void dp8390_device::recv_cb(uint8_t *buf, int len) {
if(!LOOPBACK) recv(buf, len); if(!LOOPBACK) recv(buf, len);
} }
WRITE_LINE_MEMBER(dp8390_device::dp8390_cs) {
m_cs = state;
}
WRITE_LINE_MEMBER(dp8390_device::dp8390_reset) { WRITE_LINE_MEMBER(dp8390_device::dp8390_reset) {
if(!state) device_reset(); if(!state) device_reset();
} }
uint16_t dp8390_device::dp8390_r(offs_t offset) { uint16_t dp8390_device::remote_read() {
uint16_t data;
if(m_cs) {
uint32_t high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0; uint32_t high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
if(m_regs.dcr & 1) { if(m_regs.dcr & 1) {
m_regs.crda &= ~1; m_regs.crda &= ~1;
data = m_mem_read_cb(high16 + m_regs.crda++); uint16_t data = m_mem_read_cb(high16 + m_regs.crda++);
data |= m_mem_read_cb(high16 + m_regs.crda++) << 8; data |= m_mem_read_cb(high16 + m_regs.crda++) << 8;
m_regs.rbcr -= (m_regs.rbcr < 2)?m_regs.rbcr:2; m_regs.rbcr -= (m_regs.rbcr < 2)?m_regs.rbcr:2;
check_dma_complete(); check_dma_complete();
return DP8390_BYTE_ORDER(data); return DP8390_BYTE_ORDER(data);
} else { } else {
m_regs.rbcr -= (m_regs.rbcr)?1:0; m_regs.rbcr -= (m_regs.rbcr)?1:0;
data = m_mem_read_cb(high16 + m_regs.crda++); uint16_t data = m_mem_read_cb(high16 + m_regs.crda++);
check_dma_complete(); check_dma_complete();
return data; return data;
} }
} }
uint8_t dp8390_device::cs_read(offs_t offset) {
uint8_t data;
switch((offset & 0x0f)|(m_regs.cr & 0xc0)) { switch((offset & 0x0f)|(m_regs.cr & 0xc0)) {
case 0x00: case 0x00:
case 0x40: case 0x40:
@ -350,8 +345,7 @@ uint16_t dp8390_device::dp8390_r(offs_t offset) {
return data; return data;
} }
void dp8390_device::dp8390_w(offs_t offset, uint16_t data) { void dp8390_device::remote_write(uint16_t data) {
if(m_cs) {
uint32_t high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0; uint32_t high16 = (m_regs.dcr & 4)?m_regs.rsar<<16:0;
if(m_regs.dcr & 1) { if(m_regs.dcr & 1) {
data = DP8390_BYTE_ORDER(data); data = DP8390_BYTE_ORDER(data);
@ -366,10 +360,9 @@ void dp8390_device::dp8390_w(offs_t offset, uint16_t data) {
m_regs.rbcr -= (m_regs.rbcr)?1:0; m_regs.rbcr -= (m_regs.rbcr)?1:0;
check_dma_complete(); check_dma_complete();
} }
return;
} }
data &= 0xff; void dp8390_device::cs_write(offs_t offset, uint8_t data) {
switch((offset & 0x0f)|(m_regs.cr & 0xc0)) { switch((offset & 0x0f)|(m_regs.cr & 0xc0)) {
case 0x00: case 0x00:
case 0x40: case 0x40:

View File

@ -16,9 +16,10 @@ public:
auto mem_read_callback() { return m_mem_read_cb.bind(); } auto mem_read_callback() { return m_mem_read_cb.bind(); }
auto mem_write_callback() { return m_mem_write_cb.bind(); } auto mem_write_callback() { return m_mem_write_cb.bind(); }
void dp8390_w(offs_t offset, uint16_t data); void remote_write(uint16_t data);
uint16_t dp8390_r(offs_t offset); void cs_write(offs_t offset, uint8_t data);
DECLARE_WRITE_LINE_MEMBER( dp8390_cs ); uint16_t remote_read();
uint8_t cs_read(offs_t offset);
DECLARE_WRITE_LINE_MEMBER( dp8390_reset ); DECLARE_WRITE_LINE_MEMBER( dp8390_reset );
void recv_cb(uint8_t *buf, int len) override; void recv_cb(uint8_t *buf, int len) override;
@ -52,7 +53,6 @@ private:
void recv(uint8_t *buf, int len); void recv(uint8_t *buf, int len);
int m_reset; int m_reset;
bool m_cs;
int m_rdma_active; int m_rdma_active;
struct { struct {