Message ID | 20240621075607.17902-1-philmd@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bswap: Add st24_be_p() to store 24 bits in big-endian order | expand |
On 6/21/24 9:56 AM, Philippe Mathieu-Daudé wrote: > Commit 14180d6221 ("bswap: Add the ability to store to an > unaligned 24 bit field") added st24_le_p() for little > endianness, add st24_be_p() equivalent for bit one. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > Some SD card registers are 3 bytes wide stored MSB first. > --- Reviewed-by: Cédric Le Goater <clg@redhat.com> Thanks, C. > include/qemu/bswap.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h > index bd67468e5e..ad22910a5d 100644 > --- a/include/qemu/bswap.h > +++ b/include/qemu/bswap.h > @@ -38,12 +38,14 @@ static inline void bswap64s(uint64_t *s) > #if HOST_BIG_ENDIAN > #define be_bswap(v, size) (v) > #define le_bswap(v, size) glue(__builtin_bswap, size)(v) > +#define be_bswap24(v) (v) > #define le_bswap24(v) bswap24(v) > #define be_bswaps(v, size) > #define le_bswaps(p, size) \ > do { *p = glue(__builtin_bswap, size)(*p); } while (0) > #else > #define le_bswap(v, size) (v) > +#define be_bswap24(v) bswap24(v) > #define le_bswap24(v) (v) > #define be_bswap(v, size) glue(__builtin_bswap, size)(v) > #define le_bswaps(v, size) > @@ -357,6 +359,11 @@ static inline void stw_be_p(void *ptr, uint16_t v) > stw_he_p(ptr, be_bswap(v, 16)); > } > > +static inline void st24_be_p(void *ptr, uint32_t v) > +{ > + st24_he_p(ptr, be_bswap24(v)); > +} > + > static inline void stl_be_p(void *ptr, uint32_t v) > { > stl_he_p(ptr, be_bswap(v, 32));
On 6/21/24 00:56, Philippe Mathieu-Daudé wrote: > Commit 14180d6221 ("bswap: Add the ability to store to an > unaligned 24 bit field") added st24_le_p() for little > endianness, add st24_be_p() equivalent for bit one. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > Some SD card registers are 3 bytes wide stored MSB first. > --- > include/qemu/bswap.h | 7 +++++++ > 1 file changed, 7 insertions(+) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~
On 21/6/24 09:56, Philippe Mathieu-Daudé wrote: > Commit 14180d6221 ("bswap: Add the ability to store to an > unaligned 24 bit field") added st24_le_p() for little > endianness, add st24_be_p() equivalent for bit one. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > Some SD card registers are 3 bytes wide stored MSB first. > --- > include/qemu/bswap.h | 7 +++++++ > 1 file changed, 7 insertions(+) Patch queued.
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index bd67468e5e..ad22910a5d 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -38,12 +38,14 @@ static inline void bswap64s(uint64_t *s) #if HOST_BIG_ENDIAN #define be_bswap(v, size) (v) #define le_bswap(v, size) glue(__builtin_bswap, size)(v) +#define be_bswap24(v) (v) #define le_bswap24(v) bswap24(v) #define be_bswaps(v, size) #define le_bswaps(p, size) \ do { *p = glue(__builtin_bswap, size)(*p); } while (0) #else #define le_bswap(v, size) (v) +#define be_bswap24(v) bswap24(v) #define le_bswap24(v) (v) #define be_bswap(v, size) glue(__builtin_bswap, size)(v) #define le_bswaps(v, size) @@ -357,6 +359,11 @@ static inline void stw_be_p(void *ptr, uint16_t v) stw_he_p(ptr, be_bswap(v, 16)); } +static inline void st24_be_p(void *ptr, uint32_t v) +{ + st24_he_p(ptr, be_bswap24(v)); +} + static inline void stl_be_p(void *ptr, uint32_t v) { stl_he_p(ptr, be_bswap(v, 32));
Commit 14180d6221 ("bswap: Add the ability to store to an unaligned 24 bit field") added st24_le_p() for little endianness, add st24_be_p() equivalent for bit one. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- Some SD card registers are 3 bytes wide stored MSB first. --- include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+)