[0d04024] | 1 | /*
|
---|
| 2 | * Copyright (C) 2005 Jakub Jermar
|
---|
| 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>
|
---|
| 47 | #include <typedefs.h>
|
---|
[0cfc4d38] | 48 | #include <config.h>
|
---|
[49b6d32] | 49 | #include <arch/trap/trap.h>
|
---|
[7bb6b06] | 50 | #include <arch/trap/exception.h>
|
---|
[008029d] | 51 | #include <panic.h>
|
---|
[b6fba84] | 52 | #include <arch/asm.h>
|
---|
[02f441c0] | 53 |
|
---|
[a7961271] | 54 | static void dtlb_pte_copy(pte_t *t, bool ro);
|
---|
| 55 | static void itlb_pte_copy(pte_t *t);
|
---|
| 56 | static void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, const char *str);
|
---|
[fd85ae5] | 57 | static void do_fast_data_access_mmu_miss_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str);
|
---|
| 58 | static void do_fast_data_access_protection_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str);
|
---|
[f47fd19] | 59 |
|
---|
[b6fba84] | 60 | char *context_encoding[] = {
|
---|
| 61 | "Primary",
|
---|
| 62 | "Secondary",
|
---|
| 63 | "Nucleus",
|
---|
| 64 | "Reserved"
|
---|
| 65 | };
|
---|
[0d04024] | 66 |
|
---|
| 67 | void tlb_arch_init(void)
|
---|
| 68 | {
|
---|
[c6e314a] | 69 | /*
|
---|
[287920f] | 70 | * TLBs are actually initialized early
|
---|
[c6e314a] | 71 | * in start.S.
|
---|
| 72 | */
|
---|
[97f1691] | 73 | }
|
---|
[b6fba84] | 74 |
|
---|
[97f1691] | 75 | /** Insert privileged mapping into DMMU TLB.
|
---|
| 76 | *
|
---|
| 77 | * @param page Virtual page address.
|
---|
| 78 | * @param frame Physical frame address.
|
---|
| 79 | * @param pagesize Page size.
|
---|
| 80 | * @param locked True for permanent mappings, false otherwise.
|
---|
| 81 | * @param cacheable True if the mapping is cacheable, false otherwise.
|
---|
| 82 | */
|
---|
[7f1c620] | 83 | void dtlb_insert_mapping(uintptr_t page, uintptr_t frame, int pagesize, bool locked, bool cacheable)
|
---|
[97f1691] | 84 | {
|
---|
| 85 | tlb_tag_access_reg_t tag;
|
---|
| 86 | tlb_data_t data;
|
---|
| 87 | page_address_t pg;
|
---|
| 88 | frame_address_t fr;
|
---|
[b6fba84] | 89 |
|
---|
[97f1691] | 90 | pg.address = page;
|
---|
| 91 | fr.address = frame;
|
---|
[02f441c0] | 92 |
|
---|
| 93 | tag.value = ASID_KERNEL;
|
---|
| 94 | tag.vpn = pg.vpn;
|
---|
| 95 |
|
---|
| 96 | dtlb_tag_access_write(tag.value);
|
---|
| 97 |
|
---|
| 98 | data.value = 0;
|
---|
| 99 | data.v = true;
|
---|
[97f1691] | 100 | data.size = pagesize;
|
---|
[02f441c0] | 101 | data.pfn = fr.pfn;
|
---|
[97f1691] | 102 | data.l = locked;
|
---|
| 103 | data.cp = cacheable;
|
---|
| 104 | data.cv = cacheable;
|
---|
[02f441c0] | 105 | data.p = true;
|
---|
| 106 | data.w = true;
|
---|
[d681c17] | 107 | data.g = false;
|
---|
[02f441c0] | 108 |
|
---|
| 109 | dtlb_data_in_write(data.value);
|
---|
[0d04024] | 110 | }
|
---|
| 111 |
|
---|
[a7961271] | 112 | /** Copy PTE to TLB.
|
---|
| 113 | *
|
---|
| 114 | * @param t Page Table Entry to be copied.
|
---|
| 115 | * @param ro If true, the entry will be created read-only, regardless of its w field.
|
---|
| 116 | */
|
---|
| 117 | void dtlb_pte_copy(pte_t *t, bool ro)
|
---|
| 118 | {
|
---|
| 119 | tlb_tag_access_reg_t tag;
|
---|
| 120 | tlb_data_t data;
|
---|
| 121 | page_address_t pg;
|
---|
| 122 | frame_address_t fr;
|
---|
| 123 |
|
---|
| 124 | pg.address = t->page;
|
---|
| 125 | fr.address = t->frame;
|
---|
| 126 |
|
---|
| 127 | tag.value = 0;
|
---|
| 128 | tag.context = t->as->asid;
|
---|
| 129 | tag.vpn = pg.vpn;
|
---|
| 130 |
|
---|
| 131 | dtlb_tag_access_write(tag.value);
|
---|
| 132 |
|
---|
| 133 | data.value = 0;
|
---|
| 134 | data.v = true;
|
---|
| 135 | data.size = PAGESIZE_8K;
|
---|
| 136 | data.pfn = fr.pfn;
|
---|
| 137 | data.l = false;
|
---|
| 138 | data.cp = t->c;
|
---|
| 139 | data.cv = t->c;
|
---|
[cfa70add] | 140 | data.p = t->k; /* p like privileged */
|
---|
[a7961271] | 141 | data.w = ro ? false : t->w;
|
---|
| 142 | data.g = t->g;
|
---|
| 143 |
|
---|
| 144 | dtlb_data_in_write(data.value);
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | void itlb_pte_copy(pte_t *t)
|
---|
[f47fd19] | 148 | {
|
---|
[a7961271] | 149 | tlb_tag_access_reg_t tag;
|
---|
| 150 | tlb_data_t data;
|
---|
| 151 | page_address_t pg;
|
---|
| 152 | frame_address_t fr;
|
---|
| 153 |
|
---|
| 154 | pg.address = t->page;
|
---|
| 155 | fr.address = t->frame;
|
---|
| 156 |
|
---|
| 157 | tag.value = 0;
|
---|
| 158 | tag.context = t->as->asid;
|
---|
| 159 | tag.vpn = pg.vpn;
|
---|
| 160 |
|
---|
| 161 | itlb_tag_access_write(tag.value);
|
---|
| 162 |
|
---|
| 163 | data.value = 0;
|
---|
| 164 | data.v = true;
|
---|
| 165 | data.size = PAGESIZE_8K;
|
---|
| 166 | data.pfn = fr.pfn;
|
---|
| 167 | data.l = false;
|
---|
| 168 | data.cp = t->c;
|
---|
| 169 | data.cv = t->c;
|
---|
[cfa70add] | 170 | data.p = t->k; /* p like privileged */
|
---|
[a7961271] | 171 | data.w = false;
|
---|
| 172 | data.g = t->g;
|
---|
| 173 |
|
---|
| 174 | itlb_data_in_write(data.value);
|
---|
[f47fd19] | 175 | }
|
---|
| 176 |
|
---|
[008029d] | 177 | /** ITLB miss handler. */
|
---|
[f47fd19] | 178 | void fast_instruction_access_mmu_miss(int n, istate_t *istate)
|
---|
[008029d] | 179 | {
|
---|
[a7961271] | 180 | uintptr_t va = ALIGN_DOWN(istate->tpc, PAGE_SIZE);
|
---|
| 181 | pte_t *t;
|
---|
| 182 |
|
---|
| 183 | page_table_lock(AS, true);
|
---|
| 184 | t = page_mapping_find(AS, va);
|
---|
| 185 | if (t && PTE_EXECUTABLE(t)) {
|
---|
| 186 | /*
|
---|
| 187 | * The mapping was found in the software page hash table.
|
---|
| 188 | * Insert it into ITLB.
|
---|
| 189 | */
|
---|
| 190 | t->a = true;
|
---|
| 191 | itlb_pte_copy(t);
|
---|
| 192 | page_table_unlock(AS, true);
|
---|
| 193 | } else {
|
---|
| 194 | /*
|
---|
| 195 | * Forward the page fault to the address space page fault handler.
|
---|
| 196 | */
|
---|
| 197 | page_table_unlock(AS, true);
|
---|
| 198 | if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) {
|
---|
| 199 | do_fast_instruction_access_mmu_miss_fault(istate, __FUNCTION__);
|
---|
| 200 | }
|
---|
| 201 | }
|
---|
[008029d] | 202 | }
|
---|
| 203 |
|
---|
[f47fd19] | 204 | /** DTLB miss handler.
|
---|
| 205 | *
|
---|
| 206 | * Note that some faults (e.g. kernel faults) were already resolved
|
---|
| 207 | * by the low-level, assembly language part of the fast_data_access_mmu_miss
|
---|
| 208 | * handler.
|
---|
| 209 | */
|
---|
| 210 | void fast_data_access_mmu_miss(int n, istate_t *istate)
|
---|
[008029d] | 211 | {
|
---|
[68656282] | 212 | tlb_tag_access_reg_t tag;
|
---|
[f47fd19] | 213 | uintptr_t va;
|
---|
| 214 | pte_t *t;
|
---|
[7cb53f62] | 215 |
|
---|
[68656282] | 216 | tag.value = dtlb_tag_access_read();
|
---|
[fd85ae5] | 217 | va = tag.vpn << PAGE_WIDTH;
|
---|
| 218 |
|
---|
[f47fd19] | 219 | if (tag.context == ASID_KERNEL) {
|
---|
| 220 | if (!tag.vpn) {
|
---|
| 221 | /* NULL access in kernel */
|
---|
[fd85ae5] | 222 | do_fast_data_access_mmu_miss_fault(istate, tag, __FUNCTION__);
|
---|
[f47fd19] | 223 | }
|
---|
[fd85ae5] | 224 | do_fast_data_access_mmu_miss_fault(istate, tag, "Unexpected kernel page fault.");
|
---|
[68656282] | 225 | }
|
---|
| 226 |
|
---|
[f47fd19] | 227 | page_table_lock(AS, true);
|
---|
| 228 | t = page_mapping_find(AS, va);
|
---|
| 229 | if (t) {
|
---|
| 230 | /*
|
---|
| 231 | * The mapping was found in the software page hash table.
|
---|
| 232 | * Insert it into DTLB.
|
---|
| 233 | */
|
---|
[a7961271] | 234 | t->a = true;
|
---|
| 235 | dtlb_pte_copy(t, true);
|
---|
[f47fd19] | 236 | page_table_unlock(AS, true);
|
---|
| 237 | } else {
|
---|
| 238 | /*
|
---|
| 239 | * Forward the page fault to the address space page fault handler.
|
---|
| 240 | */
|
---|
| 241 | page_table_unlock(AS, true);
|
---|
| 242 | if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) {
|
---|
[fd85ae5] | 243 | do_fast_data_access_mmu_miss_fault(istate, tag, __FUNCTION__);
|
---|
[f47fd19] | 244 | }
|
---|
| 245 | }
|
---|
[008029d] | 246 | }
|
---|
| 247 |
|
---|
| 248 | /** DTLB protection fault handler. */
|
---|
[f47fd19] | 249 | void fast_data_access_protection(int n, istate_t *istate)
|
---|
[008029d] | 250 | {
|
---|
[e0b241f] | 251 | tlb_tag_access_reg_t tag;
|
---|
| 252 | uintptr_t va;
|
---|
| 253 | pte_t *t;
|
---|
| 254 |
|
---|
| 255 | tag.value = dtlb_tag_access_read();
|
---|
[fd85ae5] | 256 | va = tag.vpn << PAGE_WIDTH;
|
---|
[e0b241f] | 257 |
|
---|
| 258 | page_table_lock(AS, true);
|
---|
| 259 | t = page_mapping_find(AS, va);
|
---|
| 260 | if (t && PTE_WRITABLE(t)) {
|
---|
| 261 | /*
|
---|
| 262 | * The mapping was found in the software page hash table and is writable.
|
---|
| 263 | * Demap the old mapping and insert an updated mapping into DTLB.
|
---|
| 264 | */
|
---|
| 265 | t->a = true;
|
---|
| 266 | t->d = true;
|
---|
| 267 | dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, va);
|
---|
| 268 | dtlb_pte_copy(t, false);
|
---|
| 269 | page_table_unlock(AS, true);
|
---|
| 270 | } else {
|
---|
| 271 | /*
|
---|
| 272 | * Forward the page fault to the address space page fault handler.
|
---|
| 273 | */
|
---|
| 274 | page_table_unlock(AS, true);
|
---|
| 275 | if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) {
|
---|
[fd85ae5] | 276 | do_fast_data_access_protection_fault(istate, tag, __FUNCTION__);
|
---|
[e0b241f] | 277 | }
|
---|
| 278 | }
|
---|
[008029d] | 279 | }
|
---|
| 280 |
|
---|
[0d04024] | 281 | /** Print contents of both TLBs. */
|
---|
| 282 | void tlb_print(void)
|
---|
| 283 | {
|
---|
| 284 | int i;
|
---|
| 285 | tlb_data_t d;
|
---|
| 286 | tlb_tag_read_reg_t t;
|
---|
| 287 |
|
---|
| 288 | printf("I-TLB contents:\n");
|
---|
| 289 | for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
|
---|
| 290 | d.value = itlb_data_access_read(i);
|
---|
[c52ed6b] | 291 | t.value = itlb_tag_read_read(i);
|
---|
[0d04024] | 292 |
|
---|
[fbf7b4c] | 293 | printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, ie=%d, soft2=%#x, diag=%#x, pfn=%#x, soft=%#x, l=%d, cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n",
|
---|
[dbb6886] | 294 | i, t.vpn, t.context, d.v, d.size, d.nfo, d.ie, d.soft2, d.diag, d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
|
---|
[0d04024] | 295 | }
|
---|
| 296 |
|
---|
| 297 | printf("D-TLB contents:\n");
|
---|
| 298 | for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
|
---|
| 299 | d.value = dtlb_data_access_read(i);
|
---|
[c52ed6b] | 300 | t.value = dtlb_tag_read_read(i);
|
---|
[0d04024] | 301 |
|
---|
[fbf7b4c] | 302 | printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, ie=%d, soft2=%#x, diag=%#x, pfn=%#x, soft=%#x, l=%d, cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n",
|
---|
[dbb6886] | 303 | i, t.vpn, t.context, d.v, d.size, d.nfo, d.ie, d.soft2, d.diag, d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
|
---|
[0d04024] | 304 | }
|
---|
| 305 |
|
---|
| 306 | }
|
---|
[dbb6886] | 307 |
|
---|
[a7961271] | 308 | void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, const char *str)
|
---|
| 309 | {
|
---|
[e2bf639] | 310 | fault_if_from_uspace(istate, "%s\n", str);
|
---|
[7bb6b06] | 311 | dump_istate(istate);
|
---|
[a7961271] | 312 | panic("%s\n", str);
|
---|
| 313 | }
|
---|
| 314 |
|
---|
[fd85ae5] | 315 | void do_fast_data_access_mmu_miss_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str)
|
---|
[f47fd19] | 316 | {
|
---|
| 317 | uintptr_t va;
|
---|
| 318 |
|
---|
[fd85ae5] | 319 | va = tag.vpn << PAGE_WIDTH;
|
---|
[f47fd19] | 320 |
|
---|
[e2bf639] | 321 | fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d)\n", str, va, tag.context);
|
---|
[7bb6b06] | 322 | dump_istate(istate);
|
---|
[f47fd19] | 323 | printf("Faulting page: %p, ASID=%d\n", va, tag.context);
|
---|
| 324 | panic("%s\n", str);
|
---|
| 325 | }
|
---|
| 326 |
|
---|
[fd85ae5] | 327 | void do_fast_data_access_protection_fault(istate_t *istate, tlb_tag_access_reg_t tag, const char *str)
|
---|
[e0b241f] | 328 | {
|
---|
| 329 | uintptr_t va;
|
---|
| 330 |
|
---|
[fd85ae5] | 331 | va = tag.vpn << PAGE_WIDTH;
|
---|
[e0b241f] | 332 |
|
---|
[e2bf639] | 333 | fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d)\n", str, va, tag.context);
|
---|
[e0b241f] | 334 | printf("Faulting page: %p, ASID=%d\n", va, tag.context);
|
---|
[7bb6b06] | 335 | dump_istate(istate);
|
---|
[e0b241f] | 336 | panic("%s\n", str);
|
---|
| 337 | }
|
---|
| 338 |
|
---|
[dbb6886] | 339 | /** Invalidate all unlocked ITLB and DTLB entries. */
|
---|
| 340 | void tlb_invalidate_all(void)
|
---|
| 341 | {
|
---|
| 342 | int i;
|
---|
| 343 | tlb_data_t d;
|
---|
| 344 | tlb_tag_read_reg_t t;
|
---|
| 345 |
|
---|
| 346 | for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
|
---|
| 347 | d.value = itlb_data_access_read(i);
|
---|
| 348 | if (!d.l) {
|
---|
| 349 | t.value = itlb_tag_read_read(i);
|
---|
| 350 | d.v = false;
|
---|
| 351 | itlb_tag_access_write(t.value);
|
---|
| 352 | itlb_data_access_write(i, d.value);
|
---|
| 353 | }
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
|
---|
| 357 | d.value = dtlb_data_access_read(i);
|
---|
| 358 | if (!d.l) {
|
---|
| 359 | t.value = dtlb_tag_read_read(i);
|
---|
| 360 | d.v = false;
|
---|
| 361 | dtlb_tag_access_write(t.value);
|
---|
| 362 | dtlb_data_access_write(i, d.value);
|
---|
| 363 | }
|
---|
| 364 | }
|
---|
| 365 |
|
---|
| 366 | }
|
---|
| 367 |
|
---|
| 368 | /** Invalidate all ITLB and DTLB entries that belong to specified ASID (Context).
|
---|
| 369 | *
|
---|
| 370 | * @param asid Address Space ID.
|
---|
| 371 | */
|
---|
| 372 | void tlb_invalidate_asid(asid_t asid)
|
---|
| 373 | {
|
---|
[fd85ae5] | 374 | tlb_context_reg_t pc_save, ctx;
|
---|
[ed166f7] | 375 |
|
---|
[fd85ae5] | 376 | /* switch to nucleus because we are mapped by the primary context */
|
---|
| 377 | nucleus_enter();
|
---|
| 378 |
|
---|
| 379 | ctx.v = pc_save.v = mmu_primary_context_read();
|
---|
[ed166f7] | 380 | ctx.context = asid;
|
---|
[fd85ae5] | 381 | mmu_primary_context_write(ctx.v);
|
---|
| 382 |
|
---|
| 383 | itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0);
|
---|
| 384 | dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0);
|
---|
[ed166f7] | 385 |
|
---|
[fd85ae5] | 386 | mmu_primary_context_write(pc_save.v);
|
---|
[ed166f7] | 387 |
|
---|
[fd85ae5] | 388 | nucleus_leave();
|
---|
[dbb6886] | 389 | }
|
---|
| 390 |
|
---|
[4512d7e] | 391 | /** Invalidate all ITLB and DTLB entries for specified page range in specified address space.
|
---|
[dbb6886] | 392 | *
|
---|
| 393 | * @param asid Address Space ID.
|
---|
[4512d7e] | 394 | * @param page First page which to sweep out from ITLB and DTLB.
|
---|
| 395 | * @param cnt Number of ITLB and DTLB entries to invalidate.
|
---|
[dbb6886] | 396 | */
|
---|
[7f1c620] | 397 | void tlb_invalidate_pages(asid_t asid, uintptr_t page, count_t cnt)
|
---|
[dbb6886] | 398 | {
|
---|
[4512d7e] | 399 | int i;
|
---|
[fd85ae5] | 400 | tlb_context_reg_t pc_save, ctx;
|
---|
[ed166f7] | 401 |
|
---|
[fd85ae5] | 402 | /* switch to nucleus because we are mapped by the primary context */
|
---|
| 403 | nucleus_enter();
|
---|
| 404 |
|
---|
| 405 | ctx.v = pc_save.v = mmu_primary_context_read();
|
---|
[ed166f7] | 406 | ctx.context = asid;
|
---|
[fd85ae5] | 407 | mmu_primary_context_write(ctx.v);
|
---|
[4512d7e] | 408 |
|
---|
| 409 | for (i = 0; i < cnt; i++) {
|
---|
[fd85ae5] | 410 | itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, page + i * PAGE_SIZE);
|
---|
| 411 | dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, page + i * PAGE_SIZE);
|
---|
[4512d7e] | 412 | }
|
---|
[ed166f7] | 413 |
|
---|
[fd85ae5] | 414 | mmu_primary_context_write(pc_save.v);
|
---|
| 415 |
|
---|
| 416 | nucleus_leave();
|
---|
[dbb6886] | 417 | }
|
---|
[b45c443] | 418 |
|
---|
[10b890b] | 419 | /** @}
|
---|
[b45c443] | 420 | */
|
---|