Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arc / include / asm / page.h
1 /*
2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8 #ifndef __ASM_ARC_PAGE_H
9 #define __ASM_ARC_PAGE_H
10
11 #include <uapi/asm/page.h>
12
13
14 #ifndef __ASSEMBLY__
15
16 #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
17 #define free_user_page(page, addr) free_page(addr)
18
19 #define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
20 #define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
21
22 #ifndef CONFIG_ARC_CACHE_VIPT_ALIASING
23
24 #define clear_user_page(addr, vaddr, pg) clear_page(addr)
25 #define copy_user_page(vto, vfrom, vaddr, pg) copy_page(vto, vfrom)
26
27 #else /* VIPT aliasing dcache */
28
29 struct vm_area_struct;
30 struct page;
31
32 #define __HAVE_ARCH_COPY_USER_HIGHPAGE
33
34 void copy_user_highpage(struct page *to, struct page *from,
35 unsigned long u_vaddr, struct vm_area_struct *vma);
36 void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
37
38 #endif /* CONFIG_ARC_CACHE_VIPT_ALIASING */
39
40 #undef STRICT_MM_TYPECHECKS
41
42 #ifdef STRICT_MM_TYPECHECKS
43 /*
44 * These are used to make use of C type-checking..
45 */
46 typedef struct {
47 unsigned long pte;
48 } pte_t;
49 typedef struct {
50 unsigned long pgd;
51 } pgd_t;
52 typedef struct {
53 unsigned long pgprot;
54 } pgprot_t;
55 typedef unsigned long pgtable_t;
56
57 #define pte_val(x) ((x).pte)
58 #define pgd_val(x) ((x).pgd)
59 #define pgprot_val(x) ((x).pgprot)
60
61 #define __pte(x) ((pte_t) { (x) })
62 #define __pgd(x) ((pgd_t) { (x) })
63 #define __pgprot(x) ((pgprot_t) { (x) })
64
65 #define pte_pgprot(x) __pgprot(pte_val(x))
66
67 #else /* !STRICT_MM_TYPECHECKS */
68
69 typedef unsigned long pte_t;
70 typedef unsigned long pgd_t;
71 typedef unsigned long pgprot_t;
72 typedef unsigned long pgtable_t;
73
74 #define pte_val(x) (x)
75 #define pgd_val(x) (x)
76 #define pgprot_val(x) (x)
77 #define __pte(x) (x)
78 #define __pgprot(x) (x)
79 #define pte_pgprot(x) (x)
80
81 #endif
82
83 #define ARCH_PFN_OFFSET (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT)
84
85 #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
86
87 /*
88 * __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
89 *
90 * These macros have historically been misnamed
91 * virt here means link-address/program-address as embedded in object code.
92 * So if kernel img is linked at 0x8000_0000 onwards, 0x8010_0000 will be
93 * 128th page, and virt_to_page( ) will return the struct page corresp to it.
94 * mem_map[ ] is an array of struct page for each page frame in the system
95 *
96 * Independent of where linux is linked at, link-addr = physical address
97 * So the old macro __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE
98 * would have been wrong in case kernel is not at 0x8zs
99 */
100 #define __pa(vaddr) ((unsigned long)vaddr)
101 #define __va(paddr) ((void *)((unsigned long)(paddr)))
102
103 #define virt_to_page(kaddr) \
104 (mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT))
105
106 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
107
108 /* Default Permissions for page, used in mmap.c */
109 #ifdef CONFIG_ARC_STACK_NONEXEC
110 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE)
111 #else
112 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
113 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
114 #endif
115
116 #define WANT_PAGE_VIRTUAL 1
117
118 #include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
119 #include <asm-generic/getorder.h>
120
121 #endif /* !__ASSEMBLY__ */
122
123 #endif