From 88ddada87a945c4424bd275f190463e8cabc601c Mon Sep 17 00:00:00 2001 From: cracyc Date: Tue, 2 Jul 2024 12:58:44 -0500 Subject: isa/dectalk: hack it to work until it can be better understood i386: some limit checks --- src/devices/bus/isa/dectalk.cpp | 10 +++------- src/devices/cpu/i386/i386.cpp | 6 +++--- src/devices/cpu/i386/i386.h | 4 ++-- src/devices/cpu/i386/i386op16.hxx | 10 +++++----- src/devices/cpu/i386/i386op32.hxx | 10 +++++----- src/devices/cpu/i386/i386segs.hxx | 4 ++-- src/devices/cpu/i86/i186.h | 3 +++ src/devices/machine/at.cpp | 1 + src/devices/machine/genpc.cpp | 1 + 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/devices/bus/isa/dectalk.cpp b/src/devices/bus/isa/dectalk.cpp index a66896f51a4..2d61a1fe6f0 100644 --- a/src/devices/bus/isa/dectalk.cpp +++ b/src/devices/bus/isa/dectalk.cpp @@ -53,14 +53,11 @@ uint16_t dectalk_isa_device::host_irq_r() uint8_t dectalk_isa_device::dma_r() { - if (!machine().side_effects_disabled()) - m_cpu->drq1_w(0); return m_dma; } void dectalk_isa_device::dma_w(uint8_t data) { - m_cpu->drq1_w(0); m_dma = data; } @@ -88,7 +85,6 @@ void dectalk_isa_device::output_ctl_w(uint16_t data) uint16_t dectalk_isa_device::dsp_dma_r() { m_bio = ASSERT_LINE; - m_cpu->drq1_w(0); return m_dsp_dma; } @@ -102,7 +98,7 @@ int dectalk_isa_device::bio_line_r() { // TODO: reading the bio line doesn't cause any direct external effects so this is wrong if(m_bio == ASSERT_LINE) - m_cpu->drq0_w(1); + m_cpu->dma_sync_req(0); return m_bio; } @@ -191,7 +187,7 @@ void dectalk_isa_device::write(offs_t offset, uint8_t data) break; case 4: m_dma = data; - m_cpu->drq1_w(1); + m_cpu->dma_sync_req(1); break; case 6: m_cpu->int1_w(1); @@ -213,7 +209,7 @@ uint8_t dectalk_isa_device::read(offs_t offset) return m_data >> 8; case 4: if (!machine().side_effects_disabled()) - m_cpu->drq1_w(1); + m_cpu->dma_sync_req(1); return m_dma; } return 0; diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp index 62d3e17dabb..3a1ae532b6c 100644 --- a/src/devices/cpu/i386/i386.cpp +++ b/src/devices/cpu/i386/i386.cpp @@ -40,7 +40,7 @@ #define LOG_PM_FAULT_DF (1U << 10) #define LOG_PM_FAULT_UD (1U << 11) -//#define VERBOSE (LOG_PM_FAULT_GP) +#define VERBOSE (LOG_PM_FAULT_GP | LOG_PM_FAULT_UD | LOG_PM_EVENTS | LOG_LIMIT_CHECK) #include "logmacro.h" /* seems to be defined on mingw-gcc */ @@ -165,14 +165,14 @@ MODRM_TABLE i386_MODRM_table[256]; /*************************************************************************/ -uint32_t i386_device::i386_translate(int segment, uint32_t ip, int rwn) +uint32_t i386_device::i386_translate(int segment, uint32_t ip, int rwn, int size) { // TODO: segment limit access size, execution permission, handle exception thrown from exception handler if (PROTECTED_MODE && !V8086_MODE && (rwn != -1)) { if (!(m_sreg[segment].valid)) FAULT_THROW((segment == SS) ? FAULT_SS : FAULT_GP, 0); - if (i386_limit_check(segment, ip)) + if (i386_limit_check(segment, ip, size)) FAULT_THROW((segment == SS) ? FAULT_SS : FAULT_GP, 0); if ((rwn == 0) && ((m_sreg[segment].flags & 8) && !(m_sreg[segment].flags & 2))) FAULT_THROW(FAULT_GP, 0); diff --git a/src/devices/cpu/i386/i386.h b/src/devices/cpu/i386/i386.h index 7889ce5f0a8..634421c238c 100644 --- a/src/devices/cpu/i386/i386.h +++ b/src/devices/cpu/i386/i386.h @@ -435,7 +435,7 @@ protected: void register_state_i386(); void register_state_i386_x87(); void register_state_i386_x87_xmm(); - uint32_t i386_translate(int segment, uint32_t ip, int rwn); + uint32_t i386_translate(int segment, uint32_t ip, int rwn, int size = 1); inline vtlb_entry get_permissions(uint32_t pte, int wp); bool i386_translate_address(int intention, bool debug, offs_t *address, vtlb_entry *entry); bool translate_address(int pl, int type, uint32_t *address, uint32_t *error); @@ -512,7 +512,7 @@ protected: uint32_t GetEA(uint8_t modrm, int rwn); uint32_t Getx87EA(uint8_t modrm, int rwn); void i386_check_sreg_validity(int reg); - int i386_limit_check(int seg, uint32_t offset); + int i386_limit_check(int seg, uint32_t offset, int size = 1); void i386_sreg_load(uint16_t selector, uint8_t reg, bool *fault); void i386_trap(int irq, int irq_gate, int trap_level); void i386_trap_with_error(int irq, int irq_gate, int trap_level, uint32_t error); diff --git a/src/devices/cpu/i386/i386op16.hxx b/src/devices/cpu/i386/i386op16.hxx index 4950a7ed73e..8f206a31157 100644 --- a/src/devices/cpu/i386/i386op16.hxx +++ b/src/devices/cpu/i386/i386op16.hxx @@ -1225,9 +1225,9 @@ void i386_device::i386_lodsw() // Opcode 0xad { uint32_t eas; if( m_segment_prefix ) { - eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0, 2); } else { - eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0, 2); } REG16(AX) = READ16(eas); BUMP_SI(2); @@ -1424,11 +1424,11 @@ void i386_device::i386_movsw() // Opcode 0xa5 uint32_t eas, ead; uint16_t v; if( m_segment_prefix ) { - eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0, 2); } else { - eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0, 2); } - ead = i386_translate(ES, m_address_size ? REG32(EDI) : REG16(DI), 1 ); + ead = i386_translate(ES, m_address_size ? REG32(EDI) : REG16(DI), 1, 2); v = READ16(eas); WRITE16(ead, v); BUMP_SI(2); diff --git a/src/devices/cpu/i386/i386op32.hxx b/src/devices/cpu/i386/i386op32.hxx index 72a4c0c2eb7..8166b14e02d 100644 --- a/src/devices/cpu/i386/i386op32.hxx +++ b/src/devices/cpu/i386/i386op32.hxx @@ -1068,9 +1068,9 @@ void i386_device::i386_lodsd() // Opcode 0xad { uint32_t eas; if( m_segment_prefix ) { - eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0, 4 ); } else { - eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0, 4 ); } REG32(EAX) = READ32(eas); BUMP_SI(4); @@ -1243,11 +1243,11 @@ void i386_device::i386_movsd() // Opcode 0xa5 { uint32_t eas, ead, v; if( m_segment_prefix ) { - eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(m_segment_override, m_address_size ? REG32(ESI) : REG16(SI), 0, 4 ); } else { - eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0 ); + eas = i386_translate(DS, m_address_size ? REG32(ESI) : REG16(SI), 0, 4 ); } - ead = i386_translate(ES, m_address_size ? REG32(EDI) : REG16(DI), 1 ); + ead = i386_translate(ES, m_address_size ? REG32(EDI) : REG16(DI), 1, 4 ); v = READ32(eas); WRITE32(ead, v); BUMP_SI(4); diff --git a/src/devices/cpu/i386/i386segs.hxx b/src/devices/cpu/i386/i386segs.hxx index 0e42ddf8dd8..ba121ebd0de 100644 --- a/src/devices/cpu/i386/i386segs.hxx +++ b/src/devices/cpu/i386/i386segs.hxx @@ -216,7 +216,7 @@ void i386_device::i386_check_sreg_validity(int reg) } } -int i386_device::i386_limit_check(int seg, uint32_t offset) +int i386_device::i386_limit_check(int seg, uint32_t offset, int size) { if(PROTECTED_MODE && !V8086_MODE) { @@ -231,7 +231,7 @@ int i386_device::i386_limit_check(int seg, uint32_t offset) } else { - if(offset > m_sreg[seg].limit) + if((offset + size - 1) > m_sreg[seg].limit) { LOGMASKED(LOG_LIMIT_CHECK, "Limit check at 0x%08x failed. Segment %04x, limit %08x, offset %08x\n",m_pc,m_sreg[seg].selector,m_sreg[seg].limit,offset); //machine().debug_break(); diff --git a/src/devices/cpu/i86/i186.h b/src/devices/cpu/i86/i186.h index b3159454138..a21aeac7c23 100644 --- a/src/devices/cpu/i86/i186.h +++ b/src/devices/cpu/i86/i186.h @@ -37,6 +37,9 @@ public: void int2_w(int state) { external_int(2, state); } void int3_w(int state) { external_int(3, state); } + // This a hack, only use if there are sync problems with another cpu + void dma_sync_req(int which) { drq_callback(which); } + // device_memory_interface overrides virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/machine/at.cpp b/src/devices/machine/at.cpp index e77c72af599..57ca4c23bd3 100644 --- a/src/devices/machine/at.cpp +++ b/src/devices/machine/at.cpp @@ -134,6 +134,7 @@ void at_mb_device::device_add_mconfig(machine_config &config) m_isabus->drq6_callback().set(m_dma8237_2, FUNC(am9517a_device::dreq2_w)); m_isabus->drq7_callback().set(m_dma8237_2, FUNC(am9517a_device::dreq3_w)); m_isabus->iochck_callback().set(FUNC(at_mb_device::iochck_w)); + m_isabus->iochrdy_callback().set_inputline(m_maincpu, INPUT_LINE_HALT); MC146818(config, m_mc146818, 32.768_kHz_XTAL); m_mc146818->irq().set(m_pic8259_slave, FUNC(pic8259_device::ir0_w)); diff --git a/src/devices/machine/genpc.cpp b/src/devices/machine/genpc.cpp index b0e57789932..9426b6cbb8f 100644 --- a/src/devices/machine/genpc.cpp +++ b/src/devices/machine/genpc.cpp @@ -468,6 +468,7 @@ void ibm5160_mb_device::device_add_mconfig(machine_config &config) m_isabus->drq2_callback().set(m_dma8237, FUNC(am9517a_device::dreq2_w)); m_isabus->drq3_callback().set(m_dma8237, FUNC(am9517a_device::dreq3_w)); m_isabus->iochck_callback().set(FUNC(ibm5160_mb_device::iochck_w)); + m_isabus->iochrdy_callback().set_inputline(m_maincpu, INPUT_LINE_HALT); /* sound hardware */ SPEAKER(config, "mono").front_center(); -- cgit v1.2.3