Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Aug 2004 06:15:13 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 59378 for review
Message-ID:  <200408110615.i7B6FDxL054081@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=59378

Change 59378 by scottl@scottl-wv1u on 2004/08/11 06:14:31

	Create all of the newbus infrastructure for bus_reserve_resource().
	Make msi.c and related stuff compile.

Affected files ...

.. //depot/projects/newint/sys/i386/i386/legacy.c#3 edit
.. //depot/projects/newint/sys/i386/i386/local_apic.c#4 edit
.. //depot/projects/newint/sys/i386/i386/mptable_pci.c#3 edit
.. //depot/projects/newint/sys/i386/i386/msi.c#3 edit
.. //depot/projects/newint/sys/i386/i386/nexus.c#3 edit
.. //depot/projects/newint/sys/i386/include/msi.h#2 edit
.. //depot/projects/newint/sys/i386/include/resource.h#2 edit
.. //depot/projects/newint/sys/kern/bus_if.m#3 edit
.. //depot/projects/newint/sys/kern/subr_bus.c#3 edit
.. //depot/projects/newint/sys/sys/bus.h#5 edit

Differences ...

==== //depot/projects/newint/sys/i386/i386/legacy.c#3 (text+ko) ====

@@ -102,6 +102,7 @@
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_reserve_resource,	bus_generic_reserve_resource),
 
 	{ 0, 0 }
 };
@@ -372,6 +373,7 @@
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_reserve_resource,	bus_generic_reserve_resource),
 
 	{ 0, 0 }
 };

==== //depot/projects/newint/sys/i386/i386/local_apic.c#4 (text+ko) ====

@@ -48,6 +48,7 @@
 #include <machine/frame.h>
 #include <machine/intr_machdep.h>
 #include <machine/apicvar.h>
+#include <machine/msi.h>
 #include <machine/md_var.h>
 #include <machine/smp.h>
 #include <machine/specialreg.h>

==== //depot/projects/newint/sys/i386/i386/mptable_pci.c#3 (text+ko) ====

@@ -90,6 +90,7 @@
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_reserve_resource,	bus_generic_reserve_resource),
 
 	/* pcib interface */
 	DEVMETHOD(pcib_maxslots,	legacy_pcib_maxslots),
@@ -145,6 +146,7 @@
 	DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_reserve_resource,	bus_generic_reserve_resource),
 
 	/* pcib interface */
 	DEVMETHOD(pcib_maxslots,	pcib_maxslots),

==== //depot/projects/newint/sys/i386/i386/msi.c#3 (text+ko) ====

@@ -35,14 +35,18 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 
+#include <machine/frame.h>
 #include <machine/intr_machdep.h>
+#include <machine/apicvar.h>
+#include <machine/msi.h>
+#include <machine/md_var.h>
 
 struct msi_intsrc {
-	struct intsrc io_intsrc,
-	device_t msi_dev,
-	u_int msi_ctrl,
-	u_int msi_addr,
-	u_int msi_data,
+	struct intsrc io_intsrc;
+	device_t msi_dev;
+	u_int msi_ctrl;
+	u_int msi_addr;
+	u_int msi_data;
 	u_int io_vector;
 };
 
@@ -156,12 +160,13 @@
 
 static int
 msi_config_intr(struct intsrc *isrc, enum intr_trigger trig,
-		enum intr_polarity pol);
+		enum intr_polarity pol)
 {
 	return (0);
 }
 
-void msi_init(void)
+void
+msi_init(void)
 {
 
 	if ((cpu_id & 0xf00) != 0xf00)
@@ -170,3 +175,9 @@
 	if (bootverbose || 1)
 		printf("Initializing MSI\n");
 }
+
+int
+msi_reserve_resource(device_t dev, int *start, int *size, int flags)
+{
+	return (0);
+}

==== //depot/projects/newint/sys/i386/i386/nexus.c#3 (text+ko) ====

@@ -60,6 +60,7 @@
 #include <machine/pmap.h>
 
 #include <machine/resource.h>
+#include <machine/msi.h>
 
 #ifdef DEV_ISA
 #include <isa/isavar.h>
@@ -100,6 +101,7 @@
 			     void (*)(void *), void *, void **);
 static	int nexus_teardown_intr(device_t, device_t, struct resource *,
 				void *);
+static	int nexus_reserve_resource(device_t, device_t, int, int *, int *, int);
 static	int nexus_set_resource(device_t, device_t, int, int, u_long, u_long);
 static	int nexus_get_resource(device_t, device_t, int, int, u_long *, u_long *);
 static void nexus_delete_resource(device_t, device_t, int, int);
@@ -126,6 +128,7 @@
 	DEVMETHOD(bus_set_resource,	nexus_set_resource),
 	DEVMETHOD(bus_get_resource,	nexus_get_resource),
 	DEVMETHOD(bus_delete_resource,	nexus_delete_resource),
+	DEVMETHOD(bus_reserve_resource,	nexus_reserve_resource),
 
 	{ 0, 0 }
 };
@@ -512,6 +515,16 @@
 }
 
 static int
