Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/dev/lib/libpci Add a "userfeature" definition for i...



details:   https://anonhg.NetBSD.org/src/rev/4989ab00db15
branches:  trunk
changeset: 809038:4989ab00db15
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Jun 15 15:38:52 2015 +0000

description:
Add a "userfeature" definition for iospace.  I/O space is supported if
that flag is given and calling the init routine succeeds (and we're on
x86, which we probably need to be on anyway for this PCI component to
currently be supported).

Also, some adjustments to make things between flags consistent, namely
deprecate the Makefile variable RUMP_PCI_IOSPACE and don't require
userfeature.h to map 1:1 to the interfaces.

Includes contributions from Robert Millan.

diffstat:

 sys/rump/dev/lib/libpci/Makefile            |   4 ++--
 sys/rump/dev/lib/libpci/pci_at_mainbus.c    |  19 +++++++++++++++----
 sys/rump/dev/lib/libpci/pci_user.h          |  19 +++++++++++++++++--
 sys/rump/dev/lib/libpci/rumpdev_bus_dma.c   |   6 +++---
 sys/rump/dev/lib/libpci/rumpdev_bus_space.c |   5 +++--
 5 files changed, 40 insertions(+), 13 deletions(-)

diffs (144 lines):

diff -r 52443b1359dd -r 4989ab00db15 sys/rump/dev/lib/libpci/Makefile
--- a/sys/rump/dev/lib/libpci/Makefile  Mon Jun 15 14:24:01 2015 +0000
+++ b/sys/rump/dev/lib/libpci/Makefile  Mon Jun 15 15:38:52 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.5 2015/06/03 13:41:56 pooka Exp $
+#      $NetBSD: Makefile,v 1.6 2015/06/15 15:38:52 pooka Exp $
 #
 
 RUMPTOP= ${TOPRUMP}
@@ -26,7 +26,7 @@
 CPPFLAGS+= -I${RUMPTOP}/librump/rumpvfs
 
 .if ${RUMP_PCI_IOSPACE:Uno} == "yes"
-CPPFLAGS+=-DRUMP_PCI_IOSPACE
+.error RUMP_PCI_IOSPACE defined in Makefile.  Use userfeatures.h instead.
 .endif
 
 .PATH:                 ${RUMPCOMP_USER_PATH.rumpdev_pci}
diff -r 52443b1359dd -r 4989ab00db15 sys/rump/dev/lib/libpci/pci_at_mainbus.c
--- a/sys/rump/dev/lib/libpci/pci_at_mainbus.c  Mon Jun 15 14:24:01 2015 +0000
+++ b/sys/rump/dev/lib/libpci/pci_at_mainbus.c  Mon Jun 15 15:38:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_at_mainbus.c,v 1.5 2014/08/22 14:28:58 pooka Exp $ */
+/*     $NetBSD: pci_at_mainbus.c,v 1.6 2015/06/15 15:38:52 pooka Exp $ */
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_at_mainbus.c,v 1.5 2014/08/22 14:28:58 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_at_mainbus.c,v 1.6 2015/06/15 15:38:52 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -43,6 +43,8 @@
 #include "rump_private.h"
 #include "rump_vfs_private.h"
 
+#include "pci_user.h"
+
 RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
        extern const struct cdevsw pci_cdevsw;
@@ -80,8 +82,17 @@
 #endif
        pba.pba_flags = PCI_FLAGS_MEM_OKAY |
            PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;;
-#ifdef RUMP_PCI_IOSPACE
-       pba.pba_flags |= PCI_FLAGS_IO_OKAY;
+
+#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE
+       int error;
+
+       error = rumpcomp_pci_iospace_init();
+       if (!error) {
+               pba.pba_flags |= PCI_FLAGS_IO_OKAY;
+       } else {
+               aprint_error("pci: I/O space init error %d, I/O space not "
+                   "available\n", error);
+       }
 #endif
 
        mainbus = device_find_by_driver_unit("mainbus", 0);
