Changeset a35b458 in mainline for kernel/arch/sparc64/src/mm
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/arch/sparc64/src/mm
- Files:
-
- 8 edited
-
sun4u/as.c (modified) (9 diffs)
-
sun4u/frame.c (modified) (4 diffs)
-
sun4u/tlb.c (modified) (16 diffs)
-
sun4u/tsb.c (modified) (6 diffs)
-
sun4v/as.c (modified) (6 diffs)
-
sun4v/frame.c (modified) (3 diffs)
-
sun4v/tlb.c (modified) (7 diffs)
-
sun4v/tsb.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/mm/sun4u/as.c
r3061bc1 ra35b458 69 69 tsb_entry_t *tsb = (tsb_entry_t *) PA2KA(tsb_base); 70 70 memsetb(tsb, TSB_SIZE, 0); 71 71 72 72 as->arch.itsb = tsb; 73 73 as->arch.dtsb = tsb + ITSB_ENTRY_COUNT; 74 74 #endif 75 75 76 76 return EOK; 77 77 } … … 81 81 #ifdef CONFIG_TSB 82 82 frame_free(KA2PA((uintptr_t) as->arch.itsb), TSB_FRAMES); 83 83 84 84 return TSB_FRAMES; 85 85 #else … … 93 93 tsb_invalidate(as, 0, (size_t) -1); 94 94 #endif 95 95 96 96 return 0; 97 97 } … … 107 107 { 108 108 tlb_context_reg_t ctx; 109 109 110 110 /* 111 111 * Note that we don't and may not lock the address space. That's ok … … 115 115 * 116 116 */ 117 117 118 118 /* 119 119 * Write ASID to secondary context register. The primary context … … 126 126 ctx.context = as->asid; 127 127 mmu_secondary_context_write(ctx.v); 128 128 129 129 #ifdef CONFIG_TSB 130 130 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 131 131 132 132 assert(as->arch.itsb); 133 133 assert(as->arch.dtsb); 134 134 135 135 uintptr_t tsb = (uintptr_t) as->arch.itsb; 136 136 137 137 if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 138 138 /* … … 145 145 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 146 146 } 147 147 148 148 /* 149 149 * Setup TSB Base registers. … … 151 151 */ 152 152 tsb_base_reg_t tsb_base_reg; 153 153 154 154 tsb_base_reg.value = 0; 155 155 tsb_base_reg.size = TSB_BASE_REG_SIZE; 156 156 tsb_base_reg.split = 0; 157 157 158 158 tsb_base_reg.base = ((uintptr_t) as->arch.itsb) >> MMU_PAGE_WIDTH; 159 159 itsb_base_write(tsb_base_reg.value); 160 160 tsb_base_reg.base = ((uintptr_t) as->arch.dtsb) >> MMU_PAGE_WIDTH; 161 161 dtsb_base_write(tsb_base_reg.value); 162 162 163 163 #if defined (US3) 164 164 /* … … 198 198 * 199 199 */ 200 200 201 201 #ifdef CONFIG_TSB 202 202 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 203 203 204 204 assert(as->arch.itsb); 205 205 assert(as->arch.dtsb); 206 206 207 207 uintptr_t tsb = (uintptr_t) as->arch.itsb; 208 208 209 209 if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 210 210 /* -
kernel/arch/sparc64/src/mm/sun4u/frame.c
r3061bc1 ra35b458 48 48 { 49 49 unsigned int i; 50 50 51 51 for (i = 0; i < memmap.cnt; i++) { 52 52 uintptr_t base; … … 62 62 size = ALIGN_DOWN(memmap.zones[i].size - 63 63 (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 64 64 65 65 if (!frame_adjust_zone_bounds(low, &base, &size)) 66 66 continue; 67 67 68 68 pfn_t confdata; 69 69 pfn_t pfn = ADDR2PFN(base); … … 74 74 if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0)))) 75 75 confdata = ADDR2PFN(KA2PA(PFN2ADDR(2))); 76 76 77 77 zone_create(pfn, count, confdata, 78 78 ZONE_AVAILABLE | ZONE_LOWMEM); … … 90 90 if (config.cpu_active > 1) 91 91 return; 92 92 93 93 frame_common_arch_init(true); 94 94 95 95 /* 96 96 * On sparc64, physical memory can start on a non-zero address. -
kernel/arch/sparc64/src/mm/sun4u/tlb.c
r3061bc1 ra35b458 178 178 tag.context = t->as->asid; 179 179 tag.vpn = pg.vpn; 180 180 181 181 itlb_tag_access_write(tag.value); 182 182 183 183 data.value = 0; 184 184 data.v = true; … … 190 190 data.w = false; 191 191 data.g = t->g; 192 192 193 193 itlb_data_in_write(data.value); 194 194 } … … 353 353 tlb_data_t d; 354 354 tlb_tag_read_reg_t t; 355 355 356 356 printf("I-TLB contents:\n"); 357 357 for (i = 0; i < ITLB_ENTRY_COUNT; i++) { … … 377 377 tlb_data_t d; 378 378 tlb_tag_read_reg_t t; 379 379 380 380 printf("TLB_ISMALL contents:\n"); 381 381 for (i = 0; i < tlb_ismall_size(); i++) { … … 384 384 print_tlb_entry(i, t, d); 385 385 } 386 386 387 387 printf("TLB_IBIG contents:\n"); 388 388 for (i = 0; i < tlb_ibig_size(); i++) { … … 391 391 print_tlb_entry(i, t, d); 392 392 } 393 393 394 394 printf("TLB_DSMALL contents:\n"); 395 395 for (i = 0; i < tlb_dsmall_size(); i++) { … … 398 398 print_tlb_entry(i, t, d); 399 399 } 400 400 401 401 printf("TLB_DBIG_1 contents:\n"); 402 402 for (i = 0; i < tlb_dbig_size(); i++) { … … 405 405 print_tlb_entry(i, t, d); 406 406 } 407 407 408 408 printf("TLB_DBIG_2 contents:\n"); 409 409 for (i = 0; i < tlb_dbig_size(); i++) { … … 423 423 sfsr.value = dtlb_sfsr_read(); 424 424 sfar = dtlb_sfar_read(); 425 425 426 426 #if defined (US) 427 427 printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, " … … 433 433 sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv); 434 434 #endif 435 435 436 436 printf("DTLB SFAR: address=%p\n", (void *) sfar); 437 437 438 438 dtlb_sfsr_write(0); 439 439 } … … 446 446 sfsr.value = dtlb_sfsr_read(); 447 447 sfar = dtlb_sfar_read(); 448 448 449 449 #if defined (US) 450 450 printf("DTLB SFSR: asi=%#x, ft=%#x, e=%d, ct=%d, pr=%d, w=%d, ow=%d, " … … 456 456 sfsr.e, sfsr.ct, sfsr.pr, sfsr.w, sfsr.ow, sfsr.fv); 457 457 #endif 458 458 459 459 printf("DTLB SFAR: address=%p\n", (void *) sfar); 460 460 461 461 dtlb_sfsr_write(0); 462 462 } … … 467 467 { 468 468 int i; 469 469 470 470 /* 471 471 * Walk all ITLB and DTLB entries and remove all unlocked mappings. … … 521 521 { 522 522 tlb_context_reg_t pc_save, ctx; 523 523 524 524 /* switch to nucleus because we are mapped by the primary context */ 525 525 nucleus_enter(); 526 526 527 527 ctx.v = pc_save.v = mmu_primary_context_read(); 528 528 ctx.context = asid; 529 529 mmu_primary_context_write(ctx.v); 530 530 531 531 itlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0); 532 532 dtlb_demap(TLB_DEMAP_CONTEXT, TLB_DEMAP_PRIMARY, 0); 533 533 534 534 mmu_primary_context_write(pc_save.v); 535 535 536 536 nucleus_leave(); 537 537 } … … 548 548 unsigned int i; 549 549 tlb_context_reg_t pc_save, ctx; 550 550 551 551 /* switch to nucleus because we are mapped by the primary context */ 552 552 nucleus_enter(); 553 553 554 554 ctx.v = pc_save.v = mmu_primary_context_read(); 555 555 ctx.context = asid; 556 556 mmu_primary_context_write(ctx.v); 557 557 558 558 for (i = 0; i < cnt * MMU_PAGES_PER_PAGE; i++) { 559 559 itlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_PRIMARY, … … 562 562 page + i * MMU_PAGE_SIZE); 563 563 } 564 564 565 565 mmu_primary_context_write(pc_save.v); 566 566 567 567 nucleus_leave(); 568 568 } -
kernel/arch/sparc64/src/mm/sun4u/tsb.c
r3061bc1 ra35b458 57 57 size_t i; 58 58 size_t cnt; 59 59 60 60 assert(as->arch.itsb); 61 61 assert(as->arch.dtsb); 62 62 63 63 i0 = (page >> MMU_PAGE_WIDTH) & ITSB_ENTRY_MASK; 64 64 … … 67 67 else 68 68 cnt = pages * 2; 69 69 70 70 for (i = 0; i < cnt; i++) { 71 71 as->arch.itsb[(i0 + i) & ITSB_ENTRY_MASK].tag.invalid = true; … … 86 86 87 87 assert(index <= 1); 88 88 89 89 as = t->as; 90 90 entry = ((t->page >> MMU_PAGE_WIDTH) + index) & ITSB_ENTRY_MASK; … … 112 112 tte->data.p = t->k; /* p as privileged, k as kernel */ 113 113 tte->data.v = t->p; /* v as valid, p as present */ 114 114 115 115 write_barrier(); 116 116 117 117 tte->tag.invalid = false; /* mark the entry as valid */ 118 118 } … … 129 129 tsb_entry_t *tte; 130 130 size_t entry; 131 131 132 132 assert(index <= 1); 133 133 … … 161 161 tte->data.w = ro ? false : t->w; 162 162 tte->data.v = t->p; 163 163 164 164 write_barrier(); 165 165 166 166 tte->tag.invalid = false; /* mark the entry as valid */ 167 167 } -
kernel/arch/sparc64/src/mm/sun4v/as.c
r3061bc1 ra35b458 79 79 as->arch.tsb_description.reserved = 0; 80 80 as->arch.tsb_description.context = 0; 81 81 82 82 memsetb(tsb, TSB_SIZE, 0); 83 83 #endif 84 84 85 85 return EOK; 86 86 } … … 90 90 #ifdef CONFIG_TSB 91 91 frame_free(as->arch.tsb_description.tsb_base, TSB_FRAMES); 92 92 93 93 return TSB_FRAMES; 94 94 #else … … 102 102 tsb_invalidate(as, 0, (size_t) -1); 103 103 #endif 104 104 105 105 return EOK; 106 106 } … … 117 117 { 118 118 mmu_secondary_context_write(as->asid); 119 119 120 120 #ifdef CONFIG_TSB 121 121 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 122 122 123 123 assert(as->arch.tsb_description.tsb_base); 124 124 uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base); 125 125 126 126 if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 127 127 /* … … 134 134 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 135 135 } 136 136 137 137 __hypercall_fast2(MMU_TSB_CTXNON0, 1, KA2PA(&as->arch.tsb_description)); 138 138 #endif … … 156 156 * 157 157 */ 158 158 159 159 #ifdef CONFIG_TSB 160 160 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 161 161 162 162 assert(as->arch.tsb_description.tsb_base); 163 163 164 164 uintptr_t tsb = PA2KA(as->arch.tsb_description.tsb_base); 165 165 166 166 if (!overlaps(tsb, TSB_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 167 167 /* -
kernel/arch/sparc64/src/mm/sun4v/frame.c
r3061bc1 ra35b458 48 48 { 49 49 unsigned int i; 50 50 51 51 for (i = 0; i < memmap.cnt; i++) { 52 52 uintptr_t base; … … 62 62 size = ALIGN_DOWN(memmap.zones[i].size - 63 63 (base - ((uintptr_t) memmap.zones[i].start)), FRAME_SIZE); 64 64 65 65 if (!frame_adjust_zone_bounds(low, &base, &size)) 66 66 continue; … … 74 74 if (confdata == ADDR2PFN(KA2PA(PFN2ADDR(0)))) 75 75 confdata = ADDR2PFN(KA2PA(PFN2ADDR(2))); 76 76 77 77 zone_create(pfn, count, confdata, 78 78 ZONE_AVAILABLE | ZONE_LOWMEM); -
kernel/arch/sparc64/src/mm/sun4v/tlb.c
r3061bc1 ra35b458 128 128 { 129 129 tte_data_t data; 130 130 131 131 data.value = 0; 132 132 data.v = true; … … 143 143 data.w = true; 144 144 data.size = pagesize; 145 145 146 146 if (locked) { 147 147 __hypercall_fast4( … … 163 163 { 164 164 tte_data_t data; 165 165 166 166 data.value = 0; 167 167 data.v = true; … … 178 178 data.w = ro ? false : t->w; 179 179 data.size = PAGESIZE_8K; 180 180 181 181 __hypercall_hyperfast( 182 182 t->page, t->as->asid, data.value, MMU_FLAG_DTLB, 0, MMU_MAP_ADDR); … … 190 190 { 191 191 tte_data_t data; 192 192 193 193 data.value = 0; 194 194 data.v = true; … … 203 203 data.w = false; 204 204 data.size = PAGESIZE_8K; 205 205 206 206 __hypercall_hyperfast( 207 207 t->page, t->as->asid, data.value, MMU_FLAG_ITLB, 0, MMU_MAP_ADDR); … … 387 387 { 388 388 unsigned int i; 389 389 390 390 /* switch to nucleus because we are mapped by the primary context */ 391 391 nucleus_enter(); -
kernel/arch/sparc64/src/mm/sun4v/tsb.c
r3061bc1 ra35b458 59 59 size_t i0, i; 60 60 size_t cnt; 61 61 62 62 assert(as->arch.tsb_description.tsb_base); 63 63 64 64 i0 = (page >> MMU_PAGE_WIDTH) & TSB_ENTRY_MASK; 65 65 … … 68 68 else 69 69 cnt = pages; 70 70 71 71 tsb = (tsb_entry_t *) PA2KA(as->arch.tsb_description.tsb_base); 72 72 for (i = 0; i < cnt; i++) … … 87 87 as = t->as; 88 88 index = (t->page >> MMU_PAGE_WIDTH) & TSB_ENTRY_MASK; 89 89 90 90 tsb = (tsb_entry_t *) PA2KA(as->arch.tsb_description.tsb_base); 91 91 tte = &tsb[index]; … … 114 114 tte->data.w = false; 115 115 tte->data.size = PAGESIZE_8K; 116 116 117 117 write_barrier(); 118 118 119 119 tte->data.v = t->p; /* v as valid, p as present */ 120 120 } … … 162 162 tte->data.w = ro ? false : t->w; 163 163 tte->data.size = PAGESIZE_8K; 164 164 165 165 write_barrier(); 166 166 167 167 tte->data.v = t->p; /* v as valid, p as present */ 168 168 }
Note:
See TracChangeset
for help on using the changeset viewer.
