--- tme/bus/multibus/sun-mie.c 2018/04/24 16:43:15 1.1.1.3 +++ tme/bus/multibus/sun-mie.c 2018/04/24 16:45:16 1.1.1.4 @@ -1,4 +1,4 @@ -/* $Id: sun-mie.c,v 1.1.1.3 2018/04/24 16:43:15 root Exp $ */ +/* $Id: sun-mie.c,v 1.1.1.4 2018/04/24 16:45:16 root Exp $ */ /* bus/multibus/sun_mie.c - implementation of the Sun Intel Ethernet Multibus emulation: */ @@ -34,7 +34,7 @@ */ #include -_TME_RCSID("$Id: sun-mie.c,v 1.1.1.3 2018/04/24 16:43:15 root Exp $"); +_TME_RCSID("$Id: sun-mie.c,v 1.1.1.4 2018/04/24 16:45:16 root Exp $"); /* includes: */ #include @@ -158,6 +158,10 @@ struct tme_sun_mie { /* the callout flags: */ int tme_sun_mie_callout_flags; + int tme_sun_mie_ca_callout_delay; + int tme_sun_mie_ca_callout_pending; + int tme_sun_mie_pending_deassert_intr; + /* if our interrupt line is currently asserted: */ int tme_sun_mie_int_asserted; @@ -200,6 +204,8 @@ struct tme_sun_mie_connection { static const struct tme_bus_signals _tme_sun_mie_bus_signals_generic = TME_BUS_SIGNALS_GENERIC; static const struct tme_bus_signals _tme_sun_mie_bus_signals_i825x6 = TME_BUS_SIGNALS_I825X6; +extern int printf(const char *format, ...); + /* the sun_mie callout function. it must be called with the mutex locked: */ static void _tme_sun_mie_callout(struct tme_sun_mie *sun_mie, int new_callouts) @@ -286,6 +292,12 @@ _tme_sun_mie_callout(struct tme_sun_mie /* unlock the mutex: */ tme_mutex_unlock(&sun_mie->tme_sun_mie_mutex); +#if 1 + printf("callout conn_i825x6->tme_bus_signal; signal %x, level %x; %x\n", + (int)signal, (int)level, (int)(signal | level)); +#endif + +if (signal) /* do the callout: */ rc = (conn_i825x6 != NULL ? ((*conn_i825x6->tme_bus_signal) @@ -355,6 +367,9 @@ _tme_sun_mie_callout(struct tme_sun_mie /* if this callout was successful, note the new state of the interrupt signal: */ if (rc == TME_OK) { +#if 1 + printf("IE assert int %x, csr %x\n", (int)int_asserted, (int)csr); +#endif sun_mie->tme_sun_mie_int_asserted = int_asserted; } @@ -404,6 +419,15 @@ _tme_sun_mie_bus_cycle_regs(void *_sun_m tme_uint16_t pcr_old, pcr_new, pcr_diff; int new_callouts; +#if 1 + printf("mie_bus_cycle_regs; type %x, addr %x, size %d, %02x %02x\n", + (int)cycle_init->tme_bus_cycle_type, + (int)cycle_init->tme_bus_cycle_address, + (int)cycle_init->tme_bus_cycle_size, + (int)cycle_init->tme_bus_cycle_buffer[0], + (int)cycle_init->tme_bus_cycle_buffer[1]); +#endif + /* recover our data structure: */ sun_mie = (struct tme_sun_mie *) _sun_mie; @@ -470,6 +494,10 @@ _tme_sun_mie_bus_cycle_regs(void *_sun_m & ~TME_SUN_MIE_CSR_READONLY) | (csr_old & TME_SUN_MIE_CSR_READONLY)); +#if 1 + printf("csr_new %x, csr_old %x, csr %x\n", + (int)csr_new, (int)csr_old, (int)TME_SUN_MIE_CSR_GET(sun_mie)); +#endif TME_SUN_MIE_CSR_PUT(sun_mie, csr_new); pcr_new = ((TME_SUN_MIE_PCR_GET(sun_mie) & ~TME_SUN_MIE_PCR_READONLY) @@ -505,6 +533,11 @@ _tme_sun_mie_bus_cycle_regs(void *_sun_m /* nothing to do */ } +#if 1 + printf("IE now csr %x, tme_sun_mie_int_asserted %x\n", + (int)csr_new, (int)sun_mie->tme_sun_mie_int_asserted); +#endif + #ifndef TME_NO_LOG if (csr_new != sun_mie->tme_sun_mie_last_log_csr) { sun_mie->tme_sun_mie_last_log_csr = csr_new; @@ -516,6 +549,16 @@ _tme_sun_mie_bus_cycle_regs(void *_sun_m } #endif /* !TME_NO_LOG */ +#if 1 + if (cycle_init->tme_bus_cycle_type & TME_BUS_CYCLE_WRITE) + if (sun_mie->tme_sun_mie_pending_deassert_intr) { + sun_mie->tme_sun_mie_pending_deassert_intr = 0; + printf("turning off pending intr\n"); + csr_new &= ~TME_SUN_MIE_CSR_INTR; + TME_SUN_MIE_CSR_PUT(sun_mie, csr_new); + } +#endif + /* make any new callouts: */ _tme_sun_mie_callout(sun_mie, new_callouts); @@ -533,6 +576,13 @@ _tme_sun_mie_bus_signal(struct tme_bus_c { struct tme_sun_mie *sun_mie; +#if 1 + printf("_tme_sun_mie_bus_signal() %x, index %d, count %d\n", + (int)signal, + (int)TME_BUS_SIGNAL_INDEX(signal), + (int)_tme_sun_mie_bus_signals_generic.tme_bus_signals_count); +#endif + /* return now if this is not a generic bus signal: */ if (TME_BUS_SIGNAL_INDEX(signal) > _tme_sun_mie_bus_signals_generic.tme_bus_signals_count) { @@ -542,6 +592,32 @@ _tme_sun_mie_bus_signal(struct tme_bus_c /* recover our data structures: */ sun_mie = conn_bus->tme_bus_connection.tme_connection_element->tme_element_private; +#if 1 + printf("_tme_sun_mie_bus_signal() doing it %x\n", (int)signal); +#endif + +#if 1 +if (TME_BUS_SIGNAL_WHICH(signal) == TME_BUS_SIGNAL_INT_UNSPEC) +{ + tme_uint16_t csr; + unsigned int level; + csr = TME_SUN_MIE_CSR_GET(sun_mie); + level = signal & TME_BUS_SIGNAL_LEVEL_MASK; + + if (level == TME_BUS_SIGNAL_LEVEL_ASSERTED) { + printf("assert csr intr!\n"); + csr |= TME_SUN_MIE_CSR_INTR; + TME_SUN_MIE_CSR_PUT(sun_mie, csr); + } + if (level == TME_BUS_SIGNAL_LEVEL_NEGATED) { + printf("deassert csr intr!\n"); +// csr &= ~TME_SUN_MIE_CSR_INTR; +// TME_SUN_MIE_CSR_PUT(sun_mie, csr); + sun_mie->tme_sun_mie_pending_deassert_intr = 1; + } +} +#endif + /* since this function is currently only given to the i825x6, just copy its signal through to the Multibus: */ conn_bus = sun_mie->tme_sun_mie_conn_regs; @@ -665,6 +741,13 @@ _tme_sun_mie_tlb_fill(struct tme_bus_con tlb->tme_bus_tlb_emulator_off_read = tlb->tme_bus_tlb_emulator_off_write; +#if 1 + printf("_tme_sun_mie_tlb_fill() tlb first %08x, last %08x, off_write %08x\n", + (int)tlb->tme_bus_tlb_addr_first, + (int)tlb->tme_bus_tlb_addr_last, + (int)tlb->tme_bus_tlb_emulator_off_write); +#endif + /* add this TLB entry to the active list: */ sun_mie->tme_sun_mie_tlb_tokens[tlb_i] = tlb->tme_bus_tlb_token; @@ -745,6 +828,12 @@ _tme_sun_mie_tlb_fill_regs(struct tme_bu tlb->tme_bus_tlb_emulator_off_read = &sun_mie->tme_sun_mie_regs[0]; tlb->tme_bus_tlb_rwlock = &sun_mie->tme_sun_mie_rwlock; +#if 0 + /* XXX when debugging, nothing is fast readable or writable: */ + tlb->tme_bus_tlb_emulator_off_read = TME_EMULATOR_OFF_UNDEF; + tlb->tme_bus_tlb_emulator_off_write = TME_EMULATOR_OFF_UNDEF; +#endif + /* allow reading and writing: */ tlb->tme_bus_tlb_cycles_ok = TME_BUS_CYCLE_READ | TME_BUS_CYCLE_WRITE;