qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: Alistair Francis <alistair.francis@wdc.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	"open list:RISC-V" <qemu-riscv@nongnu.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Alistair Francis <alistair23@gmail.com>
Subject: Re: [PATCH v1 1/5] target/riscv: Convert the RISC-V exceptions to an enum
Date: Thu, 18 Mar 2021 09:58:25 +0800	[thread overview]
Message-ID: <CAEUhbmVCmjFWs1SMh6ZLggC-i6wqXxwt9E6L_aXNuQvX8tPnuA@mail.gmail.com> (raw)
In-Reply-To: <685a79eb7992d8b780570501cdb784b607144f02.1616002766.git.alistair.francis@wdc.com>

On Thu, Mar 18, 2021 at 1:41 AM Alistair Francis
<alistair.francis@wdc.com> wrote:
>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
>  target/riscv/cpu_bits.h   | 44 ++++++++++++++++++++-------------------
>  target/riscv/cpu.c        |  2 +-
>  target/riscv/cpu_helper.c |  4 ++--
>  3 files changed, 26 insertions(+), 24 deletions(-)
>
> diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
> index caf4599207..8ae404c32a 100644
> --- a/target/riscv/cpu_bits.h
> +++ b/target/riscv/cpu_bits.h
> @@ -527,27 +527,29 @@
>  #define DEFAULT_RSTVEC      0x1000
>
>  /* Exception causes */
> -#define EXCP_NONE                                -1 /* sentinel value */
> -#define RISCV_EXCP_INST_ADDR_MIS                 0x0
> -#define RISCV_EXCP_INST_ACCESS_FAULT             0x1
> -#define RISCV_EXCP_ILLEGAL_INST                  0x2
> -#define RISCV_EXCP_BREAKPOINT                    0x3
> -#define RISCV_EXCP_LOAD_ADDR_MIS                 0x4
> -#define RISCV_EXCP_LOAD_ACCESS_FAULT             0x5
> -#define RISCV_EXCP_STORE_AMO_ADDR_MIS            0x6
> -#define RISCV_EXCP_STORE_AMO_ACCESS_FAULT        0x7
> -#define RISCV_EXCP_U_ECALL                       0x8
> -#define RISCV_EXCP_S_ECALL                      0x9
> -#define RISCV_EXCP_VS_ECALL                      0xa
> -#define RISCV_EXCP_M_ECALL                       0xb
> -#define RISCV_EXCP_INST_PAGE_FAULT               0xc /* since: priv-1.10.0 */
> -#define RISCV_EXCP_LOAD_PAGE_FAULT               0xd /* since: priv-1.10.0 */
> -#define RISCV_EXCP_STORE_PAGE_FAULT              0xf /* since: priv-1.10.0 */
> -#define RISCV_EXCP_SEMIHOST                      0x10
> -#define RISCV_EXCP_INST_GUEST_PAGE_FAULT         0x14
> -#define RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT       0x15
> -#define RISCV_EXCP_VIRT_INSTRUCTION_FAULT        0x16
> -#define RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT  0x17
> +typedef enum RiscVException {

nits: looking at other places in the RISC-V codes, I believe it's
better to name it "RISCVException"

> +    RISCV_EXCP_NONE = -1, /* sentinel value */
> +    RISCV_EXCP_INST_ADDR_MIS = 0x0,
> +    RISCV_EXCP_INST_ACCESS_FAULT = 0x1,
> +    RISCV_EXCP_ILLEGAL_INST = 0x2,
> +    RISCV_EXCP_BREAKPOINT = 0x3,
> +    RISCV_EXCP_LOAD_ADDR_MIS = 0x4,
> +    RISCV_EXCP_LOAD_ACCESS_FAULT = 0x5,
> +    RISCV_EXCP_STORE_AMO_ADDR_MIS = 0x6,
> +    RISCV_EXCP_STORE_AMO_ACCESS_FAULT = 0x7,
> +    RISCV_EXCP_U_ECALL = 0x8,
> +    RISCV_EXCP_S_ECALL = 0x9,
> +    RISCV_EXCP_VS_ECALL = 0xa,
> +    RISCV_EXCP_M_ECALL = 0xb,
> +    RISCV_EXCP_INST_PAGE_FAULT = 0xc, /* since: priv-1.10.0 */
> +    RISCV_EXCP_LOAD_PAGE_FAULT = 0xd, /* since: priv-1.10.0 */
> +    RISCV_EXCP_STORE_PAGE_FAULT = 0xf, /* since: priv-1.10.0 */
> +    RISCV_EXCP_SEMIHOST = 0x10,
> +    RISCV_EXCP_INST_GUEST_PAGE_FAULT = 0x14,
> +    RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT = 0x15,
> +    RISCV_EXCP_VIRT_INSTRUCTION_FAULT = 0x16,
> +    RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT = 0x17,
> +} RiscVException;
>
>  #define RISCV_EXCP_INT_FLAG                0x80000000
>  #define RISCV_EXCP_INT_MASK                0x7fffffff
> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> index 2a990f6253..63584b4a20 100644
> --- a/target/riscv/cpu.c
> +++ b/target/riscv/cpu.c
> @@ -357,7 +357,7 @@ static void riscv_cpu_reset(DeviceState *dev)
>      env->mcause = 0;
>      env->pc = env->resetvec;
>  #endif
> -    cs->exception_index = EXCP_NONE;
> +    cs->exception_index = RISCV_EXCP_NONE;
>      env->load_res = -1;
>      set_default_nan_mode(1, &env->fp_status);
>  }
> diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
> index 83a6bcfad0..af702f65b1 100644
> --- a/target/riscv/cpu_helper.c
> +++ b/target/riscv/cpu_helper.c
> @@ -72,7 +72,7 @@ static int riscv_cpu_local_irq_pending(CPURISCVState *env)
>      if (irqs) {
>          return ctz64(irqs); /* since non-zero */
>      } else {
> -        return EXCP_NONE; /* indicates no pending interrupt */
> +        return RISCV_EXCP_NONE; /* indicates no pending interrupt */
>      }
>  }
>  #endif
> @@ -1017,5 +1017,5 @@ void riscv_cpu_do_interrupt(CPUState *cs)
>       */
>
>  #endif
> -    cs->exception_index = EXCP_NONE; /* mark handled to qemu */
> +    cs->exception_index = RISCV_EXCP_NONE; /* mark handled to qemu */
>  }
> --

