linux/arch/score/include/asm/pgtable.h
<<
>>
Prefs
   1#ifndef _ASM_SCORE_PGTABLE_H
   2#define _ASM_SCORE_PGTABLE_H
   3
   4#include <linux/const.h>
   5#define __ARCH_USE_5LEVEL_HACK
   6#include <asm-generic/pgtable-nopmd.h>
   7
   8#include <asm/fixmap.h>
   9#include <asm/setup.h>
  10#include <asm/pgtable-bits.h>
  11
  12extern void load_pgd(unsigned long pg_dir);
  13extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
  14
  15/* PGDIR_SHIFT determines what a third-level page table entry can map */
  16#define PGDIR_SHIFT     22
  17#define PGDIR_SIZE      (_AC(1, UL) << PGDIR_SHIFT)
  18#define PGDIR_MASK      (~(PGDIR_SIZE - 1))
  19
  20/*
  21 * Entries per page directory level: we use two-level, so
  22 * we don't really have any PUD/PMD directory physically.
  23 */
  24#define PGD_ORDER       0
  25#define PTE_ORDER       0
  26
  27#define PTRS_PER_PGD    1024
  28#define PTRS_PER_PTE    1024
  29
  30#define USER_PTRS_PER_PGD       (0x80000000UL/PGDIR_SIZE)
  31#define FIRST_USER_ADDRESS      0UL
  32
  33#define VMALLOC_START           (0xc0000000UL)
  34
  35#define PKMAP_BASE              (0xfd000000UL)
  36
  37#define VMALLOC_END             (FIXADDR_START - 2*PAGE_SIZE)
  38
  39#define pte_ERROR(e) \
  40        printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \
  41                __FILE__, __LINE__, pte_val(e))
  42#define pgd_ERROR(e) \
  43        printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \
  44                __FILE__, __LINE__, pgd_val(e))
  45
  46/*
  47 * Empty pgd/pmd entries point to the invalid_pte_table.
  48 */
  49static inline int pmd_none(pmd_t pmd)
  50{
  51        return pmd_val(pmd) == (unsigned long) invalid_pte_table;
  52}
  53
  54#define pmd_bad(pmd)            (pmd_val(pmd) & ~PAGE_MASK)
  55
  56static inline int pmd_present(pmd_t pmd)
  57{
  58        return pmd_val(pmd) != (unsigned long) invalid_pte_table;
  59}
  60
  61static inline void pmd_clear(pmd_t *pmdp)
  62{
  63        pmd_val(*pmdp) = ((unsigned long) invalid_pte_table);
  64}
  65
  66#define pte_page(x)             pfn_to_page(pte_pfn(x))
  67#define pte_pfn(x)              ((unsigned long)((x).pte >> PAGE_SHIFT))
  68#define pfn_pte(pfn, prot)      \
  69        __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
  70
  71#define __pgd_offset(address)   pgd_index(address)
  72#define __pud_offset(address)   (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
  73#define __pmd_offset(address)   (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
  74
  75/* to find an entry in a kernel page-table-directory */
  76#define pgd_offset_k(address)   pgd_offset(&init_mm, address)
  77#define pgd_index(address)      (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
  78
  79/* to find an entry in a page-table-directory */
  80#define pgd_offset(mm, addr)    ((mm)->pgd + pgd_index(addr))
  81
  82/* Find an entry in the third-level page table.. */
  83#define __pte_offset(address)           \
  84        (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
  85#define pte_offset(dir, address)        \
  86        ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
  87#define pte_offset_kernel(dir, address) \
  88        ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
  89
  90#define pte_offset_map(dir, address)    \
  91        ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
  92#define pte_unmap(pte) ((void)(pte))
  93
  94#define __pte_to_swp_entry(pte)         \
  95        ((swp_entry_t) { pte_val(pte)})
  96#define __swp_entry_to_pte(x)   ((pte_t) {(x).val})
  97
  98#define pmd_phys(pmd)           __pa((void *)pmd_val(pmd))
  99#define pmd_page(pmd)           (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
 100#define mk_pte(page, prot)      pfn_pte(page_to_pfn(page), prot)
 101static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
 102
 103#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
 104#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
 105#define pte_clear(mm, addr, xp)         \
 106        do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
 107
 108/*
 109 * The "pgd_xxx()" functions here are trivial for a folded two-level
 110 * setup: the pgd is never bad, and a pmd always exists (as it's folded
 111 * into the pgd entry)
 112 */
 113#define pgd_present(pgd)        (1)
 114#define pgd_none(pgd)           (0)
 115#define pgd_bad(pgd)            (0)
 116#define pgd_clear(pgdp)         do { } while (0)
 117
 118#define kern_addr_valid(addr)   (1)
 119#define pmd_page_vaddr(pmd)     pmd_val(pmd)
 120
 121#define pte_none(pte)           (!(pte_val(pte) & ~_PAGE_GLOBAL))
 122#define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
 123
 124#define PAGE_NONE       __pgprot(_PAGE_PRESENT | _PAGE_CACHE)
 125#define PAGE_SHARED     __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
 126                                _PAGE_CACHE)
 127#define PAGE_COPY       __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHE)
 128#define PAGE_READONLY   __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHE)
 129#define PAGE_KERNEL     __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE | \
 130                                _PAGE_GLOBAL | _PAGE_CACHE)
 131#define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE | \
 132                                __WRITEABLE | _PAGE_GLOBAL & ~_PAGE_CACHE)
 133
 134#define __P000  PAGE_NONE
 135#define __P001  PAGE_READONLY
 136#define __P010  PAGE_COPY
 137#define __P011  PAGE_COPY
 138#define __P100  PAGE_READONLY
 139#define __P101  PAGE_READONLY
 140#define __P110  PAGE_COPY
 141#define __P111  PAGE_COPY
 142
 143#define __S000  PAGE_NONE
 144#define __S001  PAGE_READONLY
 145#define __S010  PAGE_SHARED
 146#define __S011  PAGE_SHARED
 147#define __S100  PAGE_READONLY
 148#define __S101  PAGE_READONLY
 149#define __S110  PAGE_SHARED
 150#define __S111  PAGE_SHARED
 151
 152#define pgprot_noncached pgprot_noncached
 153
 154static inline pgprot_t pgprot_noncached(pgprot_t _prot)
 155{
 156        unsigned long prot = pgprot_val(_prot);
 157
 158        prot = (prot & ~_CACHE_MASK);
 159
 160        return __pgprot(prot);
 161}
 162
 163#define __swp_type(x)           ((x).val & 0x1f)
 164#define __swp_offset(x)         ((x).val >> 10)
 165#define __swp_entry(type, offset) ((swp_entry_t){(type) | ((offset) << 10)})
 166
 167extern unsigned long empty_zero_page;
 168extern unsigned long zero_page_mask;
 169
 170#define ZERO_PAGE(vaddr) \
 171        (virt_to_page((void *)(empty_zero_page + \
 172         (((unsigned long)(vaddr)) & zero_page_mask))))
 173
 174#define pgtable_cache_init()    do {} while (0)
 175
 176#define arch_enter_lazy_cpu_mode()      do {} while (0)
 177
 178static inline int pte_write(pte_t pte)
 179{
 180        return pte_val(pte) & _PAGE_WRITE;
 181}
 182
 183static inline int pte_dirty(pte_t pte)
 184{
 185        return pte_val(pte) & _PAGE_MODIFIED;
 186}
 187
 188static inline int pte_young(pte_t pte)
 189{
 190        return pte_val(pte) & _PAGE_ACCESSED;
 191}
 192
 193#define pte_special(pte)        (0)
 194
 195static inline pte_t pte_wrprotect(pte_t pte)
 196{
 197        pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
 198        return pte;
 199}
 200
 201static inline pte_t pte_mkclean(pte_t pte)
 202{
 203        pte_val(pte) &= ~(_PAGE_MODIFIED|_PAGE_SILENT_WRITE);
 204        return pte;
 205}
 206
 207static inline pte_t pte_mkold(pte_t pte)
 208{
 209        pte_val(pte) &= ~(_PAGE_ACCESSED|_PAGE_SILENT_READ);
 210        return pte;
 211}
 212
 213static inline pte_t pte_mkwrite(pte_t pte)
 214{
 215        pte_val(pte) |= _PAGE_WRITE;
 216        if (pte_val(pte) & _PAGE_MODIFIED)
 217                pte_val(pte) |= _PAGE_SILENT_WRITE;
 218        return pte;
 219}
 220
 221static inline pte_t pte_mkdirty(pte_t pte)
 222{
 223        pte_val(pte) |= _PAGE_MODIFIED;
 224        if (pte_val(pte) & _PAGE_WRITE)
 225                pte_val(pte) |= _PAGE_SILENT_WRITE;
 226        return pte;
 227}
 228
 229static inline pte_t pte_mkyoung(pte_t pte)
 230{
 231        pte_val(pte) |= _PAGE_ACCESSED;
 232        if (pte_val(pte) & _PAGE_READ)
 233                pte_val(pte) |= _PAGE_SILENT_READ;
 234        return pte;
 235}
 236
 237#define set_pmd(pmdptr, pmdval)         \
 238         do { *(pmdptr) = (pmdval); } while (0)
 239#define pte_present(pte)        (pte_val(pte) & _PAGE_PRESENT)
 240
 241extern unsigned long pgd_current;
 242extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 243extern void paging_init(void);
 244
 245static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 246{
 247        return __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot));
 248}
 249
 250extern void __update_tlb(struct vm_area_struct *vma,
 251        unsigned long address,  pte_t pte);
 252extern void __update_cache(struct vm_area_struct *vma,
 253        unsigned long address,  pte_t pte);
 254
 255static inline void update_mmu_cache(struct vm_area_struct *vma,
 256        unsigned long address, pte_t *ptep)
 257{
 258        pte_t pte = *ptep;
 259        __update_tlb(vma, address, pte);
 260        __update_cache(vma, address, pte);
 261}
 262
 263#ifndef __ASSEMBLY__
 264#include <asm-generic/pgtable.h>
 265
 266void setup_memory(void);
 267#endif /* __ASSEMBLY__ */
 268
 269#endif /* _ASM_SCORE_PGTABLE_H */
 270