1 /* $Id: spitfire.h,v 1.18 2001/11/29 16:42:10 kanoj Exp $
2 * spitfire.h: SpitFire/BlackBird/Cheetah inline MMU operations.
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
7 #ifndef _SPARC64_SPITFIRE_H
8 #define _SPARC64_SPITFIRE_H
12 /* The following register addresses are accessible via ASI_DMMU
13 * and ASI_IMMU, that is there is a distinct and unique copy of
14 * each these registers for each TLB.
16 #define TSB_TAG_TARGET 0x0000000000000000 /* All chips */
17 #define TLB_SFSR 0x0000000000000018 /* All chips */
18 #define TSB_REG 0x0000000000000028 /* All chips */
19 #define TLB_TAG_ACCESS 0x0000000000000030 /* All chips */
20 #define VIRT_WATCHPOINT 0x0000000000000038 /* All chips */
21 #define PHYS_WATCHPOINT 0x0000000000000040 /* All chips */
22 #define TSB_EXTENSION_P 0x0000000000000048 /* Ultra-III and later */
23 #define TSB_EXTENSION_S 0x0000000000000050 /* Ultra-III and later, D-TLB only */
24 #define TSB_EXTENSION_N 0x0000000000000058 /* Ultra-III and later */
25 #define TLB_TAG_ACCESS_EXT 0x0000000000000060 /* Ultra-III+ and later */
27 /* These registers only exist as one entity, and are accessed
30 #define PRIMARY_CONTEXT 0x0000000000000008
31 #define SECONDARY_CONTEXT 0x0000000000000010
32 #define DMMU_SFAR 0x0000000000000020
33 #define VIRT_WATCHPOINT 0x0000000000000038
34 #define PHYS_WATCHPOINT 0x0000000000000040
36 #define SPITFIRE_HIGHEST_LOCKED_TLBENT (64 - 1)
37 #define CHEETAH_HIGHEST_LOCKED_TLBENT (16 - 1)
39 #define L1DCACHE_SIZE 0x4000
43 enum ultra_tlb_layout
{
49 extern enum ultra_tlb_layout tlb_type
;
51 extern int cheetah_pcache_forced_on
;
52 extern void cheetah_enable_pcache(void);
54 #define sparc64_highest_locked_tlbent() \
55 (tlb_type == spitfire ? \
56 SPITFIRE_HIGHEST_LOCKED_TLBENT : \
57 CHEETAH_HIGHEST_LOCKED_TLBENT)
59 /* The data cache is write through, so this just invalidates the
62 static __inline__
void spitfire_put_dcache_tag(unsigned long addr
, unsigned long tag
)
64 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
67 : "r" (tag
), "r" (addr
), "i" (ASI_DCACHE_TAG
));
70 /* The instruction cache lines are flushed with this, but note that
71 * this does not flush the pipeline. It is possible for a line to
72 * get flushed but stale instructions to still be in the pipeline,
73 * a flush instruction (to any address) is sufficient to handle
74 * this issue after the line is invalidated.
76 static __inline__
void spitfire_put_icache_tag(unsigned long addr
, unsigned long tag
)
78 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
81 : "r" (tag
), "r" (addr
), "i" (ASI_IC_TAG
));
84 static __inline__
unsigned long spitfire_get_dtlb_data(int entry
)
88 __asm__
__volatile__("ldxa [%1] %2, %0"
90 : "r" (entry
<< 3), "i" (ASI_DTLB_DATA_ACCESS
));
92 /* Clear TTE diag bits. */
93 data
&= ~0x0003fe0000000000UL
;
98 static __inline__
unsigned long spitfire_get_dtlb_tag(int entry
)
102 __asm__
__volatile__("ldxa [%1] %2, %0"
104 : "r" (entry
<< 3), "i" (ASI_DTLB_TAG_READ
));
108 static __inline__
void spitfire_put_dtlb_data(int entry
, unsigned long data
)
110 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
113 : "r" (data
), "r" (entry
<< 3),
114 "i" (ASI_DTLB_DATA_ACCESS
));
117 static __inline__
unsigned long spitfire_get_itlb_data(int entry
)
121 __asm__
__volatile__("ldxa [%1] %2, %0"
123 : "r" (entry
<< 3), "i" (ASI_ITLB_DATA_ACCESS
));
125 /* Clear TTE diag bits. */
126 data
&= ~0x0003fe0000000000UL
;
131 static __inline__
unsigned long spitfire_get_itlb_tag(int entry
)
135 __asm__
__volatile__("ldxa [%1] %2, %0"
137 : "r" (entry
<< 3), "i" (ASI_ITLB_TAG_READ
));
141 static __inline__
void spitfire_put_itlb_data(int entry
, unsigned long data
)
143 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
146 : "r" (data
), "r" (entry
<< 3),
147 "i" (ASI_ITLB_DATA_ACCESS
));
150 static __inline__
void spitfire_flush_dtlb_nucleus_page(unsigned long page
)
152 __asm__
__volatile__("stxa %%g0, [%0] %1\n\t"
155 : "r" (page
| 0x20), "i" (ASI_DMMU_DEMAP
));
158 static __inline__
void spitfire_flush_itlb_nucleus_page(unsigned long page
)
160 __asm__
__volatile__("stxa %%g0, [%0] %1\n\t"
163 : "r" (page
| 0x20), "i" (ASI_IMMU_DEMAP
));
166 /* Cheetah has "all non-locked" tlb flushes. */
167 static __inline__
void cheetah_flush_dtlb_all(void)
169 __asm__
__volatile__("stxa %%g0, [%0] %1\n\t"
172 : "r" (0x80), "i" (ASI_DMMU_DEMAP
));
175 static __inline__
void cheetah_flush_itlb_all(void)
177 __asm__
__volatile__("stxa %%g0, [%0] %1\n\t"
180 : "r" (0x80), "i" (ASI_IMMU_DEMAP
));
183 /* Cheetah has a 4-tlb layout so direct access is a bit different.
184 * The first two TLBs are fully assosciative, hold 16 entries, and are
185 * used only for locked and >8K sized translations. One exists for
186 * data accesses and one for instruction accesses.
188 * The third TLB is for data accesses to 8K non-locked translations, is
189 * 2 way assosciative, and holds 512 entries. The fourth TLB is for
190 * instruction accesses to 8K non-locked translations, is 2 way
191 * assosciative, and holds 128 entries.
193 * Cheetah has some bug where bogus data can be returned from
194 * ASI_{D,I}TLB_DATA_ACCESS loads, doing the load twice fixes
195 * the problem for me. -DaveM
197 static __inline__
unsigned long cheetah_get_ldtlb_data(int entry
)
201 __asm__
__volatile__("ldxa [%1] %2, %%g0\n\t"
204 : "r" ((0 << 16) | (entry
<< 3)),
205 "i" (ASI_DTLB_DATA_ACCESS
));
210 static __inline__
unsigned long cheetah_get_litlb_data(int entry
)
214 __asm__
__volatile__("ldxa [%1] %2, %%g0\n\t"
217 : "r" ((0 << 16) | (entry
<< 3)),
218 "i" (ASI_ITLB_DATA_ACCESS
));
223 static __inline__
unsigned long cheetah_get_ldtlb_tag(int entry
)
227 __asm__
__volatile__("ldxa [%1] %2, %0"
229 : "r" ((0 << 16) | (entry
<< 3)),
230 "i" (ASI_DTLB_TAG_READ
));
235 static __inline__
unsigned long cheetah_get_litlb_tag(int entry
)
239 __asm__
__volatile__("ldxa [%1] %2, %0"
241 : "r" ((0 << 16) | (entry
<< 3)),
242 "i" (ASI_ITLB_TAG_READ
));
247 static __inline__
void cheetah_put_ldtlb_data(int entry
, unsigned long data
)
249 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
253 "r" ((0 << 16) | (entry
<< 3)),
254 "i" (ASI_DTLB_DATA_ACCESS
));
257 static __inline__
void cheetah_put_litlb_data(int entry
, unsigned long data
)
259 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
263 "r" ((0 << 16) | (entry
<< 3)),
264 "i" (ASI_ITLB_DATA_ACCESS
));
267 static __inline__
unsigned long cheetah_get_dtlb_data(int entry
, int tlb
)
271 __asm__
__volatile__("ldxa [%1] %2, %%g0\n\t"
274 : "r" ((tlb
<< 16) | (entry
<< 3)), "i" (ASI_DTLB_DATA_ACCESS
));
279 static __inline__
unsigned long cheetah_get_dtlb_tag(int entry
, int tlb
)
283 __asm__
__volatile__("ldxa [%1] %2, %0"
285 : "r" ((tlb
<< 16) | (entry
<< 3)), "i" (ASI_DTLB_TAG_READ
));
289 static __inline__
void cheetah_put_dtlb_data(int entry
, unsigned long data
, int tlb
)
291 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
295 "r" ((tlb
<< 16) | (entry
<< 3)),
296 "i" (ASI_DTLB_DATA_ACCESS
));
299 static __inline__
unsigned long cheetah_get_itlb_data(int entry
)
303 __asm__
__volatile__("ldxa [%1] %2, %%g0\n\t"
306 : "r" ((2 << 16) | (entry
<< 3)),
307 "i" (ASI_ITLB_DATA_ACCESS
));
312 static __inline__
unsigned long cheetah_get_itlb_tag(int entry
)
316 __asm__
__volatile__("ldxa [%1] %2, %0"
318 : "r" ((2 << 16) | (entry
<< 3)), "i" (ASI_ITLB_TAG_READ
));
322 static __inline__
void cheetah_put_itlb_data(int entry
, unsigned long data
)
324 __asm__
__volatile__("stxa %0, [%1] %2\n\t"
327 : "r" (data
), "r" ((2 << 16) | (entry
<< 3)),
328 "i" (ASI_ITLB_DATA_ACCESS
));
331 #endif /* !(__ASSEMBLY__) */
333 #endif /* !(_SPARC64_SPITFIRE_H) */