1/*-
2 * Copyright (c) 2001 Jake Burkholder.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/sparc64/include/tlb.h 91616 2002-03-04 07:07:10Z jake $
27 */
28
29#ifndef _MACHINE_TLB_H_
30#define _MACHINE_TLB_H_
31
32#define TLB_SLOT_COUNT 64
33
34#define TLB_SLOT_TSB_KERNEL_MIN 62 /* XXX */
--- 64 unchanged lines hidden (view full) ---
99static __inline void
100tlb_dtlb_context_primary_demap(void)
101{
102 stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_DMMU_DEMAP, 0);
103 membar(Sync);
104}
105
106static __inline void
107tlb_dtlb_page_demap(u_long ctx, vm_offset_t va)
108{
109 if (ctx == TLB_CTX_KERNEL) {
110 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE,
111 ASI_DMMU_DEMAP, 0);
112 membar(Sync);
113 } else if (ctx != -1) {
114 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
115 ASI_DMMU_DEMAP, 0);
116 membar(Sync);
--- 28 unchanged lines hidden (view full) ---
145static __inline void
146tlb_itlb_context_primary_demap(void)
147{
148 stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_IMMU_DEMAP, 0);
149 membar(Sync);
150}
151
152static __inline void
153tlb_itlb_page_demap(u_long ctx, vm_offset_t va)
154{
155 if (ctx == TLB_CTX_KERNEL) {
156 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE,
157 ASI_IMMU_DEMAP, 0);
158 flush(KERNBASE);
159 } else if (ctx != -1) {
160 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
161 ASI_IMMU_DEMAP, 0);
162 membar(Sync);
--- 16 unchanged lines hidden (view full) ---
179 * user page.
180 */
181 membar(Sync);
182 }
183 intr_restore(pst);
184}
185
186static __inline void
187tlb_context_demap(u_int ctx)
188{
189 if (ctx != -1) {
190 tlb_dtlb_context_primary_demap();
191 tlb_itlb_context_primary_demap();
192 }
193}
194
195static __inline void
196tlb_itlb_store_slot(vm_offset_t va, u_long ctx, struct tte tte, int slot)
197{
198 u_long pst;
199
200 pst = intr_disable();
201 stxa(AA_IMMU_TAR, ASI_IMMU, TLB_TAR_VA(va) | TLB_TAR_CTX(ctx));
202 stxa(TLB_DAR_SLOT(slot), ASI_ITLB_DATA_ACCESS_REG, tte.tte_data);
203 flush(va);
204 intr_restore(pst);
205}
206
207static __inline void
208tlb_page_demap(u_int tlb, u_int ctx, vm_offset_t va)
209{
210 if (tlb & TLB_DTLB)
211 tlb_dtlb_page_demap(ctx, va);
212 if (tlb & TLB_ITLB)
213 tlb_itlb_page_demap(ctx, va);
214}
215
216static __inline void
217tlb_range_demap(u_int ctx, vm_offset_t start, vm_offset_t end)
218{
219 for (; start < end; start += PAGE_SIZE)
220 tlb_page_demap(TLB_DTLB | TLB_ITLB, ctx, start);
221}
222
223static __inline void
224tlb_tte_demap(struct tte tte, u_int ctx)
225{
226 tlb_page_demap(TD_GET_TLB(tte.tte_data), ctx, TV_GET_VA(tte.tte_vpn));
227}
228
229static __inline void
230tlb_store(u_int tlb, vm_offset_t va, u_long ctx, struct tte tte)
231{
232 KASSERT(ctx != -1, ("tlb_store: invalid context"));
233 if (tlb & TLB_DTLB)
234 tlb_dtlb_store(va, ctx, tte);
--- 15 unchanged lines hidden ---
2 * Copyright (c) 2001 Jake Burkholder.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/sparc64/include/tlb.h 91616 2002-03-04 07:07:10Z jake $
27 */
28
29#ifndef _MACHINE_TLB_H_
30#define _MACHINE_TLB_H_
31
32#define TLB_SLOT_COUNT 64
33
34#define TLB_SLOT_TSB_KERNEL_MIN 62 /* XXX */
--- 64 unchanged lines hidden (view full) ---
99static __inline void
100tlb_dtlb_context_primary_demap(void)
101{
102 stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_DMMU_DEMAP, 0);
103 membar(Sync);
104}
105
106static __inline void
107tlb_dtlb_page_demap(u_long ctx, vm_offset_t va)
108{
109 if (ctx == TLB_CTX_KERNEL) {
110 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE,
111 ASI_DMMU_DEMAP, 0);
112 membar(Sync);
113 } else if (ctx != -1) {
114 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
115 ASI_DMMU_DEMAP, 0);
116 membar(Sync);
--- 28 unchanged lines hidden (view full) ---
145static __inline void
146tlb_itlb_context_primary_demap(void)
147{
148 stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_IMMU_DEMAP, 0);
149 membar(Sync);
150}
151
152static __inline void
153tlb_itlb_page_demap(u_long ctx, vm_offset_t va)
154{
155 if (ctx == TLB_CTX_KERNEL) {
156 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE,
157 ASI_IMMU_DEMAP, 0);
158 flush(KERNBASE);
159 } else if (ctx != -1) {
160 stxa(TLB_DEMAP_VA(va) | TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE,
161 ASI_IMMU_DEMAP, 0);
162 membar(Sync);
--- 16 unchanged lines hidden (view full) ---
179 * user page.
180 */
181 membar(Sync);
182 }
183 intr_restore(pst);
184}
185
186static __inline void
187tlb_context_demap(u_int ctx)
188{
189 if (ctx != -1) {
190 tlb_dtlb_context_primary_demap();
191 tlb_itlb_context_primary_demap();
192 }
193}
194
195static __inline void
196tlb_itlb_store_slot(vm_offset_t va, u_long ctx, struct tte tte, int slot)
197{
198 u_long pst;
199
200 pst = intr_disable();
201 stxa(AA_IMMU_TAR, ASI_IMMU, TLB_TAR_VA(va) | TLB_TAR_CTX(ctx));
202 stxa(TLB_DAR_SLOT(slot), ASI_ITLB_DATA_ACCESS_REG, tte.tte_data);
203 flush(va);
204 intr_restore(pst);
205}
206
207static __inline void
208tlb_page_demap(u_int tlb, u_int ctx, vm_offset_t va)
209{
210 if (tlb & TLB_DTLB)
211 tlb_dtlb_page_demap(ctx, va);
212 if (tlb & TLB_ITLB)
213 tlb_itlb_page_demap(ctx, va);
214}
215
216static __inline void
217tlb_range_demap(u_int ctx, vm_offset_t start, vm_offset_t end)
218{
219 for (; start < end; start += PAGE_SIZE)
220 tlb_page_demap(TLB_DTLB | TLB_ITLB, ctx, start);
221}
222
223static __inline void
224tlb_tte_demap(struct tte tte, u_int ctx)
225{
226 tlb_page_demap(TD_GET_TLB(tte.tte_data), ctx, TV_GET_VA(tte.tte_vpn));
227}
228
229static __inline void
230tlb_store(u_int tlb, vm_offset_t va, u_long ctx, struct tte tte)
231{
232 KASSERT(ctx != -1, ("tlb_store: invalid context"));
233 if (tlb & TLB_DTLB)
234 tlb_dtlb_store(va, ctx, tte);
--- 15 unchanged lines hidden ---