aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2006-09-27 02:13:36 -0400
committerPaul Mundt <lethal@linux-sh.org>2006-09-27 02:13:36 -0400
commit26ff6c11ef38e08990c1e417c299246e6ab18ff7 (patch)
treeebd37fd0270b7c7dfe8474a046663db78fcdb1ab /include/asm-sh
parent9359e757709a211040e4b0151eae69248e7c6eca (diff)
sh: page table alloc cleanups and page fault optimizations.
Cleanup of page table allocators, using generic folded PMD and PUD helpers. TLB flushing operations are moved to a more sensible spot. The page fault handler is also optimized slightly, we no longer waste cycles on IRQ disabling for flushing of the page from the ITLB, since we're already under CLI protection by the initial exception handler. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh')
-rw-r--r--include/asm-sh/cache.h8
-rw-r--r--include/asm-sh/cacheflush.h1
-rw-r--r--include/asm-sh/cpu-sh3/cacheflush.h8
-rw-r--r--include/asm-sh/cpu-sh4/cacheflush.h29
-rw-r--r--include/asm-sh/page.h12
-rw-r--r--include/asm-sh/pgalloc.h37
-rw-r--r--include/asm-sh/pgtable.h80
7 files changed, 73 insertions, 102 deletions
diff --git a/include/asm-sh/cache.h b/include/asm-sh/cache.h
index 33f13367054b..e3a180cf5062 100644
--- a/include/asm-sh/cache.h
+++ b/include/asm-sh/cache.h
@@ -10,7 +10,6 @@
10#ifdef __KERNEL__ 10#ifdef __KERNEL__
11 11
12#include <asm/cpu/cache.h> 12#include <asm/cpu/cache.h>
13#include <asm/cpu/cacheflush.h>
14 13
15#define SH_CACHE_VALID 1 14#define SH_CACHE_VALID 1
16#define SH_CACHE_UPDATED 2 15#define SH_CACHE_UPDATED 2
@@ -49,12 +48,5 @@ struct cache_info {
49 unsigned long flags; 48 unsigned long flags;
50}; 49};
51 50
52/* Flush (write-back only) a region (smaller than a page) */
53extern void __flush_wback_region(void *start, int size);
54/* Flush (write-back & invalidate) a region (smaller than a page) */
55extern void __flush_purge_region(void *start, int size);
56/* Flush (invalidate only) a region (smaller than a page) */
57extern void __flush_invalidate_region(void *start, int size);
58
59#endif /* __KERNEL__ */ 51#endif /* __KERNEL__ */
60#endif /* __ASM_SH_CACHE_H */ 52#endif /* __ASM_SH_CACHE_H */
diff --git a/include/asm-sh/cacheflush.h b/include/asm-sh/cacheflush.h
index 9dfb33edb008..92930b4a40d4 100644
--- a/include/asm-sh/cacheflush.h
+++ b/include/asm-sh/cacheflush.h
@@ -2,6 +2,7 @@
2#define __ASM_SH_CACHEFLUSH_H 2#define __ASM_SH_CACHEFLUSH_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/mm.h>
5#include <asm/cpu/cacheflush.h> 6#include <asm/cpu/cacheflush.h>
6 7
7/* Flush (write-back only) a region (smaller than a page) */ 8/* Flush (write-back only) a region (smaller than a page) */
diff --git a/include/asm-sh/cpu-sh3/cacheflush.h b/include/asm-sh/cpu-sh3/cacheflush.h
index f51aed00c68f..db0cb071ea8e 100644
--- a/include/asm-sh/cpu-sh3/cacheflush.h
+++ b/include/asm-sh/cpu-sh3/cacheflush.h
@@ -10,7 +10,7 @@
10#ifndef __ASM_CPU_SH3_CACHEFLUSH_H 10#ifndef __ASM_CPU_SH3_CACHEFLUSH_H
11#define __ASM_CPU_SH3_CACHEFLUSH_H 11#define __ASM_CPU_SH3_CACHEFLUSH_H
12 12
13/* 13/*
14 * Cache flushing: 14 * Cache flushing:
15 * 15 *
16 * - flush_cache_all() flushes entire cache 16 * - flush_cache_all() flushes entire cache
@@ -35,10 +35,6 @@
35 /* 32KB cache, 4kb PAGE sizes need to check bit 12 */ 35 /* 32KB cache, 4kb PAGE sizes need to check bit 12 */
36#define CACHE_ALIAS 0x00001000 36#define CACHE_ALIAS 0x00001000
37 37
38struct page;
39struct mm_struct;
40struct vm_area_struct;
41
42extern void flush_cache_all(void); 38extern void flush_cache_all(void);
43extern void flush_cache_mm(struct mm_struct *mm); 39extern void flush_cache_mm(struct mm_struct *mm);
44extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 40extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
@@ -79,8 +75,6 @@ extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);
79 75
80#define p3_cache_init() do { } while (0) 76#define p3_cache_init() do { } while (0)
81 77
82#define HAVE_ARCH_UNMAPPED_AREA
83
84#endif 78#endif
85 79
86#endif /* __ASM_CPU_SH3_CACHEFLUSH_H */ 80#endif /* __ASM_CPU_SH3_CACHEFLUSH_H */
diff --git a/include/asm-sh/cpu-sh4/cacheflush.h b/include/asm-sh/cpu-sh4/cacheflush.h
index ea58c4c5944d..a95fc951aff6 100644
--- a/include/asm-sh/cpu-sh4/cacheflush.h
+++ b/include/asm-sh/cpu-sh4/cacheflush.h
@@ -16,30 +16,26 @@
16 * caching; in which case they're only semi-broken), 16 * caching; in which case they're only semi-broken),
17 * so we need them. 17 * so we need them.
18 */ 18 */
19struct page; 19void flush_cache_all(void);
20struct mm_struct; 20void flush_cache_mm(struct mm_struct *mm);
21struct vm_area_struct; 21void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
22 22 unsigned long end);
23extern void flush_cache_all(void); 23void flush_cache_page(struct vm_area_struct *vma, unsigned long addr,
24extern void flush_cache_mm(struct mm_struct *mm); 24 unsigned long pfn);
25extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 25void flush_dcache_page(struct page *pg);
26 unsigned long end);
27extern void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn);
28extern void flush_dcache_page(struct page *pg);
29 26
30#define flush_dcache_mmap_lock(mapping) do { } while (0) 27#define flush_dcache_mmap_lock(mapping) do { } while (0)
31#define flush_dcache_mmap_unlock(mapping) do { } while (0) 28#define flush_dcache_mmap_unlock(mapping) do { } while (0)
32 29
33extern void flush_icache_range(unsigned long start, unsigned long end); 30void flush_icache_range(unsigned long start, unsigned long end);
34extern void flush_cache_sigtramp(unsigned long addr); 31void flush_cache_sigtramp(unsigned long addr);
35extern void flush_icache_user_range(struct vm_area_struct *vma, 32void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
36 struct page *page, unsigned long addr, 33 unsigned long addr, int len);
37 int len);
38 34
39#define flush_icache_page(vma,pg) do { } while (0) 35#define flush_icache_page(vma,pg) do { } while (0)
40 36
41/* Initialization of P3 area for copy_user_page */ 37/* Initialization of P3 area for copy_user_page */
42extern void p3_cache_init(void); 38void p3_cache_init(void);
43 39
44#define PG_mapped PG_arch_1 40#define PG_mapped PG_arch_1
45 41
@@ -57,4 +53,3 @@ static inline int remap_area_pages(unsigned long addr, unsigned long phys_addr,
57} 53}
58#endif /* CONFIG_MMU */ 54#endif /* CONFIG_MMU */
59#endif /* __ASM_CPU_SH4_CACHEFLUSH_H */ 55#endif /* __ASM_CPU_SH4_CACHEFLUSH_H */
60
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index 4811d410d123..51d7281a546a 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -41,7 +41,8 @@ extern void (*copy_page)(void *to, void *from);
41extern void clear_page_slow(void *to); 41extern void clear_page_slow(void *to);
42extern void copy_page_slow(void *to, void *from); 42extern void copy_page_slow(void *to, void *from);
43 43
44#if defined(CONFIG_SH7705_CACHE_32KB) && defined(CONFIG_MMU) 44#if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
45 defined(CONFIG_SH7705_CACHE_32KB))
45struct page; 46struct page;
46extern void clear_user_page(void *to, unsigned long address, struct page *pg); 47extern void clear_user_page(void *to, unsigned long address, struct page *pg);
47extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); 48extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
@@ -50,29 +51,20 @@ extern void __copy_user_page(void *to, void *from, void *orig_to);
50#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU) 51#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
51#define clear_user_page(page, vaddr, pg) clear_page(page) 52#define clear_user_page(page, vaddr, pg) clear_page(page)
52#define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 53#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
53#elif defined(CONFIG_CPU_SH4)
54struct page;
55extern void clear_user_page(void *to, unsigned long address, struct page *pg);
56extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
57extern void __clear_user_page(void *to, void *orig_to);
58extern void __copy_user_page(void *to, void *from, void *orig_to);
59#endif 54#endif
60 55
61/* 56/*
62 * These are used to make use of C type-checking.. 57 * These are used to make use of C type-checking..
63 */ 58 */
64typedef struct { unsigned long pte; } pte_t; 59typedef struct { unsigned long pte; } pte_t;
65typedef struct { unsigned long pmd; } pmd_t;
66typedef struct { unsigned long pgd; } pgd_t; 60typedef struct { unsigned long pgd; } pgd_t;
67typedef struct { unsigned long pgprot; } pgprot_t; 61typedef struct { unsigned long pgprot; } pgprot_t;
68 62
69#define pte_val(x) ((x).pte) 63#define pte_val(x) ((x).pte)
70#define pmd_val(x) ((x).pmd)
71#define pgd_val(x) ((x).pgd) 64#define pgd_val(x) ((x).pgd)
72#define pgprot_val(x) ((x).pgprot) 65#define pgprot_val(x) ((x).pgprot)
73 66
74#define __pte(x) ((pte_t) { (x) } ) 67#define __pte(x) ((pte_t) { (x) } )
75#define __pmd(x) ((pmd_t) { (x) } )
76#define __pgd(x) ((pgd_t) { (x) } ) 68#define __pgd(x) ((pgd_t) { (x) } )
77#define __pgprot(x) ((pgprot_t) { (x) } ) 69#define __pgprot(x) ((pgprot_t) { (x) } )
78 70
diff --git a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h
index f4f233f7a4f5..e841465ab4d2 100644
--- a/include/asm-sh/pgalloc.h
+++ b/include/asm-sh/pgalloc.h
@@ -1,15 +1,6 @@
1#ifndef __ASM_SH_PGALLOC_H 1#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H 2#define __ASM_SH_PGALLOC_H
3 3
4#include <linux/threads.h>
5#include <linux/slab.h>
6#include <linux/mm.h>
7
8#define pgd_quicklist ((unsigned long *)0)
9#define pmd_quicklist ((unsigned long *)0)
10#define pte_quicklist ((unsigned long *)0)
11#define pgtable_cache_size 0L
12
13#define pmd_populate_kernel(mm, pmd, pte) \ 4#define pmd_populate_kernel(mm, pmd, pte) \
14 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) 5 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
15 6
@@ -24,38 +15,24 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
24 */ 15 */
25static inline pgd_t *pgd_alloc(struct mm_struct *mm) 16static inline pgd_t *pgd_alloc(struct mm_struct *mm)
26{ 17{
27 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t)); 18 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
28 pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL);
29
30 if (pgd)
31 memset(pgd, 0, pgd_size);
32
33 return pgd;
34} 19}
35 20
36static inline void pgd_free(pgd_t *pgd) 21static inline void pgd_free(pgd_t *pgd)
37{ 22{
38 kfree(pgd); 23 free_page((unsigned long)pgd);
39} 24}
40 25
41static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 26static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42 unsigned long address) 27 unsigned long address)
43{ 28{
44 pte_t *pte; 29 return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
45
46 pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
47
48 return pte;
49} 30}
50 31
51static inline struct page *pte_alloc_one(struct mm_struct *mm, 32static inline struct page *pte_alloc_one(struct mm_struct *mm,
52 unsigned long address) 33 unsigned long address)
53{ 34{
54 struct page *pte; 35 return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
55
56 pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
57
58 return pte;
59} 36}
60 37
61static inline void pte_free_kernel(pte_t *pte) 38static inline void pte_free_kernel(pte_t *pte)
@@ -75,14 +52,8 @@ static inline void pte_free(struct page *pte)
75 * inside the pgd, so has no extra memory associated with it. 52 * inside the pgd, so has no extra memory associated with it.
76 */ 53 */
77 54
78#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
79#define pmd_free(x) do { } while (0) 55#define pmd_free(x) do { } while (0)
80#define __pmd_free_tlb(tlb,x) do { } while (0) 56#define __pmd_free_tlb(tlb,x) do { } while (0)
81#define pgd_populate(mm, pmd, pte) BUG()
82#define check_pgt_cache() do { } while (0) 57#define check_pgt_cache() do { } while (0)
83 58
84#ifdef CONFIG_CPU_SH4
85#define PG_mapped PG_arch_1
86#endif
87
88#endif /* __ASM_SH_PGALLOC_H */ 59#endif /* __ASM_SH_PGALLOC_H */
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index 40d41a78041e..9728b58f7c13 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -1,42 +1,42 @@
1#ifndef __ASM_SH_PGTABLE_H
2#define __ASM_SH_PGTABLE_H
3
4#include <asm-generic/4level-fixup.h>
5
6/* 1/*
2 * This file contains the functions and defines necessary to modify and
3 * use the SuperH page table tree.
4 *
7 * Copyright (C) 1999 Niibe Yutaka 5 * Copyright (C) 1999 Niibe Yutaka
8 * Copyright (C) 2002, 2003, 2004 Paul Mundt 6 * Copyright (C) 2002 - 2005 Paul Mundt
7 *
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.
9 */ 11 */
12#ifndef __ASM_SH_PGTABLE_H
13#define __ASM_SH_PGTABLE_H
10 14
11#include <asm/pgtable-2level.h> 15#include <asm-generic/pgtable-nopmd.h>
16#include <asm/page.h>
17
18#define PTRS_PER_PGD 1024
12 19
13/*
14 * This file contains the functions and defines necessary to modify and use
15 * the SuperH page table tree.
16 */
17#ifndef __ASSEMBLY__ 20#ifndef __ASSEMBLY__
18#include <asm/processor.h>
19#include <asm/addrspace.h> 21#include <asm/addrspace.h>
20#include <asm/fixmap.h> 22#include <asm/fixmap.h>
21#include <linux/threads.h>
22 23
23extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 24extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
24extern void paging_init(void); 25extern void paging_init(void);
25 26
26/* 27/*
27 * Basically we have the same two-level (which is the logical three level
28 * Linux page table layout folded) page tables as the i386.
29 */
30
31/*
32 * ZERO_PAGE is a global shared page that is always zero: used 28 * ZERO_PAGE is a global shared page that is always zero: used
33 * for zero-mapped memory areas etc.. 29 * for zero-mapped memory areas etc..
34 */ 30 */
35extern unsigned long empty_zero_page[1024]; 31extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
36#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 32#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
37 33
38#endif /* !__ASSEMBLY__ */ 34#endif /* !__ASSEMBLY__ */
39 35
36/* traditional two-level paging structure */
37#define PGDIR_SHIFT 22
38#define PTRS_PER_PMD 1
39#define PTRS_PER_PTE 1024
40#define PMD_SIZE (1UL << PMD_SHIFT) 40#define PMD_SIZE (1UL << PMD_SHIFT)
41#define PMD_MASK (~(PMD_SIZE-1)) 41#define PMD_MASK (~(PMD_SIZE-1))
42#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 42#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
@@ -47,7 +47,6 @@ extern unsigned long empty_zero_page[1024];
47 47
48#define PTE_PHYS_MASK 0x1ffff000 48#define PTE_PHYS_MASK 0x1ffff000
49 49
50#ifndef __ASSEMBLY__
51/* 50/*
52 * First 1MB map is used by fixed purpose. 51 * First 1MB map is used by fixed purpose.
53 * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c) 52 * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c)
@@ -65,7 +64,7 @@ extern unsigned long empty_zero_page[1024];
65#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ 64#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */
66#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ 65#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */
67#define _PAGE_PROTNONE 0x200 /* software: if not present */ 66#define _PAGE_PROTNONE 0x200 /* software: if not present */
68#define _PAGE_ACCESSED 0x400 /* software: page referenced */ 67#define _PAGE_ACCESSED 0x400 /* software: page referenced */
69#define _PAGE_U0_SHARED 0x800 /* software: page is shared in user space */ 68#define _PAGE_U0_SHARED 0x800 /* software: page is shared in user space */
70 69
71#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ 70#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */
@@ -83,7 +82,6 @@ extern unsigned long empty_zero_page[1024];
83#define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */ 82#define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */
84#define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */ 83#define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */
85 84
86
87/* Mask which drop software flags 85/* Mask which drop software flags
88 * We also drop WT bit since it is used for _PAGE_FILE 86 * We also drop WT bit since it is used for _PAGE_FILE
89 * bit in this implementation. 87 * bit in this implementation.
@@ -115,6 +113,8 @@ extern unsigned long empty_zero_page[1024];
115#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 113#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
116#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_SHARED) 114#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_SHARED)
117 115
116#ifndef __ASSEMBLY__
117
118#ifdef CONFIG_MMU 118#ifdef CONFIG_MMU
119#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) 119#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD)
120#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_SHARED | _PAGE_FLAGS_HARD) 120#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_SHARED | _PAGE_FLAGS_HARD)
@@ -137,12 +137,13 @@ extern unsigned long empty_zero_page[1024];
137#define PAGE_KERNEL_PCC __pgprot(0) 137#define PAGE_KERNEL_PCC __pgprot(0)
138#endif 138#endif
139 139
140#endif /* __ASSEMBLY__ */
141
140/* 142/*
141 * As i386 and MIPS, SuperH can't do page protection for execute, and 143 * As i386 and MIPS, SuperH can't do page protection for execute, and
142 * considers that the same as a read. Also, write permissions imply 144 * considers that the same as a read. Also, write permissions imply
143 * read permissions. This is the closest we can get.. 145 * read permissions. This is the closest we can get..
144 */ 146 */
145
146#define __P000 PAGE_NONE 147#define __P000 PAGE_NONE
147#define __P001 PAGE_READONLY 148#define __P001 PAGE_READONLY
148#define __P010 PAGE_COPY 149#define __P010 PAGE_COPY
@@ -161,6 +162,26 @@ extern unsigned long empty_zero_page[1024];
161#define __S110 PAGE_SHARED 162#define __S110 PAGE_SHARED
162#define __S111 PAGE_SHARED 163#define __S111 PAGE_SHARED
163 164
165#ifndef __ASSEMBLY__
166
167/*
168 * Certain architectures need to do special things when PTEs
169 * within a page table are directly modified. Thus, the following
170 * hook is made available.
171 */
172#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
173#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
174
175/*
176 * (pmds are folded into pgds so this doesn't get actually called,
177 * but the define is needed for a generic inline function.)
178 */
179#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
180
181#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT)))
182#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
183#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
184
164#define pte_none(x) (!pte_val(x)) 185#define pte_none(x) (!pte_val(x))
165#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 186#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
166#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 187#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
@@ -171,7 +192,7 @@ extern unsigned long empty_zero_page[1024];
171#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 192#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
172 193
173#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 194#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
174#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) 195#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK)
175 196
176/* 197/*
177 * The following only work if pte_present() is true. 198 * The following only work if pte_present() is true.
@@ -248,6 +269,11 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
248#define pte_unmap(pte) do { } while (0) 269#define pte_unmap(pte) do { } while (0)
249#define pte_unmap_nested(pte) do { } while (0) 270#define pte_unmap_nested(pte) do { } while (0)
250 271
272#define pte_ERROR(e) \
273 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
274#define pgd_ERROR(e) \
275 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
276
251struct vm_area_struct; 277struct vm_area_struct;
252extern void update_mmu_cache(struct vm_area_struct * vma, 278extern void update_mmu_cache(struct vm_area_struct * vma,
253 unsigned long address, pte_t pte); 279 unsigned long address, pte_t pte);
@@ -272,8 +298,6 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
272 298
273typedef pte_t *pte_addr_t; 299typedef pte_t *pte_addr_t;
274 300
275#endif /* !__ASSEMBLY__ */
276
277#define kern_addr_valid(addr) (1) 301#define kern_addr_valid(addr) (1)
278 302
279#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 303#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
@@ -301,5 +325,7 @@ extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t
301 325
302#include <asm-generic/pgtable.h> 326#include <asm-generic/pgtable.h>
303 327
328#endif /* !__ASSEMBLY__ */
329
304#endif /* __ASM_SH_PAGE_H */ 330#endif /* __ASM_SH_PAGE_H */
305 331