New field curState is added in structure CPULoongArchState, it points to CPULoongArchState itself now.
Signed-off-by: Bibo Mao <[email protected]> --- target/loongarch/cpu.c | 2 ++ target/loongarch/cpu.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 8f277f7696..693ce30b60 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -278,6 +278,7 @@ static void loongarch_la464_initfn(Object *obj) uint32_t data = 0, field; int i; + set_current_state(env, env); for (i = 0; i < 21; i++) { env->cpucfg[i] = 0x0; } @@ -406,6 +407,7 @@ static void loongarch_la132_initfn(Object *obj) uint32_t data = 0; int i; + set_current_state(env, env); for (i = 0; i < 21; i++) { env->cpucfg[i] = 0x0; } diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 096d778928..e738923049 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -317,6 +317,8 @@ typedef struct LoongArchBT { #define CPU_VENDOR_LOONGSON "Loongson" #define CPU_MODEL_3A5000 "3A5000" #define CPU_MODEL_1C101 "1C101" +struct CPUArchState; +typedef struct CPUArchState CPUSysState; typedef struct CPUArchState { uint64_t gpr[32]; @@ -415,6 +417,7 @@ typedef struct CPUArchState { AddressSpace *address_space_iocsr; uint32_t mp_state; #endif + CPUSysState *curState; } CPULoongArchState; typedef struct LoongArchCPUTopo { @@ -481,6 +484,16 @@ struct LoongArchCPUClass { #define MMU_USER_IDX MMU_PLV_USER #define MMU_DA_IDX 4 +static inline CPUSysState *get_current_state(CPULoongArchState *env) +{ + return env->curState; +} + +static inline void set_current_state(CPULoongArchState *env, CPUSysState *cur) +{ + env->curState = cur; +} + static inline bool is_la64(CPULoongArchState *env) { return FIELD_EX32(env->cpucfg[1], CPUCFG1, ARCH) == CPUCFG1_ARCH_LA64; -- 2.39.3
