-/* $OpenBSD: acpiiort.c,v 1.1 2021/02/28 21:31:10 patrick Exp $ */
+/* $OpenBSD: acpiiort.c,v 1.2 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2021 Patrick Wildt <patrick@blueri.se>
*
SIMPLEQ_INSERT_TAIL(&acpiiort_smmu_list, as, as_list);
}
-void
-acpiiort_smmu_hook(struct acpi_iort_node *node, uint32_t rid,
- struct pci_attach_args *pa)
+bus_dma_tag_t
+acpiiort_smmu_map(struct acpi_iort_node *node, uint32_t rid,
+ bus_dma_tag_t dmat)
{
struct acpiiort_smmu *as;
SIMPLEQ_FOREACH(as, &acpiiort_smmu_list, as_list) {
- if (as->as_node == node) {
- as->as_hook(as->as_cookie, rid, pa);
- break;
- }
+ if (as->as_node == node)
+ return as->as_map(as->as_cookie, rid, dmat);
}
+
+ return dmat;
}
-/* $OpenBSD: acpiiort.h,v 1.1 2021/02/28 21:31:10 patrick Exp $ */
+/* $OpenBSD: acpiiort.h,v 1.2 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2021 Patrick Wildt <patrick@blueri.se>
*
SIMPLEQ_ENTRY(acpiiort_smmu) as_list;
struct acpi_iort_node *as_node;
void *as_cookie;
- void (*as_hook)(void *, uint32_t,
- struct pci_attach_args *);
+ bus_dma_tag_t (*as_map)(void *, uint32_t,
+ bus_dma_tag_t);
};
void acpiiort_smmu_register(struct acpiiort_smmu *);
-void acpiiort_smmu_hook(struct acpi_iort_node *, uint32_t,
- struct pci_attach_args *);
+bus_dma_tag_t acpiiort_smmu_map(struct acpi_iort_node *, uint32_t, bus_dma_tag_t);
-/* $OpenBSD: acpipci.c,v 1.26 2021/02/28 21:42:08 patrick Exp $ */
+/* $OpenBSD: acpipci.c,v 1.27 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
node = (struct acpi_iort_node *)((char *)iort + offset);
if (node->type == ACPI_IORT_SMMU)
- acpiiort_smmu_hook(node, rid, pa);
+ pa->pa_dmat = acpiiort_smmu_map(node, rid, pa->pa_dmat);
return 0;
}
-/* $OpenBSD: smmu.c,v 1.9 2021/03/06 19:30:07 patrick Exp $ */
+/* $OpenBSD: smmu.c,v 1.10 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2008-2009,2014-2016 Dale Rahn <drahn@dalerahn.com>
* Copyright (c) 2021 Patrick Wildt <patrick@blueri.se>
}
bus_dma_tag_t
-smmu_device_hook(struct smmu_softc *sc, uint32_t sid, bus_dma_tag_t dmat)
+smmu_device_map(void *cookie, uint32_t sid, bus_dma_tag_t dmat)
{
+ struct smmu_softc *sc = cookie;
struct smmu_domain *dom;
dom = smmu_domain_lookup(sc, sid);
return dom->sd_dmat;
}
-void
-smmu_pci_device_hook(void *cookie, uint32_t rid, struct pci_attach_args *pa)
-{
- struct smmu_softc *sc = cookie;
-
- printf("%s: rid %x\n", sc->sc_dev.dv_xname, rid);
- pa->pa_dmat = smmu_device_hook(sc, rid, pa->pa_dmat);
-}
-
struct smmu_domain *
smmu_domain_lookup(struct smmu_softc *sc, uint32_t sid)
{
-/* $OpenBSD: smmu_acpi.c,v 1.1 2021/02/28 21:39:31 patrick Exp $ */
+/* $OpenBSD: smmu_acpi.c,v 1.2 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2021 Patrick Wildt <patrick@blueri.se>
*
as = malloc(sizeof(*as), M_DEVBUF, M_WAITOK | M_ZERO);
as->as_node = node;
as->as_cookie = sc;
- as->as_hook = smmu_pci_device_hook;
+ as->as_map = smmu_device_map;
acpiiort_smmu_register(as);
}
-/* $OpenBSD: smmu_fdt.c,v 1.2 2021/03/01 21:35:03 patrick Exp $ */
+/* $OpenBSD: smmu_fdt.c,v 1.3 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2021 Patrick Wildt <patrick@blueri.se>
*
struct smmu_fdt_softc *fsc = (struct smmu_fdt_softc *)cookie;
struct smmu_softc *sc = &fsc->sc_smmu;
- return smmu_device_hook(sc, cells[0], dmat);
+ return smmu_device_map(sc, cells[0], dmat);
}
-/* $OpenBSD: smmuvar.h,v 1.3 2021/03/05 00:55:45 patrick Exp $ */
+/* $OpenBSD: smmuvar.h,v 1.4 2021/03/15 22:48:57 patrick Exp $ */
/*
* Copyright (c) 2021 Patrick Wildt <patrick@blueri.se>
*
int smmu_attach(struct smmu_softc *);
int smmu_global_irq(void *);
int smmu_context_irq(void *);
-bus_dma_tag_t smmu_device_hook(struct smmu_softc *, uint32_t, bus_dma_tag_t);
-void smmu_pci_device_hook(void *, uint32_t, struct pci_attach_args *);
+bus_dma_tag_t smmu_device_map(void *, uint32_t, bus_dma_tag_t);