root/include/asm-mips/page.h

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

INCLUDED FROM


DEFINITIONS

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

   1 #ifndef __ASM_MIPS_PAGE_H
   2 #define __ASM_MIPS_PAGE_H
   3 
   4 #define CONFIG_STRICT_MM_TYPECHECKS
   5 
   6 #ifndef __ASSEMBLY__
   7 
   8 #include <linux/linkage.h>
   9 
  10 #define invalidate()    tlbflush();
  11 extern asmlinkage void tlbflush(void);
  12 
  13 /* Certain architectures need to do special things when pte's
  14  * within a page table are directly modified.  Thus, the following
  15  * hook is made available.
  16  */
  17 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
  18 
  19 typedef unsigned short mem_map_t;
  20 
  21 #ifdef CONFIG_STRICT_MM_TYPECHECKS
  22 /*
  23  * These are used to make use of C type-checking..
  24  */
  25 typedef struct { unsigned long pte; } pte_t;
  26 typedef struct { unsigned long pgd; } pgd_t;
  27 typedef struct { unsigned long pgprot; } pgprot_t;
  28 
  29 #define pte_val(x)      ((x).pte)
  30 #define pgd_val(x)      ((x).pgd)
  31 #define pgprot_val(x)   ((x).pgprot)
  32 
  33 #define __pte(x)        ((pte_t) { (x) } )
  34 #define __pgd(x)        ((pgd_t) { (x) } )
  35 #define __pgprot(x)     ((pgprot_t) { (x) } )
  36 
  37 #else /* !defined (CONFIG_STRICT_MM_TYPECHECKS) */
  38 /*
  39  * .. while these make it easier on the compiler
  40  */
  41 typedef unsigned long pte_t;
  42 typedef unsigned long pgd_t;
  43 typedef unsigned long pgprot_t;
  44 
  45 #define pte_val(x)      (x)
  46 #define pgd_val(x)      (x)
  47 #define pgprot_val(x)   (x)
  48 
  49 #define __pte(x)        (x)
  50 #define __pgd(x)        (x)
  51 #define __pgprot(x)     (x)
  52 
  53 #endif /* !defined (CONFIG_STRICT_MM_TYPECHECKS) */
  54 #endif /* __ASSEMBLY__ */
  55 
  56 /*
  57  * Note that we shift the lower 32bits of each EntryLo[01] entry
  58  * 6 bits to the left. That way we can convert the PFN into the
  59  * physical address by a single 'and' operation and gain 6 additional
  60  * bits for storing information which isn't present in a normal
  61  * MIPS page table.
  62  */
  63 #define _PAGE_PRESENT               (1<<0)  /* implemented in software */
  64 #define _PAGE_COW                   (1<<1)  /* implemented in software */
  65 #define _PAGE_DIRTY                 (1<<2)  /* implemented in software */
  66 #define _PAGE_USER                  (1<<3)
  67 #define _PAGE_UNUSED1               (1<<4)
  68 #define _PAGE_UNUSED2               (1<<5)
  69 #define _PAGE_GLOBAL                (1<<6)
  70 #define _PAGE_ACCESSED              (1<<7)   /* The MIPS valid bit      */
  71 #define _PAGE_RW                    (1<<8)   /* The MIPS dirty bit      */
  72 #define _CACHE_CACHABLE_NO_WA       (0<<9)
  73 #define _CACHE_CACHABLE_WA          (1<<9)
  74 #define _CACHE_UNCACHED             (2<<9)
  75 #define _CACHE_CACHABLE_NONCOHERENT (3<<9)
  76 #define _CACHE_CACHABLE_CE          (4<<9)
  77 #define _CACHE_CACHABLE_COW         (5<<9)
  78 #define _CACHE_CACHABLE_CUW         (6<<9)
  79 #define _CACHE_MASK                 (7<<9)
  80 
  81 #define _PAGE_TABLE     (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY | \
  82                          _CACHE_CACHABLE_NO_WA)
  83 
  84 #define _PAGE_CHG_MASK  (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _CACHE_MASK)
  85 
  86 #define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
  87 #define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _CACHE_CACHABLE_NO_WA)
  88 #define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_COW | _CACHE_CACHABLE_NO_WA)
  89 #define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _CACHE_CACHABLE_NO_WA)
  90 #define PAGE_KERNEL     __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
  91 
  92 /*
  93  * MIPS can't do page protection for execute, and considers that the same like
  94  * read. Also, write permissions imply read permissions. This is the closest
  95  * we can get by reasonable means..
  96  */
  97 #define __P000  PAGE_NONE
  98 #define __P001  PAGE_READONLY
  99 #define __P010  PAGE_COPY
 100 #define __P011  PAGE_COPY
 101 #define __P100  PAGE_READONLY
 102 #define __P101  PAGE_READONLY
 103 #define __P110  PAGE_COPY
 104 #define __P111  PAGE_COPY
 105 
 106 #define __S000  PAGE_NONE
 107 #define __S001  PAGE_READONLY
 108 #define __S010  PAGE_SHARED
 109 #define __S011  PAGE_SHARED
 110 #define __S100  PAGE_READONLY
 111 #define __S101  PAGE_READONLY
 112 #define __S110  PAGE_SHARED
 113 #define __S111  PAGE_SHARED
 114 
 115 /* PAGE_SHIFT determines the page size */
 116 #define PAGE_SHIFT                      12
 117 #define PGDIR_SHIFT                     22
 118 #define PAGE_SIZE                       (1UL << PAGE_SHIFT)
 119 #define PGDIR_SIZE                      (1UL << PGDIR_SHIFT)
 120 
 121 #ifdef __KERNEL__
 122 
 123 #define PAGE_OFFSET     KERNELBASE
 124 #define MAP_NR(addr)    (((addr) - PAGE_OFFSET) >> PAGE_SHIFT)
 125 #define MAP_PAGE_RESERVED (1<<15)
 126 
 127 #if !defined (__ASSEMBLY__)
 128 
 129 /* page table for 0-4MB for everybody */
 130 extern unsigned long pg0[1024];
 131 
 132 /*
 133  * BAD_PAGETABLE is used when we need a bogus page-table, while
 134  * BAD_PAGE is used for a bogus page.
 135  *
 136  * ZERO_PAGE is a global shared page that is always zero: used
 137  * for zero-mapped memory areas etc..
 138  */
 139 extern pte_t __bad_page(void);
 140 extern pte_t * __bad_pagetable(void);
 141 
 142 extern unsigned long __zero_page(void);
 143 
 144 #define BAD_PAGETABLE __bad_pagetable()
 145 #define BAD_PAGE __bad_page()
 146 #define ZERO_PAGE __zero_page()
 147 
 148 /* number of bits that fit into a memory pointer */
 149 #define BITS_PER_PTR                    (8*sizeof(unsigned long))
 150 
 151 /* to mask away the intra-page address bits */
 152 #define PAGE_MASK                       (~(PAGE_SIZE-1))
 153 
 154 /* to mask away the intra-page address bits */
 155 #define PGDIR_MASK                      (~(PGDIR_SIZE-1))
 156 
 157 /* to align the pointer to the (next) page boundary */
 158 #define PAGE_ALIGN(addr)                (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 159 
 160 /* to align the pointer to a pointer address */
 161 #define PTR_MASK                        (~(sizeof(void*)-1))
 162 
 163 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
 164 /* 64-bit machines, beware!  SRB. */
 165 #define SIZEOF_PTR_LOG2                 2
 166 
 167 /* to find an entry in a page-table-directory */
 168 #define PAGE_DIR_OFFSET(tsk,address) \
 169 ((((unsigned long)(address)) >> PGDIR_SHIFT) + (pgd_t *) (tsk)->tss.pg_dir)
 170 
 171 /* to find an entry in a page-table */
 172 #define PAGE_PTR(address) \
 173 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
 174 
 175 /* the no. of pointers that fit on a page */
 176 #define PTRS_PER_PAGE                   (PAGE_SIZE/sizeof(void*))
 177 
 178 /* to set the page-dir */
 179 #define SET_PAGE_DIR(tsk,pgdir) \
 180 do { \
 181         (tsk)->tss.pg_dir = (unsigned long) (pgdir); \
 182         if ((tsk) == current) \
 183                 invalidate(); \
 184 } while (0)
 185 
 186 extern unsigned long high_memory;
 187 
 188 extern inline int pte_none(pte_t pte)           { return !pte_val(pte); }
     /* [previous][next][first][last][top][bottom][index][help] */
 189 extern inline int pte_present(pte_t pte)        { return pte_val(pte) & _PAGE_PRESENT; }
     /* [previous][next][first][last][top][bottom][index][help] */
 190 extern inline void pte_clear(pte_t *ptep)       { pte_val(*ptep) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 191 
 192 extern inline int pgd_none(pgd_t pgd)           { return !pgd_val(pgd); }
     /* [previous][next][first][last][top][bottom][index][help] */
 193 extern inline int pgd_bad(pgd_t pgd)            { return (pgd_val(pgd) & ~PAGE_MASK) != _PAGE_TABLE || pgd_val(pgd) > high_memory; }
     /* [previous][next][first][last][top][bottom][index][help] */
 194 extern inline int pgd_present(pgd_t pgd)        { return pgd_val(pgd) & _PAGE_PRESENT; }
     /* [previous][next][first][last][top][bottom][index][help] */
 195 extern inline void pgd_clear(pgd_t * pgdp)      { pgd_val(*pgdp) = 0; }
     /* [previous][next][first][last][top][bottom][index][help] */
 196 
 197 /*
 198  * The following only work if pte_present() is true.
 199  * Undefined behaviour if not..
 200  */
 201 extern inline int pte_read(pte_t pte)           { return pte_val(pte) & _PAGE_USER; }
     /* [previous][next][first][last][top][bottom][index][help] */
 202 extern inline int pte_write(pte_t pte)          { return pte_val(pte) & _PAGE_RW; }
     /* [previous][next][first][last][top][bottom][index][help] */
 203 extern inline int pte_exec(pte_t pte)           { return pte_val(pte) & _PAGE_USER; }
     /* [previous][next][first][last][top][bottom][index][help] */
 204 extern inline int pte_dirty(pte_t pte)          { return pte_val(pte) & _PAGE_DIRTY; }
     /* [previous][next][first][last][top][bottom][index][help] */
 205 extern inline int pte_young(pte_t pte)          { return pte_val(pte) & _PAGE_ACCESSED; }
     /* [previous][next][first][last][top][bottom][index][help] */
 206 extern inline int pte_cow(pte_t pte)            { return pte_val(pte) & _PAGE_COW; }
     /* [previous][next][first][last][top][bottom][index][help] */
 207 
 208 extern inline pte_t pte_wrprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_RW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 209 extern inline pte_t pte_rdprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 210 extern inline pte_t pte_exprotect(pte_t pte)    { pte_val(pte) &= ~_PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 211 extern inline pte_t pte_mkclean(pte_t pte)      { pte_val(pte) &= ~_PAGE_DIRTY; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 212 extern inline pte_t pte_mkold(pte_t pte)        { pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 213 extern inline pte_t pte_uncow(pte_t pte)        { pte_val(pte) &= ~_PAGE_COW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 214 extern inline pte_t pte_mkwrite(pte_t pte)      { pte_val(pte) |= _PAGE_RW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 215 extern inline pte_t pte_mkread(pte_t pte)       { pte_val(pte) |= _PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 216 extern inline pte_t pte_mkexec(pte_t pte)       { pte_val(pte) |= _PAGE_USER; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 217 extern inline pte_t pte_mkdirty(pte_t pte)      { pte_val(pte) |= _PAGE_DIRTY; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 218 extern inline pte_t pte_mkyoung(pte_t pte)      { pte_val(pte) |= _PAGE_ACCESSED; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 219 extern inline pte_t pte_mkcow(pte_t pte)        { pte_val(pte) |= _PAGE_COW; return pte; }
     /* [previous][next][first][last][top][bottom][index][help] */
 220 
 221 /*
 222  * Conversion functions: convert a page and protection to a page entry,
 223  * and a page entry and page directory to the page they refer to.
 224  */
 225 extern inline pte_t mk_pte(unsigned long page, pgprot_t pgprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 226 { pte_t pte; pte_val(pte) = page | pgprot_val(pgprot); return pte; }
 227 
 228 extern inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
     /* [previous][next][first][last][top][bottom][index][help] */
 229 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
 230 
 231 extern inline unsigned long pte_page(pte_t pte) { return pte_val(pte) & PAGE_MASK; }
     /* [previous][next][first][last][top][bottom][index][help] */
 232 extern inline unsigned long pgd_page(pgd_t pgd) { return pgd_val(pgd) & PAGE_MASK; }
     /* [previous][next][first][last][top][bottom][index][help] */
 233 
 234 extern inline void pgd_set(pgd_t * pgdp, pte_t * ptep)
     /* [previous][next][first][last][top][bottom][index][help] */
 235 { pgd_val(*pgdp) = _PAGE_TABLE | (unsigned long) ptep; }
 236 
 237 #endif /* !defined (__ASSEMBLY__) */
 238 #endif /* defined (__KERNEL__) */
 239 
 240 #endif /* __ASM_MIPS_PAGE_H */

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