[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 02/22] plat/include: Use macro-ed helper to simplify ioreg_read/write for Arm64


  • To: <minios-devel@xxxxxxxxxxxxxxxxxxxx>, <simon.kuenzer@xxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Thu, 8 Nov 2018 09:51:33 +0000
  • Authentication-results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=bestguesspass action=none header.from=arm.com;
  • Cc: Kaly.Xin@xxxxxxx, nd@xxxxxxx, wei.chen@xxxxxxx
  • Delivery-date: Thu, 08 Nov 2018 09:52:15 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.