Subversion Repositories HelenOS

Rev

Rev 3343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3343 Rev 3440
Line 329... Line 329...
329
                __func__);
329
                __func__);
330
        }
330
        }
331
    }
331
    }
332
}
332
}
333
 
333
 
-
 
334
/** Print TLB entry (for debugging purposes).
-
 
335
 *
-
 
336
 * The diag field has been left out in order to make this function more generic
-
 
337
 * (there is no diag field in US3 architeture).
-
 
338
 *
-
 
339
 * @param i TLB entry number
-
 
340
 * @param t TLB entry tag
-
 
341
 * @param d TLB entry data
-
 
342
 */
-
 
343
static void print_tlb_entry(int i, tlb_tag_read_reg_t t, tlb_data_t d)
-
 
344
{
-
 
345
    printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
-
 
346
        "ie=%d, soft2=%#x, pfn=%#x, soft=%#x, l=%d, "
-
 
347
        "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn,
-
 
348
        t.context, d.v, d.size, d.nfo, d.ie, d.soft2,
-
 
349
        d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
-
 
350
}
-
 
351
 
-
 
352
#if defined (US)
-
 
353
 
334
/** Print contents of both TLBs. */
354
/** Print contents of both TLBs. */
335
void tlb_print(void)
355
void tlb_print(void)
336
{
356
{
337
    int i;
357
    int i;
338
    tlb_data_t d;
358
    tlb_data_t d;
Line 340... Line 360...
340
   
360
   
341
    printf("I-TLB contents:\n");
361
    printf("I-TLB contents:\n");
342
    for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
362
    for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
343
        d.value = itlb_data_access_read(i);
363
        d.value = itlb_data_access_read(i);
344
        t.value = itlb_tag_read_read(i);
364
        t.value = itlb_tag_read_read(i);
345
 
-
 
346
        printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
-
 
347
            "ie=%d, soft2=%#x, diag=%#x, pfn=%#x, soft=%#x, l=%d, "
-
 
348
            "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn,
-
 
349
            t.context, d.v, d.size, d.nfo, d.ie, d.soft2, d.diag,
365
        print_tlb_entry(i, t, d);
350
            d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
-
 
351
    }
366
    }
352
 
367
 
353
    printf("D-TLB contents:\n");
368
    printf("D-TLB contents:\n");
354
    for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
369
    for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
355
        d.value = dtlb_data_access_read(i);
370
        d.value = dtlb_data_access_read(i);
356
        t.value = dtlb_tag_read_read(i);
371
        t.value = dtlb_tag_read_read(i);
357
       
-
 
358
        printf("%d: vpn=%#llx, context=%d, v=%d, size=%d, nfo=%d, "
-
 
359
            "ie=%d, soft2=%#x, diag=%#x, pfn=%#x, soft=%#x, l=%d, "
-
 
360
            "cp=%d, cv=%d, e=%d, p=%d, w=%d, g=%d\n", i, t.vpn,
-
 
361
            t.context, d.v, d.size, d.nfo, d.ie, d.soft2, d.diag,
372
        print_tlb_entry(i, t, d);
362
            d.pfn, d.soft, d.l, d.cp, d.cv, d.e, d.p, d.w, d.g);
-
 
363
    }
373
    }
-
 
374
}
364
 
375
 
-
 
376
#elif defined (US3)
-
 
377
 
-
 
378
/** Print contents of all TLBs. */
-
 
379
void tlb_print(void)
-
 
