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