Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Dec 2005 21:14:40 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 88472 for review
Message-ID:  <200512202114.jBKLEefU035806@repoman.freebsd.org>

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

Change 88472 by imp@imp_Speedy on 2005/12/20 21:13:56

	IFC @88471	(to pick up Makefile.arm changes for tramps!)

Affected files ...

.. //depot/projects/arm/src/sys/amd64/pci/pci_bus.c#3 integrate
.. //depot/projects/arm/src/sys/conf/Makefile.arm#8 integrate
.. //depot/projects/arm/src/sys/conf/files#9 integrate
.. //depot/projects/arm/src/sys/dev/acpica/acpi_pci.c#3 integrate
.. //depot/projects/arm/src/sys/dev/pci/hostb_pci.c#1 branch
.. //depot/projects/arm/src/sys/dev/pci/pci.c#5 integrate
.. //depot/projects/arm/src/sys/dev/pci/pci_if.m#2 integrate
.. //depot/projects/arm/src/sys/dev/pci/pci_private.h#3 integrate
.. //depot/projects/arm/src/sys/dev/pci/pcireg.h#3 integrate
.. //depot/projects/arm/src/sys/dev/pci/pcivar.h#3 integrate
.. //depot/projects/arm/src/sys/dev/smbus/smb.c#3 integrate
.. //depot/projects/arm/src/sys/dev/smbus/smbus.c#3 integrate
.. //depot/projects/arm/src/sys/i386/pci/pci_bus.c#3 integrate
.. //depot/projects/arm/src/sys/pci/agp.c#2 integrate
.. //depot/projects/arm/src/sys/pci/agpvar.h#2 integrate
.. //depot/projects/arm/src/sys/sparc64/pci/ofw_pcibus.c#5 integrate

Differences ...

==== //depot/projects/arm/src/sys/amd64/pci/pci_bus.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_bus.c,v 1.114 2005/09/18 01:42:43 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/pci/pci_bus.c,v 1.115 2005/12/20 21:09:44 jhb Exp $");
 
 #include "opt_cpu.h"
 
