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

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