qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Duo jia <jiaduo19920301@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: How does qemu detect the completion of interrupt execution?
Date: Fri, 3 Sep 2021 12:19:26 +0100	[thread overview]
Message-ID: <CAFEAcA-8iXVQtjv3akpwz==D6wvY7JDvKbpP5QgrLGdxBNLJeg@mail.gmail.com> (raw)
In-Reply-To: <CALUzjTaDo94110xX7bAr4B5y_XEXqoFH==88hsgffau0rNgZAw@mail.gmail.com>

On Fri, 3 Sept 2021 at 11:54, Duo jia <jiaduo19920301@gmail.com> wrote:
>
> I do some support on STM8 arch, the reference manual link is:
>>
>> https://www.st.com/resource/en/reference_manual/cd00218714-stm8l050j3-stm8l051f3-stm8l052c6-stm8l052r8-mcus-and-stm8l151l152-stm8l162-stm8al31-stm8al3l-lines-stmicroelectronics.pdf
>
> I don't kown when to check the "PENDING" because I can't get the when interrrupt exec over.
> Is there a similar implementation in qemu?

Thanks for the link. Looking at that spec, the condition
for "interrupt execution has finished" is "the guest executes an
IRET instruction". However, you don't need to do anything special
at that point (beyond making the IRET instruction do the things
it should do with restoring registers).

If you look at the diagram, the check you need to make
is "do the I1:I0 bits for this pending interrupt specify a
higher priority than the values in CCR.I1 and I0?". That is
how you determine "interrupt has higher priority than current one"
to know whether to actually take the interrupt.

On interrupt entry the CCR bits are set from the ITC_SPRx registers,
which means that taking an interrupt automatically sets the CPU
priority such that the interrupt cannot be nested. And
finishing the execution of the interrupt routine will automatically
allow a pending second interrupt to be taken immediately, because
the IRET instruction restores the old values of CCR.I1,I0, and
those old values then mean that the CPU is at a priority that
permits the pending interrupt to be taken.

thanks
-- PMM


  parent reply	other threads:[~2021-09-03 11:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  4:29 How does qemu detect the completion of interrupt execution? Duo jia
2021-08-06 10:15 ` Peter Maydell
2021-08-10  7:04   ` Duo jia
2021-09-02  2:17   ` Duo jia
2021-09-02  7:43     ` Peter Maydell
2021-09-03  8:32       ` Duo jia
2021-09-03 10:25         ` Peter Maydell
     [not found]           ` <CALUzjTaDo94110xX7bAr4B5y_XEXqoFH==88hsgffau0rNgZAw@mail.gmail.com>
2021-09-03 11:19             ` Peter Maydell [this message]
2021-09-06  2:46               ` Duo jia
2021-09-06  9:24                 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA-8iXVQtjv3akpwz==D6wvY7JDvKbpP5QgrLGdxBNLJeg@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=jiaduo19920301@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).