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 16 17
#include <asm-generic/pgtable-nopmd.h>
#include <asm/page.h>

L
Linus Torvalds 已提交
18 19 20 21 22 23 24 25
#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..
 */
26
extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
L
Linus Torvalds 已提交
27 28 29 30
#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))

#endif /* !__ASSEMBLY__ */

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

#ifdef CONFIG_29BIT
#define NPHYS		29
#else
#define NPHYS		32
#endif

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

48 49 50 51
/*
 * traditional two-level paging structure
 */
/* PTE bits */
52
#if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
53 54 55 56 57 58 59 60 61
# define PTE_MAGNITUDE	3	/* 64-bit PTEs on extended mode SH-X2 TLB */
#else
# define PTE_MAGNITUDE	2	/* 32-bit PTEs */
#endif
#define PTE_SHIFT	PAGE_SHIFT
#define PTE_BITS	(PTE_SHIFT - PTE_MAGNITUDE)

/* PGD bits */
#define PGDIR_SHIFT	(PTE_SHIFT + PTE_BITS)
62
#define PGDIR_SIZE	(1UL << PGDIR_SHIFT)
L
Linus Torvalds 已提交
63 64
#define PGDIR_MASK	(~(PGDIR_SIZE-1))

65
/* Entries per level */
66
#define PTRS_PER_PTE	(PAGE_SIZE / (1 << PTE_MAGNITUDE))
67
#define PTRS_PER_PGD	(PAGE_SIZE / sizeof(pgd_t))
68

L
Linus Torvalds 已提交
69
#define USER_PTRS_PER_PGD	(TASK_SIZE/PGDIR_SIZE)
70
#define FIRST_USER_ADDRESS	0
L
Linus Torvalds 已提交
71

72 73 74 75 76 77 78
#ifdef CONFIG_32BIT
#define PHYS_ADDR_MASK		0xffffffff
#else
#define PHYS_ADDR_MASK		0x1fffffff
#endif

#define PTE_PHYS_MASK		(PHYS_ADDR_MASK & PAGE_MASK)
P
Paul Mundt 已提交
79
#define PTE_FLAGS_MASK		(~(PTE_PHYS_MASK) << PAGE_SHIFT)
L
Linus Torvalds 已提交
80

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

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

/*
95 96 97 98 99 100 101
 * 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 已提交
102
 */
103
	 /*xwr*/
L
Linus Torvalds 已提交
104 105 106 107
#define __P000	PAGE_NONE
#define __P001	PAGE_READONLY
#define __P010	PAGE_COPY
#define __P011	PAGE_COPY
108 109
#define __P100	PAGE_EXECREAD
#define __P101	PAGE_EXECREAD
L
Linus Torvalds 已提交
110 111 112 113 114
#define __P110	PAGE_COPY
#define __P111	PAGE_COPY

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

typedef pte_t *pte_addr_t;

#define kern_addr_valid(addr)	(1)

#define io_remap_pfn_range(vma, vaddr, pfn, size, prot)		\
		remap_pfn_range(vma, vaddr, pfn, size, prot)

129
#define pte_pfn(x)		((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
130

L
Linus Torvalds 已提交
131 132 133 134 135
/*
 * No page table caches to initialise
 */
#define pgtable_cache_init()	do { } while (0)

136 137
#if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \
	defined(CONFIG_SH7705_CACHE_32KB))
138
struct mm_struct;
139
#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
140
pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
141 142
#endif

143 144 145
struct vm_area_struct;
extern void update_mmu_cache(struct vm_area_struct * vma,
			     unsigned long address, pte_t pte);
146 147
extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
extern void paging_init(void);
148 149
extern void page_table_range_init(unsigned long start, unsigned long end,
				  pgd_t *pgd);
150

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

153
#endif /* __ASM_SH_PGTABLE_H */