[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCHv6 11/37] plat/common: Introduce SYSREG_READ32/64 SYSTEM_WRITE32/64 for different size



Hi Julien,

> -----Original Message-----
> From: Julien Grall <julien.grall@xxxxxxx>
> Sent: 2018年9月17日 8:44
> To: Wei Chen (Arm Technology China) <Wei.Chen@xxxxxxx>; minios-
> devel@xxxxxxxxxxxxxxxxxxxx; simon.kuenzer@xxxxxxxxx
> Cc: Kaly Xin (Arm Technology China) <Kaly.Xin@xxxxxxx>; nd <nd@xxxxxxx>
> Subject: Re: [Minios-devel] [UNIKRAFT PATCHv6 11/37] plat/common: Introduce
> SYSREG_READ32/64 SYSTEM_WRITE32/64 for different size
> 
> Hi,
> 
> On 09/14/2018 08:56 AM, Wei Chen wrote:
> > On Arm, the system registers may have different size. Introduce these
> > four helpers will give us a direct visual about the register's size we
> > are accessing.
> >
> > Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
> > ---
> >   plat/common/include/arm/arm64/cpu.h | 14 ++++++++++++++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/plat/common/include/arm/arm64/cpu.h
> b/plat/common/include/arm/arm64/cpu.h
> > index 702761c..db8be9c 100644
> > --- a/plat/common/include/arm/arm64/cpu.h
> > +++ b/plat/common/include/arm/arm64/cpu.h
> > @@ -90,3 +90,17 @@ static inline void ioreg_write64(volatile uint64_t *addr,
> uint64_t value)
> >   #define SYSREG_WRITE(reg, val) \
> >     __asm__ __volatile__("msr " __STRINGIFY(reg) ", %0" \
> >                     : : "r" ((uint64_t)(val)))
> > +
> > +#define SYSREG_READ32(reg) \
> > +({ uint32_t val; \
> > +   __asm__ __volatile__("mrs %0, " __STRINGIFY(reg) \
> > +                   : "=&r" (val)); \
> 
> I am not entirely sure why you need the earlycloberr (&) here. The
> operand will not be written before the instruction has finished.
> 

Is there any harm that I am using the "&", because I always use it
in such case?

> > +   val; \
> > +})
> > +
> > +#define SYSREG_WRITE32(reg, val) \
> > +   __asm__ __volatile__("msr " __STRINGIFY(reg) ", %0" \
> > +                   : : "r" ((uint32_t)(val)))
> > +
> > +#define SYSREG_READ64(reg) SYSREG_READ(reg)
> > +#define SYSREG_WRITE64(reg, val) SYSREG_WRITE(reg, val)
> >
> 
> Cheers,
> 
> --
> Julien Grall
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.