Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _H8300_PAGE_H |
| 2 | #define _H8300_PAGE_H |
| 3 | |
David Woodhouse | 0000f0b | 2006-09-21 08:51:43 +0100 | [diff] [blame] | 4 | #ifdef __KERNEL__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | /* PAGE_SHIFT determines the page size */ |
| 7 | |
| 8 | #define PAGE_SHIFT (12) |
| 9 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
| 10 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/setup.h> |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #ifndef __ASSEMBLY__ |
| 15 | |
| 16 | #define get_user_page(vaddr) __get_free_page(GFP_KERNEL) |
| 17 | #define free_user_page(page, addr) free_page(addr) |
| 18 | |
| 19 | #define clear_page(page) memset((page), 0, PAGE_SIZE) |
| 20 | #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE) |
| 21 | |
| 22 | #define clear_user_page(page, vaddr, pg) clear_page(page) |
| 23 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) |
| 24 | |
Mel Gorman | 769848c | 2007-07-17 04:03:05 -0700 | [diff] [blame] | 25 | #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ |
| 26 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE |
| 28 | |
| 29 | /* |
| 30 | * These are used to make use of C type-checking.. |
| 31 | */ |
| 32 | typedef struct { unsigned long pte; } pte_t; |
| 33 | typedef struct { unsigned long pmd[16]; } pmd_t; |
| 34 | typedef struct { unsigned long pgd; } pgd_t; |
| 35 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 36 | |
| 37 | #define pte_val(x) ((x).pte) |
| 38 | #define pmd_val(x) ((&x)->pmd[0]) |
| 39 | #define pgd_val(x) ((x).pgd) |
| 40 | #define pgprot_val(x) ((x).pgprot) |
| 41 | |
| 42 | #define __pte(x) ((pte_t) { (x) } ) |
| 43 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 44 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 45 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 46 | |
| 47 | /* to align the pointer to the (next) page boundary */ |
| 48 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | extern unsigned long memory_start; |
| 51 | extern unsigned long memory_end; |
| 52 | |
| 53 | #endif /* !__ASSEMBLY__ */ |
| 54 | |
| 55 | #include <asm/page_offset.h> |
| 56 | |
| 57 | #define PAGE_OFFSET (PAGE_OFFSET_RAW) |
| 58 | |
| 59 | #ifndef __ASSEMBLY__ |
| 60 | |
Yoshinori Sato | 74ad74c | 2005-04-16 15:25:21 -0700 | [diff] [blame] | 61 | #define __pa(vaddr) virt_to_phys(vaddr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #define __va(paddr) phys_to_virt((unsigned long)paddr) |
| 63 | |
| 64 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) |
| 65 | #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) |
| 66 | |
| 67 | #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) |
| 68 | #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | #define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) |
Yoshinori Sato | 74ad74c | 2005-04-16 15:25:21 -0700 | [diff] [blame] | 70 | #define pfn_valid(page) (page < max_mapnr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
KAMEZAWA Hiroyuki | dd6cc76 | 2006-03-27 01:15:41 -0800 | [diff] [blame] | 72 | #define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ |
| 75 | ((void *)(kaddr) < (void *)memory_end)) |
| 76 | |
| 77 | #endif /* __ASSEMBLY__ */ |
| 78 | |
KAMEZAWA Hiroyuki | dd6cc76 | 2006-03-27 01:15:41 -0800 | [diff] [blame] | 79 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 80 | #include <asm-generic/page.h> |
| 81 | |
David Woodhouse | 0000f0b | 2006-09-21 08:51:43 +0100 | [diff] [blame] | 82 | #endif /* __KERNEL__ */ |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #endif /* _H8300_PAGE_H */ |