Set memory attributes on page
[pscnv.git] / pscnv / pscnv_vm.h
blob39dd82ad0d06262317d068ba26d788825191153c
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2010 PathScale Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef __PSCNV_VM_H__
28 #define __PSCNV_VM_H__
30 struct pscnv_bo;
31 struct pscnv_chan;
33 struct pscnv_vspace {
34 int vid;
35 struct drm_device *dev;
36 struct mutex lock;
37 struct pscnv_mm *mm;
38 struct drm_file *filp;
39 struct kref ref;
40 uint64_t size;
41 uint32_t flags;
42 void *engdata;
45 struct pscnv_vm_engine {
46 void (*takedown) (struct drm_device *dev);
47 int (*do_vspace_new) (struct pscnv_vspace *vs);
48 void (*do_vspace_free) (struct pscnv_vspace *vs);
49 int (*place_map) (struct pscnv_vspace *, struct pscnv_bo *, uint64_t start, uint64_t end, int back, struct pscnv_mm_node **res);
50 int (*do_map) (struct pscnv_vspace *vs, struct pscnv_bo *bo, uint64_t offset);
51 int (*do_unmap) (struct pscnv_vspace *vs, uint64_t offset, uint64_t length);
52 int (*map_user) (struct pscnv_bo *);
53 int (*map_kernel) (struct pscnv_bo *);
54 void (*bar_flush) (struct drm_device *dev);
55 struct pscnv_vspace *fake_vspaces[4];
56 struct pscnv_vspace *vspaces[128];
57 spinlock_t vs_lock;
60 extern struct pscnv_vspace *pscnv_vspace_new(struct drm_device *, uint64_t size, uint32_t flags, int fake);
61 extern int pscnv_vspace_map(struct pscnv_vspace *, struct pscnv_bo *, uint64_t start, uint64_t end, int back, struct pscnv_mm_node **res);
62 extern int pscnv_vspace_unmap(struct pscnv_vspace *, uint64_t start);
63 extern int pscnv_vspace_unmap_node(struct pscnv_mm_node *node);
65 extern void pscnv_vspace_ref_free(struct kref *ref);
67 static inline void pscnv_vspace_ref(struct pscnv_vspace *vs) {
68 kref_get(&vs->ref);
71 static inline void pscnv_vspace_unref(struct pscnv_vspace *vs) {
72 kref_put(&vs->ref, pscnv_vspace_ref_free);
75 extern int pscnv_mmap(struct file *filp, struct vm_area_struct *vma);
78 int nv50_vm_init(struct drm_device *dev);
79 int nvc0_vm_init(struct drm_device *dev);
80 void nv84_vm_bar_flush(struct drm_device *dev);
82 #endif