From 1dc09ab41ae703a1f15be87cacab5e842cf1a09d Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Mon, 4 Mar 2019 15:30:11 +0100 Subject: Implemented interrupt delivery and processing for serial port. Signed-off-by: Pavel Pisa --- qtmips_machine/cop0state.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'qtmips_machine/cop0state.cpp') diff --git a/qtmips_machine/cop0state.cpp b/qtmips_machine/cop0state.cpp index ea937ce..9c5fa1c 100644 --- a/qtmips_machine/cop0state.cpp +++ b/qtmips_machine/cop0state.cpp @@ -91,7 +91,7 @@ const Cop0State::cop0reg_desc_t Cop0State::cop0reg_desc[Cop0State::COP0REGS_CNT] &Cop0State::read_cop0reg_default, &Cop0State::write_cop0reg_default}, [Cop0State::Compare] = {"Compare", 0x00000000, &Cop0State::read_cop0reg_default, &Cop0State::write_cop0reg_default}, - [Cop0State::Status] = {"Status", 0x00000000, + [Cop0State::Status] = {"Status", Status_IE | Status_IntMask, &Cop0State::read_cop0reg_default, &Cop0State::write_cop0reg_default}, [Cop0State::Cause] = {"Cause", 0x00000000, &Cop0State::read_cop0reg_default, &Cop0State::write_cop0reg_default}, @@ -178,3 +178,31 @@ void Cop0State::update_execption_cause(enum ExceptionCause excause, bool in_dela if (excause != EXCAUSE_INT) cop0reg[(int)Cause] |= (int)excause << 2; } + +void Cop0State::set_interrupt_signal(uint irq_num, bool active) { + std::uint32_t mask; + if (irq_num >= 8) + return; + mask = Status_Int0 << irq_num; + if (active) + cop0reg[(int)Cause] |= mask; + else + cop0reg[(int)Cause] &= ~mask; +} + +bool Cop0State::core_interrupt_request() { + std::uint32_t irqs; + irqs = cop0reg[(int)Status]; + irqs &= cop0reg[(int)Cause]; + irqs &= Status_IntMask; + + return !!(irqs && cop0reg[(int)Status] & Status_IntMask && + !(cop0reg[(int)Status] & Status_EXL)); +} + +void Cop0State::set_status_exl(bool value) { + if (value) + cop0reg[(int)Status] |= Status_EXL; + else + cop0reg[(int)Status] &= ~Status_EXL; +} -- cgit v1.2.3