root/include/asm-alpha/page.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. SET_PAGE_DIR
  2. PAGE_DIR_OFFSET
  3. mk_pte
  4. pte_modify
  5. pgd_set
  6. pte_page
  7. pgd_page
  8. pte_none
  9. pte_present
  10. pte_clear
  11. pgd_none
  12. pgd_bad
  13. pgd_present
  14. pgd_clear
  15. pte_read
  16. pte_write
  17. pte_exec
  18. pte_dirty
  19. pte_young
  20. pte_cow
  21. pte_wrprotect
  22. pte_rdprotect
  23. pte_exprotect
  24. pte_mkclean
  25. pte_mkold
  26. pte_uncow
  27. pte_mkwrite
  28. pte_mkread
  29. pte_mkexec
  30. pte_mkdirty
  31. pte_mkyoung
  32. pte_mkcow

   1 #ifndef _ALPHA_PAGE_H
   2 #define _ALPHA_PAGE_H
   3 
   4 #define CONFIG_STRICT_MM_TYPECHECKS
   5 
   6 #define invalidate_all() \
   7 __asm__ __volatile__( \
   8         "lda $16,-2($31)\n\t" \
   9         ".long 51" \
  10         : : :"$1", "$16", "$17", "$22","$23","$24","$25")
  11 
  12 #define invalidate() \
  13 __asm__ __volatile__( \
  14         "lda $16,-1($31)\n\t" \
  15         ".long 51" \
  16         : : :"$1", "$16", "$17", "$22","$23","$24","$25")
  17 
  18 /* PAGE_SHIFT determines the page size */
  19 #define PAGE_SHIFT                      13
  20 #define PGDIR_SHIFT                     23
  21 #define PAGE_SIZE                       (1UL << PAGE_SHIFT)
  22 #define PGDIR_SIZE                      (1UL << PGDIR_SHIFT)
  23 
  24 #ifdef __KERNEL__
  25 
  26 #define PAGE_OFFSET 0xFFFFFC0000000000
  27 #define MAP_NR(addr) (((addr) - PAGE_OFFSET) >> PAGE_SHIFT)
  28 #define MAP_PAGE_RESERVED (1<<31)
  29 
  30 typedef unsigned int mem_map_t;
  31 
  32 #define VMALLOC_START           0xFFFFFE0000000000
  33 #define VMALLOC_VMADDR(x)       ((unsigned long)(x))
  34 
  35 #ifdef CONFIG_STRICT_MM_TYPECHECKS
  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 pgd; } pgd_t;
  41 typedef struct { unsigned long pgprot; } pgprot_t;
  42 
  43 #define pte_val(x)      ((x).pte)
  44 #define pgd_val(x)      ((x).pgd)
  45 #define pgprot_val(x)   ((x).pgprot)
  46 
  47 #define __pte(x)        ((pte_t) { (x) } )
  48 #define __pgd(x)        ((pgd_t) { (x) } )
  49 #define __pgprot(x)     ((pgprot_t) { (x) } )
  50 
  51 #else
  52 /*
  53  * .. while these make it easier on the compiler
  54  */
  55 typedef unsigned long pte_t;
  56 typedef unsigned long pgd_t;
  57 typedef unsigned long pgprot_t;
  58 
  59 #define pte_val(x)      (x)
  60 #define pgd_val(x)      (x)
  61 #define pgprot_val(x)   (x)
  62 
  63 #define __pte(x)        (x)
  64 #define __pgd(x)        (x)
  65 #define __pgprot(x)     (x)
  66 
  67 #endif
  68 
  69 /*
  70  * OSF/1 PAL-code-imposed page table bits
  71  */
  72 #define _PAGE_VALID     0x0001
  73 #define _PAGE_FOR       0x0002  /* used for page protection (fault on read) */
  74 #define _PAGE_FOW       0x0004  /* used for page protection (fault on write) */
  75 #define _PAGE_FOE       0x0008  /* used for page protection (fault on exec) */
  76 #define _PAGE_ASM       0x0010
  77 #define _PAGE_KRE       0x0100  /* xxx - see below on the "accessed" bit */
  78 #define _PAGE_URE       0x0200  /* xxx */
  79 #define _PAGE_KWE       0x1000  /* used to do the dirty bit in software */
  80 #define _PAGE_UWE       0x2000  /* used to do the dirty bit in software */
  81 
  82 /* .. and these are ours ... */
  83 #define _PAGE_COW       0x10000
  84 #define _PAGE_DIRTY     0x20000
  85 #define _PAGE_ACCESSED  0x40000
  86 
  87 /*
  88  * NOTE! The "accessed" bit isn't necessarily exact: it can be kept exactly
  89  * by software (use the KRE/URE/KWE/UWE bits appropritely), but I'll fake it.
  90  * Under Linux/AXP, the "accessed" bit just means "read", and I'll just use
  91  * the KRE/URE bits to watch for it. That way we don't need to overload the
  92  * KWE/UWE bits with both handling dirty and accessed.
  93  *
  94  * Note that the kernel uses the accessed bit just to check whether to page
  95  * out a page or not, so it doesn't have to be exact anyway.
  96  */
  97 
  98 #define __DIRTY_BITS    (_PAGE_DIRTY | _PAGE_KWE | _PAGE_UWE)
  99 #define __ACCESS_BITS   (_PAGE_ACCESSED | _PAGE_KRE | _PAGE_URE)
 100 
 101 #define _PFN_MASK       0xFFFFFFFF00000000
 102 
 103 #define _PAGE_TABLE     (_PAGE_VALID | __DIRTY_BITS | __ACCESS_BITS)
 104 #define _PAGE_CHG_MASK  (_PFN_MASK | __DIRTY_BITS | __ACCESS_BITS)
 105 
 106 /*
 107  * All the normal masks have the "page accessed" bits on, as any time they are used,
 108  * the page is accessed. They are cleared only by the page-out routines
 109  */
 110 #define PAGE_NONE       __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
 111 #define PAGE_SHARED     __pgprot(_PAGE_VALID | __ACCESS_BITS)
 112 #define PAGE_COPY       __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_COW)
 113 #define PAGE_READONLY   __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
 114 #define PAGE_KERNEL     __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
 115 
 116 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
 117 
 118 #define __P000  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
 119 #define __P001  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOW | _PAGE_FOE)
 120 #define __P010  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR | _PAGE_FOE)
 121 #define __P011  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOE)
 122 #define __P100  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR | _PAGE_FOW)
 123 #define __P101  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOW)
 124 #define __P110  _PAGE_NORMAL(_PAGE_COW | _PAGE_FOR)
 125 #define __P111  _PAGE_NORMAL(_PAGE_COW)
 126 
 127 #define __S000  _PAGE_NORMAL(_PAGE_FOR | _PAGE_FOW | _PAGE_FOE)
 128 #define __S001  _PAGE_NORMAL(_PAGE_FOW | _PAGE_FOE)
 129 #define __S010  _PAGE_NORMAL(_PAGE_FOR | _PAGE_FOE)
 130 #define __S011  _PAGE_NORMAL(_PAGE_FOE)
 131 #define __S100  _PAGE_NORMAL(_PAGE_FOR | _PAGE_FOW)
 132 #define __S101  _PAGE_NORMAL(_PAGE_FOW)
 133 #define __S110  _PAGE_NORMAL(_PAGE_FOR)
 134 #define __S111  _PAGE_NORMAL(0)
 135 
 136 /*
 137  * BAD_PAGETABLE is used when we need a bogus page-table, while
 138  * BAD_PAGE is used for a bogus page.
 139  *
 140  * ZERO_PAGE is a global shared page that is always zero: used
 141  * for zero-mapped memory areas etc..
 142  */
 143 extern pte_t __bad_page(void);
 144 extern pte_t * __bad_pagetable(void);
 145 
 146 extern unsigned long __zero_page(void);
 147 
 148 #define BAD_PAGETABLE __bad_pagetable()
 149 #define BAD_PAGE __bad_page()
 150 #define ZERO_PAGE __zero_page()
 151 
 152 /* number of bits that fit into a memory pointer */
 153 #define BITS_PER_PTR                    (8*sizeof(unsigned long))
 154 
 155 /* to mask away the intra-page address bits */
 156 #define PAGE_MASK                       (~(PAGE_SIZE-1))
 157 
 158 /* to mask away the intra-page address bits */
 159 #define PGDIR_MASK                      (~(PGDIR_SIZE-1))
 160 
 161 /* to align the pointer to the (next) page boundary */
 162 #define PAGE_ALIGN(addr)                (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 163 
 164 /* to align the pointer to a pointer address */
 165 #define PTR_MASK                        (~(sizeof(void*)-1))
 166 
 167 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
 168 #define SIZEOF_PTR_LOG2                 3
 169 
 170 /* to find an entry in a page-table */
 171 #define PAGE_PTR(address)               \
 172   ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
 173 
 174 /* the no. of pointers that fit on a page */
 175 #define PTRS_PER_PAGE                   (PAGE_SIZE/sizeof(void*))
 176 
 177 /* to set the page-dir */
 178 extern inline void SET_PAGE_DIR(struct task_struct * tsk, pgd_t * pgdir)
     /* [previous][next][first][last][top][bottom][index][help] */
 179 {
 180         tsk->tss.ptbr = ((unsigned long) pgdir - PAGE_OFFSET) >> PAGE_SHIFT;
 181         if (tsk == current)
 182                 invalidate();
 183 }
 184 
 185 /* to find an entry in a page-table-directory */
 186 extern inline pgd_t * PAGE_DIR_OFFSET(struct task_struct * tsk, unsigned long address)
     /* [previous][next][first][last][top][bottom][index][help] */
 187 {
 188         return (pgd_t *) ((tsk->tss.ptbr << PAGE_SHIFT) + PAGE_OFFSET) +
 189                 ((address >> 33) & PTR_MASK);
 190 }
 191 
 192 extern unsigned long high_memory;
 193 
 194 /*
 195  * Conversion functions: convert a page and protection to a page entry,
 196  * and a page entry and page directory to the page they refer to.
 197  */
 198 extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 199 { pte_t pte; pte_val(pte) = (page << (32-PAGE_SHIFT)) | pgprot_val(pgprot); return pte; }
 200 
 201 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 202 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
 203 
 204 extern inline void pgd_set(pgd_t * pgdp, pte_t * ptep)
     /* [previous][next][first][last][top][bottom][index][help] */
 205 { pgd_val(*pgdp) = _PAGE_TABLE | (((unsigned long) ptep) << (32-PAGE_SHIFT)); }
 206 
 207 extern inline unsigned long pte_page(pte_t pte) { return (pte_val(pte) & _PFN_MASK) >> (32-PAGE_SHIFT); }
     /* [previous][next][first][last][top][bottom][index][help] */
 208 extern inline unsigned long pgd_page(pgd_t pgd) { return (pgd_val(pgd) & _PFN_MASK) >> (32-PAGE_SHIFT); }
     /* [previous][next][first][last][top][bottom][index][help] */
 209 
 210 extern inline int pte_none(pte_t pte)           { return !pte_val(pte); }
     /* [previous][next][first][last][top][bottom][index][help] */
 211 extern inline int pte_present(pte_t pte)        { return pte_val(pte) & _PAGE_VALID; }
     /* [previous][next][first][last][top][bottom][index][help] */
 212 extern inline void pte_clear(pte_t *ptep)       { pte_val(*ptep) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 213 
 214 extern inline int pgd_none(pgd_t pgd)           { return !pgd_val(pgd); }
     /* [previous][next][first][last][top][bottom][index][help] */
 215 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] */
 216 extern inline int pgd_present(pgd_t pgd)        { return pgd_val(pgd) & _PAGE_VALID; }
     /* [previous][next][first][last][top][bottom][index][help] */
 217 extern inline void pgd_clear(pgd_t * pgdp)      { pgd_val(*pgdp) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 218 
 219 /*
 220  * The following only work if pte_present() is true.
 221  * Undefined behaviour if not..
 222  */
 223 extern inline int pte_read(pte_t pte)           { return !(pte_val(pte) & _PAGE_FOR); }
     /* [previous][next][first][last][top][bottom][index][help] */
 224 extern inline int pte_write(pte_t pte)          { return !(pte_val(pte) & _PAGE_FOW); }
     /* [previous][next][first][last][top][bottom][index][help] */
 225 extern inline int pte_exec(pte_t pte)           { return !(pte_val(pte) & _PAGE_FOE); }
     /* [previous][next][first][last][top][bottom][index][help] */
 226 extern inline int pte_dirty(pte_t pte)          { return pte_val(pte) & _PAGE_DIRTY; }
     /* [previous][next][first][last][top][bottom][index][help] */
 227 extern inline int pte_young(pte_t pte)          { return pte_val(pte) & _PAGE_ACCESSED; }
     /* [previous][next][first][last][top][bottom][index][help] */
 228 extern inline int pte_cow(pte_t pte)            { return pte_val(pte) & _PAGE_COW; }
     /* [previous][next][first][last][top][bottom][index][help] */
 229 
 230 extern inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) |= _PAGE_FOW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 231 extern inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) |= _PAGE_FOR; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 232 extern inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) |= _PAGE_FOE; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 233 extern inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) &= ~(__DIRTY_BITS); return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 234 extern inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) &= ~(__ACCESS_BITS); return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 235 extern inline pte_t pte_uncow(pte_t pte)        { pte_val(pte) &= ~_PAGE_COW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 236 extern inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) &= _PAGE_FOW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 237 extern inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) &= _PAGE_FOR; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 238 extern inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) &= _PAGE_FOE; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 239 extern inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) |= __DIRTY_BITS; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 240 extern inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) |= __ACCESS_BITS; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 241 extern inline pte_t pte_mkcow(pte_t pte)        { pte_val(pte) |= _PAGE_COW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 242 
 243 #endif /* __KERNEL__ */
 244 
 245 #endif /* _ALPHA_PAGE_H */

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