380
{
-
 
381
    int i;
-
 
382
    tlb_data_t d;
-
 
383
    tlb_tag_read_reg_t t;
-
 
384
   
-
 
385
    printf("IT16 contents:\n");
-
 
386
    for (i = 0; i < 16; i++) {
-
 
387
        d.value = dtlb_data_access_read(TLB_IT16, i);
-
 
388
        t.value = dtlb_tag_read_read(TLB_IT16, i);
-
 
389
        print_tlb_entry(i, t, d);
-
 
390
    }
-
 
391
   
-
 
392
    printf("IT128 contents:\n");
-
 
393
    for (i = 0; i < 128; i++) {
-
 
394
        d.value = dtlb_data_access_read(TLB_IT128, i);
-
 
395
        t.value = dtlb_tag_read_read(TLB_IT128, i);
-
 
396
        print_tlb_entry(i, t, d);
-
 
397
    }
-
 
398
   
-
 
399
    printf("DT16 contents:\n");
-
 
400
    for (i = 0; i < 16; i++) {
-
 
401
        d.value = dtlb_data_access_read(TLB_DT16, i);
-
 
402
        t.value = dtlb_tag_read_read(TLB_DT16, i);
-
 
403
        print_tlb_entry(i, t, d);
-
 
404
    }
-
 
405
   
-
 
406
    printf("DT512_1 contents:\n");
-
 
407
    for (i = 0; i < 512; i++) {
-
 
408
        d.value = dtlb_data_access_read(TLB_DT512_1, i);
-
 
409
        t.value = dtlb_tag_read_read(TLB_DT512_1, i);
-
 
410
        print_tlb_entry(i, t, d);
-
 
411
    }
-
 
412
   
-
 
413
    printf("DT512_2 contents:\n");
-
 
414
    for (i = 0; i < 512; i++) {
-
 
415
        d.value = dtlb_data_access_read(TLB_DT512_2, i);
-
 
416
        t.value = dtlb_tag_read_read(TLB_DT512_2, i);
-
 
417
        print_tlb_entry(i, t, d);
-
 
418
    }
365
}
419
}
366
 
420
 
-
 
421
#endif
-
 
422
 
367
void do_fast_instruction_access_mmu_miss_fault(istate_t *istate,
423
void do_fast_instruction_access_mmu_miss_fault(istate_t *istate,
368
    const char *str)
424
    const char *str)
369
{
425
{
370
    fault_if_from_uspace(istate, "%s\n", str);
426
    fault_if_from_uspace(istate, "%s\n", str);
371
    dump_istate(istate);
427
    dump_istate(istate);
Line 417... Line 473...
417
    printf("DTLB SFAR: address=%p\n", sfar);
473
    printf("DTLB SFAR: address=%p\n", sfar);
418
   
474
   
419
    dtlb_sfsr_write(0);
475
    dtlb_sfsr_write(0);
420
}
476
}
421
 
477
 
-
 
478
#if defined (US3)
422
/** Invalidate all unlocked ITLB and DTLB entries. */
479
/** Invalidates given TLB entry if and only if it is non-locked or global.
-
 
480
 *
-
 
481
 * @param tlb
-
 
482
 *  TLB number (one of TLB_DT16, TLB_DT512_1, TLB_DT512_2,
-
 
483
 *  TLB_IT16, TLB_IT128)
-
 
484
 * @param entry entry index within the given TLB
-
 
485
 */
