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