[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCHv3 02/25] plat/include: Use macro-ed helper to simplify ioreg_read/write for Arm64
As discussed in mailing list [1], we can use macro-ed helpers to avoid having to write 4 times of the same things of ioreg_read_8/16/32/64 and ioreg_write8/16/32/64. Signed-off-by: Wei Chen <wei.chen@xxxxxxx> --- plat/common/include/arm/arm64/cpu.h | 64 +++++++++++------------------ 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/plat/common/include/arm/arm64/cpu.h b/plat/common/include/arm/arm64/cpu.h index bfea461..53fa577 100644 --- a/plat/common/include/arm/arm64/cpu.h +++ b/plat/common/include/arm/arm64/cpu.h @@ -34,45 +34,31 @@ #include <inttypes.h> -static inline uint8_t ioreg_read8(const volatile uint8_t *addr) -{ - return *addr; -} - -static inline void ioreg_write8(volatile uint8_t *addr, uint8_t value) -{ - *addr = value; -} - -static inline uint16_t ioreg_read16(const volatile uint16_t *addr) -{ - return *addr; -} - -static inline void ioreg_write16(volatile uint16_t *addr, uint16_t value) -{ - *addr = value; -} - -static inline uint32_t ioreg_read32(const volatile uint32_t *addr) -{ - return *addr; -} - -static inline void ioreg_write32(volatile uint32_t *addr, uint32_t value) -{ - *addr = value; -} - -static inline uint64_t ioreg_read64(const volatile uint64_t *addr) -{ - return *addr; -} - -static inline void ioreg_write64(volatile uint64_t *addr, uint64_t value) -{ - *addr = value; -} +/* Define macros to access IO registers */ +#define __IOREG_READ(bits) \ + static inline uint##bits##_t \ + ioreg_read##bits(const volatile uint##bits##_t *addr) \ + { return *addr; } + +#define __IOREG_WRITE(bits) \ + static inline void \ + ioreg_write##bits(volatile uint##bits##_t *addr, \ + uint##bits##_t value) \ + { *addr = value; } + + +#define __IOREG_READ_ALL() __IOREG_READ(8) \ + __IOREG_READ(16) \ + __IOREG_READ(32) \ + __IOREG_READ(64) \ + +#define __IOREG_WRITE_ALL() __IOREG_WRITE(8) \ + __IOREG_WRITE(16) \ + __IOREG_WRITE(32) \ + __IOREG_WRITE(64) \ + +__IOREG_READ_ALL() +__IOREG_WRITE_ALL() /* Define compatibility IO macros */ #define outb(addr, v) UK_BUG() -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |