All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 4/8] target-mips: Provide function to test if a CPU supports an ISA
@ 2017-02-08 16:33 Yongbok Kim
  2017-02-08 21:29 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Yongbok Kim @ 2017-02-08 16:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: paul.burton, aurelien

From: Paul Burton <paul.burton@imgtec.com>

Provide a new cpu_supports_isa function which allows callers to
determine whether a CPU supports one of the ISA_ flags, by testing
whether the associated struct mips_def_t sets the ISA flags in its
insn_flags field.

An example use of this is to allow boards which generate bootloader code
to determine the properties of the CPU that will be used, for example
whether the CPU is 64 bit or which architecture revision it implements.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
---
 target/mips/cpu.h       |  1 +
 target/mips/translate.c | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index e1c78f5..4a4747a 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -815,6 +815,7 @@ int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 
 #define cpu_init(cpu_model) CPU(cpu_mips_init(cpu_model))
 bool cpu_supports_cps_smp(const char *cpu_model);
+bool cpu_supports_isa(const char *cpu_model, unsigned int isa);
 void cpu_set_exception_base(int vp_index, target_ulong address);
 
 /* TODO QOM'ify CPU reset and remove */
diff --git a/target/mips/translate.c b/target/mips/translate.c
index 7f8ecf4..8b4a072 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -20233,6 +20233,16 @@ bool cpu_supports_cps_smp(const char *cpu_model)
     return (def->CP0_Config3 & (1 << CP0C3_CMGCR)) != 0;
 }
 
+bool cpu_supports_isa(const char *cpu_model, unsigned int isa)
+{
+    const mips_def_t *def = cpu_mips_find_by_name(cpu_model);
+    if (!def) {
+        return false;
+    }
+
+    return (def->insn_flags & isa) != 0;
+}
+
 void cpu_set_exception_base(int vp_index, target_ulong address)
 {
     MIPSCPU *vp = MIPS_CPU(qemu_get_cpu(vp_index));
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v3 4/8] target-mips: Provide function to test if a CPU supports an ISA
  2017-02-08 16:33 [Qemu-devel] [PATCH v3 4/8] target-mips: Provide function to test if a CPU supports an ISA Yongbok Kim
@ 2017-02-08 21:29 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-02-08 21:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Yongbok Kim, aurelien, Paul Burton



On 02/08/2017 01:33 PM, Yongbok Kim wrote:
> From: Paul Burton <paul.burton@imgtec.com>
>
> Provide a new cpu_supports_isa function which allows callers to
> determine whether a CPU supports one of the ISA_ flags, by testing
> whether the associated struct mips_def_t sets the ISA flags in its
> insn_flags field.
>
> An example use of this is to allow boards which generate bootloader code
> to determine the properties of the CPU that will be used, for example
> whether the CPU is 64 bit or which architecture revision it implements.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
> Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
> ---
>  target/mips/cpu.h       |  1 +
>  target/mips/translate.c | 10 ++++++++++
>  2 files changed, 11 insertions(+)
>
> diff --git a/target/mips/cpu.h b/target/mips/cpu.h
> index e1c78f5..4a4747a 100644
> --- a/target/mips/cpu.h
> +++ b/target/mips/cpu.h
> @@ -815,6 +815,7 @@ int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
>
>  #define cpu_init(cpu_model) CPU(cpu_mips_init(cpu_model))
>  bool cpu_supports_cps_smp(const char *cpu_model);
> +bool cpu_supports_isa(const char *cpu_model, unsigned int isa);
>  void cpu_set_exception_base(int vp_index, target_ulong address);
>
>  /* TODO QOM'ify CPU reset and remove */
> diff --git a/target/mips/translate.c b/target/mips/translate.c
> index 7f8ecf4..8b4a072 100644
> --- a/target/mips/translate.c
> +++ b/target/mips/translate.c
> @@ -20233,6 +20233,16 @@ bool cpu_supports_cps_smp(const char *cpu_model)
>      return (def->CP0_Config3 & (1 << CP0C3_CMGCR)) != 0;
>  }
>
> +bool cpu_supports_isa(const char *cpu_model, unsigned int isa)
> +{
> +    const mips_def_t *def = cpu_mips_find_by_name(cpu_model);
> +    if (!def) {
> +        return false;
> +    }
> +
> +    return (def->insn_flags & isa) != 0;
> +}
> +
>  void cpu_set_exception_base(int vp_index, target_ulong address)
>  {
>      MIPSCPU *vp = MIPS_CPU(qemu_get_cpu(vp_index));
>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-08 21:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08 16:33 [Qemu-devel] [PATCH v3 4/8] target-mips: Provide function to test if a CPU supports an ISA Yongbok Kim
2017-02-08 21:29 ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.