Message ID | 31da3bcf3ec2da847199113f16bd402e2707b927.1403757527.git.alistair.francis@xilinx.com |
---|---|
State | New |
Headers | show |
On Thu, Jun 26, 2014 at 3:02 PM, Alistair Francis <alistair.francis@xilinx.com> wrote: > Include a helper function to determine if the CCNT counter > is enabled as well as the constants used to mask the pmccfiltr_el0 > and c9_pmxevtyper registers. > > Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> > --- > > target-arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 40 insertions(+), 0 deletions(-) > > diff --git a/target-arm/helper.c b/target-arm/helper.c > index ce986ee..141e252 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -547,6 +547,46 @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri) > } > > #ifndef CONFIG_USER_ONLY Blank line here for readability. > +#define PMCCFILTR_NSH 0x8000000 > +#define PMCCFILTR_P 0x80000000 > +#define PMCCFILTR_U 0x40000000 > + > +#define PMXEVTYPER_P 0x80000000 > +#define PMXEVTYPER_U 0x40000000 > + > +static bool arm_ccnt_enabled(CPUARMState *env) > +{ > + /* This does not support checking for the secure/non-secure > + * components of the PMCCFILTR_EL0 register > + */ > + > + if (!(env->cp15.c9_pmcr & PMCRE)) { > + return 0; > + } > + > + if (arm_current_pl(env) == 2) { switch(arm_current_pl(env)) > + if (!(env->cp15.pmccfiltr_el0 & PMCCFILTR_NSH)) { > + return 0; Use "true" and "false" for boolean function return values. > + } > + } else if (arm_current_pl(env) == 1) { > + if (env->cp15.pmccfiltr_el0 & PMCCFILTR_P) { > + return 0; > + } else if (env->cp15.c9_pmxevtyper & PMXEVTYPER_P) { use an || to merge the two if branches with same function body. > + return 0; > + } > + } else if (arm_current_pl(env) == 0) { > + if (env->cp15.pmccfiltr_el0 & PMCCFILTR_U) { > + return 0; > + } else if (env->cp15.c9_pmxevtyper & PMXEVTYPER_U) { > + return 0; > + } > + } > + > + return 1; > +} > +#endif > + > +#ifndef CONFIG_USER_ONLY Just drop the extra #endif #ifndef CONFIG_USER_ONLY. Regards, Peter > static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, > uint64_t value) > { > -- > 1.7.1 > >
On Thu, Jun 26, 2014 at 9:28 PM, Peter Crosthwaite <peter.crosthwaite@xilinx.com> wrote: > On Thu, Jun 26, 2014 at 3:02 PM, Alistair Francis > <alistair.francis@xilinx.com> wrote: >> Include a helper function to determine if the CCNT counter >> is enabled as well as the constants used to mask the pmccfiltr_el0 >> and c9_pmxevtyper registers. >> >> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> >> --- >> >> target-arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> 1 files changed, 40 insertions(+), 0 deletions(-) >> >> diff --git a/target-arm/helper.c b/target-arm/helper.c >> index ce986ee..141e252 100644 >> --- a/target-arm/helper.c >> +++ b/target-arm/helper.c >> @@ -547,6 +547,46 @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri) >> } >> >> #ifndef CONFIG_USER_ONLY > > Blank line here for readability. > >> +#define PMCCFILTR_NSH 0x8000000 >> +#define PMCCFILTR_P 0x80000000 >> +#define PMCCFILTR_U 0x40000000 >> + >> +#define PMXEVTYPER_P 0x80000000 >> +#define PMXEVTYPER_U 0x40000000 >> + >> +static bool arm_ccnt_enabled(CPUARMState *env) >> +{ >> + /* This does not support checking for the secure/non-secure >> + * components of the PMCCFILTR_EL0 register >> + */ >> + >> + if (!(env->cp15.c9_pmcr & PMCRE)) { >> + return 0; >> + } >> + >> + if (arm_current_pl(env) == 2) { > > switch(arm_current_pl(env)) > >> + if (!(env->cp15.pmccfiltr_el0 & PMCCFILTR_NSH)) { >> + return 0; > > Use "true" and "false" for boolean function return values. > >> + } >> + } else if (arm_current_pl(env) == 1) { >> + if (env->cp15.pmccfiltr_el0 & PMCCFILTR_P) { >> + return 0; >> + } else if (env->cp15.c9_pmxevtyper & PMXEVTYPER_P) { > > use an || to merge the two if branches with same function body. > >> + return 0; >> + } >> + } else if (arm_current_pl(env) == 0) { >> + if (env->cp15.pmccfiltr_el0 & PMCCFILTR_U) { >> + return 0; >> + } else if (env->cp15.c9_pmxevtyper & PMXEVTYPER_U) { >> + return 0; >> + } >> + } >> + >> + return 1; >> +} >> +#endif >> + >> +#ifndef CONFIG_USER_ONLY > > Just drop the extra #endif #ifndef CONFIG_USER_ONLY. > All fixed (in a respun version I got from Alistair). Regards, Peter > Regards, > Peter > >> static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, >> uint64_t value) >> { >> -- >> 1.7.1 >> >>
diff --git a/target-arm/helper.c b/target-arm/helper.c index ce986ee..141e252 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -547,6 +547,46 @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri) } #ifndef CONFIG_USER_ONLY +#define PMCCFILTR_NSH 0x8000000 +#define PMCCFILTR_P 0x80000000 +#define PMCCFILTR_U 0x40000000 + +#define PMXEVTYPER_P 0x80000000 +#define PMXEVTYPER_U 0x40000000 + +static bool arm_ccnt_enabled(CPUARMState *env) +{ + /* This does not support checking for the secure/non-secure + * components of the PMCCFILTR_EL0 register + */ + + if (!(env->cp15.c9_pmcr & PMCRE)) { + return 0; + } + + if (arm_current_pl(env) == 2) { + if (!(env->cp15.pmccfiltr_el0 & PMCCFILTR_NSH)) { + return 0; + } + } else if (arm_current_pl(env) == 1) { + if (env->cp15.pmccfiltr_el0 & PMCCFILTR_P) { + return 0; + } else if (env->cp15.c9_pmxevtyper & PMXEVTYPER_P) { + return 0; + } + } else if (arm_current_pl(env) == 0) { + if (env->cp15.pmccfiltr_el0 & PMCCFILTR_U) { + return 0; + } else if (env->cp15.c9_pmxevtyper & PMXEVTYPER_U) { + return 0; + } + } + + return 1; +} +#endif + +#ifndef CONFIG_USER_ONLY static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) {
Include a helper function to determine if the CCNT counter is enabled as well as the constants used to mask the pmccfiltr_el0 and c9_pmxevtyper registers. Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> --- target-arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-)