[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xen/arm: vtimer: Introduce vtimer_emulate_sysreg{32, 64}
commit ce0fac22e7f367ba72ebd762331f8c9bdf1e2519 Author: Julien Grall <julien.grall@xxxxxxxxxx> AuthorDate: Fri Dec 11 15:28:22 2015 +0000 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Tue Jan 5 11:49:40 2016 +0000 xen/arm: vtimer: Introduce vtimer_emulate_sysreg{32, 64} Factorize the code to emulate a a 32-bit/64-bit sysreg in specific helpers. While this is currently not necessary, it will be helpful in a following patch to handle properly some registers. Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- xen/arch/arm/vtimer.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 files changed, 33 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index 629feb4..b9c0b41 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -302,11 +302,39 @@ static int vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr) } #ifdef CONFIG_ARM_64 -static int vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) +typedef int (*vtimer_sysreg32_fn_t)(struct cpu_user_regs *regs, uint32_t *r, + int read); +typedef int (*vtimer_sysreg64_fn_t)(struct cpu_user_regs *regs, uint64_t *r, + int read); + +static int vtimer_emulate_sysreg32(struct cpu_user_regs *regs, union hsr hsr, + vtimer_sysreg32_fn_t fn) { struct hsr_sysreg sysreg = hsr.sysreg; register_t *x = select_user_reg(regs, sysreg.reg); - uint32_t r = (uint32_t)*x; + uint32_t r = *x; + int ret; + + ret = fn(regs, &r, sysreg.read); + + if ( ret && sysreg.read ) + *x = r; + + return ret; +} + +static int vtimer_emulate_sysreg64(struct cpu_user_regs *regs, union hsr hsr, + vtimer_sysreg64_fn_t fn) +{ + struct hsr_sysreg sysreg = hsr.sysreg; + uint64_t *x = select_user_reg(regs, sysreg.reg); + + return fn(regs, x, sysreg.read); +} + +static int vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) +{ + struct hsr_sysreg sysreg = hsr.sysreg; if ( sysreg.read ) perfc_incr(vtimer_sysreg_reads); @@ -316,20 +344,11 @@ static int vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) switch ( hsr.bits & HSR_SYSREG_REGS_MASK ) { case HSR_SYSREG_CNTP_CTL_EL0: - if ( !vtimer_cntp_ctl(regs, &r, sysreg.read) ) - return 0; - if ( sysreg.read ) - *x = r; - return 1; + return vtimer_emulate_sysreg32(regs, hsr, vtimer_cntp_ctl); case HSR_SYSREG_CNTP_TVAL_EL0: - if ( !vtimer_cntp_tval(regs, &r, sysreg.read) ) - return 0; - if ( sysreg.read ) - *x = r; - return 1; - + return vtimer_emulate_sysreg32(regs, hsr, vtimer_cntp_tval); case HSR_SYSREG_CNTP_CVAL_EL0: - return vtimer_cntp_cval(regs, x, sysreg.read); + return vtimer_emulate_sysreg64(regs, hsr, vtimer_cntp_cval); default: return 0; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |