Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _H8300_PAGE_H |
| 2 | #define _H8300_PAGE_H |
| 3 | |
| 4 | #include <linux/config.h> |
| 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 | |
| 12 | #ifdef __KERNEL__ |
| 13 | |
| 14 | #include <asm/setup.h> |
| 15 | |
| 16 | #if !defined(CONFIG_SMALL_TASKS) && PAGE_SHIFT < 13 |
| 17 | #define KTHREAD_SIZE (8192) |
| 18 | #else |
| 19 | #define KTHREAD_SIZE PAGE_SIZE |
| 20 | #endif |
| 21 | |
| 22 | #ifndef __ASSEMBLY__ |
| 23 | |
| 24 | #define get_user_page(vaddr) __get_free_page(GFP_KERNEL) |
| 25 | #define free_user_page(page, addr) free_page(addr) |
| 26 | |
| 27 | #define clear_page(page) memset((page), 0, PAGE_SIZE) |
| 28 | #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE) |
| 29 | |
| 30 | #define clear_user_page(page, vaddr, pg) clear_page(page) |
| 31 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) |
| 32 | |
| 33 | #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr) |
| 34 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE |
| 35 | |
| 36 | /* |
| 37 | * These are used to make use of C type-checking.. |
| 38 | */ |
| 39 | typedef struct { unsigned long pte; } pte_t; |
| 40 | typedef struct { unsigned long pmd[16]; } pmd_t; |
| 41 | typedef struct { unsigned long pgd; } pgd_t; |
| 42 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 43 | |
| 44 | #define pte_val(x) ((x).pte) |
| 45 | #define pmd_val(x) ((&x)->pmd[0]) |
| 46 | #define pgd_val(x) ((x).pgd) |
| 47 | #define pgprot_val(x) ((x).pgprot) |
| 48 | |
| 49 | #define __pte(x) ((pte_t) { (x) } ) |
| 50 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 51 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 52 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 53 | |
| 54 | /* to align the pointer to the (next) page boundary */ |
| 55 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 56 | |
| 57 | /* Pure 2^n version of get_order */ |
| 58 | extern __inline__ int get_order(unsigned long size) |
| 59 | { |
| 60 | int order; |
| 61 | |
| 62 | size = (size-1) >> (PAGE_SHIFT-1); |
| 63 | order = -1; |
| 64 | do { |
| 65 | size >>= 1; |
| 66 | order++; |
| 67 | } while (size); |
| 68 | return order; |
| 69 | } |
| 70 | |
| 71 | extern unsigned long memory_start; |
| 72 | extern unsigned long memory_end; |
| 73 | |
| 74 | #endif /* !__ASSEMBLY__ */ |
| 75 | |
| 76 | #include <asm/page_offset.h> |
| 77 | |
| 78 | #define PAGE_OFFSET (PAGE_OFFSET_RAW) |
| 79 | |
| 80 | #ifndef __ASSEMBLY__ |
| 81 | |
Yoshinori Sato | 74ad74c | 2005-04-16 15:25:21 -0700 | [diff] [blame] | 82 | #define __pa(vaddr) virt_to_phys(vaddr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define __va(paddr) phys_to_virt((unsigned long)paddr) |
| 84 | |
| 85 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) |
| 86 | #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) |
| 87 | |
| 88 | #define MAP_NR(addr) (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT) |
| 89 | #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) |
| 90 | #define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) |
| 91 | #define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) |
Yoshinori Sato | 74ad74c | 2005-04-16 15:25:21 -0700 | [diff] [blame] | 92 | #define pfn_valid(page) (page < max_mapnr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | #define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn)) |
| 95 | #define page_to_pfn(page) virt_to_pfn(page_to_virt(page)) |
| 96 | |
| 97 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ |
| 98 | ((void *)(kaddr) < (void *)memory_end)) |
| 99 | |
| 100 | #endif /* __ASSEMBLY__ */ |
| 101 | |
| 102 | #endif /* __KERNEL__ */ |
| 103 | |
| 104 | #endif /* _H8300_PAGE_H */ |