diff -r 52443b1359dd -r 4989ab00db15 sys/rump/dev/lib/libpci/pci_user.h
--- a/sys/rump/dev/lib/libpci/pci_user.h        Mon Jun 15 14:24:01 2015 +0000
+++ b/sys/rump/dev/lib/libpci/pci_user.h        Mon Jun 15 15:38:52 2015 +0000
@@ -1,3 +1,14 @@
+/*
+ * Possible userfeature macro flags:
+ *
+ *   RUMPCOMP_USERFEATURE_PCI_DMAFREE:
+ *     Support free'ing DMA memory.  If not, panic() when free() is called.
+ *
+ *   RUMPCOMP_USERFEATURE_PCI_IOSPACE
+ *     Support for PCI I/O space.  If yes, rumpcomp_pci_iospace_init()
+ *     must be provided.
+ */
+
 #include "rumpcomp_userfeatures_pci.h"
 
 void *rumpcomp_pci_map(unsigned long, unsigned long);
@@ -9,8 +20,8 @@
 
 /* XXX: needs work: support boundary-restricted allocations */
 int rumpcomp_pci_dmalloc(size_t, size_t, unsigned long *, unsigned long *);
-#ifdef rumpcomp_pci_free
-void rumpcomp_pci_free(unsigned long, size_t);
+#ifdef RUMPCOMP_USERFEATURE_PCI_DMAFREE
+void rumpcomp_pci_dmafree(unsigned long, size_t);
 #endif
 
 struct rumpcomp_pci_dmaseg {
@@ -22,3 +33,7 @@
                            void **);
 
 unsigned long rumpcomp_pci_virt_to_mach(void *);
+
+#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE
+int rumpcomp_pci_iospace_init(void);
+#endif
diff -r 52443b1359dd -r 4989ab00db15 sys/rump/dev/lib/libpci/rumpdev_bus_dma.c
--- a/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c Mon Jun 15 14:24:01 2015 +0000
+++ b/sys/rump/dev/lib/libpci/rumpdev_bus_dma.c Mon Jun 15 15:38:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpdev_bus_dma.c,v 1.4 2015/06/03 13:55:42 pooka Exp $        */
+/*     $NetBSD: rumpdev_bus_dma.c,v 1.5 2015/06/15 15:38:52 pooka Exp $        */
 
 /*-
  * Copyright (c) 2013 Antti Kantee
@@ -446,11 +446,11 @@
 void
 bus_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
 {
-#ifdef rumpcomp_pci_free
+#ifdef RUMPCOMP_USERFEATURE_PCI_DMAFREE
        vaddr_t vacookie = segs[0]._ds_vacookie;
        bus_size_t sizecookie = segs[0]._ds_sizecookie;
 
-       rumpcomp_pci_free(vacookie, sizecookie);
+       rumpcomp_pci_dmafree(vacookie, sizecookie);
 #else
        panic("bus_dmamem_free not implemented");
 #endif
diff -r 52443b1359dd -r 4989ab00db15 sys/rump/dev/lib/libpci/rumpdev_bus_space.c
--- a/sys/rump/dev/lib/libpci/rumpdev_bus_space.c       Mon Jun 15 14:24:01 2015 +0000
+++ b/sys/rump/dev/lib/libpci/rumpdev_bus_space.c       Mon Jun 15 15:38:52 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpdev_bus_space.c,v 1.4 2015/05/17 13:45:37 pooka Exp $      */
+/*     $NetBSD: rumpdev_bus_space.c,v 1.5 2015/06/15 15:38:52 pooka Exp $      */
 
 /*-
  * Copyright (c) 2013 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,8 @@
 
 #include "pci_user.h"
 
-#if defined(RUMP_PCI_IOSPACE) && (defined(__i386__) || defined(__x86_64__))
+#if defined(RUMPCOMP_USERFEATURE_PCI_IOSPACE) \
+    && (defined(__i386__) || defined(__x86_64__))
 #define IOSPACE_SUPPORTED
 #endif
 



Home | Main Index | Thread Index | Old Index