From 88c077394d60336ff6a759e2e7d11fd9667834cd Mon Sep 17 00:00:00 2001 From: cracyc Date: Wed, 23 Apr 2014 18:14:52 +0000 Subject: [PATCH] i186: use static set irq and clean up leftovers (nw) --- src/emu/cpu/i86/i186.c | 4 +- src/mess/includes/rmnimbus.h | 69 --- src/mess/machine/rmnimbus.c | 1036 ---------------------------------- 3 files changed, 2 insertions(+), 1107 deletions(-) diff --git a/src/emu/cpu/i86/i186.c b/src/emu/cpu/i86/i186.c index 4a40b7e0b85..ad9530556d3 100644 --- a/src/emu/cpu/i86/i186.c +++ b/src/emu/cpu/i86/i186.c @@ -126,6 +126,7 @@ i80188_cpu_device::i80188_cpu_device(const machine_config &mconfig, const char * { memcpy(m_timing, m_i80186_timing, sizeof(m_i80186_timing)); m_fetch_xor = 0; + static_set_irq_acknowledge_callback(*this, device_irq_acknowledge_delegate(FUNC(i80186_cpu_device::int_callback), this)); } i80186_cpu_device::i80186_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -139,6 +140,7 @@ i80186_cpu_device::i80186_cpu_device(const machine_config &mconfig, const char * { memcpy(m_timing, m_i80186_timing, sizeof(m_i80186_timing)); m_fetch_xor = BYTE_XOR_LE(0); + static_set_irq_acknowledge_callback(*this, device_irq_acknowledge_delegate(FUNC(i80186_cpu_device::int_callback), this)); } i80186_cpu_device::i80186_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int data_bus_size) @@ -642,8 +644,6 @@ void i80186_cpu_device::device_reset() m_timer[0].control = 0; m_timer[1].control = 0; m_timer[2].control = 0; - - set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(i80186_cpu_device::int_callback),this)); } UINT8 i80186_cpu_device::read_port_byte(UINT16 port) diff --git a/src/mess/includes/rmnimbus.h b/src/mess/includes/rmnimbus.h index f0dde912069..1cd84453f23 100644 --- a/src/mess/includes/rmnimbus.h +++ b/src/mess/includes/rmnimbus.h @@ -65,61 +65,6 @@ struct t_nimbus_brush }; -/* 80186 internal stuff */ -struct mem_state -{ - UINT16 lower; - UINT16 upper; - UINT16 middle; - UINT16 middle_size; - UINT16 peripheral; -}; - -struct timer_state -{ - UINT16 control; - UINT16 maxA; - UINT16 maxB; - UINT16 count; - emu_timer *int_timer; - emu_timer *time_timer; - UINT8 time_timer_active; - attotime last_time; -}; - -struct dma_state -{ - UINT32 source; - UINT32 dest; - UINT16 count; - UINT16 control; - UINT8 finished; - emu_timer *finish_timer; -}; - -struct intr_state -{ - UINT8 pending; - UINT16 ack_mask; - UINT16 priority_mask; - UINT16 in_service; - UINT16 request; - UINT16 status; - UINT16 poll_status; - UINT16 timer; - UINT16 dma[2]; - UINT16 ext[4]; - UINT16 ext_vector[2]; // external vectors, when in cascade mode -}; - -struct i186_state -{ - struct timer_state timer[3]; - struct dma_state dma[2]; - struct intr_state intr; - struct mem_state mem; -}; - struct keyboard_t { UINT8 keyrows[NIMBUS_KEYROWS]; @@ -390,7 +335,6 @@ public: required_device m_scsi_ctrl_out; UINT32 m_debug_machine; -// i186_state m_i186; keyboard_t m_keyboard; nimbus_drives_t m_nimbus_drives; ipc_interface_t m_ipc_interface; @@ -408,8 +352,6 @@ public: UINT8 m_hs_count; UINT32 m_debug_video; UINT8 m_vector; -// DECLARE_READ16_MEMBER(nimbus_i186_internal_port_r); -// DECLARE_WRITE16_MEMBER(nimbus_i186_internal_port_w); DECLARE_READ8_MEMBER(nimbus_mcu_r); DECLARE_WRITE8_MEMBER(nimbus_mcu_w); DECLARE_READ16_MEMBER(nimbus_io_r); @@ -440,8 +382,6 @@ public: DECLARE_PALETTE_INIT(rmnimbus); UINT32 screen_update_nimbus(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void screen_eof_nimbus(screen_device &screen, bool state); -// TIMER_CALLBACK_MEMBER(internal_timer_int); -// TIMER_CALLBACK_MEMBER(dma_timer_callback); TIMER_CALLBACK_MEMBER(keyscan_callback); TIMER_CALLBACK_MEMBER(mouse_callback); DECLARE_WRITE_LINE_MEMBER(sio_interrupt); @@ -482,17 +422,8 @@ public: void write_reg_01E(); void write_reg_026(); void change_palette(UINT8 bank, UINT16 colours, UINT8 regno); -// void update_interrupt_state(); -// void handle_eoi(int data); void external_int(UINT16 intno, UINT8 vector); DECLARE_READ8_MEMBER(cascade_callback); -// void nimbus_recalculate_ints(); -// void internal_timer_sync(int which); -// void internal_timer_update(int which,int new_count,int new_maxA,int new_maxB,int new_control); -// void update_dma_control(int which, int new_control); -// void drq_callback(int which); -// void nimbus_cpu_init(); -// void nimbus_cpu_reset(); void *get_dssi_ptr(address_space &space, UINT16 ds, UINT16 si); void nimbus_bank_memory(); void memory_reset(); diff --git a/src/mess/machine/rmnimbus.c b/src/mess/machine/rmnimbus.c index 965d11b8750..216d456705c 100644 --- a/src/mess/machine/rmnimbus.c +++ b/src/mess/machine/rmnimbus.c @@ -162,1042 +162,6 @@ static void decode_dssi_f_set_new_clt(device_t *device,UINT16 ds, UINT16 si, UI static void decode_dssi_f_plonk_char(device_t *device,UINT16 ds, UINT16 si, UINT8 raw_flag); static void decode_dssi_f_rw_sectors(device_t *device,UINT16 ds, UINT16 si, UINT8 raw_flag); - -#if 0 -/************************************* - * - * 80186 interrupt controller - * - *************************************/ -IRQ_CALLBACK_MEMBER(rmnimbus_state::int_callback) -{ - UINT8 vector; - UINT16 old; - UINT16 oldreq; - - if (LOG_INTERRUPTS) - logerror("(%f) **** Acknowledged interrupt vector %02X\n", machine().time().as_double(), m_i186.intr.poll_status & 0x1f); - - /* clear the interrupt */ - device.execute().set_input_line(0, CLEAR_LINE); - m_i186.intr.pending = 0; - - oldreq=m_i186.intr.request; - - /* clear the request and set the in-service bit */ -#if LATCH_INTS - m_i186.intr.request &= ~m_i186.intr.ack_mask; -#else - m_i186.intr.request &= ~(m_i186.intr.ack_mask & 0x0f); -#endif - - if((LOG_INTERRUPTS) && (m_i186.intr.request!=oldreq)) - logerror("i186.intr.request changed from %02X to %02X\n",oldreq,m_i186.intr.request); - - old=m_i186.intr.in_service; - - m_i186.intr.in_service |= m_i186.intr.ack_mask; - - if((LOG_INTERRUPTS) && (m_i186.intr.in_service!=old)) - logerror("i186.intr.in_service changed from %02X to %02X\n",old,m_i186.intr.in_service); - - if (m_i186.intr.ack_mask == 0x0001) - { - switch (m_i186.intr.poll_status & 0x1f) - { - case 0x08: m_i186.intr.status &= ~0x01; break; - case 0x12: m_i186.intr.status &= ~0x02; break; - case 0x13: m_i186.intr.status &= ~0x04; break; - } - } - m_i186.intr.ack_mask = 0; - - /* a request no longer pending */ - m_i186.intr.poll_status &= ~0x8000; - - /* return the vector */ - switch(m_i186.intr.poll_status & 0x1F) - { - case 0x0C : vector=(m_i186.intr.ext[0] & EXTINT_CTRL_CASCADE) ? m_i186.intr.ext_vector[0] : (m_i186.intr.poll_status & 0x1f); break; - case 0x0D : vector=(m_i186.intr.ext[1] & EXTINT_CTRL_CASCADE) ? m_i186.intr.ext_vector[1] : (m_i186.intr.poll_status & 0x1f); break; - default : - vector=m_i186.intr.poll_status & 0x1f; break; - } - - if (LOG_INTERRUPTS) - { - logerror("i186.intr.ext[0]=%04X i186.intr.ext[1]=%04X\n",m_i186.intr.ext[0],m_i186.intr.ext[1]); - logerror("Ext vectors : %02X %02X\n",m_i186.intr.ext_vector[0],m_i186.intr.ext_vector[1]); - logerror("Int %02X Calling vector %02X\n",m_i186.intr.poll_status,vector); - } - - return vector; -} - - -void rmnimbus_state::update_interrupt_state() -{ - int new_vector = 0; - int Priority; - int IntNo; - - if (LOG_INTERRUPTS) - logerror("update_interrupt_status: req=%04X stat=%04X serv=%04X priority_mask=%4X\n", m_i186.intr.request, m_i186.intr.status, m_i186.intr.in_service, m_i186.intr.priority_mask); - - /* loop over priorities */ - for (Priority = 0; Priority <= m_i186.intr.priority_mask; Priority++) - { - /* note: by checking 4 bits, we also verify that the mask is off */ - if ((m_i186.intr.timer & 0x0F) == Priority) - { - /* if we're already servicing something at this level, don't generate anything new */ - if (m_i186.intr.in_service & 0x01) - return; - - /* if there's something pending, generate an interrupt */ - if (m_i186.intr.status & 0x07) - { - if (m_i186.intr.status & 1) - new_vector = 0x08; - else if (m_i186.intr.status & 2) - new_vector = 0x12; - else if (m_i186.intr.status & 4) - new_vector = 0x13; - else - popmessage("Invalid timer interrupt!"); - - /* set the clear mask and generate the int */ - m_i186.intr.ack_mask = 0x0001; - goto generate_int; - } - } - - /* check DMA interrupts */ - for (IntNo = 0; IntNo < 2; IntNo++) - if ((m_i186.intr.dma[IntNo] & 0x0F) == Priority) - { - /* if we're already servicing something at this level, don't generate anything new */ - if (m_i186.intr.in_service & (0x04 << IntNo)) - return; - - /* if there's something pending, generate an interrupt */ - if (m_i186.intr.request & (0x04 << IntNo)) - { - new_vector = 0x0a + IntNo; - - /* set the clear mask and generate the int */ - m_i186.intr.ack_mask = 0x0004 << IntNo; - goto generate_int; - } - } - - /* check external interrupts */ - for (IntNo = 0; IntNo < 4; IntNo++) - if ((m_i186.intr.ext[IntNo] & 0x0F) == Priority) - { - if (LOG_INTERRUPTS) - logerror("Int%d priority=%d\n",IntNo,Priority); - - /* if we're already servicing something at this level, don't generate anything new */ - if (m_i186.intr.in_service & (0x10 << IntNo)) - return; - - /* if there's something pending, generate an interrupt */ - if (m_i186.intr.request & (0x10 << IntNo)) - { - /* otherwise, generate an interrupt for this request */ - new_vector = 0x0c + IntNo; - - /* set the clear mask and generate the int */ - m_i186.intr.ack_mask = 0x0010 << IntNo; - goto generate_int; - } - } - } - return; - -generate_int: - /* generate the appropriate interrupt */ - m_i186.intr.poll_status = 0x8000 | new_vector; - if (!m_i186.intr.pending) - m_maincpu->set_input_line(0, ASSERT_LINE); - m_i186.intr.pending = 1; - machine().scheduler().trigger(CPU_RESUME_TRIGGER); - if (LOG_OPTIMIZATION) logerror(" - trigger due to interrupt pending\n"); - if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", machine().time().as_double(), new_vector); -} - - -void rmnimbus_state::handle_eoi(int data) -{ - int Priority; - int IntNo; - int handled=0; - - /* specific case */ - if (!(data & 0x8000)) - { - /* turn off the appropriate in-service bit */ - switch (data & 0x1f) - { - case 0x08: m_i186.intr.in_service &= ~0x01; break; - case 0x12: m_i186.intr.in_service &= ~0x01; break; - case 0x13: m_i186.intr.in_service &= ~0x01; break; - case 0x0a: m_i186.intr.in_service &= ~0x04; break; - case 0x0b: m_i186.intr.in_service &= ~0x08; break; - case 0x0c: m_i186.intr.in_service &= ~0x10; break; - case 0x0d: m_i186.intr.in_service &= ~0x20; break; - case 0x0e: m_i186.intr.in_service &= ~0x40; break; - case 0x0f: m_i186.intr.in_service &= ~0x80; break; - default: logerror("%05X:ERROR - 80186 EOI with unknown vector %02X\n", m_maincpu->pc(), data & 0x1f); - } - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", machine().time().as_double(), data & 0x1f); - } - - /* non-specific case */ - else - { - /* loop over priorities */ - for (Priority = 0; ((Priority <= 7) && !handled); Priority++) - { - /* check for in-service timers */ - if ((m_i186.intr.timer & 0x07) == Priority && (m_i186.intr.in_service & 0x01)) - { - m_i186.intr.in_service &= ~0x01; - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", machine().time().as_double()); - handled=1; - } - - /* check for in-service DMA interrupts */ - for (IntNo = 0; ((IntNo < 2) && !handled) ; IntNo++) - if ((m_i186.intr.dma[IntNo] & 0x07) == Priority && (m_i186.intr.in_service & (0x04 << IntNo))) - { - m_i186.intr.in_service &= ~(0x04 << IntNo); - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", machine().time().as_double(), IntNo); - handled=1; - } - - /* check external interrupts */ - for (IntNo = 0; ((IntNo < 4) && !handled) ; IntNo++) - if ((m_i186.intr.ext[IntNo] & 0x07) == Priority && (m_i186.intr.in_service & (0x10 << IntNo))) - { - m_i186.intr.in_service &= ~(0x10 << IntNo); - if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", machine().time().as_double(), IntNo); - handled=1; - } - } - } - nimbus_recalculate_ints(); -} - -/* Trigger an external interupt, optionally supplying the vector to take */ -void rmnimbus_state::external_int(UINT16 intno, UINT8 vector) -{ - if (LOG_INTERRUPTS_EXT) logerror("generating external int %02X, vector %02X\n",intno,vector); - - // Only 4 external ints - if(intno>3) - { - logerror("external_int() invalid external interupt no : 0x%02X (can only be 0..3)\n",intno); - return; - } - - // Only set external vector if cascade mode enabled, only valid for - // int 0 & int 1 - if (intno<2) - { - if(m_i186.intr.ext[intno] & EXTINT_CTRL_CASCADE) - m_i186.intr.ext_vector[intno]=vector; - } - - // Turn on the requested request bit and handle interrupt - m_i186.intr.request |= (0x010 << intno); - update_interrupt_state(); -} - -void rmnimbus_state::nimbus_recalculate_ints() -{ - if((m_iou_reg092 & DISK_INT_ENABLE) && m_nimbus_drives.int_ff) - { - m_nimbus_drives.int_ff=0; - external_int(0,EXTERNAL_INT_DISK); - } -} - -/************************************* - * - * 80186 internal timers - * - *************************************/ - -TIMER_CALLBACK_MEMBER(rmnimbus_state::internal_timer_int) -{ - int which = param; - struct timer_state *t = &m_i186.timer[which]; - - if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which); - - /* set the max count bit */ - t->control |= 0x0020; - - /* request an interrupt */ - if (t->control & 0x2000) - { - m_i186.intr.status |= 0x01 << which; - update_interrupt_state(); - if (LOG_TIMER) logerror(" Generating timer interrupt\n"); - } - - /* if we're continuous, reset */ - if (t->control & 0x0001) - { - int count = t->maxA ? t->maxA : 0x10000; - t->int_timer->adjust((attotime::from_hz(2000000) * count), which); - if (LOG_TIMER) logerror(" Repriming interrupt\n"); - } - else - t->int_timer->adjust(attotime::never, which); -} - - -void rmnimbus_state::internal_timer_sync(int which) -{ - struct timer_state *t = &m_i186.timer[which]; - - /* if we have a timing timer running, adjust the count */ - if (t->time_timer_active) - { - attotime current_time = t->time_timer->elapsed(); - int net_clocks = ((current_time - t->last_time) * 2000000).seconds; - t->last_time = current_time; - - /* set the max count bit if we passed the max */ - if ((int)t->count + net_clocks >= t->maxA) - t->control |= 0x0020; - - /* set the new count */ - if (t->maxA != 0) - t->count = (t->count + net_clocks) % t->maxA; - else - t->count = t->count + net_clocks; - } -} - - -void rmnimbus_state::internal_timer_update(int which,int new_count,int new_maxA,int new_maxB,int new_control) -{ - struct timer_state *t = &m_i186.timer[which]; - int update_int_timer = 0; - - if (LOG_TIMER) - logerror("internal_timer_update: %d, new_count=%d, new_maxA=%d, new_maxB=%d,new_control=%d\n",which,new_count,new_maxA,new_maxB,new_control); - - /* if we have a new count and we're on, update things */ - if (new_count != -1) - { - if (t->control & 0x8000) - { - internal_timer_sync(which); - update_int_timer = 1; - } - t->count = new_count; - } - - /* if we have a new max and we're on, update things */ - if (new_maxA != -1 && new_maxA != t->maxA) - { - if (t->control & 0x8000) - { - internal_timer_sync(which); - update_int_timer = 1; - } - t->maxA = new_maxA; - if (new_maxA == 0) - { - new_maxA = 0x10000; - } - } - - /* if we have a new max and we're on, update things */ - if (new_maxB != -1 && new_maxB != t->maxB) - { - if (t->control & 0x8000) - { - internal_timer_sync(which); - update_int_timer = 1; - } - - t->maxB = new_maxB; - - if (new_maxB == 0) - { - new_maxB = 0x10000; - } - } - - - /* handle control changes */ - if (new_control != -1) - { - int diff; - - /* merge back in the bits we don't modify */ - new_control = (new_control & ~0x1fc0) | (t->control & 0x1fc0); - - /* handle the /INH bit */ - if (!(new_control & 0x4000)) - new_control = (new_control & ~0x8000) | (t->control & 0x8000); - new_control &= ~0x4000; - - /* check for control bits we don't handle */ - diff = new_control ^ t->control; - if (diff & 0x001c) - logerror("%05X:ERROR! -unsupported timer mode %04X\n", - m_maincpu->pc(), new_control); - - /* if we have real changes, update things */ - if (diff != 0) - { - /* if we're going off, make sure our timers are gone */ - if ((diff & 0x8000) && !(new_control & 0x8000)) - { - /* compute the final count */ - internal_timer_sync(which); - - /* nuke the timer and force the interrupt timer to be recomputed */ - t->time_timer->adjust(attotime::never, which); - t->time_timer_active = 0; - update_int_timer = 1; - } - - /* if we're going on, start the timers running */ - else if ((diff & 0x8000) && (new_control & 0x8000)) - { - /* start the timing */ - t->time_timer->adjust(attotime::never, which); - t->time_timer_active = 1; - update_int_timer = 1; - } - - /* if something about the interrupt timer changed, force an update */ - if (!(diff & 0x8000) && (diff & 0x2000)) - { - internal_timer_sync(which); - update_int_timer = 1; - } - } - - /* set the new control register */ - t->control = new_control; - } - - /* update the interrupt timer */ - if (update_int_timer) - { - if ((t->control & 0x8000) && (t->control & 0x2000)) - { - int diff = t->maxA - t->count; - if (diff <= 0) - diff += 0x10000; - t->int_timer->adjust(attotime::from_hz(2000000) * diff, which); - if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which); - } - else - { - t->int_timer->adjust(attotime::never, which); - } - } -} - - - -/************************************* - * - * 80186 internal DMA - * - *************************************/ - -TIMER_CALLBACK_MEMBER(rmnimbus_state::dma_timer_callback) -{ - int which = param; - struct dma_state *d = &m_i186.dma[which]; - - /* complete the status update */ - d->control &= ~0x0002; - d->source += d->count; - d->count = 0; - - /* check for interrupt generation */ - if (d->control & 0x0100) - { - if (LOG_DMA>1) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source); - m_i186.intr.request |= 0x04 << which; - update_interrupt_state(); - } -} - - -void rmnimbus_state::update_dma_control(int which, int new_control) -{ - struct dma_state *d = &m_i186.dma[which]; - int diff; - - /* handle the CHG bit */ - if (!(new_control & CHG_NOCHG)) - new_control = (new_control & ~ST_STOP) | (d->control & ST_STOP); - new_control &= ~CHG_NOCHG; - - /* check for control bits we don't handle */ - diff = new_control ^ d->control; - if ((LOG_DMA) && (diff & 0x6811)) - logerror("%05X:ERROR! - unsupported DMA mode %04X\n", - m_maincpu->pc(), new_control); -#if 0 - /* if we're going live, set a timer */ - if ((diff & 0x0002) && (new_control & 0x0002)) - { - /* make sure the parameters meet our expectations */ - if ((new_control & 0xfe00) != 0x1600) - { - if (LOG_DMA) logerror("Unexpected DMA control %02X\n", new_control); - } - else if (/*!is_redline &&*/ ((d->dest & 1) || (d->dest & 0x3f) > 0x0b)) - { - if (LOG_DMA) logerror("Unexpected DMA destination %02X\n", d->dest); - } - else if (/*is_redline && */ (d->dest & 0xf000) != 0x4000 && (d->dest & 0xf000) != 0x5000) - { - if (LOG_DMA) logerror("Unexpected DMA destination %02X\n", d->dest); - } - - /* otherwise, set a timer */ - else - { - d->finished = 0; - } - } -#endif - - if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest); - if (DEBUG_SET(DMA_BREAK)) - debugger_break(machine()); - - /* set the new control register */ - d->control = new_control; -} - -void rmnimbus_state::drq_callback(int which) -{ - struct dma_state *dma = &m_i186.dma[which]; - address_space &memory_space = m_maincpu->space(AS_PROGRAM); - address_space &io_space = m_maincpu->space(AS_IO); - - UINT16 dma_word; - UINT8 dma_byte; - UINT8 incdec_size; - - if (LOG_DMA>1) - logerror("Control=%04X, src=%05X, dest=%05X, count=%04X\n",dma->control,dma->source,dma->dest,dma->count); - - if(!(dma->control & ST_STOP)) - { - logerror("%05X:ERROR! - drq%d with dma channel stopped\n", - m_maincpu->pc(), which); - - return; - } - - address_space &dest_space = (dma->control & DEST_MIO) ? memory_space : io_space; - address_space &src_space = (dma->control & SRC_MIO) ? memory_space : io_space; - - // Do the transfer - if(dma->control & BYTE_WORD) - { - dma_word=src_space.read_word(dma->source); - dest_space.write_word(dma->dest,dma_word); - incdec_size=2; - } - else - { - dma_byte=src_space.read_byte(dma->source); - dest_space.write_byte(dma->dest,dma_byte); - incdec_size=1; - } - - // Increment or Decrement destination ans source pointers as needed - switch (dma->control & DEST_INCDEC_MASK) - { - case DEST_DECREMENT : dma->dest -= incdec_size; - case DEST_INCREMENT : dma->dest += incdec_size; - } - - switch (dma->control & SRC_INCDEC_MASK) - { - case SRC_DECREMENT : dma->source -= incdec_size; - case SRC_INCREMENT : dma->source += incdec_size; - } - - // decrement count - dma->count -= 1; - - // Terminate if count is zero, and terminate flag set - if((dma->control & TERMINATE_ON_ZERO) && (dma->count==0)) - { - dma->control &= ~ST_STOP; - if (LOG_DMA) logerror("DMA terminated\n"); - } - - // Interrupt if count is zero, and interrupt flag set - if((dma->control & INTERRUPT_ON_ZERO) && (dma->count==0)) - { - if (LOG_DMA>1) logerror("DMA%d - requesting interrupt: count = %04X, source = %04X\n", which, dma->count, dma->source); - m_i186.intr.request |= 0x04 << which; - update_interrupt_state(); - } -} - -/*-------------------------------------------------------------------------*/ -/* Name: rmnimbus */ -/* Desc: CPU - Initialize the 80186 CPU */ -/*-------------------------------------------------------------------------*/ -void rmnimbus_state::nimbus_cpu_init() -{ - logerror("Machine reset\n"); - - /* create timers here so they stick around */ - m_i186.timer[0].int_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),this)); - m_i186.timer[1].int_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),this)); - m_i186.timer[2].int_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::internal_timer_int),this)); - m_i186.timer[0].time_timer = machine().scheduler().timer_alloc(FUNC_NULL); - m_i186.timer[1].time_timer = machine().scheduler().timer_alloc(FUNC_NULL); - m_i186.timer[2].time_timer = machine().scheduler().timer_alloc(FUNC_NULL); - m_i186.dma[0].finish_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::dma_timer_callback),this)); - m_i186.dma[1].finish_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(rmnimbus_state::dma_timer_callback),this)); -} - -void rmnimbus_state::nimbus_cpu_reset() -{ - /* reset the interrupt state */ - m_i186.intr.priority_mask = 0x0007; - m_i186.intr.timer = 0x000f; - m_i186.intr.dma[0] = 0x000f; - m_i186.intr.dma[1] = 0x000f; - m_i186.intr.ext[0] = 0x000f; - m_i186.intr.ext[1] = 0x000f; - m_i186.intr.ext[2] = 0x000f; - m_i186.intr.ext[3] = 0x000f; - m_i186.intr.in_service = 0x0000; - - /* External vectors by default to internal int 0/1 vectors */ - m_i186.intr.ext_vector[0] = 0x000C; - m_i186.intr.ext_vector[1] = 0x000D; - - m_i186.intr.pending = 0x0000; - m_i186.intr.ack_mask = 0x0000; - m_i186.intr.request = 0x0000; - m_i186.intr.status = 0x0000; - m_i186.intr.poll_status = 0x0000; - - logerror("CPU reset done\n"); -} - -READ16_MEMBER(rmnimbus_state::nimbus_i186_internal_port_r) -{ - int temp, which; - - switch (offset) - { - case 0x11: - logerror("%05X:ERROR - read from 80186 EOI\n", space.device().safe_pc()); - break; - - case 0x12: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll\n", space.device().safe_pc()); - if (m_i186.intr.poll_status & 0x8000) - int_callback(*m_maincpu, 0); - return m_i186.intr.poll_status; - - case 0x13: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll status\n", space.device().safe_pc()); - return m_i186.intr.poll_status; - - case 0x14: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt mask\n", space.device().safe_pc()); - temp = (m_i186.intr.timer >> 3) & 0x01; - temp |= (m_i186.intr.dma[0] >> 1) & 0x04; - temp |= (m_i186.intr.dma[1] >> 0) & 0x08; - temp |= (m_i186.intr.ext[0] << 1) & 0x10; - temp |= (m_i186.intr.ext[1] << 2) & 0x20; - temp |= (m_i186.intr.ext[2] << 3) & 0x40; - temp |= (m_i186.intr.ext[3] << 4) & 0x80; - return temp; - - case 0x15: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt priority mask\n", space.device().safe_pc()); - return m_i186.intr.priority_mask; - - case 0x16: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt in-service\n", space.device().safe_pc()); - return m_i186.intr.in_service; - - case 0x17: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt request\n", space.device().safe_pc()); - temp = m_i186.intr.request & ~0x0001; - if (m_i186.intr.status & 0x0007) - temp |= 1; - return temp; - - case 0x18: - if (LOG_PORTS) logerror("%05X:read 80186 interrupt status\n", space.device().safe_pc()); - return m_i186.intr.status; - - case 0x19: - if (LOG_PORTS) logerror("%05X:read 80186 timer interrupt control\n", space.device().safe_pc()); - return m_i186.intr.timer; - - case 0x1a: - if (LOG_PORTS) logerror("%05X:read 80186 DMA 0 interrupt control\n", space.device().safe_pc()); - return m_i186.intr.dma[0]; - - case 0x1b: - if (LOG_PORTS) logerror("%05X:read 80186 DMA 1 interrupt control\n", space.device().safe_pc()); - return m_i186.intr.dma[1]; - - case 0x1c: - if (LOG_PORTS) logerror("%05X:read 80186 INT 0 interrupt control\n", space.device().safe_pc()); - return m_i186.intr.ext[0]; - - case 0x1d: - if (LOG_PORTS) logerror("%05X:read 80186 INT 1 interrupt control\n", space.device().safe_pc()); - return m_i186.intr.ext[1]; - - case 0x1e: - if (LOG_PORTS) logerror("%05X:read 80186 INT 2 interrupt control\n", space.device().safe_pc()); - return m_i186.intr.ext[2]; - - case 0x1f: - if (LOG_PORTS) logerror("%05X:read 80186 INT 3 interrupt control\n", space.device().safe_pc()); - return m_i186.intr.ext[3]; - - case 0x28: - case 0x2c: - case 0x30: - if (LOG_PORTS) logerror("%05X:read 80186 Timer %d count\n", space.device().safe_pc(), (offset - 0x28) / 4); - which = (offset - 0x28) / 4; - if (!(offset & 1)) - internal_timer_sync(which); - return m_i186.timer[which].count; - - case 0x29: - case 0x2d: - case 0x31: - if (LOG_PORTS) logerror("%05X:read 80186 Timer %d max A\n", space.device().safe_pc(), (offset - 0x29) / 4); - which = (offset - 0x29) / 4; - return m_i186.timer[which].maxA; - - case 0x2a: - case 0x2e: - logerror("%05X:read 80186 Timer %d max B\n", space.device().safe_pc(), (offset - 0x2a) / 4); - which = (offset - 0x2a) / 4; - return m_i186.timer[which].maxB; - - case 0x2b: - case 0x2f: - case 0x33: - if (LOG_PORTS) logerror("%05X:read 80186 Timer %d control\n", space.device().safe_pc(), (offset - 0x2b) / 4); - which = (offset - 0x2b) / 4; - return m_i186.timer[which].control; - - case 0x50: - if (LOG_PORTS) logerror("%05X:read 80186 upper chip select\n", space.device().safe_pc()); - return m_i186.mem.upper; - - case 0x51: - if (LOG_PORTS) logerror("%05X:read 80186 lower chip select\n", space.device().safe_pc()); - return m_i186.mem.lower; - - case 0x52: - if (LOG_PORTS) logerror("%05X:read 80186 peripheral chip select\n", space.device().safe_pc()); - return m_i186.mem.peripheral; - - case 0x53: - if (LOG_PORTS) logerror("%05X:read 80186 middle chip select\n", space.device().safe_pc()); - return m_i186.mem.middle; - - case 0x54: - if (LOG_PORTS) logerror("%05X:read 80186 middle P chip select\n", space.device().safe_pc()); - return m_i186.mem.middle_size; - - case 0x60: - case 0x68: - if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower source address\n", space.device().safe_pc(), (offset - 0x60) / 8); - which = (offset - 0x60) / 8; - return m_i186.dma[which].source; - - case 0x61: - case 0x69: - if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper source address\n", space.device().safe_pc(), (offset - 0x61) / 8); - which = (offset - 0x61) / 8; - return m_i186.dma[which].source >> 16; - - case 0x62: - case 0x6a: - if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower dest address\n", space.device().safe_pc(), (offset - 0x62) / 8); - which = (offset - 0x62) / 8; - return m_i186.dma[which].dest; - - case 0x63: - case 0x6b: - if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper dest address\n", space.device().safe_pc(), (offset - 0x63) / 8); - which = (offset - 0x63) / 8; - return m_i186.dma[which].dest >> 16; - - case 0x64: - case 0x6c: - if (LOG_PORTS) logerror("%05X:read 80186 DMA%d transfer count\n", space.device().safe_pc(), (offset - 0x64) / 8); - which = (offset - 0x64) / 8; - return m_i186.dma[which].count; - - case 0x65: - case 0x6d: - if (LOG_PORTS) logerror("%05X:read 80186 DMA%d control\n", space.device().safe_pc(), (offset - 0x65) / 8); - which = (offset - 0x65) / 8; - return m_i186.dma[which].control; - - default: - logerror("%05X:read 80186 port %02X\n", space.device().safe_pc(), offset); - break; - } - return 0x00; -} - -/************************************* - * - * 80186 internal I/O writes - * - *************************************/ - -WRITE16_MEMBER(rmnimbus_state::nimbus_i186_internal_port_w) -{ - int temp, which, data16 = data; - - switch (offset) - { - case 0x11: - if (LOG_PORTS) logerror("%05X:80186 EOI = %04X\n", space.device().safe_pc(), data16); - handle_eoi(0x8000); - update_interrupt_state(); - break; - - case 0x12: - logerror("%05X:ERROR - write to 80186 interrupt poll = %04X\n", space.device().safe_pc(), data16); - break; - - case 0x13: - logerror("%05X:ERROR - write to 80186 interrupt poll status = %04X\n", space.device().safe_pc(), data16); - break; - - case 0x14: - if (LOG_PORTS) logerror("%05X:80186 interrupt mask = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.timer = (m_i186.intr.timer & ~0x08) | ((data16 << 3) & 0x08); - m_i186.intr.dma[0] = (m_i186.intr.dma[0] & ~0x08) | ((data16 << 1) & 0x08); - m_i186.intr.dma[1] = (m_i186.intr.dma[1] & ~0x08) | ((data16 << 0) & 0x08); - m_i186.intr.ext[0] = (m_i186.intr.ext[0] & ~0x08) | ((data16 >> 1) & 0x08); - m_i186.intr.ext[1] = (m_i186.intr.ext[1] & ~0x08) | ((data16 >> 2) & 0x08); - m_i186.intr.ext[2] = (m_i186.intr.ext[2] & ~0x08) | ((data16 >> 3) & 0x08); - m_i186.intr.ext[3] = (m_i186.intr.ext[3] & ~0x08) | ((data16 >> 4) & 0x08); - update_interrupt_state(); - break; - - case 0x15: - if (LOG_PORTS) logerror("%05X:80186 interrupt priority mask = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.priority_mask = data16 & 0x0007; - update_interrupt_state(); - break; - - case 0x16: - if (LOG_PORTS) logerror("%05X:80186 interrupt in-service = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.in_service = data16 & 0x00ff; - update_interrupt_state(); - break; - - case 0x17: - if (LOG_PORTS) logerror("%05X:80186 interrupt request = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.request = (m_i186.intr.request & ~0x00c0) | (data16 & 0x00c0); - update_interrupt_state(); - break; - - case 0x18: - if (LOG_PORTS) logerror("%05X:WARNING - wrote to 80186 interrupt status = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.status = (m_i186.intr.status & ~0x8007) | (data16 & 0x8007); - update_interrupt_state(); - break; - - case 0x19: - if (LOG_PORTS) logerror("%05X:80186 timer interrupt contol = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.timer = data16 & 0x000f; - break; - - case 0x1a: - if (LOG_PORTS) logerror("%05X:80186 DMA 0 interrupt control = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.dma[0] = data16 & 0x000f; - break; - - case 0x1b: - if (LOG_PORTS) logerror("%05X:80186 DMA 1 interrupt control = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.dma[1] = data16 & 0x000f; - break; - - case 0x1c: - if (LOG_PORTS) logerror("%05X:80186 INT 0 interrupt control = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.ext[0] = data16 & 0x007f; - break; - - case 0x1d: - if (LOG_PORTS) logerror("%05X:80186 INT 1 interrupt control = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.ext[1] = data16 & 0x007f; - break; - - case 0x1e: - if (LOG_PORTS) logerror("%05X:80186 INT 2 interrupt control = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.ext[2] = data16 & 0x001f; - break; - - case 0x1f: - if (LOG_PORTS) logerror("%05X:80186 INT 3 interrupt control = %04X\n", space.device().safe_pc(), data16); - m_i186.intr.ext[3] = data16 & 0x001f; - break; - - case 0x28: - case 0x2c: - case 0x30: - if (LOG_PORTS) logerror("%05X:80186 Timer %d count = %04X\n", space.device().safe_pc(), (offset - 0x28) / 4, data16); - which = (offset - 0x28) / 4; - internal_timer_update(which, data16, -1, -1, -1); - break; - - case 0x29: - case 0x2d: - case 0x31: - if (LOG_PORTS) logerror("%05X:80186 Timer %d max A = %04X\n", space.device().safe_pc(), (offset - 0x29) / 4, data16); - which = (offset - 0x29) / 4; - internal_timer_update(which, -1, data16, -1, -1); - break; - - case 0x2a: - case 0x2e: - if (LOG_PORTS) logerror("%05X:80186 Timer %d max B = %04X\n", space.device().safe_pc(), (offset - 0x2a) / 4, data16); - which = (offset - 0x2a) / 4; - internal_timer_update(which, -1, -1, data16, -1); - break; - - case 0x2b: - case 0x2f: - case 0x33: - if (LOG_PORTS) logerror("%05X:80186 Timer %d control = %04X\n", space.device().safe_pc(), (offset - 0x2b) / 4, data16); - which = (offset - 0x2b) / 4; - internal_timer_update(which, -1, -1, -1, data16); - break; - - case 0x50: - if (LOG_PORTS) logerror("%05X:80186 upper chip select = %04X\n", space.device().safe_pc(), data16); - m_i186.mem.upper = data16 | 0xc038; - break; - - case 0x51: - if (LOG_PORTS) logerror("%05X:80186 lower chip select = %04X\n", space.device().safe_pc(), data16); - m_i186.mem.lower = (data16 & 0x3fff) | 0x0038; printf("%X",m_i186.mem.lower); - break; - - case 0x52: - if (LOG_PORTS) logerror("%05X:80186 peripheral chip select = %04X\n", space.device().safe_pc(), data16); - m_i186.mem.peripheral = data16 | 0x0038; - break; - - case 0x53: - if (LOG_PORTS) logerror("%05X:80186 middle chip select = %04X\n", space.device().safe_pc(), data16); - m_i186.mem.middle = data16 | 0x01f8; - break; - - case 0x54: - if (LOG_PORTS) logerror("%05X:80186 middle P chip select = %04X\n", space.device().safe_pc(), data16); - m_i186.mem.middle_size = data16 | 0x8038; - - /* we need to do this at a time when the I86 context is swapped in */ - /* this register is generally set once at startup and never again, so it's a good */ - /* time to set it up */ - space.device().execute().set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(rmnimbus_state::int_callback),this)); - break; - - case 0x60: - case 0x68: - if (LOG_PORTS) logerror("%05X:80186 DMA%d lower source address = %04X\n", space.device().safe_pc(), (offset - 0x60) / 8, data16); - which = (offset - 0x60) / 8; - m_i186.dma[which].source = (m_i186.dma[which].source & ~0x0ffff) | (data16 & 0x0ffff); - break; - - case 0x61: - case 0x69: - if (LOG_PORTS) logerror("%05X:80186 DMA%d upper source address = %04X\n", space.device().safe_pc(), (offset - 0x61) / 8, data16); - which = (offset - 0x61) / 8; - m_i186.dma[which].source = (m_i186.dma[which].source & ~0xf0000) | ((data16 << 16) & 0xf0000); - break; - - case 0x62: - case 0x6a: - if (LOG_PORTS) logerror("%05X:80186 DMA%d lower dest address = %04X\n", space.device().safe_pc(), (offset - 0x62) / 8, data16); - which = (offset - 0x62) / 8; - m_i186.dma[which].dest = (m_i186.dma[which].dest & ~0x0ffff) | (data16 & 0x0ffff); - break; - - case 0x63: - case 0x6b: - if (LOG_PORTS) logerror("%05X:80186 DMA%d upper dest address = %04X\n", space.device().safe_pc(), (offset - 0x63) / 8, data16); - which = (offset - 0x63) / 8; - m_i186.dma[which].dest = (m_i186.dma[which].dest & ~0xf0000) | ((data16 << 16) & 0xf0000); - break; - - case 0x64: - case 0x6c: - if (LOG_PORTS) logerror("%05X:80186 DMA%d transfer count = %04X\n", space.device().safe_pc(), (offset - 0x64) / 8, data16); - which = (offset - 0x64) / 8; - m_i186.dma[which].count = data16; - break; - - case 0x65: - case 0x6d: - if (LOG_PORTS) logerror("%05X:80186 DMA%d control = %04X\n", space.device().safe_pc(), (offset - 0x65) / 8, data16); - which = (offset - 0x65) / 8; - update_dma_control(which, data16); - break; - - case 0x7f: - if (LOG_PORTS) logerror("%05X:80186 relocation register = %04X\n", space.device().safe_pc(), data16); - - /* we assume here there that this doesn't happen too often */ - /* plus, we can't really remove the old memory range, so we also assume that it's */ - /* okay to leave us mapped where we were */ - temp = (data16 & 0x0fff) << 8; - if (data16 & 0x1000) - { - m_maincpu->space(AS_PROGRAM).install_read_handler(temp, temp + 0xff, read16_delegate(FUNC(rmnimbus_state::nimbus_i186_internal_port_r),this)); - m_maincpu->space(AS_PROGRAM).install_write_handler(temp, temp + 0xff, write16_delegate(FUNC(rmnimbus_state::nimbus_i186_internal_port_w),this)); - } - else - { - temp &= 0xffff; - m_maincpu->space(AS_IO).install_read_handler(temp, temp + 0xff, read16_delegate(FUNC(rmnimbus_state::nimbus_i186_internal_port_r),this)); - m_maincpu->space(AS_IO).install_write_handler(temp, temp + 0xff, write16_delegate(FUNC(rmnimbus_state::nimbus_i186_internal_port_w),this)); - } - break; - - default: - logerror("%05X:80186 port %02X = %04X\n", space.device().safe_pc(), offset, data16); - break; - } -} -#endif - void rmnimbus_state::external_int(UINT16 intno, UINT8 vector) { m_vector = vector;