pgtable.h 4.0 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2 3 4
 * This file contains the functions and defines necessary to modify and
 * use the SuperH page table tree.
 *
L
Linus Torvalds 已提交
5
 * Copyright (C) 1999 Niibe Yutaka
6
 * Copyright (C) 2002 - 2007 Paul Mundt
7 8 9 10
 *
 * This file is subject to the terms and conditions of the GNU General
 * Public License.  See the file "COPYING" in the main directory of this
 * archive for more details.
L
Linus Torvalds 已提交
11
 */
12 13
#ifndef __ASM_SH_PGTABLE_H
#define __ASM_SH_PGTABLE_H
L
Linus Torvalds 已提交
14

15
#ifdef CONFIG_X2TLB
16
#include <asm/pgtable-3level.h>
17
#else
18
#include <asm/pgtable-2level.h>
19
#endif
20
#include <asm/page.h>
P
Paul Mundt 已提交
21
#include <asm/mmu.h>
22

L
Linus Torvalds 已提交
23 24 25 26 27 28 29 30
#ifndef __ASSEMBLY__
#include <asm/addrspace.h>
#include <asm/fixmap.h>

/*
 * ZERO_PAGE is a global shared page that is always zero: used
 * for zero-mapped memory areas etc..
 */
31
extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
L
Linus Torvalds 已提交
32 33 34 35
#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))

#endif /* !__ASSEMBLY__ */

36 37 38 39 40 41 42 43
/*
 * Effective and physical address definitions, to aid with sign
 * extension.
 */
#define NEFF		32
#define	NEFF_SIGN	(1LL << (NEFF - 1))
#define	NEFF_MASK	(-1LL << NEFF)

44 45 46 47 48 49
static inline unsigned long long neff_sign_extend(unsigned long val)
{
	unsigned long long extended = val;
	return (extended & NEFF_SIGN) ? (extended | NEFF_MASK) : extended;
}

50 51 52 53 54 55 56 57 58
#ifdef CONFIG_29BIT
#define NPHYS		29
#else
#define NPHYS		32
#endif

#define	NPHYS_SIGN	(1LL << (NPHYS - 1))
#define	NPHYS_MASK	(-1LL << NPHYS)

59
#define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
L
Linus Torvalds 已提交
60 61
#define PGDIR_MASK	(~(PGDIR_SIZE-1))

62
/* Entries per level */
63
#define PTRS_PER_PTE	(PAGE_SIZE / (1 << PTE_MAGNITUDE))
64

65
#define FIRST_USER_ADDRESS	0UL
L
Linus Torvalds 已提交
66

M
Matt Fleming 已提交
67 68 69 70 71 72 73 74 75 76 77
#define PHYS_ADDR_MASK29		0x1fffffff
#define PHYS_ADDR_MASK32		0xffffffff

static inline unsigned long phys_addr_mask(void)
{
	/* Is the MMU in 29bit mode? */
	if (__in_29bit_mode())
		return PHYS_ADDR_MASK29;

	return PHYS_ADDR_MASK32;
}
78

M
Matt Fleming 已提交
79
#define PTE_PHYS_MASK		(phys_addr_mask() & PAGE_MASK)
P
Paul Mundt 已提交
80
#define PTE_FLAGS_MASK		(~(PTE_PHYS_MASK) << PAGE_SHIFT)
L
Linus Torvalds 已提交
81

P
Paul Mundt 已提交
82
#ifdef CONFIG_SUPERH32
83
#define VMALLOC_START	(P3SEG)
P
Paul Mundt 已提交
84 85 86
#else
#define VMALLOC_START	(0xf0000000)
#endif
L
Linus Torvalds 已提交
87 88
#define VMALLOC_END	(FIXADDR_START-2*PAGE_SIZE)

89 90
#if defined(CONFIG_SUPERH32)
#include <asm/pgtable_32.h>
91
#else
92
#include <asm/pgtable_64.h>
L
Linus Torvalds 已提交
93 94 95
#endif

/*
96 97 98 99 100 101 102
 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
 * protection for execute, and considers it the same as a read. Also, write
 * permission implies read permission. This is the closest we can get..
 *
 * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme,
 * not only supporting separate execute, read, and write bits, but having
 * completely separate permission bits for user and kernel space.
L
Linus Torvalds 已提交
103
 */
104
	 /*xwr*/
L
Linus Torvalds 已提交
105 106 107 108
#define __P000	PAGE_NONE
#define __P001	PAGE_READONLY
#define __P010	PAGE_COPY
#define __P011	PAGE_COPY
109 110
#define __P100	PAGE_EXECREAD
#define __P101	PAGE_EXECREAD
L
Linus Torvalds 已提交
111 112 113 114 115
#define __P110	PAGE_COPY
#define __P111	PAGE_COPY

#define __S000	PAGE_NONE
#define __S001	PAGE_READONLY
116
#define __S010	PAGE_WRITEONLY
L
Linus Torvalds 已提交
117
#define __S011	PAGE_SHARED
118 119 120 121
#define __S100	PAGE_EXECREAD
#define __S101	PAGE_EXECREAD
#define __S110	PAGE_RWX
#define __S111	PAGE_RWX
L
Linus Torvalds 已提交
122 123 124 125 126

typedef pte_t *pte_addr_t;

#define kern_addr_valid(addr)	(1)

127
#define pte_pfn(x)		((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
128

L
Linus Torvalds 已提交
129
/*
130
 * Initialise the page table caches
L
Linus Torvalds 已提交
131
 */
132
extern void pgtable_cache_init(void);
L
Linus Torvalds 已提交
133

134
struct vm_area_struct;
135
struct mm_struct;
136 137 138 139 140 141 142

extern void __update_cache(struct vm_area_struct *vma,
			   unsigned long address, pte_t pte);
extern void __update_tlb(struct vm_area_struct *vma,
			 unsigned long address, pte_t pte);

static inline void
143
update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
144
{
145
	pte_t pte = *ptep;
146 147 148 149
	__update_cache(vma, address, pte);
	__update_tlb(vma, address, pte);
}

150 151
extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
extern void paging_init(void);
152 153
extern void page_table_range_init(unsigned long start, unsigned long end,
				  pgd_t *pgd);
154

155 156 157 158
/* arch/sh/mm/mmap.c */
#define HAVE_ARCH_UNMAPPED_AREA
#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN

L
Linus Torvalds 已提交
159 160
#include <asm-generic/pgtable.h>

161
#endif /* __ASM_SH_PGTABLE_H */