qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does qemu detect the completion of interrupt execution?


From: Peter Maydell
Subject: Re: How does qemu detect the completion of interrupt execution?
Date: Mon, 6 Sep 2021 10:24:55 +0100

On Mon, 6 Sept 2021 at 03:47, Duo jia <jiaduo19920301@gmail.com> wrote:
>
> Thank you for your explanation.
>
>>  And finishing the execution of the interrupt routine will automatically
>> allow a pending second interrupt to be taken immediately
>
>
> I think this is a hardware feature. But how to achieve it with qemu

That is what my explanation was trying to tell you how to do.

In a bit more detail:
 * your interrupt controller device should assert the irq line
   to the CPU for as long as there is any pending interrupt
   (regardless of its priority). It should deassert it when
   there is no longer a pending interrupt (ie when the guest
   writes to the interrupt status register to clear the pending
   status of an interrupt, if that was the only pending interrupt
   then the interrupt controller should stop asserting the
   irq line).
 * your stm8_cpu_set_irq function should set and clear the
   CPU_INTERRUPT_HARD flag in interrupt_request so that it
   follows the irq line value
 * your .cpu_exec_interrupt function should only take the
   interrupt if the CCR.I1/I0 bits permit it. Otherwise it
   should return false (telling the QEMU core code that there
   was no interrupt taken). cpu_exec_interrupt should *not*
   clear the CPU_INTERRUPT_HARD flag, whether it decides to
   take an interrupt or not.
 * your do_interrupt function should set CCR.I1/I0 from the
   ITC_SPRx registers (as well as doing everything else that
   interrupt entry needs to do)
 * your implementation of iret should reload the CCR.I1/I0
   bits, the way the spec describes

There are other ways to structure this (mostly involving
tying the interrupt controller model and the CPU model
together more closely), but the above is the "classic"
and probably simplest way of doing it.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]