From: Richard Henderson <richard.henderson@linaro.org>
To: Amir Gonnen <amir.gonnen@neuroblade.ai>,
qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Chris Wulff <crwulff@gmail.com>, Marek Vasut <marex@denx.de>
Subject: Re: [PATCH v3 3/5] target/nios2: Exteral Interrupt Controller (EIC)
Date: Fri, 4 Mar 2022 12:25:20 -1000 [thread overview]
Message-ID: <56be99b1-3b0f-77e9-4b11-5734c70d85f7@linaro.org> (raw)
In-Reply-To: <20220303153906.2024748-4-amir.gonnen@neuroblade.ai>
On 3/3/22 05:39, Amir Gonnen wrote:
> @@ -55,6 +55,7 @@ static void nios2_cpu_reset(DeviceState *dev)
>
> memset(env->regs, 0, sizeof(uint32_t) * NUM_CORE_REGS);
> memset(env->shadow_regs, 0, sizeof(uint32_t) * NUM_REG_SETS * NUM_GP_REGS);
> + env->regs[CR_STATUS] |= CR_STATUS_RSIE;
status is supposed to be reset to zero other than RSIE.
> @@ -131,13 +144,26 @@ static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
> Nios2CPU *cpu = NIOS2_CPU(cs);
> CPUNios2State *env = &cpu->env;
>
> - if ((interrupt_request & CPU_INTERRUPT_HARD) &&
> - (env->regs[CR_STATUS] & CR_STATUS_PIE) &&
> - (env->regs[CR_IPENDING] & env->regs[CR_IENABLE])) {
> - cs->exception_index = EXCP_IRQ;
> - nios2_cpu_do_interrupt(cs);
> - return true;
> + if (cpu->intc_present) {
> + if ((interrupt_request & CPU_INTERRUPT_HARD) &&
> + (env->regs[CR_STATUS] & CR_STATUS_PIE) &&
> + (env->regs[CR_IPENDING] & env->regs[CR_IENABLE])) {
> + cs->exception_index = EXCP_IRQ;
> + nios2_cpu_do_interrupt(cs);
> + return true;
> + }
> + } else {
> + /*
> + * IPENDING does not exist with external interrupt controller
> + * but we still use it to signal an external interrupt
> + */
> + if (env->regs[CR_IPENDING] && nios2_take_eic_irq(cpu)) {
Why CR_IPENDING? The ipending register isn't supposed to exist with the EIC. Did you in
fact mean interrupt_request & CPU_INTERRUPT_HARD, as set by nios2_cpu_set_irq?
> - /*
> - * These interrupt lines model the IIC (internal interrupt
> - * controller). QEMU does not currently support the EIC
> - * (external interrupt controller) -- if we did it would be
> - * a separate device in hw/intc with a custom interface to
> - * the CPU, and boards using it would not wire up these IRQ lines.
> - */
You should note that this is still used for EIC, though only IRQ[0].
There's a fair amount of checking cpu->intc_present, then doing two completely different
things. I'm thinking that it might be best to split these into two separate functions,
and then set up the pointers properly.
You could in fact replace intc_present with two separate cpu classes (which is where many
of those pointers are registered). That would be early enough for the cpu_init hook to
*not* register 32 interrupt lines for the EIC, as per above.
r~
next prev parent reply other threads:[~2022-03-04 22:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 15:39 [PATCH v3 0/5] target/nios2: Shadow register set, EIC and VIC Amir Gonnen
2022-03-03 15:39 ` [PATCH v3 1/5] target/nios2: Check supervisor on eret Amir Gonnen
2022-03-04 12:57 ` Peter Maydell
2022-03-04 20:58 ` Richard Henderson
2022-03-03 15:39 ` [PATCH v3 2/5] target/nios2: Shadow register set Amir Gonnen
2022-03-04 21:45 ` Richard Henderson
2022-03-03 15:39 ` [PATCH v3 3/5] target/nios2: Exteral Interrupt Controller (EIC) Amir Gonnen
2022-03-04 22:25 ` Richard Henderson [this message]
2022-03-03 15:39 ` [PATCH v3 4/5] hw/intc: Vectored Interrupt Controller (VIC) Amir Gonnen
2022-03-04 12:55 ` Peter Maydell
2022-03-03 15:39 ` [PATCH v3 5/5] hw/nios2: Machine with a Vectored Interrupt Controller Amir Gonnen
2022-03-04 12:58 ` 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=56be99b1-3b0f-77e9-4b11-5734c70d85f7@linaro.org \
--to=richard.henderson@linaro.org \
--cc=amir.gonnen@neuroblade.ai \
--cc=crwulff@gmail.com \
--cc=marex@denx.de \
--cc=peter.maydell@linaro.org \
--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).