162306a36Sopenharmony_ci#ifndef __NVIF_VMM_H__
262306a36Sopenharmony_ci#define __NVIF_VMM_H__
362306a36Sopenharmony_ci#include <nvif/object.h>
462306a36Sopenharmony_cistruct nvif_mem;
562306a36Sopenharmony_cistruct nvif_mmu;
662306a36Sopenharmony_ci
762306a36Sopenharmony_cienum nvif_vmm_type {
862306a36Sopenharmony_ci	UNMANAGED,
962306a36Sopenharmony_ci	MANAGED,
1062306a36Sopenharmony_ci	RAW,
1162306a36Sopenharmony_ci};
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cienum nvif_vmm_get {
1462306a36Sopenharmony_ci	ADDR,
1562306a36Sopenharmony_ci	PTES,
1662306a36Sopenharmony_ci	LAZY
1762306a36Sopenharmony_ci};
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_cistruct nvif_vma {
2062306a36Sopenharmony_ci	u64 addr;
2162306a36Sopenharmony_ci	u64 size;
2262306a36Sopenharmony_ci};
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistruct nvif_vmm {
2562306a36Sopenharmony_ci	struct nvif_object object;
2662306a36Sopenharmony_ci	u64 start;
2762306a36Sopenharmony_ci	u64 limit;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	struct {
3062306a36Sopenharmony_ci		u8 shift;
3162306a36Sopenharmony_ci		bool sparse:1;
3262306a36Sopenharmony_ci		bool vram:1;
3362306a36Sopenharmony_ci		bool host:1;
3462306a36Sopenharmony_ci		bool comp:1;
3562306a36Sopenharmony_ci	} *page;
3662306a36Sopenharmony_ci	int page_nr;
3762306a36Sopenharmony_ci};
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciint nvif_vmm_ctor(struct nvif_mmu *, const char *name, s32 oclass,
4062306a36Sopenharmony_ci		  enum nvif_vmm_type, u64 addr, u64 size, void *argv, u32 argc,
4162306a36Sopenharmony_ci		  struct nvif_vmm *);
4262306a36Sopenharmony_civoid nvif_vmm_dtor(struct nvif_vmm *);
4362306a36Sopenharmony_ciint nvif_vmm_get(struct nvif_vmm *, enum nvif_vmm_get, bool sparse,
4462306a36Sopenharmony_ci		 u8 page, u8 align, u64 size, struct nvif_vma *);
4562306a36Sopenharmony_civoid nvif_vmm_put(struct nvif_vmm *, struct nvif_vma *);
4662306a36Sopenharmony_ciint nvif_vmm_map(struct nvif_vmm *, u64 addr, u64 size, void *argv, u32 argc,
4762306a36Sopenharmony_ci		 struct nvif_mem *, u64 offset);
4862306a36Sopenharmony_ciint nvif_vmm_unmap(struct nvif_vmm *, u64);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciint nvif_vmm_raw_get(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift);
5162306a36Sopenharmony_ciint nvif_vmm_raw_put(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift);
5262306a36Sopenharmony_ciint nvif_vmm_raw_map(struct nvif_vmm *vmm, u64 addr, u64 size, u8 shift,
5362306a36Sopenharmony_ci		     void *argv, u32 argc, struct nvif_mem *mem, u64 offset);
5462306a36Sopenharmony_ciint nvif_vmm_raw_unmap(struct nvif_vmm *vmm, u64 addr, u64 size,
5562306a36Sopenharmony_ci		       u8 shift, bool sparse);
5662306a36Sopenharmony_ciint nvif_vmm_raw_sparse(struct nvif_vmm *vmm, u64 addr, u64 size, bool ref);
5762306a36Sopenharmony_ci#endif
58