@@ -336,64 +336,6 @@
 
 
 /*
- * Provide a device to "eat" the host->pci bridges that we dug up above
- * and stop them showing up twice on the probes.  This also stops them
- * showing up as 'none' in pciconf -l.
- */
-static int
-pci_hostb_probe(device_t dev)
-{
-	u_int32_t id;
-
-	id = pci_get_devid(dev);
-
-	switch (id) {
-
-	/* VIA VT82C596 Power Managment Function */
-	case 0x30501106:
-		return ENXIO;
-
-	default:
-		break;
-	}
-
-	if (pci_get_class(dev) == PCIC_BRIDGE &&
-	    pci_get_subclass(dev) == PCIS_BRIDGE_HOST) {
-		device_set_desc(dev, "Host to PCI bridge");
-		device_quiet(dev);
-		return -10000;
-	}
-	return ENXIO;
-}
-
-static int
-pci_hostb_attach(device_t dev)
-{
-
-	return 0;
-}
-
-static device_method_t pci_hostb_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		pci_hostb_probe),
-	DEVMETHOD(device_attach,	pci_hostb_attach),
-	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
-	DEVMETHOD(device_suspend,	bus_generic_suspend),
-	DEVMETHOD(device_resume,	bus_generic_resume),
-
-	{ 0, 0 }
-};
-static driver_t pci_hostb_driver = {
-	"hostb",
-	pci_hostb_methods,
-	1,
-};
-static devclass_t pci_hostb_devclass;
-
-DRIVER_MODULE(hostb, pci, pci_hostb_driver, pci_hostb_devclass, 0, 0);
-
-
-/*
  * Install placeholder to claim the resources owned by the
  * PCI bus interface.  This could be used to extract the
  * config space registers in the extreme case where the PnP

==== //depot/projects/arm/src/sys/conf/Makefile.arm#8 (text+ko) ====

@@ -1,7 +1,7 @@
 # Makefile.arm -- with config changes.
 # Copyright 1990 W. Jolitz
 #	from: @(#)Makefile.i386	7.1 5/10/91
-# $FreeBSD: src/sys/conf/Makefile.arm,v 1.23 2005/12/20 01:28:17 cognet Exp $
+# $FreeBSD: src/sys/conf/Makefile.arm,v 1.24 2005/12/20 20:57:20 cognet Exp $
 #
 # Makefile for FreeBSD
 #
@@ -58,40 +58,39 @@
 		${OBJCOPY} -S -O binary ${FULLKERNEL}.noheader \
 		${KERNEL_KO}.bin; \
 		rm ${FULLKERNEL}.noheader
-.if ${DDB_ENABLED} != "" || defined(BUILD_ELF_TRAMPOLINE)
-SYSTEM_LD_TAIL += ;echo "\#define KERNNAME \"${KERNEL_KO}.tmp\"" \
-	>opt_kernname.h ;\
-	sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > \
-		ldscript.$M.tramp; \
+
+trampoline: ${KERNEL_KO}.tramp
+${KERNEL_KO}.tramp: ${KERNEL_KO}
+	echo "#define KERNNAME \"${KERNEL_KO}.tmp\"" >opt_kernname.h 
+	sed s/${KERNVIRTADDR}/${KERNPHYSADDR}/ ldscript.$M > ldscript.$M.tramp
 	sed s/" + SIZEOF_HEADERS"// ldscript.$M.tramp > \
-	ldscript.$M.tramp.noheader; \
+	ldscript.$M.tramp.noheader
 	${OBJCOPY} --strip-symbol '$$d' --strip-symbol '$$a' \
-	-g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp;\
+	-g --strip-symbol '$$t' ${FULLKERNEL} ${KERNEL_KO}.tmp
 	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
-	$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S -o ${KERNEL_KO}.tramp;\
+	$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S -o ${KERNEL_KO}.tramp
 	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
 	$S/$M/$M/elf_trampoline.c $S/$M/$M/inckern.S -o \
-	${KERNEL_KO}.tramp.noheader; \
+	${KERNEL_KO}.tramp.noheader 
 	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
-	${KERNEL_KO}.tramp.bin; \
-	${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp; \
-	echo "\#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" \
-	>opt_kernname.h ;\
-	gzip -9 ${KERNEL_KO}.tmp; \
+	${KERNEL_KO}.tramp.bin 
+	${OBJCOPY} ${STRIP_FLAGS} ${KERNEL_KO}.tmp 
+	echo "#define KERNNAME \"${KERNEL_KO}.tmp.gz\"" \
+	>opt_kernname.h 
+	gzip -9 ${KERNEL_KO}.tmp
 	eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
-	echo "\#define KERNSIZE $$st_size" >>opt_kernname.h;\
-	${CC} -O2 -DKZIP -I. -c $S/kern/inflate.c -o inflate-tramp.o; \
+	echo "#define KERNSIZE $$st_size" >>opt_kernname.h
+	${CC} -O2 -DKZIP -I. -c $S/kern/inflate.c -o inflate-tramp.o
 	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp \
 	-DKZIP $S/$M/$M/elf_trampoline.c inflate-tramp.o $S/$M/$M/inckern.S \
-	-o ${KERNEL_KO}.gz.tramp;\
+	-o ${KERNEL_KO}.gz.tramp
 	${CC} -O -nostdlib -I. -Xlinker -T -Xlinker ldscript.$M.tramp.noheader \
 	-DKZIP $S/$M/$M/elf_trampoline.c inflate-tramp.o $S/$M/$M/inckern.S \
-	-o ${KERNEL_KO}.tramp.noheader; \
+	-o ${KERNEL_KO}.tramp.noheader
 	${OBJCOPY} -S -O binary ${KERNEL_KO}.tramp.noheader \
-	${KERNEL_KO}.gz.tramp.bin; \
+	${KERNEL_KO}.gz.tramp.bin
 	rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
-	inflate-tramp.o;
-.endif
+	inflate-tramp.o
 
 %BEFORE_DEPEND
 

==== //depot/projects/arm/src/sys/conf/files#9 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.1076 2005/12/12 01:14:59 rodrigc Exp $
+# $FreeBSD: src/sys/conf/files,v 1.1077 2005/12/20 21:09:44 jhb Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -751,6 +751,7 @@
 dev/pcf/pcf.c			optional pcf
 dev/pci/eisa_pci.c		optional pci eisa
 dev/pci/fixup_pci.c		optional pci
+dev/pci/hostb_pci.c		optional pci
 dev/pci/ignore_pci.c		optional pci
 dev/pci/isa_pci.c		optional pci isa
 dev/pci/pci.c			optional pci

==== //depot/projects/arm/src/sys/dev/acpica/acpi_pci.c#3 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.27 2005/09/11 18:39:01 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_pci.c,v 1.28 2005/12/20 19:57:47 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -117,6 +117,7 @@
 	DEVMETHOD(pci_get_powerstate,	pci_get_powerstate_method),
 	DEVMETHOD(pci_set_powerstate,	acpi_pci_set_powerstate_method),
 	DEVMETHOD(pci_assign_interrupt, pci_assign_interrupt_method),
+	DEVMETHOD(pci_find_extcap,	pci_find_extcap_method),
 
 	{ 0, 0 }
 };

==== //depot/projects/arm/src/sys/dev/pci/pci.c#5 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/pci/pci.c,v 1.304 2005/11/09 03:37:52 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/pci/pci.c,v 1.305 2005/12/20 19:57:47 jhb Exp $");
 
 #include "opt_bus.h"
 
@@ -133,6 +133,7 @@
 	DEVMETHOD(pci_get_powerstate,	pci_get_powerstate_method),
 	DEVMETHOD(pci_set_powerstate,	pci_set_powerstate_method),
 	DEVMETHOD(pci_assign_interrupt,	pci_assign_interrupt_method),
+	DEVMETHOD(pci_find_extcap,	pci_find_extcap_method),
 
 	{ 0, 0 }
 };
@@ -449,10 +450,10 @@
 		}
 		/* Find the next entry */
 		ptr = nextptr;
