[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 18/25] hw/virtio: Introduce VIRTIO_LD_CONVERT() macro
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 18/25] hw/virtio: Introduce VIRTIO_LD_CONVERT() macro |
Date: |
Tue, 18 May 2021 20:36:48 +0200 |
To be able to add more load/store operations,
introduce the VIRTIO_LD_CONVERT() macro.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
include/hw/virtio/virtio-access.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/include/hw/virtio/virtio-access.h
b/include/hw/virtio/virtio-access.h
index ae8c9feffc5..37e1e6ea535 100644
--- a/include/hw/virtio/virtio-access.h
+++ b/include/hw/virtio/virtio-access.h
@@ -39,6 +39,35 @@ static inline bool virtio_access_is_big_endian(VirtIODevice
*vdev)
#endif
}
+#define VIRTIO_LD_CONVERT(size, rtype)\
+static inline rtype virtio_ld ## size ## _phys(VirtIODevice *vdev, hwaddr pa)\
+{\
+ AddressSpace *dma_as = vdev->dma_as;\
+\
+ if (virtio_access_is_big_endian(vdev)) {\
+ return ld ## size ## _be_phys(dma_as, pa);\
+ }\
+ return ld ## size ## _le_phys(dma_as, pa);\
+}\
+static inline rtype virtio_ld ## size ## _p(VirtIODevice *vdev,\
+ const void *ptr)\
+{\
+ if (virtio_access_is_big_endian(vdev)) {\
+ return ld ## size ## _be_p(ptr);\
+ } else {\
+ return ld ## size ## _le_p(ptr);\
+ }\
+}\
+static inline rtype virtio_ld ## size ## _phys_cached(VirtIODevice *vdev,\
+ MemoryRegionCache
*cache,\
+ hwaddr pa)\
+{\
+ if (virtio_access_is_big_endian(vdev)) {\
+ return ld ## size ## _be_phys_cached(cache, pa);\
+ }\
+ return ld ## size ## _le_phys_cached(cache, pa);\
+}
+
static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa)
{
AddressSpace *dma_as = vdev->dma_as;
--
2.26.3
- [RFC PATCH 13/25] qemu/bswap: Use LDST_CONVERT macro to emit 64-bit load/store functions, (continued)
- [RFC PATCH 16/25] exec/memory: Add methods for aligned pointer access (physical memory), Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 15/25] exec/memory: Add methods for aligned pointer access (address space), Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 17/25] hw/virtio: Use correct type sizes, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 18/25] hw/virtio: Introduce VIRTIO_LD_CONVERT() macro,
Philippe Mathieu-Daudé <=
- [RFC PATCH 19/25] hw/virtio: Use LD_CONVERT macro to emit 16-bit unsigned load/store code, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 20/25] hw/virtio: Introduce VIRTIO_ST_CONVERT() macro, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 21/25] hw/virtio: Use ST_CONVERT() macro to emit 16-bit load/store functions, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 22/25] hw/virtio: Use LDST_CONVERT macro to emit 32-bit load/store functions, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 24/25] hw/virtio: Add methods for aligned pointer access, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 23/25] hw/virtio: Use LDST_CONVERT macro to emit 64-bit load/store functions, Philippe Mathieu-Daudé, 2021/05/18
- [RFC PATCH 25/25] hw/virtio: Optimize accesses on vring aligned pointers, Philippe Mathieu-Daudé, 2021/05/18
- Re: [RFC PATCH 00/25] exec: Add load/store API for aligned pointers, no-reply, 2021/05/18
- Re: [RFC PATCH 00/25] exec: Add load/store API for aligned pointers, Richard Henderson, 2021/05/19