This source file includes following definitions.
- get_icache_tag
- put_icache_tag
- get_icache_data
- put_icache_data
- flush_ei_page
- flush_ei_seg
- flush_ei_region
- flush_ei_ctx
- flush_ei_user
1
2
3
4
5
6
7 #ifndef _SPARC_CACHE_H
8 #define _SPARC_CACHE_H
9
10 #include <asm/asi.h>
11
12
13
14
15
16
17
18
19
20
21
22 extern inline unsigned int get_icache_tag(int setnum, int tagnum)
23 {
24 unsigned int vaddr, retval;
25
26 vaddr = ((setnum&1) << 12) | ((tagnum&0x7f) << 5);
27 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
28 "=r" (retval) :
29 "r" (vaddr), "i" (ASI_M_TXTC_TAG));
30 return retval;
31 }
32
33 extern inline void put_icache_tag(int setnum, int tagnum, unsigned int entry)
34 {
35 unsigned int vaddr;
36
37 vaddr = ((setnum&1) << 12) | ((tagnum&0x7f) << 5);
38 __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
39 "r" (entry), "r" (vaddr), "i" (ASI_M_TXTC_TAG) :
40 "memory");
41 return;
42 }
43
44
45
46
47 extern inline void get_icache_data(int setnum, int tagnum, int subblock,
48 unsigned int *data)
49 {
50 unsigned int value1, value2, vaddr;
51
52 vaddr = ((setnum&0x1) << 12) | ((tagnum&0x7f) << 5) | ((subblock&0x3) << 3);
53 __asm__ __volatile__("ldda [%2] %3, %%g2\n\t"
54 "or %%g0, %%g2, %0\n\t"
55 "or %%g0, %%g3, %1\n\t" :
56 "=r" (value1), "=r" (value2) :
57 "r" (vaddr), "i" (ASI_M_TXTC_DATA) :
58 "g2", "g3");
59 data[0] = value1; data[1] = value2;
60 return;
61 }
62
63 extern inline void put_icache_data(int setnum, int tagnum, int subblock,
64 unsigned int *data)
65 {
66 unsigned int value1, value2, vaddr;
67
68 vaddr = ((setnum&0x1) << 12) | ((tagnum&0x7f) << 5) | ((subblock&0x3) << 3);
69 value1 = data[0]; value2 = data[1];
70 __asm__ __volatile__("or %%g0, %0, %%g2\n\t"
71 "or %%g0, %1, %%g3\n\t"
72 "stda %%g2, [%2] %3\n\t" : :
73 "r" (value1), "r" (value2),
74 "r" (vaddr), "i" (ASI_M_TXTC_DATA) :
75 "g2", "g3", "memory" );
76 return;
77 }
78
79
80
81
82
83
84
85
86
87
88 extern inline void flush_ei_page(unsigned int addr)
89 {
90 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
91 "r" (addr), "i" (ASI_M_FLUSH_PAGE) :
92 "memory");
93 return;
94 }
95
96 extern inline void flush_ei_seg(unsigned int addr)
97 {
98 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
99 "r" (addr), "i" (ASI_M_FLUSH_SEG) :
100 "memory");
101 return;
102 }
103
104 extern inline void flush_ei_region(unsigned int addr)
105 {
106 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
107 "r" (addr), "i" (ASI_M_FLUSH_REGION) :
108 "memory");
109 return;
110 }
111
112 extern inline void flush_ei_ctx(unsigned int addr)
113 {
114 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
115 "r" (addr), "i" (ASI_M_FLUSH_CTX) :
116 "memory");
117 return;
118 }
119
120 extern inline void flush_ei_user(unsigned int addr)
121 {
122 __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : :
123 "r" (addr), "i" (ASI_M_FLUSH_USER) :
124 "memory");
125 return;
126 }
127
128 #endif