89c6ce61c7d7d4ebd84a282026baa8af6bc10d40
[openwrt/svn-archive/archive.git] / target / linux / ubicom32 / files / arch / ubicom32 / include / asm / page.h
1 /*
2 * arch/ubicom32/include/asm/page.h
3 * Memory page related operations and definitions.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28 #ifndef _ASM_UBICOM32_PAGE_H
29 #define _ASM_UBICOM32_PAGE_H
30
31 /* PAGE_SHIFT determines the page size */
32
33 #define PAGE_SHIFT 12
34 #define PAGE_SIZE (1 << PAGE_SHIFT)
35 #define PAGE_MASK (~(PAGE_SIZE-1))
36
37 #include <asm/setup.h>
38
39 #ifndef __ASSEMBLY__
40
41 #define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
42 #define free_user_page(page, addr) free_page(addr)
43
44 #define clear_page(page) memset((page), 0, PAGE_SIZE)
45 #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
46
47 #define clear_user_page(page, vaddr, pg) clear_page(page)
48 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
49
50 #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
51 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
52 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
53
54 /*
55 * These are used to make use of C type-checking..
56 */
57 typedef struct { unsigned long pte; } pte_t;
58 typedef struct { unsigned long pmd[16]; } pmd_t;
59 typedef struct { unsigned long pgd; } pgd_t;
60 typedef struct { unsigned long pgprot; } pgprot_t;
61 typedef struct page *pgtable_t;
62
63 #define pte_val(x) ((x).pte)
64 #define pmd_val(x) ((&x)->pmd[0])
65 #define pgd_val(x) ((x).pgd)
66 #define pgprot_val(x) ((x).pgprot)
67
68 #define __pte(x) ((pte_t) { (x) } )
69 #define __pmd(x) ((pmd_t) { (x) } )
70 #define __pgd(x) ((pgd_t) { (x) } )
71 #define __pgprot(x) ((pgprot_t) { (x) } )
72
73 extern unsigned long memory_start;
74 extern unsigned long memory_end;
75
76 #endif /* !__ASSEMBLY__ */
77
78 #include <asm/page_offset.h>
79
80 #define PAGE_OFFSET (PAGE_OFFSET_RAW)
81
82 #ifndef __ASSEMBLY__
83
84 #define __pa(vaddr) virt_to_phys((void *)(vaddr))
85 #define __va(paddr) phys_to_virt((unsigned long)(paddr))
86
87 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
88 #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
89
90 #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
91 #define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
92
93 #define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
94 #define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
95 #define pfn_valid(pfn) ((pfn) < max_mapnr)
96
97 #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
98 ((void *)(kaddr) < (void *)memory_end))
99
100 #endif /* __ASSEMBLY__ */
101
102 #ifdef __KERNEL__
103 #include <asm-generic/page.h>
104 #endif
105
106 #endif /* _ASM_UBICOM32_PAGE_H */