-		nextptr = REG(ptr + 1, 1);
+		nextptr = REG(ptr + PCICAP_NEXTPTR, 1);
 
 		/* Process this entry */
-		switch (REG(ptr, 1)) {
+		switch (REG(ptr + PCICAP_ID, 1)) {
 		case PCIY_PMG:		/* PCI power management */
 			if (cfg->pp.pp_cap == 0) {
 				cfg->pp.pp_cap = REG(ptr + PCIR_POWER_CAP, 2);
@@ -477,6 +478,57 @@
 #undef REG
 }
 
+/*
+ * Return the offset in configuration space of the requested extended
+ * capability entry or 0 if the specified capability was not found.
+ */
+int
+pci_find_extcap_method(device_t dev, device_t child, int capability,
+    int *capreg)
+{
+	struct pci_devinfo *dinfo = device_get_ivars(child);
+	pcicfgregs *cfg = &dinfo->cfg;
+	u_int32_t status;
+	u_int8_t ptr;
+
+	/*
+	 * Check the CAP_LIST bit of the PCI status register first.
+	 */
+	status = pci_read_config(child, PCIR_STATUS, 2);
+	if (!(status & PCIM_STATUS_CAPPRESENT))
+		return (ENXIO);
+
+	/*
+	 * Determine the start pointer of the capabilities list.
+	 */
+	switch (cfg->hdrtype & PCIM_HDRTYPE) {
+	case 0:
+		ptr = PCIR_CAP_PTR;
+		break;
+	case 2:
+		ptr = PCIR_CAP_PTR_2;
+		break;
+	default:
+		/* XXX: panic? */
+		return (ENXIO);		/* no extended capabilities support */
+	}
+	ptr = pci_read_config(child, ptr, 1);
+
+	/*
+	 * Traverse the capabilities list.
+	 */
+	while (ptr != 0) {
+		if (pci_read_config(child, ptr + PCICAP_ID, 1) == capability) {
+			if (capreg != NULL)
+				*capreg = ptr;
+			return (0);
+		}
+		ptr = pci_read_config(child, ptr + PCICAP_NEXTPTR, 1);
+	}
+
+	return (ENOENT);
+}
+
 /* free pcicfgregs structure and all depending data structures */
 
 int

==== //depot/projects/arm/src/sys/dev/pci/pci_if.m#2 (text+ko) ====

@@ -23,7 +23,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $FreeBSD: src/sys/dev/pci/pci_if.m,v 1.7 2005/01/06 01:43:05 imp Exp $
+# $FreeBSD: src/sys/dev/pci/pci_if.m,v 1.8 2005/12/20 19:57:47 jhb Exp $
 #
 
 #include <sys/bus.h>
@@ -82,3 +82,10 @@
 	device_t	dev;
 	device_t	child;
 };
+
+METHOD int find_extcap {
+	device_t	dev;
+	device_t	child;
+	int		capability;
+	int		*capreg;
+};

==== //depot/projects/arm/src/sys/dev/pci/pci_private.h#3 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/pci/pci_private.h,v 1.14 2005/02/28 01:14:15 imp Exp $
+ * $FreeBSD: src/sys/dev/pci/pci_private.h,v 1.15 2005/12/20 19:57:47 jhb Exp $
  *
  */
 
@@ -59,6 +59,8 @@
 int		pci_disable_busmaster_method(device_t dev, device_t child);
 int		pci_enable_io_method(device_t dev, device_t child, int space);
 int		pci_disable_io_method(device_t dev, device_t child, int space);
+int		pci_find_extcap_method(device_t dev, device_t child,
+		    int capability, int *capreg);
 struct resource	*pci_alloc_resource(device_t dev, device_t child, 
 		    int type, int *rid, u_long start, u_long end, u_long count,
 		    u_int flags);

==== //depot/projects/arm/src/sys/dev/pci/pcireg.h#3 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/pci/pcireg.h,v 1.48 2005/10/29 05:49:06 imp Exp $
+ * $FreeBSD: src/sys/dev/pci/pcireg.h,v 1.49 2005/12/20 19:57:47 jhb Exp $
  *
  */
 
@@ -88,6 +88,11 @@
 #define PCIM_MFDEV		0x80
 #define PCIR_BIST	0x0f
 
+/* Capability Register Offsets */
+
+#define	PCICAP_ID	0x0
+#define	PCICAP_NEXTPTR	0x1
+
 /* Capability Identification Numbers */
 
 #define PCIY_PMG	0x01	/* PCI Power Management */

==== //depot/projects/arm/src/sys/dev/pci/pcivar.h#3 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/pci/pcivar.h,v 1.67 2005/09/11 03:22:03 imp Exp $
+ * $FreeBSD: src/sys/dev/pci/pcivar.h,v 1.68 2005/12/20 19:57:47 jhb Exp $
  *
  */
 
@@ -348,6 +348,12 @@
     return PCI_GET_POWERSTATE(device_get_parent(dev), dev);
 }
 
