Lines Matching +full:iommu +full:- +full:addresses
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
50 #include "ps3-hvcall.h"
128 /* IOMMU interface */
160 if (device_find_child(parent, "ps3bus", -1) == NULL)
184 resource_list_init(&dinfo->resources);
187 thread = 32 - fls(mfctrl());
204 lv1_connect_interrupt_event_receive_port(dinfo->bus,
205 dinfo->dev, outlet, irq);
215 irq_type, dinfo->bus, dinfo->dev);
219 resource_list_add(&dinfo->resources, SYS_RES_IRQ, i,
240 result = lv1_map_device_mmio_region(dinfo->bus, dinfo->dev,
245 "%d.%d (%ld.%ld): %d\n", dinfo->bus, dinfo->dev,
246 dinfo->bustype, dinfo->devtype, result);
250 rman_manage_region(rm, paddr, paddr + len - 1);
251 resource_list_add(&dinfo->resources, SYS_RES_MEMORY, i,
266 resource_list_init(&dinfo->resources);
269 thread = 32 - fls(mfctrl());
287 resource_list_add(&dinfo->resources, SYS_RES_IRQ, i,
311 result = lv1_map_device_mmio_region(dinfo->bus, dinfo->dev,
316 "%d.%d (%ld.%ld): %d\n", dinfo->bus, dinfo->dev,
317 dinfo->bustype, dinfo->devtype, result);
321 rman_manage_region(rm, paddr, paddr + len - 1);
322 resource_list_add(&dinfo->resources, SYS_RES_MEMORY, i,
339 sc->sc_mem_rman.rm_type = RMAN_ARRAY;
340 sc->sc_mem_rman.rm_descr = "PS3Bus Memory Mapped I/O";
341 sc->sc_intr_rman.rm_type = RMAN_ARRAY;
342 sc->sc_intr_rman.rm_descr = "PS3Bus Interrupts";
343 rman_init(&sc->sc_mem_rman);
344 rman_init(&sc->sc_intr_rman);
345 rman_manage_region(&sc->sc_intr_rman, 0, ~0);
348 mem_regions(&sc->regions, &sc->rcount, NULL, NULL);
401 dinfo->bus = bus;
402 dinfo->dev = dev;
403 dinfo->bustype = bustype;
404 dinfo->devtype = devtype;
405 dinfo->busidx = bus_index;
406 dinfo->devidx = dev_index;
408 ps3bus_resources_init_by_type(&sc->sc_mem_rman, bus_index,
419 mtx_init(&dinfo->iommu_mtx, "iommu", NULL, MTX_DEF);
427 dinfo->bus = bus;
428 dinfo->dev = dev;
429 dinfo->bustype = bustype;
430 dinfo->devtype = devtype;
431 dinfo->busidx = bus_index;
432 dinfo->devidx = dev_index;
434 ps3bus_resources_init_by_type(&sc->sc_mem_rman, bus_index,
445 mtx_init(&dinfo->iommu_mtx, "iommu", NULL, MTX_DEF);
452 dinfo->bus = bus;
453 dinfo->dev = dev;
454 dinfo->bustype = bustype;
455 dinfo->devtype = devtype;
456 dinfo->busidx = bus_index;
457 dinfo->devidx = dev_index;
459 if (dinfo->bustype == PS3_BUSTYPE_SYSBUS ||
460 dinfo->bustype == PS3_BUSTYPE_STORAGE)
463 ps3bus_resources_init(&sc->sc_mem_rman, bus_index,
474 mtx_init(&dinfo->iommu_mtx, "iommu", NULL, MTX_DEF);
493 retval += resource_list_print_type(&dinfo->resources, "mem",
495 retval += resource_list_print_type(&dinfo->resources, "irq",
510 *result = dinfo->bus;
513 *result = dinfo->dev;
516 *result = dinfo->bustype;
519 *result = dinfo->devtype;
522 *result = dinfo->busidx;
525 *result = dinfo->devidx;
542 return (&sc->sc_mem_rman);
544 return (&sc->sc_intr_rman);
562 rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY,
570 if (start < rle->start)
571 adjstart = rle->start;
572 else if (start > rle->end)
573 adjstart = rle->end;
577 if (end < rle->start)
578 adjend = rle->start;
579 else if (end > rle->end)
580 adjend = rle->end;
584 adjcount = adjend - adjstart;
587 rle = resource_list_find(&dinfo->resources, SYS_RES_IRQ,
589 adjstart = rle->start;
590 adjcount = ulmax(count, rle->count);
591 adjend = ulmax(rle->end, rle->start + adjcount - 1);
631 map->r_vaddr = pmap_mapdev_attr(start, length, args.memattr);
632 if (map->r_vaddr == NULL)
634 map->r_bustag = &bs_be_tag;
635 map->r_bushandle = (vm_offset_t)map->r_vaddr;
636 map->r_size = length;
647 pmap_unmapdev(map->r_vaddr, map->r_size);
661 if (dinfo->bustype != PS3_BUSTYPE_SYSBUS &&
662 dinfo->bustype != PS3_BUSTYPE_STORAGE)
665 mtx_lock(&dinfo->iommu_mtx);
666 if (dinfo->dma_tag != NULL) {
667 mtx_unlock(&dinfo->iommu_mtx);
668 return (dinfo->dma_tag);
671 flags = 0; /* 32-bit mode */
672 if (dinfo->bustype == PS3_BUSTYPE_SYSBUS &&
673 dinfo->devtype == PS3_DEVTYPE_USB)
674 flags = 2; /* 8-bit mode */
677 if (dinfo->bustype == PS3_BUSTYPE_STORAGE)
680 for (i = 0; i < sc->rcount; i++) {
681 err = lv1_allocate_device_dma_region(dinfo->bus, dinfo->dev,
682 sc->regions[i].mr_size, pagesize, flags,
683 &dinfo->dma_base[i]);
690 err = lv1_map_device_dma_region(dinfo->bus, dinfo->dev,
691 sc->regions[i].mr_start, dinfo->dma_base[i],
692 sc->regions[i].mr_size,
704 0, NULL, NULL, &dinfo->dma_tag);
707 * Note: storage devices have IOMMU mappings set up by the hypervisor,
708 * but use physical, non-translated addresses. The above IOMMU
710 * the mappings, but actual DMA mappings should not use the IOMMU
713 if (dinfo->bustype != PS3_BUSTYPE_STORAGE)
714 bus_dma_tag_set_iommu(dinfo->dma_tag, dev, dinfo);
717 mtx_unlock(&dinfo->iommu_mtx);
722 return (dinfo->dma_tag);
735 for (j = 0; j < sc->rcount; j++) {
736 if (segs[i].ds_addr >= sc->regions[j].mr_start &&
737 segs[i].ds_addr < sc->regions[j].mr_start +
738 sc->regions[j].mr_size)
741 KASSERT(j < sc->rcount,
745 segs[i].ds_addr = dinfo->dma_base[j] +
746 (segs[i].ds_addr - sc->regions[j].mr_start);
771 ts->tv_sec = rtc + Y2K;
772 ts->tv_nsec = 0;
779 return (-1);