aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-frv/highmem.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-frv/highmem.h
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 'include/asm-frv/highmem.h')
-rw-r--r--include/asm-frv/highmem.h181
1 files changed, 181 insertions, 0 deletions
diff --git a/include/asm-frv/highmem.h b/include/asm-frv/highmem.h
new file mode 100644
index 000000000000..295f74a57f22
--- /dev/null
+++ b/include/asm-frv/highmem.h
@@ -0,0 +1,181 @@
1/* highmem.h: virtual kernel memory mappings for high memory
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from include/asm-i386/highmem.h
6 *
7 * See Documentation/fujitsu/frv/mmu-layout.txt for more information.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#ifndef _ASM_HIGHMEM_H
16#define _ASM_HIGHMEM_H
17
18#ifdef __KERNEL__
19
20#include <linux/config.h>
21#include <linux/init.h>
22#include <asm/mem-layout.h>
23#include <asm/spr-regs.h>
24#include <asm/mb-regs.h>
25
26#define NR_TLB_LINES 64 /* number of lines in the TLB */
27
28#ifndef __ASSEMBLY__
29
30#include <linux/interrupt.h>
31#include <asm/kmap_types.h>
32#include <asm/pgtable.h>
33
34#ifdef CONFIG_DEBUG_HIGHMEM
35#define HIGHMEM_DEBUG 1
36#else
37#define HIGHMEM_DEBUG 0
38#endif
39
40/* declarations for highmem.c */
41extern unsigned long highstart_pfn, highend_pfn;
42
43#define kmap_prot PAGE_KERNEL
44#define kmap_pte ______kmap_pte_in_TLB
45extern pte_t *pkmap_page_table;
46
47#define flush_cache_kmaps() do { } while (0)
48
49/*
50 * Right now we initialize only a single pte table. It can be extended
51 * easily, subsequent pte tables have to be allocated in one physical
52 * chunk of RAM.
53 */
54#define LAST_PKMAP PTRS_PER_PTE
55#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
56#define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT)
57#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
58
59extern void *kmap_high(struct page *page);
60extern void kunmap_high(struct page *page);
61
62extern void *kmap(struct page *page);
63extern void kunmap(struct page *page);
64
65extern struct page *kmap_atomic_to_page(void *ptr);
66
67#endif /* !__ASSEMBLY__ */
68
69/*
70 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
71 * gives a more generic (and caching) interface. But kmap_atomic can
72 * be used in IRQ contexts, so in some (very limited) cases we need
73 * it.
74 */
75#define KMAP_ATOMIC_CACHE_DAMR 8
76
77#ifndef __ASSEMBLY__
78
79#define __kmap_atomic_primary(type, paddr, ampr) \
80({ \
81 unsigned long damlr, dampr; \
82 \
83 dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
84 \
85 if (type != __KM_CACHE) \
86 asm volatile("movgs %0,dampr"#ampr :: "r"(dampr)); \
87 else \
88 asm volatile("movgs %0,iampr"#ampr"\n" \
89 "movgs %0,dampr"#ampr"\n" \
90 :: "r"(dampr) \
91 ); \
92 \
93 asm("movsg damlr"#ampr",%0" : "=r"(damlr)); \
94 \
95 /*printk("DAMR"#ampr": PRIM sl=%d L=%08lx P=%08lx\n", type, damlr, dampr);*/ \
96 \
97 (void *) damlr; \
98})
99
100#define __kmap_atomic_secondary(slot, paddr) \
101({ \
102 unsigned long damlr = KMAP_ATOMIC_SECONDARY_FRAME + (slot) * PAGE_SIZE; \
103 unsigned long dampr = paddr | xAMPRx_L | xAMPRx_M | xAMPRx_S | xAMPRx_SS_16Kb | xAMPRx_V; \
104 \
105 asm volatile("movgs %0,tplr \n" \
106 "movgs %1,tppr \n" \
107 "tlbpr %0,gr0,#2,#1" \
108 : : "r"(damlr), "r"(dampr)); \
109 \
110 /*printk("TLB: SECN sl=%d L=%08lx P=%08lx\n", slot, damlr, dampr);*/ \
111 \
112 (void *) damlr; \
113})
114
115static inline void *kmap_atomic(struct page *page, enum km_type type)
116{
117 unsigned long paddr;
118
119 preempt_disable();
120 paddr = page_to_phys(page);
121
122 switch (type) {
123 case 0: return __kmap_atomic_primary(0, paddr, 2);
124 case 1: return __kmap_atomic_primary(1, paddr, 3);
125 case 2: return __kmap_atomic_primary(2, paddr, 4);
126 case 3: return __kmap_atomic_primary(3, paddr, 5);
127 case 4: return __kmap_atomic_primary(4, paddr, 6);
128 case 5: return __kmap_atomic_primary(5, paddr, 7);
129 case 6: return __kmap_atomic_primary(6, paddr, 8);
130 case 7: return __kmap_atomic_primary(7, paddr, 9);
131 case 8: return __kmap_atomic_primary(8, paddr, 10);
132
133 case 9 ... 9 + NR_TLB_LINES - 1:
134 return __kmap_atomic_secondary(type - 9, paddr);
135
136 default:
137 BUG();
138 return 0;
139 }
140}
141
142#define __kunmap_atomic_primary(type, ampr) \
143do { \
144 asm volatile("movgs gr0,dampr"#ampr"\n"); \
145 if (type == __KM_CACHE) \
146 asm volatile("movgs gr0,iampr"#ampr"\n"); \
147} while(0)
148
149#define __kunmap_atomic_secondary(slot, vaddr) \
150do { \
151 asm volatile("tlbpr %0,gr0,#4,#1" : : "r"(vaddr)); \
152} while(0)
153
154static inline void kunmap_atomic(void *kvaddr, enum km_type type)
155{
156 switch (type) {
157 case 0: __kunmap_atomic_primary(0, 2); break;
158 case 1: __kunmap_atomic_primary(1, 3); break;
159 case 2: __kunmap_atomic_primary(2, 4); break;
160 case 3: __kunmap_atomic_primary(3, 5); break;
161 case 4: __kunmap_atomic_primary(4, 6); break;
162 case 5: __kunmap_atomic_primary(5, 7); break;
163 case 6: __kunmap_atomic_primary(6, 8); break;
164 case 7: __kunmap_atomic_primary(7, 9); break;
165 case 8: __kunmap_atomic_primary(8, 10); break;
166
167 case 9 ... 9 + NR_TLB_LINES - 1:
168 __kunmap_atomic_secondary(type - 9, kvaddr);
169 break;
170
171 default:
172 BUG();
173 }
174 preempt_enable();
175}
176
177#endif /* !__ASSEMBLY__ */
178
179#endif /* __KERNEL__ */
180
181#endif /* _ASM_HIGHMEM_H */