diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sh/mm/pg-sh4.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/sh/mm/pg-sh4.c')
-rw-r--r-- | arch/sh/mm/pg-sh4.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c new file mode 100644 index 000000000000..e5907c7330e5 --- /dev/null +++ b/arch/sh/mm/pg-sh4.c | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * arch/sh/mm/pg-sh4.c | ||
3 | * | ||
4 | * Copyright (C) 1999, 2000, 2002 Niibe Yutaka | ||
5 | * Copyright (C) 2002 Paul Mundt | ||
6 | * | ||
7 | * Released under the terms of the GNU GPL v2.0. | ||
8 | */ | ||
9 | #include <linux/config.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/mman.h> | ||
12 | #include <linux/mm.h> | ||
13 | #include <linux/threads.h> | ||
14 | #include <asm/addrspace.h> | ||
15 | #include <asm/page.h> | ||
16 | #include <asm/pgtable.h> | ||
17 | #include <asm/processor.h> | ||
18 | #include <asm/cache.h> | ||
19 | #include <asm/io.h> | ||
20 | #include <asm/uaccess.h> | ||
21 | #include <asm/pgalloc.h> | ||
22 | #include <asm/mmu_context.h> | ||
23 | #include <asm/cacheflush.h> | ||
24 | |||
25 | extern struct semaphore p3map_sem[]; | ||
26 | |||
27 | /* | ||
28 | * clear_user_page | ||
29 | * @to: P1 address | ||
30 | * @address: U0 address to be mapped | ||
31 | * @page: page (virt_to_page(to)) | ||
32 | */ | ||
33 | void clear_user_page(void *to, unsigned long address, struct page *page) | ||
34 | { | ||
35 | __set_bit(PG_mapped, &page->flags); | ||
36 | if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) | ||
37 | clear_page(to); | ||
38 | else { | ||
39 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | | ||
40 | _PAGE_RW | _PAGE_CACHABLE | | ||
41 | _PAGE_DIRTY | _PAGE_ACCESSED | | ||
42 | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); | ||
43 | unsigned long phys_addr = PHYSADDR(to); | ||
44 | unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); | ||
45 | pgd_t *dir = pgd_offset_k(p3_addr); | ||
46 | pmd_t *pmd = pmd_offset(dir, p3_addr); | ||
47 | pte_t *pte = pte_offset_kernel(pmd, p3_addr); | ||
48 | pte_t entry; | ||
49 | unsigned long flags; | ||
50 | |||
51 | entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot); | ||
52 | down(&p3map_sem[(address & CACHE_ALIAS)>>12]); | ||
53 | set_pte(pte, entry); | ||
54 | local_irq_save(flags); | ||
55 | __flush_tlb_page(get_asid(), p3_addr); | ||
56 | local_irq_restore(flags); | ||
57 | update_mmu_cache(NULL, p3_addr, entry); | ||
58 | __clear_user_page((void *)p3_addr, to); | ||
59 | pte_clear(&init_mm, p3_addr, pte); | ||
60 | up(&p3map_sem[(address & CACHE_ALIAS)>>12]); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | * copy_user_page | ||
66 | * @to: P1 address | ||
67 | * @from: P1 address | ||
68 | * @address: U0 address to be mapped | ||
69 | * @page: page (virt_to_page(to)) | ||
70 | */ | ||
71 | void copy_user_page(void *to, void *from, unsigned long address, | ||
72 | struct page *page) | ||
73 | { | ||
74 | __set_bit(PG_mapped, &page->flags); | ||
75 | if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) | ||
76 | copy_page(to, from); | ||
77 | else { | ||
78 | pgprot_t pgprot = __pgprot(_PAGE_PRESENT | | ||
79 | _PAGE_RW | _PAGE_CACHABLE | | ||
80 | _PAGE_DIRTY | _PAGE_ACCESSED | | ||
81 | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); | ||
82 | unsigned long phys_addr = PHYSADDR(to); | ||
83 | unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); | ||
84 | pgd_t *dir = pgd_offset_k(p3_addr); | ||
85 | pmd_t *pmd = pmd_offset(dir, p3_addr); | ||
86 | pte_t *pte = pte_offset_kernel(pmd, p3_addr); | ||
87 | pte_t entry; | ||
88 | unsigned long flags; | ||
89 | |||
90 | entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot); | ||
91 | down(&p3map_sem[(address & CACHE_ALIAS)>>12]); | ||
92 | set_pte(pte, entry); | ||
93 | local_irq_save(flags); | ||
94 | __flush_tlb_page(get_asid(), p3_addr); | ||
95 | local_irq_restore(flags); | ||
96 | update_mmu_cache(NULL, p3_addr, entry); | ||
97 | __copy_user_page((void *)p3_addr, from, to); | ||
98 | pte_clear(&init_mm, p3_addr, pte); | ||
99 | up(&p3map_sem[(address & CACHE_ALIAS)>>12]); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | /* | ||
104 | * For SH-4, we have our own implementation for ptep_get_and_clear | ||
105 | */ | ||
106 | inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
107 | { | ||
108 | pte_t pte = *ptep; | ||
109 | |||
110 | pte_clear(mm, addr, ptep); | ||
111 | if (!pte_not_present(pte)) { | ||
112 | unsigned long pfn = pte_pfn(pte); | ||
113 | if (pfn_valid(pfn)) { | ||
114 | struct page *page = pfn_to_page(pfn); | ||
115 | struct address_space *mapping = page_mapping(page); | ||
116 | if (!mapping || !mapping_writably_mapped(mapping)) | ||
117 | __clear_bit(PG_mapped, &page->flags); | ||
118 | } | ||
119 | } | ||
120 | return pte; | ||
121 | } | ||
122 | |||