+nexus_reserve_resource(device_t dev, device_t child, int type, int *start, int *size, int flags)
+{
+
+	if (type != SYS_RES_MESSAGE)
+		panic("nexus_reserve_resource: unhandled resource type");
+
+	return (msi_reserve_resource(child, start, size, flags));
+}
+
+static int
 nexus_set_resource(device_t dev, device_t child, int type, int rid, u_long start, u_long count)
 {
 	struct nexus_device	*ndev = DEVTONX(child);

==== //depot/projects/newint/sys/i386/include/msi.h#2 (text+ko) ====

@@ -28,3 +28,4 @@
 __FBSDID("$FreeBSD$");
 
 void msi_init(void);
+int msi_reserve_resource(device_t dev, int *start, int *size, int flags);

==== //depot/projects/newint/sys/i386/include/resource.h#2 (text+ko) ====

@@ -40,5 +40,6 @@
 #define	SYS_RES_DRQ	2	/* isa dma lines */
 #define	SYS_RES_MEMORY	3	/* i/o memory */
 #define	SYS_RES_IOPORT	4	/* i/o ports */
+#define SYS_RES_MESSAGE 5	/* interrupt message */
 
 #endif /* !_MACHINE_RESOURCE_H_ */

==== //depot/projects/newint/sys/kern/bus_if.m#3 (text+ko) ====

@@ -353,6 +353,30 @@
 };
 
 /**
+ * @brief Reserve and pre-configure a range of resources.
+ *
+ * This method is used to pre-allocate and reserve bus resources.  The
+ * primary use for it at this time is to negotiate the number of MSI
+ * messages that a driver is allowed to use.
+ *
+ * @param _dev		the parent device of @p _child
+ * @param _child	the device which owns the resource
+ * @param _type		the type of resource
+ * @param @p _start	the start of the resource range
+ * @param @p _count	the size of the resource range
+ * @param _flags	flags for the operation
+ *
+ */
+METHOD int reserve_resource {
+	device_t	_dev;
+	device_t	_child;
+	int		_type;
+	int		*_start;
+	int		*_count;
+	int		_flags;
+};
+
+/**
  * @brief Define a resource which can be allocated with
  * BUS_ALLOC_RESOURCE().
  *

==== //depot/projects/newint/sys/kern/subr_bus.c#3 (text+ko) ====

@@ -2864,6 +2864,23 @@
 }
 
 /**
+ * @brief Helper function for implementing BUS_TEARDOWN_INTR().
+ *                    
+ * This simple implementation of BUS_TEARDOWN_INTR() simply calls the
+ * BUS_TEARDOWN_INTR() method of the parent of @p dev.
+ */      
+int 
+bus_generic_reserve_resource(device_t dev, device_t child, int type, int *start,
+    int *count, int flags)
+{
+	/* Propagate up the bus hierarchy until someone handles it. */
+	if (dev->parent)
+		return (BUS_RESERVE_RESOURCE(dev->parent, child, type, start,
+		    count, flags));
+	return (EINVAL);
+}
+
+/**
  * @brief Helper function for implementing BUS_ALLOC_RESOURCE().
  *
  * This simple implementation of BUS_ALLOC_RESOURCE() simply calls the
@@ -3337,6 +3354,16 @@
 	panic("root_setup_intr");
 }
 
+static int
+root_reserve_resource(device_t dev, device_t child, int type, int *start,
+		      int *count, int flags)
+{
+	/*
+	 * Should not get here.
+	 */
+	panic("root_reserve_resource");
+}
+
 /*
  * If we get here, assume that the device is permanant and really is
  * present in the system.  Removable bus drivers are expected to intercept
@@ -3361,6 +3388,7 @@
 	KOBJMETHOD(bus_read_ivar,	bus_generic_read_ivar),
 	KOBJMETHOD(bus_write_ivar,	bus_generic_write_ivar),
 	KOBJMETHOD(bus_setup_intr,	root_setup_intr),
+	KOBJMETHOD(bus_reserve_resource, root_reserve_resource),
 	KOBJMETHOD(bus_child_present,	root_child_present),
 
 	{ 0, 0 }

==== //depot/projects/newint/sys/sys/bus.h#5 (text+ko) ====

@@ -269,6 +269,8 @@
 int	bus_generic_setup_intr(device_t dev, device_t child,
 			       struct resource *irq, int flags,
 			       driver_intr_t *intr, void *arg, void **cookiep);
+int	bus_generic_reserve_resource(device_t dev, device_t child, int type,
+				     int *start, int *count, int flags);
 
 struct resource *
 	bus_generic_rl_alloc_resource (device_t, device_t, int, int *,
@@ -304,6 +306,8 @@
 int	bus_setup_intr(device_t dev, struct resource *r, int flags,
 		       driver_intr_t handler, void *arg, void **cookiep);
 int	bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
+int	bus_reserve_resource(device_t dev, int type, int *start, int *count,
+			     int flags);
 int	bus_set_resource(device_t dev, int type, int rid,
 			 u_long start, u_long count);
 int	bus_get_resource(device_t dev, int type, int rid,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200408110615.i7B6FDxL054081>