Lines Matching +full:iommu +full:- +full:map

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
8 * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
54 #include <dev/iommu/busdma_iommu.h>
63 #include "iommu.h"
66 static MALLOC_DEFINE(M_IOMMU, "IOMMU", "IOMMU framework");
77 struct iommu_unit *iommu;
86 struct iommu_unit *iommu;
89 iommu = iodom->iommu;
90 error = IOMMU_UNMAP(iommu->dev, iodom, entry->start, entry->end -
91 entry->start);
99 struct iommu_unit *iommu;
112 va = entry->start;
113 iommu = iodom->iommu;
114 error = IOMMU_MAP(iommu->dev, iodom, va, ma, entry->end -
115 entry->start, prot);
120 .map = iommu_domain_map_buf,
125 iommu_domain_alloc(struct iommu_unit *iommu)
129 iodom = IOMMU_DOMAIN_ALLOC(iommu->dev, iommu);
133 KASSERT(iodom->end != 0, ("domain end is not set"));
135 iommu_domain_init(iommu, iodom, &domain_map_ops);
136 iodom->iommu = iommu;
145 struct iommu_unit *iommu;
147 iommu = iodom->iommu;
149 IOMMU_LOCK(iommu);
151 if ((iodom->flags & IOMMU_DOMAIN_GAS_INITED) != 0) {
159 IOMMU_DOMAIN_FREE(iommu->dev, iodom);
160 IOMMU_UNLOCK(iommu);
170 maxaddr = MIN(iodom->end, BUS_SPACE_MAXADDR);
172 t->common.impl = &bus_dma_iommu_impl;
173 t->common.alignment = 1;
174 t->common.boundary = 0;
175 t->common.lowaddr = maxaddr;
176 t->common.highaddr = maxaddr;
177 t->common.maxsize = maxaddr;
178 t->common.nsegments = BUS_SPACE_UNRESTRICTED;
179 t->common.maxsegsz = maxaddr;
185 struct iommu_unit *iommu;
188 iommu = iodom->iommu;
190 ioctx = IOMMU_CTX_ALLOC(iommu->dev, iodom, requester, disabled);
194 ioctx->domain = iodom;
204 struct iommu_unit *iommu;
207 iodom = ioctx->domain;
208 iommu = iodom->iommu;
210 error = IOMMU_CTX_INIT(iommu->dev, ioctx);
214 tag = ioctx->tag = malloc(sizeof(struct bus_dma_tag_iommu),
216 tag->owner = requester;
217 tag->ctx = ioctx;
218 tag->ctx->domain = iodom;
229 struct iommu_unit *iommu;
233 iommu = entry->iommu;
234 if (iommu->dev == dev) {
236 return (iommu);
249 struct iommu_unit *iommu;
266 "iommus", "#iommu-cells", &niommus);
268 device_printf(dev, "%s can't get iommu list.\n", __func__);
273 device_printf(dev, "%s iommu list is empty.\n", __func__);
277 error = ofw_bus_parse_xref_list_alloc(node, "iommus", "#iommu-cells",
280 device_printf(dev, "%s can't get iommu device xref.\n",
287 device_printf(dev, "%s can't get iommu device.\n", __func__);
291 iommu = iommu_lookup(iommu_dev);
292 if (iommu == NULL) {
293 device_printf(dev, "%s can't lookup iommu.\n", __func__);
301 iodom = iommu_domain_alloc(iommu);
313 ioctx->domain = iodom;
315 error = IOMMU_OFW_MD_DATA(iommu->dev, ioctx, cells, ncells);
323 IOMMU_CTX_FREE(iommu->dev, ioctx);
333 iommu_get_ctx(struct iommu_unit *iommu, device_t requester,
340 IOMMU_LOCK(iommu);
341 ioctx = IOMMU_CTX_LOOKUP(iommu->dev, requester);
343 IOMMU_UNLOCK(iommu);
346 IOMMU_UNLOCK(iommu);
352 iodom = iommu_domain_alloc(iommu);
364 IOMMU_CTX_FREE(iommu->dev, ioctx);
373 iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *ioctx)
378 IOMMU_ASSERT_LOCKED(iommu);
380 tag = ioctx->tag;
382 IOMMU_CTX_FREE(iommu->dev, ioctx);
383 IOMMU_UNLOCK(iommu);
388 error = iommu_domain_free(ioctx->domain);
390 device_printf(iommu->dev, "Could not free a domain\n");
401 entry->flags = 0;
412 KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0,
414 error = iodom->ops->unmap(iodom, entry,
424 panic("entries map is not empty");
428 iommu_register(struct iommu_unit *iommu)
432 mtx_init(&iommu->lock, "IOMMU", NULL, MTX_DEF);
435 entry->iommu = iommu;
441 sysctl_ctx_init(&iommu->sysctl_ctx);
442 iommu_init_busdma(iommu);
448 iommu_unregister(struct iommu_unit *iommu)
454 if (entry->iommu == iommu) {
461 iommu_fini_busdma(iommu);
462 sysctl_ctx_free(&iommu->sysctl_ctx);
464 mtx_destroy(&iommu->lock);
473 struct iommu_unit *iommu;
478 iommu = entry->iommu;
479 error = IOMMU_FIND(iommu->dev, dev);
482 return (entry->iommu);
509 sx_init(&iommu_sx, "IOMMU list");
512 SYSINIT(iommu, SI_SUB_DRIVERS, SI_ORDER_FIRST, iommu_init, NULL);