Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Dec 2002 11:15:45 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 22624 for review
Message-ID:  <200212221915.gBMJFjoA009596@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help

http://perforce.freebsd.org/chv.cgi?CH=22624

Change 22624 by marcel@marcel_nfs on 2002/12/22 11:15:02

	Convert sio_isa.c to the new sioprobe/sioattach interface. Leak
	a debbuging function in here as well, because we now do probe
	the ACPI listed memory mapped UARTS, we just have to grab the
	resources so that we can allocate them.

Affected files ...

.. //depot/projects/ia64/sys/dev/sio/sio_isa.c#9 edit

Differences ...

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

@@ -33,9 +33,13 @@
 #include <sys/malloc.h>
 #include <sys/mutex.h>
 #include <sys/module.h>
+#include <sys/timepps.h>
 #include <sys/tty.h>
+
 #include <machine/bus.h>
-#include <sys/timepps.h>
+#include <machine/resource.h>
+
+#include <sys/rman.h>
 
 #include <dev/sio/siovar.h>
 
@@ -49,14 +53,13 @@
 	/* Device interface */
 	DEVMETHOD(device_probe,		sio_isa_probe),
 	DEVMETHOD(device_attach,	sio_isa_attach),
-
 	{ 0, 0 }
 };
 
 static driver_t sio_isa_driver = {
 	sio_driver_name,
 	sio_isa_methods,
-	0,
+	sizeof(struct com_s),
 };
 
 static struct isa_pnp_id sio_ids[] = {
@@ -144,21 +147,69 @@
 	{0}
 };
 
+static struct resource *
+sio_isa_alloc(device_t dev, int *sp, int *rid)
+{
+	struct resource *res;
+
+	*rid = 0;
+	*sp = SYS_RES_IOPORT;
+	device_printf(dev, "trying I/O port\n");
+	res = bus_alloc_resource(dev, *sp, rid, 0, ~0, 8, RF_ACTIVE);
+	if (res == NULL) {
+		device_printf(dev, "trying memory mapped\n");
+		*rid = 0;
+		*sp = SYS_RES_MEMORY;
+		res = bus_alloc_resource(dev, *sp, rid, 0, ~0, 8, RF_ACTIVE);
+		if (res == NULL) {
+			device_printf(dev, "Bollocks!\n");
+			return (NULL);
+		}
+	}
+
+	return (res);
+}
+
 static int
-sio_isa_probe(dev)
-	device_t	dev;
+sio_isa_probe(device_t dev)
 {
+	struct com_s *com;
+	struct resource *res;
+	int error, rid, space;
+
 	/* Check isapnp ids */
 	if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
 		return (ENXIO);
-	return (sioprobe(dev, 0, 0UL, 0));
+
+	com = device_get_softc(dev);
+	res = sio_isa_alloc(dev, &space, &rid);
+	if (res == NULL)
+		return (0);
+	com->bsh = rman_get_bushandle(res);
+	com->bst = rman_get_bustag(res);
+	error = sioprobe(dev);
+	bus_release_resource(dev, space, rid, res);
+	return (error);
 }
 
 static int
 sio_isa_attach(dev)
 	device_t	dev;
 {
-	return (sioattach(dev, 0, 0UL));
+	struct com_s *com;
+	struct resource *res;
+	int error, rid, space;
+
+	com = device_get_softc(dev);
+	res = sio_isa_alloc(dev, &space, &rid);
+	if (res == NULL)
+		return (ENXIO);
+	com->bsh = rman_get_bushandle(res);
+	com->bst = rman_get_bustag(res);
+	error = sioattach(dev);
+	if (error)
+		bus_release_resource(dev, space, rid, res);
+	return (error);
 }
 
 DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);

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?200212221915.gBMJFjoA009596>