pccard.c (227309) | pccard.c (237692) |
---|---|
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ 2 3/*- 4 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> | 1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ 2 3/*- 4 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/pccard/pccard.c 227309 2011-11-07 15:43:11Z ed $"); | 33__FBSDID("$FreeBSD: head/sys/dev/pccard/pccard.c 237692 2012-06-28 07:26:44Z imp $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/malloc.h> 38#include <sys/module.h> 39#include <sys/kernel.h> 40#include <sys/queue.h> 41#include <sys/sysctl.h> --- 426 unchanged lines hidden (view full) --- 468static void 469pccard_function_init(struct pccard_function *pf, int entry) 470{ 471 struct pccard_config_entry *cfe; 472 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 473 struct resource_list *rl = &devi->resources; 474 struct resource_list_entry *rle; 475 struct resource *r = 0; | 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/malloc.h> 38#include <sys/module.h> 39#include <sys/kernel.h> 40#include <sys/queue.h> 41#include <sys/sysctl.h> --- 426 unchanged lines hidden (view full) --- 468static void 469pccard_function_init(struct pccard_function *pf, int entry) 470{ 471 struct pccard_config_entry *cfe; 472 struct pccard_ivar *devi = PCCARD_IVAR(pf->dev); 473 struct resource_list *rl = &devi->resources; 474 struct resource_list_entry *rle; 475 struct resource *r = 0; |
476 struct pccard_ce_iospace *ios; 477 struct pccard_ce_memspace *mems; |
|
476 device_t bus; 477 u_long start, end, len; 478 int i, rid, spaces; 479 480 if (pf->pf_flags & PFF_ENABLED) { 481 printf("pccard_function_init: function is enabled"); 482 return; 483 } --- 12 unchanged lines hidden (view full) --- 496 bus = device_get_parent(pf->dev); 497 STAILQ_FOREACH(cfe, &pf->cfe_head, cfe_list) { 498 if (cfe->iftype != PCCARD_IFTYPE_IO) 499 continue; 500 if (entry != -1 && cfe->number != entry) 501 continue; 502 spaces = 0; 503 for (i = 0; i < cfe->num_iospace; i++) { | 478 device_t bus; 479 u_long start, end, len; 480 int i, rid, spaces; 481 482 if (pf->pf_flags & PFF_ENABLED) { 483 printf("pccard_function_init: function is enabled"); 484 return; 485 } --- 12 unchanged lines hidden (view full) --- 498 bus = device_get_parent(pf->dev); 499 STAILQ_FOREACH(cfe, &pf->cfe_head, cfe_list) { 500 if (cfe->iftype != PCCARD_IFTYPE_IO) 501 continue; 502 if (entry != -1 && cfe->number != entry) 503 continue; 504 spaces = 0; 505 for (i = 0; i < cfe->num_iospace; i++) { |
504 start = cfe->iospace[i].start; | 506 ios = cfe->iospace + i; 507 start = ios->start; |
505 if (start) | 508 if (start) |
506 end = start + cfe->iospace[i].length - 1; | 509 end = start + ios->length - 1; |
507 else 508 end = ~0UL; 509 DEVPRINTF((bus, "I/O rid %d start %#lx end %#lx\n", 510 i, start, end)); 511 rid = i; | 510 else 511 end = ~0UL; 512 DEVPRINTF((bus, "I/O rid %d start %#lx end %#lx\n", 513 i, start, end)); 514 rid = i; |
512 len = cfe->iospace[i].length; | 515 len = ios->length; |
513 r = bus_alloc_resource(bus, SYS_RES_IOPORT, &rid, 514 start, end, len, rman_make_alignment_flags(len)); | 516 r = bus_alloc_resource(bus, SYS_RES_IOPORT, &rid, 517 start, end, len, rman_make_alignment_flags(len)); |
515 if (r == NULL) | 518 if (r == NULL) { 519 DEVPRINTF((bus, "I/O rid %d failed\n", i)); |
516 goto not_this_one; | 520 goto not_this_one; |
521 } |
|
517 rle = resource_list_add(rl, SYS_RES_IOPORT, | 522 rle = resource_list_add(rl, SYS_RES_IOPORT, |
518 rid, rman_get_start(r), rman_get_end(r), 519 cfe->iospace[i].length); | 523 rid, rman_get_start(r), rman_get_end(r), len); |
520 if (rle == NULL) 521 panic("Cannot add resource rid %d IOPORT", rid); 522 rle->res = r; 523 spaces++; 524 } 525 for (i = 0; i < cfe->num_memspace; i++) { | 524 if (rle == NULL) 525 panic("Cannot add resource rid %d IOPORT", rid); 526 rle->res = r; 527 spaces++; 528 } 529 for (i = 0; i < cfe->num_memspace; i++) { |
526 start = cfe->memspace[i].hostaddr; | 530 mems = cfe->memspace + i; 531 start = mems->cardaddr + mems->hostaddr; |
527 if (start) | 532 if (start) |
528 end = start + cfe->memspace[i].length - 1; | 533 end = start + mems->length - 1; |
529 else 530 end = ~0UL; | 534 else 535 end = ~0UL; |
531 DEVPRINTF((bus, "Memory rid %d start %#lx end %#lx\n", 532 i, start, end)); | 536 DEVPRINTF((bus, "Memory rid %d start %#lx end %#lx\ncardaddr %#lx hostaddr %#lx length %#lx\n", 537 i, start, end, mems->cardaddr, mems->hostaddr, 538 mems->length)); |
533 rid = i; | 539 rid = i; |
534 len = cfe->memspace[i].length; | 540 len = mems->length; |
535 r = bus_alloc_resource(bus, SYS_RES_MEMORY, &rid, 536 start, end, len, rman_make_alignment_flags(len)); | 541 r = bus_alloc_resource(bus, SYS_RES_MEMORY, &rid, 542 start, end, len, rman_make_alignment_flags(len)); |
537 if (r == NULL) 538 goto not_this_one; | 543 if (r == NULL) { 544 DEVPRINTF((bus, "Memory rid %d failed\n", i)); 545// goto not_this_one; 546 continue; 547 } |
539 rle = resource_list_add(rl, SYS_RES_MEMORY, | 548 rle = resource_list_add(rl, SYS_RES_MEMORY, |
540 rid, rman_get_start(r), rman_get_end(r), 541 cfe->memspace[i].length); | 549 rid, rman_get_start(r), rman_get_end(r), len); |
542 if (rle == NULL) 543 panic("Cannot add resource rid %d MEM", rid); 544 rle->res = r; 545 spaces++; 546 } 547 if (spaces == 0) { 548 DEVPRINTF((bus, "Neither memory nor I/O mapped\n")); 549 goto not_this_one; 550 } 551 if (cfe->irqmask) { 552 rid = 0; 553 r = bus_alloc_resource_any(bus, SYS_RES_IRQ, &rid, 554 RF_SHAREABLE); | 550 if (rle == NULL) 551 panic("Cannot add resource rid %d MEM", rid); 552 rle->res = r; 553 spaces++; 554 } 555 if (spaces == 0) { 556 DEVPRINTF((bus, "Neither memory nor I/O mapped\n")); 557 goto not_this_one; 558 } 559 if (cfe->irqmask) { 560 rid = 0; 561 r = bus_alloc_resource_any(bus, SYS_RES_IRQ, &rid, 562 RF_SHAREABLE); |
555 if (r == NULL) | 563 if (r == NULL) { 564 DEVPRINTF((bus, "IRQ rid %d failed\n", rid)); |
556 goto not_this_one; | 565 goto not_this_one; |
566 } |
|
557 rle = resource_list_add(rl, SYS_RES_IRQ, rid, 558 rman_get_start(r), rman_get_end(r), 1); 559 if (rle == NULL) 560 panic("Cannot add resource rid %d IRQ", rid); 561 rle->res = r; 562 } 563 /* If we get to here, we've allocated all we need */ 564 pf->cfe = cfe; --- 921 unchanged lines hidden --- | 567 rle = resource_list_add(rl, SYS_RES_IRQ, rid, 568 rman_get_start(r), rman_get_end(r), 1); 569 if (rle == NULL) 570 panic("Cannot add resource rid %d IRQ", rid); 571 rle->res = r; 572 } 573 /* If we get to here, we've allocated all we need */ 574 pf->cfe = cfe; --- 921 unchanged lines hidden --- |