1 #ifndef _ASM_IA64_PAGE_H 2 #define _ASM_IA64_PAGE_H 3 /* 4 * Pagetable related stuff. 5 * 6 * Copyright (C) 1998, 1999 Hewlett-Packard Co 7 * Copyright (C) 1998, 1999 David Mosberger-Tang <davidm@hpl.hp.com> 8 */ 9 10 #include <linux/config.h> 11 12 #include <asm/types.h> 13 14 /* 15 * PAGE_SHIFT determines the actual kernel page size. 16 */ 17 #if defined(CONFIG_IA64_PAGE_SIZE_4KB) 18 # define PAGE_SHIFT 12 19 #elif defined(CONFIG_IA64_PAGE_SIZE_8KB) 20 # define PAGE_SHIFT 13 21 #elif defined(CONFIG_IA64_PAGE_SIZE_16KB) 22 # define PAGE_SHIFT 14 23 #elif defined(CONFIG_IA64_PAGE_SIZE_64KB) 24 # define PAGE_SHIFT 16 25 #else 26 # error Unsupported page size! 27 #endif 28 29 #define PAGE_SIZE (__IA64_UL_CONST(1) << PAGE_SHIFT) 30 #define PAGE_MASK (~(PAGE_SIZE - 1)) 31 #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) 32 33 #ifdef CONFIG_HUGETLB_PAGE 34 #if defined(CONFIG_HUGETLB_PAGE_SIZE_4GB) 35 #define HPAGE_SHIFT 32 36 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1GB) 37 #define HPAGE_SHIFT 30 38 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256MB) 39 #define HPAGE_SHIFT 28 40 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB) 41 #define HPAGE_SHIFT 26 42 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_16MB) 43 #define HPAGE_SHIFT 24 44 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB) 45 #define HPAGE_SHIFT 22 46 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) 47 #define HPAGE_SHIFT 20 48 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_256KB) 49 #define HPAGE_SHIFT 18 50 #else 51 # error Unsupported IA-64 HugeTLB Page Size! 52 #endif 53 54 #define REGION_HPAGE (4UL) 55 #define REGION_SHIFT 61 56 #define HPAGE_SIZE (__IA64_UL_CONST(1) << HPAGE_SHIFT) 57 #define HPAGE_MASK (~(HPAGE_SIZE - 1)) 58 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 59 #endif 60 #define RGN_MAP_LIMIT ((1UL << (4*PAGE_SHIFT - 12)) - PAGE_SIZE) /* per region addr limit */ 61 62 #ifdef __ASSEMBLY__ 63 # define __pa(x) ((x) - PAGE_OFFSET) 64 # define __va(x) ((x) + PAGE_OFFSET) 65 #else /* !__ASSEMBLY */ 66 # ifdef __KERNEL__ 67 # define STRICT_MM_TYPECHECKS 68 69 extern void clear_page (void *page); 70 extern void copy_page (void *to, void *from); 71 72 /* 73 * Note: the MAP_NR_*() macro can't use __pa() because MAP_NR_*(X) MUST 74 * map to something >= max_mapnr if X is outside the identity mapped 75 * kernel space. 76 */ 77 78 /* 79 * The dense variant can be used as long as the size of memory holes isn't 80 * very big. 81 */ 82 #define MAP_NR_DENSE(addr) (((unsigned long) (addr) - PAGE_OFFSET) >> PAGE_SHIFT) 83 84 #define virt_to_page(kaddr) (mem_map + MAP_NR_DENSE(kaddr)) 85 #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT) 86 87 struct page; 88 extern int ia64_page_valid (struct page *); 89 #define VALID_PAGE(page) (((page - mem_map) < max_mapnr) && ia64_page_valid(page)) 90 91 typedef union ia64_va { 92 struct { 93 unsigned long off : 61; /* intra-region offset */ 94 unsigned long reg : 3; /* region number */ 95 } f; 96 unsigned long l; 97 void *p; 98 } ia64_va; 99 100 /* 101 * Note: These macros depend on the fact that PAGE_OFFSET has all 102 * region bits set to 1 and all other bits set to zero. They are 103 * expressed in this way to ensure they result in a single "dep" 104 * instruction. 105 */ 106 #define __pa(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg = 0; _v.l;}) 107 #define __va(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg = -1; _v.p;}) 108 109 #define REGION_NUMBER(x) ({ia64_va _v; _v.l = (long) (x); _v.f.reg;}) 110 #define REGION_OFFSET(x) ({ia64_va _v; _v.l = (long) (x); _v.f.off;}) 111 112 #define REGION_SIZE REGION_NUMBER(1) 113 #define REGION_KERNEL 7 114 115 #ifdef CONFIG_HUGETLB_PAGE 116 #define htlbpage_to_page(x) ((REGION_NUMBER(x) << 61) | (REGION_OFFSET(x) >> (HPAGE_SHIFT-PAGE_SHIFT))) 117 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 118 extern int is_invalid_hugepage_range(unsigned long addr, unsigned long len); 119 #else 120 #define is_invalid_hugepage_range(addr, len) 0 121 #endif 122 123 #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) 124 # define ia64_abort() __builtin_trap() 125 #else 126 # define ia64_abort() (*(volatile int *) 0 = 0) 127 #endif 128 129 #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0) 130 #define PAGE_BUG(page) do { BUG(); } while (0) 131 132 static __inline__ int get_order(unsigned long size)133get_order (unsigned long size) 134 { 135 double d = size - 1; 136 long order; 137 138 __asm__ ("getf.exp %0=%1" : "=r"(order) : "f"(d)); 139 order = order - PAGE_SHIFT - 0xffff + 1; 140 if (order < 0) 141 order = 0; 142 return order; 143 } 144 145 # endif /* __KERNEL__ */ 146 #endif /* !__ASSEMBLY__ */ 147 148 #ifdef STRICT_MM_TYPECHECKS 149 /* 150 * These are used to make use of C type-checking.. 151 */ 152 typedef struct { unsigned long pte; } pte_t; 153 typedef struct { unsigned long pmd; } pmd_t; 154 typedef struct { unsigned long pgd; } pgd_t; 155 typedef struct { unsigned long pgprot; } pgprot_t; 156 157 # define pte_val(x) ((x).pte) 158 # define pmd_val(x) ((x).pmd) 159 # define pgd_val(x) ((x).pgd) 160 # define pgprot_val(x) ((x).pgprot) 161 162 # define __pte(x) ((pte_t) { (x) } ) 163 # define __pgprot(x) ((pgprot_t) { (x) } ) 164 165 #else /* !STRICT_MM_TYPECHECKS */ 166 /* 167 * .. while these make it easier on the compiler 168 */ 169 # ifndef __ASSEMBLY__ 170 typedef unsigned long pte_t; 171 typedef unsigned long pmd_t; 172 typedef unsigned long pgd_t; 173 typedef unsigned long pgprot_t; 174 # endif 175 176 # define pte_val(x) (x) 177 # define pmd_val(x) (x) 178 # define pgd_val(x) (x) 179 # define pgprot_val(x) (x) 180 181 # define __pte(x) (x) 182 # define __pgd(x) (x) 183 # define __pgprot(x) (x) 184 #endif /* !STRICT_MM_TYPECHECKS */ 185 186 #define PAGE_OFFSET 0xe000000000000000 187 188 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ 189 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | \ 190 (((current->thread.flags & IA64_THREAD_XSTACK) != 0) \ 191 ? VM_EXEC : 0)) 192 193 #endif /* _ASM_IA64_PAGE_H */ 194