Get rid of all ugly PTE hacks.
[profile/ivi/libdrm.git] / linux-core / drm_compat.c
1 /**************************************************************************
2  * 
3  * This kernel module is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public License as
5  * published by the Free Software Foundation; either version 2 of the
6  * License, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  * 
17  **************************************************************************/
18 /*
19  * This code provides access to unexported mm kernel features. It is necessary
20  * to use the new DRM memory manager code with kernels that don't support it
21  * directly.
22  *
23  * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
24  *          Linux kernel mm subsystem authors. 
25  *          (Most code taken from there).
26  */
27
28 #include "drmP.h"
29
30 #if defined(CONFIG_X86) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15))
31 int drm_map_page_into_agp(struct page *page)
32 {
33         int i;
34         i = change_page_attr(page, 1, PAGE_KERNEL_NOCACHE);
35         /* Caller's responsibility to call global_flush_tlb() for
36          * performance reasons */
37         return i;
38 }
39
40 int drm_unmap_page_from_agp(struct page *page)
41 {
42         int i;
43         i = change_page_attr(page, 1, PAGE_KERNEL);
44         /* Caller's responsibility to call global_flush_tlb() for
45          * performance reasons */
46         return i;
47 }
48 #endif
49
50
51 pgprot_t vm_get_page_prot(unsigned long vm_flags)
52 {
53 #ifdef MODULE
54         static pgprot_t drm_protection_map[16] = {
55                 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
56                 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
57         };
58
59         return drm_protection_map[vm_flags & 0x0F];
60 #else
61         extern pgprot_t protection_map[];
62         return protection_map[vm_flags & 0x0F];
63 #endif
64 };