From: Richard Henderson Date: Mon, 13 Apr 2026 23:02:50 +0000 (+1000) Subject: linux-user/arm/nwfpe: Replace user_registers with current_cpu X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8ea1759009a248cf331b275854d8b272e0f7d8a;p=thirdparty%2Fqemu.git linux-user/arm/nwfpe: Replace user_registers with current_cpu Use the thread-local variable current_cpu instead of a global variable to access the general registers. This also means we don't need to pass env to EmulateAll. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Helge Deller --- diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 19874f4c727..262ab5cc416 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -215,7 +215,7 @@ static bool insn_is_linux_bkpt(uint32_t opcode, bool is_thumb) static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode) { TaskState *ts = get_task_state(env_cpu(env)); - int rc = EmulateAll(opcode, &ts->fpa, env); + int rc = EmulateAll(opcode, &ts->fpa); int raise, enabled; if (rc == 0) { diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c index 0f1afbd91df..44783934b2e 100644 --- a/linux-user/arm/nwfpe/fpa11.c +++ b/linux-user/arm/nwfpe/fpa11.c @@ -30,7 +30,6 @@ FPA11* qemufpa = NULL; -CPUARMState* user_registers; /* Reset the FPA11 chip. Called to initialize and reset the emulator. */ void resetFPA11(void) @@ -156,7 +155,7 @@ void SetRoundingPrecision(const unsigned int opcode) /* Emulate the instruction in the opcode. */ /* ??? This is not thread safe. */ -unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs) +unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa) { unsigned int nRc = 0; // unsigned long flags; @@ -173,12 +172,6 @@ unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs) } qemufpa=qfpa; - user_registers=qregs; - -#if 0 - fprintf(stderr,"emulating FP insn 0x%08x, PC=0x%08x\n", - opcode, qregs[ARM_REG_PC]); -#endif fpa11 = GET_FPA11(); if (fpa11->initflag == 0) /* good place for __builtin_expect */ diff --git a/linux-user/arm/nwfpe/fpa11.h b/linux-user/arm/nwfpe/fpa11.h index d459c5da02c..20f9d2eb81d 100644 --- a/linux-user/arm/nwfpe/fpa11.h +++ b/linux-user/arm/nwfpe/fpa11.h @@ -25,15 +25,6 @@ #define GET_FPA11() (qemufpa) -/* - * The processes registers are always at the very top of the 8K - * stack+task struct. Use the same method as 'current' uses to - * reach them. - */ -extern CPUARMState *user_registers; - -#define GET_USERREG() (user_registers) - /* Need task_struct */ //#include @@ -91,25 +82,25 @@ void SetRoundingPrecision(const unsigned int); static inline unsigned int readRegister(unsigned int reg) { - return (user_registers->regs[(reg)]); + CPUARMState *env = cpu_env(current_cpu); + return env->regs[reg]; } static inline void writeRegister(unsigned int x, unsigned int y) { -#if 0 - printf("writing %d to r%d\n",y,x); -#endif - user_registers->regs[(x)]=(y); + CPUARMState *env = cpu_env(current_cpu); + env->regs[x] = y; } static inline void writeConditionCodes(unsigned int x) { - cpsr_write(user_registers, x, CPSR_NZCV, CPSRWriteByInstr); + CPUARMState *env = cpu_env(current_cpu); + cpsr_write(env, x, CPSR_NZCV, CPSRWriteByInstr); } #define ARM_REG_PC 15 -unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa, CPUARMState* qregs); +unsigned int EmulateAll(unsigned int opcode, FPA11* qfpa); unsigned int EmulateCPDO(const unsigned int); unsigned int EmulateCPDT(const unsigned int);