423
void tlb_invalidate_all(void)
486
static void tlb_invalidate_entry(int tlb, index_t entry)
424
{
487
{
425
    int i;
-
 
426
    tlb_data_t d;
488
    tlb_data_t d;
427
    tlb_tag_read_reg_t t;
489
    tlb_tag_read_reg_t t;
-
 
490
   
-
 
491
    if (tlb == TLB_DT16 || tlb == TLB_DT512_1 || tlb == TLB_DT512_2) {
-
 
492
        d.value = dtlb_data_access_read(tlb, entry);
-
 
493
        if (!d.l || d.g) {
-
 
494
            t.value = dtlb_tag_read_read(tlb, entry);
-
 
495
            d.v = false;
-
 
496
            dtlb_tag_access_write(t.value);
-
 
497
            dtlb_data_access_write(tlb, entry, d.value);
-
 
498
        }
-
 
499
    } else if (tlb == TLB_IT16 || tlb == TLB_IT128) {
-
 
500
        d.value = itlb_data_access_read(tlb, entry);
-
 
501
        if (!d.l || d.g) {
-
 
502
            t.value = itlb_tag_read_read(tlb, entry);
-
 
503
            d.v = false;
-
 
504
            itlb_tag_access_write(t.value);
-
 
505
            itlb_data_access_write(tlb, entry, d.value);
-
 
506
        }
-
 
507
    }
-
 
508
}
-
 
509
#endif
428
 
510
 
-
 
511
/** Invalidate all unlocked ITLB and DTLB entries. */
-
 
512
void tlb_invalidate_all(void)
-
 
513
{
-
 
514
    int i;
-
 
515
   
429
    /*
516
    /*
430
     * Walk all ITLB and DTLB entries and remove all unlocked mappings.
517
     * Walk all ITLB and DTLB entries and remove all unlocked mappings.
431
     *
518
     *
432
     * The kernel doesn't use global mappings so any locked global mappings
519
     * The kernel doesn't use global mappings so any locked global mappings
433
     * found  must have been created by someone else. Their only purpose now
520
     * found must have been created by someone else. Their only purpose now
434
     * is to collide with proper mappings. Invalidate immediately. It should
521
     * is to collide with proper mappings. Invalidate immediately. It should
435
     * be safe to invalidate them as late as now.
522
     * be safe to invalidate them as late as now.
436
     */
523
     */
437
 
524
 
-
 
525
#if defined (US)
-
 
526
    tlb_data_t d;
-
 
527
    tlb_tag_read_reg_t t;
-
 
528
 
438
    for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
529
    for (i = 0; i < ITLB_ENTRY_COUNT; i++) {
439
        d.value = itlb_data_access_read(i);
530
        d.value = itlb_data_access_read(i);
440
        if (!d.l || d.g) {
531
        if (!d.l || d.g) {
441
            t.value = itlb_tag_read_read(i);
532
            t.value = itlb_tag_read_read(i);
442
            d.v = false;
533
            d.v = false;
443
            itlb_tag_access_write(t.value);
534
            itlb_tag_access_write(t.value);
444
            itlb_data_access_write(i, d.value);
535
            itlb_data_access_write(i, d.value);
445
        }
536
        }
446
    }
537
    }
447
   
538
 
448
    for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
539
    for (i = 0; i < DTLB_ENTRY_COUNT; i++) {
449
        d.value = dtlb_data_access_read(i);
540
        d.value = dtlb_data_access_read(i);
450
        if (!d.l || d.g) {
541
        if (!d.l || d.g) {
451
            t.value = dtlb_tag_read_read(i);
542
            t.value = dtlb_tag_read_read(i);
452
            d.v = false;
543
            d.v = false;
453
            dtlb_tag_access_write(t.value);
544
            dtlb_tag_access_write(t.value);
454
            dtlb_data_access_write(i, d.value);
545
            dtlb_data_access_write(i, d.value);
455
        }
546
        }
456
    }
547
    }
-
 
548
 
-
 
549
#elif defined (US3)
457
   
550
 
-
 
551
    for (i = 0; i < 16; i++)
-
 
552
        tlb_invalidate_entry(TLB_IT16, i);
-
 
553
    for (i = 0; i < 128; i++)
-
 
554
        tlb_invalidate_entry(TLB_IT128, i);
-
 
555
    for (i = 0; i < 16; i++)
-
 
556
        tlb_invalidate_entry(TLB_DT16, i);
-
 
557
    for (i = 0; i < 512; i++)
-
 
558
        tlb_invalidate_entry(TLB_DT512_1, i);
-
 
559
    for (i = 0; i < 512; i++)
-
 
560
        tlb_invalidate_entry(TLB_DT512_2, i);
-
 
561
#endif
-
 
562
 
458
}
563
}
459
 
564
 
460
/** Invalidate all ITLB and DTLB entries that belong to specified ASID
565
/** Invalidate all ITLB and DTLB entries that belong to specified ASID
461
 * (Context).
566
 * (Context).
462
 *
567
 *
Line 511... Line 616...
511
   
616
   
512
    nucleus_leave();
617
    nucleus_leave();
513
}
618
}
514
 
619
 
515
/** @}
620
/** @}
516
 */
621
 */
517
 
622