Subject: dev/pci/pccbb.c assumes bus_space_handle_t is integer
To: None <tech-kern@netbsd.org>
From: Takeshi Nakayama <tn@catvmics.ne.jp>
List: tech-kern
Date: 03/08/2003 06:45:03
----Next_Part(Sat_Mar__8_06:38:12_2003_229)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

I found the fact described in subject while writing the cardbus
support for sparc64.

On sparc64, bus_space_handle_t is structure, so it cannot assign 0,
nor compare by ==.

Therfore, I changed as attached for now, but I would like to avoid
the extra member to pccbb_softc.

Any ideas?

Takeshi Nakayama

----Next_Part(Sat_Mar__8_06:38:12_2003_229)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="pccbb.c.diff"

Index: sys/dev/pci/pccbb.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pccbb.c,v
retrieving revision 1.87
diff -u -d -r1.87 pccbb.c
--- sys/dev/pci/pccbb.c	2003/01/20 02:29:56	1.87
+++ sys/dev/pci/pccbb.c	2003/03/07 14:17:50
@@ -449,7 +453,7 @@
 #endif
 #endif /* rbus */
 
-	sc->sc_base_memh = 0;
+	sc->sc_base_memh_mapped = 0;
 
 	/* power management: set D0 state */
 	sc->sc_pwrmgt_offs = 0;
@@ -493,12 +497,13 @@
 				    " 0x%lx: io mode\n", sc->sc_dev.dv_xname,
 				    (unsigned long)sockbase);
 				/* give up... allocate reg space via rbus. */
-				sc->sc_base_memh = 0;
 				pci_conf_write(pc, pa->pa_tag, PCI_SOCKBASE, 0);
-			}
+			} else
+				sc->sc_base_memh_mapped = 1;
 		} else {
 			DPRINTF(("%s: socket base address 0x%lx\n",
 			    sc->sc_dev.dv_xname, sockbase));
+			sc->sc_base_memh_mapped = 1;
 		}
 	}
 
@@ -608,7 +613,7 @@
 	struct cardslot_attach_args caa;
 	struct cardslot_softc *csc;
 
-	if (0 == sc->sc_base_memh) {
+	if (0 == sc->sc_base_memh_mapped) {
 		/* The socket registers aren't mapped correctly. */
 #if rbus
 		if (rbus_space_alloc(sc->sc_rbus_memt, 0, 0x1000, 0x0fff,
@@ -638,6 +643,7 @@
 		    sc->sc_tag, PCI_SOCKBASE)));
 		sc->sc_sockbase = sockbase;
 #endif
+		sc->sc_base_memh_mapped = 1;
 	}
 
 	/* bus bridge initialization */
@@ -3172,7 +3178,7 @@
 
 	for (chainp = TAILQ_FIRST(head); chainp != NULL;
 	     chainp = TAILQ_NEXT(chainp, wc_list)) {
-		if (chainp->wc_handle != bsh)
+		if (memcmp(&chainp->wc_handle, &bsh, sizeof(bsh)))
 			continue;
 		if ((chainp->wc_end - chainp->wc_start) != (size - 1)) {
 			printf("pccbb_winlist_delete: window 0x%lx size "

----Next_Part(Sat_Mar__8_06:38:12_2003_229)----