root/include/asm-i386/pgtable.h

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

INCLUDED FROM


DEFINITIONS

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

   1 #ifndef _I386_PGTABLE_H
   2 #define _I386_PGTABLE_H
   3 
   4 #include <linux/config.h>
   5 
   6 /*
   7  * Define USE_PENTIUM_MM if you want the 4MB page table optimizations.
   8  * This works only on a intel Pentium.
   9  */
  10 #define USE_PENTIUM_MM 1
  11 
  12 /*
  13  * The Linux memory management assumes a three-level page table setup. On
  14  * the i386, we use that, but "fold" the mid level into the top-level page
  15  * table, so that we physically have the same two-level page table as the
  16  * i386 mmu expects.
  17  *
  18  * This file contains the functions and defines necessary to modify and use
  19  * the i386 page table tree.
  20  */
  21 
  22 /*
  23  * TLB invalidation:
  24  *
  25  *  - invalidate() invalidates the current mm struct TLBs
  26  *  - invalidate_all() invalidates all processes TLBs
  27  *  - invalidate_mm(mm) invalidates the specified mm context TLB's
  28  *  - invalidate_page(mm, vmaddr) invalidates one page
  29  *  - invalidate_range(mm, start, end) invalidates a range of pages
  30  *
  31  * ..but the i386 has somewhat limited invalidation capabilities,
  32  * and page-granular invalidates are available only on i486 and up.
  33  */
  34 
  35 #define __invalidate() \
  36 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
  37 
  38 #ifdef CONFIG_M386
  39 #define __invalidate_one(addr) invalidate()
  40 #else
  41 #define __invalidate_one(addr) \
  42 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr))
  43 #endif
  44  
  45 #ifndef __SMP__
  46 
  47 #define invalidate() __invalidate()
  48 #define invalidate_all() __invalidate()
  49 
  50 static inline void invalidate_mm(struct mm_struct *mm)
     /* [previous][next][first][last][top][bottom][index][help] */
  51 {
  52         if (mm == current->mm)
  53                 __invalidate();
  54 }
  55 
  56 static inline void invalidate_page(struct vm_area_struct *vma,
     /* [previous][next][first][last][top][bottom][index][help] */
  57         unsigned long addr)
  58 {
  59         if (vma->vm_mm == current->mm)
  60                 __invalidate_one(addr);
  61 }
  62 
  63 static inline void invalidate_range(struct mm_struct *mm,
     /* [previous][next][first][last][top][bottom][index][help] */
  64         unsigned long start, unsigned long end)
  65 {
  66         if (mm == current->mm)
  67                 __invalidate();
  68 }
  69 
  70 #else
  71 
  72 /*
  73  * We aren't very clever about this yet -  SMP could certainly
  74  * avoid some global invalidates..
  75  */
  76 
  77 #include <asm/smp.h>
  78 
  79 #define local_invalidate() \
  80         __invalidate()
  81 
  82 
  83 #undef CLEVER_SMP_INVALIDATE
  84 #ifdef CLEVER_SMP_INVALIDATE
  85 
  86 /*
  87  *      Smarter SMP invalidation macros. 
  88  *              c/o Linus Torvalds.
  89  *
  90  *      These mean you can really definitely utterly forget about
  91  *      writing to user space from interrupts. (Its not allowed anyway).
  92  *
  93  *      Doesn't currently work as Linus makes invalidate calls before
  94  *      stuff like current/current->mm are setup properly
  95  */
  96  
  97 static inline void invalidate_current_task(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         if (current->mm->count == 1)    /* just one copy of this mm */
 100                 local_invalidate();     /* and that's us, so.. */
 101         else
 102                 smp_invalidate();
 103 }
 104 
 105 #define invalidate() invalidate_current_task()
 106 
 107 #define invalidate_all() smp_invalidate()
 108 
 109 static inline void invalidate_mm(struct mm_struct * mm)
     /* [previous][next][first][last][top][bottom][index][help] */
 110 {
 111         if (mm == current->mm && mm->count == 1)
 112                 local_invalidate();
 113         else
 114                 smp_invalidate();
 115 }
 116 
 117 static inline void invalidate_page(struct vm_area_struct * vma,
     /* [previous][next][first][last][top][bottom][index][help] */
 118         unsigned long va)
 119 {
 120         if (vma->vm_mm == current->mm && current->mm->count == 1)
 121                 __invalidate_one(va);
 122         else
 123                 smp_invalidate();
 124 }
 125 
 126 static inline void invalidate_range(struct mm_struct * mm,
     /* [previous][next][first][last][top][bottom][index][help] */
 127         unsigned long start, unsigned long end)
 128 {
 129         invalidate_mm(mm);
 130 }
 131 
 132 
 133 #else
 134 
 135 #define invalidate() \
 136         smp_invalidate()
 137 
 138 #define invalidate_all() invalidate()
 139 
 140 static inline void invalidate_mm(struct mm_struct *mm)
     /* [previous][next][first][last][top][bottom][index][help] */
 141 {
 142         invalidate();
 143 }
 144 
 145 static inline void invalidate_page(struct vm_area_struct *vma,
     /* [previous][next][first][last][top][bottom][index][help] */
 146         unsigned long addr)
 147 {
 148         invalidate();
 149 }
 150 
 151 static inline void invalidate_range(struct mm_struct *mm,
     /* [previous][next][first][last][top][bottom][index][help] */
 152         unsigned long start, unsigned long end)
 153 {
 154         invalidate();
 155 }
 156 #endif
 157 #endif
 158 
 159 
 160 /* Certain architectures need to do special things when pte's
 161  * within a page table are directly modified.  Thus, the following
 162  * hook is made available.
 163  */
 164 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
 165 
 166 /* PMD_SHIFT determines the size of the area a second-level page table can map */
 167 #define PMD_SHIFT       22
 168 #define PMD_SIZE        (1UL << PMD_SHIFT)
 169 #define PMD_MASK        (~(PMD_SIZE-1))
 170 
 171 /* PGDIR_SHIFT determines what a third-level page table entry can map */
 172 #define PGDIR_SHIFT     22
 173 #define PGDIR_SIZE      (1UL << PGDIR_SHIFT)
 174 #define PGDIR_MASK      (~(PGDIR_SIZE-1))
 175 
 176 /*
 177  * entries per page directory level: the i386 is two-level, so
 178  * we don't really have any PMD directory physically.
 179  */
 180 #define PTRS_PER_PTE    1024
 181 #define PTRS_PER_PMD    1
 182 #define PTRS_PER_PGD    1024
 183 
 184 /* Just any arbitrary offset to the start of the vmalloc VM area: the
 185  * current 8MB value just means that there will be a 8MB "hole" after the
 186  * physical memory until the kernel virtual memory starts.  That means that
 187  * any out-of-bounds memory accesses will hopefully be caught.
 188  * The vmalloc() routines leaves a hole of 4kB between each vmalloced
 189  * area for the same reason. ;)
 190  */
 191 #define VMALLOC_OFFSET  (8*1024*1024)
 192 #define VMALLOC_START ((high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
 193 #define VMALLOC_VMADDR(x) (TASK_SIZE + (unsigned long)(x))
 194 
 195 /*
 196  * The 4MB page is guessing..  Detailed in the infamous "Chapter H"
 197  * of the Pentium details, but assuming intel did the straigtforward
 198  * thing, this bit set in the page directory entry just means that
 199  * the page directory entry points directly to a 4MB-aligned block of
 200  * memory. 
 201  */
 202 #define _PAGE_PRESENT   0x001
 203 #define _PAGE_RW        0x002
 204 #define _PAGE_USER      0x004
 205 #define _PAGE_PCD       0x010
 206 #define _PAGE_ACCESSED  0x020
 207 #define _PAGE_DIRTY     0x040
 208 #define _PAGE_4M        0x080   /* 4 MB page, Pentium+.. */
 209 
 210 #define _PAGE_TABLE     (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
 211 #define _PAGE_CHG_MASK  (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
 212 
 213 #define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
 214 #define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
 215 #define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
 216 #define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
 217 #define PAGE_KERNEL     __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
 218 
 219 /*
 220  * The i386 can't do page protection for execute, and considers that the same are read.
 221  * Also, write permissions imply read permissions. This is the closest we can get..
 222  */
 223 #define __P000  PAGE_NONE
 224 #define __P001  PAGE_READONLY
 225 #define __P010  PAGE_COPY
 226 #define __P011  PAGE_COPY
 227 #define __P100  PAGE_READONLY
 228 #define __P101  PAGE_READONLY
 229 #define __P110  PAGE_COPY
 230 #define __P111  PAGE_COPY
 231 
 232 #define __S000  PAGE_NONE
 233 #define __S001  PAGE_READONLY
 234 #define __S010  PAGE_SHARED
 235 #define __S011  PAGE_SHARED
 236 #define __S100  PAGE_READONLY
 237 #define __S101  PAGE_READONLY
 238 #define __S110  PAGE_SHARED
 239 #define __S111  PAGE_SHARED
 240 
 241 /*
 242  * Define this if things work differently on a i386 and a i486:
 243  * it will (on a i486) warn about kernel memory accesses that are
 244  * done without a 'verify_area(VERIFY_WRITE,..)'
 245  */
 246 #undef TEST_VERIFY_AREA
 247 
 248 /* page table for 0-4MB for everybody */
 249 extern unsigned long pg0[1024];
 250 /* zero page used for unitialized stuff */
 251 extern unsigned long empty_zero_page[1024];
 252 
 253 /*
 254  * BAD_PAGETABLE is used when we need a bogus page-table, while
 255  * BAD_PAGE is used for a bogus page.
 256  *
 257  * ZERO_PAGE is a global shared page that is always zero: used
 258  * for zero-mapped memory areas etc..
 259  */
 260 extern pte_t __bad_page(void);
 261 extern pte_t * __bad_pagetable(void);
 262 
 263 #define BAD_PAGETABLE __bad_pagetable()
 264 #define BAD_PAGE __bad_page()
 265 #define ZERO_PAGE ((unsigned long) empty_zero_page)
 266 
 267 /* number of bits that fit into a memory pointer */
 268 #define BITS_PER_PTR                    (8*sizeof(unsigned long))
 269 
 270 /* to align the pointer to a pointer address */
 271 #define PTR_MASK                        (~(sizeof(void*)-1))
 272 
 273 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
 274 /* 64-bit machines, beware!  SRB. */
 275 #define SIZEOF_PTR_LOG2                 2
 276 
 277 /* to find an entry in a page-table */
 278 #define PAGE_PTR(address) \
 279 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
 280 
 281 /* to set the page-dir */
 282 #define SET_PAGE_DIR(tsk,pgdir) \
 283 do { \
 284         (tsk)->tss.cr3 = (unsigned long) (pgdir); \
 285         if ((tsk) == current) \
 286                 __asm__ __volatile__("movl %0,%%cr3": :"a" ((tsk)->tss.cr3)); \
 287 } while (0)
 288 
 289 extern inline int pte_none(pte_t pte)           { return !pte_val(pte); }
     /* [previous][next][first][last][top][bottom][index][help] */
 290 extern inline int pte_present(pte_t pte)        { return pte_val(pte) & _PAGE_PRESENT; }
     /* [previous][next][first][last][top][bottom][index][help] */
 291 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] */
 292 extern inline void pte_clear(pte_t *ptep)       { pte_val(*ptep) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 293 extern inline void pte_reuse(pte_t * ptep)
     /* [previous][next][first][last][top][bottom][index][help] */
 294 {
 295         if (!mem_map[MAP_NR(ptep)].reserved)
 296                 mem_map[MAP_NR(ptep)].count++;
 297 }
 298 
 299 extern inline int pmd_none(pmd_t pmd)           { return !pmd_val(pmd); }
     /* [previous][next][first][last][top][bottom][index][help] */
 300 extern inline int pmd_bad(pmd_t pmd)            { return (pmd_val(pmd) & ~PAGE_MASK) != _PAGE_TABLE || pmd_val(pmd) > high_memory; }
     /* [previous][next][first][last][top][bottom][index][help] */
 301 extern inline int pmd_present(pmd_t pmd)        { return pmd_val(pmd) & _PAGE_PRESENT; }
     /* [previous][next][first][last][top][bottom][index][help] */
 302 #ifdef USE_PENTIUM_MM
 303 extern inline int pmd_inuse(pmd_t *pmdp)        { return (pmd_val(*pmdp) & _PAGE_4M) != 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 304 #else
 305 extern inline int pmd_inuse(pmd_t *pmdp)        { return 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 306 #endif
 307 extern inline void pmd_clear(pmd_t * pmdp)      { pmd_val(*pmdp) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 308 extern inline void pmd_reuse(pmd_t * pmdp)      { }
     /* [previous][next][first][last][top][bottom][index][help] */
 309 
 310 /*
 311  * The "pgd_xxx()" functions here are trivial for a folded two-level
 312  * setup: the pgd is never bad, and a pmd always exists (as it's folded
 313  * into the pgd entry)
 314  */
 315 extern inline int pgd_none(pgd_t pgd)           { return 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 316 extern inline int pgd_bad(pgd_t pgd)            { return 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 317 extern inline int pgd_present(pgd_t pgd)        { return 1; }
     /* [previous][next][first][last][top][bottom][index][help] */
 318 extern inline int pgd_inuse(pgd_t * pgdp)       { return mem_map[MAP_NR(pgdp)].reserved; }
     /* [previous][next][first][last][top][bottom][index][help] */
 319 extern inline void pgd_clear(pgd_t * pgdp)      { }
     /* [previous][next][first][last][top][bottom][index][help] */
 320 
 321 /*
 322  * The following only work if pte_present() is true.
 323  * Undefined behaviour if not..
 324  */
 325 extern inline int pte_read(pte_t pte)           { return pte_val(pte) & _PAGE_USER; }
     /* [previous][next][first][last][top][bottom][index][help] */
 326 extern inline int pte_write(pte_t pte)          { return pte_val(pte) & _PAGE_RW; }
     /* [previous][next][first][last][top][bottom][index][help] */
 327 extern inline int pte_exec(pte_t pte)           { return pte_val(pte) & _PAGE_USER; }
     /* [previous][next][first][last][top][bottom][index][help] */
 328 extern inline int pte_dirty(pte_t pte)          { return pte_val(pte) & _PAGE_DIRTY; }
     /* [previous][next][first][last][top][bottom][index][help] */
 329 extern inline int pte_young(pte_t pte)          { return pte_val(pte) & _PAGE_ACCESSED; }
     /* [previous][next][first][last][top][bottom][index][help] */
 330 
 331 extern inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_RW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 332 extern inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 333 extern inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 334 extern inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 335 extern inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 336 extern inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) |= _PAGE_RW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 337 extern inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) |= _PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 338 extern inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) |= _PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 339 extern inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) |= _PAGE_DIRTY; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 340 extern inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 341 
 342 /*
 343  * Conversion functions: convert a page and protection to a page entry,
 344  * and a page entry and page directory to the page they refer to.
 345  */
 346 extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 347 { pte_t pte; pte_val(pte) = page | pgprot_val(pgprot); return pte; }
 348 
 349 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 350 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
 351 
 352 extern inline unsigned long pte_page(pte_t pte)
     /* [previous][next][first][last][top][bottom][index][help] */
 353 { return pte_val(pte) & PAGE_MASK; }
 354 
 355 extern inline unsigned long pmd_page(pmd_t pmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 356 { return pmd_val(pmd) & PAGE_MASK; }
 357 
 358 /* to find an entry in a page-table-directory */
 359 extern inline pgd_t * pgd_offset(struct mm_struct * mm, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 360 {
 361         return mm->pgd + (address >> PGDIR_SHIFT);
 362 }
 363 
 364 /* Find an entry in the second-level page table.. */
 365 extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 366 {
 367         return (pmd_t *) dir;
 368 }
 369 
 370 /* Find an entry in the third-level page table.. */ 
 371 extern inline pte_t * pte_offset(pmd_t * dir, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 372 {
 373         return (pte_t *) pmd_page(*dir) + ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1));
 374 }
 375 
 376 /*
 377  * Allocate and free page tables. The xxx_kernel() versions are
 378  * used to allocate a kernel page table - this turns on ASN bits
 379  * if any, and marks the page tables reserved.
 380  */
 381 extern inline void pte_free_kernel(pte_t * pte)
     /* [previous][next][first][last][top][bottom][index][help] */
 382 {
 383         mem_map[MAP_NR(pte)].reserved = 0;
 384         free_page((unsigned long) pte);
 385 }
 386 
 387 extern inline pte_t * pte_alloc_kernel(pmd_t * pmd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 388 {
 389         address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
 390         if (pmd_none(*pmd)) {
 391                 pte_t * page = (pte_t *) get_free_page(GFP_KERNEL);
 392                 if (pmd_none(*pmd)) {
 393                         if (page) {
 394                                 pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page;
 395                                 mem_map[MAP_NR(page)].reserved = 1;
 396                                 return page + address;
 397                         }
 398                         pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
 399                         return NULL;
 400                 }
 401                 free_page((unsigned long) page);
 402         }
 403         if (pmd_bad(*pmd)) {
 404                 printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
 405                 pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
 406                 return NULL;
 407         }
 408         return (pte_t *) pmd_page(*pmd) + address;
 409 }
 410 
 411 /*
 412  * allocating and freeing a pmd is trivial: the 1-entry pmd is
 413  * inside the pgd, so has no extra memory associated with it.
 414  */
 415 extern inline void pmd_free_kernel(pmd_t * pmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 416 {
 417         pmd_val(*pmd) = 0;
 418 }
 419 
 420 extern inline pmd_t * pmd_alloc_kernel(pgd_t * pgd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 421 {
 422         return (pmd_t *) pgd;
 423 }
 424 
 425 extern inline void pte_free(pte_t * pte)
     /* [previous][next][first][last][top][bottom][index][help] */
 426 {
 427         free_page((unsigned long) pte);
 428 }
 429 
 430 extern inline pte_t * pte_alloc(pmd_t * pmd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 431 {
 432         address = (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
 433         if (pmd_none(*pmd)) {
 434                 pte_t * page = (pte_t *) get_free_page(GFP_KERNEL);
 435                 if (pmd_none(*pmd)) {
 436                         if (page) {
 437                                 pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) page;
 438                                 return page + address;
 439                         }
 440                         pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
 441                         return NULL;
 442                 }
 443                 free_page((unsigned long) page);
 444         }
 445         if (pmd_bad(*pmd)) {
 446                 printk("Bad pmd in pte_alloc: %08lx\n", pmd_val(*pmd));
 447                 pmd_val(*pmd) = _PAGE_TABLE | (unsigned long) BAD_PAGETABLE;
 448                 return NULL;
 449         }
 450         return (pte_t *) pmd_page(*pmd) + address;
 451 }
 452 
 453 /*
 454  * allocating and freeing a pmd is trivial: the 1-entry pmd is
 455  * inside the pgd, so has no extra memory associated with it.
 456  */
 457 extern inline void pmd_free(pmd_t * pmd)
     /* [previous][next][first][last][top][bottom][index][help] */
 458 {
 459         pmd_val(*pmd) = 0;
 460 }
 461 
 462 extern inline pmd_t * pmd_alloc(pgd_t * pgd, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 463 {
 464         return (pmd_t *) pgd;
 465 }
 466 
 467 extern inline void pgd_free(pgd_t * pgd)
     /* [previous][next][first][last][top][bottom][index][help] */
 468 {
 469         free_page((unsigned long) pgd);
 470 }
 471 
 472 extern inline pgd_t * pgd_alloc(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 473 {
 474         return (pgd_t *) get_free_page(GFP_KERNEL);
 475 }
 476 
 477 extern pgd_t swapper_pg_dir[1024];
 478 
 479 /*
 480  * The i386 doesn't have any external MMU info: the kernel page
 481  * tables contain all the necessary information.
 482  */
 483 extern inline void update_mmu_cache(struct vm_area_struct * vma,
     /* [previous][next][first][last][top][bottom][index][help] */
 484         unsigned long address, pte_t pte)
 485 {
 486 }
 487 
 488 #define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
 489 #define SWP_OFFSET(entry) ((entry) >> 8)
 490 #define SWP_ENTRY(type,offset) (((type) << 1) | ((offset) << 8))
 491 
 492 #endif /* _I386_PAGE_H */

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