Migrate syn_insn_abort and syn_data_abort_* to the registerfields API.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
target/arm/syndrome.h | 87 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 74 insertions(+), 13 deletions(-)
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
index 3fd82f5b565..db92a8020e3 100644
--- a/target/arm/syndrome.h
+++ b/target/arm/syndrome.h
@@ -494,20 +494,64 @@ static inline uint32_t syn_gpc(int s2ptw, int ind, int gpcsc, int vncr,
return res;
}
+/*
+ * ISS encoding for an exception from an Instruction Abort
+ *
+ * (aka instruction abort)
+ */
+FIELD(IABORT_ISS, IFSC, 0, 6)
+FIELD(IABORT_ISS, S1PTW, 7, 1)
+FIELD(IABORT_ISS, EA, 9, 1)
+FIELD(IABORT_ISS, FnV, 10, 1) /* FAR not Valid */
+FIELD(IABORT_ISS, SET, 11, 2)
+FIELD(IABORT_ISS, PFV, 14, 1)
+FIELD(IABORT_ISS, TopLevel, 21, 1) /* FEAT_THE */
+
static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
{
- return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
- | ARM_EL_IL | (ea << 9) | (s1ptw << 7) | fsc;
+ uint32_t res = syn_set_ec(0, EC_INSNABORT + same_el);
+ res = FIELD_DP32(res, SYNDROME, IL, 1);
+
+ res = FIELD_DP32(res, IABORT_ISS, EA, ea);
+ res = FIELD_DP32(res, IABORT_ISS, S1PTW, s1ptw);
+ res = FIELD_DP32(res, IABORT_ISS, IFSC, fsc);
+
+ return res;
}
+/*
+ * ISS encoding for an exception from a Data Abort
+ */
+FIELD(DABORT_ISS, DFSC, 0, 6)
+FIELD(DABORT_ISS, WNR, 6, 1)
+FIELD(DABORT_ISS, S1PTW, 7, 1)
+FIELD(DABORT_ISS, CM, 8, 1)
+FIELD(DABORT_ISS, EA, 9, 1)
+FIELD(DABORT_ISS, FnV, 10, 1)
+FIELD(DABORT_ISS, LST, 11, 2)
+FIELD(DABORT_ISS, VNCR, 13, 1)
+FIELD(DABORT_ISS, AR, 14, 1)
+FIELD(DABORT_ISS, SF, 15, 1)
+FIELD(DABORT_ISS, SRT, 16, 5)
+FIELD(DABORT_ISS, SSE, 21, 1)
+FIELD(DABORT_ISS, SAS, 22, 2)
+FIELD(DABORT_ISS, ISV, 24, 1)
+
static inline uint32_t syn_data_abort_no_iss(int same_el, int fnv,
int ea, int cm, int s1ptw,
int wnr, int fsc)
{
- return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
- | ARM_EL_IL
- | (fnv << 10) | (ea << 9) | (cm << 8) | (s1ptw << 7)
- | (wnr << 6) | fsc;
+ uint32_t res = syn_set_ec(0, EC_DATAABORT + same_el);
+ res = FIELD_DP32(res, SYNDROME, IL, 1);
+
+ res = FIELD_DP32(res, DABORT_ISS, FnV, fnv);
+ res = FIELD_DP32(res, DABORT_ISS, EA, ea);
+ res = FIELD_DP32(res, DABORT_ISS, CM, cm);
+ res = FIELD_DP32(res, DABORT_ISS, S1PTW, s1ptw);
+ res = FIELD_DP32(res, DABORT_ISS, WNR, wnr);
+ res = FIELD_DP32(res, DABORT_ISS, DFSC, fsc);
+
+ return res;
}
static inline uint32_t syn_data_abort_with_iss(int same_el,
@@ -517,11 +561,22 @@ static inline uint32_t syn_data_abort_with_iss(int same_el,
int wnr, int fsc,
bool is_16bit)
{
- return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
- | (is_16bit ? 0 : ARM_EL_IL)
- | ARM_EL_ISV | (sas << 22) | (sse << 21) | (srt << 16)
- | (sf << 15) | (ar << 14)
- | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc;
+ uint32_t res = syn_set_ec(0, EC_DATAABORT + same_el);
+ res = FIELD_DP32(res, SYNDROME, IL, is_16bit ? 0 : 1);
+
+ res = FIELD_DP32(res, DABORT_ISS, ISV, 1);
+ res = FIELD_DP32(res, DABORT_ISS, SAS, sas);
+ res = FIELD_DP32(res, DABORT_ISS, SSE, sse);
+ res = FIELD_DP32(res, DABORT_ISS, SRT, srt);
+ res = FIELD_DP32(res, DABORT_ISS, SF, sf);
+ res = FIELD_DP32(res, DABORT_ISS, AR, ar);
+ res = FIELD_DP32(res, DABORT_ISS, EA, ea);
+ res = FIELD_DP32(res, DABORT_ISS, CM, cm);
+ res = FIELD_DP32(res, DABORT_ISS, S1PTW, s1ptw);
+ res = FIELD_DP32(res, DABORT_ISS, WNR, wnr);
+ res = FIELD_DP32(res, DABORT_ISS, DFSC, fsc);
+
+ return res;
}
/*
@@ -530,8 +585,14 @@ static inline uint32_t syn_data_abort_with_iss(int same_el,
*/
static inline uint32_t syn_data_abort_vncr(int ea, int wnr, int fsc)
{
- return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (1 << ARM_EL_EC_SHIFT)
- | ARM_EL_IL | ARM_EL_VNCR | (wnr << 6) | fsc;
+ uint32_t res = syn_set_ec(0, EC_DATAABORT_SAME_EL);
+ res = FIELD_DP32(res, SYNDROME, IL, 1);
+
+ res = FIELD_DP32(res, DABORT_ISS, VNCR, 1);
+ res = FIELD_DP32(res, DABORT_ISS, WNR, wnr);
+ res = FIELD_DP32(res, DABORT_ISS, DFSC, fsc);
+
+ return res;
}
static inline uint32_t syn_swstep(int same_el, int isv, int ex)
--
2.47.3