Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Remove dependency on bus_space_write_8() for i38...
details: https://anonhg.NetBSD.org/src/rev/64f86aff723f
branches: trunk
changeset: 950234:64f86aff723f
user: reinoud <reinoud%NetBSD.org@localhost>
date: Thu Jan 21 20:48:33 2021 +0000
description:
Remove dependency on bus_space_write_8() for i386 and instead implement it as
two bus_space_write_4()'s as allowed in the spec.
diffstat:
sys/dev/pci/virtio_pci.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diffs (63 lines):
diff -r 988f847e4ecd -r 64f86aff723f sys/dev/pci/virtio_pci.c
--- a/sys/dev/pci/virtio_pci.c Thu Jan 21 19:37:23 2021 +0000
+++ b/sys/dev/pci/virtio_pci.c Thu Jan 21 20:48:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $ */
/*
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -727,6 +727,14 @@
return bus_space_read_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SIZE);
}
+/*
+ * By definition little endian only in v1.0 and 8 byters are allowed to be
+ * written as two 4 byters
+ */
+#define bus_space_write_le_8(iot, ioh, reg, val) \
+ bus_space_write_4(iot, ioh, reg, ((uint64_t) (val)) & 0xffffffff); \
+ bus_space_write_4(iot, ioh, reg + 4, ((uint64_t) (val)) >> 32);
+
static void
virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr)
{
@@ -739,15 +747,15 @@
bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, vq->vq_index);
if (addr == 0) {
bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0);
- bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, 0);
- bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, 0);
- bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, 0);
+ bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, 0);
+ bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, 0);
+ bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, 0);
} else {
- bus_space_write_8(iot, ioh,
+ bus_space_write_le_8(iot, ioh,
VIRTIO_CONFIG1_QUEUE_DESC, addr);
- bus_space_write_8(iot, ioh,
+ bus_space_write_le_8(iot, ioh,
VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset);
- bus_space_write_8(iot, ioh,
+ bus_space_write_le_8(iot, ioh,
VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset);
bus_space_write_2(iot, ioh,
VIRTIO_CONFIG1_QUEUE_ENABLE, 1);
@@ -763,6 +771,7 @@
VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec);
}
}
+#undef bus_space_write_le_8
static void
virtio_pci_set_status_10(struct virtio_softc *sc, int status)
Home |
Main Index |
Thread Index |
Old Index