Module Name:    src
Committed By:   dyoung
Date:           Tue Aug 18 17:15:10 UTC 2009

Modified Files:
        src/sys/arch/x86/pci: pcib.c pcibvar.h

Log Message:
Allow detachment and re-attachment of an ISA bus at an PCI-ISA bus
bridge, isa0 at pcib0.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/pcib.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/pcibvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pcib.c
diff -u src/sys/arch/x86/pci/pcib.c:1.8 src/sys/arch/x86/pci/pcib.c:1.9
--- src/sys/arch/x86/pci/pcib.c:1.8	Thu Apr  2 00:09:32 2009
+++ src/sys/arch/x86/pci/pcib.c	Tue Aug 18 17:15:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcib.c,v 1.8 2009/04/02 00:09:32 dyoung Exp $	*/
+/*	$NetBSD: pcib.c,v 1.9 2009/08/18 17:15:10 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.8 2009/04/02 00:09:32 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.9 2009/08/18 17:15:10 dyoung Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -50,12 +50,9 @@
 #include "pcibvar.h"
 
 int	pcibmatch(device_t, cfdata_t, void *);
-void	pcibattach(device_t, device_t, void *);
-int	pcibdetach(device_t, int);
-void	pcibchilddet(device_t, device_t);
 
 CFATTACH_DECL3_NEW(pcib, sizeof(struct pcib_softc),
-    pcibmatch, pcibattach, pcibdetach, NULL, NULL, pcibchilddet,
+    pcibmatch, pcibattach, pcibdetach, NULL, pcibrescan, pcibchilddet,
     DVF_DETACH_SHUTDOWN);
 
 void	pcib_callback(device_t);
@@ -229,22 +226,43 @@
 void
 pcibchilddet(device_t self, device_t child)
 {
-	/* we keep no references to children, so do nothing */
+	struct pcib_softc *sc = device_private(self);
+
+	if (sc->sc_isabus == child)
+		sc->sc_isabus = NULL;
 }
 
-void
-pcib_callback(device_t self)
+/* XXX share this with sys/arch/i386/pci/elan520.c */
+static bool
+ifattr_match(const char *snull, const char *t)
 {
+	return (snull == NULL) || strcmp(snull, t) == 0;
+}
+
+int
+pcibrescan(device_t self, const char *ifattr, const int *loc)
+{
+	struct pcib_softc *sc = device_private(self);
 	struct isabus_attach_args iba;
 
-	/*
-	 * Attach the ISA bus behind this bridge.
-	 */
-	memset(&iba, 0, sizeof(iba));
-	iba.iba_iot = X86_BUS_SPACE_IO;
-	iba.iba_memt = X86_BUS_SPACE_MEM;
+	if (ifattr_match(ifattr, "isabus") && sc->sc_isabus == NULL) {
+		/*
+		 * Attach the ISA bus behind this bridge.
+		 */
+		memset(&iba, 0, sizeof(iba));
+		iba.iba_iot = X86_BUS_SPACE_IO;
+		iba.iba_memt = X86_BUS_SPACE_MEM;
 #if NISA > 0
-	iba.iba_dmat = &isa_bus_dma_tag;
+		iba.iba_dmat = &isa_bus_dma_tag;
 #endif
-	config_found_ia(self, "isabus", &iba, isabusprint);
+		sc->sc_isabus =
+		    config_found_ia(self, "isabus", &iba, isabusprint);
+	}
+	return 0;
+}
+
+void
+pcib_callback(device_t self)
+{
+	pcibrescan(self, "isabus", NULL);
 }

Index: src/sys/arch/x86/pci/pcibvar.h
diff -u src/sys/arch/x86/pci/pcibvar.h:1.1 src/sys/arch/x86/pci/pcibvar.h:1.2
--- src/sys/arch/x86/pci/pcibvar.h:1.1	Sun Jul 20 16:50:29 2008
+++ src/sys/arch/x86/pci/pcibvar.h	Tue Aug 18 17:15:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcibvar.h,v 1.1 2008/07/20 16:50:29 martin Exp $	*/
+/*	$NetBSD: pcibvar.h,v 1.2 2009/08/18 17:15:10 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,10 @@
 struct pcib_softc {
 	pci_chipset_tag_t	sc_pc;
 	pcitag_t		sc_tag;
+	device_t		sc_isabus;
 };
 
-extern void	pcibattach(device_t, device_t, void *);
-
+void	pcibattach(device_t, device_t, void *);
+void	pcibchilddet(device_t, device_t);
+int	pcibdetach(device_t, int);
+int	pcibrescan(device_t, const char *, const int *);

Reply via email to