Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Nov 2002 21:51:14 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 21475 for review
Message-ID:  <200211250551.gAP5pEh8044243@repoman.freebsd.org>

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

Change 21475 by marcel@marcel_nfs on 2002/11/24 21:50:34

	Hack: if the rid passed to sioprobe and sioattach is negative,
	use memory mapped I/O instead of I/O ports. This makes the
	HP Diva controller attach...

Affected files ...

.. //depot/projects/ia64/sys/dev/sio/sio.c#17 edit

Differences ...

==== //depot/projects/ia64/sys/dev/sio/sio.c#17 (text+ko) ====

@@ -263,6 +263,7 @@
 
 	struct resource *irqres;
 	struct resource *ioportres;
+	int ioportspace;
 	void *cookie;
 	dev_t devs[6];
 
@@ -450,7 +451,7 @@
 		bus_release_resource(dev, SYS_RES_IRQ, 0, com->irqres);
 	}
 	if (com->ioportres)
-		bus_release_resource(dev, SYS_RES_IOPORT, 0, com->ioportres);
+		bus_release_resource(dev, com->ioportspace, 0, com->ioportres);
 	if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
 		device_printf(dev, "still open, forcing close\n");
 		(*linesw[com->tp->t_line].l_close)(com->tp, 0);
@@ -467,6 +468,12 @@
 	return (0);
 }
 
+__inline intrmask_t
+isa_irq_pending(void)
+{
+	return -1;
+}
+
 int
 sioprobe(dev, xrid, rclk, noprobe)
 	device_t	dev;
@@ -490,12 +497,13 @@
 	int		result;
 	u_long		xirq;
 	u_int		flags = device_get_flags(dev);
-	int		rid;
+	int		rid, space;
 	struct resource *port;
 
-	rid = xrid;
-	port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
-				  0, ~0, IO_COMSIZE, RF_ACTIVE);
+	rid = (xrid < 0) ? -xrid : xrid;
+	space = (xrid < 0) ? SYS_RES_MEMORY : SYS_RES_IOPORT;
+	port = bus_alloc_resource(dev, space, &rid, 0, ~0, IO_COMSIZE,
+	    RF_ACTIVE);
 	if (!port)
 		return (ENXIO);
 
@@ -539,7 +547,7 @@
 		for (i = 0; i < count; i++) {
 			xdev = devs[i];
 			if (device_is_enabled(xdev) &&
-			    bus_get_resource(xdev, SYS_RES_IOPORT, 0, &xioport,
+			    bus_get_resource(xdev, space, 0, &xioport,
 					     NULL) == 0)
 				outb(xioport + com_mcr, 0);
 		}
@@ -551,7 +559,7 @@
 	if (COM_LLCONSOLE(flags)) {
 		printf("sio%d: reserved for low-level i/o\n",
 		       device_get_unit(dev));
-		bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+		bus_release_resource(dev, space, rid, port);
 		device_set_softc(dev, NULL);
 		free(com, M_DEVBUF);
 		return (ENXIO);
@@ -579,7 +587,7 @@
 			idev = dev;
 		}
 		if (!COM_NOTAST4(flags)) {
-			if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io,
+			if (bus_get_resource(idev, space, 0, &io,
 					     NULL) == 0) {
 				xiobase = io;
 				if (bus_get_resource(idev, SYS_RES_IRQ, 0,
@@ -712,7 +720,7 @@
 		sio_setreg(com, com_ier, 0);
 		sio_setreg(com, com_cfcr, CFCR_8BITS);
 		mtx_unlock_spin(&sio_lock);
-		bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+		bus_release_resource(dev, space, rid, port);
 		if (iobase == siocniobase)
 			result = 0;
 		if (result != 0) {
@@ -789,7 +797,7 @@
 			}
 			break;
 		}
-	bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+	bus_release_resource(dev, space, rid, port);
 	if (iobase == siocniobase)
 		result = 0;
 	if (result != 0) {
@@ -878,13 +886,14 @@
 	int		minorbase;
 	int		unit;
 	u_int		flags;
-	int		rid;
+	int		rid, space;
 	struct resource *port;
 	int		ret;
 
-	rid = xrid;
-	port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
-				  0, ~0, IO_COMSIZE, RF_ACTIVE);
+	rid = (xrid < 0) ? -xrid : xrid;
+	space = (xrid < 0) ? SYS_RES_MEMORY : SYS_RES_IOPORT;
+	port = bus_alloc_resource(dev, space, &rid, 0, ~0, IO_COMSIZE,
+	    RF_ACTIVE);
 	if (!port)
 		return (ENXIO);
 
@@ -910,6 +919,7 @@
 	bzero(com, sizeof *com);
 	com->unit = unit;
 	com->ioportres = port;
+	com->ioportspace = space;
 	com->bst = rman_get_bustag(port);
 	com->bsh = rman_get_bushandle(port);
 	com->cfcr_image = CFCR_8BITS;
@@ -960,7 +970,7 @@
 		 * console, so that other devices can't snarf them.
 		 */
 		if (iobase != siocniobase)
-			bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+			bus_release_resource(dev, space, rid, port);
 		return (ENOMEM);
 	}
 	mtx_unlock_spin(&sio_lock);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




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