--- tme/bus/multibus/3c400.c 2018/04/24 16:38:45 1.1.1.2 +++ tme/bus/multibus/3c400.c 2018/04/24 16:43:15 1.1.1.5 @@ -1,4 +1,4 @@ -/* $Id: 3c400.c,v 1.1.1.2 2018/04/24 16:38:45 root Exp $ */ +/* $Id: 3c400.c,v 1.1.1.5 2018/04/24 16:43:15 root Exp $ */ /* bus/multibus/3c400.c - implementation of the Multibus 3c400 emulation: */ @@ -34,7 +34,7 @@ */ #include -_TME_RCSID("$Id: 3c400.c,v 1.1.1.2 2018/04/24 16:38:45 root Exp $"); +_TME_RCSID("$Id: 3c400.c,v 1.1.1.5 2018/04/24 16:43:15 root Exp $"); /* includes: */ #include @@ -95,9 +95,13 @@ _TME_RCSID("$Id: 3c400.c,v 1.1.1.2 2018/ /* these get and put the CSR: */ #define TME_3C400_CSR_GET(_3c400) \ - tme_betoh_u16(*((tme_uint16_t *) &(_3c400)->tme_3c400_card[TME_3C400_REG_CSR])) + ((((tme_uint16_t) (_3c400)->tme_3c400_card[TME_3C400_REG_CSR + 0]) << 8) \ + + (_3c400)->tme_3c400_card[TME_3C400_REG_CSR + 1]) #define TME_3C400_CSR_PUT(_3c400, csr) \ - (*((tme_uint16_t *) &(_3c400)->tme_3c400_card[TME_3C400_REG_CSR]) = tme_htobe_u16(csr)) + do { \ + (_3c400)->tme_3c400_card[TME_3C400_REG_CSR + 0] = (csr) >> 8; \ + (_3c400)->tme_3c400_card[TME_3C400_REG_CSR + 1] = (tme_uint8_t) (csr); \ + } while (/* CONSTCOND */ 0) /* the callout flags: */ #define TME_3C400_CALLOUT_CHECK (0) @@ -430,8 +434,9 @@ _tme_3c400_callout(struct tme_3c400 *_3c tme_mutex_unlock(&_3c400->tme_3c400_mutex); /* get our bus connection: */ - conn_bus = TME_ATOMIC_READ(struct tme_bus_connection *, - _3c400->tme_3c400_device.tme_bus_device_connection); + conn_bus = tme_memory_atomic_pointer_read(struct tme_bus_connection *, + _3c400->tme_3c400_device.tme_bus_device_connection, + &_3c400->tme_3c400_device.tme_bus_device_connection_rwlock); /* call out the bus interrupt signal edge: */ rc = (*conn_bus->tme_bus_signal) @@ -439,8 +444,7 @@ _tme_3c400_callout(struct tme_3c400 *_3c TME_BUS_SIGNAL_INT_UNSPEC | (int_asserted ? TME_BUS_SIGNAL_LEVEL_ASSERTED - : TME_BUS_SIGNAL_LEVEL_NEGATED) - | TME_BUS_SIGNAL_EDGE); + : TME_BUS_SIGNAL_LEVEL_NEGATED)); /* lock our mutex: */ tme_mutex_lock(&_3c400->tme_3c400_mutex); @@ -680,13 +684,18 @@ _tme_3c400_read(struct tme_ethernet_conn /* the _3c400 TLB filler: */ static int _tme_3c400_tlb_fill(void *__3c400, struct tme_bus_tlb *tlb, - tme_bus_addr_t address, unsigned int cycles) + tme_bus_addr_t address_wider, unsigned int cycles) { struct tme_3c400 *_3c400; + tme_bus_addr32_t address; /* recover our data structure: */ _3c400 = (struct tme_3c400 *) __3c400; + /* get the normal-width address: */ + address = address_wider; + assert (address == address_wider); + /* the address must be within range: */ assert(address < TME_3C400_SIZ_CARD); @@ -698,8 +707,8 @@ _tme_3c400_tlb_fill(void *__3c400, struc && address < TME_3C400_REG_AROM) { /* this TLB entry covers this range: */ - TME_ATOMIC_WRITE(tme_bus_addr_t, tlb->tme_bus_tlb_addr_first, TME_3C400_REG_CSR); - TME_ATOMIC_WRITE(tme_bus_addr_t, tlb->tme_bus_tlb_addr_last, TME_3C400_REG_AROM - 1); + tlb->tme_bus_tlb_addr_first = TME_3C400_REG_CSR; + tlb->tme_bus_tlb_addr_last = TME_3C400_REG_AROM - 1; } /* if this address falls from the address ROM to the address RAM: */ @@ -707,16 +716,16 @@ _tme_3c400_tlb_fill(void *__3c400, struc && address < TME_3C400_REG_ARAM) { /* this TLB entry covers this range: */ - TME_ATOMIC_WRITE(tme_bus_addr_t, tlb->tme_bus_tlb_addr_first, TME_3C400_REG_AROM); - TME_ATOMIC_WRITE(tme_bus_addr_t, tlb->tme_bus_tlb_addr_last, TME_3C400_REG_ARAM - 1); + tlb->tme_bus_tlb_addr_first = TME_3C400_REG_AROM; + tlb->tme_bus_tlb_addr_last = TME_3C400_REG_ARAM - 1; } /* anything else covers the remainder of the device: */ else { /* this TLB entry can cover from the address RAM to the end of the card: */ - TME_ATOMIC_WRITE(tme_bus_addr_t, tlb->tme_bus_tlb_addr_first, TME_3C400_REG_ARAM); - TME_ATOMIC_WRITE(tme_bus_addr_t, tlb->tme_bus_tlb_addr_last, TME_3C400_SIZ_CARD - 1); + tlb->tme_bus_tlb_addr_first = TME_3C400_REG_ARAM; + tlb->tme_bus_tlb_addr_last = TME_3C400_SIZ_CARD - 1; /* this TLB entry allows fast writing: */ tlb->tme_bus_tlb_emulator_off_write = &_3c400->tme_3c400_card[0];