+static __inline int
+pci_find_extcap(device_t dev, int capability, int *capreg)
+{
+    return PCI_FIND_EXTCAP(device_get_parent(dev), dev, capability, capreg);
+}
+
 device_t pci_find_bsf(uint8_t, uint8_t, uint8_t);
 device_t pci_find_device(uint16_t, uint16_t);
 #endif	/* _SYS_BUS_H_ */

==== //depot/projects/arm/src/sys/dev/smbus/smb.c#3 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/smbus/smb.c,v 1.35 2005/12/20 14:26:47 ru Exp $
+ * $FreeBSD: src/sys/dev/smbus/smb.c,v 1.36 2005/12/20 21:06:57 ru Exp $
  */
 
 #include <sys/param.h>
@@ -58,13 +58,11 @@
 static int smb_probe(device_t);
 static int smb_attach(device_t);
 static int smb_detach(device_t);
-static void smb_identify(driver_t *driver, device_t parent);
 
 static devclass_t smb_devclass;
 
 static device_method_t smb_methods[] = {
 	/* device interface */
-	DEVMETHOD(device_identify,	smb_identify),
 	DEVMETHOD(device_probe,		smb_probe),
 	DEVMETHOD(device_attach,	smb_attach),
 	DEVMETHOD(device_detach,	smb_detach),
@@ -94,14 +92,6 @@
 	.d_name =	"smb",
 };
 
