Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy...
[pandora-kernel.git] / include / asm-cris / page.h
1 #ifndef _CRIS_PAGE_H
2 #define _CRIS_PAGE_H
3
4 #ifdef __KERNEL__
5
6 #include <asm/arch/page.h>
7 #include <linux/const.h>
8
9 /* PAGE_SHIFT determines the page size */
10 #define PAGE_SHIFT      13
11 #define PAGE_SIZE       (_AC(1, UL) << PAGE_SHIFT)
12 #define PAGE_MASK       (~(PAGE_SIZE-1))
13
14 #define clear_page(page)        memset((void *)(page), 0, PAGE_SIZE)
15 #define copy_page(to,from)      memcpy((void *)(to), (void *)(from), PAGE_SIZE)
16
17 #define clear_user_page(page, vaddr, pg)    clear_page(page)
18 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
19
20 #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
21         alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
22 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
23
24 /*
25  * These are used to make use of C type-checking..
26  */
27 #ifndef __ASSEMBLY__
28 typedef struct { unsigned long pte; } pte_t;
29 typedef struct { unsigned long pgd; } pgd_t;
30 typedef struct { unsigned long pgprot; } pgprot_t;
31 #endif
32
33 #define pte_val(x)      ((x).pte)
34 #define pgd_val(x)      ((x).pgd)
35 #define pgprot_val(x)   ((x).pgprot)
36
37 #define __pte(x)        ((pte_t) { (x) } )
38 #define __pgd(x)        ((pgd_t) { (x) } )
39 #define __pgprot(x)     ((pgprot_t) { (x) } )
40
41 /* On CRIS the PFN numbers doesn't start at 0 so we have to compensate */
42 /* for that before indexing into the page table starting at mem_map    */
43 #define ARCH_PFN_OFFSET         (PAGE_OFFSET >> PAGE_SHIFT)
44 #define pfn_valid(pfn)          (((pfn) - (PAGE_OFFSET >> PAGE_SHIFT)) < max_mapnr)
45
46 /* to index into the page map. our pages all start at physical addr PAGE_OFFSET so
47  * we can let the map start there. notice that we subtract PAGE_OFFSET because
48  * we start our mem_map there - in other ports they map mem_map physically and
49  * use __pa instead. in our system both the physical and virtual address of DRAM
50  * is too high to let mem_map start at 0, so we do it this way instead (similar
51  * to arm and m68k I think)
52  */ 
53
54 #define virt_to_page(kaddr)    (mem_map + (((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT))
55 #define VALID_PAGE(page)       (((page) - mem_map) < max_mapnr)
56 #define virt_addr_valid(kaddr)  pfn_valid((unsigned)(kaddr) >> PAGE_SHIFT)
57
58 /* convert a page (based on mem_map and forward) to a physical address
59  * do this by figuring out the virtual address and then use __pa
60  */
61
62 #define page_to_phys(page)     __pa((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
63
64 /* to align the pointer to the (next) page boundary */
65 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
66
67 #ifndef __ASSEMBLY__
68
69 #endif /* __ASSEMBLY__ */
70
71 #define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_EXEC | \
72                                  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
73
74 #include <asm-generic/memory_model.h>
75 #include <asm-generic/page.h>
76
77 #endif /* __KERNEL__ */
78
79 #endif /* _CRIS_PAGE_H */
80