Lines Matching +full:dma +full:- +full:window
1 /*-
2 * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
50 * @param unit The device unit number, or -1 to select the next available unit
54 * @retval non-zero Failed to attach the bhndb device.
84 /* Skip non-allocated resources */ in bhndb_do_suspend_resources()
85 if (rle->res == NULL) in bhndb_do_suspend_resources()
88 BHNDB_SUSPEND_RESOURCE(device_get_parent(dev), dev, rle->type, in bhndb_do_suspend_resources()
89 rle->res); in bhndb_do_suspend_resources()
168 /* Skip non-allocated resources */ in bhnd_generic_br_resume_child()
169 if (rle->res == NULL) in bhnd_generic_br_resume_child()
173 rle->type, rle->res); in bhnd_generic_br_resume_child()
205 for (u_int i = 0; hr->resource_specs[i].type != -1; i++) { in bhndb_host_resource_for_range()
206 struct resource *r = hr->resources[i]; in bhndb_host_resource_for_range()
208 if (hr->resource_specs[i].type != type) in bhndb_host_resource_for_range()
215 if (rman_get_end(r) < (start + count - 1)) in bhndb_host_resource_for_range()
225 * Find a host resource of that matches the given register window definition.
228 * @param win A register window definition.
239 rspecs = hr->resource_specs; in bhndb_host_resource_for_regwin()
240 for (u_int i = 0; rspecs[i].type != -1; i++) { in bhndb_host_resource_for_regwin()
241 if (win->res.type != rspecs[i].type) in bhndb_host_resource_for_regwin()
244 if (win->res.rid != rspecs[i].rid) in bhndb_host_resource_for_regwin()
248 return (hr->resources[i]); in bhndb_host_resource_for_regwin()
251 device_printf(hr->owner, "missing regwin resource spec " in bhndb_host_resource_for_regwin()
252 "(type=%d, rid=%d)\n", win->res.type, win->res.rid); in bhndb_host_resource_for_regwin()
285 r->dev = dev; in bhndb_alloc_resources()
286 r->cfg = cfg; in bhndb_alloc_resources()
287 r->res = NULL; in bhndb_alloc_resources()
288 r->min_prio = BHNDB_PRIORITY_NONE; in bhndb_alloc_resources()
289 STAILQ_INIT(&r->bus_regions); in bhndb_alloc_resources()
290 STAILQ_INIT(&r->bus_intrs); in bhndb_alloc_resources()
292 mtx_init(&r->dw_steal_mtx, device_get_nameunit(dev), in bhndb_alloc_resources()
296 r->ht_mem_rman.rm_start = 0; in bhndb_alloc_resources()
297 r->ht_mem_rman.rm_end = ~0; in bhndb_alloc_resources()
298 r->ht_mem_rman.rm_type = RMAN_ARRAY; in bhndb_alloc_resources()
299 r->ht_mem_rman.rm_descr = "BHNDB host memory"; in bhndb_alloc_resources()
300 if ((error = rman_init(&r->ht_mem_rman))) { in bhndb_alloc_resources()
301 device_printf(r->dev, "could not initialize ht_mem_rman\n"); in bhndb_alloc_resources()
307 r->br_mem_rman.rm_start = 0; in bhndb_alloc_resources()
308 r->br_mem_rman.rm_end = BUS_SPACE_MAXADDR_32BIT; in bhndb_alloc_resources()
309 r->br_mem_rman.rm_type = RMAN_ARRAY; in bhndb_alloc_resources()
310 r->br_mem_rman.rm_descr = "BHNDB bridged memory"; in bhndb_alloc_resources()
312 if ((error = rman_init(&r->br_mem_rman))) { in bhndb_alloc_resources()
313 device_printf(r->dev, "could not initialize br_mem_rman\n"); in bhndb_alloc_resources()
318 error = rman_manage_region(&r->br_mem_rman, 0, BUS_SPACE_MAXADDR_32BIT); in bhndb_alloc_resources()
320 device_printf(r->dev, "could not configure br_mem_rman\n"); in bhndb_alloc_resources()
325 r->br_irq_rman.rm_start = 0; in bhndb_alloc_resources()
326 r->br_irq_rman.rm_end = RM_MAX_END; in bhndb_alloc_resources()
327 r->br_irq_rman.rm_type = RMAN_ARRAY; in bhndb_alloc_resources()
328 r->br_irq_rman.rm_descr = "BHNDB bridged interrupts"; in bhndb_alloc_resources()
330 if ((error = rman_init(&r->br_irq_rman))) { in bhndb_alloc_resources()
331 device_printf(r->dev, "could not initialize br_irq_rman\n"); in bhndb_alloc_resources()
336 error = rman_manage_region(&r->br_irq_rman, 0, RM_MAX_END); in bhndb_alloc_resources()
338 device_printf(r->dev, "could not configure br_irq_rman\n"); in bhndb_alloc_resources()
344 r->dwa_count = bhndb_regwin_count(cfg->register_windows, in bhndb_alloc_resources()
346 if (r->dwa_count >= INT_MAX) { in bhndb_alloc_resources()
347 device_printf(r->dev, "max dynamic regwin count exceeded\n"); in bhndb_alloc_resources()
351 /* Allocate the dynamic window allocation table. */ in bhndb_alloc_resources()
352 r->dw_alloc = malloc(sizeof(r->dw_alloc[0]) * r->dwa_count, M_BHND, in bhndb_alloc_resources()
354 if (r->dw_alloc == NULL) in bhndb_alloc_resources()
357 /* Allocate the dynamic window allocation freelist */ in bhndb_alloc_resources()
358 r->dwa_freelist = bit_alloc(r->dwa_count, M_BHND, M_NOWAIT); in bhndb_alloc_resources()
359 if (r->dwa_freelist == NULL) in bhndb_alloc_resources()
362 /* Initialize the dynamic window table */ in bhndb_alloc_resources()
365 for (win = cfg->register_windows; in bhndb_alloc_resources()
366 win->win_type != BHNDB_REGWIN_T_INVALID; win++) in bhndb_alloc_resources()
370 /* Skip non-DYN windows */ in bhndb_alloc_resources()
371 if (win->win_type != BHNDB_REGWIN_T_DYN) in bhndb_alloc_resources()
374 /* Validate the window size */ in bhndb_alloc_resources()
375 if (win->win_size == 0) { in bhndb_alloc_resources()
376 device_printf(r->dev, "ignoring zero-length dynamic " in bhndb_alloc_resources()
377 "register window\n"); in bhndb_alloc_resources()
380 last_window_size = win->win_size; in bhndb_alloc_resources()
381 } else if (last_window_size != win->win_size) { in bhndb_alloc_resources()
386 * window allocator and the resource priority system in bhndb_alloc_resources()
388 * window allocation pools. in bhndb_alloc_resources()
390 device_printf(r->dev, "devices that vend multiple " in bhndb_alloc_resources()
391 "dynamic register window sizes are not currently " in bhndb_alloc_resources()
396 dwa = &r->dw_alloc[rnid]; in bhndb_alloc_resources()
397 dwa->win = win; in bhndb_alloc_resources()
398 dwa->parent_res = NULL; in bhndb_alloc_resources()
399 dwa->rnid = rnid; in bhndb_alloc_resources()
400 dwa->target = 0x0; in bhndb_alloc_resources()
402 LIST_INIT(&dwa->refs); in bhndb_alloc_resources()
407 error = bhndb_alloc_host_resources(&r->res, dev, parent_dev, r->cfg); in bhndb_alloc_resources()
409 device_printf(r->dev, in bhndb_alloc_resources()
417 for (size_t i = 0; i < r->dwa_count; i++) { in bhndb_alloc_resources()
421 dwa = &r->dw_alloc[i]; in bhndb_alloc_resources()
422 win = dwa->win; in bhndb_alloc_resources()
425 dwa->parent_res = bhndb_host_resource_for_regwin(r->res, win); in bhndb_alloc_resources()
426 if (dwa->parent_res == NULL) { in bhndb_alloc_resources()
427 device_printf(r->dev, "no host resource found for %u " in bhndb_alloc_resources()
428 "register window with offset %#jx and " in bhndb_alloc_resources()
430 win->win_type, in bhndb_alloc_resources()
431 (uintmax_t)win->win_offset, in bhndb_alloc_resources()
432 (uintmax_t)win->win_size); in bhndb_alloc_resources()
438 if (rman_get_size(dwa->parent_res) < win->win_offset + in bhndb_alloc_resources()
439 win->win_size) in bhndb_alloc_resources()
441 device_printf(r->dev, "resource %d too small for " in bhndb_alloc_resources()
442 "register window with offset %llx and size %llx\n", in bhndb_alloc_resources()
443 rman_get_rid(dwa->parent_res), in bhndb_alloc_resources()
444 (unsigned long long) win->win_offset, in bhndb_alloc_resources()
445 (unsigned long long) win->win_size); in bhndb_alloc_resources()
453 for (u_int i = 0; r->res->resource_specs[i].type != -1; i++) { in bhndb_alloc_resources()
456 /* skip non-memory resources */ in bhndb_alloc_resources()
457 if (r->res->resource_specs[i].type != SYS_RES_MEMORY) in bhndb_alloc_resources()
461 res = r->res->resources[i]; in bhndb_alloc_resources()
462 error = rman_manage_region(&r->ht_mem_rman, in bhndb_alloc_resources()
465 device_printf(r->dev, in bhndb_alloc_resources()
476 rman_fini(&r->ht_mem_rman); in bhndb_alloc_resources()
479 rman_fini(&r->br_mem_rman); in bhndb_alloc_resources()
482 rman_fini(&r->br_irq_rman); in bhndb_alloc_resources()
484 if (r->dw_alloc != NULL) in bhndb_alloc_resources()
485 free(r->dw_alloc, M_BHND); in bhndb_alloc_resources()
487 if (r->dwa_freelist != NULL) in bhndb_alloc_resources()
488 free(r->dwa_freelist, M_BHND); in bhndb_alloc_resources()
490 if (r->res != NULL) in bhndb_alloc_resources()
491 bhndb_release_host_resources(r->res); in bhndb_alloc_resources()
493 mtx_destroy(&r->dw_steal_mtx); in bhndb_alloc_resources()
501 * Create a new DMA tag for the given @p translation.
504 * @param parent_dmat The parent DMA tag, or NULL if none.
505 * @param translation The DMA translation for which a DMA tag will
507 * @param[out] dmat On success, the newly created DMA tag.
510 * @retval non-zero if creating the new DMA tag otherwise fails, a regular
527 dt_mask = (translation->addr_mask | translation->addrext_mask); in bhndb_dma_tag_create()
528 KASSERT(dt_mask != 0, ("DMA addr_mask invalid: %#jx", in bhndb_dma_tag_create()
534 /* Constrain to translation window size */ in bhndb_dma_tag_create()
535 if (translation->addr_mask < maxsegsz) in bhndb_dma_tag_create()
536 maxsegsz = translation->addr_mask; in bhndb_dma_tag_create()
538 /* Create our DMA tag */ in bhndb_dma_tag_create()
548 device_printf(dev, "failed to create bridge DMA tag: %d\n", in bhndb_dma_tag_create()
574 /* No window regions may still be held */ in bhndb_free_resources()
576 for (int i = 0; i < br->dwa_count; i++) { in bhndb_free_resources()
577 dwa = &br->dw_alloc[i]; in bhndb_free_resources()
583 device_printf(br->dev, in bhndb_free_resources()
584 "leaked dynamic register window %d\n", dwa->rnid); in bhndb_free_resources()
590 STAILQ_FOREACH(ih, &br->bus_intrs, ih_link) { in bhndb_free_resources()
591 device_printf(br->dev, "interrupt handler leaked %p\n", in bhndb_free_resources()
592 ih->ih_cookiep); in bhndb_free_resources()
601 if (br->res != NULL) in bhndb_free_resources()
602 bhndb_release_host_resources(br->res); in bhndb_free_resources()
605 for (size_t i = 0; i < br->dwa_count; i++) { in bhndb_free_resources()
606 dwa = &br->dw_alloc[i]; in bhndb_free_resources()
608 LIST_FOREACH_SAFE(dwr, &dwa->refs, dw_link, dwr_next) { in bhndb_free_resources()
615 STAILQ_FOREACH_SAFE(region, &br->bus_regions, link, r_next) { in bhndb_free_resources()
616 STAILQ_REMOVE(&br->bus_regions, region, bhndb_region, link); in bhndb_free_resources()
621 rman_fini(&br->ht_mem_rman); in bhndb_free_resources()
622 rman_fini(&br->br_mem_rman); in bhndb_free_resources()
623 rman_fini(&br->br_irq_rman); in bhndb_free_resources()
625 free(br->dw_alloc, M_BHND); in bhndb_free_resources()
626 free(br->dwa_freelist, M_BHND); in bhndb_free_resources()
628 mtx_destroy(&br->dw_steal_mtx); in bhndb_free_resources()
660 hr->owner = parent_dev; in bhndb_alloc_host_resources()
661 hr->cfg = hwcfg; in bhndb_alloc_host_resources()
662 hr->resource_specs = NULL; in bhndb_alloc_host_resources()
663 hr->resources = NULL; in bhndb_alloc_host_resources()
664 hr->dma_tags = NULL; in bhndb_alloc_host_resources()
665 hr->num_dma_tags = 0; in bhndb_alloc_host_resources()
669 for (size_t i = 0; hwcfg->resource_specs[i].type != -1; i++) in bhndb_alloc_host_resources()
672 /* Determine the total count and validate our DMA translation table. */ in bhndb_alloc_host_resources()
674 for (dt = hwcfg->dma_translations; dt != NULL && in bhndb_alloc_host_resources()
678 if ((dt->base_addr & dt->addr_mask) != 0) { in bhndb_alloc_host_resources()
679 device_printf(dev, "invalid DMA translation; base " in bhndb_alloc_host_resources()
681 (uintmax_t)dt->base_addr, (uintmax_t)dt->addr_mask); in bhndb_alloc_host_resources()
687 if ((dt->addrext_mask & dt->addr_mask) != 0) { in bhndb_alloc_host_resources()
688 device_printf(dev, "invalid DMA translation; addrext " in bhndb_alloc_host_resources()
690 (uintmax_t)dt->addrext_mask, in bhndb_alloc_host_resources()
691 (uintmax_t)dt->addr_mask); in bhndb_alloc_host_resources()
701 /* Allocate our DMA tags */ in bhndb_alloc_host_resources()
702 hr->dma_tags = malloc(sizeof(*hr->dma_tags) * ndt, M_BHND, in bhndb_alloc_host_resources()
706 &hwcfg->dma_translations[i], &hr->dma_tags[i]); in bhndb_alloc_host_resources()
710 hr->num_dma_tags++; in bhndb_alloc_host_resources()
713 /* Allocate space for a non-const copy of our resource_spec in bhndb_alloc_host_resources()
716 hr->resource_specs = malloc(sizeof(hr->resource_specs[0]) * (nres + 1), in bhndb_alloc_host_resources()
721 hr->resource_specs[i] = hwcfg->resource_specs[i]; in bhndb_alloc_host_resources()
723 hr->resource_specs[nres].type = -1; in bhndb_alloc_host_resources()
726 hr->resources = malloc(sizeof(hr->resources[0]) * nres, M_BHND, in bhndb_alloc_host_resources()
730 error = bus_alloc_resources(hr->owner, hr->resource_specs, in bhndb_alloc_host_resources()
731 hr->resources); in bhndb_alloc_host_resources()
742 if (hr->resource_specs != NULL) in bhndb_alloc_host_resources()
743 free(hr->resource_specs, M_BHND); in bhndb_alloc_host_resources()
745 if (hr->resources != NULL) in bhndb_alloc_host_resources()
746 free(hr->resources, M_BHND); in bhndb_alloc_host_resources()
748 for (size_t i = 0; i < hr->num_dma_tags; i++) in bhndb_alloc_host_resources()
749 bus_dma_tag_destroy(hr->dma_tags[i]); in bhndb_alloc_host_resources()
751 if (hr->dma_tags != NULL) in bhndb_alloc_host_resources()
752 free(hr->dma_tags, M_BHND); in bhndb_alloc_host_resources()
767 bus_release_resources(hr->owner, hr->resource_specs, hr->resources); in bhndb_release_host_resources()
769 for (size_t i = 0; i < hr->num_dma_tags; i++) in bhndb_release_host_resources()
770 bus_dma_tag_destroy(hr->dma_tags[i]); in bhndb_release_host_resources()
772 free(hr->resources, M_BHND); in bhndb_release_host_resources()
773 free(hr->resource_specs, M_BHND); in bhndb_release_host_resources()
774 free(hr->dma_tags, M_BHND); in bhndb_release_host_resources()
781 * This function uses a heuristic valid on all known PCI/PCIe/PCMCIA-bridged
784 * - The core must have a Broadcom vendor ID.
785 * - The core devclass must match the bridge type.
786 * - The core must be the first device on the bus with the bridged device
820 if (match != NULL && match_core_idx < match->core_idx) in bhndb_find_hostb_core()
824 match_core_idx = match->core_idx; in bhndb_find_hostb_core()
845 * @retval non-NULL success
858 isrc->is_owner = owner; in bhndb_alloc_intr_isrc()
859 isrc->is_rid = rid; in bhndb_alloc_intr_isrc()
860 isrc->is_res = bus_alloc_resource(owner, SYS_RES_IRQ, &isrc->is_rid, in bhndb_alloc_intr_isrc()
862 if (isrc->is_res == NULL) { in bhndb_alloc_intr_isrc()
878 bus_release_resource(isrc->is_owner, SYS_RES_IRQ, isrc->is_rid, in bhndb_free_intr_isrc()
879 isrc->is_res); in bhndb_free_intr_isrc()
890 * @retval non-NULL success
900 ih->ih_owner = owner; in bhndb_alloc_intr_handler()
901 ih->ih_res = r; in bhndb_alloc_intr_handler()
902 ih->ih_isrc = isrc; in bhndb_alloc_intr_handler()
903 ih->ih_cookiep = NULL; in bhndb_alloc_intr_handler()
904 ih->ih_active = false; in bhndb_alloc_intr_handler()
918 KASSERT(!ih->ih_active, ("free of active interrupt handler %p", in bhndb_free_intr_handler()
919 ih->ih_cookiep)); in bhndb_free_intr_handler()
934 KASSERT(!ih->ih_active, ("duplicate registration of interrupt " in bhndb_register_intr_handler()
935 "handler %p", ih->ih_cookiep)); in bhndb_register_intr_handler()
936 KASSERT(ih->ih_cookiep != NULL, ("missing cookiep")); in bhndb_register_intr_handler()
938 ih->ih_active = true; in bhndb_register_intr_handler()
939 STAILQ_INSERT_HEAD(&br->bus_intrs, ih, ih_link); in bhndb_register_intr_handler()
952 KASSERT(ih->ih_active, ("duplicate deregistration of interrupt " in bhndb_deregister_intr_handler()
953 "handler %p", ih->ih_cookiep)); in bhndb_deregister_intr_handler()
958 STAILQ_REMOVE(&br->bus_intrs, ih, bhndb_intr_handler, ih_link); in bhndb_deregister_intr_handler()
959 ih->ih_active = false; in bhndb_deregister_intr_handler()
967 * @param cookiep The interrupt handler's bus-assigned cookiep value.
974 STAILQ_FOREACH(ih, &br->bus_intrs, ih_link) { in bhndb_find_intr_handler()
1008 STAILQ_FOREACH(ih, &br->bus_intrs, ih_link) { in bhndb_find_resource_limits()
1009 if (ih->ih_res == r) in bhndb_find_resource_limits()
1022 /* Check for an enclosing dynamic register window */ in bhndb_find_resource_limits()
1024 *start = dynamic->target; in bhndb_find_resource_limits()
1025 *end = dynamic->target + dynamic->win->win_size - 1; in bhndb_find_resource_limits()
1032 if (sregion != NULL && sregion->static_regwin != NULL) { in bhndb_find_resource_limits()
1033 *start = sregion->addr; in bhndb_find_resource_limits()
1034 *end = sregion->addr + sregion->size - 1; in bhndb_find_resource_limits()
1044 device_printf(br->dev, "unknown resource type: %d\n", in bhndb_find_resource_limits()
1059 * @param static_regwin If available, a static register window mapping this
1063 * @retval non-zero if adding the bus region fails.
1085 STAILQ_INSERT_HEAD(&br->bus_regions, reg, link); in bhndb_add_resource_region()
1107 /* Must be backed by a static register window */ in bhndb_has_static_region_mapping()
1108 if (region->static_regwin == NULL) in bhndb_has_static_region_mapping()
1112 r_addr += region->size; in bhndb_has_static_region_mapping()
1139 STAILQ_FOREACH(region, &br->bus_regions, link) { in bhndb_find_resource_region()
1141 if (addr < region->addr) in bhndb_find_resource_region()
1144 if (addr + size > region->addr + region->size) in bhndb_find_resource_region()
1157 * @param dwa The dynamic window allocation to search
1165 LIST_FOREACH(rentry, &dwa->refs, dw_link) { in bhndb_dw_find_resource_entry()
1166 struct resource *dw_res = rentry->dw_res; in bhndb_dw_find_resource_entry()
1191 * @retval NULL if no dynamic window is allocated for @p r.
1198 for (size_t i = 0; i < br->dwa_count; i++) { in bhndb_dw_find_resource()
1199 dwa = &br->dw_alloc[i]; in bhndb_dw_find_resource()
1214 * Find an existing dynamic window mapping @p size bytes
1215 * at @p addr. The window may or may not be free.
1221 * @retval bhndb_dw_alloc A window allocation that fully contains the requested
1233 for (size_t i = 0; i < br->dwa_count; i++) { in bhndb_dw_find_mapping()
1234 dwr = &br->dw_alloc[i]; in bhndb_dw_find_mapping()
1235 win = dwr->win; in bhndb_dw_find_mapping()
1238 if (addr < dwr->target) in bhndb_dw_find_mapping()
1241 if (addr + size > dwr->target + win->win_size) in bhndb_dw_find_mapping()
1269 ("double-retain of dynamic window for same resource")); in bhndb_dw_retain()
1272 * within a non-sleepable lock */ in bhndb_dw_retain()
1277 rentry->dw_res = res; in bhndb_dw_retain()
1278 LIST_INSERT_HEAD(&dwa->refs, rentry, dw_link); in bhndb_dw_retain()
1281 bit_set(br->dwa_freelist, dwa->rnid); in bhndb_dw_retain()
1309 if (LIST_EMPTY(&dwa->refs)) in bhndb_dw_release()
1310 bit_clear(br->dwa_freelist, dwa->rnid); in bhndb_dw_release()
1317 * This will apply any necessary window alignment and verify that
1318 * the window is capable of mapping the requested range prior to modifying
1328 * @retval non-zero no usable register window available.
1338 rw = dwa->win; in bhndb_dw_set_addr()
1340 KASSERT(bhndb_dw_is_free(br, dwa) || mtx_owned(&br->dw_steal_mtx), in bhndb_dw_set_addr()
1341 ("attempting to set the target address on an in-use window")); in bhndb_dw_set_addr()
1343 /* Page-align the target address */ in bhndb_dw_set_addr()
1344 offset = addr % rw->win_size; in bhndb_dw_set_addr()
1345 dwa->target = addr - offset; in bhndb_dw_set_addr()
1347 /* Verify that the window is large enough for the full target */ in bhndb_dw_set_addr()
1348 if (rw->win_size - offset < size) in bhndb_dw_set_addr()
1351 /* Update the window target */ in bhndb_dw_set_addr()
1352 error = BHNDB_SET_WINDOW_ADDR(dev, dwa->win, dwa->target); in bhndb_dw_set_addr()
1354 dwa->target = 0x0; in bhndb_dw_set_addr()
1362 * Steal an in-use allocation record from @p br, returning the record's current
1366 * avoid holding a stolen window longer than required to issue an I/O
1372 * @param br The resource state from which a window should be stolen.
1373 * @param saved The stolen window's saved target address.
1375 * @retval non-NULL success
1376 * @retval NULL no dynamic window regions are defined.
1384 ("attempting to steal an in-use window while free windows remain")); in bhndb_dw_steal()
1387 if (br->dwa_count == 0) in bhndb_dw_steal()
1395 * stealing an in-use existing register window. in bhndb_dw_steal()
1397 mtx_lock_spin(&br->dw_steal_mtx); in bhndb_dw_steal()
1399 dw_stolen = &br->dw_alloc[0]; in bhndb_dw_steal()
1400 *saved = dw_stolen->target; in bhndb_dw_steal()
1418 mtx_assert(&br->dw_steal_mtx, MA_OWNED); in bhndb_dw_return_stolen()
1422 panic("failed to restore register window target %#jx: %d\n", in bhndb_dw_return_stolen()
1426 mtx_unlock_spin(&br->dw_steal_mtx); in bhndb_dw_return_stolen()
1433 * @param type The required window type, or BHNDB_REGWIN_T_INVALID to
1434 * count all register window types.
1444 for (rw = table; rw->win_type != BHNDB_REGWIN_T_INVALID; rw++) { in bhndb_regwin_count()
1445 if (type == BHNDB_REGWIN_T_INVALID || rw->win_type == type) in bhndb_regwin_count()
1453 * Search @p table for the first window with the given @p type.
1456 * @param type The required window type.
1457 * @param min_size The minimum window size.
1459 * @retval bhndb_regwin The first matching window.
1460 * @retval NULL If no window of the requested type could be found.
1468 for (rw = table; rw->win_type != BHNDB_REGWIN_T_INVALID; rw++) in bhndb_regwin_find_type()
1470 if (rw->win_type == type && rw->win_size >= min_size) in bhndb_regwin_find_type()
1478 * Search @p windows for the first matching core window.
1482 * @param unit The required core unit, or -1.
1489 * @retval bhndb_regwin The first matching window.
1490 * @retval NULL If no matching window was found.
1499 for (rw = table; rw->win_type != BHNDB_REGWIN_T_INVALID; rw++) in bhndb_regwin_find_core()
1504 if (rw->win_type != BHNDB_REGWIN_T_CORE) in bhndb_regwin_find_core()
1507 if (rw->d.core.class != class) in bhndb_regwin_find_core()
1510 if (unit != -1 && rw->d.core.unit != unit) in bhndb_regwin_find_core()
1513 if (rw->d.core.port_type != port_type) in bhndb_regwin_find_core()
1516 if (rw->d.core.port != port) in bhndb_regwin_find_core()
1519 if (rw->d.core.region != region) in bhndb_regwin_find_core()
1523 * this register window */ in bhndb_regwin_find_core()
1524 if (rw->d.core.offset > offset) in bhndb_regwin_find_core()
1527 rw_offset = offset - rw->d.core.offset; in bhndb_regwin_find_core()
1529 if (rw->win_size < rw_offset) in bhndb_regwin_find_core()
1532 if (rw->win_size - rw_offset < min_size) in bhndb_regwin_find_core()
1542 * Search @p windows for the best available window of at least @p min_size.
1545 * - BHND_REGWIN_T_CORE
1546 * - BHND_REGWIN_T_DYN
1550 * @param unit The required core unit, or -1.
1557 * @retval bhndb_regwin The first matching window.
1558 * @retval NULL If no matching window was found.
1573 /* Fall back on a generic dynamic window */ in bhndb_regwin_find_best()
1578 * Return true if @p regw defines a BHNDB_REGWIN_T_CORE register window
1581 * @param regw A register window to match against.
1589 if (regw->win_type != BHNDB_REGWIN_T_CORE) in bhndb_regwin_match_core()
1593 if (bhnd_core_class(core) != regw->d.core.class) in bhndb_regwin_match_core()
1597 if (core->unit != regw->d.core.unit) in bhndb_regwin_match_core()
1617 for (hp = table; hp->ports != NULL; hp++) { in bhndb_hw_priority_find_core()
1618 if (bhnd_core_matches(core, &hp->match)) in bhndb_hw_priority_find_core()
1645 for (u_int i = 0; i < hp->num_ports; i++) { in bhndb_hw_priorty_find_port()
1646 const struct bhndb_port_priority *pp = &hp->ports[i]; in bhndb_hw_priorty_find_port()
1648 if (pp->type != port_type) in bhndb_hw_priorty_find_port()
1651 if (pp->port != port) in bhndb_hw_priorty_find_port()
1654 if (pp->region != region) in bhndb_hw_priorty_find_port()