diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2024-09-30 14:45:48 +0800 |
---|---|---|
committer | Yu-Ping Wu <yupingso@google.com> | 2024-10-15 10:16:40 +0000 |
commit | a03e5456e68d8937f4c43ec112c1495ae26a6356 (patch) | |
tree | b9696ef8abef4522287d54731dd194737c0548d5 /payloads | |
parent | 1890bd6117ecb6059d694b383db4d0dbcfdf0986 (diff) |
libpayload/endian: Add read32p/write32p macros and friends
Add {read,write}{8,16,32,64}p macros and similar macros for clrsetbits,
setbits and clrbits.
Change-Id: If01e38663ffc1c08c553850d3210604c9b240655
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84592
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/include/endian.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/payloads/libpayload/include/endian.h b/payloads/libpayload/include/endian.h index 35fe0fd283..fd59af1b5c 100644 --- a/payloads/libpayload/include/endian.h +++ b/payloads/libpayload/include/endian.h @@ -193,6 +193,16 @@ static inline void le64enc(void *pp, uint32_t u) #define letohl(in) le32toh(in) #define letohll(in) le64toh(in) +/* read/write with uintptr_t address */ +#define read8p(addr) read8((void *)((uintptr_t)(addr))) +#define read16p(addr) read16((void *)((uintptr_t)(addr))) +#define read32p(addr) read32((void *)((uintptr_t)(addr))) +#define read64p(addr) read64((void *)((uintptr_t)(addr))) +#define write8p(addr, value) write8((void *)((uintptr_t)(addr)), value) +#define write16p(addr, value) write16((void *)((uintptr_t)(addr)), value) +#define write32p(addr, value) write32((void *)((uintptr_t)(addr)), value) +#define write64p(addr, value) write64((void *)((uintptr_t)(addr)), value) + /* Handy bit manipulation macros */ #define __clrsetbits(endian, bits, addr, clear, set) \ @@ -238,4 +248,19 @@ static inline void le64enc(void *pp, uint32_t u) #define clrbits32(addr, clear) clrsetbits32(addr, clear, 0) #define clrbits64(addr, clear) clrsetbits64(addr, clear, 0) +#define clrsetbits8p(addr, clear, set) clrsetbits8((void *)((uintptr_t)(addr)), clear, set) +#define clrsetbits16p(addr, clear, set) clrsetbits16((void *)((uintptr_t)(addr)), clear, set) +#define clrsetbits32p(addr, clear, set) clrsetbits32((void *)((uintptr_t)(addr)), clear, set) +#define clrsetbits64p(addr, clear, set) clrsetbits64((void *)((uintptr_t)(addr)), clear, set) + +#define setbits8p(addr, set) clrsetbits8((void *)((uintptr_t)(addr)), 0, set) +#define setbits16p(addr, set) clrsetbits16((void *)((uintptr_t)(addr)), 0, set) +#define setbits32p(addr, set) clrsetbits32((void *)((uintptr_t)(addr)), 0, set) +#define setbits64p(addr, set) clrsetbits64((void *)((uintptr_t)(addr)), 0, set) + +#define clrbits8p(addr, clear) clrsetbits8((void *)((uintptr_t)(addr)), clear, 0) +#define clrbits16p(addr, clear) clrsetbits16((void *)((uintptr_t)(addr)), clear, 0) +#define clrbits32p(addr, clear) clrsetbits32((void *)((uintptr_t)(addr)), clear, 0) +#define clrbits64p(addr, clear) clrsetbits64((void *)((uintptr_t)(addr)), clear, 0) + #endif /* _ENDIAN_H_ */ |