1 /* $NetBSD: mmu.h,v 1.2 2021/12/18 23:45:33 riastradh Exp $ */ 2 3 #ifndef __NVIF_MMU_H__ 4 #define __NVIF_MMU_H__ 5 #include <nvif/object.h> 6 7 struct nvif_mmu { 8 struct nvif_object object; 9 u8 dmabits; 10 u8 heap_nr; 11 u8 type_nr; 12 u8 kind_inv; 13 u16 kind_nr; 14 s32 mem; 15 16 struct { 17 u64 size; 18 } *heap; 19 20 struct { 21 #define NVIF_MEM_VRAM 0x01 22 #define NVIF_MEM_HOST 0x02 23 #define NVIF_MEM_COMP 0x04 24 #define NVIF_MEM_DISP 0x08 25 #define NVIF_MEM_KIND 0x10 26 #define NVIF_MEM_MAPPABLE 0x20 27 #define NVIF_MEM_COHERENT 0x40 28 #define NVIF_MEM_UNCACHED 0x80 29 u8 type; 30 u8 heap; 31 } *type; 32 33 u8 *kind; 34 }; 35 36 int nvif_mmu_init(struct nvif_object *, s32 oclass, struct nvif_mmu *); 37 void nvif_mmu_fini(struct nvif_mmu *); 38 39 static inline bool nvif_mmu_kind_valid(struct nvif_mmu * mmu,u8 kind)40nvif_mmu_kind_valid(struct nvif_mmu *mmu, u8 kind) 41 { 42 if (kind) { 43 if (kind >= mmu->kind_nr || mmu->kind[kind] == mmu->kind_inv) 44 return false; 45 } 46 return true; 47 } 48 49 static inline int nvif_mmu_type(struct nvif_mmu * mmu,u8 mask)50nvif_mmu_type(struct nvif_mmu *mmu, u8 mask) 51 { 52 int i; 53 for (i = 0; i < mmu->type_nr; i++) { 54 if ((mmu->type[i].type & mask) == mask) 55 return i; 56 } 57 return -EINVAL; 58 } 59 #endif 60