xref: /freebsd/sys/arm64/iommu/iommu_pmap.h (revision 95ee2897)
1f17c4e38SRuslan Bukin /*-
2f17c4e38SRuslan Bukin  * SPDX-License-Identifier: BSD-2-Clause
3f17c4e38SRuslan Bukin  *
4f17c4e38SRuslan Bukin  * Copyright (c) 2021 Ruslan Bukin <br@bsdpad.com>
5f17c4e38SRuslan Bukin  *
6f17c4e38SRuslan Bukin  * This work was supported by Innovate UK project 105694, "Digital Security
7f17c4e38SRuslan Bukin  * by Design (DSbD) Technology Platform Prototype".
8f17c4e38SRuslan Bukin  *
9f17c4e38SRuslan Bukin  * Redistribution and use in source and binary forms, with or without
10f17c4e38SRuslan Bukin  * modification, are permitted provided that the following conditions
11f17c4e38SRuslan Bukin  * are met:
12f17c4e38SRuslan Bukin  * 1. Redistributions of source code must retain the above copyright
13f17c4e38SRuslan Bukin  *    notice, this list of conditions and the following disclaimer.
14f17c4e38SRuslan Bukin  * 2. Redistributions in binary form must reproduce the above copyright
15f17c4e38SRuslan Bukin  *    notice, this list of conditions and the following disclaimer in the
16f17c4e38SRuslan Bukin  *    documentation and/or other materials provided with the distribution.
17f17c4e38SRuslan Bukin  *
18f17c4e38SRuslan Bukin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19f17c4e38SRuslan Bukin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20f17c4e38SRuslan Bukin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21f17c4e38SRuslan Bukin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22f17c4e38SRuslan Bukin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23f17c4e38SRuslan Bukin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24f17c4e38SRuslan Bukin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25f17c4e38SRuslan Bukin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26f17c4e38SRuslan Bukin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27f17c4e38SRuslan Bukin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28f17c4e38SRuslan Bukin  * SUCH DAMAGE.
29f17c4e38SRuslan Bukin  */
30f17c4e38SRuslan Bukin 
31f17c4e38SRuslan Bukin #ifndef	_ARM64_IOMMU_IOMMU_PMAP_H_
32f17c4e38SRuslan Bukin #define	_ARM64_IOMMU_IOMMU_PMAP_H_
33f17c4e38SRuslan Bukin 
34b97e94d9SAndrew Turner struct smmu_pmap {
35b97e94d9SAndrew Turner 	struct mtx	sp_mtx;
36b97e94d9SAndrew Turner 	vm_paddr_t	sp_l0_paddr;
37b97e94d9SAndrew Turner 	pd_entry_t	*sp_l0;
38b97e94d9SAndrew Turner #ifdef INVARIANTS
39b97e94d9SAndrew Turner 	long		sp_resident_count;
40b97e94d9SAndrew Turner #endif
41b97e94d9SAndrew Turner };
42b97e94d9SAndrew Turner 
43f17c4e38SRuslan Bukin /* System MMU (SMMU). */
44b97e94d9SAndrew Turner int smmu_pmap_enter(struct smmu_pmap *pmap, vm_offset_t va, vm_paddr_t pa,
45b97e94d9SAndrew Turner     vm_prot_t prot, u_int flags);
46b97e94d9SAndrew Turner int smmu_pmap_remove(struct smmu_pmap *pmap, vm_offset_t va);
47f17c4e38SRuslan Bukin 
48f17c4e38SRuslan Bukin /* Mali GPU */
49b97e94d9SAndrew Turner int pmap_gpu_enter(struct smmu_pmap *pmap, vm_offset_t va, vm_paddr_t pa,
50f17c4e38SRuslan Bukin     vm_prot_t prot, u_int flags);
51b97e94d9SAndrew Turner int pmap_gpu_remove(struct smmu_pmap *pmap, vm_offset_t va);
52f17c4e38SRuslan Bukin 
53f17c4e38SRuslan Bukin /* Common */
54b97e94d9SAndrew Turner void smmu_pmap_remove_pages(struct smmu_pmap *pmap);
55b97e94d9SAndrew Turner void smmu_pmap_release(struct smmu_pmap *pmap);
56b97e94d9SAndrew Turner int smmu_pmap_pinit(struct smmu_pmap *pmap);
57f17c4e38SRuslan Bukin 
58f17c4e38SRuslan Bukin #endif /* !_ARM64_IOMMU_IOMMU_PMAP_H_ */
59