PERFORCE change 34230 for review
Marcel Moolenaar
marcel at FreeBSD.org
Tue Jul 8 23:55:57 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=34230
Change 34230 by marcel at marcel_nfs on 2003/07/08 23:55:29
Add flag PUC_FLAGS_ALTRES. The flag tells puc(4) to try both
memory and I/O port resources. The first one will be used.
PUC_FLAGS_MEMORY tells puc(4) to try memory first. By default
I/O port us tried first as that is the most common.
Replace the magic 8 (size of ns8250 register resource) with
ressz, which we set according to the subtype.
Minor cleanups.
Affected files ...
.. //depot/projects/uart/dev/puc/puc.c#4 edit
.. //depot/projects/uart/dev/puc/pucvar.h#4 edit
Differences ...
==== //depot/projects/uart/dev/puc/puc.c#4 (text+ko) ====
@@ -220,8 +220,15 @@
res = bus_alloc_resource(dev, type, &rid, 0ul, ~0ul, 1,
RF_ACTIVE);
+ if (res == NULL &&
+ sc->sc_desc.ports[i].flags & PUC_FLAGS_ALTRES) {
+ type = (type == SYS_RES_IOPORT)
+ ? SYS_RES_MEMORY : SYS_RES_IOPORT;
+ res = bus_alloc_resource(dev, type, &rid, 0ul, ~0ul, 1,
+ RF_ACTIVE);
+ }
if (res == NULL) {
- printf("could not get resource\n");
+ device_printf(dev, "could not get resource\n");
continue;
}
sc->sc_bar_mappings[bidx].type = type;
@@ -306,11 +313,11 @@
rle->res->r_start = rman_get_start(res) +
sc->sc_desc.ports[i].offset;
- rle->res->r_end = rle->res->r_start + 8 - 1;
+ rle->res->r_end = rle->res->r_start + ressz - 1;
rle->res->r_bustag = rman_get_bustag(res);
bus_space_subregion(rle->res->r_bustag,
rman_get_bushandle(res),
- sc->sc_desc.ports[i].offset, 8,
+ sc->sc_desc.ports[i].offset, ressz,
&rle->res->r_bushandle);
}
@@ -328,7 +335,7 @@
if (sc->sc_ports[i].dev == NULL) {
if (sc->barmuxed) {
bus_space_unmap(rman_get_bustag(rle->res),
- rman_get_bushandle(rle->res), 8);
+ rman_get_bushandle(rle->res), ressz);
free(rle->res, M_DEVBUF);
free(pdev, M_DEVBUF);
}
@@ -348,8 +355,7 @@
if (device_probe_and_attach(sc->sc_ports[i].dev) != 0) {
if (sc->barmuxed) {
bus_space_unmap(rman_get_bustag(rle->res),
- rman_get_bushandle(rle->res),
- 8);
+ rman_get_bushandle(rle->res), ressz);
free(rle->res, M_DEVBUF);
free(pdev, M_DEVBUF);
}
@@ -438,7 +444,7 @@
printf("print_resource_list: rl %p\n", rl);
SLIST_FOREACH(rle, rl, link)
- printf(" type %x, rid %x start %x end %x count %x\n",
+ printf(" type %x, rid %x start %lx end %lx count %lx\n",
rle->type, rle->rid, rle->start, rle->end, rle->count);
printf("print_resource_list: end.\n");
#endif
@@ -465,11 +471,9 @@
retval = NULL;
rle = resource_list_find(rl, type, *rid);
if (rle) {
- start = rle->start;
- end = rle->end;
- count = rle->count;
#ifdef PUC_DEBUG
- printf("found rle, %lx, %lx, %lx\n", start, end, count);
+ printf("found rle, %lx, %lx, %lx\n", rle->start, rle->end,
+ rle->count);
#endif
retval = rle->res;
} else
==== //depot/projects/uart/dev/puc/pucvar.h#4 (text+ko) ====
@@ -104,6 +104,7 @@
#define PUC_ILR_TYPE_DIGI 1
#define PUC_FLAGS_MEMORY 0x0001 /* Use memory mapped I/O. */
+#define PUC_FLAGS_ALTRES 0x0002 /* Use alternate I/O type. */
#define PUC_PORT_VALID(desc, port) \
((port) < PUC_MAX_PORTS && (desc).ports[(port)].type != PUC_PORT_TYPE_NONE)
More information about the p4-projects
mailing list