| 429 | } |
| 430 | |
| 431 | static struct resource * |
| 432 | arm_gic_alloc_resource(device_t bus, device_t child, int type, int *rid, |
| 433 | rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) |
| 434 | { |
| 435 | struct arm_gic_softc *sc; |
| 436 | struct resource_list_entry *rle; |
| 437 | struct resource_list *rl; |
| 438 | int j; |
| 439 | |
| 440 | KASSERT(type == SYS_RES_MEMORY, ("Invalid resoure type %x", type)); |
| 441 | |
| 442 | sc = device_get_softc(bus); |
| 443 | |
| 444 | /* |
| 445 | * Request for the default allocation with a given rid: use resource |
| 446 | * list stored in the local device info. |
| 447 | */ |
| 448 | if (RMAN_IS_DEFAULT_RANGE(start, end)) { |
| 449 | rl = BUS_GET_RESOURCE_LIST(bus, child); |
| 450 | |
| 451 | if (type == SYS_RES_IOPORT) |
| 452 | type = SYS_RES_MEMORY; |
| 453 | |
| 454 | rle = resource_list_find(rl, type, *rid); |
| 455 | if (rle == NULL) { |
| 456 | if (bootverbose) |
| 457 | device_printf(bus, "no default resources for " |
| 458 | "rid = %d, type = %d\n", *rid, type); |
| 459 | return (NULL); |
| 460 | } |
| 461 | start = rle->start; |
| 462 | end = rle->end; |
| 463 | count = rle->count; |
| 464 | } |
| 465 | |
| 466 | /* Remap through ranges property */ |
| 467 | for (j = 0; j < sc->nranges; j++) { |
| 468 | if (start >= sc->ranges[j].bus && end < |
| 469 | sc->ranges[j].bus + sc->ranges[j].size) { |
| 470 | start -= sc->ranges[j].bus; |
| 471 | start += sc->ranges[j].host; |
| 472 | end -= sc->ranges[j].bus; |
| 473 | end += sc->ranges[j].host; |
| 474 | break; |
| 475 | } |
| 476 | } |
| 477 | if (j == sc->nranges && sc->nranges != 0) { |
| 478 | if (bootverbose) |
| 479 | device_printf(bus, "Could not map resource " |
| 480 | "%#jx-%#jx\n", (uintmax_t)start, (uintmax_t)end); |
| 481 | |
| 482 | return (NULL); |
| 483 | } |
| 484 | |
| 485 | return (bus_generic_alloc_resource(bus, child, type, rid, start, end, |
| 486 | count, flags)); |
| 487 | } |
| 488 |
nothing calls this directly
no test coverage detected