From 394933640bc0515617117ed0cb8de7702bc9c1bf Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Thu, 25 Jun 2015 16:19:49 -0700 Subject: libpayload: arm(64): add read8/16/32 and write8/16/32 This applys the same change made by https://chromium-review.googlesource.com/261692 to libpayload. BUG=none BRANCH=tot TEST=built for veyron_jerry, rush_ryu, samus Change-Id: I26dd66d79cd1559a7852b3c9d252420f2fed5fa0 Signed-off-by: Patrick Georgi Original-Commit-Id: d0d6f70aa805e18966e80618fbf9e9605274b030 Original-Change-Id: Ib0c199238f8fa58643d51782b17550dbd0d9ebd7 Original-Signed-off-by: Daisuke Nojiri Original-Reviewed-on: https://chromium-review.googlesource.com/282541 Original-Reviewed-by: Aaron Durbin Reviewed-on: http://review.coreboot.org/10773 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/libpayload/include/arm/arch/io.h | 47 +++++++++++++++++++++++++++++ payloads/libpayload/include/arm64/arch/io.h | 47 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/payloads/libpayload/include/arm/arch/io.h b/payloads/libpayload/include/arm/arch/io.h index df3a0d51ae..2743852299 100644 --- a/payloads/libpayload/include/arm/arch/io.h +++ b/payloads/libpayload/include/arm/arch/io.h @@ -34,6 +34,14 @@ #include #include +/* + * readb/w/l writeb/w/l are deprecated. use read8/16/32 and write8/16/32 + * instead for future development. + * + * TODO: make the existing code use read8/16/32 and write8/16/32 then remove + * readb/w/l and writeb/w/l. + */ + static inline uint8_t readb(volatile const void *_a) { dmb(); @@ -73,4 +81,43 @@ static inline void writel(uint32_t _v, volatile void *_a) dmb(); } +static inline uint8_t read8(const void *addr) +{ + dmb(); + return *(volatile uint8_t *)addr; +} + +static inline uint16_t read16(const void *addr) +{ + dmb(); + return *(volatile uint16_t *)addr; +} + +static inline uint32_t read32(const void *addr) +{ + dmb(); + return *(volatile uint32_t *)addr; +} + +static inline void write8(void *addr, uint8_t val) +{ + dmb(); + *(volatile uint8_t *)addr = val; + dmb(); +} + +static inline void write16(void *addr, uint16_t val) +{ + dmb(); + *(volatile uint16_t *)addr = val; + dmb(); +} + +static inline void write32(void *addr, uint32_t val) +{ + dmb(); + *(volatile uint32_t *)addr = val; + dmb(); +} + #endif diff --git a/payloads/libpayload/include/arm64/arch/io.h b/payloads/libpayload/include/arm64/arch/io.h index f8be1aec95..c177598d86 100644 --- a/payloads/libpayload/include/arm64/arch/io.h +++ b/payloads/libpayload/include/arm64/arch/io.h @@ -35,6 +35,14 @@ #include #include +/* + * readb/w/l writeb/w/l are deprecated. use read8/16/32 and write8/16/32 + * instead for future development. + * + * TODO: make the existing code use read8/16/32 and write8/16/32 then remove + * readb/w/l and writeb/w/l. + */ + static inline uint8_t readb(volatile const void *_a) { dmb(); @@ -74,4 +82,43 @@ static inline void writel(uint32_t _v, volatile void *_a) dmb(); } +static inline uint8_t read8(const void *addr) +{ + dmb(); + return *(volatile uint8_t *)addr; +} + +static inline uint16_t read16(const void *addr) +{ + dmb(); + return *(volatile uint16_t *)addr; +} + +static inline uint32_t read32(const void *addr) +{ + dmb(); + return *(volatile uint32_t *)addr; +} + +static inline void write8(void *addr, uint8_t val) +{ + dmb(); + *(volatile uint8_t *)addr = val; + dmb(); +} + +static inline void write16(void *addr, uint16_t val) +{ + dmb(); + *(volatile uint16_t *)addr = val; + dmb(); +} + +static inline void write32(void *addr, uint32_t val) +{ + dmb(); + *(volatile uint32_t *)addr = val; + dmb(); +} + #endif -- cgit v1.2.3