[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 13/23] target/riscv: Implement AIA mtopi, stopi, and vstop
From: |
Alistair Francis |
Subject: |
Re: [PATCH v5 13/23] target/riscv: Implement AIA mtopi, stopi, and vstopi CSRs |
Date: |
Tue, 21 Dec 2021 16:47:34 +1000 |
On Sat, Dec 11, 2021 at 2:34 PM Anup Patel <anup.patel@wdc.com> wrote:
>
> The AIA specification introduces new [m|s|vs]topi CSRs for
> reporting pending local IRQ number and associated IRQ priority.
>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> ---
> target/riscv/csr.c | 155 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 155 insertions(+)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 4b3edc1043..6f613d182d 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -189,6 +189,15 @@ static int smode32(CPURISCVState *env, int csrno)
> return smode(env, csrno);
> }
>
> +static int aia_smode(CPURISCVState *env, int csrno)
> +{
> + if (!riscv_feature(env, RISCV_FEATURE_AIA)) {
> + return RISCV_EXCP_ILLEGAL_INST;
> + }
> +
> + return smode(env, csrno);
> +}
> +
> static int aia_smode32(CPURISCVState *env, int csrno)
> {
> if (!riscv_feature(env, RISCV_FEATURE_AIA)) {
> @@ -833,6 +842,28 @@ static RISCVException rmw_mieh(CPURISCVState *env, int
> csrno,
> return ret;
> }
>
> +static int read_mtopi(CPURISCVState *env, int csrno, target_ulong *val)
> +{
> + int irq;
> + uint8_t iprio;
> +
> + irq = riscv_cpu_mirq_pending(env);
> + if (irq <= 0 || irq > 63) {
> + *val = 0;
> + } else {
> + iprio = env->miprio[irq];
> + if (!iprio) {
> + if (riscv_cpu_default_priority(irq) > IPRIO_DEFAULT_M) {
> + iprio = IPRIO_MMAXIPRIO;
> + }
> + }
> + *val = (irq & TOPI_IID_MASK) << TOPI_IID_SHIFT;
> + *val |= iprio;
> + }
> +
> + return RISCV_EXCP_NONE;
> +}
> +
> static RISCVException read_mtvec(CPURISCVState *env, int csrno,
> target_ulong *val)
> {
> @@ -1362,6 +1393,121 @@ static RISCVException write_satp(CPURISCVState *env,
> int csrno,
> return RISCV_EXCP_NONE;
> }
>
> +static int read_vstopi(CPURISCVState *env, int csrno, target_ulong *val)
> +{
> + int irq, ret;
> + target_ulong topei;
> + uint64_t vseip, vsgein;
> + uint32_t iid, iprio, hviid, hviprio, gein;
> +#define VSTOPI_NUM_SRCS 5
This should be defined at the top of the file.
Alistair
- [PATCH v5 08/23] target/riscv: Allow AIA device emulation to set ireg rmw callback, (continued)
- [PATCH v5 08/23] target/riscv: Allow AIA device emulation to set ireg rmw callback, Anup Patel, 2021/12/10
- [PATCH v5 09/23] target/riscv: Implement AIA local interrupt priorities, Anup Patel, 2021/12/10
- [PATCH v5 10/23] target/riscv: Implement AIA CSRs for 64 local interrupts on RV32, Anup Patel, 2021/12/10
- [PATCH v5 11/23] target/riscv: Implement AIA hvictl and hviprioX CSRs, Anup Patel, 2021/12/10
- [PATCH v5 12/23] target/riscv: Implement AIA interrupt filtering CSRs, Anup Patel, 2021/12/10
- [PATCH v5 13/23] target/riscv: Implement AIA mtopi, stopi, and vstopi CSRs, Anup Patel, 2021/12/10
- Re: [PATCH v5 13/23] target/riscv: Implement AIA mtopi, stopi, and vstopi CSRs,
Alistair Francis <=
- [PATCH v5 14/23] target/riscv: Implement AIA xiselect and xireg CSRs, Anup Patel, 2021/12/10
- [PATCH v5 15/23] target/riscv: Implement AIA IMSIC interface CSRs, Anup Patel, 2021/12/10
- [PATCH v5 16/23] hw/riscv: virt: Use AIA INTC compatible string when available, Anup Patel, 2021/12/10
- [PATCH v5 17/23] target/riscv: Allow users to force enable AIA CSRs in HART, Anup Patel, 2021/12/10
- [PATCH v5 18/23] hw/intc: Add RISC-V AIA APLIC device emulation, Anup Patel, 2021/12/10
- [PATCH v5 19/23] hw/riscv: virt: Add optional AIA APLIC support to virt machine, Anup Patel, 2021/12/10
- [PATCH v5 20/23] hw/intc: Add RISC-V AIA IMSIC device emulation, Anup Patel, 2021/12/10