Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/virtio Add virtio mmio probe function



details:   https://anonhg.NetBSD.org/src/rev/b316206538f7
branches:  trunk
changeset: 959234:b316206538f7
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Fri Feb 05 21:25:36 2021 +0000

description:
Add virtio mmio probe function

diffstat:

 sys/dev/virtio/virtio_mmio.c    |  14 ++++++++++++--
 sys/dev/virtio/virtio_mmiovar.h |   3 ++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diffs (52 lines):

diff -r b05b06cab432 -r b316206538f7 sys/dev/virtio/virtio_mmio.c
--- a/sys/dev/virtio/virtio_mmio.c      Fri Feb 05 20:45:38 2021 +0000
+++ b/sys/dev/virtio/virtio_mmio.c      Fri Feb 05 21:25:36 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: virtio_mmio.c,v 1.5 2021/01/28 15:43:13 reinoud Exp $  */
+/*     $NetBSD: virtio_mmio.c,v 1.6 2021/02/05 21:25:36 reinoud Exp $  */
 /*     $OpenBSD: virtio_mmio.c,v 1.2 2017/02/24 17:12:31 patrick Exp $ */
 
 /*
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: virtio_mmio.c,v 1.5 2021/01/28 15:43:13 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_mmio.c,v 1.6 2021/02/05 21:25:36 reinoud Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -139,6 +139,16 @@
                          status|old);
 }
 
+bool
+virtio_mmio_common_probe_present(struct virtio_mmio_softc *sc)
+{
+       uint32_t magic;
+
+       magic = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
+           VIRTIO_MMIO_MAGIC_VALUE);
+       return (magic == VIRTIO_MMIO_MAGIC);
+}
+
 void
 virtio_mmio_common_attach(struct virtio_mmio_softc *sc)
 {
diff -r b05b06cab432 -r b316206538f7 sys/dev/virtio/virtio_mmiovar.h
--- a/sys/dev/virtio/virtio_mmiovar.h   Fri Feb 05 20:45:38 2021 +0000
+++ b/sys/dev/virtio/virtio_mmiovar.h   Fri Feb 05 21:25:36 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_mmiovar.h,v 1.3 2018/07/16 02:36:39 kre Exp $ */
+/* $NetBSD: virtio_mmiovar.h,v 1.4 2021/02/05 21:25:36 reinoud Exp $ */
 /*
  * Copyright (c) 2018 Jonathan A. Kollasch
  * All rights reserved.
@@ -44,6 +44,7 @@
 
 };
 
+bool virtio_mmio_common_probe_present(struct virtio_mmio_softc *);
 void virtio_mmio_common_attach(struct virtio_mmio_softc *);
 int virtio_mmio_common_detach(struct virtio_mmio_softc *, int);
 int virtio_mmio_intr(void *);



Home | Main Index | Thread Index | Old Index