Otherwise,
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


  reply	other threads:[~2021-03-18  1:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 17:39 [PATCH v1 0/5] RISC-V: Convert the CSR access functions to use Alistair Francis
2021-03-17 17:39 ` [PATCH v1 1/5] target/riscv: Convert the RISC-V exceptions to an enum Alistair Francis
2021-03-18  1:58   ` Bin Meng [this message]
2021-03-19 13:19     ` Alistair Francis
2021-03-17 17:39 ` [PATCH v1 2/5] target/riscv: Use the RiscVException enum for CSR predicates Alistair Francis
2021-03-17 19:44   ` Richard Henderson
2021-03-19 13:17     ` Alistair Francis
2021-03-17 17:39 ` [PATCH v1 3/5] target/riscv: Fix 32-bit HS mode access permissions Alistair Francis
2021-03-17 17:39 ` [PATCH v1 4/5] target/riscv: Use the RiscVException enum for CSR operations Alistair Francis
2021-03-17 17:40 ` [PATCH v1 5/5] target/riscv: Use RiscVException enum for CSR access Alistair Francis
2021-03-18 13:25   ` Richard Henderson
2021-03-19 13:19     ` Alistair Francis

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=CAEUhbmVCmjFWs1SMh6ZLggC-i6wqXxwt9E6L_aXNuQvX8tPnuA@mail.gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@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).