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