On 2/24/22 03:48, Amir Gonnen wrote:
@@ -88,7 +93,9 @@ struct Nios2CPUClass { #define CR_STATUS_IH (1 << 3) #define CR_STATUS_IL (63 << 4) #define CR_STATUS_CRS (63 << 10) +#define CR_STATUS_CRS_OFFSET 10 #define CR_STATUS_PRS (63 << 16) +#define CR_STATUS_PRS_OFFSET 16 #define CR_STATUS_NMI (1 << 22) #define CR_STATUS_RSIE (1 << 23) #define CR_ESTATUS (CR_BASE + 1)
It would be preferable to use hw/registerfields.h: FIELD(CR_STATUS, IL, 4, 6) FIELD(CR_STATUS, CRS, 10, 6) FIELD(CR_STATUS, PRS, 16, 6)
+static inline uint32_t cpu_get_crs(const CPUNios2State *env) +{ + return (env->regs[CR_STATUS] & CR_STATUS_CRS) + >> CR_STATUS_CRS_OFFSET; +}
This becomes return FIELD_EX32(env->regs[CR_STATUS], CR_STATUS, CRS);
+ env->regs[CR_STATUS] = (env->regs[CR_STATUS] & (~CR_STATUS_PRS)) + | ((prev_set << CR_STATUS_PRS_OFFSET) & CR_STATUS_PRS);
This becomes env->regs[CR_STATUS] = FIELD_DP32(env->regs[CR_STATUS], CR_STATUS, PRS, prev_set); etc. r~