2 * Copyright 2010 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef __NOUVEAU_VM_H__
26 #define __NOUVEAU_VM_H__
30 #include "nouveau_drv.h"
31 #include "nouveau_mm.h"
33 struct nouveau_vm_pgt
{
34 struct nouveau_gpuobj
*obj
[2];
38 struct nouveau_vm_pgd
{
39 struct list_head head
;
40 struct nouveau_gpuobj
*obj
;
44 struct nouveau_vm
*vm
;
45 struct nouveau_mm_node
*node
;
51 struct drm_device
*dev
;
52 struct nouveau_mm
*mm
;
55 struct list_head pgd_list
;
59 struct nouveau_vm_pgt
*pgt
;
67 void (*map_pgt
)(struct nouveau_gpuobj
*pgd
, u32 pde
,
68 struct nouveau_gpuobj
*pgt
[2]);
69 void (*map
)(struct nouveau_vma
*, struct nouveau_gpuobj
*,
70 struct nouveau_mem
*, u32 pte
, u32 cnt
,
72 void (*map_sg
)(struct nouveau_vma
*, struct nouveau_gpuobj
*,
73 struct nouveau_mem
*, u32 pte
, u32 cnt
, dma_addr_t
*);
74 void (*unmap
)(struct nouveau_gpuobj
*pgt
, u32 pte
, u32 cnt
);
75 void (*flush
)(struct nouveau_vm
*);
79 int nouveau_vm_new(struct drm_device
*, u64 offset
, u64 length
, u64 mm_offset
,
80 struct nouveau_vm
**);
81 int nouveau_vm_ref(struct nouveau_vm
*, struct nouveau_vm
**,
82 struct nouveau_gpuobj
*pgd
);
83 int nouveau_vm_get(struct nouveau_vm
*, u64 size
, u32 page_shift
,
84 u32 access
, struct nouveau_vma
*);
85 void nouveau_vm_put(struct nouveau_vma
*);
86 void nouveau_vm_map(struct nouveau_vma
*, struct nouveau_mem
*);
87 void nouveau_vm_map_at(struct nouveau_vma
*, u64 offset
, struct nouveau_mem
*);
88 void nouveau_vm_unmap(struct nouveau_vma
*);
89 void nouveau_vm_unmap_at(struct nouveau_vma
*, u64 offset
, u64 length
);
90 void nouveau_vm_map_sg(struct nouveau_vma
*, u64 offset
, u64 length
,
91 struct nouveau_mem
*, dma_addr_t
*);
94 void nv50_vm_map_pgt(struct nouveau_gpuobj
*pgd
, u32 pde
,
95 struct nouveau_gpuobj
*pgt
[2]);
96 void nv50_vm_map(struct nouveau_vma
*, struct nouveau_gpuobj
*,
97 struct nouveau_mem
*, u32 pte
, u32 cnt
, u64 phys
, u64 delta
);
98 void nv50_vm_map_sg(struct nouveau_vma
*, struct nouveau_gpuobj
*,
99 struct nouveau_mem
*, u32 pte
, u32 cnt
, dma_addr_t
*);
100 void nv50_vm_unmap(struct nouveau_gpuobj
*, u32 pte
, u32 cnt
);
101 void nv50_vm_flush(struct nouveau_vm
*);
102 void nv50_vm_flush_engine(struct drm_device
*, int engine
);
105 void nvc0_vm_map_pgt(struct nouveau_gpuobj
*pgd
, u32 pde
,
106 struct nouveau_gpuobj
*pgt
[2]);
107 void nvc0_vm_map(struct nouveau_vma
*, struct nouveau_gpuobj
*,
108 struct nouveau_mem
*, u32 pte
, u32 cnt
, u64 phys
, u64 delta
);
109 void nvc0_vm_map_sg(struct nouveau_vma
*, struct nouveau_gpuobj
*,
110 struct nouveau_mem
*, u32 pte
, u32 cnt
, dma_addr_t
*);
111 void nvc0_vm_unmap(struct nouveau_gpuobj
*, u32 pte
, u32 cnt
);
112 void nvc0_vm_flush(struct nouveau_vm
*);