bswap: Add st24_be_p() to store 24 bits in big-endian order
PATCH 1/1 bswap: Add st24_be_p() to store 24 bits in big-endian order
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.
---
Some SD card registers are 3 bytes wide stored MSB first.
--- include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/qemu/bswap.h +7 -0
@@ -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 ));
Signature · 1 line
2.41.0
Quoted 8 lines · Philippe Mathieu-Daudé
Commit
14180d6221("bswap: Add the ability to store to an unaligned 24 bit field") addedst24_le_p()for little endianness, addst24_be_p()equivalent for bit one.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Some SD card registers are 3 bytes wide stored MSB first.
---
Thanks,
C.
Quoted 34 lines
include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+)include/qemu/bswap.h +7
-0@@ -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 ));
Quoted 10 lines · Philippe Mathieu-Daudé
Commit
14180d6221("bswap: Add the ability to store to an unaligned 24 bit field") addedst24_le_p()for little endianness, addst24_be_p()equivalent for bit one.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Some SD card registers are 3 bytes wide stored MSB first.--- include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+)
r~
Quoted 10 lines · Philippe Mathieu-Daudé
Commit
14180d6221("bswap: Add the ability to store to an unaligned 24 bit field") addedst24_le_p()for little endianness, addst24_be_p()equivalent for bit one.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Some SD card registers are 3 bytes wide stored MSB first.--- include/qemu/bswap.h | 7 +++++++ 1 file changed, 7 insertions(+)
Patch queued.