1 #ifndef _ASM_POWERPC_PGTABLE_PPC32_H
2 #define _ASM_POWERPC_PGTABLE_PPC32_H
7 #include <linux/sched.h>
32 #define PGDIR_SHIFT (PAGE_SHIFT + PTE_SHIFT)
33 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
34 #define PGDIR_MASK (~(PGDIR_SIZE-1))
41 #define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_SHIFT)
42 #define PGD_TABLE_SIZE (sizeof(pgd_t) << (32 - PGDIR_SHIFT))
45 #define PTRS_PER_PTE (1 << PTE_SHIFT)
46 #define PTRS_PER_PMD 1
47 #define PTRS_PER_PGD (1 << (32 - PGDIR_SHIFT))
49 #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
50 #define FIRST_USER_ADDRESS 0
52 #define pte_ERROR(e) \
53 printk("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \
54 (unsigned long long)pte_val(e))
55 #define pgd_ERROR(e) \
56 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
64 #define KVIRT_TOP PKMAP_BASE
66 #define KVIRT_TOP (0xfe000000UL)
74 #ifdef CONFIG_NOT_COHERENT_CACHE
75 #define IOREMAP_TOP ((KVIRT_TOP - CONFIG_CONSISTENT_SIZE) & PAGE_MASK)
77 #define IOREMAP_TOP KVIRT_TOP
97 #define VMALLOC_OFFSET (0x1000000)
99 #define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
101 #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
103 #define VMALLOC_END ioremap_bot
110 #if defined(CONFIG_40x)
112 #elif defined(CONFIG_44x)
114 #elif defined(CONFIG_FSL_BOOKE) && defined(CONFIG_PTE_64BIT)
116 #elif defined(CONFIG_FSL_BOOKE)
118 #elif defined(CONFIG_8xx)
129 #define pte_clear(mm, addr, ptep) \
130 do { pte_update(ptep, ~_PAGE_HASHPTE, 0); } while (0)
132 #define pmd_none(pmd) (!pmd_val(pmd))
133 #define pmd_bad(pmd) (pmd_val(pmd) & _PMD_BAD)
134 #define pmd_present(pmd) (pmd_val(pmd) & _PMD_PRESENT_MASK)
135 #define pmd_clear(pmdp) do { pmd_val(*(pmdp)) = 0; } while (0)
142 unsigned long pmdval,
int count);
146 unsigned long pmdval);
167 #ifndef CONFIG_PTE_64BIT
172 #ifdef PTE_ATOMIC_UPDATES
173 unsigned long old,
tmp;
182 :
"=&r" (old),
"=&r" (tmp),
"=m" (*p)
183 :
"r" (p),
"r" (clr),
"r" (
set),
"m" (*p)
186 unsigned long old =
pte_val(*p);
187 *p =
__pte((old & ~clr) |
set);
201 #ifdef PTE_ATOMIC_UPDATES
202 unsigned long long old;
213 :
"=&r" (old),
"=&r" (tmp),
"=m" (*p)
214 :
"r" (p),
"r" ((
unsigned long)(p) + 4),
"r" (clr),
"r" (
set),
"m" (*p)
217 unsigned long long old =
pte_val(*p);
218 *p =
__pte((old & ~(
unsigned long long)clr) |
set);
233 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
234 static inline int __ptep_test_and_clear_young(
unsigned int context,
unsigned long addr,
pte_t *ptep)
238 #if _PAGE_HASHPTE != 0
246 #define ptep_test_and_clear_young(__vma, __addr, __ptep) \
247 __ptep_test_and_clear_young((__vma)->vm_mm->context.id, __addr, __ptep)
249 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
256 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
257 static inline void ptep_set_wrprotect(
struct mm_struct *mm,
unsigned long addr,
265 ptep_set_wrprotect(mm, addr, ptep);
276 #define __HAVE_ARCH_PTE_SAME
277 #define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HASHPTE) == 0)
287 #define pmd_page_vaddr(pmd) \
288 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
289 #define pmd_page(pmd) \
290 pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)
292 #define pmd_page_vaddr(pmd) \
293 ((unsigned long) (pmd_val(pmd) & PAGE_MASK))
294 #define pmd_page(pmd) \
295 pfn_to_page((__pa(pmd_val(pmd)) >> PAGE_SHIFT))
299 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
302 #define pgd_index(address) ((address) >> PGDIR_SHIFT)
303 #define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
306 #define pte_index(address) \
307 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
308 #define pte_offset_kernel(dir, addr) \
309 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
310 #define pte_offset_map(dir, addr) \
311 ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
312 #define pte_unmap(pte) kunmap_atomic(pte)
320 #define __swp_type(entry) ((entry).val & 0x1f)
321 #define __swp_offset(entry) ((entry).val >> 5)
322 #define __swp_entry(type, offset) ((swp_entry_t) { (type) | ((offset) << 5) })
323 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> 3 })
324 #define __swp_entry_to_pte(x) ((pte_t) { (x).val << 3 })
327 #define PTE_FILE_MAX_BITS 29
328 #define pte_to_pgoff(pte) (pte_val(pte) >> 3)
329 #define pgoff_to_pte(off) ((pte_t) { ((off) << 3) | _PAGE_FILE })
334 #define pgtable_cache_init() do { } while (0)