Commit 103f3d9a26df944f4c29de190d72dfbf913c71af

Authored by Kirill A. Shutemov
Committed by Linus Torvalds
1 parent f5b45de9b0

cris: drop _PAGE_FILE and pte_file()-related helpers

We've replaced remap_file_pages(2) implementation with emulation.  Nobody
creates non-linear mapping anymore.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 3 changed files with 0 additions and 10 deletions Inline Diff

arch/cris/include/arch-v10/arch/mmu.h
1 /* 1 /*
2 * CRIS MMU constants and PTE layout 2 * CRIS MMU constants and PTE layout
3 */ 3 */
4 4
5 #ifndef _CRIS_ARCH_MMU_H 5 #ifndef _CRIS_ARCH_MMU_H
6 #define _CRIS_ARCH_MMU_H 6 #define _CRIS_ARCH_MMU_H
7 7
8 /* type used in struct mm to couple an MMU context to an active mm */ 8 /* type used in struct mm to couple an MMU context to an active mm */
9 9
10 typedef struct 10 typedef struct
11 { 11 {
12 unsigned int page_id; 12 unsigned int page_id;
13 } mm_context_t; 13 } mm_context_t;
14 14
15 /* kernel memory segments */ 15 /* kernel memory segments */
16 16
17 #define KSEG_F 0xf0000000UL 17 #define KSEG_F 0xf0000000UL
18 #define KSEG_E 0xe0000000UL 18 #define KSEG_E 0xe0000000UL
19 #define KSEG_D 0xd0000000UL 19 #define KSEG_D 0xd0000000UL
20 #define KSEG_C 0xc0000000UL 20 #define KSEG_C 0xc0000000UL
21 #define KSEG_B 0xb0000000UL 21 #define KSEG_B 0xb0000000UL
22 #define KSEG_A 0xa0000000UL 22 #define KSEG_A 0xa0000000UL
23 #define KSEG_9 0x90000000UL 23 #define KSEG_9 0x90000000UL
24 #define KSEG_8 0x80000000UL 24 #define KSEG_8 0x80000000UL
25 #define KSEG_7 0x70000000UL 25 #define KSEG_7 0x70000000UL
26 #define KSEG_6 0x60000000UL 26 #define KSEG_6 0x60000000UL
27 #define KSEG_5 0x50000000UL 27 #define KSEG_5 0x50000000UL
28 #define KSEG_4 0x40000000UL 28 #define KSEG_4 0x40000000UL
29 #define KSEG_3 0x30000000UL 29 #define KSEG_3 0x30000000UL
30 #define KSEG_2 0x20000000UL 30 #define KSEG_2 0x20000000UL
31 #define KSEG_1 0x10000000UL 31 #define KSEG_1 0x10000000UL
32 #define KSEG_0 0x00000000UL 32 #define KSEG_0 0x00000000UL
33 33
34 /* CRIS PTE bits (see R_TLB_LO in the register description) 34 /* CRIS PTE bits (see R_TLB_LO in the register description)
35 * 35 *
36 * Bit: 31 30-13 12-------4 3 2 1 0 36 * Bit: 31 30-13 12-------4 3 2 1 0
37 * _______________________________________________________ 37 * _______________________________________________________
38 * | cache |pfn | reserved | global | valid | kernel | we | 38 * | cache |pfn | reserved | global | valid | kernel | we |
39 * |_______|____|__________|________|_______|________|_____| 39 * |_______|____|__________|________|_______|________|_____|
40 * 40 *
41 * (pfn = physical frame number) 41 * (pfn = physical frame number)
42 */ 42 */
43 43
44 /* Real HW-based PTE bits. We use some synonym names so that 44 /* Real HW-based PTE bits. We use some synonym names so that
45 * things become less confusing in combination with the SW-based 45 * things become less confusing in combination with the SW-based
46 * bits further below. 46 * bits further below.
47 * 47 *
48 */ 48 */
49 49
50 #define _PAGE_WE (1<<0) /* page is write-enabled */ 50 #define _PAGE_WE (1<<0) /* page is write-enabled */
51 #define _PAGE_SILENT_WRITE (1<<0) /* synonym */ 51 #define _PAGE_SILENT_WRITE (1<<0) /* synonym */
52 #define _PAGE_KERNEL (1<<1) /* page is kernel only */ 52 #define _PAGE_KERNEL (1<<1) /* page is kernel only */
53 #define _PAGE_VALID (1<<2) /* page is valid */ 53 #define _PAGE_VALID (1<<2) /* page is valid */
54 #define _PAGE_SILENT_READ (1<<2) /* synonym */ 54 #define _PAGE_SILENT_READ (1<<2) /* synonym */
55 #define _PAGE_GLOBAL (1<<3) /* global page - context is ignored */ 55 #define _PAGE_GLOBAL (1<<3) /* global page - context is ignored */
56 #define _PAGE_NO_CACHE (1<<31) /* part of the uncached memory map */ 56 #define _PAGE_NO_CACHE (1<<31) /* part of the uncached memory map */
57 57
58 /* Bits the HW doesn't care about but the kernel uses them in SW */ 58 /* Bits the HW doesn't care about but the kernel uses them in SW */
59 59
60 #define _PAGE_PRESENT (1<<4) /* page present in memory */ 60 #define _PAGE_PRESENT (1<<4) /* page present in memory */
61 #define _PAGE_FILE (1<<5) /* set: pagecache, unset: swap (when !PRESENT) */
62 #define _PAGE_ACCESSED (1<<5) /* simulated in software using valid bit */ 61 #define _PAGE_ACCESSED (1<<5) /* simulated in software using valid bit */
63 #define _PAGE_MODIFIED (1<<6) /* simulated in software using we bit */ 62 #define _PAGE_MODIFIED (1<<6) /* simulated in software using we bit */
64 #define _PAGE_READ (1<<7) /* read-enabled */ 63 #define _PAGE_READ (1<<7) /* read-enabled */
65 #define _PAGE_WRITE (1<<8) /* write-enabled */ 64 #define _PAGE_WRITE (1<<8) /* write-enabled */
66 65
67 /* Define some higher level generic page attributes. */ 66 /* Define some higher level generic page attributes. */
68 67
69 #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED) 68 #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
70 #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED) 69 #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
71 70
72 #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE) 71 #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE)
73 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED) 72 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED)
74 73
75 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED) 74 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
76 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \ 75 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \
77 _PAGE_ACCESSED) 76 _PAGE_ACCESSED)
78 #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE) // | _PAGE_COW 77 #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE) // | _PAGE_COW
79 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE) 78 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE)
80 #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \ 79 #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \
81 _PAGE_PRESENT | __READABLE | __WRITEABLE) 80 _PAGE_PRESENT | __READABLE | __WRITEABLE)
82 #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL) 81 #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL)
83 82
84 /* 83 /*
85 * CRIS can't do page protection for execute, and considers read the same. 84 * CRIS can't do page protection for execute, and considers read the same.
86 * Also, write permissions imply read permissions. This is the closest we can 85 * Also, write permissions imply read permissions. This is the closest we can
87 * get.. 86 * get..
88 */ 87 */
89 88
90 #define __P000 PAGE_NONE 89 #define __P000 PAGE_NONE
91 #define __P001 PAGE_READONLY 90 #define __P001 PAGE_READONLY
92 #define __P010 PAGE_COPY 91 #define __P010 PAGE_COPY
93 #define __P011 PAGE_COPY 92 #define __P011 PAGE_COPY
94 #define __P100 PAGE_READONLY 93 #define __P100 PAGE_READONLY
95 #define __P101 PAGE_READONLY 94 #define __P101 PAGE_READONLY
96 #define __P110 PAGE_COPY 95 #define __P110 PAGE_COPY
97 #define __P111 PAGE_COPY 96 #define __P111 PAGE_COPY
98 97
99 #define __S000 PAGE_NONE 98 #define __S000 PAGE_NONE
100 #define __S001 PAGE_READONLY 99 #define __S001 PAGE_READONLY
101 #define __S010 PAGE_SHARED 100 #define __S010 PAGE_SHARED
102 #define __S011 PAGE_SHARED 101 #define __S011 PAGE_SHARED
103 #define __S100 PAGE_READONLY 102 #define __S100 PAGE_READONLY
104 #define __S101 PAGE_READONLY 103 #define __S101 PAGE_READONLY
105 #define __S110 PAGE_SHARED 104 #define __S110 PAGE_SHARED
106 #define __S111 PAGE_SHARED 105 #define __S111 PAGE_SHARED
107
108 #define PTE_FILE_MAX_BITS 26
109 106
110 #endif 107 #endif
111 108
arch/cris/include/arch-v32/arch/mmu.h
1 #ifndef _ASM_CRIS_ARCH_MMU_H 1 #ifndef _ASM_CRIS_ARCH_MMU_H
2 #define _ASM_CRIS_ARCH_MMU_H 2 #define _ASM_CRIS_ARCH_MMU_H
3 3
4 /* MMU context type. */ 4 /* MMU context type. */
5 typedef struct 5 typedef struct
6 { 6 {
7 unsigned int page_id; 7 unsigned int page_id;
8 } mm_context_t; 8 } mm_context_t;
9 9
10 /* Kernel memory segments. */ 10 /* Kernel memory segments. */
11 #define KSEG_F 0xf0000000UL 11 #define KSEG_F 0xf0000000UL
12 #define KSEG_E 0xe0000000UL 12 #define KSEG_E 0xe0000000UL
13 #define KSEG_D 0xd0000000UL 13 #define KSEG_D 0xd0000000UL
14 #define KSEG_C 0xc0000000UL 14 #define KSEG_C 0xc0000000UL
15 #define KSEG_B 0xb0000000UL 15 #define KSEG_B 0xb0000000UL
16 #define KSEG_A 0xa0000000UL 16 #define KSEG_A 0xa0000000UL
17 #define KSEG_9 0x90000000UL 17 #define KSEG_9 0x90000000UL
18 #define KSEG_8 0x80000000UL 18 #define KSEG_8 0x80000000UL
19 #define KSEG_7 0x70000000UL 19 #define KSEG_7 0x70000000UL
20 #define KSEG_6 0x60000000UL 20 #define KSEG_6 0x60000000UL
21 #define KSEG_5 0x50000000UL 21 #define KSEG_5 0x50000000UL
22 #define KSEG_4 0x40000000UL 22 #define KSEG_4 0x40000000UL
23 #define KSEG_3 0x30000000UL 23 #define KSEG_3 0x30000000UL
24 #define KSEG_2 0x20000000UL 24 #define KSEG_2 0x20000000UL
25 #define KSEG_1 0x10000000UL 25 #define KSEG_1 0x10000000UL
26 #define KSEG_0 0x00000000UL 26 #define KSEG_0 0x00000000UL
27 27
28 /* 28 /*
29 * CRISv32 PTE bits: 29 * CRISv32 PTE bits:
30 * 30 *
31 * Bit: 31 30-13 12-5 4 3 2 1 0 31 * Bit: 31 30-13 12-5 4 3 2 1 0
32 * +-------+-----+------+--------+-------+--------+-------+---------+ 32 * +-------+-----+------+--------+-------+--------+-------+---------+
33 * | cache | pfn | zero | global | valid | kernel | write | execute | 33 * | cache | pfn | zero | global | valid | kernel | write | execute |
34 * +-------+-----+------+--------+-------+--------+-------+---------+ 34 * +-------+-----+------+--------+-------+--------+-------+---------+
35 */ 35 */
36 36
37 /* 37 /*
38 * Defines for accessing the bits. Also define some synonyms for use with 38 * Defines for accessing the bits. Also define some synonyms for use with
39 * the software-based defined bits below. 39 * the software-based defined bits below.
40 */ 40 */
41 #define _PAGE_EXECUTE (1 << 0) /* Execution bit. */ 41 #define _PAGE_EXECUTE (1 << 0) /* Execution bit. */
42 #define _PAGE_WE (1 << 1) /* Write bit. */ 42 #define _PAGE_WE (1 << 1) /* Write bit. */
43 #define _PAGE_SILENT_WRITE (1 << 1) /* Same as above. */ 43 #define _PAGE_SILENT_WRITE (1 << 1) /* Same as above. */
44 #define _PAGE_KERNEL (1 << 2) /* Kernel mode page. */ 44 #define _PAGE_KERNEL (1 << 2) /* Kernel mode page. */
45 #define _PAGE_VALID (1 << 3) /* Page is valid. */ 45 #define _PAGE_VALID (1 << 3) /* Page is valid. */
46 #define _PAGE_SILENT_READ (1 << 3) /* Same as above. */ 46 #define _PAGE_SILENT_READ (1 << 3) /* Same as above. */
47 #define _PAGE_GLOBAL (1 << 4) /* Global page. */ 47 #define _PAGE_GLOBAL (1 << 4) /* Global page. */
48 #define _PAGE_NO_CACHE (1 << 31) /* part of the uncached memory map */ 48 #define _PAGE_NO_CACHE (1 << 31) /* part of the uncached memory map */
49 49
50 50
51 /* 51 /*
52 * The hardware doesn't care about these bits, but the kernel uses them in 52 * The hardware doesn't care about these bits, but the kernel uses them in
53 * software. 53 * software.
54 */ 54 */
55 #define _PAGE_PRESENT (1 << 5) /* Page is present in memory. */ 55 #define _PAGE_PRESENT (1 << 5) /* Page is present in memory. */
56 #define _PAGE_FILE (1 << 6) /* 1=pagecache, 0=swap (when !present) */
57 #define _PAGE_ACCESSED (1 << 6) /* Simulated in software using valid bit. */ 56 #define _PAGE_ACCESSED (1 << 6) /* Simulated in software using valid bit. */
58 #define _PAGE_MODIFIED (1 << 7) /* Simulated in software using we bit. */ 57 #define _PAGE_MODIFIED (1 << 7) /* Simulated in software using we bit. */
59 #define _PAGE_READ (1 << 8) /* Read enabled. */ 58 #define _PAGE_READ (1 << 8) /* Read enabled. */
60 #define _PAGE_WRITE (1 << 9) /* Write enabled. */ 59 #define _PAGE_WRITE (1 << 9) /* Write enabled. */
61 60
62 /* Define some higher level generic page attributes. */ 61 /* Define some higher level generic page attributes. */
63 #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED) 62 #define __READABLE (_PAGE_READ | _PAGE_SILENT_READ | _PAGE_ACCESSED)
64 #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED) 63 #define __WRITEABLE (_PAGE_WRITE | _PAGE_SILENT_WRITE | _PAGE_MODIFIED)
65 64
66 #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE) 65 #define _PAGE_TABLE (_PAGE_PRESENT | __READABLE | __WRITEABLE)
67 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED) 66 #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_MODIFIED)
68 67
69 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED) 68 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
70 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \ 69 #define PAGE_SHARED __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \
71 _PAGE_ACCESSED) 70 _PAGE_ACCESSED)
72 #define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \ 71 #define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_WRITE | \
73 _PAGE_ACCESSED | _PAGE_EXECUTE) 72 _PAGE_ACCESSED | _PAGE_EXECUTE)
74 73
75 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE) 74 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | __READABLE)
76 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_EXECUTE | _PAGE_ACCESSED) 75 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_EXECUTE | _PAGE_ACCESSED)
77 76
78 #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE) 77 #define PAGE_COPY __pgprot(_PAGE_PRESENT | __READABLE)
79 #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_EXECUTE) 78 #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | __READABLE | _PAGE_EXECUTE)
80 #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \ 79 #define PAGE_KERNEL __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | \
81 _PAGE_PRESENT | __READABLE | __WRITEABLE) 80 _PAGE_PRESENT | __READABLE | __WRITEABLE)
82 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | _PAGE_EXECUTE | \ 81 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_GLOBAL | _PAGE_KERNEL | _PAGE_EXECUTE | \
83 _PAGE_PRESENT | __READABLE | __WRITEABLE) 82 _PAGE_PRESENT | __READABLE | __WRITEABLE)
84 #define PAGE_SIGNAL_TRAMPOLINE __pgprot(_PAGE_GLOBAL | _PAGE_EXECUTE | \ 83 #define PAGE_SIGNAL_TRAMPOLINE __pgprot(_PAGE_GLOBAL | _PAGE_EXECUTE | \
85 _PAGE_PRESENT | __READABLE) 84 _PAGE_PRESENT | __READABLE)
86 85
87 #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL) 86 #define _KERNPG_TABLE (_PAGE_TABLE | _PAGE_KERNEL)
88 87
89 /* CRISv32 can do page protection for execute. 88 /* CRISv32 can do page protection for execute.
90 * Write permissions imply read permissions. 89 * Write permissions imply read permissions.
91 * Note that the numbers are in Execute-Write-Read order! 90 * Note that the numbers are in Execute-Write-Read order!
92 */ 91 */
93 #define __P000 PAGE_NONE 92 #define __P000 PAGE_NONE
94 #define __P001 PAGE_READONLY 93 #define __P001 PAGE_READONLY
95 #define __P010 PAGE_COPY 94 #define __P010 PAGE_COPY
96 #define __P011 PAGE_COPY 95 #define __P011 PAGE_COPY
97 #define __P100 PAGE_READONLY_EXEC 96 #define __P100 PAGE_READONLY_EXEC
98 #define __P101 PAGE_READONLY_EXEC 97 #define __P101 PAGE_READONLY_EXEC
99 #define __P110 PAGE_COPY_EXEC 98 #define __P110 PAGE_COPY_EXEC
100 #define __P111 PAGE_COPY_EXEC 99 #define __P111 PAGE_COPY_EXEC
101 100
102 #define __S000 PAGE_NONE 101 #define __S000 PAGE_NONE
103 #define __S001 PAGE_READONLY 102 #define __S001 PAGE_READONLY
104 #define __S010 PAGE_SHARED 103 #define __S010 PAGE_SHARED
105 #define __S011 PAGE_SHARED 104 #define __S011 PAGE_SHARED
106 #define __S100 PAGE_READONLY_EXEC 105 #define __S100 PAGE_READONLY_EXEC
107 #define __S101 PAGE_READONLY_EXEC 106 #define __S101 PAGE_READONLY_EXEC
108 #define __S110 PAGE_SHARED_EXEC 107 #define __S110 PAGE_SHARED_EXEC
109 #define __S111 PAGE_SHARED_EXEC 108 #define __S111 PAGE_SHARED_EXEC
110
111 #define PTE_FILE_MAX_BITS 25
112 109
113 #endif /* _ASM_CRIS_ARCH_MMU_H */ 110 #endif /* _ASM_CRIS_ARCH_MMU_H */
114 111
arch/cris/include/asm/pgtable.h
1 /* 1 /*
2 * CRIS pgtable.h - macros and functions to manipulate page tables. 2 * CRIS pgtable.h - macros and functions to manipulate page tables.
3 */ 3 */
4 4
5 #ifndef _CRIS_PGTABLE_H 5 #ifndef _CRIS_PGTABLE_H
6 #define _CRIS_PGTABLE_H 6 #define _CRIS_PGTABLE_H
7 7
8 #include <asm/page.h> 8 #include <asm/page.h>
9 #include <asm-generic/pgtable-nopmd.h> 9 #include <asm-generic/pgtable-nopmd.h>
10 10
11 #ifndef __ASSEMBLY__ 11 #ifndef __ASSEMBLY__
12 #include <linux/sched.h> 12 #include <linux/sched.h>
13 #include <asm/mmu.h> 13 #include <asm/mmu.h>
14 #endif 14 #endif
15 #include <arch/pgtable.h> 15 #include <arch/pgtable.h>
16 16
17 /* 17 /*
18 * The Linux memory management assumes a three-level page table setup. On 18 * The Linux memory management assumes a three-level page table setup. On
19 * CRIS, we use that, but "fold" the mid level into the top-level page 19 * CRIS, we use that, but "fold" the mid level into the top-level page
20 * table. Since the MMU TLB is software loaded through an interrupt, it 20 * table. Since the MMU TLB is software loaded through an interrupt, it
21 * supports any page table structure, so we could have used a three-level 21 * supports any page table structure, so we could have used a three-level
22 * setup, but for the amounts of memory we normally use, a two-level is 22 * setup, but for the amounts of memory we normally use, a two-level is
23 * probably more efficient. 23 * probably more efficient.
24 * 24 *
25 * This file contains the functions and defines necessary to modify and use 25 * This file contains the functions and defines necessary to modify and use
26 * the CRIS page table tree. 26 * the CRIS page table tree.
27 */ 27 */
28 #ifndef __ASSEMBLY__ 28 #ifndef __ASSEMBLY__
29 extern void paging_init(void); 29 extern void paging_init(void);
30 #endif 30 #endif
31 31
32 /* Certain architectures need to do special things when pte's 32 /* Certain architectures need to do special things when pte's
33 * within a page table are directly modified. Thus, the following 33 * within a page table are directly modified. Thus, the following
34 * hook is made available. 34 * hook is made available.
35 */ 35 */
36 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval)) 36 #define set_pte(pteptr, pteval) ((*(pteptr)) = (pteval))
37 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 37 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
38 38
39 /* 39 /*
40 * (pmds are folded into pgds so this doesn't get actually called, 40 * (pmds are folded into pgds so this doesn't get actually called,
41 * but the define is needed for a generic inline function.) 41 * but the define is needed for a generic inline function.)
42 */ 42 */
43 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval) 43 #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
44 #define set_pgu(pudptr, pudval) (*(pudptr) = pudval) 44 #define set_pgu(pudptr, pudval) (*(pudptr) = pudval)
45 45
46 /* PGDIR_SHIFT determines the size of the area a second-level page table can 46 /* PGDIR_SHIFT determines the size of the area a second-level page table can
47 * map. It is equal to the page size times the number of PTE's that fit in 47 * map. It is equal to the page size times the number of PTE's that fit in
48 * a PMD page. A PTE is 4-bytes in CRIS. Hence the following number. 48 * a PMD page. A PTE is 4-bytes in CRIS. Hence the following number.
49 */ 49 */
50 50
51 #define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-2)) 51 #define PGDIR_SHIFT (PAGE_SHIFT + (PAGE_SHIFT-2))
52 #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 52 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
53 #define PGDIR_MASK (~(PGDIR_SIZE-1)) 53 #define PGDIR_MASK (~(PGDIR_SIZE-1))
54 54
55 /* 55 /*
56 * entries per page directory level: we use a two-level, so 56 * entries per page directory level: we use a two-level, so
57 * we don't really have any PMD directory physically. 57 * we don't really have any PMD directory physically.
58 * pointers are 4 bytes so we can use the page size and 58 * pointers are 4 bytes so we can use the page size and
59 * divide it by 4 (shift by 2). 59 * divide it by 4 (shift by 2).
60 */ 60 */
61 #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-2)) 61 #define PTRS_PER_PTE (1UL << (PAGE_SHIFT-2))
62 #define PTRS_PER_PGD (1UL << (PAGE_SHIFT-2)) 62 #define PTRS_PER_PGD (1UL << (PAGE_SHIFT-2))
63 63
64 /* calculate how many PGD entries a user-level program can use 64 /* calculate how many PGD entries a user-level program can use
65 * the first mappable virtual address is 0 65 * the first mappable virtual address is 0
66 * (TASK_SIZE is the maximum virtual address space) 66 * (TASK_SIZE is the maximum virtual address space)
67 */ 67 */
68 68
69 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 69 #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
70 #define FIRST_USER_ADDRESS 0 70 #define FIRST_USER_ADDRESS 0
71 71
72 /* zero page used for uninitialized stuff */ 72 /* zero page used for uninitialized stuff */
73 #ifndef __ASSEMBLY__ 73 #ifndef __ASSEMBLY__
74 extern unsigned long empty_zero_page; 74 extern unsigned long empty_zero_page;
75 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 75 #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
76 #endif 76 #endif
77 77
78 /* number of bits that fit into a memory pointer */ 78 /* number of bits that fit into a memory pointer */
79 #define BITS_PER_PTR (8*sizeof(unsigned long)) 79 #define BITS_PER_PTR (8*sizeof(unsigned long))
80 80
81 /* to align the pointer to a pointer address */ 81 /* to align the pointer to a pointer address */
82 #define PTR_MASK (~(sizeof(void*)-1)) 82 #define PTR_MASK (~(sizeof(void*)-1))
83 83
84 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */ 84 /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
85 /* 64-bit machines, beware! SRB. */ 85 /* 64-bit machines, beware! SRB. */
86 #define SIZEOF_PTR_LOG2 2 86 #define SIZEOF_PTR_LOG2 2
87 87
88 /* to find an entry in a page-table */ 88 /* to find an entry in a page-table */
89 #define PAGE_PTR(address) \ 89 #define PAGE_PTR(address) \
90 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK) 90 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
91 91
92 /* to set the page-dir */ 92 /* to set the page-dir */
93 #define SET_PAGE_DIR(tsk,pgdir) 93 #define SET_PAGE_DIR(tsk,pgdir)
94 94
95 #define pte_none(x) (!pte_val(x)) 95 #define pte_none(x) (!pte_val(x))
96 #define pte_present(x) (pte_val(x) & _PAGE_PRESENT) 96 #define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
97 #define pte_clear(mm,addr,xp) do { pte_val(*(xp)) = 0; } while (0) 97 #define pte_clear(mm,addr,xp) do { pte_val(*(xp)) = 0; } while (0)
98 98
99 #define pmd_none(x) (!pmd_val(x)) 99 #define pmd_none(x) (!pmd_val(x))
100 /* by removing the _PAGE_KERNEL bit from the comparison, the same pmd_bad 100 /* by removing the _PAGE_KERNEL bit from the comparison, the same pmd_bad
101 * works for both _PAGE_TABLE and _KERNPG_TABLE pmd entries. 101 * works for both _PAGE_TABLE and _KERNPG_TABLE pmd entries.
102 */ 102 */
103 #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_KERNEL)) != _PAGE_TABLE) 103 #define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_KERNEL)) != _PAGE_TABLE)
104 #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 104 #define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
105 #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0) 105 #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0)
106 106
107 #ifndef __ASSEMBLY__ 107 #ifndef __ASSEMBLY__
108 108
109 /* 109 /*
110 * The following only work if pte_present() is true. 110 * The following only work if pte_present() is true.
111 * Undefined behaviour if not.. 111 * Undefined behaviour if not..
112 */ 112 */
113 113
114 static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; } 114 static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
115 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; } 115 static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_MODIFIED; }
116 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 116 static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
117 static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
118 static inline int pte_special(pte_t pte) { return 0; } 117 static inline int pte_special(pte_t pte) { return 0; }
119 118
120 static inline pte_t pte_wrprotect(pte_t pte) 119 static inline pte_t pte_wrprotect(pte_t pte)
121 { 120 {
122 pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE); 121 pte_val(pte) &= ~(_PAGE_WRITE | _PAGE_SILENT_WRITE);
123 return pte; 122 return pte;
124 } 123 }
125 124
126 static inline pte_t pte_mkclean(pte_t pte) 125 static inline pte_t pte_mkclean(pte_t pte)
127 { 126 {
128 pte_val(pte) &= ~(_PAGE_MODIFIED | _PAGE_SILENT_WRITE); 127 pte_val(pte) &= ~(_PAGE_MODIFIED | _PAGE_SILENT_WRITE);
129 return pte; 128 return pte;
130 } 129 }
131 130
132 static inline pte_t pte_mkold(pte_t pte) 131 static inline pte_t pte_mkold(pte_t pte)
133 { 132 {
134 pte_val(pte) &= ~(_PAGE_ACCESSED | _PAGE_SILENT_READ); 133 pte_val(pte) &= ~(_PAGE_ACCESSED | _PAGE_SILENT_READ);
135 return pte; 134 return pte;
136 } 135 }
137 136
138 static inline pte_t pte_mkwrite(pte_t pte) 137 static inline pte_t pte_mkwrite(pte_t pte)
139 { 138 {
140 pte_val(pte) |= _PAGE_WRITE; 139 pte_val(pte) |= _PAGE_WRITE;
141 if (pte_val(pte) & _PAGE_MODIFIED) 140 if (pte_val(pte) & _PAGE_MODIFIED)
142 pte_val(pte) |= _PAGE_SILENT_WRITE; 141 pte_val(pte) |= _PAGE_SILENT_WRITE;
143 return pte; 142 return pte;
144 } 143 }
145 144
146 static inline pte_t pte_mkdirty(pte_t pte) 145 static inline pte_t pte_mkdirty(pte_t pte)
147 { 146 {
148 pte_val(pte) |= _PAGE_MODIFIED; 147 pte_val(pte) |= _PAGE_MODIFIED;
149 if (pte_val(pte) & _PAGE_WRITE) 148 if (pte_val(pte) & _PAGE_WRITE)
150 pte_val(pte) |= _PAGE_SILENT_WRITE; 149 pte_val(pte) |= _PAGE_SILENT_WRITE;
151 return pte; 150 return pte;
152 } 151 }
153 152
154 static inline pte_t pte_mkyoung(pte_t pte) 153 static inline pte_t pte_mkyoung(pte_t pte)
155 { 154 {
156 pte_val(pte) |= _PAGE_ACCESSED; 155 pte_val(pte) |= _PAGE_ACCESSED;
157 if (pte_val(pte) & _PAGE_READ) 156 if (pte_val(pte) & _PAGE_READ)
158 { 157 {
159 pte_val(pte) |= _PAGE_SILENT_READ; 158 pte_val(pte) |= _PAGE_SILENT_READ;
160 if ((pte_val(pte) & (_PAGE_WRITE | _PAGE_MODIFIED)) == 159 if ((pte_val(pte) & (_PAGE_WRITE | _PAGE_MODIFIED)) ==
161 (_PAGE_WRITE | _PAGE_MODIFIED)) 160 (_PAGE_WRITE | _PAGE_MODIFIED))
162 pte_val(pte) |= _PAGE_SILENT_WRITE; 161 pte_val(pte) |= _PAGE_SILENT_WRITE;
163 } 162 }
164 return pte; 163 return pte;
165 } 164 }
166 static inline pte_t pte_mkspecial(pte_t pte) { return pte; } 165 static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
167 166
168 /* 167 /*
169 * Conversion functions: convert a page and protection to a page entry, 168 * Conversion functions: convert a page and protection to a page entry,
170 * and a page entry and page directory to the page they refer to. 169 * and a page entry and page directory to the page they refer to.
171 */ 170 */
172 171
173 /* What actually goes as arguments to the various functions is less than 172 /* What actually goes as arguments to the various functions is less than
174 * obvious, but a rule of thumb is that struct page's goes as struct page *, 173 * obvious, but a rule of thumb is that struct page's goes as struct page *,
175 * really physical DRAM addresses are unsigned long's, and DRAM "virtual" 174 * really physical DRAM addresses are unsigned long's, and DRAM "virtual"
176 * addresses (the 0xc0xxxxxx's) goes as void *'s. 175 * addresses (the 0xc0xxxxxx's) goes as void *'s.
177 */ 176 */
178 177
179 static inline pte_t __mk_pte(void * page, pgprot_t pgprot) 178 static inline pte_t __mk_pte(void * page, pgprot_t pgprot)
180 { 179 {
181 pte_t pte; 180 pte_t pte;
182 /* the PTE needs a physical address */ 181 /* the PTE needs a physical address */
183 pte_val(pte) = __pa(page) | pgprot_val(pgprot); 182 pte_val(pte) = __pa(page) | pgprot_val(pgprot);
184 return pte; 183 return pte;
185 } 184 }
186 185
187 #define mk_pte(page, pgprot) __mk_pte(page_address(page), (pgprot)) 186 #define mk_pte(page, pgprot) __mk_pte(page_address(page), (pgprot))
188 187
189 #define mk_pte_phys(physpage, pgprot) \ 188 #define mk_pte_phys(physpage, pgprot) \
190 ({ \ 189 ({ \
191 pte_t __pte; \ 190 pte_t __pte; \
192 \ 191 \
193 pte_val(__pte) = (physpage) + pgprot_val(pgprot); \ 192 pte_val(__pte) = (physpage) + pgprot_val(pgprot); \
194 __pte; \ 193 __pte; \
195 }) 194 })
196 195
197 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 196 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
198 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; } 197 { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); return pte; }
199 198
200 #define pgprot_noncached(prot) __pgprot((pgprot_val(prot) | _PAGE_NO_CACHE)) 199 #define pgprot_noncached(prot) __pgprot((pgprot_val(prot) | _PAGE_NO_CACHE))
201 200
202 201
203 /* pte_val refers to a page in the 0x4xxxxxxx physical DRAM interval 202 /* pte_val refers to a page in the 0x4xxxxxxx physical DRAM interval
204 * __pte_page(pte_val) refers to the "virtual" DRAM interval 203 * __pte_page(pte_val) refers to the "virtual" DRAM interval
205 * pte_pagenr refers to the page-number counted starting from the virtual DRAM start 204 * pte_pagenr refers to the page-number counted starting from the virtual DRAM start
206 */ 205 */
207 206
208 static inline unsigned long __pte_page(pte_t pte) 207 static inline unsigned long __pte_page(pte_t pte)
209 { 208 {
210 /* the PTE contains a physical address */ 209 /* the PTE contains a physical address */
211 return (unsigned long)__va(pte_val(pte) & PAGE_MASK); 210 return (unsigned long)__va(pte_val(pte) & PAGE_MASK);
212 } 211 }
213 212
214 #define pte_pagenr(pte) ((__pte_page(pte) - PAGE_OFFSET) >> PAGE_SHIFT) 213 #define pte_pagenr(pte) ((__pte_page(pte) - PAGE_OFFSET) >> PAGE_SHIFT)
215 214
216 /* permanent address of a page */ 215 /* permanent address of a page */
217 216
218 #define __page_address(page) (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT)) 217 #define __page_address(page) (PAGE_OFFSET + (((page) - mem_map) << PAGE_SHIFT))
219 #define pte_page(pte) (mem_map+pte_pagenr(pte)) 218 #define pte_page(pte) (mem_map+pte_pagenr(pte))
220 219
221 /* only the pte's themselves need to point to physical DRAM (see above) 220 /* only the pte's themselves need to point to physical DRAM (see above)
222 * the pagetable links are purely handled within the kernel SW and thus 221 * the pagetable links are purely handled within the kernel SW and thus
223 * don't need the __pa and __va transformations. 222 * don't need the __pa and __va transformations.
224 */ 223 */
225 224
226 static inline void pmd_set(pmd_t * pmdp, pte_t * ptep) 225 static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
227 { pmd_val(*pmdp) = _PAGE_TABLE | (unsigned long) ptep; } 226 { pmd_val(*pmdp) = _PAGE_TABLE | (unsigned long) ptep; }
228 227
229 #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) 228 #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
230 #define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 229 #define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
231 230
232 /* to find an entry in a page-table-directory. */ 231 /* to find an entry in a page-table-directory. */
233 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 232 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
234 233
235 /* to find an entry in a page-table-directory */ 234 /* to find an entry in a page-table-directory */
236 static inline pgd_t * pgd_offset(const struct mm_struct *mm, unsigned long address) 235 static inline pgd_t * pgd_offset(const struct mm_struct *mm, unsigned long address)
237 { 236 {
238 return mm->pgd + pgd_index(address); 237 return mm->pgd + pgd_index(address);
239 } 238 }
240 239
241 /* to find an entry in a kernel page-table-directory */ 240 /* to find an entry in a kernel page-table-directory */
242 #define pgd_offset_k(address) pgd_offset(&init_mm, address) 241 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
243 242
244 /* Find an entry in the third-level page table.. */ 243 /* Find an entry in the third-level page table.. */
245 #define __pte_offset(address) \ 244 #define __pte_offset(address) \
246 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 245 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
247 #define pte_offset_kernel(dir, address) \ 246 #define pte_offset_kernel(dir, address) \
248 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 247 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
249 #define pte_offset_map(dir, address) \ 248 #define pte_offset_map(dir, address) \
250 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 249 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
251 250
252 #define pte_unmap(pte) do { } while (0) 251 #define pte_unmap(pte) do { } while (0)
253 #define pte_pfn(x) ((unsigned long)(__va((x).pte)) >> PAGE_SHIFT) 252 #define pte_pfn(x) ((unsigned long)(__va((x).pte)) >> PAGE_SHIFT)
254 #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 253 #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
255 254
256 #define pte_ERROR(e) \ 255 #define pte_ERROR(e) \
257 printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), pte_val(e)) 256 printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), pte_val(e))
258 #define pgd_ERROR(e) \ 257 #define pgd_ERROR(e) \
259 printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) 258 printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), pgd_val(e))
260 259
261 260
262 extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* defined in head.S */ 261 extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* defined in head.S */
263 262
264 /* 263 /*
265 * CRIS doesn't have any external MMU info: the kernel page 264 * CRIS doesn't have any external MMU info: the kernel page
266 * tables contain all the necessary information. 265 * tables contain all the necessary information.
267 * 266 *
268 * Actually I am not sure on what this could be used for. 267 * Actually I am not sure on what this could be used for.
269 */ 268 */
270 static inline void update_mmu_cache(struct vm_area_struct * vma, 269 static inline void update_mmu_cache(struct vm_area_struct * vma,
271 unsigned long address, pte_t *ptep) 270 unsigned long address, pte_t *ptep)
272 { 271 {
273 } 272 }
274 273
275 /* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) */ 274 /* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) */
276 /* Since the PAGE_PRESENT bit is bit 4, we can use the bits above */ 275 /* Since the PAGE_PRESENT bit is bit 4, we can use the bits above */
277 276
278 #define __swp_type(x) (((x).val >> 5) & 0x7f) 277 #define __swp_type(x) (((x).val >> 5) & 0x7f)
279 #define __swp_offset(x) ((x).val >> 12) 278 #define __swp_offset(x) ((x).val >> 12)
280 #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 5) | ((offset) << 12) }) 279 #define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 5) | ((offset) << 12) })
281 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 280 #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
282 #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 281 #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
283 282
284 #define kern_addr_valid(addr) (1) 283 #define kern_addr_valid(addr) (1)
285 284
286 #include <asm-generic/pgtable.h> 285 #include <asm-generic/pgtable.h>
287 286
288 /* 287 /*
289 * No page table caches to initialise 288 * No page table caches to initialise
290 */ 289 */
291 #define pgtable_cache_init() do { } while (0) 290 #define pgtable_cache_init() do { } while (0)
292
293 #define pte_to_pgoff(x) (pte_val(x) >> 6)
294 #define pgoff_to_pte(x) __pte(((x) << 6) | _PAGE_FILE)
295 291
296 typedef pte_t *pte_addr_t; 292 typedef pte_t *pte_addr_t;
297 293
298 #endif /* __ASSEMBLY__ */ 294 #endif /* __ASSEMBLY__ */
299 #endif /* _CRIS_PGTABLE_H */ 295 #endif /* _CRIS_PGTABLE_H */
300 296