Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: page.h,v 1.39 2002/02/09 19:49:31 davem Exp $ */ |
| 2 | |
| 3 | #ifndef _SPARC64_PAGE_H |
| 4 | #define _SPARC64_PAGE_H |
| 5 | |
| 6 | #include <linux/config.h> |
| 7 | #include <asm/const.h> |
| 8 | |
| 9 | #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB) |
| 10 | #define PAGE_SHIFT 13 |
| 11 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB) |
| 12 | #define PAGE_SHIFT 16 |
| 13 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB) |
| 14 | #define PAGE_SHIFT 19 |
| 15 | #elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB) |
| 16 | #define PAGE_SHIFT 22 |
| 17 | #else |
| 18 | #error No page size specified in kernel configuration |
| 19 | #endif |
| 20 | |
| 21 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) |
| 22 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 23 | |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 24 | /* Flushing for D-cache alias handling is only needed if |
| 25 | * the page size is smaller than 16K. |
| 26 | */ |
| 27 | #if PAGE_SHIFT < 14 |
| 28 | #define DCACHE_ALIASING_POSSIBLE |
| 29 | #endif |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #ifdef __KERNEL__ |
| 32 | |
David S. Miller | dcc1e8d | 2006-03-22 00:49:59 -0800 | [diff] [blame] | 33 | #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB) |
| 34 | #define HPAGE_SHIFT 22 |
| 35 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K) |
| 36 | #define HPAGE_SHIFT 19 |
| 37 | #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K) |
| 38 | #define HPAGE_SHIFT 16 |
| 39 | #endif |
| 40 | |
| 41 | #ifdef CONFIG_HUGETLB_PAGE |
| 42 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) |
| 43 | #define HPAGE_MASK (~(HPAGE_SIZE - 1UL)) |
| 44 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
| 45 | #define ARCH_HAS_SETCLEAR_HUGE_PTE |
| 46 | #define ARCH_HAS_HUGETLB_PREFAULT_HOOK |
| 47 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA |
| 48 | #endif |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #ifndef __ASSEMBLY__ |
| 51 | |
| 52 | extern void _clear_page(void *page); |
| 53 | #define clear_page(X) _clear_page((void *)(X)) |
| 54 | struct page; |
| 55 | extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page); |
| 56 | #define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE) |
| 57 | extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage); |
| 58 | |
| 59 | /* Unlike sparc32, sparc64's parameter passing API is more |
| 60 | * sane in that structures which as small enough are passed |
| 61 | * in registers instead of on the stack. Thus, setting |
| 62 | * STRICT_MM_TYPECHECKS does not generate worse code so |
| 63 | * let's enable it to get the type checking. |
| 64 | */ |
| 65 | |
| 66 | #define STRICT_MM_TYPECHECKS |
| 67 | |
| 68 | #ifdef STRICT_MM_TYPECHECKS |
| 69 | /* These are used to make use of C type-checking.. */ |
| 70 | typedef struct { unsigned long pte; } pte_t; |
| 71 | typedef struct { unsigned long iopte; } iopte_t; |
| 72 | typedef struct { unsigned int pmd; } pmd_t; |
| 73 | typedef struct { unsigned int pgd; } pgd_t; |
| 74 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 75 | |
| 76 | #define pte_val(x) ((x).pte) |
| 77 | #define iopte_val(x) ((x).iopte) |
| 78 | #define pmd_val(x) ((x).pmd) |
| 79 | #define pgd_val(x) ((x).pgd) |
| 80 | #define pgprot_val(x) ((x).pgprot) |
| 81 | |
| 82 | #define __pte(x) ((pte_t) { (x) } ) |
| 83 | #define __iopte(x) ((iopte_t) { (x) } ) |
| 84 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 85 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 86 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 87 | |
| 88 | #else |
| 89 | /* .. while these make it easier on the compiler */ |
| 90 | typedef unsigned long pte_t; |
| 91 | typedef unsigned long iopte_t; |
| 92 | typedef unsigned int pmd_t; |
| 93 | typedef unsigned int pgd_t; |
| 94 | typedef unsigned long pgprot_t; |
| 95 | |
| 96 | #define pte_val(x) (x) |
| 97 | #define iopte_val(x) (x) |
| 98 | #define pmd_val(x) (x) |
| 99 | #define pgd_val(x) (x) |
| 100 | #define pgprot_val(x) (x) |
| 101 | |
| 102 | #define __pte(x) (x) |
| 103 | #define __iopte(x) (x) |
| 104 | #define __pmd(x) (x) |
| 105 | #define __pgd(x) (x) |
| 106 | #define __pgprot(x) (x) |
| 107 | |
| 108 | #endif /* (STRICT_MM_TYPECHECKS) */ |
| 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \ |
David S. Miller | 8bcd174 | 2006-03-02 18:12:27 -0800 | [diff] [blame] | 111 | (_AC(0x0000000070000000,UL)) : \ |
| 112 | (_AC(0xfffff80000000000,UL) + (1UL << 32UL))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | #endif /* !(__ASSEMBLY__) */ |
| 115 | |
| 116 | /* to align the pointer to the (next) page boundary */ |
| 117 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 118 | |
| 119 | /* We used to stick this into a hard-coded global register (%g4) |
| 120 | * but that does not make sense anymore. |
| 121 | */ |
| 122 | #define PAGE_OFFSET _AC(0xFFFFF80000000000,UL) |
| 123 | |
| 124 | #ifndef __ASSEMBLY__ |
| 125 | |
| 126 | #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) |
| 127 | #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET)) |
| 128 | |
David S. Miller | d111201 | 2006-03-08 02:16:07 -0800 | [diff] [blame] | 129 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
| 131 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT) |
| 132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 134 | |
| 135 | #define virt_to_phys __pa |
| 136 | #define phys_to_virt __va |
| 137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | #endif /* !(__ASSEMBLY__) */ |
| 139 | |
| 140 | #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ |
| 141 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 142 | |
| 143 | #endif /* !(__KERNEL__) */ |
| 144 | |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 145 | #include <asm-generic/page.h> |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | #endif /* !(_SPARC64_PAGE_H) */ |