-static void
-smb_identify(driver_t *driver, device_t parent)
-{
-
-	if (!device_find_child(parent, "smb", -1))
-		device_add_child(parent, "smb", -1);
-}
-
 static int
 smb_probe(device_t dev)
 {

==== //depot/projects/arm/src/sys/dev/smbus/smbus.c#3 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/smbus/smbus.c,v 1.19 2005/12/20 14:26:47 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/smbus/smbus.c,v 1.20 2005/12/20 21:06:57 ru Exp $");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
@@ -49,11 +49,12 @@
  * Device methods
  */
 static int smbus_probe(device_t);
+static int smbus_attach(device_t);
 
 static device_method_t smbus_methods[] = {
         /* device interface */
         DEVMETHOD(device_probe,         smbus_probe),
-        DEVMETHOD(device_attach,        bus_generic_attach),
+        DEVMETHOD(device_attach,        smbus_attach),
         DEVMETHOD(device_detach,        bus_generic_detach),
 
         /* bus interface */
@@ -81,6 +82,15 @@
 	return (0);
 }
 
+static int
+smbus_attach(device_t dev)
+{
+	device_add_child(dev, NULL, -1);
+	bus_generic_attach(dev);
+
+	return (0);
+}
+
 void
 smbus_generic_intr(device_t dev, u_char devaddr, char low, char high)
 {

==== //depot/projects/arm/src/sys/i386/pci/pci_bus.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/pci/pci_bus.c,v 1.121 2005/09/17 23:57:53 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/pci/pci_bus.c,v 1.122 2005/12/20 21:09:45 jhb Exp $");
 
 #include "opt_cpu.h"
 
@@ -548,64 +548,6 @@
 
 
 /*
- * Provide a device to "eat" the host->pci bridges that we dug up above
- * and stop them showing up twice on the probes.  This also stops them
- * showing up as 'none' in pciconf -l.
- */
-static int
-pci_hostb_probe(device_t dev)
-{
-	u_int32_t id;
-
-	id = pci_get_devid(dev);
-
-	switch (id) {
-
-	/* VIA VT82C596 Power Managment Function */
-	case 0x30501106:
-		return ENXIO;
-
-	default:
-		break;
-	}
-
-	if (pci_get_class(dev) == PCIC_BRIDGE &&
-	    pci_get_subclass(dev) == PCIS_BRIDGE_HOST) {
-		device_set_desc(dev, "Host to PCI bridge");
-		device_quiet(dev);
-		return -10000;
-	}
-	return ENXIO;
-}
-
-static int
-pci_hostb_attach(device_t dev)
-{
-
-	return 0;
-}
-
-static device_method_t pci_hostb_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		pci_hostb_probe),
-	DEVMETHOD(device_attach,	pci_hostb_attach),
-	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
-	DEVMETHOD(device_suspend,	bus_generic_suspend),
-	DEVMETHOD(device_resume,	bus_generic_resume),
-
-	{ 0, 0 }
-};
-static driver_t pci_hostb_driver = {
-	"hostb",
-	pci_hostb_methods,
-	1,
-};
-static devclass_t pci_hostb_devclass;
-
-DRIVER_MODULE(hostb, pci, pci_hostb_driver, pci_hostb_devclass, 0, 0);
-
-
-/*
  * Install placeholder to claim the resources owned by the
  * PCI bus interface.  This could be used to extract the
  * config space registers in the extreme case where the PnP

==== //depot/projects/arm/src/sys/pci/agp.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/pci/agp.c,v 1.46 2004/10/24 07:12:13 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/pci/agp.c,v 1.50 2005/12/20 21:06:43 jhb Exp $");
 
 #include "opt_bus.h"
 
@@ -101,33 +101,12 @@
 u_int8_t
 agp_find_caps(device_t dev)
 {
-	u_int32_t status;
-	u_int8_t ptr, next;
+	int capreg;
 
-	/*
-	 * Check the CAP_LIST bit of the PCI status register first.
-	 */
-	status = pci_read_config(dev, PCIR_STATUS, 2);
-	if (!(status & 0x10))
-		return 0;
 
