2 * This file contains the functions and defines necessary to modify and
3 * use the SuperH page table tree.
5 * Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2002 - 2007 Paul Mundt
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of this
10 * archive for more details.
12 #ifndef __ASM_SH_PGTABLE_H
13 #define __ASM_SH_PGTABLE_H
15 #include <asm/pgtable_nopmd.h>
19 #include <asm/addrspace.h>
20 #include <asm/fixmap.h>
23 * ZERO_PAGE is a global shared page that is always zero: used
24 * for zero-mapped memory areas etc..
26 extern unsigned long empty_zero_page
[PAGE_SIZE
/ sizeof(unsigned long)];
27 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
29 #endif /* !__ASSEMBLY__ */
32 * Effective and physical address definitions, to aid with sign
36 #define NEFF_SIGN (1LL << (NEFF - 1))
37 #define NEFF_MASK (-1LL << NEFF)
39 static inline unsigned long long neff_sign_extend(unsigned long val
)
41 unsigned long long extended
= val
;
42 return (extended
& NEFF_SIGN
) ? (extended
| NEFF_MASK
) : extended
;
51 #define NPHYS_SIGN (1LL << (NPHYS - 1))
52 #define NPHYS_MASK (-1LL << NPHYS)
54 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
55 #define PGDIR_MASK (~(PGDIR_SIZE-1))
57 /* Entries per level */
58 #define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE))
60 #define FIRST_USER_ADDRESS 0
62 #define PHYS_ADDR_MASK29 0x1fffffff
63 #define PHYS_ADDR_MASK32 0xffffffff
66 static inline unsigned long phys_addr_mask(void)
68 /* Is the MMU in 29bit mode? */
69 if (__in_29bit_mode())
70 return PHYS_ADDR_MASK29
;
72 return PHYS_ADDR_MASK32
;
74 #elif defined(CONFIG_32BIT)
75 static inline unsigned long phys_addr_mask(void)
77 return PHYS_ADDR_MASK32
;
80 static inline unsigned long phys_addr_mask(void)
82 return PHYS_ADDR_MASK29
;
86 #define PTE_PHYS_MASK (phys_addr_mask() & PAGE_MASK)
87 #define PTE_FLAGS_MASK (~(PTE_PHYS_MASK) << PAGE_SHIFT)
89 #ifdef CONFIG_SUPERH32
90 #define VMALLOC_START (P3SEG)
92 #define VMALLOC_START (0xf0000000)
94 #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
96 #if defined(CONFIG_SUPERH32)
97 #include <asm/pgtable_32.h>
99 #include <asm/pgtable_64.h>
103 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
104 * protection for execute, and considers it the same as a read. Also, write
105 * permission implies read permission. This is the closest we can get..
107 * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme,
108 * not only supporting separate execute, read, and write bits, but having
109 * completely separate permission bits for user and kernel space.
112 #define __P000 PAGE_NONE
113 #define __P001 PAGE_READONLY
114 #define __P010 PAGE_COPY
115 #define __P011 PAGE_COPY
116 #define __P100 PAGE_EXECREAD
117 #define __P101 PAGE_EXECREAD
118 #define __P110 PAGE_COPY
119 #define __P111 PAGE_COPY
121 #define __S000 PAGE_NONE
122 #define __S001 PAGE_READONLY
123 #define __S010 PAGE_WRITEONLY
124 #define __S011 PAGE_SHARED
125 #define __S100 PAGE_EXECREAD
126 #define __S101 PAGE_EXECREAD
127 #define __S110 PAGE_RWX
128 #define __S111 PAGE_RWX
130 typedef pte_t
*pte_addr_t
;
132 #define kern_addr_valid(addr) (1)
134 #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
135 remap_pfn_range(vma, vaddr, pfn, size, prot)
137 #define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
140 * No page table caches to initialise
142 #define pgtable_cache_init() do { } while (0)
144 struct vm_area_struct
;
146 extern void __update_cache(struct vm_area_struct
*vma
,
147 unsigned long address
, pte_t pte
);
148 extern void __update_tlb(struct vm_area_struct
*vma
,
149 unsigned long address
, pte_t pte
);
152 update_mmu_cache(struct vm_area_struct
*vma
, unsigned long address
, pte_t pte
)
154 __update_cache(vma
, address
, pte
);
155 __update_tlb(vma
, address
, pte
);
158 extern pgd_t swapper_pg_dir
[PTRS_PER_PGD
];
159 extern void paging_init(void);
160 extern void page_table_range_init(unsigned long start
, unsigned long end
,
163 /* arch/sh/mm/mmap.c */
164 #define HAVE_ARCH_UNMAPPED_AREA
165 #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
167 #include <asm-generic/pgtable.h>
169 #endif /* __ASM_SH_PGTABLE_H */