target-mips: Provide function to test if a CPU supports an ISA
PATCH v3 4/8 target-mips: Provide function to test if a CPU supports an ISA
From: Paul Burton <[email protected]>
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.
--- target/mips/cpu.h | 1 + target/mips/translate.c | 10 ++++++++++ 2 files changed, 11 insertions(+)
target/mips/cpu.h +1 -0
@@ -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 */
target/mips/translate.c +10 -0
@@ -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));
Signature · 1 line
2.7.4
Quoted 43 lines · Yongbok Kim
From: Paul Burton <[email protected]>
Provide a new
cpu_supports_isafunction which allows callers to determine whether a CPU supports one of theISA_flags, by testing whether the associated structmips_def_tsets the ISA flags in itsinsn_flagsfield.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 <[email protected]>Reviewed-by Leon Alrae <[email protected]>Signed-off-by Yongbok Kim <[email protected]>--- target/mips/cpu.h | 1 + target/mips/translate.c | 10 ++++++++++ 2 files changed, 11 insertions(+)target/mips/cpu.h +1
-0@@ -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 */ target/mips/translate.c +3
-0@@ -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);
target/mips/translate.c bool cpu_supports_cps_smp(const char *cpu_model) · line 20248
Quoted 10 lines
target/mips/translate.c +7
-0+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));