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