@@ -11,8 +11,28 @@
#include "qemu/osdep.h"
#include "hw/virtio/virtio.h"
+#include "hw/virtio/virtio-access.h"
#include "cpu.h"
+#if defined(TARGET_PPC64) || defined(TARGET_ARM)
+#define LEGACY_VIRTIO_IS_BIENDIAN 1
+#endif
+
+bool virtio_access_is_big_endian(VirtIODevice *vdev)
+{
+#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
+ return virtio_is_big_endian(vdev);
+#elif TARGET_BIG_ENDIAN
+ if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
+ /* Devices conforming to VIRTIO 1.0 or later are always LE. */
+ return false;
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
@@ -20,24 +20,7 @@
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-bus.h"
-#if defined(TARGET_PPC64) || defined(TARGET_ARM)
-#define LEGACY_VIRTIO_IS_BIENDIAN 1
-#endif
-
-static inline bool virtio_access_is_big_endian(VirtIODevice *vdev)
-{
-#if defined(LEGACY_VIRTIO_IS_BIENDIAN)
- return virtio_is_big_endian(vdev);
-#elif TARGET_BIG_ENDIAN
- if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
- /* Devices conforming to VIRTIO 1.0 or later are always LE. */
- return false;
- }
- return true;
-#else
- return false;
-#endif
-}
+bool virtio_access_is_big_endian(VirtIODevice *vdev);
static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa)
{
In order to avoid target-specific code in VirtIO headers, move this particular function -- which is only called once in virtio_init() -- in its own unit. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/virtio/virtio-config.c | 20 ++++++++++++++++++++ include/hw/virtio/virtio-access.h | 19 +------------------ 2 files changed, 21 insertions(+), 18 deletions(-)