--- tme/ic/i825x6.c 2018/04/24 16:41:45 1.1.1.2 +++ tme/ic/i825x6.c 2018/04/24 16:45:31 1.1.1.4 @@ -1,4 +1,4 @@ -/* $Id: i825x6.c,v 1.1.1.2 2018/04/24 16:41:45 root Exp $ */ +/* $Id: i825x6.c,v 1.1.1.4 2018/04/24 16:45:31 root Exp $ */ /* ic/i825x6.c - implementation of the Intel 825x6 emulation: */ @@ -34,7 +34,7 @@ */ #include -_TME_RCSID("$Id: i825x6.c,v 1.1.1.2 2018/04/24 16:41:45 root Exp $"); +_TME_RCSID("$Id: i825x6.c,v 1.1.1.4 2018/04/24 16:45:31 root Exp $"); /* XXX FIXME - TLB usage here is not thread-safe: */ @@ -119,6 +119,10 @@ do { \ #define TME_I825X6_CALLOUT_CA TME_BIT(5) #define TME_I825X6_CALLOUT_CU TME_BIT(6) +#if 1 +extern int printf(const char *format, ...); +#endif + /* structures: */ /* an rx buffer: */ @@ -165,8 +169,8 @@ struct tme_i825x6 { int tme_i825x6_callout_flags; /* our DMA TLB hash: */ - struct tme_bus_tlb * tme_shared tme_i825x6_tlb_hash; - tme_rwlock_t tme_i825x6_tlb_hash_rwlock; + struct tme_bus_tlb tme_i825x6_tlb_hash[TME_I825X6_TLB_HASH_SIZE]; + int tme_i825x6_tlb_hash_added; /* the i825x6 bus signals: */ struct tme_bus_signals tme_i825x6_bus_signals; @@ -261,6 +265,10 @@ _tme_i825x6_reset(struct tme_i825x6 *i82 if (i825x6->tme_i825x6_stat_cus_rus_t & TME_I825X6_SCB_STAT_MASK) { i825x6->tme_i825x6_stat_cus_rus_t &= ~TME_I825X6_SCB_STAT_MASK; +#if 1 +printf("_tme_i825x6_reset() CALLOUT_INT\n"); +#endif + i825x6->tme_i825x6_callout_flags |= TME_I825X6_CALLOUT_INT; } @@ -291,10 +299,8 @@ _tme_i825x6_tlb_hash(void *_i825x6, i825x6 = (struct tme_i825x6 *) _i825x6; /* return the TLB entry: */ - return (tme_memory_atomic_pointer_read(struct tme_bus_tlb *, - i825x6->tme_i825x6_tlb_hash, - &i825x6->tme_i825x6_tlb_hash_rwlock) - + ((linear_address >> 10) & (TME_I825X6_TLB_HASH_SIZE - 1))); + return (i825x6->tme_i825x6_tlb_hash + + ((((tme_bus_addr32_t) linear_address) >> 10) & (TME_I825X6_TLB_HASH_SIZE - 1))); } /* this locks the mutex: */ @@ -388,8 +394,8 @@ _tme_i825x6_rx_buffers_add(struct tme_i8 struct tme_i825x6_rx_buffer *rx_buffer, **_prev; struct tme_bus_tlb *tlb, tlb_local; struct tme_bus_connection *conn_bus; - tme_bus_addr_t count_minus_one, count; - tme_bus_addr_t tlb_addr_last; + tme_bus_addr32_t count_minus_one, count; + tme_bus_addr32_t tlb_addr_last; int err; /* recover the rx buffers list: */ @@ -413,7 +419,7 @@ _tme_i825x6_rx_buffers_add(struct tme_i8 if it doesn't allow writing, reload it: */ tlb_addr_last = tlb->tme_bus_tlb_addr_last; if (tme_bus_tlb_is_invalid(tlb) - || address_init < tlb->tme_bus_tlb_addr_first + || address_init < (tme_bus_addr32_t) tlb->tme_bus_tlb_addr_first || address_init > tlb_addr_last || (tlb->tme_bus_tlb_emulator_off_write == TME_EMULATOR_OFF_UNDEF && !(tlb->tme_bus_tlb_cycles_ok & TME_BUS_CYCLE_WRITE))) { @@ -421,9 +427,8 @@ _tme_i825x6_rx_buffers_add(struct tme_i8 /* unbusy this TLB entry for filling: */ tme_bus_tlb_unbusy_fill(tlb); - /* reserve this TLB entry: */ - tlb_local.tme_bus_tlb_global = tlb; - tlb = &tlb_local; + /* pass this TLB's token: */ + tlb_local.tme_bus_tlb_token = tlb->tme_bus_tlb_token; /* get our bus connection: */ conn_bus = tme_memory_atomic_pointer_read(struct tme_bus_connection *, @@ -436,7 +441,7 @@ _tme_i825x6_rx_buffers_add(struct tme_i8 /* reload the TLB entry: */ err = (*conn_bus->tme_bus_tlb_fill) (conn_bus, - tlb, + &tlb_local, address_init, TME_BUS_CYCLE_WRITE); @@ -450,7 +455,7 @@ _tme_i825x6_rx_buffers_add(struct tme_i8 } /* store the TLB entry: */ - tme_bus_tlb_back(tlb); + *tlb = tlb_local; /* loop to check the newly filled TLB entry: */ continue; @@ -700,6 +705,10 @@ _tme_i825x6_chunks_dma_tx(struct tme_i82 tme_uint32_t count; int rc; +#if 1 + printf("_tme_i825x6_chunks_dma_tx; xmit %d\n", size); +#endif + /* while we have bytes left to DMA: */ for (; size > 0; ) { @@ -780,6 +789,9 @@ _tme_i825x6_callout_ca(struct tme_i825x6 tme_uint16_t rbd_offset_first; int rc; +#if 1 +printf("_tme_i825x6_callout_ca()\n"); +#endif /* if this CA follows RESET: */ if (i825x6->tme_i825x6_ca_follows_reset) { @@ -820,6 +832,9 @@ _tme_i825x6_callout_ca(struct tme_i825x6 | TME_I825X6_SCB_RUS_IDLE); /* "The 82596 ... sends an interrupt to the CPU": */ +#if 1 +printf("_tme_i825x6_callout_ca() CALLOUT_INT\n"); +#endif i825x6->tme_i825x6_callout_flags = TME_I825X6_CALLOUTS_RUNNING | TME_I825X6_CALLOUT_INT; } @@ -1475,6 +1490,9 @@ _tme_i825x6_callout_ru(struct tme_i825x6 + TME_I825X6_RFD_C_B_OK_STATUS), c_b_ok_status); +#if 1 + printf("_tme_i825x6_callout_ru() signal int\n"); +#endif /* signal an interrupt: */ stat_cus_rus_t |= TME_I825X6_SCB_STAT_FR; @@ -1622,6 +1640,9 @@ _tme_i825x6_callout(struct tme_i825x6 *i /* unlock the mutex: */ tme_mutex_unlock(&i825x6->tme_i825x6_mutex); +#if 1 + printf("_tme_i825x6_callout; \n"); +#endif /* do the callout: */ rc = (conn_eth != NULL ? ((*conn_eth->tme_ethernet_connection_ctrl) @@ -1732,6 +1753,9 @@ _tme_i825x6_callout(struct tme_i825x6 *i & TME_I825X6_SCB_STAT_MASK) != !(stat_cus_rus_t & TME_I825X6_SCB_STAT_MASK)) { +#if 1 +printf("_tme_i825x6_callout() CALLOUT_INT\n"); +#endif i825x6->tme_i825x6_callout_flags |= TME_I825X6_CALLOUT_INT; } @@ -1766,6 +1790,9 @@ _tme_i825x6_callout(struct tme_i825x6 *i i825x6->tme_i825x6_device.tme_bus_device_connection, &i825x6->tme_i825x6_device.tme_bus_device_connection_rwlock); +#if 1 + printf("_tme_i825x6_callout; signal int - asserted %x\n", (int)int_asserted); +#endif /* call out the bus interrupt signal edge: */ rc = (*conn_bus->tme_bus_signal) (conn_bus, @@ -1780,6 +1807,9 @@ _tme_i825x6_callout(struct tme_i825x6 *i /* if this callout failed, remember that at some later time this callout should be attempted again: */ if (rc != TME_OK) { +#if 1 +printf("_tme_i825x6_callout() later CALLOUT_INT\n"); +#endif later_callouts |= TME_I825X6_CALLOUT_INT; } } @@ -1811,6 +1841,11 @@ _tme_i825x6_signal(void *_i825x6, level = signal & TME_BUS_SIGNAL_LEVEL_MASK; signal = TME_BUS_SIGNAL_WHICH(signal); +#if 1 + printf("_tme_i825x6_signal() level %x, signal %x; switch index %x\n", + (int)level, (int)signal, + (int)(signal - i825x6->tme_i825x6_bus_signals.tme_bus_signals_first)); +#endif /* dispatch on the generic bus signals: */ switch (signal) { case TME_BUS_SIGNAL_RESET: @@ -1829,6 +1864,14 @@ _tme_i825x6_signal(void *_i825x6, case TME_I825X6_SIGNAL_CA: if (level == TME_BUS_SIGNAL_LEVEL_ASSERTED) { new_callouts |= TME_I825X6_CALLOUT_CA; + } else { +#if 1 + printf("TME_I825X6_SIGNAL_CA; deasserted!!!!\n"); +#endif +#if 1 + i825x6->tme_i825x6_stat_cus_rus_t &= ~TME_I825X6_SCB_STAT_MASK; + new_callouts |= TME_I825X6_CALLOUT_INT; +#endif } break; @@ -1940,6 +1983,10 @@ _tme_i825x6_read(struct tme_ethernet_con & TME_I825X6_CB_CMD_MASK) == TME_I825X6_CB_CMD_TRANSMIT) { +#if 1 + printf("_tme_i825x6_read; xmit\n"); +#endif + /* assume that we will succeed: */ err = TME_OK; do { @@ -2093,9 +2140,7 @@ _tme_i825x6_connection_make_bus(struct t hash yet, allocate it and add our bus signals: */ if (rc == TME_OK && state == TME_CONNECTION_FULL - && tme_memory_atomic_pointer_read(struct tme_bus_tlb *, - i825x6->tme_i825x6_tlb_hash, - &i825x6->tme_i825x6_tlb_hash_rwlock) == NULL) { + && !i825x6->tme_i825x6_tlb_hash_added) { /* get our bus connection: */ conn_bus @@ -2103,14 +2148,12 @@ _tme_i825x6_connection_make_bus(struct t i825x6->tme_i825x6_device.tme_bus_device_connection, &i825x6->tme_i825x6_device.tme_bus_device_connection_rwlock); - /* allocate the TLB set: */ - rc = ((*conn_bus->tme_bus_tlb_set_allocate) - (conn_bus, - TME_I825X6_TLB_HASH_SIZE, - sizeof(struct tme_bus_tlb), - &i825x6->tme_i825x6_tlb_hash, - &i825x6->tme_i825x6_device.tme_bus_device_connection_rwlock)); + /* add the TLB set: */ + rc = tme_bus_device_tlb_set_add(&i825x6->tme_i825x6_device, + TME_I825X6_TLB_HASH_SIZE, + i825x6->tme_i825x6_tlb_hash); assert (rc == TME_OK); + i825x6->tme_i825x6_tlb_hash_added = TRUE; /* add our bus signals: */ i825x6->tme_i825x6_bus_signals = _tme_i825x6_bus_signals;