aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/include/asm
diff options
context:
space:
mode:
authorMatt Fleming <matt@console-pimps.org>2009-11-25 17:00:08 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-12-17 00:31:15 -0500
commitb73c806341cfc7492ede6a2ce713cb579547d0ab (patch)
tree9318727eab90409f518c95031445063e93c0a651 /arch/sh/include/asm
parent2f7bb2dfed3b15b388c88250b66f590aabc438da (diff)
sh: Abstract the number of page table levels
Keep the dimensions of the page tables in a separate header file in preparation for allowing a three level page table structure. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/include/asm')
-rw-r--r--arch/sh/include/asm/pgalloc.h24
-rw-r--r--arch/sh/include/asm/pgalloc_nopmd.h30
-rw-r--r--arch/sh/include/asm/pgtable.h18
-rw-r--r--arch/sh/include/asm/pgtable_nopmd.h22
4 files changed, 56 insertions, 38 deletions
diff --git a/arch/sh/include/asm/pgalloc.h b/arch/sh/include/asm/pgalloc.h
index 63ca37bd9a95..fe9f037ac5fd 100644
--- a/arch/sh/include/asm/pgalloc.h
+++ b/arch/sh/include/asm/pgalloc.h
@@ -4,9 +4,10 @@
4#include <linux/quicklist.h> 4#include <linux/quicklist.h>
5#include <asm/page.h> 5#include <asm/page.h>
6 6
7#define QUICK_PGD 0 /* We preserve special mappings over free */
8#define QUICK_PT 1 /* Other page table pages that are zero on free */ 7#define QUICK_PT 1 /* Other page table pages that are zero on free */
9 8
9#include <asm/pgalloc_nopmd.h>
10
10static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, 11static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
11 pte_t *pte) 12 pte_t *pte)
12{ 13{
@@ -20,28 +21,9 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
20} 21}
21#define pmd_pgtable(pmd) pmd_page(pmd) 22#define pmd_pgtable(pmd) pmd_page(pmd)
22 23
23static inline void pgd_ctor(void *x)
24{
25 pgd_t *pgd = x;
26
27 memcpy(pgd + USER_PTRS_PER_PGD,
28 swapper_pg_dir + USER_PTRS_PER_PGD,
29 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
30}
31
32/* 24/*
33 * Allocate and free page tables. 25 * Allocate and free page tables.
34 */ 26 */
35static inline pgd_t *pgd_alloc(struct mm_struct *mm)
36{
37 return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
38}
39
40static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
41{
42 quicklist_free(QUICK_PGD, NULL, pgd);
43}
44
45static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 27static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
46 unsigned long address) 28 unsigned long address)
47{ 29{
@@ -81,7 +63,7 @@ do { \
81 63
82static inline void check_pgt_cache(void) 64static inline void check_pgt_cache(void)
83{ 65{
84 quicklist_trim(QUICK_PGD, NULL, 25, 16); 66 __check_pgt_cache();
85 quicklist_trim(QUICK_PT, NULL, 25, 16); 67 quicklist_trim(QUICK_PT, NULL, 25, 16);
86} 68}
87 69
diff --git a/arch/sh/include/asm/pgalloc_nopmd.h b/arch/sh/include/asm/pgalloc_nopmd.h
new file mode 100644
index 000000000000..e4b344c37e74
--- /dev/null
+++ b/arch/sh/include/asm/pgalloc_nopmd.h
@@ -0,0 +1,30 @@
1#ifndef __ASM_SH_PGALLOC_NOPMD_H
2#define __ASM_SH_PGALLOC_NOPMD_H
3
4#define QUICK_PGD 0 /* We preserve special mappings over free */
5
6static inline void pgd_ctor(void *x)
7{
8 pgd_t *pgd = x;
9
10 memcpy(pgd + USER_PTRS_PER_PGD,
11 swapper_pg_dir + USER_PTRS_PER_PGD,
12 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
13}
14
15static inline pgd_t *pgd_alloc(struct mm_struct *mm)
16{
17 return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
18}
19
20static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
21{
22 quicklist_free(QUICK_PGD, NULL, pgd);
23}
24
25static inline void __check_pgt_cache(void)
26{
27 quicklist_trim(QUICK_PGD, NULL, 25, 16);
28}
29
30#endif /* __ASM_SH_PGALLOC_NOPMD_H */
diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h
index ba3046e4f06f..9a0f66c1134c 100644
--- a/arch/sh/include/asm/pgtable.h
+++ b/arch/sh/include/asm/pgtable.h
@@ -12,7 +12,7 @@
12#ifndef __ASM_SH_PGTABLE_H 12#ifndef __ASM_SH_PGTABLE_H
13#define __ASM_SH_PGTABLE_H 13#define __ASM_SH_PGTABLE_H
14 14
15#include <asm-generic/pgtable-nopmd.h> 15#include <asm/pgtable_nopmd.h>
16#include <asm/page.h> 16#include <asm/page.h>
17 17
18#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
@@ -51,28 +51,12 @@ static inline unsigned long long neff_sign_extend(unsigned long val)
51#define NPHYS_SIGN (1LL << (NPHYS - 1)) 51#define NPHYS_SIGN (1LL << (NPHYS - 1))
52#define NPHYS_MASK (-1LL << NPHYS) 52#define NPHYS_MASK (-1LL << NPHYS)
53 53
54/*
55 * traditional two-level paging structure
56 */
57/* PTE bits */
58#if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
59# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
60#else
61# define PTE_MAGNITUDE 2 /* 32-bit PTEs */
62#endif
63#define PTE_SHIFT PAGE_SHIFT
64#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
65
66/* PGD bits */
67#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
68#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 54#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
69#define PGDIR_MASK (~(PGDIR_SIZE-1)) 55#define PGDIR_MASK (~(PGDIR_SIZE-1))
70 56
71/* Entries per level */ 57/* Entries per level */
72#define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE)) 58#define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE))
73#define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t))
74 59
75#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
76#define FIRST_USER_ADDRESS 0 60#define FIRST_USER_ADDRESS 0
77 61
78#define PHYS_ADDR_MASK29 0x1fffffff 62#define PHYS_ADDR_MASK29 0x1fffffff
diff --git a/arch/sh/include/asm/pgtable_nopmd.h b/arch/sh/include/asm/pgtable_nopmd.h
new file mode 100644
index 000000000000..f0b525b3cb4a
--- /dev/null
+++ b/arch/sh/include/asm/pgtable_nopmd.h
@@ -0,0 +1,22 @@
1#ifndef __ASM_SH_PGTABLE_NOPMD_H
2#define __ASM_SH_PGTABLE_NOPMD_H
3
4#include <asm-generic/pgtable-nopmd.h>
5
6/*
7 * traditional two-level paging structure
8 */
9
10/* PTE bits */
11#define PTE_MAGNITUDE 2 /* 32-bit PTEs */
12
13#define PTE_SHIFT PAGE_SHIFT
14#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
15
16/* PGD bits */
17#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
18
19#define PTRS_PER_PGD (PAGE_SIZE / (1 << PTE_MAGNITUDE))
20#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
21
22#endif /* __ASM_SH_PGTABLE_NOPMD_H */