root/include/asm-alpha/pgtable.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. mk_pte
  2. pte_modify
  3. pmd_set
  4. pgd_set
  5. pte_page
  6. pmd_page
  7. pgd_page
  8. pte_none
  9. pte_present
  10. pte_inuse
  11. pte_clear
  12. pte_reuse
  13. pmd_none
  14. pmd_bad
  15. pmd_present
  16. pmd_inuse
  17. pmd_clear
  18. pmd_reuse
  19. pgd_none
  20. pgd_bad
  21. pgd_present
  22. pgd_inuse
  23. pgd_clear
  24. pte_read
  25. pte_write
  26. pte_exec
  27. pte_dirty
  28. pte_young
  29. pte_cow
  30. pte_wrprotect
  31. pte_rdprotect
  32. pte_exprotect
  33. pte_mkclean
  34. pte_mkold
  35. pte_uncow
  36. pte_mkwrite
  37. pte_mkread
  38. pte_mkexec
  39. pte_mkdirty
  40. pte_mkyoung
  41. pte_mkcow
  42. SET_PAGE_DIR
  43. pgd_offset
  44. pmd_offset
  45. pte_offset
  46. pte_free_kernel
  47. pte_alloc_kernel
  48. pmd_free_kernel
  49. pmd_alloc_kernel
  50. pte_free
  51. pte_alloc
  52. pmd_free
  53. pmd_alloc
  54. pgd_free
  55. pgd_alloc
  56. update_mmu_cache
  57. mk_swap_pte

   1 #ifndef _ALPHA_PGTABLE_H
   2 #define _ALPHA_PGTABLE_H
   3 
   4 /*
   5  * This file contains the functions and defines necessary to modify and use
   6  * the alpha page table tree.
   7  *
   8  * This hopefully works with any standard alpha page-size, as defined
   9  * in <asm/page.h> (currently 8192).
  10  */
  11 
  12 /* PMD_SHIFT determines the size of the area a second-level page table can map */
  13 #define PMD_SHIFT       (PAGE_SHIFT + (PAGE_SHIFT-3))
  14 #define PMD_SIZE        (1UL << PMD_SHIFT)
  15 #define PMD_MASK        (~(PMD_SIZE-1))
  16 
  17 /* PGDIR_SHIFT determines what a third-level page table entry can map */
  18 #define PGDIR_SHIFT     (PAGE_SHIFT + 2*(PAGE_SHIFT-3))
  19 #define PGDIR_SIZE      (1UL << PGDIR_SHIFT)
  20 #define PGDIR_MASK      (~(PGDIR_SIZE-1))
  21 
  22 /*
  23  * entries per page directory level: the alpha is three-level, with
  24  * all levels having a one-page page table.
  25  *
  26  * The PGD is special: the last entry is reserved for self-mapping.
  27  */
  28 #define PTRS_PER_PTE    (1UL << (PAGE_SHIFT-3))
  29 #define PTRS_PER_PMD    (1UL << (PAGE_SHIFT-3))
  30 #define PTRS_PER_PGD    ((1UL << (PAGE_SHIFT-3))-1)
  31 
  32 /* the no. of pointers that fit on a page: this will go away */
  33 #define PTRS_PER_PAGE   (1UL << (PAGE_SHIFT-3))
  34 
  35 #define VMALLOC_START           0xFFFFFE0000000000
  36 #define VMALLOC_VMADDR(x)       ((unsigned long)(x))
  37 
  38 /*
  39  * OSF/1 PAL-code-imposed page table bits
  40  */
  41 #define _PAGE_VALID     0x0001
  42 #define _PAGE_FOR       0x0002  /* used for page protection (fault on read) */
  43 #define _PAGE_FOW       0x0004  /* used for page protection (fault on write) */
  44 #define _PAGE_FOE       0x0008  /* used for page protection (fault on exec) */
  45 #define _PAGE_ASM       0x0010
  46 #define _PAGE_KRE       0x0100  /* xxx - see below on the "accessed" bit */
  47 #define _PAGE_URE       0x0200  /* xxx */
  48 #define _PAGE_KWE       0x1000  /* used to do the dirty bit in software */
  49 #define _PAGE_UWE       0x2000  /* used to do the dirty bit in software */
  50 
  51 /* .. and these are ours ... */
  52 #define _PAGE_COW       0x10000
  53 #define _PAGE_DIRTY     0x20000
  54 #define _PAGE_ACCESSED  0x40000
  55 
  56 /*
  57  * NOTE! The "accessed" bit isn't necessarily exact: it can be kept exactly
  58  * by software (use the KRE/URE/KWE/UWE bits appropriately), but I'll fake it.
  59  * Under Linux/AXP, the "accessed" bit just means "read", and I'll just use
  60  * the KRE/URE bits to watch for it. That way we don't need to overload the
  61  * KWE/UWE bits with both handling dirty and accessed.
  62  *
  63  * Note that the kernel uses the accessed bit just to check whether to page
  64  * out a page or not, so it doesn't have to be exact anyway.
  65  */
  66 
  67 #define __DIRTY_BITS    (_PAGE_DIRTY | _PAGE_KWE | _PAGE_UWE)
  68 #define __ACCESS_BITS   (_PAGE_ACCESSED | _PAGE_KRE | _PAGE_URE)
  69 
  70 #define _PFN_MASK       0xFFFFFFFF00000000
  71 
  72 #define _PAGE_TABLE     (_PAGE_VALID | __DIRTY_BITS | __ACCESS_BITS)
  73 #define _PAGE_CHG_MASK  (_PFN_MASK | __DIRTY_BITS | __ACCESS_BITS)
  74 
  75 /*
  76  * All the normal masks have the "page accessed" bits on, as any time they are used,
  77  * the page is accessed. They are cleared only by the page-out routines
  78  */
  79 #define PAGE_NONE       __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
  80 #define PAGE_SHARED     __pgprot(_PAGE_VALID | __ACCESS_BITS)
  81 #define PAGE_COPY       __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_COW)
  82 #define PAGE_READONLY   __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
  83 #define PAGE_KERNEL     __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
  84 
  85 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
  86 
  87 #define _PAGE_P(x) _PAGE_NORMAL((x) | (((x) & _PAGE_FOW)?0:(_PAGE_FOW | _PAGE_COW)))
  88 #define _PAGE_S(x) _PAGE_NORMAL(x)
  89 
  90 /*
  91  * The hardware can handle write-only mappings, but as the alpha
  92  * architecture does byte-wide writes with a read-modify-write
  93  * sequence, it's not practical to have write-without-read privs.
  94  * Thus the "-w- -> rw-" and "-wx -> rwx" mapping here (and in
  95  * arch/alpha/mm/fault.c)
  96  */
  97         /* xwr */
  98 #define __P000  _PAGE_P(_PAGE_FOE | _PAGE_FOW | _PAGE_FOR)
  99 #define __P001  _PAGE_P(_PAGE_FOE | _PAGE_FOW)
 100 #define __P010  _PAGE_P(_PAGE_FOE)
 101 #define __P011  _PAGE_P(_PAGE_FOE)
 102 #define __P100  _PAGE_P(_PAGE_FOW | _PAGE_FOR)
 103 #define __P101  _PAGE_P(_PAGE_FOW)
 104 #define __P110  _PAGE_P(0)
 105 #define __P111  _PAGE_P(0)
 106 
 107 #define __S000  _PAGE_S(_PAGE_FOE | _PAGE_FOW | _PAGE_FOR)
 108 #define __S001  _PAGE_S(_PAGE_FOE | _PAGE_FOW)
 109 #define __S010  _PAGE_S(_PAGE_FOE)
 110 #define __S011  _PAGE_S(_PAGE_FOE)
 111 #define __S100  _PAGE_S(_PAGE_FOW | _PAGE_FOR)
 112 #define __S101  _PAGE_S(_PAGE_FOW)
 113 #define __S110  _PAGE_S(0)
 114 #define __S111  _PAGE_S(0)
 115 
 116 /*
 117  * BAD_PAGETABLE is used when we need a bogus page-table, while
 118  * BAD_PAGE is used for a bogus page.
 119  *
 120  * ZERO_PAGE is a global shared page that is always zero: used
 121  * for zero-mapped memory areas etc..
 122  */
 123 extern pte_t __bad_page(void);
 124 extern pmd_t * __bad_pagetable(void);
 125 
 126 extern unsigned long __zero_page(void);
 127 
 128 #define BAD_PAGETABLE __bad_pagetable()
 129 #define BAD_PAGE __bad_page()
 130 #define ZERO_PAGE __zero_page()
 131 
 132 /* number of bits that fit into a memory pointer */
 133 #define BITS_PER_PTR                    (8*sizeof(unsigned long))
 134 
 135 /* to align the pointer to a pointer address */
 136 #define PTR_MASK                        (~(sizeof(void*)-1))
 137 
 138 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
 139 #define SIZEOF_PTR_LOG2                 3
 140 
 141 /* to find an entry in a page-table */
 142 #define PAGE_PTR(address)               \
 143   ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
 144 
 145 extern unsigned long high_memory;
 146 
 147 /*
 148  * Conversion functions: convert a page and protection to a page entry,
 149  * and a page entry and page directory to the page they refer to.
 150  */
 151 extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 152 { pte_t pte; pte_val(pte) = ((page-PAGE_OFFSET) << (32-PAGE_SHIFT)) | pgprot_val(pgprot); return pte; }
 153 
 154 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 155 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
 156 
 157 extern inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
     /* [previous][next][first][last][top][bottom][index][help] */
 158 { pmd_val(*pmdp) = _PAGE_TABLE | ((((unsigned long) ptep) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
 159 
 160 extern inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
     /* [previous][next][first][last][top][bottom][index][help] */
 161 { pgd_val(*pgdp) = _PAGE_TABLE | ((((unsigned long) pmdp) - PAGE_OFFSET) << (32-PAGE_SHIFT)); }
 162 
 163 extern inline unsigned long pte_page(pte_t pte)
     /* [previous][next][first][last][top][bottom][index][help] */
 164 { return PAGE_OFFSET + ((pte_val(pte) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
 165 
 166 extern inline unsigned long pmd_page(pmd_t pmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 167 { return PAGE_OFFSET + ((pmd_val(pmd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
 168 
 169 extern inline unsigned long pgd_page(pgd_t pgd)
     /* [previous][next][first][last][top][bottom][index][help] */
 170 { return PAGE_OFFSET + ((pgd_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT)); }
 171 
 172 extern inline int pte_none(pte_t pte)           { return !pte_val(pte); }
     /* [previous][next][first][last][top][bottom][index][help] */
 173 extern inline int pte_present(pte_t pte)        { return pte_val(pte) & _PAGE_VALID; }
     /* [previous][next][first][last][top][bottom][index][help] */
 174 extern inline int pte_inuse(pte_t *ptep)        { return mem_map[MAP_NR(ptep)].reserved || mem_map[MAP_NR(ptep)].count != 1; }
     /* [previous][next][first][last][top][bottom][index][help] */
 175 extern inline void pte_clear(pte_t *ptep)       { pte_val(*ptep) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 176 extern inline void pte_reuse(pte_t * ptep)
     /* [previous][next][first][last][top][bottom][index][help] */
 177 {
 178         if (!mem_map[MAP_NR(ptep)].reserved)
 179                 mem_map[MAP_NR(ptep)].count++;
 180 }
 181 
 182 extern inline int pmd_none(pmd_t pmd)           { return !pmd_val(pmd); }
     /* [previous][next][first][last][top][bottom][index][help] */
 183 extern inline int pmd_bad(pmd_t pmd)            { return (pmd_val(pmd) & ~_PFN_MASK) != _PAGE_TABLE || pmd_page(pmd) > high_memory; }
     /* [previous][next][first][last][top][bottom][index][help] */
 184 extern inline int pmd_present(pmd_t pmd)        { return pmd_val(pmd) & _PAGE_VALID; }
     /* [previous][next][first][last][top][bottom][index][help] */
 185 extern inline int pmd_inuse(pmd_t *pmdp)        { return mem_map[MAP_NR(pmdp)].reserved || mem_map[MAP_NR(pmdp)].count != 1; }
     /* [previous][next][first][last][top][bottom][index][help] */
 186 extern inline void pmd_clear(pmd_t * pmdp)      { pmd_val(*pmdp) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 187 extern inline void pmd_reuse(pmd_t * pmdp)
     /* [previous][next][first][last][top][bottom][index][help] */
 188 {
 189         if (!mem_map[MAP_NR(pmdp)].reserved)
 190                 mem_map[MAP_NR(pmdp)].count++;
 191 }
 192 
 193 extern inline int pgd_none(pgd_t pgd)           { return !pgd_val(pgd); }
     /* [previous][next][first][last][top][bottom][index][help] */
 194 extern inline int pgd_bad(pgd_t pgd)            { return (pgd_val(pgd) & ~_PFN_MASK) != _PAGE_TABLE || pgd_page(pgd) > high_memory; }
     /* [previous][next][first][last][top][bottom][index][help] */
 195 extern inline int pgd_present(pgd_t pgd)        { return pgd_val(pgd) & _PAGE_VALID; }
     /* [previous][next][first][last][top][bottom][index][help] */
 196 extern inline int pgd_inuse(pgd_t *pgdp)        { return mem_map[MAP_NR(pgdp)].reserved; }
     /* [previous][next][first][last][top][bottom][index][help] */
 197 extern inline void pgd_clear(pgd_t * pgdp)      { pgd_val(*pgdp) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 198 
 199 /*
 200  * The following only work if pte_present() is true.
 201  * Undefined behaviour if not..
 202  */
 203 extern inline int pte_read(pte_t pte)           { return !(pte_val(pte) & _PAGE_FOR); }
     /* [previous][next][first][last][top][bottom][index][help] */
 204 extern inline int pte_write(pte_t pte)          { return !(pte_val(pte) & _PAGE_FOW); }
     /* [previous][next][first][last][top][bottom][index][help] */
 205 extern inline int pte_exec(pte_t pte)           { return !(pte_val(pte) & _PAGE_FOE); }
     /* [previous][next][first][last][top][bottom][index][help] */
 206 extern inline int pte_dirty(pte_t pte)          { return pte_val(pte) & _PAGE_DIRTY; }
     /* [previous][next][first][last][top][bottom][index][help] */
 207 extern inline int pte_young(pte_t pte)          { return pte_val(pte) & _PAGE_ACCESSED; }
     /* [previous][next][first][last][top][bottom][index][help] */
 208 extern inline int pte_cow(pte_t pte)            { return pte_val(pte) & _PAGE_COW; }
     /* [previous][next][first][last][top][bottom][index][help] */
 209 
 210 extern inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) |= _PAGE_FOW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 211 extern inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) |= _PAGE_FOR; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 212 extern inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) |= _PAGE_FOE; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 213 extern inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) &= ~(__DIRTY_BITS); return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 214 extern inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) &= ~(__ACCESS_BITS); return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 215 extern inline pte_t pte_uncow(pte_t pte)        { pte_val(pte) &= ~_PAGE_COW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 216 extern inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) &= ~_PAGE_FOW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 217 extern inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) &= ~_PAGE_FOR; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 218 extern inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) &= ~_PAGE_FOE; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 219 extern inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) |= __DIRTY_BITS; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 220 extern inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) |= __ACCESS_BITS; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 221 extern inline pte_t pte_mkcow(pte_t pte)        { pte_val(pte) |= _PAGE_COW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 222 
 223 /* 
 224  * To set the page-dir. Note the self-mapping in the last entry
 225  *
 226  * Also note that if we update the current process ptbr, we need to
 227  * update the PAL-cached ptbr value as well.. There doesn't seem to
 228  * be any "wrptbr" PAL-insn, but we can do a dummy swpctx to ourself
 229  * instead.
 230  */
 231 extern inline void SET_PAGE_DIR(struct task_struct * tsk, pgd_t * pgdir)
     /* [previous][next][first][last][top][bottom][index][help] */
 232 {
 233         pgd_val(pgdir[PTRS_PER_PGD]) = pte_val(mk_pte((unsigned long) pgdir, PAGE_KERNEL));
 234         tsk->tss.ptbr = ((unsigned long) pgdir - PAGE_OFFSET) >> PAGE_SHIFT;
 235         if (tsk == current)
 236                 __asm__ __volatile__(
 237                         "bis %0,%0,$16\n\t"
 238                         "call_pal %1"
 239                         : /* no outputs */
 240                         : "r" (&tsk->tss), "i" (PAL_swpctx)
 241                         : "$0", "$1", "$16", "$22", "$23", "$24", "$25");
 242 }
 243 
 244 #define PAGE_DIR_OFFSET(tsk,address) pgd_offset((tsk),(address))
 245 
 246 /* to find an entry in a page-table-directory. */
 247 extern inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 248 {
 249         return mm->pgd + ((address >> PGDIR_SHIFT) & (PTRS_PER_PAGE - 1));
 250 }
 251 
 252 /* Find an entry in the second-level page table.. */
 253 extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 254 {
 255         return (pmd_t *) pgd_page(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
 256 }
 257 
 258 /* Find an entry in the third-level page table.. */
 259 extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 260 {
 261         return (pte_t *) pmd_page(*dir) + ((address >> PAGE_SHIFT) & (PTRS_PER_PAGE - 1));
 262 }
 263 
 264 /*      
 265  * Allocate and free page tables. The xxx_kernel() versions are
 266  * used to allocate a kernel page table - this turns on ASN bits
 267  * if any, and marks the page tables reserved.
 268  */
 269 extern inline void pte_free_kernel(pte_t * pte)
     /* [previous][next][first][last][top][bottom][index][help] */
 270 {
 271         mem_map[MAP_NR(pte)].reserved = 0;
 272         free_page((unsigned long) pte);
 273 }
 274 
 275 extern inline pte_t * pte_alloc_kernel(pmd_t *pmd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 276 {
 277         address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
 278         if (pmd_none(*pmd)) {
 279                 pte_t *page = (pte_t *) get_free_page(GFP_KERNEL);
 280                 if (pmd_none(*pmd)) {
 281                         if (page) {
 282                                 pmd_set(pmd, page);
 283                                 mem_map[MAP_NR(page)].reserved = 1;
 284                                 return page + address;
 285                         }
 286                         pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
 287                         return NULL;
 288                 }
 289                 free_page((unsigned long) page);
 290         }
 291         if (pmd_bad(*pmd)) {
 292                 printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
 293                 pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
 294                 return NULL;
 295         }
 296         return (pte_t *) pmd_page(*pmd) + address;
 297 }
 298 
 299 extern inline void pmd_free_kernel(pmd_t * pmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 300 {
 301         mem_map[MAP_NR(pmd)].reserved = 0;
 302         free_page((unsigned long) pmd);
 303 }
 304 
 305 extern inline pmd_t * pmd_alloc_kernel(pgd_t *pgd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 306 {
 307         address = (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
 308         if (pgd_none(*pgd)) {
 309                 pmd_t *page = (pmd_t *) get_free_page(GFP_KERNEL);
 310                 if (pgd_none(*pgd)) {
 311                         if (page) {
 312                                 pgd_set(pgd, page);
 313                                 mem_map[MAP_NR(page)].reserved = 1;
 314                                 return page + address;
 315                         }
 316                         pgd_set(pgd, BAD_PAGETABLE);
 317                         return NULL;
 318                 }
 319                 free_page((unsigned long) page);
 320         }
 321         if (pgd_bad(*pgd)) {
 322                 printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd));
 323                 pgd_set(pgd, BAD_PAGETABLE);
 324                 return NULL;
 325         }
 326         return (pmd_t *) pgd_page(*pgd) + address;
 327 }
 328 
 329 extern inline void pte_free(pte_t * pte)
     /* [previous][next][first][last][top][bottom][index][help] */
 330 {
 331         free_page((unsigned long) pte);
 332 }
 333 
 334 extern inline pte_t * pte_alloc(pmd_t *pmd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 335 {
 336         address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
 337         if (pmd_none(*pmd)) {
 338                 pte_t *page = (pte_t *) get_free_page(GFP_KERNEL);
 339                 if (pmd_none(*pmd)) {
 340                         if (page) {
 341                                 pmd_set(pmd, page);
 342                                 return page + address;
 343                         }
 344                         pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
 345                         return NULL;
 346                 }
 347                 free_page((unsigned long) page);
 348         }
 349         if (pmd_bad(*pmd)) {
 350                 printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
 351                 pmd_set(pmd, (pte_t *) BAD_PAGETABLE);
 352                 return NULL;
 353         }
 354         return (pte_t *) pmd_page(*pmd) + address;
 355 }
 356 
 357 extern inline void pmd_free(pmd_t * pmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 358 {
 359         free_page((unsigned long) pmd);
 360 }
 361 
 362 extern inline pmd_t * pmd_alloc(pgd_t *pgd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 363 {
 364         address = (address >> PMD_SHIFT) & (PTRS_PER_PMD - 1);
 365         if (pgd_none(*pgd)) {
 366                 pmd_t *page = (pmd_t *) get_free_page(GFP_KERNEL);
 367                 if (pgd_none(*pgd)) {
 368                         if (page) {
 369                                 pgd_set(pgd, page);
 370                                 return page + address;
 371                         }
 372                         pgd_set(pgd, BAD_PAGETABLE);
 373                         return NULL;
 374                 }
 375                 free_page((unsigned long) page);
 376         }
 377         if (pgd_bad(*pgd)) {
 378                 printk("Bad pgd in pmd_alloc: %08lx\n", pgd_val(*pgd));
 379                 pgd_set(pgd, BAD_PAGETABLE);
 380                 return NULL;
 381         }
 382         return (pmd_t *) pgd_page(*pgd) + address;
 383 }
 384 
 385 extern inline void pgd_free(pgd_t * pgd)
     /* [previous][next][first][last][top][bottom][index][help] */
 386 {
 387         free_page((unsigned long) pgd);
 388 }
 389 
 390 extern inline pgd_t * pgd_alloc(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 391 {
 392         return (pgd_t *) get_free_page(GFP_KERNEL);
 393 }
 394 
 395 extern pgd_t swapper_pg_dir[1024];
 396 
 397 /*
 398  * The alpha doesn't have any external MMU info: the kernel page
 399  * tables contain all the necessary information.
 400  */
 401 extern inline void update_mmu_cache(struct vm_area_struct * vma,
     /* [previous][next][first][last][top][bottom][index][help] */
 402         unsigned long address, pte_t pte)
 403 {
 404 }
 405 
 406 /*
 407  * Non-present pages: high 24 bits are offset, next 8 bits type,
 408  * low 32 bits zero..
 409  */
 410 extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
     /* [previous][next][first][last][top][bottom][index][help] */
 411 { pte_t pte; pte_val(pte) = (type << 32) | (offset << 40); return pte; }
 412 
 413 #define SWP_TYPE(entry) (((entry) >> 32) & 0xff)
 414 #define SWP_OFFSET(entry) ((entry) >> 40)
 415 #define SWP_ENTRY(type,offset) pte_val(mk_swap_pte((type),(offset)))
 416 
 417 #endif /* _ALPHA_PGTABLE_H */

/* [previous][next][first][last][top][bottom][index][help] */