-	/*
-	 * Traverse the capabilities list.
-	 */
-	for (ptr = pci_read_config(dev, AGP_CAPPTR, 1);
-	     ptr != 0;
-	     ptr = next) {
-		u_int32_t capid = pci_read_config(dev, ptr, 4);
-		next = AGP_CAPID_GET_NEXT_PTR(capid);
-
-		/*
-		 * If this capability entry ID is 2, then we are done.
-		 */
-		if (AGP_CAPID_GET_CAP_ID(capid) == 2)
-			return ptr;
-	}
-
-	return 0;
+	if (pci_find_extcap(dev, PCIY_AGP, &capreg) != 0)
+		capreg = 0;
+	return (capreg);
 }
 
 /*
@@ -230,8 +209,7 @@
 	 * Find and map the aperture.
 	 */
 	rid = AGP_APBASE;
-	sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
-						 RF_ACTIVE);
+	sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 0);
 	if (!sc->as_aperture)
 		return ENOMEM;
 
@@ -274,9 +252,10 @@
 agp_generic_detach(device_t dev)
 {
 	struct agp_softc *sc = device_get_softc(dev);
+
+	destroy_dev(sc->as_devnode);
 	bus_release_resource(dev, SYS_RES_MEMORY, AGP_APBASE, sc->as_aperture);
 	mtx_destroy(&sc->as_lock);
-	destroy_dev(sc->as_devnode);
 	agp_flush_cache();
 	return 0;
 }
@@ -851,9 +830,18 @@
 device_t
 agp_find_device()
 {
+	device_t *children;
+	int i, count;
+
 	if (!agp_devclass)
-		return 0;
-	return devclass_get_device(agp_devclass, 0);
+		return NULL;
+	if (devclass_get_devices(agp_devclass, &children, &count) != 0)
+		return NULL;
+	for (i = 0; i < count; i++) {
+		if (device_is_attached(children[i]))
+			return (children[i]);
+	}
+	return NULL;
 }
 
 enum agp_acquire_state
@@ -872,7 +860,6 @@
 		pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4);
 	info->ai_aperture_base = rman_get_start(sc->as_aperture);
 	info->ai_aperture_size = rman_get_size(sc->as_aperture);
-	info->ai_aperture_va = (vm_offset_t) rman_get_virtual(sc->as_aperture);
 	info->ai_memory_allowed = sc->as_maxmem;
 	info->ai_memory_used = sc->as_allocated;
 }

==== //depot/projects/arm/src/sys/pci/agpvar.h#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/pci/agpvar.h,v 1.2 2001/12/19 08:54:29 mdodd Exp $
+ *	$FreeBSD: src/sys/pci/agpvar.h,v 1.3 2005/12/20 20:05:21 jhb Exp $
  */
 
 #ifndef _PCI_AGPVAR_H_
@@ -47,7 +47,6 @@
 	u_int32_t	ai_mode;
 	vm_offset_t	ai_aperture_base;
 	vm_size_t	ai_aperture_size;
-	vm_offset_t	ai_aperture_va;
 	vm_size_t	ai_memory_allowed;
 	vm_size_t	ai_memory_used;
 	u_int32_t	ai_devid;

==== //depot/projects/arm/src/sys/sparc64/pci/ofw_pcibus.c#5 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/sparc64/pci/ofw_pcibus.c,v 1.8 2005/12/03 18:11:26 marius Exp $");
+__FBSDID("$FreeBSD: src/sys/sparc64/pci/ofw_pcibus.c,v 1.9 2005/12/20 19:57:47 jhb Exp $");
 
 #include "opt_ofw_pci.h"
 
@@ -106,6 +106,7 @@
 	DEVMETHOD(pci_get_powerstate,	pci_get_powerstate_method),
 	DEVMETHOD(pci_set_powerstate,	pci_set_powerstate_method),
 	DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
+	DEVMETHOD(pci_find_extcap,	pci_find_extcap_method),
 
 	/* ofw_bus interface */
 	DEVMETHOD(ofw_bus_get_devinfo,	ofw_pcibus_get_devinfo),



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