Yu-Ping Wu has submitted this change. ( https://review.coreboot.org/c/coreboot/+/84592?usp=email )
Change subject: libpayload/endian: Add read32p/write32p macros and friends ......................................................................
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 --- M payloads/libpayload/include/endian.h 1 file changed, 25 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Yidi Lin: Looks good to me, approved
diff --git a/payloads/libpayload/include/endian.h b/payloads/libpayload/include/endian.h index 35fe0fd..fd59af1 100644 --- a/payloads/libpayload/include/endian.h +++ b/payloads/libpayload/include/endian.h @@ -193,6 +193,16 @@ #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 @@ #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_ */