puc.c (90763) | puc.c (90925) |
---|---|
1/* $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ */ 2 3/*- 4 * Copyright (c) 2002 JF Hay. All rights reserved. 5 * Copyright (c) 2000 M. Warner Losh. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 44 unchanged lines hidden (view full) --- 53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60#include <sys/cdefs.h> | 1/* $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ */ 2 3/*- 4 * Copyright (c) 2002 JF Hay. All rights reserved. 5 * Copyright (c) 2000 M. Warner Losh. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 44 unchanged lines hidden (view full) --- 53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60#include <sys/cdefs.h> |
61__FBSDID("$FreeBSD: head/sys/dev/puc/puc.c 90763 2002-02-17 09:41:23Z nyan $"); | 61__FBSDID("$FreeBSD: head/sys/dev/puc/puc.c 90925 2002-02-19 14:58:11Z nyan $"); |
62 63/* 64 * PCI "universal" communication card device driver, glues com, lpt, 65 * and similar ports to PCI via bridge chip often much larger than 66 * the devices being glued. 67 * 68 * Author: Christopher G. Demetriou, May 14, 1998 (derived from NetBSD 69 * sys/dev/pci/pciide.c, revision 1.6). --- 212 unchanged lines hidden (view full) --- 282 8); 283 rle = resource_list_find(&pdev->resources, SYS_RES_IOPORT, 0); 284 285 if (sc->barmuxed == 0) { 286 rle->res = sc->sc_bar_mappings[bidx].res; 287 } else { 288 rle->res = malloc(sizeof(struct resource), M_DEVBUF, 289 M_WAITOK | M_ZERO); | 62 63/* 64 * PCI "universal" communication card device driver, glues com, lpt, 65 * and similar ports to PCI via bridge chip often much larger than 66 * the devices being glued. 67 * 68 * Author: Christopher G. Demetriou, May 14, 1998 (derived from NetBSD 69 * sys/dev/pci/pciide.c, revision 1.6). --- 212 unchanged lines hidden (view full) --- 282 8); 283 rle = resource_list_find(&pdev->resources, SYS_RES_IOPORT, 0); 284 285 if (sc->barmuxed == 0) { 286 rle->res = sc->sc_bar_mappings[bidx].res; 287 } else { 288 rle->res = malloc(sizeof(struct resource), M_DEVBUF, 289 M_WAITOK | M_ZERO); |
290 if (rle->res == NULL) | 290 if (rle->res == NULL) { 291 free(pdev, M_DEVBUF); |
291 return (ENOMEM); | 292 return (ENOMEM); |
293 } |
|
292 293 rle->res->r_start = rman_get_start(res) + 294 sc->sc_desc->ports[i].offset; 295 rle->res->r_end = rle->res->r_start + 8 - 1; 296 rle->res->r_bustag = rman_get_bustag(res); 297 bus_space_subregion(rle->res->r_bustag, 298 rman_get_bushandle(res), 299 sc->sc_desc->ports[i].offset, 8, 300 &rle->res->r_bushandle); 301 } 302 303 pdev->serialfreq = sc->sc_desc->ports[i].serialfreq; 304 305 childunit = puc_find_free_unit(typestr); 306 sc->sc_ports[i].dev = device_add_child(dev, typestr, childunit); | 294 295 rle->res->r_start = rman_get_start(res) + 296 sc->sc_desc->ports[i].offset; 297 rle->res->r_end = rle->res->r_start + 8 - 1; 298 rle->res->r_bustag = rman_get_bustag(res); 299 bus_space_subregion(rle->res->r_bustag, 300 rman_get_bushandle(res), 301 sc->sc_desc->ports[i].offset, 8, 302 &rle->res->r_bushandle); 303 } 304 305 pdev->serialfreq = sc->sc_desc->ports[i].serialfreq; 306 307 childunit = puc_find_free_unit(typestr); 308 sc->sc_ports[i].dev = device_add_child(dev, typestr, childunit); |
307 if (sc->sc_ports[i].dev == NULL) | 309 if (sc->sc_ports[i].dev == NULL) { 310 if (sc->barmuxed) { 311 bus_space_unmap(rman_get_bustag(rle->res), 312 rman_get_bushandle(rle->res), 313 8); 314 free(rle->res, M_DEVBUF); 315 free(pdev, M_DEVBUF); 316 } |
308 continue; | 317 continue; |
318 } |
|
309 device_set_ivars(sc->sc_ports[i].dev, pdev); 310 device_set_desc(sc->sc_ports[i].dev, sc->sc_desc->name); 311 if (!bootverbose) 312 device_quiet(sc->sc_ports[i].dev); 313#ifdef PUC_DEBUG 314 printf("puc: type %d, bar %x, offset %x\n", 315 sc->sc_desc->ports[i].type, 316 sc->sc_desc->ports[i].bar, 317 sc->sc_desc->ports[i].offset); 318 print_resource_list(&pdev->resources); 319#endif | 319 device_set_ivars(sc->sc_ports[i].dev, pdev); 320 device_set_desc(sc->sc_ports[i].dev, sc->sc_desc->name); 321 if (!bootverbose) 322 device_quiet(sc->sc_ports[i].dev); 323#ifdef PUC_DEBUG 324 printf("puc: type %d, bar %x, offset %x\n", 325 sc->sc_desc->ports[i].type, 326 sc->sc_desc->ports[i].bar, 327 sc->sc_desc->ports[i].offset); 328 print_resource_list(&pdev->resources); 329#endif |
320 device_probe_and_attach(sc->sc_ports[i].dev); | 330 if (device_probe_and_attach(sc->sc_ports[i].dev) != 0) { 331 if (sc->barmuxed) { 332 bus_space_unmap(rman_get_bustag(rle->res), 333 rman_get_bushandle(rle->res), 334 8); 335 free(rle->res, M_DEVBUF); 336 free(pdev, M_DEVBUF); 337 } 338 } |
321 } 322 323#ifdef PUC_DEBUG 324 bootverbose = 0; 325#endif 326 return (0); 327} 328 --- 368 unchanged lines hidden --- | 339 } 340 341#ifdef PUC_DEBUG 342 bootverbose = 0; 343#endif 344 return (0); 345} 346 --- 368 unchanged lines hidden --- |