source: mainline/kernel/arch/sparc64/src/mm/sun4u/tlb.c@ f238e86

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f238e86 was f238e86, checked in by Pavel Rimsky <pavel@…>, 16 years ago

Both sun4u and sun4v are compilable, sun4u feature-complete, sun4v reaches (at least) version_print.

  • Property mode set to 100644
File size: 15.2 KB
RevLine 
[0d04024]1/*
[df4ed85]2 * Copyright (c) 2005 Jakub Jermar
[0d04024]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 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
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
15 * derived from this software without specific prior written permission.
16 *
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
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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
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
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
[10b890b]29/** @addtogroup sparc64mm
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[0d04024]35#include <arch/mm/tlb.h>
36#include <mm/tlb.h>
[f47fd19]37#include <mm/as.h>
38#include <mm/asid.h>
[0cfc4d38]39#include <arch/mm/frame.h>
40#include <arch/mm/page.h>
41#include <arch/mm/mmu.h>
[f47fd19]42#include <arch/interrupt.h>
[e2bf639]43#include <interrupt.h>
[f47fd19]44#include <arch.h>
[0d04024]45#include <print.h>
[dbb6886]46#include <arch/types.h>
[0cfc4d38]47#include <config.h>
[49b6d32]48#include <arch/trap/trap.h>
[7bb6b06]49#include <arch/trap/exception.h>
[008029d]50#include <panic.h>
[b6fba84]51#include <arch/asm.h>
[02f441c0]52
[29b2bbf]53#ifdef CONFIG_TSB
54#include <arch/mm/tsb.h>
55#endif
56
[98000fb]57static void dtlb_pte_copy(pte_t *, size_t, bool);
58static void itlb_pte_copy(pte_t *, size_t);
[965dc18]59static void do_fast_instruction_access_mmu_miss_fault(istate_t *, const char *);
60static void do_fast_data_access_mmu_miss_fault(istate_t *, tlb_tag_access_reg_t,
61 const char *);
62static void do_fast_data_access_protection_fault(istate_t *,
63 tlb_tag_access_reg_t, const char *);
[f47fd19]64
[b6fba84]65char *context_encoding[] = {
66 "Primary",
67 "Secondary",
68 "Nucleus",
69 "Reserved"
70};
[0d04024]71
72void tlb_arch_init(void)
73{
[c6e314a]74 /*
[c23baab]75 * Invalidate all non-locked DTLB and ITLB entries.
[c6e314a]76 */
[c23baab]77 tlb_invalidate_all();
[8cee705]78
79 /*
80 * Clear both SFSRs.
81 */
82 dtlb_sfsr_write(0);
83 itlb_sfsr_write(0);
[97f1691]84}
[b6fba84]85
[97f1691]86/** Insert privileged mapping into DMMU TLB.
87 *
[965dc18]88 * @param page Virtual page address.
89 * @param frame Physical frame address.
90 * @param pagesize Page size.
91 * @param locked True for permanent mappings, false otherwise.
92 * @param cacheable True if the mapping is cacheable, false otherwise.
[97f1691]93 */
[2057572]94void dtlb_insert_mapping(uintptr_t page, uintptr_t frame, int pagesize,
95 bool locked, bool cacheable)
[97f1691]96{
97 tlb_tag_access_reg_t tag;
98 tlb_data_t data;
99 page_address_t pg;
100 frame_address_t fr;
[b6fba84]101
[97f1691]102 pg.address = page;
103 fr.address = frame;
[02f441c0]104
[965dc18]105 tag.context = ASID_KERNEL;
[02f441c0]106 tag.vpn = pg.vpn;
107
108 dtlb_tag_access_write(tag.value);
109
110 data.value = 0;
111 data.v = true;
[97f1691]112 data.size = pagesize;
[02f441c0]113 data.pfn = fr.pfn;
[97f1691]114 data.l = locked;
115 data.cp = cacheable;
[92778f2]116#ifdef CONFIG_VIRT_IDX_DCACHE
[97f1691]117 data.cv = cacheable;
[92778f2]118#endif /* CONFIG_VIRT_IDX_DCACHE */
[02f441c0]119 data.p = true;
120 data.w = true;
[d681c17]121 data.g = false;
[02f441c0]122
123 dtlb_data_in_write(data.value);
[0d04024]124}
125
[a7961271]126/** Copy PTE to TLB.
127 *
[965dc18]128 * @param t Page Table Entry to be copied.
129 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage.
130 * @param ro If true, the entry will be created read-only, regardless
131 * of its w field.
[a7961271]132 */
[98000fb]133void dtlb_pte_copy(pte_t *t, size_t index, bool ro)
[a7961271]134{
135 tlb_tag_access_reg_t tag;
136 tlb_data_t data;
137 page_address_t pg;
138 frame_address_t fr;
139
[2057572]140 pg.address = t->page + (index << MMU_PAGE_WIDTH);
141 fr.address = t->frame + (index << MMU_PAGE_WIDTH);
[a7961271]142
143 tag.value = 0;
144 tag.context = t->as->asid;
145 tag.vpn = pg.vpn;
[2057572]146
[a7961271]147 dtlb_tag_access_write(tag.value);
[2057572]148
[a7961271]149 data.value = 0;
150 data.v = true;
151 data.size = PAGESIZE_8K;
152 data.pfn = fr.pfn;
153 data.l = false;
154 data.cp = t->c;
[92778f2]155#ifdef CONFIG_VIRT_IDX_DCACHE
[a7961271]156 data.cv = t->c;
[92778f2]157#endif /* CONFIG_VIRT_IDX_DCACHE */
[cfa70add]158 data.p = t->k; /* p like privileged */
[a7961271]159 data.w = ro ? false : t->w;
160 data.g = t->g;
[2057572]161
[a7961271]162 dtlb_data_in_write(data.value);
163}
164
[29b2bbf]165/** Copy PTE to ITLB.
166 *
[965dc18]167 * @param t Page Table Entry to be copied.
168 * @param index Zero if lower 8K-subpage, one if higher 8K-subpage.
[29b2bbf]169 */
[98000fb]170void itlb_pte_copy(pte_t *t, size_t index)
[f47fd19]171{
[a7961271]172 tlb_tag_access_reg_t tag;
173 tlb_data_t data;
174 page_address_t pg;
175 frame_address_t fr;
176
[2057572]177 pg.address = t->page + (index << MMU_PAGE_WIDTH);
178 fr.address = t->frame + (index << MMU_PAGE_WIDTH);
[a7961271]179
180 tag.value = 0;
181 tag.context = t->as->asid;
182 tag.vpn = pg.vpn;
183
184 itlb_tag_access_write(tag.value);
185
186 data.value = 0;
187 data.v = true;
188 data.size = PAGESIZE_8K;
189 data.pfn = fr.pfn;
190 data.l = false;
191 data.cp = t->c;
[cfa70add]192 data.p = t->k; /* p like privileged */
[a7961271]193 data.w = false;
194 data.g = t->g;
195
196 itlb_data_in_write(data.value);
[f47fd19]197}
198
[008029d]199/** ITLB miss handler. */
[36f19c0]200void fast_instruction_access_mmu_miss(unative_t unused, istate_t *istate)
[008029d]201{
[2bf4936]202 uintptr_t page_16k = ALIGN_DOWN(istate->tpc, PAGE_SIZE);
[98000fb]203 size_t index = (istate->tpc >> MMU_PAGE_WIDTH) % MMU_PAGES_PER_PAGE;
[a7961271]204 pte_t *t;
205
206 page_table_lock(AS, true);
[2bf4936]207 t = page_mapping_find(AS, page_16k);
[a7961271]208 if (t && PTE_EXECUTABLE(t)) {
209 /*
210 * The mapping was found in the software page hash table.
211 * Insert it into ITLB.
212 */
213 t->a = true;
[2057572]214 itlb_pte_copy(t, index);
[29b2bbf]215#ifdef CONFIG_TSB
[2057572]216 itsb_pte_copy(t, index);
[29b2bbf]217#endif
[a7961271]218 page_table_unlock(AS, true);
219 } else {
220 /*
[771cd22]221 * Forward the page fault to the address space page fault
222 * handler.
[a7961271]223 */
224 page_table_unlock(AS, true);
[2bf4936]225 if (as_page_fault(page_16k, PF_ACCESS_EXEC, istate) ==
226 AS_PF_FAULT) {
[771cd22]227 do_fast_instruction_access_mmu_miss_fault(istate,
[3ee8a075]228 __func__);
[a7961271]229 }
230 }
[008029d]231}
232
[f47fd19]233/** DTLB miss handler.
234 *
[771cd22]235 * Note that some faults (e.g. kernel faults) were already resolved by the
236 * low-level, assembly language part of the fast_data_access_mmu_miss handler.
[36f19c0]237 *
[965dc18]238 * @param tag Content of the TLB Tag Access register as it existed
239 * when the trap happened. This is to prevent confusion
240 * created by clobbered Tag Access register during a nested
241 * DTLB miss.
242 * @param istate Interrupted state saved on the stack.
[f47fd19]243 */
[36f19c0]244void fast_data_access_mmu_miss(tlb_tag_access_reg_t tag, istate_t *istate)
[008029d]245{
[2bf4936]246 uintptr_t page_8k;
247 uintptr_t page_16k;
[98000fb]248 size_t index;
[f47fd19]249 pte_t *t;
[7cb53f62]250
[2bf4936]251 page_8k = (uint64_t) tag.vpn << MMU_PAGE_WIDTH;
252 page_16k = ALIGN_DOWN(page_8k, PAGE_SIZE);
[2057572]253 index = tag.vpn % MMU_PAGES_PER_PAGE;
[fd85ae5]254
[f47fd19]255 if (tag.context == ASID_KERNEL) {
256 if (!tag.vpn) {
257 /* NULL access in kernel */
[771cd22]258 do_fast_data_access_mmu_miss_fault(istate, tag,
[3ee8a075]259 __func__);
[2bf4936]260 } else if (page_8k >= end_of_identity) {
261 /*
262 * The kernel is accessing the I/O space.
263 * We still do identity mapping for I/O,
264 * but without caching.
265 */
266 dtlb_insert_mapping(page_8k, KA2PA(page_8k),
267 PAGESIZE_8K, false, false);
268 return;
[f47fd19]269 }
[771cd22]270 do_fast_data_access_mmu_miss_fault(istate, tag, "Unexpected "
[2057572]271 "kernel page fault.");
[68656282]272 }
273
[f47fd19]274 page_table_lock(AS, true);
[2bf4936]275 t = page_mapping_find(AS, page_16k);
[f47fd19]276 if (t) {
277 /*
278 * The mapping was found in the software page hash table.
279 * Insert it into DTLB.
280 */
[a7961271]281 t->a = true;
[2057572]282 dtlb_pte_copy(t, index, true);
[29b2bbf]283#ifdef CONFIG_TSB
[2057572]284 dtsb_pte_copy(t, index, true);
[29b2bbf]285#endif
[f47fd19]286 page_table_unlock(AS, true);
287 } else {
288 /*
[2057572]289 * Forward the page fault to the address space page fault
290 * handler.
[f47fd19]291 */
292 page_table_unlock(AS, true);
[2bf4936]293 if (as_page_fault(page_16k, PF_ACCESS_READ, istate) ==
294 AS_PF_FAULT) {
[771cd22]295 do_fast_data_access_mmu_miss_fault(istate, tag,
[3ee8a075]296 __func__);
[f47fd19]297 }
298 }
[008029d]299}
300
[36f19c0]301/** DTLB protection fault handler.
302 *
[965dc18]303 * @param tag Content of the TLB Tag Access register as it existed
304 * when the trap happened. This is to prevent confusion
305 * created by clobbered Tag Access register during a nested
306 * DTLB miss.
307 * @param istate Interrupted state saved on the stack.
[36f19c0]308 */
309void fast_data_access_protection(tlb_tag_access_reg_t tag, istate_t *istate)
[008029d]310{
[2bf4936]311 uintptr_t page_16k;
[98000fb]312 size_t index;
[e0b241f]313 pte_t *t;
314
[2bf4936]315 page_16k = ALIGN_DOWN((uint64_t) tag.vpn << MMU_PAGE_WIDTH, PAGE_SIZE);
[2057572]316 index = tag.vpn % MMU_PAGES_PER_PAGE; /* 16K-page emulation */
[e0b241f]317
318 page_table_lock(AS, true);
[2bf4936]319 t = page_mapping_find(AS, page_16k);
[e0b241f]320 if (t && PTE_WRITABLE(t)) {
321 /*
[771cd22]322 * The mapping was found in the software page hash table and is
323 * writable. Demap the old mapping and insert an updated mapping
324 * into DTLB.
[e0b241f]325 */
326 t->a = true;
327 t->d = true;
[2057572]328 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY,
[2bf4936]329 page_16k + index * MMU_PAGE_SIZE);
[2057572]330 dtlb_pte_copy(t, index, false);
[29b2bbf]331#ifdef CONFIG_TSB
[2057572]332 dtsb_pte_copy(t, index, false);
[29b2bbf]333#endif
[e0b241f]334 page_table_unlock(AS, true);
335 } else {
336 /*
[771cd22]337 * Forward the page fault to the address space page fault
338 * handler.
[e0b241f]339 */
340 page_table_unlock(AS, true);
[2bf4936]341 if (as_page_fault(page_16k, PF_ACCESS_WRITE, istate) ==
342 AS_PF_FAULT) {
[771cd22]343 do_fast_data_access_protection_fault(istate, tag,
[3ee8a075]344 __func__);
[e0b241f]345 }
346 }
[008029d]347}
348
[965dc18]349/** Print TLB entry (for debugging purposes).
350 *
351 * The diag field has been left out in order to make this function more generic
352 * (there is no diag field in US3 architeture).
353 *
354 * @param i TLB entry number
355 * @param t TLB entry tag
356 * @param d TLB entry data
357 */
358static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
359{
360 printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
361 "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
362 "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn,
363 t.context, d.v, d.size, d.nfo, d.ie, d.soft2,
364 d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
365}
366
367#if defined (US)
368
[0d04024]369/** Print contents of both TLBs. */
370void tlb_print(void)
371{
372 int i;
373 tlb_data_t d;
374 tlb_tag_read_reg_t t;
375
376 printf("I-TLB contents:\n");
377 for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
378 d.value = itlb_data_access_read(i);
[c52ed6b]379 t.value = itlb_tag_read_read(i);
[965dc18]380 print_tlb_entry(i, t, d);
[0d04024]381 }
382
383 printf("D-TLB contents:\n");
384 for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
385 d.value = dtlb_data_access_read(i);
[c52ed6b]386 t.value = dtlb_tag_read_read(i);
[965dc18]387 print_tlb_entry(i, t, d);
[0d04024]388 }
[965dc18]389}
390
391#elif defined (US3)
[0d04024]392
[965dc18]393/** Print contents of all TLBs. */
394void tlb_print(void)
395{
396 int i;
397 tlb_data_t d;
398 tlb_tag_read_reg_t t;
399
400 printf("TLB_ISMALL contents:\n");
401 for (i = 0; i < tlb_ismall_size(); i++) {
402 d.value = dtlb_data_access_read(TLB_ISMALL, i);
403 t.value = dtlb_tag_read_read(TLB_ISMALL, i);
404 print_tlb_entry(i, t, d);
405 }
406
407 printf("TLB_IBIG contents:\n");
408 for (i = 0; i < tlb_ibig_size(); i++) {
409 d.value = dtlb_data_access_read(TLB_IBIG, i);
410 t.value = dtlb_tag_read_read(TLB_IBIG, i);
411 print_tlb_entry(i, t, d);
412 }
413
414 printf("TLB_DSMALL contents:\n");
415 for (i = 0; i < tlb_dsmall_size(); i++) {
416 d.value = dtlb_data_access_read(TLB_DSMALL, i);
417 t.value = dtlb_tag_read_read(TLB_DSMALL, i);
418 print_tlb_entry(i, t, d);
419 }
420
421 printf("TLB_DBIG_1 contents:\n");
422 for (i = 0; i < tlb_dbig_size(); i++) {
423 d.value = dtlb_data_access_read(TLB_DBIG_0, i);
424 t.value = dtlb_tag_read_read(TLB_DBIG_0, i);
425 print_tlb_entry(i, t, d);
426 }
427
428 printf("TLB_DBIG_2 contents:\n");
429 for (i = 0; i < tlb_dbig_size(); i++) {
430 d.value = dtlb_data_access_read(TLB_DBIG_1, i);
431 t.value = dtlb_tag_read_read(TLB_DBIG_1, i);
432 print_tlb_entry(i, t, d);
433 }
[0d04024]434}
[dbb6886]435
[965dc18]436#endif
437
[2057572]438void do_fast_instruction_access_mmu_miss_fault(istate_t *istate,
439 const char *str)
[a7961271]440{
[f651e80]441 fault_if_from_uspace(istate, "%s.", str);
[7bb6b06]442 dump_istate(istate);
[f651e80]443 panic("%s.", str);
[a7961271]444}
445
[2057572]446void do_fast_data_access_mmu_miss_fault(istate_t *istate,
447 tlb_tag_access_reg_t tag, const char *str)
[f47fd19]448{
449 uintptr_t va;
450
[2057572]451 va = tag.vpn << MMU_PAGE_WIDTH;
[36f19c0]452 if (tag.context) {
[f651e80]453 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va,
[36f19c0]454 tag.context);
455 }
[7bb6b06]456 dump_istate(istate);
[f651e80]457 printf("Faulting page: %p, ASID=%d.\n", va, tag.context);
458 panic("%s.", str);
[f47fd19]459}
460
[2057572]461void do_fast_data_access_protection_fault(istate_t *istate,
462 tlb_tag_access_reg_t tag, const char *str)
[e0b241f]463{
464 uintptr_t va;
465
[2057572]466 va = tag.vpn << MMU_PAGE_WIDTH;
[e0b241f]467
[36f19c0]468 if (tag.context) {
[f651e80]469 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va,
[36f19c0]470 tag.context);
471 }
[e0b241f]472 printf("Faulting page: %p, ASID=%d\n", va, tag.context);
[7bb6b06]473 dump_istate(istate);
[f651e80]474 panic("%s.", str);
[e0b241f]475}
476
[8cee705]477void dump_sfsr_and_sfar(void)
478{
479 tlb_sfsr_reg_t sfsr;
480 uintptr_t sfar;
481
482 sfsr.value = dtlb_sfsr_read();
483 sfar = dtlb_sfar_read();
484
[965dc18]485#if defined (US)
[771cd22]486 printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, "
[2057572]487 "fv=%d\n", sfsr.asi, sfsr.ft, sfsr.e, sfsr.ct, sfsr.pr, sfsr.w,
488 sfsr.ow, sfsr.fv);
[965dc18]489#elif defined (US3)
490 printf("DTLB SFSR: nf=%d, asi=%#x, tm=%d, ft=%#x, e=%d, ct=%d, pr=%d, "
491 "w=%d, ow=%d, fv=%d\n", sfsr.nf, sfsr.asi, sfsr.tm, sfsr.ft,
492 sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv);
493#endif
494
[8cee705]495 printf("DTLB SFAR: address=%p\n", sfar);
496
497 dtlb_sfsr_write(0);
498}
499
[687246b]500#if defined (US)
[965dc18]501/** Invalidate all unlocked ITLB and DTLB entries. */
502void tlb_invalidate_all(void)
503{
504 int i;
505
[8dbc18c]506 /*
507 * Walk all ITLB and DTLB entries and remove all unlocked mappings.
508 *
509 * The kernel doesn't use global mappings so any locked global mappings
[965dc18]510 * found must have been created by someone else. Their only purpose now
[8dbc18c]511 * is to collide with proper mappings. Invalidate immediately. It should
512 * be safe to invalidate them as late as now.
513 */
514
[965dc18]515 tlb_data_t d;
516 tlb_tag_read_reg_t t;
517
[dbb6886]518 for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
519 d.value = itlb_data_access_read(i);
[8dbc18c]520 if (!d.l || d.g) {
[dbb6886]521 t.value = itlb_tag_read_read(i);
522 d.v = false;
523 itlb_tag_access_write(t.value);
524 itlb_data_access_write(i, d.value);
525 }
526 }
[965dc18]527
[dbb6886]528 for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
529 d.value = dtlb_data_access_read(i);
[8dbc18c]530 if (!d.l || d.g) {
[dbb6886]531 t.value = dtlb_tag_read_read(i);
532 d.v = false;
533 dtlb_tag_access_write(t.value);
534 dtlb_data_access_write(i, d.value);
535 }
536 }
[965dc18]537
[687246b]538}
[965dc18]539
[687246b]540#elif defined (US3)
[965dc18]541
[687246b]542/** Invalidate all unlocked ITLB and DTLB entries. */
543void tlb_invalidate_all(void)
544{
545 itlb_demap(TLB_DEMAP_ALL, 0, 0);
546 dtlb_demap(TLB_DEMAP_ALL, 0, 0);
[dbb6886]547}
548
[687246b]549#endif
550
[771cd22]551/** Invalidate all ITLB and DTLB entries that belong to specified ASID
552 * (Context).
[dbb6886]553 *
554 * @param asid Address Space ID.
555 */
556void tlb_invalidate_asid(asid_t asid)
557{
[fd85ae5]558 tlb_context_reg_t pc_save, ctx;
[ed166f7]559
[fd85ae5]560 /* switch to nucleus because we are mapped by the primary context */
561 nucleus_enter();
562
563 ctx.v = pc_save.v = mmu_primary_context_read();
[ed166f7]564 ctx.context = asid;
[fd85ae5]565 mmu_primary_context_write(ctx.v);
566
567 itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0);
568 dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0);
[ed166f7]569
[fd85ae5]570 mmu_primary_context_write(pc_save.v);
[ed166f7]571
[fd85ae5]572 nucleus_leave();
[dbb6886]573}
574
[771cd22]575/** Invalidate all ITLB and DTLB entries for specified page range in specified
576 * address space.
[dbb6886]577 *
[965dc18]578 * @param asid Address Space ID.
579 * @param page First page which to sweep out from ITLB and DTLB.
580 * @param cnt Number of ITLB and DTLB entries to invalidate.
[dbb6886]581 */
[98000fb]582void tlb_invalidate_pages(asid_t asid, uintptr_t page, size_t cnt)
[dbb6886]583{
[6c441cf8]584 unsigned int i;
[fd85ae5]585 tlb_context_reg_t pc_save, ctx;
[ed166f7]586
[fd85ae5]587 /* switch to nucleus because we are mapped by the primary context */
588 nucleus_enter();
589
590 ctx.v = pc_save.v = mmu_primary_context_read();
[ed166f7]591 ctx.context = asid;
[fd85ae5]592 mmu_primary_context_write(ctx.v);
[4512d7e]593
[2057572]594 for (i = 0; i < cnt * MMU_PAGES_PER_PAGE; i++) {
[454f1da]595 itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY,
[2057572]596 page + i * MMU_PAGE_SIZE);
[454f1da]597 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY,
[2057572]598 page + i * MMU_PAGE_SIZE);
[4512d7e]599 }
[ed166f7]600
[fd85ae5]601 mmu_primary_context_write(pc_save.v);
602
603 nucleus_leave();
[dbb6886]604}
[b45c443]605
[10b890b]606/** @}
[b45c443]607 */
Note: See TracBrowser for help on using the repository browser.