Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/iommu.h
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
* (d) - Protected by domain lock | * (d) - Protected by domain lock | ||||
* (c) - Immutable after initialization | * (c) - Immutable after initialization | ||||
*/ | */ | ||||
struct iommu_domain { | struct iommu_domain { | ||||
struct iommu_unit *iommu; /* (c) */ | struct iommu_unit *iommu; /* (c) */ | ||||
struct mtx lock; /* (c) */ | struct mtx lock; /* (c) */ | ||||
struct task unload_task; /* (c) */ | struct task unload_task; /* (c) */ | ||||
u_int entries_cnt; /* (d) */ | |||||
struct iommu_map_entries_tailq unload_entries; /* (d) Entries to | struct iommu_map_entries_tailq unload_entries; /* (d) Entries to | ||||
unload */ | unload */ | ||||
}; | }; | ||||
struct iommu_ctx { | struct iommu_ctx { | ||||
struct iommu_domain *domain; /* (c) */ | struct iommu_domain *domain; /* (c) */ | ||||
struct bus_dma_tag_iommu *tag; /* (c) Root tag */ | struct bus_dma_tag_iommu *tag; /* (c) Root tag */ | ||||
u_long loads; /* atomic updates, for stat only */ | u_long loads; /* atomic updates, for stat only */ | ||||
Show All 10 Lines | |||||
#define IOMMU_LOCK(unit) mtx_lock(&(unit)->lock) | #define IOMMU_LOCK(unit) mtx_lock(&(unit)->lock) | ||||
#define IOMMU_UNLOCK(unit) mtx_unlock(&(unit)->lock) | #define IOMMU_UNLOCK(unit) mtx_unlock(&(unit)->lock) | ||||
#define IOMMU_ASSERT_LOCKED(unit) mtx_assert(&(unit)->lock, MA_OWNED) | #define IOMMU_ASSERT_LOCKED(unit) mtx_assert(&(unit)->lock, MA_OWNED) | ||||
#define IOMMU_DOMAIN_LOCK(dom) mtx_lock(&(dom)->lock) | #define IOMMU_DOMAIN_LOCK(dom) mtx_lock(&(dom)->lock) | ||||
#define IOMMU_DOMAIN_UNLOCK(dom) mtx_unlock(&(dom)->lock) | #define IOMMU_DOMAIN_UNLOCK(dom) mtx_unlock(&(dom)->lock) | ||||
#define IOMMU_DOMAIN_ASSERT_LOCKED(dom) mtx_assert(&(dom)->lock, MA_OWNED) | #define IOMMU_DOMAIN_ASSERT_LOCKED(dom) mtx_assert(&(dom)->lock, MA_OWNED) | ||||
static inline bool | |||||
iommu_test_boundary(iommu_gaddr_t start, iommu_gaddr_t size, | |||||
iommu_gaddr_t boundary) | |||||
{ | |||||
if (boundary == 0) | |||||
return (true); | |||||
return (start + size <= ((start + boundary) & ~(boundary - 1))); | |||||
} | |||||
void iommu_free_ctx(struct iommu_ctx *ctx); | void iommu_free_ctx(struct iommu_ctx *ctx); | ||||
void iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *ctx); | void iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *ctx); | ||||
struct iommu_ctx *iommu_get_ctx(struct iommu_unit *, device_t dev, | struct iommu_ctx *iommu_get_ctx(struct iommu_unit *, device_t dev, | ||||
uint16_t rid, bool id_mapped, bool rmrr_init); | uint16_t rid, bool id_mapped, bool rmrr_init); | ||||
struct iommu_unit *iommu_find(device_t dev, bool verbose); | struct iommu_unit *iommu_find(device_t dev, bool verbose); | ||||
void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free); | void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free); | ||||
void iommu_domain_unload(struct iommu_domain *domain, | void iommu_domain_unload(struct iommu_domain *domain, | ||||
Show All 17 Lines |