Rev 901 | Rev 1780 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 901 | Rev 1702 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Jakub Jermar |
2 | * Copyright (C) 2005 Jakub Jermar |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
- | 29 | /** @addtogroup sparc64mm |
|
- | 30 | * @{ |
|
- | 31 | */ |
|
- | 32 | /** @file |
|
- | 33 | */ |
|
- | 34 | ||
29 | #ifndef __sparc64_TLB_H__ |
35 | #ifndef __sparc64_TLB_H__ |
30 | #define __sparc64_TLB_H__ |
36 | #define __sparc64_TLB_H__ |
31 | 37 | ||
32 | #include <arch/mm/tte.h> |
38 | #include <arch/mm/tte.h> |
33 | #include <arch/mm/mmu.h> |
39 | #include <arch/mm/mmu.h> |
34 | #include <arch/mm/page.h> |
40 | #include <arch/mm/page.h> |
35 | #include <arch/asm.h> |
41 | #include <arch/asm.h> |
36 | #include <arch/barrier.h> |
42 | #include <arch/barrier.h> |
37 | #include <arch/types.h> |
43 | #include <arch/types.h> |
38 | #include <typedefs.h> |
44 | #include <typedefs.h> |
39 | 45 | ||
40 | #define ITLB_ENTRY_COUNT 64 |
46 | #define ITLB_ENTRY_COUNT 64 |
41 | #define DTLB_ENTRY_COUNT 64 |
47 | #define DTLB_ENTRY_COUNT 64 |
42 | 48 | ||
43 | /** Page sizes. */ |
49 | /** Page sizes. */ |
44 | #define PAGESIZE_8K 0 |
50 | #define PAGESIZE_8K 0 |
45 | #define PAGESIZE_64K 1 |
51 | #define PAGESIZE_64K 1 |
46 | #define PAGESIZE_512K 2 |
52 | #define PAGESIZE_512K 2 |
47 | #define PAGESIZE_4M 3 |
53 | #define PAGESIZE_4M 3 |
48 | 54 | ||
49 | /** Bit width of the TLB-locked portion of kernel address space. */ |
55 | /** Bit width of the TLB-locked portion of kernel address space. */ |
50 | #define KERNEL_PAGE_WIDTH 22 /* 4M */ |
56 | #define KERNEL_PAGE_WIDTH 22 /* 4M */ |
51 | 57 | ||
52 | union tlb_context_reg { |
58 | union tlb_context_reg { |
53 | __u64 v; |
59 | __u64 v; |
54 | struct { |
60 | struct { |
55 | unsigned long : 51; |
61 | unsigned long : 51; |
56 | unsigned context : 13; /**< Context/ASID. */ |
62 | unsigned context : 13; /**< Context/ASID. */ |
57 | } __attribute__ ((packed)); |
63 | } __attribute__ ((packed)); |
58 | }; |
64 | }; |
59 | typedef union tlb_context_reg tlb_context_reg_t; |
65 | typedef union tlb_context_reg tlb_context_reg_t; |
60 | 66 | ||
61 | /** I-/D-TLB Data In/Access Register type. */ |
67 | /** I-/D-TLB Data In/Access Register type. */ |
62 | typedef tte_data_t tlb_data_t; |
68 | typedef tte_data_t tlb_data_t; |
63 | 69 | ||
64 | /** I-/D-TLB Data Access Address in Alternate Space. */ |
70 | /** I-/D-TLB Data Access Address in Alternate Space. */ |
65 | union tlb_data_access_addr { |
71 | union tlb_data_access_addr { |
66 | __u64 value; |
72 | __u64 value; |
67 | struct { |
73 | struct { |
68 | __u64 : 55; |
74 | __u64 : 55; |
69 | unsigned tlb_entry : 6; |
75 | unsigned tlb_entry : 6; |
70 | unsigned : 3; |
76 | unsigned : 3; |
71 | } __attribute__ ((packed)); |
77 | } __attribute__ ((packed)); |
72 | }; |
78 | }; |
73 | typedef union tlb_data_access_addr tlb_data_access_addr_t; |
79 | typedef union tlb_data_access_addr tlb_data_access_addr_t; |
74 | typedef union tlb_data_access_addr tlb_tag_read_addr_t; |
80 | typedef union tlb_data_access_addr tlb_tag_read_addr_t; |
75 | 81 | ||
76 | /** I-/D-TLB Tag Read Register. */ |
82 | /** I-/D-TLB Tag Read Register. */ |
77 | union tlb_tag_read_reg { |
83 | union tlb_tag_read_reg { |
78 | __u64 value; |
84 | __u64 value; |
79 | struct { |
85 | struct { |
80 | __u64 vpn : 51; /**< Virtual Address bits 63:13. */ |
86 | __u64 vpn : 51; /**< Virtual Address bits 63:13. */ |
81 | unsigned context : 13; /**< Context identifier. */ |
87 | unsigned context : 13; /**< Context identifier. */ |
82 | } __attribute__ ((packed)); |
88 | } __attribute__ ((packed)); |
83 | }; |
89 | }; |
84 | typedef union tlb_tag_read_reg tlb_tag_read_reg_t; |
90 | typedef union tlb_tag_read_reg tlb_tag_read_reg_t; |
85 | typedef union tlb_tag_read_reg tlb_tag_access_reg_t; |
91 | typedef union tlb_tag_read_reg tlb_tag_access_reg_t; |
86 | 92 | ||
87 | /** TLB Demap Operation types. */ |
93 | /** TLB Demap Operation types. */ |
88 | #define TLB_DEMAP_PAGE 0 |
94 | #define TLB_DEMAP_PAGE 0 |
89 | #define TLB_DEMAP_CONTEXT 1 |
95 | #define TLB_DEMAP_CONTEXT 1 |
90 | 96 | ||
91 | /** TLB Demap Operation Context register encodings. */ |
97 | /** TLB Demap Operation Context register encodings. */ |
92 | #define TLB_DEMAP_PRIMARY 0 |
98 | #define TLB_DEMAP_PRIMARY 0 |
93 | #define TLB_DEMAP_SECONDARY 1 |
99 | #define TLB_DEMAP_SECONDARY 1 |
94 | #define TLB_DEMAP_NUCLEUS 2 |
100 | #define TLB_DEMAP_NUCLEUS 2 |
95 | 101 | ||
96 | /** TLB Demap Operation Address. */ |
102 | /** TLB Demap Operation Address. */ |
97 | union tlb_demap_addr { |
103 | union tlb_demap_addr { |
98 | __u64 value; |
104 | __u64 value; |
99 | struct { |
105 | struct { |
100 | __u64 vpn: 51; /**< Virtual Address bits 63:13. */ |
106 | __u64 vpn: 51; /**< Virtual Address bits 63:13. */ |
101 | unsigned : 6; /**< Ignored. */ |
107 | unsigned : 6; /**< Ignored. */ |
102 | unsigned type : 1; /**< The type of demap operation. */ |
108 | unsigned type : 1; /**< The type of demap operation. */ |
103 | unsigned context : 2; /**< Context register selection. */ |
109 | unsigned context : 2; /**< Context register selection. */ |
104 | unsigned : 4; /**< Zero. */ |
110 | unsigned : 4; /**< Zero. */ |
105 | } __attribute__ ((packed)); |
111 | } __attribute__ ((packed)); |
106 | }; |
112 | }; |
107 | typedef union tlb_demap_addr tlb_demap_addr_t; |
113 | typedef union tlb_demap_addr tlb_demap_addr_t; |
108 | 114 | ||
109 | /** TLB Synchronous Fault Status Register. */ |
115 | /** TLB Synchronous Fault Status Register. */ |
110 | union tlb_sfsr_reg { |
116 | union tlb_sfsr_reg { |
111 | __u64 value; |
117 | __u64 value; |
112 | struct { |
118 | struct { |
113 | unsigned long : 39; /**< Implementation dependent. */ |
119 | unsigned long : 39; /**< Implementation dependent. */ |
114 | unsigned nf : 1; /**< Nonfaulting load. */ |
120 | unsigned nf : 1; /**< Nonfaulting load. */ |
115 | unsigned asi : 8; /**< ASI. */ |
121 | unsigned asi : 8; /**< ASI. */ |
116 | unsigned tm : 1; /**< TLB miss. */ |
122 | unsigned tm : 1; /**< TLB miss. */ |
117 | unsigned : 1; |
123 | unsigned : 1; |
118 | unsigned ft : 7; /**< Fault type. */ |
124 | unsigned ft : 7; /**< Fault type. */ |
119 | unsigned e : 1; /**< Side-effect bit. */ |
125 | unsigned e : 1; /**< Side-effect bit. */ |
120 | unsigned ct : 2; /**< Context Register selection. */ |
126 | unsigned ct : 2; /**< Context Register selection. */ |
121 | unsigned pr : 1; /**< Privilege bit. */ |
127 | unsigned pr : 1; /**< Privilege bit. */ |
122 | unsigned w : 1; /**< Write bit. */ |
128 | unsigned w : 1; /**< Write bit. */ |
123 | unsigned ow : 1; /**< Overwrite bit. */ |
129 | unsigned ow : 1; /**< Overwrite bit. */ |
124 | unsigned fv : 1; /**< Fault Valid bit. */ |
130 | unsigned fv : 1; /**< Fault Valid bit. */ |
125 | } __attribute__ ((packed)); |
131 | } __attribute__ ((packed)); |
126 | }; |
132 | }; |
127 | typedef union tlb_sfsr_reg tlb_sfsr_reg_t; |
133 | typedef union tlb_sfsr_reg tlb_sfsr_reg_t; |
128 | 134 | ||
129 | /** Read MMU Primary Context Register. |
135 | /** Read MMU Primary Context Register. |
130 | * |
136 | * |
131 | * @return Current value of Primary Context Register. |
137 | * @return Current value of Primary Context Register. |
132 | */ |
138 | */ |
133 | static inline __u64 mmu_primary_context_read(void) |
139 | static inline __u64 mmu_primary_context_read(void) |
134 | { |
140 | { |
135 | return asi_u64_read(ASI_DMMU, VA_PRIMARY_CONTEXT_REG); |
141 | return asi_u64_read(ASI_DMMU, VA_PRIMARY_CONTEXT_REG); |
136 | } |
142 | } |
137 | 143 | ||
138 | /** Write MMU Primary Context Register. |
144 | /** Write MMU Primary Context Register. |
139 | * |
145 | * |
140 | * @param v New value of Primary Context Register. |
146 | * @param v New value of Primary Context Register. |
141 | */ |
147 | */ |
142 | static inline void mmu_primary_context_write(__u64 v) |
148 | static inline void mmu_primary_context_write(__u64 v) |
143 | { |
149 | { |
144 | asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v); |
150 | asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v); |
145 | flush(); |
151 | flush(); |
146 | } |
152 | } |
147 | 153 | ||
148 | /** Read MMU Secondary Context Register. |
154 | /** Read MMU Secondary Context Register. |
149 | * |
155 | * |
150 | * @return Current value of Secondary Context Register. |
156 | * @return Current value of Secondary Context Register. |
151 | */ |
157 | */ |
152 | static inline __u64 mmu_secondary_context_read(void) |
158 | static inline __u64 mmu_secondary_context_read(void) |
153 | { |
159 | { |
154 | return asi_u64_read(ASI_DMMU, VA_SECONDARY_CONTEXT_REG); |
160 | return asi_u64_read(ASI_DMMU, VA_SECONDARY_CONTEXT_REG); |
155 | } |
161 | } |
156 | 162 | ||
157 | /** Write MMU Primary Context Register. |
163 | /** Write MMU Primary Context Register. |
158 | * |
164 | * |
159 | * @param v New value of Primary Context Register. |
165 | * @param v New value of Primary Context Register. |
160 | */ |
166 | */ |
161 | static inline void mmu_secondary_context_write(__u64 v) |
167 | static inline void mmu_secondary_context_write(__u64 v) |
162 | { |
168 | { |
163 | asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v); |
169 | asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v); |
164 | flush(); |
170 | flush(); |
165 | } |
171 | } |
166 | 172 | ||
167 | /** Read IMMU TLB Data Access Register. |
173 | /** Read IMMU TLB Data Access Register. |
168 | * |
174 | * |
169 | * @param entry TLB Entry index. |
175 | * @param entry TLB Entry index. |
170 | * |
176 | * |
171 | * @return Current value of specified IMMU TLB Data Access Register. |
177 | * @return Current value of specified IMMU TLB Data Access Register. |
172 | */ |
178 | */ |
173 | static inline __u64 itlb_data_access_read(index_t entry) |
179 | static inline __u64 itlb_data_access_read(index_t entry) |
174 | { |
180 | { |
175 | tlb_data_access_addr_t reg; |
181 | tlb_data_access_addr_t reg; |
176 | 182 | ||
177 | reg.value = 0; |
183 | reg.value = 0; |
178 | reg.tlb_entry = entry; |
184 | reg.tlb_entry = entry; |
179 | return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value); |
185 | return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value); |
180 | } |
186 | } |
181 | 187 | ||
182 | /** Write IMMU TLB Data Access Register. |
188 | /** Write IMMU TLB Data Access Register. |
183 | * |
189 | * |
184 | * @param entry TLB Entry index. |
190 | * @param entry TLB Entry index. |
185 | * @param value Value to be written. |
191 | * @param value Value to be written. |
186 | */ |
192 | */ |
187 | static inline void itlb_data_access_write(index_t entry, __u64 value) |
193 | static inline void itlb_data_access_write(index_t entry, __u64 value) |
188 | { |
194 | { |
189 | tlb_data_access_addr_t reg; |
195 | tlb_data_access_addr_t reg; |
190 | 196 | ||
191 | reg.value = 0; |
197 | reg.value = 0; |
192 | reg.tlb_entry = entry; |
198 | reg.tlb_entry = entry; |
193 | asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value); |
199 | asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value); |
194 | flush(); |
200 | flush(); |
195 | } |
201 | } |
196 | 202 | ||
197 | /** Read DMMU TLB Data Access Register. |
203 | /** Read DMMU TLB Data Access Register. |
198 | * |
204 | * |
199 | * @param entry TLB Entry index. |
205 | * @param entry TLB Entry index. |
200 | * |
206 | * |
201 | * @return Current value of specified DMMU TLB Data Access Register. |
207 | * @return Current value of specified DMMU TLB Data Access Register. |
202 | */ |
208 | */ |
203 | static inline __u64 dtlb_data_access_read(index_t entry) |
209 | static inline __u64 dtlb_data_access_read(index_t entry) |
204 | { |
210 | { |
205 | tlb_data_access_addr_t reg; |
211 | tlb_data_access_addr_t reg; |
206 | 212 | ||
207 | reg.value = 0; |
213 | reg.value = 0; |
208 | reg.tlb_entry = entry; |
214 | reg.tlb_entry = entry; |
209 | return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value); |
215 | return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value); |
210 | } |
216 | } |
211 | 217 | ||
212 | /** Write DMMU TLB Data Access Register. |
218 | /** Write DMMU TLB Data Access Register. |
213 | * |
219 | * |
214 | * @param entry TLB Entry index. |
220 | * @param entry TLB Entry index. |
215 | * @param value Value to be written. |
221 | * @param value Value to be written. |
216 | */ |
222 | */ |
217 | static inline void dtlb_data_access_write(index_t entry, __u64 value) |
223 | static inline void dtlb_data_access_write(index_t entry, __u64 value) |
218 | { |
224 | { |
219 | tlb_data_access_addr_t reg; |
225 | tlb_data_access_addr_t reg; |
220 | 226 | ||
221 | reg.value = 0; |
227 | reg.value = 0; |
222 | reg.tlb_entry = entry; |
228 | reg.tlb_entry = entry; |
223 | asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value); |
229 | asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value); |
224 | flush(); |
230 | flush(); |
225 | } |
231 | } |
226 | 232 | ||
227 | /** Read IMMU TLB Tag Read Register. |
233 | /** Read IMMU TLB Tag Read Register. |
228 | * |
234 | * |
229 | * @param entry TLB Entry index. |
235 | * @param entry TLB Entry index. |
230 | * |
236 | * |
231 | * @return Current value of specified IMMU TLB Tag Read Register. |
237 | * @return Current value of specified IMMU TLB Tag Read Register. |
232 | */ |
238 | */ |
233 | static inline __u64 itlb_tag_read_read(index_t entry) |
239 | static inline __u64 itlb_tag_read_read(index_t entry) |
234 | { |
240 | { |
235 | tlb_tag_read_addr_t tag; |
241 | tlb_tag_read_addr_t tag; |
236 | 242 | ||
237 | tag.value = 0; |
243 | tag.value = 0; |
238 | tag.tlb_entry = entry; |
244 | tag.tlb_entry = entry; |
239 | return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value); |
245 | return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value); |
240 | } |
246 | } |
241 | 247 | ||
242 | /** Read DMMU TLB Tag Read Register. |
248 | /** Read DMMU TLB Tag Read Register. |
243 | * |
249 | * |
244 | * @param entry TLB Entry index. |
250 | * @param entry TLB Entry index. |
245 | * |
251 | * |
246 | * @return Current value of specified DMMU TLB Tag Read Register. |
252 | * @return Current value of specified DMMU TLB Tag Read Register. |
247 | */ |
253 | */ |
248 | static inline __u64 dtlb_tag_read_read(index_t entry) |
254 | static inline __u64 dtlb_tag_read_read(index_t entry) |
249 | { |
255 | { |
250 | tlb_tag_read_addr_t tag; |
256 | tlb_tag_read_addr_t tag; |
251 | 257 | ||
252 | tag.value = 0; |
258 | tag.value = 0; |
253 | tag.tlb_entry = entry; |
259 | tag.tlb_entry = entry; |
254 | return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value); |
260 | return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value); |
255 | } |
261 | } |
256 | 262 | ||
257 | /** Write IMMU TLB Tag Access Register. |
263 | /** Write IMMU TLB Tag Access Register. |
258 | * |
264 | * |
259 | * @param v Value to be written. |
265 | * @param v Value to be written. |
260 | */ |
266 | */ |
261 | static inline void itlb_tag_access_write(__u64 v) |
267 | static inline void itlb_tag_access_write(__u64 v) |
262 | { |
268 | { |
263 | asi_u64_write(ASI_IMMU, VA_IMMU_TAG_ACCESS, v); |
269 | asi_u64_write(ASI_IMMU, VA_IMMU_TAG_ACCESS, v); |
264 | flush(); |
270 | flush(); |
265 | } |
271 | } |
266 | 272 | ||
267 | /** Read IMMU TLB Tag Access Register. |
273 | /** Read IMMU TLB Tag Access Register. |
268 | * |
274 | * |
269 | * @return Current value of IMMU TLB Tag Access Register. |
275 | * @return Current value of IMMU TLB Tag Access Register. |
270 | */ |
276 | */ |
271 | static inline __u64 itlb_tag_access_read(void) |
277 | static inline __u64 itlb_tag_access_read(void) |
272 | { |
278 | { |
273 | return asi_u64_read(ASI_IMMU, VA_IMMU_TAG_ACCESS); |
279 | return asi_u64_read(ASI_IMMU, VA_IMMU_TAG_ACCESS); |
274 | } |
280 | } |
275 | 281 | ||
276 | /** Write DMMU TLB Tag Access Register. |
282 | /** Write DMMU TLB Tag Access Register. |
277 | * |
283 | * |
278 | * @param v Value to be written. |
284 | * @param v Value to be written. |
279 | */ |
285 | */ |
280 | static inline void dtlb_tag_access_write(__u64 v) |
286 | static inline void dtlb_tag_access_write(__u64 v) |
281 | { |
287 | { |
282 | asi_u64_write(ASI_DMMU, VA_DMMU_TAG_ACCESS, v); |
288 | asi_u64_write(ASI_DMMU, VA_DMMU_TAG_ACCESS, v); |
283 | flush(); |
289 | flush(); |
284 | } |
290 | } |
285 | 291 | ||
286 | /** Read DMMU TLB Tag Access Register. |
292 | /** Read DMMU TLB Tag Access Register. |
287 | * |
293 | * |
288 | * @return Current value of DMMU TLB Tag Access Register. |
294 | * @return Current value of DMMU TLB Tag Access Register. |
289 | */ |
295 | */ |
290 | static inline __u64 dtlb_tag_access_read(void) |
296 | static inline __u64 dtlb_tag_access_read(void) |
291 | { |
297 | { |
292 | return asi_u64_read(ASI_DMMU, VA_DMMU_TAG_ACCESS); |
298 | return asi_u64_read(ASI_DMMU, VA_DMMU_TAG_ACCESS); |
293 | } |
299 | } |
294 | 300 | ||
295 | 301 | ||
296 | /** Write IMMU TLB Data in Register. |
302 | /** Write IMMU TLB Data in Register. |
297 | * |
303 | * |
298 | * @param v Value to be written. |
304 | * @param v Value to be written. |
299 | */ |
305 | */ |
300 | static inline void itlb_data_in_write(__u64 v) |
306 | static inline void itlb_data_in_write(__u64 v) |
301 | { |
307 | { |
302 | asi_u64_write(ASI_ITLB_DATA_IN_REG, 0, v); |
308 | asi_u64_write(ASI_ITLB_DATA_IN_REG, 0, v); |
303 | flush(); |
309 | flush(); |
304 | } |
310 | } |
305 | 311 | ||
306 | /** Write DMMU TLB Data in Register. |
312 | /** Write DMMU TLB Data in Register. |
307 | * |
313 | * |
308 | * @param v Value to be written. |
314 | * @param v Value to be written. |
309 | */ |
315 | */ |
310 | static inline void dtlb_data_in_write(__u64 v) |
316 | static inline void dtlb_data_in_write(__u64 v) |
311 | { |
317 | { |
312 | asi_u64_write(ASI_DTLB_DATA_IN_REG, 0, v); |
318 | asi_u64_write(ASI_DTLB_DATA_IN_REG, 0, v); |
313 | flush(); |
319 | flush(); |
314 | } |
320 | } |
315 | 321 | ||
316 | /** Read ITLB Synchronous Fault Status Register. |
322 | /** Read ITLB Synchronous Fault Status Register. |
317 | * |
323 | * |
318 | * @return Current content of I-SFSR register. |
324 | * @return Current content of I-SFSR register. |
319 | */ |
325 | */ |
320 | static inline __u64 itlb_sfsr_read(void) |
326 | static inline __u64 itlb_sfsr_read(void) |
321 | { |
327 | { |
322 | return asi_u64_read(ASI_IMMU, VA_IMMU_SFSR); |
328 | return asi_u64_read(ASI_IMMU, VA_IMMU_SFSR); |
323 | } |
329 | } |
324 | 330 | ||
325 | /** Write ITLB Synchronous Fault Status Register. |
331 | /** Write ITLB Synchronous Fault Status Register. |
326 | * |
332 | * |
327 | * @param v New value of I-SFSR register. |
333 | * @param v New value of I-SFSR register. |
328 | */ |
334 | */ |
329 | static inline void itlb_sfsr_write(__u64 v) |
335 | static inline void itlb_sfsr_write(__u64 v) |
330 | { |
336 | { |
331 | asi_u64_write(ASI_IMMU, VA_IMMU_SFSR, v); |
337 | asi_u64_write(ASI_IMMU, VA_IMMU_SFSR, v); |
332 | flush(); |
338 | flush(); |
333 | } |
339 | } |
334 | 340 | ||
335 | /** Read DTLB Synchronous Fault Status Register. |
341 | /** Read DTLB Synchronous Fault Status Register. |
336 | * |
342 | * |
337 | * @return Current content of D-SFSR register. |
343 | * @return Current content of D-SFSR register. |
338 | */ |
344 | */ |
339 | static inline __u64 dtlb_sfsr_read(void) |
345 | static inline __u64 dtlb_sfsr_read(void) |
340 | { |
346 | { |
341 | return asi_u64_read(ASI_DMMU, VA_DMMU_SFSR); |
347 | return asi_u64_read(ASI_DMMU, VA_DMMU_SFSR); |
342 | } |
348 | } |
343 | 349 | ||
344 | /** Write DTLB Synchronous Fault Status Register. |
350 | /** Write DTLB Synchronous Fault Status Register. |
345 | * |
351 | * |
346 | * @param v New value of D-SFSR register. |
352 | * @param v New value of D-SFSR register. |
347 | */ |
353 | */ |
348 | static inline void dtlb_sfsr_write(__u64 v) |
354 | static inline void dtlb_sfsr_write(__u64 v) |
349 | { |
355 | { |
350 | asi_u64_write(ASI_DMMU, VA_DMMU_SFSR, v); |
356 | asi_u64_write(ASI_DMMU, VA_DMMU_SFSR, v); |
351 | flush(); |
357 | flush(); |
352 | } |
358 | } |
353 | 359 | ||
354 | /** Read DTLB Synchronous Fault Address Register. |
360 | /** Read DTLB Synchronous Fault Address Register. |
355 | * |
361 | * |
356 | * @return Current content of D-SFAR register. |
362 | * @return Current content of D-SFAR register. |
357 | */ |
363 | */ |
358 | static inline __u64 dtlb_sfar_read(void) |
364 | static inline __u64 dtlb_sfar_read(void) |
359 | { |
365 | { |
360 | return asi_u64_read(ASI_DMMU, VA_DMMU_SFAR); |
366 | return asi_u64_read(ASI_DMMU, VA_DMMU_SFAR); |
361 | } |
367 | } |
362 | 368 | ||
363 | /** Perform IMMU TLB Demap Operation. |
369 | /** Perform IMMU TLB Demap Operation. |
364 | * |
370 | * |
365 | * @param type Selects between context and page demap. |
371 | * @param type Selects between context and page demap. |
366 | * @param context_encoding Specifies which Context register has Context ID for demap. |
372 | * @param context_encoding Specifies which Context register has Context ID for demap. |
367 | * @param page Address which is on the page to be demapped. |
373 | * @param page Address which is on the page to be demapped. |
368 | */ |
374 | */ |
369 | static inline void itlb_demap(int type, int context_encoding, __address page) |
375 | static inline void itlb_demap(int type, int context_encoding, __address page) |
370 | { |
376 | { |
371 | tlb_demap_addr_t da; |
377 | tlb_demap_addr_t da; |
372 | page_address_t pg; |
378 | page_address_t pg; |
373 | 379 | ||
374 | da.value = 0; |
380 | da.value = 0; |
375 | pg.address = page; |
381 | pg.address = page; |
376 | 382 | ||
377 | da.type = type; |
383 | da.type = type; |
378 | da.context = context_encoding; |
384 | da.context = context_encoding; |
379 | da.vpn = pg.vpn; |
385 | da.vpn = pg.vpn; |
380 | 386 | ||
381 | asi_u64_write(ASI_IMMU_DEMAP, da.value, 0); |
387 | asi_u64_write(ASI_IMMU_DEMAP, da.value, 0); |
382 | flush(); |
388 | flush(); |
383 | } |
389 | } |
384 | 390 | ||
385 | /** Perform DMMU TLB Demap Operation. |
391 | /** Perform DMMU TLB Demap Operation. |
386 | * |
392 | * |
387 | * @param type Selects between context and page demap. |
393 | * @param type Selects between context and page demap. |
388 | * @param context_encoding Specifies which Context register has Context ID for demap. |
394 | * @param context_encoding Specifies which Context register has Context ID for demap. |
389 | * @param page Address which is on the page to be demapped. |
395 | * @param page Address which is on the page to be demapped. |
390 | */ |
396 | */ |
391 | static inline void dtlb_demap(int type, int context_encoding, __address page) |
397 | static inline void dtlb_demap(int type, int context_encoding, __address page) |
392 | { |
398 | { |
393 | tlb_demap_addr_t da; |
399 | tlb_demap_addr_t da; |
394 | page_address_t pg; |
400 | page_address_t pg; |
395 | 401 | ||
396 | da.value = 0; |
402 | da.value = 0; |
397 | pg.address = page; |
403 | pg.address = page; |
398 | 404 | ||
399 | da.type = type; |
405 | da.type = type; |
400 | da.context = context_encoding; |
406 | da.context = context_encoding; |
401 | da.vpn = pg.vpn; |
407 | da.vpn = pg.vpn; |
402 | 408 | ||
403 | asi_u64_write(ASI_DMMU_DEMAP, da.value, 0); |
409 | asi_u64_write(ASI_DMMU_DEMAP, da.value, 0); |
404 | flush(); |
410 | flush(); |
405 | } |
411 | } |
406 | 412 | ||
407 | extern void fast_instruction_access_mmu_miss(void); |
413 | extern void fast_instruction_access_mmu_miss(void); |
408 | extern void fast_data_access_mmu_miss(void); |
414 | extern void fast_data_access_mmu_miss(void); |
409 | extern void fast_data_access_protection(void); |
415 | extern void fast_data_access_protection(void); |
410 | 416 | ||
411 | extern void dtlb_insert_mapping(__address page, __address frame, int pagesize, bool locked, bool cacheable); |
417 | extern void dtlb_insert_mapping(__address page, __address frame, int pagesize, bool locked, bool cacheable); |
412 | 418 | ||
413 | #endif |
419 | #endif |
- | 420 | ||
- | 421 | /** @} |
|
- | 422 | */ |
|
- | 423 | ||
414 | 424 |