target-mips: implement R6 multi-threading
PATCH v2 1/1 target-mips: implement R6 multi-threading
From: Yongbok Kim <[email protected]>
MIPS Release 6 provides multi-threading features which replace pre-R6 MT Module. CP0.Config3.MT is always 0 in R6, instead there is new CP0.Config5.VP (Virtual Processor) bit which indicates presence of multi-threading support which includes CP0.GlobalNumber register and DVP/EVP instructions.
Signed-off-by Yongbok Kim <[email protected]>
Signed-off-by Leon Alrae <[email protected]>
---
This is an updated version of the patch originally sent by Yongbok some time ago.
v2:
* rebased
* fix typo: GlobalNumer -> GlobalNumber
* fix minor style issues
* update the patch description
--- disas/mips.c | 4 +++ target-mips/cpu.c | 9 +++++++ target-mips/cpu.h | 25 +++++++++++++++++++ target-mips/helper.h | 4 +++ target-mips/op_helper.c | 48 +++++++++++++++++++++++++++++++++++ target-mips/translate.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ target-mips/translate_init.c | 3 ++- 7 files changed, 151 insertions(+), 1 deletion(-)
disas/mips.c +4 -0
@@ -1405,6 +1405,10 @@ const struct mips_opcode mips_builtin_opcodes[] = {"cmp.sor.d", "D,S,T", 0x46a00019, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, 0, I32R6}, {"cmp.sune.d", "D,S,T", 0x46a0001a, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, 0, I32R6}, {"cmp.sne.d", "D,S,T", 0x46a0001b, 0xffe0003f, RD_S|RD_T|WR_D|FP_D, 0, I32R6}, +{"dvp", "", 0x41600024, 0xffffffff, TRAP, 0, I32R6}, +{"dvp", "t", 0x41600024, 0xffe0ffff, TRAP|WR_t, 0, I32R6}, +{"evp", "", 0x41600004, 0xffffffff, TRAP, 0, I32R6}, +{"evp", "t", 0x41600004, 0xffe0ffff, TRAP|WR_t, 0, I32R6},/* MSA */ {"sll.b", "+d,+e,+f", 0x7800000d, 0xffe0003f, WR_VD|RD_VS|RD_VT, 0, MSA},
target-mips/cpu.c +9 -0
@@ -77,6 +77,15 @@ static bool mips_cpu_has_work(CPUState *cs) has_work = false; } } +/* MIPS Release 6 has the ability to halt the CPU. */ +if (env->CP0_Config5 & (1 <<CP0C5_VP )) { +if (cs->interrupt_request &CPU_INTERRUPT_WAKE ) { + has_work = true; + } +if (!mips_vp_active (env)) { + has_work = false; + } + }return has_work; }
target-mips/cpu.h +25 -0
@@ -238,6 +238,8 @@ struct CPUMIPSState {int32_t CP0_Index;/* CP0_MVP* are per MVP registers. */ +int32_t CP0_VPControl; +#define CP0VPCtl_DIS 0int32_t CP0_Random;int32_t CP0_VPEControl;#define CP0VPECo_YSI 21
@@ -287,6 +289,8 @@ struct CPUMIPSState {# define CP0EnLo_RI 31# define CP0EnLo_XI 30#endif +int32_t CP0_GlobalNumber; +#define CP0GN_VPId 0target_ulong CP0_Context;target_ulong CP0_KScratch[MIPS_KSCRATCH_NUM ];int32_t CP0_PageMask;
@@ -472,6 +476,7 @@ struct CPUMIPSState {#define CP0C5_XNP 13#define CP0C5_UFE 9#define CP0C5_FRE 8 +#define CP0C5_VP 7#define CP0C5_SBRI 6#define CP0C5_MVH 5#define CP0C5_LLB 4
@@ -859,6 +864,26 @@ static inline int mips_vpe_active(CPUMIPSState *env)return active; } +static inline int mips_vp_active (CPUMIPSState *env) +{ +CPUState *other_cs = first_cpu; + +/* Check if the VP disabled other VPs (which means the VP is enabled) */ +if ((env->CP0_VPControl >> CP0VPCtl_DIS) &1 ) { +return 1 ; + } + +/* Check if the virtual processor is disabled due to a DVP */ +CPU_FOREACH (other_cs) { +MIPSCPU *other_cpu =MIPS_CPU (other_cs); +if ((&other_cpu->env != env) && + ((other_cpu->env.CP0_VPControl >> CP0VPCtl_DIS) &1 )) { +return 0 ; + } + } +return 1 ; +} +#include "exec/exec-all.h" static inline void compute_hflags (CPUMIPSState *env)
target-mips/helper.h +4 -0
@@ -176,6 +176,10 @@ DEF_HELPER_0(dmt, tl) DEF_HELPER_0(emt, tl) DEF_HELPER_1(dvpe, tl, env)DEF_HELPER_1 (evpe, tl, env) + +/* R6 Multi-threading */ +DEF_HELPER_1(dvp, tl, env) +DEF_HELPER_1(evp, tl, env)#endif /* !CONFIG_USER_ONLY */ /* microMIPS functions */
target-mips/op_helper.c +48 -0
60 lines not on this page · raw message
target-mips/translate.c +59 -0
137 lines not on this page · raw message
target-mips/translate_init.c +2 -1
@@ -665,7 +665,8 @@ static const mips_def_t mips_defs[] = (1 << CP0C3_RXI) | (1 << CP0C3_LPA), .CP0_Config4 =MIPS_CONFIG4 | (1U <<CP0C4_M ) | (3 <<CP0C4_IE ) | (0xfc << CP0C4_KScrExist), - .CP0_Config5 = MIPS_CONFIG5 | (1 << CP0C5_XNP) | (1 << CP0C5_LLB), + .CP0_Config5 =MIPS_CONFIG5 | (1 <<CP0C5_XNP ) | (1 <<CP0C5_VP ) | + (1 << CP0C5_LLB), .CP0_Config5_rw_bitmask = (1 << CP0C5_MSAEn) | (1 <<CP0C5_SBRI ) | (1 << CP0C5_FRE) | (1 << CP0C5_UFE), .CP0_LLAddr_rw_bitmask = 0,
Signature · 1 line
2.1.0